gxc
2019-12-17 96428beef8b714ddb163216de37ab59d31ff5aa7
ZigbeeApp/Shared/Phone/UserView/UserHomeView.cs
@@ -223,7 +223,7 @@
                                            var attriButeList = ac.DeviceStatusReport.AttriBute;
                                            foreach(var attList in attriButeList)
                                            {
                                                var curTemp = (attList.AttriButeData / 100 < ACControlBase.Temperature_High || attList.AttriButeData / 100 > ACControlBase.Temperature_Low) ? attList.AttriButeData / 100 : ACControlBase.Temperature_Default;
                                                var curTemp = (attList.AttriButeData / 100 < ACControlBase.Temperature_High && attList.AttriButeData / 100 > ACControlBase.Temperature_Low) ? attList.AttriButeData / 100 : ACControlBase.Temperature_Default;
                                                switch (attList.AttributeId)
                                                {
                                                    case 0:
@@ -924,20 +924,20 @@
            else
            {
                deviceVerticalScrolViewLayout = new VerticalScrolViewLayout { };
                functionSceneBodyView.AddChidren(deviceVerticalScrolViewLayout);
                for (int i = 0; i < deviceList.Count; i++)
                {
                    var device = deviceList[i];
                    //new System.Threading.Thread(() =>
                    //{
                        Application.RunOnMainThread(() =>
                        {
                            try
                {
                    int t = i % 2;
                    int tt = i / 2;
                    int xx = 43 + i % 2 * (20 + 487);
                    int yy = 14;
                    var device = deviceList[i];
                    if (device == null || device.CommonDevice == null)
                    {
                        continue;
                    }
                    if (i % 2 == 0)
                    {
                        itemView = new FrameLayout()
@@ -946,18 +946,17 @@
                        };
                        deviceVerticalScrolViewLayout.AddChidren(itemView);
                    }
                    //收藏
                    EventHandler<MouseEventArgs> collectionEvent = (sender, e) =>
                    {
                        if ((sender as Button).IsSelected)
                        {
                            Shared.Common.Room.CurrentRoom.GetLoveRoom().DeleteDevice(device.FileName);
                                        Common.Room.CurrentRoom.GetLoveRoom().DeleteDevice(device.FileName);
                            (sender as Button).IsSelected = false;
                        }
                        else
                        {
                            Shared.Common.Room.CurrentRoom.GetLoveRoom().AddDevice(device.FileName);
                                        Common.Room.CurrentRoom.GetLoveRoom().AddDevice(device.FileName);
                            (sender as Button).IsSelected = true;
                        }
                        if (Room.CurrentRoom.IsLove)
@@ -966,19 +965,17 @@
                        }
                    };
                    //////判断设备是否支持的属性 如开关等控制
                    if (device.CommonDevice.Type == ZigBee.Device.DeviceType.WindowCoveringDevice)
                                if (device.CommonDevice.Type == DeviceType.WindowCoveringDevice)
                    {
                        //窗帘 卷帘
                        var rollerShade = (ZigBee.Device.Rollershade)device.CommonDevice;
                        //不上非远程
                        if (rollerShade.Gateway == null)
                                    if (rollerShade.Gateway != null)
                        {
                            continue;
                        }
                                        new System.Threading.Thread(() =>
                                        {
                                            System.Threading.Thread.Sleep(100 * i);
                        if (rollerShade.Gateway.IsVirtual)
                        {
                            //发送读取状态命令
                            ReadStatus(rollerShade, () =>
                            {
                                ReadDeviceAttributeLogic.Instance.SendCurtainStatuComand(device.CommonDevice);
@@ -991,6 +988,9 @@
                                ReadDeviceAttributeLogic.Instance.SendCurtainStatuComand(device.CommonDevice);
                            }
                        }
                                        })
                                        { IsBackground = true }.Start();
                        var lightView = new FunctionMainView(xx, yy);
                        lightView.Tag = device;
                        itemView.AddChidren(lightView);
@@ -1072,19 +1072,18 @@
                        lightView.CollectButton.MouseUpEventHandler += collectionEvent;
                    }
                    else if (device.CommonDevice.Type == ZigBee.Device.DeviceType.OnOffOutput)
                                }
                                else if (device.CommonDevice.Type == DeviceType.OnOffOutput)
                    {
                        //开关灯
                        var light = device.CommonDevice as ToggleLight;
                        //补上非远程
                        if (light.Gateway == null)
                                    if (light.Gateway != null)
                        {
                            continue;
                        }
                                        new System.Threading.Thread(() =>
                                        {
                                            System.Threading.Thread.Sleep(100 * i);
                        if (light.Gateway.IsVirtual)
                        {
                            //发送读取状态命令
                            ReadStatus(light, () =>
                            {
                                ReadDeviceAttributeLogic.Instance.SendLightStatuComand(device.CommonDevice);
@@ -1097,6 +1096,8 @@
                                ReadDeviceAttributeLogic.Instance.SendLightStatuComand(device.CommonDevice);
                            }
                        }
                                        })
                                        { IsBackground = true }.Start();
                        var lightView = new FunctionMainView(xx, yy);
                        itemView.AddChidren(lightView);
@@ -1205,20 +1206,19 @@
                        };
                        lightView.CollectButton.MouseUpEventHandler += collectionEvent;
                    }
                    else if (device.CommonDevice.Type == ZigBee.Device.DeviceType.AirSwitch)
                                }
                                else if (device.CommonDevice.Type == DeviceType.AirSwitch)
                    {
                        //空气开关
                        var airSwitch = device.CommonDevice as AirSwitch;
                        //补上非远程
                        if (airSwitch.Gateway == null)
                                    if (airSwitch.Gateway != null)
                        {
                            continue;
                        }
                                        new System.Threading.Thread(() =>
                                        {
                                            System.Threading.Thread.Sleep(100 * i);
                        if (airSwitch.Gateway.IsVirtual)
                        {
                            //发送读取状态命令
                            ReadStatus(airSwitch, () =>
                            {
                                ReadDeviceAttributeLogic.Instance.SendLightStatuComand(device.CommonDevice);
@@ -1226,12 +1226,13 @@
                        }
                        else
                        {
                            //防止短时间内多次读取设备状态
                            if ((DateTime.Now - airSwitch.LastDateTime).TotalSeconds > CommonPage.ReadDeviceStatuSpan)
                            {
                                ReadDeviceAttributeLogic.Instance.SendLightStatuComand(device.CommonDevice);
                            }
                        }
                                        })
                                        { IsBackground = true }.Start();
                        var lightView = new FunctionMainView(xx, yy);
                        itemView.AddChidren(lightView);
@@ -1313,19 +1314,18 @@
                        lightView.CollectButton.MouseUpEventHandler += collectionEvent;
                    }
                    else if (device.CommonDevice.Type == ZigBee.Device.DeviceType.Thermostat)
                                }
                                else if (device.CommonDevice.Type == DeviceType.Thermostat)
                    {
                        //恒温器-AC-空调
                        var ac = device.CommonDevice as AC;
                        //补上非远程
                        if (ac.Gateway == null)
                                    if (ac.Gateway != null)
                        {
                            continue;
                        }
                                        new System.Threading.Thread(() =>
                                        {
                                            System.Threading.Thread.Sleep(100 * i);
                        if (ac.Gateway.IsVirtual)
                        {
                            //发送读取状态命令
                            ReadStatus(ac, () =>
                            {
                                ReadDeviceAttributeLogic.Instance.SendACStatuComand(device.CommonDevice);
@@ -1333,12 +1333,14 @@
                        }
                        else
                        {
                            //防止短时间内多次读取设备状态
                            if ((DateTime.Now - ac.LastDateTime).TotalSeconds > CommonPage.ReadDeviceStatuSpan)
                            {
                                ReadDeviceAttributeLogic.Instance.SendACStatuComand(device.CommonDevice);
                            }
                        }
                                        })
                                        { IsBackground = true }.Start();
                        var lightView = new FunctionMainView(xx, yy);
                        itemView.AddChidren(lightView);
                        lightView.Init();
@@ -1418,15 +1420,16 @@
                        lightView.CollectButton.MouseUpEventHandler += collectionEvent;
                    }
                    else if (device.CommonDevice.Type == ZigBee.Device.DeviceType.DimmableLight)
                                }
                                else if (device.CommonDevice.Type == DeviceType.DimmableLight)
                    {
                        //调光灯
                        var dimmableLight = device.CommonDevice as DimmableLight;
                        //补上非远程
                        if (dimmableLight.Gateway == null)
                                    if (dimmableLight.Gateway != null)
                        {
                            continue;
                        }
                                        new System.Threading.Thread(() =>
                                        {
                                            System.Threading.Thread.Sleep(100 * i);
                        if (dimmableLight.Gateway.IsVirtual)
                        {
                            //发送读取状态命令
@@ -1443,6 +1446,8 @@
                                ReadDeviceAttributeLogic.Instance.SendDimmableLightStatuComand(device.CommonDevice);
                            }
                        }
                                        })
                                        { IsBackground = true }.Start();
                        var lightView = new FunctionMainView(xx, yy);
                        itemView.AddChidren(lightView);
@@ -1530,18 +1535,13 @@
                            //dimmableLightControl.action = RefreshBodyView;
                            dimmableLightControl.Show(device, Room.CurrentRoom);
                        };
                        lightView.CollectButton.MouseUpEventHandler += collectionEvent;
                    }
                    else if (device.CommonDevice.Type == ZigBee.Device.DeviceType.DoorLock)
                                }
                                else if (device.CommonDevice.Type == DeviceType.DoorLock)
                    {
                        //门锁
                        var dimmableLight = device.CommonDevice as DoorLock;
                        //补上非远程
                        if (dimmableLight.Gateway == null)
                        {
                            continue;
                        }
                        var lightView = new FunctionMainView(xx, yy);
                        itemView.AddChidren(lightView);
@@ -1598,9 +1598,16 @@
                        lightView.CollectButton.MouseUpEventHandler += collectionEvent;
                    }
                }
            }
                            catch(Exception ex)
                            {
        }
                        });
                    //})
                    //{ IsBackground = true }.Start();
                }
            }
        }
        #endregion