From 2d5639dfb8014e78e6f1e68240fa751c19bb3a28 Mon Sep 17 00:00:00 2001 From: gxc <guoxuecheng@guoxuechengdeMacBook-Pro.local> Date: 星期四, 02 一月 2020 18:35:40 +0800 Subject: [PATCH] 2019.1.2 --- ZigbeeApp/Shared/Phone/Device/Category/Category.cs | 179 +++++++++++++++++++++++++++++++++++++++++++++++++++-------- 1 files changed, 153 insertions(+), 26 deletions(-) diff --git a/ZigbeeApp/Shared/Phone/Device/Category/Category.cs b/ZigbeeApp/Shared/Phone/Device/Category/Category.cs index a061d26..6660e7d 100644 --- a/ZigbeeApp/Shared/Phone/Device/Category/Category.cs +++ b/ZigbeeApp/Shared/Phone/Device/Category/Category.cs @@ -119,10 +119,6 @@ /// sceneList /// </summary> private List<SceneUI> sceneList; - /// <summary> - /// 褰撳墠閫変腑鎴块棿 - /// </summary> - private Common.Room curRoom; #endregion #region 鈼� 鎺ュ彛____________________________ @@ -363,6 +359,66 @@ { deviceUI.CommonDevice.IsOnline = 1; deviceUI.CommonDevice.LastDateTime = DateTime.Now; + } + break; + + case DeviceType.TemperatureSensor: + //娓╁害 + if (common.DeviceStatusReport.CluterID == 1026) + { + var tempera = deviceUI.CommonDevice as TemperatureSensor; + foreach (var data in common.DeviceStatusReport.AttriBute) + { + if (data.AttributeId == (int)ZigBee.Device.AttriButeId.MeasuredValue) + { + if (data.AttriButeData == 0) + { + tempera.Temperatrue = 0; + } + else if (data.AttriButeData > 32767) + { + //璐熸暟(鐗规畩澶勭悊) + string strValue = (data.AttriButeData - 65536).ToString(); + //灏忔暟鐐归渶瑕佷竴浣� + strValue = strValue.Substring(0, strValue.Length - 1); + tempera.Temperatrue = Convert.ToDecimal(strValue.Insert(strValue.Length - 1, ".")); + } + else + { + //灏忔暟鐐归渶瑕佷竴浣� + string strValue = data.AttriButeData.ToString(); + strValue = strValue.Substring(0, strValue.Length - 1); + tempera.Temperatrue = Convert.ToDecimal(strValue.Insert(strValue.Length - 1, ".")); + } + var row = rowLayout.GetChildren(0) as CategoryFunctionRow; + row.SetStatuText(deviceUI.GetDeviceStatu()); + } + } + } + //婀垮害 + if (common.DeviceStatusReport.CluterID == 1029) + { + var tempera = deviceUI.CommonDevice as TemperatureSensor; + foreach (var data in common.DeviceStatusReport.AttriBute) + { + if (data.AttributeId == (int)ZigBee.Device.AttriButeId.MeasuredValue) + { + if (data.AttriButeData == 0) + { + tempera.Humidity = 0; + } + else + { + //灏忔暟鐐归渶瑕佷竴浣�(婀垮害娌℃湁璐熸暟) + string strValue = data.AttriButeData.ToString(); + strValue = strValue.Substring(0, strValue.Length - 1); + tempera.Humidity = Convert.ToDecimal(strValue.Insert(strValue.Length - 1, ".")); + tempera.LastDateTime = DateTime.Now; + } + var row = rowLayout.GetChildren(0) as CategoryFunctionRow; + row.SetStatuText(deviceUI.GetDeviceStatu()); + } + } } break; } @@ -668,6 +724,7 @@ floors.FloorAction += (floorId) => { floorBtn.Text = Config.Instance.Home.GetFloorNameById(floorId); + Common.Room.CurrentRoom = Common.Room.CurrentRoom.GetLoveRoom(); RefreshBodyView(); }; } @@ -1006,7 +1063,7 @@ { if (e2) { - if(curRoom.IsLove) + if(Common.Room.CurrentRoom.IsLove) { Shared.Common.Room.CurrentRoom.DeleteDevice(deviceUI.FileName); deviceListScrolView.RemoveViewByTag((delSender as Button).Tag); @@ -1117,7 +1174,7 @@ UserView.HomePage.Instance.AddChidren(lightControl); UserView.HomePage.Instance.PageIndex += 1; //lightControl.action = RefreshBodyView; - lightControl.Show(deviceUI, curRoom); + lightControl.Show(deviceUI, Common.Room.CurrentRoom); } else if (deviceUI.CommonDevice.DfunctionType == DeviceFunctionType.A鎻掑骇) { @@ -1125,7 +1182,7 @@ UserView.HomePage.Instance.AddChidren(lightControl); UserView.HomePage.Instance.PageIndex += 1; //lightControl.action = RefreshBodyView; - lightControl.Show(deviceUI, curRoom); + lightControl.Show(deviceUI, Common.Room.CurrentRoom); } else { @@ -1133,7 +1190,7 @@ UserView.HomePage.Instance.AddChidren(lightControl); UserView.HomePage.Instance.PageIndex += 1; //lightControl.action = RefreshBodyView; - lightControl.Show(deviceUI, curRoom); + lightControl.Show(deviceUI, Common.Room.CurrentRoom); } }; @@ -1147,7 +1204,7 @@ Tag = deviceUI, Radius = 0 }; - if (curRoom.IsSharedRoom == false) + if (Common.Room.CurrentRoom.IsSharedRoom == false) { deviceTypeRowLayout.AddRightView(editBtn); editBtn.MouseUpEventHandler += deviceDetailHandler; @@ -1237,7 +1294,7 @@ UserView.HomePage.Instance.AddChidren(lightControl); UserView.HomePage.Instance.PageIndex += 1; //lightControl.action = RefreshBodyView; - lightControl.Show(deviceUI, curRoom); + lightControl.Show(deviceUI, Common.Room.CurrentRoom); }; var editBtn = new CommonForm.RowLayoutEditButton() @@ -1250,7 +1307,7 @@ Tag = deviceUI, Radius = 0 }; - if (curRoom.IsSharedRoom == false) + if (Common.Room.CurrentRoom.IsSharedRoom == false) { deviceTypeRowLayout.AddRightView(editBtn); editBtn.MouseUpEventHandler += deviceDetailHandler; @@ -1340,7 +1397,7 @@ UserView.HomePage.Instance.PageIndex += 1; UserView.HomePage.Instance.ScrollEnabled = false; //dimmableLightControl.action = RefreshBodyView; - dimmableLightControl.Show(deviceUI, curRoom); + dimmableLightControl.Show(deviceUI, Common.Room.CurrentRoom); }; var editBtn = new CommonForm.RowLayoutEditButton() @@ -1353,7 +1410,7 @@ Tag = deviceUI, Radius = 0 }; - if (curRoom.IsSharedRoom == false) + if (Common.Room.CurrentRoom.IsSharedRoom == false) { deviceTypeRowLayout.AddRightView(editBtn); editBtn.MouseUpEventHandler += deviceDetailHandler; @@ -1449,7 +1506,7 @@ Tag = deviceUI, Radius = 0 }; - if (curRoom.IsSharedRoom == false) + if (Common.Room.CurrentRoom.IsSharedRoom == false) { deviceTypeRowLayout.AddRightView(editBtn); editBtn.MouseUpEventHandler += deviceDetailHandler; @@ -1464,7 +1521,7 @@ UserView.HomePage.Instance.PageIndex += 1; UserView.HomePage.Instance.ScrollEnabled = false; //rollerShadeControl.action = RefreshBodyView; - acControl.Show(deviceUI, curRoom); + acControl.Show(deviceUI, Common.Room.CurrentRoom); }; } } @@ -1532,14 +1589,12 @@ var editBtn = new CommonForm.RowLayoutEditButton() { Tag = deviceUI, - Radius = 0 }; var delBtn = new Device.CommonForm.RowLayoutDeleteButton() { Tag = deviceUI, - Radius = 0 }; - if (curRoom.IsSharedRoom == false) + if (Common.Room.CurrentRoom.IsSharedRoom == false) { deviceTypeRowLayout.AddRightView(editBtn); editBtn.MouseUpEventHandler += deviceDetailHandler; @@ -1554,7 +1609,7 @@ UserView.HomePage.Instance.PageIndex += 1; UserView.HomePage.Instance.ScrollEnabled = false; //rollerShadeControl.action = RefreshBodyView; - rollerShadeControl.Show(deviceUI, curRoom); + rollerShadeControl.Show(deviceUI, Common.Room.CurrentRoom); }; } } @@ -1578,7 +1633,7 @@ deviceRow.ClickBtn.MouseUpEventHandler += (send2, e2) => { - var userDoorLockPage = new UserDoorLockPage(curRoom, deviceUI); + var userDoorLockPage = new UserDoorLockPage(Common.Room.CurrentRoom, deviceUI); HomePage.Instance.AddChidren(userDoorLockPage); HomePage.Instance.PageIndex += 1; userDoorLockPage.Show(); @@ -1592,7 +1647,7 @@ { Tag = deviceUI }; - if (curRoom.IsSharedRoom == false) + if (Common.Room.CurrentRoom.IsSharedRoom == false) { deviceTypeRowLayout.AddRightView(editBtn); editBtn.MouseUpEventHandler += deviceDetailHandler; @@ -1626,12 +1681,84 @@ { Tag = deviceUI }; - if (curRoom.IsSharedRoom == false) + if (Common.Room.CurrentRoom.IsSharedRoom == false) { deviceTypeRowLayout.AddRightView(editBtn); editBtn.MouseUpEventHandler += deviceDetailHandler; deviceTypeRowLayout.AddRightView(delBtn); delBtn.MouseUpEventHandler += delEvent; + } + } + else if (deviceUI.CommonDevice.Type == DeviceType.TemperatureSensor) + { + var tempera = deviceUI.CommonDevice as TemperatureSensor; + if (tempera.Gateway != null) + { + new System.Threading.Thread(() => + { + System.Threading.Thread.Sleep(100 * i); + if (tempera.Gateway.IsVirtual) + { + UserHomeView.ReadStatus(tempera, () => + { + if (tempera.SensorDiv == 1) + { + ReadDeviceAttributeLogic.Instance.SendTemperatureStatuComand(deviceUI.CommonDevice); + } + else if (tempera.SensorDiv == 2) + { + ReadDeviceAttributeLogic.Instance.SendHumidityStatuComand(deviceUI.CommonDevice); + } + }); + } + else + { + if (CommonPage.ReadDeviceStatuSpan < (DateTime.Now - tempera.LastDateTime).TotalSeconds) + { + if (tempera.SensorDiv == 1) + { + ReadDeviceAttributeLogic.Instance.SendTemperatureStatuComand(deviceUI.CommonDevice); + } + else if (tempera.SensorDiv == 2) + { + ReadDeviceAttributeLogic.Instance.SendHumidityStatuComand(deviceUI.CommonDevice); + } + } + } + }) + { IsBackground = true }.Start(); + var deviceTypeRowLayout = new RowLayout() + { + Height = Application.GetRealHeight(129 + 35), + LineColor = ZigbeeColor.Current.GXCBackgroundColor, + Tag = deviceUI + }; + deviceListScrolView.AddChidren(deviceTypeRowLayout); + + var deviceRow = new CategoryFunctionRow(0, 35); + deviceRow.Init(deviceUI.IconPath, deviceUI.OnlineIconPath); + deviceRow.SetTitle(deviceUI.CommonDevice.DeviceEpointName); + deviceRow.SetStatuText(deviceUI.GetDeviceStatu()); + deviceRow.IsSelected = false; + deviceRow.HideSwitchBtn(true); + deviceTypeRowLayout.AddChidren(deviceRow); + + var editBtn = new CommonForm.RowLayoutEditButton() + { + Tag = deviceUI + }; + var delBtn = new Device.CommonForm.RowLayoutDeleteButton() + { + Tag = deviceUI + }; + if (Common.Room.CurrentRoom.IsSharedRoom == false) + { + deviceTypeRowLayout.AddRightView(editBtn); + editBtn.MouseUpEventHandler += deviceDetailHandler; + deviceTypeRowLayout.AddRightView(delBtn); + delBtn.MouseUpEventHandler += delEvent; + } + } } else @@ -1660,7 +1787,7 @@ { Tag = deviceUI }; - if (curRoom.IsSharedRoom == false) + if (Common.Room.CurrentRoom.IsSharedRoom == false) { deviceTypeRowLayout.AddRightView(editBtn); editBtn.MouseUpEventHandler += deviceDetailHandler; @@ -1718,10 +1845,9 @@ roomBtn.SetTitle(room.Name); row.AddChidren(roomBtn); - if (room.IsLove) + if (room.Id == Common.Room.CurrentRoom.Id) { roomBtn.IsSelected = true; - this.curRoom = room; curBtn = roomBtn; if(sceneBtn.IsSelected) { @@ -1732,6 +1858,7 @@ RefreshFunction(room); } } + roomBtn.ButtonClickEvent += (sender, e) => { if (sender == curBtn) @@ -1741,7 +1868,7 @@ sender.IsSelected = true; curBtn.IsSelected = false; curBtn = sender; - this.curRoom = room; + Common.Room.CurrentRoom = room; if (sceneBtn.IsSelected) { RefreshScene(room); -- Gitblit v1.8.0