WJC
2020-04-02 94e4e5b9fd3da964c44b7b14227d6fe2bbb426d7
ZigbeeApp/Shared/Common/Device.cs
@@ -37,7 +37,7 @@
            }
        }
        /// <summary>
        /// 本地所有设备的缓存(排序)
        /// 本地所有设备的缓存
        /// </summary>
        public List<CommonDevice> listAllDevice
        {
@@ -45,12 +45,14 @@
            {
                lock (dicAllDevice)
                {
                    var list = new List<CommonDevice>();
                    foreach (var device in dicAllDevice.Values)
                    //先获取全部的Mac
                    var listMac = new List<string>();
                    foreach (var strMac in this.dicDeviceEpoint.Keys)
                    {
                        list.Add(device);
                        listMac.Add(strMac);
                    }
                    return list;
                    //根据MAC地址,获取全部回路的设备对象(强制排序)
                    return this.GetDevicesByMac(listMac);
                }
            }
        }
@@ -71,6 +73,10 @@
        /// 需要转换的设备的模块ID(keys:旧模块ID,value:新模块ID)
        /// </summary>
        private Dictionary<string, string> dicDeviceModelIdChanged = null;
        /// <summary>
        /// 图片共有(keys:指定设备的具体类型 value:指定共有对象的具体类型)
        /// </summary>
        private Dictionary<string, string> dicPictrueShard = null;
        /// <summary>
        /// 本地所有设备的缓存(非公开)
        /// </summary>
@@ -107,8 +113,14 @@
            List<string> listFile = this.GetAllDeviceFile();
            foreach (string file in listFile)
            {
                CommonDevice device = null;
                //反序列化为指定的类,不然数据会丢失而导致无法强转
                var device = ZigBee.Device.CommonDevice.CommonDeviceByFilePath(file);
                try
                {
                    device = CommonDevice.CommonDeviceByFilePath(file);
                }
                catch (Exception ex) { HdlLogLogic.Current.WriteLog(ex); }
                if (device == null || device.CurrentGateWayId == null)
                {
#if DEBUG
@@ -213,26 +225,34 @@
        #region ■ 添加设备___________________________
        /// <summary>
        /// 将指定网关的设备存入缓存中(从新获取镜像)
        /// <para>将指定网关的设备存入缓存中(从新获取镜像)</para>
        /// <para>-1:异常 1:正常 2:设备信息缺损</para>
        /// </summary>
        /// <param name="zbGateway">网关对象</param>
        /// <param name="deviceComingAction">接收到设备时的事件,设备对象为null时,代表接收完成</param>
        /// <returns>一直返回true</returns>
        public bool SetDeviceToMemmoryByGateway(ZbGateway zbGateway, Action<CommonDevice> deviceComingAction = null)
        public int SetDeviceToMemmoryByGateway(ZbGateway zbGateway)
        {
            //从网关获取全部的设备
            int statu = 0;
            List<CommonDevice> listDevice = new List<CommonDevice>();
            List<CommonDevice> list = this.GetDeviceListFromGateway(zbGateway, true, deviceComingAction);
            List<CommonDevice> list = this.GetDeviceListFromGateway(zbGateway, ref statu, true);
            if (list == null)
            {
                return false;
                return -1;
            }
            listDevice.AddRange(list);
            //获取这个网关的本地所有设备
            string gwID = HdlGatewayLogic.Current.GetGatewayId(zbGateway);
            List<CommonDevice> listLocalDevices = this.GetDeviceByGatewayID(gwID);
            //获取ota设备
            foreach (var ota in this.dicOTADevice.Values)
            {
                if (ota.CurrentGateWayId == gwID)
                {
                    listLocalDevices.Add(ota);
                }
            }
            Dictionary<string, CommonDevice> dicExist = new Dictionary<string, CommonDevice>();
            foreach (var device in listLocalDevices)
            {
@@ -264,25 +284,13 @@
            for (int i = 0; i < listDevice.Count; i++)
            {
                var device = listDevice[i];
                //对未命名的设备重新命名
                if (this.GetSimpleEpointName(device) == string.Empty)
                //对未命名的虚拟设备重新命名
                if (device.DriveCode > 0 && this.GetSimpleEpointName(device) == string.Empty)
                {
                    //根据设备类型获取名称
                    var dName = this.GetDeviceObjectText(new List<CommonDevice>() { device }, false);
                    //虚拟设备的话,附加回路号
                    if (device.DriveCode > 0)
                    {
                        //在端点名字的后面附加【回路】字样
                        dName += "(" + device.DeviceEpoint + Language.StringByID(R.MyInternationalizationString.uDeviceCircuit) + ")";
                    }
                    //多回路设备的话,附加回路号
                    else if (dicDeviceEpoint.ContainsKey(device.DeviceAddr) == true && dicDeviceEpoint[device.DeviceAddr].Count > 1)
                    {
                        var arry = dName.Split(new string[] { "(" }, StringSplitOptions.RemoveEmptyEntries);
                        dName = arry[0].Trim();
                        //在端点名字的后面附加【回路】字样
                        dName += "(" + device.DeviceEpoint + Language.StringByID(R.MyInternationalizationString.uDeviceCircuit) + ")";
                    }
                    //在端点名字的后面附加【回路】字样
                    dName += "(" + device.DeviceEpoint + Language.StringByID(R.MyInternationalizationString.uDeviceCircuit) + ")";
                    HdlThreadLogic.Current.RunThread(async () =>
                    {
@@ -291,14 +299,26 @@
                }
            }
            //如果本地和网关的设备不一致的时候,暂时删除本地的设备
            //注意:只是删除设备文件,房间内容什么的还存在着
            foreach (var device in dicExist.Values)
            //只有完全获取的时候,才会去处理删除的问题
            if (statu != 1)
            {
                this.DeleteMemmoryDevice(device, false);
                return statu;
            }
            return true;
            //如果本地和网关的设备不一致的时候,删除本地的设备
            foreach (var device in dicExist.Values)
            {
                if (device is OTADevice)
                {
                    this.DeleteMemmoryOtaDevice(device.DeviceAddr);
                }
                else
                {
                    this.DeleteMemmoryDevice(device, true);
                }
            }
            return statu;
        }
        /// <summary>
@@ -454,6 +474,30 @@
                }
                //备份数据
                await HdlGatewayLogic.Current.UpLoadDeviceBackupDataToGateway(device, GatewayBackupEnum.AMac名称, newMacName);
                //如果它只有一个回路,则更改端点名字
                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;
        }
@@ -467,15 +511,25 @@
            lock (dicAllDevice)
            {
                string mainKeys = this.GetDeviceMainKeys(device);
                if (this.dicAllDevice.ContainsKey(mainKeys) == false)
                if (this.dicAllDevice.ContainsKey(mainKeys) == true)
                {
                    return;
                }
                this.dicAllDevice[mainKeys] = device;
                device.ReSave();
                    //一般设备
                    this.dicAllDevice[mainKeys] = device;
                    device.ReSave();
                //添加自动备份
                HdlAutoBackupLogic.AddOrEditorFile(device.FilePath);
                    //添加自动备份
                    HdlAutoBackupLogic.AddOrEditorFile(device.FilePath);
                }
                else if (this.dicOTADevice.ContainsKey(mainKeys) == true)
                {
                    //Ota设备
                    this.dicOTADevice[mainKeys] = (OTADevice)device;
                    device.ReSave();
                    //添加自动备份
                    HdlAutoBackupLogic.AddOrEditorFile(device.FilePath);
                }
            }
        }
@@ -507,11 +561,14 @@
                return false;
            }
            //删除文件
            //删除缓存的Ota设备
            this.DeleteMemmoryOtaDevice(listdevice[0].DeviceAddr);
            //删除一般设备文件
            foreach (CommonDevice device in listdevice)
            {
                this.DeleteMemmoryDevice(device);
            }
            if (this.dicDeviceRoomId.ContainsKey(listdevice[0].DeviceAddr) == true)
            {
                //移除真实设备的房间索引
@@ -522,12 +579,20 @@
        }
        /// <summary>
        /// 删除缓存的设备
        /// 删除缓存的一般设备
        /// </summary>
        /// <param name="device">设备对象</param>
        /// <param name="deleteRoom">是否从房间删除</param>
        public void DeleteMemmoryDevice(CommonDevice device, bool deleteRoom = true)
        {
            if (deleteRoom == true && HdlRoomLogic.Current.CurrentRoom != null)
            {
                //从房间中删除
                HdlRoomLogic.Current.DeleteDevice(device);
                //删除我的喜爱的设备
                HdlRoomLogic.Current.DeleteLoveDevice(device);
            }
            //删除缓存
            string mainKeys = this.GetDeviceMainKeys(device);
            lock (dicAllDevice)
@@ -535,6 +600,11 @@
                if (this.dicAllDevice.ContainsKey(mainKeys) == true)
                {
                    this.dicAllDevice.Remove(mainKeys);
                }
                if (this.dicDeviceEpoint.ContainsKey(device.DeviceAddr) == true)
                {
                    //变更端点数
                    this.dicDeviceEpoint[device.DeviceAddr].Remove(device.DeviceEpoint);
                }
            }
