From 6ba43603ccd8868a4ee73e9b978b7cb20a5b2c52 Mon Sep 17 00:00:00 2001
From: wei <kaede@kaededeMacBook-Air.local>
Date: 星期五, 04 十二月 2020 14:24:53 +0800
Subject: [PATCH] Merge remote-tracking branch 'origin/WJC'
---
HDL_ON/DAL/DriverLayer/Control.cs | 50 +++++++++++++++++++++++++++++++++++++++-----------
1 files changed, 39 insertions(+), 11 deletions(-)
diff --git a/HDL_ON/DAL/DriverLayer/Control.cs b/HDL_ON/DAL/DriverLayer/Control.cs
index bdf87b9..22e42b4 100644
--- a/HDL_ON/DAL/DriverLayer/Control.cs
+++ b/HDL_ON/DAL/DriverLayer/Control.cs
@@ -53,7 +53,7 @@
public string Get_TimeStamp()
{
long t = DateTime.Now.Ticks / 10000;
- return t.ToString();
+ return t.ToString();
}
bool _gatewayOnline = false;
@@ -76,10 +76,28 @@
/// 缃戝叧閫氳ID
/// </summary>
public string GatewayId;
+
+ bool _isRemote = false;
/// <summary>
/// 鏄惁涓鸿繙绋嬭繛鎺�
/// </summary>
- public bool IsRemote = false;
+ public bool IsRemote {
+ get
+ {
+ return _isRemote;
+ }
+ set
+ {
+ _isRemote = value;
+ if(value)
+ {
+ DAL.Mqtt.MqttClient.InitState();
+ }else
+ {
+ DAL.Mqtt.MqttClient.DisConnectRemote();
+ }
+ }
+ }
/// <summary>
/// 閫氳鍦板潃IP
/// </summary>
@@ -128,7 +146,7 @@
/// </summary>
public void CloseUdp()
{
- if(myUdp!= null)
+ if (myUdp != null)
{
myUdp = null;
}
@@ -161,15 +179,24 @@
public void SearchLoaclGateway()
{
OpenUdp(DB_ResidenceData.residenceData.GatewayType == 0 ? 6000 : 8585);
-
- if (DB_ResidenceData.residenceData.GatewayType == 0)
+ new System.Threading.Thread(() =>
{
- myUdp.ControlBytesSend(Command.ReadGateway, 255, 255, new byte[] { (byte)new Random().Next(255), (byte)new Random().Next(255) });
- }
- else if (DB_ResidenceData.residenceData.GatewayType == 1)
- {
- myUdp.SearchLocalGateway();
- }
+ for (int i = 0; i < 5; i++)
+ {
+ if (GatewayOnline)
+ break;
+ if (DB_ResidenceData.residenceData.GatewayType == 0)
+ {
+ myUdp.ControlBytesSend(Command.ReadGateway, 255, 255, new byte[] { (byte)new Random().Next(255), (byte)new Random().Next(255) });
+ }
+ else if (DB_ResidenceData.residenceData.GatewayType == 1)
+ {
+ myUdp.SearchLocalGateway();
+ }
+ System.Threading.Thread.Sleep(500);
+ }
+ })
+ { IsBackground = true }.Start();
}
/// <summary>
@@ -353,6 +380,7 @@
Ins.GatewayOnline = true;
Ins.GatewayId = device.gatewayId;
reportIp = "239.0.168.188";// device.ip_address;
+ Ins.IsRemote = false;
}
break;
}
--
Gitblit v1.8.0