From 611786df5108dca0bdcff03834cc285cba4b8e61 Mon Sep 17 00:00:00 2001
From: 陈嘉乐 <cjl@hdlchina.com.cn>
Date: 星期二, 13 十月 2020 16:48:43 +0800
Subject: [PATCH] 2020-10-13-1

---
 HDL_ON/DriverLayer/Control_Bus.cs |   48 +++++++++++++++++++++++++++++++++---------------
 1 files changed, 33 insertions(+), 15 deletions(-)

diff --git a/HDL_ON/DriverLayer/Control_Bus.cs b/HDL_ON/DriverLayer/Control_Bus.cs
index dd8490b..0579d89 100644
--- a/HDL_ON/DriverLayer/Control_Bus.cs
+++ b/HDL_ON/DriverLayer/Control_Bus.cs
@@ -15,6 +15,10 @@
     public partial class Control
     {
         public DateTime LatestDateTime = DateTime.Now;
+        /// <summary>
+        /// 鎺у埗澶辫触娆℃暟
+        /// </summary>
+        public static int controlLostCount = 0;
 
         /// <summary>
         /// 鎵�鏈夊井淇″涓�绔彛鐨勬帶鍒堕兘浼氭斁鍒拌繖涓泦鍚堥噷
@@ -319,14 +323,14 @@
                     //case Command.Remote3thACK:
                     //    receiveFlag = string.Format("{0},", (int)command);
                     //    break;
-                    //case Command.ReadDeviceLoopInfoACK:
-                    //    if (usefulBytes[0] == 1)
-                    //    {
-                    //        receiveFlag += string.Format("{0},{1}", usefulBytes[0], usefulBytes[2]); ;
-                    //    }
-                    //    else
-                    //        receiveFlag += string.Format("{0},{1},{2}", usefulBytes[0], usefulBytes[1], usefulBytes[2]);
-                    //    break;
+                    case Command.ReadDeviceLoopInfoACK:
+                        if (usefulBytes[0] == 1)
+                        {
+                            receiveFlag += string.Format("{0},{1}", usefulBytes[0], usefulBytes[2]); ;
+                        }
+                        else
+                            receiveFlag += string.Format("{0},{1},{2}", usefulBytes[0], usefulBytes[1], usefulBytes[2]);
+                        break;
                     //case Command.SetDeviceLoopInfoACK:
                     //case Command.InfraredControlACK:
                     //case Command.SetSecurityByPassACK:
@@ -502,16 +506,30 @@
              鈥�            }
             else
             {
+                //Bus socket鏃犳硶鎺у埗锛岄噸鍚満鍒�
+                if (controlLostCount > 10)
+                {
+                    BusSocket.Stop();
+                    new System.Threading.Thread(() =>
+                    {
+                        System.Threading.Thread.Sleep(1000);
+                        BusSocket.Start(6000);
+                        controlLostCount = 0;
+                    })
+                    { IsBackground = true }.Start();
+                }
+
                 try
                 {
                     MainPage.Log("鍙戦�佹暟鎹�:" + SendFlag);
                     BusSocket.AsyncBeginSend(Packet);
                     Packet.HaveSendCount--;
+                    controlLostCount++;
 
                     //杩欓噷鏄噸鍙戜袱娆�
                     while (Packet.HaveSendCount < 3)
                     {
-                        if (Packet.FlagDateTime.AddMilliseconds(1000).Ticks <= System.DateTime.Now.Ticks)
+                        if (Packet.FlagDateTime.AddMilliseconds(1000).Ticks <= DateTime.Now.Ticks)
                         {
                             MainPage.Log("閲嶅彂鏁版嵁:" + SendFlag);
                             BusSocket.AsyncBeginSend(Packet);
@@ -677,12 +695,12 @@
                 //case Command.Remote3th:
                 //    this.SendFlag = string.Format("{0},", (int)target.Command + 1);
                 //    break;
-                //case Command.ReadDeviceLoopInfo:
-                //    if (target.AddData[0] == 1)//鐗规畩澶勭悊鐏厜绫伙紝DMX妯″潡姣忎竴涓洖璺笉鍥哄畾灏忕被锛屾牴鎹叿浣撹缃潵鍥炲
-                //        this.sendFlag += string.Format("{0},{1}", target.AddData[0], target.AddData[2]);
-                //    else
-                //        this.sendFlag += string.Format("{0},{1},{2}", target.AddData[0], target.AddData[1], target.AddData[2]);
-                //    break;
+                case Command.ReadDeviceLoopInfo:
+                    if (target.AddData[0] == 1)//鐗规畩澶勭悊鐏厜绫伙紝DMX妯″潡姣忎竴涓洖璺笉鍥哄畾灏忕被锛屾牴鎹叿浣撹缃潵鍥炲
+                        this.sendFlag += string.Format("{0},{1}", target.AddData[0], target.AddData[2]);
+                    else
+                        this.sendFlag += string.Format("{0},{1},{2}", target.AddData[0], target.AddData[1], target.AddData[2]);
+                    break;
                 //case Command.SetDeviceLoopInfo:
                 //case Command.InfraredControl:
                 //case Command.SetSecurityByPass:

--
Gitblit v1.8.0