陈嘉乐
2020-09-02 652243206427f35a256400a149a1734085824cb9
ZigbeeApp/Shared/Common/Device.cs
@@ -58,17 +58,9 @@
        }
        /// <summary>
        /// R文件里面设备模块ID的翻译名字的前缀
        /// 设备的模块ID的枚举 keys:模块ID (Axxx代表是第三方设备)
        /// </summary>
        public const string deviceModelIdName = "uDeviceModelId";
        /// <summary>
        /// R文件里面所有设备名字的ID
        /// </summary>
        public Dictionary<string, int> dicDeviceAllNameID = null;
        /// <summary>
        /// 设备的模块ID的枚举(keys:模块ID  value:设备具体类型值-设备所属类型值(自定义的值,嘛,只要不重复就可以)
        /// </summary>
        private Dictionary<string, string> dicDeviceModelIdEnum = null;
        private Dictionary<string, DeviceNameContent> dicDeviceModelIdEnum = null;
        /// <summary>
        /// 需要转换的设备的模块ID(keys:旧模块ID,value:新模块ID)
        /// </summary>
@@ -105,9 +97,9 @@
        {
            this.dicAllDevice.Clear();
            this.dicDeviceEpoint.Clear();
            //初始化R文件里面设备默认名字的ID
            this.InitDeviceDefultNameIDList();
            //初始化设备枚举
            this.InitDeviceModelIdEnum();
            //获取本地全部的设备文件
            List<string> listFile = this.GetAllDeviceFile();
@@ -123,12 +115,6 @@
                if (device == null || device.CurrentGateWayId == null)
                {
#if DEBUG
                    //调查,为什么它会把全部设备删掉?
                    string file1 = UserCenterLogic.CombinePath(file);
                    string file2 = UserCenterLogic.CombinePath("Back_" + file);
                    System.IO.File.Copy(file1, file2, true);
#endif
                    //失效的文件,没有网关id的都删除掉
                    Global.DeleteFilebyHomeId(file);
                    continue;
@@ -143,12 +129,6 @@
                    }
                    else
                    {
#if DEBUG
                        //调查,为什么它会把全部设备删掉?
                        string file1 = UserCenterLogic.CombinePath(file);
                        string file2 = UserCenterLogic.CombinePath("Back_" + file);
                        System.IO.File.Copy(file1, file2, true);
#endif
                        //如果是主人,或者管理员,那么这个文件是非法的,直接删除
                        Global.DeleteFilebyHomeId(file);
                        continue;
@@ -211,7 +191,7 @@
            var listGateway = HdlGatewayLogic.Current.GetAllLocalGateway();
            foreach (var gateway in listGateway)
            {
                string gwId = HdlGatewayLogic.Current.GetGatewayId(gateway);
                string gwId = gateway.GwId;
                if (listId.Contains(gwId) == false)
                {
                    //这个网关对于当前这个成员来说是非法的
@@ -229,12 +209,13 @@
        /// <para>-1:异常 1:正常 2:设备信息缺损</para>
        /// </summary>
        /// <param name="zbGateway">网关对象</param>
        public int SetDeviceToMemmoryByGateway(ZbGateway zbGateway)
        /// <param name="useLocalConnect">是否强制使用本地连接发送</param>
        public int SetDeviceToMemmoryByGateway(ZbGateway zbGateway, bool useLocalConnect)
        {
            //从网关获取全部的设备
            int statu = 0;
            List<CommonDevice> listDevice = new List<CommonDevice>();
            List<CommonDevice> list = this.GetDeviceListFromGateway(zbGateway, ref statu, true);
            List<CommonDevice> list = this.GetDeviceListFromGateway(zbGateway, ref statu, useLocalConnect);
            if (list == null)
            {
                return -1;
@@ -242,7 +223,7 @@
            listDevice.AddRange(list);
            //获取这个网关的本地所有设备
            string gwID = HdlGatewayLogic.Current.GetGatewayId(zbGateway);
            string gwID = zbGateway.GwId;
            List<CommonDevice> listLocalDevices = this.GetDeviceByGatewayID(gwID);
            //获取ota设备
            foreach (var ota in this.dicOTADevice.Values)
@@ -261,6 +242,7 @@
            }
            //添加设备的缓存
            var listDriveDevice = new List<CommonDevice>();
            for (int i = 0; i < listDevice.Count; i++)
            {
                var device = listDevice[i];
@@ -278,26 +260,18 @@
                    dicExist.Remove(maikey);
                }
                //获取设备的固定属性
                HdlDeviceFixedAttributeLogic.Current.SetAllFixedAttributeToDevice(device);
            }
            for (int i = 0; i < listDevice.Count; i++)
            {
                var device = listDevice[i];
                if (HdlDeviceFixedAttributeLogic.Current.SetAllFixedAttributeToDevice(device) == true)
                {
                    System.Threading.Thread.Sleep(200);
                }
                //对未命名的虚拟设备重新命名
                if (device.DriveCode > 0 && this.GetSimpleEpointName(device) == string.Empty)
                {
                    //根据设备类型获取名称
                    var dName = this.GetDeviceObjectText(new List<CommonDevice>() { device }, false);
                    //在端点名字的后面附加【回路】字样
                    dName += "(" + device.DeviceEpoint + Language.StringByID(R.MyInternationalizationString.uDeviceCircuit) + ")";
                    HdlThreadLogic.Current.RunThread(() =>
                    {
                        this.ReName(device, dName, ShowErrorMode.NO);
                    });
                    listDriveDevice.Add(device);
                }
            }
            //设置虚拟设备的默认名字
            this.SetDriveDeviceDefultName(listDriveDevice);
            //只有完全获取的时候,才会去处理删除的问题
            if (statu != 1)
@@ -352,6 +326,8 @@
                    var tempDevice = this.dicOTADevice[mainKeys];
                    //将DeviceInfo的属性设置到主属性中
                    this.SetDeviceInfoToMain(tempDevice, device);
                    //刷新设备功能类型(这个东西需要独立出来)
                    this.RefreshDeviceFunctionType(tempDevice, device, false);
                    device = tempDevice;
                }
@@ -373,6 +349,8 @@
                    var tempDevice = this.dicAllDevice[mainKeys];
                    //将DeviceInfo的属性设置到主属性中
                    this.SetDeviceInfoToMain(tempDevice, device);
                    //刷新设备功能类型(这个东西需要独立出来)
                    this.RefreshDeviceFunctionType(tempDevice, device, false);
                    device = tempDevice;
                }
                else
@@ -442,7 +420,7 @@
            if (Common.Config.Instance.Home.IsVirtually == true)
            {
                //修改设备名字的话,主页需要重新刷新
                Phone.UserView.UserPage.Instance.RefreshForm = true;
                Phone.UserView.UserPage.Instance.RefreshAllForm = true;
                return true;
            }
@@ -466,7 +444,7 @@
                }
            }
            //修改设备名字的话,主页需要重新刷新
            Phone.UserView.UserPage.Instance.RefreshForm = true;
            Phone.UserView.UserPage.Instance.RefreshAllForm = true;
            return true;
        }
@@ -545,6 +523,42 @@
            return true;
        }
        /// <summary>
        /// 设置虚拟设备的默认名字
        /// </summary>
        /// <param name="listDriveDevice">虚拟设备列表</param>
        private void SetDriveDeviceDefultName(List<CommonDevice> listDriveDevice)
        {
            if (listDriveDevice.Count == 0)
            {
                return;
            }
            //如果虚拟设备还没有名字的话
            HdlThreadLogic.Current.RunThread(() =>
            {
                //如果不这样放在一个线程里,有可能对Dictionary产生影响
                foreach (var myDevice in listDriveDevice)
                {
                    string dName = string.Empty;
                    if (this.IsMiniLight(myDevice) == true)
                    {
                        //Mini夜灯
                        dName = Language.StringByID(R.MyInternationalizationString.uMiniNightLight);
                    }
                    else
                    {
                        //根据设备类型获取名称
                        dName = this.GetDeviceObjectText(new List<CommonDevice>() { myDevice }, false);
                        //在端点名字的后面附加【回路】字样
                        dName += "(" + myDevice.DeviceEpoint + Language.StringByID(R.MyInternationalizationString.uDeviceCircuit) + ")";
                    }
                    this.ReName(myDevice, dName, ShowErrorMode.NO);
                    System.Threading.Thread.Sleep(100);
                }
            });
        }
        ///<summary >
        /// 修改设备mac名称
        /// <para>macName:设备名称</para>
@@ -554,18 +568,18 @@
            //如果当前是虚拟住宅
            if (Common.Config.Instance.Home.IsVirtually == true)
            {
                return Phone.ModelData.DeviceModelDataLogic.Current.ReDeviceMacName(device, macName, "MacRename");
                return Phone.TemplateData.TemplateDeviceDataLogic.Current.ReDeviceMacName(device, macName);
            }
            //获取编辑设备Mac名字的命令字符
            var sendData = this.GetReDeviceMacNameCommandText(device.DeviceAddr, device.DeviceEpoint, macName);
            var result = HdlDeviceCommonLogic.Current.SendJobjectDataToGateway(device, "MacRename", sendData, "MacRename_Respon");
            var result = HdlDeviceCommonLogic.Current.SendJobjectDataToGateway(device, "MacRename", sendData, "MacRename_Respon", 8);
            if (result.ErrorMsg != null || result.ErrorMsgDiv == 0)
            {
                return null;
            }
            //加缓存
            Phone.ModelData.DeviceModelDataLogic.Current.ReDeviceMacName(device, macName, "MacRename");
            Phone.TemplateData.TemplateDeviceDataLogic.Current.ReDeviceMacName(device, macName);
            var tempData = Newtonsoft.Json.JsonConvert.DeserializeObject<CommonDevice.RenameDeviceMacNameData>(result.ReceiptData);
            return new CommonDevice.RenameDeviceMacNameAllData { renameDeviceMacNameData = tempData };
@@ -582,17 +596,17 @@
            //如果当前是虚拟住宅
            if (Common.Config.Instance.Home.IsVirtually == true)
            {
                return Phone.ModelData.DeviceModelDataLogic.Current.ReDeviceEpointName(device, deviceName, "DeviceRename");
                return Phone.TemplateData.TemplateDeviceDataLogic.Current.ReDeviceEpointName(device, deviceName);
            }
            //获取编辑设备端点名字的命令字符
            var sendData = this.GetReDeviceEpointNameCommandText(device.DeviceAddr, device.DeviceEpoint, deviceName);
            var result = HdlDeviceCommonLogic.Current.SendJobjectDataToGateway(device, "DeviceRename", sendData, "DeviceRenameRespon");
            var result = HdlDeviceCommonLogic.Current.SendJobjectDataToGateway(device, "DeviceRename", sendData, "DeviceRenameRespon", 8);
            if (result.ErrorMsg != null || result.ErrorMsgDiv == 0)
            {
                return null;
            }
            //加缓存
            Phone.ModelData.DeviceModelDataLogic.Current.ReDeviceEpointName(device, deviceName, "DeviceRename");
            Phone.TemplateData.TemplateDeviceDataLogic.Current.ReDeviceEpointName(device, deviceName);
            var tempData = Newtonsoft.Json.JsonConvert.DeserializeObject<CommonDevice.DeviceRenameResponseData>(result.ReceiptData);
            return new CommonDevice.DeviceRenameAllData { deviceRenameData = tempData };
