From 2f30d9dfe474db862e1b409065a7ba5280bed92b Mon Sep 17 00:00:00 2001 From: tangxu <76880903@qq.com> Date: 星期一, 31 十月 2022 14:18:44 +0800 Subject: [PATCH] Merge branch 'master' of http://47.103.154.90:83/r/IStation/Service.V4.1 --- Socket/IStation.DataDockingSocket4NT/MsgHandle/StartUpMsgHelper.cs | 53 ++++++++++++++++++++++++++++++++++++++--------------- 1 files changed, 38 insertions(+), 15 deletions(-) diff --git a/Socket/IStation.DataDockingSocket4NT/MsgHandle/StartUpMsgHelper.cs b/Socket/IStation.DataDockingSocket4NT/MsgHandle/StartUpMsgHelper.cs index fd927e0..d20494b 100644 --- a/Socket/IStation.DataDockingSocket4NT/MsgHandle/StartUpMsgHelper.cs +++ b/Socket/IStation.DataDockingSocket4NT/MsgHandle/StartUpMsgHelper.cs @@ -1,5 +1,4 @@ -锘縰sing IStation.DataDockingSocket.MsgHandle; -using IStation.Model; +锘縰sing IStation.Model; using IStation.Untity; using System; using System.Collections.Generic; @@ -24,7 +23,7 @@ /// <returns></returns> public static bool StartJob(Model.IMonitorDataDockingSession session, MonitorTestControlParas.StartContext paras) { - if (session != null) + if (session == null) { NtLogHelper.Error($"寮�鏈� session:Close"); return false; @@ -82,7 +81,7 @@ return false; } /// <summary> - /// 鍏虫満鎸囦护 + /// 寮�鏈烘寚浠� /// </summary> static string ControlMsgOpen = "01-06-00-0F-00-01-78-09"; /// <summary> @@ -92,30 +91,56 @@ public static bool HandleReceive(Model.IMonitorDataDockingSession session, byte[] byteMessage) { if (InstructionStatus == eStartUpInstructionStatus.鏈彂閫�) + { + NtLogHelper.Info("InstructionStatus==eStartUpInstructionStatus.鏈彂閫�"); return false; + } if (InstructionStatus == eStartUpInstructionStatus.寮�鏈烘寚浠ゅ彂閫�) { - if (byteMessage.Length >= ControlMsgOpen.Length) + NtLogHelper.Info("InstructionStatus==eStartUpInstructionStatus.寮�鏈烘寚浠ゅ彂閫�"); + var byteMsgOpen = Encoding.Unicode.GetBytes(ControlMsgOpen); + //if (byteMessage.Length >= byteMsgOpen.Length) + //{ + string strMessage = BitConverter.ToString(byteMessage, 0, byteMessage.Length); + if (strMessage == ControlMsgOpen) { - string strMessage = BitConverter.ToString(byteMessage, 0, byteMessage.Length); - if (strMessage == ControlMsgOpen) - {//01-06-00-0F-00-01-78-09 - InstructionStatus = eStartUpInstructionStatus.鏈彂閫�; + NtLogHelper.Info($"strMessage ({strMessage})== ControlMsgOpen ({ControlMsgOpen})"); + //01-06-00-0F-00-01-78-09 + InstructionStatus = eStartUpInstructionStatus.鏈彂閫�; - NtLogHelper.Debug("寮�鏈烘寚浠よ繑鍥�:" + BitTransfer.ToString(byteMessage)); + NtLogHelper.Info("寮�鏈烘寚浠よ繑鍥�:" + BitTransfer.ToString(byteMessage)); + if (_lastParas.OperatingValue > 0) + { //寮�鍚嚜鍔ㄥ叧闂� ShutDownMsgHelper.StartAutoClose(_lastParas.OperatingValue); - return true; } + else + { + NtLogHelper.Info("鏃堕棿灏忎簬绛変簬0,涓嶅紑鍚嚜鍔ㄥ叧闂�"); + } + return true; } + else + { + NtLogHelper.Info($"strMessage ({strMessage})!= ControlMsgOpen ({ControlMsgOpen})"); + } + //} + //else + //{ + // NtLogHelper.Info($"byteMessage.Length ({byteMessage.Length}) <= ControlMsgOpen.Length ({ControlMsgOpen.Length})"); + //} + //杩斿洖澶辫触, 鍐嶅彂閫佷竴娆″啀纭涓�涓� if ((DateTime.Now - _lastOpenSendTime).TotalSeconds > 5) { + NtLogHelper.Info($"杩斿洖澶辫触, 鍐嶅彂閫佷竴娆″啀纭涓�涓�"); SendOpenMsg(session); } } + if (InstructionStatus == eStartUpInstructionStatus.璋冮鎸囦护鍙戦��) { + NtLogHelper.Info($"InstructionStatus == eStartUpInstructionStatus.璋冮鎸囦护鍙戦��"); //闇�瑕佸垽鏂槸鍚︽槸璋冮鎸囦护:浠ュ悗鍐嶈ˉ鍏� { SendOpenMsg(session); @@ -125,6 +150,7 @@ //杩斿洖澶辫触, 鍐嶅彂閫佷竴娆″啀纭涓�涓� if ((DateTime.Now - _lastHzSendTime).TotalSeconds > 5) { + NtLogHelper.Info($"杩斿洖澶辫触, 鍐嶅彂閫佷竴娆″啀纭涓�涓�"); StartJob(session, _lastParas); } } @@ -132,10 +158,9 @@ return false; } - private static void SendOpenMsg(Model.IMonitorDataDockingSession session) + private static void SendOpenMsg(Model.IMonitorDataDockingSession session) { byte[] bts = GetControlMsg寮�鏈�(); - session.Send(bts, 0, bts.Length); InstructionStatus = eStartUpInstructionStatus.寮�鏈烘寚浠ゅ彂閫�; @@ -166,9 +191,7 @@ public static byte[] GetControlMsg璋冮(double frequece) { var iFrequece = (int)(frequece * 10); - byte[] commandSend = null; - ModBusRtuHelper.BuildSendMessage06(0x01, 20, 2, iFrequece, ref commandSend); -- Gitblit v1.9.3