From 7d005a7618e3d7a80d8ede3baf6ecc4bf8019cd5 Mon Sep 17 00:00:00 2001
From: wxr <464027401@qq.com>
Date: 星期二, 01 九月 2020 15:22:09 +0800
Subject: [PATCH] 2020-09-01
---
HDL_ON/DriverLayer/Control_Bus.cs | 99 ++++++++++++++++++++++++++++++++-----------------
1 files changed, 64 insertions(+), 35 deletions(-)
diff --git a/HDL_ON/DriverLayer/Control_Bus.cs b/HDL_ON/DriverLayer/Control_Bus.cs
index dd8490b..8a81269 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>
/// 鎵�鏈夊井淇″涓�绔彛鐨勬帶鍒堕兘浼氭斁鍒拌繖涓泦鍚堥噷
@@ -45,6 +49,8 @@
return control.UsefulBytes;
}
+ static DAL.Net.TcpListener tcpListener;
+
/// <summary>
/// 000E 鎼滅储鍥炲
/// </summary>
@@ -59,12 +65,17 @@
return;
}
-
- if (!CommonPage.isHttpListenerStart)
+ if (tcpListener == null)
{
- //鏁版嵁鎺ユ敹绔彛娌℃墦寮�锛屼笉鍥炲
- CommonPage.InitHttpListener();
+ tcpListener = new DAL.Net.TcpListener();
+ tcpListener.OpenServer(8586);
}
+
+ //if (!CommonPage.isHttpListenerStart)
+ //{
+ // //鏁版嵁鎺ユ敹绔彛娌℃墦寮�锛屼笉鍥炲
+ // CommonPage.InitHttpListener();
+ //}
var sendStr = MainPage.LoginUser.accountString;
if (usefullBytes.Length == 0)
{
@@ -173,6 +184,9 @@
Console.WriteLine("buspro 璇诲娉ㄥ洖澶�");
ReceiveReadRemark(usefulBytes);
break;
+ case Command.ReadLightAllLoopBrightnessACK:
+ receiveFlag += "";
+ break;
//case Command.YIPanelDeviceInofACK:
// for (int i = 0; i < 4; i++)
// {
@@ -222,8 +236,6 @@
//case Command.SetSensorPushValuesACK:
//case Command.ReadSensorPushValuesACK:
// receiveFlag += string.Format("{0},{1}", usefulBytes[0], usefulBytes[1]);
- // break;
- //case Command.ReadLightEquipmentAllLoopBrightnessACK:
// break;
//case Command.UpLoadInfraredACK:
// receiveFlag += string.Format("{0},{1}", usefulBytes[0], usefulBytes[1]);
@@ -319,14 +331,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:
@@ -339,14 +351,14 @@
//case Command.ReadWirelessPanelButtonKeyACK:
//case Command.WriteWirelessPanelButtonKeyACK:
//case Command.ReadDryContactStatusACK:
- //case Command.InstructionPanelKeyACK:
- //case Command.ReadInstructionPanelKeyACK:
- //case Command.ReadAnalogValueACK:
- //case Command.ReadSensorTargetRemarkACK:
- //case Command.SetHornTargetStateACK:
- //case Command.ReadHornTargetStateACK:
- // receiveFlag += string.Format("{0},{1}", usefulBytes[0], usefulBytes[1]);
- // break;
+ case Command.InstructionPanelKeyACK:
+ case Command.ReadInstructionPanelKeyACK:
+ //case Command.ReadAnalogValueACK:
+ //case Command.ReadSensorTargetRemarkACK:
+ //case Command.SetHornTargetStateACK:
+ //case Command.ReadHornTargetStateACK:
+ receiveFlag += string.Format("{0},{1}", usefulBytes[0], usefulBytes[1]);
+ break;
//case Command.AssignedAddressACK:
//case Command.UpdataCurtainModelRunTimeACK:
//case Command.ReadCurtainStutasACK:
@@ -502,6 +514,19 @@
鈥� }
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);
@@ -511,10 +536,11 @@
//杩欓噷鏄噸鍙戜袱娆�
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);
+ controlLostCount++;
}
System.Threading.Thread.Sleep(100);
}
@@ -551,6 +577,9 @@
break;
case Command.SetLogicLoopColor:
this.sendFlag += string.Format("{0},{1},{2}", target.AddData[0], target.AddData[1], target.AddData[2]);
+ break;
+ case Command.ReadLightAllLoopBrightness:
+ this.SendFlag += "";
break;
//case Command.YIPanelDeviceInof:
// for (int i = 0; i < 4; i++)
@@ -677,12 +706,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:
@@ -696,12 +725,12 @@
//case Command.SetCurtainModelStutas:
//case Command.DownloadInfrared:
//case Command.UpLoadInfrared:
- //case Command.InstructionPanelKey:
- //case Command.ReadInstructionPanelKey:
- //case Command.ReadSensorTargetRemark:
- //case Command.SetHornTargetState:
- // this.sendFlag += string.Format("{0},{1}", target.AddData[0], target.AddData[1]);
- // break;
+ case Command.InstructionPanelKey:
+ case Command.ReadInstructionPanelKey:
+ //case Command.ReadSensorTargetRemark:
+ //case Command.SetHornTargetState:
+ this.sendFlag += string.Format("{0},{1}", target.AddData[0], target.AddData[1]);
+ break;
//case Command.AssignedAddress:
//case Command.UpdataCurtainModelRunTime:
//case Command.ReadCurtainStatus:
--
Gitblit v1.8.0