| | |
| | | { |
| | | case DeviceType.OnOffOutput: |
| | | //开关功能 |
| | | if (common.DeviceStatusReport.CluterID == 6) |
| | | if ((common as ToggleLight).DeviceStatusReport.CluterID == 6) |
| | | { |
| | | var light = deviceUI.CommonDevice as ToggleLight; |
| | | light.DeviceStatusReport = common.DeviceStatusReport; |
| | | light.DeviceStatusReport = (common as ToggleLight).DeviceStatusReport; |
| | | for (int j = 0; j < rowLayout.ChildrenCount; j++) |
| | | { |
| | | var tempView = rowLayout.GetChildren(j); |
| | |
| | | } |
| | | } |
| | | } |
| | | if (common.DeviceStatusReport.CluterID == 3) |
| | | if ((common as ToggleLight).DeviceStatusReport.CluterID == 3) |
| | | { |
| | | var light = deviceUI.CommonDevice as ToggleLight; |
| | | light.IsOnline = 1; |
| | |
| | | |
| | | case DeviceType.AirSwitch: |
| | | //开关功能 |
| | | if (common.DeviceStatusReport.CluterID == 6) |
| | | if ((common as ZigBee.Device.AirSwitch).DeviceStatusReport.CluterID == 6) |
| | | { |
| | | var airSwitch = deviceUI.CommonDevice as ZigBee.Device.AirSwitch; |
| | | airSwitch.DeviceStatusReport = common.DeviceStatusReport; |
| | | airSwitch.DeviceStatusReport = (common as ZigBee.Device.AirSwitch).DeviceStatusReport; |
| | | for (int j = 0; j < rowLayout.ChildrenCount; j++) |
| | | { |
| | | var tempView = rowLayout.GetChildren(j); |
| | |
| | | } |
| | | } |
| | | } |
| | | if (common.DeviceStatusReport.CluterID == 3) |
| | | if ((common as ZigBee.Device.AirSwitch).DeviceStatusReport.CluterID == 3) |
| | | { |
| | | var airSwitch = deviceUI.CommonDevice as ZigBee.Device.AirSwitch; |
| | | airSwitch.IsOnline = 1; |
| | |
| | | } |
| | | break; |
| | | case DeviceType.WindowCoveringDevice: |
| | | if (common.DeviceStatusReport.CluterID == 3) |
| | | if ((common as Rollershade).DeviceStatusReport.CluterID == 3) |
| | | { |
| | | var rollerShape = deviceUI.CommonDevice as Rollershade; |
| | | //记录回复时间 |
| | |
| | | |
| | | case DeviceType.Thermostat: |
| | | //AC功能 |
| | | if (common.DeviceStatusReport.CluterID == 513) |
| | | if ((common as ZigBee.Device.AC).DeviceStatusReport.CluterID == 513) |
| | | { |
| | | var attriButeList = common.DeviceStatusReport.AttriBute; |
| | | var attriButeList = (common as ZigBee.Device.AC).DeviceStatusReport.AttriBute; |
| | | if (attriButeList == null || attriButeList.Count == 0) |
| | | { |
| | | return; |
| | | } |
| | | var ac = deviceUI.CommonDevice as ZigBee.Device.AC; |
| | | ac.DeviceStatusReport = common.DeviceStatusReport; |
| | | ac.DeviceStatusReport = (common as ZigBee.Device.AC).DeviceStatusReport; |
| | | switch (attriButeList[0].AttributeId) |
| | | { |
| | | case 0: |
| | |
| | | } |
| | | |
| | | } |
| | | if (common.DeviceStatusReport.CluterID == 3) |
| | | if ((common as ZigBee.Device.AC).DeviceStatusReport.CluterID == 3) |
| | | { |
| | | var ac = deviceUI.CommonDevice as ZigBee.Device.AC; |
| | | ac.IsOnline = 1; |
| | |
| | | break; |
| | | case DeviceType.DimmableLight: |
| | | //调光灯功能 |
| | | if (common.DeviceStatusReport.CluterID == 6) |
| | | if ((common as ZigBee.Device.DimmableLight).DeviceStatusReport.CluterID == 6) |
| | | { |
| | | var dimmableLight = deviceUI.CommonDevice as ZigBee.Device.DimmableLight; |
| | | dimmableLight.DeviceStatusReport = common.DeviceStatusReport; |
| | | dimmableLight.DeviceStatusReport = (common as ZigBee.Device.DimmableLight).DeviceStatusReport; |
| | | for (int j = 0; j < rowLayout.ChildrenCount; j++) |
| | | { |
| | | var tempView = rowLayout.GetChildren(j); |
| | |
| | | } |
| | | } |
| | | } |
| | | if (common.DeviceStatusReport.CluterID == 3) |
| | | if ((common as ZigBee.Device.DimmableLight).DeviceStatusReport.CluterID == 3) |
| | | { |
| | | var dimmableLight = deviceUI.CommonDevice as ZigBee.Device.DimmableLight; |
| | | dimmableLight.IsOnline = 1; |
| | |
| | | zbGateway.ReportAction += UpdateDeviceControllStatu; |
| | | AddZbGateway(zbGatewayList, zbGateway, commonDeviceList, deviceUI.CommonDevice); |
| | | |
| | | (send2 as CommonForm.SelectedStatuButton).IsSelected = !(send2 as CommonForm.SelectedStatuButton).IsSelected; |
| | | if ((send2 as CommonForm.SelectedStatuButton).IsSelected) |
| | | (send2 as Button).IsSelected = !(send2 as Button).IsSelected; |
| | | if ((send2 as Button).IsSelected) |
| | | { |
| | | airSwitch.SwitchControl(1); |
| | | } |
| | |
| | | zbGateway.ReportAction += UpdateDeviceControllStatu; |
| | | AddZbGateway(zbGatewayList, zbGateway, commonDeviceList, deviceUI.CommonDevice); |
| | | |
| | | (send2 as CommonForm.SelectedStatuButton).IsSelected = !(send2 as CommonForm.SelectedStatuButton).IsSelected; |
| | | if ((send2 as CommonForm.SelectedStatuButton).IsSelected) |
| | | (send2 as Button).IsSelected = !(send2 as Button).IsSelected; |
| | | if ((send2 as Button).IsSelected) |
| | | { |
| | | dimmableLight.SwitchControl(1); |
| | | } |
| | |
| | | |
| | | #endregion |
| | | |
| | | |
| | | #region ◆ 自动化__________________________ |
| | | |
| | | /// <summary> |
| | |
| | | var Idlist = await Logic.Send.GetLogicId(0); |
| | | if (Idlist.Count != 0) |
| | | { |
| | | var listlogic = await Logic.Send.ReadList(Idlist.Count,0); |
| | | var listlogic = await Logic.Send.ReadList(Idlist.Count, 0); |
| | | //foreach可能集合已被修改,枚举操作可能不会执行,可能出现崩溃(建议for)。 |
| | | for (int j = 0; j < listlogic.Count; j++) |
| | | { |
| | |
| | | |
| | | |
| | | } |
| | | |
| | | #region ◆ 控制状态_________________________ |
| | | |
| | | /// <summary> |
| | | /// 显示设备控制状态 |
| | | /// </summary> |
| | | /// <param name="command">Command.</param> |
| | | /// <param name="objValue">Object value.</param> |
| | | private void UpdateDeviceControllStatu(string command, object objValue) |
| | | { |
| | | if (command != "DeviceDefaultAck" || objValue == null) |
| | | { |
| | | return; |
| | | } |
| | | var tempDevice = (CommonDevice)objValue; |
| | | if (null == commonDeviceList.Find((obj) => obj.DeviceEpoint == tempDevice.DeviceEpoint && obj.DeviceAddr == tempDevice.DeviceAddr)) |
| | | { |
| | | return; |
| | | } |
| | | //标记已经发送控制命令到网关 |
| | | sendedControlCommand = true; |
| | | //DeviceUI.ShowStatuTip(R.MyInternationalizationString.Success); |
| | | } |
| | | |
| | | /// <summary> |
| | | /// 移除全部更新控制设备的action |
| | | /// </summary> |
| | | private void RemoveAllUpdateControlDeviceStatuAction() |
| | | { |
| | | foreach (var gateway in zbGatewayList) |
| | | { |
| | | //移除action |
| | | if (gateway != null) |
| | | { |
| | | gateway.ReportAction -= UpdateDeviceControllStatu; |
| | | } |
| | | } |
| | | } |
| | | |
| | | /// <summary> |
| | | /// 移除单个控制设备的更新状态action |
| | | /// </summary> |
| | | /// <param name="gateway">Gateway.</param> |
| | | private void RemoveUpdateControlDeviceStatuAction(ZbGateway gateway) |
| | | { |
| | | //移除action |
| | | if (gateway != null) |
| | | { |
| | | gateway.ReportAction -= UpdateDeviceControllStatu; |
| | | } |
| | | } |
| | | |
| | | /// <summary> |
| | | /// 添加需要监控回调状态的网关和设备 |
| | | /// </summary> |
| | | /// <param name="gatewayList">Gateway list.</param> |
| | | /// <param name="gateway">Gateway.</param> |
| | | /// <param name="deviceList">Device list.</param> |
| | | /// <param name="common">Common.</param> |
| | | private void AddZbGateway(List<ZbGateway> gatewayList, ZbGateway gateway, List<CommonDevice> deviceList, CommonDevice common) |
| | | { |
| | | if (null == gatewayList.Find((obj) => obj.getGatewayBaseInfo.gwID == gateway.getGatewayBaseInfo.gwID)) |
| | | { |
| | | gatewayList.Add(gateway); |
| | | } |
| | | if (null == commonDeviceList.Find((obj) => obj.DeviceEpoint == common.DeviceEpoint && obj.DeviceAddr == common.DeviceAddr)) |
| | | { |
| | | commonDeviceList.Add(common); |
| | | } |
| | | } |
| | | |
| | | #endregion |
| | | |
| | | private void StatusColor(Common.Logic logic, RowLayout logicRowlayout, int intvalue) |
| | | { |
| | |
| | | } |
| | | } |
| | | #endregion |
| | | |
| | | #region ◆ 控制状态_________________________ |
| | | |
| | | /// <summary> |
| | | /// 显示设备控制状态 |
| | | /// </summary> |
| | | /// <param name="command">Command.</param> |
| | | /// <param name="objValue">Object value.</param> |
| | | private void UpdateDeviceControllStatu(string command, object objValue) |
| | | { |
| | | if (command != "DeviceDefaultAck" || objValue == null) |
| | | { |
| | | return; |
| | | } |
| | | var tempDevice = (CommonDevice)objValue; |
| | | if (null == commonDeviceList.Find((obj) => obj.DeviceEpoint == tempDevice.DeviceEpoint && obj.DeviceAddr == tempDevice.DeviceAddr)) |
| | | { |
| | | return; |
| | | } |
| | | //标记已经发送控制命令到网关 |
| | | sendedControlCommand = true; |
| | | //DeviceUI.ShowStatuTip(R.MyInternationalizationString.Success); |
| | | } |
| | | |
| | | /// <summary> |
| | | /// 移除全部更新控制设备的action |
| | | /// </summary> |
| | | private void RemoveAllUpdateControlDeviceStatuAction() |
| | | { |
| | | foreach (var gateway in zbGatewayList) |
| | | { |
| | | //移除action |
| | | if (gateway != null) |
| | | { |
| | | gateway.ReportAction -= UpdateDeviceControllStatu; |
| | | } |
| | | } |
| | | } |
| | | |
| | | /// <summary> |
| | | /// 移除单个控制设备的更新状态action |
| | | /// </summary> |
| | | /// <param name="gateway">Gateway.</param> |
| | | private void RemoveUpdateControlDeviceStatuAction(ZbGateway gateway) |
| | | { |
| | | //移除action |
| | | if (gateway != null) |
| | | { |
| | | gateway.ReportAction -= UpdateDeviceControllStatu; |
| | | } |
| | | } |
| | | |
| | | /// <summary> |
| | | /// 添加需要监控回调状态的网关和设备 |
| | | /// </summary> |
| | | /// <param name="gatewayList">Gateway list.</param> |
| | | /// <param name="gateway">Gateway.</param> |
| | | /// <param name="deviceList">Device list.</param> |
| | | /// <param name="common">Common.</param> |
| | | private void AddZbGateway(List<ZbGateway> gatewayList, ZbGateway gateway, List<CommonDevice> deviceList, CommonDevice common) |
| | | { |
| | | if (null == gatewayList.Find((obj) => obj.getGatewayBaseInfo.gwID == gateway.getGatewayBaseInfo.gwID)) |
| | | { |
| | | gatewayList.Add(gateway); |
| | | } |
| | | if (null == commonDeviceList.Find((obj) => obj.DeviceEpoint == common.DeviceEpoint && obj.DeviceAddr == common.DeviceAddr)) |
| | | { |
| | | commonDeviceList.Add(common); |
| | | } |
| | | } |
| | | |
| | | #endregion |
| | | } |
| | | } |