diff --git a/src/JT809.Protocol.Extensions.JT1078.Test/JT809_JT1078_0x1700Test.cs b/src/JT809.Protocol.Extensions.JT1078.Test/JT809_JT1078_0x1700Test.cs index 4cd0afa..ebe9144 100644 --- a/src/JT809.Protocol.Extensions.JT1078.Test/JT809_JT1078_0x1700Test.cs +++ b/src/JT809.Protocol.Extensions.JT1078.Test/JT809_JT1078_0x1700Test.cs @@ -27,9 +27,9 @@ namespace JT809.Protocol.Extensions.JT1078.Test [Fact] public void Test1() { - var PlateFormIds = Enumerable.Range(0, 11).Select(s => (byte)s).ToArray(); - var AuthorizeCode1s = Enumerable.Range(0, 64).Select(s => (byte)s).ToArray(); - var AuthorizeCode2s = Enumerable.Range(0, 64).Select(s => (byte)s).ToArray(); + var PlateFormIds = "01234567890"; + var AuthorizeCode1s = "0123456789012345678901234567890123456789012345678901234567890123"; + var AuthorizeCode2s = "0123456789012345678901234567890123456789012345678901234567890123"; JT809_JT1078_0x1700 jT809_JT1078_0x1700 = new JT809_JT1078_0x1700() { @@ -43,16 +43,16 @@ namespace JT809.Protocol.Extensions.JT1078.Test } }; var hex = JT809Serializer.Serialize(jT809_JT1078_0x1700).ToHexString(); - Assert.Equal("D4C1423132333435000000000000000000000000000217010000008B000102030405060708090A000102030405060708090A0B0C0D0E0F101112131415161718191A1B1C1D1E1F202122232425262728292A2B2C2D2E2F303132333435363738393A3B3C3D3E3F000102030405060708090A0B0C0D0E0F101112131415161718191A1B1C1D1E1F202122232425262728292A2B2C2D2E2F303132333435363738393A3B3C3D3E3F", hex); + Assert.Equal("D4C1423132333435000000000000000000000000000217010000008B30313233343536373839303031323334353637383930313233343536373839303132333435363738393031323334353637383930313233343536373839303132333435363738393031323330313233343536373839303132333435363738393031323334353637383930313233343536373839303132333435363738393031323334353637383930313233", hex); } [Fact] public void Test2() { - var PlateFormIds = Enumerable.Range(0, 11).Select(s => (byte)s).ToArray(); - var AuthorizeCode1s = Enumerable.Range(0, 64).Select(s => (byte)s).ToArray(); - var AuthorizeCode2s = Enumerable.Range(0, 64).Select(s => (byte)s).ToArray(); - var jT809_JT1078_0x1700 = JT809Serializer.Deserialize("D4C1423132333435000000000000000000000000000217010000008B000102030405060708090A000102030405060708090A0B0C0D0E0F101112131415161718191A1B1C1D1E1F202122232425262728292A2B2C2D2E2F303132333435363738393A3B3C3D3E3F000102030405060708090A0B0C0D0E0F101112131415161718191A1B1C1D1E1F202122232425262728292A2B2C2D2E2F303132333435363738393A3B3C3D3E3F".ToHexBytes()); + var PlateFormIds = "01234567890"; + var AuthorizeCode1s = "0123456789012345678901234567890123456789012345678901234567890123"; + var AuthorizeCode2s = "0123456789012345678901234567890123456789012345678901234567890123"; + var jT809_JT1078_0x1700 = JT809Serializer.Deserialize("D4C1423132333435000000000000000000000000000217010000008B30313233343536373839303031323334353637383930313233343536373839303132333435363738393031323334353637383930313233343536373839303132333435363738393031323330313233343536373839303132333435363738393031323334353637383930313233343536373839303132333435363738393031323334353637383930313233".ToHexBytes()); Assert.Equal("粤B12345", jT809_JT1078_0x1700.VehicleNo); Assert.Equal(Protocol.Enums.JT809VehicleColorType.黄色, jT809_JT1078_0x1700.VehicleColor); Assert.Equal((ushort)JT809_JT1078_SubBusinessType.时效口令上报消息, jT809_JT1078_0x1700.SubBusinessType); diff --git a/src/JT809.Protocol.Extensions.JT1078.Test/JT809_JT1078_0x1800Test.cs b/src/JT809.Protocol.Extensions.JT1078.Test/JT809_JT1078_0x1800Test.cs index 812fc46..993b7d3 100644 --- a/src/JT809.Protocol.Extensions.JT1078.Test/JT809_JT1078_0x1800Test.cs +++ b/src/JT809.Protocol.Extensions.JT1078.Test/JT809_JT1078_0x1800Test.cs @@ -35,7 +35,7 @@ namespace JT809.Protocol.Extensions.JT1078.Test SubBodies= new JT809_JT1078_0x1800_0x1801() { ServerIp="127.0.0.1", ServerPort=8080, - Result=1 + Result= JT809_JT1078_0x1800_0x1801_Result.失败 } }; var hex = JT809Serializer.Serialize(jT809_JT1078_0x1800).ToHexString(); @@ -52,7 +52,7 @@ namespace JT809.Protocol.Extensions.JT1078.Test var jT809_JT1078_0x1800_0x1801 = jT809_JT1078_0x1800.SubBodies as JT809_JT1078_0x1800_0x1801; Assert.Equal("127.0.0.1", jT809_JT1078_0x1800_0x1801.ServerIp); Assert.Equal(8080, jT809_JT1078_0x1800_0x1801.ServerPort); - Assert.Equal(1, jT809_JT1078_0x1800_0x1801.Result); + Assert.Equal(1, (byte)jT809_JT1078_0x1800_0x1801.Result); } [Fact] @@ -64,7 +64,7 @@ namespace JT809.Protocol.Extensions.JT1078.Test VehicleColor = Protocol.Enums.JT809VehicleColorType.黄色, SubBusinessType = (ushort)JT809_JT1078_SubBusinessType.主动请求停止实时音视频传输应答消息, SubBodies = new JT809_JT1078_0x1800_0x1802() { - Result=1 + Result= JT809_JT1078_0x1800_0x1802_Result.失败 } }; var hex = JT809Serializer.Serialize(jT809_JT1078_0x1800).ToHexString(); @@ -79,7 +79,7 @@ namespace JT809.Protocol.Extensions.JT1078.Test Assert.Equal(Protocol.Enums.JT809VehicleColorType.黄色, jT809_JT1078_0x1800.VehicleColor); Assert.Equal((ushort)JT809_JT1078_SubBusinessType.主动请求停止实时音视频传输应答消息, jT809_JT1078_0x1800.SubBusinessType); var jT809_JT1078_0x1800_0x1802 = jT809_JT1078_0x1800.SubBodies as JT809_JT1078_0x1800_0x1802; - Assert.Equal(1, jT809_JT1078_0x1800_0x1802.Result); + Assert.Equal(1, (byte)jT809_JT1078_0x1800_0x1802.Result); } } } diff --git a/src/JT809.Protocol.Extensions.JT1078.Test/JT809_JT1078_0x1900Test.cs b/src/JT809.Protocol.Extensions.JT1078.Test/JT809_JT1078_0x1900Test.cs index 33e1544..c48631a 100644 --- a/src/JT809.Protocol.Extensions.JT1078.Test/JT809_JT1078_0x1900Test.cs +++ b/src/JT809.Protocol.Extensions.JT1078.Test/JT809_JT1078_0x1900Test.cs @@ -111,7 +111,7 @@ namespace JT809.Protocol.Extensions.JT1078.Test VehicleColor = Protocol.Enums.JT809VehicleColorType.黄色, SubBusinessType = (ushort)JT809_JT1078_SubBusinessType.查询音视频资源目录应答消息, SubBodies = new JT809_JT1078_0x1900_0x1902() { - Result=1, + Result= JT809_JT1078_0x1900_0x1902_Result.失败, ItemNum=2, ItemList = new List { new JT809_JT1078_0x1900_Record{ @@ -150,7 +150,7 @@ namespace JT809.Protocol.Extensions.JT1078.Test Assert.Equal((ushort)JT809_JT1078_SubBusinessType.查询音视频资源目录应答消息, jT809_JT1078_0x1900.SubBusinessType); var jT809_JT1078_0x1900_0x1902 = jT809_JT1078_0x1900.SubBodies as JT809_JT1078_0x1900_0x1902; Assert.Equal(2u, jT809_JT1078_0x1900_0x1902.ItemNum); - Assert.Equal(1, jT809_JT1078_0x1900_0x1902.Result); + Assert.Equal(1, (byte)jT809_JT1078_0x1900_0x1902.Result); Assert.Equal(1u, jT809_JT1078_0x1900_0x1902.ItemList[0].AlarmType); Assert.Equal(2, jT809_JT1078_0x1900_0x1902.ItemList[0].AVItemType); diff --git a/src/JT809.Protocol.Extensions.JT1078.Test/JT809_JT1078_0x1A00Test.cs b/src/JT809.Protocol.Extensions.JT1078.Test/JT809_JT1078_0x1A00Test.cs index eacbf71..400f04d 100644 --- a/src/JT809.Protocol.Extensions.JT1078.Test/JT809_JT1078_0x1A00Test.cs +++ b/src/JT809.Protocol.Extensions.JT1078.Test/JT809_JT1078_0x1A00Test.cs @@ -45,7 +45,7 @@ namespace JT809.Protocol.Extensions.JT1078.Test SubBusinessType= (ushort)JT809_JT1078_SubBusinessType.远程录像回放请求应答消息, SubBodies= new JT809_JT1078_0x1A00_0x1A01() { - Result=1, + Result= JT809_JT1078_0x1A00_0x1A01_Result.失败, ServerIp="127.0.0.1", ServerPort=8080 } @@ -62,7 +62,7 @@ namespace JT809.Protocol.Extensions.JT1078.Test Assert.Equal(Protocol.Enums.JT809VehicleColorType.黄色, jT809_JT1078_0x1A00.VehicleColor); Assert.Equal((ushort)JT809_JT1078_SubBusinessType.远程录像回放请求应答消息, jT809_JT1078_0x1A00.SubBusinessType); var jT809_JT1078_0x1A00_0x1A01 = jT809_JT1078_0x1A00.SubBodies as JT809_JT1078_0x1A00_0x1A01; - Assert.Equal(1, jT809_JT1078_0x1A00_0x1A01.Result); + Assert.Equal(1, (byte)jT809_JT1078_0x1A00_0x1A01.Result); Assert.Equal("127.0.0.1", jT809_JT1078_0x1A00_0x1A01.ServerIp); Assert.Equal(8080, jT809_JT1078_0x1A00_0x1A01.ServerPort); } @@ -76,7 +76,7 @@ namespace JT809.Protocol.Extensions.JT1078.Test VehicleColor = Protocol.Enums.JT809VehicleColorType.黄色, SubBusinessType = (ushort)JT809_JT1078_SubBusinessType.远程录像回放控制应答消息, SubBodies = new JT809_JT1078_0x1A00_0x1A02() { - Result=1 + Result= JT809_JT1078_0x1A00_0x1A02_Result.失败 } }; var hex = JT809Serializer.Serialize(jT809_JT1078_0x1A00).ToHexString(); @@ -91,7 +91,7 @@ namespace JT809.Protocol.Extensions.JT1078.Test Assert.Equal(Protocol.Enums.JT809VehicleColorType.黄色, jT809_JT1078_0x1A00.VehicleColor); Assert.Equal((ushort)JT809_JT1078_SubBusinessType.远程录像回放控制应答消息, jT809_JT1078_0x1A00.SubBusinessType); var jT809_JT1078_0x1A00_0x1A02 = jT809_JT1078_0x1A00.SubBodies as JT809_JT1078_0x1A00_0x1A02; - Assert.Equal(1, jT809_JT1078_0x1A00_0x1A02.Result); + Assert.Equal(1, (byte)jT809_JT1078_0x1A00_0x1A02.Result); } } } diff --git a/src/JT809.Protocol.Extensions.JT1078.Test/JT809_JT1078_0x1B00Test.cs b/src/JT809.Protocol.Extensions.JT1078.Test/JT809_JT1078_0x1B00Test.cs index 64ecce7..87ff30d 100644 --- a/src/JT809.Protocol.Extensions.JT1078.Test/JT809_JT1078_0x1B00Test.cs +++ b/src/JT809.Protocol.Extensions.JT1078.Test/JT809_JT1078_0x1B00Test.cs @@ -45,7 +45,7 @@ namespace JT809.Protocol.Extensions.JT1078.Test SubBusinessType= (ushort)JT809_JT1078_SubBusinessType.远程录像下载请求应答消息, SubBodies= new JT809_JT1078_0x1B00_0x1B01() { - Result=1, + Result= JT809_JT1078_0x1B00_0x1B01_Result.失败, SessionId=2 } }; @@ -61,8 +61,8 @@ namespace JT809.Protocol.Extensions.JT1078.Test Assert.Equal(Protocol.Enums.JT809VehicleColorType.黄色, jT809_JT1078_0x1B00.VehicleColor); Assert.Equal((ushort)JT809_JT1078_SubBusinessType.远程录像下载请求应答消息, jT809_JT1078_0x1B00.SubBusinessType); var jT809_JT1078_0x1B00_0x1B01 = jT809_JT1078_0x1B00.SubBodies as JT809_JT1078_0x1B00_0x1B01; - Assert.Equal(1, jT809_JT1078_0x1B00_0x1B01.Result); - Assert.Equal(2, jT809_JT1078_0x1B00_0x1B01.SessionId); + Assert.Equal(1, (byte)jT809_JT1078_0x1B00_0x1B01.Result); + Assert.Equal(2, (byte)jT809_JT1078_0x1B00_0x1B01.SessionId); } [Fact] @@ -74,7 +74,7 @@ namespace JT809.Protocol.Extensions.JT1078.Test VehicleColor = Protocol.Enums.JT809VehicleColorType.黄色, SubBusinessType = (ushort)JT809_JT1078_SubBusinessType.远程录像下载通知消息, SubBodies = new JT809_JT1078_0x1B00_0x1B02() { - Result=1, + Result= JT809_JT1078_0x1B00_0x1B02_Result.失败, UserName="tk", SessionId=2, ServerIp="127.0.0.1", @@ -95,7 +95,7 @@ namespace JT809.Protocol.Extensions.JT1078.Test Assert.Equal(Protocol.Enums.JT809VehicleColorType.黄色, jT809_JT1078_0x1B00.VehicleColor); Assert.Equal((ushort)JT809_JT1078_SubBusinessType.远程录像下载通知消息, jT809_JT1078_0x1B00.SubBusinessType); var jT809_JT1078_0x1B00_0x1B02 = jT809_JT1078_0x1B00.SubBodies as JT809_JT1078_0x1B00_0x1B02; - Assert.Equal(1, jT809_JT1078_0x1B00_0x1B02.Result); + Assert.Equal(1, (byte)jT809_JT1078_0x1B00_0x1B02.Result); Assert.Equal("tk", jT809_JT1078_0x1B00_0x1B02.UserName); Assert.Equal(2, jT809_JT1078_0x1B00_0x1B02.SessionId); Assert.Equal("127.0.0.1", jT809_JT1078_0x1B00_0x1B02.ServerIp); @@ -114,7 +114,7 @@ namespace JT809.Protocol.Extensions.JT1078.Test SubBusinessType = (ushort)JT809_JT1078_SubBusinessType.远程录像下载控制应答消息, SubBodies = new JT809_JT1078_0x1B00_0x1B03() { - Result = 1 + Result = JT809_JT1078_0x1B00_0x1B03_Result.失败 } }; var hex = JT809Serializer.Serialize(jT809_JT1078_0x1B00).ToHexString(); @@ -129,7 +129,7 @@ namespace JT809.Protocol.Extensions.JT1078.Test Assert.Equal(Protocol.Enums.JT809VehicleColorType.黄色, jT809_JT1078_0x1B00.VehicleColor); Assert.Equal((ushort)JT809_JT1078_SubBusinessType.远程录像下载控制应答消息, jT809_JT1078_0x1B00.SubBusinessType); var jT809_JT1078_0x1B00_0x1B03 = jT809_JT1078_0x1B00.SubBodies as JT809_JT1078_0x1B00_0x1B03; - Assert.Equal(1, jT809_JT1078_0x1B00_0x1B03.Result); + Assert.Equal(1, (byte)jT809_JT1078_0x1B00_0x1B03.Result); } } } diff --git a/src/JT809.Protocol.Extensions.JT1078.Test/JT809_JT1078_0x9800Test.cs b/src/JT809.Protocol.Extensions.JT1078.Test/JT809_JT1078_0x9800Test.cs index af69277..70ef290 100644 --- a/src/JT809.Protocol.Extensions.JT1078.Test/JT809_JT1078_0x9800Test.cs +++ b/src/JT809.Protocol.Extensions.JT1078.Test/JT809_JT1078_0x9800Test.cs @@ -28,7 +28,7 @@ namespace JT809.Protocol.Extensions.JT1078.Test public void Test1() { var GnssDatas = Enumerable.Range(0, 36).Select(m => (byte)m).ToArray(); - var AuthorizeCodes = Enumerable.Range(0, 64).Select(m => (byte)m).ToArray(); + var AuthorizeCodes = "0123456789012345678901234567890123456789012345678901234567890123"; JT809_JT1078_0x9800 jT809_JT1078_0x9800 = new JT809_JT1078_0x9800() { VehicleNo="粤B12345", @@ -42,19 +42,19 @@ namespace JT809.Protocol.Extensions.JT1078.Test } }; var hex = JT809Serializer.Serialize(jT809_JT1078_0x9800).ToHexString(); - Assert.Equal("D4C142313233343500000000000000000000000000029801000000660201000102030405060708090A0B0C0D0E0F101112131415161718191A1B1C1D1E1F202122232425262728292A2B2C2D2E2F303132333435363738393A3B3C3D3E3F000102030405060708090A0B0C0D0E0F101112131415161718191A1B1C1D1E1F20212223", hex); + Assert.Equal("D4C14231323334350000000000000000000000000002980100000066020130313233343536373839303132333435363738393031323334353637383930313233343536373839303132333435363738393031323334353637383930313233000102030405060708090A0B0C0D0E0F101112131415161718191A1B1C1D1E1F20212223", hex); } [Fact] public void Test2() { var GnssDatas = Enumerable.Range(0, 36).Select(m => (byte)m).ToArray(); - var AuthorizeCodes = Enumerable.Range(0, 64).Select(m => (byte)m).ToArray(); - var jT809_JT1078_0x1900 = JT809Serializer.Deserialize("D4C142313233343500000000000000000000000000029801000000660201000102030405060708090A0B0C0D0E0F101112131415161718191A1B1C1D1E1F202122232425262728292A2B2C2D2E2F303132333435363738393A3B3C3D3E3F000102030405060708090A0B0C0D0E0F101112131415161718191A1B1C1D1E1F20212223".ToHexBytes()); - Assert.Equal("粤B12345", jT809_JT1078_0x1900.VehicleNo); - Assert.Equal(Protocol.Enums.JT809VehicleColorType.黄色, jT809_JT1078_0x1900.VehicleColor); - Assert.Equal((ushort)JT809_JT1078_SubBusinessType.实时音视频请求消息, jT809_JT1078_0x1900.SubBusinessType); - var jT809_JT1078_0x9800_0x9801 = jT809_JT1078_0x1900.SubBodies as JT809_JT1078_0x9800_0x9801; + var AuthorizeCodes = "0123456789012345678901234567890123456789012345678901234567890123"; + var jT809_JT1078_0x9800 = JT809Serializer.Deserialize("D4C14231323334350000000000000000000000000002980100000066020130313233343536373839303132333435363738393031323334353637383930313233343536373839303132333435363738393031323334353637383930313233000102030405060708090A0B0C0D0E0F101112131415161718191A1B1C1D1E1F20212223".ToHexBytes()); + Assert.Equal("粤B12345", jT809_JT1078_0x9800.VehicleNo); + Assert.Equal(Protocol.Enums.JT809VehicleColorType.黄色, jT809_JT1078_0x9800.VehicleColor); + Assert.Equal((ushort)JT809_JT1078_SubBusinessType.实时音视频请求消息, jT809_JT1078_0x9800.SubBusinessType); + var jT809_JT1078_0x9800_0x9801 = jT809_JT1078_0x9800.SubBodies as JT809_JT1078_0x9800_0x9801; Assert.Equal(1, jT809_JT1078_0x9800_0x9801.AVitemType); Assert.Equal(2, jT809_JT1078_0x9800_0x9801.ChannelId); Assert.Equal(GnssDatas, jT809_JT1078_0x9800_0x9801.GnssData); diff --git a/src/JT809.Protocol.Extensions.JT1078.Test/JT809_JT1078_0x9900Test.cs b/src/JT809.Protocol.Extensions.JT1078.Test/JT809_JT1078_0x9900Test.cs index 3e11256..940f218 100644 --- a/src/JT809.Protocol.Extensions.JT1078.Test/JT809_JT1078_0x9900Test.cs +++ b/src/JT809.Protocol.Extensions.JT1078.Test/JT809_JT1078_0x9900Test.cs @@ -44,7 +44,7 @@ namespace JT809.Protocol.Extensions.JT1078.Test VehicleColor= Protocol.Enums.JT809VehicleColorType.黄色, SubBusinessType= (ushort)JT809_JT1078_SubBusinessType.主动上传音视频资源目录信息应答消息, SubBodies= new JT809_JT1078_0x9900_0x9901() { - Result=1, + Result= JT809_JT1078_0x9900_0x9901_Result.失败, ItemNumber=2 } }; @@ -60,15 +60,15 @@ namespace JT809.Protocol.Extensions.JT1078.Test Assert.Equal(Protocol.Enums.JT809VehicleColorType.黄色, jT809_JT1078_0x9900.VehicleColor); Assert.Equal((ushort)JT809_JT1078_SubBusinessType.主动上传音视频资源目录信息应答消息, jT809_JT1078_0x9900.SubBusinessType); var jT809_JT1078_0x9900_0x9901 = jT809_JT1078_0x9900.SubBodies as JT809_JT1078_0x9900_0x9901; - Assert.Equal(1, jT809_JT1078_0x9900_0x9901.Result); - Assert.Equal(2, jT809_JT1078_0x9900_0x9901.ItemNumber); + Assert.Equal(1, (byte)jT809_JT1078_0x9900_0x9901.Result); + Assert.Equal(2, (byte)jT809_JT1078_0x9900_0x9901.ItemNumber); } [Fact] public void Test3() { var GnssDatas = Enumerable.Range(0, 36).Select(m => (byte)m).ToArray(); - var AuthorizeCodes = Enumerable.Range(0, 64).Select(m => (byte)m).ToArray(); + var AuthorizeCodes = "0123456789012345678901234567890123456789012345678901234567890123"; JT809_JT1078_0x9900 jT809_JT1078_0x9900 = new JT809_JT1078_0x9900() { VehicleNo = "粤B12345", @@ -87,15 +87,15 @@ namespace JT809.Protocol.Extensions.JT1078.Test } }; var hex = JT809Serializer.Serialize(jT809_JT1078_0x9900).ToHexString(); - Assert.Equal("D4C1423132333435000000000000000000000000000299020000008001000000005969798200000000596ACB020000000000000002030504000102030405060708090A0B0C0D0E0F101112131415161718191A1B1C1D1E1F202122232425262728292A2B2C2D2E2F303132333435363738393A3B3C3D3E3F000102030405060708090A0B0C0D0E0F101112131415161718191A1B1C1D1E1F20212223", hex); + Assert.Equal("D4C1423132333435000000000000000000000000000299020000008001000000005969798200000000596ACB02000000000000000203050430313233343536373839303132333435363738393031323334353637383930313233343536373839303132333435363738393031323334353637383930313233000102030405060708090A0B0C0D0E0F101112131415161718191A1B1C1D1E1F20212223", hex); } [Fact] public void Test4() { var GnssDatas = Enumerable.Range(0, 36).Select(m => (byte)m).ToArray(); - var AuthorizeCodes = Enumerable.Range(0, 64).Select(m => (byte)m).ToArray(); - var jT809_JT1078_0x9900 = JT809Serializer.Deserialize("D4C1423132333435000000000000000000000000000299020000008001000000005969798200000000596ACB020000000000000002030504000102030405060708090A0B0C0D0E0F101112131415161718191A1B1C1D1E1F202122232425262728292A2B2C2D2E2F303132333435363738393A3B3C3D3E3F000102030405060708090A0B0C0D0E0F101112131415161718191A1B1C1D1E1F20212223".ToHexBytes()); + var AuthorizeCodes = "0123456789012345678901234567890123456789012345678901234567890123"; + var jT809_JT1078_0x9900 = JT809Serializer.Deserialize("D4C1423132333435000000000000000000000000000299020000008001000000005969798200000000596ACB02000000000000000203050430313233343536373839303132333435363738393031323334353637383930313233343536373839303132333435363738393031323334353637383930313233000102030405060708090A0B0C0D0E0F101112131415161718191A1B1C1D1E1F20212223".ToHexBytes()); Assert.Equal("粤B12345", jT809_JT1078_0x9900.VehicleNo); Assert.Equal(Protocol.Enums.JT809VehicleColorType.黄色, jT809_JT1078_0x9900.VehicleColor); Assert.Equal((ushort)JT809_JT1078_SubBusinessType.查询音视频资源目录请求消息, jT809_JT1078_0x9900.SubBusinessType); diff --git a/src/JT809.Protocol.Extensions.JT1078.Test/JT809_JT1078_0x9A00Test.cs b/src/JT809.Protocol.Extensions.JT1078.Test/JT809_JT1078_0x9A00Test.cs index 77e8578..c749f77 100644 --- a/src/JT809.Protocol.Extensions.JT1078.Test/JT809_JT1078_0x9A00Test.cs +++ b/src/JT809.Protocol.Extensions.JT1078.Test/JT809_JT1078_0x9A00Test.cs @@ -39,7 +39,7 @@ namespace JT809.Protocol.Extensions.JT1078.Test public void Test1() { var GnssDatas = Enumerable.Range(0, 36).Select(m => (byte)m).ToArray(); - var AuthorizeCodes = Enumerable.Range(0, 64).Select(m => (byte)m).ToArray(); + var AuthorizeCodes = "0123456789012345678901234567890123456789012345678901234567890123"; JT809_JT1078_0x9A00 jT809_JT1078_0x9A00 = new JT809_JT1078_0x9A00() { VehicleNo = "粤B12345", @@ -57,15 +57,15 @@ namespace JT809.Protocol.Extensions.JT1078.Test } }; var hex = JT809Serializer.Serialize(jT809_JT1078_0x9A00).ToHexString(); - Assert.Equal("D4C142313233343500000000000000000000000000029A01000000780201040300000000596ACB0200000000596C1C82000102030405060708090A0B0C0D0E0F101112131415161718191A1B1C1D1E1F202122232425262728292A2B2C2D2E2F303132333435363738393A3B3C3D3E3F000102030405060708090A0B0C0D0E0F101112131415161718191A1B1C1D1E1F20212223", hex); + Assert.Equal("D4C142313233343500000000000000000000000000029A01000000780201040300000000596ACB0200000000596C1C8230313233343536373839303132333435363738393031323334353637383930313233343536373839303132333435363738393031323334353637383930313233000102030405060708090A0B0C0D0E0F101112131415161718191A1B1C1D1E1F20212223", hex); } [Fact] public void Test2() { var GnssDatas = Enumerable.Range(0, 36).Select(m => (byte)m).ToArray(); - var AuthorizeCodes = Enumerable.Range(0, 64).Select(m => (byte)m).ToArray(); - var jT809_JT1078_0x9A00 = JT809Serializer.Deserialize("D4C142313233343500000000000000000000000000029A01000000780201040300000000596ACB0200000000596C1C82000102030405060708090A0B0C0D0E0F101112131415161718191A1B1C1D1E1F202122232425262728292A2B2C2D2E2F303132333435363738393A3B3C3D3E3F000102030405060708090A0B0C0D0E0F101112131415161718191A1B1C1D1E1F20212223".ToHexBytes()); + var AuthorizeCodes = "0123456789012345678901234567890123456789012345678901234567890123"; + var jT809_JT1078_0x9A00 = JT809Serializer.Deserialize("D4C142313233343500000000000000000000000000029A01000000780201040300000000596ACB0200000000596C1C8230313233343536373839303132333435363738393031323334353637383930313233343536373839303132333435363738393031323334353637383930313233000102030405060708090A0B0C0D0E0F101112131415161718191A1B1C1D1E1F20212223".ToHexBytes()); Assert.Equal("粤B12345", jT809_JT1078_0x9A00.VehicleNo); Assert.Equal(Protocol.Enums.JT809VehicleColorType.黄色, jT809_JT1078_0x9A00.VehicleColor); Assert.Equal((ushort)JT809_JT1078_SubBusinessType.远程录像回放请求消息, jT809_JT1078_0x9A00.SubBusinessType); @@ -91,9 +91,9 @@ namespace JT809.Protocol.Extensions.JT1078.Test VehicleColor = Protocol.Enums.JT809VehicleColorType.黄色, SubBusinessType = (ushort)JT809_JT1078_SubBusinessType.远程录像回放控制消息, SubBodies = new JT809_JT1078_0x9A00_0x9A02() { - ControlType=1, + ControlType= ControlType.暂停回放, DateTime= Convert.ToDateTime("2017-07-17 10:10:10"), - FastTime=1 + FastTime= FastTime._1倍 } }; var hex = JT809Serializer.Serialize(jT809_JT1078_0x9A00).ToHexString(); @@ -108,9 +108,9 @@ namespace JT809.Protocol.Extensions.JT1078.Test Assert.Equal(Protocol.Enums.JT809VehicleColorType.黄色, jT809_JT1078_0x9A00.VehicleColor); Assert.Equal((ushort)JT809_JT1078_SubBusinessType.远程录像回放控制消息, jT809_JT1078_0x9A00.SubBusinessType); var jT809_JT1078_0x9A00_0x9A02 = jT809_JT1078_0x9A00.SubBodies as JT809_JT1078_0x9A00_0x9A02; - Assert.Equal(1, jT809_JT1078_0x9A00_0x9A02.ControlType); + Assert.Equal(1, (byte)jT809_JT1078_0x9A00_0x9A02.ControlType); Assert.Equal(Convert.ToDateTime("2017-07-17 10:10:10"), jT809_JT1078_0x9A00_0x9A02.DateTime); - Assert.Equal(1, jT809_JT1078_0x9A00_0x9A02.FastTime); + Assert.Equal(1, (byte)jT809_JT1078_0x9A00_0x9A02.FastTime); } } } diff --git a/src/JT809.Protocol.Extensions.JT1078.Test/JT809_JT1078_0x9B00Test.cs b/src/JT809.Protocol.Extensions.JT1078.Test/JT809_JT1078_0x9B00Test.cs index 92a82d7..2826de1 100644 --- a/src/JT809.Protocol.Extensions.JT1078.Test/JT809_JT1078_0x9B00Test.cs +++ b/src/JT809.Protocol.Extensions.JT1078.Test/JT809_JT1078_0x9B00Test.cs @@ -39,7 +39,7 @@ namespace JT809.Protocol.Extensions.JT1078.Test public void Test1() { var GnssDatas = Enumerable.Range(0, 36).Select(m => (byte)m).ToArray(); - var AuthorizeCodes = Enumerable.Range(0, 64).Select(m => (byte)m).ToArray(); + var AuthorizeCodes = "0123456789012345678901234567890123456789012345678901234567890123"; JT809_JT1078_0x9B00 jT809_JT1078_0x9B00 = new JT809_JT1078_0x9B00() { VehicleNo = "粤B12345", @@ -59,15 +59,15 @@ namespace JT809.Protocol.Extensions.JT1078.Test } }; var hex = JT809Serializer.Serialize(jT809_JT1078_0x9B00).ToHexString(); - Assert.Equal("D4C142313233343500000000000000000000000000029B01000000840200000000596ACB0200000000596C1C82000000000000000501040300000006000102030405060708090A0B0C0D0E0F101112131415161718191A1B1C1D1E1F202122232425262728292A2B2C2D2E2F303132333435363738393A3B3C3D3E3F000102030405060708090A0B0C0D0E0F101112131415161718191A1B1C1D1E1F20212223", hex); + Assert.Equal("D4C142313233343500000000000000000000000000029B01000000840200000000596ACB0200000000596C1C8200000000000000050104030000000630313233343536373839303132333435363738393031323334353637383930313233343536373839303132333435363738393031323334353637383930313233000102030405060708090A0B0C0D0E0F101112131415161718191A1B1C1D1E1F20212223", hex); } [Fact] public void Test2() { var GnssDatas = Enumerable.Range(0, 36).Select(m => (byte)m).ToArray(); - var AuthorizeCodes = Enumerable.Range(0, 64).Select(m => (byte)m).ToArray(); - var jT809_JT1078_0x9B00 = JT809Serializer.Deserialize("D4C142313233343500000000000000000000000000029B01000000840200000000596ACB0200000000596C1C82000000000000000501040300000006000102030405060708090A0B0C0D0E0F101112131415161718191A1B1C1D1E1F202122232425262728292A2B2C2D2E2F303132333435363738393A3B3C3D3E3F000102030405060708090A0B0C0D0E0F101112131415161718191A1B1C1D1E1F20212223".ToHexBytes()); + var AuthorizeCodes = "0123456789012345678901234567890123456789012345678901234567890123"; + var jT809_JT1078_0x9B00 = JT809Serializer.Deserialize("D4C142313233343500000000000000000000000000029B01000000840200000000596ACB0200000000596C1C8200000000000000050104030000000630313233343536373839303132333435363738393031323334353637383930313233343536373839303132333435363738393031323334353637383930313233000102030405060708090A0B0C0D0E0F101112131415161718191A1B1C1D1E1F20212223".ToHexBytes()); Assert.Equal("粤B12345", jT809_JT1078_0x9B00.VehicleNo); Assert.Equal(Protocol.Enums.JT809VehicleColorType.黄色, jT809_JT1078_0x9B00.VehicleColor); Assert.Equal((ushort)JT809_JT1078_SubBusinessType.远程录像下载请求消息, jT809_JT1078_0x9B00.SubBusinessType); @@ -93,7 +93,7 @@ namespace JT809.Protocol.Extensions.JT1078.Test VehicleColor = Protocol.Enums.JT809VehicleColorType.黄色, SubBusinessType = (ushort)JT809_JT1078_SubBusinessType.远程录像下载完成通知应答消息, SubBodies = new JT809_JT1078_0x9B00_0x9B02() { - Result=1, + Result= JT809_JT1078_0x9B00_0x9B02_Result.失败, SessionId=2 } }; @@ -109,8 +109,8 @@ namespace JT809.Protocol.Extensions.JT1078.Test Assert.Equal(Protocol.Enums.JT809VehicleColorType.黄色, jT809_JT1078_0x9B00.VehicleColor); Assert.Equal((ushort)JT809_JT1078_SubBusinessType.远程录像下载完成通知应答消息, jT809_JT1078_0x9B00.SubBusinessType); var jT809_JT1078_0x9B00_0x9B02 = jT809_JT1078_0x9B00.SubBodies as JT809_JT1078_0x9B00_0x9B02; - Assert.Equal(1, jT809_JT1078_0x9B00_0x9B02.Result); - Assert.Equal(2, jT809_JT1078_0x9B00_0x9B02.SessionId); + Assert.Equal(1, (byte)jT809_JT1078_0x9B00_0x9B02.Result); + Assert.Equal(2, (byte)jT809_JT1078_0x9B00_0x9B02.SessionId); } [Fact] public void Test5() @@ -122,7 +122,7 @@ namespace JT809.Protocol.Extensions.JT1078.Test SubBusinessType = (ushort)JT809_JT1078_SubBusinessType.远程录像下载控制消息, SubBodies = new JT809_JT1078_0x9B00_0x9B03() { - Type=1, + Type= JT809_JT1078_0x9B00_0x9B03_Type.继续, SessionId = 2 } }; @@ -138,8 +138,8 @@ namespace JT809.Protocol.Extensions.JT1078.Test Assert.Equal(Protocol.Enums.JT809VehicleColorType.黄色, jT809_JT1078_0x9B00.VehicleColor); Assert.Equal((ushort)JT809_JT1078_SubBusinessType.远程录像下载控制消息, jT809_JT1078_0x9B00.SubBusinessType); var jT809_JT1078_0x9B00_0x9B03 = jT809_JT1078_0x9B00.SubBodies as JT809_JT1078_0x9B00_0x9B03; - Assert.Equal(1, jT809_JT1078_0x9B00_0x9B03.Type); - Assert.Equal(2, jT809_JT1078_0x9B00_0x9B03.SessionId); + Assert.Equal(1, (byte)jT809_JT1078_0x9B00_0x9B03.Type); + Assert.Equal(2, (byte)jT809_JT1078_0x9B00_0x9B03.SessionId); } } } diff --git a/src/JT809.Protocol.Extensions.JT1078.Test/JT809_JT1078_AnalyzeTest.cs b/src/JT809.Protocol.Extensions.JT1078.Test/JT809_JT1078_AnalyzeTest.cs new file mode 100644 index 0000000..a3ecd60 --- /dev/null +++ b/src/JT809.Protocol.Extensions.JT1078.Test/JT809_JT1078_AnalyzeTest.cs @@ -0,0 +1,101 @@ +using JT809.Protocol.Extensions.JT1078.MessageBody; +using Microsoft.Extensions.DependencyInjection; +using Newtonsoft.Json; +using System; +using System.Collections.Generic; +using System.Text; +using Xunit; + +namespace JT809.Protocol.Extensions.JT1078.Test +{ + public class JT809_JT1078_AnalyzeTest + { + JT809Serializer JT809Serializer; + public JT809_JT1078_AnalyzeTest() + { + IServiceCollection serviceDescriptors1 = new ServiceCollection(); + serviceDescriptors1 + .AddJT809Configure() + .AddJT1078Configure(); + var ServiceProvider1 = serviceDescriptors1.BuildServiceProvider(); + var defaultConfig = ServiceProvider1.GetRequiredService(); + JT809Serializer = defaultConfig.GetSerializer(); + + Newtonsoft.Json.JsonConvert.DefaultSettings = new Func(() => + { + //日期类型默认格式化处理 + return new Newtonsoft.Json.JsonSerializerSettings + { + DateFormatHandling = Newtonsoft.Json.DateFormatHandling.MicrosoftDateFormat, + DateFormatString = "yyyy-MM-dd HH:mm:ss" + }; + }); + } + [Fact] + public void Analyze() + { + var hex = "D4C1423132333435000000000000000000000000000217010000008B30313233343536373839303031323334353637383930313233343536373839303132333435363738393031323334353637383930313233343536373839303132333435363738393031323330313233343536373839303132333435363738393031323334353637383930313233343536373839303132333435363738393031323334353637383930313233".ToHexBytes(); + var json = JT809Serializer.Analyze(hex); + + hex = "D4C14231323334350000000000000000000000000002170200000000".ToHexBytes(); + json = JT809Serializer.Analyze(hex); + + hex = "D4C142313233343500000000000000000000000000021801000000230100000000000000000000000000000000000000000000003132372E302E302E311F90".ToHexBytes(); + json = JT809Serializer.Analyze(hex); + + hex = "D4C1423132333435000000000000000000000000000218020000000101".ToHexBytes(); + json = JT809Serializer.Analyze(hex); + + hex = "D4C142313233343500000000000000000000000000021901000000440000000203000000005D2BE082000000005D2D32020000000000000001020605000000041F000000005D045382000000005D05A502000000000000000B153D3300000029".ToHexBytes(); + json = JT809Serializer.Analyze(hex); + + hex = "D4C14231323334350000000000000000000000000002190200000045010000000203000000005D2BE082000000005D2D32020000000000000001020605000000041F000000005D045382000000005D05A502000000000000000B153D3300000029".ToHexBytes(); + json = JT809Serializer.Analyze(hex); + + hex = "D4C142313233343500000000000000000000000000021A010000002300000000000000000000000000000000000000000000003132372E302E302E311F9001".ToHexBytes(); + json = JT809Serializer.Analyze(hex); + + hex = "D4C142313233343500000000000000000000000000021A020000000101".ToHexBytes(); + json = JT809Serializer.Analyze(hex); + + hex = "D4C142313233343500000000000000000000000000021B0100000003010002".ToHexBytes(); + json = JT809Serializer.Analyze(hex); + + hex = "D4C142313233343500000000000000000000000000021B020000013401000200000000000000000000000000000000000000000000003132372E302E302E311F900000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000746B0000000000000000000000000000746B313233343536000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000443A2F2F3132332F343536".ToHexBytes(); + json = JT809Serializer.Analyze(hex); + + hex = "D4C142313233343500000000000000000000000000021B030000000101".ToHexBytes(); + json = JT809Serializer.Analyze(hex); + + hex = "D4C14231323334350000000000000000000000000002970200000000".ToHexBytes(); + json = JT809Serializer.Analyze(hex); + + hex = "D4C14231323334350000000000000000000000000002980100000066020130313233343536373839303132333435363738393031323334353637383930313233343536373839303132333435363738393031323334353637383930313233000102030405060708090A0B0C0D0E0F101112131415161718191A1B1C1D1E1F20212223".ToHexBytes(); + json = JT809Serializer.Analyze(hex); + + hex = "D4C142313233343500000000000000000000000000029802000000020102".ToHexBytes(); + json = JT809Serializer.Analyze(hex); + + hex = "D4C142313233343500000000000000000000000000029901000000020102".ToHexBytes(); + json = JT809Serializer.Analyze(hex); + + hex = "D4C1423132333435000000000000000000000000000299020000008001000000005969798200000000596ACB02000000000000000203050430313233343536373839303132333435363738393031323334353637383930313233343536373839303132333435363738393031323334353637383930313233000102030405060708090A0B0C0D0E0F101112131415161718191A1B1C1D1E1F20212223".ToHexBytes(); + json = JT809Serializer.Analyze(hex); + + hex = "D4C142313233343500000000000000000000000000029A01000000780201040300000000596ACB0200000000596C1C8230313233343536373839303132333435363738393031323334353637383930313233343536373839303132333435363738393031323334353637383930313233000102030405060708090A0B0C0D0E0F101112131415161718191A1B1C1D1E1F20212223".ToHexBytes(); + json = JT809Serializer.Analyze(hex); + + hex = "D4C142313233343500000000000000000000000000029A020000000A010100000000596C1C82".ToHexBytes(); + json = JT809Serializer.Analyze(hex); + + hex = "D4C142313233343500000000000000000000000000029B01000000840200000000596ACB0200000000596C1C8200000000000000050104030000000630313233343536373839303132333435363738393031323334353637383930313233343536373839303132333435363738393031323334353637383930313233000102030405060708090A0B0C0D0E0F101112131415161718191A1B1C1D1E1F20212223".ToHexBytes(); + json = JT809Serializer.Analyze(hex); + + hex = "D4C142313233343500000000000000000000000000029B0200000003010002".ToHexBytes(); + json = JT809Serializer.Analyze(hex); + + hex = "D4C142313233343500000000000000000000000000029B0300000003000201".ToHexBytes(); + json = JT809Serializer.Analyze(hex); + } + } +} diff --git a/src/JT809.Protocol.Extensions.JT1078/Enums/ControlType.cs b/src/JT809.Protocol.Extensions.JT1078/Enums/ControlType.cs new file mode 100644 index 0000000..22b54ce --- /dev/null +++ b/src/JT809.Protocol.Extensions.JT1078/Enums/ControlType.cs @@ -0,0 +1,20 @@ +using System; +using System.Collections.Generic; +using System.Text; + +namespace JT809.Protocol.Extensions.JT1078.Enums +{ + /// + /// 控制类型 + /// + public enum ControlType:byte + { + 正常回放=0x00, + 暂停回放 = 0x01, + 结束回放 = 0x02, + 快进回放 = 0x03, + 关键帧快退回放 = 0x04, + 拖动回放 = 0x05, + 关键帧播放 = 0x06, + } +} diff --git a/src/JT809.Protocol.Extensions.JT1078/Enums/FastTime.cs b/src/JT809.Protocol.Extensions.JT1078/Enums/FastTime.cs new file mode 100644 index 0000000..0d62ad0 --- /dev/null +++ b/src/JT809.Protocol.Extensions.JT1078/Enums/FastTime.cs @@ -0,0 +1,16 @@ +using System; +using System.Collections.Generic; +using System.Text; + +namespace JT809.Protocol.Extensions.JT1078.Enums +{ + public enum FastTime : byte + { + 无效 = 0x00, + _1倍 = 0x01, + _2倍 = 0x02, + _4倍 = 0x03, + _8倍 = 0x04, + _16倍 = 0x05, + } +} diff --git a/src/JT809.Protocol.Extensions.JT1078/Enums/JT809_JT1078_0x1800_0x1801_Result.cs b/src/JT809.Protocol.Extensions.JT1078/Enums/JT809_JT1078_0x1800_0x1801_Result.cs new file mode 100644 index 0000000..a55d0c9 --- /dev/null +++ b/src/JT809.Protocol.Extensions.JT1078/Enums/JT809_JT1078_0x1800_0x1801_Result.cs @@ -0,0 +1,16 @@ +using System; +using System.Collections.Generic; +using System.Text; + +namespace JT809.Protocol.Extensions.JT1078.Enums +{ + public enum JT809_JT1078_0x1800_0x1801_Result:byte + { + 成功=0x00, + 失败 = 0x01, + 不支持 = 0x02, + 会话结束 = 0x03, + 时效口令错误 = 0x04, + 不满足跨域条件 = 0x05, + } +} diff --git a/src/JT809.Protocol.Extensions.JT1078/Enums/JT809_JT1078_0x1800_0x1802_Result.cs b/src/JT809.Protocol.Extensions.JT1078/Enums/JT809_JT1078_0x1800_0x1802_Result.cs new file mode 100644 index 0000000..0eab755 --- /dev/null +++ b/src/JT809.Protocol.Extensions.JT1078/Enums/JT809_JT1078_0x1800_0x1802_Result.cs @@ -0,0 +1,14 @@ +using System; +using System.Collections.Generic; +using System.Text; + +namespace JT809.Protocol.Extensions.JT1078.Enums +{ + public enum JT809_JT1078_0x1800_0x1802_Result:byte + { + 成功 = 0x00, + 失败 = 0x01, + 不支持 = 0x02, + 会话结束 = 0x03, + } +} diff --git a/src/JT809.Protocol.Extensions.JT1078/Enums/JT809_JT1078_0x1900_0x1902_Result.cs b/src/JT809.Protocol.Extensions.JT1078/Enums/JT809_JT1078_0x1900_0x1902_Result.cs new file mode 100644 index 0000000..eac384b --- /dev/null +++ b/src/JT809.Protocol.Extensions.JT1078/Enums/JT809_JT1078_0x1900_0x1902_Result.cs @@ -0,0 +1,16 @@ +using System; +using System.Collections.Generic; +using System.Text; + +namespace JT809.Protocol.Extensions.JT1078.Enums +{ + public enum JT809_JT1078_0x1900_0x1902_Result:byte + { + 成功 = 0x00, + 失败 = 0x01, + 不支持 = 0x02, + 会话结束 = 0x03, + 时效口令错误 = 0x04, + 不满足跨域条件 = 0x05, + } +} diff --git a/src/JT809.Protocol.Extensions.JT1078/Enums/JT809_JT1078_0x1A00_0x1A01_Result.cs b/src/JT809.Protocol.Extensions.JT1078/Enums/JT809_JT1078_0x1A00_0x1A01_Result.cs new file mode 100644 index 0000000..57d5cfe --- /dev/null +++ b/src/JT809.Protocol.Extensions.JT1078/Enums/JT809_JT1078_0x1A00_0x1A01_Result.cs @@ -0,0 +1,16 @@ +using System; +using System.Collections.Generic; +using System.Text; + +namespace JT809.Protocol.Extensions.JT1078.Enums +{ + public enum JT809_JT1078_0x1A00_0x1A01_Result:byte + { + 成功 = 0x00, + 失败 = 0x01, + 不支持 = 0x02, + 会话结束 = 0x03, + 时效口令错误 = 0x04, + 不满足跨域条件 = 0x05, + } +} diff --git a/src/JT809.Protocol.Extensions.JT1078/Enums/JT809_JT1078_0x1A00_0x1A02_Result.cs b/src/JT809.Protocol.Extensions.JT1078/Enums/JT809_JT1078_0x1A00_0x1A02_Result.cs new file mode 100644 index 0000000..bd95398 --- /dev/null +++ b/src/JT809.Protocol.Extensions.JT1078/Enums/JT809_JT1078_0x1A00_0x1A02_Result.cs @@ -0,0 +1,14 @@ +using System; +using System.Collections.Generic; +using System.Text; + +namespace JT809.Protocol.Extensions.JT1078.Enums +{ + public enum JT809_JT1078_0x1A00_0x1A02_Result:byte + { + 成功 = 0x00, + 失败 = 0x01, + 不支持 = 0x02, + 会话结束 = 0x03, + } +} diff --git a/src/JT809.Protocol.Extensions.JT1078/Enums/JT809_JT1078_0x1B00_0x1B01_Result.cs b/src/JT809.Protocol.Extensions.JT1078/Enums/JT809_JT1078_0x1B00_0x1B01_Result.cs new file mode 100644 index 0000000..18ba1bb --- /dev/null +++ b/src/JT809.Protocol.Extensions.JT1078/Enums/JT809_JT1078_0x1B00_0x1B01_Result.cs @@ -0,0 +1,16 @@ +using System; +using System.Collections.Generic; +using System.Text; + +namespace JT809.Protocol.Extensions.JT1078.Enums +{ + public enum JT809_JT1078_0x1B00_0x1B01_Result:byte + { + 成功 = 0x00, + 失败 = 0x01, + 不支持 = 0x02, + 会话结束 = 0x03, + 时效口令错误 = 0x04, + 不满足跨域条件 = 0x05, + } +} diff --git a/src/JT809.Protocol.Extensions.JT1078/Enums/JT809_JT1078_0x1B00_0x1B02_Result.cs b/src/JT809.Protocol.Extensions.JT1078/Enums/JT809_JT1078_0x1B00_0x1B02_Result.cs new file mode 100644 index 0000000..475ca4d --- /dev/null +++ b/src/JT809.Protocol.Extensions.JT1078/Enums/JT809_JT1078_0x1B00_0x1B02_Result.cs @@ -0,0 +1,12 @@ +using System; +using System.Collections.Generic; +using System.Text; + +namespace JT809.Protocol.Extensions.JT1078.Enums +{ + public enum JT809_JT1078_0x1B00_0x1B02_Result:byte + { + 成功 = 0x00, + 失败 = 0x01, + } +} diff --git a/src/JT809.Protocol.Extensions.JT1078/Enums/JT809_JT1078_0x1B00_0x1B03_Result.cs b/src/JT809.Protocol.Extensions.JT1078/Enums/JT809_JT1078_0x1B00_0x1B03_Result.cs new file mode 100644 index 0000000..acc04e4 --- /dev/null +++ b/src/JT809.Protocol.Extensions.JT1078/Enums/JT809_JT1078_0x1B00_0x1B03_Result.cs @@ -0,0 +1,14 @@ +using System; +using System.Collections.Generic; +using System.Text; + +namespace JT809.Protocol.Extensions.JT1078.Enums +{ + public enum JT809_JT1078_0x1B00_0x1B03_Result:byte + { + 成功 = 0x00, + 失败 = 0x01, + 不支持 = 0x02, + 会话结束 = 0x03, + } +} diff --git a/src/JT809.Protocol.Extensions.JT1078/Enums/JT809_JT1078_0x9900_0x9901_Result.cs b/src/JT809.Protocol.Extensions.JT1078/Enums/JT809_JT1078_0x9900_0x9901_Result.cs new file mode 100644 index 0000000..2a405d3 --- /dev/null +++ b/src/JT809.Protocol.Extensions.JT1078/Enums/JT809_JT1078_0x9900_0x9901_Result.cs @@ -0,0 +1,14 @@ +using System; +using System.Collections.Generic; +using System.Text; + +namespace JT809.Protocol.Extensions.JT1078.Enums +{ + public enum JT809_JT1078_0x9900_0x9901_Result:byte + { + 成功 = 0x00, + 失败 = 0x01, + 不支持 = 0x02, + 会话结束 = 0x03, + } +} diff --git a/src/JT809.Protocol.Extensions.JT1078/Enums/JT809_JT1078_0x9B00_0x9B02_Result.cs b/src/JT809.Protocol.Extensions.JT1078/Enums/JT809_JT1078_0x9B00_0x9B02_Result.cs new file mode 100644 index 0000000..2afec6e --- /dev/null +++ b/src/JT809.Protocol.Extensions.JT1078/Enums/JT809_JT1078_0x9B00_0x9B02_Result.cs @@ -0,0 +1,14 @@ +using System; +using System.Collections.Generic; +using System.Text; + +namespace JT809.Protocol.Extensions.JT1078.Enums +{ + public enum JT809_JT1078_0x9B00_0x9B02_Result:byte + { + 成功=0x00, + 失败 = 0x01, + 不支持 = 0x02, + 会话结束 = 0x03, + } +} diff --git a/src/JT809.Protocol.Extensions.JT1078/Enums/JT809_JT1078_0x9B00_0x9B03_Type.cs b/src/JT809.Protocol.Extensions.JT1078/Enums/JT809_JT1078_0x9B00_0x9B03_Type.cs new file mode 100644 index 0000000..2dda417 --- /dev/null +++ b/src/JT809.Protocol.Extensions.JT1078/Enums/JT809_JT1078_0x9B00_0x9B03_Type.cs @@ -0,0 +1,13 @@ +using System; +using System.Collections.Generic; +using System.Text; + +namespace JT809.Protocol.Extensions.JT1078.Enums +{ + public enum JT809_JT1078_0x9B00_0x9B03_Type:byte + { + 暂停=0x00, + 继续 = 0x01, + 取消 = 0x02, + } +} diff --git a/src/JT809.Protocol.Extensions.JT1078/Formatters/JT809_JT1078_0x9B00_0x9B03_Formatter.cs b/src/JT809.Protocol.Extensions.JT1078/Formatters/JT809_JT1078_0x9B00_0x9B03_Formatter.cs index 7277144..d3eca00 100644 --- a/src/JT809.Protocol.Extensions.JT1078/Formatters/JT809_JT1078_0x9B00_0x9B03_Formatter.cs +++ b/src/JT809.Protocol.Extensions.JT1078/Formatters/JT809_JT1078_0x9B00_0x9B03_Formatter.cs @@ -1,4 +1,5 @@ -using JT809.Protocol.Extensions.JT1078.MessageBody; +using JT809.Protocol.Extensions.JT1078.Enums; +using JT809.Protocol.Extensions.JT1078.MessageBody; using JT809.Protocol.Formatters; using JT809.Protocol.MessagePack; using System; @@ -13,14 +14,14 @@ namespace JT809.Protocol.Extensions.JT1078.Formatters { JT809_JT1078_0x9B00_0x9B03 jT808_JT1078_0x9B00_0x9B03 = new JT809_JT1078_0x9B00_0x9B03(); jT808_JT1078_0x9B00_0x9B03.SessionId = reader.ReadUInt16(); - jT808_JT1078_0x9B00_0x9B03.Type = reader.ReadByte(); + jT808_JT1078_0x9B00_0x9B03.Type = (JT809_JT1078_0x9B00_0x9B03_Type)reader.ReadByte(); return jT808_JT1078_0x9B00_0x9B03; } public void Serialize(ref JT809MessagePackWriter writer, JT809_JT1078_0x9B00_0x9B03 value, IJT809Config config) { writer.WriteUInt16(value.SessionId); - writer.WriteByte(value.Type); + writer.WriteByte((byte)value.Type); } } } diff --git a/src/JT809.Protocol.Extensions.JT1078/JT809.Protocol.Extensions.JT1078.xml b/src/JT809.Protocol.Extensions.JT1078/JT809.Protocol.Extensions.JT1078.xml index c13acbb..6f1997f 100644 --- a/src/JT809.Protocol.Extensions.JT1078/JT809.Protocol.Extensions.JT1078.xml +++ b/src/JT809.Protocol.Extensions.JT1078/JT809.Protocol.Extensions.JT1078.xml @@ -4,6 +4,11 @@ JT809.Protocol.Extensions.JT1078 + + + 控制类型 + + 主链路时效口令业务类 diff --git a/src/JT809.Protocol.Extensions.JT1078/MessageBody/JT809_JT1078_0x1700.cs b/src/JT809.Protocol.Extensions.JT1078/MessageBody/JT809_JT1078_0x1700.cs index 26ad5f7..a455a31 100644 --- a/src/JT809.Protocol.Extensions.JT1078/MessageBody/JT809_JT1078_0x1700.cs +++ b/src/JT809.Protocol.Extensions.JT1078/MessageBody/JT809_JT1078_0x1700.cs @@ -2,17 +2,19 @@ using JT809.Protocol.Exceptions; using JT809.Protocol.Extensions.JT1078.Enums; using JT809.Protocol.Formatters; +using JT809.Protocol.Interfaces; using JT809.Protocol.MessagePack; using System; using System.Collections.Generic; using System.Text; +using System.Text.Json; namespace JT809.Protocol.Extensions.JT1078.MessageBody { /// /// 主链路时效口令交互消息 /// - public class JT809_JT1078_0x1700 : JT809ExchangeMessageBodies,IJT809MessagePackFormatter + public class JT809_JT1078_0x1700 : JT809ExchangeMessageBodies,IJT809MessagePackFormatter, IJT809Analyze { public override ushort MsgId { get; }=JT809_JT1078_BusinessType.主链路时效口令业务类.ToUInt16Value(); @@ -20,6 +22,39 @@ namespace JT809.Protocol.Extensions.JT1078.MessageBody public override string Description { get; }= "主链路时效口令交互消息"; + public void Analyze(ref JT809MessagePackReader reader, Utf8JsonWriter writer, IJT809Config config) + { + JT809_JT1078_0x1700 value = new JT809_JT1078_0x1700(); + var virtualHex = reader.ReadVirtualArray(21); + value.VehicleNo = reader.ReadString(21); + writer.WriteString($"[{virtualHex.ToArray().ToHexString()}]车牌号", value.VehicleNo); + value.VehicleColor = (JT809VehicleColorType)reader.ReadByte(); + writer.WriteString($"[{((byte)value.VehicleColor).ReadNumber()}]车牌颜色", value.VehicleColor.ToString()); + value.SubBusinessType = reader.ReadUInt16(); + writer.WriteString($"[{value.SubBusinessType.ReadNumber()}]子业务类型标识", ((JT809SubBusinessType)value.SubBusinessType).ToString()); + value.DataLength = reader.ReadUInt32(); + writer.WriteNumber($"[{value.DataLength.ReadNumber()}]后续数据长度", value.DataLength); + try + { + if (config.SubBusinessTypeFactory.TryGetValue(value.SubBusinessType, out object instance)) + { + if (instance is JT809SubBodies subBodies) + { + if (!subBodies.SkipSerialization) + { + writer.WriteStartObject("子业务类型"); + instance.Analyze(ref reader, writer, config); + writer.WriteEndObject(); + } + } + } + } + catch + { + throw new JT809Exception(JT809ErrorCode.SubBodiesParseError, $"SubBusinessType>{value.SubBusinessType.ToString()}"); + } + } + public JT809_JT1078_0x1700 Deserialize(ref JT809MessagePackReader reader, IJT809Config config) { JT809_JT1078_0x1700 value = new JT809_JT1078_0x1700(); diff --git a/src/JT809.Protocol.Extensions.JT1078/MessageBody/JT809_JT1078_0x1700_0x1701.cs b/src/JT809.Protocol.Extensions.JT1078/MessageBody/JT809_JT1078_0x1700_0x1701.cs index cd6a687..b5876f7 100644 --- a/src/JT809.Protocol.Extensions.JT1078/MessageBody/JT809_JT1078_0x1700_0x1701.cs +++ b/src/JT809.Protocol.Extensions.JT1078/MessageBody/JT809_JT1078_0x1700_0x1701.cs @@ -1,48 +1,64 @@ using JT809.Protocol.Extensions.JT1078.Enums; using JT809.Protocol.Formatters; +using JT809.Protocol.Interfaces; using JT809.Protocol.MessagePack; using System; using System.Collections.Generic; using System.Text; +using System.Text.Json; namespace JT809.Protocol.Extensions.JT1078.MessageBody { /// /// 时效口令上报消息 /// - public class JT809_JT1078_0x1700_0x1701 : JT809SubBodies,IJT809MessagePackFormatter + public class JT809_JT1078_0x1700_0x1701 : JT809SubBodies,IJT809MessagePackFormatter, IJT809Analyze { /// /// 企业视频监控平台唯一编码,平台所属企业行政区域代码+平台公共编号 /// - public byte[] PlateFormId { get; set; } + public string PlateFormId { get; set; } /// /// 归属地区政府平台使用的时效口令 /// - public byte[] AuthorizeCode1 { get; set; } + public string AuthorizeCode1 { get; set; } /// /// 跨域地区政府平台使用的时效口令 /// - public byte[] AuthorizeCode2 { get; set; } + public string AuthorizeCode2 { get; set; } public override ushort SubMsgId { get; } = JT809_JT1078_SubBusinessType.时效口令上报消息.ToUInt16Value(); public override string Description { get; }= "时效口令上报消息"; + public void Analyze(ref JT809MessagePackReader reader, Utf8JsonWriter writer, IJT809Config config) + { + JT809_JT1078_0x1700_0x1701 value = new JT809_JT1078_0x1700_0x1701(); + var virtualHex = reader.ReadVirtualArray(11); + value.PlateFormId = reader.ReadString(11); + writer.WriteString($"[{virtualHex.ToArray().ToHexString()}]企业视频监控平台唯一编码",value.PlateFormId); + virtualHex = reader.ReadVirtualArray(64); + value.AuthorizeCode1 = reader.ReadString(64); + writer.WriteString($"[{virtualHex.ToArray().ToHexString()}]归属地区政府平台使用的时效口令", value.AuthorizeCode1); + virtualHex = reader.ReadVirtualArray(64); + value.AuthorizeCode2 = reader.ReadString(64); + writer.WriteString($"[{virtualHex.ToArray().ToHexString()}]跨域地区政府平台使用的时效口令", value.AuthorizeCode2); + } + public JT809_JT1078_0x1700_0x1701 Deserialize(ref JT809MessagePackReader reader, IJT809Config config) { - JT809_JT1078_0x1700_0x1701 jT808_JT1078_0X1701 = new JT809_JT1078_0x1700_0x1701(); - jT808_JT1078_0X1701.PlateFormId = reader.ReadArray(11).ToArray(); - jT808_JT1078_0X1701.AuthorizeCode1 = reader.ReadArray(64).ToArray(); - jT808_JT1078_0X1701.AuthorizeCode2 = reader.ReadArray(64).ToArray(); - return jT808_JT1078_0X1701; + JT809_JT1078_0x1700_0x1701 value = new JT809_JT1078_0x1700_0x1701(); + value.PlateFormId = reader.ReadString(11); + value.AuthorizeCode1 = reader.ReadString(64); + value.AuthorizeCode2 = reader.ReadString(64); + return value; } public void Serialize(ref JT809MessagePackWriter writer, JT809_JT1078_0x1700_0x1701 value, IJT809Config config) { - writer.WriteArray(value.PlateFormId); - writer.WriteArray(value.AuthorizeCode1); - writer.WriteArray(value.AuthorizeCode2); + writer.WriteStringPadRight(value.PlateFormId,11); + writer.WriteStringPadRight(value.AuthorizeCode1,64); + writer.WriteStringPadRight(value.AuthorizeCode2,64); } } } \ No newline at end of file diff --git a/src/JT809.Protocol.Extensions.JT1078/MessageBody/JT809_JT1078_0x1800.cs b/src/JT809.Protocol.Extensions.JT1078/MessageBody/JT809_JT1078_0x1800.cs index 8452cd6..a9fd8bd 100644 --- a/src/JT809.Protocol.Extensions.JT1078/MessageBody/JT809_JT1078_0x1800.cs +++ b/src/JT809.Protocol.Extensions.JT1078/MessageBody/JT809_JT1078_0x1800.cs @@ -1,17 +1,19 @@ using JT809.Protocol.Enums; using JT809.Protocol.Exceptions; using JT809.Protocol.Formatters; +using JT809.Protocol.Interfaces; using JT809.Protocol.MessagePack; using System; using System.Collections.Generic; using System.Text; +using System.Text.Json; namespace JT809.Protocol.Extensions.JT1078.MessageBody { /// /// 主链路实时音视频交互消息 /// - public class JT809_JT1078_0x1800 : JT809ExchangeMessageBodies, IJT809MessagePackFormatter + public class JT809_JT1078_0x1800 : JT809ExchangeMessageBodies, IJT809MessagePackFormatter, IJT809Analyze { public override ushort MsgId { get; } @@ -19,6 +21,39 @@ namespace JT809.Protocol.Extensions.JT1078.MessageBody public override string Description { get; } = "主链路实时音视频交互消息"; + public void Analyze(ref JT809MessagePackReader reader, Utf8JsonWriter writer, IJT809Config config) + { + JT809_JT1078_0x1800 value = new JT809_JT1078_0x1800(); + var virtualHex = reader.ReadVirtualArray(21); + value.VehicleNo = reader.ReadString(21); + writer.WriteString($"[{virtualHex.ToArray().ToHexString()}]车牌号", value.VehicleNo); + value.VehicleColor = (JT809VehicleColorType)reader.ReadByte(); + writer.WriteString($"[{((byte)value.VehicleColor).ReadNumber()}]车牌颜色", value.VehicleColor.ToString()); + value.SubBusinessType = reader.ReadUInt16(); + writer.WriteString($"[{value.SubBusinessType.ReadNumber()}]子业务类型标识", ((JT809SubBusinessType)value.SubBusinessType).ToString()); + value.DataLength = reader.ReadUInt32(); + writer.WriteNumber($"[{value.DataLength.ReadNumber()}]后续数据长度", value.DataLength); + try + { + if (config.SubBusinessTypeFactory.TryGetValue(value.SubBusinessType, out object instance)) + { + if (instance is JT809SubBodies subBodies) + { + if (!subBodies.SkipSerialization) + { + writer.WriteStartObject("子业务类型"); + instance.Analyze(ref reader, writer, config); + writer.WriteEndObject(); + } + } + } + } + catch + { + throw new JT809Exception(JT809ErrorCode.SubBodiesParseError, $"SubBusinessType>{value.SubBusinessType.ToString()}"); + } + } + public JT809_JT1078_0x1800 Deserialize(ref JT809MessagePackReader reader, IJT809Config config) { JT809_JT1078_0x1800 value = new JT809_JT1078_0x1800(); diff --git a/src/JT809.Protocol.Extensions.JT1078/MessageBody/JT809_JT1078_0x1800_0x1801.cs b/src/JT809.Protocol.Extensions.JT1078/MessageBody/JT809_JT1078_0x1800_0x1801.cs index 1c55619..61cad01 100644 --- a/src/JT809.Protocol.Extensions.JT1078/MessageBody/JT809_JT1078_0x1800_0x1801.cs +++ b/src/JT809.Protocol.Extensions.JT1078/MessageBody/JT809_JT1078_0x1800_0x1801.cs @@ -1,21 +1,23 @@ using JT809.Protocol.Extensions.JT1078.Enums; using JT809.Protocol.Formatters; +using JT809.Protocol.Interfaces; using JT809.Protocol.MessagePack; using System; using System.Collections.Generic; using System.Text; +using System.Text.Json; namespace JT809.Protocol.Extensions.JT1078.MessageBody { /// /// 实时音视频请求应答消息 /// - public class JT809_JT1078_0x1800_0x1801 : JT809SubBodies, IJT809MessagePackFormatter + public class JT809_JT1078_0x1800_0x1801 : JT809SubBodies, IJT809MessagePackFormatter, IJT809Analyze { /// /// 应答结果 /// - public byte Result { get; set; } + public JT809_JT1078_0x1800_0x1801_Result Result { get; set; } /// /// 企业视频服务器ip地址 /// 32 @@ -30,18 +32,30 @@ namespace JT809.Protocol.Extensions.JT1078.MessageBody public override string Description { get; } = "实时音视频请求应答消息"; + public void Analyze(ref JT809MessagePackReader reader, Utf8JsonWriter writer, IJT809Config config) + { + JT809_JT1078_0x1800_0x1801 value = new JT809_JT1078_0x1800_0x1801(); + value.Result = (JT809_JT1078_0x1800_0x1801_Result)reader.ReadByte(); + writer.WriteString($"[{((byte)value.Result).ReadNumber()}]应答结果", value.Result.ToString()); + var virtualHex = reader.ReadVirtualArray(32); + value.ServerIp = reader.ReadString(32); + writer.WriteString($"[{virtualHex.ToArray().ToHexString()}]企业视频服务器ip地址", value.ServerIp); + value.ServerPort = reader.ReadUInt16(); + writer.WriteNumber($"[{value.ServerPort.ReadNumber()}]企业视频服务器端口号", value.ServerPort); + } + public JT809_JT1078_0x1800_0x1801 Deserialize(ref JT809MessagePackReader reader, IJT809Config config) { - JT809_JT1078_0x1800_0x1801 jT808_JT1078_0x1800_0x1801 = new JT809_JT1078_0x1800_0x1801(); - jT808_JT1078_0x1800_0x1801.Result = reader.ReadByte(); - jT808_JT1078_0x1800_0x1801.ServerIp = reader.ReadString(32); - jT808_JT1078_0x1800_0x1801.ServerPort = reader.ReadUInt16(); - return jT808_JT1078_0x1800_0x1801; + JT809_JT1078_0x1800_0x1801 value = new JT809_JT1078_0x1800_0x1801(); + value.Result = (JT809_JT1078_0x1800_0x1801_Result)reader.ReadByte(); + value.ServerIp = reader.ReadString(32); + value.ServerPort = reader.ReadUInt16(); + return value; } public void Serialize(ref JT809MessagePackWriter writer, JT809_JT1078_0x1800_0x1801 value, IJT809Config config) { - writer.WriteByte(value.Result); + writer.WriteByte((byte)value.Result); writer.WriteStringPadLeft(value.ServerIp, 32); writer.WriteUInt16(value.ServerPort); } diff --git a/src/JT809.Protocol.Extensions.JT1078/MessageBody/JT809_JT1078_0x1800_0x1802.cs b/src/JT809.Protocol.Extensions.JT1078/MessageBody/JT809_JT1078_0x1800_0x1802.cs index 732b789..77d199a 100644 --- a/src/JT809.Protocol.Extensions.JT1078/MessageBody/JT809_JT1078_0x1800_0x1802.cs +++ b/src/JT809.Protocol.Extensions.JT1078/MessageBody/JT809_JT1078_0x1800_0x1802.cs @@ -1,36 +1,45 @@ using JT809.Protocol.Extensions.JT1078.Enums; using JT809.Protocol.Formatters; +using JT809.Protocol.Interfaces; using JT809.Protocol.MessagePack; using System; using System.Collections.Generic; using System.Text; +using System.Text.Json; namespace JT809.Protocol.Extensions.JT1078.MessageBody { /// /// 主动请求停止实时音视频传输应答消息 /// - public class JT809_JT1078_0x1800_0x1802 : JT809SubBodies, IJT809MessagePackFormatter + public class JT809_JT1078_0x1800_0x1802 : JT809SubBodies, IJT809MessagePackFormatter, IJT809Analyze { /// /// 应答结果 /// - public byte Result { get; set; } + public JT809_JT1078_0x1800_0x1802_Result Result { get; set; } public override ushort SubMsgId { get; } = JT809_JT1078_SubBusinessType.主动请求停止实时音视频传输应答消息.ToUInt16Value(); public override string Description { get; } = "主动请求停止实时音视频传输应答消息"; + public void Analyze(ref JT809MessagePackReader reader, Utf8JsonWriter writer, IJT809Config config) + { + JT809_JT1078_0x1800_0x1802 value = new JT809_JT1078_0x1800_0x1802(); + value.Result = (JT809_JT1078_0x1800_0x1802_Result)reader.ReadByte(); + writer.WriteString($"[{((byte)value.Result).ReadNumber()}]应答结果", value.Result.ToString()); + } + public JT809_JT1078_0x1800_0x1802 Deserialize(ref JT809MessagePackReader reader, IJT809Config config) { - JT809_JT1078_0x1800_0x1802 jT808_JT1078_0x1800_0x1802 = new JT809_JT1078_0x1800_0x1802(); - jT808_JT1078_0x1800_0x1802.Result = reader.ReadByte(); - return jT808_JT1078_0x1800_0x1802; + JT809_JT1078_0x1800_0x1802 value = new JT809_JT1078_0x1800_0x1802(); + value.Result = (JT809_JT1078_0x1800_0x1802_Result)reader.ReadByte(); + return value; } public void Serialize(ref JT809MessagePackWriter writer, JT809_JT1078_0x1800_0x1802 value, IJT809Config config) { - writer.WriteByte(value.Result); + writer.WriteByte((byte)value.Result); } } } \ No newline at end of file diff --git a/src/JT809.Protocol.Extensions.JT1078/MessageBody/JT809_JT1078_0x1900.cs b/src/JT809.Protocol.Extensions.JT1078/MessageBody/JT809_JT1078_0x1900.cs index dee85a7..f02b847 100644 --- a/src/JT809.Protocol.Extensions.JT1078/MessageBody/JT809_JT1078_0x1900.cs +++ b/src/JT809.Protocol.Extensions.JT1078/MessageBody/JT809_JT1078_0x1900.cs @@ -2,17 +2,19 @@ using JT809.Protocol.Exceptions; using JT809.Protocol.Extensions.JT1078.Enums; using JT809.Protocol.Formatters; +using JT809.Protocol.Interfaces; using JT809.Protocol.MessagePack; using System; using System.Collections.Generic; using System.Text; +using System.Text.Json; namespace JT809.Protocol.Extensions.JT1078.MessageBody { /// /// 主链路远程录像检索交互消息 /// - public class JT809_JT1078_0x1900 : JT809ExchangeMessageBodies,IJT809MessagePackFormatter + public class JT809_JT1078_0x1900 : JT809ExchangeMessageBodies,IJT809MessagePackFormatter, IJT809Analyze { public override ushort MsgId { get; } = JT809_JT1078_BusinessType.主链路远程录像检索业务类.ToUInt16Value(); @@ -20,6 +22,39 @@ namespace JT809.Protocol.Extensions.JT1078.MessageBody public override string Description { get; } = "主链路远程录像检索交互消息"; + public void Analyze(ref JT809MessagePackReader reader, Utf8JsonWriter writer, IJT809Config config) + { + JT809_JT1078_0x1900 value = new JT809_JT1078_0x1900(); + var virtualHex = reader.ReadVirtualArray(21); + value.VehicleNo = reader.ReadString(21); + writer.WriteString($"[{virtualHex.ToArray().ToHexString()}]车牌号", value.VehicleNo); + value.VehicleColor = (JT809VehicleColorType)reader.ReadByte(); + writer.WriteString($"[{((byte)value.VehicleColor).ReadNumber()}]车牌颜色", value.VehicleColor.ToString()); + value.SubBusinessType = reader.ReadUInt16(); + writer.WriteString($"[{value.SubBusinessType.ReadNumber()}]子业务类型标识", ((JT809SubBusinessType)value.SubBusinessType).ToString()); + value.DataLength = reader.ReadUInt32(); + writer.WriteNumber($"[{value.DataLength.ReadNumber()}]后续数据长度", value.DataLength); + try + { + if (config.SubBusinessTypeFactory.TryGetValue(value.SubBusinessType, out object instance)) + { + if (instance is JT809SubBodies subBodies) + { + if (!subBodies.SkipSerialization) + { + writer.WriteStartObject("子业务类型"); + instance.Analyze(ref reader, writer, config); + writer.WriteEndObject(); + } + } + } + } + catch + { + throw new JT809Exception(JT809ErrorCode.SubBodiesParseError, $"SubBusinessType>{value.SubBusinessType.ToString()}"); + } + } + public JT809_JT1078_0x1900 Deserialize(ref JT809MessagePackReader reader, IJT809Config config) { JT809_JT1078_0x1900 value = new JT809_JT1078_0x1900(); diff --git a/src/JT809.Protocol.Extensions.JT1078/MessageBody/JT809_JT1078_0x1900_0x1901.cs b/src/JT809.Protocol.Extensions.JT1078/MessageBody/JT809_JT1078_0x1900_0x1901.cs index 9521ad6..f364c53 100644 --- a/src/JT809.Protocol.Extensions.JT1078/MessageBody/JT809_JT1078_0x1900_0x1901.cs +++ b/src/JT809.Protocol.Extensions.JT1078/MessageBody/JT809_JT1078_0x1900_0x1901.cs @@ -1,14 +1,16 @@ using JT809.Protocol.Extensions.JT1078.Enums; using JT809.Protocol.Formatters; +using JT809.Protocol.Interfaces; using JT809.Protocol.MessagePack; using System.Collections.Generic; +using System.Text.Json; namespace JT809.Protocol.Extensions.JT1078.MessageBody { /// /// 主动上传音视频资源目录信息消息 /// - public class JT809_JT1078_0x1900_0x1901 : JT809SubBodies, IJT809MessagePackFormatter + public class JT809_JT1078_0x1900_0x1901 : JT809SubBodies, IJT809MessagePackFormatter, IJT809Analyze { /// /// 资源目录项数目 @@ -23,22 +25,42 @@ namespace JT809.Protocol.Extensions.JT1078.MessageBody public override string Description { get; } = "主动上传音视频资源目录信息消息"; + public void Analyze(ref JT809MessagePackReader reader, Utf8JsonWriter writer, IJT809Config config) + { + JT809_JT1078_0x1900_0x1901 value = new JT809_JT1078_0x1900_0x1901(); + value.ItemNum = reader.ReadUInt32(); + writer.WriteNumber($"[{value.ItemNum.ReadNumber() }]资源目录项数目", value.ItemNum); + if (value.ItemNum > 0) + { + writer.WriteStartArray("资源目录项列表"); + List jT808_JT1078_0x1900_0x1901_RecordList = new List(); + var formatter = config.GetMessagePackFormatter(); + for (int i = 0; i < value.ItemNum; i++) + { + writer.WriteStartObject(); + formatter.Analyze(ref reader, writer, config); + writer.WriteEndObject(); + } + writer.WriteEndArray(); + } + } + public JT809_JT1078_0x1900_0x1901 Deserialize(ref JT809MessagePackReader reader, IJT809Config config) { - JT809_JT1078_0x1900_0x1901 jT808_JT1078_0x1900_0x1901 = new JT809_JT1078_0x1900_0x1901(); - jT808_JT1078_0x1900_0x1901.ItemNum = reader.ReadUInt32(); - if (jT808_JT1078_0x1900_0x1901.ItemNum > 0) + JT809_JT1078_0x1900_0x1901 value = new JT809_JT1078_0x1900_0x1901(); + value.ItemNum = reader.ReadUInt32(); + if (value.ItemNum > 0) { List jT808_JT1078_0x1900_0x1901_RecordList = new List(); var formatter = config.GetMessagePackFormatter(); - for (int i = 0; i < jT808_JT1078_0x1900_0x1901.ItemNum; i++) + for (int i = 0; i < value.ItemNum; i++) { var jT808_JT1078_0x1900_0x1901_Record = formatter.Deserialize(ref reader, config); jT808_JT1078_0x1900_0x1901_RecordList.Add(jT808_JT1078_0x1900_0x1901_Record); } - jT808_JT1078_0x1900_0x1901.ItemList = jT808_JT1078_0x1900_0x1901_RecordList; + value.ItemList = jT808_JT1078_0x1900_0x1901_RecordList; } - return jT808_JT1078_0x1900_0x1901; + return value; } public void Serialize(ref JT809MessagePackWriter writer, JT809_JT1078_0x1900_0x1901 value, IJT809Config config) diff --git a/src/JT809.Protocol.Extensions.JT1078/MessageBody/JT809_JT1078_0x1900_0x1902.cs b/src/JT809.Protocol.Extensions.JT1078/MessageBody/JT809_JT1078_0x1900_0x1902.cs index b37c2ad..a636660 100644 --- a/src/JT809.Protocol.Extensions.JT1078/MessageBody/JT809_JT1078_0x1900_0x1902.cs +++ b/src/JT809.Protocol.Extensions.JT1078/MessageBody/JT809_JT1078_0x1900_0x1902.cs @@ -1,19 +1,21 @@ using JT809.Protocol.Extensions.JT1078.Enums; using JT809.Protocol.Formatters; +using JT809.Protocol.Interfaces; using JT809.Protocol.MessagePack; using System.Collections.Generic; +using System.Text.Json; namespace JT809.Protocol.Extensions.JT1078.MessageBody { /// /// 查询音视频资源目录应答消息 /// - public class JT809_JT1078_0x1900_0x1902 : JT809SubBodies, IJT809MessagePackFormatter + public class JT809_JT1078_0x1900_0x1902 : JT809SubBodies, IJT809MessagePackFormatter, IJT809Analyze { /// /// 应答结果 /// - public byte Result { get; set; } + public JT809_JT1078_0x1900_0x1902_Result Result { get; set; } /// /// 资源目录项数目 /// @@ -28,28 +30,51 @@ namespace JT809.Protocol.Extensions.JT1078.MessageBody public override string Description { get; } = "查询音视频资源目录应答消息"; + public void Analyze(ref JT809MessagePackReader reader, Utf8JsonWriter writer, IJT809Config config) + { + JT809_JT1078_0x1900_0x1902 value = new JT809_JT1078_0x1900_0x1902(); + value.Result = (JT809_JT1078_0x1900_0x1902_Result)reader.ReadByte(); + writer.WriteString($"[{((byte)value.Result).ReadNumber() }]应答结果", value.Result.ToString()); + value.ItemNum = reader.ReadUInt32(); + writer.WriteNumber($"[{value.ItemNum.ReadNumber() }]资源目录项数目", value.ItemNum); + if (value.ItemNum > 0) + { + writer.WriteStartArray("资源目录项列表"); + List jT808_JT1078_0x1900_0x1901_RecordList = new List(); + var formatter = config.GetMessagePackFormatter(); + for (int i = 0; i < value.ItemNum; i++) + { + writer.WriteStartObject(); + formatter.Analyze(ref reader, writer, config); + writer.WriteEndObject(); + } + writer.WriteEndArray(); + value.ItemList = jT808_JT1078_0x1900_0x1901_RecordList; + } + } + public JT809_JT1078_0x1900_0x1902 Deserialize(ref JT809MessagePackReader reader, IJT809Config config) { - JT809_JT1078_0x1900_0x1902 jT808_JT1078_0x1900_0x1902 = new JT809_JT1078_0x1900_0x1902(); - jT808_JT1078_0x1900_0x1902.Result = reader.ReadByte(); - jT808_JT1078_0x1900_0x1902.ItemNum = reader.ReadUInt32(); - if (jT808_JT1078_0x1900_0x1902.ItemNum > 0) + JT809_JT1078_0x1900_0x1902 value = new JT809_JT1078_0x1900_0x1902(); + value.Result = (JT809_JT1078_0x1900_0x1902_Result)reader.ReadByte(); + value.ItemNum = reader.ReadUInt32(); + if (value.ItemNum > 0) { List jT808_JT1078_0x1900_0x1901_RecordList = new List(); var formatter = config.GetMessagePackFormatter(); - for (int i = 0; i < jT808_JT1078_0x1900_0x1902.ItemNum; i++) + for (int i = 0; i < value.ItemNum; i++) { var jT808_JT1078_0x1900_0x1901_Record = formatter.Deserialize(ref reader, config); jT808_JT1078_0x1900_0x1901_RecordList.Add(jT808_JT1078_0x1900_0x1901_Record); } - jT808_JT1078_0x1900_0x1902.ItemList = jT808_JT1078_0x1900_0x1901_RecordList; + value.ItemList = jT808_JT1078_0x1900_0x1901_RecordList; } - return jT808_JT1078_0x1900_0x1902; + return value; } public void Serialize(ref JT809MessagePackWriter writer, JT809_JT1078_0x1900_0x1902 value, IJT809Config config) { - writer.WriteByte(value.Result); + writer.WriteByte((byte)value.Result); writer.WriteUInt32(value.ItemNum); if (value.ItemList.Count > 0) { diff --git a/src/JT809.Protocol.Extensions.JT1078/MessageBody/JT809_JT1078_0x1900_Record.cs b/src/JT809.Protocol.Extensions.JT1078/MessageBody/JT809_JT1078_0x1900_Record.cs index f4869e7..ed24388 100644 --- a/src/JT809.Protocol.Extensions.JT1078/MessageBody/JT809_JT1078_0x1900_Record.cs +++ b/src/JT809.Protocol.Extensions.JT1078/MessageBody/JT809_JT1078_0x1900_Record.cs @@ -1,15 +1,17 @@ using JT809.Protocol.Formatters; +using JT809.Protocol.Interfaces; using JT809.Protocol.MessagePack; using System; using System.Collections.Generic; using System.Text; +using System.Text.Json; namespace JT809.Protocol.Extensions.JT1078.MessageBody { /// /// 上传音视频资源目录项 /// - public class JT809_JT1078_0x1900_Record : IJT809MessagePackFormatter + public class JT809_JT1078_0x1900_Record : IJT809MessagePackFormatter, IJT809Analyze { /// /// 逻辑通道号 @@ -43,18 +45,119 @@ namespace JT809.Protocol.Extensions.JT1078.MessageBody /// 文件大小 /// public uint FileSize { get; set; } + + public void Analyze(ref JT809MessagePackReader reader, Utf8JsonWriter writer, IJT809Config config) + { + JT809_JT1078_0x1900_Record value = new JT809_JT1078_0x1900_Record(); + value.ChannelId = reader.ReadByte(); + writer.WriteString($"[{value.ChannelId.ReadNumber()}]逻辑通道号", LogicalChannelNoDisplay(value.ChannelId)); + var virtualHex = reader.ReadVirtualArray(8); + value.StartTime = reader.ReadUTCDateTime(); + writer.WriteString($"[{virtualHex.ToArray().ToHexString()}]开始时间", value.StartTime); + virtualHex = reader.ReadVirtualArray(8); + value.EndTime = reader.ReadUTCDateTime(); + writer.WriteString($"[{virtualHex.ToArray().ToHexString()}]结束时间", value.StartTime); + value.AlarmType = reader.ReadUInt64(); + writer.WriteNumber($"[{value.AlarmType.ReadNumber()}]报警标志物", value.AlarmType); + value.AVItemType = reader.ReadByte(); + writer.WriteString($"[{value.AVItemType.ReadNumber()}]音视频资源类型", AVResourceTypeDisplay(value.AVItemType)); + value.StreamType = reader.ReadByte(); + writer.WriteString($"[{value.StreamType.ReadNumber()}]码流类型", StreamTypeDisplay(value.StreamType)); + value.MemType = reader.ReadByte(); + writer.WriteString($"[{value.MemType.ReadNumber()}]存储器类型", MemoryTypeDisplay(value.MemType)); + value.FileSize = reader.ReadUInt32(); + writer.WriteNumber($"[{value.FileSize.ReadNumber()}]文件大小(B)", value.FileSize); + string LogicalChannelNoDisplay(byte LogicalChannelNo) + { + switch (LogicalChannelNo) + { + case 1: + return "驾驶员"; + case 2: + return "车辆正前方"; + case 3: + return "车前门"; + case 4: + return "车厢前部"; + case 5: + return "车厢后部"; + case 7: + return "行李舱"; + case 8: + return "车辆左侧"; + case 9: + return "车辆右侧"; + case 10: + return "车辆正后方"; + case 11: + return "车厢中部"; + case 12: + return "车中门"; + case 13: + return "驾驶席车门"; + case 33: + return "驾驶员"; + case 36: + return "车厢前部"; + case 37: + return "车厢后部"; + default: + return "预留"; + } + } + string AVResourceTypeDisplay(byte AVResourceType) + { + switch (AVResourceType) + { + case 0: + return "音视频"; + case 1: + return "音频"; + case 2: + return "视频"; + default: + break; + } + return "未知"; + } + string StreamTypeDisplay(byte StreamType) + { + switch (StreamType) + { + case 1: + return "主码流"; + case 2: + return "子码流"; + default: + return "未知"; + } + } + string MemoryTypeDisplay(byte MemoryType) + { + switch (MemoryType) + { + case 1: + return "主存储器"; + case 2: + return "灾备存储器"; + default: + return "未知"; + } + } + } + public JT809_JT1078_0x1900_Record Deserialize(ref JT809MessagePackReader reader, IJT809Config config) { - JT809_JT1078_0x1900_Record jT808_JT1078_0x1900_0x1901_Record = new JT809_JT1078_0x1900_Record(); - jT808_JT1078_0x1900_0x1901_Record.ChannelId = reader.ReadByte(); - jT808_JT1078_0x1900_0x1901_Record.StartTime = reader.ReadUTCDateTime(); - jT808_JT1078_0x1900_0x1901_Record.EndTime = reader.ReadUTCDateTime(); - jT808_JT1078_0x1900_0x1901_Record.AlarmType = reader.ReadUInt64(); - jT808_JT1078_0x1900_0x1901_Record.AVItemType = reader.ReadByte(); - jT808_JT1078_0x1900_0x1901_Record.StreamType = reader.ReadByte(); - jT808_JT1078_0x1900_0x1901_Record.MemType = reader.ReadByte(); - jT808_JT1078_0x1900_0x1901_Record.FileSize = reader.ReadUInt32(); - return jT808_JT1078_0x1900_0x1901_Record; + JT809_JT1078_0x1900_Record value = new JT809_JT1078_0x1900_Record(); + value.ChannelId = reader.ReadByte(); + value.StartTime = reader.ReadUTCDateTime(); + value.EndTime = reader.ReadUTCDateTime(); + value.AlarmType = reader.ReadUInt64(); + value.AVItemType = reader.ReadByte(); + value.StreamType = reader.ReadByte(); + value.MemType = reader.ReadByte(); + value.FileSize = reader.ReadUInt32(); + return value; } public void Serialize(ref JT809MessagePackWriter writer, JT809_JT1078_0x1900_Record value, IJT809Config config) diff --git a/src/JT809.Protocol.Extensions.JT1078/MessageBody/JT809_JT1078_0x1A00.cs b/src/JT809.Protocol.Extensions.JT1078/MessageBody/JT809_JT1078_0x1A00.cs index 605f619..3d78d48 100644 --- a/src/JT809.Protocol.Extensions.JT1078/MessageBody/JT809_JT1078_0x1A00.cs +++ b/src/JT809.Protocol.Extensions.JT1078/MessageBody/JT809_JT1078_0x1A00.cs @@ -1,7 +1,9 @@ -using JT809.Protocol.Enums; +using System.Text.Json; +using JT809.Protocol.Enums; using JT809.Protocol.Exceptions; using JT809.Protocol.Extensions.JT1078.Enums; using JT809.Protocol.Formatters; +using JT809.Protocol.Interfaces; using JT809.Protocol.MessagePack; namespace JT809.Protocol.Extensions.JT1078.MessageBody @@ -9,7 +11,7 @@ namespace JT809.Protocol.Extensions.JT1078.MessageBody /// /// 主链路远程录像回放交互消息 /// - public class JT809_JT1078_0x1A00 : JT809ExchangeMessageBodies, IJT809MessagePackFormatter + public class JT809_JT1078_0x1A00 : JT809ExchangeMessageBodies, IJT809MessagePackFormatter, IJT809Analyze { public override ushort MsgId { get; } = JT809_JT1078_BusinessType.主链路远程录像回放业务类.ToUInt16Value(); @@ -17,6 +19,39 @@ namespace JT809.Protocol.Extensions.JT1078.MessageBody public override string Description { get; } = "主链路远程录像回放交互消息"; + public void Analyze(ref JT809MessagePackReader reader, Utf8JsonWriter writer, IJT809Config config) + { + JT809_JT1078_0x1A00 value = new JT809_JT1078_0x1A00(); + var virtualHex = reader.ReadVirtualArray(21); + value.VehicleNo = reader.ReadString(21); + writer.WriteString($"[{virtualHex.ToArray().ToHexString()}]车牌号", value.VehicleNo); + value.VehicleColor = (JT809VehicleColorType)reader.ReadByte(); + writer.WriteString($"[{((byte)value.VehicleColor).ReadNumber()}]车牌颜色", value.VehicleColor.ToString()); + value.SubBusinessType = reader.ReadUInt16(); + writer.WriteString($"[{value.SubBusinessType.ReadNumber()}]子业务类型标识", ((JT809SubBusinessType)value.SubBusinessType).ToString()); + value.DataLength = reader.ReadUInt32(); + writer.WriteNumber($"[{value.DataLength.ReadNumber()}]后续数据长度", value.DataLength); + try + { + if (config.SubBusinessTypeFactory.TryGetValue(value.SubBusinessType, out object instance)) + { + if (instance is JT809SubBodies subBodies) + { + if (!subBodies.SkipSerialization) + { + writer.WriteStartObject("子业务类型"); + instance.Analyze(ref reader, writer, config); + writer.WriteEndObject(); + } + } + } + } + catch + { + throw new JT809Exception(JT809ErrorCode.SubBodiesParseError, $"SubBusinessType>{value.SubBusinessType.ToString()}"); + } + } + public JT809_JT1078_0x1A00 Deserialize(ref JT809MessagePackReader reader, IJT809Config config) { JT809_JT1078_0x1A00 value = new JT809_JT1078_0x1A00(); diff --git a/src/JT809.Protocol.Extensions.JT1078/MessageBody/JT809_JT1078_0x1A00_0x1A01.cs b/src/JT809.Protocol.Extensions.JT1078/MessageBody/JT809_JT1078_0x1A00_0x1A01.cs index 5d0fac2..846ff61 100644 --- a/src/JT809.Protocol.Extensions.JT1078/MessageBody/JT809_JT1078_0x1A00_0x1A01.cs +++ b/src/JT809.Protocol.Extensions.JT1078/MessageBody/JT809_JT1078_0x1A00_0x1A01.cs @@ -1,16 +1,18 @@ using JT809.Protocol.Extensions.JT1078.Enums; using JT809.Protocol.Formatters; +using JT809.Protocol.Interfaces; using JT809.Protocol.MessagePack; using System; using System.Collections.Generic; using System.Text; +using System.Text.Json; namespace JT809.Protocol.Extensions.JT1078.MessageBody { /// /// 远程录像回放请求应答消息 /// - public class JT809_JT1078_0x1A00_0x1A01 : JT809SubBodies, IJT809MessagePackFormatter + public class JT809_JT1078_0x1A00_0x1A01 : JT809SubBodies, IJT809MessagePackFormatter, IJT809Analyze { /// /// 企业视频服务器ip地址 @@ -24,26 +26,38 @@ namespace JT809.Protocol.Extensions.JT1078.MessageBody /// /// 应答结果 /// - public byte Result { get; set; } + public JT809_JT1078_0x1A00_0x1A01_Result Result { get; set; } public override ushort SubMsgId { get; } = JT809_JT1078_SubBusinessType.远程录像回放请求应答消息.ToUInt16Value(); public override string Description { get; } = "远程录像回放请求应答消息"; + public void Analyze(ref JT809MessagePackReader reader, Utf8JsonWriter writer, IJT809Config config) + { + JT809_JT1078_0x1A00_0x1A01 value = new JT809_JT1078_0x1A00_0x1A01(); + var virtualHex = reader.ReadVirtualArray(32); + value.ServerIp = reader.ReadString(32); + writer.WriteString($"[{virtualHex.ToArray().ToHexString()}]企业视频服务器ip地址", value.ServerIp); + value.ServerPort = reader.ReadUInt16(); + writer.WriteNumber($"[{value.ServerPort.ReadNumber()}]企业视频服务器端口号", value.ServerPort); + value.Result = (JT809_JT1078_0x1A00_0x1A01_Result)reader.ReadByte(); + writer.WriteString($"[{((byte)value.Result).ReadNumber()}]应答结果", value.Result.ToString()); + } + public JT809_JT1078_0x1A00_0x1A01 Deserialize(ref JT809MessagePackReader reader, IJT809Config config) { - JT809_JT1078_0x1A00_0x1A01 jT808_JT1078_0x1A00_0x1A01 = new JT809_JT1078_0x1A00_0x1A01(); - jT808_JT1078_0x1A00_0x1A01.ServerIp = reader.ReadString(32); - jT808_JT1078_0x1A00_0x1A01.ServerPort = reader.ReadUInt16(); - jT808_JT1078_0x1A00_0x1A01.Result = reader.ReadByte(); - return jT808_JT1078_0x1A00_0x1A01; + JT809_JT1078_0x1A00_0x1A01 value = new JT809_JT1078_0x1A00_0x1A01(); + value.ServerIp = reader.ReadString(32); + value.ServerPort = reader.ReadUInt16(); + value.Result = (JT809_JT1078_0x1A00_0x1A01_Result)reader.ReadByte(); + return value; } public void Serialize(ref JT809MessagePackWriter writer, JT809_JT1078_0x1A00_0x1A01 value, IJT809Config config) { writer.WriteStringPadLeft(value.ServerIp, 32); writer.WriteUInt16(value.ServerPort); - writer.WriteByte(value.Result); + writer.WriteByte((byte)value.Result); } } } \ No newline at end of file diff --git a/src/JT809.Protocol.Extensions.JT1078/MessageBody/JT809_JT1078_0x1A00_0x1A02.cs b/src/JT809.Protocol.Extensions.JT1078/MessageBody/JT809_JT1078_0x1A00_0x1A02.cs index b4c8b32..0e323ce 100644 --- a/src/JT809.Protocol.Extensions.JT1078/MessageBody/JT809_JT1078_0x1A00_0x1A02.cs +++ b/src/JT809.Protocol.Extensions.JT1078/MessageBody/JT809_JT1078_0x1A00_0x1A02.cs @@ -1,5 +1,7 @@ -using JT809.Protocol.Extensions.JT1078.Enums; +using System.Text.Json; +using JT809.Protocol.Extensions.JT1078.Enums; using JT809.Protocol.Formatters; +using JT809.Protocol.Interfaces; using JT809.Protocol.MessagePack; namespace JT809.Protocol.Extensions.JT1078.MessageBody @@ -7,27 +9,34 @@ namespace JT809.Protocol.Extensions.JT1078.MessageBody /// /// 远程录像回放控制应答消息 /// - public class JT809_JT1078_0x1A00_0x1A02 : JT809SubBodies, IJT809MessagePackFormatter + public class JT809_JT1078_0x1A00_0x1A02 : JT809SubBodies, IJT809MessagePackFormatter, IJT809Analyze { /// /// 应答结果 /// - public byte Result { get; set; } + public JT809_JT1078_0x1A00_0x1A02_Result Result { get; set; } public override ushort SubMsgId { get; } = JT809_JT1078_SubBusinessType.远程录像回放控制应答消息.ToUInt16Value(); public override string Description { get; } = "远程录像回放控制应答消息"; + public void Analyze(ref JT809MessagePackReader reader, Utf8JsonWriter writer, IJT809Config config) + { + JT809_JT1078_0x1A00_0x1A02 value = new JT809_JT1078_0x1A00_0x1A02(); + value.Result = (JT809_JT1078_0x1A00_0x1A02_Result)reader.ReadByte(); + writer.WriteString($"[{((byte)value.Result).ReadNumber()}]应答结果", value.Result.ToString()); + } + public JT809_JT1078_0x1A00_0x1A02 Deserialize(ref JT809MessagePackReader reader, IJT809Config config) { - JT809_JT1078_0x1A00_0x1A02 jT808_JT1078_0x1A00_0x1A02 = new JT809_JT1078_0x1A00_0x1A02(); - jT808_JT1078_0x1A00_0x1A02.Result = reader.ReadByte(); - return jT808_JT1078_0x1A00_0x1A02; + JT809_JT1078_0x1A00_0x1A02 value = new JT809_JT1078_0x1A00_0x1A02(); + value.Result = (JT809_JT1078_0x1A00_0x1A02_Result)reader.ReadByte(); + return value; } public void Serialize(ref JT809MessagePackWriter writer, JT809_JT1078_0x1A00_0x1A02 value, IJT809Config config) { - writer.WriteByte(value.Result); + writer.WriteByte((byte)value.Result); } } } \ No newline at end of file diff --git a/src/JT809.Protocol.Extensions.JT1078/MessageBody/JT809_JT1078_0x1B00.cs b/src/JT809.Protocol.Extensions.JT1078/MessageBody/JT809_JT1078_0x1B00.cs index 0a37b2d..fed0c64 100644 --- a/src/JT809.Protocol.Extensions.JT1078/MessageBody/JT809_JT1078_0x1B00.cs +++ b/src/JT809.Protocol.Extensions.JT1078/MessageBody/JT809_JT1078_0x1B00.cs @@ -1,7 +1,9 @@ -using JT809.Protocol.Enums; +using System.Text.Json; +using JT809.Protocol.Enums; using JT809.Protocol.Exceptions; using JT809.Protocol.Extensions.JT1078.Enums; using JT809.Protocol.Formatters; +using JT809.Protocol.Interfaces; using JT809.Protocol.MessagePack; namespace JT809.Protocol.Extensions.JT1078.MessageBody @@ -9,7 +11,7 @@ namespace JT809.Protocol.Extensions.JT1078.MessageBody /// /// 主链路远程录像下载交互消息 /// - public class JT809_JT1078_0x1B00 : JT809ExchangeMessageBodies, IJT809MessagePackFormatter + public class JT809_JT1078_0x1B00 : JT809ExchangeMessageBodies, IJT809MessagePackFormatter, IJT809Analyze { public override ushort MsgId { get; } = JT809_JT1078_BusinessType.主链路远程录像下载业务类.ToUInt16Value(); @@ -17,6 +19,38 @@ namespace JT809.Protocol.Extensions.JT1078.MessageBody public override string Description { get; } = "主链路远程录像下载交互消息"; + public void Analyze(ref JT809MessagePackReader reader, Utf8JsonWriter writer, IJT809Config config) + { + JT809_JT1078_0x1B00 value = new JT809_JT1078_0x1B00(); + var virtualHex = reader.ReadVirtualArray(21); + value.VehicleNo = reader.ReadString(21); + writer.WriteString($"[{virtualHex.ToArray().ToHexString()}]车牌号", value.VehicleNo); + value.VehicleColor = (JT809VehicleColorType)reader.ReadByte(); + writer.WriteString($"[{((byte)value.VehicleColor).ReadNumber()}]车牌颜色", value.VehicleColor.ToString()); + value.SubBusinessType = reader.ReadUInt16(); + writer.WriteString($"[{value.SubBusinessType.ReadNumber()}]子业务类型标识", ((JT809SubBusinessType)value.SubBusinessType).ToString()); + value.DataLength = reader.ReadUInt32(); + writer.WriteNumber($"[{value.DataLength.ReadNumber()}]后续数据长度", value.DataLength); + try + { + if (config.SubBusinessTypeFactory.TryGetValue(value.SubBusinessType, out object instance)) + { + if (instance is JT809SubBodies subBodies) + { + if (!subBodies.SkipSerialization) + { + writer.WriteStartObject("子业务类型"); + instance.Analyze(ref reader, writer, config); + writer.WriteEndObject(); + } + } + } + } + catch + { + throw new JT809Exception(JT809ErrorCode.SubBodiesParseError, $"SubBusinessType>{value.SubBusinessType.ToString()}"); + } + } public JT809_JT1078_0x1B00 Deserialize(ref JT809MessagePackReader reader, IJT809Config config) { diff --git a/src/JT809.Protocol.Extensions.JT1078/MessageBody/JT809_JT1078_0x1B00_0x1B01.cs b/src/JT809.Protocol.Extensions.JT1078/MessageBody/JT809_JT1078_0x1B00_0x1B01.cs index fa75990..6eabe2a 100644 --- a/src/JT809.Protocol.Extensions.JT1078/MessageBody/JT809_JT1078_0x1B00_0x1B01.cs +++ b/src/JT809.Protocol.Extensions.JT1078/MessageBody/JT809_JT1078_0x1B00_0x1B01.cs @@ -1,21 +1,23 @@ using JT809.Protocol.Extensions.JT1078.Enums; using JT809.Protocol.Formatters; +using JT809.Protocol.Interfaces; using JT809.Protocol.MessagePack; using System; using System.Collections.Generic; using System.Text; +using System.Text.Json; namespace JT809.Protocol.Extensions.JT1078.MessageBody { /// /// 远程录像下载请求应答消息 /// - public class JT809_JT1078_0x1B00_0x1B01 : JT809SubBodies, IJT809MessagePackFormatter + public class JT809_JT1078_0x1B00_0x1B01 : JT809SubBodies, IJT809MessagePackFormatter, IJT809Analyze { /// /// 应答结果 /// - public byte Result { get; set; } + public JT809_JT1078_0x1B00_0x1B01_Result Result { get; set; } /// /// 对应平台文件上传消息的流水号 /// @@ -25,17 +27,26 @@ namespace JT809.Protocol.Extensions.JT1078.MessageBody public override string Description { get; } = "远程录像下载请求应答消息"; + public void Analyze(ref JT809MessagePackReader reader, Utf8JsonWriter writer, IJT809Config config) + { + JT809_JT1078_0x1B00_0x1B01 value = new JT809_JT1078_0x1B00_0x1B01(); + value.Result = (JT809_JT1078_0x1B00_0x1B01_Result)reader.ReadByte(); + writer.WriteString($"[{((byte)value.Result).ReadNumber() }]应答结果", value.Result.ToString()); + value.SessionId = reader.ReadUInt16(); + writer.WriteNumber($"[{value.SessionId.ReadNumber()}]对应平台文件上传消息的流水号", value.SessionId); + } + public JT809_JT1078_0x1B00_0x1B01 Deserialize(ref JT809MessagePackReader reader, IJT809Config config) { - JT809_JT1078_0x1B00_0x1B01 jT808_JT1078_0x1B00_0x1B01 = new JT809_JT1078_0x1B00_0x1B01(); - jT808_JT1078_0x1B00_0x1B01.Result = reader.ReadByte(); - jT808_JT1078_0x1B00_0x1B01.SessionId = reader.ReadUInt16(); - return jT808_JT1078_0x1B00_0x1B01; + JT809_JT1078_0x1B00_0x1B01 value = new JT809_JT1078_0x1B00_0x1B01(); + value.Result = (JT809_JT1078_0x1B00_0x1B01_Result)reader.ReadByte(); + value.SessionId = reader.ReadUInt16(); + return value; } public void Serialize(ref JT809MessagePackWriter writer, JT809_JT1078_0x1B00_0x1B01 value, IJT809Config config) { - writer.WriteByte(value.Result); + writer.WriteByte((byte)value.Result); writer.WriteUInt16(value.SessionId); } } diff --git a/src/JT809.Protocol.Extensions.JT1078/MessageBody/JT809_JT1078_0x1B00_0x1B02.cs b/src/JT809.Protocol.Extensions.JT1078/MessageBody/JT809_JT1078_0x1B00_0x1B02.cs index 0faf8e0..fd30508 100644 --- a/src/JT809.Protocol.Extensions.JT1078/MessageBody/JT809_JT1078_0x1B00_0x1B02.cs +++ b/src/JT809.Protocol.Extensions.JT1078/MessageBody/JT809_JT1078_0x1B00_0x1B02.cs @@ -1,5 +1,7 @@ -using JT809.Protocol.Extensions.JT1078.Enums; +using System.Text.Json; +using JT809.Protocol.Extensions.JT1078.Enums; using JT809.Protocol.Formatters; +using JT809.Protocol.Interfaces; using JT809.Protocol.MessagePack; namespace JT809.Protocol.Extensions.JT1078.MessageBody @@ -7,12 +9,12 @@ namespace JT809.Protocol.Extensions.JT1078.MessageBody /// /// 远程录像下载通知消息 /// - public class JT809_JT1078_0x1B00_0x1B02 : JT809SubBodies, IJT809MessagePackFormatter + public class JT809_JT1078_0x1B00_0x1B02 : JT809SubBodies, IJT809MessagePackFormatter, IJT809Analyze { /// /// 应答结果 /// - public byte Result { get; set; } + public JT809_JT1078_0x1B00_0x1B02_Result Result { get; set; } /// /// 对应平台文件上传消息的流水号 /// @@ -45,22 +47,45 @@ namespace JT809.Protocol.Extensions.JT1078.MessageBody public override string Description { get; } = "远程录像下载通知消息"; + public void Analyze(ref JT809MessagePackReader reader, Utf8JsonWriter writer, IJT809Config config) + { + JT809_JT1078_0x1B00_0x1B02 value = new JT809_JT1078_0x1B00_0x1B02(); + value.Result = (JT809_JT1078_0x1B00_0x1B02_Result)reader.ReadByte(); + writer.WriteString($"[{((byte)value.Result).ReadNumber() }]应答结果", value.Result.ToString()); + value.SessionId = reader.ReadUInt16(); + writer.WriteNumber($"[{value.SessionId.ReadNumber()}]对应平台文件上传消息的流水号", value.SessionId); + var virtualHex = reader.ReadVirtualArray(32); + value.ServerIp = reader.ReadString(32); + writer.WriteString($"[{virtualHex.ToArray().ToHexString()}]FTP服务器ip地址", value.ServerIp); + value.TcpPort = reader.ReadUInt16(); + writer.WriteNumber($"[{value.TcpPort.ReadNumber()}]FTP服务器端口", value.TcpPort); + virtualHex = reader.ReadVirtualArray(49); + value.UserName = reader.ReadString(49); + writer.WriteString($"[{virtualHex.ToArray().ToHexString()}]FTP用户名", value.UserName); + virtualHex = reader.ReadVirtualArray(22); + value.Password = reader.ReadString(22); + writer.WriteString($"[{virtualHex.ToArray().ToHexString()}]FTP密码", value.Password); + virtualHex = reader.ReadVirtualArray(200); + value.FilePath = reader.ReadString(200); + writer.WriteString($"[{virtualHex.ToArray().ToHexString()}]文件存储路径", value.FilePath); + } + public JT809_JT1078_0x1B00_0x1B02 Deserialize(ref JT809MessagePackReader reader, IJT809Config config) { - JT809_JT1078_0x1B00_0x1B02 jT808_JT1078_0x1B00_0x1B02 = new JT809_JT1078_0x1B00_0x1B02(); - jT808_JT1078_0x1B00_0x1B02.Result = reader.ReadByte(); - jT808_JT1078_0x1B00_0x1B02.SessionId = reader.ReadUInt16(); - jT808_JT1078_0x1B00_0x1B02.ServerIp = reader.ReadString(32); - jT808_JT1078_0x1B00_0x1B02.TcpPort = reader.ReadUInt16(); - jT808_JT1078_0x1B00_0x1B02.UserName = reader.ReadString(49); - jT808_JT1078_0x1B00_0x1B02.Password = reader.ReadString(22); - jT808_JT1078_0x1B00_0x1B02.FilePath = reader.ReadString(200); - return jT808_JT1078_0x1B00_0x1B02; + JT809_JT1078_0x1B00_0x1B02 value = new JT809_JT1078_0x1B00_0x1B02(); + value.Result = (JT809_JT1078_0x1B00_0x1B02_Result)reader.ReadByte(); + value.SessionId = reader.ReadUInt16(); + value.ServerIp = reader.ReadString(32); + value.TcpPort = reader.ReadUInt16(); + value.UserName = reader.ReadString(49); + value.Password = reader.ReadString(22); + value.FilePath = reader.ReadString(200); + return value; } public void Serialize(ref JT809MessagePackWriter writer, JT809_JT1078_0x1B00_0x1B02 value, IJT809Config config) { - writer.WriteByte(value.Result); + writer.WriteByte((byte)value.Result); writer.WriteUInt16(value.SessionId); writer.WriteStringPadLeft(value.ServerIp, 32); writer.WriteUInt16(value.TcpPort); diff --git a/src/JT809.Protocol.Extensions.JT1078/MessageBody/JT809_JT1078_0x1B00_0x1B03.cs b/src/JT809.Protocol.Extensions.JT1078/MessageBody/JT809_JT1078_0x1B00_0x1B03.cs index a9d3292..d96a421 100644 --- a/src/JT809.Protocol.Extensions.JT1078/MessageBody/JT809_JT1078_0x1B00_0x1B03.cs +++ b/src/JT809.Protocol.Extensions.JT1078/MessageBody/JT809_JT1078_0x1B00_0x1B03.cs @@ -1,5 +1,7 @@ -using JT809.Protocol.Extensions.JT1078.Enums; +using System.Text.Json; +using JT809.Protocol.Extensions.JT1078.Enums; using JT809.Protocol.Formatters; +using JT809.Protocol.Interfaces; using JT809.Protocol.MessagePack; namespace JT809.Protocol.Extensions.JT1078.MessageBody @@ -7,27 +9,34 @@ namespace JT809.Protocol.Extensions.JT1078.MessageBody /// /// 远程录像下载控制应答消息 /// - public class JT809_JT1078_0x1B00_0x1B03 : JT809SubBodies, IJT809MessagePackFormatter + public class JT809_JT1078_0x1B00_0x1B03 : JT809SubBodies, IJT809MessagePackFormatter, IJT809Analyze { /// /// 应答结果 /// - public byte Result { get; set; } + public JT809_JT1078_0x1B00_0x1B03_Result Result { get; set; } public override ushort SubMsgId { get; } = JT809_JT1078_SubBusinessType.远程录像下载控制应答消息.ToUInt16Value(); public override string Description { get; } = "远程录像下载控制应答消息"; + public void Analyze(ref JT809MessagePackReader reader, Utf8JsonWriter writer, IJT809Config config) + { + JT809_JT1078_0x1B00_0x1B03 value = new JT809_JT1078_0x1B00_0x1B03(); + value.Result = (JT809_JT1078_0x1B00_0x1B03_Result)reader.ReadByte(); + writer.WriteString($"[{((byte)value.Result).ReadNumber()}]应答结果", value.Result.ToString()); + } + public JT809_JT1078_0x1B00_0x1B03 Deserialize(ref JT809MessagePackReader reader, IJT809Config config) { - JT809_JT1078_0x1B00_0x1B03 jT808_JT1078_0x1B00_0x1B01 = new JT809_JT1078_0x1B00_0x1B03(); - jT808_JT1078_0x1B00_0x1B01.Result = reader.ReadByte(); - return jT808_JT1078_0x1B00_0x1B01; + JT809_JT1078_0x1B00_0x1B03 value = new JT809_JT1078_0x1B00_0x1B03(); + value.Result = (JT809_JT1078_0x1B00_0x1B03_Result)reader.ReadByte(); + return value; } public void Serialize(ref JT809MessagePackWriter writer, JT809_JT1078_0x1B00_0x1B03 value, IJT809Config config) { - writer.WriteByte(value.Result); + writer.WriteByte((byte)value.Result); } } } \ No newline at end of file diff --git a/src/JT809.Protocol.Extensions.JT1078/MessageBody/JT809_JT1078_0x9700.cs b/src/JT809.Protocol.Extensions.JT1078/MessageBody/JT809_JT1078_0x9700.cs index 67b7e58..dd425fd 100644 --- a/src/JT809.Protocol.Extensions.JT1078/MessageBody/JT809_JT1078_0x9700.cs +++ b/src/JT809.Protocol.Extensions.JT1078/MessageBody/JT809_JT1078_0x9700.cs @@ -1,7 +1,9 @@ -using JT809.Protocol.Enums; +using System.Text.Json; +using JT809.Protocol.Enums; using JT809.Protocol.Exceptions; using JT809.Protocol.Extensions.JT1078.Enums; using JT809.Protocol.Formatters; +using JT809.Protocol.Interfaces; using JT809.Protocol.MessagePack; namespace JT809.Protocol.Extensions.JT1078.MessageBody @@ -9,7 +11,7 @@ namespace JT809.Protocol.Extensions.JT1078.MessageBody /// /// 从链路时效口令交互消息 /// - public class JT809_JT1078_0x9700 : JT809ExchangeMessageBodies, IJT809MessagePackFormatter + public class JT809_JT1078_0x9700 : JT809ExchangeMessageBodies, IJT809MessagePackFormatter, IJT809Analyze { public override ushort MsgId { get; } = JT809_JT1078_BusinessType.从链路时效口令业务类.ToUInt16Value(); @@ -17,6 +19,39 @@ namespace JT809.Protocol.Extensions.JT1078.MessageBody public override string Description { get; } = "从链路时效口令交互消息"; + public void Analyze(ref JT809MessagePackReader reader, Utf8JsonWriter writer, IJT809Config config) + { + JT809_JT1078_0x9700 value = new JT809_JT1078_0x9700(); + var virtualHex = reader.ReadVirtualArray(21); + value.VehicleNo = reader.ReadString(21); + writer.WriteString($"[{virtualHex.ToArray().ToHexString()}]车牌号", value.VehicleNo); + value.VehicleColor = (JT809VehicleColorType)reader.ReadByte(); + writer.WriteString($"[{((byte)value.VehicleColor).ReadNumber()}]车牌颜色", value.VehicleColor.ToString()); + value.SubBusinessType = reader.ReadUInt16(); + writer.WriteString($"[{value.SubBusinessType.ReadNumber()}]子业务类型标识", ((JT809SubBusinessType)value.SubBusinessType).ToString()); + value.DataLength = reader.ReadUInt32(); + writer.WriteNumber($"[{value.DataLength.ReadNumber()}]后续数据长度", value.DataLength); + try + { + if (config.SubBusinessTypeFactory.TryGetValue(value.SubBusinessType, out object instance)) + { + if (instance is JT809SubBodies subBodies) + { + if (!subBodies.SkipSerialization) + { + writer.WriteStartObject("子业务类型"); + instance.Analyze(ref reader, writer, config); + writer.WriteEndObject(); + } + } + } + } + catch + { + throw new JT809Exception(JT809ErrorCode.SubBodiesParseError, $"SubBusinessType>{value.SubBusinessType.ToString()}"); + } + } + public JT809_JT1078_0x9700 Deserialize(ref JT809MessagePackReader reader, IJT809Config config) { JT809_JT1078_0x9700 value = new JT809_JT1078_0x9700(); diff --git a/src/JT809.Protocol.Extensions.JT1078/MessageBody/JT809_JT1078_0x9800.cs b/src/JT809.Protocol.Extensions.JT1078/MessageBody/JT809_JT1078_0x9800.cs index a4989d4..7c3eb08 100644 --- a/src/JT809.Protocol.Extensions.JT1078/MessageBody/JT809_JT1078_0x9800.cs +++ b/src/JT809.Protocol.Extensions.JT1078/MessageBody/JT809_JT1078_0x9800.cs @@ -1,7 +1,9 @@ -using JT809.Protocol.Enums; +using System.Text.Json; +using JT809.Protocol.Enums; using JT809.Protocol.Exceptions; using JT809.Protocol.Extensions.JT1078.Enums; using JT809.Protocol.Formatters; +using JT809.Protocol.Interfaces; using JT809.Protocol.MessagePack; namespace JT809.Protocol.Extensions.JT1078.MessageBody @@ -9,7 +11,7 @@ namespace JT809.Protocol.Extensions.JT1078.MessageBody /// /// 从链路实时音视频交互信息 /// - public class JT809_JT1078_0x9800 : JT809ExchangeMessageBodies, IJT809MessagePackFormatter + public class JT809_JT1078_0x9800 : JT809ExchangeMessageBodies, IJT809MessagePackFormatter, IJT809Analyze { public override ushort MsgId { get; } = JT809_JT1078_BusinessType.从链路实时音视频业务类.ToUInt16Value(); @@ -17,6 +19,39 @@ namespace JT809.Protocol.Extensions.JT1078.MessageBody public override string Description { get; } = "从链路实时音视频交互信息"; + public void Analyze(ref JT809MessagePackReader reader, Utf8JsonWriter writer, IJT809Config config) + { + JT809_JT1078_0x9800 value = new JT809_JT1078_0x9800(); + var virtualHex = reader.ReadVirtualArray(21); + value.VehicleNo = reader.ReadString(21); + writer.WriteString($"[{virtualHex.ToArray().ToHexString()}]车牌号", value.VehicleNo); + value.VehicleColor = (JT809VehicleColorType)reader.ReadByte(); + writer.WriteString($"[{((byte)value.VehicleColor).ReadNumber()}]车牌颜色", value.VehicleColor.ToString()); + value.SubBusinessType = reader.ReadUInt16(); + writer.WriteString($"[{value.SubBusinessType.ReadNumber()}]子业务类型标识", ((JT809SubBusinessType)value.SubBusinessType).ToString()); + value.DataLength = reader.ReadUInt32(); + writer.WriteNumber($"[{value.DataLength.ReadNumber()}]后续数据长度", value.DataLength); + try + { + if (config.SubBusinessTypeFactory.TryGetValue(value.SubBusinessType, out object instance)) + { + if (instance is JT809SubBodies subBodies) + { + if (!subBodies.SkipSerialization) + { + writer.WriteStartObject("子业务类型"); + instance.Analyze(ref reader, writer, config); + writer.WriteEndObject(); + } + } + } + } + catch + { + throw new JT809Exception(JT809ErrorCode.SubBodiesParseError, $"SubBusinessType>{value.SubBusinessType.ToString()}"); + } + } + public JT809_JT1078_0x9800 Deserialize(ref JT809MessagePackReader reader, IJT809Config config) { JT809_JT1078_0x9800 value = new JT809_JT1078_0x9800(); diff --git a/src/JT809.Protocol.Extensions.JT1078/MessageBody/JT809_JT1078_0x9800_0x9801.cs b/src/JT809.Protocol.Extensions.JT1078/MessageBody/JT809_JT1078_0x9800_0x9801.cs index cf61c9d..0e75c23 100644 --- a/src/JT809.Protocol.Extensions.JT1078/MessageBody/JT809_JT1078_0x9800_0x9801.cs +++ b/src/JT809.Protocol.Extensions.JT1078/MessageBody/JT809_JT1078_0x9800_0x9801.cs @@ -1,5 +1,7 @@ -using JT809.Protocol.Extensions.JT1078.Enums; +using System.Text.Json; +using JT809.Protocol.Extensions.JT1078.Enums; using JT809.Protocol.Formatters; +using JT809.Protocol.Interfaces; using JT809.Protocol.MessagePack; namespace JT809.Protocol.Extensions.JT1078.MessageBody @@ -7,7 +9,7 @@ namespace JT809.Protocol.Extensions.JT1078.MessageBody /// /// 实时音视频请求消息 /// - public class JT809_JT1078_0x9800_0x9801 : JT809SubBodies, IJT809MessagePackFormatter + public class JT809_JT1078_0x9800_0x9801 : JT809SubBodies, IJT809MessagePackFormatter, IJT809Analyze { /// /// 逻辑通道号 @@ -20,7 +22,7 @@ namespace JT809.Protocol.Extensions.JT1078.MessageBody /// /// 时效口令 /// - public byte[] AuthorizeCode { get; set; } + public string AuthorizeCode { get; set; } /// /// 车辆进入跨域地区后5min之内的任何位置,仅跨域访问请求时使用此字段 /// @@ -30,21 +32,89 @@ namespace JT809.Protocol.Extensions.JT1078.MessageBody public override string Description { get; } = "实时音视频请求消息"; + public void Analyze(ref JT809MessagePackReader reader, Utf8JsonWriter writer, IJT809Config config) + { + JT809_JT1078_0x9800_0x9801 value = new JT809_JT1078_0x9800_0x9801(); + value.ChannelId = reader.ReadByte(); + writer.WriteString($"[{value.ChannelId.ReadNumber()}]逻辑通道号", LogicalChannelNoDisplay(value.ChannelId)); + value.AVitemType = reader.ReadByte(); + writer.WriteString($"[{value.AVitemType.ReadNumber()}]音视频资源类型", AVResourceTypeDisplay(value.AVitemType)); + var virtualHex = reader.ReadVirtualArray(64); + value.AuthorizeCode = reader.ReadString(64); + writer.WriteString($"[{virtualHex.ToArray().ToHexString()}]时效口令", value.AuthorizeCode); + virtualHex = reader.ReadVirtualArray(36); + value.GnssData = reader.ReadArray(36).ToArray(); + writer.WriteString($"[{virtualHex.ToArray().ToHexString()}]车辆进入跨域地区后5min之内的任何位置", virtualHex.ToArray().ToHexString()); + string LogicalChannelNoDisplay(byte LogicalChannelNo) + { + switch (LogicalChannelNo) + { + case 1: + return "驾驶员"; + case 2: + return "车辆正前方"; + case 3: + return "车前门"; + case 4: + return "车厢前部"; + case 5: + return "车厢后部"; + case 7: + return "行李舱"; + case 8: + return "车辆左侧"; + case 9: + return "车辆右侧"; + case 10: + return "车辆正后方"; + case 11: + return "车厢中部"; + case 12: + return "车中门"; + case 13: + return "驾驶席车门"; + case 33: + return "驾驶员"; + case 36: + return "车厢前部"; + case 37: + return "车厢后部"; + default: + return "预留"; + } + } + string AVResourceTypeDisplay(byte AVResourceType) + { + switch (AVResourceType) + { + case 0: + return "音视频"; + case 1: + return "音频"; + case 2: + return "视频"; + default: + break; + } + return "未知"; + } + } + public JT809_JT1078_0x9800_0x9801 Deserialize(ref JT809MessagePackReader reader, IJT809Config config) { - JT809_JT1078_0x9800_0x9801 jT808_JT1078_0x9800_0x9801 = new JT809_JT1078_0x9800_0x9801(); - jT808_JT1078_0x9800_0x9801.ChannelId = reader.ReadByte(); - jT808_JT1078_0x9800_0x9801.AVitemType = reader.ReadByte(); - jT808_JT1078_0x9800_0x9801.AuthorizeCode = reader.ReadArray(64).ToArray(); - jT808_JT1078_0x9800_0x9801.GnssData = reader.ReadArray(36).ToArray(); - return jT808_JT1078_0x9800_0x9801; + JT809_JT1078_0x9800_0x9801 value = new JT809_JT1078_0x9800_0x9801(); + value.ChannelId = reader.ReadByte(); + value.AVitemType = reader.ReadByte(); + value.AuthorizeCode = reader.ReadString(64); + value.GnssData = reader.ReadArray(36).ToArray(); + return value; } public void Serialize(ref JT809MessagePackWriter writer, JT809_JT1078_0x9800_0x9801 value, IJT809Config config) { writer.WriteByte(value.ChannelId); writer.WriteByte(value.AVitemType); - writer.WriteArray(value.AuthorizeCode); + writer.WriteStringPadRight(value.AuthorizeCode,64); writer.WriteArray(value.GnssData); } } diff --git a/src/JT809.Protocol.Extensions.JT1078/MessageBody/JT809_JT1078_0x9800_0x9802.cs b/src/JT809.Protocol.Extensions.JT1078/MessageBody/JT809_JT1078_0x9800_0x9802.cs index 8ab9a48..636f88f 100644 --- a/src/JT809.Protocol.Extensions.JT1078/MessageBody/JT809_JT1078_0x9800_0x9802.cs +++ b/src/JT809.Protocol.Extensions.JT1078/MessageBody/JT809_JT1078_0x9800_0x9802.cs @@ -1,5 +1,7 @@ -using JT809.Protocol.Extensions.JT1078.Enums; +using System.Text.Json; +using JT809.Protocol.Extensions.JT1078.Enums; using JT809.Protocol.Formatters; +using JT809.Protocol.Interfaces; using JT809.Protocol.MessagePack; namespace JT809.Protocol.Extensions.JT1078.MessageBody @@ -7,7 +9,7 @@ namespace JT809.Protocol.Extensions.JT1078.MessageBody /// /// 主动请求停止实时音视频传输消息 /// - public class JT809_JT1078_0x9800_0x9802 : JT809SubBodies, IJT809MessagePackFormatter + public class JT809_JT1078_0x9800_0x9802 : JT809SubBodies, IJT809MessagePackFormatter, IJT809Analyze { /// /// 逻辑通道号 @@ -22,12 +24,74 @@ namespace JT809.Protocol.Extensions.JT1078.MessageBody public override string Description { get; } = "主动请求停止实时音视频传输消息"; + public void Analyze(ref JT809MessagePackReader reader, Utf8JsonWriter writer, IJT809Config config) + { + JT809_JT1078_0x9800_0x9802 value = new JT809_JT1078_0x9800_0x9802(); + value.ChannelId = reader.ReadByte(); + writer.WriteString($"[{value.ChannelId.ReadNumber()}]逻辑通道号", LogicalChannelNoDisplay(value.ChannelId)); + value.AVitemType = reader.ReadByte(); + writer.WriteString($"[{value.AVitemType.ReadNumber()}]音视频资源类型", AVResourceTypeDisplay(value.AVitemType)); + string LogicalChannelNoDisplay(byte LogicalChannelNo) + { + switch (LogicalChannelNo) + { + case 1: + return "驾驶员"; + case 2: + return "车辆正前方"; + case 3: + return "车前门"; + case 4: + return "车厢前部"; + case 5: + return "车厢后部"; + case 7: + return "行李舱"; + case 8: + return "车辆左侧"; + case 9: + return "车辆右侧"; + case 10: + return "车辆正后方"; + case 11: + return "车厢中部"; + case 12: + return "车中门"; + case 13: + return "驾驶席车门"; + case 33: + return "驾驶员"; + case 36: + return "车厢前部"; + case 37: + return "车厢后部"; + default: + return "预留"; + } + } + string AVResourceTypeDisplay(byte AVResourceType) + { + switch (AVResourceType) + { + case 0: + return "音视频"; + case 1: + return "音频"; + case 2: + return "视频"; + default: + break; + } + return "未知"; + } + } + public JT809_JT1078_0x9800_0x9802 Deserialize(ref JT809MessagePackReader reader, IJT809Config config) { - JT809_JT1078_0x9800_0x9802 jT808_JT1078_0x9800_0x9802 = new JT809_JT1078_0x9800_0x9802(); - jT808_JT1078_0x9800_0x9802.ChannelId = reader.ReadByte(); - jT808_JT1078_0x9800_0x9802.AVitemType = reader.ReadByte(); - return jT808_JT1078_0x9800_0x9802; + JT809_JT1078_0x9800_0x9802 value = new JT809_JT1078_0x9800_0x9802(); + value.ChannelId = reader.ReadByte(); + value.AVitemType = reader.ReadByte(); + return value; } public void Serialize(ref JT809MessagePackWriter writer, JT809_JT1078_0x9800_0x9802 value, IJT809Config config) diff --git a/src/JT809.Protocol.Extensions.JT1078/MessageBody/JT809_JT1078_0x9900.cs b/src/JT809.Protocol.Extensions.JT1078/MessageBody/JT809_JT1078_0x9900.cs index 2f8abf5..648cc1c 100644 --- a/src/JT809.Protocol.Extensions.JT1078/MessageBody/JT809_JT1078_0x9900.cs +++ b/src/JT809.Protocol.Extensions.JT1078/MessageBody/JT809_JT1078_0x9900.cs @@ -1,7 +1,9 @@ -using JT809.Protocol.Enums; +using System.Text.Json; +using JT809.Protocol.Enums; using JT809.Protocol.Exceptions; using JT809.Protocol.Extensions.JT1078.Enums; using JT809.Protocol.Formatters; +using JT809.Protocol.Interfaces; using JT809.Protocol.MessagePack; namespace JT809.Protocol.Extensions.JT1078.MessageBody @@ -9,7 +11,7 @@ namespace JT809.Protocol.Extensions.JT1078.MessageBody /// /// 从链路远程录像检索交互消息 /// - public class JT809_JT1078_0x9900 : JT809ExchangeMessageBodies, IJT809MessagePackFormatter + public class JT809_JT1078_0x9900 : JT809ExchangeMessageBodies, IJT809MessagePackFormatter, IJT809Analyze { public override ushort MsgId { get; } = JT809_JT1078_BusinessType.从链路远程录像检索业务类.ToUInt16Value(); @@ -17,6 +19,39 @@ namespace JT809.Protocol.Extensions.JT1078.MessageBody public override string Description { get; } = "从链路远程录像检索交互消息"; + public void Analyze(ref JT809MessagePackReader reader, Utf8JsonWriter writer, IJT809Config config) + { + JT809_JT1078_0x9900 value = new JT809_JT1078_0x9900(); + var virtualHex = reader.ReadVirtualArray(21); + value.VehicleNo = reader.ReadString(21); + writer.WriteString($"[{virtualHex.ToArray().ToHexString()}]车牌号", value.VehicleNo); + value.VehicleColor = (JT809VehicleColorType)reader.ReadByte(); + writer.WriteString($"[{((byte)value.VehicleColor).ReadNumber()}]车牌颜色", value.VehicleColor.ToString()); + value.SubBusinessType = reader.ReadUInt16(); + writer.WriteString($"[{value.SubBusinessType.ReadNumber()}]子业务类型标识", ((JT809SubBusinessType)value.SubBusinessType).ToString()); + value.DataLength = reader.ReadUInt32(); + writer.WriteNumber($"[{value.DataLength.ReadNumber()}]后续数据长度", value.DataLength); + try + { + if (config.SubBusinessTypeFactory.TryGetValue(value.SubBusinessType, out object instance)) + { + if (instance is JT809SubBodies subBodies) + { + if (!subBodies.SkipSerialization) + { + writer.WriteStartObject("子业务类型"); + instance.Analyze(ref reader, writer, config); + writer.WriteEndObject(); + } + } + } + } + catch + { + throw new JT809Exception(JT809ErrorCode.SubBodiesParseError, $"SubBusinessType>{value.SubBusinessType.ToString()}"); + } + } + public JT809_JT1078_0x9900 Deserialize(ref JT809MessagePackReader reader, IJT809Config config) { JT809_JT1078_0x9900 value = new JT809_JT1078_0x9900(); diff --git a/src/JT809.Protocol.Extensions.JT1078/MessageBody/JT809_JT1078_0x9900_0x9901.cs b/src/JT809.Protocol.Extensions.JT1078/MessageBody/JT809_JT1078_0x9900_0x9901.cs index 2f92955..396d95d 100644 --- a/src/JT809.Protocol.Extensions.JT1078/MessageBody/JT809_JT1078_0x9900_0x9901.cs +++ b/src/JT809.Protocol.Extensions.JT1078/MessageBody/JT809_JT1078_0x9900_0x9901.cs @@ -1,5 +1,7 @@ -using JT809.Protocol.Extensions.JT1078.Enums; +using System.Text.Json; +using JT809.Protocol.Extensions.JT1078.Enums; using JT809.Protocol.Formatters; +using JT809.Protocol.Interfaces; using JT809.Protocol.MessagePack; namespace JT809.Protocol.Extensions.JT1078.MessageBody @@ -7,12 +9,12 @@ namespace JT809.Protocol.Extensions.JT1078.MessageBody /// /// 主动上传音视频资源目录信息应答消息 /// - public class JT809_JT1078_0x9900_0x9901 : JT809SubBodies, IJT809MessagePackFormatter + public class JT809_JT1078_0x9900_0x9901 : JT809SubBodies, IJT809MessagePackFormatter, IJT809Analyze { /// /// 应答结果 /// - public byte Result { get; set; } + public JT809_JT1078_0x9900_0x9901_Result Result { get; set; } /// /// 资源目录总数 /// @@ -22,17 +24,26 @@ namespace JT809.Protocol.Extensions.JT1078.MessageBody public override string Description { get; } = "主动上传音视频资源目录信息应答消息"; + public void Analyze(ref JT809MessagePackReader reader, Utf8JsonWriter writer, IJT809Config config) + { + JT809_JT1078_0x9900_0x9901 value = new JT809_JT1078_0x9900_0x9901(); + value.Result = (JT809_JT1078_0x9900_0x9901_Result)reader.ReadByte(); + writer.WriteString($"[{ (byte)value.Result }]应答结果", value.Result.ToString()); + value.ItemNumber = reader.ReadByte(); + writer.WriteNumber($"[{value.ItemNumber.ReadNumber()}]资源目录总数", value.ItemNumber); + } + public JT809_JT1078_0x9900_0x9901 Deserialize(ref JT809MessagePackReader reader, IJT809Config config) { - JT809_JT1078_0x9900_0x9901 jT808_JT1078_0x9900_0x9901 = new JT809_JT1078_0x9900_0x9901(); - jT808_JT1078_0x9900_0x9901.Result = reader.ReadByte(); - jT808_JT1078_0x9900_0x9901.ItemNumber = reader.ReadByte(); - return jT808_JT1078_0x9900_0x9901; + JT809_JT1078_0x9900_0x9901 value = new JT809_JT1078_0x9900_0x9901(); + value.Result = (JT809_JT1078_0x9900_0x9901_Result)reader.ReadByte(); + value.ItemNumber = reader.ReadByte(); + return value; } public void Serialize(ref JT809MessagePackWriter writer, JT809_JT1078_0x9900_0x9901 value, IJT809Config config) { - writer.WriteByte(value.Result); + writer.WriteByte((byte)value.Result); writer.WriteByte(value.ItemNumber); } } diff --git a/src/JT809.Protocol.Extensions.JT1078/MessageBody/JT809_JT1078_0x9900_0x9902.cs b/src/JT809.Protocol.Extensions.JT1078/MessageBody/JT809_JT1078_0x9900_0x9902.cs index 46b2821..7f22c8a 100644 --- a/src/JT809.Protocol.Extensions.JT1078/MessageBody/JT809_JT1078_0x9900_0x9902.cs +++ b/src/JT809.Protocol.Extensions.JT1078/MessageBody/JT809_JT1078_0x9900_0x9902.cs @@ -1,14 +1,16 @@ using JT809.Protocol.Extensions.JT1078.Enums; using JT809.Protocol.Formatters; +using JT809.Protocol.Interfaces; using JT809.Protocol.MessagePack; using System; +using System.Text.Json; namespace JT809.Protocol.Extensions.JT1078.MessageBody { /// /// 查询音视频资源目录请求消息 /// - public class JT809_JT1078_0x9900_0x9902 : JT809SubBodies, IJT809MessagePackFormatter + public class JT809_JT1078_0x9900_0x9902 : JT809SubBodies, IJT809MessagePackFormatter, IJT809Analyze { /// /// 逻辑通道号 @@ -42,7 +44,7 @@ namespace JT809.Protocol.Extensions.JT1078.MessageBody /// 时效口令 /// 64 /// - public byte[] AuthorizeCode { get; set; } + public string AuthorizeCode { get; set; } /// /// 车辆进入跨域地区后5min之内任一位置,仅跨域访问请求时,使用此字段 /// 36 @@ -53,20 +55,123 @@ namespace JT809.Protocol.Extensions.JT1078.MessageBody public override string Description { get; } = "查询音视频资源目录请求消息"; + public void Analyze(ref JT809MessagePackReader reader, Utf8JsonWriter writer, IJT809Config config) + { + JT809_JT1078_0x9900_0x9902 value = new JT809_JT1078_0x9900_0x9902(); + value.ChannelId = reader.ReadByte(); + writer.WriteString($"[{value.ChannelId.ReadNumber()}]逻辑通道号", LogicalChannelNoDisplay(value.ChannelId)); + var virtualHex = reader.ReadVirtualArray(8); + value.StartTime = reader.ReadUTCDateTime(); + writer.WriteString($"[{virtualHex.ToArray().ToHexString()}]开始时间", value.StartTime); + virtualHex = reader.ReadVirtualArray(8); + value.EndTime = reader.ReadUTCDateTime(); + writer.WriteString($"[{virtualHex.ToArray().ToHexString()}]结束时间", value.StartTime); + value.AlarmType = reader.ReadUInt64(); + writer.WriteNumber($"[{value.AlarmType.ReadNumber()}]报警标志物", value.AlarmType); + value.AVItemType = reader.ReadByte(); + writer.WriteString($"[{value.AVItemType.ReadNumber()}]音视频资源类型", AVResourceTypeDisplay(value.AVItemType)); + value.StreamType = reader.ReadByte(); + writer.WriteString($"[{value.StreamType.ReadNumber()}]码流类型", StreamTypeDisplay(value.StreamType)); + value.MemType = reader.ReadByte(); + writer.WriteString($"[{value.MemType.ReadNumber()}]存储器类型", MemoryTypeDisplay(value.MemType)); + virtualHex = reader.ReadVirtualArray(64); + value.AuthorizeCode = reader.ReadString(64); + writer.WriteString($"[{virtualHex.ToArray().ToHexString()}]时效口令", value.AuthorizeCode); + virtualHex = reader.ReadVirtualArray(36); + value.GnssData = reader.ReadArray(36).ToArray(); + writer.WriteString($"[{virtualHex.ToArray().ToHexString()}]车辆进入跨域地区后5min之内任一位置", virtualHex.ToArray().ToHexString()); + string LogicalChannelNoDisplay(byte LogicalChannelNo) + { + switch (LogicalChannelNo) + { + case 1: + return "驾驶员"; + case 2: + return "车辆正前方"; + case 3: + return "车前门"; + case 4: + return "车厢前部"; + case 5: + return "车厢后部"; + case 7: + return "行李舱"; + case 8: + return "车辆左侧"; + case 9: + return "车辆右侧"; + case 10: + return "车辆正后方"; + case 11: + return "车厢中部"; + case 12: + return "车中门"; + case 13: + return "驾驶席车门"; + case 33: + return "驾驶员"; + case 36: + return "车厢前部"; + case 37: + return "车厢后部"; + default: + return "预留"; + } + } + string AVResourceTypeDisplay(byte AVResourceType) + { + switch (AVResourceType) + { + case 0: + return "音视频"; + case 1: + return "音频"; + case 2: + return "视频"; + default: + break; + } + return "未知"; + } + string StreamTypeDisplay(byte StreamType) + { + switch (StreamType) + { + case 1: + return "主码流"; + case 2: + return "子码流"; + default: + return "未知"; + } + } + string MemoryTypeDisplay(byte MemoryType) + { + switch (MemoryType) + { + case 1: + return "主存储器"; + case 2: + return "灾备存储器"; + default: + return "未知"; + } + } + } + public JT809_JT1078_0x9900_0x9902 Deserialize(ref JT809MessagePackReader reader, IJT809Config config) { - JT809_JT1078_0x9900_0x9902 jT808_JT1078_0x9900_0x9902 = new JT809_JT1078_0x9900_0x9902(); - jT808_JT1078_0x9900_0x9902.ChannelId = reader.ReadByte(); -#warning 此处时间8个字节,暂使用utc时间代替 - jT808_JT1078_0x9900_0x9902.StartTime = reader.ReadUTCDateTime(); - jT808_JT1078_0x9900_0x9902.EndTime = reader.ReadUTCDateTime(); - jT808_JT1078_0x9900_0x9902.AlarmType = reader.ReadUInt64(); - jT808_JT1078_0x9900_0x9902.AVItemType = reader.ReadByte(); - jT808_JT1078_0x9900_0x9902.StreamType = reader.ReadByte(); - jT808_JT1078_0x9900_0x9902.MemType = reader.ReadByte(); - jT808_JT1078_0x9900_0x9902.AuthorizeCode = reader.ReadArray(64).ToArray(); - jT808_JT1078_0x9900_0x9902.GnssData = reader.ReadArray(36).ToArray(); - return jT808_JT1078_0x9900_0x9902; + JT809_JT1078_0x9900_0x9902 value = new JT809_JT1078_0x9900_0x9902(); + value.ChannelId = reader.ReadByte(); + value.StartTime = reader.ReadUTCDateTime(); + value.EndTime = reader.ReadUTCDateTime(); + value.AlarmType = reader.ReadUInt64(); + value.AVItemType = reader.ReadByte(); + value.StreamType = reader.ReadByte(); + value.MemType = reader.ReadByte(); + value.AuthorizeCode = reader.ReadString(64); + value.GnssData = reader.ReadArray(36).ToArray(); + return value; } public void Serialize(ref JT809MessagePackWriter writer, JT809_JT1078_0x9900_0x9902 value, IJT809Config config) @@ -78,7 +183,7 @@ namespace JT809.Protocol.Extensions.JT1078.MessageBody writer.WriteByte(value.AVItemType); writer.WriteByte(value.StreamType); writer.WriteByte(value.MemType); - writer.WriteArray(value.AuthorizeCode); + writer.WriteStringPadRight(value.AuthorizeCode, 64); writer.WriteArray(value.GnssData); } } diff --git a/src/JT809.Protocol.Extensions.JT1078/MessageBody/JT809_JT1078_0x9A00.cs b/src/JT809.Protocol.Extensions.JT1078/MessageBody/JT809_JT1078_0x9A00.cs index 8448fa4..7030750 100644 --- a/src/JT809.Protocol.Extensions.JT1078/MessageBody/JT809_JT1078_0x9A00.cs +++ b/src/JT809.Protocol.Extensions.JT1078/MessageBody/JT809_JT1078_0x9A00.cs @@ -1,7 +1,9 @@ -using JT809.Protocol.Enums; +using System.Text.Json; +using JT809.Protocol.Enums; using JT809.Protocol.Exceptions; using JT809.Protocol.Extensions.JT1078.Enums; using JT809.Protocol.Formatters; +using JT809.Protocol.Interfaces; using JT809.Protocol.MessagePack; namespace JT809.Protocol.Extensions.JT1078.MessageBody @@ -9,7 +11,7 @@ namespace JT809.Protocol.Extensions.JT1078.MessageBody /// /// 从链路远程录像回放交互消息 /// - public class JT809_JT1078_0x9A00 : JT809ExchangeMessageBodies, IJT809MessagePackFormatter + public class JT809_JT1078_0x9A00 : JT809ExchangeMessageBodies, IJT809MessagePackFormatter, IJT809Analyze { public override ushort MsgId { get; } = JT809_JT1078_BusinessType.从链路远程录像回放业务类.ToUInt16Value(); @@ -17,6 +19,39 @@ namespace JT809.Protocol.Extensions.JT1078.MessageBody public override string Description { get; } = "从链路远程录像回放交互消息"; + public void Analyze(ref JT809MessagePackReader reader, Utf8JsonWriter writer, IJT809Config config) + { + JT809_JT1078_0x9A00 value = new JT809_JT1078_0x9A00(); + var virtualHex = reader.ReadVirtualArray(21); + value.VehicleNo = reader.ReadString(21); + writer.WriteString($"[{virtualHex.ToArray().ToHexString()}]车牌号", value.VehicleNo); + value.VehicleColor = (JT809VehicleColorType)reader.ReadByte(); + writer.WriteString($"[{((byte)value.VehicleColor).ReadNumber()}]车牌颜色", value.VehicleColor.ToString()); + value.SubBusinessType = reader.ReadUInt16(); + writer.WriteString($"[{value.SubBusinessType.ReadNumber()}]子业务类型标识", ((JT809SubBusinessType)value.SubBusinessType).ToString()); + value.DataLength = reader.ReadUInt32(); + writer.WriteNumber($"[{value.DataLength.ReadNumber()}]后续数据长度", value.DataLength); + try + { + if (config.SubBusinessTypeFactory.TryGetValue(value.SubBusinessType, out object instance)) + { + if (instance is JT809SubBodies subBodies) + { + if (!subBodies.SkipSerialization) + { + writer.WriteStartObject("子业务类型"); + instance.Analyze(ref reader, writer, config); + writer.WriteEndObject(); + } + } + } + } + catch + { + throw new JT809Exception(JT809ErrorCode.SubBodiesParseError, $"SubBusinessType>{value.SubBusinessType.ToString()}"); + } + } + public JT809_JT1078_0x9A00 Deserialize(ref JT809MessagePackReader reader, IJT809Config config) { JT809_JT1078_0x9A00 value = new JT809_JT1078_0x9A00(); diff --git a/src/JT809.Protocol.Extensions.JT1078/MessageBody/JT809_JT1078_0x9A00_0x9A01.cs b/src/JT809.Protocol.Extensions.JT1078/MessageBody/JT809_JT1078_0x9A00_0x9A01.cs index 9028654..87f1c92 100644 --- a/src/JT809.Protocol.Extensions.JT1078/MessageBody/JT809_JT1078_0x9A00_0x9A01.cs +++ b/src/JT809.Protocol.Extensions.JT1078/MessageBody/JT809_JT1078_0x9A00_0x9A01.cs @@ -1,14 +1,16 @@ using JT809.Protocol.Extensions.JT1078.Enums; using JT809.Protocol.Formatters; +using JT809.Protocol.Interfaces; using JT809.Protocol.MessagePack; using System; +using System.Text.Json; namespace JT809.Protocol.Extensions.JT1078.MessageBody { /// /// 远程录像回放请求消息 /// - public class JT809_JT1078_0x9A00_0x9A01 : JT809SubBodies, IJT809MessagePackFormatter + public class JT809_JT1078_0x9A00_0x9A01 : JT809SubBodies, IJT809MessagePackFormatter, IJT809Analyze { /// /// 逻辑通道号 @@ -38,7 +40,7 @@ namespace JT809.Protocol.Extensions.JT1078.MessageBody /// 时效口令 /// 64 /// - public byte[] AuthorizeCode { get; set; } + public string AuthorizeCode { get; set; } /// /// 车辆进入跨域地区后5min之内任一位置,仅跨域访问请求时,使用此字段 /// 36 @@ -49,18 +51,120 @@ namespace JT809.Protocol.Extensions.JT1078.MessageBody public override string Description { get; } = "远程录像回放请求消息"; + public void Analyze(ref JT809MessagePackReader reader, Utf8JsonWriter writer, IJT809Config config) + { + JT809_JT1078_0x9A00_0x9A01 value = new JT809_JT1078_0x9A00_0x9A01(); + value.ChannelId = reader.ReadByte(); + writer.WriteString($"[{value.ChannelId.ReadNumber()}]逻辑通道号", LogicalChannelNoDisplay(value.ChannelId)); + value.AVItemType = reader.ReadByte(); + writer.WriteString($"[{value.AVItemType.ReadNumber()}]音视频资源类型", AVResourceTypeDisplay(value.AVItemType)); + value.StreamType = reader.ReadByte(); + writer.WriteString($"[{value.StreamType.ReadNumber()}]码流类型", StreamTypeDisplay(value.StreamType)); + value.MemType = reader.ReadByte(); + writer.WriteString($"[{value.MemType.ReadNumber()}]存储器类型", MemoryTypeDisplay(value.MemType)); + var virtualHex = reader.ReadVirtualArray(8); + value.PlayBackStartTime = reader.ReadUTCDateTime(); + writer.WriteString($"[{virtualHex.ToArray().ToHexString()}]回放开始时间", value.PlayBackStartTime); + virtualHex = reader.ReadVirtualArray(8); + value.PlayBackEndTime = reader.ReadUTCDateTime(); + writer.WriteString($"[{virtualHex.ToArray().ToHexString()}]回放结束时间", value.PlayBackEndTime); + virtualHex = reader.ReadVirtualArray(64); + value.AuthorizeCode = reader.ReadString(64); + writer.WriteString($"[{virtualHex.ToArray().ToHexString()}]时效口令", value.AuthorizeCode); + virtualHex = reader.ReadVirtualArray(36); + value.GnssData = reader.ReadArray(36).ToArray(); + writer.WriteString($"[{virtualHex.ToArray().ToHexString()}]车辆进入跨域地区后5min之内任一位置", virtualHex.ToArray().ToHexString()); + string LogicalChannelNoDisplay(byte LogicalChannelNo) + { + switch (LogicalChannelNo) + { + case 1: + return "驾驶员"; + case 2: + return "车辆正前方"; + case 3: + return "车前门"; + case 4: + return "车厢前部"; + case 5: + return "车厢后部"; + case 7: + return "行李舱"; + case 8: + return "车辆左侧"; + case 9: + return "车辆右侧"; + case 10: + return "车辆正后方"; + case 11: + return "车厢中部"; + case 12: + return "车中门"; + case 13: + return "驾驶席车门"; + case 33: + return "驾驶员"; + case 36: + return "车厢前部"; + case 37: + return "车厢后部"; + default: + return "预留"; + } + } + string AVResourceTypeDisplay(byte AVResourceType) + { + switch (AVResourceType) + { + case 0: + return "音视频"; + case 1: + return "音频"; + case 2: + return "视频"; + default: + break; + } + return "未知"; + } + string StreamTypeDisplay(byte StreamType) + { + switch (StreamType) + { + case 1: + return "主码流"; + case 2: + return "子码流"; + default: + return "未知"; + } + } + string MemoryTypeDisplay(byte MemoryType) + { + switch (MemoryType) + { + case 1: + return "主存储器"; + case 2: + return "灾备存储器"; + default: + return "未知"; + } + } + } + public JT809_JT1078_0x9A00_0x9A01 Deserialize(ref JT809MessagePackReader reader, IJT809Config config) { - JT809_JT1078_0x9A00_0x9A01 jT808_JT1078_0x9A00_0x9A01 = new JT809_JT1078_0x9A00_0x9A01(); - jT808_JT1078_0x9A00_0x9A01.ChannelId = reader.ReadByte(); - jT808_JT1078_0x9A00_0x9A01.AVItemType = reader.ReadByte(); - jT808_JT1078_0x9A00_0x9A01.StreamType = reader.ReadByte(); - jT808_JT1078_0x9A00_0x9A01.MemType = reader.ReadByte(); - jT808_JT1078_0x9A00_0x9A01.PlayBackStartTime = reader.ReadUTCDateTime(); - jT808_JT1078_0x9A00_0x9A01.PlayBackEndTime = reader.ReadUTCDateTime(); - jT808_JT1078_0x9A00_0x9A01.AuthorizeCode = reader.ReadArray(64).ToArray(); - jT808_JT1078_0x9A00_0x9A01.GnssData = reader.ReadArray(36).ToArray(); - return jT808_JT1078_0x9A00_0x9A01; + JT809_JT1078_0x9A00_0x9A01 value = new JT809_JT1078_0x9A00_0x9A01(); + value.ChannelId = reader.ReadByte(); + value.AVItemType = reader.ReadByte(); + value.StreamType = reader.ReadByte(); + value.MemType = reader.ReadByte(); + value.PlayBackStartTime = reader.ReadUTCDateTime(); + value.PlayBackEndTime = reader.ReadUTCDateTime(); + value.AuthorizeCode = reader.ReadString(64); + value.GnssData = reader.ReadArray(36).ToArray(); + return value; } public void Serialize(ref JT809MessagePackWriter writer, JT809_JT1078_0x9A00_0x9A01 value, IJT809Config config) @@ -71,7 +175,7 @@ namespace JT809.Protocol.Extensions.JT1078.MessageBody writer.WriteByte(value.MemType); writer.WriteUTCDateTime(value.PlayBackStartTime); writer.WriteUTCDateTime(value.PlayBackEndTime); - writer.WriteArray(value.AuthorizeCode); + writer.WriteStringPadRight(value.AuthorizeCode, 64); writer.WriteArray(value.GnssData); } } diff --git a/src/JT809.Protocol.Extensions.JT1078/MessageBody/JT809_JT1078_0x9A00_0x9A02.cs b/src/JT809.Protocol.Extensions.JT1078/MessageBody/JT809_JT1078_0x9A00_0x9A02.cs index 13fd3fd..bb17410 100644 --- a/src/JT809.Protocol.Extensions.JT1078/MessageBody/JT809_JT1078_0x9A00_0x9A02.cs +++ b/src/JT809.Protocol.Extensions.JT1078/MessageBody/JT809_JT1078_0x9A00_0x9A02.cs @@ -1,23 +1,25 @@ using JT809.Protocol.Extensions.JT1078.Enums; using JT809.Protocol.Formatters; +using JT809.Protocol.Interfaces; using JT809.Protocol.MessagePack; using System; +using System.Text.Json; namespace JT809.Protocol.Extensions.JT1078.MessageBody { /// /// 远程录像回放控制消息 /// - public class JT809_JT1078_0x9A00_0x9A02 : JT809SubBodies, IJT809MessagePackFormatter + public class JT809_JT1078_0x9A00_0x9A02 : JT809SubBodies, IJT809MessagePackFormatter, IJT809Analyze { /// /// 控制类型 /// - public byte ControlType { get; set; } + public ControlType ControlType { get; set; } /// /// 快进或倒退倍数 /// - public byte FastTime { get; set; } + public FastTime FastTime { get; set; } /// /// 拖动位置 /// @@ -26,19 +28,32 @@ namespace JT809.Protocol.Extensions.JT1078.MessageBody public override ushort SubMsgId { get; } = JT809_JT1078_SubBusinessType.远程录像回放控制消息.ToUInt16Value(); public override string Description { get; } = "远程录像回放控制消息"; + + public void Analyze(ref JT809MessagePackReader reader, Utf8JsonWriter writer, IJT809Config config) + { + JT809_JT1078_0x9A00_0x9A02 value = new JT809_JT1078_0x9A00_0x9A02(); + value.ControlType = (ControlType)reader.ReadByte(); + writer.WriteString($"[{((byte)value.ControlType).ReadNumber()}]控制类型", value.ControlType.ToString()); + value.FastTime = (FastTime)reader.ReadByte(); + writer.WriteString($"[{((byte)value.FastTime).ReadNumber()}]快进或倒退倍数", value.FastTime.ToString()); + var virtualHex = reader.ReadVirtualArray(8); + value.DateTime = reader.ReadUTCDateTime(); + writer.WriteString($"[{virtualHex.ToArray().ToHexString()}]拖动位置", value.DateTime); + } + public JT809_JT1078_0x9A00_0x9A02 Deserialize(ref JT809MessagePackReader reader, IJT809Config config) { - JT809_JT1078_0x9A00_0x9A02 jT808_JT1078_0x9A00_0x9A02 = new JT809_JT1078_0x9A00_0x9A02(); - jT808_JT1078_0x9A00_0x9A02.ControlType = reader.ReadByte(); - jT808_JT1078_0x9A00_0x9A02.FastTime = reader.ReadByte(); - jT808_JT1078_0x9A00_0x9A02.DateTime = reader.ReadUTCDateTime(); - return jT808_JT1078_0x9A00_0x9A02; + JT809_JT1078_0x9A00_0x9A02 value = new JT809_JT1078_0x9A00_0x9A02(); + value.ControlType = (ControlType)reader.ReadByte(); + value.FastTime = (FastTime)reader.ReadByte(); + value.DateTime = reader.ReadUTCDateTime(); + return value; } public void Serialize(ref JT809MessagePackWriter writer, JT809_JT1078_0x9A00_0x9A02 value, IJT809Config config) { - writer.WriteByte(value.ControlType); - writer.WriteByte(value.FastTime); + writer.WriteByte((byte)value.ControlType); + writer.WriteByte((byte)value.FastTime); writer.WriteUTCDateTime(value.DateTime); } } diff --git a/src/JT809.Protocol.Extensions.JT1078/MessageBody/JT809_JT1078_0x9B00.cs b/src/JT809.Protocol.Extensions.JT1078/MessageBody/JT809_JT1078_0x9B00.cs index 21ae9ad..62a4791 100644 --- a/src/JT809.Protocol.Extensions.JT1078/MessageBody/JT809_JT1078_0x9B00.cs +++ b/src/JT809.Protocol.Extensions.JT1078/MessageBody/JT809_JT1078_0x9B00.cs @@ -2,17 +2,19 @@ using JT809.Protocol.Exceptions; using JT809.Protocol.Extensions.JT1078.Enums; using JT809.Protocol.Formatters; +using JT809.Protocol.Interfaces; using JT809.Protocol.MessagePack; using System; using System.Collections.Generic; using System.Text; +using System.Text.Json; namespace JT809.Protocol.Extensions.JT1078.MessageBody { /// /// 从链路远程录像下载交互消息 /// - public class JT809_JT1078_0x9B00 : JT809ExchangeMessageBodies, IJT809MessagePackFormatter + public class JT809_JT1078_0x9B00 : JT809ExchangeMessageBodies, IJT809MessagePackFormatter, IJT809Analyze { public override ushort MsgId { get; } = JT809_JT1078_BusinessType.从链路远程录像下载业务类.ToUInt16Value(); @@ -20,6 +22,39 @@ namespace JT809.Protocol.Extensions.JT1078.MessageBody public override string Description { get; } = "从链路远程录像下载交互消息"; + public void Analyze(ref JT809MessagePackReader reader, Utf8JsonWriter writer, IJT809Config config) + { + JT809_JT1078_0x9B00 value = new JT809_JT1078_0x9B00(); + var virtualHex = reader.ReadVirtualArray(21); + value.VehicleNo = reader.ReadString(21); + writer.WriteString($"[{virtualHex.ToArray().ToHexString()}]车牌号", value.VehicleNo); + value.VehicleColor = (JT809VehicleColorType)reader.ReadByte(); + writer.WriteString($"[{((byte)value.VehicleColor).ReadNumber()}]车牌颜色", value.VehicleColor.ToString()); + value.SubBusinessType = reader.ReadUInt16(); + writer.WriteString($"[{value.SubBusinessType.ReadNumber()}]子业务类型标识", ((JT809SubBusinessType)value.SubBusinessType).ToString()); + value.DataLength = reader.ReadUInt32(); + writer.WriteNumber($"[{value.DataLength.ReadNumber()}]后续数据长度", value.DataLength); + try + { + if (config.SubBusinessTypeFactory.TryGetValue(value.SubBusinessType, out object instance)) + { + if (instance is JT809SubBodies subBodies) + { + if (!subBodies.SkipSerialization) + { + writer.WriteStartObject("子业务类型"); + instance.Analyze(ref reader, writer, config); + writer.WriteEndObject(); + } + } + } + } + catch + { + throw new JT809Exception(JT809ErrorCode.SubBodiesParseError, $"SubBusinessType>{value.SubBusinessType.ToString()}"); + } + } + public JT809_JT1078_0x9B00 Deserialize(ref JT809MessagePackReader reader, IJT809Config config) { JT809_JT1078_0x9B00 value = new JT809_JT1078_0x9B00(); diff --git a/src/JT809.Protocol.Extensions.JT1078/MessageBody/JT809_JT1078_0x9B00_0x9B01.cs b/src/JT809.Protocol.Extensions.JT1078/MessageBody/JT809_JT1078_0x9B00_0x9B01.cs index 5b727aa..3887ba9 100644 --- a/src/JT809.Protocol.Extensions.JT1078/MessageBody/JT809_JT1078_0x9B00_0x9B01.cs +++ b/src/JT809.Protocol.Extensions.JT1078/MessageBody/JT809_JT1078_0x9B00_0x9B01.cs @@ -2,17 +2,19 @@ using JT809.Protocol.Extensions.JT1078.Enums; using JT809.Protocol.Extensions.JT1078.Formatters; using JT809.Protocol.Formatters; +using JT809.Protocol.Interfaces; using JT809.Protocol.MessagePack; using System; using System.Collections.Generic; using System.Text; +using System.Text.Json; namespace JT809.Protocol.Extensions.JT1078.MessageBody { /// /// 远程录像下载请求消息 /// - public class JT809_JT1078_0x9B00_0x9B01 : JT809SubBodies, IJT809MessagePackFormatter + public class JT809_JT1078_0x9B00_0x9B01 : JT809SubBodies, IJT809MessagePackFormatter, IJT809Analyze { /// /// 逻辑通道号 @@ -50,7 +52,7 @@ namespace JT809.Protocol.Extensions.JT1078.MessageBody /// 时效口令 /// 64 /// - public byte[] AuthorizeCode { get; set; } + public string AuthorizeCode { get; set; } /// /// 车辆进入跨域地区后5min之内任一位置,仅跨域访问请求时,使用此字段 /// 36 @@ -60,20 +62,127 @@ namespace JT809.Protocol.Extensions.JT1078.MessageBody public override ushort SubMsgId { get; } = JT809_JT1078_SubBusinessType.远程录像下载请求消息.ToUInt16Value(); public override string Description { get; } = "远程录像下载请求消息"; + + public void Analyze(ref JT809MessagePackReader reader, Utf8JsonWriter writer, IJT809Config config) + { + JT809_JT1078_0x9B00_0x9B01 value = new JT809_JT1078_0x9B00_0x9B01(); + value.ChannelId = reader.ReadByte(); + writer.WriteString($"[{value.ChannelId.ReadNumber()}]逻辑通道号", LogicalChannelNoDisplay(value.ChannelId)); + var virtualHex = reader.ReadVirtualArray(8); + value.StartTime = reader.ReadUTCDateTime(); + writer.WriteString($"[{virtualHex.ToArray().ToHexString()}]开始时间", value.StartTime); + virtualHex = reader.ReadVirtualArray(8); + value.EndTime = reader.ReadUTCDateTime(); + writer.WriteString($"[{virtualHex.ToArray().ToHexString()}]结束时间", value.StartTime); + value.AlarmType = reader.ReadUInt64(); + writer.WriteNumber($"[{value.AlarmType.ReadNumber()}]报警标志物", value.AlarmType); + value.AVItemType = reader.ReadByte(); + writer.WriteString($"[{value.AVItemType.ReadNumber()}]音视频资源类型", AVResourceTypeDisplay(value.AVItemType)); + value.StreamType = reader.ReadByte(); + writer.WriteString($"[{value.StreamType.ReadNumber()}]码流类型", StreamTypeDisplay(value.StreamType)); + value.MemType = reader.ReadByte(); + writer.WriteString($"[{value.MemType.ReadNumber()}]存储器类型", MemoryTypeDisplay(value.MemType)); + value.FileSize = reader.ReadUInt32(); + writer.WriteNumber($"[{value.FileSize.ReadNumber()}文件大小 byte]", value.FileSize); + virtualHex = reader.ReadVirtualArray(64); + value.AuthorizeCode = reader.ReadString(64); + writer.WriteString($"[{virtualHex.ToArray().ToHexString()}]时效口令", value.AuthorizeCode); + virtualHex = reader.ReadVirtualArray(36); + value.GnssData = reader.ReadArray(36).ToArray(); + writer.WriteString($"[{virtualHex.ToArray().ToHexString()}]车辆进入跨域地区后5min之内任一位置", virtualHex.ToArray().ToHexString()); + string LogicalChannelNoDisplay(byte LogicalChannelNo) + { + switch (LogicalChannelNo) + { + case 1: + return "驾驶员"; + case 2: + return "车辆正前方"; + case 3: + return "车前门"; + case 4: + return "车厢前部"; + case 5: + return "车厢后部"; + case 7: + return "行李舱"; + case 8: + return "车辆左侧"; + case 9: + return "车辆右侧"; + case 10: + return "车辆正后方"; + case 11: + return "车厢中部"; + case 12: + return "车中门"; + case 13: + return "驾驶席车门"; + case 33: + return "驾驶员"; + case 36: + return "车厢前部"; + case 37: + return "车厢后部"; + default: + return "预留"; + } + } + string AVResourceTypeDisplay(byte AVResourceType) + { + switch (AVResourceType) + { + case 0: + return "音视频"; + case 1: + return "音频"; + case 2: + return "视频"; + default: + break; + } + return "未知"; + } + string StreamTypeDisplay(byte StreamType) + { + switch (StreamType) + { + case 1: + return "主码流"; + case 2: + return "子码流"; + default: + return "未知"; + } + } + string MemoryTypeDisplay(byte MemoryType) + { + switch (MemoryType) + { + case 1: + return "主存储器"; + case 2: + return "灾备存储器"; + default: + return "未知"; + } + } + } + public JT809_JT1078_0x9B00_0x9B01 Deserialize(ref JT809MessagePackReader reader, IJT809Config config) { - JT809_JT1078_0x9B00_0x9B01 jT808_JT1078_0x9B00_0x9B01 = new JT809_JT1078_0x9B00_0x9B01(); - jT808_JT1078_0x9B00_0x9B01.ChannelId = reader.ReadByte(); - jT808_JT1078_0x9B00_0x9B01.StartTime = reader.ReadUTCDateTime(); - jT808_JT1078_0x9B00_0x9B01.EndTime = reader.ReadUTCDateTime(); - jT808_JT1078_0x9B00_0x9B01.AlarmType = reader.ReadUInt64(); - jT808_JT1078_0x9B00_0x9B01.AVItemType = reader.ReadByte(); - jT808_JT1078_0x9B00_0x9B01.StreamType = reader.ReadByte(); - jT808_JT1078_0x9B00_0x9B01.MemType = reader.ReadByte(); - jT808_JT1078_0x9B00_0x9B01.FileSize = reader.ReadUInt32(); - jT808_JT1078_0x9B00_0x9B01.AuthorizeCode = reader.ReadArray(64).ToArray(); - jT808_JT1078_0x9B00_0x9B01.GnssData = reader.ReadArray(36).ToArray(); - return jT808_JT1078_0x9B00_0x9B01; + JT809_JT1078_0x9B00_0x9B01 value = new JT809_JT1078_0x9B00_0x9B01(); + value.ChannelId = reader.ReadByte(); + value.StartTime = reader.ReadUTCDateTime(); + value.EndTime = reader.ReadUTCDateTime(); + value.AlarmType = reader.ReadUInt64(); + value.AVItemType = reader.ReadByte(); + value.StreamType = reader.ReadByte(); + value.MemType = reader.ReadByte(); + value.FileSize = reader.ReadUInt32(); + value.AuthorizeCode = reader.ReadString(64); + value.GnssData = reader.ReadArray(36).ToArray(); + return value; } public void Serialize(ref JT809MessagePackWriter writer, JT809_JT1078_0x9B00_0x9B01 value, IJT809Config config) @@ -86,7 +195,7 @@ namespace JT809.Protocol.Extensions.JT1078.MessageBody writer.WriteByte(value.StreamType); writer.WriteByte(value.MemType); writer.WriteUInt32(value.FileSize); - writer.WriteArray(value.AuthorizeCode); + writer.WriteStringPadRight(value.AuthorizeCode,64); writer.WriteArray(value.GnssData); } } diff --git a/src/JT809.Protocol.Extensions.JT1078/MessageBody/JT809_JT1078_0x9B00_0x9B02.cs b/src/JT809.Protocol.Extensions.JT1078/MessageBody/JT809_JT1078_0x9B00_0x9B02.cs index 6d3d8f8..fcb4c5d 100644 --- a/src/JT809.Protocol.Extensions.JT1078/MessageBody/JT809_JT1078_0x9B00_0x9B02.cs +++ b/src/JT809.Protocol.Extensions.JT1078/MessageBody/JT809_JT1078_0x9B00_0x9B02.cs @@ -1,5 +1,7 @@ -using JT809.Protocol.Extensions.JT1078.Enums; +using System.Text.Json; +using JT809.Protocol.Extensions.JT1078.Enums; using JT809.Protocol.Formatters; +using JT809.Protocol.Interfaces; using JT809.Protocol.MessagePack; namespace JT809.Protocol.Extensions.JT1078.MessageBody @@ -7,12 +9,12 @@ namespace JT809.Protocol.Extensions.JT1078.MessageBody /// /// 远程录像下载完成通知应答消息 /// - public class JT809_JT1078_0x9B00_0x9B02 : JT809SubBodies,IJT809MessagePackFormatter + public class JT809_JT1078_0x9B00_0x9B02 : JT809SubBodies,IJT809MessagePackFormatter, IJT809Analyze { /// /// 应答结果 /// - public byte Result { get; set; } + public JT809_JT1078_0x9B00_0x9B02_Result Result { get; set; } /// /// 对应平台文件上传消息的流水号 /// @@ -22,17 +24,26 @@ namespace JT809.Protocol.Extensions.JT1078.MessageBody public override string Description { get; } = "远程录像下载完成通知应答消息"; + public void Analyze(ref JT809MessagePackReader reader, Utf8JsonWriter writer, IJT809Config config) + { + JT809_JT1078_0x9B00_0x9B02 value = new JT809_JT1078_0x9B00_0x9B02(); + value.Result = (JT809_JT1078_0x9B00_0x9B02_Result)reader.ReadByte(); + writer.WriteString($"[{((byte)value.Result).ReadNumber()}]应答结果", value.Result.ToString()); + value.SessionId = reader.ReadUInt16(); + writer.WriteNumber($"[{value.SessionId.ReadNumber()}]对应平台文件上传消息的流水号", value.SessionId); + } + public JT809_JT1078_0x9B00_0x9B02 Deserialize(ref JT809MessagePackReader reader, IJT809Config config) { - JT809_JT1078_0x9B00_0x9B02 jT808_JT1078_0x9B00_0x9B02 = new JT809_JT1078_0x9B00_0x9B02(); - jT808_JT1078_0x9B00_0x9B02.Result = reader.ReadByte(); - jT808_JT1078_0x9B00_0x9B02.SessionId = reader.ReadUInt16(); - return jT808_JT1078_0x9B00_0x9B02; + JT809_JT1078_0x9B00_0x9B02 value = new JT809_JT1078_0x9B00_0x9B02(); + value.Result = (JT809_JT1078_0x9B00_0x9B02_Result)reader.ReadByte(); + value.SessionId = reader.ReadUInt16(); + return value; } public void Serialize(ref JT809MessagePackWriter writer, JT809_JT1078_0x9B00_0x9B02 value, IJT809Config config) { - writer.WriteByte(value.Result); + writer.WriteByte((byte)value.Result); writer.WriteUInt16(value.SessionId); } } diff --git a/src/JT809.Protocol.Extensions.JT1078/MessageBody/JT809_JT1078_0x9B00_0x9B03.cs b/src/JT809.Protocol.Extensions.JT1078/MessageBody/JT809_JT1078_0x9B00_0x9B03.cs index d1fb96a..43287d1 100644 --- a/src/JT809.Protocol.Extensions.JT1078/MessageBody/JT809_JT1078_0x9B00_0x9B03.cs +++ b/src/JT809.Protocol.Extensions.JT1078/MessageBody/JT809_JT1078_0x9B00_0x9B03.cs @@ -1,16 +1,18 @@ using JT809.Protocol.Extensions.JT1078.Enums; using JT809.Protocol.Formatters; +using JT809.Protocol.Interfaces; using JT809.Protocol.MessagePack; using System; using System.Collections.Generic; using System.Text; +using System.Text.Json; namespace JT809.Protocol.Extensions.JT1078.MessageBody { /// /// 远程录像下载控制消息 /// - public class JT809_JT1078_0x9B00_0x9B03 : JT809SubBodies, IJT809MessagePackFormatter + public class JT809_JT1078_0x9B00_0x9B03 : JT809SubBodies, IJT809MessagePackFormatter, IJT809Analyze { /// /// 对应平台文件上传消息的流水号 @@ -19,24 +21,33 @@ namespace JT809.Protocol.Extensions.JT1078.MessageBody /// /// 控制类型 /// - public byte Type { get; set; } + public JT809_JT1078_0x9B00_0x9B03_Type Type { get; set; } public override ushort SubMsgId { get; } = JT809_JT1078_SubBusinessType.远程录像下载控制消息.ToUInt16Value(); public override string Description { get; } = "远程录像下载控制消息"; + public void Analyze(ref JT809MessagePackReader reader, Utf8JsonWriter writer, IJT809Config config) + { + JT809_JT1078_0x9B00_0x9B03 value = new JT809_JT1078_0x9B00_0x9B03(); + value.SessionId = reader.ReadUInt16(); + writer.WriteNumber($"[{ value.SessionId.ReadNumber()}]对应平台文件上传消息的流水号", value.SessionId); + value.Type = (JT809_JT1078_0x9B00_0x9B03_Type)reader.ReadByte(); + writer.WriteString($"[{((byte)value.Type).ReadNumber()}]控制类型", value.Type.ToString()); + } + public JT809_JT1078_0x9B00_0x9B03 Deserialize(ref JT809MessagePackReader reader, IJT809Config config) { - JT809_JT1078_0x9B00_0x9B03 jT808_JT1078_0x9B00_0x9B03 = new JT809_JT1078_0x9B00_0x9B03(); - jT808_JT1078_0x9B00_0x9B03.SessionId = reader.ReadUInt16(); - jT808_JT1078_0x9B00_0x9B03.Type = reader.ReadByte(); - return jT808_JT1078_0x9B00_0x9B03; + JT809_JT1078_0x9B00_0x9B03 value = new JT809_JT1078_0x9B00_0x9B03(); + value.SessionId = reader.ReadUInt16(); + value.Type = (JT809_JT1078_0x9B00_0x9B03_Type)reader.ReadByte(); + return value; } public void Serialize(ref JT809MessagePackWriter writer, JT809_JT1078_0x9B00_0x9B03 value, IJT809Config config) { writer.WriteUInt16(value.SessionId); - writer.WriteByte(value.Type); + writer.WriteByte((byte)value.Type); } } } \ No newline at end of file