From b186c02eb9e44268727b769be477d1956e97fbb0 Mon Sep 17 00:00:00 2001
From: gxc <guoxuecheng@guoxuechengdeMacBook-Pro.local>
Date: 星期四, 02 一月 2020 09:08:05 +0800
Subject: [PATCH] 2019.1.2

---
 ZigbeeApp/Shared/Phone/Device/Category/Category.cs |  225 +++++++++++++++++++++++++++++++++++++++++++++++--------
 1 files changed, 190 insertions(+), 35 deletions(-)

diff --git a/ZigbeeApp/Shared/Phone/Device/Category/Category.cs b/ZigbeeApp/Shared/Phone/Device/Category/Category.cs
index 10ac345..e019f26 100644
--- a/ZigbeeApp/Shared/Phone/Device/Category/Category.cs
+++ b/ZigbeeApp/Shared/Phone/Device/Category/Category.cs
@@ -365,6 +365,66 @@
                                         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;
                             }
                         }
                     }
@@ -1072,9 +1132,9 @@
                                     var deviceRow = new CategoryFunctionRow(0, 35);
                                     deviceRow.Init(deviceUI.IconPath, deviceUI.OnlineIconPath);
                                     deviceRow.SetTitle(deviceUI.CommonDevice.DeviceEpointName);
-                                    deviceRow.SetOnLineStatu(light.IsOnline == 1);
+                                    //deviceRow.SetOnLineStatu(light.IsOnline == 1);
                                     deviceRow.SetStatuText(deviceUI.GetDeviceStatu());
-                                    deviceRow.SetStatu(light.OnOffStatus == 1);
+                                    deviceRow.IsSelected = light.OnOffStatus == 1;
                                     deviceTypeRowLayout.AddChidren(deviceRow);
 
                                     deviceRow.SwitchBtn.MouseUpEventHandler += (send2, e2) =>
@@ -1193,8 +1253,8 @@
                                     var deviceRow = new CategoryFunctionRow(0, 35);
                                     deviceRow.Init(deviceUI.IconPath, deviceUI.OnlineIconPath);
                                     deviceRow.SetTitle(deviceUI.CommonDevice.DeviceEpointName);
-                                    deviceRow.SetOnLineStatu(airSwitch.IsOnline == 1);
-                                    deviceRow.SetStatu(airSwitch.OnOffStatus == 1);
+                                    //deviceRow.SetOnLineStatu(airSwitch.IsOnline == 1);
+                                    deviceRow.IsSelected = airSwitch.OnOffStatus == 1;
                                     deviceRow.SetStatuText(deviceUI.GetDeviceStatu());
                                     deviceTypeRowLayout.AddChidren(deviceRow);
 
@@ -1204,8 +1264,8 @@
                                         sendedControlCommand = false;
                                         zbGateway.ReportAction += UpdateDeviceControllStatu;
                                         AddZbGateway(zbGatewayList, zbGateway, commonDeviceList, deviceUI.CommonDevice);
-
                                         (send2 as Button).IsSelected = !(send2 as Button).IsSelected;
