From 014abc547ffd1a9f23c58fd7a471dffc5933fdd3 Mon Sep 17 00:00:00 2001
From: wxr <464027401@qq.com>
Date: 星期四, 17 十二月 2020 14:27:56 +0800
Subject: [PATCH] Merge branch 'master' into NewFilePath
---
HDL_ON/DAL/DriverLayer/Control.cs | 62 +++++++++++++++----------------
1 files changed, 30 insertions(+), 32 deletions(-)
diff --git a/HDL_ON/DAL/DriverLayer/Control.cs b/HDL_ON/DAL/DriverLayer/Control.cs
index 33a81c0..dcd5410 100644
--- a/HDL_ON/DAL/DriverLayer/Control.cs
+++ b/HDL_ON/DAL/DriverLayer/Control.cs
@@ -77,7 +77,12 @@
if (value)
{
MainPage.Log($"缃戝叧鍦ㄧ嚎锛屽埛鏂拌澶囩姸鎬�");
- FunctionList.List.ReadAllFunctionStatus();
+ new System.Threading.Thread(() =>
+ {
+ System.Threading.Thread.Sleep(1000);
+ FunctionList.List.ReadAllFunctionStatus();
+ })
+ { IsBackground = true, Priority = System.Threading.ThreadPriority.AboveNormal }.Start();
}
}
}
@@ -118,7 +123,7 @@
/// <summary>
/// 鏈湴udp
/// </summary>
- public Control_Udp myUdp = null;
+ public Control_Udp myUdp1 = null;
/// <summary>
/// 閫氳鏂瑰紡
@@ -139,11 +144,6 @@
/// </summary>
public void OpenUdp(int port)
{
- if (myUdp == null)
- {
- myUdp = new Control_Udp();
- }
-
UdpSocket._BusSocket.Start(port);
}
/// <summary>
@@ -151,10 +151,6 @@
/// </summary>
public void CloseUdp()
{
- if (myUdp != null)
- {
- myUdp = null;
- }
UdpSocket._BusSocket.Stop();
}
@@ -192,11 +188,11 @@
break;
if (DB_ResidenceData.Instance.GatewayType == 0)
{
- myUdp.ControlBytesSend(Command.ReadGateway, 255, 255, new byte[] { (byte)new Random().Next(255), (byte)new Random().Next(255) });
+ new Control_Udp().ControlBytesSend(Command.ReadGateway, 255, 255, new byte[] { (byte)new Random().Next(255), (byte)new Random().Next(255) });
}
else if (DB_ResidenceData.Instance.GatewayType == 1)
{
- myUdp.SearchLocalGateway();
+ new Control_Udp().SearchLocalGateway();
}
System.Threading.Thread.Sleep(500);
}
@@ -222,7 +218,7 @@
{
if (DB_ResidenceData.Instance.GatewayType == 0)
{
- myUdp.ControlBusScenes(scene);
+ new Control_Udp().ControlBusScenes(scene);
}
}
}
@@ -239,10 +235,11 @@
{
function.usageCount++;
function.refreshTime = DateTime.Now;
- DAL.Server.HttpServerRequest httpServer = new DAL.Server.HttpServerRequest();
+
//杩滅▼閫氳
if (Ins.IsRemote)
{
+ DAL.Server.HttpServerRequest httpServer = new DAL.Server.HttpServerRequest();
//ALink鎺у埗銆丅us鎺у埗浣跨敤鍚屼竴涓帴鍙f帶鍒讹紝鐢变簯绔礋璐hВ鏋�
var apiControlData = function.GetApiControlData(commandDictionary);
var actionObjs = new List<ApiAlinkControlActionObj>();
@@ -258,10 +255,7 @@
{
try
{
- if (myUdp != null)
- {
- myUdp.WriteBusData(function, commandDictionary);
- }
+ new Control_Udp().WriteBusData(function, commandDictionary);
}
catch (Exception ex)
{
@@ -271,13 +265,10 @@
//ALink鎺у埗
else
{
- if (myUdp != null)
- {
- var functionControlDataObj = function.GetGatewayAlinkControlData(commandDictionary);
- var functionControlDataJson = Newtonsoft.Json.JsonConvert.SerializeObject(functionControlDataObj);
- var sendBytes = Ins.ConvertSendBodyData(CommunicationTopic.ct.ControlFunctionTopic, functionControlDataJson);
- Ins.myUdp.SendLocalHdlLinkData(sendBytes);
- }
+ 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);
}
}
}
@@ -306,7 +297,7 @@
{
try
{
- Ins.myUdp.ReadBusData(function);
+ new Control_Udp().ReadBusData(function);
}
catch (Exception ex)
{
@@ -329,7 +320,7 @@
};
var functionControlDataJson = Newtonsoft.Json.JsonConvert.SerializeObject(readDataObj);
var sendBytes = Ins.ConvertSendBodyData(CommunicationTopic.ct.ReadStatus, functionControlDataJson);
- Ins.myUdp.SendLocalHdlLinkData(sendBytes);
+ new Control_Udp().SendLocalHdlLinkData(sendBytes,readDataObj.id);
}
}
}
@@ -363,7 +354,7 @@
else
{
Dictionary<string, string> keys = new Dictionary<string, string>();
- keys.Add("sid", scene.userSceneId);
+ keys.Add("sid", scene.sid);
var aLinkData = new AlinkReadFunctionStatusObj()
{
id = Ins.msg_id.ToString(),
@@ -375,7 +366,7 @@
};
var aLinkJson = Newtonsoft.Json.JsonConvert.SerializeObject(aLinkData);
var sendBytes = Ins.ConvertSendBodyData(CommunicationTopic.ct.ControlScene, aLinkJson);
- Ins.myUdp.SendLocalHdlLinkData(sendBytes);
+ new Control_Udp().SendLocalHdlLinkData(sendBytes,aLinkData.id);
}
}
/// <summary>
@@ -463,7 +454,8 @@
else if(receiveObj.Topic == CommunicationTopic.ct.ReadStatus+"_reply" ||
receiveObj.Topic == CommunicationTopic.ct.GatewayUpStatus)
{
- UpdataFunctionStatus(receiveObj.BodyDataString);
+ //TODO 鏆傛椂涓嶄紶姝g‘鐨勬暟鎹笂鍘伙紝濡傛灉鍚庨潰瑕佷紭鍖栧墠闈㈣繖浜涗唬鐮�
+ UpdataFunctionStatus(receiveObj.BodyDataString,null);
}
}
return receiveObj;
@@ -474,12 +466,18 @@
/// A鍗忚鏁版嵁
/// </summary>
/// <param name="updateBytes"></param>
- public void UpdataFunctionStatus(string revString)
+ public void UpdataFunctionStatus(string revString,byte []usefulBytes)
{
MainPage.Log($"A鍗忚鏇存柊鐘舵��:{revString}");
+ if(Control.Ins.myUdp!= null)
+ {
+ //閲嶇疆閲嶅惎udp鍒ゆ柇璋冩暣
+ Ins.myUdp.controlLostCount = 0;
+ }
var temp = Newtonsoft.Json.JsonConvert.DeserializeObject<AlinkFunctionStatusObj>(revString);
if (temp != null)
{
+ Control_Udp.ReceiveRepeatManager(temp.id,usefulBytes);
var allLocalFuntion = FunctionList.List.GetDeviceFunctionList();
foreach (var updateTemp in temp.objects)
{
--
Gitblit v1.8.0