@@ -680,22 +694,26 @@
        /// <param name="listdevice">设备对象(MAC地址必须要相同)</param>
        public async Task<bool> DeleteDevice(List<CommonDevice> listdevice)
        {
            var data = new CommonDevice.RemoveDeviceData();
            var info = new CommonDevice.RemoveDeviceListInfo();
            info.DeviceAddr = listdevice[0].DeviceAddr;
            data.DeviceAddrList.Add(info);
            //删一次的时候,它会把MAC地址下面全部的设备都删除
            var result = await listdevice[0].DeleteDeviceAsync(data);
            if (result == null || result.removeDeviceResponseData == null || result.removeDeviceResponseData.Result != 0)
            //虚拟住宅的话,不需要删除网关的设备
            if (Config.Instance.Home.IsVirtually == false)
            {
                //设备删除失败
                string msg = Language.StringByID(R.MyInternationalizationString.uDeviceDeleteFail);
                //拼接上【网关回复超时】的Msg
                msg = UserCenterLogic.CombineGatewayTimeOutMsg(msg, result);
                var data = new CommonDevice.RemoveDeviceData();
                var info = new CommonDevice.RemoveDeviceListInfo();
                info.DeviceAddr = listdevice[0].DeviceAddr;
                data.DeviceAddrList.Add(info);
                this.ShowErrorMsg(msg);
                return false;
                //删一次的时候,它会把MAC地址下面全部的设备都删除
                var result = await listdevice[0].DeleteDeviceAsync(data);
                if (result == null || result.removeDeviceResponseData == null || result.removeDeviceResponseData.Result != 0)
                {
                    //设备删除失败
                    string msg = Language.StringByID(R.MyInternationalizationString.uDeviceDeleteFail);
                    //拼接上【网关回复超时】的Msg
                    msg = UserCenterLogic.CombineGatewayTimeOutMsg(msg, result);
                    this.ShowErrorMsg(msg);
                    return false;
                }
            }
            //删除缓存的Ota设备
@@ -723,7 +741,7 @@
        public void DeleteMemmoryDevice(CommonDevice device, bool deleteRoom = true)
        {
            //删除缓存设备的话,主页需要重新刷新
            Phone.UserView.UserPage.Instance.RefreshForm = true;
            Phone.UserView.UserPage.Instance.RefreshAllForm = true;
            if (deleteRoom == true)
            {
@@ -800,6 +818,33 @@
        #endregion
        #region ■ 同步设备___________________________
        /// <summary>
        ///  同步设备并且刷新缓存(同步失败时,会显示信息)
        /// </summary>
        /// <param name="litdevice">设备对象(MAC地址必须要相同)</param>
        public async Task<bool> SynchronizationDevice(List<CommonDevice> listdevice)
        {
            //虚拟住宅的话,不需要删除网关的设备
            if (Config.Instance.Home.IsVirtually == false)
            {
                //同步
                var result = await listdevice[0].SyncMsgToBindSource(listdevice[0].DeviceAddr, listdevice[0].DeviceEpoint);
                if (result == null || result.result != 0)
                {
                    //同步删除失败
                    string msg = Language.StringByID(R.MyInternationalizationString.SynchronizationFailed);
                    //拼接上【网关回复超时】的Msg
                    msg = UserCenterLogic.CombineGatewayTimeOutMsg(msg, result);
                    this.ShowErrorMsg(msg);
                    return false;
                }
            }
            return true;
        }
        #endregion
        #region ■ 测试设备___________________________
        /// <summary>
@@ -827,14 +872,24 @@
                //门锁没有定位功能
                return false;
            }
            var myTypeInfo = this.GetMyDeviceEnumInfo(new List<CommonDevice>() { device });
            if (device.Type == DeviceType.IASZone)
            {
                var myTypeInfo = this.GetMyDeviceEnumInfo(new List<CommonDevice>() { device });
                if (myTypeInfo.ConcreteType == DeviceConcreteType.Sensor_Pir)
                {
                    //传感器除了Pir都没有定位功能
                    return true;
                }
                else if (myTypeInfo.ConcreteType == DeviceConcreteType.Sensor_SphericalMotion)
                {
                    //球型移动传感器虽然是电池设备,但是它有定位功能
                    return true;
                }
                return false;
            }
            //温湿度传感器没有定位功能
            if (myTypeInfo.ConcreteType == DeviceConcreteType.Sensor_TemperatureHumidity)
            {
                return false;
            }
@@ -845,6 +900,22 @@
                {
                    return true;
                }
            }
            return false;
        }
        /// <summary>
        /// 检测设备是否拥有一键同步功能
        /// </summary>
        /// <param name="device"></param>
        /// <returns></returns>
        public bool DeviceIsCanSynchronization(CommonDevice device)
        {
            //获取设备类型的
            var deviceEnumInfo = Common.LocalDevice.Current.GetMyDeviceEnumInfo(new List<CommonDevice>() { device });
            if (deviceEnumInfo.ConcreteType == DeviceConcreteType.ButtonPanel_SimpleMultifunction)
            {
                return true;
            }
            return false;
        }
@@ -979,6 +1050,89 @@
        }
        /// <summary>
        /// 根据MAC地址,获取简约面板全部回路的设备对象
        /// </summary>
        /// <param name="listDevice"></param>
        /// <returns></returns>
        public List<CommonDevice> GetMutilfunctionPanelByMac(List<CommonDevice> listDevice, bool sort = true)
        {
            //和彪哥、设备和产品部同事确认:
            //简约多功能面板[不显示多余的回路,只显示携带的2个继电器,1个温度传感器,1个湿度传感器
            var list = new List<CommonDevice>();
            foreach (var dev in listDevice)
            {
                if (dev.Type == DeviceType.TemperatureSensor)
                {
                    if (dev.DeviceEpoint == 64)
                    {
                        list.Add(dev);
                    }
                }
                else if (dev.Type == DeviceType.FreshAirHumiditySensor)
                {
                    if (dev.DeviceEpoint == 65)
                    {
                        list.Add(dev);
                    }
                }
                else if (dev.Type == DeviceType.OnOffOutput)
                {
                    list.Add(dev);
                }
            }
            if (sort == false)
            {
                return list;
            }
            list.Sort((obj1, obj2) =>
            {
                if (obj1.DeviceEpoint > obj2.DeviceEpoint)
                {
                    return 1;
                }
                return -1;
            });
            return list;
        }
        /// <summary>
        /// 根据MAC地址,获取新风、简约环境面板全部回路的设备对象
        /// </summary>
        /// <param name="listDevice"></param>
        /// <returns></returns>
        public List<CommonDevice> GetPanelMatchEpointByMac(List<CommonDevice> listDevice, bool sort = true)
        {
            var list = new List<CommonDevice>();
            foreach (var dev in listDevice)
            {
                if (dev.Type == DeviceType.TemperatureSensor)
                {
                    list.Add(dev);
                }
                else if (dev.Type == DeviceType.FreshAirHumiditySensor)
                {
                    list.Add(dev);
                }
            }
            if (sort == false)
            {
                return list;
            }
            list.Sort((obj1, obj2) =>
            {
                if (obj1.DeviceEpoint > obj2.DeviceEpoint)
                {
                    return 1;
                }
                return -1;
            });
            return list;
        }
        /// <summary>
        /// 根据MAC地址,获取全部回路的设备对象(强制排序)
        /// </summary>
        /// <param name="DeviceAddr">Mac地址</param>
@@ -1032,7 +1186,7 @@
        public List<string> GetAllDeviceFile()
        {
            List<string> listDeviceFile = new List<string>();
            List<string> listAllFile = Global.FileListByHomeId();
            List<string> listAllFile = HdlFileLogic.Current.GetRootPathListFile();
            foreach (string file in listAllFile)
            {
@@ -1093,6 +1247,75 @@
        #endregion
        #region ■ 获取设备信息_______________________
        /// <summary>
        /// 读取单个端点回路设备信息
        /// </summary>
        /// <param name="device">设备对象</param>
        /// <returns></returns>
        public CommonDevice.DeviceInfoData ReadDeviceEpointDeviceInfo(CommonDevice device)
        {
            var jObject = new Newtonsoft.Json.Linq.JObject { { "DeviceAddr", device.DeviceAddr }, { "Epoint", device.DeviceEpoint }, { "Cluster_ID", 0 }, { "Command", 80 } };
            var result = HdlDeviceCommonLogic.Current.SendJobjectDataToGateway(device, "GetStatusRecord", jObject.ToString(), "GetStatusRecord_Respon");
            if (result.ErrorMsg != null || result.ErrorMsgDiv == 0)
            {
                return null;
            }
            var info = Newtonsoft.Json.JsonConvert.DeserializeObject<CommonDevice.DeviceInfoData>(result.ReceiptData);
            return info;
        }
        #endregion
        #region ■ 设置设备功能类型___________________
        /// <summary>
        /// 设置设备功能类型到网关
        /// </summary>
        /// <param name="device">设备回路</param>
        /// <param name="functionType">功能类型</param>
        /// <returns></returns>
        public bool SendDeviceFunctionTypeToGateway(CommonDevice device, DeviceFunctionType functionType)
        {
            //如果是虚拟住宅
            if (Common.Config.Instance.Home.IsVirtually == true)
            {
                device.DfunctionType = functionType;
                return true;
            }
            //获取命令字符
            var sendCommond = this.GetDeviceFunctionTypeCommandText(device, functionType);
            var result = HdlDeviceCommonLogic.Current.SendJobjectDataToGateway(device, "Device/SetEPDeviceFunctionType", sendCommond, "Device/SetEPDeviceFunctionTypeRespon");
            if (result.ErrorMsg != null || result.ErrorMsgDiv == 0)
            {
                return false;
            }
            var resultData = Newtonsoft.Json.Linq.JObject.Parse(result.ReceiptData);
            if (resultData.Property("Result") != null)
            {
                //0:修改成功 1:修改失败
                return resultData["Result"].ToString() == "0";
            }
            return false;
        }
        /// <summary>
        /// 获取更改设备功能类型的命令文本
        /// </summary>
        /// <param name="device"></param>
        /// <param name="functionType"></param>
        /// <returns></returns>
        public string GetDeviceFunctionTypeCommandText(CommonDevice device, DeviceFunctionType functionType)
        {
            var jObject = new Newtonsoft.Json.Linq.JObject { { "DeviceAddr", device.DeviceAddr }, { "Epoint", device.DeviceEpoint }, { "Cluster_ID", 0 }, { "Command", 110 } };
            var data = new Newtonsoft.Json.Linq.JObject { { "FunctionType", (int)functionType } };
            jObject.Add("Data", data);
            return jObject.ToString();
        }
        #endregion
        #region ■ 获取设备名称_______________________
        /// <summary>
@@ -1107,6 +1330,12 @@
            {
                return dName;
            }
            if (this.IsMiniLight(device) == true)
            {
                //Mini夜灯
                return Language.StringByID(R.MyInternationalizationString.uMiniNightLight);
            }
            //如果这个设备只有一个回路的话,返回Mac名字给它
            if (this.GetDevicesCountByMac(device.DeviceAddr) <= 1)
            {
@@ -1131,7 +1360,9 @@
            }
            if (device.Type == DeviceType.OnOffOutput
                || device.Type == DeviceType.DimmableLight || device.Type == DeviceType.ColorDimmableLight)
                || device.Type == DeviceType.DimmableLight
                || device.Type == DeviceType.ColorDimmableLight
                || device.Type == DeviceType.ColorTemperatureLight)
            {
                //继电器,掉光器都叫回路
                return Language.StringByID(R.MyInternationalizationString.uDeviceCircuit) + epointNo;
@@ -1140,17 +1371,7 @@
            {
                //空调都叫室内机
                return Language.StringByID(R.MyInternationalizationString.uIndoorUnit) + epointNo;
            }
            else if (device.Type == DeviceType.FreshAir)
            {
                //新风面板中的按键叫新风
                return Language.StringByID(R.MyInternationalizationString.FreshAir);
            }
            else if (device.Type == DeviceType.FreshAirHumiditySensor)
            {
                //新风面板湿度传感器
                return Language.StringByID(R.MyInternationalizationString.HumiditySensor);
            }
            }
            //获取设备类型
            var deviceInfoType = this.GetMyDeviceEnumInfo(new List<CommonDevice>() { device });
@@ -1164,24 +1385,43 @@
                //其他的干接点叫干接点
                else
                {
                    return Language.StringByID(R.MyInternationalizationString.uDeviceBelongId16) + epointNo;
                    var infoContent = this.GetDeviceModelIdNameInfo("A419");
                    return infoContent != null ? infoContent.A官方名字 : string.Empty;
                }
            }
            else if (device.Type == DeviceType.FreshAirHumiditySensor)
            {
                //新风面板/简约多功能/简约环境面板湿度传感器
                return deviceInfoType.DeviceDefultName + Language.StringByID(R.MyInternationalizationString.HumiditySensor);
            }
            else if (device.Type == DeviceType.TemperatureSensor)
            {
                if (deviceInfoType.ConcreteType == DeviceConcreteType.ButtonPanel_FangyueFreshAir)
                if (deviceInfoType.ConcreteType == DeviceConcreteType.ButtonPanel_FangyueFreshAir
                    || deviceInfoType.ConcreteType == DeviceConcreteType.ButtonPanel_SimpleEnvironment
                    || deviceInfoType.ConcreteType == DeviceConcreteType.ButtonPanel_FangyueEnvironment
                    || deviceInfoType.ConcreteType == DeviceConcreteType.ButtonPanel_SimpleMultifunction)
                {
                    //新风面板中的Thermostat为温度传感器
                    return Language.StringByID(R.MyInternationalizationString.TemperatureSensor);
                    //新风面板/简约多功能/简约/方悦环境面板 温度传感器
                    return deviceInfoType.DeviceDefultName + Language.StringByID(R.MyInternationalizationString.TemperatureSensor);
                }
                else if (deviceInfoType.BeloneType == DeviceBeloneType.A按键面板)
                {
                    //面板的温度探头叫  面板名字+温度
                    return Language.StringByID(deviceInfoType.DefultNameId) + Language.StringByID(R.MyInternationalizationString.uTemperature);
                    return deviceInfoType.DeviceDefultName + Language.StringByID(R.MyInternationalizationString.uTemperature);
                }
                else if (((TemperatureSensor)device).SensorDiv == 1)
                {
                    //温度传感器
                    return Language.StringByID(R.MyInternationalizationString.TemperatureSensor);
                }
                else if (((TemperatureSensor)device).SensorDiv == 2)
                {
                    //湿度传感器
                    return Language.StringByID(R.MyInternationalizationString.HumiditySensor);
                }
            }
            //其他情况,使用它的默认名称
            return Language.StringByID(deviceInfoType.DefultNameId) + epointNo;
            return deviceInfoType.DeviceDefultName + epointNo;
        }
        /// <summary>
