From bdc8f378f6d736fda030b3ceceab3acd91505679 Mon Sep 17 00:00:00 2001
From: wjc <1243177876@qq.com>
Date: 星期二, 28 三月 2023 16:10:50 +0800
Subject: [PATCH] Merge branch 'wjc' into dev-cqy(1.5.9)

---
 HDL_ON/DAL/DriverLayer/Control.cs |  114 ++++++++++++++++++++++++++++++--------------------------
 1 files changed, 61 insertions(+), 53 deletions(-)

diff --git a/HDL_ON/DAL/DriverLayer/Control.cs b/HDL_ON/DAL/DriverLayer/Control.cs
index 652bc0d..bd951d5 100644
--- a/HDL_ON/DAL/DriverLayer/Control.cs
+++ b/HDL_ON/DAL/DriverLayer/Control.cs
@@ -83,8 +83,10 @@
         /// <summary>
         /// 鍒ゆ柇鏄惁鏈湴鍔犲瘑骞朵笖鍔犲瘑key涓嶄负绌�
         /// </summary>
-        public bool IsLocalEncryptAndGetAesKey {
-            get {
+        public bool IsLocalEncryptAndGetAesKey
+        {
+            get
+            {
                 return IsLocalEncrypt && (!string.IsNullOrEmpty(DB_ResidenceData.Instance.CurrentRegion.localSecret));
             }
         }
@@ -139,7 +141,7 @@
                 if (_GatewayOnline_Cloud != value)
                 {
                     _GatewayOnline_Cloud = value;
-                    if(GatewayOnline_Local)
+                    if (GatewayOnline_Local)
                     {
                         return;
                     }
@@ -249,7 +251,7 @@
         public void SearchLoaclGateway()
         {
             //2021-01-15 : 浣忓畢娌℃湁缁戝畾缃戝叧鐨勬椂鍊欎笉鐢ㄦ悳绱紝骞朵笖涓嶈兘閾炬帴mqtt
-            if(DB_ResidenceData.Instance.HomeGateway == null || string.IsNullOrEmpty(DB_ResidenceData.Instance.HomeGateway.gatewayId))
+            if (DB_ResidenceData.Instance.HomeGateway == null || string.IsNullOrEmpty(DB_ResidenceData.Instance.HomeGateway.gatewayId))
             {
                 return;
             }
@@ -308,9 +310,10 @@
         /// </summary>
         public void LoginGateway()
         {
-            if(loginGatewayThread== null)
+            if (loginGatewayThread == null)
             {
-                loginGatewayThread = new System.Threading.Thread(() => {
+                loginGatewayThread = new System.Threading.Thread(() =>
+                {
                     while (!Ins.myTcpClient.isConnected)
                     {
                         if (Ins.GatewayOnline_Local && myTcpClient.isConnected)
@@ -337,7 +340,8 @@
                 try
                 {
                     loginGatewayThread?.Abort();
-                }catch (Exception ex)
+                }
+                catch (Exception ex)
                 {
                     MainPage.Log($"閲嶅惎鐧诲綍缃戝叧绾跨▼寮傚父:{ex.Message}");
                 }
@@ -347,7 +351,7 @@
                     LoginGateway();
                 }
             }
-            
+
         }
 
 
@@ -357,9 +361,9 @@
         public void ControlScene(Scene scene)
         {
             //浣撻獙妯″紡
-            if(MainPage.NoLoginMode)
+            if (MainPage.NoLoginMode)
             {
-                foreach(var sceneFunction in scene.functions)
+                foreach (var sceneFunction in scene.functions)
                 {
                     var revString = "";
                     var upDataObj = new AlinkFunctionStatusObj();
@@ -406,7 +410,7 @@
         /// <param name="function"></param>
         /// <param name="useRemote">鏄惁鐩存帴浣跨敤杩滅▼鍙戦��</param>
         /// <returns></returns>
-        public bool SendWriteCommand(Function function, Dictionary<string, string> commandDictionary, bool useRemote = false,int resend = 3)
+        public bool SendWriteCommand(Function function, Dictionary<string, string> commandDictionary, bool useRemote = false, int resend = 3)
         {
             function.controlCounter++;
             function.refreshTime = DateTime.Now;
@@ -504,7 +508,7 @@
                         var functionControlDataObj = function.GetGatewayAlinkControlData(commandDictionary);
                         var functionControlDataJson = Newtonsoft.Json.JsonConvert.SerializeObject(functionControlDataObj);
                         var sendBytes = Ins.ConvertSendBodyData(CommunicationTopic.ct.ControlFunctionTopic, functionControlDataJson);
-                        new Control_Udp().SendLocalHdlLinkData(sendBytes, functionControlDataObj.id,resend);
+                        new Control_Udp().SendLocalHdlLinkData(sendBytes, functionControlDataObj.id, resend);
                         MainPage.Log($"鏈湴閫氳 鍙戦�丠DL-Link鏁版嵁:{functionControlDataJson}");
                     }
                 }
@@ -522,7 +526,7 @@
                                 commandDictionary.Add(FunctionAttributeKey.OnOff, commandDictionary[FunctionAttributeKey.Brightness] == "0" ? "off" : "on");
                             }
                         }
-                        if(function.spk == SPK.LightCCT)
+                        if (function.spk == SPK.LightCCT)
                         {
                             if (!commandDictionary.ContainsKey(FunctionAttributeKey.CCT))
                             {
@@ -546,10 +550,10 @@
         /// <summary>
         /// 鍏ㄥ紑鍏ㄥ叧鍔熻兘
         /// </summary>
-        public void SwtichFunctions(bool open,List<Function> functions)
+        public void SwtichFunctions(bool open, List<Function> functions)
         {
             //dome妯″紡鎺у埗
-            if(MainPage.NoLoginMode)
+            if (MainPage.NoLoginMode)
             {
                 new System.Threading.Thread(() =>
                 {
@@ -557,7 +561,7 @@
                     {
                         Dictionary<string, string> d1 = new Dictionary<string, string>();
                         d1.Add(FunctionAttributeKey.OnOff, open ? "on" : "off");
-                         if (function.spk == SPK.PanelSocket)
+                        if (function.spk == SPK.PanelSocket)
                         {
                             if (function.attributes.Find((obj) => obj.key == "on_off_usb") != null)
                             {
@@ -623,16 +627,16 @@
         {
             var pm = new DAL.Server.HttpServerRequest();
             var pack = pm.GetDeviceInfoList(functionIds);
-            if(pack!= null&& pack.Data!=null)
+            if (pack != null && pack.Data != null)
             {
                 //寰呮祴璇�2021-03-04
                 var ddd = Newtonsoft.Json.JsonConvert.DeserializeObject<List<AlinkStatusData>>(pack.Data.ToString());
-                if(ddd!= null)
+                if (ddd != null)
                 {
-                    foreach(var function in ddd)
+                    foreach (var function in ddd)
                     {
                         var temp = FunctionList.List.GetDeviceFunctionList().Find((obj) => obj.deviceId == function.deviceId);
-                        if(temp!= null)
+                        if (temp != null)
                         {
                             if (SPK.Get3tySpk(SPK.BrandType.Tuya).Contains(temp.spk))
                             {
@@ -648,7 +652,7 @@
         /// 鍙戦�佽鍙栧懡浠�
         /// 鑷姩鍒ゆ柇鏄惁涓篈鍗忚璁惧
         /// </summary>
-        public void SendReadCommand(Function function ,bool forceRemote = false)
+        public void SendReadCommand(Function function, bool forceRemote = false)
         {
             function.refreshTime = DateTime.Now;
             if (forceRemote)
@@ -732,7 +736,7 @@
                             {
                                 busClient.ReadBusData(function);
                             }
-                            
+
                         }
                         catch (Exception ex)
                         {
@@ -776,7 +780,7 @@
         /// <summary>
         /// 瀹夐槻鎺у埗
         /// </summary>
-        public void ControlSecurity(SecurityAlarm securityAlarm,string state)
+        public void ControlSecurity(SecurityAlarm securityAlarm, string state)
         {
             if (!Ins.GatewayOnline_Local)//缃戝叧鏈湴涓嶅湪绾�
             {
@@ -834,7 +838,7 @@
                 };
                 var aLinkJson = Newtonsoft.Json.JsonConvert.SerializeObject(aLinkData);
                 var sendBytes = Ins.ConvertSendBodyData(CommunicationTopic.ct.ControlScene, aLinkJson);
-                new Control_Udp().SendLocalHdlLinkData(sendBytes, aLinkData.id,0);
+                new Control_Udp().SendLocalHdlLinkData(sendBytes, aLinkData.id, 0);
             }
         }
 
@@ -928,10 +932,10 @@
         /// 杞崲鎺ユ敹鍒扮殑鏁版嵁
         /// </summary>
         /// <returns></returns>
-        public void ConvertReceiveData(byte[] receiveBytes,string ip)
+        public void ConvertReceiveData(byte[] receiveBytes, string ip)
         {
             var reString = Encoding.UTF8.GetString(receiveBytes);
-            AnalysisReceiveData(reString, receiveBytes,ip);
+            AnalysisReceiveData(reString, receiveBytes, ip);
         }
         /// <summary>
         /// 杞崲鎺ユ敹鍒扮殑鏁版嵁
@@ -939,7 +943,7 @@
         /// <param name="receiveString">杞琒tring鍚庣殑鏁版嵁</param>
         /// <param name="originalReceiveBytes"鍘熷Bytes鏁版嵁</param>
         /// <returns></returns>
-        public LocalCommunicationData AnalysisReceiveData(string receiveString, byte[] originalReceiveBytes , string sIp = null)
+        public LocalCommunicationData AnalysisReceiveData(string receiveString, byte[] originalReceiveBytes, string sIp = null)
         {
             LocalCommunicationData receiveObj = new LocalCommunicationData();
 
@@ -1118,7 +1122,8 @@
                         MainPage.Log($"瀹夐槻灞�鍩熺綉寮傚父锛歿ex.Message}");
                     }
                 }
-                else if (receiveObj.Topic == $"/user/{GatewayId}/custom/gateway/login_reply") {
+                else if (receiveObj.Topic == $"/user/{GatewayId}/custom/gateway/login_reply")
+                {
                     var temp = Newtonsoft.Json.JsonConvert.DeserializeObject<JObject>(receiveObj.BodyDataString);
                     if (temp.GetValue("objects").ToString().Contains("success"))
                     {
@@ -1161,7 +1166,7 @@
             }
             else
             {
-                if(processedDataList.Count> 50)
+                if (processedDataList.Count > 50)
                 {
                     processedDataList.RemoveAt(0);
                 }
@@ -1175,7 +1180,7 @@
         /// A鍗忚鏁版嵁
         /// </summary>
         /// <param name="updateBytes"></param>
-        public void UpdataFunctionStatus(string revString, byte[] usefulBytes,bool isCloudData = false)
+        public void UpdataFunctionStatus(string revString, byte[] usefulBytes, bool isCloudData = false)
         {
             ////test 浜戠杩炴帴鎴愬姛鏃讹紝涓嶉�傜敤鏈湴鏁版嵁鏇存柊
             //if (Ins.GatewayOnline_Cloud && !isCloudData)
@@ -1218,7 +1223,7 @@
 
                         if (Ins.GatewayOnline_Local && isCloudData)//鏈湴閾炬帴锛岄櫎浜嗘秱楦﹁澶囨暟鎹箣澶栫殑浜戠鏁版嵁涓嶅鐞�
                         {
-                            if (!SPK.Get3tySpk(SPK.BrandType.All3tyBrand).Contains(localFunction.spk) && !SPK.MusicSpkList().Contains( localFunction.spk))
+                            if (!SPK.Get3tySpk(SPK.BrandType.All3tyBrand).Contains(localFunction.spk) && !SPK.MusicSpkList().Contains(localFunction.spk))
                             {
                                 //MainPage.Log($"A鍗忚鏇存柊鐘舵��:鏈湴閾炬帴锛岄櫎浜嗘秱楦﹁澶囨暟鎹箣澶栫殑浜戠鏁版嵁涓嶅鐞�........");
 
@@ -1226,21 +1231,21 @@
                             }
                         }
 
-                        //if (SPK.MusicSpkList().Contains(localFunction.spk))
-                        //{
-                        //    if (updateTemp.status.Count < 3)
-                        //    {
-                        //        ///鏄煶涔愬姛鑳界殑
-                        //        ///涓婃姤灞炴�у皯3鏉′笉鍋氬鐞�
-                        //        return;
-                        //    }
-                        //}
-                        MainPage.Log($"闊充箰鏀跺埌鏁版嵁:{revString}");
+                        if (SPK.MusicSpkList().Contains(localFunction.spk))
+                        {
+                            MainPage.Log($"闊充箰鏀跺埌鏁版嵁:{revString}");
+
+                        }
                         foreach (var attr in updateTemp.status)
                         {
                             localFunction.time_stamp = temp.time_stamp;
                             localFunction.SetAttrState(attr.key, attr.value);
-                            Console.WriteLine("闊充箰鎾斁鍣ㄦ坊鍔犵紦瀛樻暟鎹�=======" + revString);
+                            if (SPK.MusicSpkList().Contains(localFunction.spk))
+                            {
+                                Console.WriteLine("闊充箰鎾斁鍣ㄦ坊鍔犵紦瀛樻暟鎹�=======" + revString);
+
+                            }
+
 
                         }
 
@@ -1256,7 +1261,7 @@
                                 break;
                             case SPK.AirSwitch:
                                 AirSwitchPage.UpdataState(localFunction);
-                                if(localFunction.GetAttribute(FunctionAttributeKey.Power)!=null)//濡傛灉鏄甫鐢甸噺鐨勭┖寮�涔熻鏇存柊鑳芥簮鐣岄潰
+                                if (localFunction.GetAttribute(FunctionAttributeKey.Power) != null)//濡傛灉鏄甫鐢甸噺鐨勭┖寮�涔熻鏇存柊鑳芥簮鐣岄潰
                                 {
                                     EnergyMainPage.UpdataStatus(localFunction);
                                 }
@@ -1295,7 +1300,7 @@
                                 CurtainModulePage.UpdataState(localFunction);
                                 break;
                             case SPK.CurtainDream:
-                                if(localFunction.GetAttrState(FunctionAttributeKey.Percent) == "0")
+                                if (localFunction.GetAttrState(FunctionAttributeKey.Percent) == "0")
                                 {
                                     localFunction.SetAttrState(FunctionAttributeKey.OnOff, "off");
                                 }
@@ -1388,7 +1393,7 @@
                             case SPK.SensorTemperature:
                             case SPK.SensorHumidity:
                             case SPK.SensorHcho:
-                                if(localFunction.spk == SPK.SensorTemperature)
+                                if (localFunction.spk == SPK.SensorTemperature)
                                 {
                                     HomePage.LoadEvent_RefreshEnvirIndoorTemp();
                                 }
@@ -1490,7 +1495,7 @@
                             case SPK.AvMusic:
                             case SPK.MusicStandard:
                                 //UI.Music.MusicMain.mMusicMain.RefreshView(updateTemp);
-                                Console.WriteLine("闊充箰鎾斁鍣ㄦ樉绀虹姸鎬�======="+ revString);
+                                Console.WriteLine("闊充箰鎾斁鍣ㄦ樉绀虹姸鎬�=======" + revString);
                                 //wjc
                                 break;
                             case SPK.Inverter:
@@ -1524,12 +1529,12 @@
         /// <summary>
         /// //涓�閿紙杩滅▼锛夊紑閿�
         /// </summary>
-        public void OneKeyUnlocking(Function doorlock,string extStr)
+        public void OneKeyUnlocking(Function doorlock, string extStr)
         {
             if (Ins.GatewayOnline_Local)
             {
                 Dictionary<string, string> dic = new Dictionary<string, string>();
-                var functionControlDataObj = doorlock.GetGatewayAlinkDoorlockData(UserInfo.Current.ID,extStr);
+                var functionControlDataObj = doorlock.GetGatewayAlinkDoorlockData(UserInfo.Current.ID, extStr);
                 var functionControlDataJson = Newtonsoft.Json.JsonConvert.SerializeObject(functionControlDataObj);
                 var sendBytes = Ins.ConvertSendBodyData($"/base/{Control.Ins.GatewayId}/thing/service/doorRemoteOpen/down", functionControlDataJson);
                 new Control_Udp().SendLocalHdlLinkData(sendBytes, functionControlDataObj.id, 0);
@@ -1544,7 +1549,7 @@
         /// </summary>
         /// <param name="functionId"></param>
         /// <param name="pwd"></param>
-        public void ConfirmUnlocking(string functionId,string pwd)
+        public void ConfirmUnlocking(string functionId, string pwd)
         {
             Loading loading = new Loading();
             MainPage.BaseView.AddChidren(loading);
@@ -1580,8 +1585,10 @@
                         //{
                         //    return false;
                         //}
-                        if (pack.Code != StateCode.SUCCESS) {
-                            Application.RunOnMainThread(() => {
+                        if (pack.Code != StateCode.SUCCESS)
+                        {
+                            Application.RunOnMainThread(() =>
+                            {
                                 new PublicAssmebly().TipMsg(Language.StringByID(StringId.Tip), pack.message);
                                 UserInfo.Current.doorPasswordString = "";//
                                 UserInfo.Current.LastTimeOpenDoor = DateTime.MinValue;
@@ -1590,8 +1597,9 @@
                     }
                     if (pack.Code != StateCode.SUCCESS)
                     {
-                        Application.RunOnMainThread(() => {
-                            if(string.IsNullOrEmpty(pack.message))
+                        Application.RunOnMainThread(() =>
+                        {
+                            if (string.IsNullOrEmpty(pack.message))
                             {
                                 new PublicAssmebly().TipMsg(Language.StringByID(StringId.Tip),
                                     Language.StringByID(StringId.OperationFailed));

--
Gitblit v1.8.0