黄学彪
2020-11-19 9ef48d7b2da7c408b53f73be0f6eef3cbac1c84a
ZigbeeApp/Shared/Common/Device.cs
@@ -81,10 +81,6 @@
        /// 设备的总回路(keys:Mac地址  value:全部端口号)
        /// </summary>
        private Dictionary<string, HashSet<int>> dicDeviceEpoint = new Dictionary<string, HashSet<int>>();
        /// <summary>
        /// 物理设备属于哪个房间的记录
        /// </summary>
        private Dictionary<string, string> dicDeviceRoomId = null;
        #endregion
@@ -107,9 +103,16 @@
            {
                CommonDevice device = null;
                //反序列化为指定的类,不然数据会丢失而导致无法强转
                try
                try
                {
                    device = CommonDevice.CommonDeviceByFilePath(file);
                    //读取它的内容
                    var fileData = HdlFileLogic.Current.ReadFileTextContent(System.IO.Path.Combine(Config.Instance.FullPath, file));
                    var jobject = Newtonsoft.Json.Linq.JObject.Parse(fileData);
                    if (jobject.Property("DeviceID") == null)
                    {
                        continue;
                    }
                    device = CommonDevice.CommonDeviceByByteString(Convert.ToInt32(jobject["DeviceID"].ToString()), fileData);
                }
                catch (Exception ex) { HdlLogLogic.Current.WriteLog(ex); }
@@ -152,6 +155,15 @@
                }
                this.dicDeviceEpoint[device.DeviceAddr].Add(device.DeviceEpoint);
                //对应旧版本的设备文件 Device_OnoffOutput_abcdfrtgg_01
                bool bolSave = file.Split(new string[] { "_" }, StringSplitOptions.None).Length == 4;
                if (bolSave == true)
                {
                    //删掉这个文件,重新生成
                    HdlAutoBackupLogic.DeleteFile(file);
                    Global.DeleteFilebyHomeId(file);
                }
                //检测Ui图片是否正确,这个图片本地是否存在?
                if (string.IsNullOrEmpty(IO.FileUtils.GetImageFilePath(device.IconPath)) == true)
                {
@@ -159,12 +171,28 @@
                    device.IconPath = string.Empty;
                    device.ReSave();
                    HdlAutoBackupLogic.AddOrEditorFile(device.FilePath);
                    bolSave = false;
                }
                //重新生成文件
                if (bolSave == true)
                {
                    device.ReSave();
                    HdlAutoBackupLogic.AddOrEditorFile(device.FilePath);
                }
            }
            //成员身份的时候,删除掉非法的网关文件
            this.DeleteGatewayFileByMemberModel();
            //初始化物理设备所属房间的记录
            this.InitRealDeviceRoomId();
            HdlRoomLogic.Current.InitRealDeviceRoomId();
#if DEBUG
            if (UserCenterResourse.HideOption.CenterHideMenu == 1)
            {
                //检测一些代码配置(debug)
                this.CheckOhtherSettion();
            }
#endif
        }
        /// <summary>
@@ -200,6 +228,38 @@
            }
        }
        /// <summary>
        /// 检测一些代码配置(debug)
        /// </summary>
        private void CheckOhtherSettion()
        {
            foreach (var item in Enum.GetValues(typeof(DeviceType)))
            {
                string itemName = item.ToString();
                int itemValue = (int)item;
                if (itemName == "UnKown" || itemName == "ZbGateway")
                {
                    continue;
                }
                var device = this.NewDeviceObjectByDeviceId((DeviceType)itemValue, 1);
                string strMsg = string.Empty;
                if (device == null)
                {
                    strMsg = itemName + "没有实装(1)";
                }
                device = CommonDevice.CommonDeviceByByteString(itemValue, "{}");
                if (device == null)
                {
                    strMsg += "\r\n" + itemName + "没有实装(2)";
                }
                if (strMsg != string.Empty)
                {
                    this.ShowErrorMsg(strMsg);
                    return;
                }
            }
        }
        #endregion
        #region ■ 添加设备___________________________
