| | |
| | | /// 构造函数 |
| | | /// </summary> |
| | | /// <param name="device"></param> |
| | | /// <param name="deviceBindType">1:新风;2:温度传感器;3:湿度传感器</param> |
| | | public PanelFangyueFreshAirTargetsForm(CommonDevice device, int deviceBindType) |
| | | /// <param name="deviceBindType">1:新风;2:温度传感器;3:湿度传感器;4:PM2.5传感器</param> |
| | | /// <param name="bindDev">绑定目标 </param> |
| | | public PanelFangyueFreshAirTargetsForm(CommonDevice device, CommonDevice bindDev, int deviceBindType) |
| | | { |
| | | this.curControlDev = device as FreshAir; |
| | | this.curBindDevice = bindDev; |
| | | this.curDeviceBindType = deviceBindType; |
| | | } |
| | | #endregion |
| | | |
| | | #region 变量申明 |
| | | /// <summary> |
| | | /// 当前控制设备 |
| | | /// </summary> |
| | | //CommonDevice currentControlDevice; |
| | | #region 变量申明 |
| | | /// <summary> |
| | | /// 当前新风面板【控制设备】 |
| | | /// </summary> |
| | | FreshAir curControlDev; |
| | | /// <summary> |
| | | /// 当前被绑设备 |
| | | /// </summary> |
| | | CommonDevice curBindDevice; |
| | | /// <summary> |
| | | /// 显示被绑定设备或场景的view |
| | | /// </summary> |
| | |
| | | /// PM绑定目标回调 |
| | | /// </summary> |
| | | public Action<string> actionPMTarget = null; |
| | | |
| | | #endregion |
| | | |
| | | #region UI设计 |
| | |
| | | FrameLayout curentOldRoomFrameLayout = null; |
| | | int index = 0; |
| | | var roomTempList = GetSupportRoomList(); |
| | | Room slectedRoom = null; |
| | | |
| | | for (int i = 0; i < roomTempList.Count; i++) |
| | | { |
| | | var room = roomTempList[i]; |
| | | bool canSelect = false; |
| | | if (curControlDev.currentSelectRoomId == room.Id) |
| | | { |
| | | slectedRoom = room; |
| | | canSelect = true; |
| | | } |
| | | //房间 |
| | | var btnRoomFrameLayout = new FrameLayout |
| | | { |
| | |
| | | btnRoomFrameLayout.AddChidren(btnRoom); |
| | | |
| | | btnRoom.IsSelected = false; |
| | | if (index == 0) |
| | | if (canSelect) |
| | | { |
| | | btnRoomFrameLayout.BackgroundImagePath = "Item/RoomIconBackgroundSelected.png"; |
| | | btnRoom.TextColor = Shared.Common.ZigbeeColor.Current.XMWhite; |
| | | curentOldRoom = btnRoom; |
| | | curentOldRoomFrameLayout = btnRoomFrameLayout; |
| | | } |
| | | |
| | | //被绑定的目标还未分配区域,默认是第一个 |
| | | if (string.IsNullOrEmpty(curControlDev.currentSelectRoomId)) |
| | | { |
| | | if (index == 0) |
| | | { |
| | | btnRoomFrameLayout.BackgroundImagePath = "Item/RoomIconBackgroundSelected.png"; |
| | | btnRoom.TextColor = Shared.Common.ZigbeeColor.Current.XMWhite; |
| | | curentOldRoom = btnRoom; |
| | | curentOldRoomFrameLayout = btnRoomFrameLayout; |
| | | } |
| | | } |
| | | |
| | | if (index == roomTempList.Count - 1 && index > 3) |
| | | { |
| | | var btnRoomFrameLayoutEmpty = new FrameLayout |
| | | { |
| | | Height = Application.GetMinReal(159), |
| | | Width = Application.GetMinReal(50), |
| | | Y = Application.GetRealHeight(23), |
| | | X = Application.GetRealWidth(5), |
| | | BorderWidth = 1, |
| | | }; |
| | | btnHorizontalScrolViewLayout.AddChidren(btnRoomFrameLayoutEmpty); |
| | | } |
| | | |
| | | EventHandler<MouseEventArgs> eHandlerRoom = (sender, e) => |
| | | { |
| | | if (!btnRoom.IsSelected) |
| | |
| | | curentOldRoomFrameLayout.BackgroundImagePath = "Item/RoomIconBackgroundSelected.png"; |
| | | } |
| | | curRoom = room; |
| | | curControlDev.RoomId = room.Id; |
| | | |
| | | //新风面板保存使能 |
| | | btnFinifh.Enable = true; |
| | |
| | | } |
| | | BindInfo.FinishDisplay(roomTempList, btnFinifh); |
| | | |
| | | if (roomTempList.Count != 0) |
| | | if (roomTempList.Count == 0) |
| | | { |
| | | curRoom = roomTempList[0]; |
| | | curRoom = new Shared.Common.Room(); |
| | | } |
| | | else |
| | | { |
| | | curRoom = new Shared.Common.Room(); |
| | | if (slectedRoom == null) |
| | | { |
| | | curRoom = roomTempList[0]; |
| | | } |
| | | else |
| | | { |
| | | curRoom = slectedRoom; |
| | | } |
| | | } |
| | | |
| | | RefreshDeviceList(curRoom); |
| | |
| | | line2.Visible = false; |
| | | } |
| | | |
| | | switch (curDeviceBindType) |
| | | { |
| | | case 1: |
| | | devicePic.UnSelectedImagePath = "Device/FreshAirEpoint.png"; |
| | | break; |
| | | case 2: |
| | | devicePic.UnSelectedImagePath = "Device/SensorTemperature.png"; |
| | | if (device.Type == DeviceType.PMSensor) |
| | | { |
| | | btnBindName.Text = Common.LocalDevice.Current.GetDeviceEpointName(device) + "-" + Language.StringByID(R.MyInternationalizationString.TemperatureSensor); |
| | | } |
| | | break; |
| | | case 3: |
| | | devicePic.UnSelectedImagePath = "Device/SensorHumidity.png"; |
| | | if (device.Type == DeviceType.PMSensor) |
| | | { |
| | | btnBindName.Text = Common.LocalDevice.Current.GetDeviceEpointName(device) + "-" + Language.StringByID(R.MyInternationalizationString.HumiditySensor); |
| | | } |
| | | break; |
| | | case 4: |
| | | devicePic.UnSelectedImagePath = "Device/AirQualitySensorEpoint.png"; |
| | | break; |
| | | } |
| | | #endregion |
| | | |
| | | string mianKey = device.DeviceAddr + device.DeviceEpoint; |
| | |
| | | } |
| | | |
| | | EventHandler<MouseEventArgs> hander = (sender, e) => |
| | | { |
| | | btnChoose.IsSelected = !btnChoose.IsSelected; |
| | | if (!btnChoose.IsSelected) |
| | | { |
| | | if (oldDevice != null) |
| | | { |
| | | oldDevice.IsSelected = false; |
| | | oldDevice.Visible = false; |
| | | } |
| | | oldDevice = btnChoose; |
| | | oldDevice.IsSelected = false; |
| | | oldDevice.Visible = false; |
| | | targetList.Clear(); |
| | | } |
| | | else |
| | | { |
| | | if (oldDevice != null) |
| | | { |
| | | oldDevice.IsSelected = false; |
| | | oldDevice.Visible = false; |
| | | } |
| | | oldDevice = btnChoose; |
| | | oldDevice.IsSelected = true; |
| | | oldDevice.Visible = true; |
| | | targetList.Clear(); |
| | | targetList.Add(device); |
| | | } |
| | | { |
| | | btnChoose.IsSelected = !btnChoose.IsSelected; |
| | | if (!btnChoose.IsSelected) |
| | | { |
| | | if (oldDevice != null) |
| | | { |
| | | oldDevice.IsSelected = false; |
| | | oldDevice.Visible = false; |
| | | } |
| | | oldDevice = btnChoose; |
| | | oldDevice.IsSelected = false; |
| | | oldDevice.Visible = false; |
| | | targetList.Clear(); |
| | | } |
| | | else |
| | | { |
| | | if (oldDevice != null) |
| | | { |
| | | oldDevice.IsSelected = false; |
| | | oldDevice.Visible = false; |
| | | } |
| | | oldDevice = btnChoose; |
| | | oldDevice.IsSelected = true; |
| | | oldDevice.Visible = true; |
| | | targetList.Clear(); |
| | | targetList.Add(device); |
| | | } |
| | | |
| | | //新风面板:由于目标没有提供删除接口,所以可以取消选中能保存 |
| | | btnFinifh.Enable = true; |
| | | btnFinifh.BackgroundColor = Shared.Common.ZigbeeColor.Current.XMBlack; |
| | | }; |
| | | //新风面板:由于目标没有提供删除接口,所以可以取消选中能保存 |
| | | btnFinifh.Enable = true; |
| | | btnFinifh.BackgroundColor = Shared.Common.ZigbeeColor.Current.XMBlack; |
| | | }; |
| | | rowLayout.MouseUpEventHandler += hander; |
| | | devicePic.MouseUpEventHandler += hander; |
| | | btnBindName.MouseUpEventHandler += hander; |
| | |
| | | { |
| | | CommonPage.Loading.Start(""); |
| | | }); |
| | | //获取被绑目标等信息 |
| | | BindDevInfo(curBindDevice); |
| | | |
| | | //获取楼层 |
| | | dicFloorList = HdlRoomLogic.Current.GetFloorSortList(); |
| | | curControlDev.currentSelectFloorId = BindInfo.GetCurrentSelectFloorId(); |
| | | if (BindInfo.GetCurrentSelectFloorIdName() != null) |
| | | { |
| | | Application.RunOnMainThread(() => |
| | | { |
| | | btnFloorText.Text = BindInfo.GetCurrentSelectFloorIdName(); |
| | | }); |
| | | } |
| | | |
| | | //获取楼层中房间列表 |
| | | supportRoomList = GetFloorRoomList(); |
| | | if (supportRoomList.Count == 0) |
| | | { |
| | | return; |
| | | } |
| | | |
| | | //获取所有房间中匹配的能绑的目标 |
| | | currentPanelSupportBindDeviceList = GetAllRoomSupportDeviceList(); |
| | | |
| | | //获取面板中存在的绑定目标 |
| | | var panelBindListRes = await this.curControlDev.GetDeviceBindAsync(); |
| | | var panelBindListRes = HdlDeviceBindLogic.Current.GetDeviceBindAsync(curControlDev); |
| | | if (panelBindListRes != null && panelBindListRes.getAllBindResponseData != null) |
| | | { |
| | | curControlDev.bindList.Clear(); |
| | |
| | | new Tip() { MaxWidth = 150, Text = Language.StringByID(R.MyInternationalizationString.GwResponseOvertime), Direction = AMPopTipDirection.None, CloseTime = 1 }.Show(Common.CommonPage.Instance); |
| | | }); |
| | | } |
| | | |
| | | targetList.Clear(); |
| | | //选中目标列表 targetList |
| | | if (currentPanelSupportBindDeviceList.Count != 0 && curControlDev.bindList.Count != 0) |
| | | { |
| | | foreach (var bindDev in currentPanelSupportBindDeviceList) |
| | | foreach (var bindDev in curControlDev.bindList) |
| | | { |
| | | var mainKey = bindDev.DeviceAddr + bindDev.DeviceEpoint; |
| | | var dev = curControlDev.bindList.Find(obj => (obj != null) && (obj.BindMacAddr + obj.BindEpoint == mainKey)); |
| | | var mainKey = bindDev.BindMacAddr + bindDev.BindEpoint; |
| | | var dev = currentPanelSupportBindDeviceList.Find(obj => (obj != null) && (obj.DeviceAddr + obj.DeviceEpoint == mainKey)); |
| | | if (dev != null) |
| | | { |
| | | var device = LocalDevice.Current.GetDevice(bindDev.DeviceAddr, bindDev.DeviceEpoint); |
| | | var device = LocalDevice.Current.GetDevice(dev.DeviceAddr, dev.DeviceEpoint); |
| | | if (device != null) |
| | | { |
| | | switch (curDeviceBindType) |
| | |
| | | case 2: |
| | | if (device.Type == DeviceType.TemperatureSensor) |
| | | { |
| | | targetList.Add(device); |
| | | oldTargetList.Add(device); |
| | | var bDev = device as TemperatureSensor; |
| | | if (bDev.SensorDiv == 1) |
| | | { |
| | | targetList.Add(device); |
| | | oldTargetList.Add(device); |
| | | } |
| | | } |
| | | if (device.Type == DeviceType.PMSensor) |
| | | { |
| | | if (bindDev.BindCluster == 1026) |
| | | { |
| | | targetList.Add(device); |
| | | oldTargetList.Add(device); |
| | | } |
| | | } |
| | | break; |
| | | case 3: |
| | | if (device.Type == DeviceType.TemperatureSensor) |
| | | { |
| | | var bDev = device as TemperatureSensor; |
| | | if (bDev.SensorDiv == 2) |
| | | { |
| | | targetList.Add(device); |
| | | oldTargetList.Add(device); |
| | | } |
| | | } |
| | | if (device.Type == DeviceType.FreshAirHumiditySensor) |
| | | { |
| | | targetList.Add(device); |
| | | oldTargetList.Add(device); |
| | | } |
| | | if (device.Type == DeviceType.PMSensor) |
| | | { |
| | | if (bindDev.BindCluster == 1029) |
| | | { |
| | | targetList.Add(device); |
| | | oldTargetList.Add(device); |
| | | } |
| | | } |
| | | break; |
| | | case 4: |
| | | //PM2.5 |
| | | if (device.Type == DeviceType.PMSensor) |
| | | { |
| | | if (bindDev.BindCluster == 1066) |
| | | { |
| | | targetList.Add(device); |
| | | oldTargetList.Add(device); |
| | | } |
| | | } |
| | | break; |
| | | } |
| | | |
| | |
| | | { |
| | | Application.RunOnMainThread(() => |
| | | { |
| | | if (supportRoomList.Count != 0) |
| | | { |
| | | RefreshRoomList(); |
| | | } |
| | | |
| | | //首次是否能点击保存 |
| | | if (targetList.Count == 0) |
| | | { |
| | | curControlDev.currentSelectFloorId = BindInfo.GetCurrentSelectFloorId(); |
| | | curControlDev.currentSelectRoomId = null; |
| | | if (BindInfo.GetCurrentSelectFloorIdName() != null) |
| | | { |
| | | Application.RunOnMainThread(() => |
| | | { |
| | | btnFloorText.Text = BindInfo.GetCurrentSelectFloorIdName(); |
| | | }); |
| | | } |
| | | btnFinifh.Enable = false; |
| | | btnFinifh.BackgroundColor = Shared.Common.ZigbeeColor.Current.XMUnSelect; |
| | | } |
| | | else |
| | | { |
| | | foreach (var dev in targetList) |
| | | { |
| | | //获取本地设备列表 |
| | | var localDeviceList = Shared.Common.LocalDevice.Current.listAllDevice; |
| | | var tempDev = localDeviceList.Find(obj => obj.DeviceAddr == dev.DeviceAddr && obj.DeviceEpoint == dev.DeviceEpoint); |
| | | if (tempDev != null) |
| | | { |
| | | //获取设备所属房间 |
| | | var tempDevRoom = HdlRoomLogic.Current.GetRoomByDevice(tempDev); |
| | | if (tempDevRoom != null) |
| | | { |
| | | curControlDev.currentSelectRoomId = tempDevRoom.Id; |
| | | curControlDev.currentSelectFloorId = tempDevRoom.FloorId; |
| | | } |
| | | } |
| | | } |
| | | if (!string.IsNullOrEmpty(curControlDev.currentSelectFloorId)) |
| | | { |
| | | if (BindInfo.GetBindTargetsFloorIdName(curControlDev.currentSelectFloorId) != null) |
| | | { |
| | | btnFloorText.Text = BindInfo.GetBindTargetsFloorIdName(curControlDev.currentSelectFloorId); |
| | | } |
| | | } |
| | | |
| | | btnFinifh.Enable = true; |
| | | btnFinifh.BackgroundColor = Shared.Common.ZigbeeColor.Current.XMBlack; |
| | | } |
| | | |
| | | |
| | | //获取楼层中房间列表 |
| | | if (supportRoomList.Count != 0) |
| | | { |
| | | RefreshRoomList(); |
| | | } |
| | | |
| | | CommonPage.Loading.Hide(); |
| | |
| | | /// <param name="curControlDev"></param> |
| | | void SaveTarget() |
| | | { |
| | | btnFinifh.Enable = false; |
| | | if (targetList.Count == 0) |
| | | { |
| | | //空目标 |
| | |
| | | break; |
| | | case 4: |
| | | //PM2.5 |
| | | removeDevice.BindCluster = 1066; |
| | | break; |
| | | } |
| | | removeDevice.BindMacAddr = bd.DeviceAddr; |
| | |
| | | delDevice.RemoveBindList.Add(removeDevice); |
| | | |
| | | var delResult = new DelDeviceBindResponseAllData(); |
| | | delResult = await curControlDev.DelDeviceBindAsync(delDevice); |
| | | delResult = HdlDeviceBindLogic.Current.DelDeviceBindAsync(delDevice); |
| | | if (delResult != null && delResult.removeBindResultResponseData != null) |
| | | { |
| | | if (delResult.removeBindResultResponseData.Result == 0) |
| | |
| | | btnFinifh.BackgroundColor = Shared.Common.ZigbeeColor.Current.XMBlack; |
| | | this.RemoveFromParent(); |
| | | }); |
| | | |
| | | } |
| | | else |
| | | { |
| | |
| | | }); |
| | | return; |
| | | } |
| | | } |
| | | else |
| | | { |
| | | Application.RunOnMainThread(() => |
| | | { |
| | | new Tip() { MaxWidth = 150, Text = Language.StringByID(R.MyInternationalizationString.OperrateFailed), Direction = AMPopTipDirection.None, CloseTime = 1 }.Show(CommonPage.Instance); |
| | | btnFinifh.Enable = true; |
| | | btnFinifh.BackgroundColor = Shared.Common.ZigbeeColor.Current.XMBlack; |
| | | CommonPage.Loading.Hide(); |
| | | }); |
| | | return; |
| | | } |
| | | } |
| | | } |
| | |
| | | catch (Exception ex) |
| | | { |
| | | var mess = ex.Message; |
| | | Application.RunOnMainThread(() => |
| | | { |
| | | CommonPage.Loading.Hide(); |
| | | }); |
| | | btnFinifh.Enable = true; |
| | | } |
| | | }); |
| | | } |
| | |
| | | { |
| | | foreach (var bd in oldTargetList) |
| | | { |
| | | var delDevice = new DelDeviceBindData(); |
| | | delDevice.DeviceAddr = curControlDev.DeviceAddr; |
| | | delDevice.Epoint = curControlDev.DeviceEpoint; |
| | | |
| | | var removeDevice = new RemoveBindListObj(); |
| | | removeDevice.BindType = 0; |
| | | switch (curDeviceBindType) |
| | | { |
| | | case 1: |
| | | removeDevice.BindCluster = 514; |
| | | break; |
| | | case 2: |
| | | removeDevice.BindCluster = 1026; |
| | | break; |
| | | case 3: |
| | | removeDevice.BindCluster = 1029; |
| | | break; |
| | | case 4: |
| | | //PM2.5 |
| | | break; |
| | | } |
| | | removeDevice.BindMacAddr = bd.DeviceAddr; |
| | | removeDevice.BindEpoint = bd.DeviceEpoint; |
| | | delDevice.RemoveBindList.Add(removeDevice); |
| | | |
| | | var delDevice = DelBindDevice(bd); |
| | | var delResult = new DelDeviceBindResponseAllData(); |
| | | delResult = await curControlDev.DelDeviceBindAsync(delDevice); |
| | | delResult = HdlDeviceBindLogic.Current.DelDeviceBindAsync(delDevice); |
| | | if (delResult == null || delResult.removeBindResultResponseData == null) |
| | | { |
| | | Application.RunOnMainThread(() => |
| | | { |
| | | new Tip() { MaxWidth = 150, Text = Language.StringByID(R.MyInternationalizationString.BindFailed), Direction = AMPopTipDirection.None, CloseTime = 1 }.Show(CommonPage.Instance); |
| | | btnFinifh.Enable = true; |
| | | btnFinifh.BackgroundColor = Shared.Common.ZigbeeColor.Current.XMBlack; |
| | | CommonPage.Loading.Hide(); |
| | | }); |
| | | return; |
| | | } |
| | | if (delResult != null && delResult.removeBindResultResponseData != null) |
| | | { |
| | | if (delResult.removeBindResultResponseData.Result != 0) |
| | | { |
| | | Application.RunOnMainThread(() => |
| | | { |
| | | new Tip() { MaxWidth = 150, Text = Language.StringByID(R.MyInternationalizationString.BindFailed), Direction = AMPopTipDirection.None, CloseTime = 1 }.Show(CommonPage.Instance); |
| | | btnFinifh.Enable = true; |
| | | btnFinifh.BackgroundColor = Shared.Common.ZigbeeColor.Current.XMBlack; |
| | | CommonPage.Loading.Hide(); |
| | | }); |
| | | return; |
| | | } |
| | | } |
| | | } |
| | | } |
| | | else |
| | | { |
| | | //检测已经绑定的目标是否不在本地或者没有分配到任何房间中 |
| | | //此时需要删除已经被绑定到目标,才能继续绑定新目标 |
| | | if (curBindDevice != null) |
| | | { |
| | | var delDevice = DelBindDevice(curBindDevice); |
| | | var delResult = new DelDeviceBindResponseAllData(); |
| | | delResult = HdlDeviceBindLogic.Current.DelDeviceBindAsync(delDevice); |
| | | if (delResult == null || delResult.removeBindResultResponseData == null) |
| | | { |
| | | Application.RunOnMainThread(() => |
| | | { |
| | | new Tip() { MaxWidth = 150, Text = Language.StringByID(R.MyInternationalizationString.BindFailed), Direction = AMPopTipDirection.None, CloseTime = 1 }.Show(CommonPage.Instance); |
| | | btnFinifh.Enable = true; |
| | | btnFinifh.BackgroundColor = Shared.Common.ZigbeeColor.Current.XMBlack; |
| | | CommonPage.Loading.Hide(); |
| | | }); |
| | | return; |
| | | } |
| | | if (delResult != null && delResult.removeBindResultResponseData != null) |
| | | { |
| | | if (delResult.removeBindResultResponseData.Result != 0) |
| | |
| | | break; |
| | | case 4: |
| | | //PM2.5 |
| | | addBindInfo.BindCluster = 1066; |
| | | break; |
| | | } |
| | | addBindInfo.BindType = 0; |
| | | addBindInfo.BindMacAddr = de.DeviceAddr; |
| | | addBindInfo.BindEpoint = de.DeviceEpoint; |
| | | addBindeDev.BindName = de.DeviceEpointName; |
| | | switch (curDeviceBindType) |
| | | { |
| | | case 2: |
| | | if (de.Type == DeviceType.PMSensor) |
| | | { |
| | | addBindeDev.BindName = Common.LocalDevice.Current.GetDeviceEpointName(de) + "-" + Language.StringByID(R.MyInternationalizationString.TemperatureSensor); |
| | | } |
| | | break; |
| | | case 3: |
| | | if (de.Type == DeviceType.PMSensor) |
| | | { |
| | | addBindeDev.BindName = Common.LocalDevice.Current.GetDeviceEpointName(de) + "-" + Language.StringByID(R.MyInternationalizationString.HumiditySensor); |
| | | } |
| | | break; |
| | | } |
| | | addBindeDev.BindList.Add(addBindInfo); |
| | | bindName = de.DeviceEpointName; |
| | | } |
| | | |
| | | var dev = new AddedDeviceBindResponseAllData(); |
| | | dev = await curControlDev.AddDeviceBindAsync(addBindeDev); |
| | | dev = HdlDeviceBindLogic.Current.AddDeviceBindAsync(addBindeDev); |
| | | if (dev == null || dev.addedDeviceBindResponseData == null) |
| | | { |
| | | Application.RunOnMainThread(() => |
| | |
| | | { |
| | | if (dev.addedDeviceBindResponseData.Result == 0) |
| | | { |
| | | curControlDev.bindList = dev.addedDeviceBindResponseData.BindList; |
| | | targetList.Clear(); |
| | | |
| | | switch (curDeviceBindType) |
| | | { |
| | | case 1: |
| | | if (actionFreshAirTarget != null) |
| | | { |
| | | actionFreshAirTarget(bindName); |
| | | actionFreshAirTarget(addBindeDev.BindName); |
| | | } |
| | | break; |
| | | case 2: |
| | | if (actionTemperatureTarget != null) |
| | | { |
| | | actionTemperatureTarget(bindName); |
| | | actionTemperatureTarget(addBindeDev.BindName); |
| | | } |
| | | break; |
| | | case 3: |
| | | if (actionHumidityTarget != null) |
| | | { |
| | | actionHumidityTarget(bindName); |
| | | actionHumidityTarget(addBindeDev.BindName); |
| | | } |
| | | break; |
| | | case 4: |
| | | if (actionPMTarget != null) |
| | | { |
| | | actionPMTarget(bindName); |
| | | actionPMTarget(addBindeDev.BindName); |
| | | } |
| | | break; |
| | | } |
| | |
| | | } |
| | | catch (Exception ex) |
| | | { |
| | | Application.RunOnMainThread(() => |
| | | { |
| | | CommonPage.Loading.Hide(); |
| | | }); |
| | | btnFinifh.Enable = true; |
| | | var mess = ex.Message; |
| | | } |
| | | }); |
| | | } |
| | | } |
| | | |
| | | /// <summary> |
| | | /// 当前被绑定设备所属楼层和房间 |
| | | /// </summary> |
| | | /// <param name="bindDev"></param> |
| | | void BindDevInfo(CommonDevice bindDev) |
| | | { |
| | | if (bindDev == null) |
| | | { |
| | | return; |
| | | } |
| | | //获取本地设备列表 |
| | | var localDeviceList = Shared.Common.LocalDevice.Current.listAllDevice; |
| | | var tempDev = localDeviceList.Find(obj => obj.DeviceAddr == bindDev.DeviceAddr && obj.DeviceEpoint == bindDev.DeviceEpoint); |
| | | if (tempDev != null) |
| | | { |
| | | //获取设备所属房间 |
| | | var tempDevRoom = HdlRoomLogic.Current.GetRoomByDevice(tempDev); |
| | | if (tempDevRoom != null) |
| | | { |
| | | curControlDev.currentSelectRoomId = tempDevRoom.Id; |
| | | curControlDev.currentSelectFloorId = tempDevRoom.FloorId; |
| | | } |
| | | } |
| | | } |
| | | |
| | |
| | | } |
| | | } |
| | | return exist; |
| | | } |
| | | |
| | | /// <summary> |
| | | /// 检测已经绑定的目标是否不在本地或者没有分配到任何房间中 |
| | | /// </summary> |
| | | /// <returns></returns> |
| | | private DelDeviceBindData DelBindDevice(CommonDevice bd) |
| | | { |
| | | var delDevice = new DelDeviceBindData(); |
| | | delDevice.DeviceAddr = curControlDev.DeviceAddr; |
| | | delDevice.Epoint = curControlDev.DeviceEpoint; |
| | | |
| | | var removeDevice = new RemoveBindListObj(); |
| | | removeDevice.BindType = 0; |
| | | switch (curDeviceBindType) |
| | | { |
| | | case 1: |
| | | removeDevice.BindCluster = 514; |
| | | break; |
| | | case 2: |
| | | removeDevice.BindCluster = 1026; |
| | | break; |
| | | case 3: |
| | | removeDevice.BindCluster = 1029; |
| | | break; |
| | | case 4: |
| | | //PM2.5 |
| | | removeDevice.BindCluster = 1066; |
| | | break; |
| | | } |
| | | removeDevice.BindMacAddr = bd.DeviceAddr; |
| | | removeDevice.BindEpoint = bd.DeviceEpoint; |
| | | delDevice.RemoveBindList.Add(removeDevice); |
| | | return delDevice; |
| | | } |
| | | |
| | | /// <summary> |
| | |
| | | foreach (var de in room.ListDevice) |
| | | { |
| | | var device = LocalDevice.Current.GetDevice(de); |
| | | |
| | | if (device != null) |
| | | { |
| | | //获取设备类型的 |
| | |
| | | } |
| | | break; |
| | | case 2: |
| | | foreach (var de in room.ListDevice) |
| | | { |
| | | var device = LocalDevice.Current.GetDevice(de); |
| | | if (device != null) |
| | | { |
| | | if (device.Type == DeviceType.TemperatureSensor) |
| | | { |
| | | roomIncludeMatchDevice.Add(device); |
| | | } |
| | | } |
| | | } |
| | | roomIncludeMatchDevice = GetMatchTemperatureSensorDevice(room); |
| | | break; |
| | | case 3: |
| | | roomIncludeMatchDevice = GetMatchHumiditySensorDevice(room); |
| | | foreach (var de in room.ListDevice) |
| | | { |
| | | var device = LocalDevice.Current.GetDevice(de); |
| | |
| | | } |
| | | break; |
| | | case 4: |
| | | foreach (var de in room.ListDevice) |
| | | { |
| | | var device = LocalDevice.Current.GetDevice(de); |
| | | if (device != null) |
| | | { |
| | | if (device.Type == DeviceType.PMSensor) |
| | | { |
| | | roomIncludeMatchDevice.Add(device); |
| | | } |
| | | } |
| | | } |
| | | break; |
| | | } |
| | | |
| | |
| | | { |
| | | continue; |
| | | } |
| | | } |
| | | |
| | | if (!string.IsNullOrEmpty(room.FloorId)) |
| | | { |
| | | //有楼层 |
| | | if (room.FloorId == curControlDev.currentSelectFloorId) |
| | | if (!string.IsNullOrEmpty(room.FloorId)) |
| | | { |
| | | //有楼层 |
| | | if (room.FloorId == curControlDev.currentSelectFloorId) |
| | | { |
| | | roomTempList.Add(room); |
| | | } |
| | | } |
| | | else |
| | | { |
| | | //没有楼层 |
| | | roomTempList.Add(room); |
| | | } |
| | | } |
| | | else |
| | | { |
| | | //没有楼层 |
| | | roomTempList.Add(room); |
| | | } |
| | | } |
| | | return roomTempList; |
| | | } |
| | | |
| | | /// <summary> |
| | | /// 匹配温度传感器 |
| | | /// </summary> |
| | | /// <param name="room"></param> |
| | | List<CommonDevice> GetMatchTemperatureSensorDevice(Room room) |
| | | { |
| | | List<CommonDevice> roomIncludeMatchTempDevice = new List<CommonDevice>(); |
| | | foreach (var de in room.ListDevice) |
| | | { |
| | | var device = LocalDevice.Current.GetDevice(de); |
| | | if (device != null) |
| | | {
|
| | | //电池设备不支持绑定
|
| | | if (device.ZigbeeType != 1)
|
| | | {
|
| | | continue;
|
| | | } |
| | | if (device.Type == DeviceType.TemperatureSensor) |
| | | { |
| | | var dev = device as TemperatureSensor; |
| | | if (dev.SensorDiv == 1) |
| | | { |
| | | roomIncludeMatchTempDevice.Add(device); |
| | | } |
| | | } |
| | | else if (device.Type == DeviceType.PMSensor) |
| | | { |
| | | var dev = device as PMSensor; |
| | | foreach (var clu in dev.InClusterList) |
| | | { |
| | | if (clu.InCluster == 1026) |
| | | { |
| | | roomIncludeMatchTempDevice.Add(device); |
| | | } |
| | | } |
| | | } |
| | | } |
| | | } |
| | | return roomIncludeMatchTempDevice; |
| | | } |
| | | |
| | | /// <summary> |
| | | /// 匹配湿度传感器 |
| | | /// </summary> |
| | | /// <param name="room"></param> |
| | | List<CommonDevice> GetMatchHumiditySensorDevice(Room room) |
| | | { |
| | | List<CommonDevice> roomIncludeMatchHumpDevice = new List<CommonDevice>(); |
| | | foreach (var de in room.ListDevice) |
| | | { |
| | | var device = LocalDevice.Current.GetDevice(de); |
| | | if (device != null) |
| | | {
|
| | | //电池设备不支持绑定
|
| | | if (device.ZigbeeType != 1)
|
| | | {
|
| | | continue;
|
| | | } |
| | | if (device.Type == DeviceType.TemperatureSensor) |
| | | { |
| | | var dev = device as TemperatureSensor; |
| | | if (dev.SensorDiv == 2) |
| | | { |
| | | roomIncludeMatchHumpDevice.Add(device); |
| | | } |
| | | } |
| | | else if (device.Type == DeviceType.PMSensor) |
| | | { |
| | | var dev = device as PMSensor; |
| | | foreach (var clu in dev.InClusterList) |
| | | { |
| | | if (clu.InCluster == 1029) |
| | | { |
| | | roomIncludeMatchHumpDevice.Add(device); |
| | | } |
| | | } |
| | | } |
| | | } |
| | | } |
| | | return roomIncludeMatchHumpDevice; |
| | | } |
| | | |
| | | /// <summary> |
| | |
| | | { |
| | | continue; |
| | | } |
| | | foreach (var deviceKeys in r.ListDevice) |
| | | var deviceListTemp = GetMatchTemperatureSensorDevice(r); |
| | | foreach (var dev in deviceListTemp) |
| | | { |
| | | var device = LocalDevice.Current.GetDevice(deviceKeys); |
| | | if (device != null) |
| | | { |
| | | if (device.Type == DeviceType.TemperatureSensor) |
| | | { |
| | | currentPanelBindSupportDeviceListTemp.Add(device); |
| | | } |
| | | } |
| | | currentPanelBindSupportDeviceListTemp.Add(dev); |
| | | } |
| | | } |
| | | break; |
| | |
| | | if (r.ListDevice.Count == 0) |
| | | { |
| | | continue; |
| | | } |
| | | var deviceListTemp = GetMatchHumiditySensorDevice(r); |
| | | foreach (var dev in deviceListTemp) |
| | | { |
| | | currentPanelBindSupportDeviceListTemp.Add(dev); |
| | | } |
| | | foreach (var deviceKeys in r.ListDevice) |
| | | { |
| | |
| | | } |
| | | break; |
| | | case 4: |
| | | foreach (var r in supportRoomList) |
| | | { |
| | | if (r.ListDevice.Count == 0) |
| | | { |
| | | continue; |
| | | } |
| | | foreach (var deviceKeys in r.ListDevice) |
| | | { |
| | | var device = LocalDevice.Current.GetDevice(deviceKeys); |
| | | if (device != null) |
| | | { |
| | | if (device.Type == DeviceType.PMSensor) |
| | | { |
| | | currentPanelBindSupportDeviceListTemp.Add(device); |
| | | } |
| | | } |
| | | } |
| | | } |
| | | break; |
| | | } |
| | | return currentPanelBindSupportDeviceListTemp; |
| | |
| | | } |
| | | break; |
| | | case 2: |
| | | foreach (var deviceKeys in curRoom.ListDevice) |
| | | { |
| | | var device = LocalDevice.Current.GetDevice(deviceKeys); |
| | | if (device != null) |
| | | { |
| | | if (device.Type == DeviceType.TemperatureSensor) |
| | | { |
| | | curRoomDeviceListTemp.Add(device); |
| | | } |
| | | } |
| | | } |
| | | curRoomDeviceListTemp = GetMatchTemperatureSensorDevice(curRoom); |
| | | break; |
| | | case 3: |
| | | curRoomDeviceListTemp = GetMatchHumiditySensorDevice(curRoom); |
| | | foreach (var deviceKeys in curRoom.ListDevice) |
| | | { |
| | | var device = LocalDevice.Current.GetDevice(deviceKeys); |
| | |
| | | } |
| | | break; |
| | | case 4: |
| | | foreach (var deviceKeys in curRoom.ListDevice) |
| | | { |
| | | var device = LocalDevice.Current.GetDevice(deviceKeys); |
| | | if (device != null) |
| | | { |
| | | if (device.Type == DeviceType.PMSensor) |
| | | { |
| | | curRoomDeviceListTemp.Add(device); |
| | | } |
| | | } |
| | | } |
| | | break; |
| | | } |
| | | return curRoomDeviceListTemp; |