From 33470790ac0069c7734fb1a5b8b07350950c6dfe Mon Sep 17 00:00:00 2001
From: wxr <464027401@qq.com>
Date: 星期二, 24 十一月 2020 15:51:31 +0800
Subject: [PATCH] 20201124,整理mqtt订阅

---
 HDL_ON/DAL/DriverLayer/Control.cs |   86 +++++++++++++++++++++---------------------
 1 files changed, 43 insertions(+), 43 deletions(-)

diff --git a/HDL_ON/DAL/DriverLayer/Control.cs b/HDL_ON/DAL/DriverLayer/Control.cs
index 743e402..ed155f1 100644
--- a/HDL_ON/DAL/DriverLayer/Control.cs
+++ b/HDL_ON/DAL/DriverLayer/Control.cs
@@ -4,12 +4,12 @@
 
 namespace HDL_ON.DriverLayer
 {
-
     /// <summary>
     /// 閫氳鏂瑰紡
     /// </summary>
     public enum CommunicationMode
     {
+        none,
         /// <summary>
         /// 鏈湴udp
         /// </summary>
@@ -20,12 +20,10 @@
         tcp_local_client,
     }
 
-
-
     public class Control
     {
         static Control _control;
-        public static Control ins
+        public static Control Ins
         {
             get
             {
@@ -36,10 +34,26 @@
                 return _control;
             }
         }
+        bool _gatewayOnline = false;
         /// <summary>
         /// 缃戝叧鏄惁鍦ㄧ嚎
         /// </summary>
-        public bool gatewayOnline = false;
+        public bool GatewayOnline {
+            get
+            {
+                return _gatewayOnline;
+            }
+            set
+            {
+                _gatewayOnline = value;
+                //淇敼涓婚〉杩炴帴鐘舵��
+                UI.HomePage.LoadEvent_CheckLinkStatus();
+            }
+        }
+        /// <summary>
+        /// 鏄惁涓鸿繙绋嬭繛鎺�
+        /// </summary>
+        public bool IsRemote = false;
         /// <summary>
         /// 閫氳鍦板潃IP
         /// </summary>
@@ -55,7 +69,7 @@
         /// <summary>
         /// 鏈湴udp
         /// </summary>
-        public Control_Udp_Bus myUdp = null;
+        public Control_Udp myUdp = null;
 
         /// <summary>
         /// 閫氳鏂瑰紡
@@ -72,63 +86,49 @@
         }
 
         /// <summary>
-        /// 鏀瑰彉閫氳鏂瑰紡
+        /// 鎵撳紑Udp
         /// </summary>
-        public void ChangeCommunicationMode(CommunicationMode communicationMode)
+        public void OpenUdp()
         {
-            if (this.communicationMode == communicationMode)
+            if (myUdp == null)
             {
-                return;
+                myUdp = new Control_Udp();
             }
 
-            this.communicationMode = communicationMode;
-
-
-            switch (this.communicationMode)
+            UdpSocket._BusSocket.Start();
+        }
+        /// <summary>
+        /// 鎵撳紑tcp瀹㈡湇绔�
+        /// </summary>
+        public void OpenTcpClent()
+        {
+            if (myTcpClient == null)
             {
-                case CommunicationMode.local_BusUdp:
-                    if (myUdp == null)
-                    {
-                        myUdp = new Control_Udp_Bus();
-                    }
-                    UdpSocket._BusSocket.Start();
-                    if (myTcpClient != null)
-                    {
-                        myTcpClient.Close();
-                        myTcpClient = null;
-                    }
-                    break;
-                case CommunicationMode.tcp_local_client:
-                    if (myTcpClient == null)
-                    {
-                        myTcpClient = new Control_TcpClient(reportIp);
-                        myTcpClient.Connect();
-                    }
-                    if (myUdp != null)
-                    {
-                        UdpSocket._BusSocket.Stop();
-                        myUdp = null;
-                    }
-                    break;
+                myTcpClient = new Control_TcpClient(reportIp);
+                myTcpClient.Connect();
             }
         }
+
+        ///// <summary>
+        ///// 鏀瑰彉閫氳鏂瑰紡
+        ///// </summary>
+        //public void ChangeCommunicationMode(CommunicationMode communicationMode)
+        //{
+        //    this.communicationMode = communicationMode;
+        //}
 
         /// <summary>
         /// 鎼滅储鏈湴缃戝叧鍒楄〃
         /// </summary>
         public void SearchLoaclGateway()
         {
-            ChangeCommunicationMode(CommunicationMode.local_BusUdp);
+            OpenUdp();
             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)
             {
-                UdpSocket._BusSocket.SearchNetDeviceAction = (revIp) =>
-                {
-                    MainPage.Log($"鎼滅储鍒扮綉缁滆澶囷細{revIp}");
-                };
                 myUdp.SearchLocalGateway();
             }
         }

--
Gitblit v1.8.0