WJC
2020-03-23 bba578c2f0acf2eca747edcb69426771e0cadd32
ZigbeeApp/Shared/Common/Device.cs
@@ -475,9 +475,28 @@
                //备份数据
                await HdlGatewayLogic.Current.UpLoadDeviceBackupDataToGateway(device, GatewayBackupEnum.AMac名称, newMacName);
                //如果它只有一个回路,则更改端点名字
                if (this.dicDeviceEpoint.ContainsKey(device.DeviceAddr) == true && this.dicDeviceEpoint[device.DeviceAddr].Count == 1)
                if (this.dicDeviceEpoint.ContainsKey(device.DeviceAddr) == true)
                {
                    //只有一个端点
                    if (this.dicDeviceEpoint[device.DeviceAddr].Count == 1)
                {
                    return await this.ReName(device, newMacName);
                    }
                    //如果它有两个端点时,pir传感器特殊处理
                    else if (this.dicDeviceEpoint[device.DeviceAddr].Count == 2)
                    {
                        var myType = this.GetMyDeviceEnumInfo(listDevice);
                        if (myType.ConcreteType == DeviceConcreteType.Sensor_Pir)
                        {
                            foreach (var myDevice in listDevice)
                            {
                                if (myDevice.Type == DeviceType.IASZone)
                                {
                                    return await this.ReName(myDevice, newMacName);
                                }
                            }
                        }
                    }
                }
            }
            return true;
@@ -1145,6 +1164,33 @@
        }
        /// <summary>
        /// 设置设备【图标】到指定的控件(注意,此函数设置的选择状态的图片是白色的)
        /// </summary>
        /// <param name="btnIcon">控件对象</param>
        /// <param name="device">设备对象</param>
        /// <returns></returns>
        public void SetDeviceIconToControl2(Button btnIcon, CommonDevice device)
        {
            if (device == null)
            {
                btnIcon.UnSelectedImagePath = "Device/ThirdPartyDevice.png";
                return;
            }
            string unSelectFilePath = device.IconPath;
            string selectFilePath = unSelectFilePath.Replace(".png", "Selected2.png");
            //获取设备【图标】
            if (btnIcon.UnSelectedImagePath != unSelectFilePath)
            {
                btnIcon.UnSelectedImagePath = unSelectFilePath;
            }
            if (btnIcon.SelectedImagePath != selectFilePath)
            {
                btnIcon.SelectedImagePath = selectFilePath;
            }
        }
        /// <summary>
        /// 获取设备【图标】
        /// </summary>
        /// <param name="listdevice">设备对象</param>
@@ -1397,6 +1443,9 @@
                return null;
            }
            string modelKeys = device.ModelIdentifier;
            //交换一下模块ID(麦乐克那边的传感器)
            this.ChangedDeviceModeId(ref modelKeys);
            if (this.dicDeviceModelIdEnum.ContainsKey(modelKeys) == false)
            {
                //没有匹配到模块ID,则直接走第三方设备的判断
@@ -1814,6 +1863,80 @@
                return null;
            }
            return HdlRoomLogic.Current.GetRoomById(this.dicDeviceRoomId[device.DeviceAddr]);
        }
        #endregion
        #region ■ 设备排序___________________________
        /// <summary>
        /// 设备排序
        /// </summary>
        /// <param name="i_listDevice">请确保这个东西已经按mac和端点排序了</param>
        /// <returns></returns>
        public List<CommonDevice> SortDeviceByBelongType(List<CommonDevice> i_listDevice)
        {
            //获取排序规则
            var listRule = this.GetBelongTypeSortRule();
            var dicDevice = new Dictionary<DeviceBeloneType, List<CommonDevice>>();
            dicDevice[DeviceBeloneType.A未知设备] = new List<CommonDevice>();
            foreach (var device in i_listDevice)
            {
                //获取所属类型
                var typeInfo = this.GetDeviceBelongEnumInfo(device);
                if (listRule.Contains(typeInfo.BeloneType) == false)
                {
                    //不在排序范围内,都丢在最后面
                    dicDevice[DeviceBeloneType.A未知设备].Add(device);
                    continue;
                }
                if (dicDevice.ContainsKey(typeInfo.BeloneType) == false)
                {
                    dicDevice[typeInfo.BeloneType] = new List<CommonDevice>();
                }
                dicDevice[typeInfo.BeloneType].Add(device);
            }
            var listSort = new List<CommonDevice>();
            foreach (var myType in listRule)
            {
                //根据规则顺序,添加设备
                if (dicDevice.ContainsKey(myType) == false || dicDevice[myType].Count == 0)
                {
                    continue;
                }
                listSort.AddRange(dicDevice[myType]);
            }
            return listSort;
        }
        /// <summary>
        /// 获取设备所属类型的的排序规则
        /// </summary>
        /// <returns></returns>
        public HashSet<DeviceBeloneType> GetBelongTypeSortRule()
        {
            //谁在前面,谁就优先显示
            var list = new HashSet<DeviceBeloneType>();
            list.Add(DeviceBeloneType.A灯光);
            list.Add(DeviceBeloneType.A彩灯);
            list.Add(DeviceBeloneType.A开关);
            list.Add(DeviceBeloneType.A插座);
            list.Add(DeviceBeloneType.A调光器);
            list.Add(DeviceBeloneType.A窗帘);
            list.Add(DeviceBeloneType.A空调);
            list.Add(DeviceBeloneType.A继电器);
            list.Add(DeviceBeloneType.A干接点);
            list.Add(DeviceBeloneType.A智能门锁);
            list.Add(DeviceBeloneType.A智能空开);
            list.Add(DeviceBeloneType.A传感器);
            //其他的看着办呗,都是排在后面的,都归为这个属性
            list.Add(DeviceBeloneType.A未知设备);
            return list;
        }
        #endregion