@@ -1196,10 +1436,15 @@
            {
                return dName;
            }
            if (this.IsMiniLight(device) == true)
            {
                //Mini夜灯
                return Language.StringByID(R.MyInternationalizationString.uMiniNightLight);
            }
            //获取设备类型
            var deviceInfoType = this.GetMyDeviceEnumInfo(new List<CommonDevice>() { device });
            return Language.StringByID(deviceInfoType.DefultNameId);
            return deviceInfoType.DeviceDefultName;
        }
        /// <summary>
@@ -1208,7 +1453,7 @@
        /// <param name="device">设备对象</param>
        /// <param name="macName">Mac名字</param>
        /// <returns></returns>
        private void SetMacName(CommonDevice device, string macName)
        public void SetMacName(CommonDevice device, string macName)
        {
            device.DeviceName = macName;
        }
@@ -1219,7 +1464,7 @@
        /// <param name="device">设备对象</param>
        /// <param name="epointName">端点名字</param>
        /// <returns></returns>
        private void SetEpointName(CommonDevice device, string epointName)
        public void SetEpointName(CommonDevice device, string epointName)
        {
            device.DeviceEpointName = epointName;
        }
@@ -1242,32 +1487,6 @@
        public string GetSimpleEpointName(CommonDevice device)
        {
            return device.DeviceEpointName;
        }
        /// <summary>
        /// 初始化R文件里面设备默认名字的ID
        /// </summary>
        private void InitDeviceDefultNameIDList()
        {
            if (this.dicDeviceAllNameID != null)
            {
                return;
            }
            this.dicDeviceAllNameID = new Dictionary<string, int>();
            Type type = typeof(R.MyInternationalizationString);
            var PropertyList = type.GetFields();
            foreach (var item in PropertyList)
            {
                if (item.Name.StartsWith(deviceModelIdName) == true
                    || item.Name.StartsWith("uDeviceBelongId") == true)
                {
                    this.dicDeviceAllNameID[item.Name] = Convert.ToInt32(item.GetValue(null));
                }
            }
            //初始化设备枚举
            this.InitDeviceModelIdEnum();
        }
        #endregion
@@ -1587,7 +1806,7 @@
            //获取自定义设备类型
            var myInfoType = this.GetMyDeviceEnumInfo(listDevice);
            //获取设备类型的翻译名字
            string strName = Language.StringByID(myInfoType.ObjectTypeNameId);
            string strName = myInfoType.ObjectTypeName;
            if (strName == string.Empty)
            {
                //加一层保险,未知设备
@@ -1649,32 +1868,25 @@
                return null;
            }
            string[] strValue = this.dicDeviceModelIdEnum[modelKeys].Split(new string[] { "-" }, StringSplitOptions.RemoveEmptyEntries);
            int ConcreteValue = Convert.ToInt32(strValue[0]);
            int BeloneValue = Convert.ToInt32(strValue[1]);
            var nameContent = this.dicDeviceModelIdEnum[modelKeys];
            //设置设备的【设备所属类型】
            info.BeloneType = (DeviceBeloneType)BeloneValue;
            if (dicDeviceAllNameID.ContainsKey("uDeviceBelongId" + BeloneValue) == true)
            {
                //设备所属类型的翻译名字
                info.BeloneTextId = dicDeviceAllNameID["uDeviceBelongId" + BeloneValue];
            }
            info.BeloneType = (DeviceBeloneType)nameContent.BeloneTypeValue;
            info.BeloneText = nameContent.A所属名字;
            //设备具体类型
            info.ConcreteType = (DeviceConcreteType)ConcreteValue;
            if (info.ConcreteType.ToString() == ConcreteValue.ToString())
            info.ConcreteType = (DeviceConcreteType)nameContent.ConcreteTypeValue;
            if (info.ConcreteType.ToString() == nameContent.ConcreteTypeValue.ToString())
            {
                info.ConcreteType = DeviceConcreteType.UnKownDevice;
            }
            string keyName = deviceModelIdName + ConcreteValue;
            if (this.dicDeviceAllNameID.ContainsKey(keyName) == true)
            {
                //设备的官方名称
                info.ConcreteTextId = this.dicDeviceAllNameID[keyName];
            }
            //设备的官方名称
            info.ConcreteText = nameContent.A官方名字;
            //设备的类型翻译名称
            info.ObjectTypeNameId = Convert.ToInt32(strValue[2]);
            info.ObjectTypeName = nameContent.A类型名字;
            //设备默认名字
            info.DeviceDefultName = nameContent.A备注名字;
            return info;
        }
@@ -1695,33 +1907,22 @@
                || info.BeloneType == DeviceBeloneType.A彩灯)
            {
                //归为灯光
                info.ConcreteTextId = R.MyInternationalizationString.uDeviceBelongId15;
                info.BeloneType = DeviceBeloneType.A灯光;
                info.ConcreteType = DeviceConcreteType.Light;
                info.ObjectTypeNameId = 60007;//调光模块
                int value = (int)info.BeloneType;
                if (dicDeviceAllNameID.ContainsKey("uDeviceBelongId" + value) == true)
                {
                    //设备所属类型的翻译名字
                    info.BeloneTextId = dicDeviceAllNameID["uDeviceBelongId" + value];
                }
                info.ConcreteText = this.dicDeviceModelIdEnum["A418"].A官方名字;
                info.BeloneType = DeviceBeloneType.A灯光;
                info.BeloneText = this.dicDeviceModelIdEnum["A418"].A官方名字;
                info.ObjectTypeName = this.dicDeviceModelIdEnum["A418"].A类型名字;//调光模块
            }
            else if (info.BeloneType == DeviceBeloneType.A传感器
                || device.Type == DeviceType.TemperatureSensor)
                || device.Type == DeviceType.TemperatureSensor
                || device.Type == DeviceType.FreshAirHumiditySensor)
            {
                //传感器合并
                info.BeloneType = DeviceBeloneType.A传感器;
                info.ConcreteType = DeviceConcreteType.Sensor;
                info.ConcreteTextId = R.MyInternationalizationString.uDeviceBelongId1200;
                info.ObjectTypeNameId = 60000;//传感器
                int value = (int)info.BeloneType;
                if (dicDeviceAllNameID.ContainsKey("uDeviceBelongId" + value) == true)
                {
                    //设备所属类型的翻译名字
                    info.BeloneTextId = dicDeviceAllNameID["uDeviceBelongId" + value];
                }
                info.ConcreteText = this.dicDeviceModelIdEnum["A402"].A官方名字;
                info.BeloneType = DeviceBeloneType.A传感器;
                info.BeloneText = this.dicDeviceModelIdEnum["A402"].A官方名字;
                info.ObjectTypeName = this.dicDeviceModelIdEnum["A402"].A类型名字;//传感器
            }
            return info;
