From 00aa52cdf20fc56d527823bac22166ea96780780 Mon Sep 17 00:00:00 2001 From: wenjy Date: Sun, 18 Feb 2024 14:30:50 +0800 Subject: [PATCH] =?UTF-8?q?change=20-=20=E6=A0=A1=E6=97=B6=E6=8C=87?= =?UTF-8?q?=E4=BB=A4=E6=97=B6=E9=97=B4=E6=A0=BC=E5=BC=8F=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Ems.CollectService.Analysis/BufferAnalysis.cs | 26 ++++++++++++++----- 1 file changed, 20 insertions(+), 6 deletions(-) diff --git a/Ems.CollectService.Analysis/BufferAnalysis.cs b/Ems.CollectService.Analysis/BufferAnalysis.cs index 7c679db..8bbe996 100644 --- a/Ems.CollectService.Analysis/BufferAnalysis.cs +++ b/Ems.CollectService.Analysis/BufferAnalysis.cs @@ -157,6 +157,8 @@ namespace Ems.CollectService.Analysis if (client.ID.Contains("450063")) { Thread.Sleep(500); + SendMessagePackInfo.m_MessageType = (byte)CallbackSendData._SetTime; + SendMessagePackInfo.m_PackLen = new byte[] {0x00, 0x0D}; bool isRes = SendTimeSyncToClient(client, SendMessagePackInfo); logger.Info($"向客户端:{client.ID};地址:{client.GetIPPort()};发送校时指令{(isRes ? "成功":"失败")}"); } @@ -943,13 +945,14 @@ namespace Ems.CollectService.Analysis 0x00, 0x00, 0x00, - (byte)currentTime.Second, - (byte)currentTime.Minute, - (byte)currentTime.Hour, - (byte)(currentTime.Year%100), - (byte)currentTime.Month, - (byte)currentTime.Day, + HexStrTorbytes(currentTime.ToString("ss"))[0], + HexStrTorbytes(currentTime.ToString("mm"))[0], + HexStrTorbytes(currentTime.ToString("HH"))[0], + HexStrTorbytes(currentTime.ToString("dd"))[0], + HexStrTorbytes(currentTime.ToString("MM"))[0], + HexStrTorbytes(currentTime.ToString("yy"))[0], }; + Array.Copy(timeBuffer, 0, SendBuffer, num, timeBuffer.Length); num = (ushort)(num + 12); @@ -968,5 +971,16 @@ namespace Ems.CollectService.Analysis return false; } } + + public static byte[] HexStrTorbytes(string strHex)//e.g. " 01 01" ---> { 0x01, 0x01} + { + strHex = strHex.Replace(" ", ""); + if ((strHex.Length % 2) != 0) + strHex += " "; + byte[] returnBytes = new byte[strHex.Length / 2]; + for (int i = 0; i < returnBytes.Length; i++) + returnBytes[i] = Convert.ToByte(strHex.Substring(i * 2, 2), 16); + return returnBytes; + } } }