| | |
| | | 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: |
| | |
| | | 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() |
| | |
| | | }; |
| | | 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) |
| | |
| | | } |
| | | }; |
| | | |
| | | //////判断设备是否支持的属性 如开关等控制 |
| | | 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); |
| | |
| | | ReadDeviceAttributeLogic.Instance.SendCurtainStatuComand(device.CommonDevice); |
| | | } |
| | | } |
| | | }) |
| | | { IsBackground = true }.Start(); |
| | | |
| | | var lightView = new FunctionMainView(xx, yy); |
| | | lightView.Tag = device; |
| | | itemView.AddChidren(lightView); |
| | |
| | | |
| | | 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); |
| | |
| | | ReadDeviceAttributeLogic.Instance.SendLightStatuComand(device.CommonDevice); |
| | | } |
| | | } |
| | | }) |
| | | { IsBackground = true }.Start(); |
| | | |
| | | var lightView = new FunctionMainView(xx, yy); |
| | | itemView.AddChidren(lightView); |
| | |
| | | }; |
| | | |
| | | 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); |
| | |
| | | } |
| | | 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); |
| | |
| | | |
| | | 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); |
| | |
| | | } |
| | | 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(); |
| | |
| | | |
| | | 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) |
| | | { |
| | | //发送读取状态命令 |
| | |
| | | ReadDeviceAttributeLogic.Instance.SendDimmableLightStatuComand(device.CommonDevice); |
| | | } |
| | | } |
| | | }) |
| | | { IsBackground = true }.Start(); |
| | | |
| | | var lightView = new FunctionMainView(xx, yy); |
| | | itemView.AddChidren(lightView); |
| | |
| | | //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); |
| | |
| | | lightView.CollectButton.MouseUpEventHandler += collectionEvent; |
| | | } |
| | | } |
| | | } |
| | | catch(Exception ex) |
| | | { |
| | | |
| | | } |
| | | }); |
| | | //}) |
| | | //{ IsBackground = true }.Start(); |
| | | } |
| | | } |
| | | } |
| | | |
| | | #endregion |
| | | |