@@ -2261,7 +2384,7 @@
            //1、在这里填写上模块ID,然后是 DeviceConcreteType ,然后是 DeviceBeloneType
            //2、然后在最下面的【自定义设备类型】折叠栏里添加【设备的具体类型】,【设备的所属类型】
            //3、以设备的具体类型为名字(去掉【-】)添加设备的【所属图片】,【真实物理图片】。回路图片需要特殊处理
            //4、添加R文件,添加Language文件
            //4、添加R文件(uDeviceModelId),添加Language文件
            //5、如果需要共有图片,则在这个函数的最底下添加
            //*********************************************************************
@@ -2285,6 +2408,7 @@
            this.dicDeviceModelIdEnum["MP8B/TILE-ZB.18"] = "242-200";//方悦四开八控面板
            this.dicDeviceModelIdEnum["MPFA/TILE-ZB.18"] = "250-200";//方悦新风面板
            this.dicDeviceModelIdEnum["MPTE3/TILE-ZB.18"] = "253-200";//方悦环境面板
            this.dicDeviceModelIdEnum["MP2W/TILE-ZB.18"] = "256-200";//窗帘面板
            //=========★★PIR传感器类(1200-1299)★★=========
            this.dicDeviceModelIdEnum["MSPIR01-ZB.10"] = "1200-1200";//pir传感器220
@@ -2299,12 +2423,14 @@
            //=========★★继电器类(2300-2499)★★=========
            this.dicDeviceModelIdEnum["MPR0310-ZB.10"] = "2300-2300";//3路继电器小模块
            this.dicDeviceModelIdEnum["MFA01-ZB1.0"] = "2310-2300";//方悦新风小模块
            //=========★★调光器类(2500-2799)★★=========
            this.dicDeviceModelIdEnum["MPD0101-ZB.10"] = "2500-2500";//1路调光器小模块
            //=========★★智能门锁类(2800-????)★★=========
            this.dicDeviceModelIdEnum["H06C"] = "2800-2800";//智能门锁(H06C)
            this.dicDeviceModelIdEnum["S-one"] = "2802-2800";//智能门锁(S-one)
            //=========★★空调类(3600-3899)★★=========
            this.dicDeviceModelIdEnum["MAC/GW-ZB.10"] = "3600-3600";//zigbee空调网关模块
@@ -2340,6 +2466,8 @@
            this.dicPictrueShard["ButtonPanel_SimpleFour"] = "ButtonPanel_Four";//简约4按键面板 沿用 4按键的图标
            this.dicPictrueShard["ButtonPanel_SimpleThree"] = "ButtonPanel_Three";//简约3按键面板 沿用 3按键的图标
            this.dicPictrueShard["ButtonPanel_SimpleTwo"] = "ButtonPanel_Two";//简约2按键面板 沿用 2按键的图标
            this.dicPictrueShard["IntelligentLocks_Sone"] = "IntelligentLocks_H06C";//S-one的门锁图片沿用H06C的图标
        }
        #endregion
@@ -2434,11 +2562,15 @@
        /// <summary>
        /// 方悦新风面板 镜像id:250
        /// </summary>
        ButtonPanel_FangyueNewWind = 250,
        ButtonPanel_FangyueFreshAir = 250,
        /// <summary>
        /// 方悦环境面板 镜像id:253
        /// </summary>
        ButtonPanel_FangyueEnvironment = 253,
        /// <summary>
        /// 窗帘面板 镜像id:256
        /// </summary>
        ButtonPanel_Curtain = 256,
        //=========★★PIR传感器类(1200-1299)★★=========
        /// <summary>
@@ -2505,6 +2637,10 @@
        /// 三路继电器 镜像id:2300
        /// </summary>
        Relay_ThreeLoad = 2300,
        /// <summary>
        /// 方悦新风小模块 镜像id:2310
        /// </summary>
        Relay_FangyueFreshAirModul = 2310,
        //=========★★调光器类(2500-2799)★★=========
        /// <summary>
@@ -2525,6 +2661,10 @@
        /// H06C
        /// </summary>
        IntelligentLocks_H06C = 2800,
        /// <summary>
        /// S-one
        /// </summary>
        IntelligentLocks_Sone = 2802,
        //=========★★彩灯类(????-????)★★=========
        /// <summary>