@@ -208,14 +268,14 @@
        /// <para>将指定网关的设备存入缓存中(从新获取镜像)</para>
        /// <para>-1:异常 1:正常 2:设备信息缺损</para>
        /// </summary>
        /// <param name="zbGateway">网关对象</param>
        /// <param name="gatewayId">网关Id</param>
        /// <param name="useLocalConnect">是否强制使用本地连接发送</param>
        public int SetDeviceToMemmoryByGateway(ZbGateway zbGateway, bool useLocalConnect)
        public int SetDeviceToMemmoryByGateway(string gatewayId, bool useLocalConnect)
        {
            //从网关获取全部的设备
            int statu = 0;
            List<CommonDevice> listDevice = new List<CommonDevice>();
            List<CommonDevice> list = this.GetDeviceListFromGateway(zbGateway, ref statu, useLocalConnect);
            List<CommonDevice> list = this.GetDeviceListFromGateway(gatewayId, ref statu, useLocalConnect);
            if (list == null)
            {
                return -1;
@@ -223,12 +283,11 @@
            listDevice.AddRange(list);
            //获取这个网关的本地所有设备
            string gwID = zbGateway.GwId;
            List<CommonDevice> listLocalDevices = this.GetDeviceByGatewayID(gwID);
            List<CommonDevice> listLocalDevices = this.GetDeviceByGatewayID(gatewayId);
            //获取ota设备
            foreach (var ota in this.dicOTADevice.Values)
            {
                if (ota.CurrentGateWayId == gwID)
                if (ota.CurrentGateWayId == gatewayId)
                {
                    listLocalDevices.Add(ota);
                }
@@ -260,7 +319,10 @@
                    dicExist.Remove(maikey);
                }
                //获取设备的固定属性
                HdlDeviceFixedAttributeLogic.Current.SetAllFixedAttributeToDevice(device);
                if (HdlDeviceFixedAttributeLogic.Current.SetAllFixedAttributeToDevice(device) == true)
                {
                    System.Threading.Thread.Sleep(200);
                }
                //对未命名的虚拟设备重新命名
                if (device.DriveCode > 0 && this.GetSimpleEpointName(device) == string.Empty)
                {
@@ -297,7 +359,7 @@
            if (listDeleteMac.Count > 0)
            {
                //将真实物理设备从房间中移除
                this.DeleteRealDeviceFromRoom(listDeleteMac);
                HdlRoomLogic.Current.DeleteRealDeviceFromRoom(listDeleteMac);
            }
            return statu;
@@ -382,6 +444,12 @@
        public void AddVirtualDeviceToMemory(CommonDevice device)
        {
            string mainKeys = this.GetDeviceMainKeys(device);
            if (device is OTADevice)
            {
                this.dicOTADevice[mainKeys] = (OTADevice)device;
                device.ReSave();
                return;
            }
            this.dicAllDevice[mainKeys] = device;
            //设备回路收集
@@ -720,13 +788,9 @@
            {
                this.DeleteMemmoryDevice(device);
            }
            //移除真实设备的房间索引
            HdlRoomLogic.Current.DeleteRealDeviceFromRoom(listdevice[0]);
            if (this.dicDeviceRoomId.ContainsKey(listdevice[0].DeviceAddr) == true)
            {
                //移除真实设备的房间索引
                this.dicDeviceRoomId.Remove(listdevice[0].DeviceAddr);
                this.SaveRealDeviceRoomId(null, null);
            }
            return true;
        }
@@ -762,6 +826,8 @@
                    this.dicDeviceEpoint[device.DeviceAddr].Remove(device.DeviceEpoint);
                }
            }
            //删除模板数据
            Phone.TemplateData.TemplateCommonLogic.Current.DeleteDevice(device);
            //删除设备文件
            string filePath = device.FilePath;
@@ -847,13 +913,25 @@
        /// <summary>
        /// 发送定位指令到设备
        /// </summary>
        /// <param name="device"></param>
        public void SetFixedPositionCommand(CommonDevice device)
        /// <param name="device">设备回路</param>
        /// <param name="isRealDevice">是否是定位真实设备</param>
        public void SetFixedPositionCommand(CommonDevice device, bool isRealDevice = false)
        {
            //如果当前住宅不是虚拟住宅
            if (Common.Config.Instance.Home.IsVirtually == false)
            {
                device.IdentifyControl(device.DeviceAddr, device.DeviceEpoint, 5);
                int epoint = device.DeviceEpoint;
                //如果是定位真实设备的话
                if (isRealDevice == true)
                {
                    var myType = this.GetMyDeviceEnumInfo(new List<CommonDevice> { device });
                    if (myType.ConcreteType == DeviceConcreteType.DimmableLight_OneLoad)
                    {
                        //一路调光器需要发8回路
                        epoint = 8;
                    }
                }
                device.IdentifyControl(device.DeviceAddr, epoint, 5);
            }
        }
@@ -1100,7 +1178,7 @@
        /// <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)
            {
@@ -1111,7 +1189,7 @@
                else if (dev.Type == DeviceType.FreshAirHumiditySensor)
                {
                    list.Add(dev);
                }
                }
            }
            if (sort == false)
            {
@@ -1125,7 +1203,7 @@
                    return 1;
                }
                return -1;
            });
            });
            return list;
        }
@@ -1247,7 +1325,7 @@
        #region ■ 获取设备信息_______________________
        /// <summary>
        /// 读取单个端点回路设备信息
        /// 从网关读取单个端点回路设备信息
        /// </summary>
        /// <param name="device">设备对象</param>
        /// <returns></returns>
