From e9fe52b61589ec226fafbc3288d43faf32a8c4c2 Mon Sep 17 00:00:00 2001
From: JLChen <551775569@qq.com>
Date: 星期五, 22 一月 2021 17:33:26 +0800
Subject: [PATCH] 2021-01-22 1.继续完善sid和oid生成方法

---
 Crabtree/SmartHome/HDL/Common/HDLLinkUtlis.cs | 2034 ++++++++++++++++++++++++++++++++++++++++++++---------------
 1 files changed, 1,519 insertions(+), 515 deletions(-)

diff --git a/Crabtree/SmartHome/HDL/Common/HDLLinkUtlis.cs b/Crabtree/SmartHome/HDL/Common/HDLLinkUtlis.cs
index 3671959..94eedcd 100644
--- a/Crabtree/SmartHome/HDL/Common/HDLLinkUtlis.cs
+++ b/Crabtree/SmartHome/HDL/Common/HDLLinkUtlis.cs
@@ -1,562 +1,1566 @@
-锘�//using System;
-//using System.Collections.Generic;
-//using Shared;
+锘縰sing System;
+using System.Collections.Generic;
+using Shared;
 
-//namespace SmartHome
-//{
-//    /// <summary>
-//    /// HDLLink鍗忚 宸ュ叿绫�
-//    /// </summary>
-//    public class HDLLinkUtlis
-//    {
-//        #region 鈻� Current___________________________
-//        /// <summary>
-//        /// 閫氱敤鏂规硶
-//        /// </summary>
-//        private static HDLLinkUtlis m_Current = null;
-//        /// <summary>
-//        /// 閫氱敤鏂规硶
-//        /// </summary>
-//        public static HDLLinkUtlis Current {
-//            get {
-//                if (m_Current == null) {
-//                    m_Current = new HDLLinkUtlis ();
-//                }
-//                return m_Current;
-//            }
-//        }
-//        #endregion
+namespace SmartHome
+{
+    /// <summary>
+    /// HDLLink鍗忚 宸ュ叿绫�
+    /// </summary>
+    public class HDLLinkUtlis
+    {
+        #region 鈻� Current___________________________
+        /// <summary>
+        /// 閫氱敤鏂规硶
+        /// </summary>
+        private static HDLLinkUtlis m_Current = null;
+        /// <summary>
+        /// 閫氱敤鏂规硶
+        /// </summary>
+        public static HDLLinkUtlis Current {
+            get {
+                if (m_Current == null) {
+                    m_Current = new HDLLinkUtlis ();
+                }
+                return m_Current;
+            }
+        }
+        #endregion
 
 
 
 
-//        /// <summary>
-//        /// 灏嗗湪绾胯澶囪浆鎹㈡垚sid + 灞炴�у垪琛�
-//        /// </summary>
-//        /// <param name="onlineDevices"></param>
-//        /// <returns></returns>
-//        public List<Sid> ConvertToSidListToIotCloud (string sOid, Common onlineDevice)
-//        {
-//            List<Sid> tmpResult = new List<Sid> ();
-//            try {
-//                if (onlineDevice.bytSimpleParam == null || onlineDevice.bytSimpleParam.Length == 0) {
-//                    string sSimpleList = DeviceTypeList.GetSimpleFunctionListFromPublicModeGroup (onlineDevice.DeviceType);
-//                    #region
-//                    string [] ArayStr = sSimpleList.Trim ().Split (new char [] { ' ' });
-//                    List<byte> ArayTmp = new List<byte> ();
-//                    for (int i = 0; i < ArayStr.Length; i++) {
-//                        if (ArayStr [i] != null && ArayStr [i] != "" && ArayStr [i].Trim () != "") {
-//                            ArayTmp.Add (Convert.ToByte (ArayStr [i], 16));
-//                        }
-//                    }
-//                    onlineDevice.bytSimpleParam = ArayTmp.ToArray ();
-//                    #endregion
-//                }
-//                if (onlineDevice.bytSimpleParam != null && onlineDevice.bytSimpleParam.Length > 0) {
-//                    for (int intI = 0; intI < onlineDevice.bytSimpleParam.Length / 3; intI++) {
-//                        byte BigType = onlineDevice.bytSimpleParam [0 + intI * 3];
-//                        byte SmallType = onlineDevice.bytSimpleParam [1 + intI * 3];
-//                        int Count = onlineDevice.bytSimpleParam [2 + intI * 3];
-//                        if (Count > 0) {
-//                            for (int j = 1; j <= Count; j++) {
-//                                Sid tmpSid = new Sid ();
-//                                tmpSid.sid = HDLSysPF.FormingNewSid (onlineDevice.Type, sOid, j, false, BigType, SmallType);
-//                                tmpSid.oid = sOid;
+        /// <summary>
+        /// 灏嗗湪绾胯澶囪浆鎹㈡垚sid + 灞炴�у垪琛�
+        /// </summary>
+        /// <param name="moduleCommon">妯″潡璁惧</param>
+        /// <returns></returns>
+        public List<Sid> ConvertToSidListToIotCloud (string sOid, Common moduleCommon)
+        {
+            List<Sid> tmpResult = new List<Sid> ();
+            try {
+                if (moduleCommon != null && moduleCommon.LoopCount > 0) {
+                    for (int intI = 0; intI < moduleCommon.LoopCount; intI++) {
+                        //byte BigType = moduleCommon.bytSimpleParam [0 + intI * 3];
+                        //byte SmallType = moduleCommon.bytSimpleParam [1 + intI * 3];
+                        int Count = moduleCommon.LoopCount;
+                        if (Count > 0) {
+                            for (int j = 1; j <= Count; j++) {
+                                //妯″潡閲岄潰鐨勫崟涓洖璺�
+                                Common deviceCommon = new Common ();
+                                Sid tmpSid = new Sid ();
+                                tmpSid.sid = FormingNewSid (sOid, deviceCommon);
+                                tmpSid.oid = sOid;
+                                tmpSid.name = deviceCommon.Name;
 
-//                                try {
-//                                    tmpSid.name = onlineDevice.myEasyDesignChannelRemark [intI] [j - 1];
-//                                } catch (Exception ex) {
-//                                    tmpSid.name = "";
-//                                }
-//                                if (tmpSid.name == null || tmpSid.name == "" || tmpSid.name == "Unread") {
-//                                    tmpSid.name = onlineDevice.Remark + CsConst.mstrINIDefault.IniReadValue ("public", "00000", "") + " " + j.Tostring ();
-//                                    if (onlineDevice.Remark == "") {
-//                                        tmpSid.name = onlineDevice.strDescription + CsConst.mstrINIDefault.IniReadValue ("public", "00000", "") + " " + j.Tostring ();
-//                                    }
-//                                }
-//                                GateWay.sidObject tmp = HDLSysPF.UpdateSidAttributesToDeviceList (onlineDevice, tmpSid.name, sOid, j, BigType, SmallType, true);
-//                                tmpSid.attributes = tmp.attributes;//UpdateSidAttributesToDeviceList(onlineDevice.DeviceType, sOid, j, BigType, SmallType, ref spk);
-//                                tmpSid.spk = tmp.spk;
-//                                tmpResult.Add (tmpSid);
-//                            }
-//                        }
-//                    }
-//                }
-//                return tmpResult;
-//            } catch (Exception) {
-//                return tmpResult;
-//                //throw;
-//            }
-//        }
+                                SidObject tmp = UpdateSidAttributesToDeviceList (deviceCommon, sOid);
+                                tmpSid.attributes = tmp.attributes;//UpdateSidAttributesToDeviceList(onlineDevice.DeviceType, sOid, j, BigType, SmallType, ref spk);
+                                tmpSid.spk = tmp.spk;
+                                tmpResult.Add (tmpSid);
+                            }
+                        }
+                    }
+                }
+                return tmpResult;
+            } catch (Exception) {
+                return tmpResult;
+            }
+        }
 
-//        /// <summary>
-//        /// 
-//        /// </summary>
-//        /// <param name="homeId"></param>
-//        /// <param name="onlineDevices"></param>
-//        /// <param name="gatewayId"></param>
-//        /// <param name="currentProject"></param>
-//        public void ConvertOidListToIotStruct (string homeId, List<Common> onlineDevices, string gatewayId, ref IotCloud currentProject)
-//        {
-//            try {
-//                //step 1 ;鎶撴崲绫诲瀷
-//                Sids functionList = currentProject.functions;
-//                List<Sid> tmpFunction = new List<Sid> ();
+        /// <summary>
+        /// 澶勭悊鏈湴鏁版嵁锛岃浆鎹㈢敓鎴怬id鍜孲id鍒楄〃
+        /// </summary>
+        /// <param name="homeId"></param>
+        /// <param name="onlineDevices"></param>
+        /// <param name="gatewayId"></param>
+        /// <param name="currentProject"></param>
+        public void ConvertOidListToIotStruct (string homeId, string gatewayId, List<Common> moduleCommonList, ref IotCloud currentProject)
+        {
+            try {
+                //step 1 杞崲绫诲瀷
+                Sids functionList = new Sids();
+                List<Sid> tmpFunction = new List<Sid> ();
 
-//                //step 2 杞崲绫诲瀷
-//                Oids tmp = ConvertToOidListToIotCloud (onlineDevices, ref tmpFunction);
-//                if (currentProject.modules == null || currentProject.modules.devices == null || currentProject.modules.devices.Count == 0) currentProject.modules = tmp;
-//                else {
-//                    foreach (Oid tmpModule in tmp.devices) {
-//                        Oid tmpFind = currentProject.modules.devices.Find (P => P.mac.Equals (tmpModule.mac));
-//                        if (tmpFind == null) currentProject.modules.devices.Add (tmpModule);
-//                    }
-//                }
-//                tmp.homeId = homeId;
+                //step 2 杞崲绫诲瀷
+                Oids mOidList = ConvertToOidListToIotCloud (moduleCommonList, ref tmpFunction);
+                if (currentProject.modules == null || currentProject.modules.devices == null || currentProject.modules.devices.Count == 0) {
+                    currentProject.modules = mOidList;
+                } else {
+                    foreach (Oid tmpModule in mOidList.devices) {
+                        Oid tmpFind = currentProject.modules.devices.Find (P => P.mac.Equals (tmpModule.mac));
+                        if (tmpFind == null) currentProject.modules.devices.Add (tmpModule);
+                    }
+                }
+                mOidList.homeId = homeId;
 
-//                //涓婁紶鍔熻兘鍒楄〃
-//                #region
-//                //if (functionList == null)
-//                //{
-//                functionList = new Sids ();
-//                functionList.devices = new List<Sid> ();
-//                functionList.devices = tmpFunction;
-//                //}
-//                functionList.homeId = homeId;
-//                functionList.gatewayId = gatewayId;
-//                currentProject.modules = tmp;
-//                currentProject.functions = functionList;
-//                #endregion
 
-//            } catch (Exception ex) {
-//                //MessageBox.Show (ex.Tostring ());
-//                //throw;
-//            }
-//        }
+                functionList.devices = new List<Sid> ();
+                functionList.homeId = homeId;
+                functionList.gatewayId = gatewayId;
+                if (tmpFunction != null) {
+                    functionList.devices = tmpFunction;
+                }
+              
+                currentProject.modules = mOidList;
+                currentProject.functions = functionList;
 
-//        /// <summary>
-//        /// 
-//        /// </summary>
-//        /// <param name="homeId"></param>
-//        /// <param name="onlineDevices"></param>
-//        /// <param name="gatewayId"></param>
-//        /// <param name="currentProject"></param>
-//        public void ConvertOidListToIotStruct (string homeId, List<Common> onlineDevices, string gatewayId, ref IotCloud currentProject)
-//        {
-//            try {
-//                //step 1 杞崲绫诲瀷
-//                Sids functionList = currentProject.functions;
-//                List<Sid> tmpFunction = new List<Sid> ();
+            } catch (Exception ex) {
+                //MessageBox.Show (ex.Tostring ());
+                //throw;
+            }
+        }
 
-//                //step 2 杞崲绫诲瀷
-//                Oids tmp = ConvertToOidListToIotCloud (onlineDevices, ref tmpFunction);
-//                if (currentProject.modules == null || currentProject.modules.devices == null || currentProject.modules.devices.Count == 0) currentProject.modules = tmp;
-//                else {
-//                    foreach (Oid tmpModule in tmp.devices) {
-//                        Oid tmpFind = currentProject.modules.devices.Find (P => P.mac.Equals (tmpModule.mac));
-//                        if (tmpFind == null) currentProject.modules.devices.Add (tmpModule);
-//                    }
-//                }
-//                tmp.homeId = homeId;
+        /// <summary>
+        /// 杞崲绫诲瀷鍦ㄧ嚎璁惧鍒楄〃杞琌ID鍒楄〃 鍙湪涓婁紶鎴栬�呬笅杞芥椂浣跨敤
+        /// </summary>
+        /// <param name="onlineDevices"></param>
+        /// <returns></returns>
+        public Oids ConvertToOidListToIotCloud (List<Common> moduleCommonList, ref List<Sid> functionLists)
+        {
+            Oids tmpResult = new Oids ();
+            try {
+                tmpResult.devices = new List<Oid> ();
+                //HDLSysPF.IniDeviceChannelRemark (); //鏁寸悊鍏ㄩ儴璁惧澶囨敞鍒扮紦瀛樺垪琛�
+                foreach (Common tmp in moduleCommonList) {
+                    Oid tmpOid = new Oid ();
+                    tmpOid.protocolType = "bus";
+                    tmpOid.device_name = tmp.Name;
+                    tmpOid.oid = FormingNewOid (tmp.Type);
+                    tmpOid.addresses = string.Format ("{0}{1}", tmp.SubnetID.ToString ("X2"), tmp.DeviceID.ToString ("X2"));
+                    tmpOid.device_model = tmp.Type.ToString ();
+                    tmpOid.fw_version = "";
+                    tmpOid.deviceType = tmp.Type.ToString ();
+                    tmpOid.hw_info = "";
+                    tmpOid.mac = tmp.MAC;
+                    tmpResult.devices.Add (tmpOid);
 
-//                //涓婁紶鍔熻兘鍒楄〃
-//                #region
-//                //if (functionList == null)
-//                //{
-//                functionList = new Sids ();
-//                functionList.devices = new List<Sid> ();
-//                functionList.devices = tmpFunction;
-//                //}
-//                functionList.homeId = homeId;
-//                functionList.gatewayId = gatewayId;
-//                currentProject.modules = tmp;
-//                currentProject.functions = functionList;
-//                #endregion
+                    functionLists.AddRange (ConvertToSidListToIotCloud (tmpOid.oid, tmp));
+                }
+                return tmpResult;
+            } catch (Exception ex) {
+                return tmpResult;
+                //throw;
+            }
+        }
 
-//            } catch (Exception ex) {
-//                //MessageBox.Show (ex.Tostring ());
-//                //throw;
-//            }
-//        }
+        ///// <summary>
+        ///// 
+        ///// </summary>
+        ///// <param name="homeId"></param>
+        ///// <param name="onlineDevices"></param>
+        ///// <param name="gatewayId"></param>
+        ///// <param name="currentProject"></param>
+        //public void ConvertOidListToIotStruct (string homeId, List<Common> onlineDevices, string gatewayId, ref IotCloud currentProject)
+        //{
+        //    try {
+        //        //step 1 杞崲绫诲瀷
+        //        Sids functionList = currentProject.functions;
+        //        List<Sid> tmpFunction = new List<Sid> ();
 
-//        /// <summary>
-//        /// 鐢熸垚璁惧Oid
-//        /// </summary>
-//        /// <param name="iDeviceType"></param>
-//        /// <returns></returns>
-//        public string FormingNewOid (DeviceType deviceType)
-//        {
-//            string sOid = "";
-//            try {
-//                //1.鐢熸垚 鍘傚晢 + 閫氳鏂瑰紡 
-//                string sOidBeginsWith = "000101";//鍘傚晢 + 閫氳鏂瑰紡
-//                //2.鐢熸垚浜у搧鏃堕棿鎴�
-//                long sTimeSp = ConvertDateTimeLong (); //浠�2020骞�1鏈�1鏃ョ畻鍑虹殑鏃堕棿鎴�0.1s涓哄崟浣�
-//                string sTimeSpan = "";
-//                ConvertIntToByteArray (sTimeSp, ref sTimeSpan);
-//                if (sTimeSpan.Length != 8) return sOid;
-//                //寤惰繜10ms
+        //        //step 2 杞崲绫诲瀷
+        //        Oids tmp = ConvertToOidListToIotCloud (onlineDevices, ref tmpFunction);
+        //        if (currentProject.modules == null || currentProject.modules.devices == null || currentProject.modules.devices.Count == 0) currentProject.modules = tmp;
 
-//                //3.鐢熸垚浜у搧绫诲埆
-//                var productType = GetProductType (deviceType);
-//                sOid = sOidBeginsWith + sTimeSpan + productType;
+        //        else {
+        //            foreach (Oid tmpModule in tmp.devices) {
+        //                Oid tmpFind = currentProject.modules.devices.Find (P => P.mac.Equals (tmpModule.mac));
+        //                if (tmpFind == null) currentProject.modules.devices.Add (tmpModule);
+        //            }
+        //        }
+        //        tmp.homeId = homeId;
 
-//                return sOid;
-//            } catch {
-//                return sOid;
-//            }
-//        }
+        //        //涓婁紶鍔熻兘鍒楄〃
+        //        #region
+        //        //if (functionList == null)
+        //        //{
+        //        functionList = new Sids ();
+        //        functionList.devices = new List<Sid> ();
+        //        functionList.devices = tmpFunction;
+        //        //}
+        //        functionList.homeId = homeId;
+        //        functionList.gatewayId = gatewayId;
+        //        currentProject.modules = tmp;
+        //        currentProject.functions = functionList;
+        //        #endregion
 
-//        /// <summary>
-//        /// 鑾峰彇浜у搧绫诲埆
-//        //浜у搧绫诲埆 1byte
-//        //缂栧彿   鎻忚堪
-//		//01	璋冨厜鍣�
-//		//02	缁х數鍣�
-//		//03	骞叉帴鐐规ā鍧�
-//		//04	浼犳劅鍣�
-//		//05	闈㈡澘
-//		//06	RCU
-//		//07	缃戝叧
-//		//08	绾㈠鍙戝皠
-//		//09	Android灞�
-//		//10	鍦烘櫙
-//		//11	闊充箰鎾斁鍣�
-//		//12	232/485杞崲鍣�
-//		//21	鑷姩鍖�
-//        //22	瀹夐槻闃插尯
-//        //14	绐楀笜妯″潡
-//        //15	HVAC
-//        //16	鍦扮儹妯″潡
-//        /// </summary>
-//        /// <param name="deviceType"></param>
-//        /// <returns></returns>
-//        public string GetProductType (DeviceType deviceType)
-//        {
-//            string productType = "";
-//            switch (deviceType) {
-//            case DeviceType.LightDimming:
-//                productType = "01";//01	璋冨厜鍣�
-//                break;
-//            case DeviceType.LightSwitch:
-//                productType = "02";//02 缁х數鍣ㄧ被
-//                break;
-//            case DeviceType.CurtainModel:
-//            case DeviceType.CurtainRoller:
-//            case DeviceType.CurtainTrietex:
-//                productType = "03";//03	閬槼绫伙紙绐楀笜锛�
-//                break;
-//            case DeviceType.SensorWindSpeed:
-//                productType = "04";//04	浼犳劅鍣級
-//                break;
-//            case DeviceType.OnePortWirelessFR:
-//            case DeviceType.OnePortBus:
-//            case DeviceType.RCU:
-//            case DeviceType.SuperWireless:
-//            case DeviceType.OnePortMqttFR:
-//                productType = "07";//07	缃戝叧绫�
-//                break;
-//            case DeviceType.ACPanel:
-//            case DeviceType.ACDevice:
-//            case DeviceType.ACInfrared:
-//            case DeviceType.ACCoolmaster:
-//            case DeviceType.CustomAC:
-//            case DeviceType.HVAC:
-//            case DeviceType.FoolHeat:
-//            case DeviceType.FoolHeatPanel:
-//                productType = "12";//12 鎭掓俯鍣紙绌鸿皟銆佸湴鐑級
-//                break;
-        
-//            }
+        //    } catch (Exception ex) {
+        //        //MessageBox.Show (ex.Tostring ());
+        //        //throw;
+        //    }
+        //}
 
-//            return productType;
-//        }
+        /// <summary>
+        /// 鐢熸垚璁惧Oid
+        /// </summary>
+        /// <param name="iDeviceType"></param>
+        /// <returns></returns>
+        public string FormingNewOid (DeviceType deviceType)
+        {
+            string sOid = "";
+            try {
+                //1.鐢熸垚 鍘傚晢 + 閫氳鏂瑰紡 
+                string sOidBeginsWith = "000101";//鍘傚晢 + 閫氳鏂瑰紡
+                //2.鐢熸垚浜у搧鏃堕棿鎴�
+                long sTimeSp = ConvertDateTimeLong (); //浠�2020骞�1鏈�1鏃ョ畻鍑虹殑鏃堕棿鎴�0.1s涓哄崟浣�
+                string sTimeSpan = "";
+                ConvertIntToByteArray (sTimeSp, ref sTimeSpan);
+                if (sTimeSpan.Length != 8) return sOid;
+                //寤惰繜10ms
 
-          
+                //3.鐢熸垚浜у搧绫诲埆
+                var productType = GetProductType (deviceType);
+                sOid = sOidBeginsWith + sTimeSpan + productType;
 
-//        /// <summary>
-//        /// 鑾峰彇鐢熸垚鐗╃悊妯″瀷鍙傛暟
+                return sOid;
+            } catch {
+                return sOid;
+            }
+        }
 
-//        /// </summary>
-//        /// <param name="deviceType"></param>
-//        /// <returns></returns>
-//        public string GetPhysicalModelType (DeviceType deviceType)
-//        {
-//            string productType = "";
-//            switch (deviceType) {
-//            case DeviceType.LightDimming:
-//                productType = "0101";
-//                break;
-//            }
+        /// <summary>
+        /// 鑾峰彇浜у搧绫诲埆
+        /// 浜у搧绫诲埆鐩墠娌℃湁瑙勮寖鐨勬枃妗�,娌℃湁纭畾鐨勬爣鍑�
+        /// 鏆傛椂鍜宐uspro杞欢瑙勫垯涓�鑷�
+        ///
+        ///鏂囨。瑙勫垯锛屼絾鏄笉鏄纭殑鐗堟湰
+        //浜у搧绫诲埆 1byte
+        //缂栧彿   鎻忚堪
+        //01	璋冨厜鍣�
+        //02	缁х數鍣�
+        //03	骞叉帴鐐规ā鍧�
+        //04	浼犳劅鍣�
+        //05	闈㈡澘
+        //06	RCU
+        //07	缃戝叧
+        //08	绾㈠鍙戝皠
+        //09	Android灞�
+        //10	鍦烘櫙
+        //11	闊充箰鎾斁鍣�
+        //12	232/485杞崲鍣�
+        //21	鑷姩鍖�
+        //22	瀹夐槻闃插尯
+        //14	绐楀笜妯″潡
+        //15	HVAC
+        //16	鍦扮儹妯″潡
+        /// </summary>
+        /// <param name="deviceType"></param>
+        /// <returns></returns>
+        public string GetProductType (DeviceType deviceType)
+        {
+            string productType = "";
+            switch (deviceType) {
+            case DeviceType.LightDimming:
+            case DeviceType.LightCCT:
+            case DeviceType.LightDALI:
+            case DeviceType.LightRGB:
+            case DeviceType.LightRGBW:
+            case DeviceType.LightLogic:
+            case DeviceType.LightRGBandCCT:
+            case DeviceType.DMX48:
+                productType = "01";//01	璋冨厜鍣�
+                break;
+            case DeviceType.LightSwitch:
+            case DeviceType.LightEnergySwitch:
+            case DeviceType.LightEnergySocket:
+            case DeviceType.LightSwitchSocket:
+            case DeviceType.LightMixSwitch:
+                productType = "02";//02 缁х數鍣ㄧ被
+                break;
+            case DeviceType.CurtainModel:
+            case DeviceType.CurtainRoller:
+            case DeviceType.CurtainTrietex:
+                productType = "03";//03	閬槼绫伙紙绐楀笜锛�
+                break;
+            case DeviceType.SensorWindSpeed:
+                productType = "04";//04	浼犳劅鍣級
+                break;
+            case DeviceType.OnePortWirelessFR:
+            case DeviceType.OnePortBus:
+            case DeviceType.RCU:
+            case DeviceType.SuperWireless:
+            case DeviceType.OnePortMqttFR:
+                productType = "07";//07	缃戝叧绫�
+                break;
+            case DeviceType.ACPanel:
+            case DeviceType.ACDevice:
+            case DeviceType.ACInfrared:
+            case DeviceType.ACCoolmaster:
+            case DeviceType.CustomAC:
+            case DeviceType.HVAC:
+            case DeviceType.FoolHeat:
+            case DeviceType.FoolHeatPanel:
+                productType = "12";//12 鎭掓俯鍣紙绌鸿皟銆佸湴鐑級
+                break;
+            case DeviceType.MusicModel:
+            case DeviceType.MusicPanel:
+            case DeviceType.MusicA31:
+                productType = "0B";
+                break;
+            default:
+                productType = "00";
+                break;
+            }
 
-//            return productType;
-//        }
-        
+            return productType;
+        }
 
 
 
-//        /// <summary>
-//        /// 鐢熸垚鍔熻兘璁惧Sid
-//        /// </summary>
-//        /// <param name="iDeviceType"></param>
-//        /// <param name="sOid"></param>
-//        /// <param name="iChnId"></param>
-//        /// <param name="isUseE548ReturnBigSmallType"></param>
-//        /// <param name="BigType"></param>
-//        /// <param name="SmallType"></param>
-//        /// <returns></returns>
-//        public string FormingNewSid (int iDeviceType, string sOid, int iChnId, bool isUseE548ReturnBigSmallType, byte BigType, byte SmallType)
-//        {
-//            if (sOid == null || sOid == "") return "";
-//            try {
-//                string sSid = "";
-//                if (DimmerDeviceTypeList.HDLDimmerDeviceTypeList.Contains (iDeviceType)) {
-//                    if (DimmerDeviceTypeList.DALIDimmerDeviceTypeLists.Contains (iDeviceType)) {
-//                        BigType = 1;
-//                        SmallType = 7;
-//                        sSid += "0203";
-//                    } else {
-//                        sSid += "0202";
-//                    }
-//                } else if (RelayDeviceTypeList.HDLRelayDeviceTypeList.Contains (iDeviceType)) {
-//                    sSid += "0201";
-//                } else if (CurtainDeviceType.HDLCurtainModuleDeviceType.Contains (iDeviceType)) {
+        /// <summary>
+        /// 鑾峰彇鐢熸垚鐗╃悊妯″瀷鍙傛暟
+        /// 2021-01-22 鐩墠鐗╂ā杩樹笉瀹屽杽
+        /// </summary>
+        /// <param name="deviceType"></param>
+        /// <returns></returns>
+        public string GetPhysicalModelType (DeviceType deviceType)
+        {
+            string productType = "";
+            switch (deviceType) {
+            case DeviceType.LightEnergySwitch:
+                productType = "0101";
+                break;
+            case DeviceType.LightEnergySocket:
+            case DeviceType.LightSwitchSocket:
+                productType = "0102";
+                break;
+            case DeviceType.LightSwitch:
+            case DeviceType.LightMixSwitch:
+                productType = "0201";
+                break;
+            case DeviceType.LightDimming:
+                productType = "0202";
+                break;
+            case DeviceType.LightCCT:
+            case DeviceType.LightDALI:
+                productType = "0203";
+                break;
+            case DeviceType.LightRGB:
+            case DeviceType.LightRGBW:
+            case DeviceType.LightLogic:
+            case DeviceType.LightRGBandCCT:
+            case DeviceType.DMX48:
+                productType = "0204";
+                break;
+            //绐楀笜
+            case DeviceType.CurtainModel:
+                productType = "0301";
+                break;
+            case DeviceType.CurtainTrietex:
+                productType = "0303";
+                break;
+            case DeviceType.CurtainRoller:
+                productType = "0304";
+                break;
+            case DeviceType.ACPanel:
+            case DeviceType.ACDevice:
+            case DeviceType.ACInfrared:
+            case DeviceType.ACCoolmaster:
+            case DeviceType.CustomAC:
+            case DeviceType.HVAC:
+                productType = "0701";
+                break;
+            case DeviceType.FoolHeat:
+            case DeviceType.FoolHeatPanel:
+                productType = "0801";
+                break;
+            case DeviceType.MusicModel:
+            case DeviceType.MusicPanel:
+            case DeviceType.MusicA31:
+                productType = "0901";
+                break;
+            case DeviceType.FanModule:
+                productType = "1001";
+                break;
+            default:
+                productType = ((int)deviceType).ToString ("X4");
+                break;
+            }
 
-//                    if (CurtainDeviceType.NormalMotorCurtainDeviceType.Contains (iDeviceType) || (iDeviceType == 9700)) //鎵�鏈夊紑鍚堝笜 //0 2020 05 24鍒涙槑寮�鍚堝笜
-//                    {
-//                        sSid += "0303";
-//                    } else if (CurtainDeviceType.RollerCurtainDeviceType.Contains (iDeviceType)
-//                      || (iDeviceType == 9701))//鎵�鏈� 鍗峰笜鎺у埗鍣� 
-//                      {
-//                        sSid += "0304";
-//                    } else {
-//                        sSid += "0301";
-//                    }
-//                } else if (HVACModuleDeviceTypeList.HDLHVACModuleDeviceTypeLists.Contains (iDeviceType)) {
-//                    sSid += "0401";
-//                } else if (Eightin1DeviceTypeList.HDL8in1DeviceType.Contains (iDeviceType)
-//                      || Sevenin1DeviceTypeList.HDL7in1DeviceType.Contains (iDeviceType)
-//                      || HaikeSensorDeviceTypeList.HaikeSensorDeviceType.Contains (iDeviceType)
-//                      || Twelvein1DeviceTypeList.HDL12in1DeviceType.Contains (iDeviceType)
-//                      || Rs232DeviceTypeList.HDLRs232DeviceType.Contains (iDeviceType)) {
-//                    if (BigType == 19 && SmallType == 0) {
-//                        sSid += "1301";
-//                    } else if (BigType == 5 && SmallType == 0) {
-//                        sSid += "0519";
-//                    } else {
-//                        sSid += BigType.Tostring ("X2") + SmallType.Tostring ("X2");
-//                    }
-//                } else if (FloorheatingDeviceTypeList.HDLFloorHeatingDeviceType.Contains (iDeviceType)) {
-//                    sSid += "0402";
-//                } else if (DMXDeviceTypeList.HDLDMXDeviceTypeList.Contains (iDeviceType)) {
-//                    sSid += "0204";
-//                } else if (DimmerDeviceTypeList.DALIDimmerDeviceTypeLists.Contains (iDeviceType)) {
-//                    sSid += "0203";
-//                } else if (AudioDeviceTypeList.AudioBoxDeviceTypeList.Contains (iDeviceType)) {
-//                    sSid += "0901";
-//                }
-//                string sTmpWithE548 = sSid;
-//                sSid = sOid + sSid + iChnId.Tostring ("X4");
-//                if (isUseE548ReturnBigSmallType) {
-//                    sSid += BigType.Tostring ("X2") + SmallType.Tostring ("X2");
-//                } else {
-//                    sSid += sTmpWithE548;
-//                }
+            return productType;
+        }
 
-//                return sSid;
-//            } catch {
-//                return "";
-//            }
-//        }
-
-//        private long LastTime = 0;
-//        /// <summary>
-//        /// DateTime鏃堕棿鏍煎紡杞崲涓�13浣嶅甫姣鐨刄nix鏃堕棿鎴�
-//        /// </summary>
-//        /// <param name="time"> DateTime鏃堕棿鏍煎紡</param>
-//        /// <returns>Unix鏃堕棿鎴虫牸寮�</returns>
-//        public long ConvertDateTimeLong ()
-//        {
-//            System.DateTime startTime = TimeZone.CurrentTimeZone.ToLocalTime (new System.DateTime (2020, 1, 1));
-//            long l = (long)(Math.Round ((DateTime.Now - startTime).TotalSeconds, 1) * 10);
-//            if (l <= LastTime) l = LastTime + 1;
-//            LastTime = l;
-//            return l;
-//        }
-
-//        public bool ConvertIntToByteArray (long m, ref string strTmp)
-//        {
-//            strTmp = "00000000";
-//            byte [] arry = new byte [4];
-//            arry [0] = (byte)(m & 0xFF);
-//            arry [1] = (byte)((m & 0xFF00) >> 8);
-//            arry [2] = (byte)((m & 0xFF0000) >> 16);
-//            arry [3] = (byte)((m & 0xFF000000) >> 24);
-//            strTmp = arry [0].ToString ("X2") + arry [1].ToString ("X2") + arry [2].ToString ("X2") + arry [3].ToString ("X2");
-//            return true;
-//        }
-
-//    }
+                    
 
 
-//    [Serializable]
-//    public class Sids : BaseCloudFeedback
-//    {
-//        public string homeId { get; set; }
-//        public string gatewayId { get; set; }
-//        public List<Sid> devices { get; set; }
-//    }
-
-//    [Serializable]
-//    public class BaseCloudFeedback
-//    {
-//        public int code { get; set; }
-//        public string timestamp { get; set; }
-//        public bool isSuccess { get; set; }
-//        public string message { get; set; }
-//    }
+        /// <summary>
+        /// 鐢熸垚鍔熻兘璁惧Sid
+        /// </summary>
+        /// <param name="iDeviceType"></param>
+        /// <param name="sOid"></param>
+        /// <param name="iChnId"></param>
+        /// <param name="isUseE548ReturnBigSmallType"></param>
+        /// <param name="BigType"></param>
+        /// <param name="SmallType"></param>
+        /// <returns></returns>
+        public string FormingNewSid (string sOid, Common loopCommon)
+        {
+            if (sOid == null || sOid == "") return "";
+            try {
+                //鐗╂ā鍨嬬被+閫氶亾鍙�+澶у皬绫诲埆
+                string sSid = "";
+                //1.鐗╂ā鍨嬬被
+                string mPhysicalModelType = GetPhysicalModelType (loopCommon.Type);
+                //2.閫氶亾鍙�
+                string loopIDStr = loopCommon.LoopID.ToString ("X4");
+                //3.澶у皬绫诲埆
+                string bigMinStr = loopCommon.BigClass.ToString ("X2") + loopCommon.MinClass.ToString ("X2");
+                //4.鎷兼帴
+                sSid = sOid + mPhysicalModelType + loopIDStr + bigMinStr;
+                return sSid;
+            } catch {
+                return "";
+            }
+        }
 
 
-//    [Serializable]
-//    public class Oids : BaseCloudFeedback
-//    {
-//        public string homeId { get; set; }
-//        public string gatewayId { get; set; }
-//        public List<Oid> devices { get; set; }
-//    }
+        /// <summary>
+        /// 鐢熸垚SPK灞炴��
+        /// </summary>
+        /// <param name="loopCommon"></param>
+        /// <param name="iChnRemark"></param>
+        /// <param name="sOid"></param>
+        /// <param name="iChnId"></param>
+        /// <param name="BigType"></param>
+        /// <param name="SmallType"></param>
+        /// <param name="isUseE548ReturnBigSmallType"></param>
+        /// <returns></returns>
+        public SidObject UpdateSidAttributesToDeviceList (Common loopCommon, string sOid)
+        {
+            SidObject tmp = new SidObject ();
+            try {
+                string sSid = FormingNewSid (sOid, loopCommon);
+                tmp.oid = sOid;
+                tmp.sid = sSid;
+                tmp.name = loopCommon.Name;
+                tmp.attributes = new List<Function> ();
+                tmp.omodel = loopCommon.Type.ToString ();
+                //缁х數鍣ㄥ紑鍏崇被
+                if (loopCommon.Type == DeviceType.LightSwitch
+                    || loopCommon.Type == DeviceType.LightEnergySwitch
+                    || loopCommon.Type == DeviceType.LightEnergySocket
+                    || loopCommon.Type == DeviceType.LightSwitchSocket
+                    || loopCommon.Type == DeviceType.LightMixSwitch) {
+                    tmp.spk = "light.switch";
+                    #region on_off
+                    Function tempFunction = new Function ();
+                    tempFunction.key = "on_off";
+                    tempFunction.data_type = "string";
+                    tempFunction.value = new List<string> ();
+                    tempFunction.value.Add ("on");
+                    tempFunction.value.Add ("off");
+                    tempFunction.max = 1;
+                    tempFunction.min = 0;
+                    tmp.attributes.Add (tempFunction);
+                    #endregion
+                } else if (loopCommon.Type == DeviceType.LightDimming
+                    || loopCommon.Type == DeviceType.LightCCT
+                    || loopCommon.Type == DeviceType.LightDALI) {
+                    //璋冨厜绫�
+                    tmp.spk = "light.dimming";
+                    #region on_off
+                    Function tempFunction = new Function ();
+                    tempFunction.key = "on_off";
+                    tempFunction.data_type = "string";
+                    tempFunction.value = new List<string> ();
+                    tempFunction.value.Add ("on");
+                    tempFunction.value.Add ("off");
+                    tempFunction.max = 1;
+                    tempFunction.min = 0;
+                    tmp.attributes.Add (tempFunction);
+                    #endregion
 
-//    [Serializable]
-//    public class Oid
-//    {
-//        public string protocolType { get; set; }
-//        public string device_name { get; set; }
-//        public string oid { get; set; }
-//        public string addresses { get; set; }
-//        public string device_model { get; set; }
+                    #region brightness
+                    Function tempFunction1 = new Function ();
+                    tempFunction1.key = "brightness";
+                    tempFunction1.data_type = "integer";
+                    tempFunction1.value = new List<string> ();
 
-//        public string fw_version { get; set; }
-//        public string hw_info { get; set; }
-//        public string mac { get; set; }
-//        public string deviceType { get; set; }
-//    }
+                    tempFunction1.max = 100;
+                    tempFunction1.min = 0;
+                    tmp.attributes.Add (tempFunction1);
+                    #endregion
 
-//    [Serializable]
-//    public class Sid
-//    {
-//        public string sid { get; set; }
-//        public string name { get; set; }
-//        public string [] uids { get; set; }
-//        public string spk { get; set; }
+                    #region fade_time
+                    Function tempFunction3 = new Function ();
+                    tempFunction3.key = "fade_time";
+                    tempFunction3.data_type = "integer";
+                    tempFunction3.value = new List<string> ();
+                    //tempFunction1.value.Add("percent");
+                    //for (int iPercent = 0; iPercent <= 100; iPercent++)
+                    //{
+                    //    tempFunction1.value.Add(iPercent.ToString());
+                    //}
+                    tempFunction3.max = 100;
+                    tempFunction3.min = 0;
+                    tmp.attributes.Add (tempFunction3);
+                    #endregion
 
-//        public string oid { get; set; }  //璁惧妯″潡鍦板潃
-//        public string omodel { get; set; }    //鍨嬪彿
-//        public List<Function> attributes { get; set; } //灞炴�у垪琛�
-//    }
+                    if (loopCommon.Type == DeviceType.LightCCT || loopCommon.Type == DeviceType.LightDALI)//鑹叉俯绫诲埆
+                    {
+                        tmp.spk = "light.cct";
+                        #region cct
+                        Function tempFunction2 = new Function ();
+                        tempFunction2.key = "cct";
+                        tempFunction2.data_type = "integer";
+                        tempFunction2.value = new List<string> ();
+                        //tempFunction2.value.Add("warm light ");
+                        //tempFunction2.value.Add("cold light ");
+                        tempFunction2.max = 65535;
+                        tempFunction2.min = 0;
+                        tmp.attributes.Add (tempFunction2);
+                        #endregion
+                    }
+                } else if (loopCommon.Type == DeviceType.LightRGB
+                    || loopCommon.Type == DeviceType.LightRGBW
+                    || loopCommon.Type == DeviceType.LightLogic
+                    || loopCommon.Type == DeviceType.LightRGBandCCT
+                    || loopCommon.Type == DeviceType.DMX48) {
+
+                    tmp.spk = "light.rgb";
+                    #region on_off
+                    Function tempFunction = new Function ();
+                    tempFunction.key = "on_off";
+                    tempFunction.data_type = "string";
+                    tempFunction.value = new List<string> ();
+                    tempFunction.value.Add ("on");
+                    tempFunction.value.Add ("off");
+                    tempFunction.max = 1;
+                    tempFunction.min = 0;
+                    tmp.attributes.Add (tempFunction);
+                    #endregion
+
+                    #region brightness
+                    Function tempFunction2 = new Function ();
+                    tempFunction2.key = "brightness";
+                    tempFunction2.data_type = "integer";
+                    tempFunction2.value = new List<string> ();
+                    tempFunction2.max = 100;
+                    tempFunction2.min = 0;
+                    tmp.attributes.Add (tempFunction2);
+                    #endregion
 
 
-//    [Serializable]
-//    public class Function
-//    {
-//        //public string name { get; set; }
-//        public string key { get; set; }
-//        public List<string> value { get; set; }
-//        public int max { get; set; }
-//        public int min { get; set; }
-//        public string data_type { get; set; }
-//    }
 
-//}
+                    if (loopCommon.Type == DeviceType.LightRGBW) {
+                        tmp.spk = "light.rgbw";
+                        #region color
+                        Function tempFunction3 = new Function ();
+                        tempFunction3.key = "rgb";
+                        tempFunction3.data_type = "integer";
+                        tempFunction3.value = new List<string> ();
+                        //tempFunction2.value.Add("red");
+                        //tempFunction2.value.Add("green");
+                        //tempFunction2.value.Add("blue");
+                        tempFunction3.max = 255;
+                        tempFunction3.min = 0;
+                        tmp.attributes.Add (tempFunction3);
+                        #endregion
+                    } else {
+                        #region color
+                        Function tempFunction3 = new Function ();
+                        tempFunction3.key = "rgb";
+                        tempFunction3.data_type = "integer";
+                        tempFunction3.value = new List<string> ();
+                        tempFunction3.min = 0;
+                        tmp.attributes.Add (tempFunction3);
+                        #endregion
+
+                    }
+
+                    if (loopCommon.Type == DeviceType.LightRGBandCCT) {
+                        #region CCT
+                        Function tempFunctionCCT = new Function ();
+                        tempFunctionCCT.key = "cct";
+                        tempFunctionCCT.data_type = "integer";
+                        tempFunctionCCT.value = new List<string> ();
+                        //tempFunction2.value.Add("red");
+                        //tempFunction2.value.Add("green");
+                        //tempFunction2.value.Add("blue");
+                        tempFunctionCCT.max = 65535;
+                        tempFunctionCCT.min = 0;
+                        tmp.attributes.Add (tempFunctionCCT);
+                        #endregion
+                    }
+
+                } else if (loopCommon.Type == DeviceType.CurtainModel || loopCommon.Type == DeviceType.CurtainRoller || loopCommon.Type == DeviceType.CurtainTrietex) {
+                    tmp.spk = "curtain.switch";
+                    #region on_off
+                    Function tempFunction = new Function ();
+                    tempFunction.key = "on_off";
+                    tempFunction.data_type = "string";
+                    tempFunction.value = new List<string> ();
+                    tempFunction.value.Add ("on");
+                    tempFunction.value.Add ("off");
+                    tempFunction.value.Add ("stop");
+                    tempFunction.max = 2;
+                    tempFunction.min = 0;
+                    tmp.attributes.Add (tempFunction);
+                    #endregion
+                    if (loopCommon.Type == DeviceType.CurtainRoller || loopCommon.Type == DeviceType.CurtainTrietex)//鎵�鏈夊嵎甯樻帶鍒跺櫒 
+                    {
+                        tmp.spk = "curtain.trietex";
+                        #region openlevel
+                        Function tempFunction1 = new Function ();
+                        tempFunction1.key = "percent";
+                        tempFunction1.data_type = "integer";
+                        tempFunction1.value = new List<string> ();
+                        //tempFunction1.value.Add("percent");
+                        tempFunction1.max = 100;
+                        tempFunction1.min = 0;
+                        tmp.attributes.Add (tempFunction1);
+                        #endregion
+                    }
+                } else if (loopCommon.Type == DeviceType.ACPanel
+                   || loopCommon.Type == DeviceType.ACDevice
+                   || loopCommon.Type == DeviceType.ACInfrared
+                   || loopCommon.Type == DeviceType.ACCoolmaster
+                   || loopCommon.Type == DeviceType.CustomAC
+                   || loopCommon.Type == DeviceType.HVAC) {
+
+                    //绌鸿皟绫�
+                    tmp.spk = "ac.standard";
+                    #region on_off
+                    Function tempFunction = new Function ();
+                    tempFunction.key = "on_off";
+                    tempFunction.data_type = "string";
+                    tempFunction.value = new List<string> ();
+                    tempFunction.value.Add ("on");
+                    tempFunction.value.Add ("off");
+                    tempFunction.max = 1;
+                    tempFunction.min = 0;
+                    tmp.attributes.Add (tempFunction);
+                    #endregion
+
+                    #region mode
+                    Function tempFunction1 = new Function ();
+                    tempFunction1.key = "mode";
+                    tempFunction1.data_type = "integer";
+                    tempFunction1.value = new List<string> ();
+                    tempFunction1.value.Add ("cool");
+                    tempFunction1.value.Add ("heat");
+                    tempFunction1.value.Add ("fan");
+                    tempFunction1.value.Add ("auto");
+                    tempFunction1.value.Add ("dry");
+
+                    tempFunction1.max = 4;
+                    tempFunction1.min = 0;
+                    tmp.attributes.Add (tempFunction1);
+                    #endregion
+
+                    #region fan
+                    Function tempFunction2 = new Function ();
+                    tempFunction2.key = "fan";
+                    tempFunction2.data_type = "integer";
+                    tempFunction2.value = new List<string> ();
+                    tempFunction2.value.Add ("high");
+                    tempFunction2.value.Add ("medium");
+                    tempFunction2.value.Add ("low");
+                    tempFunction2.value.Add ("auto");
+                    tempFunction2.max = 3;
+                    tempFunction2.min = 0;
+                    tmp.attributes.Add (tempFunction2);
+                    #endregion
+
+                    #region temp
+                    Function tempFunction3 = new Function ();
+                    tempFunction3.key = "set_temp";
+                    //2020 08 11  hvac 娓╁害鎺у埗 1掳-> int 0.5掳->float
+                    //if (HVACModuleDeviceTypeList.HDLHVACwithAcControlHighPrecision.Contains(DevOnLineTmp.DeviceType))
+                    //{
+                    //20201224 璁剧疆娓╁害鏁版嵁绫诲瀷缁熶竴float 浼熷崡鍚庣画ai+鏁版嵁绫诲瀷缃戝叧澶勭悊
+                    tempFunction3.data_type = "float";
+                    //}
+                    //else
+                    //{
+                    //    tempFunction3.data_type = "integer";
+                    //}
+                    tempFunction3.value = new List<string> ();
+                    tempFunction3.max = 30;
+                    tempFunction3.min = 16;
+                    tmp.attributes.Add (tempFunction3);
+                    #endregion
+
+                    #region temp_step
+                    Function tempFunction5 = new Function ();
+                    tempFunction5.key = "set_temp_step";
+                    tempFunction5.data_type = "string";
+                    tempFunction5.value = new List<string> ();
+                    tempFunction5.value.Add ("up");
+                    tempFunction5.value.Add ("down");
+                    tempFunction5.max = 1;
+                    tempFunction5.min = 0;
+                    tmp.attributes.Add (tempFunction5);
+                    #endregion
+
+                    #region room_temp
+                    Function tempFunction6 = new Function ();
+                    tempFunction6.key = "room_temp";
+                    tempFunction6.data_type = "float";
+                    tempFunction6.value = new List<string> ();
+                    tempFunction6.max = 50;
+                    tempFunction6.min = -50;
+                    tmp.attributes.Add (tempFunction6);
+                    #endregion
+
+                    #region swing
+                    Function tempFunction4 = new Function ();
+                    tempFunction4.key = "swing";
+                    tempFunction4.data_type = "string";
+                    tempFunction4.value = new List<string> ();
+                    tempFunction4.value.Add ("up_down");
+                    //tempFunction4.value.Add("down");
+                    tempFunction4.value.Add ("left_right");
+                    //tempFunction4.value.Add("right");
+                    tempFunction4.value.Add ("stop");
+                    tempFunction4.max = 3;
+                    tempFunction4.min = 0;
+                    tmp.attributes.Add (tempFunction4);
+                    #endregion
+
+                    #region lock
 
 
-////sid缁勬垚閮ㄥ垎锛�
-////sid
-////鏉ユ簮	鍘傚晢浠g爜	閫氳鏂瑰紡	浜у搧鏃堕棿鎴�	浜у搧绫诲埆	鐗╂ā鍨嬬被	閫氶亾鍙�	澶у皬绫诲埆
-////1byte	1byte	1byte	4byte	1byte	2byte	2byte	2byte
-////oid缁勬垚閮ㄥ垎锛�
-////鏉ユ簮	鍘傚晢浠g爜	閫氳鏂瑰紡	浜у搧鏃堕棿鎴�	浜у搧绫诲埆
-////1byte	1 byte	1 byte	4 byte	1byte
-////鍏朵腑鍚勯儴鍒嗕唬鐮佸垪琛細
-////鏉ユ簮	1byte	缂栧彿	鎻忚堪
-////		00	榛樿鍘熺敓鎬佺郴缁熸暟鎹�
-////		01	缃戝叧鎴栬�呭叾浠朅璁惧
-////		02	璋冭瘯杞欢
-////		03	APP搴旂敤绋嬪簭
-////		04	绗笁鏂圭綉鍏虫垨鑰呭钩鍙�
+                    #endregion
+                } else if (loopCommon.Type == DeviceType.FoolHeat
+                    || loopCommon.Type == DeviceType.FoolHeatPanel) {
+                    tmp.spk = "floorHeat.standard";
+                    #region on_off
+                    Function tempFunction = new Function ();
+                    tempFunction.key = "on_off";
+                    tempFunction.data_type = "string";
+                    tempFunction.value = new List<string> ();
+                    tempFunction.value.Add ("on");
+                    tempFunction.value.Add ("off");
+                    tempFunction.max = 1;
+                    tempFunction.min = 0;
+                    tmp.attributes.Add (tempFunction);
+                    #endregion
 
-////鍘傚晢浠g爜	1byte	缂栧彿	鎻忚堪
-////		01	HDL
-////		02	
+                    #region mode
+                    Function tempFunction1 = new Function ();
+                    tempFunction1.key = "mode";
+                    tempFunction1.data_type = "string";
+                    tempFunction1.value = new List<string> ();
+                    tempFunction1.value.Add ("day");
+                    tempFunction1.value.Add ("night");
+                    tempFunction1.value.Add ("away");
+                    tempFunction1.value.Add ("normal");
+                    tempFunction1.value.Add ("timer");
+                    tempFunction1.max = 4;
+                    tempFunction1.min = 0;
+                    tmp.attributes.Add (tempFunction1);
+                    #endregion
 
-////閫氳鏂瑰紡	1byte	缂栧彿	鎻忚堪
-////		01	HDL Bus
-////		02	Zigbee
-////		03	KNX
-////		04	Z-Wave
+                    #region temp
+                    Function tempFunction3 = new Function ();
+                    tempFunction3.key = "set_temp";
+                    tempFunction3.data_type = "float";
+                    tempFunction3.value = new List<string> ();
+                    //tempFunction3.value.Add("up");
+                    //tempFunction3.value.Add("down");
+                    //tempFunction3.value.Add("value");
+                    tempFunction3.max = 35;
+                    tempFunction3.min = 0;
+                    tmp.attributes.Add (tempFunction3);
+                    #endregion
 
-////浜у搧鏃堕棿鎴�	4bytes	浠�2020骞�1鏈�1鏃ョ畻鍑虹殑鏃堕棿鎴�0.1s涓哄崟浣�
+                    #region temp
+                    Function tempFunction4 = new Function ();
+                    tempFunction4.key = "set_temp_step";
+                    tempFunction4.data_type = "string";
+                    tempFunction4.value = new List<string> ();
+                    tempFunction4.value.Add ("up");
+                    tempFunction4.value.Add ("down");
+                    tempFunction4.max = 1;
+                    tempFunction4.min = 0;
+                    tmp.attributes.Add (tempFunction4);
+                    #endregion
 
-////浜у搧绫诲埆	1byte	缂栧彿	鎻忚堪
-////		01	璋冨厜鍣�
-////		02	缁х數鍣�
-////		03	骞叉帴鐐规ā鍧�
-////		04	浼犳劅鍣�
-////		05	闈㈡澘
-////		06	RCU
-////		07	缃戝叧
-////		08	绾㈠鍙戝皠
-////		09	Android灞�
-////		10	鍦烘櫙
-////		11	闊充箰鎾斁鍣�
-////		12	232/485杞崲鍣�
-////		21	鑷姩鍖�
-////		22	瀹夐槻闃插尯
-////		14	绐楀笜妯″潡
-////		15	HVAC
-////		16	鍦扮儹妯″潡
+                    #region room_temp
+                    Function tempFunction5 = new Function ();
+                    tempFunction5.key = "room_temp";
+                    tempFunction5.data_type = "float";
+                    tempFunction5.value = new List<string> ();
+                    tempFunction5.max = 50;
+                    tempFunction5.min = -50;
+                    tmp.attributes.Add (tempFunction5);
+                    #endregion
 
-////鐗╂ā鍨嬬被鍨�	2bytes	缂栧彿	鎻忚堪
-////		01	寮�鍏崇被	01	寮�鍏�
-////				02	鎻掑骇
-////				03	
-////		02	鐓ф槑	01	寮�鍏�
-////				02	璋冨厜
-////				03	鑹叉俯(CCT)
-////				04	RGB
-////		03	閬槼	01	绐楀笜鎺у埗鍣�
-////				02	鐧惧彾绐�
-////				03	寮�鍚堝笜
-////				04	鍗峰笜
-////				05	聽鎺ㄧ獥鍣�
-////				06	聽鎶曞奖骞�
-////		04	闈㈡澘	01	鎸夐敭闈㈡澘
-////		05	浼犳劅鍣�	01	绉诲姩鎺㈡祴
-////				02	娓╁害浼犳劅鍣�
-////				03	婀垮害浼犳劅鍣�
-////				04	鐓у害浼犳劅鍣�
-////				05	TVOC
-////				06	PM2.5
-////				07	CO2
-////				08	姣背娉紶鎰熷櫒
-////				09	
-////				10	
-////				11	鐑熼浘浼犳劅鍣�
-////				25	骞叉帴鐐�
-////		07	鎭掓俯鍣�	01	绌鸿皟
-////				02	椋庢墖
-////				03	姣涚粏绌鸿皟
-////		08	鍦扮儹	01	鍦扮儹妯″潡
-////		09	鑳屾櫙闊充箰	01	闊充箰鎾斁鍣�
-////				02	Sonos
-////		10	鍦烘櫙	01	鍦烘櫙
-////				02	鐢靛奖鍦烘櫙
-////		19	鏂伴	01	鏂伴
+                    #region lock
 
-////13	鑳芥簮	01	鐢佃〃
-////				02	姘磋〃
-////				03	鐕冩皵
-////		16	鐢靛櫒	01	椋庢墖
-////				02	TV
-////		20	瀹夐槻	01	瀹夐槻
-////		21	鑷姩鍖�	01	鑷姩鍖�
-////澶х被鍒�	1bytes	锛堥鐣欙級
-////灏忕被鍒�	1byte	锛堥鐣欙級
\ No newline at end of file
+
+                    #endregion
+                } else if (loopCommon.Type == DeviceType.MusicA31
+                    || loopCommon.Type == DeviceType.MusicModel
+                    || loopCommon.Type == DeviceType.MusicPanel) {
+                    tmp.spk = "music.standard";
+                    // on_off  volume song_step  audio  list_channel  mode  song_num  special_song  volume_level
+                    #region on_off
+                    Function tempFunction = new Function ();
+                    tempFunction.key = "on_off";
+                    tempFunction.data_type = "string";
+                    tempFunction.value = new List<string> ();
+                    tempFunction.value.Add ("play");
+                    tempFunction.value.Add ("pause");
+
+                    //tempFunction.value.Add("play");
+                    //tempFunction.value.Add("stop");
+                    //tempFunction.value.Add("pause");
+                    //play stop pause
+                    tempFunction.max = 2;
+                    tempFunction.min = 0;
+                    tmp.attributes.Add (tempFunction);
+                    #endregion
+
+                    #region volume
+                    Function tempFunction1 = new Function ();
+                    tempFunction1.key = "volume";
+                    tempFunction1.data_type = "integer";
+                    tempFunction1.value = new List<string> ();
+                    //tempFunction1.value.Add("percent");
+                    tempFunction1.max = 100;
+                    tempFunction1.min = 0;
+                    tmp.attributes.Add (tempFunction1);
+                    #endregion
+
+                    #region volume_step
+                    Function tempFunction9 = new Function ();
+                    tempFunction9.key = "volume_step";
+                    tempFunction9.data_type = "string";
+                    tempFunction9.value = new List<string> ();
+                    tempFunction9.value.Add ("up");
+                    tempFunction9.value.Add ("down");
+                    tempFunction9.max = 1;
+                    tempFunction9.min = 0;
+                    tmp.attributes.Add (tempFunction9);
+                    #endregion
+
+
+                    #region volume_level
+                    Function tempFunction10 = new Function ();
+                    tempFunction10.key = "volume_level";
+                    tempFunction10.data_type = "integer";
+                    tempFunction10.value = new List<string> ();
+                    //tempFunction1.value.Add("percent");
+                    tempFunction10.max = 10;
+                    tempFunction10.min = 0;
+                    tmp.attributes.Add (tempFunction10);
+                    #endregion
+
+                    #region volume_level_step
+                    Function tempFunction11 = new Function ();
+                    tempFunction11.key = "volume_level_step";
+                    tempFunction11.data_type = "string";
+                    tempFunction11.value = new List<string> ();
+                    tempFunction11.value.Add ("up");
+                    tempFunction11.value.Add ("down");
+                    tempFunction11.max = 1;
+                    tempFunction11.min = 0;
+                    tmp.attributes.Add (tempFunction11);
+                    #endregion
+
+                    #region treble
+                    Function tempFunction14 = new Function ();
+                    tempFunction14.key = "treble";
+                    tempFunction14.data_type = "integer";
+                    tempFunction14.max = 10;
+                    tempFunction14.min = -10;
+                    tmp.attributes.Add (tempFunction14);
+                    #endregion
+
+                    #region treble_step
+                    Function tempFunction12 = new Function ();
+                    tempFunction12.key = "treble_step";
+                    tempFunction12.data_type = "string";
+                    tempFunction12.value = new List<string> ();
+                    tempFunction12.value.Add ("up");
+                    tempFunction12.value.Add ("down");
+                    tempFunction12.max = 1;
+                    tempFunction12.min = 0;
+                    tmp.attributes.Add (tempFunction12);
+                    #endregion
+
+
+                    #region bass
+                    Function tempFunction15 = new Function ();
+                    tempFunction15.key = "bass";
+                    tempFunction15.data_type = "integer";
+                    tempFunction15.max = 10;
+                    tempFunction15.min = -10;
+                    tmp.attributes.Add (tempFunction15);
+                    #endregion
+
+                    #region bass_step
+                    Function tempFunction13 = new Function ();
+                    tempFunction13.key = "bass_step";
+                    tempFunction13.data_type = "string";
+                    tempFunction13.value = new List<string> ();
+                    tempFunction13.value.Add ("up");
+                    tempFunction13.value.Add ("down");
+                    tempFunction13.max = 1;
+                    tempFunction13.min = 0;
+                    tmp.attributes.Add (tempFunction13);
+                    #endregion
+
+                    #region mode
+                    Function tempFunction5 = new Function ();
+                    tempFunction5.key = "mode";
+                    tempFunction5.data_type = "string";
+                    tempFunction5.value = new List<string> ();
+                    //singel/single_circle/order/all
+                    //single/single_cycle/order/list_cycle/random
+                    tempFunction5.value.Add ("single");
+                    tempFunction5.value.Add ("single_cycle");
+                    tempFunction5.value.Add ("order");
+                    tempFunction5.value.Add ("list_cycle");
+                    tempFunction5.value.Add ("random");
+                    tempFunction5.max = 3;
+                    tempFunction5.min = 0;
+                    tmp.attributes.Add (tempFunction5);
+                    #endregion
+
+                    #region source
+                    //1	= SD, 2 = External Input, 3 = FTP, 4 = Radio
+                    //sdcard/external_input/ftp/radio
+                    Function tempFunction3 = new Function ();
+                    tempFunction3.key = "source";
+                    tempFunction3.data_type = "string";
+                    tempFunction3.value = new List<string> ();
+                    tempFunction3.value.Add ("sdcard");
+                    tempFunction3.value.Add ("audio_in");
+                    tempFunction3.value.Add ("ftp");
+                    tempFunction3.value.Add ("radio");
+                    tempFunction3.value.Add ("bluetooth");
+                    tempFunction3.max = 3;
+                    tempFunction3.min = 0;
+                    tmp.attributes.Add (tempFunction3);
+                    #endregion
+
+                    #region song_step
+                    Function tempFunction2 = new Function ();
+                    tempFunction2.key = "song_step";
+                    tempFunction2.data_type = "string";
+                    tempFunction2.value = new List<string> ();
+                    tempFunction2.value.Add ("up");
+                    tempFunction2.value.Add ("down");
+                    tempFunction2.max = 1;
+                    tempFunction2.min = 0;
+                    tmp.attributes.Add (tempFunction2);
+                    #endregion
+
+                    #region bass
+                    Function tempFunction16 = new Function ();
+                    tempFunction16.key = "playlist_name";
+                    tempFunction16.data_type = "string";
+                    tmp.attributes.Add (tempFunction16);
+                    #endregion
+
+                    #region bass
+                    Function tempFunction17 = new Function ();
+                    tempFunction17.key = "song_name";
+                    tempFunction17.data_type = "string";
+                    tmp.attributes.Add (tempFunction17);
+                    #endregion
+
+                    #region bass
+                    Function tempFunction19 = new Function ();
+                    tempFunction19.key = "song_time";
+                    tempFunction19.data_type = "string";
+                    tmp.attributes.Add (tempFunction19);
+                    #endregion
+
+                    #region bass
+                    Function tempFunction20 = new Function ();
+                    tempFunction20.key = "playing_time";
+                    tempFunction20.data_type = "string";
+                    tmp.attributes.Add (tempFunction20);
+                    #endregion
+                } else if (loopCommon.BigClass == 5) {
+                    //浼犳劅鍣�
+                    if (loopCommon.Type == DeviceType.SensorMobileDetection) {
+                        tmp.spk = "sensor.pir";
+                        #region on_off
+                        Function tempFunction = new Function ();
+                        tempFunction.key = "enable";
+                        tempFunction.data_type = "string";
+                        tempFunction.value = new List<string> ();
+                        tempFunction.value.Add ("true");
+                        tempFunction.value.Add ("false");
+                        tempFunction.max = 1;
+                        tempFunction.min = 0;
+                        tmp.attributes.Add (tempFunction);
+                        #endregion
+
+                        #region status
+                        Function tempFunction1 = new Function ();
+                        tempFunction1.key = "status";
+                        tempFunction1.data_type = "string";
+                        tempFunction1.value = new List<string> ();
+                        tempFunction1.value.Add ("true");
+                        tempFunction1.value.Add ("false");
+                        tempFunction1.max = 1;
+                        tempFunction1.min = 0;
+                        tmp.attributes.Add (tempFunction1);
+                        #endregion
+
+                        #region sensitivity
+                        Function tempFunction2 = new Function ();
+                        tempFunction2.key = "sensitivity";
+                        tempFunction2.data_type = "integer";
+                        tempFunction2.max = 100;
+                        tempFunction2.min = 0;
+                        tmp.attributes.Add (tempFunction2);
+                        #endregion
+                    }else if (loopCommon.Type == DeviceType.SensorTemperature) {
+                        tmp.spk = "sensor.temperature";
+                        #region on_off
+                        Function tempFunction = new Function ();
+                        tempFunction.key = "enable";
+                        tempFunction.data_type = "string";
+                        tempFunction.value = new List<string> ();
+                        tempFunction.value.Add ("true");
+                        tempFunction.value.Add ("false");
+                        tempFunction.max = 1;
+                        tempFunction.min = 0;
+                        tmp.attributes.Add (tempFunction);
+                        #endregion
+
+                        #region temp
+                        Function tempFunction1 = new Function ();
+                        tempFunction1.key = "value";  //2020 12 22 
+                        tempFunction1.data_type = "float";
+                        tempFunction1.max = 50;
+                        tempFunction1.min = 0;
+                        tmp.attributes.Add (tempFunction1);
+                        #endregion
+
+                        #region type
+                        Function tempFunction2 = new Function ();
+                        tempFunction2.key = "type";
+                        tempFunction2.data_type = "string";
+                        tempFunction2.value = new List<string> ();
+                        tempFunction2.value.Add ("C");
+                        tempFunction2.value.Add ("F");
+                        tempFunction2.max = 1;
+                        tempFunction2.min = 0;
+                        tmp.attributes.Add (tempFunction2);
+                        #endregion
+
+                        //#region precision
+                        //Function tempFunction3 = new GateWay.Function();
+                        //tempFunction3.key = "precision";
+                        //tempFunction3.data_type = "string";
+                        //tempFunction3.value = new List<string>();
+                        //tempFunction3.value.Add("0.01");
+                        //tempFunction3.value.Add("0.1");
+                        //tempFunction3.value.Add("100");
+                        //tempFunction3.max = 2;
+                        //tempFunction3.min = 0;
+                        //tmp.attributes.Add(tempFunction3);
+                        //#endregion
+                    }else if (loopCommon.Type == DeviceType.SensorIllumination) {
+                        tmp.spk = "sensor.light";
+                        #region on_off
+                        Function tempFunction = new Function ();
+                        tempFunction.key = "enable";
+                        tempFunction.data_type = "string";
+                        tempFunction.value = new List<string> ();
+                        tempFunction.value.Add ("true");
+                        tempFunction.value.Add ("false");
+                        tempFunction.max = 1;
+                        tempFunction.min = 0;
+                        tmp.attributes.Add (tempFunction);
+                        #endregion
+
+                        #region lux
+                        Function tempFunction1 = new Function ();
+                        tempFunction1.key = "value";  //2020 12 22 
+                        tempFunction1.data_type = "integer";
+                        tmp.attributes.Add (tempFunction1);
+                        #endregion
+
+                        #region error_value
+                        Function tempFunction2 = new Function ();
+                        tempFunction2.key = "error_value";
+                        tempFunction2.data_type = "integer";
+                        tmp.attributes.Add (tempFunction2);
+                        #endregion
+
+                        #region precision
+                        Function tempFunction3 = new Function ();
+                        tempFunction3.key = "precision";
+                        tempFunction3.data_type = "string";
+                        tempFunction3.value = new List<string> ();
+                        tempFunction3.value.Add ("0.01");
+                        tempFunction3.value.Add ("0.1");
+                        tempFunction3.value.Add ("100");
+                        tempFunction3.max = 2;
+                        tempFunction3.min = 0;
+                        tmp.attributes.Add (tempFunction3);
+                        #endregion
+                    } else if (loopCommon.Type == DeviceType.SensorPM25) {
+                        tmp.spk = "sensor.pm25";
+                        #region on_off
+                        Function tempFunction = new Function ();
+                        tempFunction.key = "enable";
+                        tempFunction.data_type = "string";
+                        tempFunction.value = new List<string> ();
+                        tempFunction.value.Add ("true");
+                        tempFunction.value.Add ("false");
+                        tempFunction.max = 1;
+                        tempFunction.min = 0;
+                        tmp.attributes.Add (tempFunction);
+                        #endregion
+
+                        #region value
+                        Function tempFunction1 = new Function ();
+                        tempFunction1.key = "value";
+                        tempFunction1.data_type = "integer";
+                        tmp.attributes.Add (tempFunction1);
+                        #endregion
+
+                        #region error_value
+                        Function tempFunction2 = new Function ();
+                        tempFunction2.key = "error_value";
+                        tempFunction2.data_type = "integer";
+                        tmp.attributes.Add (tempFunction2);
+                        #endregion
+
+                        #region precision
+                        Function tempFunction3 = new Function ();
+                        tempFunction3.key = "precision";
+                        tempFunction3.data_type = "string";
+                        tempFunction3.value = new List<string> ();
+                        tempFunction3.value.Add ("0.01");
+                        tempFunction3.value.Add ("0.1");
+                        tempFunction3.value.Add ("100");
+                        tempFunction3.max = 2;
+                        tempFunction3.min = 0;
+                        tmp.attributes.Add (tempFunction3);
+                        #endregion
+                    }else if (loopCommon.Type == DeviceType.SensorHumidity) {
+                        tmp.spk = "sensor.humidity";
+                        #region on_off
+                        Function tempFunction = new Function ();
+                        tempFunction.key = "enable";
+                        tempFunction.data_type = "string";
+                        tempFunction.value = new List<string> ();
+                        tempFunction.value.Add ("true");
+                        tempFunction.value.Add ("false");
+                        tempFunction.max = 1;
+                        tempFunction.min = 0;
+                        tmp.attributes.Add (tempFunction);
+                        #endregion
+                        #region value
+                        Function tempFunction1 = new Function ();
+                        tempFunction1.key = "value";
+                        tempFunction1.data_type = "float";
+                        tempFunction1.max = 10000;
+                        tempFunction1.min = 0;
+                        tmp.attributes.Add (tempFunction1);
+                        #endregion
+                    }else if (loopCommon.Type == DeviceType.SensorTVOC) {
+                        tmp.spk = "sensor.tvoc";
+                        #region on_off
+                        Function tempFunction = new Function ();
+                        tempFunction.key = "enable";
+                        tempFunction.data_type = "string";
+                        tempFunction.value = new List<string> ();
+                        tempFunction.value.Add ("true");
+                        tempFunction.value.Add ("false");
+                        tempFunction.max = 1;
+                        tempFunction.min = 0;
+                        tmp.attributes.Add (tempFunction);
+                        #endregion
+                        #region value
+                        Function tempFunction1 = new Function ();
+                        tempFunction1.key = "value";
+                        tempFunction1.data_type = "integer";
+                        tempFunction1.max = 10000;
+                        tempFunction1.min = 0;
+                        tmp.attributes.Add (tempFunction1);
+                        #endregion
+                    }else if (loopCommon.Type == DeviceType.SensorCO2) {
+                        tmp.spk = "sensor.co2";
+                        #region on_off
+                        Function tempFunction = new Function ();
+                        tempFunction.key = "enable";
+                        tempFunction.data_type = "string";
+                        tempFunction.value = new List<string> ();
+                        tempFunction.value.Add ("true");
+                        tempFunction.value.Add ("false");
+                        tempFunction.max = 1;
+                        tempFunction.min = 0;
+                        tmp.attributes.Add (tempFunction);
+                        #endregion
+                        #region value
+                        Function tempFunction1 = new Function ();
+                        tempFunction1.key = "value";
+                        tempFunction1.data_type = "integer";
+                        tempFunction1.max = 10000;
+                        tempFunction1.min = 0;
+                        tmp.attributes.Add (tempFunction1);
+                        #endregion
+                    }else if (loopCommon.Type == DeviceType.Sensor) {
+                        tmp.spk = "dryContact.standard";
+                        #region on_off
+                        Function tempFunction = new Function ();
+                        tempFunction.key = "enable";
+                        tempFunction.data_type = "string";
+                        tempFunction.value = new List<string> ();
+                        tempFunction.value.Add ("true");
+                        tempFunction.value.Add ("false");
+                        tempFunction.max = 1;
+                        tempFunction.min = 0;
+                        tmp.attributes.Add (tempFunction);
+                        #endregion
+
+                        #region status
+                        Function tempFunction1 = new Function ();
+                        tempFunction1.key = "status";
+                        tempFunction1.data_type = "string";
+                        tempFunction1.value = new List<string> ();
+                        tempFunction1.value.Add ("on");
+                        tempFunction1.value.Add ("off");
+                        tempFunction1.max = 1;
+                        tempFunction1.min = 0;
+                        tmp.attributes.Add (tempFunction1);
+                        #endregion
+                    } else {
+                        #region on_off
+                        Function tempFunction = new Function ();
+                        tempFunction.key = "enable";
+                        tempFunction.data_type = "string";
+                        tempFunction.value = new List<string> ();
+                        tempFunction.value.Add ("true");
+                        tempFunction.value.Add ("false");
+                        tempFunction.max = 1;
+                        tempFunction.min = 0;
+                        tmp.attributes.Add (tempFunction);
+                        #endregion
+                        #region value
+                        Function tempFunction1 = new Function ();
+                        tempFunction1.key = "value";
+                        tempFunction1.data_type = "integer";
+                        tempFunction1.max = 10000;
+                        tempFunction1.min = 0;
+                        tmp.attributes.Add (tempFunction1);
+                        #endregion
+                    }
+
+
+
+                } else {
+                    #region on_off
+                    Function tempFunction = new Function ();
+                    tempFunction.key = "on_off";
+                    tempFunction.data_type = "string";
+                    tempFunction.value = new List<string> ();
+                    tempFunction.value.Add ("on");
+                    tempFunction.value.Add ("off");
+                    tempFunction.max = 1;
+                    tempFunction.min = 0;
+                    tmp.attributes.Add (tempFunction);
+                    #endregion
+                }
+
+            } catch { }
+            return tmp;
+        }
+
+        //#region 鍒ゆ柇绫诲瀷
+        ///// <summary>
+        ///// 缁х數鍣ㄧ被鍒�
+        ///// </summary>
+        ///// <param name="deviceType"></param>
+        ///// <returns></returns>
+        //public bool IsHDLRelayDeviceType (DeviceType deviceType)
+        //{
+        //    return false;
+        //}
+
+        ///// <summary>
+        ///// 璋冨厜鍣ㄧ被鍒�
+        ///// </summary>
+        ///// <param name="deviceType"></param>
+        ///// <returns></returns>
+        //public bool IsHDLDimmerDeviceType (DeviceType deviceType)
+        //{
+        //    return false;
+        //}
+
+        ///// <summary>
+        ///// 閬槼绫诲埆锛堢獥甯樸�佸嵎甯樸�佸紑鍚堝笜锛�
+        ///// </summary>
+        ///// <param name="deviceType"></param>
+        ///// <returns></returns>
+        //public bool IsHDLCurtainDeviceType (DeviceType deviceType)
+        //{
+        //    return deviceType == DeviceType.CurtainModel
+        //            || deviceType == DeviceType.CurtainRoller
+        //            || deviceType == DeviceType.CurtainTrietex;
+        //}
+
+        ///// <summary>
+        ///// 浼犳劅鍣ㄧ被鍒�
+        ///// </summary>
+        ///// <param name="deviceType"></param>
+        ///// <returns></returns>
+        //public bool IsHDLSensorDeviceType (DeviceType deviceType)
+        //{
+        //    return false;
+        //}
+
+        ///// <summary>
+        ///// 缃戝叧绫诲埆
+        ///// </summary>
+        ///// <param name="deviceType"></param>
+        ///// <returns></returns>
+        //public bool IsHDLGatewayDeviceType (DeviceType deviceType)
+        //{
+        //    return false;
+        //}
+
+        ///// <summary>
+        ///// 绌鸿皟
+        ///// </summary>
+        ///// <param name="deviceType"></param>
+        ///// <returns></returns>
+        //public bool IsHDLACDeviceType (DeviceType deviceType)
+        //{
+        //    return false;
+        //}
+
+        //#endregion
+
+
+        #region 鐢熸垚4浣峛yte 鏃堕棿鎴�
+        private long LastTime = 0;
+        /// <summary>
+        /// DateTime鏃堕棿鏍煎紡杞崲涓�13浣嶅甫姣鐨刄nix鏃堕棿鎴�
+        /// </summary>
+        /// <param name="time"> DateTime鏃堕棿鏍煎紡</param>
+        /// <returns>Unix鏃堕棿鎴虫牸寮�</returns>
+        public long ConvertDateTimeLong ()
+        {
+            System.DateTime startTime = TimeZone.CurrentTimeZone.ToLocalTime (new System.DateTime (2020, 1, 1));
+            long l = (long)(Math.Round ((DateTime.Now - startTime).TotalSeconds, 1) * 10);
+            if (l <= LastTime) l = LastTime + 1;
+            LastTime = l;
+            return l;
+        }
+        /// <summary>
+        /// 
+        /// </summary>
+        /// <param name="m"></param>
+        /// <param name="strTmp"></param>
+        /// <returns></returns>
+        public bool ConvertIntToByteArray (long m, ref string strTmp)
+        {
+            strTmp = "00000000";
+            byte [] arry = new byte [4];
+            arry [0] = (byte)(m & 0xFF);
+            arry [1] = (byte)((m & 0xFF00) >> 8);
+            arry [2] = (byte)((m & 0xFF0000) >> 16);
+            arry [3] = (byte)((m & 0xFF000000) >> 24);
+            strTmp = arry [0].ToString ("X2") + arry [1].ToString ("X2") + arry [2].ToString ("X2") + arry [3].ToString ("X2");
+            return true;
+        }
+        #endregion
+
+    }
+
+    [Serializable]
+    public class BaseCloudFeedback
+    {
+        public int code { get; set; }
+        public string timestamp { get; set; }
+        public bool isSuccess { get; set; }
+        public string message { get; set; }
+    }
+
+    [Serializable]
+    public class Sids
+    {
+        public string homeId { get; set; }
+        public string gatewayId { get; set; }
+        public List<Sid> devices { get; set; }
+    }
+
+    [Serializable]
+    public class Oids
+    {
+        public string homeId { get; set; }
+        public string gatewayId { get; set; }
+        public List<Oid> devices { get; set; }
+    }
+
+    [Serializable]
+    public class Oid
+    {
+        public string protocolType { get; set; }
+        public string device_name { get; set; }
+        public string oid { get; set; }
+        public string addresses { get; set; }
+        public string device_model { get; set; }
+
+        public string fw_version { get; set; }
+        public string hw_info { get; set; }
+        public string mac { get; set; }
+        public string deviceType { get; set; }
+    }
+
+    [Serializable]
+    public class Sid
+    {
+        public string sid { get; set; }
+        public string name { get; set; }
+        public string [] uids { get; set; }
+        public string spk { get; set; }
+
+        public string oid { get; set; }  //璁惧妯″潡鍦板潃
+        public string omodel { get; set; }    //鍨嬪彿
+        public List<Function> attributes { get; set; } //灞炴�у垪琛�
+    }
+
+
+    [Serializable]
+    public class Function
+    {
+        //public string name { get; set; }
+        public string key { get; set; }
+        public List<string> value { get; set; }
+        public int max { get; set; }
+        public int min { get; set; }
+        public string data_type { get; set; }
+    }
+
+    [Serializable]
+    public class SidObject : Sid
+    {
+
+    }
+
+    [Serializable]
+    public class IotCloud
+    {
+        public Oids modules { get; set; } //璁惧鍒楄〃
+        public Sids functions { get; set; } //鍔熻兘鍒楄〃
+    }
+
+    ///// <summary>
+    ///// 涓婁紶Oid鍒楄〃
+    ///// </summary>
+    //[Serializable]
+    //public class UploadOids
+    //{
+    //    public string homeId { get; set; } //浣忓畢ID
+    //    public Oids devices { get; set; } //璁惧鍒楄〃
+    //}
+
+    ///// <summary>
+    ///// 涓婁紶Sid鍒楄〃
+    ///// </summary>
+    //[Serializable]
+    //public class UploadSids
+    //{
+    //    public string homeId { get; set; } //浣忓畢ID
+    //    public string gatewayId { get; set; } //缃戝叧ID
+    //    public Sids devices { get; set; } //璁惧鍒楄〃
+    //}
+
+}
+
+
+//sid缁勬垚閮ㄥ垎锛�
+//sid
+//鏉ユ簮	鍘傚晢浠g爜	閫氳鏂瑰紡	浜у搧鏃堕棿鎴�	浜у搧绫诲埆	鐗╂ā鍨嬬被	閫氶亾鍙�	澶у皬绫诲埆
+//1byte	1byte	1byte	4byte	1byte	2byte	2byte	2byte
+//oid缁勬垚閮ㄥ垎锛�
+//鏉ユ簮	鍘傚晢浠g爜	閫氳鏂瑰紡	浜у搧鏃堕棿鎴�	浜у搧绫诲埆
+//1byte	1 byte	1 byte	4 byte	1byte
+//鍏朵腑鍚勯儴鍒嗕唬鐮佸垪琛細
+//鏉ユ簮	1byte	缂栧彿	鎻忚堪
+//		00	榛樿鍘熺敓鎬佺郴缁熸暟鎹�
+//		01	缃戝叧鎴栬�呭叾浠朅璁惧
+//		02	璋冭瘯杞欢
+//		03	APP搴旂敤绋嬪簭
+//		04	绗笁鏂圭綉鍏虫垨鑰呭钩鍙�
+
+//鍘傚晢浠g爜	1byte	缂栧彿	鎻忚堪
+//		01	HDL
+//		02	
+
+//閫氳鏂瑰紡	1byte	缂栧彿	鎻忚堪
+//		01	HDL Bus
+//		02	Zigbee
+//		03	KNX
+//		04	Z-Wave
+
+//浜у搧鏃堕棿鎴�	4bytes	浠�2020骞�1鏈�1鏃ョ畻鍑虹殑鏃堕棿鎴�0.1s涓哄崟浣�
+
+//浜у搧绫诲埆	1byte	缂栧彿	鎻忚堪
+//		01	璋冨厜鍣�
+//		02	缁х數鍣�
+//		03	骞叉帴鐐规ā鍧�
+//		04	浼犳劅鍣�
+//		05	闈㈡澘
+//		06	RCU
+//		07	缃戝叧
+//		08	绾㈠鍙戝皠
+//		09	Android灞�
+//		10	鍦烘櫙
+//		11	闊充箰鎾斁鍣�
+//		12	232/485杞崲鍣�
+//		21	鑷姩鍖�
+//		22	瀹夐槻闃插尯
+//		14	绐楀笜妯″潡
+//		15	HVAC
+//		16	鍦扮儹妯″潡
+
+//鐗╂ā鍨嬬被鍨�	2bytes	缂栧彿	鎻忚堪
+//		01	寮�鍏崇被	01	寮�鍏�
+//				02	鎻掑骇
+//				03	
+//		02	鐓ф槑	01	寮�鍏�
+//				02	璋冨厜
+//				03	鑹叉俯(CCT)
+//				04	RGB
+//		03	閬槼	01	绐楀笜鎺у埗鍣�
+//				02	鐧惧彾绐�
+//				03	寮�鍚堝笜
+//				04	鍗峰笜
+//				05	聽鎺ㄧ獥鍣�
+//				06	聽鎶曞奖骞�
+//		04	闈㈡澘	01	鎸夐敭闈㈡澘
+//		05	浼犳劅鍣�	01	绉诲姩鎺㈡祴
+//				02	娓╁害浼犳劅鍣�
+//				03	婀垮害浼犳劅鍣�
+//				04	鐓у害浼犳劅鍣�
+//				05	TVOC
+//				06	PM2.5
+//				07	CO2
+//				08	姣背娉紶鎰熷櫒
+//				09	
+//				10	
+//				11	鐑熼浘浼犳劅鍣�
+//				25	骞叉帴鐐�
+//		07	鎭掓俯鍣�	01	绌鸿皟
+//				02	椋庢墖
+//				03	姣涚粏绌鸿皟
+//		08	鍦扮儹	01	鍦扮儹妯″潡
+//		09	鑳屾櫙闊充箰	01	闊充箰鎾斁鍣�
+//				02	Sonos
+//		10	鍦烘櫙	01	鍦烘櫙
+//				02	鐢靛奖鍦烘櫙
+//		19	鏂伴	01	鏂伴
+
+//13	鑳芥簮	01	鐢佃〃
+//				02	姘磋〃
+//				03	鐕冩皵
+//		16	鐢靛櫒	01	椋庢墖
+//				02	TV
+//		20	瀹夐槻	01	瀹夐槻
+//		21	鑷姩鍖�	01	鑷姩鍖�
+//澶х被鍒�	1bytes	锛堥鐣欙級
+//灏忕被鍒�	1byte	锛堥鐣欙級
\ No newline at end of file

--
Gitblit v1.8.0