From c7df85937f73fb347ee0b19e9c052d2d00a6df6c Mon Sep 17 00:00:00 2001
From: 黄学彪 <hxb@hdlchina.com.cn>
Date: 星期五, 18 九月 2020 13:58:19 +0800
Subject: [PATCH] 新版本

---
 ZigbeeApp/Shared/Common/Device.cs |  275 +++++++++++++++++++++++++++++++++++++++++++-----------
 1 files changed, 218 insertions(+), 57 deletions(-)

diff --git a/ZigbeeApp/Shared/Common/Device.cs b/ZigbeeApp/Shared/Common/Device.cs
index 8b92a87..ec7fb84 100755
--- a/ZigbeeApp/Shared/Common/Device.cs
+++ b/ZigbeeApp/Shared/Common/Device.cs
@@ -99,7 +99,7 @@
             this.dicDeviceEpoint.Clear();
 
             //鍒濆鍖栬澶囨灇涓�
-            this.InitDeviceModelIdEnum();
+            this.InitDeviceModelIdEnum();
 
             //鑾峰彇鏈湴鍏ㄩ儴鐨勮澶囨枃浠�
             List<string> listFile = this.GetAllDeviceFile();
@@ -165,6 +165,14 @@
             this.DeleteGatewayFileByMemberModel();
             //鍒濆鍖栫墿鐞嗚澶囨墍灞炴埧闂寸殑璁板綍
             this.InitRealDeviceRoomId();
+
+#if DEBUG
+            if (UserCenterResourse.HideOption.CenterHideMenu == 1)
+            {
+                //妫�娴嬩竴浜涗唬鐮侀厤缃�(debug)
+                this.CheckOhtherSettion();
+            }
+#endif
         }
 
         /// <summary>
@@ -196,6 +204,38 @@
                 {
                     //杩欎釜缃戝叧瀵逛簬褰撳墠杩欎釜鎴愬憳鏉ヨ鏄潪娉曠殑
                     HdlGatewayLogic.Current.DeleteGatewayFile(gwId);
+                }
+            }
+        }
+
+        /// <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);
+                string strMsg = string.Empty;
+                if (device == null)
+                {
+                    strMsg = itemName + "娌℃湁瀹炶(1)";
+                }
+                device = CommonDevice.CommonDeviceByByteString(itemName, "{}");
+                if (device == null)
+                {
+                    strMsg += "\r\n" + itemName + "娌℃湁瀹炶(2)";
+                }
+                if (strMsg != string.Empty)
+                {
+                    this.ShowErrorMsg(strMsg);
+                    return;
                 }
             }
         }
@@ -260,7 +300,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)
                 {
@@ -382,6 +425,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;
 
             //璁惧鍥炶矾鏀堕泦
@@ -565,7 +614,7 @@
             //濡傛灉褰撳墠鏄櫄鎷熶綇瀹�
             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鍚嶅瓧鐨勫懡浠ゅ瓧绗�
@@ -576,7 +625,7 @@
                 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 };
@@ -593,7 +642,7 @@
             //濡傛灉褰撳墠鏄櫄鎷熶綇瀹�
             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);
@@ -603,7 +652,7 @@
                 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 };
@@ -762,6 +811,8 @@
                     this.dicDeviceEpoint[device.DeviceAddr].Remove(device.DeviceEpoint);
                 }
             }
+            //鍒犻櫎妯℃澘鏁版嵁
+            Phone.TemplateData.TemplateCommonLogic.Current.DeleteDevice(device);
 
             //鍒犻櫎璁惧鏂囦欢
             string filePath = device.FilePath;
@@ -847,13 +898,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);
             }
         }
 
@@ -885,7 +948,7 @@
                 return false;
             }
             //娓╂箍搴︿紶鎰熷櫒娌℃湁瀹氫綅鍔熻兘
-            if (myTypeInfo.ConcreteType == DeviceConcreteType.Sensor_TemperatrueHumidity)
+            if (myTypeInfo.ConcreteType == DeviceConcreteType.Sensor_TemperatureHumidity)
             {
                 return false;
             }