@@ -1263,6 +1341,145 @@
            return info;
        }
        /// <summary>
        /// 从网关读取指定Mac下的设备列表(返回的是网关回复的设备Json,调用ConvertJObjectToDevice方法转为Device对象)
        /// </summary>
        /// <param name="realGateway">真实网关对象</param>
        /// <param name="i_deviceMac">设备Mac</param>
        /// <param name="useLocalConnect">是否使用本地连接发送</param>
        /// <param name="listFucDevice">需要变更功能类型的回路</param>
        /// <param name="statu">状态-> -1:异常,会返回null, 1:没有异常, 2:数据接收不全</param>
        /// <returns></returns>
        public List<Newtonsoft.Json.Linq.JObject> ReadDeviceListByMacFromGateway(string gatewayId, string i_deviceMac, bool useLocalConnect, ref int statu)
        {
            //是否达成中断的时机
            bool canBreak = false;
            //超时时间
            int TimeOut = 0;
            //设备总数
            int deviceCount = -1;
            //接收数
            int receiveCount = 0;
            //设备列表
            var listDeviceJson = new List<Newtonsoft.Json.Linq.JObject>();
            HdlGatewayReceiveLogic.Current.AddGatewayReceiveEvent(gatewayId, (topic, message) =>
            {
                if (topic == gatewayId + "/GetStatusRecord_Respon")
                {
                    lock (listDeviceJson)
                    {
                        //设备接收数
                        receiveCount++;
                        TimeOut = 0;
                        var jobject = Newtonsoft.Json.Linq.JObject.Parse(message);
                        var totalNum = Newtonsoft.Json.JsonConvert.DeserializeObject<int>(jobject["Data"]["TotalNum"].ToString());
                        if (totalNum == 0)
                        {
                            //这个网关没有设备
                            canBreak = true;
                            return;
                        }
                        if (deviceCount == -1)
                        {
                            //设置需要接收多少个设备
                            deviceCount = totalNum;
                        }
                        listDeviceJson.Add(jobject);
                    }
                    if (receiveCount == deviceCount && deviceCount != -1)
                    {
                        //设备全部接收完成
                        canBreak = true;
                    }
                }
            });
            var jObject = new Newtonsoft.Json.Linq.JObject { { "DeviceAddr", i_deviceMac }, { "Epoint", 255 }, { "Cluster_ID", 0 }, { "Command", 80 } };
            HdlGatewayLogic.Current.SendJobjectData(gatewayId, "GetStatusRecord", jObject.ToString(), useLocalConnect);
            while (canBreak == false && TimeOut <= 150)
            {
                System.Threading.Thread.Sleep(20);
                TimeOut++;
            }
            //移除监听
            HdlGatewayReceiveLogic.Current.RemoveGatewayReceiveEvent();
            if (TimeOut > 150)
            {
                statu = listDeviceJson.Count == 0 ? -1 : 2;
            }
            else
            {
                statu = 1;
            }
            return listDeviceJson;
        }
        /// <summary>
        /// 将设备的Json转换为设备对象
        /// </summary>
        /// <param name="listIObjects">设备Json</param>
        /// <param name="gwId">网关id</param>
        /// <param name="listFucDevice">需要变更功能类型的回路</param>
        /// <returns></returns>
        public List<CommonDevice> ConvertJObjectToDevice(List<Newtonsoft.Json.Linq.JObject> listIObjects, string gwId, ref List<CommonDevice> listFucDevice)
        {
            //设备列表
            var listDevice = new List<CommonDevice>();
            //网关里面有可能会有重复的回路
            var listCheck = new HashSet<string>();
            foreach (var jobject in listIObjects)
            {
                var deviceID = (DeviceType)jobject.Value<int>("Device_ID");
                //根据设备类型创建设备对象的实例
                var device = this.NewDeviceObjectByDeviceId(deviceID, jobject, gwId);
                if (device != null)
                {
                    string mainkeys = this.GetDeviceMainKeys(device);
                    //网关里面有可能会有重复的回路
                    if (listCheck.Contains(mainkeys) == false)
                    {
                        listDevice.Add(device);
                        listCheck.Add(mainkeys);
                        //刷新一下本地缓存
                        var localDevice = this.GetDevice(mainkeys);
                        var tempDevice = localDevice == null ? device : localDevice;
                        //如果这个设备ID变更了的话
                        bool typeNotEquals = localDevice != null && deviceID != localDevice.Type;
                        if (typeNotEquals == true)
                        {
                            //重新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;
                        }
                    }
                }
            }
            return listDevice;
        }
        #endregion
        #region ■ 设置设备功能类型___________________
@@ -1275,10 +1492,15 @@
        /// <returns></returns>
        public bool SendDeviceFunctionTypeToGateway(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);
            var result = HdlDeviceCommonLogic.Current.SendJobjectDataToGateway(device, "Device/SetEPDeviceFunctionType", jObject.ToString(), "Device/SetEPDeviceFunctionTypeRespon");
            //如果是虚拟住宅
            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;
@@ -1290,6 +1512,20 @@
                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
@@ -1338,7 +1574,7 @@
            }
            if (device.Type == DeviceType.OnOffOutput
                || device.Type == DeviceType.DimmableLight
                || device.Type == DeviceType.DimmableLight
                || device.Type == DeviceType.ColorDimmableLight
                || device.Type == DeviceType.ColorTemperatureLight)
            {
@@ -1349,7 +1585,7 @@
            {
                //空调都叫室内机
                return Language.StringByID(R.MyInternationalizationString.uIndoorUnit) + epointNo;
            }
            }
            //获取设备类型
            var deviceInfoType = this.GetMyDeviceEnumInfo(new List<CommonDevice>() { device });
@@ -1364,7 +1600,7 @@
                else
                {
                    var infoContent = this.GetDeviceModelIdNameInfo("A419");
                    return infoContent != null ? infoContent.A官方名字 : string.Empty;
                    return infoContent != null ? infoContent.A官方名字 + epointNo : string.Empty;
                }
            }
            else if (device.Type == DeviceType.FreshAirHumiditySensor)
