| | |
| | | /// 构造函数 |
| | | /// </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> |
| | |
| | | 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; |
| | | } |
| | | } |
| | | |
| | | EventHandler<MouseEventArgs> eHandlerRoom = (sender, e) => |
| | | { |
| | | if (!btnRoom.IsSelected) |
| | |
| | | line2.Visible = false; |
| | | } |
| | | |
| | | switch (curDeviceBindType) |
| | | { |
| | | case 1: |
| | | devicePic.UnSelectedImagePath = "Device/FreshAirEpoint.png"; |
| | | break; |
| | | case 2: |
| | | devicePic.UnSelectedImagePath = "Device/SensorTemperature.png"; |
| | | break; |
| | | case 3: |
| | | devicePic.UnSelectedImagePath = "Device/SensorHumidity.png"; |
| | | break; |
| | | case 4: |
| | | devicePic.UnSelectedImagePath = "Device/FreshAirEpoint.png"; |
| | | break; |
| | | } |
| | | #endregion |
| | | |
| | | string mianKey = device.DeviceAddr + device.DeviceEpoint; |
| | |
| | | btnFloorText.Text = dicFloorList[floorId]; |
| | | |
| | | //获取楼层中房间列表 |
| | | supportRoomList = GetFloorRoomList(curFloorId); |
| | | supportRoomList = GetFloorRoomList(); |
| | | if (!btnMethodText.IsSelected) |
| | | { |
| | | if (oldbutton != null) |
| | |
| | | { |
| | | CommonPage.Loading.Start(""); |
| | | }); |
| | | //获取被绑目标等信息 |
| | | BindDevInfo(curBindDevice); |
| | | |
| | | //获取楼层 |
| | | dicFloorList = HdlRoomLogic.Current.GetFloorSortList(); |
| | | //获取楼层中房间列表 |
| | | supportRoomList = GetFloorRoomList(curControlDev.currentSelectFloorId); |
| | | supportRoomList = GetFloorRoomList(); |
| | | |
| | | //获取所有房间中匹配的能绑的目标 |
| | | currentPanelSupportBindDeviceList = GetAllRoomSupportDeviceList(); |
| | |
| | | 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); |
| | | } |
| | | } |
| | | 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); |
| | |
| | | if (targetList.Count == 0) |
| | | { |
| | | curControlDev.currentSelectFloorId = BindInfo.GetCurrentSelectFloorId(); |
| | | curControlDev.currentSelectRoomId = null; |
| | | if (BindInfo.GetCurrentSelectFloorIdName() != null) |
| | | { |
| | | Application.RunOnMainThread(() => |
| | |
| | | } |
| | | |
| | | /// <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; |
| | | } |
| | | } |
| | | } |
| | | |
| | | /// <summary> |
| | | /// 检测目标是否被绑定过 |
| | | /// </summary> |
| | | /// <returns></returns> |
| | |
| | | } |
| | | 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); |
| | |
| | | { |
| | | 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.Type == DeviceType.TemperatureSensor) |
| | | { |
| | | var dev = device as TemperatureSensor; |
| | | if (dev.SensorDiv == 1) |
| | | { |
| | | 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.Type == DeviceType.TemperatureSensor) |
| | | { |
| | | var dev = device as TemperatureSensor; |
| | | if (dev.SensorDiv == 2) |
| | | { |
| | | roomIncludeMatchHumpDevice.Add(device); |
| | | } |
| | | } |
| | | } |
| | | } |
| | | return roomIncludeMatchHumpDevice; |
| | | } |
| | | |
| | | /// <summary> |
| | | /// 获取楼层对应的房间列表 |
| | | /// </summary> |
| | | /// <returns></returns> |
| | | private List<Room> GetFloorRoomList(string floorId) |
| | | private List<Room> GetFloorRoomList() |
| | | { |
| | | supportRoomList.Clear(); |
| | | var supportRoomListTemp = new List<Room>(); |
| | |
| | | { |
| | | if (string.IsNullOrEmpty(room.FloorId)) |
| | | { |
| | | if (room.FloorId != floorId) |
| | | { |
| | | continue; |
| | | } |
| | | if (room.IsLove) |
| | | { |
| | | continue; |
| | |
| | | { |
| | | 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 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); |