@@ -1749,50 +1950,50 @@
            {
                if (listdevice.Count > 1)
                {
                    info.ConcreteTextId = R.MyInternationalizationString.uDeviceBelongId200;
                    info.ConcreteText = this.dicDeviceModelIdEnum["A401"].A官方名字;
                    info.BeloneType = DeviceBeloneType.A按键面板;
                    info.ConcreteType = DeviceConcreteType.ButtonPanel;
                }
                else
                {
                    info.ConcreteTextId = R.MyInternationalizationString.uDeviceBelongId16;
                    info.ConcreteText = this.dicDeviceModelIdEnum["A419"].A官方名字;
                    info.BeloneType = DeviceBeloneType.A干接点;
                    info.ConcreteType = DeviceConcreteType.DryContact;
                }
                info.ObjectTypeNameId = 60003;//智能面板
                info.ObjectTypeName = this.dicDeviceModelIdEnum["A401"].A类型名字;//智能面板
            }
            //3包含窗帘的话,当窗帘处理
            else if (dicType.ContainsKey(DeviceType.WindowCoveringDevice) == true)
            {
                info.ConcreteTextId = R.MyInternationalizationString.uDeviceBelongId100;
                info.ConcreteText = this.dicDeviceModelIdEnum["A400"].A官方名字;
                info.BeloneType = DeviceBeloneType.A窗帘;
                info.ConcreteType = DeviceConcreteType.Curtain;
                info.ObjectTypeNameId = 60002;//遮阳模块
                info.ObjectTypeName = this.dicDeviceModelIdEnum["A400"].A类型名字;//遮阳模块
            }
            //4空气开关
            else if (dicType.ContainsKey(DeviceType.AirSwitch) == true)
            {
                //默认值
                info.ConcreteTextId = R.MyInternationalizationString.uDeviceBelongId4100;
                info.ConcreteText = this.dicDeviceModelIdEnum["A408"].A官方名字;
                info.BeloneType = DeviceBeloneType.A开关;
                info.ConcreteType = DeviceConcreteType.AirSwitch;
                info.ObjectTypeNameId = 60001;//开关模块
                info.ObjectTypeName = this.dicDeviceModelIdEnum["A408"].A类型名字;//开关模块
                if (dicType[DeviceType.AirSwitch].DfunctionType == DeviceFunctionType.A开关)
                {
                    info.ConcreteTextId = R.MyInternationalizationString.uDeviceBelongId13;
                    info.ConcreteText = this.dicDeviceModelIdEnum["A416"].A官方名字;
                    info.BeloneType = DeviceBeloneType.A开关;
                    info.ConcreteType = DeviceConcreteType.Switch;
                }
                else if (dicType[DeviceType.AirSwitch].DfunctionType == DeviceFunctionType.A插座)
                {
                    info.ConcreteTextId = R.MyInternationalizationString.uDeviceBelongId14;
                    info.ConcreteText = this.dicDeviceModelIdEnum["A417"].A官方名字;
                    info.BeloneType = DeviceBeloneType.A插座;
                    info.ConcreteType = DeviceConcreteType.Socket1;
                }
                else if (dicType[DeviceType.AirSwitch].DfunctionType == DeviceFunctionType.A灯光)
                {
                    info.ConcreteTextId = R.MyInternationalizationString.uDeviceBelongId15;
                    info.ConcreteText = this.dicDeviceModelIdEnum["A418"].A官方名字;
                    info.BeloneType = DeviceBeloneType.A灯光;
                    info.ConcreteType = DeviceConcreteType.Light;
                }
@@ -1801,26 +2002,26 @@
            else if (dicType.ContainsKey(DeviceType.OnOffOutput) == true)
            {
                //默认值
                info.ConcreteTextId = R.MyInternationalizationString.uDeviceBelongId2300;
                info.ConcreteText = this.dicDeviceModelIdEnum["A403"].A官方名字;
                info.BeloneType = DeviceBeloneType.A继电器;
                info.ConcreteType = DeviceConcreteType.Relay;
                info.ObjectTypeNameId = 60001;//开关模块
                info.ObjectTypeName = this.dicDeviceModelIdEnum["A403"].A类型名字;//开关模块
                if (dicType[DeviceType.OnOffOutput].DfunctionType == DeviceFunctionType.A开关)
                {
                    info.ConcreteTextId = R.MyInternationalizationString.uDeviceBelongId13;
                    info.ConcreteText = this.dicDeviceModelIdEnum["A416"].A官方名字;
                    info.BeloneType = DeviceBeloneType.A开关;
                    info.ConcreteType = DeviceConcreteType.Switch;
                }
                else if (dicType[DeviceType.OnOffOutput].DfunctionType == DeviceFunctionType.A插座)
                {
                    info.ConcreteTextId = R.MyInternationalizationString.uDeviceBelongId14;
                    info.ConcreteText = this.dicDeviceModelIdEnum["A417"].A官方名字;
                    info.BeloneType = DeviceBeloneType.A插座;
                    info.ConcreteType = DeviceConcreteType.Socket1;
                }
                else if (dicType[DeviceType.OnOffOutput].DfunctionType == DeviceFunctionType.A灯光)
                {
                    info.ConcreteTextId = R.MyInternationalizationString.uDeviceBelongId15;
                    info.ConcreteText = this.dicDeviceModelIdEnum["A418"].A官方名字;
                    info.BeloneType = DeviceBeloneType.A灯光;
                    info.ConcreteType = DeviceConcreteType.Light;
                }
@@ -1828,58 +2029,58 @@
            //6调光器
            else if (dicType.ContainsKey(DeviceType.DimmableLight) == true)
            {
                info.ConcreteTextId = R.MyInternationalizationString.uDeviceBelongId2500;
                info.ConcreteText = this.dicDeviceModelIdEnum["A404"].A官方名字;
                info.BeloneType = DeviceBeloneType.A调光器;
                info.ConcreteType = DeviceConcreteType.DimmableLight;
                info.ObjectTypeNameId = 60007;//调光模块
                info.ObjectTypeName = this.dicDeviceModelIdEnum["A404"].A类型名字;//调光模块
            }
            //7彩灯
            else if (dicType.ContainsKey(DeviceType.ColorDimmableLight) == true)
            {
                info.ConcreteTextId = R.MyInternationalizationString.uDeviceBelongId9;
                info.ConcreteText = this.dicDeviceModelIdEnum["A410"].A官方名字;
                info.BeloneType = DeviceBeloneType.A彩灯;
                info.ConcreteType = DeviceConcreteType.ColorLight;
                info.ObjectTypeNameId = 60007;//调光模块
                info.ObjectTypeName = this.dicDeviceModelIdEnum["A410"].A类型名字;//调光模块
            }
            //8空调
            else if (dicType.ContainsKey(DeviceType.Thermostat) == true)
            {
                info.ConcreteTextId = R.MyInternationalizationString.uDeviceBelongId3600;
                info.ConcreteText = this.dicDeviceModelIdEnum["A406"].A官方名字;
                info.BeloneType = DeviceBeloneType.A空调;
                info.ConcreteType = DeviceConcreteType.AirConditioner;
                info.ObjectTypeNameId = 60009;//空调模块
                info.ObjectTypeName = this.dicDeviceModelIdEnum["A406"].A类型名字;//空调模块
            }
            //9中继器
            else if (dicType.ContainsKey(DeviceType.Repeater) == true)
            {
                info.ConcreteTextId = R.MyInternationalizationString.uDeviceBelongId3900;
                info.ConcreteText = this.dicDeviceModelIdEnum["A407"].A官方名字;
                info.BeloneType = DeviceBeloneType.A中继器;
                info.ConcreteType = DeviceConcreteType.Repeater;
                info.ObjectTypeNameId = 60006;//系统设备
                info.ObjectTypeName = this.dicDeviceModelIdEnum["A407"].A类型名字;//系统设备
            }
            //10转换器
            else if (dicType.ContainsKey(DeviceType.Transverter) == true)
            {
                info.ConcreteTextId = R.MyInternationalizationString.uDeviceBelongId4200;
                info.ConcreteText = this.dicDeviceModelIdEnum["A409"].A官方名字;
                info.BeloneType = DeviceBeloneType.A转换器;
                info.ConcreteType = DeviceConcreteType.Converter;
                info.ObjectTypeNameId = 60008;//转换器
                info.ObjectTypeName = this.dicDeviceModelIdEnum["A409"].A类型名字;//转换器
            }
            //11智能门锁
            else if (dicType.ContainsKey(DeviceType.DoorLock) == true)
            {
                info.ConcreteTextId = R.MyInternationalizationString.uDeviceBelongId2800;
                info.ConcreteText = this.dicDeviceModelIdEnum["A405"].A官方名字;
                info.BeloneType = DeviceBeloneType.A智能门锁;
                info.ConcreteType = DeviceConcreteType.IntelligentLocks;
                info.ObjectTypeNameId = 60010;//智能门锁
                info.ObjectTypeName = this.dicDeviceModelIdEnum["A405"].A类型名字;//智能门锁
            }
            //12包含传感器的话,当传感器处理
            else if (dicType.ContainsKey(DeviceType.IASZone) == true)
            {
                info.BeloneType = DeviceBeloneType.A传感器;
                info.ConcreteType = DeviceConcreteType.Sensor;
                info.ConcreteTextId = R.MyInternationalizationString.uDeviceBelongId1200;
                info.ObjectTypeNameId = 60000;//传感器
                info.ConcreteText = this.dicDeviceModelIdEnum["A402"].A官方名字;
                info.ObjectTypeName = this.dicDeviceModelIdEnum["A402"].A类型名字;//传感器
                //设置传感器具体的类型
                this.SetSensorDeviceSpecificType(ref info, listdevice);
            }
@@ -1910,48 +2111,53 @@
                {
                    //设置传感器具体的类型
                    info.BeloneType = DeviceBeloneType.A温湿度传感器;
                    info.ConcreteTextId = R.MyInternationalizationString.uDeviceBelongId10;
                    info.ConcreteText = this.dicDeviceModelIdEnum["A411"].A官方名字;
                    info.ConcreteType = DeviceConcreteType.Sensor_TemperatureHumidity;
                }
                else if (temperatrue == true && humidity == false)
                {
                    //设置传感器具体的类型
                    info.BeloneType = DeviceBeloneType.A温度传感器;
                    info.ConcreteTextId = R.MyInternationalizationString.uDeviceBelongId11;
                    info.ConcreteText = this.dicDeviceModelIdEnum["A412"].A官方名字;
                    info.ConcreteType = DeviceConcreteType.Sensor_Temperature;
                }
                else if (temperatrue == false && humidity == true)
                {
                    //设置传感器具体的类型
                    info.BeloneType = DeviceBeloneType.A湿度传感器;
                    info.ConcreteTextId = R.MyInternationalizationString.uDeviceBelongId12;
                    info.ConcreteText = this.dicDeviceModelIdEnum["A413"].A官方名字;
                    info.ConcreteType = DeviceConcreteType.Sensor_Humidity;
                }
                info.ObjectTypeNameId = 60000;//传感器
                info.ObjectTypeName = this.dicDeviceModelIdEnum["A411"].A类型名字;//传感器
            }
            //14新风设备
            else if (dicType.ContainsKey(DeviceType.FreshAir) == true)
            {
                info.ConcreteTextId = R.MyInternationalizationString.uDeviceModelId2310;
                info.ConcreteText = this.dicDeviceModelIdEnum["A414"].A官方名字;
                info.BeloneType = DeviceBeloneType.A新风;
                info.ConcreteType = DeviceConcreteType.Relay_FangyueFreshAirModul;
                info.ObjectTypeNameId = 60011;//新风
                info.ObjectTypeName = this.dicDeviceModelIdEnum["A414"].A类型名字;//新风
            }
            //15 PM2.5传感器设备
            else if (dicType.ContainsKey(DeviceType.PMSensor) == true)
            {
                info.ConcreteTextId = R.MyInternationalizationString.uDeviceModelId1307;
                info.ConcreteText = this.dicDeviceModelIdEnum["A415"].A官方名字;
                info.BeloneType = DeviceBeloneType.APM2点5空气质量传感器;
                info.ConcreteType = DeviceConcreteType.Sensor_PMTwoPointFive;
                info.ObjectTypeNameId = 60000;//传感器
                info.ObjectTypeName = this.dicDeviceModelIdEnum["A415"].A类型名字;//传感器
            }
            //16色温灯
            else if (dicType.ContainsKey(DeviceType.ColorTemperatureLight) == true)
            {
                info.ConcreteText = this.dicDeviceModelIdEnum["A420"].A官方名字;
                info.BeloneType = DeviceBeloneType.A彩灯;
                info.ConcreteType = DeviceConcreteType.ColorLight_Temperature;
                info.ObjectTypeName = this.dicDeviceModelIdEnum["A420"].A类型名字;//调光模块
            }
            int value = (int)info.BeloneType;
            if (dicDeviceAllNameID.ContainsKey("uDeviceBelongId" + value) == true)
            {
                //设备所属类型的翻译名字
                info.BeloneTextId = dicDeviceAllNameID["uDeviceBelongId" + value];
            }
            //设备所属类型的翻译名字
            info.BeloneText = info.ConcreteText;
            info.DeviceDefultName = info.ConcreteText;
            return info;
        }