@@ -1376,9 +1612,10 @@
            {
                if (deviceInfoType.ConcreteType == DeviceConcreteType.ButtonPanel_FangyueFreshAir
                    || deviceInfoType.ConcreteType == DeviceConcreteType.ButtonPanel_SimpleEnvironment
                    || deviceInfoType.ConcreteType == DeviceConcreteType.ButtonPanel_FangyueEnvironment
                    || deviceInfoType.ConcreteType == DeviceConcreteType.ButtonPanel_SimpleMultifunction)
                {
                    //新风面板/简约多功能/简约环境面板 温度传感器
                    //新风面板/简约多功能/简约/方悦环境面板 温度传感器
                    return deviceInfoType.DeviceDefultName + Language.StringByID(R.MyInternationalizationString.TemperatureSensor);
                }
                else if (deviceInfoType.BeloneType == DeviceBeloneType.A按键面板)
@@ -1657,30 +1894,36 @@
        /// <summary>
        /// 获取【设备功能类型】的菜单图标
        /// </summary>
        /// <param name="specificType">自定义设备类型</param>
        /// <param name="deviceEnumInfo">自定义设备类型</param>
        /// <param name="unSelectPath">图片地址</param>
        /// <param name="selectPath">图片地址</param>
        /// <returns></returns>
        public void GetDeviceFunctionTypeMenuIcon(DeviceConcreteType specificType, ref string unSelectPath, ref string selectPath)
        public void GetDeviceFunctionTypeMenuIcon(DeviceEnumInfo deviceEnumInfo, ref string unSelectPath, ref string selectPath)
        {
            //新风小模块
            if (specificType == DeviceConcreteType.Relay_FangyueFreshAirModul)
            if (deviceEnumInfo.ConcreteType == DeviceConcreteType.Relay_FangyueFreshAirModul)
            {
                unSelectPath = "Device/FreshAirEpoint.png";
                selectPath = "Device/FreshAirEpointSelected.png";
                return;
            }
            //PM2.5空气质量传感器
            else if (specificType == DeviceConcreteType.Sensor_PMTwoPointFive)
            else if (deviceEnumInfo.ConcreteType == DeviceConcreteType.Sensor_PMTwoPointFive)
            {
                unSelectPath = "Device/AirQualitySensorEpoint.png";
                selectPath = "Device/AirQualitySensorEpointSelected.png";
                return;
            }
            else if (deviceEnumInfo.BeloneType == DeviceBeloneType.A窗帘)
            {
                unSelectPath = "ZigeeLogic/curtain.png";
                selectPath = "ZigeeLogic/selectedcurtain.png";
                return;
            }
            //上面需要特殊处理
            //获取【设备类型】的图标
            this.GetDeviceObjectIcon(specificType, ref unSelectPath, ref selectPath);
            this.GetDeviceObjectIcon(deviceEnumInfo.ConcreteType, ref unSelectPath, ref selectPath);
        }
        /// <summary>
@@ -2202,177 +2445,6 @@
        #endregion
        #region ■ 物理设备所属房间___________________
        /// <summary>
        /// 初始化物理设备所属房间的记录
        /// </summary>
        private void InitRealDeviceRoomId()
        {
            this.dicDeviceRoomId = new Dictionary<string, string>();
            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>
        /// 保存物理设备所属房间的记录
        /// </summary>
        /// <param name="listDevice">需要保存的设备对象</param>
        /// <param name="roomId">需要保存的哪个设备的房间ID</param>
        /// <param name="saveRoadDevice">如果只有一个回路,是否把回路的房间一起修改</param>
        public void SaveRealDeviceRoomId(List<CommonDevice> listDevice, string roomId, bool saveRoadDevice = true)
        {
            if (listDevice == null)
            {
                return;
            }
            //如果设备只有一个回路,如果改变了真实设备区域,则它的回路的区域也一起改了
            if (saveRoadDevice == true && listDevice != null && listDevice.Count == 1)
            {
                if (listDevice[0] is OTADevice)
                {
                    //单纯只是Ota设备则不处理
                    return;
                }
                HdlRoomLogic.Current.ChangedRoom(listDevice[0], roomId, false);
            }
            bool save = false;
            if (roomId == string.Empty)
            {
                //选择的是未分配
                this.dicDeviceRoomId.Remove(listDevice[0].DeviceAddr);
                save = true;
            }
            else
            {
                if (this.dicDeviceRoomId.ContainsKey(listDevice[0].DeviceAddr) == false)
                {
                    this.dicDeviceRoomId[listDevice[0].DeviceAddr] = roomId;
                    save = true;
                }
                else
                {
                    //2020.05.18追加:如果记录的房间ID是不存在的话,则重新覆盖
                    var room = HdlRoomLogic.Current.GetRoomById(this.dicDeviceRoomId[listDevice[0].DeviceAddr]);
                    if (room == null || this.dicDeviceRoomId[listDevice[0].DeviceAddr] != roomId)
                    {
                        this.dicDeviceRoomId[listDevice[0].DeviceAddr] = roomId;
                        save = true;
                    }
                }
            }
            if (save == true)
            {
                //保存记录
                HdlFileLogic.Current.SaveFileContent(DirNameResourse.DeviceRoomIdFile, this.dicDeviceRoomId);
                //添加自动备份
                HdlAutoBackupLogic.AddOrEditorFile(DirNameResourse.DeviceRoomIdFile);
            }
        }
        /// <summary>
        /// 获取真实物理设备的房间名字
        /// </summary>
        /// <param name="device">设备的某一个回路</param>
        /// <returns></returns>
        public string GeteRealDeviceRoomName(CommonDevice device)
        {
            if (this.dicDeviceRoomId.ContainsKey(device.DeviceAddr) == false)
            {
                //未分配区域
                return Language.StringByID(R.MyInternationalizationString.uDeviceNotAssignedRoom);
            }
            var room = HdlRoomLogic.Current.GetRoomById(this.dicDeviceRoomId[device.DeviceAddr]);
            return HdlRoomLogic.Current.GetRoomName(room);
        }
        /// <summary>
        /// 获取真实物理设备属于哪个房间
        /// </summary>
        /// <param name="device">设备的某一个回路</param>
        /// <returns></returns>
        public Room GeteRealDeviceRoom(CommonDevice device)
        {
            if (this.dicDeviceRoomId.ContainsKey(device.DeviceAddr) == false)
            {
                return null;
            }
            return HdlRoomLogic.Current.GetRoomById(this.dicDeviceRoomId[device.DeviceAddr]);
        }
        /// <summary>
        /// 将真实物理设备从房间中移除
        /// </summary>
        /// <param name="device">随便一个回路</param>
        public void DeleteRealDeviceFromRoom(CommonDevice device)
        {
            //将真实物理设备从房间中移除
            this.DeleteRealDeviceFromRoom(new List<string>() { device.DeviceAddr });
        }
        /// <summary>
        /// 将真实物理设备从房间中移除
        /// </summary>
        /// <param name="listMac">设备Mac地址</param>
        public void DeleteRealDeviceFromRoom(List<string> listMac)
        {
            bool save = false;
            foreach (var deviceMacAddr in listMac)
            {
                if (this.dicDeviceRoomId.ContainsKey(deviceMacAddr) == true)
                {
                    this.dicDeviceRoomId.Remove(deviceMacAddr);
                    save = true;
                }
            }
            if (save == false)
            {
                //没有改变,不需要保存
                return;
            }
            //保存记录
            HdlFileLogic.Current.SaveFileContent(DirNameResourse.DeviceRoomIdFile, this.dicDeviceRoomId);
            //添加自动备份
            HdlAutoBackupLogic.AddOrEditorFile(DirNameResourse.DeviceRoomIdFile);
        }
        /// <summary>
        /// 根据房间ID,移除指定的真实物理设备的所属房间记录
        /// </summary>
        /// <param name="i_RoomId"></param>
        public void DeleteRealDeviceByRoomId(string i_RoomId)
        {
            var listDeleteKey = new List<string>();
            foreach (var deviceAddr in this.dicDeviceRoomId.Keys)
            {
                if (this.dicDeviceRoomId[deviceAddr] == i_RoomId
                    && listDeleteKey.Contains(deviceAddr) == false)
                {
                    listDeleteKey.Add(deviceAddr);
                }
            }
            //将真实物理设备从房间中移除
            this.DeleteRealDeviceFromRoom(listDeleteKey);
        }
        #endregion
        #region ■ 设备排序___________________________
        /// <summary>
@@ -2442,7 +2514,7 @@
            //其他的看着办呗,都是排在后面的,都归为这个属性
            list.Add(DeviceBeloneType.A未知设备);
            return list;
        }
@@ -2510,6 +2582,11 @@
            else if (i_device.Type == DeviceType.FreshAirHumiditySensor)
            {
                //新风的湿度传感器不显示
                return false;
            }
            if (((int)i_device.Type).ToString() == i_device.Type.ToString())
            {
                //此设备id在DeviceType里面还没有注册,则不能显示出来
                return false;
            }
@@ -2633,7 +2710,7 @@
        {
            HdlThreadLogic.Current.RunMain(() =>
            {
                var contr = new ShowMsgControl(ShowMsgType.Error, msg);
                var contr = new ShowMsgControl(Phone.ShowMsgType.Error, msg);
                contr.Show();
            });
        }
@@ -2646,7 +2723,7 @@
        {
            HdlThreadLogic.Current.RunMain(() =>
            {
                var contr = new ShowMsgControl(ShowMsgType.Tip, msg);
                var contr = new ShowMsgControl(Phone.ShowMsgType.Tip, msg);
                contr.Show();
            });
        }
@@ -2658,164 +2735,157 @@
        #region ■ 获取设备列表的接口_________________
        /// <summary>
        /// <para>从网关重新获取设备列表(返回的设备为虚拟出来的)</para>
        /// <para>从网关重新获取设备列表(返回的设备为虚拟出来的),一次性全部获取</para>
        /// <para>statu状态 -1:异常,会返回null, 1:没有异常, 2:数据接收不全</para>
        /// </summary>
        /// <param name="zbGateway">网关对象</param>
        /// <param name="gatewayId">网关id</param>
        /// <param name="statu">状态-> -1:异常,会返回null, 1:没有异常, 2:数据接收不全</param>
        /// <param name="useLocalConnect">是否使用本地连接发送</param>
        /// <param name="mode">是否显示错误</param>
        /// <returns></returns>
        public List<CommonDevice> GetDeviceListFromGateway(ZbGateway zbGateway, ref int statu, bool useLocalConnect, ShowErrorMode mode = ShowErrorMode.YES)
        public List<CommonDevice> GetDeviceListFromGateway(string gatewayId, ref int statu, bool useLocalConnect, ShowErrorMode mode = ShowErrorMode.YES)
        {
            //如果切换到了别的界面,则不显示错误信息
            string nowFormId = UserCenterResourse.NowActionFormID;
            ZbGateway realWay = null;
            if (HdlGatewayLogic.Current.GetRealGateway(ref realWay, zbGateway) == false)
            {
                if (nowFormId == UserCenterResourse.NowActionFormID && mode == ShowErrorMode.YES)
                {
                    //错误:网关对象丢失
                    string msg = Language.StringByID(R.MyInternationalizationString.uErrorGatewayLostMsg);
                    this.ShowTipMsg(msg);
                }
                statu = -1;
                return null;
            }
            //需要变更功能类型的回路
            var listFucDevice = new List<CommonDevice>();
            //是否达成中断的时机
            bool canBreak = false;
            //网关ID
            string gatewayID = zbGateway.GwId;
            //超时时间
            int TimeOut = 0;
            //当前设备接收数
            int nowReceiveCount = 0;
            //设备总数
            int deviceCount = -1;
            //接收数
            int receiveCount = 0;
            //设备列表
            var listDevice = new List<CommonDevice>();
            //网关里面有可能会有重复的回路
            var listCheck = new HashSet<string>();
            Action<string, string> getDeviceAction = (topic, message) =>
            ///Mac的端点总数
            var dicMacPointCount = new Dictionary<string, int>();
            HdlGatewayReceiveLogic.Current.AddGatewayReceiveEvent(gatewayId, (topic, message) =>
            {
                if (topic == gatewayID + "/DeviceInfoRespon")
                if (topic == gatewayId + "/DeviceInfoRespon")
                {
                    try
                    lock (listDevice)
                    {
                        lock (listDevice)
                        TimeOut = 0;
                        var jobject = Newtonsoft.Json.Linq.JObject.Parse(message);
                        var totalNum = Convert.ToInt32(jobject["Data"]["TotalNum"].ToString());
                        if (totalNum == 0)
                        {
                            //设备接收数
                            receiveCount++;
                            //这个网关没有设备
                            canBreak = true;
                            return;
                        }
                        if (deviceCount == -1)
                        {
                            //设置需要接收多少个设备
                            deviceCount = totalNum;
                        }
                        nowReceiveCount++;
                            TimeOut = 0;
                            var jobject = Newtonsoft.Json.Linq.JObject.Parse(message);
                            var totalNum = Newtonsoft.Json.JsonConvert.DeserializeObject<int>(jobject["Data"]["TotalNum"].ToString());
                            if (totalNum == 0)
                            {
                                //这个网关没有设备
                                canBreak = true;
                                return;
                            }
                            if (deviceCount == -1)
                            {
                                //设置需要接收多少个设备
                                deviceCount = totalNum;
                            }
                        //设备回路数收集
                        string deviceMac = jobject.Value<string>("DeviceAddr");
                        if (dicMacPointCount.ContainsKey(deviceMac) == false)
                        {
                            dicMacPointCount[deviceMac] = 0;
                        }
                        dicMacPointCount[deviceMac]++;
                            var deviceID = (DeviceType)jobject.Value<int>("Device_ID");
                            //根据设备类型创建设备对象的实例
                            var device = this.NewDeviceObjectByDeviceId(deviceID, jobject, zbGateway);
                            if (device != null)
                        var deviceID = (DeviceType)jobject.Value<int>("Device_ID");
                        //根据设备类型创建设备对象的实例
                        var device = this.NewDeviceObjectByDeviceId(deviceID, jobject, gatewayId);
                        if (device != null)
                        {
                            string mainkeys = this.GetDeviceMainKeys(device);
                            //网关里面有可能会有重复的回路
                            if (listCheck.Contains(mainkeys) == false)
                            {
                                string mainkeys = this.GetDeviceMainKeys(device);
                                //网关里面有可能会有重复的回路
                                if (listCheck.Contains(mainkeys) == false)
                                listDevice.Add(device);
                                listCheck.Add(mainkeys);
                                //刷新一下本地缓存
                                var localDevice = this.GetDevice(mainkeys);
                                var tempDevice = localDevice == null ? device : localDevice;
                                //如果这个设备ID变更了的话
                                bool typeNotEquals = localDevice != null && deviceID != localDevice.Type;
                                if (typeNotEquals == true)
                                {
                                    listDevice.Add(device);
                                    listCheck.Add(mainkeys);
                                    //刷新一下本地缓存
                                    var localDevice = this.GetDevice(mainkeys);
                                    var tempDevice = localDevice == null ? device : localDevice;
                                    //重新New这个对象
                                    typeNotEquals = this.ReNewDeviceOnTypeIsChanged(localDevice, deviceID);
                                    //重新再次获取对象
                                    tempDevice = this.GetDevice(mainkeys);
                                }
                                    //刷新属性
                                    this.SetDeviceInfoToMain(tempDevice, device);
                                    if (this.RefreshDeviceFunctionType(tempDevice, device, false) == true)
                                    {
                                        //需要发送功能类型给网关
                                        listFucDevice.Add(tempDevice);
                                    }
                                //刷新属性
                                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;
                                }
                            }
                        }
                    }
                    //Log出力
                    catch (Exception ex) { HdlLogLogic.Current.WriteLog(ex); }
                    if (receiveCount == deviceCount && deviceCount != -1)
                    if (nowReceiveCount >= deviceCount)
                    {
                        //设备全部接收完成
                        canBreak = true;
                    }
                }
                else if (topic == gatewayID + "/DeviceInfoResponEnd")
                {
                }
            };
            });
            //发送命令
            var jObject = new Newtonsoft.Json.Linq.JObject { { "Cluster_ID", 0 }, { "Command", 93 } };
            HdlGatewayLogic.Current.SendJobjectData(gatewayId, "GetDeviceInfo", jObject.ToString(), useLocalConnect);
            realWay.Actions += getDeviceAction;
            try
            {
                var jObject = new Newtonsoft.Json.Linq.JObject { { "Cluster_ID", 0 }, { "Command", 93 } };
                if (useLocalConnect == false)
                {
                    realWay.Send("GetDeviceInfo", jObject.ToString());
                }
                else
                {
                    //强制使用本地连接
                    realWay.SendLocation("GetDeviceInfo", Encoding.UTF8.GetBytes(jObject.ToString()));
                }
            }
            catch { canBreak = true; }
            while (canBreak == false && TimeOut < 60)
            while (canBreak == false && TimeOut <= 30)
            {
                System.Threading.Thread.Sleep(100);
                TimeOut++;
            }
            //移除网关监听事件
            HdlGatewayReceiveLogic.Current.RemoveGatewayReceiveEvent();
            realWay.Actions -= getDeviceAction;
            getDeviceAction = null;
            if (TimeOut >= 60)
            if (TimeOut > 30)
            {
                if (listDevice.Count == 0)
                if (listDevice.Count > 0)
                {
                    if (nowFormId == UserCenterResourse.NowActionFormID && mode == ShowErrorMode.YES)
                    {
                        //获取设备列表失败
                        //[XXXX]网关回复超时,请稍后再试
                        string msg = Language.StringByID(R.MyInternationalizationString.uGetDeviceListFail);
                        msg += "\r\n[" + HdlGatewayLogic.Current.GetGatewayName(zbGateway).ToString() + "]";
                        msg = UserCenterLogic.CombineGatewayTimeOutMsg(msg, null, "回复超时", false);
                        this.ShowTipMsg(msg);
                    }
                    statu = -1;
                    return null;
                }
                else
                {
                    if (nowFormId == UserCenterResourse.NowActionFormID && mode == ShowErrorMode.YES)
                    //网络不稳定,设备列表信息缺损,则采用按序号获取设备
                    statu = this.GetDeviceListFromGatewayByMac(gatewayId, ref listDevice, ref listFucDevice, dicMacPointCount, useLocalConnect);
                    if (statu == 2)
                    {
                        //网络不稳定,设备列表信息缺损
                        string msg = Language.StringByID(R.MyInternationalizationString.uNetworkUnStableAndDeviceInfoIsNotFull);
                        this.ShowTipMsg(msg);
                    }
                    statu = 2;
                }
                else
                {
                    if (mode == ShowErrorMode.YES)
                    {
                        //获取设备列表失败
                        //[XXXX]网关回复超时,请稍后再试
                        string msg = Language.StringByID(R.MyInternationalizationString.uGetDeviceListFail);
                        var localGw = HdlGatewayLogic.Current.GetLocalGateway(gatewayId);
                        if (localGw != null)
                        {
                            msg += "\r\n[" + HdlGatewayLogic.Current.GetGatewayName(localGw).ToString() + "]";
                        }
                        msg = UserCenterLogic.CombineGatewayTimeOutMsg(msg, null, "回复超时", false);
                        this.ShowTipMsg(msg);
                    }
                    statu = -1;
                    return null;
                }
            }
            else
