diff --git a/src/GBNewEnergy.Protocol/NEBodies.cs b/src/GBNewEnergy.Protocol/NEBodies.cs index b2a3ff2..0034e72 100644 --- a/src/GBNewEnergy.Protocol/NEBodies.cs +++ b/src/GBNewEnergy.Protocol/NEBodies.cs @@ -29,13 +29,13 @@ namespace GBNewEnergy.Protocol /// 登入流水号 /// 作用:看数据是否是连续请求 /// - public ushort LoginNum { get; protected set; } + public ushort LoginNum { get; set; } /// /// 数据采集时间 /// 采用北京时间 /// - public DateTime CurrentDateTime { get; protected set; } = DateTime.Now; + public DateTime CurrentDateTime { get; set; } = DateTime.Now; protected NEBodies(byte[] buffer, NEGlobalConfigs nEConfigs) : base(buffer, nEConfigs) { } diff --git a/src/GBNewEnergy.Protocol/NEPackage.cs b/src/GBNewEnergy.Protocol/NEPackage.cs index a84e2b6..c84637a 100644 --- a/src/GBNewEnergy.Protocol/NEPackage.cs +++ b/src/GBNewEnergy.Protocol/NEPackage.cs @@ -115,6 +115,7 @@ namespace GBNewEnergy.Protocol VIN = Buffer.ReadStringLittle(4, 17); EncryptMethod = (NEEncryptMethod)Buffer[21]; DataUnitLength = Buffer.ReadUShortH2LLittle(22, 2); + // 2.4. 验证校验码 // 进行BCC校验码 // 校验位 = 报文长度 - 最后一位(校验位) - 偏移量(2) int checkBit = Buffer.Length - CheckBit - 2; diff --git a/src/JTNE.Protocol.Test/JTNEPackageTest.cs b/src/JTNE.Protocol.Test/JTNEPackageTest.cs index 0b2450b..1c5d642 100644 --- a/src/JTNE.Protocol.Test/JTNEPackageTest.cs +++ b/src/JTNE.Protocol.Test/JTNEPackageTest.cs @@ -3,6 +3,7 @@ using System.Collections.Generic; using System.Text; using Xunit; using JTNE.Protocol.Extensions; +using JTNE.Protocol.Enums; namespace JTNE.Protocol.Test { @@ -12,7 +13,12 @@ namespace JTNE.Protocol.Test public void Test1() { var hex = "23 23 05 FE 4C 47 48 43 34 56 31 44 33 48 45 32 30 32 36 35 32 01 00 08 12 06 08 12 06 3A 00 01 E9".ToHexBytes(); - var package=JTNESerializer.Deserialize(hex); + var package = JTNESerializer.Deserialize(hex); + Assert.Equal("LGHC4V1D3HE202652", package.VIN); + Assert.Equal(JTNEAskId.CMD.ToByteValue(), package.AskId); + Assert.Equal((ushort)8, package.DataUnitLength); + Assert.Equal(0x01, package.EncryptMethod); + Assert.Equal(JTNEMsgId.platformlogin.ToByteValue(), package.MsgId); } } } diff --git a/src/JTNE.Protocol.Test/MessageBody/JTNE_0x01Test.cs b/src/JTNE.Protocol.Test/MessageBody/JTNE_0x01Test.cs new file mode 100644 index 0000000..fcf9092 --- /dev/null +++ b/src/JTNE.Protocol.Test/MessageBody/JTNE_0x01Test.cs @@ -0,0 +1,45 @@ +using JTNE.Protocol.MessageBody; +using System; +using System.Collections.Generic; +using System.Text; +using Xunit; +using JTNE.Protocol.Extensions; + +namespace JTNE.Protocol.Test.MessageBody +{ + public class JTNE_0x01Test + { + [Fact] + public void Test1() + { + JTNE_0x01 jTNE_0X01 = new JTNE_0x01(); + jTNE_0X01.PDATime = DateTime.Parse("2019-01-22 23:55:56"); + jTNE_0X01.LoginNum = 1; + jTNE_0X01.BatteryLength = 0x04; + jTNE_0X01.SIM = "12345678998765432100"; + jTNE_0X01.BatteryNos = new List() + { + "1234", + "4567", + "9870" + }; + var hex = JTNESerializer.Serialize(jTNE_0X01).ToHexString(); + Assert.Equal("190122235556000131323334353637383939383736353433323130300304313233343435363739383730", hex); + } + + [Fact] + public void Test2() + { + var data = "190122235556000131323334353637383939383736353433323130300304313233343435363739383730".ToHexBytes(); + JTNE_0x01 jTNE_0X01 = JTNESerializer.Deserialize(data); + Assert.Equal(DateTime.Parse("2019-01-22 23:55:56"), jTNE_0X01.PDATime); + Assert.Equal(1, jTNE_0X01.LoginNum); + Assert.Equal(0x04, jTNE_0X01.BatteryLength); + Assert.Equal("12345678998765432100", jTNE_0X01.SIM); + Assert.Equal(3, jTNE_0X01.BatteryCount); + Assert.Equal("1234", jTNE_0X01.BatteryNos[0]); + Assert.Equal("4567", jTNE_0X01.BatteryNos[1]); + Assert.Equal("9870", jTNE_0X01.BatteryNos[2]); + } + } +} diff --git a/src/JTNE.Protocol.Test/MessageBody/JTNE_0x04Test.cs b/src/JTNE.Protocol.Test/MessageBody/JTNE_0x04Test.cs new file mode 100644 index 0000000..451746f --- /dev/null +++ b/src/JTNE.Protocol.Test/MessageBody/JTNE_0x04Test.cs @@ -0,0 +1,31 @@ +using JTNE.Protocol.MessageBody; +using System; +using System.Collections.Generic; +using System.Text; +using Xunit; +using JTNE.Protocol.Extensions; + +namespace JTNE.Protocol.Test.MessageBody +{ + public class JTNE_0x04Test + { + [Fact] + public void Test1() + { + JTNE_0x04 jTNE_0X04 = new JTNE_0x04(); + jTNE_0X04.LogoutTime = DateTime.Parse("2019-01-22 23:55:56"); + jTNE_0X04.LogoutNum = 4444; + var hex = JTNESerializer.Serialize(jTNE_0X04).ToHexString(); + Assert.Equal("190122235556115C", hex); + } + + [Fact] + public void Test2() + { + var data = "190122235556115C".ToHexBytes(); + JTNE_0x04 jTNE_0X04 = JTNESerializer.Deserialize(data); + Assert.Equal(DateTime.Parse("2019-01-22 23:55:56"), jTNE_0X04.LogoutTime); + Assert.Equal(4444, jTNE_0X04.LogoutNum); + } + } +} diff --git a/src/JTNE.Protocol.Test/MessageBody/JTNE_0x05Test.cs b/src/JTNE.Protocol.Test/MessageBody/JTNE_0x05Test.cs new file mode 100644 index 0000000..63c35ed --- /dev/null +++ b/src/JTNE.Protocol.Test/MessageBody/JTNE_0x05Test.cs @@ -0,0 +1,37 @@ +using JTNE.Protocol.MessageBody; +using System; +using System.Collections.Generic; +using System.Text; +using Xunit; +using JTNE.Protocol.Extensions; + +namespace JTNE.Protocol.Test.MessageBody +{ + public class JTNE_0x05Test + { + [Fact] + public void Test1() + { + JTNE_0x05 jTNE_0X05 = new JTNE_0x05(); + jTNE_0X05.LoginTime = DateTime.Parse("2019-01-22 23:55:56"); + jTNE_0X05.LoginNum = 6666; + jTNE_0X05.PlatformUserName = "SmallChi518"; + jTNE_0X05.PlatformPassword = "1234567890123456789"; + jTNE_0X05.EncryptMethod = 0x00; + var hex = JTNESerializer.Serialize(jTNE_0X05).ToHexString(); + Assert.Equal("1901222355561A0A536D616C6C43686935313800313233343536373839303132333435363738390000", hex); + } + + [Fact] + public void Test2() + { + var data = "1901222355561A0A536D616C6C43686935313800313233343536373839303132333435363738390000".ToHexBytes(); + JTNE_0x05 jTNE_0X05 = JTNESerializer.Deserialize(data); + Assert.Equal(DateTime.Parse("2019-01-22 23:55:56"), jTNE_0X05.LoginTime); + Assert.Equal(6666, jTNE_0X05.LoginNum); + Assert.Equal("SmallChi518", jTNE_0X05.PlatformUserName); + Assert.Equal("1234567890123456789", jTNE_0X05.PlatformPassword); + Assert.Equal(0x00, jTNE_0X05.EncryptMethod); + } + } +} diff --git a/src/JTNE.Protocol.Test/MessageBody/JTNE_0x06Test.cs b/src/JTNE.Protocol.Test/MessageBody/JTNE_0x06Test.cs new file mode 100644 index 0000000..1914b0e --- /dev/null +++ b/src/JTNE.Protocol.Test/MessageBody/JTNE_0x06Test.cs @@ -0,0 +1,31 @@ +using JTNE.Protocol.MessageBody; +using System; +using System.Collections.Generic; +using System.Text; +using Xunit; +using JTNE.Protocol.Extensions; + +namespace JTNE.Protocol.Test.MessageBody +{ + public class JTNE_0x06Test + { + [Fact] + public void Test1() + { + JTNE_0x06 jTNE_0X06 = new JTNE_0x06(); + jTNE_0X06.LogoutTime = DateTime.Parse("2019-01-22 23:55:56"); + jTNE_0X06.LogoutNum = 6666; + var hex = JTNESerializer.Serialize(jTNE_0X06).ToHexString(); + Assert.Equal("1901222355561A0A", hex); + } + + [Fact] + public void Test2() + { + var data = "1901222355561A0A".ToHexBytes(); + JTNE_0x06 jTNE_0X06 = JTNESerializer.Deserialize(data); + Assert.Equal(DateTime.Parse("2019-01-22 23:55:56"), jTNE_0X06.LogoutTime); + Assert.Equal(6666, jTNE_0X06.LogoutNum); + } + } +} diff --git a/src/JTNE.Protocol/Formatters/JTNEPackageFormatter.cs b/src/JTNE.Protocol/Formatters/JTNEPackageFormatter.cs index c80e4af..87cf3bf 100644 --- a/src/JTNE.Protocol/Formatters/JTNEPackageFormatter.cs +++ b/src/JTNE.Protocol/Formatters/JTNEPackageFormatter.cs @@ -17,19 +17,30 @@ namespace JTNE.Protocol.Formatters throw new JTNEException(JTNEErrorCode.BeginFlagError, $"{bytes[offset]},{bytes[offset + 1]}"); // 2.进行BCC校验码 // 校验位 = 报文长度 - 最后一位(校验位) - byte bCCCode = bytes[bytes.Length - 1]; - byte bCCCode2 = bytes.ToXor(2, bytes.Length - 1); - if (bCCCode != bCCCode2) - throw new JTNEException(JTNEErrorCode.BCCCodeError, $"request:{bCCCode}!=calculate:{bCCCode2}"); + if (!JTNEGlobalConfigs.Instance.SkipCRCCode) + { + byte bCCCode = bytes[bytes.Length - 1]; + byte bCCCode2 = bytes.ToXor(2, bytes.Length - 1); + if (bCCCode != bCCCode2) + throw new JTNEException(JTNEErrorCode.BCCCodeError, $"request:{bCCCode}!=calculate:{bCCCode2}"); + } JTNEPackage jTNEPackage = new JTNEPackage(); offset += 2; + // 3.命令标识 jTNEPackage.MsgId = JTNEBinaryExtensions.ReadByteLittle(bytes, ref offset); + // 4.应答标识 jTNEPackage.AskId = JTNEBinaryExtensions.ReadByteLittle(bytes, ref offset); + // 5.VIN jTNEPackage.VIN = JTNEBinaryExtensions.ReadStringLittle(bytes, ref offset,17); + // 6.数据加密方式 jTNEPackage.EncryptMethod = JTNEBinaryExtensions.ReadByteLittle(bytes, ref offset); + // 7.数据单元长度是数据单元的总字节数 jTNEPackage.DataUnitLength = JTNEBinaryExtensions.ReadUInt16Little(bytes, ref offset); - //todo:解码 + // 8.数据体 + // 8.1.根据数据加密方式进行解码 + // 8.2.解析出对应数据体 jTNEPackage.Bodies = JTNEBinaryExtensions.ReadBytesLittle(bytes, ref offset, jTNEPackage.DataUnitLength); + // 9.校验码 jTNEPackage.BCCCode = JTNEBinaryExtensions.ReadByteLittle(bytes, ref offset); readSize = offset; return jTNEPackage; @@ -37,7 +48,28 @@ namespace JTNE.Protocol.Formatters public int Serialize(ref byte[] bytes, int offset, JTNEPackage value) { - throw new NotImplementedException(); + // 1.起始符1 + offset += JTNEBinaryExtensions.WriteByteLittle(bytes, offset, value.BeginFlag1); + // 2.起始符2 + offset += JTNEBinaryExtensions.WriteByteLittle(bytes, offset, value.BeginFlag2); + // 3.命令标识 + offset += JTNEBinaryExtensions.WriteByteLittle(bytes, offset, value.MsgId); + // 4.应答标识 + offset += JTNEBinaryExtensions.WriteByteLittle(bytes, offset, value.AskId); + // 5.VIN + offset += JTNEBinaryExtensions.WriteStringPadRightLittle(bytes, offset, value.VIN,17); + // 6.数据加密方式 + offset += JTNEBinaryExtensions.WriteByteLittle(bytes, offset, value.MsgId); + // 7.数据单元长度是数据单元的总字节数 + // 7.1.先解析出数据体 + // 7.2.判断是否有加密 + offset += JTNEBinaryExtensions.WriteUInt16Little(bytes, offset,(ushort)value.Bodies.Length); + // 8.数据体 + offset += JTNEBinaryExtensions.WriteBytesLittle(bytes, offset,value.Bodies); + // 9.校验码 + var bccCode = bytes.ToXor(2, offset - 2); + offset += JTNEBinaryExtensions.WriteByteLittle(bytes, offset, bccCode); + return offset; } } } diff --git a/src/JTNE.Protocol/Formatters/MessageBodyFormatters/JTNE_0x01_Formatter.cs b/src/JTNE.Protocol/Formatters/MessageBodyFormatters/JTNE_0x01_Formatter.cs new file mode 100644 index 0000000..2e245ff --- /dev/null +++ b/src/JTNE.Protocol/Formatters/MessageBodyFormatters/JTNE_0x01_Formatter.cs @@ -0,0 +1,46 @@ +using JTNE.Protocol.Extensions; +using JTNE.Protocol.MessageBody; +using System; +using System.Collections.Generic; +using System.Text; + +namespace JTNE.Protocol.Formatters.MessageBodyFormatters +{ + public class JTNE_0x01_Formatter : IJTNEFormatter + { + public JTNE_0x01 Deserialize(ReadOnlySpan bytes, out int readSize) + { + int offset = 0; + JTNE_0x01 jTNE_0X01 = new JTNE_0x01(); + jTNE_0X01.PDATime = JTNEBinaryExtensions.ReadDateTime6Little(bytes, ref offset); + jTNE_0X01.LoginNum = JTNEBinaryExtensions.ReadUInt16Little(bytes, ref offset); + jTNE_0X01.SIM = JTNEBinaryExtensions.ReadStringLittle(bytes, ref offset, 20); + jTNE_0X01.BatteryCount = JTNEBinaryExtensions.ReadByteLittle(bytes, ref offset); + jTNE_0X01.BatteryLength = JTNEBinaryExtensions.ReadByteLittle(bytes, ref offset); + jTNE_0X01.BatteryNos = new List(); + if ((jTNE_0X01.BatteryCount * jTNE_0X01.BatteryLength) > 0) + { + for (int i = 0; i < jTNE_0X01.BatteryCount; i++) + { + jTNE_0X01.BatteryNos.Add(JTNEBinaryExtensions.ReadStringLittle(bytes, ref offset, jTNE_0X01.BatteryLength)); + } + } + readSize = offset; + return jTNE_0X01; + } + + public int Serialize(ref byte[] bytes, int offset, JTNE_0x01 value) + { + offset += JTNEBinaryExtensions.WriteDateTime6Little(bytes, offset, value.PDATime); + offset += JTNEBinaryExtensions.WriteUInt16Little(bytes, offset, value.LoginNum); + offset += JTNEBinaryExtensions.WriteStringLittle(bytes, offset, value.SIM, 20); + offset += JTNEBinaryExtensions.WriteByteLittle(bytes, offset, (byte)value.BatteryNos.Count); + offset += JTNEBinaryExtensions.WriteByteLittle(bytes, offset, value.BatteryLength); + foreach(var item in value.BatteryNos) + { + offset += JTNEBinaryExtensions.WriteStringLittle(bytes, offset, item, value.BatteryLength); + } + return offset; + } + } +} diff --git a/src/JTNE.Protocol/Formatters/MessageBodyFormatters/JTNE_0x04_Formatter.cs b/src/JTNE.Protocol/Formatters/MessageBodyFormatters/JTNE_0x04_Formatter.cs new file mode 100644 index 0000000..adc689f --- /dev/null +++ b/src/JTNE.Protocol/Formatters/MessageBodyFormatters/JTNE_0x04_Formatter.cs @@ -0,0 +1,28 @@ +using JTNE.Protocol.Extensions; +using JTNE.Protocol.MessageBody; +using System; +using System.Collections.Generic; +using System.Text; + +namespace JTNE.Protocol.Formatters.MessageBodyFormatters +{ + public class JTNE_0x04_Formatter : IJTNEFormatter + { + public JTNE_0x04 Deserialize(ReadOnlySpan bytes, out int readSize) + { + int offset = 0; + JTNE_0x04 jTNE_0X01 = new JTNE_0x04(); + jTNE_0X01.LogoutTime = JTNEBinaryExtensions.ReadDateTime6Little(bytes, ref offset); + jTNE_0X01.LogoutNum = JTNEBinaryExtensions.ReadUInt16Little(bytes, ref offset); + readSize = offset; + return jTNE_0X01; + } + + public int Serialize(ref byte[] bytes, int offset, JTNE_0x04 value) + { + offset += JTNEBinaryExtensions.WriteDateTime6Little(bytes, offset, value.LogoutTime); + offset += JTNEBinaryExtensions.WriteUInt16Little(bytes, offset, value.LogoutNum); + return offset; + } + } +} diff --git a/src/JTNE.Protocol/Formatters/MessageBodyFormatters/JTNE_0x05_Formatter.cs b/src/JTNE.Protocol/Formatters/MessageBodyFormatters/JTNE_0x05_Formatter.cs new file mode 100644 index 0000000..1e14bde --- /dev/null +++ b/src/JTNE.Protocol/Formatters/MessageBodyFormatters/JTNE_0x05_Formatter.cs @@ -0,0 +1,34 @@ +using JTNE.Protocol.Extensions; +using JTNE.Protocol.MessageBody; +using System; +using System.Collections.Generic; +using System.Text; + +namespace JTNE.Protocol.Formatters.MessageBodyFormatters +{ + public class JTNE_0x05_Formatter : IJTNEFormatter + { + public JTNE_0x05 Deserialize(ReadOnlySpan bytes, out int readSize) + { + int offset = 0; + JTNE_0x05 jTNE_0X05 = new JTNE_0x05(); + jTNE_0X05.LoginTime = JTNEBinaryExtensions.ReadDateTime6Little(bytes, ref offset); + jTNE_0X05.LoginNum = JTNEBinaryExtensions.ReadUInt16Little(bytes, ref offset); + jTNE_0X05.PlatformUserName = JTNEBinaryExtensions.ReadStringLittle(bytes, ref offset,12); + jTNE_0X05.PlatformPassword = JTNEBinaryExtensions.ReadStringLittle(bytes, ref offset, 20); + jTNE_0X05.EncryptMethod = JTNEBinaryExtensions.ReadByteLittle(bytes, ref offset); + readSize = offset; + return jTNE_0X05; + } + + public int Serialize(ref byte[] bytes, int offset, JTNE_0x05 value) + { + offset += JTNEBinaryExtensions.WriteDateTime6Little(bytes, offset, value.LoginTime); + offset += JTNEBinaryExtensions.WriteUInt16Little(bytes, offset, value.LoginNum); + offset += JTNEBinaryExtensions.WriteStringLittle(bytes, offset, value.PlatformUserName,12); + offset += JTNEBinaryExtensions.WriteStringLittle(bytes, offset, value.PlatformPassword, 20); + offset += JTNEBinaryExtensions.WriteByteLittle(bytes, offset, value.EncryptMethod); + return offset; + } + } +} diff --git a/src/JTNE.Protocol/Formatters/MessageBodyFormatters/JTNE_0x06_Formatter.cs b/src/JTNE.Protocol/Formatters/MessageBodyFormatters/JTNE_0x06_Formatter.cs new file mode 100644 index 0000000..a750a71 --- /dev/null +++ b/src/JTNE.Protocol/Formatters/MessageBodyFormatters/JTNE_0x06_Formatter.cs @@ -0,0 +1,28 @@ +using JTNE.Protocol.Extensions; +using JTNE.Protocol.MessageBody; +using System; +using System.Collections.Generic; +using System.Text; + +namespace JTNE.Protocol.Formatters.MessageBodyFormatters +{ + public class JTNE_0x06_Formatter : IJTNEFormatter + { + public JTNE_0x06 Deserialize(ReadOnlySpan bytes, out int readSize) + { + int offset = 0; + JTNE_0x06 jTNE_0X06 = new JTNE_0x06(); + jTNE_0X06.LogoutTime = JTNEBinaryExtensions.ReadDateTime6Little(bytes, ref offset); + jTNE_0X06.LogoutNum = JTNEBinaryExtensions.ReadUInt16Little(bytes, ref offset); + readSize = offset; + return jTNE_0X06; + } + + public int Serialize(ref byte[] bytes, int offset, JTNE_0x06 value) + { + offset += JTNEBinaryExtensions.WriteDateTime6Little(bytes, offset, value.LogoutTime); + offset += JTNEBinaryExtensions.WriteUInt16Little(bytes, offset, value.LogoutNum); + return offset; + } + } +} diff --git a/src/JTNE.Protocol/JTNE.Protocol.csproj b/src/JTNE.Protocol/JTNE.Protocol.csproj index f77f861..7fb3179 100644 --- a/src/JTNE.Protocol/JTNE.Protocol.csproj +++ b/src/JTNE.Protocol/JTNE.Protocol.csproj @@ -5,10 +5,10 @@ latest Copyright 2018. SmallChi - JTNewEnergy - JTNewEnergy - JTNewEnergy协议、GBNewEnergy协议、电动汽车远程服务与管理系统平台数据交换 - JTNewEnergy协议、GBNewEnergy协议、电动汽车远程服务与管理系统平台数据交换 + JTNE.Protocol + JTNE.Protocol + JTNE协议、JTNewEnergy协议、GBNewEnergy协议、新能源协议、电动汽车远程服务与管理系统平台数据交换 + JTNE协议、JTNewEnergy协议、GBNewEnergy协议、新能源协议、电动汽车远程服务与管理系统平台数据交换 false https://github.com/SmallChi/JTNewEnergy https://github.com/SmallChi/JTNewEnergy diff --git a/src/JTNE.Protocol/JTNEGlobalConfigs.cs b/src/JTNE.Protocol/JTNEGlobalConfigs.cs index a0943ab..ecadc9e 100644 --- a/src/JTNE.Protocol/JTNEGlobalConfigs.cs +++ b/src/JTNE.Protocol/JTNEGlobalConfigs.cs @@ -14,6 +14,7 @@ namespace JTNE.Protocol { Encoding.RegisterProvider(CodePagesEncodingProvider.Instance); Encoding = Encoding.UTF8; + SkipCRCCode = false; } /// /// 字符串编码 @@ -30,5 +31,24 @@ namespace JTNE.Protocol return instance.Value; } } + + /// + /// 跳过校验码 + /// 测试的时候需要手动修改值,避免验证 + /// 默认:false + /// + public bool SkipCRCCode { get; private set; } + + /// + /// 设置跳过校验码 + /// 场景:测试的时候,可能需要手动改数据,所以测试的时候有用 + /// + /// + /// + public JTNEGlobalConfigs SetSkipCRCCode(bool skipCRCCode) + { + instance.Value.SkipCRCCode = skipCRCCode; + return instance.Value; + } } } diff --git a/src/JTNE.Protocol/MessageBody/JTNE_0x01.cs b/src/JTNE.Protocol/MessageBody/JTNE_0x01.cs new file mode 100644 index 0000000..8fbe501 --- /dev/null +++ b/src/JTNE.Protocol/MessageBody/JTNE_0x01.cs @@ -0,0 +1,45 @@ +using JTNE.Protocol.Attributes; +using JTNE.Protocol.Formatters.MessageBodyFormatters; +using System; +using System.Collections.Generic; +using System.Text; + +namespace JTNE.Protocol.MessageBody +{ + /// + /// 车辆登入 + /// + [JTNEFormatter(typeof(JTNE_0x01_Formatter))] + public class JTNE_0x01: JTNEBodies + { + /// + /// 数据采集时间 + /// 采用北京时间 + /// + public DateTime PDATime { get; set; } + /// + /// 登入流水号 + /// 作用:看数据是否是连续请求 + /// + public ushort LoginNum { get; set; } + /// + /// SIM卡ICCID号(ICCID应为终端从SIM卡获取的值,不应认为填写或修改) + /// + public string SIM { get; set; } + /// + /// 电池总成数 + /// 可充电储能子系统数 + /// + public byte BatteryCount { get; set; } + /// + /// 电池编码长度 + /// 可充电储能系统编码长度 + /// + public byte BatteryLength { get; set; } + /// + /// 电池编码 + /// 可充电储能系统编码 + /// + public List BatteryNos { get; set; } + } +} diff --git a/src/JTNE.Protocol/MessageBody/JTNE_0x04.cs b/src/JTNE.Protocol/MessageBody/JTNE_0x04.cs new file mode 100644 index 0000000..1439434 --- /dev/null +++ b/src/JTNE.Protocol/MessageBody/JTNE_0x04.cs @@ -0,0 +1,24 @@ +using JTNE.Protocol.Attributes; +using JTNE.Protocol.Formatters.MessageBodyFormatters; +using System; +using System.Collections.Generic; +using System.Text; + +namespace JTNE.Protocol.MessageBody +{ + /// + /// 车辆登出 + /// + [JTNEFormatter(typeof(JTNE_0x04_Formatter))] + public class JTNE_0x04: JTNEBodies + { + /// + /// 登出时间 + /// + public DateTime LogoutTime { get; set; } + /// + /// 登出流水号与当次登入流水号一致 + /// + public ushort LogoutNum { get; set; } + } +} diff --git a/src/JTNE.Protocol/MessageBody/JTNE_0x05.cs b/src/JTNE.Protocol/MessageBody/JTNE_0x05.cs new file mode 100644 index 0000000..496e518 --- /dev/null +++ b/src/JTNE.Protocol/MessageBody/JTNE_0x05.cs @@ -0,0 +1,37 @@ +using JTNE.Protocol.Attributes; +using JTNE.Protocol.Formatters.MessageBodyFormatters; +using System; +using System.Collections.Generic; +using System.Text; + +namespace JTNE.Protocol.MessageBody +{ + /// + /// 平台登入 + /// + [JTNEFormatter(typeof(JTNE_0x05_Formatter))] + public class JTNE_0x05 : JTNEBodies + { + /// + /// 平台登入时间 + /// + public DateTime LoginTime { get; set; } + /// + /// 登入流水号 + /// 下级平台每登入一次,登入流水号自动加1,从1开始循环累加,最大值为65531,循环周期为天 + /// + public ushort LoginNum { get; set; } + /// + /// 平台用户名 + /// + public string PlatformUserName { get; set; } + /// + /// 平台密码 + /// + public string PlatformPassword { get; set; } + /// + /// 加密规则 + /// + public byte EncryptMethod{ get; set; } +} +} diff --git a/src/JTNE.Protocol/MessageBody/JTNE_0x06.cs b/src/JTNE.Protocol/MessageBody/JTNE_0x06.cs new file mode 100644 index 0000000..f8388e1 --- /dev/null +++ b/src/JTNE.Protocol/MessageBody/JTNE_0x06.cs @@ -0,0 +1,24 @@ +using JTNE.Protocol.Attributes; +using JTNE.Protocol.Formatters.MessageBodyFormatters; +using System; +using System.Collections.Generic; +using System.Text; + +namespace JTNE.Protocol.MessageBody +{ + /// + /// 平台登出 + /// + [JTNEFormatter(typeof(JTNE_0x06_Formatter))] + public class JTNE_0x06 : JTNEBodies + { + /// + /// 登出时间 + /// + public DateTime LogoutTime { get; set; } + /// + /// 登出流水号与当次登入流水号一致 + /// + public ushort LogoutNum { get; set; } + } +} diff --git a/src/JTNE.Protocol/MessageBody/JTNE_0x07.cs b/src/JTNE.Protocol/MessageBody/JTNE_0x07.cs new file mode 100644 index 0000000..c54a892 --- /dev/null +++ b/src/JTNE.Protocol/MessageBody/JTNE_0x07.cs @@ -0,0 +1,16 @@ +using JTNE.Protocol.Attributes; +using JTNE.Protocol.Formatters.MessageBodyFormatters; +using System; +using System.Collections.Generic; +using System.Text; + +namespace JTNE.Protocol.MessageBody +{ + /// + /// 车载终端心跳 + /// + public class JTNE_0x07 : JTNEBodies + { + + } +} diff --git a/src/JTNE.Protocol/MessageBody/JTNE_0x08.cs b/src/JTNE.Protocol/MessageBody/JTNE_0x08.cs new file mode 100644 index 0000000..4f60acb --- /dev/null +++ b/src/JTNE.Protocol/MessageBody/JTNE_0x08.cs @@ -0,0 +1,16 @@ +using JTNE.Protocol.Attributes; +using JTNE.Protocol.Formatters.MessageBodyFormatters; +using System; +using System.Collections.Generic; +using System.Text; + +namespace JTNE.Protocol.MessageBody +{ + /// + /// 终端校时 + /// + public class JTNE_0x08 : JTNEBodies + { + + } +}