@@ -555,9 +625,17 @@
                    HdlAutoBackupLogic.DeleteFile(device.FilePath);
                }
            }
        }
        /// <summary>
        /// 删除缓存的Ota设备
        /// </summary>
        /// <param name="macAdrr"></param>
        /// <param name="ePoint"></param>
        public void DeleteMemmoryOtaDevice(string macAdrr, int ePoint = 200)
        {
            //删除200端口文件
            string otaKeys = this.GetDeviceMainKeys(device.DeviceAddr, 200);
            string otaKeys = this.GetDeviceMainKeys(macAdrr, ePoint);
            if (this.dicOTADevice.ContainsKey(otaKeys) == true)
            {
                string otaFile = this.dicOTADevice[otaKeys].FilePath;
@@ -566,23 +644,17 @@
                    if (UserCenterResourse.UserInfo.AuthorityNo == 3)
                    {
                        //成员的话,直接删除,没有商量的余地
                        Global.DeleteFilebyHomeId(filePath);
                        Global.DeleteFilebyHomeId(otaFile);
                    }
                    else
                    {
                        //变更:搞掉它,不留了
                        Global.DeleteFilebyHomeId(filePath);
                        Global.DeleteFilebyHomeId(otaFile);
                        //删除自动备份
                        HdlAutoBackupLogic.DeleteFile(otaFile);
                    }
                }
                this.dicOTADevice.Remove(otaKeys);
            }
            if (deleteRoom == true && Room.CurrentRoom != null)
            {
                //从房间中删除
                Room.CurrentRoom.DeleteDevice(device);
            }
        }
@@ -660,24 +732,23 @@
        /// <summary>
        /// 根据网关ID获取所有的设备
        /// </summary>
        /// <param name="gwId">网关ID</param>
        /// <param name="gwId">网关ID</param>>
        /// <returns></returns>
        public List<CommonDevice> GetDeviceByGatewayID(string gwId)
        {
            List<CommonDevice> list = new List<CommonDevice>();
            lock (dicAllDevice)
            {
                //各网关的所有设备
                var listMac = new List<string>();
                //各网关的所有设备的Mac
                foreach (CommonDevice device in this.dicAllDevice.Values)
                {
                    if (gwId == device.CurrentGateWayId)
                    {
                        list.Add(device);
                        listMac.Add(device.DeviceAddr);
                    }
                }
                return this.GetDevicesByMac(listMac);
            }
            return list;
        }
        /// <summary>
@@ -710,11 +781,12 @@
        }
        /// <summary>
        /// 根据MAC地址,获取全部回路的设备对象(已经排序)
        /// 根据MAC地址,获取全部回路的设备对象
        /// </summary>
        /// <param name="DeviceAddr">Mac地址</param>
        /// <param name="sort">是否排序</param>
        /// <returns></returns>
        public List<CommonDevice> GetDevicesByMac(string DeviceAddr)
        public List<CommonDevice> GetDevicesByMac(string DeviceAddr, bool sort = true)
        {
            var list = new List<CommonDevice>();
            if (dicDeviceEpoint.ContainsKey(DeviceAddr) == false)
@@ -729,6 +801,11 @@
                    list.Add(device);
                }
            }
            if (sort == false)
            {
                return list;
            }
            //排序
            list.Sort((obj1, obj2) =>
            {
@@ -739,6 +816,53 @@
                return -1;
            });
            return list;
        }
        /// <summary>
        /// 根据MAC地址,获取全部回路的设备对象(强制排序)
        /// </summary>
        /// <param name="DeviceAddr">Mac地址</param>
        /// <returns></returns>
        public List<CommonDevice> GetDevicesByMac(List<string> listMacAddr)
        {
            //先排序
            listMacAddr.Sort();
            var list = new List<CommonDevice>();
            foreach (string strMac in listMacAddr)
            {
                var listEpoint = new List<int>();
                //获取全部的端点
                foreach (int epoint in this.dicDeviceEpoint[strMac])
                {
                    listEpoint.Add(epoint);
                }
                //然后排序
                listEpoint.Sort();
                foreach (int epoint in listEpoint)
                {
                    var device = this.GetDevice(strMac, epoint);
                    if (device != null)
                    {
                        list.Add(device);
                    }
                }
            }
            return list;
        }
        /// <summary>
        /// 根据MAC地址,获取全部回路的数量
        /// </summary>
        /// <param name="DeviceAddr">Mac地址</param>
        /// <returns></returns>
        public int GetDevicesCountByMac(string DeviceAddr)
        {
            if (dicDeviceEpoint.ContainsKey(DeviceAddr) == false)
            {
                return 0;
            }
            return dicDeviceEpoint[DeviceAddr].Count;
        }
        /// <summary>
