| | |
| | | /// <summary> |
| | | /// The action. |
| | | /// </summary> |
| | | public Action<DeviceUI, Common.Room> action; |
| | | public Action<CommonDevice, Common.Room> action; |
| | | |
| | | /// <summary> |
| | | /// The light image. |
| | |
| | | /// <summary> |
| | | /// 传过来的设备 |
| | | /// </summary> |
| | | private DeviceUI device; |
| | | private CommonDevice device; |
| | | /// <summary> |
| | | /// 传过来的房间 |
| | | /// </summary> |
| | |
| | | { |
| | | var deviceUI = device; |
| | | //设备为空 |
| | | if (deviceUI.CommonDevice == null) |
| | | if (deviceUI == null) |
| | | { |
| | | return; |
| | | } |
| | | //是否为当前设备 |
| | | if (deviceUI.CommonDevice.DeviceEpoint != common.DeviceEpoint || deviceUI.CommonDevice.DeviceAddr != common.DeviceAddr) |
| | | if (deviceUI.DeviceEpoint != common.DeviceEpoint || deviceUI.DeviceAddr != common.DeviceAddr) |
| | | { |
| | | return; |
| | | } |
| | | if (deviceUI.CommonDevice.Type == DeviceType.AirSwitch) |
| | | if (deviceUI.Type == DeviceType.AirSwitch) |
| | | { |
| | | if (common.DeviceStatusReport.CluterID == 6) |
| | | { |
| | | var light = deviceUI.CommonDevice as AirSwitch; |
| | | var light = deviceUI as AirSwitch; |
| | | light.DeviceStatusReport = common.DeviceStatusReport; |
| | | //记录、更新状态 |
| | | if (light.DeviceStatusReport.AttriBute == null || light.DeviceStatusReport.AttriBute.Count == 0) |
| | |
| | | return; |
| | | } |
| | | light.OnOffStatus = light.DeviceStatusReport.AttriBute[0].AttriButeData; |
| | | StatuBtn.Text = $"{Language.StringByID(R.MyInternationalizationString.Current)} {device.GetDeviceStatu()}"; |
| | | StatuBtn.Text = Language.StringByID(R.MyInternationalizationString.Current) + " " + UserCenter.HdlDeviceOtherLogic.Current.GetDeviceStatu(device); |
| | | |
| | | if (device.CommonDevice.DfunctionType == DeviceFunctionType.A开关) |
| | | if (device.DfunctionType == DeviceFunctionType.A开关) |
| | | { |
| | | SetONOFFStatu(light.OnOffStatus == 1); |
| | | } |
| | | else if (device.CommonDevice.DfunctionType == DeviceFunctionType.A插座) |
| | | else if (device.DfunctionType == DeviceFunctionType.A插座) |
| | | { |
| | | deviceIMG.IsSelected = switchBtn.IsSelected = light.OnOffStatus == 1; |
| | | } |
| | |
| | | { |
| | | var deviceUI = device; |
| | | //设备为空 |
| | | if (deviceUI.CommonDevice == null) |
| | | if (deviceUI == null) |
| | | { |
| | | return; |
| | | } |
| | | //是否为当前设备 |
| | | if (deviceUI.CommonDevice.DeviceEpoint != common.DeviceEpoint || deviceUI.CommonDevice.DeviceAddr != common.DeviceAddr) |
| | | if (deviceUI.DeviceEpoint != common.DeviceEpoint || deviceUI.DeviceAddr != common.DeviceAddr) |
| | | { |
| | | return; |
| | | } |
| | | deviceUI.CommonDevice.IsOnline = common.IsOnline; |
| | | deviceUI.IsOnline = common.IsOnline; |
| | | //OnBtn.IsSelected = OffBtn.IsSelected= deviceUI.CommonDevice.IsOnline == 1; |
| | | deviceUI.CommonDevice.LastDateTime = DateTime.Now; |
| | | deviceUI.LastDateTime = DateTime.Now; |
| | | } |
| | | catch (Exception ex) |
| | | { |
| | |
| | | /// </summary> |
| | | /// <param name="dev">Device.</param> |
| | | /// <param name="room">Room.</param> |
| | | public void Show(DeviceUI dev, Shared.Common.Room room) |
| | | public void Show(CommonDevice dev, Shared.Common.Room room) |
| | | { |
| | | device = dev; |
| | | zbGateway = this.device.CommonDevice.Gateway; |
| | | zbGateway = this.device.Gateway; |
| | | this.room = room; |
| | | |
| | | AddTop(); |
| | |
| | | AddBodyView(device); |
| | | |
| | | |
| | | var light = dev.CommonDevice as AirSwitch; |
| | | var light = dev as AirSwitch; |
| | | //补上非远程 |
| | | if (light.Gateway == null) |
| | | { |
| | |
| | | { |
| | | UserHomeView.ReadStatus(light, () => |
| | | { |
| | | ReadDeviceAttributeLogic.Instance.SendLightStatuComand(device.CommonDevice); |
| | | ReadDeviceAttributeLogic.Instance.SendLightStatuComand(device); |
| | | }); |
| | | } |
| | | else |
| | |
| | | //防止短时间内多次读取状态 |
| | | if (CommonPage.ReadDeviceStatuSpan < (DateTime.Now - light.LastDateTime).TotalSeconds) |
| | | { |
| | | ReadDeviceAttributeLogic.Instance.SendLightStatuComand(device.CommonDevice); |
| | | ReadDeviceAttributeLogic.Instance.SendLightStatuComand(device); |
| | | } |
| | | } |
| | | |
| | | if (Common.Room.CurrentRoom.IsCollectInRoom(device.FileName) == false) |
| | | if (UserCenter.HdlRoomLogic.Current.IsCollectInRoom(device) == false) |
| | | { |
| | | collectionBtn.IsSelected = false; |
| | | } |
| | |
| | | /// <summary> |
| | | /// AddBodyView |
| | | /// </summary> |
| | | public void AddBodyView(DeviceUI device) |
| | | public void AddBodyView(CommonDevice device) |
| | | { |
| | | bodyFrameLayout = new FrameLayout() |
| | | { |
| | |
| | | Width = Application.GetRealWidth(500), |
| | | Height = Application.GetRealHeight(60), |
| | | Gravity = Gravity.CenterHorizontal, |
| | | Text = Common.LocalDevice.Current.GetDeviceEpointName(device.CommonDevice), |
| | | Text = Common.LocalDevice.Current.GetDeviceEpointName(device), |
| | | TextColor = ZigbeeColor.Current.GXCTextBlackColor, |
| | | TextSize = 15, |
| | | IsBold = true |
| | |
| | | Height = Application.GetRealHeight(60), |
| | | Gravity = Gravity.CenterHorizontal, |
| | | TextColor = ZigbeeColor.Current.GXCTextGrayColor, |
| | | Text = $"{Language.StringByID(R.MyInternationalizationString.Current)} {device.GetDeviceStatu()}", |
| | | Text = Language.StringByID(R.MyInternationalizationString.Current) + " " + UserCenter.HdlDeviceOtherLogic.Current.GetDeviceStatu(device), |
| | | TextSize = 10 |
| | | }; |
| | | itemView.AddChidren(StatuBtn); |
| | |
| | | /// </summary> |
| | | private void AddByFunctionType(FrameLayout itemView) |
| | | { |
| | | if (device.CommonDevice.DfunctionType == DeviceFunctionType.A开关) |
| | | if (device.DfunctionType == DeviceFunctionType.A开关) |
| | | { |
| | | AddOnOff(itemView); |
| | | } |
| | | else if (device.CommonDevice.DfunctionType == DeviceFunctionType.A插座) |
| | | else if (device.DfunctionType == DeviceFunctionType.A插座) |
| | | { |
| | | AddPlug(itemView); |
| | | } |
| | |
| | | Height = Application.GetMinRealAverage(81), |
| | | UnSelectedImagePath = "Light/OFF.png", |
| | | SelectedImagePath = "Light/OFFSelected.png", |
| | | IsSelected = (device.CommonDevice as AirSwitch).OnOffStatus == 0 |
| | | IsSelected = (device as AirSwitch).OnOffStatus == 0 |
| | | }; |
| | | itemView.AddChidren(OffBtn); |
| | | |
| | |
| | | Height = Application.GetMinRealAverage(81), |
| | | UnSelectedImagePath = "Light/ON.png", |
| | | SelectedImagePath = "Light/ONSelected.png", |
| | | IsSelected = (device.CommonDevice as AirSwitch).OnOffStatus == 1 |
| | | IsSelected = (device as AirSwitch).OnOffStatus == 1 |
| | | }; |
| | | itemView.AddChidren(OnBtn); |
| | | |
| | |
| | | Gravity = Gravity.CenterHorizontal, |
| | | UnSelectedImagePath = "Light/DeskLamp.png", |
| | | SelectedImagePath = "Light/DeskLampSelected.png", |
| | | IsSelected = (device.CommonDevice as AirSwitch).OnOffStatus == 1 |
| | | IsSelected = (device as AirSwitch).OnOffStatus == 1 |
| | | }; |
| | | itemView.AddChidren(deviceIMG); |
| | | |
| | |
| | | Gravity = Gravity.CenterHorizontal, |
| | | UnSelectedImagePath = "Item/Switch.png", |
| | | SelectedImagePath = "Item/SwitchSelected.png", |
| | | IsSelected = (device.CommonDevice as AirSwitch).OnOffStatus == 1 |
| | | IsSelected = (device as AirSwitch).OnOffStatus == 1 |
| | | }; |
| | | itemView.AddChidren(switchBtn); |
| | | |
| | |
| | | Gravity = Gravity.CenterHorizontal, |
| | | UnSelectedImagePath = "Light/Plug.png", |
| | | SelectedImagePath = "Light/PlugSelected.png", |
| | | IsSelected = (device.CommonDevice as AirSwitch).OnOffStatus == 1 |
| | | IsSelected = (device as AirSwitch).OnOffStatus == 1 |
| | | }; |
| | | itemView.AddChidren(deviceIMG); |
| | | |
| | |
| | | Gravity = Gravity.CenterHorizontal, |
| | | UnSelectedImagePath = "Item/Switch.png", |
| | | SelectedImagePath = "Item/SwitchSelected.png", |
| | | IsSelected = (device.CommonDevice as AirSwitch).OnOffStatus == 1 |
| | | IsSelected = (device as AirSwitch).OnOffStatus == 1 |
| | | }; |
| | | itemView.AddChidren(switchBtn); |
| | | |
| | |
| | | zbGateway.ReportAction += UpdateDeviceControllStatu; |
| | | switchBtn.IsSelected = !switchBtn.IsSelected; |
| | | deviceIMG.IsSelected = !deviceIMG.IsSelected; |
| | | StatuBtn.Text = deviceIMG.IsSelected ? $"{Language.StringByID(R.MyInternationalizationString.Current)} {Language.StringByID(R.MyInternationalizationString.Open)}" : $"{Language.StringByID(R.MyInternationalizationString.Current)} {Language.StringByID(R.MyInternationalizationString.Shut)}"; |
| | | StatuBtn.Text = Language.StringByID(R.MyInternationalizationString.Current) + " "; |
| | | if (deviceIMG.IsSelected == true)
|
| | | {
|
| | | StatuBtn.Text += Language.StringByID(R.MyInternationalizationString.uOpen1);
|
| | | } |
| | | else
|
| | | {
|
| | | StatuBtn.Text += Language.StringByID(R.MyInternationalizationString.Close);
|
| | | } |
| | | |
| | | if (switchBtn.IsSelected == true) |
| | | { |
| | | (device.CommonDevice as AirSwitch).SwitchControl(1); |
| | | (device as AirSwitch).SwitchControl(1); |
| | | } |
| | | else |
| | | { |
| | | (device.CommonDevice as AirSwitch).SwitchControl(0); |
| | | (device as AirSwitch).SwitchControl(0); |
| | | } |
| | | //控制延时回调 |
| | | DeviceUI.SendCommandDelayAction(device.CommonDevice, () => |
| | | UserCenter.HdlDeviceOtherLogic.Current.SendCommandDelayAction(device, () => |
| | | { |
| | | if (Parent == null) |
| | | { |
| | |
| | | RemoveUpdateControlDeviceStatuAction(); |
| | | if (sendedControlCommand == false) |
| | | { |
| | | DeviceUI.ShowStatuTip(R.MyInternationalizationString.FAIL); |
| | | UserCenter.HdlDeviceOtherLogic.Current.ShowStatuTip(R.MyInternationalizationString.FAIL); |
| | | } |
| | | }); |
| | | } |
| | |
| | | private void ON(object sender, MouseEventArgs eventArgs) |
| | | { |
| | | SetONOFFStatu(true); |
| | | (device.CommonDevice as AirSwitch).SwitchControl(1); |
| | | (device as AirSwitch).SwitchControl(1); |
| | | //控制延时回调 |
| | | zbGateway.ReportAction += UpdateDeviceControllStatu; |
| | | DeviceUI.SendCommandDelayAction(device.CommonDevice, () => |
| | | UserCenter.HdlDeviceOtherLogic.Current.SendCommandDelayAction(device, () => |
| | | { |
| | | if (Parent == null) |
| | | { |
| | |
| | | RemoveUpdateControlDeviceStatuAction(); |
| | | if (sendedControlCommand == false) |
| | | { |
| | | DeviceUI.ShowStatuTip(R.MyInternationalizationString.FAIL); |
| | | UserCenter.HdlDeviceOtherLogic.Current.ShowStatuTip(R.MyInternationalizationString.FAIL); |
| | | } |
| | | }); |
| | | } |
| | |
| | | private void OFF(object sender, MouseEventArgs eventArgs) |
| | | { |
| | | SetONOFFStatu(false); |
| | | (device.CommonDevice as AirSwitch).SwitchControl(0); |
| | | (device as AirSwitch).SwitchControl(0); |
| | | //控制延时回调 |
| | | zbGateway.ReportAction += UpdateDeviceControllStatu; |
| | | DeviceUI.SendCommandDelayAction(device.CommonDevice, () => |
| | | UserCenter.HdlDeviceOtherLogic.Current.SendCommandDelayAction(device, () => |
| | | { |
| | | if (Parent == null) |
| | | { |
| | |
| | | RemoveUpdateControlDeviceStatuAction(); |
| | | if (sendedControlCommand == false) |
| | | { |
| | | DeviceUI.ShowStatuTip(R.MyInternationalizationString.FAIL); |
| | | UserCenter.HdlDeviceOtherLogic.Current.ShowStatuTip(R.MyInternationalizationString.FAIL); |
| | | } |
| | | }); |
| | | } |
| | |
| | | /// </summary> |
| | | /// <param name="statu"></param> |
| | | private void SetONOFFStatu(bool statu) |
| | | { |
| | | {
|
| | | StatuBtn.Text = Language.StringByID(R.MyInternationalizationString.Current) + " "; |
| | | if (statu) |
| | | { |
| | | OnBtn.IsSelected = true; |
| | | OffBtn.IsSelected = false; |
| | | OffBtn.IsSelected = false;
|
| | | StatuBtn.Text += Language.StringByID(R.MyInternationalizationString.uOpen1); |
| | | } |
| | | else |
| | | { |
| | | OnBtn.IsSelected = false; |
| | | OffBtn.IsSelected = true; |
| | | OffBtn.IsSelected = true;
|
| | | StatuBtn.Text += Language.StringByID(R.MyInternationalizationString.Close); |
| | | } |
| | | StatuBtn.Text = statu ? $"{Language.StringByID(R.MyInternationalizationString.Current)} {Language.StringByID(R.MyInternationalizationString.Open)}" : $"{Language.StringByID(R.MyInternationalizationString.Current)} {Language.StringByID(R.MyInternationalizationString.Shut)}"; |
| | | } |
| | | |
| | | |
| | |
| | | //collection |
| | | if ((sender as Button).IsSelected) |
| | | { |
| | | Shared.Common.Room.CurrentRoom.GetLoveRoom().DeleteDevice(device.FileName); |
| | | UserCenter.HdlRoomLogic.Current.DeleteLoveDevice(device); |
| | | (sender as Button).IsSelected = false; |
| | | } |
| | | else |
| | | { |
| | | Shared.Common.Room.CurrentRoom.GetLoveRoom().AddDevice(device.FileName); |
| | | UserCenter.HdlRoomLogic.Current.AddLoveDevice(device); |
| | | (sender as Button).IsSelected = true; |
| | | } |
| | | } |
| | |
| | | return; |
| | | } |
| | | var tempDevice = (CommonDevice)objValue; |
| | | if (tempDevice.DeviceEpoint != this.device.CommonDevice.DeviceEpoint || tempDevice.DeviceAddr != this.device.CommonDevice.DeviceAddr) |
| | | if (tempDevice.DeviceEpoint != this.device.DeviceEpoint || tempDevice.DeviceAddr != this.device.DeviceAddr) |
| | | { |
| | | //不是当前设备的推送,则不处理 |
| | | return; |