@@ -2838,6 +2908,129 @@
            return listDevice;
        }
        /// <summary>
        /// 根据序号获取设备列表信息(只有在设备缺损的时候才调用这个函数) 1:正常 2:设备缺损
        /// </summary>
        /// <param name="gatewayId">网关id</param>
        /// <param name="listDevice">存储的设备对象集合</param>
        /// <param name="listFucDevice">需要变更功能类型的回路</param>
        /// <param name="dicNowPointCount">当前已经获取的Mac的端点总数</param>
        /// <param name="useLocalConnect">是否使用本地连接发送</param>
        /// <returns></returns>
        public int GetDeviceListFromGatewayByMac(string gatewayId, ref List<CommonDevice> listDevice, ref List<CommonDevice> listFucDevice, Dictionary<string, int> dicNowPointCount, bool useLocalConnect)
        {
            //首先先获取设备的mac列表
            var jObject33 = new Newtonsoft.Json.Linq.JObject { { "Cluster_ID", 0 }, { "Command", 87 } };
            var result = HdlGatewayLogic.Current.SendJobjectDataToGateway(gatewayId, "GetStatusRecord", jObject33.ToString(), "DeviceMACDeviceListRespon", 3, useLocalConnect);
            if (result.ErrorMsgDiv == -1 || result.ErrorMsgDiv == 0)
            {
                //如果网关没有对这个主题做出回应的话,则说明它是一个旧网关
                return 2;
            }
            var resultMac = Newtonsoft.Json.JsonConvert.DeserializeObject<ReceiptMacResult>(result.ReceiptData);
            //设备列表
            var listDeviceJson = new List<Newtonsoft.Json.Linq.JObject>();
            int statu = 0;
            foreach (var macInfo in resultMac.MACDeviceList)
            {
                if (dicNowPointCount.ContainsKey(macInfo.MacAddr) == true
                    && dicNowPointCount[macInfo.MacAddr] == macInfo.EPTotalNum)
                {
                    //如果这个mac的端点数一致,则说明已经接收齐了,不需要再次接收
                    continue;
                }
                //从网关读取指定Mac下的设备列表
                var jsonData = this.ReadDeviceListByMacFromGateway(gatewayId, macInfo.MacAddr, useLocalConnect, ref statu);
                foreach (var myData in jsonData)
                {
                    listDeviceJson.Add(myData);
                }
                if (statu != 1)
                {
                    //没有正常完成,则中断
                    break;
                }
            }
            //转化为设备列表
            var listTempDevice = this.ConvertJObjectToDevice(listDeviceJson, gatewayId, ref listFucDevice);
            for (int i = 0; i < listTempDevice.Count; i++)
            {
                listDevice.Add(listTempDevice[i]);
            }
            return statu == 1 ? 1 : 2;
        }
        /// <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((int)newDeviceType, 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;
        }
        /// <summary>
        /// 接收设备Mac列表的类
        /// </summary>
        private class ReceiptMacResult
        {
            /// <summary>
            /// mac总数
            /// </summary>
            public int MACDeviceTotalNum = 0;
            /// <summary>
            /// 设备mac列表
            /// </summary>
            public List<MacResult> MACDeviceList = new List<MacResult>();
        }
        /// <summary>
        /// 设备Mac的内容
        /// </summary>
        private class MacResult
        {
            /// <summary>
            /// 设备Mac
            /// </summary>
            public string MacAddr = string.Empty;
            /// <summary>
            /// mac端点的总数
            /// </summary>
            public int EPTotalNum = 0;
        }
        #endregion
        #region ■ 创建新设备对象相关_________________
