using Shared; using HDL_ON.Stan; using HDL_ON.UI.CSS; using HDL_ON.Entity; using System; namespace HDL_ON.UI { public class SenesorMegahealthPage : DeviceFunctionCardCommonForm { #region ■ 变量声明___________________________ /// /// 图标 /// private IconViewControl btnIcon = null; /// /// 文本控件 /// private NormalViewControl btnSuctionView = null; #endregion #region ■ 初始化_____________________________ /// /// 初始化白色区域的内容 /// public override void InitFrameWhiteContent() { base.SetTitleText(Language.StringByID(StringId.SenesorMillimeterWave)); //添加第二索引页 this.AddSecondPage(); //初始化第一个索引页的内容 this.InitFrameWhiteContent1(); //初始化第二个索引页的内容 this.InitFrameWhiteContent2(); //刷新当前设备的状态缓存 this.RefreshNowDeviceStatuMemory(this.device); //刷新界面状态 this.RefreshFormStatu(); //读取状态 new System.Threading.Thread(() => { if (device.spk == SPK.SenesorMegahealth|| device.spk == SPK.SenesorMegahealth2) { DriverLayer.Control.Ins.SendReadCommand(device, true); } }) { IsBackground = true }.Start(); } /// /// 初始化第一个索引页的内容 /// private void InitFrameWhiteContent1() { btnIcon = new IconViewControl(198) { Gravity = Gravity.CenterHorizontal, Y = Application.GetRealWidth(146), UnSelectedImagePath = "FunctionIcon/ArmSensor/UnderProtectionBgIcon.png", }; FrameWhiteCentet1.AddChidren(btnIcon); btnSuctionView = new NormalViewControl(300, 84, true) { Gravity = Gravity.CenterHorizontal, Y = btnIcon.Bottom, TextAlignment = TextAlignment.Center, TextSize = CSS_FontSize.TextFontSize, TextColor = CSS_Color.TextualColor, SelectedTextColor = CSS_Color.MainColor, }; FrameWhiteCentet1.AddChidren(btnSuctionView); //加载瞬时值 var btnInstantaneousValue = new Button() { Gravity = Gravity.CenterHorizontal, Y = Application.GetRealHeight(391), Width = Application.GetMinRealAverage(32), Height = Application.GetMinRealAverage(32), UnSelectedImagePath = "FunctionIcon/EnvironmentalScience/DiagramIconOn.png", }; FrameWhiteCentet1.AddChidren(btnInstantaneousValue); var btnInstantaneousValueText = new Button() { Gravity = Gravity.CenterHorizontal, Y = btnInstantaneousValue.Bottom, Width = Application.GetRealWidth(96), Height = Application.GetRealHeight(29), TextAlignment = TextAlignment.Center, TextSize = CSS_FontSize.PromptFontSize_FirstLevel, TextColor = CSS_Color.TextualColor, TextID = StringId.AlarmDataStatistics, IsMoreLines = true }; FrameWhiteCentet1.AddChidren(btnInstantaneousValueText); EventHandler eventHandler = (sender, e) => { //var page = new SocketPage_InstantaneousValue(function); //MainPage.BasePageView.AddChidren(page); //page.LoadPage(); //MainPage.BasePageView.PageIndex = MainPage.BasePageView.ChildrenCount - 1; }; btnInstantaneousValue.MouseUpEventHandler = eventHandler; btnInstantaneousValueText.MouseUpEventHandler = eventHandler; } /// /// 初始化第二个索引页的内容 /// private void InitFrameWhiteContent2() { var paging = new ArmSensorHistroyPaging(device); paging.InitFrame(FrameWhiteCentet2); } #endregion #region ■ 设备状态反馈_______________________ /// /// 设备状态反馈 /// /// public override void DeviceStatuPush(Function i_LocalDevice) { //不是同一个东西 if (this.device.sid != i_LocalDevice.sid) { return; } //刷新当前设备的状态缓存 this.RefreshNowDeviceStatuMemory(i_LocalDevice); //刷新界面状态 this.RefreshFormStatu(); } #endregion #region ■ 发送各种命令_______________________ #endregion #region ■ 刷新界面状态_______________________ /// /// 刷新界面状态 /// private void RefreshFormStatu() { Application.RunOnMainThread(() => { var temp = device.attributes.Find((sta) => sta.key == FunctionAttributeKey.ActionStatus); if (temp != null) { if (temp.state == "fall") //跌倒 { btnIcon.UnSelectedImagePath = "FunctionIcon/ArmSensor/SomeoneFellBgIcon.png"; btnSuctionView.TextID = StringId.SomeoneFell; btnSuctionView.IsSelected = true; } else if (temp.state == "uninhabited")//无人 { btnIcon.UnSelectedImagePath = "FunctionIcon/ArmSensor/UnderProtectionBgIcon.png"; btnSuctionView.TextID = StringId.UnderProtection; btnSuctionView.IsSelected = false; } else//有人 { btnIcon.UnSelectedImagePath = "FunctionIcon/ArmSensor/SomeoneInBgIcon.png"; btnSuctionView.TextID = StringId.SomeoneIn; btnSuctionView.IsSelected = true; } } else { temp = device.attributes.Find((sta) => sta.key == FunctionAttributeKey.PeopleStatus); if (temp != null) { if (temp.state == "true") { btnIcon.IsSelected = true; btnSuctionView.TextID = StringId.Someone; btnSuctionView.IsSelected = true; } else { btnIcon.IsSelected = false; btnSuctionView.TextID = StringId.SensorNormalState; btnSuctionView.IsSelected = false; } //增加实验室模式反馈 var tempStatus = device.attributes.Find((sta) => sta.key == FunctionAttributeKey.TargetStatus); if(tempStatus != null) { if(tempStatus.state == "4") { btnIcon.UnSelectedImagePath = "FunctionIcon/ArmSensor/SomeoneFellBgIcon.png"; btnSuctionView.TextID = StringId.SomeoneFell; btnSuctionView.IsSelected = true; } } } } }); } #endregion #region ■ 一般方法___________________________ /// /// 刷新当前设备的状态缓存 /// private void RefreshNowDeviceStatuMemory(Function i_LocalDevice) { //foreach (var data in i_LocalDevice.status) //{ // if (data.key == FunctionAttributeKey.Status) // { // Application.RunOnMainThread(() => // { // if (data.value.ToLower() == "open") // { // this.btnIcon.IsSelected = true; // this.btnSuctionView.IsSelected = true; // this.btnSuctionView.TextID = StringId.Open; // } // else // { // this.btnIcon.IsSelected = false; // this.btnSuctionView.IsSelected = false; // this.btnSuctionView.TextID = StringId.Close; // } // }); // } //} } #endregion } }