From bb6ad792b598927a5459a5fb6f6c27fb1aa9e94e Mon Sep 17 00:00:00 2001
From: wei <kaede@kaededeMacBook-Air.local>
Date: 星期四, 17 十二月 2020 14:06:36 +0800
Subject: [PATCH] 20201217-1

---
 HDL_ON/Entity/Function/Function.cs |   36 +++++++++++++++++++++++++++---------
 1 files changed, 27 insertions(+), 9 deletions(-)

diff --git a/HDL_ON/Entity/Function/Function.cs b/HDL_ON/Entity/Function/Function.cs
index e33e5c6..ddafe50 100644
--- a/HDL_ON/Entity/Function/Function.cs
+++ b/HDL_ON/Entity/Function/Function.cs
@@ -208,7 +208,7 @@
             string busId = "";
             if (bus != null)
             {
-                busId = bus.SubnetID + "_" + bus.DeviceID + "_" + bus.loopId;
+                busId = bus.SubnetID + "_" + bus.DeviceID + "_" + bus.LoopId;
             }
             return busId;
         }
@@ -286,17 +286,22 @@
             var sFunc = new SceneFunction();
             foreach (var attr in attributes)
             {
+                if (attr.curValue.ToString() == "{}")
+                {
+                    attr.curValue = "0";
+                }
                 if (attr.key == FunctionAttributeKey.SetTemp)
                 {
-                    var vv = Convert.ToDouble(attr.value);
+                    double vv = 16;
+                    Double.TryParse(attr.curValue.ToString(),out vv);
                     sFunc.status.Add(new SceneFunctionStatus() { key = attr.key, value = Convert.ToInt32(vv).ToString() });
                 }
                 else
                 {
                     sFunc.status.Add(new SceneFunctionStatus() { key = attr.key, value = attr.curValue.ToString() });
                 }
-                sFunc.sid = this.sid;
             }
+            sFunc.sid = this.sid;
             return sFunc;
         }
 
@@ -317,9 +322,9 @@
 
             var acd = new AlinkControlData();
             acd.sid = sid;
-            var aca = new AlinkControlAttributes();
             foreach (var dic in commandDictionary)
             {
+                var aca = new AlinkControlAttributes();
                 aca.key = dic.Key;
                 aca.value = dic.Value;
                 acd.status.Add(aca);
@@ -420,6 +425,7 @@
     /// 鍔熻兘灞炴��
     /// 灞炴�у瓧娈佃В鏋愶細attri :灞炴�у唴瀹癸紝value 灞炴�х殑鍊硷紝max 鏈�澶у�� min 鏈�灏忓��
     /// </summary>
+    [System.Serializable]
     public class FunctionAttributes
     {
         /// <summary>
@@ -464,7 +470,11 @@
         /// <summary>
         /// 棰滆壊
         /// </summary>
-        public const string Color = "color";
+        public const string RGB = "rgb";
+        /// <summary>
+        /// 娓愬彉鏃堕棿
+        /// </summary>
+        public const string FadeTime = "fade_time";
         /// <summary>
         /// 妯″紡
         /// </summary>
@@ -529,7 +539,15 @@
                 return Convert.ToByte(addresses.Substring(2, 2), 16);
             }
         }
-        public byte loopId;
+        public byte LoopId
+        {
+            get
+            {
+                return Convert.ToByte(loopId, 16);
+            }
+        }
+
+        public string loopId;
     }
 
     public static class SPK
@@ -625,15 +643,15 @@
         /// <summary>
         /// 瀹剁數銆佹彃搴�
         /// </summary>
-        public const string ElectricSocket = "electric.socket ";
+        public const string ElectricSocket = "electrical.socket";
         /// <summary>
         /// 瀹剁數銆佺數瑙�
         /// </summary>
-        public const string ElectricTV = "electric.tv";
+        public const string ElectricTV = "electrical.tv";
         /// <summary>
         /// 瀹剁數銆侀鎵�
         /// </summary>
-        public const string ElectricFan = "electric.fan";
+        public const string ElectricFan = "electrical.fan";
     }
 
 }
\ No newline at end of file

--
Gitblit v1.8.0