@@ -2847,14 +3040,12 @@
        /// </summary>
        /// <param name="deviceType">设备类型</param>
        /// <param name="jobject">主题Data</param>
        /// <param name="zbGateway">网关对象</param>
        /// <param name="gwid">网关id</param>
        /// <returns></returns>
        private CommonDevice NewDeviceObjectByDeviceId(DeviceType deviceType, Newtonsoft.Json.Linq.JObject jobject, ZbGateway zbGateway)
        private CommonDevice NewDeviceObjectByDeviceId(DeviceType deviceType, Newtonsoft.Json.Linq.JObject jobject, string gwid)
        {
            string gwId = zbGateway.GwId;
            //根据设备类型创建设备对象的实例
            CommonDevice device = this.NewDeviceObjectByDeviceId(deviceType);
            CommonDevice device = this.NewDeviceObjectByDeviceId(deviceType, jobject.Value<int>("Epoint"));
            if (device == null)
            {
                return null;
@@ -2869,7 +3060,7 @@
            //设置设备主键类
            this.SetNewDeviceMainKeys(device, jobject);
            device.CurrentGateWayId = gwId;
            device.CurrentGateWayId = gwid;
            return device;
        }
@@ -2890,6 +3081,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;
@@ -2940,33 +3132,16 @@
        /// 根据设备Type创建对应的设备对象
        /// </summary>
        /// <param name="deviceType">设备Type</param>
        /// <param name="DeviceEpoint">设备端点(没有什么特殊需求的话,填0即可)</param>
        /// <returns></returns>
        public CommonDevice NewDeviceObjectByDeviceId(DeviceType deviceType)
        public CommonDevice NewDeviceObjectByDeviceId(DeviceType deviceType, int DeviceEpoint)
        {
            CommonDevice device = null;
            //根据设备类型创建设备对象的实例
            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(); }
            else if (deviceType == DeviceType.FreshAir) { device = new FreshAir(); }
            else if (deviceType == DeviceType.DoorLock) { device = new DoorLock(); }
            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; }
            var device = CommonDevice.CommonDeviceByByteString((int)deviceType, "{\"DeviceID\":" + (int)deviceType + ",\"DeviceEpoint\":" + DeviceEpoint + "}");
            if (device == null)
            {
                return null;
            }
            device.DeviceEpointName = string.Empty;
            device.DeviceName = string.Empty;
