From e13a9980ce617db1394a76944186c5d5bd595d5d Mon Sep 17 00:00:00 2001 From: wei <kaede@kaededeMacBook-Air.local> Date: 星期三, 02 六月 2021 14:37:12 +0800 Subject: [PATCH] 5月需求bug修复 --- HDL_ON/DAL/DriverLayer/Control.cs | 84 +++++++++++++++++++----------------------- 1 files changed, 38 insertions(+), 46 deletions(-) diff --git a/HDL_ON/DAL/DriverLayer/Control.cs b/HDL_ON/DAL/DriverLayer/Control.cs index 106ed8e..f66b0e0 100644 --- a/HDL_ON/DAL/DriverLayer/Control.cs +++ b/HDL_ON/DAL/DriverLayer/Control.cs @@ -50,15 +50,15 @@ return _msg_id++; } } - /// <summary> - /// 鑾峰彇13浣嶆椂闂存埑 - /// </summary> - /// <returns></returns> - public string Get_TimeStamp() - { - long t = DateTime.Now.Ticks / 10000; - return t.ToString(); - } + ///// <summary> + ///// 鑾峰彇13浣嶆椂闂存埑 + ///// </summary> + ///// <returns></returns> + //public string Get_TimeStamp() + //{ + // long t = DateTime.Now.Ticks / 10000; + // return t.ToString(); + //} /// <summary> /// 鏄惁鎼滅储鏈湴缃戝叧鎴愬姛 @@ -229,7 +229,7 @@ public void SearchLoaclGateway() { //2021-01-15 : 浣忓畢娌℃湁缁戝畾缃戝叧鐨勬椂鍊欎笉鐢ㄦ悳绱紝骞朵笖涓嶈兘閾炬帴mqtt - if(DB_ResidenceData.Instance.HomeGateway == null) + if(DB_ResidenceData.Instance.HomeGateway == null || string.IsNullOrEmpty(DB_ResidenceData.Instance.HomeGateway.gatewayId)) { return; } @@ -336,7 +336,7 @@ } } - MainPage.Log($"鍙戦�佹暟鎹�:{Newtonsoft.Json.JsonConvert.SerializeObject(commandDictionary)}"); + //MainPage.Log($"鍙戦�佹暟鎹�:{Newtonsoft.Json.JsonConvert.SerializeObject(commandDictionary)}"); ///绗笁鏂规秱楦﹁澶囩粺涓�浣跨敤杩滅▼鎺у埗 switch(function.spk) @@ -561,7 +561,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; } @@ -602,7 +602,7 @@ } } - MainPage.Log($"灞�鍩熺綉淇℃伅: {receiveObj.Topic}"); + MainPage.Log($"灞�鍩熺綉淇℃伅: {receiveObj.Topic} : 鍐呭: {res[1]}"); //楠岃瘉鏈夋晥鏁版嵁闀垮害 @@ -613,15 +613,16 @@ //} receiveObj.BodyDataString = res[1]; - var bodyJObj = Newtonsoft.Json.JsonConvert.DeserializeObject<ResponsePack>(res[1]); - if (bodyJObj == null) - { - return receiveObj; - } if (receiveObj.Topic == CommunicationTopic.SearchLoaclGatewayReply) { + var bodyJObj = Newtonsoft.Json.JsonConvert.DeserializeObject<ResponsePack>(res[1]); + if (bodyJObj == null) + { + return receiveObj; + } + var device = Newtonsoft.Json.JsonConvert.DeserializeObject<DeviceModule>(bodyJObj.objects.ToString()); - if (device.device_mac == DB_ResidenceData.Instance.residenceGatewayMAC) + if (device.device_mac.ToUpper() == DB_ResidenceData.Instance.HomeGateway.mac.ToUpper()) { MainPage.Log("鏈湴鎼滅储缃戝叧鎴愬姛"); Ins.IsSearchLocalGatewaySuccessful = true; @@ -634,7 +635,7 @@ { Ins.GatewayId = device.device_mac; } - reportIp = "239.0.168.188";// device.ip_address; + reportIp = "239.0.168.188";// device.ip_address;//涓绘挱鍦板潃涔熻兘鎺у埗璁惧 } } else if (receiveObj.Topic == CommunicationTopic.ct.ReadStatus + "_reply" || @@ -643,6 +644,11 @@ { //TODO 鏆傛椂涓嶄紶姝g‘鐨勬暟鎹笂鍘伙紝濡傛灉鍚庨潰瑕佷紭鍖栧墠闈㈣繖浜涗唬鐮� UpdataFunctionStatus(receiveObj.BodyDataString, null); + } + else + { + //涓�浜涚壒娈婄殑涓婚澶勭悊(涓轰簡鎵ц閫熷害,灏藉彲鑳界殑鍒姞鑰楁椂鐨勬搷浣�) + Stan.HdlCloudReceiveLogic.Current.CloudOverallMsgReceiveEx(receiveObj.Topic, receiveObj.BodyDataString); } } return receiveObj; @@ -689,6 +695,7 @@ MainPage.Log($"A鍗忚鏇存柊鐘舵��:{revString}"); foreach (var attr in updateTemp.status) { + localFunction.time_stamp = temp.time_stamp; localFunction.SetAttrState(attr.key, attr.value); } @@ -696,6 +703,9 @@ Function localObj = null; switch (localFunction.spk) { + case SPK.ElectricEnergy: + EnergyMainPage.UpdataStatus(localFunction); + break; case SPK.LightSwitch: RelayPage.UpdataState(localFunction); break; @@ -802,36 +812,18 @@ case SPK.SensorTVOC: case SPK.SensorTemperature: case SPK.SensorHumidity: - var sensor = FunctionList.List.GetEnvirSensorsList().Find((obj) => obj.sid == updateTemp.sid); - if (sensor != null) + if(localFunction.spk == SPK.SensorTemperature) { - localObj = sensor; - foreach (var attr in updateTemp.status) - { - var localAttr = sensor.attributes.Find((obj) => obj.key == attr.key); - if (localAttr != null) - { - localAttr.curValue = attr.value; - } - } - EnvironmentalSciencePage.LoadEvent_UpdataStatus(sensor); + HomePage.LoadEvent_RefreshEnvirIndoorTemp(); } + else if (localFunction.spk == SPK.SensorHumidity) + { + HomePage.LoadEvent_RefreshEnvirIndoorHumi(); + } + EnvironmentalPage.LoadEvent_UpdataStatus(localFunction); break; case SPK.ElectricSocket: - var es = FunctionList.List.GetElectricSocketList().Find((obj) => obj.sid == updateTemp.sid); - if (es != null) - { - localObj = es; - foreach (var attr in updateTemp.status) - { - var localAttr = es.attributes.Find((obj) => obj.key == attr.key); - if (localAttr != null) - { - localAttr.curValue = attr.value; - } - } - SocketPage.UpdataState(es); - } + SocketPage.UpdataState(localFunction); break; case SPK.ElectricTV: break; -- Gitblit v1.8.0