change - 校时指令时间格式修改

master
wenjy 9 months ago
parent a890a98e7c
commit 00aa52cdf2

@ -157,6 +157,8 @@ namespace Ems.CollectService.Analysis
if (client.ID.Contains("450063")) if (client.ID.Contains("450063"))
{ {
Thread.Sleep(500); Thread.Sleep(500);
SendMessagePackInfo.m_MessageType = (byte)CallbackSendData._SetTime;
SendMessagePackInfo.m_PackLen = new byte[] {0x00, 0x0D};
bool isRes = SendTimeSyncToClient(client, SendMessagePackInfo); bool isRes = SendTimeSyncToClient(client, SendMessagePackInfo);
logger.Info($"向客户端:{client.ID};地址:{client.GetIPPort()};发送校时指令{(isRes ? "":"")}"); logger.Info($"向客户端:{client.ID};地址:{client.GetIPPort()};发送校时指令{(isRes ? "":"")}");
} }
@ -943,13 +945,14 @@ namespace Ems.CollectService.Analysis
0x00, 0x00,
0x00, 0x00,
0x00, 0x00,
(byte)currentTime.Second, HexStrTorbytes(currentTime.ToString("ss"))[0],
(byte)currentTime.Minute, HexStrTorbytes(currentTime.ToString("mm"))[0],
(byte)currentTime.Hour, HexStrTorbytes(currentTime.ToString("HH"))[0],
(byte)(currentTime.Year%100), HexStrTorbytes(currentTime.ToString("dd"))[0],
(byte)currentTime.Month, HexStrTorbytes(currentTime.ToString("MM"))[0],
(byte)currentTime.Day, HexStrTorbytes(currentTime.ToString("yy"))[0],
}; };
Array.Copy(timeBuffer, 0, SendBuffer, num, timeBuffer.Length); Array.Copy(timeBuffer, 0, SendBuffer, num, timeBuffer.Length);
num = (ushort)(num + 12); num = (ushort)(num + 12);
@ -968,5 +971,16 @@ namespace Ems.CollectService.Analysis
return false; 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;
}
} }
} }

Loading…
Cancel
Save