@@ -1977,43 +2183,43 @@
            {
                //运动传感器
                info.ConcreteType = DeviceConcreteType.Sensor_Motion;
                info.ConcreteTextId = R.MyInternationalizationString.uMotionSensor;
                info.ConcreteText = Language.StringByID(R.MyInternationalizationString.uMotionSensor);
            }
            else if (iasZone.IasDeviceType == 40)
            {
                //烟雾传感器
                info.ConcreteType = DeviceConcreteType.Sensor_Fire;
                info.ConcreteTextId = R.MyInternationalizationString.uDeviceModelId1302;
                info.ConcreteText = Language.StringByID(R.MyInternationalizationString.uSensorFire);
            }
            else if (iasZone.IasDeviceType == 42)
            {
                //水侵传感器
                info.ConcreteType = DeviceConcreteType.Sensor_Water;
                info.ConcreteTextId = R.MyInternationalizationString.uDeviceModelId1304;
                info.ConcreteText = Language.StringByID(R.MyInternationalizationString.uSensorWater);
            }
            else if (iasZone.IasDeviceType == 43)
            {
                //燃气传感器
                info.ConcreteType = DeviceConcreteType.Sensor_CarbonMonoxide;
                info.ConcreteTextId = R.MyInternationalizationString.uDeviceModelId1300;
                info.ConcreteText = Language.StringByID(R.MyInternationalizationString.uSensorCarbonMonoxide);
            }
            else if (iasZone.IasDeviceType == 44)
            {
                //紧急按钮
                info.ConcreteType = DeviceConcreteType.Sensor_EmergencyButton;
                info.ConcreteTextId = R.MyInternationalizationString.uDeviceModelId1305;
                info.ConcreteText = Language.StringByID(R.MyInternationalizationString.uSensorEmergencyButton);
            }
            else if (iasZone.IasDeviceType == 277)
            {
                //钥匙扣
                info.ConcreteType = DeviceConcreteType.Sensor_Keyfob;
                info.ConcreteTextId = R.MyInternationalizationString.uKeyfob;
                info.ConcreteText = Language.StringByID(R.MyInternationalizationString.uKeyfob);
            }
            else if (iasZone.IasDeviceType == 21 || iasZone.IasDeviceType == 22)
            {
                //门窗传感器
                info.ConcreteType = DeviceConcreteType.Sensor_DoorWindow;
                info.ConcreteTextId = R.MyInternationalizationString.uDeviceModelId1301;
                info.ConcreteText = Language.StringByID(R.MyInternationalizationString.uSensorDoorWindow);
            }
        }
@@ -2027,12 +2233,21 @@
        private void InitRealDeviceRoomId()
        {
            this.dicDeviceRoomId = new Dictionary<string, string>();
            string fullName = UserCenterLogic.CombinePath(DirNameResourse.DeviceRoomIdFile);
            var strData = UserCenterLogic.LoadFileContent(fullName);
            string fullName = DirNameResourse.DeviceRoomIdFile;
            var strData = HdlFileLogic.Current.ReadFileTextContent(fullName);
            if (strData != null)
            {
                this.dicDeviceRoomId = Newtonsoft.Json.JsonConvert.DeserializeObject<Dictionary<string, string>>(strData);
            }
        }
        /// <summary>
        /// 获取全部物理设备所属房间的记录
        /// </summary>
        /// <returns></returns>
        public Dictionary<string, string> GetAllRealDeviceRoomData()
        {
            return this.dicDeviceRoomId;
        }
        /// <summary>
@@ -2075,7 +2290,7 @@
                {
                    //2020.05.18追加:如果记录的房间ID是不存在的话,则重新覆盖
                    var room = HdlRoomLogic.Current.GetRoomById(this.dicDeviceRoomId[listDevice[0].DeviceAddr]);
                    if (room == null)
                    if (room == null || this.dicDeviceRoomId[listDevice[0].DeviceAddr] != roomId)
                    {
                        this.dicDeviceRoomId[listDevice[0].DeviceAddr] = roomId;
                        save = true;
@@ -2086,8 +2301,7 @@
            if (save == true)
            {
                //保存记录
                string fullName = UserCenterLogic.CombinePath(DirNameResourse.DeviceRoomIdFile);
                UserCenterLogic.SaveFileContent(fullName, this.dicDeviceRoomId);
                HdlFileLogic.Current.SaveFileContent(DirNameResourse.DeviceRoomIdFile, this.dicDeviceRoomId);
                //添加自动备份
                HdlAutoBackupLogic.AddOrEditorFile(DirNameResourse.DeviceRoomIdFile);
@@ -2107,7 +2321,7 @@
                return Language.StringByID(R.MyInternationalizationString.uDeviceNotAssignedRoom);
            }
            var room = HdlRoomLogic.Current.GetRoomById(this.dicDeviceRoomId[device.DeviceAddr]);
            return HdlRoomLogic.Current.GetFloorRoomName(room);
            return HdlRoomLogic.Current.GetRoomName(room);
        }
        /// <summary>
@@ -2155,8 +2369,7 @@
                return;
            }
            //保存记录
            string fullName = UserCenterLogic.CombinePath(DirNameResourse.DeviceRoomIdFile);
            UserCenterLogic.SaveFileContent(fullName, this.dicDeviceRoomId);
            HdlFileLogic.Current.SaveFileContent(DirNameResourse.DeviceRoomIdFile, this.dicDeviceRoomId);
            //添加自动备份
            HdlAutoBackupLogic.AddOrEditorFile(DirNameResourse.DeviceRoomIdFile);
