@@ -29,13 +29,13 @@ namespace GBNewEnergy.Protocol | |||||
/// 登入流水号 | /// 登入流水号 | ||||
/// 作用:看数据是否是连续请求 | /// 作用:看数据是否是连续请求 | ||||
/// </summary> | /// </summary> | ||||
public ushort LoginNum { get; protected set; } | |||||
public ushort LoginNum { get; set; } | |||||
/// <summary> | /// <summary> | ||||
/// 数据采集时间 | /// 数据采集时间 | ||||
/// 采用北京时间 | /// 采用北京时间 | ||||
/// </summary> | /// </summary> | ||||
public DateTime CurrentDateTime { get; protected set; } = DateTime.Now; | |||||
public DateTime CurrentDateTime { get; set; } = DateTime.Now; | |||||
protected NEBodies(byte[] buffer, NEGlobalConfigs nEConfigs) : base(buffer, nEConfigs) { } | protected NEBodies(byte[] buffer, NEGlobalConfigs nEConfigs) : base(buffer, nEConfigs) { } | ||||
@@ -115,6 +115,7 @@ namespace GBNewEnergy.Protocol | |||||
VIN = Buffer.ReadStringLittle(4, 17); | VIN = Buffer.ReadStringLittle(4, 17); | ||||
EncryptMethod = (NEEncryptMethod)Buffer[21]; | EncryptMethod = (NEEncryptMethod)Buffer[21]; | ||||
DataUnitLength = Buffer.ReadUShortH2LLittle(22, 2); | DataUnitLength = Buffer.ReadUShortH2LLittle(22, 2); | ||||
// 2.4. 验证校验码 | |||||
// 进行BCC校验码 | // 进行BCC校验码 | ||||
// 校验位 = 报文长度 - 最后一位(校验位) - 偏移量(2) | // 校验位 = 报文长度 - 最后一位(校验位) - 偏移量(2) | ||||
int checkBit = Buffer.Length - CheckBit - 2; | int checkBit = Buffer.Length - CheckBit - 2; | ||||
@@ -3,6 +3,7 @@ using System.Collections.Generic; | |||||
using System.Text; | using System.Text; | ||||
using Xunit; | using Xunit; | ||||
using JTNE.Protocol.Extensions; | using JTNE.Protocol.Extensions; | ||||
using JTNE.Protocol.Enums; | |||||
namespace JTNE.Protocol.Test | namespace JTNE.Protocol.Test | ||||
{ | { | ||||
@@ -12,7 +13,12 @@ namespace JTNE.Protocol.Test | |||||
public void Test1() | 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 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); | |||||
} | } | ||||
} | } | ||||
} | } |
@@ -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<string>() | |||||
{ | |||||
"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<JTNE_0x01>(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]); | |||||
} | |||||
} | |||||
} |
@@ -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<JTNE_0x04>(data); | |||||
Assert.Equal(DateTime.Parse("2019-01-22 23:55:56"), jTNE_0X04.LogoutTime); | |||||
Assert.Equal(4444, jTNE_0X04.LogoutNum); | |||||
} | |||||
} | |||||
} |
@@ -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<JTNE_0x05>(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); | |||||
} | |||||
} | |||||
} |
@@ -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<JTNE_0x06>(data); | |||||
Assert.Equal(DateTime.Parse("2019-01-22 23:55:56"), jTNE_0X06.LogoutTime); | |||||
Assert.Equal(6666, jTNE_0X06.LogoutNum); | |||||
} | |||||
} | |||||
} |
@@ -17,19 +17,30 @@ namespace JTNE.Protocol.Formatters | |||||
throw new JTNEException(JTNEErrorCode.BeginFlagError, $"{bytes[offset]},{bytes[offset + 1]}"); | throw new JTNEException(JTNEErrorCode.BeginFlagError, $"{bytes[offset]},{bytes[offset + 1]}"); | ||||
// 2.进行BCC校验码 | // 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(); | JTNEPackage jTNEPackage = new JTNEPackage(); | ||||
offset += 2; | offset += 2; | ||||
// 3.命令标识 | |||||
jTNEPackage.MsgId = JTNEBinaryExtensions.ReadByteLittle(bytes, ref offset); | jTNEPackage.MsgId = JTNEBinaryExtensions.ReadByteLittle(bytes, ref offset); | ||||
// 4.应答标识 | |||||
jTNEPackage.AskId = JTNEBinaryExtensions.ReadByteLittle(bytes, ref offset); | jTNEPackage.AskId = JTNEBinaryExtensions.ReadByteLittle(bytes, ref offset); | ||||
// 5.VIN | |||||
jTNEPackage.VIN = JTNEBinaryExtensions.ReadStringLittle(bytes, ref offset,17); | jTNEPackage.VIN = JTNEBinaryExtensions.ReadStringLittle(bytes, ref offset,17); | ||||
// 6.数据加密方式 | |||||
jTNEPackage.EncryptMethod = JTNEBinaryExtensions.ReadByteLittle(bytes, ref offset); | jTNEPackage.EncryptMethod = JTNEBinaryExtensions.ReadByteLittle(bytes, ref offset); | ||||
// 7.数据单元长度是数据单元的总字节数 | |||||
jTNEPackage.DataUnitLength = JTNEBinaryExtensions.ReadUInt16Little(bytes, ref offset); | jTNEPackage.DataUnitLength = JTNEBinaryExtensions.ReadUInt16Little(bytes, ref offset); | ||||
//todo:解码 | |||||
// 8.数据体 | |||||
// 8.1.根据数据加密方式进行解码 | |||||
// 8.2.解析出对应数据体 | |||||
jTNEPackage.Bodies = JTNEBinaryExtensions.ReadBytesLittle(bytes, ref offset, jTNEPackage.DataUnitLength); | jTNEPackage.Bodies = JTNEBinaryExtensions.ReadBytesLittle(bytes, ref offset, jTNEPackage.DataUnitLength); | ||||
// 9.校验码 | |||||
jTNEPackage.BCCCode = JTNEBinaryExtensions.ReadByteLittle(bytes, ref offset); | jTNEPackage.BCCCode = JTNEBinaryExtensions.ReadByteLittle(bytes, ref offset); | ||||
readSize = offset; | readSize = offset; | ||||
return jTNEPackage; | return jTNEPackage; | ||||
@@ -37,7 +48,28 @@ namespace JTNE.Protocol.Formatters | |||||
public int Serialize(ref byte[] bytes, int offset, JTNEPackage value) | 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; | |||||
} | } | ||||
} | } | ||||
} | } |
@@ -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<JTNE_0x01> | |||||
{ | |||||
public JTNE_0x01 Deserialize(ReadOnlySpan<byte> 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<string>(); | |||||
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; | |||||
} | |||||
} | |||||
} |
@@ -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<JTNE_0x04> | |||||
{ | |||||
public JTNE_0x04 Deserialize(ReadOnlySpan<byte> 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; | |||||
} | |||||
} | |||||
} |
@@ -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<JTNE_0x05> | |||||
{ | |||||
public JTNE_0x05 Deserialize(ReadOnlySpan<byte> 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; | |||||
} | |||||
} | |||||
} |
@@ -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<JTNE_0x06> | |||||
{ | |||||
public JTNE_0x06 Deserialize(ReadOnlySpan<byte> 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; | |||||
} | |||||
} | |||||
} |
@@ -5,10 +5,10 @@ | |||||
<LangVersion>latest</LangVersion> | <LangVersion>latest</LangVersion> | ||||
<Copyright>Copyright 2018.</Copyright> | <Copyright>Copyright 2018.</Copyright> | ||||
<Authors>SmallChi</Authors> | <Authors>SmallChi</Authors> | ||||
<PackageId>JTNewEnergy</PackageId> | |||||
<Product>JTNewEnergy</Product> | |||||
<Description>JTNewEnergy协议、GBNewEnergy协议、电动汽车远程服务与管理系统平台数据交换</Description> | |||||
<PackageReleaseNotes>JTNewEnergy协议、GBNewEnergy协议、电动汽车远程服务与管理系统平台数据交换</PackageReleaseNotes> | |||||
<PackageId>JTNE.Protocol</PackageId> | |||||
<Product>JTNE.Protocol</Product> | |||||
<Description>JTNE协议、JTNewEnergy协议、GBNewEnergy协议、新能源协议、电动汽车远程服务与管理系统平台数据交换</Description> | |||||
<PackageReleaseNotes>JTNE协议、JTNewEnergy协议、GBNewEnergy协议、新能源协议、电动汽车远程服务与管理系统平台数据交换</PackageReleaseNotes> | |||||
<PackageRequireLicenseAcceptance>false</PackageRequireLicenseAcceptance> | <PackageRequireLicenseAcceptance>false</PackageRequireLicenseAcceptance> | ||||
<RepositoryUrl>https://github.com/SmallChi/JTNewEnergy</RepositoryUrl> | <RepositoryUrl>https://github.com/SmallChi/JTNewEnergy</RepositoryUrl> | ||||
<PackageProjectUrl>https://github.com/SmallChi/JTNewEnergy</PackageProjectUrl> | <PackageProjectUrl>https://github.com/SmallChi/JTNewEnergy</PackageProjectUrl> | ||||
@@ -14,6 +14,7 @@ namespace JTNE.Protocol | |||||
{ | { | ||||
Encoding.RegisterProvider(CodePagesEncodingProvider.Instance); | Encoding.RegisterProvider(CodePagesEncodingProvider.Instance); | ||||
Encoding = Encoding.UTF8; | Encoding = Encoding.UTF8; | ||||
SkipCRCCode = false; | |||||
} | } | ||||
/// <summary> | /// <summary> | ||||
/// 字符串编码 | /// 字符串编码 | ||||
@@ -30,5 +31,24 @@ namespace JTNE.Protocol | |||||
return instance.Value; | return instance.Value; | ||||
} | } | ||||
} | } | ||||
/// <summary> | |||||
/// 跳过校验码 | |||||
/// 测试的时候需要手动修改值,避免验证 | |||||
/// 默认:false | |||||
/// </summary> | |||||
public bool SkipCRCCode { get; private set; } | |||||
/// <summary> | |||||
/// 设置跳过校验码 | |||||
/// 场景:测试的时候,可能需要手动改数据,所以测试的时候有用 | |||||
/// </summary> | |||||
/// <param name="skipCRCCode"></param> | |||||
/// <returns></returns> | |||||
public JTNEGlobalConfigs SetSkipCRCCode(bool skipCRCCode) | |||||
{ | |||||
instance.Value.SkipCRCCode = skipCRCCode; | |||||
return instance.Value; | |||||
} | |||||
} | } | ||||
} | } |
@@ -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 | |||||
{ | |||||
/// <summary> | |||||
/// 车辆登入 | |||||
/// </summary> | |||||
[JTNEFormatter(typeof(JTNE_0x01_Formatter))] | |||||
public class JTNE_0x01: JTNEBodies | |||||
{ | |||||
/// <summary> | |||||
/// 数据采集时间 | |||||
/// 采用北京时间 | |||||
/// </summary> | |||||
public DateTime PDATime { get; set; } | |||||
/// <summary> | |||||
/// 登入流水号 | |||||
/// 作用:看数据是否是连续请求 | |||||
/// </summary> | |||||
public ushort LoginNum { get; set; } | |||||
/// <summary> | |||||
/// SIM卡ICCID号(ICCID应为终端从SIM卡获取的值,不应认为填写或修改) | |||||
/// </summary> | |||||
public string SIM { get; set; } | |||||
/// <summary> | |||||
/// 电池总成数 | |||||
/// 可充电储能子系统数 | |||||
/// </summary> | |||||
public byte BatteryCount { get; set; } | |||||
/// <summary> | |||||
/// 电池编码长度 | |||||
/// 可充电储能系统编码长度 | |||||
/// </summary> | |||||
public byte BatteryLength { get; set; } | |||||
/// <summary> | |||||
/// 电池编码 | |||||
/// 可充电储能系统编码 | |||||
/// </summary> | |||||
public List<string> BatteryNos { get; set; } | |||||
} | |||||
} |
@@ -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 | |||||
{ | |||||
/// <summary> | |||||
/// 车辆登出 | |||||
/// </summary> | |||||
[JTNEFormatter(typeof(JTNE_0x04_Formatter))] | |||||
public class JTNE_0x04: JTNEBodies | |||||
{ | |||||
/// <summary> | |||||
/// 登出时间 | |||||
/// </summary> | |||||
public DateTime LogoutTime { get; set; } | |||||
/// <summary> | |||||
/// 登出流水号与当次登入流水号一致 | |||||
/// </summary> | |||||
public ushort LogoutNum { get; set; } | |||||
} | |||||
} |
@@ -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 | |||||
{ | |||||
/// <summary> | |||||
/// 平台登入 | |||||
/// </summary> | |||||
[JTNEFormatter(typeof(JTNE_0x05_Formatter))] | |||||
public class JTNE_0x05 : JTNEBodies | |||||
{ | |||||
/// <summary> | |||||
/// 平台登入时间 | |||||
/// </summary> | |||||
public DateTime LoginTime { get; set; } | |||||
/// <summary> | |||||
/// 登入流水号 | |||||
/// 下级平台每登入一次,登入流水号自动加1,从1开始循环累加,最大值为65531,循环周期为天 | |||||
/// </summary> | |||||
public ushort LoginNum { get; set; } | |||||
/// <summary> | |||||
/// 平台用户名 | |||||
/// </summary> | |||||
public string PlatformUserName { get; set; } | |||||
/// <summary> | |||||
/// 平台密码 | |||||
/// </summary> | |||||
public string PlatformPassword { get; set; } | |||||
/// <summary> | |||||
/// 加密规则 | |||||
/// </summary> | |||||
public byte EncryptMethod{ get; set; } | |||||
} | |||||
} |
@@ -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 | |||||
{ | |||||
/// <summary> | |||||
/// 平台登出 | |||||
/// </summary> | |||||
[JTNEFormatter(typeof(JTNE_0x06_Formatter))] | |||||
public class JTNE_0x06 : JTNEBodies | |||||
{ | |||||
/// <summary> | |||||
/// 登出时间 | |||||
/// </summary> | |||||
public DateTime LogoutTime { get; set; } | |||||
/// <summary> | |||||
/// 登出流水号与当次登入流水号一致 | |||||
/// </summary> | |||||
public ushort LogoutNum { get; set; } | |||||
} | |||||
} |
@@ -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 | |||||
{ | |||||
/// <summary> | |||||
/// 车载终端心跳 | |||||
/// </summary> | |||||
public class JTNE_0x07 : JTNEBodies | |||||
{ | |||||
} | |||||
} |
@@ -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 | |||||
{ | |||||
/// <summary> | |||||
/// 终端校时 | |||||
/// </summary> | |||||
public class JTNE_0x08 : JTNEBodies | |||||
{ | |||||
} | |||||
} |