@@ -778,6 +902,35 @@
            return this.dicOTADevice[mainkeys];
        }
        /// <summary>
        /// 获取特殊的,没有其他回路,单纯只有200端点的OTA设备
        /// </summary>
        /// <param name="gwId">网关ID</param>
        /// <returns></returns>
        public List<OTADevice> GetSpecialOtaDevice(string gwId)
        {
            var list = new List<OTADevice>();
            foreach (var ota in this.dicOTADevice.Values)
            {
                if (ota.CurrentGateWayId != gwId)
                {
                    //不是同一个网关
                    continue;
                }
                //没有其他回路
                if (dicDeviceEpoint.ContainsKey(ota.DeviceAddr) == false
                    || dicDeviceEpoint[ota.DeviceAddr].Count == 0)
                {
                    //目前只针对中央空调
                    if (ota.ModelIdentifier == "MAC/GW-ZB.10")
                    {
                        list.Add(ota);
                    }
                }
            }
            return list;
        }
        #endregion
        #region ■ 获取设备名称_______________________
@@ -795,16 +948,39 @@
                return dName;
            }
            //根据设备类型获取名称
            dName = this.GetDeviceObjectText(new List<CommonDevice>() { device }, false);
            var tempValue = this.GetDeviceObjectText(new List<CommonDevice>() { device }, false);
            var arry = tempValue.Split(new string[] { "(" }, StringSplitOptions.RemoveEmptyEntries);
            dName = arry[0].Trim();
            //如果是虚拟设备
            if (device.DriveCode > 0
                || (this.dicDeviceEpoint.ContainsKey(device.DeviceAddr) == true && this.dicDeviceEpoint[device.DeviceAddr].Count > 1))
            if (device.DriveCode > 0)
            {
                var arry = dName.Split(new string[] { "(" }, StringSplitOptions.RemoveEmptyEntries);
                dName = arry[0].Trim();
                //在端点名字的后面附加【回路】字样
                dName += "(" + device.DeviceEpoint + Language.StringByID(R.MyInternationalizationString.uDeviceCircuit) + ")";
                return dName;
            }
            //获取设备类型
            var deviceInfoType = this.GetMyDeviceEnumInfo(new List<CommonDevice>() { device });
            if (deviceInfoType.BeloneType == Common.DeviceBeloneType.A按键面板 && device.Type == DeviceType.TemperatureSensor)
            {
                //面板的最后一个回路是温度传感器
                dName += Language.StringByID(R.MyInternationalizationString.uDeviceBelongId11);
            }
            else if (deviceInfoType.ConcreteType == Common.DeviceConcreteType.Sensor_Pir)
            {
                //pir传感器,它又搞特殊东西,传感器自身用自己的名字,继电器回路的话……
                if (device.Type == DeviceType.OnOffOutput)
                {
                    dName += Language.StringByID(R.MyInternationalizationString.uDeviceBelongId2300);
                }
            }
            else if (this.dicDeviceEpoint.ContainsKey(device.DeviceAddr) == true && this.dicDeviceEpoint[device.DeviceAddr].Count > 1)
            {
                //XXXXX(N回路)
                dName += "(" + device.DeviceEpoint + Language.StringByID(R.MyInternationalizationString.uDeviceCircuit) + ")";
            }
            return dName;
        }
@@ -977,9 +1153,41 @@
            //获取设备【图标】
            this.GetDeviceIcon(device, ref unSelectFilePath, ref selectFilePath);
            if (btnIcon.UnSelectedImagePath != unSelectFilePath)
            {
                btnIcon.UnSelectedImagePath = unSelectFilePath;
            }
            if (btnIcon.SelectedImagePath != selectFilePath)
            {
                btnIcon.SelectedImagePath = selectFilePath;
            }
        }
            btnIcon.UnSelectedImagePath = unSelectFilePath;
            btnIcon.SelectedImagePath = selectFilePath;
        /// <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>