@@ -3007,7 +3182,7 @@
                    mainDevice.IconPath = "Device/Light.png";
                }
                mainDevice.DfunctionType = DeviceFunctionType.A灯光;
                if (device.DeviceInfo.FunctionType != (int)DeviceFunctionType.A灯光)
                if (device.DeviceInfo != null && device.DeviceInfo.FunctionType != (int)DeviceFunctionType.A灯光)
                {
                    //调光器固定灯光
                    if (sendFucType == true)
@@ -3025,7 +3200,7 @@
                    mainDevice.IconPath = "Device/ColorLightTemperature.png";
                }
                mainDevice.DfunctionType = DeviceFunctionType.A灯光;
                if (device.DeviceInfo.FunctionType != (int)DeviceFunctionType.A灯光)
                if (device.DeviceInfo != null && device.DeviceInfo.FunctionType != (int)DeviceFunctionType.A灯光)
                {
                    //色温灯固定灯光
                    if (sendFucType == true)
@@ -3044,7 +3219,7 @@
                if (mainDevice.DfunctionType == DeviceFunctionType.A未定义)
                {
                    mainDevice.DfunctionType = DeviceFunctionType.A灯光;
                    if (device.DeviceInfo.FunctionType != (int)DeviceFunctionType.A灯光)
                    if (device.DeviceInfo != null && device.DeviceInfo.FunctionType != (int)DeviceFunctionType.A灯光)
                    {
                        //继电器默认为灯光
                        if (sendFucType == true)
@@ -3064,7 +3239,7 @@
                if (mainDevice.DfunctionType == DeviceFunctionType.A未定义)
                {
                    mainDevice.DfunctionType = DeviceFunctionType.A开关;
                    if (device.DeviceInfo.FunctionType != (int)DeviceFunctionType.A开关)
                    if (device.DeviceInfo != null && device.DeviceInfo.FunctionType != (int)DeviceFunctionType.A开关)
                    {
                        //空气开关默认为开关
                        if (sendFucType == true)
@@ -3083,7 +3258,7 @@
                    mainDevice.IconPath = "Device/ColorLight.png";
                }
                mainDevice.DfunctionType = DeviceFunctionType.A灯光;
                if (device.DeviceInfo.FunctionType != (int)DeviceFunctionType.A灯光)
                if (device.DeviceInfo != null && device.DeviceInfo.FunctionType != (int)DeviceFunctionType.A灯光)
                {
                    //彩灯默认为开关
                    if (sendFucType == true)
@@ -3169,7 +3344,7 @@
                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.BeloneTypeValue = Convert.ToInt32(strArry2[3].Trim());
                content.A所属名字 = strArry2[4].Trim();
                content.A类型名字 = strArry2[5].Trim();
                this.dicDeviceModelIdEnum[strArry1[0].Trim()] = content;
@@ -3434,7 +3609,19 @@
        /// 方悦新风小模块 镜像id:2310
        /// </summary>
        Relay_FangyueFreshAirModul = 2310,
        /// <summary>
        /// 国标3路10A继电器小模块 镜像id:2301
        /// </summary>
        Relay_NationalThreeLoadTenA = 2301,
        /// <summary>
        /// 欧标2路5A继电器小模块 镜像id:2315
        /// </summary>
        Relay_EuropeanTwoLoadFiveA = 2315,
        /// <summary>
        /// 7路干接点输入输出模块 镜像id:2320
        /// </summary>
        Relay_SevenLoadInOutPutDryContact = 2320,
        //=========★★调光器类(2500-2799)★★=========
        /// <summary>
        /// 调光器