@@ -1275,10 +1338,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 +1358,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
@@ -1364,7 +1446,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,15 +1458,26 @@
             {
                 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鎸夐敭闈㈡澘)
                 {
                     //闈㈡澘鐨勬俯搴︽帰澶村彨  闈㈡澘鍚嶅瓧+娓╁害
                     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);
                 }
             }
             //鍏朵粬鎯呭喌,浣跨敤瀹冪殑榛樿鍚嶇О
@@ -1420,7 +1513,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;
         }
@@ -1431,7 +1524,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;
         }
@@ -1647,30 +1740,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>
@@ -2079,14 +2178,14 @@
                     //璁剧疆浼犳劅鍣ㄥ叿浣撶殑绫诲瀷
                     info.BeloneType = DeviceBeloneType.A娓╂箍搴︿紶鎰熷櫒;
                     info.ConcreteText = this.dicDeviceModelIdEnum["A411"].A瀹樻柟鍚嶅瓧;
-                    info.ConcreteType = DeviceConcreteType.Sensor_TemperatrueHumidity;
+                    info.ConcreteType = DeviceConcreteType.Sensor_TemperatureHumidity;
                 }
                 else if (temperatrue == true && humidity == false)
                 {
                     //璁剧疆浼犳劅鍣ㄥ叿浣撶殑绫诲瀷
                     info.BeloneType = DeviceBeloneType.A娓╁害浼犳劅鍣�;
                     info.ConcreteText = this.dicDeviceModelIdEnum["A412"].A瀹樻柟鍚嶅瓧;
-                    info.ConcreteType = DeviceConcreteType.Sensor_Temperatrue;
+                    info.ConcreteType = DeviceConcreteType.Sensor_Temperature;
                 }
                 else if (temperatrue == false && humidity == true)
                 {
@@ -2188,12 +2287,6 @@
                 info.ConcreteType = DeviceConcreteType.Sensor_DoorWindow;
                 info.ConcreteText = Language.StringByID(R.MyInternationalizationString.uSensorDoorWindow);
             }
-            else if (iasZone.IasDeviceType == 541)
-            {
-                //鐞冨瀷绉诲姩浼犳劅鍣�
-                info.ConcreteType = DeviceConcreteType.Sensor_SphericalMotion;
-                info.ConcreteText = this.dicDeviceModelIdEnum["MSPIRB-ZB.10"].A瀹樻柟鍚嶅瓧;
-            }
         }
 
         #endregion
@@ -2231,19 +2324,18 @@
         /// <param name="saveRoadDevice">濡傛灉鍙湁涓�涓洖璺�,鏄惁鎶婂洖璺殑鎴块棿涓�璧蜂慨鏀�</param>
         public void SaveRealDeviceRoomId(List<CommonDevice> listDevice, string roomId, bool saveRoadDevice = true)
         {
-            if (listDevice == null)
+            if (listDevice == null || listDevice.Count == 0)
             {
                 return;
             }
             //濡傛灉璁惧鍙湁涓�涓洖璺紝濡傛灉鏀瑰彉浜嗙湡瀹炶澶囧尯鍩燂紝鍒欏畠鐨勫洖璺殑鍖哄煙涔熶竴璧锋敼浜�
-            if (saveRoadDevice == true && listDevice != null && listDevice.Count == 1)
+            if (saveRoadDevice == true && listDevice.Count == 1)
             {
-                if (listDevice[0] is OTADevice)
+                if ((listDevice[0] is OTADevice) == false)
                 {
-                    //鍗曠函鍙槸Ota璁惧鍒欎笉澶勭悊
-                    return;
+                    //ota璁惧涓嶉渶瑕佸鐞�
+                    HdlRoomLogic.Current.ChangedRoom(listDevice[0], roomId, false);
                 }
-                HdlRoomLogic.Current.ChangedRoom(listDevice[0], roomId, false);
             }
             bool save = false;
             if (roomId == string.Empty)
@@ -2629,7 +2721,7 @@
         {
             HdlThreadLogic.Current.RunMain(() =>
             {
-                var contr = new ShowMsgControl(ShowMsgType.Error, msg);
+                var contr = new ShowMsgControl(Phone.ShowMsgType.Error, msg);
                 contr.Show();
             });
         }
@@ -2642,7 +2734,7 @@
         {
             HdlThreadLogic.Current.RunMain(() =>
             {
-                var contr = new ShowMsgControl(ShowMsgType.Tip, msg);
+                var contr = new ShowMsgControl(Phone.ShowMsgType.Tip, msg);
                 contr.Show();
             });
         }
@@ -2737,12 +2829,30 @@
                                     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;
                                     }
                                 }
                             }
