2.增加2019版本新增0x0702对应的人脸匹配度、UID属性兼容及对应测试 3.修复位置附加数据工厂对2019版本的解析tags/v2.4.1
@@ -10,25 +10,25 @@ namespace JT808.Protocol.Test.JT808LocationAttach | |||
/// UserName-BCD(10) | |||
/// Gerder-byte-1 | |||
/// </summary> | |||
public class JT808LocationAttachImpl0x06: JT808_0x0200_CustomBodyBase, IJT808MessagePackFormatter<JT808LocationAttachImpl0x06> | |||
public class JT808LocationAttachImpl0x61: JT808_0x0200_CustomBodyBase, IJT808MessagePackFormatter<JT808LocationAttachImpl0x61> | |||
{ | |||
public override byte AttachInfoId { get; set; } = 0x06; | |||
public override byte AttachInfoId { get; set; } = 0x61; | |||
public override byte AttachInfoLength { get; set; } = 13; | |||
public int Age { get; set; } | |||
public byte Gender { get; set; } | |||
public string UserName { get; set; } | |||
public JT808LocationAttachImpl0x06 Deserialize(ref JT808MessagePackReader reader, IJT808Config config) | |||
public JT808LocationAttachImpl0x61 Deserialize(ref JT808MessagePackReader reader, IJT808Config config) | |||
{ | |||
JT808LocationAttachImpl0x06 jT808LocationAttachImpl0x06 = new JT808LocationAttachImpl0x06(); | |||
jT808LocationAttachImpl0x06.AttachInfoId = reader.ReadByte(); | |||
jT808LocationAttachImpl0x06.AttachInfoLength = reader.ReadByte(); | |||
jT808LocationAttachImpl0x06.Age = reader.ReadInt32(); | |||
jT808LocationAttachImpl0x06.Gender = reader.ReadByte(); | |||
jT808LocationAttachImpl0x06.UserName = reader.ReadRemainStringContent(); | |||
return jT808LocationAttachImpl0x06; | |||
JT808LocationAttachImpl0x61 jT808LocationAttachImpl0x61 = new JT808LocationAttachImpl0x61(); | |||
jT808LocationAttachImpl0x61.AttachInfoId = reader.ReadByte(); | |||
jT808LocationAttachImpl0x61.AttachInfoLength = reader.ReadByte(); | |||
jT808LocationAttachImpl0x61.Age = reader.ReadInt32(); | |||
jT808LocationAttachImpl0x61.Gender = reader.ReadByte(); | |||
jT808LocationAttachImpl0x61.UserName = reader.ReadRemainStringContent(); | |||
return jT808LocationAttachImpl0x61; | |||
} | |||
public void Serialize(ref JT808MessagePackWriter writer, JT808LocationAttachImpl0x06 value, IJT808Config config) | |||
public void Serialize(ref JT808MessagePackWriter writer, JT808LocationAttachImpl0x61 value, IJT808Config config) | |||
{ | |||
writer.WriteByte(value.AttachInfoId); | |||
writer.WriteByte(value.AttachInfoLength); | |||
@@ -25,7 +25,7 @@ namespace JT808.Protocol.Test.MessageBody | |||
IJT808Config jT808Config = new DefaultGlobalConfig(); | |||
IJT808Config jT808Config1 = new DefaultGlobalConfig(); | |||
jT808Config1.SkipCRCCode = true; | |||
jT808Config.JT808_0X0200_Custom_Factory.SetMap<JT808LocationAttachImpl0x06>(); | |||
jT808Config.JT808_0X0200_Custom_Factory.SetMap<JT808LocationAttachImpl0x61>(); | |||
JT808Serializer = new JT808Serializer(jT808Config); | |||
JT808Serializer1 = new JT808Serializer(jT808Config1); | |||
} | |||
@@ -192,21 +192,21 @@ namespace JT808.Protocol.Test.MessageBody | |||
{ | |||
Oil = 55 | |||
}); | |||
jT808UploadLocationRequest.JT808CustomLocationAttachData.Add(0x06, new JT808LocationAttachImpl0x06 | |||
jT808UploadLocationRequest.JT808CustomLocationAttachData.Add(0x61, new JT808LocationAttachImpl0x61 | |||
{ | |||
Age = 18, | |||
Gender = 1, | |||
UserName = "smallchi" | |||
}); | |||
var hex = JT808Serializer.Serialize(jT808UploadLocationRequest).ToHexString(); | |||
Assert.Equal("000000010000000200BA7F0E07E4F11C0028003C000018071510101001040000006402020037060D0000001201736D616C6C636869", hex); | |||
Assert.Equal("000000010000000200BA7F0E07E4F11C0028003C000018071510101001040000006402020037610D0000001201736D616C6C636869", hex); | |||
} | |||
[Fact] | |||
public void Test4() | |||
{ | |||
// 1.添加自定义附加信息扩展 AddJT808LocationAttachMethod | |||
byte[] bodys = "00 00 00 01 00 00 00 02 00 BA 7F 0E 07 E4 F1 1C 00 28 00 3C 00 00 18 07 15 10 10 10 01 04 00 00 00 64 02 02 00 37 06 0D 00 00 00 12 01 73 6D 61 6C 6C 63 68 69".ToHexBytes(); | |||
byte[] bodys = "000000010000000200BA7F0E07E4F11C0028003C000018071510101001040000006402020037610D0000001201736D616C6C636869".ToHexBytes(); | |||
JT808_0x0200 jT808UploadLocationRequest = JT808Serializer.Deserialize<JT808_0x0200>(bodys); | |||
Assert.Equal((uint)1, jT808UploadLocationRequest.AlarmFlag); | |||
Assert.Equal(DateTime.Parse("2018-07-15 10:10:10"), jT808UploadLocationRequest.GPSTime); | |||
@@ -216,10 +216,10 @@ namespace JT808.Protocol.Test.MessageBody | |||
Assert.Equal((uint)2, jT808UploadLocationRequest.StatusFlag); | |||
Assert.Equal(100, ((JT808_0x0200_0x01)jT808UploadLocationRequest.JT808LocationAttachData[JT808Constants.JT808_0x0200_0x01]).Mileage); | |||
Assert.Equal(55, ((JT808_0x0200_0x02)jT808UploadLocationRequest.JT808LocationAttachData[JT808Constants.JT808_0x0200_0x02]).Oil); | |||
var jT808LocationAttachImpl0x06 = (JT808LocationAttachImpl0x06)jT808UploadLocationRequest.JT808CustomLocationAttachData[0x06]; | |||
Assert.Equal(18, jT808LocationAttachImpl0x06.Age); | |||
Assert.Equal(1, jT808LocationAttachImpl0x06.Gender); | |||
Assert.Equal("smallchi", jT808LocationAttachImpl0x06.UserName); | |||
var jT808LocationAttachImpl0x61 = (JT808LocationAttachImpl0x61)jT808UploadLocationRequest.JT808CustomLocationAttachData[0x61]; | |||
Assert.Equal(18, jT808LocationAttachImpl0x61.Age); | |||
Assert.Equal(1, jT808LocationAttachImpl0x61.Gender); | |||
Assert.Equal("smallchi", jT808LocationAttachImpl0x61.UserName); | |||
} | |||
[Fact] | |||
@@ -518,6 +518,112 @@ namespace JT808.Protocol.Test.MessageBody | |||
//16 | |||
//7E | |||
} | |||
[Fact] | |||
public void Test_JT808_0x0200_0x07_1() | |||
{ | |||
JT808_0x0200 jT808UploadLocationRequest = new JT808_0x0200(); | |||
jT808UploadLocationRequest.AlarmFlag = 1; | |||
jT808UploadLocationRequest.Altitude = 40; | |||
jT808UploadLocationRequest.GPSTime = DateTime.Parse("2021-05-28 18:10:10"); | |||
jT808UploadLocationRequest.Lat = 12222222; | |||
jT808UploadLocationRequest.Lng = 132444444; | |||
jT808UploadLocationRequest.Speed = 60; | |||
jT808UploadLocationRequest.Direction = 0; | |||
jT808UploadLocationRequest.StatusFlag = 2; | |||
jT808UploadLocationRequest.JT808LocationAttachData = new Dictionary<byte, JT808_0x0200_BodyBase>(); | |||
jT808UploadLocationRequest.JT808LocationAttachData.Add(JT808Constants.JT808_0x0200_0x07, new JT808_0x0200_0x07 | |||
{ | |||
BeiDou=new List<JT808_0x0200_0x07.SatelliteStatusInformation>() | |||
{ | |||
new JT808_0x0200_0x07.SatelliteStatusInformation() | |||
{ | |||
No=1, | |||
Elevation=3, | |||
AzimuthAngle=2 | |||
}, | |||
new JT808_0x0200_0x07.SatelliteStatusInformation() | |||
{ | |||
No=2, | |||
Elevation=4, | |||
AzimuthAngle=5 | |||
}, | |||
new JT808_0x0200_0x07.SatelliteStatusInformation() | |||
{ | |||
No=3, | |||
Elevation=5, | |||
AzimuthAngle=6 | |||
}, | |||
new JT808_0x0200_0x07.SatelliteStatusInformation() | |||
{ | |||
No=4, | |||
Elevation=5, | |||
AzimuthAngle=6 | |||
} | |||
}, | |||
GPS=new List<JT808_0x0200_0x07.SatelliteStatusInformation>() | |||
{ | |||
new JT808_0x0200_0x07.SatelliteStatusInformation() | |||
{ | |||
No=2, | |||
Elevation=4, | |||
AzimuthAngle=5 | |||
}, | |||
new JT808_0x0200_0x07.SatelliteStatusInformation() | |||
{ | |||
No=3, | |||
Elevation=5, | |||
AzimuthAngle=6 | |||
}, | |||
new JT808_0x0200_0x07.SatelliteStatusInformation() | |||
{ | |||
No=4, | |||
Elevation=5, | |||
AzimuthAngle=6 | |||
} | |||
}, | |||
GLONASS = new List<JT808_0x0200_0x07.SatelliteStatusInformation> | |||
{ | |||
new JT808_0x0200_0x07.SatelliteStatusInformation() | |||
{ | |||
No=3, | |||
Elevation=5, | |||
AzimuthAngle=6 | |||
}, | |||
new JT808_0x0200_0x07.SatelliteStatusInformation() | |||
{ | |||
No=4, | |||
Elevation=5, | |||
AzimuthAngle=6 | |||
} | |||
}, | |||
Galileo =new List<JT808_0x0200_0x07.SatelliteStatusInformation> | |||
{ | |||
new JT808_0x0200_0x07.SatelliteStatusInformation() | |||
{ | |||
No=4, | |||
Elevation=5, | |||
AzimuthAngle=6 | |||
} | |||
} | |||
}); | |||
var hex = JT808Serializer.Serialize(jT808UploadLocationRequest).ToHexString(); | |||
Assert.Equal("000000010000000200BA7F0E07E4F11C0028003C0000210528181010072C0401030002020400050305000604050006030204000503050006040500060203050006040500060104050006", hex); | |||
} | |||
[Fact] | |||
public void Test_JT808_0x0200_0x07_2() | |||
{ | |||
byte[] bytes = "000000010000000200BA7F0E07E4F11C0028003C0000210528181010072C0401030002020400050305000604050006030204000503050006040500060203050006040500060104050006".ToHexBytes(); | |||
var jT808_0X0200 = JT808Serializer.Deserialize<JT808_0x0200>(bytes); | |||
var jT808_0x0200_0x07=(JT808_0x0200_0x07)jT808_0X0200.JT808LocationAttachData[JT808Constants.JT808_0x0200_0x07]; | |||
Assert.Equal((byte)(4 + (4 * 4 + 4 * 3 + 4 * 2 + 4)), jT808_0x0200_0x07.AttachInfoLength); | |||
Assert.Equal(4, jT808_0x0200_0x07.BeiDou.Count); | |||
Assert.Equal(3, jT808_0x0200_0x07.GPS.Count); | |||
Assert.Equal(2, jT808_0x0200_0x07.GLONASS.Count); | |||
Assert.Single(jT808_0x0200_0x07.Galileo); | |||
} | |||
[Fact] | |||
public void LatLngTest1_1() | |||
{ | |||
@@ -66,9 +66,8 @@ namespace JT808.Protocol.Test.MessageBody | |||
LicenseIssuing = "qwertx", | |||
CertificateExpiresDate = DateTime.Parse("2018-08-16") | |||
}; | |||
var hex = JT808Serializer.Serialize(jT808_0X0702).ToHexString(); | |||
Assert.Equal("0118081609161600056B6F696B6571776531323334353661616100000000000000000671776572747820180816".Replace(" ", ""), hex); | |||
Assert.Equal("0118081609161600056B6F696B6500000000000000007177653132333435366161610671776572747820180816".Replace(" ", ""), hex); | |||
} | |||
[Fact] | |||
@@ -100,7 +99,7 @@ namespace JT808.Protocol.Test.MessageBody | |||
DriverIdentityCard="12345678901234567" | |||
}; | |||
var hex = JT808Serializer.Serialize(jT808_0X0702, JT808Version.JTT2019).ToHexString(); | |||
Assert.Equal("0119120111111100056B6F696B65717765313233343536616161000000000000000006717765727478201912013132333435363738393031323334353637000000", hex); | |||
Assert.Equal("0119120111111100056B6F696B65000000000000000071776531323334353661616106717765727478201912010000003132333435363738393031323334353637", hex); | |||
} | |||
@@ -125,5 +124,49 @@ namespace JT808.Protocol.Test.MessageBody | |||
byte[] bytes = "0119120111111100056B6F696B65717765313233343536616161303030303030303006717765727478201912013132333435363738393031323334353637303030".ToHexBytes(); | |||
string json = JT808Serializer.Analyze<JT808_0x0702>(bytes, JT808Version.JTT2019); | |||
} | |||
[Fact] | |||
public void Test_2019_4() | |||
{ | |||
JT808_0x0702 jT808_0X0702 = new JT808_0x0702 | |||
{ | |||
IC_Card_Status = JT808ICCardStatus.从业资格证IC卡插入_驾驶员上班, | |||
IC_Card_PlugDateTime = DateTime.Parse("2021-05-28 18:11:11"), | |||
IC_Card_ReadResult = JT808ICCardReadResult.IC卡读卡成功, | |||
DriverUserName = "koike", | |||
QualificationCode = "qwe123456aaa", | |||
LicenseIssuing = "qwertx", | |||
CertificateExpiresDate = DateTime.Parse("2021-05-28"), | |||
DriverIdentityCard = "12345678901234567", | |||
FaceMatchValue=99, | |||
UID= "12345678901234567" | |||
}; | |||
var hex = JT808Serializer.Serialize(jT808_0X0702, JT808Version.JTT2019).ToHexString(); | |||
Assert.Equal("0121052818111100056B6F696B65000000000000000071776531323334353661616106717765727478202105280000003132333435363738393031323334353637630000003132333435363738393031323334353637", hex); | |||
} | |||
[Fact] | |||
public void Test_2019_5() | |||
{ | |||
byte[] bytes = "0121052818111100056B6F696B65000000000000000071776531323334353661616106717765727478202105280000003132333435363738393031323334353637630000003132333435363738393031323334353637".ToHexBytes(); | |||
JT808_0x0702 jT808_0X0702 = JT808Serializer.Deserialize<JT808_0x0702>(bytes, JT808Version.JTT2019); | |||
Assert.Equal(JT808ICCardStatus.从业资格证IC卡插入_驾驶员上班, jT808_0X0702.IC_Card_Status); | |||
Assert.Equal(DateTime.Parse("2021-05-28 18:11:11"), jT808_0X0702.IC_Card_PlugDateTime); | |||
Assert.Equal(JT808ICCardReadResult.IC卡读卡成功, jT808_0X0702.IC_Card_ReadResult); | |||
Assert.Equal("koike", jT808_0X0702.DriverUserName); | |||
Assert.Equal("qwe123456aaa", jT808_0X0702.QualificationCode); | |||
Assert.Equal("qwertx", jT808_0X0702.LicenseIssuing); | |||
Assert.Equal(DateTime.Parse("2021-05-28"), jT808_0X0702.CertificateExpiresDate); | |||
Assert.Equal("12345678901234567", jT808_0X0702.DriverIdentityCard); | |||
Assert.Equal(99, jT808_0X0702.FaceMatchValue.Value); | |||
Assert.Equal("12345678901234567", jT808_0X0702.UID); | |||
} | |||
[Fact] | |||
public void Test_2019_6() | |||
{ | |||
byte[] bytes = "0121052818111100056B6F696B65000000000000000071776531323334353661616106717765727478202105280000003132333435363738393031323334353637630000003132333435363738393031323334353637".ToHexBytes(); | |||
string json = JT808Serializer.Analyze<JT808_0x0702>(bytes, JT808Version.JTT2019); | |||
} | |||
} | |||
} |
@@ -20,6 +20,9 @@ namespace JT808.Protocol.Internal | |||
Map.Add(JT808Constants.JT808_0x0200_0x02, new JT808_0x0200_0x02()); | |||
Map.Add(JT808Constants.JT808_0x0200_0x03, new JT808_0x0200_0x03()); | |||
Map.Add(JT808Constants.JT808_0x0200_0x04, new JT808_0x0200_0x04()); | |||
Map.Add(JT808Constants.JT808_0x0200_0x05, new JT808_0x0200_0x05()); | |||
Map.Add(JT808Constants.JT808_0x0200_0x06, new JT808_0x0200_0x06()); | |||
Map.Add(JT808Constants.JT808_0x0200_0x07, new JT808_0x0200_0x07()); | |||
Map.Add(JT808Constants.JT808_0x0200_0x11, new JT808_0x0200_0x11()); | |||
Map.Add(JT808Constants.JT808_0x0200_0x12, new JT808_0x0200_0x12()); | |||
Map.Add(JT808Constants.JT808_0x0200_0x13, new JT808_0x0200_0x13()); | |||
@@ -4891,6 +4891,11 @@ | |||
JT808_0x0200_0x06 | |||
</summary> | |||
</member> | |||
<member name="F:JT808.Protocol.JT808Constants.JT808_0x0200_0x07"> | |||
<summary> | |||
JT808_0x0200_0x07 | |||
</summary> | |||
</member> | |||
<member name="F:JT808.Protocol.JT808Constants.JT808_0x0200_0x11"> | |||
<summary> | |||
JT808_0x0200_0x11 | |||
@@ -9218,6 +9223,104 @@ | |||
<param name="value"></param> | |||
<param name="config"></param> | |||
</member> | |||
<member name="T:JT808.Protocol.MessageBody.JT808_0x0200_0x07"> | |||
<summary> | |||
卫星状态数据 | |||
2019版本 | |||
</summary> | |||
</member> | |||
<member name="M:JT808.Protocol.MessageBody.JT808_0x0200_0x07.#ctor"> | |||
<summary> | |||
</summary> | |||
</member> | |||
<member name="P:JT808.Protocol.MessageBody.JT808_0x0200_0x07.AttachInfoId"> | |||
<summary> | |||
JT808_0x0200_0x07 | |||
</summary> | |||
</member> | |||
<member name="P:JT808.Protocol.MessageBody.JT808_0x0200_0x07.AttachInfoLength"> | |||
<summary> | |||
4 的倍数 | |||
</summary> | |||
</member> | |||
<member name="P:JT808.Protocol.MessageBody.JT808_0x0200_0x07.BeiDou"> | |||
<summary> | |||
BeiDou | |||
最小值是 0,最大值 12,CN 值大于等于 20 的卫星数量 | |||
</summary> | |||
</member> | |||
<member name="P:JT808.Protocol.MessageBody.JT808_0x0200_0x07.GPS"> | |||
<summary> | |||
GPS | |||
最小值是 0,最大值 12,CN 值大于等于 20 的卫星数量 | |||
</summary> | |||
</member> | |||
<member name="P:JT808.Protocol.MessageBody.JT808_0x0200_0x07.GLONASS"> | |||
<summary> | |||
GLONASS | |||
最小值是 0,最大值 12,CN 值大于等于 20 的卫星数量 | |||
</summary> | |||
</member> | |||
<member name="P:JT808.Protocol.MessageBody.JT808_0x0200_0x07.Galileo"> | |||
<summary> | |||
Galileo | |||
最小值是 0,最大值 12,CN 值大于等于 20 的卫星数量 | |||
</summary> | |||
</member> | |||
<member name="M:JT808.Protocol.MessageBody.JT808_0x0200_0x07.Analyze(JT808.Protocol.MessagePack.JT808MessagePackReader@,System.Text.Json.Utf8JsonWriter,JT808.Protocol.IJT808Config)"> | |||
<summary> | |||
</summary> | |||
<param name="reader"></param> | |||
<param name="writer"></param> | |||
<param name="config"></param> | |||
</member> | |||
<member name="M:JT808.Protocol.MessageBody.JT808_0x0200_0x07.Deserialize(JT808.Protocol.MessagePack.JT808MessagePackReader@,JT808.Protocol.IJT808Config)"> | |||
<summary> | |||
</summary> | |||
<param name="reader"></param> | |||
<param name="config"></param> | |||
<returns></returns> | |||
</member> | |||
<member name="M:JT808.Protocol.MessageBody.JT808_0x0200_0x07.Serialize(JT808.Protocol.MessagePack.JT808MessagePackWriter@,JT808.Protocol.MessageBody.JT808_0x0200_0x07,JT808.Protocol.IJT808Config)"> | |||
<summary> | |||
</summary> | |||
<param name="writer"></param> | |||
<param name="value"></param> | |||
<param name="config"></param> | |||
</member> | |||
<member name="T:JT808.Protocol.MessageBody.JT808_0x0200_0x07.SatelliteStatusInformation"> | |||
<summary> | |||
卫星状态信息 | |||
</summary> | |||
</member> | |||
<member name="P:JT808.Protocol.MessageBody.JT808_0x0200_0x07.SatelliteStatusInformation.No"> | |||
<summary> | |||
卫星编号 | |||
1-200 | |||
</summary> | |||
</member> | |||
<member name="P:JT808.Protocol.MessageBody.JT808_0x0200_0x07.SatelliteStatusInformation.Elevation"> | |||
<summary> | |||
仰角 | |||
0-90 | |||
</summary> | |||
</member> | |||
<member name="P:JT808.Protocol.MessageBody.JT808_0x0200_0x07.SatelliteStatusInformation.AzimuthAngle"> | |||
<summary> | |||
方位角 | |||
</summary> | |||
</member> | |||
<member name="M:JT808.Protocol.MessageBody.JT808_0x0200_0x07.SatelliteStatusInformation.Analyze(System.String,System.Text.Json.Utf8JsonWriter)"> | |||
<summary> | |||
</summary> | |||
<param name="type"></param> | |||
<param name="writer"></param> | |||
</member> | |||
<member name="T:JT808.Protocol.MessageBody.JT808_0x0200_0x11"> | |||
<summary> | |||
超速报警附加信息 | |||
@@ -10160,6 +10263,20 @@ | |||
2019版本 | |||
</summary> | |||
</member> | |||
<member name="P:JT808.Protocol.MessageBody.JT808_0x0702.FaceMatchValue"> | |||
<summary> | |||
人脸匹配度 | |||
身份证或从业资格证照片与人脸匹配度比例:0~100 | |||
2019版本 | |||
</summary> | |||
</member> | |||
<member name="P:JT808.Protocol.MessageBody.JT808_0x0702.UID"> | |||
<summary> | |||
身份证 UID | |||
长度 20 位,不足补0x00 | |||
2019版本 | |||
</summary> | |||
</member> | |||
<member name="M:JT808.Protocol.MessageBody.JT808_0x0702.Analyze(JT808.Protocol.MessagePack.JT808MessagePackReader@,System.Text.Json.Utf8JsonWriter,JT808.Protocol.IJT808Config)"> | |||
<summary> | |||
@@ -52,6 +52,10 @@ namespace JT808.Protocol | |||
/// </summary> | |||
public const byte JT808_0x0200_0x06 = 0x06; | |||
/// <summary> | |||
/// JT808_0x0200_0x07 | |||
/// </summary> | |||
public const byte JT808_0x0200_0x07 = 0x07; | |||
/// <summary> | |||
/// JT808_0x0200_0x11 | |||
/// </summary> | |||
public const byte JT808_0x0200_0x11 = 0x11; | |||
@@ -0,0 +1,296 @@ | |||
| |||
using JT808.Protocol.Extensions; | |||
using JT808.Protocol.Formatters; | |||
using JT808.Protocol.Interfaces; | |||
using JT808.Protocol.MessagePack; | |||
using System.Collections.Generic; | |||
using System.Text.Json; | |||
namespace JT808.Protocol.MessageBody | |||
{ | |||
/// <summary> | |||
/// 卫星状态数据 | |||
/// 2019版本 | |||
/// </summary> | |||
public class JT808_0x0200_0x07 : JT808_0x0200_BodyBase, IJT808MessagePackFormatter<JT808_0x0200_0x07>, IJT808Analyze, IJT808_2019_Version | |||
{ | |||
/// <summary> | |||
/// | |||
/// </summary> | |||
public JT808_0x0200_0x07() | |||
{ | |||
BeiDou = new List<SatelliteStatusInformation>(); | |||
GPS = new List<SatelliteStatusInformation>(); | |||
GLONASS = new List<SatelliteStatusInformation>(); | |||
Galileo = new List<SatelliteStatusInformation>(); | |||
} | |||
/// <summary> | |||
/// JT808_0x0200_0x07 | |||
/// </summary> | |||
public override byte AttachInfoId { get; set; } = JT808Constants.JT808_0x0200_0x07; | |||
/// <summary> | |||
/// 4 的倍数 | |||
/// </summary> | |||
public override byte AttachInfoLength { get; set; } | |||
/// <summary> | |||
/// BeiDou | |||
/// 最小值是 0,最大值 12,CN 值大于等于 20 的卫星数量 | |||
/// </summary> | |||
public List<SatelliteStatusInformation> BeiDou { get; set; } | |||
/// <summary> | |||
/// GPS | |||
/// 最小值是 0,最大值 12,CN 值大于等于 20 的卫星数量 | |||
/// </summary> | |||
public List<SatelliteStatusInformation> GPS { get; set; } | |||
/// <summary> | |||
/// GLONASS | |||
/// 最小值是 0,最大值 12,CN 值大于等于 20 的卫星数量 | |||
/// </summary> | |||
public List<SatelliteStatusInformation> GLONASS { get; set; } | |||
/// <summary> | |||
/// Galileo | |||
/// 最小值是 0,最大值 12,CN 值大于等于 20 的卫星数量 | |||
/// </summary> | |||
public List<SatelliteStatusInformation> Galileo { get; set; } | |||
/// <summary> | |||
/// | |||
/// </summary> | |||
/// <param name="reader"></param> | |||
/// <param name="writer"></param> | |||
/// <param name="config"></param> | |||
public void Analyze(ref JT808MessagePackReader reader, Utf8JsonWriter writer, IJT808Config config) | |||
{ | |||
JT808_0x0200_0x07 value = new JT808_0x0200_0x07(); | |||
value.AttachInfoId = reader.ReadByte(); | |||
writer.WriteNumber($"[{value.AttachInfoId.ReadNumber()}]附加信息Id", value.AttachInfoId); | |||
value.AttachInfoLength = reader.ReadByte(); | |||
writer.WriteNumber($"[{value.AttachInfoLength.ReadNumber()}]附加信息长度", value.AttachInfoLength); | |||
//BeiDou | |||
byte beidouCount = reader.ReadByte(); | |||
writer.WriteNumber($"[{beidouCount.ReadNumber()}]北斗卫星数量", beidouCount); | |||
writer.WriteStartArray(); | |||
for (int i = 0; i < beidouCount; i++) | |||
{ | |||
SatelliteStatusInformation ssi = new SatelliteStatusInformation(); | |||
ssi.No = reader.ReadByte(); | |||
ssi.Elevation = reader.ReadByte(); | |||
ssi.AzimuthAngle = reader.ReadUInt16(); | |||
ssi.Analyze("BeiDou", writer); | |||
} | |||
writer.WriteEndArray(); | |||
//GPS | |||
byte gpsCount = reader.ReadByte(); | |||
writer.WriteNumber($"[{gpsCount.ReadNumber()}]GPS卫星数量", gpsCount); | |||
writer.WriteStartArray(); | |||
for (int i = 0; i < gpsCount; i++) | |||
{ | |||
SatelliteStatusInformation ssi = new SatelliteStatusInformation(); | |||
ssi.No = reader.ReadByte(); | |||
ssi.Elevation = reader.ReadByte(); | |||
ssi.AzimuthAngle = reader.ReadUInt16(); | |||
ssi.Analyze("GPS", writer); | |||
} | |||
writer.WriteEndArray(); | |||
//GLONASS | |||
byte glonassCount = reader.ReadByte(); | |||
writer.WriteNumber($"[{glonassCount.ReadNumber()}]GLONASS卫星数量", glonassCount); | |||
writer.WriteStartArray(); | |||
for (int i = 0; i < glonassCount; i++) | |||
{ | |||
SatelliteStatusInformation ssi = new SatelliteStatusInformation(); | |||
ssi.No = reader.ReadByte(); | |||
ssi.Elevation = reader.ReadByte(); | |||
ssi.AzimuthAngle = reader.ReadUInt16(); | |||
ssi.Analyze("GLONASS", writer); | |||
} | |||
writer.WriteEndArray(); | |||
//Galileo | |||
byte galileoCount = reader.ReadByte(); | |||
writer.WriteNumber($"[{galileoCount.ReadNumber()}]Galileo卫星数量", galileoCount); | |||
writer.WriteStartArray(); | |||
for (int i = 0; i < galileoCount; i++) | |||
{ | |||
SatelliteStatusInformation ssi = new SatelliteStatusInformation(); | |||
ssi.No = reader.ReadByte(); | |||
ssi.Elevation = reader.ReadByte(); | |||
ssi.AzimuthAngle = reader.ReadUInt16(); | |||
ssi.Analyze("Galileo", writer); | |||
} | |||
writer.WriteEndArray(); | |||
} | |||
/// <summary> | |||
/// | |||
/// </summary> | |||
/// <param name="reader"></param> | |||
/// <param name="config"></param> | |||
/// <returns></returns> | |||
public JT808_0x0200_0x07 Deserialize(ref JT808MessagePackReader reader, IJT808Config config) | |||
{ | |||
JT808_0x0200_0x07 value = new JT808_0x0200_0x07(); | |||
value.AttachInfoId = reader.ReadByte(); | |||
value.AttachInfoLength = reader.ReadByte(); | |||
//BeiDou | |||
byte beidouCount = reader.ReadByte(); | |||
for(int i = 0; i < beidouCount; i++) | |||
{ | |||
SatelliteStatusInformation ssi = new SatelliteStatusInformation(); | |||
ssi.No = reader.ReadByte(); | |||
ssi.Elevation = reader.ReadByte(); | |||
ssi.AzimuthAngle = reader.ReadUInt16(); | |||
value.BeiDou.Add(ssi); | |||
} | |||
//GPS | |||
byte gpsCount = reader.ReadByte(); | |||
for (int i = 0; i < gpsCount; i++) | |||
{ | |||
SatelliteStatusInformation ssi = new SatelliteStatusInformation(); | |||
ssi.No = reader.ReadByte(); | |||
ssi.Elevation = reader.ReadByte(); | |||
ssi.AzimuthAngle = reader.ReadUInt16(); | |||
value.GPS.Add(ssi); | |||
} | |||
//GLONASS | |||
byte glonassCount = reader.ReadByte(); | |||
for (int i = 0; i < glonassCount; i++) | |||
{ | |||
SatelliteStatusInformation ssi = new SatelliteStatusInformation(); | |||
ssi.No = reader.ReadByte(); | |||
ssi.Elevation = reader.ReadByte(); | |||
ssi.AzimuthAngle = reader.ReadUInt16(); | |||
value.GLONASS.Add(ssi); | |||
} | |||
//Galileo | |||
byte galileoCount = reader.ReadByte(); | |||
for (int i = 0; i < galileoCount; i++) | |||
{ | |||
SatelliteStatusInformation ssi = new SatelliteStatusInformation(); | |||
ssi.No = reader.ReadByte(); | |||
ssi.Elevation = reader.ReadByte(); | |||
ssi.AzimuthAngle = reader.ReadUInt16(); | |||
value.Galileo.Add(ssi); | |||
} | |||
return value; | |||
} | |||
/// <summary> | |||
/// | |||
/// </summary> | |||
/// <param name="writer"></param> | |||
/// <param name="value"></param> | |||
/// <param name="config"></param> | |||
public void Serialize(ref JT808MessagePackWriter writer, JT808_0x0200_0x07 value, IJT808Config config) | |||
{ | |||
writer.WriteByte(value.AttachInfoId); | |||
//各个类型的卫星数量为1个字节 | |||
int attachInfoLength = 4; | |||
if (value.BeiDou != null) | |||
{ | |||
attachInfoLength +=value.BeiDou.Count * 4; | |||
} | |||
if (value.GPS != null) | |||
{ | |||
attachInfoLength += value.GPS.Count * 4; | |||
} | |||
if (value.GLONASS != null) | |||
{ | |||
attachInfoLength += value.GLONASS.Count * 4; | |||
} | |||
if (value.Galileo != null) | |||
{ | |||
attachInfoLength += value.Galileo.Count * 4; | |||
} | |||
writer.WriteByte((byte)attachInfoLength); | |||
if (value.BeiDou != null) | |||
{ | |||
writer.WriteByte((byte)value.BeiDou.Count); | |||
foreach (var item in value.BeiDou) | |||
{ | |||
writer.WriteByte(item.No); | |||
writer.WriteByte(item.Elevation); | |||
writer.WriteUInt16(item.AzimuthAngle); | |||
} | |||
} | |||
else | |||
{ | |||
writer.WriteByte(0); | |||
} | |||
if (value.GPS != null) | |||
{ | |||
writer.WriteByte((byte)value.GPS.Count); | |||
foreach (var item in value.GPS) | |||
{ | |||
writer.WriteByte(item.No); | |||
writer.WriteByte(item.Elevation); | |||
writer.WriteUInt16(item.AzimuthAngle); | |||
} | |||
} | |||
else | |||
{ | |||
writer.WriteByte(0); | |||
} | |||
if (value.GLONASS != null) | |||
{ | |||
writer.WriteByte((byte)value.GLONASS.Count); | |||
foreach (var item in value.GLONASS) | |||
{ | |||
writer.WriteByte(item.No); | |||
writer.WriteByte(item.Elevation); | |||
writer.WriteUInt16(item.AzimuthAngle); | |||
} | |||
} | |||
else | |||
{ | |||
writer.WriteByte(0); | |||
} | |||
if (value.Galileo != null) | |||
{ | |||
writer.WriteByte((byte)value.Galileo.Count); | |||
foreach (var item in value.Galileo) | |||
{ | |||
writer.WriteByte(item.No); | |||
writer.WriteByte(item.Elevation); | |||
writer.WriteUInt16(item.AzimuthAngle); | |||
} | |||
} | |||
else | |||
{ | |||
writer.WriteByte(0); | |||
} | |||
} | |||
/// <summary> | |||
/// 卫星状态信息 | |||
/// </summary> | |||
public class SatelliteStatusInformation | |||
{ | |||
/// <summary> | |||
/// 卫星编号 | |||
/// 1-200 | |||
/// </summary> | |||
public byte No { get; set; } | |||
/// <summary> | |||
/// 仰角 | |||
/// 0-90 | |||
/// </summary> | |||
public byte Elevation { get; set; } | |||
/// <summary> | |||
/// 方位角 | |||
/// </summary> | |||
public ushort AzimuthAngle { get; set; } | |||
/// <summary> | |||
/// | |||
/// </summary> | |||
/// <param name="type"></param> | |||
/// <param name="writer"></param> | |||
public void Analyze(string type,Utf8JsonWriter writer) | |||
{ | |||
writer.WriteStartObject(); | |||
writer.WriteNumber($"[{type}-{No}]卫星编号", No); | |||
writer.WriteNumber($"[{type}-{Elevation}]仰角", Elevation); | |||
writer.WriteNumber($"[{type}-{AzimuthAngle}]方位角", AzimuthAngle); | |||
writer.WriteEndObject(); | |||
} | |||
} | |||
} | |||
} |
@@ -74,6 +74,18 @@ namespace JT808.Protocol.MessageBody | |||
/// </summary> | |||
public string DriverIdentityCard { get; set; } | |||
/// <summary> | |||
/// 人脸匹配度 | |||
/// 身份证或从业资格证照片与人脸匹配度比例:0~100 | |||
/// 2019版本 | |||
/// </summary> | |||
public byte? FaceMatchValue { get; set; } | |||
/// <summary> | |||
/// 身份证 UID | |||
/// 长度 20 位,不足补0x00 | |||
/// 2019版本 | |||
/// </summary> | |||
public string UID { get; set; } | |||
/// <summary> | |||
/// | |||
/// </summary> | |||
/// <param name="reader"></param> | |||
@@ -112,6 +124,15 @@ namespace JT808.Protocol.MessageBody | |||
var driverIdentityCardBuffer = reader.ReadVirtualArray(20); | |||
value.DriverIdentityCard = reader.ReadString(20); | |||
writer.WriteString($"[{driverIdentityCardBuffer.ToArray().ToHexString()}]驾驶员身份证号", value.DriverIdentityCard); | |||
//兼容808-2019 补充 | |||
if (reader.ReadCurrentRemainContentLength() > 0) | |||
{ | |||
value.FaceMatchValue = reader.ReadByte(); | |||
writer.WriteNumber($"[{value.FaceMatchValue.Value.ReadNumber()}]人脸匹配度", value.FaceMatchValue.Value); | |||
var uidBuffer = reader.ReadVirtualArray(20); | |||
value.UID = reader.ReadString(20); | |||
writer.WriteString($"[{uidBuffer.ToArray().ToHexString()}]身份证UID", value.UID); | |||
} | |||
} | |||
} | |||
} | |||
@@ -141,6 +162,12 @@ namespace JT808.Protocol.MessageBody | |||
if(reader.Version== JT808Version.JTT2019) | |||
{ | |||
value.DriverIdentityCard = reader.ReadString(20); | |||
//兼容808-2019 补充 | |||
if (reader.ReadCurrentRemainContentLength() > 0) | |||
{ | |||
value.FaceMatchValue = reader.ReadByte(); | |||
value.UID = reader.ReadString(20); | |||
} | |||
} | |||
} | |||
} | |||
@@ -163,13 +190,22 @@ namespace JT808.Protocol.MessageBody | |||
{ | |||
writer.WriteByte((byte)value.DriverUserName.Length); | |||
writer.WriteString(value.DriverUserName); | |||
writer.WriteString(value.QualificationCode.PadRight(20, '\0').ValiString(nameof(value.QualificationCode),20)); | |||
writer.WriteString(value.QualificationCode.PadLeft(20, '\0').ValiString(nameof(value.QualificationCode),20)); | |||
writer.WriteByte((byte)value.LicenseIssuing.Length); | |||
writer.WriteString(value.LicenseIssuing); | |||
writer.WriteDateTime4(value.CertificateExpiresDate); | |||
if (writer.Version == JT808Version.JTT2019) | |||
{ | |||
writer.WriteString(value.DriverIdentityCard.PadRight(20,'\0').ValiString(nameof(value.DriverIdentityCard), 20)); | |||
writer.WriteString(value.DriverIdentityCard.PadLeft(20,'\0').ValiString(nameof(value.DriverIdentityCard), 20)); | |||
//兼容808-2019 补充 | |||
if (value.FaceMatchValue.HasValue) | |||
{ | |||
writer.WriteByte(value.FaceMatchValue.Value); | |||
} | |||
if (!string.IsNullOrEmpty(value.UID)) | |||
{ | |||
writer.WriteString(value.UID.PadLeft(20, '\0').ValiString(nameof(value.UID), 20)); | |||
} | |||
} | |||
} | |||
} | |||