+                                        deviceRow.IsSelected = (send2 as Button).IsSelected;
                                         if ((send2 as Button).IsSelected)
                                         {
                                             airSwitch.SwitchControl(1);
@@ -1296,9 +1356,9 @@
                                     var deviceRow = new CategoryFunctionRow(0, 35);
                                     deviceRow.Init(deviceUI.IconPath, deviceUI.OnlineIconPath);
                                     deviceRow.SetTitle(deviceUI.CommonDevice.DeviceEpointName);
-                                    deviceRow.SetOnLineStatu(dimmableLight.IsOnline == 1);
+                                    //deviceRow.SetOnLineStatu(dimmableLight.IsOnline == 1);
                                     deviceRow.SetStatuText(deviceUI.GetDeviceStatu());
-                                    deviceRow.SetStatu(dimmableLight.OnOffStatus == 1);
+                                    deviceRow.IsSelected = dimmableLight.OnOffStatus == 1;
                                     deviceTypeRowLayout.AddChidren(deviceRow);
 
                                     deviceRow.SwitchBtn.MouseUpEventHandler += (send2, e2) =>
@@ -1307,8 +1367,8 @@
                                         sendedControlCommand = false;
                                         zbGateway.ReportAction += UpdateDeviceControllStatu;
                                         AddZbGateway(zbGatewayList, zbGateway, commonDeviceList, deviceUI.CommonDevice);
-
                                         (send2 as Button).IsSelected = !(send2 as Button).IsSelected;
+                                        deviceRow.IsSelected = (send2 as Button).IsSelected;
                                         if ((send2 as Button).IsSelected)
                                         {
                                             dimmableLight.SwitchControl(1);
@@ -1401,9 +1461,9 @@
                                     var deviceRow = new CategoryFunctionRow(0, 35);
                                     deviceRow.Init(deviceUI.IconPath, deviceUI.OnlineIconPath);
                                     deviceRow.SetTitle(deviceUI.CommonDevice.DeviceEpointName);
-                                    deviceRow.SetOnLineStatu(ac.IsOnline == 1);
+                                    //deviceRow.SetOnLineStatu(ac.IsOnline == 1);
                                     deviceRow.SetStatuText(deviceUI.GetDeviceStatu());
-                                    deviceRow.SetStatu(ac.currentSystemMode != 1);
+                                    deviceRow.IsSelected = ac.currentSystemMode != 1;
                                     deviceTypeRowLayout.AddChidren(deviceRow);
 
                                     deviceRow.SwitchBtn.MouseUpEventHandler += (send2, e2) =>
@@ -1414,6 +1474,7 @@
                                         AddZbGateway(zbGatewayList, zbGateway, commonDeviceList, deviceUI.CommonDevice);
 
                                         (send2 as Button).IsSelected = !(send2 as Button).IsSelected;
+                                        deviceRow.IsSelected = (send2 as Button).IsSelected;
                                         if ((send2 as Button).IsSelected)
                                         {
                                             ac.Open();
@@ -1505,7 +1566,7 @@
                                     var deviceRow = new CategoryFunctionForWinRow(0, 35);
                                     deviceRow.Init(deviceUI);
                                     deviceRow.SetTitle(deviceUI.CommonDevice.DeviceEpointName);
-                                    deviceRow.SetOnLineStatu(rollerShade.IsOnline == 1);
+                                    //deviceRow.SetOnLineStatu(rollerShade.IsOnline == 1);
                                     deviceRow.SetStatuText(deviceUI.GetDeviceStatu());
                                     deviceRow.IsSelected = rollerShade.WcdCurrentPositionLiftPercentage != 0;
                                     deviceRow.SetRollerShadeIcon(rollerShade.WcdType);
@@ -1570,7 +1631,7 @@
                                 var deviceRow = new CategoryFunctionRow(0, 35);
                                 deviceRow.Init(deviceUI.IconPath, deviceUI.OnlineIconPath);
                                 deviceRow.SetTitle(deviceUI.CommonDevice.DeviceEpointName);
-                                deviceRow.SetOnLineStatu(deviceUI.CommonDevice.IsOnline == 1);
+                                //deviceRow.SetOnLineStatu(deviceUI.CommonDevice.IsOnline == 1);
                                 deviceRow.SetStatuText(deviceUI.GetDeviceStatu());
                                 deviceRow.HideSwitchBtn(true);
                                 deviceTypeRowLayout.AddChidren(deviceRow);
@@ -1599,6 +1660,112 @@
                                     delBtn.MouseUpEventHandler += delEvent;
                                 }
                             }
+                            else if (deviceUI.CommonDevice.Type == DeviceType.IASZone)
+                            {
+                                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 = (deviceUI.CommonDevice as IASZone).iASInfo?.Alarm1 == 1;
+                                deviceRow.HideSwitchBtn(true);
+                                deviceTypeRowLayout.AddChidren(deviceRow);
+
+                                var editBtn = new CommonForm.RowLayoutEditButton()
+                                {
+                                    Tag = deviceUI
+                                };
+                                var delBtn = new Device.CommonForm.RowLayoutDeleteButton()
+                                {
+                                    Tag = deviceUI
+                                };
+                                if (curRoom.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 (curRoom.IsSharedRoom == false)
+                                    {
+                                        deviceTypeRowLayout.AddRightView(editBtn);
+                                        editBtn.MouseUpEventHandler += deviceDetailHandler;
+                                        deviceTypeRowLayout.AddRightView(delBtn);
+                                        delBtn.MouseUpEventHandler += delEvent;
+                                    }
+
+                                }
+                            }
                             else
                             {
                                 var deviceTypeRowLayout = new RowLayout()
@@ -1612,7 +1779,7 @@
                                 var deviceRow = new CategoryFunctionRow(0, 35);
                                 deviceRow.Init(deviceUI.IconPath, deviceUI.OnlineIconPath);
                                 deviceRow.SetTitle(deviceUI.CommonDevice.DeviceEpointName);
-                                deviceRow.SetOnLineStatu(deviceUI.CommonDevice.IsOnline == 1);
+                                //deviceRow.SetOnLineStatu(deviceUI.CommonDevice.IsOnline == 1);
                                 deviceRow.SetStatuText(deviceUI.GetDeviceStatu());
                                 deviceRow.HideSwitchBtn(true);
                                 deviceTypeRowLayout.AddChidren(deviceRow);
@@ -1667,32 +1834,21 @@
             };
             functionSceneAutoBodyView.AddChidren(functionSceneBodyView);
 
-            Button curBtn = new Button();
+            RoomButton curBtn = new RoomButton(0,0);
             foreach (var room in Common.Room.CurrentRoom.GetRoomsByCurrentFloorIdAppendLoveRoom())
             {
                 var row = new FrameLayout()
                 {
-                    Width = Application.GetRealWidth(187 + 50),
+                    Width = Application.GetRealWidth(255),
                     Height = Application.GetRealHeight(167)
                 };
                 roomFL.AddChidren(row);
 
-                var roomBtn = new Button()
-                {
-                    Width = Application.GetRealWidth(187),
-                    Height = Application.GetRealHeight(78),
-                    Radius = (uint)Application.GetRealHeight(78 / 2),
-                    Gravity = Gravity.Center,
-                    Text = room.Name,
-                    TextColor = ZigbeeColor.Current.GXCTextGrayColor,
-                    SelectedTextColor = ZigbeeColor.Current.GXCTextWhiteColor,
-                    BackgroundColor = ZigbeeColor.Current.GXCButtonUnSelectedColor3,
-                    SelectedBackgroundColor = ZigbeeColor.Current.GXCButtonSelectedColor,
-                    BorderColor = ZigbeeColor.Current.GXCBorderUnSelectedColor,
-                    BorderWidth = 1
-                };
+                RoomButton roomBtn = new RoomButton(0, 0);
+                roomBtn.Gravity = Gravity.Center;
+                roomBtn.Init();
+                roomBtn.SetTitle(room.Name);
                 row.AddChidren(roomBtn);
-                roomBtn.SetViewShadow(true,5);
 
                 if (room.IsLove)
                 {
@@ -1707,17 +1863,16 @@
                     {
                         RefreshFunction(room);
                     }
-
                 }
-                roomBtn.MouseUpEventHandler += (sender, e) =>
+                roomBtn.ButtonClickEvent += (sender, e) =>
                 {
-                    if ((sender as Button) == curBtn)
+                    if (sender  == curBtn)
                     {
                         return;
                     }
-                    (sender as Button).IsSelected = true;
+                    sender.IsSelected = true;
                     curBtn.IsSelected = false;
-                    curBtn = sender as Button;
+                    curBtn = sender;
                     this.curRoom = room;
                     if (sceneBtn.IsSelected)
                     {

--
Gitblit v1.8.0