@@ -2834,6 +2944,45 @@
             return listDevice;
         }
 
+        /// <summary>
+        /// 鍦ㄨ澶嘥ype鍙樻洿鏃�,閲嶆柊New杩欎釜璁惧瀵硅薄(浠呴檺鍦ㄥ埛鏂拌澶囧垪琛ㄤ娇鐢�,骞朵笖鏈湴闇�瑕佸瓨鍦�)
+        /// </summary>
+        /// <param name="oldLocalDevice">鍘熸潵鐨勬湰鍦板璞�</param>
+        /// <param name="newDeviceType">鏂扮殑璁惧Type</param>
+        private bool ReNewDeviceOnTypeIsChanged(CommonDevice oldLocalDevice, DeviceType newDeviceType)
+        {
+            //鍏堣幏鍙栨湰鍦拌繖涓棫璁惧瀵硅薄鐨刯son
+            string oldFile = System.IO.Path.Combine(Config.Instance.FullPath, oldLocalDevice.FilePath);
+            var deviceData = HdlFileLogic.Current.ReadFileTextContent(oldFile);
+            if (deviceData == null)
+            {
+                //搴旇涓嶄細
+                return false;
+            }
+            //鏍规嵁鏂癟ype閲嶆柊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
 
         #region 鈻� 鍒涘缓鏂拌澶囧璞$浉鍏砡________________
@@ -2877,14 +3026,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;
@@ -2892,6 +3035,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;
@@ -2917,6 +3061,8 @@
             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)
@@ -2965,6 +3111,8 @@
             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.Transverter) { device = new Transverter(); }
+            else if (deviceType == DeviceType.DimmerSwitch) { device = new DimmerSwitch(); }
             else if (deviceType == DeviceType.OtaDevice || deviceType == DeviceType.OtaPanelDevice) { device = new OTADevice(); }
             else { return null; }
 
@@ -3007,7 +3155,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 +3173,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 +3192,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 +3212,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 +3231,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)
@@ -3194,6 +3342,7 @@
             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>
@@ -3399,9 +3548,9 @@
         /// </summary>
         Sensor_PMTwoPointFive = 1307,
         /// <summary>
-        /// 娓╂箍搴︿紶鎰熷櫒
+        /// 娓╂箍搴︿紶鎰熷櫒(杩欎釜鍗曡瘝鎷奸敊浜�,浣嗘槸閿欎簡灏遍敊浜嗗憲,灏辫繖鏍蜂簡)
         /// </summary>
-        Sensor_TemperatrueHumidity = 1308,
+        Sensor_TemperatureHumidity = 1308,
 
         /// <summary>
         /// 杩愬姩浼犳劅鍣�
@@ -3412,9 +3561,9 @@
         /// </summary>
         Sensor_Keyfob = -1307,
         /// <summary>
-        /// 娓╁害浼犳劅鍣�
+        /// 娓╁害浼犳劅鍣�(杩欎釜鍗曡瘝鎷奸敊浜�,浣嗘槸閿欎簡灏遍敊浜嗗憲,灏辫繖鏍蜂簡)
         /// </summary>
-        Sensor_Temperatrue = -1309,
+        Sensor_Temperature = -1309,
         /// <summary>
         /// 婀垮害浼犳劅鍣�
         /// </summary>
@@ -3433,7 +3582,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>
         /// 璋冨厜鍣�

--
Gitblit v1.8.0