|
|
@ -3,6 +3,7 @@ using DotNetty.Codecs;
|
|
|
|
using DotNetty.Transport.Channels;
|
|
|
|
using DotNetty.Transport.Channels;
|
|
|
|
using HybirdFrameworkCore.Utils;
|
|
|
|
using HybirdFrameworkCore.Utils;
|
|
|
|
using log4net;
|
|
|
|
using log4net;
|
|
|
|
|
|
|
|
using Newtonsoft.Json;
|
|
|
|
using Service.TBox.Msg;
|
|
|
|
using Service.TBox.Msg;
|
|
|
|
using Service.TBox.Msg.TBox;
|
|
|
|
using Service.TBox.Msg.TBox;
|
|
|
|
|
|
|
|
|
|
|
@ -10,10 +11,6 @@ namespace Service.TBox.Codec;
|
|
|
|
|
|
|
|
|
|
|
|
public class Decoder : ByteToMessageDecoder
|
|
|
|
public class Decoder : ByteToMessageDecoder
|
|
|
|
{
|
|
|
|
{
|
|
|
|
//TODO 实际开发时去掉
|
|
|
|
|
|
|
|
public static Queue<BaseMsg> Msgs { get; set; } = new();
|
|
|
|
|
|
|
|
//TODO 实际开发时去掉
|
|
|
|
|
|
|
|
public static Queue<byte[]> BytesQueue { get; set; } = new();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private static readonly ILog Log = LogManager.GetLogger(typeof(Decoder));
|
|
|
|
private static readonly ILog Log = LogManager.GetLogger(typeof(Decoder));
|
|
|
|
|
|
|
|
|
|
|
@ -27,9 +24,6 @@ public class Decoder : ByteToMessageDecoder
|
|
|
|
input.SkipBytes(1);
|
|
|
|
input.SkipBytes(1);
|
|
|
|
input.ReadBytes(bytes);
|
|
|
|
input.ReadBytes(bytes);
|
|
|
|
|
|
|
|
|
|
|
|
//TODO 实际开发时去掉
|
|
|
|
|
|
|
|
BytesQueue.Enqueue(bytes);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Log.Info($"receive {BitUtls.BytesToHexStr(bytes)}");
|
|
|
|
Log.Info($"receive {BitUtls.BytesToHexStr(bytes)}");
|
|
|
|
|
|
|
|
|
|
|
|
int id = BitConverter.ToInt32(new byte[] { bytes[3], bytes[2], bytes[1], bytes[0] }, 0);
|
|
|
|
int id = BitConverter.ToInt32(new byte[] { bytes[3], bytes[2], bytes[1], bytes[0] }, 0);
|
|
|
@ -37,12 +31,12 @@ public class Decoder : ByteToMessageDecoder
|
|
|
|
{
|
|
|
|
{
|
|
|
|
0x1882D0F3 => ModelConvert.Decode<SocMsg>(bytes),
|
|
|
|
0x1882D0F3 => ModelConvert.Decode<SocMsg>(bytes),
|
|
|
|
0x18FF48A8 => ModelConvert.Decode<StatusMsg>(bytes),
|
|
|
|
0x18FF48A8 => ModelConvert.Decode<StatusMsg>(bytes),
|
|
|
|
|
|
|
|
|
|
|
|
0x18E1D0F3=> ModelConvert.Decode<BatteryOneSn>(bytes),
|
|
|
|
0x18E1D0F3=> ModelConvert.Decode<BatteryOneSn>(bytes),
|
|
|
|
0x18E2D0F3=> ModelConvert.Decode<BatteryTwoSn>(bytes),
|
|
|
|
0x18E2D0F3=> ModelConvert.Decode<BatteryTwoSn>(bytes),
|
|
|
|
0x18E3D0F3=> ModelConvert.Decode<BatteryThreeSn>(bytes),
|
|
|
|
0x18E3D0F3=> ModelConvert.Decode<BatteryThreeSn>(bytes),
|
|
|
|
0x18E4D0F3=> ModelConvert.Decode<BatteryFourSn>(bytes),
|
|
|
|
0x18E4D0F3=> ModelConvert.Decode<BatteryFourSn>(bytes),
|
|
|
|
|
|
|
|
|
|
|
|
0x18E1F3D0=> ModelConvert.Decode<VinMsg>(bytes),
|
|
|
|
0x18E1F3D0=> ModelConvert.Decode<VinMsg>(bytes),
|
|
|
|
0x1801D8A7=> ModelConvert.Decode<VersionMsg>(bytes),
|
|
|
|
0x1801D8A7=> ModelConvert.Decode<VersionMsg>(bytes),
|
|
|
|
//0x1880D0F3=> ModelConvert.Decode<StatusMsg>(bytes),
|
|
|
|
//0x1880D0F3=> ModelConvert.Decode<StatusMsg>(bytes),
|
|
|
@ -56,8 +50,7 @@ public class Decoder : ByteToMessageDecoder
|
|
|
|
_ => ModelConvert.Decode<OtherMsg>(bytes),
|
|
|
|
_ => ModelConvert.Decode<OtherMsg>(bytes),
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
//TODO 实际开发时去掉
|
|
|
|
Log.Info($"receive={BitUtls.BytesToHexStr(bytes)}, msg={JsonConvert.SerializeObject(baseMsg)}");
|
|
|
|
Msgs.Enqueue(baseMsg);
|
|
|
|
|
|
|
|
output.Add(baseMsg);
|
|
|
|
output.Add(baseMsg);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|