From 271faaf6664166dc368639b9f2e577f63f901be5 Mon Sep 17 00:00:00 2001
From: wei <kaede@kaededeMacBook-Air.local>
Date: 星期三, 23 十二月 2020 22:23:57 +0800
Subject: [PATCH] 20201223-99

---
 HDL_ON/DAL/DriverLayer/Control.cs |   59 ++++++++++++++++++++++++++++++++++++++++++-----------------
 1 files changed, 42 insertions(+), 17 deletions(-)

diff --git a/HDL_ON/DAL/DriverLayer/Control.cs b/HDL_ON/DAL/DriverLayer/Control.cs
index 2e8555f..a894698 100644
--- a/HDL_ON/DAL/DriverLayer/Control.cs
+++ b/HDL_ON/DAL/DriverLayer/Control.cs
@@ -178,14 +178,6 @@
             }
         }
 
-        ///// <summary>
-        ///// 鏀瑰彉閫氳鏂瑰紡
-        ///// </summary>
-        //public void ChangeCommunicationMode(CommunicationMode communicationMode)
-        //{
-        //    this.communicationMode = communicationMode;
-        //}
-
         /// <summary>
         /// 鎼滅储鏈湴缃戝叧鍒楄〃
         /// </summary>
@@ -240,7 +232,6 @@
                 })
                 { IsBackground = true }.Start();
             }
-            
         }
 
         /// <summary>
@@ -250,7 +241,11 @@
         {
             if (Ins.IsRemote || DB_ResidenceData.Instance.GatewayType == 1)
             {
-                ControlAProtocolScene(scene);
+                new System.Threading.Thread(() =>
+                {
+                    ControlAProtocolScene(scene);
+                })
+                { IsBackground = true }.Start();
             }
             else
             {
@@ -271,8 +266,32 @@
         /// <returns></returns>
         public void SendWriteCommand(Function function, Dictionary<string, string> commandDictionary)
         {
-            function.usageCount++;
+            function.controlCounter++;
             function.refreshTime = DateTime.Now;
+
+            //濡傛灉鏄帶鍒惰皟鍏夌殑寮�鏃讹紝浜害鍊间笉鑳戒负0
+            if (commandDictionary.Count > 2)
+            {
+                if (commandDictionary.ContainsKey(FunctionAttributeKey.OnOff) && commandDictionary.ContainsKey(FunctionAttributeKey.Brightness))
+                {
+                    if (commandDictionary[FunctionAttributeKey.OnOff] == "on")
+                    {
+                        if (commandDictionary[FunctionAttributeKey.Brightness] == "0")
+                        {
+                            commandDictionary[FunctionAttributeKey.Brightness] = "100";
+                        }
+                    }
+                    if (commandDictionary[FunctionAttributeKey.OnOff] == "off")
+                    {
+                        if (commandDictionary[FunctionAttributeKey.Brightness] != "0")
+                        {
+                            commandDictionary[FunctionAttributeKey.Brightness] = "0";
+                        }
+                    }
+                }
+            }
+
+            MainPage.Log($"鍙戦�佹暟鎹�:{Newtonsoft.Json.JsonConvert.SerializeObject(commandDictionary)}");
 
             //杩滅▼閫氳
             if (Ins.IsRemote)
@@ -283,7 +302,6 @@
                 var actionObjs = new List<ApiAlinkControlActionObj>();
                 actionObjs.Add(apiControlData);
                 var pack = httpServer.ControlDevice(actionObjs);
-                //MainPage.Log($"{pack.Code}:{pack.Data}");
             }
             //鏈湴閫氳
             else
@@ -307,6 +325,7 @@
                     var functionControlDataJson = Newtonsoft.Json.JsonConvert.SerializeObject(functionControlDataObj);
                     var sendBytes = Ins.ConvertSendBodyData(CommunicationTopic.ct.ControlFunctionTopic, functionControlDataJson);
                     new Control_Udp().SendLocalHdlLinkData(sendBytes, functionControlDataObj.id);
+                    MainPage.Log($"鍙戦�丠DL-Link鏁版嵁:{functionControlDataJson}");
                 }
             }
         }
@@ -358,6 +377,7 @@
                     };
                     var functionControlDataJson = Newtonsoft.Json.JsonConvert.SerializeObject(readDataObj);
                     var sendBytes = Ins.ConvertSendBodyData(CommunicationTopic.ct.ReadStatus, functionControlDataJson);
+                    MainPage.Log($"鍙戦�丠DL-Link鏁版嵁:{functionControlDataJson}");
                     new Control_Udp().SendLocalHdlLinkData(sendBytes, readDataObj.id);
                 }
             }
@@ -386,8 +406,8 @@
         {
             if (Ins.IsRemote)
             {
-                var pm = new HDL_ON.DAL.Server.HttpServerRequest();
-                pm.ExecuteScene(scene.userSceneId);
+                var pm = new DAL.Server.HttpServerRequest();
+                var result = pm.ExecuteScene(scene.userSceneId);
             }
             else
             {
@@ -418,7 +438,7 @@
 
             string sendDataString = topicString + lengthString + bodyDataString;
             byte[] sendDataBytes = Encoding.ASCII.GetBytes(sendDataString);
-            MainPage.Log($"杞崲HDL-Link鏁版嵁\r\n{sendDataString}\r\n");
+            //MainPage.Log($"杞崲HDL-Link鏁版嵁\r\n{sendDataString}\r\n");
 
             return sendDataBytes;
         }
@@ -458,6 +478,10 @@
                             break;
                     }
                 }
+
+                MainPage.Log($"time 1 :{receiveObj.Topic}");
+
+
                 //楠岃瘉鏈夋晥鏁版嵁闀垮害
                 //if (res[1].Length != receiveObj.Length)
                 //{
@@ -492,6 +516,7 @@
                     }
                 }
                 else if (receiveObj.Topic == CommunicationTopic.ct.ReadStatus + "_reply" ||
+                    receiveObj.Topic == CommunicationTopic.ct.ControlFunctionTopic + "_reply" ||
                     receiveObj.Topic == CommunicationTopic.ct.GatewayUpStatus)
                 {
                     //TODO 鏆傛椂涓嶄紶姝g‘鐨勬暟鎹笂鍘伙紝濡傛灉鍚庨潰瑕佷紭鍖栧墠闈㈣繖浜涗唬鐮�
@@ -547,7 +572,7 @@
                                                 localAttr.curValue = attr.value;
                                             }
                                         }
-                                        MainPage.Log($"{localSwitch.trait_on_off.curValue}: ");
+                                        //rgb.lastState = Language.StringByID(StringId.Brightness) + " : " + rgb.brightness + "%";
                                         RelayPage.UpdataState(localSwitch);
                                     }
                                     break;
@@ -618,7 +643,7 @@
                                             }
                                         }
                                         lightCCT.lastState = Language.StringByID(StringId.Brightness) + " : " + lightCCT.brightness + "%";
-                                        DimmerPage.UpdataStates(lightCCT);
+                                        ColorTureLampPage.UpdataStates(lightCCT);
                                     }
                                     break;
                                 case SPK.CurtainSwitch:

--
Gitblit v1.8.0