雷达加判断

master
zby 3 months ago
parent d734e7868c
commit bd385059ec

@ -14,7 +14,7 @@ public class PadarClient : TcpClient<IBaseHandler, Decoder, Encoder>
/// <summary>
/// 0-雷达不工作1-无车2-无电池3-角度偏移过大4-车辆靠后5-车辆靠前6-车辆到位
/// </summary>
public byte CarState { get; set; }
public byte CarState =new byte();
public static readonly byte[] StartChar = { 0xFE, 0x68 };

@ -16,7 +16,7 @@ public class Decoder : ByteToMessageDecoder
protected override void Decode(IChannelHandlerContext context, IByteBuffer buffer, List<object> 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}");
}
catch (Exception e) { }
}
catch (Exception e)
{
}
}
}

@ -180,6 +180,9 @@ AppInfo.Container = app.Services.GetAutofacRoot();
// PlcMgr.Init();
//}
//雷达
PadarMgr.InitClient();
////启动换电流程
if (AppSettingsHelper.GetBool("swap", "enable"))
{

Loading…
Cancel
Save