@@ -1011,9 +1219,27 @@
        /// <param name="listdevice">设备对象</param>
        public void SetRealDeviceIconToControl(Button btnIcon, List<CommonDevice> listdevice)
        {
            //获取设备的真实图片
            string imagePath = this.GetRealDeviceIcon(listdevice);
            btnIcon.UnSelectedImagePath = imagePath;
        }
        /// <summary>
        /// 获取设备的真实图片
        /// </summary>
        /// <param name="listdevice">设备对象</param>
        public string GetRealDeviceIcon(List<CommonDevice> listdevice)
        {
            //获取它属于什么类型的设备
            var myDeviceType = this.GetMyDeviceEnumInfo(listdevice);
            string strConcrete = Enum.GetName(typeof(DeviceConcreteType), myDeviceType.ConcreteType);
            //图片共有
            if (this.dicPictrueShard.ContainsKey(strConcrete) == true)
            {
                strConcrete = this.dicPictrueShard[strConcrete];
            }
            string strType = strConcrete.Replace("_", string.Empty);
            //将类型转为图片地址
            string imageFilePath = "RealDevice/" + strType + ".png";
@@ -1025,7 +1251,7 @@
                if (arry.Length == 1)
                {
                    //如果它自己就是共通图片的话,不再处理
                    return;
                    return "RealDevice/CommonDevice.png";
                }
                imageFilePath = "RealDevice/" + arry[0] + ".png";
                //如果它自己的共通图片还是不存在的话,则直接使用所有设备的共通图片
@@ -1034,16 +1260,16 @@
                    imageFilePath = "RealDevice/CommonDevice.png";
                }
            }
            btnIcon.UnSelectedImagePath = imageFilePath;
            return imageFilePath;
        }
        /// <summary>
        /// 设置【设备所属类型】的图标到指定的控件
        /// 设置【设备类型】的图标到指定的控件
        /// </summary>
        /// <param name="btnIcon">控件对象</param>
        /// <param name="listdevice">设备对象</param>
        /// <returns></returns>
        public void SetDeviceBeloneIconToControl(Button btnIcon, List<CommonDevice> listdevice)
        public void SetDeviceObjectIconToControl(Button btnIcon, List<CommonDevice> listdevice)
        {
            //获取自定义设备类型
            var myDeviceType = this.GetMyDeviceEnumInfo(listdevice);
@@ -1051,8 +1277,8 @@
            string imageUnSelectFilePath = string.Empty;
            string imageSelectFilePath = string.Empty;
            //获取【设备所属类型】的图标
            this.GetDeviceBeloneIcon(myDeviceType.ConcreteType, ref imageUnSelectFilePath, ref imageSelectFilePath);
            //获取【设备类型】的图标
            this.GetDeviceObjectIcon(myDeviceType.ConcreteType, ref imageUnSelectFilePath, ref imageSelectFilePath);
            //设置图片
            btnIcon.UnSelectedImagePath = imageUnSelectFilePath;
@@ -1060,32 +1286,38 @@
        }
        /// <summary>
        /// 获取【设备所属类型】的图标
        /// 获取【设备类型】的图标
        /// </summary>
        /// <param name="listdevice">设备对象</param>
        /// <param name="unSelectPath">图片地址</param>
        /// <param name="selectPath">图片地址</param>
        /// <returns></returns>
        public void GetDeviceBeloneIcon(List<CommonDevice> listdevice, ref string unSelectPath, ref string selectPath)
        public void GetDeviceObjectIcon(List<CommonDevice> listdevice, ref string unSelectPath, ref string selectPath)
        {
            //获取自定义设备类型
            var myDeviceType = this.GetMyDeviceEnumInfo(listdevice);
            //获取【设备所属类型】的图标
            this.GetDeviceBeloneIcon(myDeviceType.ConcreteType, ref unSelectPath, ref selectPath);
            //获取【设备类型】的图标
            this.GetDeviceObjectIcon(myDeviceType.ConcreteType, ref unSelectPath, ref selectPath);
        }
        /// <summary>
        /// 获取【设备所属类型】的图标
        /// 获取【设备类型】的图标
        /// </summary>
        /// <param name="specificType">自定义设备类型</param>
        /// <param name="unSelectPath">图片地址</param>
        /// <param name="selectPath">图片地址</param>
        /// <returns></returns>
        public void GetDeviceBeloneIcon(DeviceConcreteType specificType, ref string unSelectPath, ref string selectPath)
        public void GetDeviceObjectIcon(DeviceConcreteType specificType, ref string unSelectPath, ref string selectPath)
        {
            //将具体类型转字符串
            string strSpecific = Enum.GetName(typeof(DeviceConcreteType), specificType);
            //图片共有
            if (this.dicPictrueShard.ContainsKey(strSpecific) == true)
            {
                strSpecific = this.dicPictrueShard[strSpecific];
            }
            string strType = strSpecific.Replace("_", string.Empty);
            //将类型转为图片地址
            string imageFilePath = "Device/" + strType + ".png";
@@ -1096,54 +1328,22 @@
            {
                //不存在则使用共通图片
                string[] arry = strSpecific.Split(new string[] { "_" }, StringSplitOptions.None);
                if (arry.Length == 1)
                //如果它自己就是共通图片的话,不再处理
                if (arry.Length > 1)
                {
                    //如果它自己就是共通图片的话,不再处理
                    return;
                    imageFilePath = "Device/" + arry[0] + ".png";
                    imageSelectFilePath = "Device/" + arry[0] + "Selected.png";
                }
                imageFilePath = "Device/" + arry[0] + ".png";
                imageSelectFilePath = "Device/" + arry[0] + "Selected.png";
            }
            //如果那款设备连共通图片都没有的话
            if (string.IsNullOrEmpty(IO.FileUtils.GetImageFilePath(imageFilePath)) == true)
            {
                imageFilePath = "Device/ThirdPartyDevice.png";
                imageSelectFilePath = "Device/ThirdPartyDeviceSelected.png";
            }
            //设置图片
            unSelectPath = imageFilePath;
            selectPath = imageSelectFilePath;
        }
        #endregion
        #region ■ 设备UI相关_________________________
        /// <summary>
        /// 获取设备所匹配的设备UI对象
        /// </summary>
        /// <param name="device"></param>
        /// <returns></returns>
        public DeviceUI GetDeviceUI(CommonDevice device)
        {
            //创建一个新的东西给过去
            var deviceUi = new DeviceUI();
            deviceUi.DeviceAddr = device.DeviceAddr;
            deviceUi.DeviceEpoint = device.DeviceEpoint;
            return deviceUi;
        }
        /// <summary>
        /// 获取设备所匹配的设备UI对象
        /// </summary>
        /// <param name="filePath"></param>
        /// <returns></returns>
        public DeviceUI GetDeviceUI(string filePath)
        {
            string[] arry = filePath.Split(new string[] { "_" }, StringSplitOptions.RemoveEmptyEntries);
            if (arry.Length != 4)
            {
                return null;
            }
            //创建一个新的东西给过去
            var deviceUi = new DeviceUI();
            deviceUi.DeviceAddr = arry[2];
            deviceUi.DeviceEpoint = Convert.ToInt32(arry[3]);
            return deviceUi;
        }
        #endregion
@@ -1174,7 +1374,11 @@
                return info;
            }
            //获取第三方设备的【设备类型】
            return this.GetNotHdlMyDeviceEnumInfo(listdevice);
            info = this.GetNotHdlMyDeviceEnumInfo(listdevice);
            //这里再次判断是否是河东设备,有可能它的模块ID写错了
            info.IsHdlDevice = this.IsHdlDevice(checkDevice);
            return info;
        }
        /// <summary>
