diff --git a/Service/Padar/Client/PadarClient.cs b/Service/Padar/Client/PadarClient.cs index d0933a4..1ed3f16 100644 --- a/Service/Padar/Client/PadarClient.cs +++ b/Service/Padar/Client/PadarClient.cs @@ -14,7 +14,7 @@ public class PadarClient : TcpClient /// /// 0-雷达不工作;1-无车;2-无电池,3-角度偏移过大;4-车辆靠后;5-车辆靠前;6-车辆到位 /// - public byte CarState { get; set; } + public byte CarState =new byte(); public static readonly byte[] StartChar = { 0xFE, 0x68 }; diff --git a/Service/Padar/Codec/Decoder.cs b/Service/Padar/Codec/Decoder.cs index 0cb3742..2783097 100644 --- a/Service/Padar/Codec/Decoder.cs +++ b/Service/Padar/Codec/Decoder.cs @@ -16,7 +16,7 @@ public class Decoder : ByteToMessageDecoder protected override void Decode(IChannelHandlerContext context, IByteBuffer buffer, List output) { - IByteBuffer? delimiter = FindDelimiter(buffer); + IByteBuffer delimiter = FindDelimiter(buffer); if (delimiter != null) { //分隔符索引 @@ -53,12 +53,18 @@ public class Decoder : ByteToMessageDecoder try { buffer.ReadBytes(data); + if (PadarMgr._PadarClient!=null) + { + PadarMgr._PadarClient.CarState = data[3]; + Log.Info($"receive {BitUtls.BytesToHexStr(data)}:{PadarMgr._PadarClient.CarState}"); + } + - PadarMgr._PadarClient.CarState = data[3]; - - Log.Info($"receive {BitUtls.BytesToHexStr(data)}:{PadarMgr._PadarClient.CarState}"); } - catch (Exception e) { } + catch (Exception e) + { + + } } } diff --git a/WebStarter/Program.cs b/WebStarter/Program.cs index f56d1ed..9de2ee1 100644 --- a/WebStarter/Program.cs +++ b/WebStarter/Program.cs @@ -180,6 +180,9 @@ AppInfo.Container = app.Services.GetAutofacRoot(); // PlcMgr.Init(); //} + +//雷达 +PadarMgr.InitClient(); ////启动换电流程 if (AppSettingsHelper.GetBool("swap", "enable")) {