@@ -4,6 +4,7 @@ using System; | |||||
using System.Collections.Generic; | using System.Collections.Generic; | ||||
using Xunit; | using Xunit; | ||||
using JT808.Protocol.Metadata; | using JT808.Protocol.Metadata; | ||||
using JT808.Protocol.Enums; | |||||
namespace JT808.Protocol.Test.MessageBody | namespace JT808.Protocol.Test.MessageBody | ||||
{ | { | ||||
@@ -16,23 +17,272 @@ namespace JT808.Protocol.Test.MessageBody | |||||
{ | { | ||||
JT808_0x0608 value = new JT808_0x0608 | JT808_0x0608 value = new JT808_0x0608 | ||||
{ | { | ||||
QueryType=1, | |||||
QueryType=5, | |||||
Ids=new List<uint>() { 1,2,3} | Ids=new List<uint>() { 1,2,3} | ||||
}; | }; | ||||
var hex = JT808Serializer.Serialize(value).ToHexString(); | var hex = JT808Serializer.Serialize(value).ToHexString(); | ||||
Assert.Equal("0100000003000000010000000200000003", hex); | |||||
Assert.Equal("0500000003000000010000000200000003", hex); | |||||
} | } | ||||
[Fact] | [Fact] | ||||
public void Test2() | public void Test2() | ||||
{ | { | ||||
byte[] bytes = "0100000003000000010000000200000003".ToHexBytes(); | |||||
byte[] bytes = "0500000003000000010000000200000003".ToHexBytes(); | |||||
JT808_0x0608 value = JT808Serializer.Deserialize<JT808_0x0608>(bytes); | JT808_0x0608 value = JT808Serializer.Deserialize<JT808_0x0608>(bytes); | ||||
Assert.Equal(1, value.QueryType); | |||||
Assert.Equal(5, value.QueryType); | |||||
Assert.Equal(3u, value.Count); | Assert.Equal(3u, value.Count); | ||||
Assert.Equal(1u, value.Ids[0]); | Assert.Equal(1u, value.Ids[0]); | ||||
Assert.Equal(2u, value.Ids[1]); | Assert.Equal(2u, value.Ids[1]); | ||||
Assert.Equal(3u, value.Ids[2]); | Assert.Equal(3u, value.Ids[2]); | ||||
} | } | ||||
[Fact] | |||||
public void Test_JT808_0X8600s_1() | |||||
{ | |||||
JT808_0x0608 value = new JT808_0x0608 | |||||
{ | |||||
QueryType = 1, | |||||
JT808_0x8600s=new List<JT808_0x8600>() | |||||
{ | |||||
new JT808_0x8600 | |||||
{ | |||||
AreaItems =new List<JT808CircleAreaProperty> | |||||
{ | |||||
new JT808CircleAreaProperty | |||||
{ | |||||
AreaId = 1522, | |||||
AreaProperty = 222, | |||||
CenterPointLat = 123456789, | |||||
CenterPointLng = 123456789, | |||||
Radius = 200, | |||||
StartTime = DateTime.Parse("2020-01-07 00:00:12"), | |||||
EndTime = DateTime.Parse("2020-01-07 00:00:13"), | |||||
HighestSpeed = 60, | |||||
OverspeedDuration = 200, | |||||
NightMaximumSpeed=666, | |||||
AreaName="SmallChi" | |||||
} | |||||
}, | |||||
SettingAreaProperty= JT808SettingProperty.追加区域.ToByteValue() | |||||
} | |||||
} | |||||
}; | |||||
var hex = JT808Serializer.Serialize(value, JT808Version.JTT2019).ToHexString(); | |||||
Assert.Equal("01000000010101000005F200DE075BCD15075BCD15000000C8003CC8029A0008536D616C6C436869", hex); | |||||
} | |||||
[Fact] | |||||
public void Test_JT808_0X8600s_2() | |||||
{ | |||||
byte[] bytes = "01000000010101000005F200DE075BCD15075BCD15000000C8003CC8029A0008536D616C6C436869".ToHexBytes(); | |||||
JT808_0x0608 value = JT808Serializer.Deserialize<JT808_0x0608>(bytes, JT808Version.JTT2019); | |||||
Assert.Equal(1, value.QueryType); | |||||
Assert.Equal(1u, value.Count); | |||||
var jT808_0X8600 = value.JT808_0x8600s[0]; | |||||
Assert.Equal(JT808SettingProperty.追加区域.ToByteValue(), jT808_0X8600.SettingAreaProperty); | |||||
Assert.Equal(1, jT808_0X8600.AreaCount); | |||||
var item0 = jT808_0X8600.AreaItems[0]; | |||||
Assert.Equal((uint)1522, item0.AreaId); | |||||
Assert.Equal((ushort)222, item0.AreaProperty); | |||||
Assert.Equal((uint)123456789, item0.CenterPointLat); | |||||
Assert.Equal((uint)123456789, item0.CenterPointLng); | |||||
Assert.Equal((uint)200, item0.Radius); | |||||
Assert.Null(item0.StartTime); | |||||
Assert.Null(item0.EndTime); | |||||
Assert.Equal((ushort)60, item0.HighestSpeed); | |||||
Assert.Equal((byte)200, item0.OverspeedDuration); | |||||
Assert.Equal(666, item0.NightMaximumSpeed); | |||||
Assert.Equal("SmallChi", item0.AreaName); | |||||
} | |||||
[Fact] | |||||
public void Test_JT808_0X8602s_1() | |||||
{ | |||||
JT808_0x0608 value = new JT808_0x0608 | |||||
{ | |||||
QueryType = 2, | |||||
JT808_0x8602s = new List<JT808_0x8602>() | |||||
{ | |||||
new JT808_0x8602 | |||||
{ | |||||
AreaItems =new List<JT808RectangleAreaProperty> | |||||
{ | |||||
new JT808RectangleAreaProperty | |||||
{ | |||||
AreaId = 1522, | |||||
AreaProperty = 222, | |||||
LowRightPointLat= 123456789, | |||||
LowRightPointLng= 123456788, | |||||
UpLeftPointLat= 123456787, | |||||
UpLeftPointLng= 123456786, | |||||
StartTime = DateTime.Parse("2020-01-07 00:00:12"), | |||||
EndTime = DateTime.Parse("2020-01-07 00:00:13"), | |||||
HighestSpeed = 60, | |||||
OverspeedDuration = 200, | |||||
AreaName="smallchi" | |||||
} | |||||
}, | |||||
SettingAreaProperty= JT808SettingProperty.追加区域.ToByteValue() | |||||
} | |||||
} | |||||
}; | |||||
var hex = JT808Serializer.Serialize(value, JT808Version.JTT2019).ToHexString(); | |||||
Assert.Equal("02000000010101000005F200DE075BCD13075BCD12075BCD15075BCD14003CC800000008736D616C6C636869", hex); | |||||
} | |||||
[Fact] | |||||
public void Test_JT808_0X8602s_2() | |||||
{ | |||||
byte[] bytes = "02000000010101000005F200DE075BCD13075BCD12075BCD15075BCD14003CC800000008736D616C6C636869".ToHexBytes(); | |||||
JT808_0x0608 value = JT808Serializer.Deserialize<JT808_0x0608>(bytes, JT808Version.JTT2019); | |||||
Assert.Equal(2, value.QueryType); | |||||
Assert.Equal(1u, value.Count); | |||||
var jT808_0X8602 = value.JT808_0x8602s[0]; | |||||
Assert.Equal(JT808SettingProperty.追加区域.ToByteValue(), jT808_0X8602.SettingAreaProperty); | |||||
Assert.Equal(1, jT808_0X8602.AreaCount); | |||||
var item0 = jT808_0X8602.AreaItems[0]; | |||||
Assert.Equal((uint)1522, item0.AreaId); | |||||
Assert.Equal((ushort)222, item0.AreaProperty); | |||||
Assert.Equal((uint)123456789, item0.LowRightPointLat); | |||||
Assert.Equal((uint)123456788, item0.LowRightPointLng); | |||||
Assert.Equal((uint)123456787, item0.UpLeftPointLat); | |||||
Assert.Equal((uint)123456786, item0.UpLeftPointLng); | |||||
Assert.Null(item0.StartTime); | |||||
Assert.Null(item0.EndTime); | |||||
Assert.Equal((ushort)60, item0.HighestSpeed); | |||||
Assert.Equal((byte)200, item0.OverspeedDuration); | |||||
Assert.Equal(0, item0.NightMaximumSpeed); | |||||
Assert.Equal("smallchi", item0.AreaName); | |||||
} | |||||
[Fact] | |||||
public void Test_JT808_0x8604s_1() | |||||
{ | |||||
JT808_0x0608 value = new JT808_0x0608 | |||||
{ | |||||
QueryType = 3, | |||||
JT808_0x8604s = new List<JT808_0x8604>() | |||||
{ | |||||
new JT808_0x8604 | |||||
{ AreaId = 1234, | |||||
AreaProperty = JT808SettingProperty.追加区域.ToByteValue(), | |||||
StartTime = DateTime.Parse("2020-01-07 00:00:12"), | |||||
EndTime = DateTime.Parse("2020-01-07 00:00:13"), | |||||
HighestSpeed = 62, | |||||
OverspeedDuration = 218, | |||||
PeakItems = new List<JT808PeakProperty>() | |||||
{ | |||||
new JT808PeakProperty | |||||
{ | |||||
Lat= 123456789, | |||||
Lng= 123456788 | |||||
}, | |||||
new JT808PeakProperty | |||||
{ | |||||
Lat = 123456700, | |||||
Lng = 123456701 | |||||
} | |||||
}, | |||||
AreaName="smallchi", | |||||
NightMaximumSpeed=66 | |||||
} | |||||
} | |||||
}; | |||||
var hex = JT808Serializer.Serialize(value, JT808Version.JTT2019).ToHexString(); | |||||
Assert.Equal("0300000001000004D200012001070000122001070000130002075BCD15075BCD14075BCCBC075BCCBD0008736D616C6C636869", hex); | |||||
} | |||||
[Fact] | |||||
public void Test_JT808_0X8604s_2() | |||||
{ | |||||
byte[] bytes = "0300000001000004D200012001070000122001070000130002075BCD15075BCD14075BCCBC075BCCBD0008736D616C6C636869".ToHexBytes(); | |||||
JT808_0x0608 value = JT808Serializer.Deserialize<JT808_0x0608>(bytes, JT808Version.JTT2019); | |||||
Assert.Equal(3, value.QueryType); | |||||
Assert.Equal(1u, value.Count); | |||||
var jT808_0X8604 = value.JT808_0x8604s[0]; | |||||
Assert.Equal((uint)1234, jT808_0X8604.AreaId); | |||||
Assert.Equal(JT808SettingProperty.追加区域.ToByteValue(), jT808_0X8604.AreaProperty); | |||||
Assert.Null(jT808_0X8604.HighestSpeed); | |||||
Assert.Null(jT808_0X8604.OverspeedDuration); | |||||
Assert.Equal(DateTime.Parse("2020-01-07 00:00:12"), jT808_0X8604.StartTime); | |||||
Assert.Equal(DateTime.Parse("2020-01-07 00:00:13"), jT808_0X8604.EndTime); | |||||
Assert.Equal(2, jT808_0X8604.PeakItems.Count); | |||||
Assert.Equal((uint)123456789, jT808_0X8604.PeakItems[0].Lat); | |||||
Assert.Equal((uint)123456788, jT808_0X8604.PeakItems[0].Lng); | |||||
Assert.Equal((uint)123456700, jT808_0X8604.PeakItems[1].Lat); | |||||
Assert.Equal((uint)123456701, jT808_0X8604.PeakItems[1].Lng); | |||||
Assert.Equal(0, jT808_0X8604.NightMaximumSpeed); | |||||
Assert.Equal("smallchi", jT808_0X8604.AreaName); | |||||
} | |||||
[Fact] | |||||
public void Test_JT808_0x8606s_1() | |||||
{ | |||||
JT808_0x0608 value = new JT808_0x0608 | |||||
{ | |||||
QueryType = 4, | |||||
JT808_0x8606s = new List<JT808_0x8606>() | |||||
{ | |||||
new JT808_0x8606 | |||||
{ | |||||
RouteId = 9999, | |||||
RouteProperty = 51, | |||||
StartTime = DateTime.Parse("2020-01-07 00:00:12"), | |||||
EndTime = DateTime.Parse("2020-01-07 00:00:12"), | |||||
InflectionPointItems = new List<JT808InflectionPointProperty>() | |||||
{ | |||||
new JT808InflectionPointProperty() | |||||
{ | |||||
InflectionPointId = 1000, | |||||
InflectionPointLat = 123456789, | |||||
InflectionPointLng = 123456788, | |||||
SectionDrivingUnderThreshold = 123, | |||||
SectionHighestSpeed = 69, | |||||
SectionId = 1287, | |||||
SectionLongDrivingThreshold = 50, | |||||
SectionOverspeedDuration = 23, | |||||
SectionProperty = 3, | |||||
SectionWidth = 56, | |||||
NightMaximumSpeed=80 | |||||
} | |||||
}, | |||||
RouteName = "koike518" | |||||
} | |||||
} | |||||
}; | |||||
var hex = JT808Serializer.Serialize(value, JT808Version.JTT2019).ToHexString(); | |||||
Assert.Equal("04000000010000270F00332001070000122001070000120001000003E800000507075BCD15075BCD1438030032007B004517005000086B6F696B65353138", hex); | |||||
} | |||||
[Fact] | |||||
public void Test_JT808_0X8606s_2() | |||||
{ | |||||
byte[] bytes = "04000000010000270F00332001070000122001070000120001000003E800000507075BCD15075BCD1438030032007B004517005000086B6F696B65353138".ToHexBytes(); | |||||
JT808_0x0608 value = JT808Serializer.Deserialize<JT808_0x0608>(bytes, JT808Version.JTT2019); | |||||
Assert.Equal(4, value.QueryType); | |||||
Assert.Equal(1u, value.Count); | |||||
var jT808_0X8606 = value.JT808_0x8606s[0]; | |||||
Assert.Equal((uint)9999, jT808_0X8606.RouteId); | |||||
Assert.Equal((uint)51, jT808_0X8606.RouteProperty); | |||||
Assert.Equal(DateTime.Parse("2020-01-07 00:00:12"), jT808_0X8606.StartTime); | |||||
Assert.Equal(DateTime.Parse("2020-01-07 00:00:12"), jT808_0X8606.EndTime); | |||||
Assert.Equal(1, jT808_0X8606.InflectionPointItems.Count); | |||||
Assert.Equal((uint)1000, jT808_0X8606.InflectionPointItems[0].InflectionPointId); | |||||
Assert.Equal((uint)123456789, jT808_0X8606.InflectionPointItems[0].InflectionPointLat); | |||||
Assert.Equal((uint)123456788, jT808_0X8606.InflectionPointItems[0].InflectionPointLng); | |||||
Assert.Equal((ushort)123, jT808_0X8606.InflectionPointItems[0].SectionDrivingUnderThreshold); | |||||
Assert.Equal((ushort)69, jT808_0X8606.InflectionPointItems[0].SectionHighestSpeed); | |||||
Assert.Equal((uint)1287, jT808_0X8606.InflectionPointItems[0].SectionId); | |||||
Assert.Equal((ushort)50, jT808_0X8606.InflectionPointItems[0].SectionLongDrivingThreshold); | |||||
Assert.Equal((byte)23, jT808_0X8606.InflectionPointItems[0].SectionOverspeedDuration); | |||||
Assert.Equal(3, jT808_0X8606.InflectionPointItems[0].SectionProperty); | |||||
Assert.Equal(56, jT808_0X8606.InflectionPointItems[0].SectionWidth); | |||||
Assert.Equal(80, jT808_0X8606.InflectionPointItems[0].NightMaximumSpeed.Value); | |||||
Assert.Equal("koike518", jT808_0X8606.RouteName); | |||||
} | |||||
} | } | ||||
} | } |
@@ -498,5 +498,12 @@ namespace JT808.Protocol.Enums | |||||
[JT808BodiesType(typeof(JT808_0x0608))] | [JT808BodiesType(typeof(JT808_0x0608))] | ||||
[JT808MsgIdDescription("0x0608", "查询区域或线路数据应答")] | [JT808MsgIdDescription("0x0608", "查询区域或线路数据应答")] | ||||
查询区域或线路数据应答 = 0x0608, | 查询区域或线路数据应答 = 0x0608, | ||||
/// <summary> | |||||
/// 存储多媒体数据检索应答 | |||||
/// 0x0802 | |||||
/// </summary> | |||||
[JT808BodiesType(typeof(JT808_0x0802))] | |||||
[JT808MsgIdDescription("0x0802", "存储多媒体数据检索应答")] | |||||
存储多媒体数据检索应答 = 0x0802, | |||||
} | } | ||||
} | } |
@@ -810,6 +810,41 @@ namespace JT808.Protocol.Extensions | |||||
return Create2019<JT808.Protocol.MessageBody.JT808_0x0801>(msgId,terminalPhoneNo,bodies); | return Create2019<JT808.Protocol.MessageBody.JT808_0x0801>(msgId,terminalPhoneNo,bodies); | ||||
} | } | ||||
/// <summary> | /// <summary> | ||||
/// 0x0802 - 存储多媒体数据检索应答 | |||||
/// auto-generated | |||||
/// </summary> | |||||
public static JT808Package Create_存储多媒体数据检索应答(this JT808MsgId msgId, string terminalPhoneNo,JT808.Protocol.MessageBody.JT808_0x0802 bodies) | |||||
{ | |||||
return Create<JT808.Protocol.MessageBody.JT808_0x0802>(msgId,terminalPhoneNo,bodies); | |||||
} | |||||
/// <summary> | |||||
/// 0x0802 - 存储多媒体数据检索应答 | |||||
/// auto-generated | |||||
/// </summary> | |||||
public static JT808Package Create(this JT808MsgId msgId, string terminalPhoneNo,JT808.Protocol.MessageBody.JT808_0x0802 bodies) | |||||
{ | |||||
return Create<JT808.Protocol.MessageBody.JT808_0x0802>(msgId,terminalPhoneNo,bodies); | |||||
} | |||||
/// <summary> | |||||
/// 0x0802 - 存储多媒体数据检索应答 | |||||
/// auto-generated 2019 version | |||||
/// </summary> | |||||
public static JT808Package Create_存储多媒体数据检索应答_2019(this JT808MsgId msgId, string terminalPhoneNo,JT808.Protocol.MessageBody.JT808_0x0802 bodies) | |||||
{ | |||||
return Create2019<JT808.Protocol.MessageBody.JT808_0x0802>(msgId,terminalPhoneNo,bodies); | |||||
} | |||||
/// <summary> | |||||
/// 0x0802 - 存储多媒体数据检索应答 | |||||
/// auto-generated 2019 version | |||||
/// </summary> | |||||
public static JT808Package Create2019(this JT808MsgId msgId, string terminalPhoneNo,JT808.Protocol.MessageBody.JT808_0x0802 bodies) | |||||
{ | |||||
return Create2019<JT808.Protocol.MessageBody.JT808_0x0802>(msgId,terminalPhoneNo,bodies); | |||||
} | |||||
/// <summary> | |||||
/// 0x0805 - 摄像头立即拍摄命令应答 | /// 0x0805 - 摄像头立即拍摄命令应答 | ||||
/// auto-generated | /// auto-generated | ||||
/// </summary> | /// </summary> | ||||
@@ -14,7 +14,7 @@ | |||||
<licenseUrl>https://github.com/SmallChi/JT808/blob/master/LICENSE</licenseUrl> | <licenseUrl>https://github.com/SmallChi/JT808/blob/master/LICENSE</licenseUrl> | ||||
<license>https://github.com/SmallChi/JT808/blob/master/LICENSE</license> | <license>https://github.com/SmallChi/JT808/blob/master/LICENSE</license> | ||||
<GeneratePackageOnBuild>false</GeneratePackageOnBuild> | <GeneratePackageOnBuild>false</GeneratePackageOnBuild> | ||||
<Version>2.2.4</Version> | |||||
<Version>2.2.5</Version> | |||||
<PackageLicenseFile>LICENSE</PackageLicenseFile> | <PackageLicenseFile>LICENSE</PackageLicenseFile> | ||||
</PropertyGroup> | </PropertyGroup> | ||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|AnyCPU'"> | <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|AnyCPU'"> | ||||
@@ -716,6 +716,12 @@ | |||||
0x0608 | 0x0608 | ||||
</summary> | </summary> | ||||
</member> | </member> | ||||
<member name="F:JT808.Protocol.Enums.JT808MsgId.存储多媒体数据检索应答"> | |||||
<summary> | |||||
存储多媒体数据检索应答 | |||||
0x0802 | |||||
</summary> | |||||
</member> | |||||
<member name="T:JT808.Protocol.Enums.JT808MultimediaCodingFormat"> | <member name="T:JT808.Protocol.Enums.JT808MultimediaCodingFormat"> | ||||
<summary> | <summary> | ||||
多媒体格式编码 | 多媒体格式编码 | ||||
@@ -1506,6 +1512,30 @@ | |||||
auto-generated 2019 version | auto-generated 2019 version | ||||
</summary> | </summary> | ||||
</member> | </member> | ||||
<member name="M:JT808.Protocol.Extensions.JT808PackageExtensions.Create_存储多媒体数据检索应答(JT808.Protocol.Enums.JT808MsgId,System.String,JT808.Protocol.MessageBody.JT808_0x0802)"> | |||||
<summary> | |||||
0x0802 - 存储多媒体数据检索应答 | |||||
auto-generated | |||||
</summary> | |||||
</member> | |||||
<member name="M:JT808.Protocol.Extensions.JT808PackageExtensions.Create(JT808.Protocol.Enums.JT808MsgId,System.String,JT808.Protocol.MessageBody.JT808_0x0802)"> | |||||
<summary> | |||||
0x0802 - 存储多媒体数据检索应答 | |||||
auto-generated | |||||
</summary> | |||||
</member> | |||||
<member name="M:JT808.Protocol.Extensions.JT808PackageExtensions.Create_存储多媒体数据检索应答_2019(JT808.Protocol.Enums.JT808MsgId,System.String,JT808.Protocol.MessageBody.JT808_0x0802)"> | |||||
<summary> | |||||
0x0802 - 存储多媒体数据检索应答 | |||||
auto-generated 2019 version | |||||
</summary> | |||||
</member> | |||||
<member name="M:JT808.Protocol.Extensions.JT808PackageExtensions.Create2019(JT808.Protocol.Enums.JT808MsgId,System.String,JT808.Protocol.MessageBody.JT808_0x0802)"> | |||||
<summary> | |||||
0x0802 - 存储多媒体数据检索应答 | |||||
auto-generated 2019 version | |||||
</summary> | |||||
</member> | |||||
<member name="M:JT808.Protocol.Extensions.JT808PackageExtensions.Create_摄像头立即拍摄命令应答(JT808.Protocol.Enums.JT808MsgId,System.String,JT808.Protocol.MessageBody.JT808_0x0805)"> | <member name="M:JT808.Protocol.Extensions.JT808PackageExtensions.Create_摄像头立即拍摄命令应答(JT808.Protocol.Enums.JT808MsgId,System.String,JT808.Protocol.MessageBody.JT808_0x0805)"> | ||||
<summary> | <summary> | ||||
0x0805 - 摄像头立即拍摄命令应答 | 0x0805 - 摄像头立即拍摄命令应答 | ||||
@@ -3884,6 +3914,30 @@ | |||||
查询的区域或线路的ID | 查询的区域或线路的ID | ||||
</summary> | </summary> | ||||
</member> | </member> | ||||
<member name="P:JT808.Protocol.MessageBody.JT808_0x0608.JT808_0x8600s"> | |||||
<summary> | |||||
设置圆形区域 | |||||
查询类型为1 | |||||
</summary> | |||||
</member> | |||||
<member name="P:JT808.Protocol.MessageBody.JT808_0x0608.JT808_0x8602s"> | |||||
<summary> | |||||
设置矩形区域 | |||||
查询类型为2 | |||||
</summary> | |||||
</member> | |||||
<member name="P:JT808.Protocol.MessageBody.JT808_0x0608.JT808_0x8604s"> | |||||
<summary> | |||||
设置多边形区域 | |||||
查询类型为3 | |||||
</summary> | |||||
</member> | |||||
<member name="P:JT808.Protocol.MessageBody.JT808_0x0608.JT808_0x8606s"> | |||||
<summary> | |||||
设置路线 | |||||
查询类型为4 | |||||
</summary> | |||||
</member> | |||||
<member name="T:JT808.Protocol.MessageBody.JT808_0x0701"> | <member name="T:JT808.Protocol.MessageBody.JT808_0x0701"> | ||||
<summary> | <summary> | ||||
电子运单上报 | 电子运单上报 | ||||
@@ -1,4 +1,5 @@ | |||||
using JT808.Protocol.Formatters; | |||||
using JT808.Protocol.Extensions; | |||||
using JT808.Protocol.Formatters; | |||||
using JT808.Protocol.Interfaces; | using JT808.Protocol.Interfaces; | ||||
using JT808.Protocol.MessagePack; | using JT808.Protocol.MessagePack; | ||||
using System.Collections.Generic; | using System.Collections.Generic; | ||||
@@ -20,11 +21,30 @@ namespace JT808.Protocol.MessageBody | |||||
/// 查询的区域或线路的ID数量 | /// 查询的区域或线路的ID数量 | ||||
/// </summary> | /// </summary> | ||||
public uint Count { get; set; } | public uint Count { get; set; } | ||||
/// <summary> | /// <summary> | ||||
/// 查询的区域或线路的ID | /// 查询的区域或线路的ID | ||||
/// </summary> | /// </summary> | ||||
public List<uint> Ids { get; set; } | public List<uint> Ids { get; set; } | ||||
/// <summary> | |||||
/// 设置圆形区域 | |||||
/// 查询类型为1 | |||||
/// </summary> | |||||
public List<JT808_0x8600> JT808_0x8600s { get; set; } | |||||
/// <summary> | |||||
/// 设置矩形区域 | |||||
/// 查询类型为2 | |||||
/// </summary> | |||||
public List<JT808_0x8602> JT808_0x8602s { get; set; } | |||||
/// <summary> | |||||
/// 设置多边形区域 | |||||
/// 查询类型为3 | |||||
/// </summary> | |||||
public List<JT808_0x8604> JT808_0x8604s { get; set; } | |||||
/// <summary> | |||||
/// 设置路线 | |||||
/// 查询类型为4 | |||||
/// </summary> | |||||
public List<JT808_0x8606> JT808_0x8606s { get; set; } | |||||
public JT808_0x0608 Deserialize(ref JT808MessagePackReader reader, IJT808Config config) | public JT808_0x0608 Deserialize(ref JT808MessagePackReader reader, IJT808Config config) | ||||
{ | { | ||||
JT808_0x0608 value = new JT808_0x0608(); | JT808_0x0608 value = new JT808_0x0608(); | ||||
@@ -32,29 +52,122 @@ namespace JT808.Protocol.MessageBody | |||||
value.Count = reader.ReadUInt32(); | value.Count = reader.ReadUInt32(); | ||||
if (value.Count > 0) | if (value.Count > 0) | ||||
{ | { | ||||
value.Ids = new List<uint>(); | |||||
for (int i = 0; i < value.Count; i++) | |||||
switch (value.QueryType) | |||||
{ | { | ||||
value.Ids.Add(reader.ReadUInt32()); | |||||
case 1: | |||||
value.JT808_0x8600s = new List<JT808_0x8600>(); | |||||
for (int i = 0; i < value.Count; i++) | |||||
{ | |||||
if (config.FormatterFactory.FormatterDict.TryGetValue(typeof(JT808_0x8600).GUID, out object instance)) | |||||
{ | |||||
dynamic attachImpl = JT808MessagePackFormatterResolverExtensions.JT808DynamicDeserialize(instance, ref reader, config); | |||||
value.JT808_0x8600s.Add(attachImpl); | |||||
} | |||||
} | |||||
break; | |||||
case 2: | |||||
value.JT808_0x8602s = new List<JT808_0x8602>(); | |||||
for (int i = 0; i < value.Count; i++) | |||||
{ | |||||
if (config.FormatterFactory.FormatterDict.TryGetValue(typeof(JT808_0x8602).GUID, out object instance)) | |||||
{ | |||||
dynamic attachImpl = JT808MessagePackFormatterResolverExtensions.JT808DynamicDeserialize(instance, ref reader, config); | |||||
value.JT808_0x8602s.Add(attachImpl); | |||||
} | |||||
} | |||||
break; | |||||
case 3: | |||||
value.JT808_0x8604s = new List<JT808_0x8604>(); | |||||
for (int i = 0; i < value.Count; i++) | |||||
{ | |||||
if (config.FormatterFactory.FormatterDict.TryGetValue(typeof(JT808_0x8604).GUID, out object instance)) | |||||
{ | |||||
dynamic attachImpl = JT808MessagePackFormatterResolverExtensions.JT808DynamicDeserialize(instance, ref reader, config); | |||||
value.JT808_0x8604s.Add(attachImpl); | |||||
} | |||||
} | |||||
break; | |||||
case 4: | |||||
value.JT808_0x8606s = new List<JT808_0x8606>(); | |||||
for (int i = 0; i < value.Count; i++) | |||||
{ | |||||
if (config.FormatterFactory.FormatterDict.TryGetValue(typeof(JT808_0x8606).GUID, out object instance)) | |||||
{ | |||||
dynamic attachImpl = JT808MessagePackFormatterResolverExtensions.JT808DynamicDeserialize(instance, ref reader, config); | |||||
value.JT808_0x8606s.Add(attachImpl); | |||||
} | |||||
} | |||||
break; | |||||
default: | |||||
value.Ids = new List<uint>(); | |||||
for (int i = 0; i < value.Count; i++) | |||||
{ | |||||
value.Ids.Add(reader.ReadUInt32()); | |||||
} | |||||
break; | |||||
} | } | ||||
} | } | ||||
return value; | return value; | ||||
} | } | ||||
public void Serialize(ref JT808MessagePackWriter writer, JT808_0x0608 value, IJT808Config config) | public void Serialize(ref JT808MessagePackWriter writer, JT808_0x0608 value, IJT808Config config) | ||||
{ | { | ||||
writer.WriteByte(value.QueryType); | writer.WriteByte(value.QueryType); | ||||
if (value.Ids != null && value.Ids.Count > 0) | |||||
{ | |||||
writer.WriteUInt32((uint)value.Ids.Count); | |||||
foreach (var item in value.Ids) | |||||
{ | |||||
writer.WriteUInt32(item); | |||||
} | |||||
} | |||||
else | |||||
switch (value.QueryType) | |||||
{ | { | ||||
writer.WriteUInt32(0); | |||||
case 1: | |||||
if (value.JT808_0x8600s != null && value.JT808_0x8600s.Count > 0) | |||||
{ | |||||
writer.WriteUInt32((uint)value.JT808_0x8600s.Count); | |||||
foreach (var item in value.JT808_0x8600s) | |||||
{ | |||||
JT808MessagePackFormatterResolverExtensions.JT808DynamicSerialize(item, ref writer, item, config); | |||||
} | |||||
} | |||||
break; | |||||
case 2: | |||||
if (value.JT808_0x8602s != null && value.JT808_0x8602s.Count > 0) | |||||
{ | |||||
writer.WriteUInt32((uint)value.JT808_0x8602s.Count); | |||||
foreach (var item in value.JT808_0x8602s) | |||||
{ | |||||
JT808MessagePackFormatterResolverExtensions.JT808DynamicSerialize(item, ref writer, item, config); | |||||
} | |||||
} | |||||
break; | |||||
case 3: | |||||
if (value.JT808_0x8604s != null && value.JT808_0x8604s.Count > 0) | |||||
{ | |||||
writer.WriteUInt32((uint)value.JT808_0x8604s.Count); | |||||
foreach (var item in value.JT808_0x8604s) | |||||
{ | |||||
JT808MessagePackFormatterResolverExtensions.JT808DynamicSerialize(item, ref writer, item, config); | |||||
} | |||||
} | |||||
break; | |||||
case 4: | |||||
if(value.JT808_0x8606s != null && value.JT808_0x8606s.Count > 0) | |||||
{ | |||||
writer.WriteUInt32((uint)value.JT808_0x8606s.Count); | |||||
foreach (var item in value.JT808_0x8606s) | |||||
{ | |||||
JT808MessagePackFormatterResolverExtensions.JT808DynamicSerialize(item, ref writer, item, config); | |||||
} | |||||
} | |||||
break; | |||||
default: | |||||
if (value.Ids != null && value.Ids.Count > 0) | |||||
{ | |||||
writer.WriteUInt32((uint)value.Ids.Count); | |||||
foreach (var item in value.Ids) | |||||
{ | |||||
writer.WriteUInt32(item); | |||||
} | |||||
} | |||||
else | |||||
{ | |||||
writer.WriteUInt32(0); | |||||
} | |||||
break; | |||||
} | } | ||||
} | } | ||||
} | } | ||||