@@ -1239,6 +1443,9 @@
                return null;
            }
            string modelKeys = device.ModelIdentifier;
            //交换一下模块ID(麦乐克那边的传感器)
            this.ChangedDeviceModeId(ref modelKeys);
            if (this.dicDeviceModelIdEnum.ContainsKey(modelKeys) == false)
            {
                //没有匹配到模块ID,则直接走第三方设备的判断
@@ -1270,9 +1477,51 @@
        #region ■ 获取第三方设备的设备类型___________
        /// <summary>
        /// 获取第三方设备的【设备类型】
        /// 获取设备的【所属类型信息】,此方法会把所有的传感器都归为【传感器】(包括温湿度传感器)
        /// </summary>
        /// <param name="listdevice"></param>
        /// <param name="device">设备回路</param>
        /// <returns></returns>
        public DeviceEnumInfo GetDeviceBelongEnumInfo(CommonDevice device)
        {
            var info = this.GetNotHdlMyDeviceEnumInfo(new List<CommonDevice>() { device });
            if (info.BeloneType == DeviceBeloneType.A调光器
                || info.BeloneType == DeviceBeloneType.A彩灯)
            {
                //归为灯光
                info.ConcreteTextId = R.MyInternationalizationString.uDeviceBelongId15;
                info.BeloneType = DeviceBeloneType.A灯光;
                info.ConcreteType = DeviceConcreteType.Light;
                int value = (int)info.BeloneType;
                if (dicDeviceDefultNameID.ContainsKey("uDeviceBelongId" + value) == true)
                {
                    //设备所属类型的翻译名字
                    info.BeloneTextId = dicDeviceDefultNameID["uDeviceBelongId" + value];
                }
            }
            else if (info.BeloneType == DeviceBeloneType.A传感器
                || device.Type == DeviceType.TemperatureSensor)
            {
                //传感器合并
                info.BeloneType = DeviceBeloneType.A传感器;
                info.ConcreteType = DeviceConcreteType.Sensor;
                info.ConcreteTextId = R.MyInternationalizationString.uDeviceBelongId1200;
                int value = (int)info.BeloneType;
                if (dicDeviceDefultNameID.ContainsKey("uDeviceBelongId" + value) == true)
                {
                    //设备所属类型的翻译名字
                    info.BeloneTextId = dicDeviceDefultNameID["uDeviceBelongId" + value];
                }
            }
            return info;
        }
        /// <summary>
        /// 获取第三方设备的【设备类型】(不建议使用)
        /// </summary>
        /// <param name="listdevice">Mac都一样的设备列表</param>
        /// <returns></returns>
        public DeviceEnumInfo GetNotHdlMyDeviceEnumInfo(List<CommonDevice> listdevice)
        {
@@ -1289,9 +1538,18 @@
            //1包含面板的话,当面板处理
            if (dicType.ContainsKey(DeviceType.OnOffSwitch) == true)
            {
                info.ConcreteTextId = R.MyInternationalizationString.uDeviceBelongId200;
                info.BeloneType = DeviceBeloneType.A按键面板;
                info.ConcreteType = DeviceConcreteType.ButtonPanel;
                if (listdevice.Count > 1)
                {
                    info.ConcreteTextId = R.MyInternationalizationString.uDeviceBelongId200;
                    info.BeloneType = DeviceBeloneType.A按键面板;
                    info.ConcreteType = DeviceConcreteType.ButtonPanel;
                }
                else
                {
                    info.ConcreteTextId = R.MyInternationalizationString.uDeviceBelongId16;
                    info.BeloneType = DeviceBeloneType.A干接点;
                    info.ConcreteType = DeviceConcreteType.DryContact;
                }
            }
            //3包含窗帘的话,当窗帘处理
            else if (dicType.ContainsKey(DeviceType.WindowCoveringDevice) == true)
@@ -1303,16 +1561,56 @@
            //4空气开关
            else if (dicType.ContainsKey(DeviceType.AirSwitch) == true)
            {
                //默认值
                info.ConcreteTextId = R.MyInternationalizationString.uDeviceBelongId4100;
                info.BeloneType = DeviceBeloneType.A空气开关;
                info.BeloneType = DeviceBeloneType.A智能空开;
                info.ConcreteType = DeviceConcreteType.AirSwitch;
                if (dicType[DeviceType.AirSwitch].DfunctionType == DeviceFunctionType.A开关)
                {
                    info.ConcreteTextId = R.MyInternationalizationString.uDeviceBelongId13;
                    info.BeloneType = DeviceBeloneType.A开关;
                    info.ConcreteType = DeviceConcreteType.Switch;
                }
                else if (dicType[DeviceType.AirSwitch].DfunctionType == DeviceFunctionType.A插座)
                {
                    info.ConcreteTextId = R.MyInternationalizationString.uDeviceBelongId14;
                    info.BeloneType = DeviceBeloneType.A插座;
                    info.ConcreteType = DeviceConcreteType.Socket1;
                }
                else if (dicType[DeviceType.AirSwitch].DfunctionType == DeviceFunctionType.A灯光)
                {
                    info.ConcreteTextId = R.MyInternationalizationString.uDeviceBelongId15;
                    info.BeloneType = DeviceBeloneType.A灯光;
                    info.ConcreteType = DeviceConcreteType.Light;
                }
            }
            //5继电器
            else if (dicType.ContainsKey(DeviceType.OnOffOutput) == true)
            {
                //默认值
                info.ConcreteTextId = R.MyInternationalizationString.uDeviceBelongId2300;
                info.BeloneType = DeviceBeloneType.A继电器;
                info.ConcreteType = DeviceConcreteType.Relay;
                if (dicType[DeviceType.OnOffOutput].DfunctionType == DeviceFunctionType.A开关)
                {
                    info.ConcreteTextId = R.MyInternationalizationString.uDeviceBelongId13;
                    info.BeloneType = DeviceBeloneType.A开关;
                    info.ConcreteType = DeviceConcreteType.Switch;
                }
                else if (dicType[DeviceType.OnOffOutput].DfunctionType == DeviceFunctionType.A插座)
                {
                    info.ConcreteTextId = R.MyInternationalizationString.uDeviceBelongId14;
                    info.BeloneType = DeviceBeloneType.A插座;
                    info.ConcreteType = DeviceConcreteType.Socket1;
                }
                else if (dicType[DeviceType.OnOffOutput].DfunctionType == DeviceFunctionType.A灯光)
                {
                    info.ConcreteTextId = R.MyInternationalizationString.uDeviceBelongId15;
                    info.BeloneType = DeviceBeloneType.A灯光;
                    info.ConcreteType = DeviceConcreteType.Light;
                }
            }
            //6调光器
            else if (dicType.ContainsKey(DeviceType.DimmableLight) == true)
@@ -1359,8 +1657,10 @@
            //12包含传感器的话,当传感器处理
            else if (dicType.ContainsKey(DeviceType.IASZone) == true)
            {
                //设置传感器具体的类型
                info.BeloneType = DeviceBeloneType.A传感器;
                info.ConcreteType = DeviceConcreteType.Sensor;
                info.ConcreteTextId = R.MyInternationalizationString.uDeviceBelongId1200;
                //设置传感器具体的类型
                this.SetSensorDeviceSpecificType(ref info, listdevice);
            }
            //13包含温度传感器的话
@@ -1368,7 +1668,9 @@
            {
                bool temperatrue = false;
                bool humidity = false;
                foreach (var device in listdevice)
                //获取全部的回路
                var listTemp = this.GetDevicesByMac(listdevice[0].DeviceAddr, false);
                foreach (var device in listTemp)
                {
                    if (device is TemperatureSensor)
                    {
@@ -1378,7 +1680,7 @@
                            temperatrue = true;
                        }
                        //湿度传感器
                        else if(((TemperatureSensor)device).SensorDiv == 2)
                        else if (((TemperatureSensor)device).SensorDiv == 2)
                        {
                            humidity = true;
                        }
@@ -1389,14 +1691,14 @@
                    //设置传感器具体的类型
                    info.BeloneType = DeviceBeloneType.A温湿度传感器;
                    info.ConcreteTextId = R.MyInternationalizationString.uDeviceBelongId10;
                    info.ConcreteType = DeviceConcreteType.Sensor_TemperatrueHumidity;
                    info.ConcreteType = DeviceConcreteType.Sensor_TemperatureHumidity;
                }
                else if (temperatrue == true && humidity == false)
                {
                    //设置传感器具体的类型
                    info.BeloneType = DeviceBeloneType.A温度传感器;
                    info.ConcreteTextId = R.MyInternationalizationString.uDeviceBelongId11;
                    info.ConcreteType = DeviceConcreteType.Sensor_Temperatrue;
                    info.ConcreteType = DeviceConcreteType.Sensor_Temperature;
                }
                else if (temperatrue == false && humidity == true)
                {
@@ -1428,10 +1730,6 @@
        /// <param name="listdevice">设备对象</param>
        private void SetSensorDeviceSpecificType(ref DeviceEnumInfo info, List<CommonDevice> listdevice)
        {
            //默认名字:传感器
            info.ConcreteType = DeviceConcreteType.Sensor;
            info.ConcreteTextId = R.MyInternationalizationString.uDeviceBelongId1200;
            //如果这个设备拥有多个回路的话,我也不知道怎么命名,只能给个默认名字
            if (listdevice.Count > 1)
            {
@@ -1505,18 +1803,30 @@
        /// </summary>
        /// <param name="listDevice">需要保存的设备对象</param>
        /// <param name="roomId">需要保存的哪个设备的房间ID</param>
        public void SaveRealDeviceRoomId(List<CommonDevice> listDevice, string roomId)
        /// <param name="saveRoadDevice">如果只有一个回路,是否把回路的房间一起修改</param>
        public void SaveRealDeviceRoomId(List<CommonDevice> listDevice, string roomId, bool saveRoadDevice = true)
        {
            this.dicDeviceRoomId[listDevice[0].DeviceAddr] = roomId;
            if (listDevice != null)
            {
                this.dicDeviceRoomId[listDevice[0].DeviceAddr] = roomId;
            }
            //保存记录
            string fullName = UserCenterLogic.CombinePath(DirNameResourse.DeviceRoomIdFile);
            UserCenterLogic.SaveFileContent(fullName, this.dicDeviceRoomId);
            //添加自动备份
            HdlAutoBackupLogic.AddOrEditorFile(DirNameResourse.DeviceRoomIdFile);
            //如果设备只有一个回路,如果改变了真实设备区域,则它的回路的区域也一起改了
            if (listDevice.Count == 1)
            if (saveRoadDevice == true && listDevice != null && listDevice.Count == 1)
            {
                Common.Room.CurrentRoom.ChangedRoom(listDevice[0], roomId);
                if (listDevice[0] is OTADevice)
                {
                    //单纯只是Ota设备则不处理
                    return;
                }
                HdlRoomLogic.Current.ChangedRoom(listDevice[0], roomId, false);
            }
        }
@@ -1532,7 +1842,7 @@
                //未分配区域
                return Language.StringByID(R.MyInternationalizationString.uDeviceNotAssignedRoom);
            }
            var room = Room.CurrentRoom.GetRoomById(this.dicDeviceRoomId[device.DeviceAddr]);
            var room = HdlRoomLogic.Current.GetRoomById(this.dicDeviceRoomId[device.DeviceAddr]);
            if (room != null)
            {
                return room.Name;
@@ -1552,7 +1862,81 @@
            {
                return null;
            }
            return Room.CurrentRoom.GetRoomById(this.dicDeviceRoomId[device.DeviceAddr]);
            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
@@ -1576,7 +1960,7 @@
        /// <returns></returns>
        public string GetDeviceMainKeys(CommonDevice device)
        {
            return device.DeviceAddr + device.DeviceEpoint;
            return this.GetDeviceMainKeys(device.DeviceAddr, device.DeviceEpoint);
        }
        /// <summary>
@@ -1587,7 +1971,7 @@
        /// <returns></returns>
        public string GetDeviceMainKeys(string DeviceAddr, int DeviceEpoint)
        {
            return DeviceAddr + DeviceEpoint;
            return DeviceAddr + "_" + DeviceEpoint;
        }
        /// <summary>
@@ -1613,16 +1997,16 @@
        /// <returns></returns>
        public string AppendVersion(int versionValue)
        {
            //转为16进制
            string txt64 = Convert.ToString(versionValue, 16).PadLeft(4, '0');
            //直接是10进制
            string txt10 = Convert.ToString(versionValue).PadLeft(4, '0');
            //这个是小数点前面的值
            int value1 = Convert.ToInt32(txt64.Substring(0, 2), 16);
            int value1 = Convert.ToInt32(txt10.Substring(0, txt10.Length - 2));
            //这个是小数点后面的值
            int value2 = Convert.ToInt32(txt64.Substring(2, 2), 16);
            int value2 = Convert.ToInt32(txt10.Substring(txt10.Length - 2, 2));
            //Ver.
            string ver = Language.StringByID(R.MyInternationalizationString.uVersionAbbreviation);
            return ver + value1 + "." + value2.ToString().PadLeft(3, '0');
            return ver + value1 + "." + value2.ToString().PadLeft(2, '0');
        }
        /// <summary>
@@ -1658,36 +2042,23 @@
        #region ■ 获取设备列表的接口_________________
        /// <summary>
        /// 从网关重新获取设备列表(★★★★★★★接收到设备时的事件★★★★★★★)
        /// <para>从网关重新获取设备列表(返回的设备为虚拟出来的)</para>
        /// <para>statu状态 -1:异常,会返回null, 1:没有异常, 2:数据接收不全</para>
        /// </summary>
        /// <param name="zbGateway">网关对象</param>
        /// <param name="ignoreTime">是否无视时间,true:每次调用都去网关获取,false:3分钟内返回的是本地的设备</param>
        /// <param name="deviceComingAction">接收到设备时的事件</param>
        /// <param name="statu">状态-> -1:异常,会返回null, 1:没有异常, 2:数据接收不全</param>
        /// <param name="ignoreTime">是否无视时间(此变量是给获取在线状态用的),true:每次调用都去网关获取,false:3分钟内返回的是本地的设备</param>
        /// <param name="mode">是否显示错误</param>
        /// <returns></returns>
        public List<CommonDevice> GetDeviceListFromGateway(ZbGateway zbGateway, bool ignoreTime, Action<CommonDevice> deviceComingAction = null, ShowErrorMode mode = ShowErrorMode.YES)
        public List<CommonDevice> GetDeviceListFromGateway(ZbGateway zbGateway, ref int statu, bool ignoreTime, ShowErrorMode mode = ShowErrorMode.YES)
        {
            if (ignoreTime == false)
            {
                if ((DateTime.Now - zbGateway.LastDateTime).TotalMilliseconds < 3 * 60 * 1000)
                {
                    //不无视时间,返回本地设备列表
                    var listTemp = this.GetDeviceByGatewayID(HdlGatewayLogic.Current.GetGatewayId(zbGateway));
                    if (deviceComingAction != null)
                    {
                        for (int i = 0; i < listTemp.Count; i++)
                        {
                            try
                            {
                                //回调函数
                                deviceComingAction.Invoke(listTemp[i]);
                            }
                            //Log出力
                            catch (Exception ex) { HdlLogLogic.Current.WriteLog(ex); }
                        }
                    }
                    deviceComingAction = null;
                    return listTemp;
                    statu = 1;
                    return this.GetDeviceByGatewayID(HdlGatewayLogic.Current.GetGatewayId(zbGateway));
                }
            }
            zbGateway.LastDateTime = DateTime.Now;
@@ -1704,6 +2075,7 @@
                    string msg = Language.StringByID(R.MyInternationalizationString.uErrorGatewayLostMsg);
                    this.ShowTipMsg(msg);
                }
                statu = -1;
                return null;
            }
@@ -1719,53 +2091,59 @@
            int receiveCount = 0;
            //设备列表
            var listDevice = new List<CommonDevice>();
            //网关里面有可能会有重复的回路
            var listCheck = new HashSet<string>();
            Action<string, string> getDeviceAction = (topic, message) =>
            {
                try
                if (topic == gatewayID + "/" + "DeviceInfoRespon")
                {
                    if (topic == gatewayID + "/" + "DeviceInfoRespon")
                    try
                    {
                        TimeOut = 0;
                        var jobject = Newtonsoft.Json.Linq.JObject.Parse(message);
                        var totalNum = Newtonsoft.Json.JsonConvert.DeserializeObject<int>(jobject["Data"]["TotalNum"].ToString());
                        if (totalNum == 0)
                        lock (listDevice)
                        {
                            //这个网关没有设备
                            canBreak = true;
                            return;
                        }
                        if (deviceCount == -1)
                        {
                            //设置需要接收多少个设备
                            deviceCount = totalNum;
                        }
                        //设备接收数
                        receiveCount++;
                            //设备接收数
                            receiveCount++;
                        var deviceID = (DeviceType)jobject.Value<int>("Device_ID");
                        //根据设备类型创建设备对象的实例
                        var device = this.NewDeviceObjectByDeviceId(deviceID, jobject, zbGateway);
                        if (device != null)
                        {
                            try
                            TimeOut = 0;
                            var jobject = Newtonsoft.Json.Linq.JObject.Parse(message);
                            var totalNum = Newtonsoft.Json.JsonConvert.DeserializeObject<int>(jobject["Data"]["TotalNum"].ToString());
                            if (totalNum == 0)
                            {
                                //回调函数
                                deviceComingAction?.Invoke(device);
                                //这个网关没有设备
                                canBreak = true;
                                return;
                            }
                            //Log出力
                            catch (Exception ex) { HdlLogLogic.Current.WriteLog(ex); }
                            if (deviceCount == -1)
                            {
                                //设置需要接收多少个设备
                                deviceCount = totalNum;
                            }
                            listDevice.Add(device);
                        }
                        if (deviceCount == receiveCount)
                        {
                            //设备全部接收完成
                            canBreak = true;
                            var deviceID = (DeviceType)jobject.Value<int>("Device_ID");
                            //根据设备类型创建设备对象的实例
                            var device = this.NewDeviceObjectByDeviceId(deviceID, jobject, zbGateway);
                            if (device != null)
                            {
                                string mainkeys = this.GetDeviceMainKeys(device);
                                //网关里面有可能会有重复的回路
                                if (listCheck.Contains(mainkeys) == false)
                                {
                                    listDevice.Add(device);
                                    listCheck.Add(mainkeys);
                                }
                            }
                        }
                    }
                    //Log出力
                    catch (Exception ex) { HdlLogLogic.Current.WriteLog(ex); }
                    if (receiveCount == deviceCount && deviceCount != -1)
                    {
                        //设备全部接收完成
                        canBreak = true;
                    }
                }
                catch { }
            };
            realWay.Actions += getDeviceAction;
@@ -1798,6 +2176,7 @@
                        msg = UserCenterLogic.CombineGatewayTimeOutMsg(msg, null, "回复超时", false);
                        this.ShowTipMsg(msg);
                    }
                    statu = -1;
                    return null;
                }
                else
@@ -1808,12 +2187,11 @@
                        string msg = Language.StringByID(R.MyInternationalizationString.uNetworkUnStableAndDeviceInfoIsNotFull);
                        this.ShowTipMsg(msg);
                    }
                    statu = 2;
                }
            }
            //回调函数(接收完成)
            deviceComingAction = null;
            }
            statu = 1;
            return listDevice;
        }