@@ -2258,48 +2471,21 @@
        #endregion
        #region ■ 获取设备在线状态列表_______________
        /// <summary>
        /// 获取设备在线状态列表(注意,一个设备只返回一个回路)
        /// </summary>
        /// <param name="gwId">网关id</param>
        /// <returns></returns>
        public List<CommonDevice> GetDeviceOnlineList(string gwId)
        {
            var zbway = HdlGatewayLogic.Current.GetLocalGateway(gwId);
            int statu = 0;
            var listDevice = this.GetDeviceListFromGateway(zbway, ref statu, false, ShowErrorMode.NO);
            if (statu == -1)
            {
                //当出现异常时,使用后备操作,直接获取本地的设备列表
                listDevice = this.GetDeviceByGatewayID(gwId);
            }
            var listCheck = new HashSet<string>();
            var listReturn = new List<CommonDevice>();
            foreach (var device in listDevice)
            {
                if (listCheck.Contains(device.DeviceAddr) == false)
                {
                    listCheck.Add(device.DeviceAddr);
                    listReturn.Add(device);
                }
            }
            return listReturn;
        }
        #endregion
        #region ■ 一般方法___________________________
        /// <summary>
        /// 从缓存变量检测设备是否在线
        /// </summary>
        /// <param name="i_device"></param>
        /// <param name="checkAll">是否检测全部回路</param>
        /// <returns></returns>
        public bool CheckDeviceIsOnline(CommonDevice i_device)
        public bool CheckDeviceIsOnline(CommonDevice i_device, bool checkAll = true)
        {
            if (checkAll == false)
            {
                //不检测全部回路
                return i_device.IsOnline == 1 || i_device.IsOnline == 2;
            }
            var listDevice = this.GetDevicesByMac(i_device.DeviceAddr, false);
            foreach (var device in listDevice)
            {
@@ -2329,16 +2515,8 @@
            if (i_device.Type == DeviceType.OnOffOutput || i_device.Type == DeviceType.AirSwitch)
            {
                //2020.03.23追加式样:未指定类型的继电器,不显示
                if (i_device.DfunctionType == DeviceFunctionType.A未定义)
                {
                    return false;
                }
            }
            //如果是新风面板的新风设备,则不显示
            else if (i_device.Type == DeviceType.FreshAir)
            {
                var myInfoType = LocalDevice.Current.GetMyDeviceEnumInfo(new List<CommonDevice>() { i_device });
                if (myInfoType.ConcreteType == DeviceConcreteType.ButtonPanel_FangyueFreshAir)
                if (i_device.DfunctionType == DeviceFunctionType.A未定义
                    || i_device.DfunctionType == DeviceFunctionType.A不指定)
                {
                    return false;
                }
@@ -2348,6 +2526,25 @@
            {
                var myInfoType = LocalDevice.Current.GetMyDeviceEnumInfo(new List<CommonDevice>() { i_device });
                if (myInfoType.BeloneType == DeviceBeloneType.A按键面板)
                {
                    return false;
                }
            }
            else if (i_device.Type == DeviceType.FreshAirHumiditySensor)
            {
                //新风的湿度传感器不显示
                return false;
            }
            //如果是新风面板或环境面板,则都不显示任何回路
            var myInfoTypeTemp = LocalDevice.Current.GetMyDeviceEnumInfo(new List<CommonDevice>() { i_device });
            if (myInfoTypeTemp.ConcreteType == DeviceConcreteType.ButtonPanel_FangyueFreshAir || myInfoTypeTemp.ConcreteType == DeviceConcreteType.ButtonPanel_SimpleEnvironment)
            {
                return false;
            }
            else if (myInfoTypeTemp.ConcreteType == DeviceConcreteType.ButtonPanel_SimpleMultifunction)
            {
                if (i_device.Type != DeviceType.OnOffOutput)
                {
                    return false;
                }
@@ -2363,6 +2560,16 @@
        public bool IsHdlDevice(CommonDevice device)
        {
            return device.ManufacturerName == "HDL";
        }
        /// <summary>
        /// 是否是Mini夜灯
        /// </summary>
        /// <param name="device"></param>
        /// <returns></returns>
        public bool IsMiniLight(CommonDevice device)
        {
            return device.DriveCode != 0 && device.Type == DeviceType.ColorTemperatureLight;
        }
        /// <summary>
@@ -2403,22 +2610,42 @@
        }
        /// <summary>
        /// 获取模块ID所指向的各种名字信息
        /// </summary>
        /// <param name="strKey"></param>
        /// <returns></returns>
        public DeviceNameContent GetDeviceModelIdNameInfo(string strKey)
        {
            if (this.dicDeviceModelIdEnum.ContainsKey(strKey) == false)
            {
                return new DeviceNameContent();
            }
            return this.dicDeviceModelIdEnum[strKey];
        }
        /// <summary>
        /// 附加设备的版本代号(返回Ver.XXX)
        /// </summary>
        /// <param name="versionValue">版本号</param>
        /// <returns></returns>
        public string AppendVersion(int versionValue)
        {
            //10101 3个byte  显示为:ver.1.01.01
            //中间那个byte为奇数时,代表是测试版本,在显示最新版本时,不需要显示,但是在历史版本那里可以显示
            //中间那个byte为偶数时, 代表是正式版本
            //直接是10进制
            string txt10 = Convert.ToString(versionValue).PadLeft(4, '0');
            //这个是小数点前面的值
            int value1 = Convert.ToInt32(txt10.Substring(0, txt10.Length - 2));
            //这个是小数点后面的值
            int value2 = Convert.ToInt32(txt10.Substring(txt10.Length - 2, 2));
            string txt10 = Convert.ToString(versionValue).PadLeft(6, '0');
            //这个是第一位
            int value1 = Convert.ToInt32(txt10.Substring(0, 2));
            //这个是第二位
            string value2 = txt10.Substring(2, 2);
            //这个是第三位
            string value3 = txt10.Substring(4, 2);
            //Ver.
            string ver = Language.StringByID(R.MyInternationalizationString.uVersionAbbreviation);
            return ver + value1 + "." + value2.ToString().PadLeft(2, '0');
            return ver + value1 + "." + value2 + "." + value3;
        }
        /// <summary>
@@ -2427,7 +2654,7 @@
        /// <param name="msg"></param>
        private void ShowErrorMsg(string msg)
        {
            Application.RunOnMainThread(() =>
            HdlThreadLogic.Current.RunMain(() =>
            {
                var contr = new ShowMsgControl(ShowMsgType.Error, msg);
                contr.Show();
@@ -2440,7 +2667,7 @@
        /// <param name="msg"></param>
        private void ShowTipMsg(string msg)
        {
            Application.RunOnMainThread(() =>
            HdlThreadLogic.Current.RunMain(() =>
            {
                var contr = new ShowMsgControl(ShowMsgType.Tip, msg);
                contr.Show();
@@ -2459,22 +2686,11 @@
        /// </summary>
        /// <param name="zbGateway">网关对象</param>
        /// <param name="statu">状态-> -1:异常,会返回null, 1:没有异常, 2:数据接收不全</param>
        /// <param name="ignoreTime">是否无视时间(此变量是给获取在线状态用的),true:每次调用都去网关获取,false:3分钟内返回的是本地的设备</param>
        /// <param name="useLocalConnect">是否使用本地连接发送</param>
        /// <param name="mode">是否显示错误</param>
        /// <returns></returns>
        public List<CommonDevice> GetDeviceListFromGateway(ZbGateway zbGateway, ref int statu, bool ignoreTime, ShowErrorMode mode = ShowErrorMode.YES)
        public List<CommonDevice> GetDeviceListFromGateway(ZbGateway zbGateway, ref int statu, bool useLocalConnect, ShowErrorMode mode = ShowErrorMode.YES)
        {
            if (ignoreTime == false)
            {
                if ((DateTime.Now - zbGateway.LastDateTime).TotalMilliseconds < 3 * 60 * 1000)
                {
                    //不无视时间,返回本地设备列表
                    statu = 1;
                    return this.GetDeviceByGatewayID(HdlGatewayLogic.Current.GetGatewayId(zbGateway));
                }
            }
            zbGateway.LastDateTime = DateTime.Now;
            //如果切换到了别的界面,则不显示错误信息
            string nowFormId = UserCenterResourse.NowActionFormID;
@@ -2490,11 +2706,13 @@
                statu = -1;
                return null;
            }
            //需要变更功能类型的回路
            var listFucDevice = new List<CommonDevice>();
            //是否达成中断的时机
            bool canBreak = false;
            //网关ID
            string gatewayID = HdlGatewayLogic.Current.GetGatewayId(zbGateway);
            string gatewayID = zbGateway.GwId;
            //超时时间
            int TimeOut = 0;
            //设备总数
@@ -2544,10 +2762,32 @@
                                    listCheck.Add(mainkeys);
                                    //刷新一下本地缓存
                                    var localDevice = this.GetDevice(mainkeys);
                                    if (localDevice != null)
                                    var tempDevice = localDevice == null ? device : localDevice;
                                    //如果这个设备ID变更了的话
                                    bool typeNotEquals = localDevice != null && deviceID != localDevice.Type;
                                    if (typeNotEquals == true)
                                    {
                                        //刷新属性
                                        this.SetDeviceInfoToMain(localDevice, device);
                                        //重新New这个对象
                                        typeNotEquals = this.ReNewDeviceOnTypeIsChanged(localDevice, deviceID);
                                        //重新再次获取对象
                                        tempDevice = this.GetDevice(mainkeys);
                                    }
                                    //刷新属性
                                    this.SetDeviceInfoToMain(tempDevice, device);
                                    if (this.RefreshDeviceFunctionType(tempDevice, device, false) == true)
                                    {
                                        //需要发送功能类型给网关
                                        listFucDevice.Add(tempDevice);
                                    }
                                    if (typeNotEquals == true)
                                    {
                                        //重新生成缓存
                                        tempDevice.ReSave();
                                        HdlAutoBackupLogic.AddOrEditorFile(tempDevice.FilePath);
                                        //全部主页菜单需要刷新
                                        Phone.UserView.UserPage.Instance.RefreshAllForm = true;
                                    }
                                }
                            }
@@ -2571,7 +2811,15 @@
            try
            {
                var jObject = new Newtonsoft.Json.Linq.JObject { { "Cluster_ID", 0 }, { "Command", 93 } };
                realWay.Send("GetDeviceInfo", jObject.ToString());
                if (useLocalConnect == false)
                {
                    realWay.Send("GetDeviceInfo", jObject.ToString());
                }
                else
                {
                    //强制使用本地连接
                    realWay.SendLocation("GetDeviceInfo", Encoding.UTF8.GetBytes(jObject.ToString()));
                }
            }
            catch { canBreak = true; }
@@ -2615,7 +2863,59 @@
            {
                statu = 1;
            }
            if (listFucDevice.Count > 0)
            {
                //如果存在需要变更的功能类型
                HdlThreadLogic.Current.RunThread(() =>
                {
                    for (int i = 0; i < listFucDevice.Count; i++)
                    {
                        this.SendDeviceFunctionTypeToGateway(listFucDevice[i], listFucDevice[i].DfunctionType);
                        System.Threading.Thread.Sleep(100);
                    }
                });
            }
            return listDevice;
        }
        /// <summary>
        /// 在设备Type变更时,重新New这个设备对象(仅限在刷新设备列表使用,并且本地需要存在)
        /// </summary>
        /// <param name="oldLocalDevice">原来的本地对象</param>
        /// <param name="newDeviceType">新的设备Type</param>
        private bool ReNewDeviceOnTypeIsChanged(CommonDevice oldLocalDevice, DeviceType newDeviceType)
        {
            //先获取本地这个旧设备对象的json
            string oldFile = System.IO.Path.Combine(Config.Instance.FullPath, oldLocalDevice.FilePath);
            var deviceData = HdlFileLogic.Current.ReadFileTextContent(oldFile);
            if (deviceData == null)
            {
                //应该不会
                return false;
            }
            //根据新Type重新New对象
            var newDevice = CommonDevice.CommonDeviceByByteString(newDeviceType.ToString(), deviceData);
            if (newDevice == null)
            {
                //好像有点可能
                return false;
            }
            //删除本地文件
            HdlFileLogic.Current.DeleteFile(oldFile);
            HdlAutoBackupLogic.DeleteFile(oldLocalDevice.FilePath);
            //重新生成文件
            if (newDevice.IsCustomizeImage == false)
            {
                newDevice.IconPath = string.Empty;
            }
            string mainkey = this.GetDeviceMainKeys(newDevice);
            lock (dicAllDevice)
            {
                this.dicAllDevice[mainkey] = newDevice;
            }
            return true;
        }
        #endregion
@@ -2623,7 +2923,7 @@
        #region ■ 创建新设备对象相关_________________
        /// <summary>
        /// 根据设备类型创建设备对象的实例
        /// 根据设备类型创建设备对象的实例(数据在DeviceInfo中)
        /// </summary>
        /// <param name="deviceType">设备类型</param>
        /// <param name="jobject">主题Data</param>
@@ -2631,7 +2931,7 @@
        /// <returns></returns>
        private CommonDevice NewDeviceObjectByDeviceId(DeviceType deviceType, Newtonsoft.Json.Linq.JObject jobject, ZbGateway zbGateway)
        {
            string gwId = HdlGatewayLogic.Current.GetGatewayId(zbGateway);
            string gwId = zbGateway.GwId;
            //根据设备类型创建设备对象的实例
            CommonDevice device = this.NewDeviceObjectByDeviceId(deviceType);
@@ -2646,15 +2946,10 @@
            {
                return null;
            }
            this.SetMacName(device, string.Empty);
            this.SetEpointName(device, string.Empty);
            //设置设备主键类
            this.SetNewDeviceMainKeys(device, jobject);
            device.CurrentGateWayId = gwId;
            //将DeviceInfo的属性设置到主属性中
            this.SetDeviceInfoToMain(device, device);
            return device;
        }
@@ -2666,14 +2961,8 @@
        /// <param name="device">设置源设备对象</param>
        public void SetDeviceInfoToMain(CommonDevice mainDevice, CommonDevice device)
        {
            if (string.IsNullOrEmpty(device.DeviceInfo.MacName) == false)
            {
                mainDevice.DeviceName = device.DeviceInfo.MacName;
            }
            if (string.IsNullOrEmpty(device.DeviceInfo.DeviceName) == false)
            {
                mainDevice.DeviceEpointName = device.DeviceInfo.DeviceName;
            }
            mainDevice.DeviceName = device.DeviceInfo.MacName;
            mainDevice.DeviceEpointName = device.DeviceInfo.DeviceName;
            mainDevice.CurrentGateWayId = device.CurrentGateWayId;
            mainDevice.ZigbeeType = device.DeviceInfo.ZigbeeType;
            mainDevice.IsOnline = device.DeviceInfo.IsOnline;
@@ -2681,6 +2970,7 @@
            mainDevice.IasDeviceType = device.DeviceInfo.DeviceType;
            mainDevice.Profile = device.DeviceInfo.Profile;
            mainDevice.Type = device.Type;
            mainDevice.DeviceID = (int)device.Type;
            //固件版本
            mainDevice.ImgVersion = device.DeviceInfo.ImgVersion;
@@ -2694,11 +2984,20 @@
            mainDevice.ModelIdentifier = device.DeviceInfo.ModelIdentifier;
            //序列号
            mainDevice.SerialNumber = device.DeviceInfo.ProductCode;
            //设备功能类型
            mainDevice.DfunctionType = (DeviceFunctionType)device.DeviceInfo.FunctionType;
            if (mainDevice.DfunctionType == DeviceFunctionType.A不指定)
            {
                //式样变更:功能类型不允许选择为空 网关默认的FunctionType为0
                mainDevice.DfunctionType = DeviceFunctionType.A未定义;
            }
            mainDevice.InClusterList.Clear();
            mainDevice.InClusterList.AddRange(device.DeviceInfo.InClusterList);
            mainDevice.OutClusterList.Clear();
            mainDevice.OutClusterList.AddRange(device.DeviceInfo.OutClusterList);
            mainDevice.AttributeStatus.Clear();
            mainDevice.AttributeStatus.AddRange(device.DeviceInfo.AttributeStatus);
            //如果是温度传感器
            if (mainDevice.Type == DeviceType.TemperatureSensor)
@@ -2716,54 +3015,6 @@
                    }
                }
            }
            //如果是调光器
            else if (mainDevice.Type == DeviceType.DimmableLight)
            {
                mainDevice.DfunctionType = DeviceFunctionType.A灯光;
                if (mainDevice.IsCustomizeImage == false)
                {
                    mainDevice.IconPath = "Device/Light.png";
                }
            }
            //如果是三路继电器的回路的话,默认为灯光
            else if (mainDevice.Type == DeviceType.OnOffOutput)
            {
                //2020.05.13变更:继电器都默认为灯光
                //var myType = this.GetHdlMyDeviceEnumInfo(mainDevice);
                //if (myType != null && myType.ConcreteType == DeviceConcreteType.Relay_ThreeLoad)
                {
                    if (mainDevice.DfunctionType == DeviceFunctionType.A未定义)
                    {
                        mainDevice.DfunctionType = DeviceFunctionType.A灯光;
                    }
                    if (mainDevice.IsCustomizeImage == false)
                    {
                        mainDevice.IconPath = "Device/Light.png";
                    }
                }
            }
            //如果是空气开关的话
            else if (mainDevice.Type == DeviceType.AirSwitch)
            {
                //空气开关默认为开关
                if (mainDevice.DfunctionType == DeviceFunctionType.A未定义)
                {
                    mainDevice.DfunctionType = DeviceFunctionType.A开关;
                }
                if (mainDevice.IsCustomizeImage == false)
                {
                    mainDevice.IconPath = "Device/Switch.png";
                }
            }
            //如果是彩灯的话
            else if (mainDevice.Type == DeviceType.ColorDimmableLight)
            {
                mainDevice.DfunctionType = DeviceFunctionType.A灯光;
                if (mainDevice.IsCustomizeImage == false)
                {
                    mainDevice.IconPath = "Device/ColorLight.png";
                }
            }
        }
        /// <summary>
@@ -2778,10 +3029,13 @@
            //根据设备类型创建设备对象的实例
            if (deviceType == DeviceType.ColorDimmableLight) { device = new ColorDimmableLight(); }
            else if (deviceType == DeviceType.DimmableLight) { device = new DimmableLight(); }
            else if (deviceType == DeviceType.ColorDimmerSwitch) { device = new ColorDimmerSwitch(); }
            else if (deviceType == DeviceType.LevelControlSwitch) { device = new LevelControlSwitch(); }
            else if (deviceType == DeviceType.OnOffSwitch) { device = new Panel(); }
            else if (deviceType == DeviceType.OnOffOutput) { device = new ToggleLight(); }
            else if (deviceType == DeviceType.AirSwitch) { device = new AirSwitch(); }
            else if (deviceType == DeviceType.WindowCoveringDevice) { device = new Rollershade(); }
            else if (deviceType == DeviceType.WindowCoveringController) { device = new WindowCoveringController(); }
            else if (deviceType == DeviceType.IASZone) { device = new IASZone(); }
            else if (deviceType == DeviceType.Repeater) { device = new Repeater(); }
            else if (deviceType == DeviceType.Thermostat) { device = new AC(); }
@@ -2790,6 +3044,8 @@
            else if (deviceType == DeviceType.TemperatureSensor) { device = new TemperatureSensor(); }
            else if (deviceType == DeviceType.PMSensor) { device = new PMSensor(); }
            else if (deviceType == DeviceType.FreshAirHumiditySensor) { device = new HumiditySensor(); }
            else if (deviceType == DeviceType.ColorTemperatureLight) { device = new ColorTemperatureLight(); }
            else if (deviceType == DeviceType.Buzzer) { device = new Buzzer(); }
            else if (deviceType == DeviceType.OtaDevice || deviceType == DeviceType.OtaPanelDevice) { device = new OTADevice(); }
            else { return null; }
@@ -2814,6 +3070,139 @@
        #endregion
        #region ■ 刷新设备功能类型___________________
        /// <summary>
        /// 刷新设备的功能类型,如果返回true,代表需要另外调用【SendDeviceFunctionTypeToGateway】函数,sendFucType为true时自动调用
        /// </summary>
        /// <param name="mainDevice">主设备对象</param>
        /// <param name="device">设置源设备对象</param>
        /// <param name="sendFucType">当需要变更时,是否发送功能类型到网关(此变量给获取设备列表有特殊含义)</param>
        public bool RefreshDeviceFunctionType(CommonDevice mainDevice, CommonDevice device, bool sendFucType)
        {
            //如果是调光器
            if (mainDevice.Type == DeviceType.DimmableLight)
            {
                if (mainDevice.IsCustomizeImage == false)
                {
                    mainDevice.IconPath = "Device/Light.png";
                }
                mainDevice.DfunctionType = DeviceFunctionType.A灯光;
                if (device.DeviceInfo.FunctionType != (int)DeviceFunctionType.A灯光)
                {
                    //调光器固定灯光
                    if (sendFucType == true)
                    {
                        this.SendDeviceFunctionTypeToGateway(mainDevice, DeviceFunctionType.A灯光);
                    }
                    return true;
                }
            }
            //如果是色温灯
            else if (mainDevice.Type == DeviceType.ColorTemperatureLight)
            {
                if (mainDevice.IsCustomizeImage == false)
                {
                    mainDevice.IconPath = "Device/ColorLightTemperature.png";
                }
                mainDevice.DfunctionType = DeviceFunctionType.A灯光;
                if (device.DeviceInfo.FunctionType != (int)DeviceFunctionType.A灯光)
                {
                    //色温灯固定灯光
                    if (sendFucType == true)
                    {
                        this.SendDeviceFunctionTypeToGateway(mainDevice, DeviceFunctionType.A灯光);
                    }
                    return true;
                }
            }
            //如果是三路继电器的回路的话,默认为灯光
            else if (mainDevice.Type == DeviceType.OnOffOutput)
            {
                //根据功能类型,重新设置设备回路图标
                this.ResetIconPathByDeviceFunctionType(mainDevice);
                //2020.05.13变更:继电器都默认为灯光
                if (mainDevice.DfunctionType == DeviceFunctionType.A未定义)
                {
                    mainDevice.DfunctionType = DeviceFunctionType.A灯光;
                    if (device.DeviceInfo.FunctionType != (int)DeviceFunctionType.A灯光)
                    {
                        //继电器默认为灯光
                        if (sendFucType == true)
                        {
                            this.SendDeviceFunctionTypeToGateway(mainDevice, DeviceFunctionType.A灯光);
                        }
                        return true;
                    }
                }
            }
            //如果是空气开关的话
            else if (mainDevice.Type == DeviceType.AirSwitch)
            {
                //根据功能类型,重新设置设备回路图标
                this.ResetIconPathByDeviceFunctionType(mainDevice);
                //空气开关默认为开关
                if (mainDevice.DfunctionType == DeviceFunctionType.A未定义)
                {
                    mainDevice.DfunctionType = DeviceFunctionType.A开关;
                    if (device.DeviceInfo.FunctionType != (int)DeviceFunctionType.A开关)
                    {
                        //空气开关默认为开关
                        if (sendFucType == true)
                        {
                            this.SendDeviceFunctionTypeToGateway(mainDevice, DeviceFunctionType.A开关);
                        }
                        return true;
                    }
                }
            }
            //如果是彩灯的话
            else if (mainDevice.Type == DeviceType.ColorDimmableLight)
            {
                if (mainDevice.IsCustomizeImage == false)
                {
                    mainDevice.IconPath = "Device/ColorLight.png";
                }
                mainDevice.DfunctionType = DeviceFunctionType.A灯光;
                if (device.DeviceInfo.FunctionType != (int)DeviceFunctionType.A灯光)
                {
                    //彩灯默认为开关
                    if (sendFucType == true)
                    {
                        this.SendDeviceFunctionTypeToGateway(mainDevice, DeviceFunctionType.A开关);
                    }
                    return true;
                }
            }
            return false;
        }
        /// <summary>
        /// 根据功能类型,重新设置设备回路图标
        /// </summary>
        /// <param name="device"></param>
        private void ResetIconPathByDeviceFunctionType(CommonDevice device)
        {
            if (device.IsCustomizeImage == true)
            {
                return;
            }
            if (device.DfunctionType == DeviceFunctionType.A开关)
            {
                device.IconPath = "Device/Switch.png";
            }
            else if (device.DfunctionType == DeviceFunctionType.A插座)
            {
                device.IconPath = "Device/Socket1.png";
            }
            else
            {
                device.IconPath = "Device/Light.png";
            }
        }
        #endregion
        //----------------------------------分割线(设备模块ID)---------------------------------------------
        #region ■ 自定义设备模块ID___________________
@@ -2823,104 +3212,49 @@
        /// </summary>
        private void InitDeviceModelIdEnum()
        {
            //*********************************************************************
            //新设备添加方法:
            //1、在最下面添加 DeviceConcreteType ,然后是 DeviceBeloneType
            //2、以设备的具体类型为名字DeviceConcreteType(去掉【-】)添加设备的【所属图片】,【真实物理图片】。回路图片需要特殊处理
            //3、如果需要共有图片,则在这个函数的最底下添加
            //4、显示的模块ID需要交换的话,则在这个函数的最底下添加
            //*********************************************************************
            if (this.dicDeviceModelIdEnum != null)
            {
                return;
            }
            this.dicDeviceModelIdEnum = new Dictionary<string, string>();
            this.dicDeviceModelIdEnum = new Dictionary<string, DeviceNameContent>();
            //*********************************************************************
            //新设备添加方法:
            //1、在这里填写上模块ID,然后是 DeviceConcreteType ,然后是 DeviceBeloneType , 然后是 设备类型的翻译ID
            //2、然后在最下面的【自定义设备类型】折叠栏里添加【设备的具体类型】,【设备的所属类型】
            //3、以设备的具体类型为名字(去掉【-】)添加设备的【所属图片】,【真实物理图片】。回路图片需要特殊处理
            //4、添加R文件(uDeviceModelId),添加Language文件
            //5、如果需要共有图片,则在这个函数的最底下添加
            //*********************************************************************
            //前言:因为zigbeehome的设备拥有四种名字:
            //1、设备官方名称            ----它由DeviceConcreteType的数值所决定(个人中心专用)
            //2、设备入网后的默认名称    ----它不需要在代码里面定义,它直接在Language文件里面定义
            //                               范围:50000开始,它的规则是DeviceConcreteType对应的R文件里面的ID的数值+20000,
            //3、设备所属名称            ----它有DeviceBeloneType的数值所决定
            //4、设备类型名称            ----它由【设备类型的翻译ID】所决定,这个值是个人中心专用,
            //                               它是Language文件里面的 60000之后的那些值
            //定义规则:模块ID(已翻译) = 设备具体类型值 - 设备所属类型值 - 设备类型的翻译ID
            //设备具体类型值:DeviceConcreteType(在这个文件最下面进行定义)
            //设备所属类型值: DeviceBeloneType(自定义的值,嘛,只要不重复就可以,在这个文件最下面进行定义)
            //设备类型的翻译ID:这个值是个人中心专用,它是Language文件里面的 60000之后的那些值
            //=========★★开合帘类(100-199)★★=========
            this.dicDeviceModelIdEnum["MWM65B-ZB.20"] = "100-100-60002";//智能开合帘电机
            this.dicDeviceModelIdEnum["MVSM35B-ZB.20"] = "101-100-60002";//智能管状电机
            //=========★★按键面板类(200-1199)★★=========
            this.dicDeviceModelIdEnum["MPT4/R4-ZB.18"] = "200-200-60003";//4按键触摸面板(带4路继电器底座)
            this.dicDeviceModelIdEnum["MPT3/R3-ZB.18"] = "201-200-60003";//3按键触摸面板
            this.dicDeviceModelIdEnum["MPT2/R2-ZB.18"] = "202-200-60003";//2按键触摸面板
            this.dicDeviceModelIdEnum["MPT1/R1-ZB.18"] = "203-200-60003";//12按键触摸面板
            this.dicDeviceModelIdEnum["MPT4-ZB.18"] = "210-200-60003";//4按键触摸面板(只带电源底座)
            this.dicDeviceModelIdEnum["MPT4R4L/S-ZB.18"] = "220-200-60003";//简约4按键面板
            this.dicDeviceModelIdEnum["MPT3R3L/S-ZB.18"] = "221-200-60003";//简约3按键面板
            this.dicDeviceModelIdEnum["MPT2R2L/S-ZB.18"] = "222-200-60003";//简约2按键面板
            this.dicDeviceModelIdEnum["MPT4SC/S-ZB.18"] = "224-200-60003";//简约4按键场景面板
            this.dicDeviceModelIdEnum["MPT2W/S-ZB.18"] = "226-200-60003";//简约2路窗帘面板
            this.dicDeviceModelIdEnum["MP2B/TILE-ZB.18"] = "240-200-60003";//方悦单开双控面板
            this.dicDeviceModelIdEnum["MP4B/TILE-ZB.18"] = "241-200-60003";//方悦双开四控面板
            this.dicDeviceModelIdEnum["MP8B/TILE-ZB.18"] = "242-200-60003";//方悦四开八控面板
            this.dicDeviceModelIdEnum["MPFA/TILE-ZB.18"] = "250-200-60003";//方悦新风面板
            this.dicDeviceModelIdEnum["MPTE3/TILE-ZB.18"] = "253-200-60003";//方悦环境面板
            this.dicDeviceModelIdEnum["MP2W/TILE-ZB.18"] = "256-200-60003";//窗帘面板
            //=========★★PIR传感器类(1200-1299)★★=========
            this.dicDeviceModelIdEnum["MSPIR01-ZB.10"] = "1200-1200-60000";//pir传感器220
            //=========★★安防类传感器类(1300-2299)★★=========
            //这里是麦乐克的
            this.dicDeviceModelIdEnum["MULTI-GASE--EA07"] = "1300-1200-60000";//燃气传感器
            this.dicDeviceModelIdEnum["MULTI-MECI--EA01"] = "1301-1200-60000";//门窗磁传感器
            this.dicDeviceModelIdEnum["MULTI-FIRE--EA05"] = "1302-1200-60000";//烟雾传感器
            this.dicDeviceModelIdEnum["MULTI-MOTI--EA04"] = "1303-1200-60000";//红外传感器
            this.dicDeviceModelIdEnum["MULTI-WATE--EA02"] = "1304-1200-60000";//水浸传感器
            this.dicDeviceModelIdEnum["MULTI-BURO--EA06"] = "1305-1200-60000";//紧急按键
            //这里是河东的
            this.dicDeviceModelIdEnum["MSG01/M-ZB.10"] = "1300-1200-60000";//燃气传感器
            this.dicDeviceModelIdEnum["MSDC01/M-ZB.10"] = "1301-1200-60000";//门窗磁传感器
            this.dicDeviceModelIdEnum["MSS01/M-ZB.10"] = "1302-1200-60000";//烟雾传感器
            this.dicDeviceModelIdEnum["MSPIR01/M-ZB.10"] = "1303-1200-60000";//红外传感器
            this.dicDeviceModelIdEnum["MSW01/M-ZB.10"] = "1304-1200-60000";//水浸传感器
            this.dicDeviceModelIdEnum["MBU01/M-ZB.10"] = "1305-1200-60000";//紧急按键
            this.dicDeviceModelIdEnum["MGCD01/ZB.10"] = "1306-1200-60000";//吸顶燃气传感器
            //PM2.5空气质量传感器 【该设备属于第三方设备,没有镜像ID】
            this.dicDeviceModelIdEnum["SZ_PM100"] = "1307-1200-60000";//PM2.5空气质量传感器
            //=========★★继电器类(2300-2499)★★=========
            this.dicDeviceModelIdEnum["MPR0310-ZB.10"] = "2300-2300-60001";//3路继电器小模块
            this.dicDeviceModelIdEnum["MFA01-ZB.10"] = "2310-2300-60011";//方悦新风小模块
            //=========★★调光器类(2500-2799)★★=========
            this.dicDeviceModelIdEnum["MPD0101-ZB.10"] = "2500-2500-60007";//1路调光器小模块
            //=========★★智能门锁类(2800-????)★★=========
            this.dicDeviceModelIdEnum["H06C"] = "2800-2800-60010";//智能门锁(H06C)
            this.dicDeviceModelIdEnum["S-one"] = "2802-2800-60010";//智能门锁(S-one)
            //=========★★空调类(3600-3899)★★=========
            this.dicDeviceModelIdEnum["MAC/GW-ZB.10"] = "3600-3600-60009";//zigbee空调网关模块
            //=========★★中继器类(3900-3999)★★=========
            this.dicDeviceModelIdEnum["MSR-ZB.10"] = "3900-3900-60006"; //zigbee中继器
            //=========★★空气开关类(4100-4199)★★=========
            this.dicDeviceModelIdEnum["MBCI01-ZB.10"] = "4100-4100-60001";//zigbee微断云控制器
            //=========★★转换器类(4200-4699)★★=========
            this.dicDeviceModelIdEnum["MBUS/GW-ZB.10"] = "4200-4200-60008";//zigbee转buspro协议转换器
            this.dicDeviceModelIdEnum["M485/GW-ZB.10"] = "4201-4200-60008";//zigbee转485协议转换器
            var listText = this.GetDeviceNameFileContent();
            foreach (var dataText in listText)
            {
                if (dataText == string.Empty || dataText.StartsWith(";") == true)
                {
                    //这是注释
                    continue;
                }
                string[] strArry1 = dataText.Split(new string[] { "=" }, StringSplitOptions.RemoveEmptyEntries);
                if (strArry1.Length != 2)
                {
                    //非法设置
                    continue;
                }
                string[] strArry2 = strArry1[1].Split(new string[] { "/" }, StringSplitOptions.RemoveEmptyEntries);
                if (strArry2.Length < 6)
                {
                    //非法设置
                    continue;
                }
                var content = new DeviceNameContent();
                content.ConcreteTypeValue = Convert.ToInt32(strArry2[0].Trim());
                content.A官方名字 = strArry2[1].Trim();
                content.A备注名字 = strArry2[2].Trim();
                content.BeloneTypeValue= Convert.ToInt32(strArry2[3].Trim());
                content.A所属名字 = strArry2[4].Trim();
                content.A类型名字 = strArry2[5].Trim();
                this.dicDeviceModelIdEnum[strArry1[0].Trim()] = content;
            }
            //✩✩✩✩✩需要交换的模块ID✩✩✩✩✩
            this.dicDeviceModelIdChanged = new Dictionary<string, string>();
@@ -2932,8 +3266,6 @@
            this.dicDeviceModelIdChanged["MULTI-WATE--EA02"] = "MSW01/M-ZB.10";//水浸传感器
            this.dicDeviceModelIdChanged["MULTI-BURO--EA06"] = "MBU01/M-ZB.10";//紧急按键
            //✩✩✩✩✩需要共有的图片对象✩✩✩✩✩
            //两者都是DeviceConcreteType
            //Keys:指定的设备    value:沿用的图片是哪款设备的
@@ -2943,6 +3275,55 @@
            this.dicPictrueShard["ButtonPanel_SimpleTwo"] = "ButtonPanel_Two";//简约2按键面板 沿用 2按键的图标
            this.dicPictrueShard["IntelligentLocks_Sone"] = "IntelligentLocks_H06C";//S-one的门锁图片 沿用 H06C的图标
            this.dicPictrueShard["Relay_FangyueFreshAirModul"] = "Relay_ThreeLoad";//方悦新风小模块图片 沿用 3路继电器的图标
            this.dicPictrueShard["ButtonPanel_FourButtonScene"] = "ButtonPanel_Four";//简约4按键场景面板 沿用 4按键面板的图标
        }
        /// <summary>
        /// 获取设备名字文件的内容
        /// </summary>
        /// <returns></returns>
        private List<string> GetDeviceNameFileContent()
        {
            System.IO.StreamReader streamReader = null;
            var listText = new List<string>();
            try
            {
#if iOS
                string textFile = Foundation.NSBundle.MainBundle.PathForResource("DeviceName.ini", null);
                streamReader = new System.IO.StreamReader(textFile, Encoding.UTF8);
                string text;
                while ((text = streamReader.ReadLine()) != null)
                {
                    listText.Add(text.Trim());
                }
                return listText;
#endif
#if Android
                var stream = Application.Activity.Assets.Open("DeviceName.ini");
                streamReader = new System.IO.StreamReader(stream, Encoding.UTF8);
                string text;
                while ((text = streamReader.ReadLine()) != null)
                {
                    listText.Add(text.Trim());
                }
                stream.Close();
                return listText;
#endif
            }
            catch
            {
                return listText;
            }
            finally
            {
                try
                {
                    streamReader?.Close();
                }
                catch
                {
                }
            }
        }
        #endregion
@@ -2951,13 +3332,10 @@
    #region ■ 自定义设备类型_________________________
    /// <summary>
    /// <para>仅限底层使用:设备的具体【设备类型】,自定义与模块id关联的枚举(值为LocalDevice里面dicDeviceModelIdEnum所指定的DeviceConcreteType值)</para>
    /// <para>变量名可以作为【设备类型】图片,这个值是瞎写的,没什么特殊意义</para>
    /// <para>设备的具体【设备类型】,变量名可以作为【设备类型】图片,这个值是瞎写的,没什么特殊意义</para>
    /// </summary>
    public enum DeviceConcreteType
    {
        //定义规则:【设备类型】图片名字=LocalDevice里面dicDeviceModelIdEnum所指定的DeviceConcreteType值
        /// <summary>
        /// 未知设备
        /// </summary>
@@ -3046,6 +3424,14 @@
        /// 窗帘面板 镜像id:256
        /// </summary>
        ButtonPanel_Curtain = 256,
        /// <summary>
        /// 简约多功能面板 镜像ID:212
        /// </summary>
        ButtonPanel_SimpleMultifunction = 212,
        /// <summary>
        /// 简约环境面板
        /// </summary>
        ButtonPanel_SimpleEnvironment = 230,
        //=========★★PIR传感器类(1200-1299)★★=========
        /// <summary>
@@ -3056,6 +3442,10 @@
        /// pir传感器220 镜像id:1200
        /// </summary>
        Sensor_Pir = 1200,
        /// <summary>
        /// 球形移动传感器 镜像id:1205
        /// </summary>
        Sensor_SphericalMotion = 1205,
        //=========★★安防类传感器类(1300-2299)★★=========
        /// <summary>
@@ -3090,6 +3480,10 @@
        /// PM2.5空气质量传感器
        /// </summary>
        Sensor_PMTwoPointFive = 1307,
        /// <summary>
        /// 温湿度传感器(这个单词拼错了,但是错了就错了呗,就这样了)
        /// </summary>
        Sensor_TemperatureHumidity = 1308,
        /// <summary>
        /// 运动传感器
@@ -3100,11 +3494,7 @@
        /// </summary>
        Sensor_Keyfob = -1307,
        /// <summary>
        /// 温湿度传感器
        /// </summary>
        Sensor_TemperatureHumidity = -1308,
        /// <summary>
        /// 温度传感器
        /// 温度传感器(这个单词拼错了,但是错了就错了呗,就这样了)
        /// </summary>
        Sensor_Temperature = -1309,
        /// <summary>
@@ -3125,7 +3515,19 @@
        /// 方悦新风小模块 镜像id:2310
        /// </summary>
        Relay_FangyueFreshAirModul = 2310,
        /// <summary>
        /// 国标3路10A继电器小模块 镜像id:2311(临时)
        /// </summary>
        Relay_NationalThreeLoadTenA = 2311,
        /// <summary>
        /// 欧标2路5A继电器小模块 镜像id:2312(临时)
        /// </summary>
        Relay_EuropeanTwoLoadFiveA = 2312,
        /// <summary>
        /// 欧标14路干接点小模块 镜像id:2313(临时)
        /// </summary>
        Relay_EuropeanFourteenLoadDryContact = 2313,
        //=========★★调光器类(2500-2799)★★=========
        /// <summary>
        /// 调光器
@@ -3155,6 +3557,10 @@
        /// 彩灯
        /// </summary>
        ColorLight = -10,
        /// <summary>
        /// 色温灯(它的镜像ID未定,暂定20000)
        /// </summary>
        ColorLight_Temperature = 20000,
        //=========★★空调(3600-3899)★★=========
        /// <summary>
@@ -3220,8 +3626,7 @@
    }
    /// <summary>
    /// <para>仅限底层使用:设备所属的【设备种类】,自定义与模块id关联的枚举(值为LocalDevice里面dicDeviceModelIdEnum所指定的DeviceBeloneType值)</para>
    /// <para>这个值是瞎写的,没什么特殊意义</para>
    /// <para>设备所属枚举,这个值是瞎写的,没什么特殊意义</para>
    /// </summary>
    public enum DeviceBeloneType
    {