@@ -0,0 +1,54 @@ | |||
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_0x02_0x01Test | |||
{ | |||
[Fact] | |||
public void Test1() | |||
{ | |||
JTNE_0x02_0x01 jTNE_0X02_0X01 = new JTNE_0x02_0x01(); | |||
jTNE_0X02_0X01.Accelerator = 0x02; | |||
jTNE_0X02_0X01.Brakes = 0x03; | |||
jTNE_0X02_0X01.CarStatus = 0x04; | |||
jTNE_0X02_0X01.ChargeStatus = 0x05; | |||
jTNE_0X02_0X01.DCStatus = 0x06; | |||
jTNE_0X02_0X01.OperationMode = 0x07; | |||
jTNE_0X02_0X01.Resistance = 123; | |||
jTNE_0X02_0X01.SOC = 0x03; | |||
jTNE_0X02_0X01.Speed = 58; | |||
jTNE_0X02_0X01.Stall = 0x02; | |||
jTNE_0X02_0X01.TotalDis = 6666; | |||
jTNE_0X02_0X01.TotalTemp = 99; | |||
jTNE_0X02_0X01.TotalVoltage = 100; | |||
var hex = JTNESerializer.Serialize(jTNE_0X02_0X01).ToHexString(); | |||
Assert.Equal("01040507003A00001A0A00640063030602007B0203", hex); | |||
} | |||
[Fact] | |||
public void Test2() | |||
{ | |||
var data = "01040507003A00001A0A00640063030602007B0203".ToHexBytes(); | |||
JTNE_0x02_0x01 jTNE_0X02_0X01 = JTNESerializer.Deserialize<JTNE_0x02_0x01>(data); | |||
Assert.Equal(JTNE_0x02_Body.JTNE_0x02_0x01, jTNE_0X02_0X01.TypeCode); | |||
Assert.Equal(0x02, jTNE_0X02_0X01.Accelerator); | |||
Assert.Equal(0x03, jTNE_0X02_0X01.Brakes); | |||
Assert.Equal(0x04, jTNE_0X02_0X01.CarStatus); | |||
Assert.Equal(0x05, jTNE_0X02_0X01.ChargeStatus); | |||
Assert.Equal(0x06, jTNE_0X02_0X01.DCStatus); | |||
Assert.Equal(0x07, jTNE_0X02_0X01.OperationMode); | |||
Assert.Equal(123, jTNE_0X02_0X01.Resistance); | |||
Assert.Equal(0x03, jTNE_0X02_0X01.SOC); | |||
Assert.Equal(58, jTNE_0X02_0X01.Speed); | |||
Assert.Equal(0x02, jTNE_0X02_0X01.Stall); | |||
Assert.Equal((uint)6666, jTNE_0X02_0X01.TotalDis); | |||
Assert.Equal(99, jTNE_0X02_0X01.TotalTemp); | |||
Assert.Equal(100, jTNE_0X02_0X01.TotalVoltage); | |||
} | |||
} | |||
} |
@@ -0,0 +1,68 @@ | |||
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_0x02_0x02Test | |||
{ | |||
[Fact] | |||
public void Test1() | |||
{ | |||
JTNE_0x02_0x02 jTNE_0X02_0X02 = new JTNE_0x02_0x02(); | |||
jTNE_0X02_0X02.Electricals = new List<Metadata.Electrical>(); | |||
Metadata.Electrical electrical1 = new Metadata.Electrical(); | |||
electrical1.ElControlTemp = 0x01; | |||
electrical1.ElCurrent = 100; | |||
electrical1.ElNo = 0x01; | |||
electrical1.ElSpeed = 65; | |||
electrical1.ElStatus = 0x02; | |||
electrical1.ElTemp = 0x03; | |||
electrical1.ElTorque = 55; | |||
electrical1.ElVoltage = 236; | |||
Metadata.Electrical electrical2 = new Metadata.Electrical(); | |||
electrical2.ElControlTemp = 0x02; | |||
electrical2.ElCurrent = 101; | |||
electrical2.ElNo = 0x02; | |||
electrical2.ElSpeed = 66; | |||
electrical2.ElStatus = 0x03; | |||
electrical2.ElTemp = 0x05; | |||
electrical2.ElTorque = 566; | |||
electrical2.ElVoltage = 2136; | |||
jTNE_0X02_0X02.Electricals.Add(electrical1); | |||
jTNE_0X02_0X02.Electricals.Add(electrical2); | |||
var hex = JTNESerializer.Serialize(jTNE_0X02_0X02).ToHexString(); | |||
Assert.Equal("0202010201004100370300EC0064020302004202360508580065", hex); | |||
} | |||
[Fact] | |||
public void Test2() | |||
{ | |||
var data = "0202010201004100370300EC0064020302004202360508580065".ToHexBytes(); | |||
JTNE_0x02_0x02 jTNE_0X02_0X02 = JTNESerializer.Deserialize<JTNE_0x02_0x02>(data); | |||
Assert.Equal(JTNE_0x02_Body.JTNE_0x02_0x02, jTNE_0X02_0X02.TypeCode); | |||
Assert.Equal(2, jTNE_0X02_0X02.ElectricalCount); | |||
Metadata.Electrical electrical1 = jTNE_0X02_0X02.Electricals[0]; | |||
Assert.Equal(0x01, electrical1.ElControlTemp); | |||
Assert.Equal(100, electrical1.ElCurrent); | |||
Assert.Equal(0x01, electrical1.ElNo); | |||
Assert.Equal(65, electrical1.ElSpeed); | |||
Assert.Equal(0x02, electrical1.ElStatus); | |||
Assert.Equal(0x03, electrical1.ElTemp); | |||
Assert.Equal(55, electrical1.ElTorque); | |||
Assert.Equal(236, electrical1.ElVoltage); | |||
Metadata.Electrical electrical2 = jTNE_0X02_0X02.Electricals[1]; | |||
Assert.Equal(0x02, electrical2.ElControlTemp); | |||
Assert.Equal(101, electrical2.ElCurrent); | |||
Assert.Equal(0x02, electrical2.ElNo); | |||
Assert.Equal(66, electrical2.ElSpeed); | |||
Assert.Equal(0x03, electrical2.ElStatus); | |||
Assert.Equal(0x05, electrical2.ElTemp); | |||
Assert.Equal(566, electrical2.ElTorque); | |||
Assert.Equal(2136, electrical2.ElVoltage); | |||
} | |||
} | |||
} |
@@ -0,0 +1,53 @@ | |||
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_0x02_0x03Test | |||
{ | |||
[Fact] | |||
public void Test1() | |||
{ | |||
JTNE_0x02_0x03 jTNE_0X02_0X03 = new JTNE_0x02_0x03(); | |||
jTNE_0X02_0X03.DCStatus = 0x02; | |||
jTNE_0X02_0X03.FuelBatteryCurrent = 111; | |||
jTNE_0X02_0X03.FuelBatteryVoltage = 2222; | |||
jTNE_0X02_0X03.FuelConsumptionRate = 3222; | |||
jTNE_0X02_0X03.HydrogenSystemMaxConcentrations = 6666; | |||
jTNE_0X02_0X03.HydrogenSystemMaxConcentrationsNo = 0x56; | |||
jTNE_0X02_0X03.HydrogenSystemMaxPressure = 3336; | |||
jTNE_0X02_0X03.HydrogenSystemMaxPressureNo = 0x65; | |||
jTNE_0X02_0X03.HydrogenSystemMaxTemp = 3355; | |||
jTNE_0X02_0X03.HydrogenSystemMaxTempNo = 0x22; | |||
jTNE_0X02_0X03.Temperatures = new byte[] | |||
{ | |||
0x01,0x02,0x03 | |||
}; | |||
var hex = JTNESerializer.Serialize(jTNE_0X02_0X03).ToHexString(); | |||
Assert.Equal("0308AE006F0C9600030102030D1B221A0A560D086502", hex); | |||
} | |||
[Fact] | |||
public void Test2() | |||
{ | |||
var data = "0308AE006F0C9600030102030D1B221A0A560D086502".ToHexBytes(); | |||
JTNE_0x02_0x03 jTNE_0X02_0X03 = JTNESerializer.Deserialize<JTNE_0x02_0x03>(data); | |||
Assert.Equal(JTNE_0x02_Body.JTNE_0x02_0x03, jTNE_0X02_0X03.TypeCode); | |||
Assert.Equal(0x02, jTNE_0X02_0X03.DCStatus); | |||
Assert.Equal(111, jTNE_0X02_0X03.FuelBatteryCurrent); | |||
Assert.Equal(2222, jTNE_0X02_0X03.FuelBatteryVoltage); | |||
Assert.Equal(3222, jTNE_0X02_0X03.FuelConsumptionRate); | |||
Assert.Equal(6666, jTNE_0X02_0X03.HydrogenSystemMaxConcentrations); | |||
Assert.Equal(0x56, jTNE_0X02_0X03.HydrogenSystemMaxConcentrationsNo); | |||
Assert.Equal(3336, jTNE_0X02_0X03.HydrogenSystemMaxPressure); | |||
Assert.Equal(0x65, jTNE_0X02_0X03.HydrogenSystemMaxPressureNo); | |||
Assert.Equal(3355, jTNE_0X02_0X03.HydrogenSystemMaxTemp); | |||
Assert.Equal(0x22, jTNE_0X02_0X03.HydrogenSystemMaxTempNo); | |||
Assert.Equal(new byte []{ 0x01, 0x02, 0x03 }, jTNE_0X02_0X03.Temperatures); | |||
} | |||
} | |||
} |
@@ -0,0 +1,34 @@ | |||
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_0x02_0x04Test | |||
{ | |||
[Fact] | |||
public void Test1() | |||
{ | |||
JTNE_0x02_0x04 jTNE_0X02_0X04 = new JTNE_0x02_0x04(); | |||
jTNE_0X02_0X04.EngineStatus = 0x01; | |||
jTNE_0X02_0X04.FuelRate = 102; | |||
jTNE_0X02_0X04.Revs = 203; | |||
var hex = JTNESerializer.Serialize(jTNE_0X02_0X04).ToHexString(); | |||
Assert.Equal("040100CB0066", hex); | |||
} | |||
[Fact] | |||
public void Test2() | |||
{ | |||
var data = "040100CB0066".ToHexBytes(); | |||
JTNE_0x02_0x04 jTNE_0X02_0X04 = JTNESerializer.Deserialize<JTNE_0x02_0x04>(data); | |||
Assert.Equal(JTNE_0x02_Body.JTNE_0x02_0x04, jTNE_0X02_0X04.TypeCode); | |||
Assert.Equal(0x01, jTNE_0X02_0X04.EngineStatus); | |||
Assert.Equal(102, jTNE_0X02_0X04.FuelRate); | |||
Assert.Equal(203, jTNE_0X02_0X04.Revs); | |||
} | |||
} | |||
} |
@@ -0,0 +1,34 @@ | |||
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_0x02_0x05Test | |||
{ | |||
[Fact] | |||
public void Test1() | |||
{ | |||
JTNE_0x02_0x05 jTNE_0X02_0X05 = new JTNE_0x02_0x05(); | |||
jTNE_0X02_0X05.Lat = 1233355; | |||
jTNE_0X02_0X05.Lng = 3255555; | |||
jTNE_0X02_0X05.PositioStatus = 0x01; | |||
var hex = JTNESerializer.Serialize(jTNE_0X02_0X05).ToHexString(); | |||
Assert.Equal("05010031AD030012D1CB", hex); | |||
} | |||
[Fact] | |||
public void Test2() | |||
{ | |||
var data = "05010031AD030012D1CB".ToHexBytes(); | |||
JTNE_0x02_0x05 jTNE_0X02_0X05 = JTNESerializer.Deserialize<JTNE_0x02_0x05>(data); | |||
Assert.Equal(JTNE_0x02_Body.JTNE_0x02_0x05, jTNE_0X02_0X05.TypeCode); | |||
Assert.Equal((uint)1233355, jTNE_0X02_0X05.Lat); | |||
Assert.Equal((uint)3255555, jTNE_0X02_0X05.Lng); | |||
Assert.Equal(0x01, jTNE_0X02_0X05.PositioStatus); | |||
} | |||
} | |||
} |
@@ -0,0 +1,50 @@ | |||
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_0x02_0x06Test | |||
{ | |||
[Fact] | |||
public void Test1() | |||
{ | |||
JTNE_0x02_0x06 jTNE_0X02_0X06 = new JTNE_0x02_0x06(); | |||
jTNE_0X02_0X06.MaxTempBatteryAssemblyNo = 0x12; | |||
jTNE_0X02_0X06.MaxTempProbeBatteryNo = 0x32; | |||
jTNE_0X02_0X06.MaxTempProbeBatteryValue = 0x42; | |||
jTNE_0X02_0X06.MaxVoltageBatteryAssemblyNo = 0x11; | |||
jTNE_0X02_0X06.MaxVoltageSingleBatteryNo = 0x15; | |||
jTNE_0X02_0X06.MaxVoltageSingleBatteryValue = 123; | |||
jTNE_0X02_0X06.MinTempBatteryAssemblyNo = 0x32; | |||
jTNE_0X02_0X06.MinTempProbeBatteryNo = 0x11; | |||
jTNE_0X02_0X06.MinTempProbeBatteryValue = 0x06; | |||
jTNE_0X02_0X06.MinVoltageBatteryAssemblyNo = 0x07; | |||
jTNE_0X02_0X06.MinVoltageSingleBatteryNo = 0x09; | |||
jTNE_0X02_0X06.MinVoltageSingleBatteryValue = 0x08; | |||
var hex = JTNESerializer.Serialize(jTNE_0X02_0X06).ToHexString(); | |||
Assert.Equal("061115007B07090008321242113206", hex); | |||
} | |||
[Fact] | |||
public void Test2() | |||
{ | |||
var data = "061115007B07090008321242113206".ToHexBytes(); | |||
JTNE_0x02_0x06 jTNE_0X02_0X06 = JTNESerializer.Deserialize<JTNE_0x02_0x06>(data); | |||
Assert.Equal(0x12, jTNE_0X02_0X06.MaxTempBatteryAssemblyNo); | |||
Assert.Equal(0x32, jTNE_0X02_0X06.MaxTempProbeBatteryNo); | |||
Assert.Equal(0x42, jTNE_0X02_0X06.MaxTempProbeBatteryValue); | |||
Assert.Equal(0x11, jTNE_0X02_0X06.MaxVoltageBatteryAssemblyNo); | |||
Assert.Equal(0x15, jTNE_0X02_0X06.MaxVoltageSingleBatteryNo); | |||
Assert.Equal(123, jTNE_0X02_0X06.MaxVoltageSingleBatteryValue); | |||
Assert.Equal(0x11, jTNE_0X02_0X06.MinTempProbeBatteryNo); | |||
Assert.Equal(0x06, jTNE_0X02_0X06.MinTempProbeBatteryValue); | |||
Assert.Equal(0x07, jTNE_0X02_0X06.MinVoltageBatteryAssemblyNo); | |||
Assert.Equal(0x09, jTNE_0X02_0X06.MinVoltageSingleBatteryNo); | |||
Assert.Equal(0x08, jTNE_0X02_0X06.MinVoltageSingleBatteryValue); | |||
} | |||
} | |||
} |
@@ -0,0 +1,67 @@ | |||
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_0x02_0x07Test | |||
{ | |||
[Fact] | |||
public void Test1() | |||
{ | |||
JTNE_0x02_0x07 jTNE_0X02_0X07 = new JTNE_0x02_0x07(); | |||
jTNE_0X02_0X07.AlarmBatteryFlag = 5533; | |||
jTNE_0X02_0X07.AlarmLevel = 0x11; | |||
jTNE_0X02_0X07.AlarmBatteryOthers = new List<uint> | |||
{ | |||
1000,1001,1002 | |||
}; | |||
jTNE_0X02_0X07.AlarmEls = new List<uint> | |||
{ | |||
2000,2001,2002 | |||
}; | |||
jTNE_0X02_0X07.AlarmEngines = new List<uint> | |||
{ | |||
3000,3001,3002 | |||
}; | |||
jTNE_0X02_0X07.AlarmOthers = new List<uint> | |||
{ | |||
4000,4001,4002 | |||
}; | |||
var hex = JTNESerializer.Serialize(jTNE_0X02_0X07).ToHexString(); | |||
Assert.Equal("07110000159D03000003E8000003E9000003EA03000007D0000007D1000007D20300000BB800000BB900000BBA0300000FA000000FA100000FA2", hex); | |||
} | |||
[Fact] | |||
public void Test2() | |||
{ | |||
var data = "07110000159D03000003E8000003E9000003EA03000007D0000007D1000007D20300000BB800000BB900000BBA0300000FA000000FA100000FA2".ToHexBytes(); | |||
JTNE_0x02_0x07 jTNE_0X02_0X07 = JTNESerializer.Deserialize<JTNE_0x02_0x07>(data); | |||
Assert.Equal(JTNE_0x02_Body.JTNE_0x02_0x07, jTNE_0X02_0X07.TypeCode); | |||
Assert.Equal(0x11, jTNE_0X02_0X07.AlarmLevel); | |||
Assert.Equal(3, jTNE_0X02_0X07.AlarmBatteryOthers.Count); | |||
Assert.Equal(new List<uint> | |||
{ | |||
1000,1001,1002 | |||
}, jTNE_0X02_0X07.AlarmBatteryOthers); | |||
Assert.Equal(3, jTNE_0X02_0X07.AlarmEls.Count); | |||
Assert.Equal(new List<uint> | |||
{ | |||
2000,2001,2002 | |||
}, jTNE_0X02_0X07.AlarmEls); | |||
Assert.Equal(3, jTNE_0X02_0X07.AlarmEngines.Count); | |||
Assert.Equal(new List<uint> | |||
{ | |||
3000,3001,3002 | |||
}, jTNE_0X02_0X07.AlarmEngines); | |||
Assert.Equal(3, jTNE_0X02_0X07.AlarmOthers.Count); | |||
Assert.Equal(new List<uint> | |||
{ | |||
4000,4001,4002 | |||
}, jTNE_0X02_0X07.AlarmOthers); | |||
} | |||
} | |||
} |
@@ -0,0 +1,74 @@ | |||
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_0x02_0x08Test | |||
{ | |||
[Fact] | |||
public void Test1() | |||
{ | |||
JTNE_0x02_0x08 jTNE_0X02_0X08 = new JTNE_0x02_0x08(); | |||
jTNE_0X02_0X08.BatteryAssemblies = new List<Metadata.BatteryAssembly>(); | |||
Metadata.BatteryAssembly batteryAssembly1 = new Metadata.BatteryAssembly(); | |||
batteryAssembly1.BatteryAssemblyCurrent = 123; | |||
batteryAssembly1.BatteryAssemblyNo = 0x01; | |||
batteryAssembly1.BatteryAssemblyVoltage = 0x02; | |||
batteryAssembly1.SingleBatteryCount = 55; | |||
batteryAssembly1.ThisSingleBatteryBeginCount = 0x02; | |||
batteryAssembly1.ThisSingleBatteryBeginNo = 111; | |||
batteryAssembly1.SingleBatteryVoltages = new List<ushort> { | |||
111,222,333 | |||
}; | |||
Metadata.BatteryAssembly batteryAssembly2 = new Metadata.BatteryAssembly(); | |||
batteryAssembly2.BatteryAssemblyCurrent = 1234; | |||
batteryAssembly2.BatteryAssemblyNo = 0x03; | |||
batteryAssembly2.BatteryAssemblyVoltage = 0x05; | |||
batteryAssembly2.SingleBatteryCount = 66; | |||
batteryAssembly2.ThisSingleBatteryBeginCount = 0x02; | |||
batteryAssembly2.ThisSingleBatteryBeginNo = 222; | |||
batteryAssembly2.SingleBatteryVoltages = new List<ushort> { | |||
444,555,666 | |||
}; | |||
jTNE_0X02_0X08.BatteryAssemblies.Add(batteryAssembly1); | |||
jTNE_0X02_0X08.BatteryAssemblies.Add(batteryAssembly2); | |||
var hex = JTNESerializer.Serialize(jTNE_0X02_0X08).ToHexString(); | |||
Assert.Equal("0802010002007B0037006F03006F00DE014D03000504D2004200DE0301BC022B029A", hex); | |||
} | |||
[Fact] | |||
public void Test2() | |||
{ | |||
var data = "0802010002007B0037006F03006F00DE014D03000504D2004200DE0301BC022B029A".ToHexBytes(); | |||
JTNE_0x02_0x08 jTNE_0X02_0X08 = JTNESerializer.Deserialize<JTNE_0x02_0x08>(data); | |||
Assert.Equal(JTNE_0x02_Body.JTNE_0x02_0x08, jTNE_0X02_0X08.TypeCode); | |||
Assert.Equal(2, jTNE_0X02_0X08.BatteryAssemblyCount); | |||
Metadata.BatteryAssembly batteryAssembly1 = jTNE_0X02_0X08.BatteryAssemblies[0]; | |||
Assert.Equal(123, batteryAssembly1.BatteryAssemblyCurrent); | |||
Assert.Equal(0x01, batteryAssembly1.BatteryAssemblyNo); | |||
Assert.Equal(0x02, batteryAssembly1.BatteryAssemblyVoltage); | |||
Assert.Equal(55, batteryAssembly1.SingleBatteryCount); | |||
Assert.Equal(111, batteryAssembly1.ThisSingleBatteryBeginNo); | |||
Assert.Equal(3, batteryAssembly1.ThisSingleBatteryBeginCount); | |||
Assert.Equal(new List<ushort> { | |||
111,222,333 | |||
}, batteryAssembly1.SingleBatteryVoltages); | |||
Metadata.BatteryAssembly batteryAssembly2 = jTNE_0X02_0X08.BatteryAssemblies[1]; | |||
Assert.Equal(1234, batteryAssembly2.BatteryAssemblyCurrent); | |||
Assert.Equal(0x03, batteryAssembly2.BatteryAssemblyNo); | |||
Assert.Equal(0x05, batteryAssembly2.BatteryAssemblyVoltage); | |||
Assert.Equal(66, batteryAssembly2.SingleBatteryCount); | |||
Assert.Equal(222, batteryAssembly2.ThisSingleBatteryBeginNo); | |||
Assert.Equal(3, batteryAssembly2.ThisSingleBatteryBeginCount); | |||
Assert.Equal(new List<ushort> { | |||
444,555,666 | |||
}, batteryAssembly2.SingleBatteryVoltages); | |||
} | |||
} | |||
} |
@@ -0,0 +1,63 @@ | |||
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_0x02_0x09Test | |||
{ | |||
[Fact] | |||
public void Test1() | |||
{ | |||
JTNE_0x02_0x09 jTNE_0X02_0X09 = new JTNE_0x02_0x09(); | |||
jTNE_0X02_0X09.BatteryTemperatures = new List<Metadata.BatteryTemperature>(); | |||
Metadata.BatteryTemperature batteryTemperature1 = new Metadata.BatteryTemperature(); | |||
batteryTemperature1.BatteryAssemblyNo = 0x01; | |||
batteryTemperature1.Temperatures = new byte[] | |||
{ | |||
0x01,0x02,0x03,0x04 | |||
}; | |||
Metadata.BatteryTemperature batteryTemperature2 = new Metadata.BatteryTemperature(); | |||
batteryTemperature2.BatteryAssemblyNo = 0x02; | |||
batteryTemperature2.Temperatures = new byte[] | |||
{ | |||
0x05,0x06,0x07,0x08 | |||
}; | |||
jTNE_0X02_0X09.BatteryTemperatures.Add(batteryTemperature1); | |||
jTNE_0X02_0X09.BatteryTemperatures.Add(batteryTemperature2); | |||
var hex = JTNESerializer.Serialize(jTNE_0X02_0X09).ToHexString(); | |||
Assert.Equal("09020100040102030402000405060708", hex); | |||
} | |||
[Fact] | |||
public void Test2() | |||
{ | |||
var data = "09020100040102030402000405060708".ToHexBytes(); | |||
JTNE_0x02_0x09 jTNE_0X02_0X09 = JTNESerializer.Deserialize<JTNE_0x02_0x09>(data); | |||
Assert.Equal(JTNE_0x02_Body.JTNE_0x02_0x09, jTNE_0X02_0X09.TypeCode); | |||
Assert.Equal(2, jTNE_0X02_0X09.BatteryTemperatureCount); | |||
Metadata.BatteryTemperature batteryTemperature1 = jTNE_0X02_0X09.BatteryTemperatures[0]; | |||
Assert.Equal(0x01, batteryTemperature1.BatteryAssemblyNo); | |||
Assert.Equal(4, batteryTemperature1.TemperatureProbeCount); | |||
Assert.Equal(new byte[] | |||
{ | |||
0x01,0x02,0x03,0x04 | |||
}, batteryTemperature1.Temperatures); | |||
Metadata.BatteryTemperature batteryTemperature2 = jTNE_0X02_0X09.BatteryTemperatures[1]; | |||
Assert.Equal(0x02, batteryTemperature2.BatteryAssemblyNo); | |||
Assert.Equal(4, batteryTemperature2.TemperatureProbeCount); | |||
Assert.Equal(new byte[] | |||
{ | |||
0x05,0x06,0x07,0x08 | |||
}, batteryTemperature2.Temperatures); | |||
} | |||
} | |||
} |
@@ -0,0 +1,56 @@ | |||
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_0x02_0x02_Formatter : IJTNEFormatter<JTNE_0x02_0x02> | |||
{ | |||
public JTNE_0x02_0x02 Deserialize(ReadOnlySpan<byte> bytes, out int readSize) | |||
{ | |||
int offset = 0; | |||
JTNE_0x02_0x02 jTNE_0X02_0X02 = new JTNE_0x02_0x02(); | |||
jTNE_0X02_0X02.TypeCode = JTNEBinaryExtensions.ReadByteLittle(bytes, ref offset); | |||
jTNE_0X02_0X02.ElectricalCount = JTNEBinaryExtensions.ReadByteLittle(bytes, ref offset); | |||
jTNE_0X02_0X02.Electricals = new List<Metadata.Electrical>(); | |||
for (var i=0;i < jTNE_0X02_0X02.ElectricalCount; i++) | |||
{ | |||
Metadata.Electrical electrical = new Metadata.Electrical(); | |||
electrical.ElNo = JTNEBinaryExtensions.ReadByteLittle(bytes, ref offset); | |||
electrical.ElStatus = JTNEBinaryExtensions.ReadByteLittle(bytes, ref offset); | |||
electrical.ElControlTemp = JTNEBinaryExtensions.ReadByteLittle(bytes, ref offset); | |||
electrical.ElSpeed = JTNEBinaryExtensions.ReadUInt16Little(bytes, ref offset); | |||
electrical.ElTorque = JTNEBinaryExtensions.ReadUInt16Little(bytes, ref offset); | |||
electrical.ElTemp = JTNEBinaryExtensions.ReadByteLittle(bytes, ref offset); | |||
electrical.ElVoltage = JTNEBinaryExtensions.ReadUInt16Little(bytes, ref offset); | |||
electrical.ElCurrent = JTNEBinaryExtensions.ReadUInt16Little(bytes, ref offset); | |||
jTNE_0X02_0X02.Electricals.Add(electrical); | |||
} | |||
readSize = offset; | |||
return jTNE_0X02_0X02; | |||
} | |||
public int Serialize(ref byte[] bytes, int offset, JTNE_0x02_0x02 value) | |||
{ | |||
offset += JTNEBinaryExtensions.WriteByteLittle(bytes, offset, value.TypeCode); | |||
if(value.Electricals!=null && value.Electricals.Count > 0) | |||
{ | |||
offset += JTNEBinaryExtensions.WriteByteLittle(bytes, offset, (byte)value.Electricals.Count); | |||
foreach(var item in value.Electricals) | |||
{ | |||
offset += JTNEBinaryExtensions.WriteByteLittle(bytes, offset, item.ElNo); | |||
offset += JTNEBinaryExtensions.WriteByteLittle(bytes, offset, item.ElStatus); | |||
offset += JTNEBinaryExtensions.WriteByteLittle(bytes, offset, item.ElControlTemp); | |||
offset += JTNEBinaryExtensions.WriteUInt16Little(bytes, offset, item.ElSpeed); | |||
offset += JTNEBinaryExtensions.WriteUInt16Little(bytes, offset, item.ElTorque); | |||
offset += JTNEBinaryExtensions.WriteByteLittle(bytes, offset, item.ElTemp); | |||
offset += JTNEBinaryExtensions.WriteUInt16Little(bytes, offset, item.ElVoltage); | |||
offset += JTNEBinaryExtensions.WriteUInt16Little(bytes, offset, item.ElCurrent); | |||
} | |||
} | |||
return offset; | |||
} | |||
} | |||
} |
@@ -0,0 +1,50 @@ | |||
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_0x02_0x03_Formatter : IJTNEFormatter<JTNE_0x02_0x03> | |||
{ | |||
public JTNE_0x02_0x03 Deserialize(ReadOnlySpan<byte> bytes, out int readSize) | |||
{ | |||
int offset = 0; | |||
JTNE_0x02_0x03 jTNE_0X02_0X03 = new JTNE_0x02_0x03(); | |||
jTNE_0X02_0X03.TypeCode = JTNEBinaryExtensions.ReadByteLittle(bytes, ref offset); | |||
jTNE_0X02_0X03.FuelBatteryVoltage = JTNEBinaryExtensions.ReadUInt16Little(bytes, ref offset); | |||
jTNE_0X02_0X03.FuelBatteryCurrent = JTNEBinaryExtensions.ReadUInt16Little(bytes, ref offset); | |||
jTNE_0X02_0X03.FuelConsumptionRate = JTNEBinaryExtensions.ReadUInt16Little(bytes, ref offset); | |||
jTNE_0X02_0X03.TemperatureProbeCount = JTNEBinaryExtensions.ReadUInt16Little(bytes, ref offset); | |||
jTNE_0X02_0X03.Temperatures = JTNEBinaryExtensions.ReadBytesLittle(bytes, ref offset, jTNE_0X02_0X03.TemperatureProbeCount); | |||
jTNE_0X02_0X03.HydrogenSystemMaxTemp = JTNEBinaryExtensions.ReadUInt16Little(bytes, ref offset); | |||
jTNE_0X02_0X03.HydrogenSystemMaxTempNo = JTNEBinaryExtensions.ReadByteLittle(bytes, ref offset); | |||
jTNE_0X02_0X03.HydrogenSystemMaxConcentrations = JTNEBinaryExtensions.ReadUInt16Little(bytes, ref offset); | |||
jTNE_0X02_0X03.HydrogenSystemMaxConcentrationsNo = JTNEBinaryExtensions.ReadByteLittle(bytes, ref offset); | |||
jTNE_0X02_0X03.HydrogenSystemMaxPressure = JTNEBinaryExtensions.ReadUInt16Little(bytes, ref offset); | |||
jTNE_0X02_0X03.HydrogenSystemMaxPressureNo = JTNEBinaryExtensions.ReadByteLittle(bytes, ref offset); | |||
jTNE_0X02_0X03.DCStatus = JTNEBinaryExtensions.ReadByteLittle(bytes, ref offset); | |||
readSize = offset; | |||
return jTNE_0X02_0X03; | |||
} | |||
public int Serialize(ref byte[] bytes, int offset, JTNE_0x02_0x03 value) | |||
{ | |||
offset += JTNEBinaryExtensions.WriteByteLittle(bytes, offset, value.TypeCode); | |||
offset += JTNEBinaryExtensions.WriteUInt16Little(bytes, offset, value.FuelBatteryVoltage); | |||
offset += JTNEBinaryExtensions.WriteUInt16Little(bytes, offset, value.FuelBatteryCurrent); | |||
offset += JTNEBinaryExtensions.WriteUInt16Little(bytes, offset, value.FuelConsumptionRate); | |||
offset += JTNEBinaryExtensions.WriteUInt16Little(bytes, offset, (ushort)value.Temperatures.Length); | |||
offset += JTNEBinaryExtensions.WriteBytesLittle(bytes, offset, value.Temperatures); | |||
offset += JTNEBinaryExtensions.WriteUInt16Little(bytes, offset, value.HydrogenSystemMaxTemp); | |||
offset += JTNEBinaryExtensions.WriteByteLittle(bytes, offset, value.HydrogenSystemMaxTempNo); | |||
offset += JTNEBinaryExtensions.WriteUInt16Little(bytes, offset, value.HydrogenSystemMaxConcentrations); | |||
offset += JTNEBinaryExtensions.WriteByteLittle(bytes, offset, value.HydrogenSystemMaxConcentrationsNo); | |||
offset += JTNEBinaryExtensions.WriteUInt16Little(bytes, offset, value.HydrogenSystemMaxPressure); | |||
offset += JTNEBinaryExtensions.WriteByteLittle(bytes, offset, value.HydrogenSystemMaxPressureNo); | |||
offset += JTNEBinaryExtensions.WriteByteLittle(bytes, offset, value.DCStatus); | |||
return offset; | |||
} | |||
} | |||
} |
@@ -0,0 +1,32 @@ | |||
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_0x02_0x04_Formatter : IJTNEFormatter<JTNE_0x02_0x04> | |||
{ | |||
public JTNE_0x02_0x04 Deserialize(ReadOnlySpan<byte> bytes, out int readSize) | |||
{ | |||
int offset = 0; | |||
JTNE_0x02_0x04 jTNE_0X02_0X04 = new JTNE_0x02_0x04(); | |||
jTNE_0X02_0X04.TypeCode = JTNEBinaryExtensions.ReadByteLittle(bytes, ref offset); | |||
jTNE_0X02_0X04.EngineStatus = JTNEBinaryExtensions.ReadByteLittle(bytes, ref offset); | |||
jTNE_0X02_0X04.Revs = JTNEBinaryExtensions.ReadUInt16Little(bytes, ref offset); | |||
jTNE_0X02_0X04.FuelRate = JTNEBinaryExtensions.ReadUInt16Little(bytes, ref offset); | |||
readSize = offset; | |||
return jTNE_0X02_0X04; | |||
} | |||
public int Serialize(ref byte[] bytes, int offset, JTNE_0x02_0x04 value) | |||
{ | |||
offset += JTNEBinaryExtensions.WriteByteLittle(bytes, offset, value.TypeCode); | |||
offset += JTNEBinaryExtensions.WriteByteLittle(bytes, offset, value.EngineStatus); | |||
offset += JTNEBinaryExtensions.WriteUInt16Little(bytes, offset, value.Revs); | |||
offset += JTNEBinaryExtensions.WriteUInt16Little(bytes, offset, value.FuelRate); | |||
return offset; | |||
} | |||
} | |||
} |
@@ -0,0 +1,32 @@ | |||
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_0x02_0x05_Formatter : IJTNEFormatter<JTNE_0x02_0x05> | |||
{ | |||
public JTNE_0x02_0x05 Deserialize(ReadOnlySpan<byte> bytes, out int readSize) | |||
{ | |||
int offset = 0; | |||
JTNE_0x02_0x05 jTNE_0X02_0X05 = new JTNE_0x02_0x05(); | |||
jTNE_0X02_0X05.TypeCode = JTNEBinaryExtensions.ReadByteLittle(bytes, ref offset); | |||
jTNE_0X02_0X05.PositioStatus = JTNEBinaryExtensions.ReadByteLittle(bytes, ref offset); | |||
jTNE_0X02_0X05.Lng = JTNEBinaryExtensions.ReadUInt32Little(bytes, ref offset); | |||
jTNE_0X02_0X05.Lat = JTNEBinaryExtensions.ReadUInt32Little(bytes, ref offset); | |||
readSize = offset; | |||
return jTNE_0X02_0X05; | |||
} | |||
public int Serialize(ref byte[] bytes, int offset, JTNE_0x02_0x05 value) | |||
{ | |||
offset += JTNEBinaryExtensions.WriteByteLittle(bytes, offset, value.TypeCode); | |||
offset += JTNEBinaryExtensions.WriteByteLittle(bytes, offset, value.PositioStatus); | |||
offset += JTNEBinaryExtensions.WriteUInt32Little(bytes, offset, value.Lng); | |||
offset += JTNEBinaryExtensions.WriteUInt32Little(bytes, offset, value.Lat); | |||
return offset; | |||
} | |||
} | |||
} |
@@ -0,0 +1,50 @@ | |||
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_0x02_0x06_Formatter : IJTNEFormatter<JTNE_0x02_0x06> | |||
{ | |||
public JTNE_0x02_0x06 Deserialize(ReadOnlySpan<byte> bytes, out int readSize) | |||
{ | |||
int offset = 0; | |||
JTNE_0x02_0x06 jTNE_0X02_0X06 = new JTNE_0x02_0x06(); | |||
jTNE_0X02_0X06.TypeCode = JTNEBinaryExtensions.ReadByteLittle(bytes, ref offset); | |||
jTNE_0X02_0X06.MaxVoltageBatteryAssemblyNo = JTNEBinaryExtensions.ReadByteLittle(bytes, ref offset); | |||
jTNE_0X02_0X06.MaxVoltageSingleBatteryNo = JTNEBinaryExtensions.ReadByteLittle(bytes, ref offset); | |||
jTNE_0X02_0X06.MaxVoltageSingleBatteryValue = JTNEBinaryExtensions.ReadUInt16Little(bytes, ref offset); | |||
jTNE_0X02_0X06.MinVoltageBatteryAssemblyNo = JTNEBinaryExtensions.ReadByteLittle(bytes, ref offset); | |||
jTNE_0X02_0X06.MinVoltageSingleBatteryNo = JTNEBinaryExtensions.ReadByteLittle(bytes, ref offset); | |||
jTNE_0X02_0X06.MinVoltageSingleBatteryValue = JTNEBinaryExtensions.ReadUInt16Little(bytes, ref offset); | |||
jTNE_0X02_0X06.MaxTempProbeBatteryNo = JTNEBinaryExtensions.ReadByteLittle(bytes, ref offset); | |||
jTNE_0X02_0X06.MaxTempBatteryAssemblyNo = JTNEBinaryExtensions.ReadByteLittle(bytes, ref offset); | |||
jTNE_0X02_0X06.MaxTempProbeBatteryValue = JTNEBinaryExtensions.ReadByteLittle(bytes, ref offset); | |||
jTNE_0X02_0X06.MinTempProbeBatteryNo = JTNEBinaryExtensions.ReadByteLittle(bytes, ref offset); | |||
jTNE_0X02_0X06.MinTempBatteryAssemblyNo = JTNEBinaryExtensions.ReadByteLittle(bytes, ref offset); | |||
jTNE_0X02_0X06.MinTempProbeBatteryValue = JTNEBinaryExtensions.ReadByteLittle(bytes, ref offset); | |||
readSize = offset; | |||
return jTNE_0X02_0X06; | |||
} | |||
public int Serialize(ref byte[] bytes, int offset, JTNE_0x02_0x06 value) | |||
{ | |||
offset += JTNEBinaryExtensions.WriteByteLittle(bytes, offset, value.TypeCode); | |||
offset += JTNEBinaryExtensions.WriteByteLittle(bytes, offset, value.MaxVoltageBatteryAssemblyNo); | |||
offset += JTNEBinaryExtensions.WriteByteLittle(bytes, offset, value.MaxVoltageSingleBatteryNo); | |||
offset += JTNEBinaryExtensions.WriteUInt16Little(bytes, offset, value.MaxVoltageSingleBatteryValue); | |||
offset += JTNEBinaryExtensions.WriteByteLittle(bytes, offset, value.MinVoltageBatteryAssemblyNo); | |||
offset += JTNEBinaryExtensions.WriteByteLittle(bytes, offset, value.MinVoltageSingleBatteryNo); | |||
offset += JTNEBinaryExtensions.WriteUInt16Little(bytes, offset, value.MinVoltageSingleBatteryValue); | |||
offset += JTNEBinaryExtensions.WriteByteLittle(bytes, offset, value.MaxTempProbeBatteryNo); | |||
offset += JTNEBinaryExtensions.WriteByteLittle(bytes, offset, value.MaxTempBatteryAssemblyNo); | |||
offset += JTNEBinaryExtensions.WriteByteLittle(bytes, offset, value.MaxTempProbeBatteryValue); | |||
offset += JTNEBinaryExtensions.WriteByteLittle(bytes, offset, value.MinTempProbeBatteryNo); | |||
offset += JTNEBinaryExtensions.WriteByteLittle(bytes, offset, value.MinTempBatteryAssemblyNo); | |||
offset += JTNEBinaryExtensions.WriteByteLittle(bytes, offset, value.MinTempProbeBatteryValue); | |||
return offset; | |||
} | |||
} | |||
} |
@@ -0,0 +1,95 @@ | |||
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_0x02_0x07_Formatter : IJTNEFormatter<JTNE_0x02_0x07> | |||
{ | |||
public JTNE_0x02_0x07 Deserialize(ReadOnlySpan<byte> bytes, out int readSize) | |||
{ | |||
int offset = 0; | |||
JTNE_0x02_0x07 jTNE_0X02_0X07 = new JTNE_0x02_0x07(); | |||
jTNE_0X02_0X07.TypeCode = JTNEBinaryExtensions.ReadByteLittle(bytes, ref offset); | |||
jTNE_0X02_0X07.AlarmLevel = JTNEBinaryExtensions.ReadByteLittle(bytes, ref offset); | |||
jTNE_0X02_0X07.AlarmBatteryFlag = JTNEBinaryExtensions.ReadUInt32Little(bytes, ref offset); | |||
jTNE_0X02_0X07.AlarmBatteryOtherCount = JTNEBinaryExtensions.ReadByteLittle(bytes, ref offset); | |||
jTNE_0X02_0X07.AlarmBatteryOthers = new List<uint>(); | |||
for(int i=0;i< jTNE_0X02_0X07.AlarmBatteryOtherCount; i++) | |||
{ | |||
jTNE_0X02_0X07.AlarmBatteryOthers.Add(JTNEBinaryExtensions.ReadUInt32Little(bytes, ref offset)); | |||
} | |||
jTNE_0X02_0X07.AlarmElCount = JTNEBinaryExtensions.ReadByteLittle(bytes, ref offset); | |||
jTNE_0X02_0X07.AlarmEls = new List<uint>(); | |||
for (int i = 0; i < jTNE_0X02_0X07.AlarmElCount; i++) | |||
{ | |||
jTNE_0X02_0X07.AlarmEls.Add(JTNEBinaryExtensions.ReadUInt32Little(bytes, ref offset)); | |||
} | |||
jTNE_0X02_0X07.AlarmEngineCount = JTNEBinaryExtensions.ReadByteLittle(bytes, ref offset); | |||
jTNE_0X02_0X07.AlarmEngines = new List<uint>(); | |||
for (int i = 0; i < jTNE_0X02_0X07.AlarmEngineCount; i++) | |||
{ | |||
jTNE_0X02_0X07.AlarmEngines.Add(JTNEBinaryExtensions.ReadUInt32Little(bytes, ref offset)); | |||
} | |||
jTNE_0X02_0X07.AlarmOtherCount = JTNEBinaryExtensions.ReadByteLittle(bytes, ref offset); | |||
jTNE_0X02_0X07.AlarmOthers = new List<uint>(); | |||
for (int i = 0; i < jTNE_0X02_0X07.AlarmOtherCount; i++) | |||
{ | |||
jTNE_0X02_0X07.AlarmOthers.Add(JTNEBinaryExtensions.ReadUInt32Little(bytes, ref offset)); | |||
} | |||
readSize = offset; | |||
return jTNE_0X02_0X07; | |||
} | |||
public int Serialize(ref byte[] bytes, int offset, JTNE_0x02_0x07 value) | |||
{ | |||
offset += JTNEBinaryExtensions.WriteByteLittle(bytes, offset, value.TypeCode); | |||
offset += JTNEBinaryExtensions.WriteByteLittle(bytes, offset, value.AlarmLevel); | |||
offset += JTNEBinaryExtensions.WriteUInt32Little(bytes, offset, value.AlarmBatteryFlag); | |||
if(value.AlarmBatteryOthers!=null && value.AlarmBatteryOthers.Count > 0) | |||
{ | |||
offset += JTNEBinaryExtensions.WriteByteLittle(bytes, offset, (byte)value.AlarmBatteryOthers.Count); | |||
foreach (var item in value.AlarmBatteryOthers) | |||
{ | |||
offset += JTNEBinaryExtensions.WriteUInt32Little(bytes, offset, item); | |||
} | |||
} | |||
if (value.AlarmEls != null && value.AlarmEls.Count > 0) | |||
{ | |||
offset += JTNEBinaryExtensions.WriteByteLittle(bytes, offset, (byte)value.AlarmEls.Count); | |||
foreach (var item in value.AlarmEls) | |||
{ | |||
offset += JTNEBinaryExtensions.WriteUInt32Little(bytes, offset, item); | |||
} | |||
} | |||
if (value.AlarmEngines != null && value.AlarmEngines.Count > 0) | |||
{ | |||
offset += JTNEBinaryExtensions.WriteByteLittle(bytes, offset, (byte)value.AlarmEngines.Count); | |||
foreach (var item in value.AlarmEngines) | |||
{ | |||
offset += JTNEBinaryExtensions.WriteUInt32Little(bytes, offset, item); | |||
} | |||
} | |||
if (value.AlarmEngines != null && value.AlarmEngines.Count > 0) | |||
{ | |||
offset += JTNEBinaryExtensions.WriteByteLittle(bytes, offset, (byte)value.AlarmOthers.Count); | |||
foreach (var item in value.AlarmOthers) | |||
{ | |||
offset += JTNEBinaryExtensions.WriteUInt32Little(bytes, offset, item); | |||
} | |||
} | |||
return offset; | |||
} | |||
} | |||
} |
@@ -0,0 +1,64 @@ | |||
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_0x02_0x08_Formatter : IJTNEFormatter<JTNE_0x02_0x08> | |||
{ | |||
public JTNE_0x02_0x08 Deserialize(ReadOnlySpan<byte> bytes, out int readSize) | |||
{ | |||
int offset = 0; | |||
JTNE_0x02_0x08 jTNE_0X02_0X08 = new JTNE_0x02_0x08(); | |||
jTNE_0X02_0X08.TypeCode = JTNEBinaryExtensions.ReadByteLittle(bytes, ref offset); | |||
jTNE_0X02_0X08.BatteryAssemblyCount = JTNEBinaryExtensions.ReadByteLittle(bytes, ref offset); | |||
jTNE_0X02_0X08.BatteryAssemblies = new List<Metadata.BatteryAssembly>(); | |||
for(int i=0;i< jTNE_0X02_0X08.BatteryAssemblyCount; i++) | |||
{ | |||
Metadata.BatteryAssembly batteryAssembly = new Metadata.BatteryAssembly(); | |||
batteryAssembly.BatteryAssemblyNo = JTNEBinaryExtensions.ReadByteLittle(bytes, ref offset); | |||
batteryAssembly.BatteryAssemblyVoltage = JTNEBinaryExtensions.ReadUInt16Little(bytes, ref offset); | |||
batteryAssembly.BatteryAssemblyCurrent = JTNEBinaryExtensions.ReadUInt16Little(bytes, ref offset); | |||
batteryAssembly.SingleBatteryCount = JTNEBinaryExtensions.ReadUInt16Little(bytes, ref offset); | |||
batteryAssembly.ThisSingleBatteryBeginNo = JTNEBinaryExtensions.ReadUInt16Little(bytes, ref offset); | |||
batteryAssembly.ThisSingleBatteryBeginCount = JTNEBinaryExtensions.ReadByteLittle(bytes, ref offset); | |||
batteryAssembly.SingleBatteryVoltages = new List<ushort>(); | |||
for(var j =0;j < batteryAssembly.ThisSingleBatteryBeginCount; j++) | |||
{ | |||
batteryAssembly.SingleBatteryVoltages.Add(JTNEBinaryExtensions.ReadUInt16Little(bytes, ref offset)); | |||
} | |||
jTNE_0X02_0X08.BatteryAssemblies.Add(batteryAssembly); | |||
} | |||
readSize = offset; | |||
return jTNE_0X02_0X08; | |||
} | |||
public int Serialize(ref byte[] bytes, int offset, JTNE_0x02_0x08 value) | |||
{ | |||
offset += JTNEBinaryExtensions.WriteByteLittle(bytes, offset, value.TypeCode); | |||
if (value.BatteryAssemblies!=null && value.BatteryAssemblies.Count > 0) | |||
{ | |||
offset += JTNEBinaryExtensions.WriteByteLittle(bytes, offset, (byte)value.BatteryAssemblies.Count); | |||
foreach (var item in value.BatteryAssemblies) | |||
{ | |||
offset += JTNEBinaryExtensions.WriteByteLittle(bytes, offset, item.BatteryAssemblyNo); | |||
offset += JTNEBinaryExtensions.WriteUInt16Little(bytes, offset, item.BatteryAssemblyVoltage); | |||
offset += JTNEBinaryExtensions.WriteUInt16Little(bytes, offset, item.BatteryAssemblyCurrent); | |||
offset += JTNEBinaryExtensions.WriteUInt16Little(bytes, offset, item.SingleBatteryCount); | |||
offset += JTNEBinaryExtensions.WriteUInt16Little(bytes, offset, item.ThisSingleBatteryBeginNo); | |||
if (item.SingleBatteryVoltages != null && item.SingleBatteryVoltages.Count > 0) | |||
{ | |||
offset += JTNEBinaryExtensions.WriteByteLittle(bytes, offset, (byte)item.SingleBatteryVoltages.Count); | |||
foreach(var item1 in item.SingleBatteryVoltages) | |||
{ | |||
offset += JTNEBinaryExtensions.WriteUInt16Little(bytes, offset, item1); | |||
} | |||
} | |||
} | |||
} | |||
return offset; | |||
} | |||
} | |||
} |
@@ -0,0 +1,49 @@ | |||
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_0x02_0x09_Formatter : IJTNEFormatter<JTNE_0x02_0x09> | |||
{ | |||
public JTNE_0x02_0x09 Deserialize(ReadOnlySpan<byte> bytes, out int readSize) | |||
{ | |||
int offset = 0; | |||
JTNE_0x02_0x09 jTNE_0X02_0X09 = new JTNE_0x02_0x09(); | |||
jTNE_0X02_0X09.TypeCode = JTNEBinaryExtensions.ReadByteLittle(bytes, ref offset); | |||
jTNE_0X02_0X09.BatteryTemperatureCount = JTNEBinaryExtensions.ReadByteLittle(bytes, ref offset); | |||
jTNE_0X02_0X09.BatteryTemperatures = new List<Metadata.BatteryTemperature>(); | |||
for(int i=0;i< jTNE_0X02_0X09.BatteryTemperatureCount; i++) | |||
{ | |||
Metadata.BatteryTemperature batteryTemperature = new Metadata.BatteryTemperature(); | |||
batteryTemperature.BatteryAssemblyNo= JTNEBinaryExtensions.ReadByteLittle(bytes, ref offset); | |||
batteryTemperature.TemperatureProbeCount = JTNEBinaryExtensions.ReadUInt16Little(bytes, ref offset); | |||
batteryTemperature.Temperatures = JTNEBinaryExtensions.ReadBytesLittle(bytes, ref offset, batteryTemperature.TemperatureProbeCount); | |||
jTNE_0X02_0X09.BatteryTemperatures.Add(batteryTemperature); | |||
} | |||
readSize = offset; | |||
return jTNE_0X02_0X09; | |||
} | |||
public int Serialize(ref byte[] bytes, int offset, JTNE_0x02_0x09 value) | |||
{ | |||
offset += JTNEBinaryExtensions.WriteByteLittle(bytes, offset, value.TypeCode); | |||
if(value.BatteryTemperatures!=null && value.BatteryTemperatures.Count > 0) | |||
{ | |||
offset += JTNEBinaryExtensions.WriteByteLittle(bytes, offset, (byte)value.BatteryTemperatures.Count); | |||
foreach (var item in value.BatteryTemperatures) | |||
{ | |||
offset += JTNEBinaryExtensions.WriteByteLittle(bytes, offset, item.BatteryAssemblyNo); | |||
if(item.Temperatures!=null && item.Temperatures.Length > 0) | |||
{ | |||
offset += JTNEBinaryExtensions.WriteUInt16Little(bytes, offset, (byte)item.Temperatures.Length); | |||
offset += JTNEBinaryExtensions.WriteBytesLittle(bytes, offset, item.Temperatures); | |||
} | |||
} | |||
} | |||
return offset; | |||
} | |||
} | |||
} |
@@ -32,4 +32,8 @@ | |||
<PackageReference Include="System.Memory" Version="4.5.2" /> | |||
<PackageReference Include="System.Text.Encoding.CodePages" Version="4.5.1" /> | |||
</ItemGroup> | |||
<ItemGroup> | |||
<Folder Include="Properties\" /> | |||
</ItemGroup> | |||
</Project> |
@@ -8,7 +8,7 @@ namespace JTNE.Protocol | |||
/// </summary> | |||
public static class JTNESerializer | |||
{ | |||
public static byte[] Serialize(JTNEPackage jTNEPackage, int minBufferSize = 1024) | |||
public static byte[] Serialize(JTNEPackage jTNEPackage, int minBufferSize = 256) | |||
{ | |||
return Serialize<JTNEPackage>(jTNEPackage, minBufferSize); | |||
} | |||
@@ -18,7 +18,7 @@ namespace JTNE.Protocol | |||
return Deserialize<JTNEPackage>(bytes); | |||
} | |||
public static byte[] Serialize<T>(T obj, int minBufferSize = 1024) | |||
public static byte[] Serialize<T>(T obj, int minBufferSize = 256) | |||
{ | |||
var formatter = JTNEFormatterExtensions.GetFormatter<T>(); | |||
byte[] buffer = JTNEArrayPool.Rent(minBufferSize); | |||
@@ -19,6 +19,6 @@ namespace JTNE.Protocol.MessageBody | |||
/// <summary> | |||
/// 自定义值 | |||
/// </summary> | |||
public Dictionary<byte, JTNE_0x02_Body> CusotmValues { get; set; } | |||
public Dictionary<byte, byte[]> CusotmValues { get; set; } | |||
} | |||
} |
@@ -12,7 +12,7 @@ namespace JTNE.Protocol.MessageBody | |||
[JTNEFormatter(typeof(JTNE_0x02_0x01_Formatter))] | |||
public class JTNE_0x02_0x01 : JTNE_0x02_Body | |||
{ | |||
public override byte TypeCode { get; set; } = 0x01; | |||
public override byte TypeCode { get; set; } = JTNE_0x02_0x01; | |||
/// <summary> | |||
/// 车辆状态 | |||
@@ -0,0 +1,28 @@ | |||
using System; | |||
using System.Collections.Generic; | |||
using System.Text; | |||
using JTNE.Protocol.Attributes; | |||
using JTNE.Protocol.Formatters.MessageBodyFormatters; | |||
using JTNE.Protocol.Metadata; | |||
namespace JTNE.Protocol.MessageBody | |||
{ | |||
/// <summary> | |||
/// 驱动电机数据 | |||
/// </summary> | |||
[JTNEFormatter(typeof(JTNE_0x02_0x02_Formatter))] | |||
public class JTNE_0x02_0x02 : JTNE_0x02_Body | |||
{ | |||
public override byte TypeCode { get; set; } = JTNE_0x02_0x02; | |||
/// <summary> | |||
/// 电机个数 | |||
/// </summary> | |||
public byte ElectricalCount { get; set; } | |||
/// <summary> | |||
/// 电机信息集合 | |||
/// </summary> | |||
public List<Electrical> Electricals { get; set; } | |||
} | |||
} |
@@ -0,0 +1,107 @@ | |||
using System; | |||
using System.Collections.Generic; | |||
using System.Text; | |||
using JTNE.Protocol.Attributes; | |||
using JTNE.Protocol.Formatters.MessageBodyFormatters; | |||
using JTNE.Protocol.Metadata; | |||
namespace JTNE.Protocol.MessageBody | |||
{ | |||
/// <summary> | |||
/// 燃料电池数据 | |||
/// </summary> | |||
[JTNEFormatter(typeof(JTNE_0x02_0x03_Formatter))] | |||
public class JTNE_0x02_0x03 : JTNE_0x02_Body | |||
{ | |||
public override byte TypeCode { get; set; } = JTNE_0x02_0x03; | |||
/// <summary> | |||
/// 燃料电池电压 | |||
/// 有效值范围:0 - 20000(表示 0V-2000V) | |||
/// 最小计量单元:0.1V | |||
/// 异常:0xFF,0XFE | |||
/// 无效:0xFF,0xFF | |||
/// </summary> | |||
public ushort FuelBatteryVoltage { get; set; } | |||
/// <summary> | |||
/// 燃料电池电流 | |||
/// 有效值范围:0 - 20000(表示 0A- +2000A) | |||
/// 最小计量单元:0.1 A | |||
/// 异常:0xFF,0XFE | |||
/// 无效:0xFF,0xFF | |||
/// </summary> | |||
public ushort FuelBatteryCurrent { get; set; } | |||
/// <summary> | |||
/// 燃料消耗率 | |||
/// 有效值范围:0-60000(表示 0kg/100km - 600kg/100km) | |||
/// 最小计量单元:0.01kg/100km | |||
/// 异常:0xFF,0XFE | |||
/// 无效:0xFF,0xFF | |||
/// </summary> | |||
public ushort FuelConsumptionRate { get; set; } | |||
/// <summary> | |||
/// 燃料电池温度探针总数 | |||
/// N个燃料电池温度探针 | |||
/// 有效值范围:0-65531 | |||
/// 异常:0xFF,0XFE | |||
/// 无效:0xFF,0xFF | |||
/// </summary> | |||
public ushort TemperatureProbeCount { get; set; } | |||
/// <summary> | |||
/// 探针温度值 | |||
/// 有效值范围:0-240(数值偏移量40 ℃,表示-40 ℃ - +200 ℃) | |||
/// 最小计量单元:1 ℃ | |||
/// </summary> | |||
public byte[] Temperatures { get; set; } | |||
/// <summary> | |||
/// 氢系统中最高温度 | |||
/// 有效值范围:0-2400(偏移量40 ℃,表示-40 ℃ - 200 ℃) | |||
/// 最小计量单元:0.1 ℃ | |||
/// 异常:0xFF,0XFE | |||
/// 无效:0xFF,0xFF | |||
/// </summary> | |||
public ushort HydrogenSystemMaxTemp { get; set; } | |||
/// <summary> | |||
/// 氢系统中最高温度探针代号 | |||
/// 有效值范围:1-252 | |||
/// 异常:0XFE | |||
/// 无效:0xFF | |||
/// </summary> | |||
public byte HydrogenSystemMaxTempNo { get; set; } | |||
/// <summary> | |||
/// 氢气最高浓度 | |||
/// 有效值范围:0-60000(表示0 mg/kg - 50000 mg/kg) | |||
/// 最小计量单元:1 mg/kg | |||
/// 异常:0xFF,0XFE | |||
/// 无效:0xFF,0xFF | |||
/// </summary> | |||
public ushort HydrogenSystemMaxConcentrations { get; set; } | |||
/// <summary> | |||
/// 氢气最高浓度传感器代号 | |||
/// 有效值范围:1-252 | |||
/// 异常:0XFE | |||
/// 无效:0xFF | |||
/// </summary> | |||
public byte HydrogenSystemMaxConcentrationsNo { get; set; } | |||
/// <summary> | |||
/// 氢气最高压力 | |||
/// 有效值范围:0-1000(表示0MPa - 100MPa),最小计量单位:0.1MPa | |||
/// </summary> | |||
public ushort HydrogenSystemMaxPressure { get; set; } | |||
/// <summary> | |||
/// 氢气最高压力传感器代号 | |||
/// 有效值访问:1-252 | |||
/// 异常:0xFE | |||
/// 无效:0xFF | |||
/// </summary> | |||
public byte HydrogenSystemMaxPressureNo { get; set; } | |||
/// <summary> | |||
/// 高压DC/DC状态 | |||
/// 0x01:工作 | |||
/// 0x02:断开 | |||
/// 0xFE:表示异常 | |||
/// 0xFF:表示无效 | |||
/// </summary> | |||
public byte DCStatus { get; set; } | |||
} | |||
} |
@@ -0,0 +1,43 @@ | |||
using System; | |||
using System.Collections.Generic; | |||
using System.Text; | |||
using JTNE.Protocol.Attributes; | |||
using JTNE.Protocol.Formatters.MessageBodyFormatters; | |||
using JTNE.Protocol.Metadata; | |||
namespace JTNE.Protocol.MessageBody | |||
{ | |||
/// <summary> | |||
/// 发动机数据 | |||
/// </summary> | |||
[JTNEFormatter(typeof(JTNE_0x02_0x04_Formatter))] | |||
public class JTNE_0x02_0x04 : JTNE_0x02_Body | |||
{ | |||
public override byte TypeCode { get; set; } = JTNE_0x02_0x04; | |||
/// <summary> | |||
/// 发动机状态 | |||
/// 0x01:启动状态 | |||
/// 0x02:关闭状态 | |||
/// 0xFE:异常 | |||
/// 0xFF:无效 | |||
/// </summary> | |||
public byte EngineStatus { get; set; } | |||
/// <summary> | |||
/// 曲轴转速 | |||
/// 有效范围:0-60000(表示0 r/min-60000 r/min) | |||
/// 最小计量单元:1 r/min | |||
/// 异常:0xFF,0XFE | |||
/// 无效:0xFF,0xFF | |||
/// </summary> | |||
public ushort Revs { get; set; } | |||
/// <summary> | |||
/// 燃料消耗率 | |||
/// 有效值范围:0-60000(表示0L/100km - 600L/100km) | |||
/// 最小计量单元:0.01L/km | |||
/// 异常:0xFF,0XFE | |||
/// 无效:0xFF,0xFF | |||
/// </summary> | |||
public ushort FuelRate { get; set; } | |||
} | |||
} |
@@ -0,0 +1,37 @@ | |||
using System; | |||
using System.Collections.Generic; | |||
using System.Text; | |||
using JTNE.Protocol.Attributes; | |||
using JTNE.Protocol.Formatters.MessageBodyFormatters; | |||
using JTNE.Protocol.Metadata; | |||
namespace JTNE.Protocol.MessageBody | |||
{ | |||
/// <summary> | |||
/// 车辆位置数据 | |||
/// </summary> | |||
[JTNEFormatter(typeof(JTNE_0x02_0x05_Formatter))] | |||
public class JTNE_0x02_0x05 : JTNE_0x02_Body | |||
{ | |||
public override byte TypeCode { get; set; } = JTNE_0x02_0x05; | |||
/// <summary> | |||
/// 定位状态 | |||
/// 0位:0:有效定位;1:无效定位(当数据通信正常,而不能获取定位信息时,发送最后一次有效定位信息,并将定位状态置为无效。) | |||
/// 1位:0:北纬;1:南纬 | |||
/// 2位:0:东经;1:西经 | |||
/// 3-7位:保留 | |||
/// </summary> | |||
public byte PositioStatus { get; set; } | |||
/// <summary> | |||
/// 经度 | |||
/// 以度位单位的经度值乘以10^6,精确到百万分之一度 | |||
/// </summary> | |||
public uint Lng { get; set; } | |||
/// <summary> | |||
/// 纬度 | |||
/// 以度位单位的纬度值乘以10^6,精确到百万分之一度 | |||
/// </summary> | |||
public uint Lat { get; set; } | |||
} | |||
} |
@@ -0,0 +1,97 @@ | |||
using System; | |||
using System.Collections.Generic; | |||
using System.Text; | |||
using JTNE.Protocol.Attributes; | |||
using JTNE.Protocol.Formatters.MessageBodyFormatters; | |||
using JTNE.Protocol.Metadata; | |||
namespace JTNE.Protocol.MessageBody | |||
{ | |||
/// <summary> | |||
/// 极值数据 | |||
/// </summary> | |||
[JTNEFormatter(typeof(JTNE_0x02_0x06_Formatter))] | |||
public class JTNE_0x02_0x06 : JTNE_0x02_Body | |||
{ | |||
public override byte TypeCode { get; set; } = JTNE_0x02_0x06; | |||
/// <summary> | |||
/// 最高电压电池总成号 | |||
/// 有效值范围:1-250 | |||
/// 异常:0XFE | |||
/// 无效:0xFF | |||
/// </summary> | |||
public byte MaxVoltageBatteryAssemblyNo { get; set; } | |||
/// <summary> | |||
/// 最高电压电池单体代号 | |||
/// 有效值范围:1-250 | |||
/// 异常:0XFE | |||
/// 无效:0xFF | |||
/// </summary> | |||
public byte MaxVoltageSingleBatteryNo { get; set; } | |||
/// <summary> | |||
/// 电池单体电压最高值 | |||
/// 有效值范围:0-15000(表示0V - 15V) | |||
/// 最小计量单元:0.001V | |||
/// 异常:0xFF,0XFE | |||
/// 无效:0xFF,0xFF | |||
/// </summary> | |||
public ushort MaxVoltageSingleBatteryValue { get; set; } | |||
/// <summary> | |||
/// 最低电压电池子系统号 | |||
/// 有效值范围:1-250 | |||
/// 异常:0XFE | |||
/// 无效:0xFF | |||
/// </summary> | |||
public byte MinVoltageBatteryAssemblyNo { get; set; } | |||
/// <summary> | |||
/// 最低电压电池单体代号 | |||
/// 有效值范围:1-250 | |||
/// 异常:0XFE | |||
/// 无效:0xFF | |||
/// </summary> | |||
public byte MinVoltageSingleBatteryNo { get; set; } | |||
/// <summary> | |||
/// 最低单体电压最低值 | |||
/// 有效值范围:0-15000(表示0V - 15V) | |||
/// 最小计量单元:0.001V | |||
/// 异常:0xFF,0XFE | |||
/// 无效:0xFF,0xFF | |||
/// </summary> | |||
public ushort MinVoltageSingleBatteryValue { get; set; } | |||
/// <summary> | |||
/// 蓄电池中最高温度子系统号 | |||
/// 有效值范围:1-250 | |||
/// 异常:0XFE | |||
/// 无效:0xFF | |||
/// </summary> | |||
public byte MaxTempProbeBatteryNo { get; set; } | |||
/// <summary> | |||
/// 蓄电池中最高温度探针序号 | |||
/// 有效值范围:1-250 | |||
/// 异常:0XFE | |||
/// 无效:0xFF | |||
/// </summary> | |||
public byte MaxTempBatteryAssemblyNo { get; set; } | |||
/// <summary> | |||
/// 最高温度值 | |||
/// 有效值范围:0-250(数值偏移量40℃,表示-40℃ - +210℃) | |||
/// 最小计量单元:1℃ | |||
/// 异常:0XFE | |||
/// 无效:0xFF | |||
/// </summary> | |||
public byte MaxTempProbeBatteryValue { get; set; } | |||
/// <summary> | |||
/// 最低温度子系统号 | |||
/// </summary> | |||
public byte MinTempProbeBatteryNo { get; set; } | |||
/// <summary> | |||
/// 蓄电池中最低温度探针序号 | |||
/// </summary> | |||
public byte MinTempBatteryAssemblyNo { get; set; } | |||
/// <summary> | |||
/// 最低温度值 | |||
/// </summary> | |||
public byte MinTempProbeBatteryValue { get; set; } | |||
} | |||
} |
@@ -0,0 +1,58 @@ | |||
using System; | |||
using System.Collections.Generic; | |||
using System.Text; | |||
using JTNE.Protocol.Attributes; | |||
using JTNE.Protocol.Formatters.MessageBodyFormatters; | |||
namespace JTNE.Protocol.MessageBody | |||
{ | |||
/// <summary> | |||
/// 报警数据 | |||
/// </summary> | |||
[JTNEFormatter(typeof(JTNE_0x02_0x07_Formatter))] | |||
public class JTNE_0x02_0x07 : JTNE_0x02_Body | |||
{ | |||
public override byte TypeCode { get; set; } = JTNE_0x02_0x07; | |||
/// <summary> | |||
/// 最高报警等级 | |||
/// </summary> | |||
public byte AlarmLevel { get; set; } | |||
/// <summary> | |||
/// 通用报警标志 | |||
/// </summary> | |||
public uint AlarmBatteryFlag { get; set; } | |||
/// <summary> | |||
/// 可充电储能装置故障总数 | |||
/// </summary> | |||
public byte AlarmBatteryOtherCount { get; set; } | |||
/// <summary> | |||
/// 可充电储能装置故障代码列表 | |||
/// </summary> | |||
public List<uint> AlarmBatteryOthers { get; set; } | |||
/// <summary> | |||
/// 驱动电机故障总数 | |||
/// </summary> | |||
public byte AlarmElCount { get; set; } | |||
/// <summary> | |||
/// 驱动电机故障代码列表 | |||
/// </summary> | |||
public List<uint> AlarmEls { get; set; } | |||
/// <summary> | |||
/// 发动机故障总数 | |||
/// </summary> | |||
public byte AlarmEngineCount { get; set; } | |||
/// <summary> | |||
/// 发动机故障列表 | |||
/// </summary> | |||
public List<uint> AlarmEngines { get; set; } | |||
/// <summary> | |||
/// 其他故障总数 | |||
/// </summary> | |||
public byte AlarmOtherCount { get; set; } | |||
/// <summary> | |||
/// 其他故障代码列表 | |||
/// </summary> | |||
public List<uint> AlarmOthers { get; set; } | |||
} | |||
} |
@@ -0,0 +1,28 @@ | |||
using System; | |||
using System.Collections.Generic; | |||
using System.Text; | |||
using JTNE.Protocol.Attributes; | |||
using JTNE.Protocol.Formatters.MessageBodyFormatters; | |||
using JTNE.Protocol.Metadata; | |||
namespace JTNE.Protocol.MessageBody | |||
{ | |||
/// <summary> | |||
/// 可充电储能装置电压数据 | |||
/// </summary> | |||
[JTNEFormatter(typeof(JTNE_0x02_0x08_Formatter))] | |||
public class JTNE_0x02_0x08 : JTNE_0x02_Body | |||
{ | |||
public override byte TypeCode { get; set; } = JTNE_0x02_0x08; | |||
/// <summary> | |||
/// 可充电储能子系统个数 | |||
/// </summary> | |||
public byte BatteryAssemblyCount { get; set; } | |||
/// <summary> | |||
/// 可充电储能子系统电压信息列表 | |||
/// 每个可充电储能子系统电压信息长度 | |||
/// </summary> | |||
public List<BatteryAssembly> BatteryAssemblies { get; set; } | |||
} | |||
} |
@@ -0,0 +1,28 @@ | |||
using System; | |||
using System.Collections.Generic; | |||
using System.Text; | |||
using JTNE.Protocol.Attributes; | |||
using JTNE.Protocol.Formatters.MessageBodyFormatters; | |||
using JTNE.Protocol.Metadata; | |||
namespace JTNE.Protocol.MessageBody | |||
{ | |||
/// <summary> | |||
/// 可充电储能装置温度数据 | |||
/// </summary> | |||
[JTNEFormatter(typeof(JTNE_0x02_0x09_Formatter))] | |||
public class JTNE_0x02_0x09 : JTNE_0x02_Body | |||
{ | |||
public override byte TypeCode { get; set; } = JTNE_0x02_0x09; | |||
/// <summary> | |||
/// 可充电储能子系统个数 | |||
/// </summary> | |||
public byte BatteryTemperatureCount { get; set; } | |||
/// <summary> | |||
/// 可充电储能子系统温度信息列表 | |||
/// 每个可充电储能子系统温度信息长度 | |||
/// </summary> | |||
public List<BatteryTemperature> BatteryTemperatures { get; set; } | |||
} | |||
} |
@@ -16,13 +16,47 @@ namespace JTNE.Protocol.MessageBody | |||
/// 驱动电机数据 | |||
/// </summary> | |||
public const byte JTNE_0x02_0x02 = 0x02; | |||
/// <summary> | |||
/// 燃料电池数据 | |||
/// </summary> | |||
public const byte JTNE_0x02_0x03 = 0x03; | |||
/// <summary> | |||
/// 发动机数据 | |||
/// </summary> | |||
public const byte JTNE_0x02_0x04 = 0x04; | |||
/// <summary> | |||
/// 车辆位置数据 | |||
/// </summary> | |||
public const byte JTNE_0x02_0x05 = 0x05; | |||
/// <summary> | |||
/// 极值数据 | |||
/// </summary> | |||
public const byte JTNE_0x02_0x06 = 0x06; | |||
/// <summary> | |||
/// 报警数据 | |||
/// </summary> | |||
public const byte JTNE_0x02_0x07 = 0x07; | |||
/// <summary> | |||
/// 可充电储能装置电压数据 | |||
/// </summary> | |||
public const byte JTNE_0x02_0x08 = 0x08; | |||
/// <summary> | |||
/// 可充电储能装置温度数据 | |||
/// </summary> | |||
public const byte JTNE_0x02_0x09 = 0x09; | |||
static JTNE_0x02_Body() | |||
{ | |||
// todo:实时位置信息上报 | |||
Keys = new Dictionary<byte, Type>(); | |||
Keys.Add(JTNE_0x02_0x01, typeof(JTNE_0x02_0x01)); | |||
Keys.Add(JTNE_0x02_0x02, typeof(JTNE_0x02_0x02)); | |||
Keys.Add(JTNE_0x02_0x03, typeof(JTNE_0x02_0x03)); | |||
Keys.Add(JTNE_0x02_0x04, typeof(JTNE_0x02_0x04)); | |||
Keys.Add(JTNE_0x02_0x05, typeof(JTNE_0x02_0x05)); | |||
Keys.Add(JTNE_0x02_0x06, typeof(JTNE_0x02_0x06)); | |||
Keys.Add(JTNE_0x02_0x07, typeof(JTNE_0x02_0x07)); | |||
Keys.Add(JTNE_0x02_0x08, typeof(JTNE_0x02_0x08)); | |||
Keys.Add(JTNE_0x02_0x09, typeof(JTNE_0x02_0x09)); | |||
} | |||
internal static Dictionary<byte, Type> Keys; | |||
@@ -0,0 +1,41 @@ | |||
using System; | |||
using System.Collections.Generic; | |||
using System.Text; | |||
namespace JTNE.Protocol.Metadata | |||
{ | |||
/// <summary> | |||
/// 每个可充电储能子系统电压信息 | |||
/// </summary> | |||
public class BatteryAssembly | |||
{ | |||
/// <summary> | |||
/// 可充电储能子系统号 | |||
/// </summary> | |||
public byte BatteryAssemblyNo { get; set; } | |||
/// <summary> | |||
/// 可充电储能装置电压 | |||
/// </summary> | |||
public ushort BatteryAssemblyVoltage { get; set; } | |||
/// <summary> | |||
/// 可充电储能装置电流 | |||
/// </summary> | |||
public ushort BatteryAssemblyCurrent { get; set; } | |||
/// <summary> | |||
/// 单体电池总数 | |||
/// </summary> | |||
public ushort SingleBatteryCount { get; set; } | |||
/// <summary> | |||
/// 本帧起始电池序号 | |||
/// </summary> | |||
public ushort ThisSingleBatteryBeginNo { get; set; } | |||
/// <summary> | |||
/// 本帧单体电池总数 | |||
/// </summary> | |||
public byte ThisSingleBatteryBeginCount { get; set; } | |||
/// <summary> | |||
/// 单体电池电压 | |||
/// </summary> | |||
public List<ushort> SingleBatteryVoltages { get; set; } | |||
} | |||
} |
@@ -0,0 +1,25 @@ | |||
using System; | |||
using System.Collections.Generic; | |||
using System.Text; | |||
namespace JTNE.Protocol.Metadata | |||
{ | |||
/// <summary> | |||
/// 每个可充电储能子系统温度信息 | |||
/// </summary> | |||
public class BatteryTemperature | |||
{ | |||
/// <summary> | |||
/// 可充电储能子系统号 | |||
/// </summary> | |||
public byte BatteryAssemblyNo { get; set; } | |||
/// <summary> | |||
/// 可充电储能温度探针个数 | |||
/// </summary> | |||
public ushort TemperatureProbeCount { get; set; } | |||
/// <summary> | |||
/// 可充电储能子系统各温度探针检测到的温度值 | |||
/// </summary> | |||
public byte[] Temperatures { get; set; } | |||
} | |||
} |
@@ -0,0 +1,45 @@ | |||
using System; | |||
using System.Collections.Generic; | |||
using System.Text; | |||
namespace JTNE.Protocol.Metadata | |||
{ | |||
/// <summary> | |||
/// 电机信息 | |||
/// </summary> | |||
public class Electrical | |||
{ | |||
/// <summary> | |||
/// 驱动电机序号 | |||
/// </summary> | |||
public byte ElNo { get; set; } | |||
/// <summary> | |||
/// 驱动驱动电机状态 | |||
/// </summary> | |||
public byte ElStatus { get; set; } | |||
/// <summary> | |||
/// 驱动电机控制器温度 | |||
/// </summary> | |||
public byte ElControlTemp { get; set; } | |||
/// <summary> | |||
/// 驱动电机转速 | |||
/// </summary> | |||
public ushort ElSpeed { get; set; } | |||
/// <summary> | |||
/// 驱动电机转矩 | |||
/// </summary> | |||
public ushort ElTorque { get; set; } | |||
/// <summary> | |||
/// 驱动电机温度 | |||
/// </summary> | |||
public byte ElTemp { get; set; } | |||
/// <summary> | |||
/// 电机控制器输入电压 | |||
/// </summary> | |||
public ushort ElVoltage { get; set; } | |||
/// <summary> | |||
/// 电机控制器直接母线电流 | |||
/// </summary> | |||
public ushort ElCurrent { get; set; } | |||
} | |||
} |