@@ -1917,7 +2295,7 @@
                }
            }
            //如果是调光器
            else if (mainDevice.Type == DeviceType.DimmableLight )
            else if (mainDevice.Type == DeviceType.DimmableLight)
            {
                mainDevice.DfunctionType = DeviceFunctionType.A灯光;
                if (mainDevice.IsCustomizeImage == false)
@@ -1926,7 +2304,7 @@
                }
            }
            //如果是彩灯的话
            else if ( mainDevice.Type == DeviceType.ColorDimmableLight)
            else if (mainDevice.Type == DeviceType.ColorDimmableLight)
            {
                mainDevice.DfunctionType = DeviceFunctionType.A灯光;
                if (mainDevice.IsCustomizeImage == false)
@@ -2001,6 +2379,15 @@
            //定义规则:模块ID(已翻译)=设备具体类型值-设备所属类型值(自定义的值,嘛,只要不重复就可以)
            //第一个值是:DeviceConcreteType  第二个值是:DeviceBeloneType
            //*********************************************************************
            //新设备添加方法:
            //1、在这里填写上模块ID,然后是 DeviceConcreteType ,然后是 DeviceBeloneType
            //2、然后在最下面的【自定义设备类型】折叠栏里添加【设备的具体类型】,【设备的所属类型】
            //3、以设备的具体类型为名字(去掉【-】)添加设备的【所属图片】,【真实物理图片】。回路图片需要特殊处理
            //4、添加R文件(uDeviceModelId),添加Language文件
            //5、如果需要共有图片,则在这个函数的最底下添加
            //*********************************************************************
            //=========★★开合帘类(100-199)★★=========
            this.dicDeviceModelIdEnum["MWM65B-ZB.20"] = "100-100";//智能开合帘电机
            this.dicDeviceModelIdEnum["MVSM35B-ZB.20"] = "101-100";//智能管状电机
@@ -2011,6 +2398,17 @@
            this.dicDeviceModelIdEnum["MPT2/R2-ZB.18"] = "202-200";//2按键触摸面板
            this.dicDeviceModelIdEnum["MPT1/R1-ZB.18"] = "203-200";//12按键触摸面板
            this.dicDeviceModelIdEnum["MPT4-ZB.18"] = "210-200";//4按键触摸面板(只带电源底座)
            this.dicDeviceModelIdEnum["MPT4R4L/S-ZB.18"] = "220-200";//简约4按键面板
            this.dicDeviceModelIdEnum["MPT3R3L/S-ZB.18"] = "221-200";//简约3按键面板
            this.dicDeviceModelIdEnum["MPT2R2L/S-ZB.18"] = "222-200";//简约2按键面板
            this.dicDeviceModelIdEnum["MPT4SC/S-ZB.18"] = "224-200";//简约4按键场景面板
            this.dicDeviceModelIdEnum["MPT2W/S-ZB.18"] = "226-200";//简约2路窗帘面板
            this.dicDeviceModelIdEnum["MP2B/TILE-ZB.18"] = "240-200";//方悦单开双控面板
            this.dicDeviceModelIdEnum["MP4B/TILE-ZB.18"] = "241-200";//方悦双开四控面板
            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
@@ -2025,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空调网关模块
@@ -2045,7 +2445,9 @@
            this.dicDeviceModelIdEnum["MBUS/GW-ZB.10"] = "4200-4200";//zigbee转buspro协议转换器
            this.dicDeviceModelIdEnum["M485/GW-ZB.10"] = "4201-4200";//zigbee转485协议转换器
            //需要交换的模块ID
            //✩✩✩✩✩需要交换的模块ID✩✩✩✩✩
            this.dicDeviceModelIdChanged = new Dictionary<string, string>();
            //=========★★安防类传感器类★★=========
            this.dicDeviceModelIdChanged["MULTI-GASE--EA07"] = "MSG01/M-ZB.10";//燃气传感器
@@ -2054,6 +2456,18 @@
            this.dicDeviceModelIdChanged["MULTI-MOTI--EA04"] = "MSPIR01/M-ZB.10";//红外传感器
            this.dicDeviceModelIdChanged["MULTI-WATE--EA02"] = "MSW01/M-ZB.10";//水浸传感器
            this.dicDeviceModelIdChanged["MULTI-BURO--EA06"] = "MBU01/M-ZB.10";//紧急按键
            //✩✩✩✩✩需要共有的图片对象✩✩✩✩✩
            //两者都是DeviceConcreteType
            //Keys:指定的设备    value:沿用的图片是哪款设备的
            this.dicPictrueShard = new Dictionary<string, string>();
            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
@@ -2062,12 +2476,12 @@
    #region ■ 自定义设备类型_________________________
    /// <summary>
    /// <para>仅限底层使用:设备的具体【设备类型】,自定义与模块id关联的枚举(值为LocalDevice里面dicDeviceModelIdEnum所指定的值)</para>
    /// <para>仅限底层使用:设备的具体【设备类型】,自定义与模块id关联的枚举(值为LocalDevice里面dicDeviceModelIdEnum所指定的DeviceConcreteType值)</para>
    /// <para>变量名可以作为【设备类型】图片,这个值是瞎写的,没什么特殊意义</para>
    /// </summary>
    public enum DeviceConcreteType
    {
        //定义规则:【设备类型】图片名字=LocalDevice里面dicDeviceModelIdEnum所指定的值
        //定义规则:【设备类型】图片名字=LocalDevice里面dicDeviceModelIdEnum所指定的DeviceConcreteType值
        /// <summary>
        /// 未知设备
@@ -2113,6 +2527,50 @@
        /// 4按键多功能触摸面板(只带电源底座) 镜像id:210
        /// </summary>
        ButtonPanel_FourNotPower = 210,
        /// <summary>
        /// 简约4按键面板 镜像id:220
        /// </summary>
        ButtonPanel_SimpleFour = 220,
        /// <summary>
        /// 简约3按键面板 镜像id:221
        /// </summary>
        ButtonPanel_SimpleThree = 221,
        /// <summary>
        /// 简约2按键面板 镜像id:222
        /// </summary>
        ButtonPanel_SimpleTwo = 222,
        /// <summary>
        /// 简约4按键场景面板 镜像id:224
        /// </summary>
        ButtonPanel_FourButtonScene = 224,
        /// <summary>
        /// 简约2路窗帘面板 镜像id:226
        /// </summary>
        ButtonPanel_TwoButtonCurtain = 226,
        /// <summary>
        /// 方悦2按键轻触式面板 镜像id:240
        /// </summary>
        ButtonPanel_FangyueTwo = 240,
        /// <summary>
        /// 方悦4按键轻触式面板 镜像id:241
        /// </summary>
        ButtonPanel_FangyueFour = 241,
        /// <summary>
        /// 方悦8按键轻触式面板 镜像id:242
        /// </summary>
        ButtonPanel_FangyueEight = 242,
        /// <summary>
        /// 方悦新风面板 镜像id:250
        /// </summary>
        ButtonPanel_FangyueFreshAir = 250,
        /// <summary>
        /// 方悦环境面板 镜像id:253
        /// </summary>
        ButtonPanel_FangyueEnvironment = 253,
        /// <summary>
        /// 窗帘面板 镜像id:256
        /// </summary>
        ButtonPanel_Curtain = 256,
        //=========★★PIR传感器类(1200-1299)★★=========
        /// <summary>
@@ -2160,11 +2618,11 @@
        /// <summary>
        /// 温湿度传感器
        /// </summary>
        Sensor_TemperatrueHumidity = -1308,
        Sensor_TemperatureHumidity = -1308,
        /// <summary>
        /// 温度传感器
        /// </summary>
        Sensor_Temperatrue = -1309,
        Sensor_Temperature = -1309,
        /// <summary>
        /// 湿度传感器
        /// </summary>
@@ -2179,7 +2637,11 @@
        /// 三路继电器 镜像id:2300
        /// </summary>
        Relay_ThreeLoad = 2300,
        /// <summary>
        /// 方悦新风小模块 镜像id:2310
        /// </summary>
        Relay_FangyueFreshAirModul = 2310,
        //=========★★调光器类(2500-2799)★★=========
        /// <summary>
        /// 调光器
@@ -2199,6 +2661,10 @@
        /// H06C
        /// </summary>
        IntelligentLocks_H06C = 2800,
        /// <summary>
        /// S-one
        /// </summary>
        IntelligentLocks_Sone = 2802,
        //=========★★彩灯类(????-????)★★=========
        /// <summary>
@@ -2228,11 +2694,11 @@
        //=========★★空气开关类(4100-????)★★=========
        /// <summary>
        /// 智能空气开关
        /// 智能空开
        /// </summary>
        AirSwitch = -4100,
        /// <summary>
        /// 微断云控制器 镜像id:4100
        /// 智能空开 镜像id:4100
        /// </summary>
        AirSwitch_CloudContr = 4100,
@@ -2249,10 +2715,28 @@
        /// zigbee转buspro协议转换器
        /// </summary>
        Converter_ZbBuspro = 4201,
        //=========★★其他类(????-????)★★=========
        /// <summary>
        /// 干接点(注意,它属于其他类,不是设备类型)
        /// </summary>
        DryContact = -10000,
        /// <summary>
        /// 灯光(注意,它属于其他类,不是设备类型)
        /// </summary>
        Light = -10001,
        /// <summary>
        /// 插座(注意,它属于其他类,不是设备类型)
        /// </summary>
        Socket1 = -10002,
        /// <summary>
        /// 开关(注意,它属于其他类,不是设备类型)
        /// </summary>
        Switch = -10003,
    }
    /// <summary>
    /// <para>仅限底层使用:设备所属的【设备种类】,自定义与模块id关联的枚举(值为LocalDevice里面dicDeviceModelIdEnum所指定的值)</para>
    /// <para>仅限底层使用:设备所属的【设备种类】,自定义与模块id关联的枚举(值为LocalDevice里面dicDeviceModelIdEnum所指定的DeviceBeloneType值)</para>
    /// <para>这个值是瞎写的,没什么特殊意义</para>
    /// </summary>
    public enum DeviceBeloneType
@@ -2294,9 +2778,9 @@
        /// </summary>
        A中继器 = 3900,
        /// <summary>
        /// 空气开关(4100-4199)
        /// 智能空开(4100-4199)
        /// </summary>
        A空气开关 = 4100,
        A智能空开 = 4100,
        /// <summary>
        /// 转换器(4200-4699)
        /// </summary>
@@ -2316,7 +2800,23 @@
        /// <summary>
        /// 湿度传感器
        /// </summary>
        A湿度传感器 = 12
        A湿度传感器 = 12,
        /// <summary>
        /// 开关
        /// </summary>
        A开关 = 13,
        /// <summary>
        /// 插座
        /// </summary>
        A插座 = 14,
        /// <summary>
        /// 灯光
        /// </summary>
        A灯光 = 15,
        /// <summary>
        /// 干接点
        /// </summary>
        A干接点 = 16
    }
    #endregion