From c3e77dbd3b4890f1b537cf8e5879f42a353bb76a Mon Sep 17 00:00:00 2001 From: "SmallChi(Koike)" <564952747@qq.com> Date: Mon, 1 Jul 2019 21:00:06 +0800 Subject: [PATCH] =?UTF-8?q?1.JT1078=E5=8D=8F=E8=AE=AE=202.JT1078=E4=B8=ADJ?= =?UTF-8?q?T808=E6=89=A9=E5=B1=95=E5=8D=8F=E8=AE=AE=203.JT1078=E4=B8=ADJT8?= =?UTF-8?q?09=E6=89=A9=E5=B1=95=E5=8D=8F=E8=AE=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .travis.yml | 19 ++ README.md | 250 +++++++++++++- .../JT1078.Protocol.Benchmark.csproj | 22 ++ .../JT1078SerializerContext.cs | 65 ++++ src/JT1078.Protocol.Benchmark/Program.cs | 26 ++ .../JT1078.Protocol.Test.csproj | 20 ++ .../JT1078SerializerTest.cs | 306 ++++++++++++++++++ src/JT1078.Protocol.Tools/App.config | 18 ++ .../ByteArrayHexConverter.cs | 29 ++ src/JT1078.Protocol.Tools/Form1.Designer.cs | 87 +++++ src/JT1078.Protocol.Tools/Form1.cs | 53 +++ src/JT1078.Protocol.Tools/Form1.resx | 120 +++++++ src/JT1078.Protocol.Tools/HexExtensions.cs | 80 +++++ .../JT1078.Protocol.Tools.csproj | 148 +++++++++ src/JT1078.Protocol.Tools/Program.cs | 22 ++ .../Properties/AssemblyInfo.cs | 36 +++ .../Properties/Resources.Designer.cs | 71 ++++ .../Properties/Resources.resx | 117 +++++++ .../Properties/Settings.Designer.cs | 30 ++ .../Properties/Settings.settings | 7 + src/JT1078.Protocol.Tools/packages.config | 8 + .../Buffers/JT1078BufferWriter.cs | 24 ++ src/JT1078.Protocol/Enums/JT1078DataType.cs | 15 + .../Enums/JT1078SubPackageType.cs | 17 + src/JT1078.Protocol/JT1078.Protocol.csproj | 34 ++ src/JT1078.Protocol/JT1078ArrayPool.cs | 24 ++ src/JT1078.Protocol/JT1078Label1.cs | 50 +++ src/JT1078.Protocol/JT1078Label2.cs | 50 +++ src/JT1078.Protocol/JT1078Label3.cs | 42 +++ src/JT1078.Protocol/JT1078Package.cs | 90 ++++++ src/JT1078.Protocol/JT1078Serializer.cs | 70 ++++ .../MessagePack/JT1078MessagePackReader.cs | 88 +++++ .../MessagePack/JT1078MessagePackWriter.cs | 109 +++++++ src/JT1078.sln | 83 +++++ ...808.Protocol.Extensions.JT1078.Test.csproj | 20 ++ .../JT808LocationAttach.cs | 81 +++++ .../JT808_0x1003Test.cs | 54 ++++ .../JT808_0x1005Test.cs | 60 ++++ .../JT808_0x1205Test.cs | 80 +++++ .../JT808_0x1206Test.cs | 58 ++++ .../JT808_0x8103CustomId.cs | 223 +++++++++++++ .../JT808_0x9101Test.cs | 75 +++++ .../JT808_0x9102Test.cs | 68 ++++ .../JT808_0x9105Test.cs | 58 ++++ .../JT808_0x9201Test.cs | 69 ++++ .../JT808_0x9202Test.cs | 60 ++++ .../JT808_0x9205Test.cs | 63 ++++ .../JT808_0x9206Test.cs | 72 +++++ .../JT808_0x9207Test.cs | 58 ++++ .../JT808_0x9301Test.cs | 59 ++++ .../JT808_0x9302Test.cs | 58 ++++ .../JT808_0x9303Test.cs | 58 ++++ .../JT808_0x9304Test.cs | 58 ++++ .../JT808_0x9305Test.cs | 58 ++++ .../JT808_0x9306Test.cs | 58 ++++ .../DependencyInjectionExtensions.cs | 38 +++ .../Formatters/JT808_0x0200_0x14_Formatter.cs | 29 ++ .../Formatters/JT808_0x0200_0x15_Formatter.cs | 29 ++ .../Formatters/JT808_0x0200_0x16_Formatter.cs | 29 ++ .../Formatters/JT808_0x0200_0x17_Formatter.cs | 29 ++ .../Formatters/JT808_0x0200_0x18_Formatter.cs | 29 ++ .../Formatters/JT808_0x1003_Formatter.cs | 41 +++ .../Formatters/JT808_0x1005_Formatter.cs | 31 ++ .../JT808_0x1205_AVResouce_Formatter.cs | 39 +++ .../Formatters/JT808_0x1205_Formatter.cs | 46 +++ .../Formatters/JT808_0x1206_Formatter.cs | 27 ++ .../JT808_0x8103_0x0075_Formatter.cs | 51 +++ ...8103_0x0076_AVChannelRefTable_Formatter.cs | 31 ++ .../JT808_0x8103_0x0076_Formatter.cs | 51 +++ .../JT808_0x8103_0x0077_Formatter.cs | 46 +++ ...8_0x8103_0x0077_SignalChannel_Formatter.cs | 47 +++ .../JT808_0x8103_0x0079_Formatter.cs | 34 ++ .../JT808_0x8103_0x007A_Formatter.cs | 30 ++ .../JT808_0x8103_0x007B_Formatter.cs | 32 ++ .../JT808_0x8103_0x007C_Formatter.cs | 37 +++ ...3_0x007C_TimerWakeDayParamter_Formatter.cs | 42 +++ .../Formatters/JT808_0x9101_Formatter.cs | 38 +++ .../Formatters/JT808_0x9102_Formatter.cs | 31 ++ .../Formatters/JT808_0x9105_Formatter.cs | 27 ++ .../Formatters/JT808_0x9201_Formatter.cs | 50 +++ .../Formatters/JT808_0x9202_Formatter.cs | 31 ++ .../Formatters/JT808_0x9205_Formatter.cs | 37 +++ .../Formatters/JT808_0x9206_Formatter.cs | 61 ++++ .../Formatters/JT808_0x9207_Formatter.cs | 27 ++ .../Formatters/JT808_0x9301_Formatter.cs | 29 ++ .../Formatters/JT808_0x9302_Formatter.cs | 27 ++ .../Formatters/JT808_0x9303_Formatter.cs | 27 ++ .../Formatters/JT808_0x9304_Formatter.cs | 27 ++ .../Formatters/JT808_0x9305_Formatter.cs | 27 ++ .../Formatters/JT808_0x9306_Formatter.cs | 27 ++ .../JT808.Protocol.Extensions.JT1078.csproj | 34 ++ .../MessageBody/JT808_0x0200_0x14.cs | 24 ++ .../MessageBody/JT808_0x0200_0x15.cs | 24 ++ .../MessageBody/JT808_0x0200_0x16.cs | 24 ++ .../MessageBody/JT808_0x0200_0x17.cs | 24 ++ .../MessageBody/JT808_0x0200_0x18.cs | 24 ++ .../MessageBody/JT808_0x1003.cs | 52 +++ .../MessageBody/JT808_0x1005.cs | 32 ++ .../MessageBody/JT808_0x1205.cs | 28 ++ .../MessageBody/JT808_0x1205_AVResouce.cs | 48 +++ .../MessageBody/JT808_0x1206.cs | 24 ++ .../MessageBody/JT808_0x8103_0x0075.cs | 74 +++++ .../MessageBody/JT808_0x8103_0x0076.cs | 42 +++ .../JT808_0x8103_0x0076_AVChannelRefTable.cs | 31 ++ .../MessageBody/JT808_0x8103_0x0077.cs | 27 ++ .../JT808_0x8103_0x0077_SignalChannel.cs | 65 ++++ .../MessageBody/JT808_0x8103_0x0079.cs | 34 ++ .../MessageBody/JT808_0x8103_0x007A.cs | 25 ++ .../MessageBody/JT808_0x8103_0x007B.cs | 29 ++ .../MessageBody/JT808_0x8103_0x007C.cs | 37 +++ ...T808_0x8103_0x007C_TimerWakeDayParamter.cs | 60 ++++ .../MessageBody/JT808_0x9003.cs | 16 + .../MessageBody/JT808_0x9101.cs | 52 +++ .../MessageBody/JT808_0x9102.cs | 45 +++ .../MessageBody/JT808_0x9105.cs | 24 ++ .../MessageBody/JT808_0x9201.cs | 68 ++++ .../MessageBody/JT808_0x9202.cs | 32 ++ .../MessageBody/JT808_0x9205.cs | 44 +++ .../MessageBody/JT808_0x9206.cs | 84 +++++ .../MessageBody/JT808_0x9207.cs | 24 ++ .../MessageBody/JT808_0x9301.cs | 28 ++ .../MessageBody/JT808_0x9302.cs | 24 ++ .../MessageBody/JT808_0x9303.cs | 24 ++ .../MessageBody/JT808_0x9304.cs | 24 ++ .../MessageBody/JT808_0x9305.cs | 24 ++ .../MessageBody/JT808_0x9306.cs | 24 ++ ...T808.Protocol.Extensions.WebApiTest.csproj | 18 ++ .../Program.cs | 91 ++++++ ...809.Protocol.Extensions.JT1078.Test.csproj | 20 ++ .../JT809_JT1078_0x1700Test.cs | 85 +++++ .../JT809_JT1078_0x1800Test.cs | 79 +++++ .../JT809_JT1078_0x1900Test.cs | 133 ++++++++ .../JT809_JT1078_0x1A00Test.cs | 91 ++++++ .../JT809_JT1078_0x1B00Test.cs | 122 +++++++ .../JT809_JT1078_0x9700Test.cs | 50 +++ .../JT809_JT1078_0x9800Test.cs | 83 +++++ .../JT809_JT1078_0x9900Test.cs | 99 ++++++ .../JT809_JT1078_0x9A00Test.cs | 101 ++++++ .../JT809_JT1078_0x9B00Test.cs | 126 ++++++++ .../DependencyInjectionExtensions.cs | 59 ++++ .../Enums/JT809_JT1078_BusinessType.cs | 93 ++++++ .../Enums/JT809_JT1078_SubBusinessType.cs | 181 +++++++++++ .../JT809MessagePackReaderExtentsion.cs | 12 + .../JT809_JT1078_0x1700_0x1701_Formatter.cs | 28 ++ .../JT809_JT1078_0x1700_0x1702_Formatter.cs | 22 ++ .../JT809_JT1078_0x1800_0x1801_Formatter.cs | 28 ++ .../JT809_JT1078_0x1800_0x1802_Formatter.cs | 24 ++ .../JT809_JT1078_0x1900_0x1901_Formatter.cs | 43 +++ ...9_JT1078_0x1900_0x1901_Record_Formatter.cs | 38 +++ .../JT809_JT1078_0x1900_0x1902_Formatter.cs | 45 +++ .../JT809_JT1078_0x1A00_0x1A01_Formatter.cs | 28 ++ .../JT809_JT1078_0x1A00_0x1A02_Formatter.cs | 24 ++ .../JT809_JT1078_0x1B00_0x1B01_Formatter.cs | 26 ++ .../JT809_JT1078_0x1B00_0x1B02_Formatter.cs | 36 +++ .../JT809_JT1078_0x1B00_0x1B03_Formatter.cs | 24 ++ .../JT809_JT1078_0x9700_0x9702_Formatter.cs | 22 ++ .../JT809_JT1078_0x9800_0x9801_Formatter.cs | 30 ++ .../JT809_JT1078_0x9800_0x9802_Formatter.cs | 26 ++ .../JT809_JT1078_0x9900_0x9901_Formatter.cs | 26 ++ .../JT809_JT1078_0x9900_0x9902_Formatter.cs | 41 +++ .../JT809_JT1078_0x9A00_0x9A01_Formatter.cs | 38 +++ .../JT809_JT1078_0x9A00_0x9A02_Formatter.cs | 28 ++ .../JT809_JT1078_0x9B00_0x9B01_Formatter.cs | 42 +++ .../JT809_JT1078_0x9B00_0x9B02_Formatter.cs | 26 ++ .../JT809_JT1078_0x9B00_0x9B03_Formatter.cs | 26 ++ .../JT809.Protocol.Extensions.JT1078.csproj | 33 ++ .../MessageBody/JT809_JT1078_0x1700.cs | 17 + .../MessageBody/JT809_JT1078_0x1700_0x1701.cs | 28 ++ .../MessageBody/JT809_JT1078_0x1700_0x1702.cs | 17 + .../MessageBody/JT809_JT1078_0x1800.cs | 17 + .../MessageBody/JT809_JT1078_0x1800_0x1801.cs | 29 ++ .../MessageBody/JT809_JT1078_0x1800_0x1802.cs | 20 ++ .../MessageBody/JT809_JT1078_0x1900.cs | 17 + .../MessageBody/JT809_JT1078_0x1900_0x1901.cs | 24 ++ .../MessageBody/JT809_JT1078_0x1900_0x1902.cs | 29 ++ .../MessageBody/JT809_JT1078_0x1900_Record.cs | 48 +++ .../MessageBody/JT809_JT1078_0x1A00.cs | 17 + .../MessageBody/JT809_JT1078_0x1A00_0x1A01.cs | 29 ++ .../MessageBody/JT809_JT1078_0x1A00_0x1A02.cs | 20 ++ .../MessageBody/JT809_JT1078_0x1B00.cs | 17 + .../MessageBody/JT809_JT1078_0x1B00_0x1B01.cs | 24 ++ .../MessageBody/JT809_JT1078_0x1B00_0x1B02.cs | 47 +++ .../MessageBody/JT809_JT1078_0x1B00_0x1B03.cs | 20 ++ .../MessageBody/JT809_JT1078_0x9700.cs | 17 + .../MessageBody/JT809_JT1078_0x9700_0x9702.cs | 17 + .../MessageBody/JT809_JT1078_0x9800.cs | 17 + .../MessageBody/JT809_JT1078_0x9800_0x9801.cs | 32 ++ .../MessageBody/JT809_JT1078_0x9800_0x9802.cs | 24 ++ .../MessageBody/JT809_JT1078_0x9900.cs | 17 + .../MessageBody/JT809_JT1078_0x9900_0x9901.cs | 24 ++ .../MessageBody/JT809_JT1078_0x9900_0x9902.cs | 54 ++++ .../MessageBody/JT809_JT1078_0x9A00.cs | 17 + .../MessageBody/JT809_JT1078_0x9A00_0x9A01.cs | 50 +++ .../MessageBody/JT809_JT1078_0x9A00_0x9A02.cs | 28 ++ .../MessageBody/JT809_JT1078_0x9B00.cs | 17 + .../MessageBody/JT809_JT1078_0x9B00_0x9B01.cs | 58 ++++ .../MessageBody/JT809_JT1078_0x9B00_0x9B02.cs | 24 ++ .../MessageBody/JT809_JT1078_0x9B00_0x9B03.cs | 24 ++ 198 files changed, 9196 insertions(+), 2 deletions(-) create mode 100644 .travis.yml create mode 100644 src/JT1078.Protocol.Benchmark/JT1078.Protocol.Benchmark.csproj create mode 100644 src/JT1078.Protocol.Benchmark/JT1078SerializerContext.cs create mode 100644 src/JT1078.Protocol.Benchmark/Program.cs create mode 100644 src/JT1078.Protocol.Test/JT1078.Protocol.Test.csproj create mode 100644 src/JT1078.Protocol.Test/JT1078SerializerTest.cs create mode 100644 src/JT1078.Protocol.Tools/App.config create mode 100644 src/JT1078.Protocol.Tools/ByteArrayHexConverter.cs create mode 100644 src/JT1078.Protocol.Tools/Form1.Designer.cs create mode 100644 src/JT1078.Protocol.Tools/Form1.cs create mode 100644 src/JT1078.Protocol.Tools/Form1.resx create mode 100644 src/JT1078.Protocol.Tools/HexExtensions.cs create mode 100644 src/JT1078.Protocol.Tools/JT1078.Protocol.Tools.csproj create mode 100644 src/JT1078.Protocol.Tools/Program.cs create mode 100644 src/JT1078.Protocol.Tools/Properties/AssemblyInfo.cs create mode 100644 src/JT1078.Protocol.Tools/Properties/Resources.Designer.cs create mode 100644 src/JT1078.Protocol.Tools/Properties/Resources.resx create mode 100644 src/JT1078.Protocol.Tools/Properties/Settings.Designer.cs create mode 100644 src/JT1078.Protocol.Tools/Properties/Settings.settings create mode 100644 src/JT1078.Protocol.Tools/packages.config create mode 100644 src/JT1078.Protocol/Buffers/JT1078BufferWriter.cs create mode 100644 src/JT1078.Protocol/Enums/JT1078DataType.cs create mode 100644 src/JT1078.Protocol/Enums/JT1078SubPackageType.cs create mode 100644 src/JT1078.Protocol/JT1078.Protocol.csproj create mode 100644 src/JT1078.Protocol/JT1078ArrayPool.cs create mode 100644 src/JT1078.Protocol/JT1078Label1.cs create mode 100644 src/JT1078.Protocol/JT1078Label2.cs create mode 100644 src/JT1078.Protocol/JT1078Label3.cs create mode 100644 src/JT1078.Protocol/JT1078Package.cs create mode 100644 src/JT1078.Protocol/JT1078Serializer.cs create mode 100644 src/JT1078.Protocol/MessagePack/JT1078MessagePackReader.cs create mode 100644 src/JT1078.Protocol/MessagePack/JT1078MessagePackWriter.cs create mode 100644 src/JT1078.sln create mode 100644 src/JT808.Protocol.Extensions.JT1078.Test/JT808.Protocol.Extensions.JT1078.Test.csproj create mode 100644 src/JT808.Protocol.Extensions.JT1078.Test/JT808LocationAttach.cs create mode 100644 src/JT808.Protocol.Extensions.JT1078.Test/JT808_0x1003Test.cs create mode 100644 src/JT808.Protocol.Extensions.JT1078.Test/JT808_0x1005Test.cs create mode 100644 src/JT808.Protocol.Extensions.JT1078.Test/JT808_0x1205Test.cs create mode 100644 src/JT808.Protocol.Extensions.JT1078.Test/JT808_0x1206Test.cs create mode 100644 src/JT808.Protocol.Extensions.JT1078.Test/JT808_0x8103CustomId.cs create mode 100644 src/JT808.Protocol.Extensions.JT1078.Test/JT808_0x9101Test.cs create mode 100644 src/JT808.Protocol.Extensions.JT1078.Test/JT808_0x9102Test.cs create mode 100644 src/JT808.Protocol.Extensions.JT1078.Test/JT808_0x9105Test.cs create mode 100644 src/JT808.Protocol.Extensions.JT1078.Test/JT808_0x9201Test.cs create mode 100644 src/JT808.Protocol.Extensions.JT1078.Test/JT808_0x9202Test.cs create mode 100644 src/JT808.Protocol.Extensions.JT1078.Test/JT808_0x9205Test.cs create mode 100644 src/JT808.Protocol.Extensions.JT1078.Test/JT808_0x9206Test.cs create mode 100644 src/JT808.Protocol.Extensions.JT1078.Test/JT808_0x9207Test.cs create mode 100644 src/JT808.Protocol.Extensions.JT1078.Test/JT808_0x9301Test.cs create mode 100644 src/JT808.Protocol.Extensions.JT1078.Test/JT808_0x9302Test.cs create mode 100644 src/JT808.Protocol.Extensions.JT1078.Test/JT808_0x9303Test.cs create mode 100644 src/JT808.Protocol.Extensions.JT1078.Test/JT808_0x9304Test.cs create mode 100644 src/JT808.Protocol.Extensions.JT1078.Test/JT808_0x9305Test.cs create mode 100644 src/JT808.Protocol.Extensions.JT1078.Test/JT808_0x9306Test.cs create mode 100644 src/JT808.Protocol.Extensions.JT1078/DependencyInjectionExtensions.cs create mode 100644 src/JT808.Protocol.Extensions.JT1078/Formatters/JT808_0x0200_0x14_Formatter.cs create mode 100644 src/JT808.Protocol.Extensions.JT1078/Formatters/JT808_0x0200_0x15_Formatter.cs create mode 100644 src/JT808.Protocol.Extensions.JT1078/Formatters/JT808_0x0200_0x16_Formatter.cs create mode 100644 src/JT808.Protocol.Extensions.JT1078/Formatters/JT808_0x0200_0x17_Formatter.cs create mode 100644 src/JT808.Protocol.Extensions.JT1078/Formatters/JT808_0x0200_0x18_Formatter.cs create mode 100644 src/JT808.Protocol.Extensions.JT1078/Formatters/JT808_0x1003_Formatter.cs create mode 100644 src/JT808.Protocol.Extensions.JT1078/Formatters/JT808_0x1005_Formatter.cs create mode 100644 src/JT808.Protocol.Extensions.JT1078/Formatters/JT808_0x1205_AVResouce_Formatter.cs create mode 100644 src/JT808.Protocol.Extensions.JT1078/Formatters/JT808_0x1205_Formatter.cs create mode 100644 src/JT808.Protocol.Extensions.JT1078/Formatters/JT808_0x1206_Formatter.cs create mode 100644 src/JT808.Protocol.Extensions.JT1078/Formatters/JT808_0x8103_0x0075_Formatter.cs create mode 100644 src/JT808.Protocol.Extensions.JT1078/Formatters/JT808_0x8103_0x0076_AVChannelRefTable_Formatter.cs create mode 100644 src/JT808.Protocol.Extensions.JT1078/Formatters/JT808_0x8103_0x0076_Formatter.cs create mode 100644 src/JT808.Protocol.Extensions.JT1078/Formatters/JT808_0x8103_0x0077_Formatter.cs create mode 100644 src/JT808.Protocol.Extensions.JT1078/Formatters/JT808_0x8103_0x0077_SignalChannel_Formatter.cs create mode 100644 src/JT808.Protocol.Extensions.JT1078/Formatters/JT808_0x8103_0x0079_Formatter.cs create mode 100644 src/JT808.Protocol.Extensions.JT1078/Formatters/JT808_0x8103_0x007A_Formatter.cs create mode 100644 src/JT808.Protocol.Extensions.JT1078/Formatters/JT808_0x8103_0x007B_Formatter.cs create mode 100644 src/JT808.Protocol.Extensions.JT1078/Formatters/JT808_0x8103_0x007C_Formatter.cs create mode 100644 src/JT808.Protocol.Extensions.JT1078/Formatters/JT808_0x8103_0x007C_TimerWakeDayParamter_Formatter.cs create mode 100644 src/JT808.Protocol.Extensions.JT1078/Formatters/JT808_0x9101_Formatter.cs create mode 100644 src/JT808.Protocol.Extensions.JT1078/Formatters/JT808_0x9102_Formatter.cs create mode 100644 src/JT808.Protocol.Extensions.JT1078/Formatters/JT808_0x9105_Formatter.cs create mode 100644 src/JT808.Protocol.Extensions.JT1078/Formatters/JT808_0x9201_Formatter.cs create mode 100644 src/JT808.Protocol.Extensions.JT1078/Formatters/JT808_0x9202_Formatter.cs create mode 100644 src/JT808.Protocol.Extensions.JT1078/Formatters/JT808_0x9205_Formatter.cs create mode 100644 src/JT808.Protocol.Extensions.JT1078/Formatters/JT808_0x9206_Formatter.cs create mode 100644 src/JT808.Protocol.Extensions.JT1078/Formatters/JT808_0x9207_Formatter.cs create mode 100644 src/JT808.Protocol.Extensions.JT1078/Formatters/JT808_0x9301_Formatter.cs create mode 100644 src/JT808.Protocol.Extensions.JT1078/Formatters/JT808_0x9302_Formatter.cs create mode 100644 src/JT808.Protocol.Extensions.JT1078/Formatters/JT808_0x9303_Formatter.cs create mode 100644 src/JT808.Protocol.Extensions.JT1078/Formatters/JT808_0x9304_Formatter.cs create mode 100644 src/JT808.Protocol.Extensions.JT1078/Formatters/JT808_0x9305_Formatter.cs create mode 100644 src/JT808.Protocol.Extensions.JT1078/Formatters/JT808_0x9306_Formatter.cs create mode 100644 src/JT808.Protocol.Extensions.JT1078/JT808.Protocol.Extensions.JT1078.csproj create mode 100644 src/JT808.Protocol.Extensions.JT1078/MessageBody/JT808_0x0200_0x14.cs create mode 100644 src/JT808.Protocol.Extensions.JT1078/MessageBody/JT808_0x0200_0x15.cs create mode 100644 src/JT808.Protocol.Extensions.JT1078/MessageBody/JT808_0x0200_0x16.cs create mode 100644 src/JT808.Protocol.Extensions.JT1078/MessageBody/JT808_0x0200_0x17.cs create mode 100644 src/JT808.Protocol.Extensions.JT1078/MessageBody/JT808_0x0200_0x18.cs create mode 100644 src/JT808.Protocol.Extensions.JT1078/MessageBody/JT808_0x1003.cs create mode 100644 src/JT808.Protocol.Extensions.JT1078/MessageBody/JT808_0x1005.cs create mode 100644 src/JT808.Protocol.Extensions.JT1078/MessageBody/JT808_0x1205.cs create mode 100644 src/JT808.Protocol.Extensions.JT1078/MessageBody/JT808_0x1205_AVResouce.cs create mode 100644 src/JT808.Protocol.Extensions.JT1078/MessageBody/JT808_0x1206.cs create mode 100644 src/JT808.Protocol.Extensions.JT1078/MessageBody/JT808_0x8103_0x0075.cs create mode 100644 src/JT808.Protocol.Extensions.JT1078/MessageBody/JT808_0x8103_0x0076.cs create mode 100644 src/JT808.Protocol.Extensions.JT1078/MessageBody/JT808_0x8103_0x0076_AVChannelRefTable.cs create mode 100644 src/JT808.Protocol.Extensions.JT1078/MessageBody/JT808_0x8103_0x0077.cs create mode 100644 src/JT808.Protocol.Extensions.JT1078/MessageBody/JT808_0x8103_0x0077_SignalChannel.cs create mode 100644 src/JT808.Protocol.Extensions.JT1078/MessageBody/JT808_0x8103_0x0079.cs create mode 100644 src/JT808.Protocol.Extensions.JT1078/MessageBody/JT808_0x8103_0x007A.cs create mode 100644 src/JT808.Protocol.Extensions.JT1078/MessageBody/JT808_0x8103_0x007B.cs create mode 100644 src/JT808.Protocol.Extensions.JT1078/MessageBody/JT808_0x8103_0x007C.cs create mode 100644 src/JT808.Protocol.Extensions.JT1078/MessageBody/JT808_0x8103_0x007C_TimerWakeDayParamter.cs create mode 100644 src/JT808.Protocol.Extensions.JT1078/MessageBody/JT808_0x9003.cs create mode 100644 src/JT808.Protocol.Extensions.JT1078/MessageBody/JT808_0x9101.cs create mode 100644 src/JT808.Protocol.Extensions.JT1078/MessageBody/JT808_0x9102.cs create mode 100644 src/JT808.Protocol.Extensions.JT1078/MessageBody/JT808_0x9105.cs create mode 100644 src/JT808.Protocol.Extensions.JT1078/MessageBody/JT808_0x9201.cs create mode 100644 src/JT808.Protocol.Extensions.JT1078/MessageBody/JT808_0x9202.cs create mode 100644 src/JT808.Protocol.Extensions.JT1078/MessageBody/JT808_0x9205.cs create mode 100644 src/JT808.Protocol.Extensions.JT1078/MessageBody/JT808_0x9206.cs create mode 100644 src/JT808.Protocol.Extensions.JT1078/MessageBody/JT808_0x9207.cs create mode 100644 src/JT808.Protocol.Extensions.JT1078/MessageBody/JT808_0x9301.cs create mode 100644 src/JT808.Protocol.Extensions.JT1078/MessageBody/JT808_0x9302.cs create mode 100644 src/JT808.Protocol.Extensions.JT1078/MessageBody/JT808_0x9303.cs create mode 100644 src/JT808.Protocol.Extensions.JT1078/MessageBody/JT808_0x9304.cs create mode 100644 src/JT808.Protocol.Extensions.JT1078/MessageBody/JT808_0x9305.cs create mode 100644 src/JT808.Protocol.Extensions.JT1078/MessageBody/JT808_0x9306.cs create mode 100644 src/JT808.Protocol.Extensions.WebApiTest/JT808.Protocol.Extensions.WebApiTest.csproj create mode 100644 src/JT808.Protocol.Extensions.WebApiTest/Program.cs create mode 100644 src/JT809.Protocol.Extensions.JT1078.Test/JT809.Protocol.Extensions.JT1078.Test.csproj create mode 100644 src/JT809.Protocol.Extensions.JT1078.Test/JT809_JT1078_0x1700Test.cs create mode 100644 src/JT809.Protocol.Extensions.JT1078.Test/JT809_JT1078_0x1800Test.cs create mode 100644 src/JT809.Protocol.Extensions.JT1078.Test/JT809_JT1078_0x1900Test.cs create mode 100644 src/JT809.Protocol.Extensions.JT1078.Test/JT809_JT1078_0x1A00Test.cs create mode 100644 src/JT809.Protocol.Extensions.JT1078.Test/JT809_JT1078_0x1B00Test.cs create mode 100644 src/JT809.Protocol.Extensions.JT1078.Test/JT809_JT1078_0x9700Test.cs create mode 100644 src/JT809.Protocol.Extensions.JT1078.Test/JT809_JT1078_0x9800Test.cs create mode 100644 src/JT809.Protocol.Extensions.JT1078.Test/JT809_JT1078_0x9900Test.cs create mode 100644 src/JT809.Protocol.Extensions.JT1078.Test/JT809_JT1078_0x9A00Test.cs create mode 100644 src/JT809.Protocol.Extensions.JT1078.Test/JT809_JT1078_0x9B00Test.cs create mode 100644 src/JT809.Protocol.Extensions.JT1078/DependencyInjectionExtensions.cs create mode 100644 src/JT809.Protocol.Extensions.JT1078/Enums/JT809_JT1078_BusinessType.cs create mode 100644 src/JT809.Protocol.Extensions.JT1078/Enums/JT809_JT1078_SubBusinessType.cs create mode 100644 src/JT809.Protocol.Extensions.JT1078/Extensions/JT809MessagePackReaderExtentsion.cs create mode 100644 src/JT809.Protocol.Extensions.JT1078/Formatters/JT809_JT1078_0x1700_0x1701_Formatter.cs create mode 100644 src/JT809.Protocol.Extensions.JT1078/Formatters/JT809_JT1078_0x1700_0x1702_Formatter.cs create mode 100644 src/JT809.Protocol.Extensions.JT1078/Formatters/JT809_JT1078_0x1800_0x1801_Formatter.cs create mode 100644 src/JT809.Protocol.Extensions.JT1078/Formatters/JT809_JT1078_0x1800_0x1802_Formatter.cs create mode 100644 src/JT809.Protocol.Extensions.JT1078/Formatters/JT809_JT1078_0x1900_0x1901_Formatter.cs create mode 100644 src/JT809.Protocol.Extensions.JT1078/Formatters/JT809_JT1078_0x1900_0x1901_Record_Formatter.cs create mode 100644 src/JT809.Protocol.Extensions.JT1078/Formatters/JT809_JT1078_0x1900_0x1902_Formatter.cs create mode 100644 src/JT809.Protocol.Extensions.JT1078/Formatters/JT809_JT1078_0x1A00_0x1A01_Formatter.cs create mode 100644 src/JT809.Protocol.Extensions.JT1078/Formatters/JT809_JT1078_0x1A00_0x1A02_Formatter.cs create mode 100644 src/JT809.Protocol.Extensions.JT1078/Formatters/JT809_JT1078_0x1B00_0x1B01_Formatter.cs create mode 100644 src/JT809.Protocol.Extensions.JT1078/Formatters/JT809_JT1078_0x1B00_0x1B02_Formatter.cs create mode 100644 src/JT809.Protocol.Extensions.JT1078/Formatters/JT809_JT1078_0x1B00_0x1B03_Formatter.cs create mode 100644 src/JT809.Protocol.Extensions.JT1078/Formatters/JT809_JT1078_0x9700_0x9702_Formatter.cs create mode 100644 src/JT809.Protocol.Extensions.JT1078/Formatters/JT809_JT1078_0x9800_0x9801_Formatter.cs create mode 100644 src/JT809.Protocol.Extensions.JT1078/Formatters/JT809_JT1078_0x9800_0x9802_Formatter.cs create mode 100644 src/JT809.Protocol.Extensions.JT1078/Formatters/JT809_JT1078_0x9900_0x9901_Formatter.cs create mode 100644 src/JT809.Protocol.Extensions.JT1078/Formatters/JT809_JT1078_0x9900_0x9902_Formatter.cs create mode 100644 src/JT809.Protocol.Extensions.JT1078/Formatters/JT809_JT1078_0x9A00_0x9A01_Formatter.cs create mode 100644 src/JT809.Protocol.Extensions.JT1078/Formatters/JT809_JT1078_0x9A00_0x9A02_Formatter.cs create mode 100644 src/JT809.Protocol.Extensions.JT1078/Formatters/JT809_JT1078_0x9B00_0x9B01_Formatter.cs create mode 100644 src/JT809.Protocol.Extensions.JT1078/Formatters/JT809_JT1078_0x9B00_0x9B02_Formatter.cs create mode 100644 src/JT809.Protocol.Extensions.JT1078/Formatters/JT809_JT1078_0x9B00_0x9B03_Formatter.cs create mode 100644 src/JT809.Protocol.Extensions.JT1078/JT809.Protocol.Extensions.JT1078.csproj create mode 100644 src/JT809.Protocol.Extensions.JT1078/MessageBody/JT809_JT1078_0x1700.cs create mode 100644 src/JT809.Protocol.Extensions.JT1078/MessageBody/JT809_JT1078_0x1700_0x1701.cs create mode 100644 src/JT809.Protocol.Extensions.JT1078/MessageBody/JT809_JT1078_0x1700_0x1702.cs create mode 100644 src/JT809.Protocol.Extensions.JT1078/MessageBody/JT809_JT1078_0x1800.cs create mode 100644 src/JT809.Protocol.Extensions.JT1078/MessageBody/JT809_JT1078_0x1800_0x1801.cs create mode 100644 src/JT809.Protocol.Extensions.JT1078/MessageBody/JT809_JT1078_0x1800_0x1802.cs create mode 100644 src/JT809.Protocol.Extensions.JT1078/MessageBody/JT809_JT1078_0x1900.cs create mode 100644 src/JT809.Protocol.Extensions.JT1078/MessageBody/JT809_JT1078_0x1900_0x1901.cs create mode 100644 src/JT809.Protocol.Extensions.JT1078/MessageBody/JT809_JT1078_0x1900_0x1902.cs create mode 100644 src/JT809.Protocol.Extensions.JT1078/MessageBody/JT809_JT1078_0x1900_Record.cs create mode 100644 src/JT809.Protocol.Extensions.JT1078/MessageBody/JT809_JT1078_0x1A00.cs create mode 100644 src/JT809.Protocol.Extensions.JT1078/MessageBody/JT809_JT1078_0x1A00_0x1A01.cs create mode 100644 src/JT809.Protocol.Extensions.JT1078/MessageBody/JT809_JT1078_0x1A00_0x1A02.cs create mode 100644 src/JT809.Protocol.Extensions.JT1078/MessageBody/JT809_JT1078_0x1B00.cs create mode 100644 src/JT809.Protocol.Extensions.JT1078/MessageBody/JT809_JT1078_0x1B00_0x1B01.cs create mode 100644 src/JT809.Protocol.Extensions.JT1078/MessageBody/JT809_JT1078_0x1B00_0x1B02.cs create mode 100644 src/JT809.Protocol.Extensions.JT1078/MessageBody/JT809_JT1078_0x1B00_0x1B03.cs create mode 100644 src/JT809.Protocol.Extensions.JT1078/MessageBody/JT809_JT1078_0x9700.cs create mode 100644 src/JT809.Protocol.Extensions.JT1078/MessageBody/JT809_JT1078_0x9700_0x9702.cs create mode 100644 src/JT809.Protocol.Extensions.JT1078/MessageBody/JT809_JT1078_0x9800.cs create mode 100644 src/JT809.Protocol.Extensions.JT1078/MessageBody/JT809_JT1078_0x9800_0x9801.cs create mode 100644 src/JT809.Protocol.Extensions.JT1078/MessageBody/JT809_JT1078_0x9800_0x9802.cs create mode 100644 src/JT809.Protocol.Extensions.JT1078/MessageBody/JT809_JT1078_0x9900.cs create mode 100644 src/JT809.Protocol.Extensions.JT1078/MessageBody/JT809_JT1078_0x9900_0x9901.cs create mode 100644 src/JT809.Protocol.Extensions.JT1078/MessageBody/JT809_JT1078_0x9900_0x9902.cs create mode 100644 src/JT809.Protocol.Extensions.JT1078/MessageBody/JT809_JT1078_0x9A00.cs create mode 100644 src/JT809.Protocol.Extensions.JT1078/MessageBody/JT809_JT1078_0x9A00_0x9A01.cs create mode 100644 src/JT809.Protocol.Extensions.JT1078/MessageBody/JT809_JT1078_0x9A00_0x9A02.cs create mode 100644 src/JT809.Protocol.Extensions.JT1078/MessageBody/JT809_JT1078_0x9B00.cs create mode 100644 src/JT809.Protocol.Extensions.JT1078/MessageBody/JT809_JT1078_0x9B00_0x9B01.cs create mode 100644 src/JT809.Protocol.Extensions.JT1078/MessageBody/JT809_JT1078_0x9B00_0x9B02.cs create mode 100644 src/JT809.Protocol.Extensions.JT1078/MessageBody/JT809_JT1078_0x9B00_0x9B03.cs diff --git a/.travis.yml b/.travis.yml new file mode 100644 index 0000000..2e12c33 --- /dev/null +++ b/.travis.yml @@ -0,0 +1,19 @@ +language: csharp +solution: JT1078.sln +dotnet: 2.2.101 +os: linux +mono: none +dist: trusty2 +script: + - dotnet restore src/JT1078.sln + - dotnet build src/JT1078.Protocol.Test/JT1078.Protocol.Test.csproj + - dotnet test src/JT1078.Protocol.Test/JT1078.Protocol.Test.csproj + - dotnet build src/JT808.Protocol.Extensions.JT1078.Test/JT808.Protocol.Extensions.JT1078.Test.csproj + - dotnet test src/JT808.Protocol.Extensions.JT1078.Test/JT808.Protocol.Extensions.JT1078.Test.csproj + - dotnet build src/JT809.Protocol.Extensions.JT1078.Test/JT809.Protocol.Extensions.JT1078.Test.csproj + - dotnet test src/JT809.Protocol.Extensions.JT1078.Test/JT809.Protocol.Extensions.JT1078.Test.csproj +after_success: + - echo successful build! +branches: + only: + - master diff --git a/README.md b/README.md index 5274be6..969f94b 100644 --- a/README.md +++ b/README.md @@ -1,2 +1,248 @@ -# JT1078 -道路运输车辆卫星定位系统-视频通讯协议 +# JT1078 + +道路运输车辆卫星定位系统-视频通讯协议主要分为三大部分。 + +1. 设备终端到平台的通信也就是JT808 +2. 企业平台到政府监管的通信也就是JT809 +3. 设备终端上传的实时音视频流数据也就是视频服务器 + +[![MIT Licence](https://img.shields.io/github/license/mashape/apistatus.svg)](https://github.com/SmallChi/JT1078/blob/master/LICENSE)[![Build Status](https://travis-ci.org/SmallChi/JT1078.svg?branch=master)](https://travis-ci.org/SmallChi/JT1078) + +## NuGet安装 + +| Package Name | Version | Downloads | +| --------------------- | -------------------------------------------------- | --------------------------------------------------- | +| Install-Package JT1078 | ![JT1078](https://img.shields.io/nuget/v/JT1078.svg) | ![JT1078](https://img.shields.io/nuget/dt/JT1078.svg) | +| Install-Package JT808.Protocol.Extensions.JT1078 | ![JT808.Protocol.Extensions.JT1078](https://img.shields.io/nuget/v/JT808.Protocol.Extensions.JT1078.svg) | ![JT808](https://img.shields.io/nuget/dt/JT808.Protocol.Extensions.JT1078.svg) | +| Install-Package JT809.Protocol.Extensions.JT1078 | ![JT809.Protocol.Extensions.JT1078](https://img.shields.io/nuget/v/JT809.Protocol.Extensions.JT1078.svg) | ![JT809](https://img.shields.io/nuget/dt/JT809.Protocol.Extensions.JT1078.svg) | + +## 基于JT1078音视频流数据的RTP协议 + +### 前提条件 + +1. 掌握进制转换:二进制转十六进制; +2. 掌握BCD编码、Hex编码; +3. 掌握各种位移、异或; +4. 掌握快速ctrl+c、ctrl+v; +5. 掌握Span\的基本用法 +6. 掌握以上装逼技能,就可以开始搬砖了。 + +### 数据结构解析 + +| 帧头标识 | 标注1| 标注1| 包序号|SIM 卡号 |逻辑通道号| 标注3 | 时间戳 |Last I Frame Interval|Last Frame Interval|数据体长度|数据体 +| :----: | :----: | :----: | :----: | :----: | :----: |:----:|:----:|:----: |:----: |:----: |:----: | +| FH_Flag | Label1 | Label2 | SN | SIM |LogicChannelNumber|Label3|Timestamp|LastIFrameInterval|LastFrameInterval|DataBodyLength|Bodies + +#### 标注1(Label1) + +|RTP协议的版本号|填充标志|扩展标志|CSRC计数器| +| :----: | :----: | :----: | :----: | +| V | P | X | CC | + +#### 标注2(Label2) + +|标志位,确定是否完整数据帧的边界|负载类型| +| :----: | :----: | +| M | PT | + +#### 标注3(Label3) + +|数据类型|分包处理标记| +| :----: | :----: | +| DataType | SubpackageType | + +> 1.参考JTT1078文档 +> 2.参考RTP协议 + +### 举个栗子1 + +#### 1.组包 + +``` package + +JT1078Package jT1078Package = new JT1078Package(); +jT1078Package.Label1 = new JT1078Label1(0x81); +jT1078Package.Label2 = new JT1078Label2(0xE2); +jT1078Package.SN = 0x1088; +jT1078Package.SIM = "11234567810"; +jT1078Package.LogicChannelNumber = 0x01; +jT1078Package.Label3 = new JT1078Label3(0x10); +jT1078Package.Timestamp = 1562085870204; +jT1078Package.LastIFrameInterval = 0x0280; +jT1078Package.LastFrameInterval = 0x0028; +jT1078Package.Bodies = "00 00 00 01 61 E1 A2 BF 00 98 CF C0 EE 1E 17 28 34 07 78 8E 39 A4 03 FD DB D1 D5 46 BF B0 63 01 3F 59 AC 34 C9 7A 02 1A B9 6A 28 A4 2C 08".ToHexBytes(); +var hex = JT1078Serializer.Serialize(jT1078Package).ToHexString(); +// 输出结果Hex: +//30 31 63 64 81 E2 10 88 01 12 34 56 78 10 01 10 00 00 01 6B B3 92 CA 7C 02 80 00 28 00 2E 00 00 00 01 61 E1 A2 BF 00 98 CF C0 EE 1E 17 28 34 07 78 8E 39 A4 03 FD DB D1 D5 46 BF B0 63 01 3F 59 AC 34 C9 7A 02 1A B9 6A 28 A4 2C 08 +``` + +#### 2.手动解包 + +``` unpackage +1.原包: +30 31 63 64 81 E2 10 88 01 12 34 56 78 10 01 10 00 00 01 6B B3 92 CA 7C 02 80 00 28 00 2E 00 00 00 01 61 E1 A2 BF 00 98 CF C0 EE 1E 17 28 34 07 78 8E 39 A4 03 FD DB D1 D5 46 BF B0 63 01 3F 59 AC 34 C9 7A 02 1A B9 6A 28 A4 2C 08 + +2.拆解: +30 31 63 64 --帧头表示 +81 --‭Label1 =>10000001‬ V P X CC +E2 --Label2 =>‭11100010‬ M PT +10 88 --SN 包序号 +01 12 34 56 78 10 --SIM卡号 +01 --逻辑通道号 +10 --Label3 =>数据类型 分包处理标记 +00 00 01 6B B3 92 CA 7C --时间戳 +02 80 --Last I Frame Interval +00 28 --Last Frame Interval +00 2E --数据体长度 +00 00 00 01 61 E1 A2 BF --数据体 +00 98 CF C0 EE 1E 17 28 +34 07 78 8E 39 A4 03 FD +DB D1 D5 46 BF B0 63 01 +3F 59 AC 34 C9 7A 02 1A +B9 6A 28 A4 2C 08 +``` + +#### 3.程序解包 + +``` unpackage2 +var bytes = "30 31 63 64 81 E2 10 88 01 12 34 56 78 10 01 10 00 00 01 6B B3 92 CA 7C 02 80 00 28 00 2E 00 00 00 01 61 E1 A2 BF 00 98 CF C0 EE 1E 17 28 34 07 78 8E 39 A4 03 FD DB D1 D5 46 BF B0 63 01 3F 59 AC 34 C9 7A 02 1A B9 6A 28 A4 2C 08".ToHexBytes(); +JT1078Package package = JT1078Serializer.Deserialize(bytes); +Assert.Equal(0x81, package.Label1.ToByte()); +Assert.Equal(0xE2, package.Label2.ToByte()); +Assert.Equal(0x1088, package.SN); +Assert.Equal("011234567810", package.SIM); +Assert.Equal(0x01, package.LogicChannelNumber); +Assert.Equal(0x10, package.Label3.ToByte()); +Assert.Equal((ulong)1562085870204, package.Timestamp); +Assert.Equal(0x0280, package.LastIFrameInterval); +Assert.Equal(0x0028, package.LastFrameInterval); +Assert.Equal(0x002E, package.DataBodyLength); +Assert.Equal("00 00 00 01 61 E1 A2 BF 00 98 CF C0 EE 1E 17 28 34 07 78 8E 39 A4 03 FD DB D1 D5 46 BF B0 63 01 3F 59 AC 34 C9 7A 02 1A B9 6A 28 A4 2C 08".ToHexBytes(), package.Bodies); +``` + +### 使用BenchmarkDotNet性能测试报告(只是玩玩,不能当真) + +``` ini + +BenchmarkDotNet=v0.11.5, OS=Windows 10.0.17763.557 (1809/October2018Update/Redstone5) +Intel Core i7-8700K CPU 3.70GHz (Coffee Lake), 1 CPU, 12 logical and 6 physical cores + [Host] : .NET Framework 4.7.2 (CLR 4.0.30319.42000), 64bit RyuJIT-v4.7.3416.0 + Job-FVMQGI : .NET Framework 4.7.2 (CLR 4.0.30319.42000), 64bit RyuJIT-v4.7.3416.0 + Job-LGLQDK : .NET Core 2.2.5 (CoreCLR 4.6.27617.05, CoreFX 4.6.27618.01), 64bit RyuJIT + +Platform=AnyCpu Runtime=Clr Server=False + +``` +| Method | Toolchain | N | Mean | Error | StdDev | Gen 0 | Gen 1 | Gen 2 | Allocated | +|------------------ |-------------- |------- |----------------:|---------------:|--------------:|-----------:|--------:|------:|-------------:| +| **JT1078Serializer** | **Default** | **100** | **1,051.97 us** | **10.8309 us** | **9.601 us** | **74.2188** | **-** | **-** | **457.83 KB** | +| JT1078Deserialize | Default | 100 | 67.31 us | 1.3317 us | 1.684 us | 23.8037 | - | - | 146.88 KB | +| JT1078Serializer | .NET Core 2.2 | 100 | 611.85 us | 12.0670 us | 18.428 us | 38.0859 | - | - | 235.16 KB | +| JT1078Deserialize | .NET Core 2.2 | 100 | 48.52 us | 0.9662 us | 1.742 us | 23.8647 | 0.0610 | - | 146.88 KB | +| **JT1078Serializer** | **Default** | **10000** | **103,736.17 us** | **2,045.0081 us** | **2,273.021 us** | **7400.0000** | **-** | **-** | **45782.72 KB** | +| JT1078Deserialize | Default | 10000 | 7,114.68 us | 160.6500 us | 254.808 us | 2382.8125 | 7.8125 | - | 14687.67 KB | +| JT1078Serializer | .NET Core 2.2 | 10000 | 58,178.53 us | 1,159.6161 us | 1,587.296 us | 3777.7778 | - | - | 23515.63 KB | +| JT1078Deserialize | .NET Core 2.2 | 10000 | 5,067.99 us | 100.7925 us | 181.750 us | 2382.8125 | 7.8125 | - | 14687.5 KB | +| **JT1078Serializer** | **Default** | **100000** | **1,038,763.25 us** | **17,757.1818 us** | **15,741.279 us** | **74000.0000** | **-** | **-** | **457827.99 KB** | +| JT1078Deserialize | Default | 100000 | 66,404.06 us | 1,396.2228 us | 1,433.818 us | 23875.0000 | - | - | 146877.21 KB | +| JT1078Serializer | .NET Core 2.2 | 100000 | 575,291.66 us | 10,749.4909 us | 10,055.081 us | 38000.0000 | - | - | 235156.25 KB | +| JT1078Deserialize | .NET Core 2.2 | 100000 | 48,081.94 us | 1,050.5808 us | 1,167.718 us | 23818.1818 | 90.9091 | - | 146875 KB | + +## 基于JT808扩展的JT1078消息协议 + +### JT808扩展协议消息对照表 + +| 序号 | 消息ID | 完成情况 | 测试情况 | 消息体名称 | +| :---: | :-----------: | :------: | :------: | :----------------------------: | +| 1 | 0x0200_0x14 | √ | √ | 视频相关报警 | +| 2 | 0x0200_0x15 | √ | √ | 视频信号丢失报警状态 | +| 3 | 0x0200_0x16 | √ | √ | 视频信号遮挡报警状态 | +| 4 | 0x0200_0x17 | √ | √ | 存储器故障报警状态 | +| 5 | 0x0200_0x18 | √ | √ | 异常驾驶行为报警详细描述 | +| 6 | 0x8103_0x0075 | √ | √ | 音视频参数设置 | +| 7 | 0x8103_0x0076 | √ | √ | 音视频通道列表设置 | +| 8 | 0x8103_0x0077 | √ | √ | 单独视频通道参数设置 | +| 9 | 0x8103_0x0079 | √ | √ | 特殊报警录像参数设置 | +| 10 | 0x8103_0x007A | √ | √ | 视频相关报警屏蔽字 | +| 11 | 0x8103_0x007B | √ | √ | 图像分析报警参数设置 | +| 12 | 0x8103_0x007C | √ | √ | 终端休眠模式唤醒设置 | +| 13 | 0x1003 | √ | √ | 终端上传音视频属性 | +| 14 | 0x1005 | √ | √ | 终端上传乘客流量 | +| 15 | 0x1205 | √ | √ | 终端上传音视频资源列表 | +| 16 | 0x1206 | √ | √ | 文件上传完成通知 | +| 17 | 0x9003 | √ | √ | 查询终端音视频属性 | +| 18 | 0x9101 | √ | √ | 实时音视频传输请求 | +| 19 | 0x9102 | √ | √ | 音视频实时传输控制 | +| 20 | 0x9105 | √ | √ | 实时音视频传输状态通知 | +| 21 | 0x9201 | √ | √ | 平台下发远程录像回放请求 | +| 22 | 0x9202 | √ | √ | 平台下发远程录像回放控制 | +| 23 | 0x9205 | √ | √ | 查询资源列表 | +| 24 | 0x9206 | √ | √ | 文件上传指令 | +| 25 | 0x9207 | √ | √ | 文件上传控制 | +| 26 | 0x9301 | √ | √ | 云台旋转 | +| 27 | 0x9302 | √ | √ | 云台调整焦距控制 | +| 28 | 0x9303 | √ | √ | 云台调整光圈控制 | +| 29 | 0x9304 | √ | √ | 云台雨刷控制 | +| 30 | 0x9305 | √ | √ | 红外补光控制 | +| 31 | 0x9306 | √ | √ | 云台变倍控制 | + +### 使用方法 + +```dotnet +IServiceCollection serviceDescriptors1 = new ServiceCollection(); +serviceDescriptors1.AddJT808Configure() + .AddJT1078Configure(); +``` + +## 基于JT809扩展的JT1078消息协议 + +### JT809扩展协议消息对照表 + +#### 主链路动态信息交换消息 + +| 序号 | 消息ID | 完成情况 | 测试情况 | 消息体名称 | +| :---: | :-----------: | :------: | :------: | :----------------------------: | +| 1 | 0x1700 | √ | √ | 主链路时效口令交互消息 | +| 2 | 0x1700_0x1701 | √ | √ | 时效口令上报消息(有疑问:数据体有问题) | +| 3 | 0x1700_0x1702 | √ | √ | 时效口令请求消息 | +| 4 | 0x1800 | √ | √ | 主链路实时音视频交互消息 | +| 5 | 0x1800_0x1801 | √ | √ | 实时音视频请求应答消息 | +| 6 | 0x1800_0x1802 | √ | √ | 主动请求停止实时音视频传输应答消息 | +| 7 | 0x1900 | √ | √ | 主链路远程录像检索 | +| 8 | 0x1900_0x1901 | √ | √ | 主动上传音视频资源目录信息消息 | +| 9 | 0x1900_0x1902 | √ | √ | 查询音视频资源目录应答消息 | +| 10 | 0x1A00 | √ | √ | 主链路远程录像回放交互消息 | +| 11 | 0x1A00_0x1A01 | √ | √ | 远程录像回放请求应答消息 | +| 12 | 0x1A00_0x1A02 | √ | √ | 远程录像回放控制应答消息 | +| 13 | 0x1B00 | √ | √ | 主链路远程录像下载交互消息 | +| 14 | 0x1B00_0x1B01 | √ | √ | 远程录像下载请求应答消息 | +| 15 | 0x1B00_0x1B02 | √ | √ | 远程录像下载通知消息 | +| 16 | 0x1B00_0x1B03 | √ | √ | 远程录像下载控制应答消息 | + +#### 从链路动态信息交换消息 + +| 序号 | 消息ID | 完成情况 | 测试情况 | 消息体名称 | +| :---: | :-----------: | :------: | :------: | :----------------------------: | +| 17 | 0x9700 | √ | √ | 从链路时效口令交互消息 | +| 18 | 0x9700_0x9702 | √ | √ | 时效口令请求应答消息(有疑问:应该有应答结果) | +| 19 | 0x9800 | √ | √ | 从链路实时音视频交互信息 | +| 20 | 0x9800_0x9801 | √ | √ | 实时音视频请求消息 | +| 21 | 0x9800_0x9802 | √ | √ | 主动请求停止实时音视频传输消息 | +| 22 | 0x9900 | √ | √ | 从链路远程录像检索交互消息 | +| 23 | 0x9900_0x9901 | √ | √ | 主动上传音视频资源目录信息应答消息 | +| 24 | 0x9900_0x9902 | √ | √ | 查询音视频资源目录请求消息 | +| 25 | 0x9A00 | √ | √ | 从链路远程录像回放交互消息 | +| 26 | 0x9A00_0x9A01 | √ | √ | 远程录像回放请求消息 | +| 27 | 0x9A00_0x9A02 | √ | √ | 远程录像回放控制消息 | +| 28 | 0x9B00 | √ | √ | 从链路远程录像下载交互消息 | +| 29 | 0x9B00_0x9B01 | √ | √ | 远程录像下载请求消息 | +| 30 | 0x9B00_0x9B02 | √ | √ | 远程录像下载完成通知应答消息 | +| 31 | 0x9B00_0x9B03 | √ | √ | 远程录像下载控制消息 | + +### 使用方法 + +```dotnet +IServiceCollection serviceDescriptors1 = new ServiceCollection(); +serviceDescriptors1.AddJT809Configure() + .AddJT1078Configure(); +``` diff --git a/src/JT1078.Protocol.Benchmark/JT1078.Protocol.Benchmark.csproj b/src/JT1078.Protocol.Benchmark/JT1078.Protocol.Benchmark.csproj new file mode 100644 index 0000000..d68e8af --- /dev/null +++ b/src/JT1078.Protocol.Benchmark/JT1078.Protocol.Benchmark.csproj @@ -0,0 +1,22 @@ + + + + netcoreapp2.2;net472 + true + AnyCPU + Exe + + + + + + + + + + + + + + + diff --git a/src/JT1078.Protocol.Benchmark/JT1078SerializerContext.cs b/src/JT1078.Protocol.Benchmark/JT1078SerializerContext.cs new file mode 100644 index 0000000..6f78d51 --- /dev/null +++ b/src/JT1078.Protocol.Benchmark/JT1078SerializerContext.cs @@ -0,0 +1,65 @@ +using BenchmarkDotNet.Attributes; +using BenchmarkDotNet.Configs; +using BenchmarkDotNet.Environments; +using BenchmarkDotNet.Jobs; +using BenchmarkDotNet.Toolchains.CsProj; +using JT808.Protocol.Extensions; +using System; +using System.Collections.Generic; +using System.Linq; + +namespace JT1078.Protocol.Benchmark +{ + [Config(typeof(JT1078SerializerConfig))] + [MarkdownExporterAttribute.GitHub] + [MemoryDiagnoser] + public class JT1078SerializerContext + { + private byte[] JT1078Bytes; + + [Params(100, 10000, 100000)] + public int N; + + [GlobalSetup] + public void Setup() + { + JT1078Bytes = "303163648188113501123456781001300000016BB392DA0503840102030405060708090A0B0C0D0E0F101112131415161718191A1B1C1D1E1F202122232425262728292A2B2C2D2E2F303132333435363738393A3B3C3D3E3F404142434445464748494A4B4C4D4E4F505152535455565758595A5B5C5D5E5F606162636465666768696A6B6C6D6E6F707172737475767778797A7B7C7D7E7F808182838485868788898A8B8C8D8E8F909192939495969798999A9B9C9D9E9FA0A1A2A3A4A5A6A7A8A9AAABACADAEAFB0B1B2B3B4B5B6B7B8B9BABBBCBDBEBFC0C1C2C3C4C5C6C7C8C9CACBCCCDCECFD0D1D2D3D4D5D6D7D8D9DADBDCDDDEDFE0E1E2E3E4E5E6E7E8E9EAEBECEDEEEFF0F1F2F3F4F5F6F7F8F9FAFBFCFDFEFF000102030405060708090A0B0C0D0E0F101112131415161718191A1B1C1D1E1F202122232425262728292A2B2C2D2E2F303132333435363738393A3B3C3D3E3F404142434445464748494A4B4C4D4E4F505152535455565758595A5B5C5D5E5F606162636465666768696A6B6C6D6E6F707172737475767778797A7B7C7D7E7F808182838485868788898A8B8C8D8E8F909192939495969798999A9B9C9D9E9FA0A1A2A3A4A5A6A7A8A9AAABACADAEAFB0B1B2B3B4B5B6B7B8B9BABBBCBDBEBFC0C1C2C3C4C5C6C7C8C9CACBCCCDCECFD0D1D2D3D4D5D6D7D8D9DADBDCDDDEDFE0E1E2E3E4E5E6E7E8E9EAEBECEDEEEFF0F1F2F3F4F5F6F7F8F9FAFBFCFDFEFF000102030405060708090A0B0C0D0E0F101112131415161718191A1B1C1D1E1F202122232425262728292A2B2C2D2E2F303132333435363738393A3B3C3D3E3F404142434445464748494A4B4C4D4E4F505152535455565758595A5B5C5D5E5F606162636465666768696A6B6C6D6E6F707172737475767778797A7B7C7D7E7F808182838485868788898A8B8C8D8E8F909192939495969798999A9B9C9D9E9FA0A1A2A3A4A5A6A7A8A9AAABACADAEAFB0B1B2B3B4B5B6B7B8B9BABBBCBDBEBFC0C1C2C3C4C5C6C7C8C9CACBCCCDCECFD0D1D2D3D4D5D6D7D8D9DADBDCDDDEDFE0E1E2E3E4E5E6E7E8E9EAEBECEDEEEFF0F1F2F3F4F5F6F7F8F9FAFBFCFDFEFF000102030405060708090A0B0C0D0E0F101112131415161718191A1B1C1D1E1F202122232425262728292A2B2C2D2E2F303132333435363738393A3B3C3D3E3F404142434445464748494A4B4C4D4E4F505152535455565758595A5B5C5D5E5F606162636465666768696A6B6C6D6E6F707172737475767778797A7B7C7D7E7F8081828384".ToHexBytes(); + } + + [Benchmark(Description = "JT1078Serializer")] + public void JT1078SerializeTest() + { + for (int i = 0; i < N; i++) + { + JT1078Package jT1078Package = new JT1078Package(); + jT1078Package.Label1 = new JT1078Label1(0x81); + jT1078Package.Label2 = new JT1078Label2(0x88); + jT1078Package.SN = 0x1135; + jT1078Package.SIM = "11234567810"; + jT1078Package.LogicChannelNumber = 0x01; + jT1078Package.Label3 = new JT1078Label3(0x30); + jT1078Package.Timestamp = 1562085874181; + jT1078Package.Bodies = Enumerable.Range(0, 900).Select(s => (byte)(s + 1)).ToArray(); + var hex = JT1078Serializer.Serialize(jT1078Package); + } + } + + [Benchmark(Description = "JT1078Deserialize")] + public void TestJT808_0x0200_Deserialize() + { + for (int i = 0; i < N; i++) + { + JT1078Package package = JT1078Serializer.Deserialize(JT1078Bytes); + } + } + } + + public class JT1078SerializerConfig : ManualConfig + { + public JT1078SerializerConfig() + { + Add(Job.Default.WithGcServer(false).With(Runtime.Clr).With(Platform.AnyCpu)); + Add(Job.Default.WithGcServer(false).With(CsProjCoreToolchain.NetCoreApp22).With(Platform.AnyCpu)); + } + } +} diff --git a/src/JT1078.Protocol.Benchmark/Program.cs b/src/JT1078.Protocol.Benchmark/Program.cs new file mode 100644 index 0000000..df83971 --- /dev/null +++ b/src/JT1078.Protocol.Benchmark/Program.cs @@ -0,0 +1,26 @@ +using BenchmarkDotNet.Attributes; +using BenchmarkDotNet.Configs; +using BenchmarkDotNet.Environments; +using BenchmarkDotNet.Exporters; +using BenchmarkDotNet.Jobs; +using BenchmarkDotNet.Reports; +using BenchmarkDotNet.Running; +using BenchmarkDotNet.Toolchains.CsProj; +using System; +using System.Collections.Generic; +using System.Threading.Tasks; + +namespace JT1078.Protocol.Benchmark +{ + class Program + { + static void Main(string[] args) + { + //安装NuGet包,BenchmarkDotNet + //在需要做性能测试的方法前加上属性[Benchmark]。 + Summary summary = BenchmarkRunner.Run(); + //Summary summary1 = BenchmarkRunner.Run(); + //Summary summary2 = BenchmarkRunner.Run(); + } + } +} diff --git a/src/JT1078.Protocol.Test/JT1078.Protocol.Test.csproj b/src/JT1078.Protocol.Test/JT1078.Protocol.Test.csproj new file mode 100644 index 0000000..3edbf60 --- /dev/null +++ b/src/JT1078.Protocol.Test/JT1078.Protocol.Test.csproj @@ -0,0 +1,20 @@ + + + + netcoreapp2.2 + + false + + + + + + + + + + + + + + diff --git a/src/JT1078.Protocol.Test/JT1078SerializerTest.cs b/src/JT1078.Protocol.Test/JT1078SerializerTest.cs new file mode 100644 index 0000000..7dd7e71 --- /dev/null +++ b/src/JT1078.Protocol.Test/JT1078SerializerTest.cs @@ -0,0 +1,306 @@ +using System; +using Xunit; +using JT808.Protocol.Extensions; +using JT1078.Protocol.Enums; +using System.Linq; + +namespace JT1078.Protocol.Test +{ + public class JT1078SerializerTest + { + [Fact] + public void SerializeTest1() + { + JT1078Package jT1078Package = new JT1078Package(); + jT1078Package.Label1 = new JT1078Label1(0x81); + jT1078Package.Label2 = new JT1078Label2(0xE2); + jT1078Package.SN = 0x1088; + jT1078Package.SIM = "11234567810"; + jT1078Package.LogicChannelNumber = 0x01; + jT1078Package.Label3 = new JT1078Label3(0x10); + jT1078Package.Timestamp = 1562085870204; + jT1078Package.LastIFrameInterval = 0x0280; + jT1078Package.LastFrameInterval = 0x0028; + jT1078Package.Bodies = "00 00 00 01 61 E1 A2 BF 00 98 CF C0 EE 1E 17 28 34 07 78 8E 39 A4 03 FD DB D1 D5 46 BF B0 63 01 3F 59 AC 34 C9 7A 02 1A B9 6A 28 A4 2C 08".ToHexBytes(); + var hex=JT1078Serializer.Serialize(jT1078Package).ToHexString(); + Assert.Equal("30 31 63 64 81 E2 10 88 01 12 34 56 78 10 01 10 00 00 01 6B B3 92 CA 7C 02 80 00 28 00 2E 00 00 00 01 61 E1 A2 BF 00 98 CF C0 EE 1E 17 28 34 07 78 8E 39 A4 03 FD DB D1 D5 46 BF B0 63 01 3F 59 AC 34 C9 7A 02 1A B9 6A 28 A4 2C 08".Replace(" ",""), hex); + } + + [Fact] + public void SerializeTest2() + { + JT1078Package jT1078Package = new JT1078Package(); + jT1078Package.Label1 = new JT1078Label1(0x81); + jT1078Package.Label2 = new JT1078Label2(0x88); + jT1078Package.SN = 0x10BA; + jT1078Package.SIM = "11234567810"; + jT1078Package.LogicChannelNumber = 0x01; + jT1078Package.Label3 = new JT1078Label3(0x30); + jT1078Package.Timestamp = 1562085871501; + jT1078Package.Bodies = "FE 6D 3B BE EF 3E 4E 7D FF B7 6D 5F F5 6F C7 BE 6F DF 77 DC DF 8E ED 3B 6F E3 3F B5 73 DF 6F EC F8 FD FF FE BE EF DB F7 6F DB BF FD D7 BF 6F FB 6F 6E F7 FF 5F DF BF D3 F7 8F FD FA B2 EF 3E F7 5F FF F1 5D 3F BF FB 26 BE ED C7 B7 7D 3F AE E3 FB EF 1D 3B AE 93 FE EF 7F DF 77 93 FE B6 65 3B BD FA E6 8E ED F8 F7 EF DB B1 FF C6 6F 7C FF EF FD DB 71 7F FF 6E EE 3E".ToHexBytes(); + var hex = JT1078Serializer.Serialize(jT1078Package).ToHexString(); + Assert.Equal("30 31 63 64 81 88 10 BA 01 12 34 56 78 10 01 30 00 00 01 6B B3 92 CF 8D 00 78 FE 6D 3B BE EF 3E 4E 7D FF B7 6D 5F F5 6F C7 BE 6F DF 77 DC DF 8E ED 3B 6F E3 3F B5 73 DF 6F EC F8 FD FF FE BE EF DB F7 6F DB BF FD D7 BF 6F FB 6F 6E F7 FF 5F DF BF D3 F7 8F FD FA B2 EF 3E F7 5F FF F1 5D 3F BF FB 26 BE ED C7 B7 7D 3F AE E3 FB EF 1D 3B AE 93 FE EF 7F DF 77 93 FE B6 65 3B BD FA E6 8E ED F8 F7 EF DB B1 FF C6 6F 7C FF EF FD DB 71 7F FF 6E EE 3E".Replace(" ", ""), hex); + } + + [Fact] + public void SerializeTest3() + { + JT1078Package jT1078Package = new JT1078Package(); + jT1078Package.Label1 = new JT1078Label1(0x81); + jT1078Package.Label2 = new JT1078Label2(0xE2); + jT1078Package.SN = 0x10BB; + jT1078Package.SIM = "11234567810"; + jT1078Package.LogicChannelNumber = 0x01; + jT1078Package.Label3 = new JT1078Label3(0x10); + jT1078Package.LastIFrameInterval = 0x0730; + jT1078Package.LastFrameInterval = 0x0028; + jT1078Package.Timestamp = 1562085871404; + jT1078Package.Bodies = "00 00 00 01 61 E4 62 BF 00 32 BE 88 82 3B 94 6F 41 EE 7C 28 7D 82 A5 9C 29 49 A8 4C BF".ToHexBytes(); + var hex = JT1078Serializer.Serialize(jT1078Package).ToHexString(); + Assert.Equal("30 31 63 64 81 E2 10 BB 01 12 34 56 78 10 01 10 00 00 01 6B B3 92 CF 2C 07 30 00 28 00 1D 00 00 00 01 61 E4 62 BF 00 32 BE 88 82 3B 94 6F 41 EE 7C 28 7D 82 A5 9C 29 49 A8 4C BF".Replace(" ", ""), hex); + } + + [Fact] + public void SerializeTest4() + { + JT1078Package jT1078Package = new JT1078Package(); + jT1078Package.Label1 = new JT1078Label1(0x81); + jT1078Package.Label2 = new JT1078Label2(0x88); + jT1078Package.SN = 0x1135; + jT1078Package.SIM = "11234567810"; + jT1078Package.LogicChannelNumber = 0x01; + jT1078Package.Label3 = new JT1078Label3(0x30); + jT1078Package.Timestamp = 1562085874181; + jT1078Package.Bodies = "B7 6D FF EF 7D FB A9 9D FE A9 1F 37 77 F3 37 BE EF FB F7 FB FB BE 7D DF B7 FD FB 76 AF DE 77 65 C7 EF E3 FB BE FF DB 4E FF DB B7 63 FF EE EF D8 BE 1D 37 B7 7D E7 7D F3 C6 F7 FD F4 BE 1F F7 B7 55 FF 76 FC FE CE 7B FF B7 7D 3F F5 FF FE 76 6C DF FE 53 DB CF 6D FB BF FD DE B1 EF 3E 77 D3 3F 6E 9A BF BF FF DB F7 FD DB 7F 63 FF 6E EC F8 EE 1F FB FD 7F FB 7D 7C DB".ToHexBytes(); + var hex = JT1078Serializer.Serialize(jT1078Package).ToHexString(); + Assert.Equal("30 31 63 64 81 88 11 35 01 12 34 56 78 10 01 30 00 00 01 6B B3 92 DA 05 00 78 B7 6D FF EF 7D FB A9 9D FE A9 1F 37 77 F3 37 BE EF FB F7 FB FB BE 7D DF B7 FD FB 76 AF DE 77 65 C7 EF E3 FB BE FF DB 4E FF DB B7 63 FF EE EF D8 BE 1D 37 B7 7D E7 7D F3 C6 F7 FD F4 BE 1F F7 B7 55 FF 76 FC FE CE 7B FF B7 7D 3F F5 FF FE 76 6C DF FE 53 DB CF 6D FB BF FD DE B1 EF 3E 77 D3 3F 6E 9A BF BF FF DB F7 FD DB 7F 63 FF 6E EC F8 EE 1F FB FD 7F FB 7D 7C DB".Replace(" ", ""), hex); + } + + [Fact] + public void SerializeTest5() + { + JT1078Package jT1078Package = new JT1078Package(); + jT1078Package.Label1 = new JT1078Label1(0x81); + jT1078Package.Label2 = new JT1078Label2(0x88); + jT1078Package.SN = 0x1135; + jT1078Package.SIM = "11234567810"; + jT1078Package.LogicChannelNumber = 0x01; + jT1078Package.Label3 = new JT1078Label3(0x30); + jT1078Package.Timestamp = 1562085874181; + jT1078Package.Bodies = Enumerable.Range(0, 900).Select(s => (byte)(s + 1)).ToArray(); + var hex = JT1078Serializer.Serialize(jT1078Package).ToHexString(); + } + + [Fact] + public void DeserializeTest1() + { + //30 31 63 64 + //81 + //E2 + //10 88 + //01 12 34 56 78 10 + //01 + //10 + //00 00 01 6B B3 92 CA 7C + //02 80 + //00 28 + //00 2E + //00 00 00 01 61 E1 A2 BF + //00 98 CF C0 EE 1E 17 28 + //34 07 78 8E 39 A4 03 FD + //DB D1 D5 46 BF B0 63 01 + //3F 59 AC 34 C9 7A 02 1A + //B9 6A 28 A4 2C 08 + var bytes = "30 31 63 64 81 E2 10 88 01 12 34 56 78 10 01 10 00 00 01 6B B3 92 CA 7C 02 80 00 28 00 2E 00 00 00 01 61 E1 A2 BF 00 98 CF C0 EE 1E 17 28 34 07 78 8E 39 A4 03 FD DB D1 D5 46 BF B0 63 01 3F 59 AC 34 C9 7A 02 1A B9 6A 28 A4 2C 08".ToHexBytes(); + JT1078Package package = JT1078Serializer.Deserialize(bytes); + Assert.Equal(0x81, package.Label1.ToByte()); + Assert.Equal(0xE2, package.Label2.ToByte()); + Assert.Equal(0x1088, package.SN); + Assert.Equal("011234567810", package.SIM); + Assert.Equal(0x01, package.LogicChannelNumber); + Assert.Equal(0x10, package.Label3.ToByte()); + Assert.Equal((ulong)1562085870204, package.Timestamp); + Assert.Equal(0x0280, package.LastIFrameInterval); + Assert.Equal(0x0028, package.LastFrameInterval); + Assert.Equal(0x002E, package.DataBodyLength); + Assert.Equal("00 00 00 01 61 E1 A2 BF 00 98 CF C0 EE 1E 17 28 34 07 78 8E 39 A4 03 FD DB D1 D5 46 BF B0 63 01 3F 59 AC 34 C9 7A 02 1A B9 6A 28 A4 2C 08".ToHexBytes(), package.Bodies); + } + + [Fact] + public void DeserializeTest2() + { + //30 31 63 64 + //81 + //88 + //10 BA + //01 12 34 56 78 10 + //01 + //30 + //00 00 01 6B B3 92 CF 8D + //00 78 + //FE 6D 3B BE EF 3E 4E 7D + //FF B7 6D 5F F5 6F C7 BE + //6F DF 77 DC DF 8E ED 3B + //6F E3 3F B5 73 DF 6F EC + //F8 FD FF FE BE EF DB F7 + //6F DB BF FD D7 BF 6F FB + //6F 6E F7 FF 5F DF BF D3 + //F7 8F FD FA B2 EF 3E F7 + //5F FF F1 5D 3F BF FB 26 + //BE ED C7 B7 7D 3F AE E3 + //FB EF 1D 3B AE 93 FE EF + //7F DF 77 93 FE B6 65 3B + //BD FA E6 8E ED F8 F7 EF + //DB B1 FF C6 6F 7C FF EF + //FD DB 71 7F FF 6E EE 3E + var bytes = "30 31 63 64 81 88 10 BA 01 12 34 56 78 10 01 30 00 00 01 6B B3 92 CF 8D 00 78 FE 6D 3B BE EF 3E 4E 7D FF B7 6D 5F F5 6F C7 BE 6F DF 77 DC DF 8E ED 3B 6F E3 3F B5 73 DF 6F EC F8 FD FF FE BE EF DB F7 6F DB BF FD D7 BF 6F FB 6F 6E F7 FF 5F DF BF D3 F7 8F FD FA B2 EF 3E F7 5F FF F1 5D 3F BF FB 26 BE ED C7 B7 7D 3F AE E3 FB EF 1D 3B AE 93 FE EF 7F DF 77 93 FE B6 65 3B BD FA E6 8E ED F8 F7 EF DB B1 FF C6 6F 7C FF EF FD DB 71 7F FF 6E EE 3E".ToHexBytes(); + JT1078Package package = JT1078Serializer.Deserialize(bytes); + Assert.Equal(0x81, package.Label1.ToByte()); + Assert.Equal(0x88, package.Label2.ToByte()); + Assert.Equal(0x10BA, package.SN); + Assert.Equal("011234567810", package.SIM); + Assert.Equal(0x01, package.LogicChannelNumber); + Assert.Equal(0x30, package.Label3.ToByte()); + Assert.Equal((ulong)1562085871501, package.Timestamp); + Assert.Equal(0x0078, package.DataBodyLength); + Assert.Equal("FE 6D 3B BE EF 3E 4E 7D FF B7 6D 5F F5 6F C7 BE 6F DF 77 DC DF 8E ED 3B 6F E3 3F B5 73 DF 6F EC F8 FD FF FE BE EF DB F7 6F DB BF FD D7 BF 6F FB 6F 6E F7 FF 5F DF BF D3 F7 8F FD FA B2 EF 3E F7 5F FF F1 5D 3F BF FB 26 BE ED C7 B7 7D 3F AE E3 FB EF 1D 3B AE 93 FE EF 7F DF 77 93 FE B6 65 3B BD FA E6 8E ED F8 F7 EF DB B1 FF C6 6F 7C FF EF FD DB 71 7F FF 6E EE 3E".ToHexBytes(), package.Bodies.ToArray()); + } + + [Fact] + public void DeserializeTest3() + { + //30 31 63 64 + //81 + //E2 + //10 BB + //01 12 34 56 78 10 + //01 + //10 + //00 00 01 6B B3 92 CF 2C + //07 30 + //00 28 + //00 1D + //00 00 00 01 61 E4 62 BF + //00 32 BE 88 82 3B 94 6F + //41 EE 7C 28 7D 82 A5 9C + //29 49 A8 4C BF + var bytes = "30 31 63 64 81 E2 10 BB 01 12 34 56 78 10 01 10 00 00 01 6B B3 92 CF 2C 07 30 00 28 00 1D 00 00 00 01 61 E4 62 BF 00 32 BE 88 82 3B 94 6F 41 EE 7C 28 7D 82 A5 9C 29 49 A8 4C BF".ToHexBytes(); + JT1078Package package = JT1078Serializer.Deserialize(bytes); + Assert.Equal(0x81, package.Label1.ToByte()); + Assert.Equal(0xE2, package.Label2.ToByte()); + Assert.Equal(0x10BB, package.SN); + Assert.Equal("011234567810", package.SIM); + Assert.Equal(0x01, package.LogicChannelNumber); + Assert.Equal(0x10, package.Label3.ToByte()); + Assert.Equal((ulong)1562085871404, package.Timestamp); + Assert.Equal(0x0730, package.LastIFrameInterval); + Assert.Equal(0x0028, package.LastFrameInterval); + Assert.Equal(0x001D, package.DataBodyLength); + Assert.Equal("00 00 00 01 61 E4 62 BF 00 32 BE 88 82 3B 94 6F 41 EE 7C 28 7D 82 A5 9C 29 49 A8 4C BF".ToHexBytes(), package.Bodies.ToArray()); + } + + [Fact] + public void DeserializeTest4() + { + //30 31 63 64 + //81 + //88 + //11 35 + //01 12 34 56 78 10 + //01 + //30 + //00 00 01 6B B3 92 DA 05 + //00 78 + //B7 6D FF EF 7D FB A9 9D + //FE A9 1F 37 77 F3 37 BE + //EF FB F7 FB FB BE 7D DF + //B7 FD FB 76 AF DE 77 65 + //C7 EF E3 FB BE FF DB 4E + //FF DB B7 63 FF EE EF D8 + //BE 1D 37 B7 7D E7 7D F3 + //C6 F7 FD F4 BE 1F F7 B7 + //55 FF 76 FC FE CE 7B FF + //B7 7D 3F F5 FF FE 76 6C + //DF FE 53 DB CF 6D FB BF + //FD DE B1 EF 3E 77 D3 3F + //6E 9A BF BF FF DB F7 FD + //DB 7F 63 FF 6E EC F8 EE + //1F FB FD 7F FB 7D 7C DB + var bytes = "30 31 63 64 81 88 11 35 01 12 34 56 78 10 01 30 00 00 01 6B B3 92 DA 05 00 78 B7 6D FF EF 7D FB A9 9D FE A9 1F 37 77 F3 37 BE EF FB F7 FB FB BE 7D DF B7 FD FB 76 AF DE 77 65 C7 EF E3 FB BE FF DB 4E FF DB B7 63 FF EE EF D8 BE 1D 37 B7 7D E7 7D F3 C6 F7 FD F4 BE 1F F7 B7 55 FF 76 FC FE CE 7B FF B7 7D 3F F5 FF FE 76 6C DF FE 53 DB CF 6D FB BF FD DE B1 EF 3E 77 D3 3F 6E 9A BF BF FF DB F7 FD DB 7F 63 FF 6E EC F8 EE 1F FB FD 7F FB 7D 7C DB".ToHexBytes(); + JT1078Package package = JT1078Serializer.Deserialize(bytes); + Assert.Equal(0x81, package.Label1.ToByte()); + Assert.Equal(0x88, package.Label2.ToByte()); + Assert.Equal(0x1135, package.SN); + Assert.Equal("011234567810", package.SIM); + Assert.Equal(0x01, package.LogicChannelNumber); + Assert.Equal(0x30, package.Label3.ToByte()); + Assert.Equal((ulong)1562085874181, package.Timestamp); + Assert.Equal(0x0078, package.DataBodyLength); + Assert.Equal("B7 6D FF EF 7D FB A9 9D FE A9 1F 37 77 F3 37 BE EF FB F7 FB FB BE 7D DF B7 FD FB 76 AF DE 77 65 C7 EF E3 FB BE FF DB 4E FF DB B7 63 FF EE EF D8 BE 1D 37 B7 7D E7 7D F3 C6 F7 FD F4 BE 1F F7 B7 55 FF 76 FC FE CE 7B FF B7 7D 3F F5 FF FE 76 6C DF FE 53 DB CF 6D FB BF FD DE B1 EF 3E 77 D3 3F 6E 9A BF BF FF DB F7 FD DB 7F 63 FF 6E EC F8 EE 1F FB FD 7F FB 7D 7C DB".ToHexBytes(), package.Bodies.ToArray()); + } + + [Fact] + public void Label1Test1() + { + Assert.Equal(0x81, JT1078Package.DefaultLabel1.ToByte()); + } + + [Fact] + public void Label1Test2() + { + Assert.Equal(223, new JT1078Label1(3, 0, 1, 15).ToByte()); + JT1078Label1 label1 = new JT1078Label1(223); + Assert.Equal(3, label1.V); + Assert.Equal(0, label1.P); + Assert.Equal(1, label1.X); + Assert.Equal(15, label1.CC); + } + + [Fact] + public void Label1Test3() + { + Assert.Equal(127, new JT1078Label1(127).ToByte()); + Assert.Equal(89, new JT1078Label1(89).ToByte()); + Assert.Equal(254, new JT1078Label1(254).ToByte()); + Assert.Equal(2, new JT1078Label1(2).ToByte()); + Assert.Equal(10, new JT1078Label1(10).ToByte()); + Assert.Equal(9, new JT1078Label1(9).ToByte()); + } + + [Fact] + public void Label2Test1() + { + JT1078Label2 label2 = new JT1078Label2(254); + Assert.Equal(254, label2.ToByte()); + Assert.Equal(1, label2.M); + Assert.Equal(126, label2.PT); + } + + [Fact] + public void Label2Test2() + { + JT1078Label2 label2 = new JT1078Label2(0, 28); + Assert.Equal(28, label2.ToByte()); + Assert.Equal(0, label2.M); + Assert.Equal(28, label2.PT); + } + + [Fact] + public void Label3Test1() + { + JT1078Label3 label3 = new JT1078Label3(34); + Assert.Equal(34, label3.ToByte()); + Assert.Equal(JT1078DataType.视频B帧, label3.DataType); + Assert.Equal(JT1078SubPackageType.分包处理时的最后一个包, label3.SubpackageType); + } + + [Fact] + public void Label3Test2() + { + JT1078Label3 label3 = new JT1078Label3(JT1078DataType.视频B帧, JT1078SubPackageType.分包处理时的最后一个包); + Assert.Equal(34, label3.ToByte()); + Assert.Equal(JT1078DataType.视频B帧, label3.DataType); + Assert.Equal(JT1078SubPackageType.分包处理时的最后一个包, label3.SubpackageType); + } + } +} diff --git a/src/JT1078.Protocol.Tools/App.config b/src/JT1078.Protocol.Tools/App.config new file mode 100644 index 0000000..226a251 --- /dev/null +++ b/src/JT1078.Protocol.Tools/App.config @@ -0,0 +1,18 @@ + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/src/JT1078.Protocol.Tools/ByteArrayHexConverter.cs b/src/JT1078.Protocol.Tools/ByteArrayHexConverter.cs new file mode 100644 index 0000000..c6c0856 --- /dev/null +++ b/src/JT1078.Protocol.Tools/ByteArrayHexConverter.cs @@ -0,0 +1,29 @@ +using Newtonsoft.Json; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace JT1078.Protocol.Tools +{ + class ByteArrayHexConverter : JsonConverter + { + public override bool CanConvert(Type objectType) => objectType == typeof(byte[]); + + public override bool CanRead => false; + public override bool CanWrite => true; + + public override object ReadJson(JsonReader reader, Type objectType, object existingValue, JsonSerializer serializer) => throw new NotImplementedException(); + + private readonly string _separator; + + public ByteArrayHexConverter(string separator = " ") => _separator = separator; + + public override void WriteJson(JsonWriter writer, object value, JsonSerializer serializer) + { + var hexString = string.Join(_separator, ((byte[])value).Select(p => p.ToString("X2"))); + writer.WriteValue(hexString); + } + } +} diff --git a/src/JT1078.Protocol.Tools/Form1.Designer.cs b/src/JT1078.Protocol.Tools/Form1.Designer.cs new file mode 100644 index 0000000..6736f3b --- /dev/null +++ b/src/JT1078.Protocol.Tools/Form1.Designer.cs @@ -0,0 +1,87 @@ +namespace JT1078.Protocol.Tools +{ + partial class JT1078Form + { + /// + /// 必需的设计器变量。 + /// + private System.ComponentModel.IContainer components = null; + + /// + /// 清理所有正在使用的资源。 + /// + /// 如果应释放托管资源,为 true;否则为 false。 + protected override void Dispose(bool disposing) + { + if (disposing && (components != null)) + { + components.Dispose(); + } + base.Dispose(disposing); + } + + #region Windows 窗体设计器生成的代码 + + /// + /// 设计器支持所需的方法 - 不要修改 + /// 使用代码编辑器修改此方法的内容。 + /// + private void InitializeComponent() + { + this.button1 = new System.Windows.Forms.Button(); + this.textBox1 = new System.Windows.Forms.TextBox(); + this.textBox2 = new System.Windows.Forms.TextBox(); + this.SuspendLayout(); + // + // button1 + // + this.button1.Location = new System.Drawing.Point(12, 31); + this.button1.Name = "button1"; + this.button1.Size = new System.Drawing.Size(226, 42); + this.button1.TabIndex = 0; + this.button1.Text = "解析"; + this.button1.UseVisualStyleBackColor = true; + this.button1.Click += new System.EventHandler(this.Button1_Click); + // + // textBox1 + // + this.textBox1.Location = new System.Drawing.Point(12, 91); + this.textBox1.Multiline = true; + this.textBox1.Name = "textBox1"; + this.textBox1.ScrollBars = System.Windows.Forms.ScrollBars.Vertical; + this.textBox1.Size = new System.Drawing.Size(275, 379); + this.textBox1.TabIndex = 2; + // + // textBox2 + // + this.textBox2.Location = new System.Drawing.Point(307, 91); + this.textBox2.Multiline = true; + this.textBox2.Name = "textBox2"; + this.textBox2.ScrollBars = System.Windows.Forms.ScrollBars.Vertical; + this.textBox2.Size = new System.Drawing.Size(503, 379); + this.textBox2.TabIndex = 3; + // + // JT1078Form + // + this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 12F); + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + this.ClientSize = new System.Drawing.Size(822, 492); + this.Controls.Add(this.textBox2); + this.Controls.Add(this.textBox1); + this.Controls.Add(this.button1); + this.Name = "JT1078Form"; + this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen; + this.Text = "JT1078解析工具"; + this.ResumeLayout(false); + this.PerformLayout(); + + } + + #endregion + + private System.Windows.Forms.Button button1; + private System.Windows.Forms.TextBox textBox1; + private System.Windows.Forms.TextBox textBox2; + } +} + diff --git a/src/JT1078.Protocol.Tools/Form1.cs b/src/JT1078.Protocol.Tools/Form1.cs new file mode 100644 index 0000000..c01ac95 --- /dev/null +++ b/src/JT1078.Protocol.Tools/Form1.cs @@ -0,0 +1,53 @@ +using System; +using System.Collections.Generic; +using System.ComponentModel; +using System.Data; +using System.Drawing; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Windows.Forms; +using JT1078.Protocol.Tools.Extensions; +using Newtonsoft.Json; +using Newtonsoft.Json.Converters; + +namespace JT1078.Protocol.Tools +{ + public partial class JT1078Form : Form + { + public JT1078Form() + { + InitializeComponent(); + Newtonsoft.Json.JsonSerializerSettings setting = new Newtonsoft.Json.JsonSerializerSettings(); + JsonConvert.DefaultSettings = new Func(() => + { + setting.Converters.Add(new StringEnumConverter()); + setting.Converters.Add(new ByteArrayHexConverter()); + return setting; + }); + } + + private void Button1_Click(object sender, EventArgs e) + { + if (string.IsNullOrEmpty(this.textBox1.Text)) + { + MessageBox.Show("请输入数据包!"); + return; + } + try + { + var buffer = this.textBox1.Text.ToHexBytes(); + + JT1078Package package = JT1078Serializer.Deserialize(buffer); + + this.textBox2.Text= JsonConvert.SerializeObject(package, Formatting.Indented); + + + } + catch (Exception ex) + { + this.textBox2.Text = JsonConvert.SerializeObject(ex); + } + } + } +} diff --git a/src/JT1078.Protocol.Tools/Form1.resx b/src/JT1078.Protocol.Tools/Form1.resx new file mode 100644 index 0000000..1af7de1 --- /dev/null +++ b/src/JT1078.Protocol.Tools/Form1.resx @@ -0,0 +1,120 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + \ No newline at end of file diff --git a/src/JT1078.Protocol.Tools/HexExtensions.cs b/src/JT1078.Protocol.Tools/HexExtensions.cs new file mode 100644 index 0000000..e830587 --- /dev/null +++ b/src/JT1078.Protocol.Tools/HexExtensions.cs @@ -0,0 +1,80 @@ +using System; + +namespace JT1078.Protocol.Tools.Extensions +{ + public static partial class BinaryExtensions + { + public static string ToHexString(this byte[] source) + { + return HexUtil.DoHexDump(source, 0, source.Length).ToUpper(); + } + /// + /// 16进制字符串转16进制数组 + /// + /// + /// + /// + public static byte[] ToHexBytes(this string hexString) + { + hexString = hexString.Replace(" ", ""); + byte[] buf = new byte[hexString.Length / 2]; + ReadOnlySpan readOnlySpan = hexString.AsSpan(); + for (int i = 0; i < hexString.Length; i++) + { + if (i % 2 == 0) + { + buf[i / 2] = Convert.ToByte(readOnlySpan.Slice(i, 2).ToString(), 16); + } + } + return buf; + } + } + + public static class HexUtil + { + static readonly char[] HexdumpTable = new char[256 * 4]; + static HexUtil() + { + char[] digits = "0123456789ABCDEF".ToCharArray(); + for (int i = 0; i < 256; i++) + { + HexdumpTable[i << 1] = digits[(int)((uint)i >> 4 & 0x0F)]; + HexdumpTable[(i << 1) + 1] = digits[i & 0x0F]; + } + } + + public static string DoHexDump(ReadOnlySpan buffer, int fromIndex, int length) + { + if (length == 0) + { + return ""; + } + int endIndex = fromIndex + length; + var buf = new char[length << 1]; + int srcIdx = fromIndex; + int dstIdx = 0; + for (; srcIdx < endIndex; srcIdx++, dstIdx += 2) + { + Array.Copy(HexdumpTable, buffer[srcIdx] << 1, buf, dstIdx, 2); + } + return new string(buf); + } + + public static string DoHexDump(byte[] array, int fromIndex, int length) + { + if (length == 0) + { + return ""; + } + int endIndex = fromIndex + length; + var buf = new char[length << 1]; + int srcIdx = fromIndex; + int dstIdx = 0; + for (; srcIdx < endIndex; srcIdx++, dstIdx += 2) + { + Array.Copy(HexdumpTable, (array[srcIdx] & 0xFF) << 1, buf, dstIdx, 2); + } + return new string(buf); + } + } +} diff --git a/src/JT1078.Protocol.Tools/JT1078.Protocol.Tools.csproj b/src/JT1078.Protocol.Tools/JT1078.Protocol.Tools.csproj new file mode 100644 index 0000000..dc30a97 --- /dev/null +++ b/src/JT1078.Protocol.Tools/JT1078.Protocol.Tools.csproj @@ -0,0 +1,148 @@ + + + + + Debug + AnyCPU + {97C4DE73-E41C-4026-B97B-79ECC8A71C91} + WinExe + JT1078.Protocol.Tools + JT1078.Protocol.Tools + v4.7.2 + 512 + true + true + false + publish\ + true + Disk + false + Foreground + 7 + Days + false + false + true + 1 + 1.0.0.%2a + false + true + true + + + AnyCPU + true + full + false + bin\Debug\ + DEBUG;TRACE + prompt + 4 + + + AnyCPU + pdbonly + true + bin\Release\ + TRACE + prompt + 4 + + + EF6E3B26CE85A0FC7A8A4536400E8FC8108FF04F + + + JT1078.Protocol.Tools_TemporaryKey.pfx + + + true + + + false + + + + ..\packages\Newtonsoft.Json.12.0.2\lib\net45\Newtonsoft.Json.dll + + + + ..\packages\System.Buffers.4.5.0\lib\netstandard2.0\System.Buffers.dll + + + + ..\packages\System.Memory.4.5.3\lib\netstandard2.0\System.Memory.dll + + + + ..\packages\System.Numerics.Vectors.4.5.0\lib\net46\System.Numerics.Vectors.dll + + + ..\packages\System.Runtime.CompilerServices.Unsafe.4.5.2\lib\netstandard2.0\System.Runtime.CompilerServices.Unsafe.dll + + + + + + + + + + + + + + + Form + + + Form1.cs + + + + + + Form1.cs + + + ResXFileCodeGenerator + Resources.Designer.cs + Designer + + + True + Resources.resx + + + + SettingsSingleFileGenerator + Settings.Designer.cs + + + True + Settings.settings + True + + + + + + + + False + Microsoft .NET Framework 4.7.2 %28x86 和 x64%29 + true + + + False + .NET Framework 3.5 SP1 + false + + + + + {60cac24b-7317-48bf-9dbf-7f3eca3689a4} + JT1078.Protocol + + + + \ No newline at end of file diff --git a/src/JT1078.Protocol.Tools/Program.cs b/src/JT1078.Protocol.Tools/Program.cs new file mode 100644 index 0000000..57969d8 --- /dev/null +++ b/src/JT1078.Protocol.Tools/Program.cs @@ -0,0 +1,22 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Threading.Tasks; +using System.Windows.Forms; + +namespace JT1078.Protocol.Tools +{ + static class Program + { + /// + /// 应用程序的主入口点。 + /// + [STAThread] + static void Main() + { + Application.EnableVisualStyles(); + Application.SetCompatibleTextRenderingDefault(false); + Application.Run(new JT1078Form()); + } + } +} diff --git a/src/JT1078.Protocol.Tools/Properties/AssemblyInfo.cs b/src/JT1078.Protocol.Tools/Properties/AssemblyInfo.cs new file mode 100644 index 0000000..2798d30 --- /dev/null +++ b/src/JT1078.Protocol.Tools/Properties/AssemblyInfo.cs @@ -0,0 +1,36 @@ +using System.Reflection; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; + +// 有关程序集的一般信息由以下 +// 控制。更改这些特性值可修改 +// 与程序集关联的信息。 +[assembly: AssemblyTitle("JT1078.Protocol.Tools")] +[assembly: AssemblyDescription("")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("")] +[assembly: AssemblyProduct("JT1078.Protocol.Tools")] +[assembly: AssemblyCopyright("Copyright © 2019")] +[assembly: AssemblyTrademark("")] +[assembly: AssemblyCulture("")] + +// 将 ComVisible 设置为 false 会使此程序集中的类型 +//对 COM 组件不可见。如果需要从 COM 访问此程序集中的类型 +//请将此类型的 ComVisible 特性设置为 true。 +[assembly: ComVisible(false)] + +// 如果此项目向 COM 公开,则下列 GUID 用于类型库的 ID +[assembly: Guid("97c4de73-e41c-4026-b97b-79ecc8a71c91")] + +// 程序集的版本信息由下列四个值组成: +// +// 主版本 +// 次版本 +// 生成号 +// 修订号 +// +//可以指定所有这些值,也可以使用“生成号”和“修订号”的默认值 +//通过使用 "*",如下所示: +// [assembly: AssemblyVersion("1.0.*")] +[assembly: AssemblyVersion("1.0.0.0")] +[assembly: AssemblyFileVersion("1.0.0.0")] diff --git a/src/JT1078.Protocol.Tools/Properties/Resources.Designer.cs b/src/JT1078.Protocol.Tools/Properties/Resources.Designer.cs new file mode 100644 index 0000000..7bc7e33 --- /dev/null +++ b/src/JT1078.Protocol.Tools/Properties/Resources.Designer.cs @@ -0,0 +1,71 @@ +//------------------------------------------------------------------------------ +// +// 此代码由工具生成。 +// 运行时版本: 4.0.30319.42000 +// +// 对此文件的更改可能导致不正确的行为,如果 +// 重新生成代码,则所做更改将丢失。 +// +//------------------------------------------------------------------------------ + +namespace JT1078.Protocol.Tools.Properties +{ + + + /// + /// 强类型资源类,用于查找本地化字符串等。 + /// + // 此类是由 StronglyTypedResourceBuilder + // 类通过类似于 ResGen 或 Visual Studio 的工具自动生成的。 + // 若要添加或删除成员,请编辑 .ResX 文件,然后重新运行 ResGen + // (以 /str 作为命令选项),或重新生成 VS 项目。 + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "4.0.0.0")] + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] + internal class Resources + { + + private static global::System.Resources.ResourceManager resourceMan; + + private static global::System.Globalization.CultureInfo resourceCulture; + + [global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")] + internal Resources() + { + } + + /// + /// 返回此类使用的缓存 ResourceManager 实例。 + /// + [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] + internal static global::System.Resources.ResourceManager ResourceManager + { + get + { + if ((resourceMan == null)) + { + global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("JT1078.Protocol.Tools.Properties.Resources", typeof(Resources).Assembly); + resourceMan = temp; + } + return resourceMan; + } + } + + /// + /// 覆盖当前线程的 CurrentUICulture 属性 + /// 使用此强类型的资源类的资源查找。 + /// + [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] + internal static global::System.Globalization.CultureInfo Culture + { + get + { + return resourceCulture; + } + set + { + resourceCulture = value; + } + } + } +} diff --git a/src/JT1078.Protocol.Tools/Properties/Resources.resx b/src/JT1078.Protocol.Tools/Properties/Resources.resx new file mode 100644 index 0000000..af7dbeb --- /dev/null +++ b/src/JT1078.Protocol.Tools/Properties/Resources.resx @@ -0,0 +1,117 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + \ No newline at end of file diff --git a/src/JT1078.Protocol.Tools/Properties/Settings.Designer.cs b/src/JT1078.Protocol.Tools/Properties/Settings.Designer.cs new file mode 100644 index 0000000..035838e --- /dev/null +++ b/src/JT1078.Protocol.Tools/Properties/Settings.Designer.cs @@ -0,0 +1,30 @@ +//------------------------------------------------------------------------------ +// +// This code was generated by a tool. +// Runtime Version:4.0.30319.42000 +// +// Changes to this file may cause incorrect behavior and will be lost if +// the code is regenerated. +// +//------------------------------------------------------------------------------ + +namespace JT1078.Protocol.Tools.Properties +{ + + + [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "11.0.0.0")] + internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase + { + + private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings()))); + + public static Settings Default + { + get + { + return defaultInstance; + } + } + } +} diff --git a/src/JT1078.Protocol.Tools/Properties/Settings.settings b/src/JT1078.Protocol.Tools/Properties/Settings.settings new file mode 100644 index 0000000..3964565 --- /dev/null +++ b/src/JT1078.Protocol.Tools/Properties/Settings.settings @@ -0,0 +1,7 @@ + + + + + + + diff --git a/src/JT1078.Protocol.Tools/packages.config b/src/JT1078.Protocol.Tools/packages.config new file mode 100644 index 0000000..a7dbfa7 --- /dev/null +++ b/src/JT1078.Protocol.Tools/packages.config @@ -0,0 +1,8 @@ + + + + + + + + \ No newline at end of file diff --git a/src/JT1078.Protocol/Buffers/JT1078BufferWriter.cs b/src/JT1078.Protocol/Buffers/JT1078BufferWriter.cs new file mode 100644 index 0000000..6280192 --- /dev/null +++ b/src/JT1078.Protocol/Buffers/JT1078BufferWriter.cs @@ -0,0 +1,24 @@ +using System; + +namespace JT1078.Protocol.Buffers +{ + /// + /// + /// + ref partial struct JT1078BufferWriter + { + private Span _buffer; + public JT1078BufferWriter(Span buffer) + { + _buffer = buffer; + WrittenCount = 0; + } + public Span Free => _buffer.Slice(WrittenCount); + public Span Written => _buffer.Slice(0, WrittenCount); + public int WrittenCount { get; private set; } + public void Advance(int count) + { + WrittenCount += count; + } + } +} diff --git a/src/JT1078.Protocol/Enums/JT1078DataType.cs b/src/JT1078.Protocol/Enums/JT1078DataType.cs new file mode 100644 index 0000000..130ff1b --- /dev/null +++ b/src/JT1078.Protocol/Enums/JT1078DataType.cs @@ -0,0 +1,15 @@ +using System; +using System.Collections.Generic; +using System.Text; + +namespace JT1078.Protocol.Enums +{ + public enum JT1078DataType:byte + { + 视频I帧=0, + 视频P帧=1, + 视频B帧=2, + 音频帧=3, + 透传数据=4, + } +} diff --git a/src/JT1078.Protocol/Enums/JT1078SubPackageType.cs b/src/JT1078.Protocol/Enums/JT1078SubPackageType.cs new file mode 100644 index 0000000..76dace0 --- /dev/null +++ b/src/JT1078.Protocol/Enums/JT1078SubPackageType.cs @@ -0,0 +1,17 @@ +using System; +using System.Collections.Generic; +using System.Text; + +namespace JT1078.Protocol.Enums +{ + /// + /// 分包处理标记 + /// + public enum JT1078SubPackageType:byte + { + 原子包_不可被拆分=0, + 分包处理时的第一个包=1, + 分包处理时的最后一个包=2, + 分包处理时的中间包=3 + } +} diff --git a/src/JT1078.Protocol/JT1078.Protocol.csproj b/src/JT1078.Protocol/JT1078.Protocol.csproj new file mode 100644 index 0000000..c89122c --- /dev/null +++ b/src/JT1078.Protocol/JT1078.Protocol.csproj @@ -0,0 +1,34 @@ + + + + netstandard2.0 + 7.3 + Copyright 2019. + SmallChi(Koike) + JT1078 + JT1078 + 基于JT1078的RTP协议 + 基于JT1078的RTP协议 + https://github.com/SmallChi/JT1078 + https://github.com/SmallChi/JT1078 + https://github.com/SmallChi/JT1078/blob/master/LICENSE + https://github.com/SmallChi/JT1078/blob/master/LICENSE + false + 1.0.0 + false + true + LICENSE + + + + + + + + + True + + + + + diff --git a/src/JT1078.Protocol/JT1078ArrayPool.cs b/src/JT1078.Protocol/JT1078ArrayPool.cs new file mode 100644 index 0000000..ebe7924 --- /dev/null +++ b/src/JT1078.Protocol/JT1078ArrayPool.cs @@ -0,0 +1,24 @@ +using System.Buffers; + +namespace JT1078.Protocol +{ + internal static class JT1078ArrayPool + { + private readonly static ArrayPool ArrayPool; + + static JT1078ArrayPool() + { + ArrayPool = ArrayPool.Create(); + } + + public static byte[] Rent(int minimumLength) + { + return ArrayPool.Rent(minimumLength); + } + + public static void Return(byte[] array, bool clearArray = false) + { + ArrayPool.Return(array, clearArray); + } + } +} diff --git a/src/JT1078.Protocol/JT1078Label1.cs b/src/JT1078.Protocol/JT1078Label1.cs new file mode 100644 index 0000000..2f1d3ba --- /dev/null +++ b/src/JT1078.Protocol/JT1078Label1.cs @@ -0,0 +1,50 @@ +using System; +using System.Collections.Generic; +using System.Text; + +namespace JT1078.Protocol +{ + /// + /// V - 2 - 固定为2 + /// P - 1 - 固定为0 + /// X - 1 - RTP头是否需要扩展位,固定为0 + /// CC - 4 - 固定为1 + /// + public class JT1078Label1 + { + public JT1078Label1(byte value) + { + V = (byte)(value >> 6); + P = (byte)(value >> 5 & 0x01); + X = (byte)(value >> 4 & 0x01); + CC = (byte)(value & 0xF); + } + /// + /// + /// + /// 0-3 + /// 0-1 + /// 0-1 + /// 0-15 + public JT1078Label1(byte v, byte p, byte x, byte cc) + { + V = v; + P = p; + X = x; + CC = cc; + } + public byte V { get; set; } + public byte P { get; set; } + public byte X { get; set; } + public byte CC { get; set; } + public byte ToByte() + { + return (byte)((V << 6) | (byte)(P << 5) | (byte)(X << 4) | CC); + } + public string BinaryCode { get { return ToString(); } } + public override string ToString() + { + return Convert.ToString(ToByte(), 2).PadLeft(8, '0'); + } + } +} diff --git a/src/JT1078.Protocol/JT1078Label2.cs b/src/JT1078.Protocol/JT1078Label2.cs new file mode 100644 index 0000000..bb6ad0b --- /dev/null +++ b/src/JT1078.Protocol/JT1078Label2.cs @@ -0,0 +1,50 @@ +using System; +using System.Text; + +namespace JT1078.Protocol +{ + /// + /// M - 1 - 标志位,确定是否是完整数据帧的边界 + /// PT - 7 - 负载类型 + /// + public class JT1078Label2 + { + public JT1078Label2(byte value) + { + M = (byte)(value >> 7); + PT = (byte)(value & 0x7f); + } + + /// + /// + /// + /// 0-1 + /// 0-127 + public JT1078Label2(byte m,byte pt) + { + M = m; + PT = pt; + } + + /// + /// M - 1 - 标志位,确定是否是完整数据帧的边界 + /// + public byte M { get; set; } + /// + /// PT - 7 - 负载类型 + /// 用于说明RTP报文中有效载荷的类型,如GSM音频、JPEM图像等 + /// + public byte PT { get; set; } + + public byte ToByte() + { + return (byte)((M << 7) | PT); + } + + public string BinaryCode { get { return ToString(); } } + public override string ToString() + { + return Convert.ToString(ToByte(), 2).PadLeft(8, '0'); + } + } +} diff --git a/src/JT1078.Protocol/JT1078Label3.cs b/src/JT1078.Protocol/JT1078Label3.cs new file mode 100644 index 0000000..79b5b21 --- /dev/null +++ b/src/JT1078.Protocol/JT1078Label3.cs @@ -0,0 +1,42 @@ +using JT1078.Protocol.Enums; +using System; +using System.Collections.Generic; +using System.Text; + +namespace JT1078.Protocol +{ + /// + /// 数据类型 + /// 分包处理标记 + /// + public class JT1078Label3 + { + public JT1078Label3(byte value) + { + DataType = (JT1078DataType)(value >> 4); + SubpackageType = (JT1078SubPackageType)(value & 0x0f); + } + public JT1078Label3(JT1078DataType dataType, JT1078SubPackageType subpackageType) + { + DataType = dataType; + SubpackageType = subpackageType; + } + /// + /// 数据类型 + /// + public JT1078DataType DataType { get; set; } + /// + /// 分包处理标记 + /// + public JT1078SubPackageType SubpackageType { get; set; } + public string BinaryCode { get { return ToString(); } } + public byte ToByte() + { + return (byte)(((byte)DataType << 4) | (byte)SubpackageType); + } + public override string ToString() + { + return Convert.ToString(ToByte(), 2).PadLeft(8, '0'); + } + } +} diff --git a/src/JT1078.Protocol/JT1078Package.cs b/src/JT1078.Protocol/JT1078Package.cs new file mode 100644 index 0000000..b2be396 --- /dev/null +++ b/src/JT1078.Protocol/JT1078Package.cs @@ -0,0 +1,90 @@ +using System; +using System.Collections.Generic; +using System.Text; + +namespace JT1078.Protocol +{ + public class JT1078Package + { + /// + /// 帧头标识 + /// + public static byte[] FH_Bytes = new byte[] { 0x30, 0x31, 0x63, 0x64 }; + /// + /// 帧头标识 + /// + public const uint FH = 0x30316364; + + public static JT1078Label1 DefaultLabel1 = new JT1078Label1(10, 0, 0, 1); + + /// + /// 帧头标识 + /// 固定为0x30 0x31 0x63 0x64 + /// + public uint FH_Flag { get; set; } = FH; + /// + /// V - 2 - 固定为2 + /// P - 1 - 固定为0 + /// X - 1 - RTP头是否需要扩展位,固定为0 + /// CC - 4 - 固定为1 + /// 01000001 + /// + public JT1078Label1 Label1 { get; set; } = DefaultLabel1; + /// + /// M - 1 - 标志位,确定是否是完整数据帧的边界 + /// PT - 7 - 负载类型 + /// + public JT1078Label2 Label2 { get; set; } + /// + /// 初始化为0,每发送一个RTP数据包,序列号加1 + /// + public ushort SN { get; set; } + /// + /// 终端设备SIM卡号 + /// BCD[6] + /// + public string SIM { get; set; } + /// + /// 逻辑通道号 + /// + public byte LogicChannelNumber { get; set; } + /// + /// 数据类型 + /// 0000:视频I帧 + /// 0001:视频P帧 + /// 0010:视频B帧 + /// 0011:音频帧 + /// 0100:透传数据 + /// + /// 0000:原子包,不可被拆分 + /// 0001:分包处理时的第一个包 + /// 0010:分包处理是的最后一个包 + /// 0011:分包处理时间的中间包 + /// + public JT1078Label3 Label3 { get; set; } + /// + /// 时间戳 + /// 标识此RTP数据包当前帧的相对时间,单位毫秒(ms)。 + /// 当数据类型为01000时,则没有该字段 + /// + public ulong Timestamp { get; set; } + /// + /// 该帧与上一个关键帧之间的时间间隔,单位毫秒(ms), + /// 当数据类型为非视频帧时,则没有该字段 + /// + public ushort LastIFrameInterval { get; set; } + /// + /// 该帧与上一个关键帧之间的时间间隔,单位毫秒(ms), + /// 当数据类型为非视频帧时,则没有该字段 + /// + public ushort LastFrameInterval { get; set; } + /// + /// 后续数据体长度,不含此字段 + /// + public ushort DataBodyLength { get; set; } + /// + /// 数据体 + /// + public byte[] Bodies{ get; set; } + } +} diff --git a/src/JT1078.Protocol/JT1078Serializer.cs b/src/JT1078.Protocol/JT1078Serializer.cs new file mode 100644 index 0000000..2593f7c --- /dev/null +++ b/src/JT1078.Protocol/JT1078Serializer.cs @@ -0,0 +1,70 @@ +using JT1078.Protocol.Enums; +using JT1078.Protocol.MessagePack; +using System; +using System.Collections.Generic; +using System.Text; + +namespace JT1078.Protocol +{ + public static class JT1078Serializer + { + public static byte[] Serialize(JT1078Package package, int minBufferSize = 4096) + { + byte[] buffer = JT1078ArrayPool.Rent(minBufferSize); + try + { + JT1078MessagePackWriter jT1078MessagePackReader = new JT1078MessagePackWriter(buffer); + jT1078MessagePackReader.WriteUInt32(package.FH_Flag); + jT1078MessagePackReader.WriteByte(package.Label1.ToByte()); + jT1078MessagePackReader.WriteByte(package.Label2.ToByte()); + jT1078MessagePackReader.WriteUInt16(package.SN); + jT1078MessagePackReader.WriteBCD(package.SIM,12); + jT1078MessagePackReader.WriteByte(package.LogicChannelNumber); + jT1078MessagePackReader.WriteByte(package.Label3.ToByte()); + if (package.Label3.DataType != JT1078DataType.透传数据) + { + jT1078MessagePackReader.WriteUInt64(package.Timestamp); + } + if (package.Label3.DataType != JT1078DataType.透传数据 && + package.Label3.DataType != JT1078DataType.音频帧) + { + jT1078MessagePackReader.WriteUInt16(package.LastIFrameInterval); + jT1078MessagePackReader.WriteUInt16(package.LastFrameInterval); + } + jT1078MessagePackReader.WriteUInt16((ushort)package.Bodies.Length); + jT1078MessagePackReader.WriteArray(package.Bodies); + return jT1078MessagePackReader.FlushAndGetArray(); + } + finally + { + JT1078ArrayPool.Return(buffer); + } + } + + public static JT1078Package Deserialize(ReadOnlySpan bytes) + { + JT1078Package jT1078Package = new JT1078Package(); + JT1078MessagePackReader jT1078MessagePackReader = new JT1078MessagePackReader(bytes); + jT1078Package.FH_Flag = jT1078MessagePackReader.ReadUInt32(); + jT1078Package.Label1 = new JT1078Label1(jT1078MessagePackReader.ReadByte()); + jT1078Package.Label2 = new JT1078Label2(jT1078MessagePackReader.ReadByte()); + jT1078Package.SN = jT1078MessagePackReader.ReadUInt16(); + jT1078Package.SIM = jT1078MessagePackReader.ReadBCD(12); + jT1078Package.LogicChannelNumber = jT1078MessagePackReader.ReadByte(); + jT1078Package.Label3 = new JT1078Label3(jT1078MessagePackReader.ReadByte()); + if (jT1078Package.Label3.DataType != JT1078DataType.透传数据) + { + jT1078Package.Timestamp = jT1078MessagePackReader.ReadUInt64(); + } + if (jT1078Package.Label3.DataType != JT1078DataType.透传数据 && + jT1078Package.Label3.DataType != JT1078DataType.音频帧) + { + jT1078Package.LastIFrameInterval = jT1078MessagePackReader.ReadUInt16(); + jT1078Package.LastFrameInterval = jT1078MessagePackReader.ReadUInt16(); + } + jT1078Package.DataBodyLength = jT1078MessagePackReader.ReadUInt16(); + jT1078Package.Bodies = jT1078MessagePackReader.ReadRemainArray().ToArray(); + return jT1078Package; + } + } +} diff --git a/src/JT1078.Protocol/MessagePack/JT1078MessagePackReader.cs b/src/JT1078.Protocol/MessagePack/JT1078MessagePackReader.cs new file mode 100644 index 0000000..a5f83a6 --- /dev/null +++ b/src/JT1078.Protocol/MessagePack/JT1078MessagePackReader.cs @@ -0,0 +1,88 @@ +using System; +using System.Buffers; +using System.Buffers.Binary; +using System.Collections.Generic; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; +using System.Text; + + +namespace JT1078.Protocol.MessagePack +{ + ref struct JT1078MessagePackReader + { + public ReadOnlySpan Reader { get; private set; } + public ReadOnlySpan SrcBuffer { get; } + public int ReaderCount { get; private set; } + public JT1078MessagePackReader(ReadOnlySpan srcBuffer) + { + SrcBuffer = srcBuffer; + ReaderCount = 0; + Reader = srcBuffer; + } + public ushort ReadUInt16() + { + var readOnlySpan = GetReadOnlySpan(2); + return BinaryPrimitives.ReadUInt16BigEndian(readOnlySpan.Slice(0, 2)); + } + public uint ReadUInt32() + { + var readOnlySpan = GetReadOnlySpan(4); + return BinaryPrimitives.ReadUInt32BigEndian(readOnlySpan.Slice(0, 4)); + } + public int ReadInt32() + { + var readOnlySpan = GetReadOnlySpan(4); + return BinaryPrimitives.ReadInt32BigEndian(readOnlySpan.Slice(0, 4)); + } + public ulong ReadUInt64() + { + var readOnlySpan = GetReadOnlySpan(8); + return BinaryPrimitives.ReadUInt64BigEndian(readOnlySpan.Slice(0, 8)); + } + public byte ReadByte() + { + var readOnlySpan = GetReadOnlySpan(1); + return readOnlySpan[0]; + } + /// + /// 数字编码 大端模式、高位在前 + /// + /// + public string ReadBigNumber(int len) + { + ulong result = 0; + var readOnlySpan = GetReadOnlySpan(len); + for (int i = 0; i < len; i++) + { + ulong currentData = (ulong)readOnlySpan[i] << (8 * (len - i - 1)); + result += currentData; + } + return result.ToString(); + } + public ReadOnlySpan ReadArray(int start,int end) + { + return Reader.Slice(start,end); + } + public string ReadBCD(int len) + { + int count = len / 2; + var readOnlySpan = GetReadOnlySpan(count); + StringBuilder bcdSb = new StringBuilder(count); + for (int i = 0; i < count; i++) + { + bcdSb.Append(readOnlySpan[i].ToString("X2")); + } + return bcdSb.ToString(); + } + public ReadOnlySpan ReadRemainArray() + { + return Reader.Slice(ReaderCount); + } + private ReadOnlySpan GetReadOnlySpan(int count) + { + ReaderCount += count; + return Reader.Slice(ReaderCount - count); + } + } +} diff --git a/src/JT1078.Protocol/MessagePack/JT1078MessagePackWriter.cs b/src/JT1078.Protocol/MessagePack/JT1078MessagePackWriter.cs new file mode 100644 index 0000000..65182f9 --- /dev/null +++ b/src/JT1078.Protocol/MessagePack/JT1078MessagePackWriter.cs @@ -0,0 +1,109 @@ +using JT1078.Protocol.Buffers; +using System; +using System.Buffers; +using System.Buffers.Binary; + +namespace JT1078.Protocol.MessagePack +{ + ref struct JT1078MessagePackWriter + { + private JT1078BufferWriter writer; + public JT1078MessagePackWriter(Span buffer) + { + this.writer = new JT1078BufferWriter(buffer); + } + public byte[] FlushAndGetArray() + { + return writer.Written.ToArray(); + } + public void WriteByte(byte value) + { + var span = writer.Free; + span[0] = value; + writer.Advance(1); + } + public void WriteUInt16(ushort value) + { + var span = writer.Free; + span[0] = (byte)(value >> 8); + span[1] = (byte)value; + writer.Advance(2); + } + public void WriteInt32(int value) + { + var span = writer.Free; + span[0] = (byte)(value >> 24); + span[1] = (byte)(value >> 16); + span[2] = (byte)(value >> 8); + span[3] = (byte)value; + writer.Advance(4); + } + public void WriteUInt64(ulong value) + { + var span = writer.Free; + span[0] = (byte)(value >> 56); + span[1] = (byte)(value >> 48); + span[2] = (byte)(value >> 40); + span[3] = (byte)(value >> 32); + span[4] = (byte)(value >> 24); + span[5] = (byte)(value >> 16); + span[6] = (byte)(value >> 8); + span[7] = (byte)value; + writer.Advance(8); + } + public void WriteUInt32(uint value) + { + var span = writer.Free; + span[0] = (byte)(value >> 24); + span[1] = (byte)(value >> 16); + span[2] = (byte)(value >> 8); + span[3] = (byte)value; + writer.Advance(4); + } + public void WriteArray(ReadOnlySpan src) + { + src.CopyTo(writer.Free); + writer.Advance(src.Length); + } + public void WriteBCD(string value, int len) + { + string bcdText = value ?? ""; + int startIndex = 0; + int noOfZero = len - bcdText.Length; + if (noOfZero > 0) + { + bcdText = bcdText.Insert(startIndex, new string('0', noOfZero)); + } + int byteIndex = 0; + int count = len / 2; + var bcdSpan = bcdText.AsSpan(); + var spanFree = writer.Free; + while (startIndex < bcdText.Length && byteIndex < count) + { + spanFree[byteIndex++] = Convert.ToByte(bcdSpan.Slice(startIndex, 2).ToString(), 16); + startIndex += 2; + } + writer.Advance(byteIndex); + } + /// + /// 数字编码 大端模式、高位在前 + /// + /// + /// + public void WriteBigNumber(string value, int len) + { + var spanFree = writer.Free; + ulong number = string.IsNullOrEmpty(value) ? 0 : (ulong)double.Parse(value); + for (int i = len - 1; i >= 0; i--) + { + spanFree[i] = (byte)(number & 0xFF); //取低8位 + number = number >> 8; + } + writer.Advance(len); + } + public int GetCurrentPosition() + { + return writer.WrittenCount; + } + } +} diff --git a/src/JT1078.sln b/src/JT1078.sln new file mode 100644 index 0000000..0a37f24 --- /dev/null +++ b/src/JT1078.sln @@ -0,0 +1,83 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio Version 16 +VisualStudioVersion = 16.0.29020.237 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "JT808.Protocol.Extensions.JT1078", "JT808.Protocol.Extensions.JT1078\JT808.Protocol.Extensions.JT1078.csproj", "{F060F379-C8E4-4CA6-A54C-938A9780ACD2}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "JT809.Protocol.Extensions.JT1078", "JT809.Protocol.Extensions.JT1078\JT809.Protocol.Extensions.JT1078.csproj", "{2F987285-EB7A-4934-909E-50E42A2D1140}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "JT1078.Protocol", "JT1078.Protocol\JT1078.Protocol.csproj", "{60CAC24B-7317-48BF-9DBF-7F3ECA3689A4}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "JT808.Protocol.Extensions.JT1078.Test", "JT808.Protocol.Extensions.JT1078.Test\JT808.Protocol.Extensions.JT1078.Test.csproj", "{C6A43FDF-C609-40BB-B598-87F0BF7B944B}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "JT809.Protocol.Extensions.JT1078.Test", "JT809.Protocol.Extensions.JT1078.Test\JT809.Protocol.Extensions.JT1078.Test.csproj", "{E9FF2716-EF30-4180-879B-E8AB979ACFF3}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "JT1078.Protocol.Test", "JT1078.Protocol.Test\JT1078.Protocol.Test.csproj", "{9ADD82F9-E0B2-4263-8573-151F673BB33F}" +EndProject +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Tests", "Tests", "{0655AF84-E578-409F-AB0E-B47E0D2F6814}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "JT1078.Protocol.Benchmark", "JT1078.Protocol.Benchmark\JT1078.Protocol.Benchmark.csproj", "{77402142-54E5-4E64-8F9E-BCAAC2CD0E8D}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "JT1078.Protocol.Tools", "JT1078.Protocol.Tools\JT1078.Protocol.Tools.csproj", "{97C4DE73-E41C-4026-B97B-79ECC8A71C91}" +EndProject +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{E378A80C-5708-4D0C-BA1A-73EEF08957F6}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "JT808.Protocol.Extensions.WebApiTest", "JT808.Protocol.Extensions.WebApiTest\JT808.Protocol.Extensions.WebApiTest.csproj", "{9DB37370-AC73-434B-9CE2-6659321858C8}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {F060F379-C8E4-4CA6-A54C-938A9780ACD2}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {F060F379-C8E4-4CA6-A54C-938A9780ACD2}.Debug|Any CPU.Build.0 = Debug|Any CPU + {F060F379-C8E4-4CA6-A54C-938A9780ACD2}.Release|Any CPU.ActiveCfg = Release|Any CPU + {F060F379-C8E4-4CA6-A54C-938A9780ACD2}.Release|Any CPU.Build.0 = Release|Any CPU + {2F987285-EB7A-4934-909E-50E42A2D1140}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {2F987285-EB7A-4934-909E-50E42A2D1140}.Debug|Any CPU.Build.0 = Debug|Any CPU + {2F987285-EB7A-4934-909E-50E42A2D1140}.Release|Any CPU.ActiveCfg = Release|Any CPU + {2F987285-EB7A-4934-909E-50E42A2D1140}.Release|Any CPU.Build.0 = Release|Any CPU + {60CAC24B-7317-48BF-9DBF-7F3ECA3689A4}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {60CAC24B-7317-48BF-9DBF-7F3ECA3689A4}.Debug|Any CPU.Build.0 = Debug|Any CPU + {60CAC24B-7317-48BF-9DBF-7F3ECA3689A4}.Release|Any CPU.ActiveCfg = Release|Any CPU + {60CAC24B-7317-48BF-9DBF-7F3ECA3689A4}.Release|Any CPU.Build.0 = Release|Any CPU + {C6A43FDF-C609-40BB-B598-87F0BF7B944B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {C6A43FDF-C609-40BB-B598-87F0BF7B944B}.Debug|Any CPU.Build.0 = Debug|Any CPU + {C6A43FDF-C609-40BB-B598-87F0BF7B944B}.Release|Any CPU.ActiveCfg = Release|Any CPU + {C6A43FDF-C609-40BB-B598-87F0BF7B944B}.Release|Any CPU.Build.0 = Release|Any CPU + {E9FF2716-EF30-4180-879B-E8AB979ACFF3}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {E9FF2716-EF30-4180-879B-E8AB979ACFF3}.Debug|Any CPU.Build.0 = Debug|Any CPU + {E9FF2716-EF30-4180-879B-E8AB979ACFF3}.Release|Any CPU.ActiveCfg = Release|Any CPU + {E9FF2716-EF30-4180-879B-E8AB979ACFF3}.Release|Any CPU.Build.0 = Release|Any CPU + {9ADD82F9-E0B2-4263-8573-151F673BB33F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {9ADD82F9-E0B2-4263-8573-151F673BB33F}.Debug|Any CPU.Build.0 = Debug|Any CPU + {9ADD82F9-E0B2-4263-8573-151F673BB33F}.Release|Any CPU.ActiveCfg = Release|Any CPU + {9ADD82F9-E0B2-4263-8573-151F673BB33F}.Release|Any CPU.Build.0 = Release|Any CPU + {77402142-54E5-4E64-8F9E-BCAAC2CD0E8D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {77402142-54E5-4E64-8F9E-BCAAC2CD0E8D}.Debug|Any CPU.Build.0 = Debug|Any CPU + {77402142-54E5-4E64-8F9E-BCAAC2CD0E8D}.Release|Any CPU.ActiveCfg = Release|Any CPU + {77402142-54E5-4E64-8F9E-BCAAC2CD0E8D}.Release|Any CPU.Build.0 = Release|Any CPU + {97C4DE73-E41C-4026-B97B-79ECC8A71C91}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {97C4DE73-E41C-4026-B97B-79ECC8A71C91}.Debug|Any CPU.Build.0 = Debug|Any CPU + {97C4DE73-E41C-4026-B97B-79ECC8A71C91}.Release|Any CPU.ActiveCfg = Release|Any CPU + {97C4DE73-E41C-4026-B97B-79ECC8A71C91}.Release|Any CPU.Build.0 = Release|Any CPU + {9DB37370-AC73-434B-9CE2-6659321858C8}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {9DB37370-AC73-434B-9CE2-6659321858C8}.Debug|Any CPU.Build.0 = Debug|Any CPU + {9DB37370-AC73-434B-9CE2-6659321858C8}.Release|Any CPU.ActiveCfg = Release|Any CPU + {9DB37370-AC73-434B-9CE2-6659321858C8}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection + GlobalSection(NestedProjects) = preSolution + {C6A43FDF-C609-40BB-B598-87F0BF7B944B} = {0655AF84-E578-409F-AB0E-B47E0D2F6814} + {E9FF2716-EF30-4180-879B-E8AB979ACFF3} = {0655AF84-E578-409F-AB0E-B47E0D2F6814} + {9ADD82F9-E0B2-4263-8573-151F673BB33F} = {0655AF84-E578-409F-AB0E-B47E0D2F6814} + {9DB37370-AC73-434B-9CE2-6659321858C8} = {0655AF84-E578-409F-AB0E-B47E0D2F6814} + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + SolutionGuid = {FAE1656D-226F-4B4B-8C33-615D7E632B26} + EndGlobalSection +EndGlobal diff --git a/src/JT808.Protocol.Extensions.JT1078.Test/JT808.Protocol.Extensions.JT1078.Test.csproj b/src/JT808.Protocol.Extensions.JT1078.Test/JT808.Protocol.Extensions.JT1078.Test.csproj new file mode 100644 index 0000000..1f2854a --- /dev/null +++ b/src/JT808.Protocol.Extensions.JT1078.Test/JT808.Protocol.Extensions.JT1078.Test.csproj @@ -0,0 +1,20 @@ + + + + netcoreapp2.2 + + false + + + + + + + + + + + + + + diff --git a/src/JT808.Protocol.Extensions.JT1078.Test/JT808LocationAttach.cs b/src/JT808.Protocol.Extensions.JT1078.Test/JT808LocationAttach.cs new file mode 100644 index 0000000..077b325 --- /dev/null +++ b/src/JT808.Protocol.Extensions.JT1078.Test/JT808LocationAttach.cs @@ -0,0 +1,81 @@ +using JT808.Protocol.Extensions.JT1078.MessageBody; +using JT808.Protocol.Interfaces; +using JT808.Protocol.MessageBody; +using Microsoft.Extensions.DependencyInjection; +using System; +using System.Collections.Generic; +using System.Reflection; +using Xunit; + +namespace JT808.Protocol.Extensions.JT1078.Test +{ + public class JT808LocationAttach + { + JT808Serializer JT808Serializer; + + public JT808LocationAttach() + { + IServiceCollection serviceDescriptors1 = new ServiceCollection(); + serviceDescriptors1.AddJT808Configure(new DefaultGlobalConfig()).AddJT1078Configure(); + var ServiceProvider1 = serviceDescriptors1.BuildServiceProvider(); + var defaultConfig = ServiceProvider1.GetRequiredService(); + JT808Serializer = new JT808Serializer(defaultConfig); + } + [Fact] + public void Test1() + { + JT808_0x0200 jT808UploadLocationRequest = new JT808_0x0200 + { + AlarmFlag = 1, + Altitude = 40, + GPSTime = DateTime.Parse("2018-07-15 10:10:10"), + Lat = 12222222, + Lng = 132444444, + Speed = 60, + Direction = 0, + StatusFlag = 2, + JT808CustomLocationAttachData = new Dictionary() + }; + jT808UploadLocationRequest.JT808CustomLocationAttachData.Add(0x14, new JT808_0x0200_0x14 + { + VideoRelateAlarm = 100 + }); + jT808UploadLocationRequest.JT808CustomLocationAttachData.Add(0x15, new JT808_0x0200_0x15 + { + VideoSignalLoseAlarmStatus = 100 + }); + jT808UploadLocationRequest.JT808CustomLocationAttachData.Add(0x16, new JT808_0x0200_0x16 + { + VideoSignalOcclusionAlarmStatus = 100 + }); + jT808UploadLocationRequest.JT808CustomLocationAttachData.Add(0x17, new JT808_0x0200_0x17 + { + StorageFaultAlarmStatus = 100 + }); + jT808UploadLocationRequest.JT808CustomLocationAttachData.Add(0x18, new JT808_0x0200_0x18 + { + AbnormalDrivingBehaviorAlarmInfo = 100 + }); + var hex = JT808Serializer.Serialize(jT808UploadLocationRequest).ToHexString(); + Assert.Equal("000000010000000200BA7F0E07E4F11C0028003C00001807151010101404000000641504000000641604000000641702006418020064", hex); + } + + [Fact] + public void Test2() + { + byte[] bodys = "000000010000000200BA7F0E07E4F11C0028003C00001807151010101404000000641504000000641604000000641702006418020064".ToHexBytes(); + JT808_0x0200 jT808UploadLocationRequest = JT808Serializer.Deserialize(bodys); + Assert.Equal((uint)1, jT808UploadLocationRequest.AlarmFlag); + Assert.Equal(DateTime.Parse("2018-07-15 10:10:10"), jT808UploadLocationRequest.GPSTime); + Assert.Equal(12222222, jT808UploadLocationRequest.Lat); + Assert.Equal(132444444, jT808UploadLocationRequest.Lng); + Assert.Equal(60, jT808UploadLocationRequest.Speed); + Assert.Equal((uint)2, jT808UploadLocationRequest.StatusFlag); + Assert.Equal((uint)100, JT808Serializer.Deserialize(jT808UploadLocationRequest.JT808CustomLocationAttachOriginalData[0x14]).VideoRelateAlarm); + Assert.Equal((uint)100, JT808Serializer.Deserialize(jT808UploadLocationRequest.JT808CustomLocationAttachOriginalData[0x15]).VideoSignalLoseAlarmStatus); + Assert.Equal((uint)100, JT808Serializer.Deserialize(jT808UploadLocationRequest.JT808CustomLocationAttachOriginalData[0x16]).VideoSignalOcclusionAlarmStatus); + Assert.Equal((uint)100, JT808Serializer.Deserialize(jT808UploadLocationRequest.JT808CustomLocationAttachOriginalData[0x17]).StorageFaultAlarmStatus); + Assert.Equal((uint)100, JT808Serializer.Deserialize(jT808UploadLocationRequest.JT808CustomLocationAttachOriginalData[0x17]).AbnormalDrivingBehaviorAlarmInfo); + } + } +} diff --git a/src/JT808.Protocol.Extensions.JT1078.Test/JT808_0x1003Test.cs b/src/JT808.Protocol.Extensions.JT1078.Test/JT808_0x1003Test.cs new file mode 100644 index 0000000..2b26be1 --- /dev/null +++ b/src/JT808.Protocol.Extensions.JT1078.Test/JT808_0x1003Test.cs @@ -0,0 +1,54 @@ +using JT808.Protocol.Extensions.JT1078.MessageBody; +using JT808.Protocol.Interfaces; +using Microsoft.Extensions.DependencyInjection; +using Microsoft.Extensions.Logging; +using System; +using System.Collections.Generic; +using System.Text; +using Xunit; + +namespace JT808.Protocol.Extensions.JT1078.Test +{ + public class JT808_0x1003Test + { + JT808Serializer JT808Serializer; + public JT808_0x1003Test() + { + IServiceCollection serviceDescriptors1 = new ServiceCollection(); + serviceDescriptors1 + .AddJT808Configure() + .AddJT1078Configure(); + var ServiceProvider1 = serviceDescriptors1.BuildServiceProvider(); + var defaultConfig = ServiceProvider1.GetRequiredService(); + JT808Serializer = defaultConfig.GetSerializer(); + } + + [Fact] + public void Test1() + { + JT808_0x1003 jT808_0x1003 = new JT808_0x1003() + { + AudioFrameLength = 1, + EnterAudioChannelsNumber = 2, + EnterAudioEncoding = 3, + EnterAudioSampleDigits = 4, + EnterAudioSampleRate = 5, + IsSupportedAudioOutput = 1, + VideoEncoding = 6, + TerminalSupportedMaxNumberOfAudioPhysicalChannels = 7, + TerminalSupportedMaxNumberOfVideoPhysicalChannels = 8 + }; + var str = Newtonsoft.Json.JsonConvert.SerializeObject(jT808_0x1003); + var hex = JT808Serializer.Serialize(jT808_0x1003).ToHexString(); + Assert.Equal("03020504000101060708", hex); + } + + [Fact] + public void Test2() + { + var str = "{\"EnterAudioEncoding\":3,\"EnterAudioChannelsNumber\":2,\"EnterAudioSampleRate\":5,\"EnterAudioSampleDigits\":4,\"AudioFrameLength\":1,\"IsSupportedAudioOutput\":1,\"VideoEncoding\":6,\"TerminalSupportedMaxNumberOfAudioPhysicalChannels\":7,\"TerminalSupportedMaxNumberOfVideoPhysicalChannels\":8,\"SkipSerialization\":false}"; + JT808_0x1003 jT808_0x1003 = JT808Serializer.Deserialize("03020504000101060708".ToHexBytes()); + Assert.Equal(Newtonsoft.Json.JsonConvert.SerializeObject(jT808_0x1003), str); + } + } +} diff --git a/src/JT808.Protocol.Extensions.JT1078.Test/JT808_0x1005Test.cs b/src/JT808.Protocol.Extensions.JT1078.Test/JT808_0x1005Test.cs new file mode 100644 index 0000000..323c1b6 --- /dev/null +++ b/src/JT808.Protocol.Extensions.JT1078.Test/JT808_0x1005Test.cs @@ -0,0 +1,60 @@ +using JT808.Protocol.Extensions.JT1078.MessageBody; +using JT808.Protocol.Interfaces; +using Microsoft.Extensions.DependencyInjection; +using Microsoft.Extensions.Logging; +using Newtonsoft.Json; +using System; +using System.Collections.Generic; +using System.Text; +using Xunit; + +namespace JT808.Protocol.Extensions.JT1078.Test +{ + public class JT808_0x1005Test + { + JT808Serializer JT808Serializer; + public JT808_0x1005Test() + { + IServiceCollection serviceDescriptors1 = new ServiceCollection(); + serviceDescriptors1 + .AddJT808Configure() + .AddJT1078Configure(); + var ServiceProvider1 = serviceDescriptors1.BuildServiceProvider(); + var defaultConfig = ServiceProvider1.GetRequiredService(); + JT808Serializer = 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 Test1() + { + JT808_0x1005 jT808_0x1005 = new JT808_0x1005() + { + BeginTime=Convert.ToDateTime("2019-07-16 10:20:01"), + EndTime= Convert.ToDateTime("2019-07-16 10:25:02"), + GettingOffNumber=1, + GettingOnNumber=1 + }; + var str = Newtonsoft.Json.JsonConvert.SerializeObject(jT808_0x1005); + var hex = JT808Serializer.Serialize(jT808_0x1005).ToHexString(); + Assert.Equal("19071610200119071610250200010001", hex); + } + + [Fact] + public void Test2() + { + var str = "{\"BeginTime\":\"2019-07-16 10:20:01\",\"EndTime\":\"2019-07-16 10:25:02\",\"GettingOnNumber\":1,\"GettingOffNumber\":1,\"SkipSerialization\":false}"; + var jT808_0x1005 = JT808Serializer.Deserialize("19071610200119071610250200010001".ToHexBytes()); + Assert.Equal(Newtonsoft.Json.JsonConvert.SerializeObject(jT808_0x1005), str); + } + } +} diff --git a/src/JT808.Protocol.Extensions.JT1078.Test/JT808_0x1205Test.cs b/src/JT808.Protocol.Extensions.JT1078.Test/JT808_0x1205Test.cs new file mode 100644 index 0000000..f25d4cb --- /dev/null +++ b/src/JT808.Protocol.Extensions.JT1078.Test/JT808_0x1205Test.cs @@ -0,0 +1,80 @@ +using JT808.Protocol.Extensions.JT1078.MessageBody; +using JT808.Protocol.Interfaces; +using Microsoft.Extensions.DependencyInjection; +using Microsoft.Extensions.Logging; +using Newtonsoft.Json; +using System; +using System.Collections.Generic; +using System.Text; +using Xunit; + +namespace JT808.Protocol.Extensions.JT1078.Test +{ + public class JT808_0x1205Test + { + JT808Serializer JT808Serializer; + public JT808_0x1205Test() + { + IServiceCollection serviceDescriptors1 = new ServiceCollection(); + serviceDescriptors1 + .AddJT808Configure() + .AddJT1078Configure(); + var ServiceProvider1 = serviceDescriptors1.BuildServiceProvider(); + var defaultConfig = ServiceProvider1.GetRequiredService(); + JT808Serializer = 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 Test1() + { + JT808_0x1205 jT808_0x1205 = new JT808_0x1205() + { + MsgNum = 1, + AVResouceTotal = 2, + AVResouces = new List { + new JT808_0x1205_AVResouce{ + AlarmFlag=1, + AVResourceType=2, + BeginTime=Convert.ToDateTime("2019-07-16 10:20:01"), + EndTime=Convert.ToDateTime("2019-07-16 10:25:01"), + FileSize=3, + LogicChannelNo=4, + MemoryType=5, + StreamType=6 + }, + new JT808_0x1205_AVResouce{ + AlarmFlag=11, + AVResourceType=21, + BeginTime=Convert.ToDateTime("2019-07-16 11:20:01"), + EndTime=Convert.ToDateTime("2019-07-16 11:25:02"), + FileSize=31, + LogicChannelNo=41, + MemoryType=51, + StreamType=61 + } + } + }; + var str = Newtonsoft.Json.JsonConvert.SerializeObject(jT808_0x1205); + var hex = JT808Serializer.Serialize(jT808_0x1205).ToHexString(); + Assert.Equal("000100000002041907161020011907161025010000000102060500000003291907161120011907161125020000000B153D330000001F", hex); + } + + [Fact] + public void Test2() + { + var str = "{\"MsgNum\":1,\"AVResouceTotal\":2,\"AVResouces\":[{\"LogicChannelNo\":4,\"BeginTime\":\"2019-07-16 10:20:01\",\"EndTime\":\"2019-07-16 10:25:01\",\"AlarmFlag\":1,\"AVResourceType\":2,\"StreamType\":6,\"MemoryType\":5,\"FileSize\":3},{\"LogicChannelNo\":41,\"BeginTime\":\"2019-07-16 11:20:01\",\"EndTime\":\"2019-07-16 11:25:02\",\"AlarmFlag\":11,\"AVResourceType\":21,\"StreamType\":61,\"MemoryType\":51,\"FileSize\":31}],\"SkipSerialization\":false}"; + var jT808_0x1205 = JT808Serializer.Deserialize("000100000002041907161020011907161025010000000102060500000003291907161120011907161125020000000B153D330000001F".ToHexBytes()); + Assert.Equal(Newtonsoft.Json.JsonConvert.SerializeObject(jT808_0x1205), str); + } + } +} diff --git a/src/JT808.Protocol.Extensions.JT1078.Test/JT808_0x1206Test.cs b/src/JT808.Protocol.Extensions.JT1078.Test/JT808_0x1206Test.cs new file mode 100644 index 0000000..bb39971 --- /dev/null +++ b/src/JT808.Protocol.Extensions.JT1078.Test/JT808_0x1206Test.cs @@ -0,0 +1,58 @@ +using JT808.Protocol.Extensions.JT1078.MessageBody; +using JT808.Protocol.Interfaces; +using Microsoft.Extensions.DependencyInjection; +using Microsoft.Extensions.Logging; +using Newtonsoft.Json; +using System; +using System.Collections.Generic; +using System.Text; +using Xunit; + +namespace JT808.Protocol.Extensions.JT1078.Test +{ + public class JT808_0x1206Test + { + JT808Serializer JT808Serializer; + public JT808_0x1206Test() + { + IServiceCollection serviceDescriptors1 = new ServiceCollection(); + serviceDescriptors1 + .AddJT808Configure() + .AddJT1078Configure(); + var ServiceProvider1 = serviceDescriptors1.BuildServiceProvider(); + var defaultConfig = ServiceProvider1.GetRequiredService(); + JT808Serializer = 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 Test1() + { + JT808_0x1206 jT808_0x1206 = new JT808_0x1206() + { + MsgNum=1, + Result=1 + }; + var str = Newtonsoft.Json.JsonConvert.SerializeObject(jT808_0x1206); + var hex = JT808Serializer.Serialize(jT808_0x1206).ToHexString(); + Assert.Equal("000101", hex); + } + + [Fact] + public void Test2() + { + var str = "{\"MsgNum\":1,\"Result\":1,\"SkipSerialization\":false}"; + var jT808_0x1206 = JT808Serializer.Deserialize("000101".ToHexBytes()); + Assert.Equal(Newtonsoft.Json.JsonConvert.SerializeObject(jT808_0x1206), str); + } + } +} diff --git a/src/JT808.Protocol.Extensions.JT1078.Test/JT808_0x8103CustomId.cs b/src/JT808.Protocol.Extensions.JT1078.Test/JT808_0x8103CustomId.cs new file mode 100644 index 0000000..2dcc3e9 --- /dev/null +++ b/src/JT808.Protocol.Extensions.JT1078.Test/JT808_0x8103CustomId.cs @@ -0,0 +1,223 @@ +using JT808.Protocol.Extensions.JT1078.MessageBody; +using JT808.Protocol.Interfaces; +using JT808.Protocol.MessageBody; +using Microsoft.Extensions.DependencyInjection; +using System; +using System.Collections.Generic; +using System.Reflection; +using System.Text; +using Xunit; + +namespace JT808.Protocol.Extensions.JT1078.Test +{ + public class JT808_0x8103CustomId + { + JT808Serializer JT808Serializer; + + public JT808_0x8103CustomId() + { + IServiceCollection serviceDescriptors1 = new ServiceCollection(); + serviceDescriptors1.AddJT808Configure(new DefaultGlobalConfig()).AddJT1078Configure(); + var ServiceProvider1 = serviceDescriptors1.BuildServiceProvider(); + var defaultConfig = ServiceProvider1.GetRequiredService(); + JT808Serializer = new JT808Serializer(defaultConfig); + } + [Fact] + public void Test1() + { + JT808Package jT808Package = new JT808Package + { + Header = new JT808Header + { + MsgId = Enums.JT808MsgId.设置终端参数.ToUInt16Value(), + MsgNum = 10, + TerminalPhoneNo = "123456789", + }, + Bodies = new JT808_0x8103 + { + ParamList = new List(), + CustomParamList = new List { + new JT808_0x8103_0x0075() { + AudioOutputEnabled=1, + OSD=2, + RTS_EncodeMode=3, + RTS_KF_Interval=4, + RTS_Resolution=5, + RTS_Target_CodeRate=6, + RTS_Target_FPS=7, + StreamStore_EncodeMode=8, + StreamStore_KF_Interval=9, + StreamStore_Resolution=10, + StreamStore_Target_CodeRate=11, + StreamStore_Target_FPS=12 + }, + new JT808_0x8103_0x0076() { + AudioChannelTotal=1, + AVChannelTotal=2, + VudioChannelTotal=3, + ParamLength=27, + AVChannelRefTables=new List{ + new JT808_0x8103_0x0076_AVChannelRefTable{ ChannelType=0, IsConnectCloudPlat=1, LogicChannelNo=2, PhysicalChannelNo=3 }, + + new JT808_0x8103_0x0076_AVChannelRefTable{ChannelType=4, IsConnectCloudPlat=5, LogicChannelNo=6, PhysicalChannelNo=7 }, + new JT808_0x8103_0x0076_AVChannelRefTable{ChannelType=8, IsConnectCloudPlat=9, LogicChannelNo=10, PhysicalChannelNo=11 }, + + new JT808_0x8103_0x0076_AVChannelRefTable{ChannelType=12, IsConnectCloudPlat=13, LogicChannelNo=14, PhysicalChannelNo=15 }, + new JT808_0x8103_0x0076_AVChannelRefTable{ ChannelType=16, IsConnectCloudPlat=17, LogicChannelNo=18, PhysicalChannelNo=19 }, + new JT808_0x8103_0x0076_AVChannelRefTable{ ChannelType=20, IsConnectCloudPlat=21, LogicChannelNo=22, PhysicalChannelNo=23 } + } + }, + new JT808_0x8103_0x0077{ + NeedSetChannelTotal=2, + ParamLength=43, + jT808_0X8103_0X0077_SignalChannels=new List{ + new JT808_0x8103_0x0077_SignalChannel{ + LogicChannelNo =1, OSD=2, RTS_EncodeMode=3, RTS_KF_Interval=4, RTS_Resolution=5, + RTS_Target_CodeRate =6, RTS_Target_FPS=7, StreamStore_EncodeMode=8, StreamStore_KF_Interval=9, StreamStore_Resolution=10, + StreamStore_Target_CodeRate=11, StreamStore_Target_FPS=12}, + new JT808_0x8103_0x0077_SignalChannel{ + LogicChannelNo=1, OSD=2, RTS_EncodeMode=3, RTS_KF_Interval=4, RTS_Resolution=5, + RTS_Target_CodeRate =6, RTS_Target_FPS=7, StreamStore_EncodeMode=8, StreamStore_KF_Interval=9, StreamStore_Resolution=10, + StreamStore_Target_CodeRate=11, StreamStore_Target_FPS=12} + } + }, + new JT808_0x8103_0x0079{ + BeginMinute=1, Duration=2, StorageThresholds=3 + }, + new JT808_0x8103_0x007A{ + AlarmShielding=1 + }, + new JT808_0x8103_0x007B{ + NuclearLoadNumber=1, FatigueThreshold=2 + }, + new JT808_0x8103_0x007C{ + SleepWakeMode=1, TimerWakeDaySet=2, WakeConditionType=3, + jT808_0X8103_0X007C_TimerWakeDayParamter=new JT808_0x8103_0x007C_TimerWakeDayParamter{ + TimePeriod1CloseTime="12", + TimePeriod1WakeTime="23", + TimePeriod2CloseTime="34", + TimePeriod2WakeTime="45", + TimePeriod3CloseTime="56", + TimePeriod3WakeTime="67", + TimePeriod4CloseTime="78", + TimePeriod4WakeTime="89", + TimerWakeEnableFlag=10 + } + } + } + } + }; + var str = Newtonsoft.Json.JsonConvert.SerializeObject(jT808Package.Bodies); + var hex = JT808Serializer.Serialize(jT808Package).ToHexString(); + Assert.Equal("7E8103009C000123456789000A070000007515030500040700000006080A00090C0000000B000201000000761B02010303020001070604050B0A08090F0E0C0D1312101117161415000000772B0201030500040700000006080A00090C0000000B000201030500040700000006080A00090C0000000B000200000079030302010000007A04000000010000007B0201020000007C140103020A00230012004500340067005600890078587E", hex); + } + + [Fact] + public void Test2() + { + var str = "{\"ParamList\":[],\"CustomParamList\":[{\"ParamId\":117,\"ParamLength\":21,\"RTS_EncodeMode\":3,\"RTS_Resolution\":5,\"RTS_KF_Interval\":4,\"RTS_Target_FPS\":7,\"RTS_Target_CodeRate\":6,\"StreamStore_EncodeMode\":8,\"StreamStore_Resolution\":10,\"StreamStore_KF_Interval\":9,\"StreamStore_Target_FPS\":12,\"StreamStore_Target_CodeRate\":11,\"OSD\":2,\"AudioOutputEnabled\":1},{\"ParamId\":118,\"ParamLength\":27,\"AVChannelTotal\":2,\"AudioChannelTotal\":1,\"VudioChannelTotal\":3,\"AVChannelRefTables\":[{\"PhysicalChannelNo\":3,\"LogicChannelNo\":2,\"ChannelType\":0,\"IsConnectCloudPlat\":1},{\"PhysicalChannelNo\":7,\"LogicChannelNo\":6,\"ChannelType\":4,\"IsConnectCloudPlat\":5},{\"PhysicalChannelNo\":11,\"LogicChannelNo\":10,\"ChannelType\":8,\"IsConnectCloudPlat\":9},{\"PhysicalChannelNo\":15,\"LogicChannelNo\":14,\"ChannelType\":12,\"IsConnectCloudPlat\":13},{\"PhysicalChannelNo\":19,\"LogicChannelNo\":18,\"ChannelType\":16,\"IsConnectCloudPlat\":17},{\"PhysicalChannelNo\":23,\"LogicChannelNo\":22,\"ChannelType\":20,\"IsConnectCloudPlat\":21}]},{\"ParamId\":119,\"ParamLength\":43,\"NeedSetChannelTotal\":2,\"jT808_0X8103_0X0077_SignalChannels\":[{\"LogicChannelNo\":1,\"RTS_EncodeMode\":3,\"RTS_Resolution\":5,\"RTS_KF_Interval\":4,\"RTS_Target_FPS\":7,\"RTS_Target_CodeRate\":6,\"StreamStore_EncodeMode\":8,\"StreamStore_Resolution\":10,\"StreamStore_KF_Interval\":9,\"StreamStore_Target_FPS\":12,\"StreamStore_Target_CodeRate\":11,\"OSD\":2},{\"LogicChannelNo\":1,\"RTS_EncodeMode\":3,\"RTS_Resolution\":5,\"RTS_KF_Interval\":4,\"RTS_Target_FPS\":7,\"RTS_Target_CodeRate\":6,\"StreamStore_EncodeMode\":8,\"StreamStore_Resolution\":10,\"StreamStore_KF_Interval\":9,\"StreamStore_Target_FPS\":12,\"StreamStore_Target_CodeRate\":11,\"OSD\":2}]},{\"ParamId\":121,\"ParamLength\":3,\"StorageThresholds\":3,\"Duration\":2,\"BeginMinute\":1},{\"ParamId\":122,\"ParamLength\":4,\"AlarmShielding\":1},{\"ParamId\":123,\"ParamLength\":2,\"NuclearLoadNumber\":1,\"FatigueThreshold\":2},{\"ParamId\":124,\"ParamLength\":20,\"SleepWakeMode\":1,\"WakeConditionType\":3,\"TimerWakeDaySet\":2,\"jT808_0X8103_0X007C_TimerWakeDayParamter\":{\"TimerWakeEnableFlag\":10,\"TimePeriod1WakeTime\":\"23\",\"TimePeriod1CloseTime\":\"12\",\"TimePeriod2WakeTime\":\"45\",\"TimePeriod2CloseTime\":\"34\",\"TimePeriod3WakeTime\":\"67\",\"TimePeriod3CloseTime\":\"56\",\"TimePeriod4WakeTime\":\"89\",\"TimePeriod4CloseTime\":\"78\"}}],\"SkipSerialization\":false}"; + byte[] bytes = "7E8103009C000123456789000A070000007515030500040700000006080A00090C0000000B000201000000761B02010303020001070604050B0A08090F0E0C0D1312101117161415000000772B0201030500040700000006080A00090C0000000B000201030500040700000006080A00090C0000000B000200000079030302010000007A04000000010000007B0201020000007C140103020A00230012004500340067005600890078587E".ToHexBytes(); + JT808Package jT808_0X8103 = JT808Serializer.Deserialize(bytes); + Assert.Equal(Enums.JT808MsgId.设置终端参数.ToUInt16Value(), jT808_0X8103.Header.MsgId); + Assert.Equal(10, jT808_0X8103.Header.MsgNum); + Assert.Equal("123456789", jT808_0X8103.Header.TerminalPhoneNo); + + JT808_0x8103 JT808Bodies = (JT808_0x8103)jT808_0X8103.Bodies; + Assert.Equal(Newtonsoft.Json.JsonConvert.SerializeObject(jT808_0X8103.Bodies), str); + } + + [Fact] + public void Test3() + { + JT808_0x8103 jT808_0x8103 = new JT808_0x8103 + { + ParamList = new List(), + CustomParamList = new List { + new JT808_0x8103_0x0075() { + AudioOutputEnabled=1, + OSD=2, + RTS_EncodeMode=3, + RTS_KF_Interval=4, + RTS_Resolution=5, + RTS_Target_CodeRate=6, + RTS_Target_FPS=7, + StreamStore_EncodeMode=8, + StreamStore_KF_Interval=9, + StreamStore_Resolution=10, + StreamStore_Target_CodeRate=11, + StreamStore_Target_FPS=12 + }, + new JT808_0x8103_0x0076() { + AudioChannelTotal=1, + AVChannelTotal=2, + VudioChannelTotal=3, + ParamLength=27, + AVChannelRefTables=new List{ + new JT808_0x8103_0x0076_AVChannelRefTable{ ChannelType=0, IsConnectCloudPlat=1, LogicChannelNo=2, PhysicalChannelNo=3 }, + + new JT808_0x8103_0x0076_AVChannelRefTable{ChannelType=4, IsConnectCloudPlat=5, LogicChannelNo=6, PhysicalChannelNo=7 }, + new JT808_0x8103_0x0076_AVChannelRefTable{ChannelType=8, IsConnectCloudPlat=9, LogicChannelNo=10, PhysicalChannelNo=11 }, + + new JT808_0x8103_0x0076_AVChannelRefTable{ChannelType=12, IsConnectCloudPlat=13, LogicChannelNo=14, PhysicalChannelNo=15 }, + new JT808_0x8103_0x0076_AVChannelRefTable{ ChannelType=16, IsConnectCloudPlat=17, LogicChannelNo=18, PhysicalChannelNo=19 }, + new JT808_0x8103_0x0076_AVChannelRefTable{ ChannelType=20, IsConnectCloudPlat=21, LogicChannelNo=22, PhysicalChannelNo=23 } + } + }, + new JT808_0x8103_0x0077{ + NeedSetChannelTotal=2, + ParamLength=43, + jT808_0X8103_0X0077_SignalChannels=new List{ + new JT808_0x8103_0x0077_SignalChannel{ + LogicChannelNo =1, OSD=2, RTS_EncodeMode=3, RTS_KF_Interval=4, RTS_Resolution=5, + RTS_Target_CodeRate =6, RTS_Target_FPS=7, StreamStore_EncodeMode=8, StreamStore_KF_Interval=9, StreamStore_Resolution=10, + StreamStore_Target_CodeRate=11, StreamStore_Target_FPS=12}, + new JT808_0x8103_0x0077_SignalChannel{ + LogicChannelNo=1, OSD=2, RTS_EncodeMode=3, RTS_KF_Interval=4, RTS_Resolution=5, + RTS_Target_CodeRate =6, RTS_Target_FPS=7, StreamStore_EncodeMode=8, StreamStore_KF_Interval=9, StreamStore_Resolution=10, + StreamStore_Target_CodeRate=11, StreamStore_Target_FPS=12} + } + }, + new JT808_0x8103_0x0079{ + BeginMinute=1, Duration=2, StorageThresholds=3 + }, + new JT808_0x8103_0x007A{ + AlarmShielding=1 + }, + new JT808_0x8103_0x007B{ + NuclearLoadNumber=1, FatigueThreshold=2 + }, + new JT808_0x8103_0x007C{ + SleepWakeMode=1, TimerWakeDaySet=2, WakeConditionType=3, + jT808_0X8103_0X007C_TimerWakeDayParamter=new JT808_0x8103_0x007C_TimerWakeDayParamter{ + TimePeriod1CloseTime="12", + TimePeriod1WakeTime="23", + TimePeriod2CloseTime="34", + TimePeriod2WakeTime="45", + TimePeriod3CloseTime="56", + TimePeriod3WakeTime="67", + TimePeriod4CloseTime="78", + TimePeriod4WakeTime="89", + TimerWakeEnableFlag=10 + } + } + } + }; + var str = Newtonsoft.Json.JsonConvert.SerializeObject(jT808_0x8103); + var hex = JT808Serializer.Serialize(jT808_0x8103).ToHexString(); + Assert.Equal("070000007515030500040700000006080A00090C0000000B000201000000761B02010303020001070604050B0A08090F0E0C0D1312101117161415000000772B0201030500040700000006080A00090C0000000B000201030500040700000006080A00090C0000000B000200000079030302010000007A04000000010000007B0201020000007C140103020A00230012004500340067005600890078", hex); + } + + [Fact] + public void Test4() + { + byte[] bytes = "070000007515030500040700000006080A00090C0000000B000201000000761B02010303020001070604050B0A08090F0E0C0D1312101117161415000000772B0201030500040700000006080A00090C0000000B000201030500040700000006080A00090C0000000B000200000079030302010000007A04000000010000007B0201020000007C140103020A00230012004500340067005600890078".ToHexBytes(); + var jT808_0X8103 = JT808Serializer.Deserialize(bytes); + + Assert.Equal("{\"ParamList\":[],\"CustomParamList\":[{\"ParamId\":117,\"ParamLength\":21,\"RTS_EncodeMode\":3,\"RTS_Resolution\":5,\"RTS_KF_Interval\":4,\"RTS_Target_FPS\":7,\"RTS_Target_CodeRate\":6,\"StreamStore_EncodeMode\":8,\"StreamStore_Resolution\":10,\"StreamStore_KF_Interval\":9,\"StreamStore_Target_FPS\":12,\"StreamStore_Target_CodeRate\":11,\"OSD\":2,\"AudioOutputEnabled\":1},{\"ParamId\":118,\"ParamLength\":27,\"AVChannelTotal\":2,\"AudioChannelTotal\":1,\"VudioChannelTotal\":3,\"AVChannelRefTables\":[{\"PhysicalChannelNo\":3,\"LogicChannelNo\":2,\"ChannelType\":0,\"IsConnectCloudPlat\":1},{\"PhysicalChannelNo\":7,\"LogicChannelNo\":6,\"ChannelType\":4,\"IsConnectCloudPlat\":5},{\"PhysicalChannelNo\":11,\"LogicChannelNo\":10,\"ChannelType\":8,\"IsConnectCloudPlat\":9},{\"PhysicalChannelNo\":15,\"LogicChannelNo\":14,\"ChannelType\":12,\"IsConnectCloudPlat\":13},{\"PhysicalChannelNo\":19,\"LogicChannelNo\":18,\"ChannelType\":16,\"IsConnectCloudPlat\":17},{\"PhysicalChannelNo\":23,\"LogicChannelNo\":22,\"ChannelType\":20,\"IsConnectCloudPlat\":21}]},{\"ParamId\":119,\"ParamLength\":43,\"NeedSetChannelTotal\":2,\"jT808_0X8103_0X0077_SignalChannels\":[{\"LogicChannelNo\":1,\"RTS_EncodeMode\":3,\"RTS_Resolution\":5,\"RTS_KF_Interval\":4,\"RTS_Target_FPS\":7,\"RTS_Target_CodeRate\":6,\"StreamStore_EncodeMode\":8,\"StreamStore_Resolution\":10,\"StreamStore_KF_Interval\":9,\"StreamStore_Target_FPS\":12,\"StreamStore_Target_CodeRate\":11,\"OSD\":2},{\"LogicChannelNo\":1,\"RTS_EncodeMode\":3,\"RTS_Resolution\":5,\"RTS_KF_Interval\":4,\"RTS_Target_FPS\":7,\"RTS_Target_CodeRate\":6,\"StreamStore_EncodeMode\":8,\"StreamStore_Resolution\":10,\"StreamStore_KF_Interval\":9,\"StreamStore_Target_FPS\":12,\"StreamStore_Target_CodeRate\":11,\"OSD\":2}]},{\"ParamId\":121,\"ParamLength\":3,\"StorageThresholds\":3,\"Duration\":2,\"BeginMinute\":1},{\"ParamId\":122,\"ParamLength\":4,\"AlarmShielding\":1},{\"ParamId\":123,\"ParamLength\":2,\"NuclearLoadNumber\":1,\"FatigueThreshold\":2},{\"ParamId\":124,\"ParamLength\":20,\"SleepWakeMode\":1,\"WakeConditionType\":3,\"TimerWakeDaySet\":2,\"jT808_0X8103_0X007C_TimerWakeDayParamter\":{\"TimerWakeEnableFlag\":10,\"TimePeriod1WakeTime\":\"23\",\"TimePeriod1CloseTime\":\"12\",\"TimePeriod2WakeTime\":\"45\",\"TimePeriod2CloseTime\":\"34\",\"TimePeriod3WakeTime\":\"67\",\"TimePeriod3CloseTime\":\"56\",\"TimePeriod4WakeTime\":\"89\",\"TimePeriod4CloseTime\":\"78\"}}],\"SkipSerialization\":false}", Newtonsoft.Json.JsonConvert.SerializeObject(jT808_0X8103)); + } + } + class DefaultGlobalConfig : GlobalConfigBase + { + public override string ConfigId => "Default"; + } +} diff --git a/src/JT808.Protocol.Extensions.JT1078.Test/JT808_0x9101Test.cs b/src/JT808.Protocol.Extensions.JT1078.Test/JT808_0x9101Test.cs new file mode 100644 index 0000000..67fad77 --- /dev/null +++ b/src/JT808.Protocol.Extensions.JT1078.Test/JT808_0x9101Test.cs @@ -0,0 +1,75 @@ +using JT808.Protocol.Extensions.JT1078.MessageBody; +using JT808.Protocol.Interfaces; +using Microsoft.Extensions.DependencyInjection; +using Microsoft.Extensions.Logging; +using System; +using System.Collections.Generic; +using System.Text; +using Xunit; + +namespace JT808.Protocol.Extensions.JT1078.Test +{ + public class JT808_0x9101Test + { + JT808Serializer JT808Serializer; + public JT808_0x9101Test() + { + IServiceCollection serviceDescriptors1 = new ServiceCollection(); + serviceDescriptors1 + .AddJT808Configure() + .AddJT1078Configure(); + var ServiceProvider1 = serviceDescriptors1.BuildServiceProvider(); + var defaultConfig = ServiceProvider1.GetRequiredService(); + JT808Serializer = defaultConfig.GetSerializer(); + } + + [Fact] + public void Test1() + { + JT808_0x9101 jT808_0X9101 = new JT808_0x9101(); + jT808_0X9101.ServerIPAddress = "127.0.0.1"; + jT808_0X9101.ServerVideoChannelTcpPort = 1888; + jT808_0X9101.ServerVideoChannelUdpPort = 0; + jT808_0X9101.LogicalChannelNo= 1; + jT808_0X9101.DataType= 1; + jT808_0X9101.StreamType= 1; + var hex = JT808Serializer.Serialize(jT808_0X9101).ToHexString(); + Assert.Equal("093132372E302E302E3107600000010101", hex); + } + + [Fact] + public void Test2() + { + JT808_0x9101 jT808_0X9101= JT808Serializer.Deserialize("093132372E302E302E3107600000010101".ToHexBytes()); + Assert.Equal("127.0.0.1", jT808_0X9101.ServerIPAddress); + Assert.Equal(9, jT808_0X9101.ServerIPAddressLength); + Assert.Equal(1888, jT808_0X9101.ServerVideoChannelTcpPort); + Assert.Equal(0, jT808_0X9101.ServerVideoChannelUdpPort); + Assert.Equal(1, jT808_0X9101.LogicalChannelNo); + Assert.Equal(1, jT808_0X9101.DataType); + Assert.Equal(1, jT808_0X9101.StreamType); + } + + [Fact] + public void Test3() + { + JT808Package jT808Package = new JT808Package(); + JT808Header header = new JT808Header(); + header.MsgId = 0x9101; + header.MsgNum = 1; + header.TerminalPhoneNo = "12345679810"; + jT808Package.Header = header; + JT808_0x9101 jT808_0X9101 = new JT808_0x9101(); + jT808_0X9101.ServerIPAddress = "127.0.0.1"; + jT808_0X9101.ServerVideoChannelTcpPort = 1888; + jT808_0X9101.ServerVideoChannelUdpPort = 0; + jT808_0X9101.LogicalChannelNo = 1; + jT808_0X9101.DataType = 1; + jT808_0X9101.StreamType = 1; + jT808Package.Bodies = jT808_0X9101; + var hex = JT808Serializer.Serialize(jT808Package).ToHexString(); + Assert.Equal("7E910100110123456798100001093132372E302E302E31076000000101014C7E", hex); + //7E910100110123456798100001093132372E302E302E31076000000101014C7E + } + } +} diff --git a/src/JT808.Protocol.Extensions.JT1078.Test/JT808_0x9102Test.cs b/src/JT808.Protocol.Extensions.JT1078.Test/JT808_0x9102Test.cs new file mode 100644 index 0000000..e3f6993 --- /dev/null +++ b/src/JT808.Protocol.Extensions.JT1078.Test/JT808_0x9102Test.cs @@ -0,0 +1,68 @@ +using JT808.Protocol.Extensions.JT1078.MessageBody; +using JT808.Protocol.Interfaces; +using Microsoft.Extensions.DependencyInjection; +using System; +using System.Collections.Generic; +using System.Text; +using Xunit; +using Microsoft.Extensions.Logging; + +namespace JT808.Protocol.Extensions.JT1078.Test +{ + public class JT808_0x9102Test + { + JT808Serializer JT808Serializer; + public JT808_0x9102Test() + { + IServiceCollection serviceDescriptors1 = new ServiceCollection(); + serviceDescriptors1 + .AddJT808Configure() + .AddJT1078Configure(); + var ServiceProvider1 = serviceDescriptors1.BuildServiceProvider(); + var defaultConfig = ServiceProvider1.GetRequiredService(); + JT808Serializer = defaultConfig.GetSerializer(); + } + + [Fact] + public void Test1() + { + JT808_0x9102 jT808_0X9102 = new JT808_0x9102(); + jT808_0X9102.LogicalChannelNo = 1; + jT808_0X9102.ControlCmd = 1; + jT808_0X9102.CloseAVData = 0; + jT808_0X9102.SwitchStreamType = 0; + var hex = JT808Serializer.Serialize(jT808_0X9102).ToHexString(); + Assert.Equal("01010000", hex); + } + + [Fact] + public void Test2() + { + JT808_0x9102 jT808_0X9102 = JT808Serializer.Deserialize("01010000".ToHexBytes()); + Assert.Equal(1, jT808_0X9102.LogicalChannelNo); + Assert.Equal(1, jT808_0X9102.ControlCmd); + Assert.Equal(0, jT808_0X9102.CloseAVData); + Assert.Equal(0, jT808_0X9102.SwitchStreamType); + } + + [Fact] + public void Test3() + { + JT808Package jT808Package = new JT808Package(); + JT808Header header = new JT808Header(); + header.MsgId = 0x9102; + header.MsgNum = 1; + header.TerminalPhoneNo = "12345679810"; + jT808Package.Header = header; + JT808_0x9102 jT808_0X9102 = new JT808_0x9102(); + jT808_0X9102.LogicalChannelNo = 1; + jT808_0X9102.ControlCmd = 1; + jT808_0X9102.CloseAVData = 0; + jT808_0X9102.SwitchStreamType = 0; + jT808Package.Bodies = jT808_0X9102; + var hex = JT808Serializer.Serialize(jT808Package).ToHexString(); + //7E910200040123456798100001010100001E7E + Assert.Equal("7E910200040123456798100001010100001E7E", hex); + } + } +} diff --git a/src/JT808.Protocol.Extensions.JT1078.Test/JT808_0x9105Test.cs b/src/JT808.Protocol.Extensions.JT1078.Test/JT808_0x9105Test.cs new file mode 100644 index 0000000..015cce8 --- /dev/null +++ b/src/JT808.Protocol.Extensions.JT1078.Test/JT808_0x9105Test.cs @@ -0,0 +1,58 @@ +using JT808.Protocol.Extensions.JT1078.MessageBody; +using JT808.Protocol.Interfaces; +using Microsoft.Extensions.DependencyInjection; +using System; +using System.Collections.Generic; +using System.Text; +using Xunit; +using Microsoft.Extensions.Logging; +using Newtonsoft.Json; + +namespace JT808.Protocol.Extensions.JT1078.Test +{ + public class JT808_0x9105Test + { + JT808Serializer JT808Serializer; + public JT808_0x9105Test() + { + IServiceCollection serviceDescriptors1 = new ServiceCollection(); + serviceDescriptors1 + .AddJT808Configure() + .AddJT1078Configure(); + var ServiceProvider1 = serviceDescriptors1.BuildServiceProvider(); + var defaultConfig = ServiceProvider1.GetRequiredService(); + JT808Serializer = 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 Test1() + { + JT808_0x9105 jT808_0x9105 = new JT808_0x9105() + { + LogicChannelNo=1, + DropRate=2 + }; + var str = Newtonsoft.Json.JsonConvert.SerializeObject(jT808_0x9105); + var hex = JT808Serializer.Serialize(jT808_0x9105).ToHexString(); + Assert.Equal("0102", hex); + } + + [Fact] + public void Test2() + { + var str = "{\"LogicChannelNo\":1,\"DropRate\":2,\"SkipSerialization\":false}"; + var jT808_0x9105 = JT808Serializer.Deserialize("0102".ToHexBytes()); + Assert.Equal(Newtonsoft.Json.JsonConvert.SerializeObject(jT808_0x9105), str); + } + } +} \ No newline at end of file diff --git a/src/JT808.Protocol.Extensions.JT1078.Test/JT808_0x9201Test.cs b/src/JT808.Protocol.Extensions.JT1078.Test/JT808_0x9201Test.cs new file mode 100644 index 0000000..5ba4195 --- /dev/null +++ b/src/JT808.Protocol.Extensions.JT1078.Test/JT808_0x9201Test.cs @@ -0,0 +1,69 @@ +using JT808.Protocol.Extensions.JT1078.MessageBody; +using JT808.Protocol.Interfaces; +using Microsoft.Extensions.DependencyInjection; +using System; +using System.Collections.Generic; +using System.Text; +using Xunit; +using Microsoft.Extensions.Logging; +using Newtonsoft.Json; + +namespace JT808.Protocol.Extensions.JT1078.Test +{ + public class JT808_0x9201Test + { + JT808Serializer JT808Serializer; + public JT808_0x9201Test() + { + IServiceCollection serviceDescriptors1 = new ServiceCollection(); + serviceDescriptors1 + .AddJT808Configure() + .AddJT1078Configure(); + var ServiceProvider1 = serviceDescriptors1.BuildServiceProvider(); + var defaultConfig = ServiceProvider1.GetRequiredService(); + JT808Serializer = 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 Test1() + { + JT808_0x9201 jT808_0x9201 = new JT808_0x9201() + { + LogicChannelNo = 1, + AVItemType = 2, + BeginTime = Convert.ToDateTime("2019-07-16 10:10:10"), + EndTime = Convert.ToDateTime("2019-07-16 10:10:10"), + FastForwardOrFastRewindMultiples1=3, + FastForwardOrFastRewindMultiples2=4, + MemType=5, + PlayBackWay=6, + ServerIp="127.0.0.1", + ServerIpLength=9, + StreamType=7, + TcpPort=80, + UdpPort=8080 + }; + var str = Newtonsoft.Json.JsonConvert.SerializeObject(jT808_0x9201); + var hex = JT808Serializer.Serialize(jT808_0x9201).ToHexString(); + Assert.Equal("093132372E302E302E3100501F9001020705060304190716101010190716101010", hex); + } + + [Fact] + public void Test2() + { + var str = "{\"ServerIpLength\":9,\"ServerIp\":\"127.0.0.1\",\"TcpPort\":80,\"UdpPort\":8080,\"LogicChannelNo\":1,\"AVItemType\":2,\"StreamType\":7,\"MemType\":5,\"PlayBackWay\":6,\"FastForwardOrFastRewindMultiples1\":3,\"FastForwardOrFastRewindMultiples2\":4,\"BeginTime\":\"2019-07-16 10:10:10\",\"EndTime\":\"2019-07-16 10:10:10\",\"SkipSerialization\":false}"; + var jT808_0x9201 = JT808Serializer.Deserialize("093132372E302E302E3100501F9001020705060304190716101010190716101010".ToHexBytes()); + Assert.Equal(Newtonsoft.Json.JsonConvert.SerializeObject(jT808_0x9201), str); + } + } +} \ No newline at end of file diff --git a/src/JT808.Protocol.Extensions.JT1078.Test/JT808_0x9202Test.cs b/src/JT808.Protocol.Extensions.JT1078.Test/JT808_0x9202Test.cs new file mode 100644 index 0000000..d4cf0cc --- /dev/null +++ b/src/JT808.Protocol.Extensions.JT1078.Test/JT808_0x9202Test.cs @@ -0,0 +1,60 @@ +using JT808.Protocol.Extensions.JT1078.MessageBody; +using JT808.Protocol.Interfaces; +using Microsoft.Extensions.DependencyInjection; +using System; +using System.Collections.Generic; +using System.Text; +using Xunit; +using Microsoft.Extensions.Logging; +using Newtonsoft.Json; + +namespace JT808.Protocol.Extensions.JT1078.Test +{ + public class JT808_0x9202Test + { + JT808Serializer JT808Serializer; + public JT808_0x9202Test() + { + IServiceCollection serviceDescriptors1 = new ServiceCollection(); + serviceDescriptors1 + .AddJT808Configure() + .AddJT1078Configure(); + var ServiceProvider1 = serviceDescriptors1.BuildServiceProvider(); + var defaultConfig = ServiceProvider1.GetRequiredService(); + JT808Serializer = 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 Test1() + { + JT808_0x9202 jT808_0x9202 = new JT808_0x9202() + { + AVChannelNo=1, + DragPlaybackPosition=Convert.ToDateTime("2019-07-16 10:10:10"), + FastForwardOrFastRewindMultiples=2, + PlayBackControl=3 + }; + var str = Newtonsoft.Json.JsonConvert.SerializeObject(jT808_0x9202); + var hex = JT808Serializer.Serialize(jT808_0x9202).ToHexString(); + Assert.Equal("010302190716101010", hex); + } + + [Fact] + public void Test2() + { + var str = "{\"AVChannelNo\":1,\"PlayBackControl\":3,\"FastForwardOrFastRewindMultiples\":2,\"DragPlaybackPosition\":\"2019-07-16 10:10:10\",\"SkipSerialization\":false}"; + var jT808_0x9202 = JT808Serializer.Deserialize("010302190716101010".ToHexBytes()); + Assert.Equal(Newtonsoft.Json.JsonConvert.SerializeObject(jT808_0x9202), str); + } + } +} \ No newline at end of file diff --git a/src/JT808.Protocol.Extensions.JT1078.Test/JT808_0x9205Test.cs b/src/JT808.Protocol.Extensions.JT1078.Test/JT808_0x9205Test.cs new file mode 100644 index 0000000..4f41352 --- /dev/null +++ b/src/JT808.Protocol.Extensions.JT1078.Test/JT808_0x9205Test.cs @@ -0,0 +1,63 @@ +using JT808.Protocol.Extensions.JT1078.MessageBody; +using JT808.Protocol.Interfaces; +using Microsoft.Extensions.DependencyInjection; +using System; +using System.Collections.Generic; +using System.Text; +using Xunit; +using Microsoft.Extensions.Logging; +using Newtonsoft.Json; + +namespace JT808.Protocol.Extensions.JT1078.Test +{ + public class JT808_0x9205Test + { + JT808Serializer JT808Serializer; + public JT808_0x9205Test() + { + IServiceCollection serviceDescriptors1 = new ServiceCollection(); + serviceDescriptors1 + .AddJT808Configure() + .AddJT1078Configure(); + var ServiceProvider1 = serviceDescriptors1.BuildServiceProvider(); + var defaultConfig = ServiceProvider1.GetRequiredService(); + JT808Serializer = 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 Test1() + { + JT808_0x9205 jT808_0x9205 = new JT808_0x9205() + { + AlarmFlag=1, + AVResourceType=2, + BeginTime= Convert.ToDateTime("2019-07-16 10:10:10"), + EndTime= Convert.ToDateTime("2019-07-16 10:10:11"), + LogicChannelNo=3, + MemoryType=4, + StreamType =5 + }; + var str = Newtonsoft.Json.JsonConvert.SerializeObject(jT808_0x9205); + var hex = JT808Serializer.Serialize(jT808_0x9205).ToHexString(); + Assert.Equal("0319071610101019071610101100000001020504", hex); + } + + [Fact] + public void Test2() + { + var str = "{\"LogicChannelNo\":3,\"BeginTime\":\"2019-07-16 10:10:10\",\"EndTime\":\"2019-07-16 10:10:11\",\"AlarmFlag\":1,\"AVResourceType\":2,\"StreamType\":5,\"MemoryType\":4,\"SkipSerialization\":false}"; + var jT808_0x9205 = JT808Serializer.Deserialize("0319071610101019071610101100000001020504".ToHexBytes()); + Assert.Equal(Newtonsoft.Json.JsonConvert.SerializeObject(jT808_0x9205), str); + } + } +} \ No newline at end of file diff --git a/src/JT808.Protocol.Extensions.JT1078.Test/JT808_0x9206Test.cs b/src/JT808.Protocol.Extensions.JT1078.Test/JT808_0x9206Test.cs new file mode 100644 index 0000000..6f745bf --- /dev/null +++ b/src/JT808.Protocol.Extensions.JT1078.Test/JT808_0x9206Test.cs @@ -0,0 +1,72 @@ +using JT808.Protocol.Extensions.JT1078.MessageBody; +using JT808.Protocol.Interfaces; +using Microsoft.Extensions.DependencyInjection; +using System; +using System.Collections.Generic; +using System.Text; +using Xunit; +using Microsoft.Extensions.Logging; +using Newtonsoft.Json; + +namespace JT808.Protocol.Extensions.JT1078.Test +{ + public class JT808_0x9206Test + { + JT808Serializer JT808Serializer; + public JT808_0x9206Test() + { + IServiceCollection serviceDescriptors1 = new ServiceCollection(); + serviceDescriptors1 + .AddJT808Configure() + .AddJT1078Configure(); + var ServiceProvider1 = serviceDescriptors1.BuildServiceProvider(); + var defaultConfig = ServiceProvider1.GetRequiredService(); + JT808Serializer = 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 Test1() + { + JT808_0x9206 jT808_0x9206 = new JT808_0x9206() + { + AlarmFlag=1, + AVResourceType=2, + BeginTime= Convert.ToDateTime("2019-07-16 10:10:10"), + EndTime= Convert.ToDateTime("2019-07-16 10:10:11"), + LogicChannelNo=3, + StreamType =5, FileUploadPath="D://1112", + FileUploadPathLength=8, + MemoryPositon=4, + Password="123456", + PasswordLength=6, + Port=808, + ServerIp="127.0.0.1", + ServerIpLength=9, + TaskExcuteCondition=7, + UserName="tk", + UserNameLength=2 + }; + var str = Newtonsoft.Json.JsonConvert.SerializeObject(jT808_0x9206); + var hex = JT808Serializer.Serialize(jT808_0x9206).ToHexString(); + Assert.Equal("093132372E302E302E31032802746B0631323334353608443A2F2F31313132031907161010101907161010110000000102050407", hex); + } + + [Fact] + public void Test2() + { + var str = "{\"ServerIpLength\":9,\"ServerIp\":\"127.0.0.1\",\"Port\":808,\"UserNameLength\":2,\"UserName\":\"tk\",\"PasswordLength\":6,\"Password\":\"123456\",\"FileUploadPathLength\":8,\"FileUploadPath\":\"D://1112\",\"LogicChannelNo\":3,\"BeginTime\":\"2019-07-16 10:10:10\",\"EndTime\":\"2019-07-16 10:10:11\",\"AlarmFlag\":1,\"AVResourceType\":2,\"StreamType\":5,\"MemoryPositon\":4,\"TaskExcuteCondition\":7,\"SkipSerialization\":false}"; + var jT808_0x9206 = JT808Serializer.Deserialize("093132372E302E302E31032802746B0631323334353608443A2F2F31313132031907161010101907161010110000000102050407".ToHexBytes()); + Assert.Equal(Newtonsoft.Json.JsonConvert.SerializeObject(jT808_0x9206), str); + } + } +} \ No newline at end of file diff --git a/src/JT808.Protocol.Extensions.JT1078.Test/JT808_0x9207Test.cs b/src/JT808.Protocol.Extensions.JT1078.Test/JT808_0x9207Test.cs new file mode 100644 index 0000000..6c43b7f --- /dev/null +++ b/src/JT808.Protocol.Extensions.JT1078.Test/JT808_0x9207Test.cs @@ -0,0 +1,58 @@ +using JT808.Protocol.Extensions.JT1078.MessageBody; +using JT808.Protocol.Interfaces; +using Microsoft.Extensions.DependencyInjection; +using System; +using System.Collections.Generic; +using System.Text; +using Xunit; +using Microsoft.Extensions.Logging; +using Newtonsoft.Json; + +namespace JT808.Protocol.Extensions.JT1078.Test +{ + public class JT808_0x9207Test + { + JT808Serializer JT808Serializer; + public JT808_0x9207Test() + { + IServiceCollection serviceDescriptors1 = new ServiceCollection(); + serviceDescriptors1 + .AddJT808Configure() + .AddJT1078Configure(); + var ServiceProvider1 = serviceDescriptors1.BuildServiceProvider(); + var defaultConfig = ServiceProvider1.GetRequiredService(); + JT808Serializer = 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 Test1() + { + JT808_0x9207 jT808_0x9207 = new JT808_0x9207() + { + MgsNum=1, + UploadControl=2 + }; + var str = Newtonsoft.Json.JsonConvert.SerializeObject(jT808_0x9207); + var hex = JT808Serializer.Serialize(jT808_0x9207).ToHexString(); + Assert.Equal("000102", hex); + } + + [Fact] + public void Test2() + { + var str = "{\"MgsNum\":1,\"UploadControl\":2,\"SkipSerialization\":false}"; + var jT808_0x9207 = JT808Serializer.Deserialize("000102".ToHexBytes()); + Assert.Equal(Newtonsoft.Json.JsonConvert.SerializeObject(jT808_0x9207), str); + } + } +} \ No newline at end of file diff --git a/src/JT808.Protocol.Extensions.JT1078.Test/JT808_0x9301Test.cs b/src/JT808.Protocol.Extensions.JT1078.Test/JT808_0x9301Test.cs new file mode 100644 index 0000000..14e5175 --- /dev/null +++ b/src/JT808.Protocol.Extensions.JT1078.Test/JT808_0x9301Test.cs @@ -0,0 +1,59 @@ +using JT808.Protocol.Extensions.JT1078.MessageBody; +using JT808.Protocol.Interfaces; +using Microsoft.Extensions.DependencyInjection; +using System; +using System.Collections.Generic; +using System.Text; +using Xunit; +using Microsoft.Extensions.Logging; +using Newtonsoft.Json; + +namespace JT808.Protocol.Extensions.JT1078.Test +{ + public class JT808_0x9301Test + { + JT808Serializer JT808Serializer; + public JT808_0x9301Test() + { + IServiceCollection serviceDescriptors1 = new ServiceCollection(); + serviceDescriptors1 + .AddJT808Configure() + .AddJT1078Configure(); + var ServiceProvider1 = serviceDescriptors1.BuildServiceProvider(); + var defaultConfig = ServiceProvider1.GetRequiredService(); + JT808Serializer = 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 Test1() + { + JT808_0x9301 jT808_0x9301 = new JT808_0x9301() + { + LogicChannelNo=1, + Speed=2, + Direction=3 + }; + var str = Newtonsoft.Json.JsonConvert.SerializeObject(jT808_0x9301); + var hex = JT808Serializer.Serialize(jT808_0x9301).ToHexString(); + Assert.Equal("010302", hex); + } + + [Fact] + public void Test2() + { + var str = "{\"LogicChannelNo\":1,\"Direction\":3,\"Speed\":2,\"SkipSerialization\":false}"; + var jT808_0x9301 = JT808Serializer.Deserialize("010302".ToHexBytes()); + Assert.Equal(Newtonsoft.Json.JsonConvert.SerializeObject(jT808_0x9301), str); + } + } +} \ No newline at end of file diff --git a/src/JT808.Protocol.Extensions.JT1078.Test/JT808_0x9302Test.cs b/src/JT808.Protocol.Extensions.JT1078.Test/JT808_0x9302Test.cs new file mode 100644 index 0000000..a9aa6d5 --- /dev/null +++ b/src/JT808.Protocol.Extensions.JT1078.Test/JT808_0x9302Test.cs @@ -0,0 +1,58 @@ +using JT808.Protocol.Extensions.JT1078.MessageBody; +using JT808.Protocol.Interfaces; +using Microsoft.Extensions.DependencyInjection; +using System; +using System.Collections.Generic; +using System.Text; +using Xunit; +using Microsoft.Extensions.Logging; +using Newtonsoft.Json; + +namespace JT808.Protocol.Extensions.JT1078.Test +{ + public class JT808_0x9302Test + { + JT808Serializer JT808Serializer; + public JT808_0x9302Test() + { + IServiceCollection serviceDescriptors1 = new ServiceCollection(); + serviceDescriptors1 + .AddJT808Configure() + .AddJT1078Configure(); + var ServiceProvider1 = serviceDescriptors1.BuildServiceProvider(); + var defaultConfig = ServiceProvider1.GetRequiredService(); + JT808Serializer = 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 Test1() + { + JT808_0x9302 jT808_0x9302 = new JT808_0x9302() + { + LogicChannelNo=1, + FocusAdjustmentDirection=2 + }; + var str = Newtonsoft.Json.JsonConvert.SerializeObject(jT808_0x9302); + var hex = JT808Serializer.Serialize(jT808_0x9302).ToHexString(); + Assert.Equal("0102", hex); + } + + [Fact] + public void Test2() + { + var str = "{\"LogicChannelNo\":1,\"FocusAdjustmentDirection\":2,\"SkipSerialization\":false}"; + var jT808_0x9302 = JT808Serializer.Deserialize("0102".ToHexBytes()); + Assert.Equal(Newtonsoft.Json.JsonConvert.SerializeObject(jT808_0x9302), str); + } + } +} \ No newline at end of file diff --git a/src/JT808.Protocol.Extensions.JT1078.Test/JT808_0x9303Test.cs b/src/JT808.Protocol.Extensions.JT1078.Test/JT808_0x9303Test.cs new file mode 100644 index 0000000..bd69497 --- /dev/null +++ b/src/JT808.Protocol.Extensions.JT1078.Test/JT808_0x9303Test.cs @@ -0,0 +1,58 @@ +using JT808.Protocol.Extensions.JT1078.MessageBody; +using JT808.Protocol.Interfaces; +using Microsoft.Extensions.DependencyInjection; +using System; +using System.Collections.Generic; +using System.Text; +using Xunit; +using Microsoft.Extensions.Logging; +using Newtonsoft.Json; + +namespace JT808.Protocol.Extensions.JT1078.Test +{ + public class JT808_0x9303Test + { + JT808Serializer JT808Serializer; + public JT808_0x9303Test() + { + IServiceCollection serviceDescriptors1 = new ServiceCollection(); + serviceDescriptors1 + .AddJT808Configure() + .AddJT1078Configure(); + var ServiceProvider1 = serviceDescriptors1.BuildServiceProvider(); + var defaultConfig = ServiceProvider1.GetRequiredService(); + JT808Serializer = 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 Test1() + { + JT808_0x9303 jT808_0x9303 = new JT808_0x9303() + { + LogicChannelNo=1, + IrisAdjustment=2 + }; + var str = Newtonsoft.Json.JsonConvert.SerializeObject(jT808_0x9303); + var hex = JT808Serializer.Serialize(jT808_0x9303).ToHexString(); + Assert.Equal("0102", hex); + } + + [Fact] + public void Test2() + { + var str = "{\"LogicChannelNo\":1,\"IrisAdjustment\":2,\"SkipSerialization\":false}"; + var jT808_0x9303 = JT808Serializer.Deserialize("0102".ToHexBytes()); + Assert.Equal(Newtonsoft.Json.JsonConvert.SerializeObject(jT808_0x9303), str); + } + } +} \ No newline at end of file diff --git a/src/JT808.Protocol.Extensions.JT1078.Test/JT808_0x9304Test.cs b/src/JT808.Protocol.Extensions.JT1078.Test/JT808_0x9304Test.cs new file mode 100644 index 0000000..5210503 --- /dev/null +++ b/src/JT808.Protocol.Extensions.JT1078.Test/JT808_0x9304Test.cs @@ -0,0 +1,58 @@ +using JT808.Protocol.Extensions.JT1078.MessageBody; +using JT808.Protocol.Interfaces; +using Microsoft.Extensions.DependencyInjection; +using System; +using System.Collections.Generic; +using System.Text; +using Xunit; +using Microsoft.Extensions.Logging; +using Newtonsoft.Json; + +namespace JT808.Protocol.Extensions.JT1078.Test +{ + public class JT808_0x9304Test + { + JT808Serializer JT808Serializer; + public JT808_0x9304Test() + { + IServiceCollection serviceDescriptors1 = new ServiceCollection(); + serviceDescriptors1 + .AddJT808Configure() + .AddJT1078Configure(); + var ServiceProvider1 = serviceDescriptors1.BuildServiceProvider(); + var defaultConfig = ServiceProvider1.GetRequiredService(); + JT808Serializer = 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 Test1() + { + JT808_0x9304 jT808_0x9304 = new JT808_0x9304() + { + LogicChannelNo=1, + StartOrStop=2 + }; + var str = Newtonsoft.Json.JsonConvert.SerializeObject(jT808_0x9304); + var hex = JT808Serializer.Serialize(jT808_0x9304).ToHexString(); + Assert.Equal("0102", hex); + } + + [Fact] + public void Test2() + { + var str = "{\"LogicChannelNo\":1,\"StartOrStop\":2,\"SkipSerialization\":false}"; + var jT808_0x9304 = JT808Serializer.Deserialize("0102".ToHexBytes()); + Assert.Equal(Newtonsoft.Json.JsonConvert.SerializeObject(jT808_0x9304), str); + } + } +} \ No newline at end of file diff --git a/src/JT808.Protocol.Extensions.JT1078.Test/JT808_0x9305Test.cs b/src/JT808.Protocol.Extensions.JT1078.Test/JT808_0x9305Test.cs new file mode 100644 index 0000000..ebcd587 --- /dev/null +++ b/src/JT808.Protocol.Extensions.JT1078.Test/JT808_0x9305Test.cs @@ -0,0 +1,58 @@ +using JT808.Protocol.Extensions.JT1078.MessageBody; +using JT808.Protocol.Interfaces; +using Microsoft.Extensions.DependencyInjection; +using System; +using System.Collections.Generic; +using System.Text; +using Xunit; +using Microsoft.Extensions.Logging; +using Newtonsoft.Json; + +namespace JT808.Protocol.Extensions.JT1078.Test +{ + public class JT808_0x9305Test + { + JT808Serializer JT808Serializer; + public JT808_0x9305Test() + { + IServiceCollection serviceDescriptors1 = new ServiceCollection(); + serviceDescriptors1 + .AddJT808Configure() + .AddJT1078Configure(); + var ServiceProvider1 = serviceDescriptors1.BuildServiceProvider(); + var defaultConfig = ServiceProvider1.GetRequiredService(); + JT808Serializer = 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 Test1() + { + JT808_0x9305 jT808_0x9305 = new JT808_0x9305() + { + LogicChannelNo=1, + StartOrStop=2 + }; + var str = Newtonsoft.Json.JsonConvert.SerializeObject(jT808_0x9305); + var hex = JT808Serializer.Serialize(jT808_0x9305).ToHexString(); + Assert.Equal("0102", hex); + } + + [Fact] + public void Test2() + { + var str = "{\"LogicChannelNo\":1,\"StartOrStop\":2,\"SkipSerialization\":false}"; + var jT808_0x9305 = JT808Serializer.Deserialize("0102".ToHexBytes()); + Assert.Equal(Newtonsoft.Json.JsonConvert.SerializeObject(jT808_0x9305), str); + } + } +} \ No newline at end of file diff --git a/src/JT808.Protocol.Extensions.JT1078.Test/JT808_0x9306Test.cs b/src/JT808.Protocol.Extensions.JT1078.Test/JT808_0x9306Test.cs new file mode 100644 index 0000000..7b6ee5c --- /dev/null +++ b/src/JT808.Protocol.Extensions.JT1078.Test/JT808_0x9306Test.cs @@ -0,0 +1,58 @@ +using JT808.Protocol.Extensions.JT1078.MessageBody; +using JT808.Protocol.Interfaces; +using Microsoft.Extensions.DependencyInjection; +using System; +using System.Collections.Generic; +using System.Text; +using Xunit; +using Microsoft.Extensions.Logging; +using Newtonsoft.Json; + +namespace JT808.Protocol.Extensions.JT1078.Test +{ + public class JT808_0x9306Test + { + JT808Serializer JT808Serializer; + public JT808_0x9306Test() + { + IServiceCollection serviceDescriptors1 = new ServiceCollection(); + serviceDescriptors1 + .AddJT808Configure() + .AddJT1078Configure(); + var ServiceProvider1 = serviceDescriptors1.BuildServiceProvider(); + var defaultConfig = ServiceProvider1.GetRequiredService(); + JT808Serializer = 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 Test1() + { + JT808_0x9306 jT808_0x9306 = new JT808_0x9306() + { + LogicChannelNo=1, + ChangeMultipleControl=2 + }; + var str = Newtonsoft.Json.JsonConvert.SerializeObject(jT808_0x9306); + var hex = JT808Serializer.Serialize(jT808_0x9306).ToHexString(); + Assert.Equal("0102", hex); + } + + [Fact] + public void Test2() + { + var str = "{\"LogicChannelNo\":1,\"ChangeMultipleControl\":2,\"SkipSerialization\":false}"; + var jT808_0x9306 = JT808Serializer.Deserialize("0102".ToHexBytes()); + Assert.Equal(Newtonsoft.Json.JsonConvert.SerializeObject(jT808_0x9306), str); + } + } +} \ No newline at end of file diff --git a/src/JT808.Protocol.Extensions.JT1078/DependencyInjectionExtensions.cs b/src/JT808.Protocol.Extensions.JT1078/DependencyInjectionExtensions.cs new file mode 100644 index 0000000..1dc1b87 --- /dev/null +++ b/src/JT808.Protocol.Extensions.JT1078/DependencyInjectionExtensions.cs @@ -0,0 +1,38 @@ +using JT808.Protocol.Extensions.JT1078.MessageBody; +using JT808.Protocol.Interfaces; +using Microsoft.Extensions.DependencyInjection; +using System; +using System.Collections.Generic; +using System.Reflection; +using System.Text; + +namespace JT808.Protocol.Extensions.JT1078 +{ + public static class DependencyInjectionExtensions + { + public static IJT808Builder AddJT1078Configure(this IJT808Builder jT808Builder) + { + jT808Builder.Config.Register(Assembly.GetExecutingAssembly()); + jT808Builder.Config.MsgIdFactory.SetMap(0x1003, ""); + jT808Builder.Config.MsgIdFactory.SetMap(0x1005, ""); + jT808Builder.Config.MsgIdFactory.SetMap(0x1205, ""); + jT808Builder.Config.MsgIdFactory.SetMap(0x1206, ""); + jT808Builder.Config.MsgIdFactory.SetMap(0x9003, ""); + jT808Builder.Config.MsgIdFactory.SetMap(0x9101, ""); + jT808Builder.Config.MsgIdFactory.SetMap(0x9102, ""); + jT808Builder.Config.MsgIdFactory.SetMap(0x9105, ""); + jT808Builder.Config.MsgIdFactory.SetMap(0x9201, ""); + jT808Builder.Config.MsgIdFactory.SetMap(0x9202, ""); + jT808Builder.Config.MsgIdFactory.SetMap(0x9205, ""); + jT808Builder.Config.MsgIdFactory.SetMap(0x9206, ""); + jT808Builder.Config.MsgIdFactory.SetMap(0x9207, ""); + jT808Builder.Config.MsgIdFactory.SetMap(0x9301, ""); + jT808Builder.Config.MsgIdFactory.SetMap(0x9302, ""); + jT808Builder.Config.MsgIdFactory.SetMap(0x9303, ""); + jT808Builder.Config.MsgIdFactory.SetMap(0x9304, ""); + jT808Builder.Config.MsgIdFactory.SetMap(0x9305, ""); + jT808Builder.Config.MsgIdFactory.SetMap(0x9306, ""); + return jT808Builder; + } + } +} diff --git a/src/JT808.Protocol.Extensions.JT1078/Formatters/JT808_0x0200_0x14_Formatter.cs b/src/JT808.Protocol.Extensions.JT1078/Formatters/JT808_0x0200_0x14_Formatter.cs new file mode 100644 index 0000000..bc0a4c4 --- /dev/null +++ b/src/JT808.Protocol.Extensions.JT1078/Formatters/JT808_0x0200_0x14_Formatter.cs @@ -0,0 +1,29 @@ +using JT808.Protocol.Extensions.JT1078.MessageBody; +using JT808.Protocol.Formatters; +using JT808.Protocol.Interfaces; +using JT808.Protocol.MessagePack; +using System; +using System.Collections.Generic; +using System.Text; + +namespace JT808.Protocol.Extensions.JT1078.Formatters +{ + public class JT808_0x0200_0x14_Formatter : IJT808MessagePackFormatter + { + public JT808_0x0200_0x14 Deserialize(ref JT808MessagePackReader reader, IJT808Config config) + { + JT808_0x0200_0x14 jT808_0x0200_0x14 = new JT808_0x0200_0x14(); + jT808_0x0200_0x14.AttachInfoId = reader.ReadByte(); + jT808_0x0200_0x14.AttachInfoLength = reader.ReadByte(); + jT808_0x0200_0x14.VideoRelateAlarm = reader.ReadUInt32(); + return jT808_0x0200_0x14; + } + + public void Serialize(ref JT808MessagePackWriter writer, JT808_0x0200_0x14 value, IJT808Config config) + { + writer.WriteByte(value.AttachInfoId); + writer.WriteByte(value.AttachInfoLength); + writer.WriteUInt32(value.VideoRelateAlarm); + } + } +} diff --git a/src/JT808.Protocol.Extensions.JT1078/Formatters/JT808_0x0200_0x15_Formatter.cs b/src/JT808.Protocol.Extensions.JT1078/Formatters/JT808_0x0200_0x15_Formatter.cs new file mode 100644 index 0000000..33bad9b --- /dev/null +++ b/src/JT808.Protocol.Extensions.JT1078/Formatters/JT808_0x0200_0x15_Formatter.cs @@ -0,0 +1,29 @@ +using JT808.Protocol.Extensions.JT1078.MessageBody; +using JT808.Protocol.Formatters; +using JT808.Protocol.Interfaces; +using JT808.Protocol.MessagePack; +using System; +using System.Collections.Generic; +using System.Text; + +namespace JT808.Protocol.Extensions.JT1078.Formatters +{ + public class JT808_0x0200_0x15_Formatter : IJT808MessagePackFormatter + { + public JT808_0x0200_0x15 Deserialize(ref JT808MessagePackReader reader, IJT808Config config) + { + JT808_0x0200_0x15 jT808_0x0200_0x15 = new JT808_0x0200_0x15(); + jT808_0x0200_0x15.AttachInfoId = reader.ReadByte(); + jT808_0x0200_0x15.AttachInfoLength = reader.ReadByte(); + jT808_0x0200_0x15.VideoSignalLoseAlarmStatus = reader.ReadUInt32(); + return jT808_0x0200_0x15; + } + + public void Serialize(ref JT808MessagePackWriter writer, JT808_0x0200_0x15 value, IJT808Config config) + { + writer.WriteByte(value.AttachInfoId); + writer.WriteByte(value.AttachInfoLength); + writer.WriteUInt32(value.VideoSignalLoseAlarmStatus); + } + } +} diff --git a/src/JT808.Protocol.Extensions.JT1078/Formatters/JT808_0x0200_0x16_Formatter.cs b/src/JT808.Protocol.Extensions.JT1078/Formatters/JT808_0x0200_0x16_Formatter.cs new file mode 100644 index 0000000..d1c2318 --- /dev/null +++ b/src/JT808.Protocol.Extensions.JT1078/Formatters/JT808_0x0200_0x16_Formatter.cs @@ -0,0 +1,29 @@ +using JT808.Protocol.Extensions.JT1078.MessageBody; +using JT808.Protocol.Formatters; +using JT808.Protocol.Interfaces; +using JT808.Protocol.MessagePack; +using System; +using System.Collections.Generic; +using System.Text; + +namespace JT808.Protocol.Extensions.JT1078.Formatters +{ + public class JT808_0x0200_0x16_Formatter : IJT808MessagePackFormatter + { + public JT808_0x0200_0x16 Deserialize(ref JT808MessagePackReader reader, IJT808Config config) + { + JT808_0x0200_0x16 jT808_0x0200_0x16 = new JT808_0x0200_0x16(); + jT808_0x0200_0x16.AttachInfoId = reader.ReadByte(); + jT808_0x0200_0x16.AttachInfoLength = reader.ReadByte(); + jT808_0x0200_0x16.VideoSignalOcclusionAlarmStatus = reader.ReadUInt32(); + return jT808_0x0200_0x16; + } + + public void Serialize(ref JT808MessagePackWriter writer, JT808_0x0200_0x16 value, IJT808Config config) + { + writer.WriteByte(value.AttachInfoId); + writer.WriteByte(value.AttachInfoLength); + writer.WriteUInt32(value.VideoSignalOcclusionAlarmStatus); + } + } +} diff --git a/src/JT808.Protocol.Extensions.JT1078/Formatters/JT808_0x0200_0x17_Formatter.cs b/src/JT808.Protocol.Extensions.JT1078/Formatters/JT808_0x0200_0x17_Formatter.cs new file mode 100644 index 0000000..8d2903f --- /dev/null +++ b/src/JT808.Protocol.Extensions.JT1078/Formatters/JT808_0x0200_0x17_Formatter.cs @@ -0,0 +1,29 @@ +using JT808.Protocol.Extensions.JT1078.MessageBody; +using JT808.Protocol.Formatters; +using JT808.Protocol.Interfaces; +using JT808.Protocol.MessagePack; +using System; +using System.Collections.Generic; +using System.Text; + +namespace JT808.Protocol.Extensions.JT1078.Formatters +{ + public class JT808_0x0200_0x17_Formatter : IJT808MessagePackFormatter + { + public JT808_0x0200_0x17 Deserialize(ref JT808MessagePackReader reader, IJT808Config config) + { + JT808_0x0200_0x17 jT808_0x0200_0x17 = new JT808_0x0200_0x17(); + jT808_0x0200_0x17.AttachInfoId = reader.ReadByte(); + jT808_0x0200_0x17.AttachInfoLength = reader.ReadByte(); + jT808_0x0200_0x17.StorageFaultAlarmStatus = reader.ReadUInt16(); + return jT808_0x0200_0x17; + } + + public void Serialize(ref JT808MessagePackWriter writer, JT808_0x0200_0x17 value, IJT808Config config) + { + writer.WriteByte(value.AttachInfoId); + writer.WriteByte(value.AttachInfoLength); + writer.WriteUInt16(value.StorageFaultAlarmStatus); + } + } +} diff --git a/src/JT808.Protocol.Extensions.JT1078/Formatters/JT808_0x0200_0x18_Formatter.cs b/src/JT808.Protocol.Extensions.JT1078/Formatters/JT808_0x0200_0x18_Formatter.cs new file mode 100644 index 0000000..fd46ff7 --- /dev/null +++ b/src/JT808.Protocol.Extensions.JT1078/Formatters/JT808_0x0200_0x18_Formatter.cs @@ -0,0 +1,29 @@ +using JT808.Protocol.Extensions.JT1078.MessageBody; +using JT808.Protocol.Formatters; +using JT808.Protocol.Interfaces; +using JT808.Protocol.MessagePack; +using System; +using System.Collections.Generic; +using System.Text; + +namespace JT808.Protocol.Extensions.JT1078.Formatters +{ + public class JT808_0x0200_0x18_Formatter : IJT808MessagePackFormatter + { + public JT808_0x0200_0x18 Deserialize(ref JT808MessagePackReader reader, IJT808Config config) + { + JT808_0x0200_0x18 jT808_0x0200_0x18 = new JT808_0x0200_0x18(); + jT808_0x0200_0x18.AttachInfoId = reader.ReadByte(); + jT808_0x0200_0x18.AttachInfoLength = reader.ReadByte(); + jT808_0x0200_0x18.AbnormalDrivingBehaviorAlarmInfo = reader.ReadUInt16(); + return jT808_0x0200_0x18; + } + + public void Serialize(ref JT808MessagePackWriter writer, JT808_0x0200_0x18 value, IJT808Config config) + { + writer.WriteByte(value.AttachInfoId); + writer.WriteByte(value.AttachInfoLength); + writer.WriteUInt16(value.AbnormalDrivingBehaviorAlarmInfo); + } + } +} diff --git a/src/JT808.Protocol.Extensions.JT1078/Formatters/JT808_0x1003_Formatter.cs b/src/JT808.Protocol.Extensions.JT1078/Formatters/JT808_0x1003_Formatter.cs new file mode 100644 index 0000000..992895d --- /dev/null +++ b/src/JT808.Protocol.Extensions.JT1078/Formatters/JT808_0x1003_Formatter.cs @@ -0,0 +1,41 @@ +using JT808.Protocol.Extensions.JT1078.MessageBody; +using JT808.Protocol.Formatters; +using JT808.Protocol.Interfaces; +using JT808.Protocol.MessagePack; +using System; +using System.Collections.Generic; +using System.Text; + +namespace JT808.Protocol.Extensions.JT1078.Formatters +{ + public class JT808_0x1003_Formatter : IJT808MessagePackFormatter + { + public JT808_0x1003 Deserialize(ref JT808MessagePackReader reader, IJT808Config config) + { + JT808_0x1003 jT808_0x1003 = new JT808_0x1003(); + jT808_0x1003.EnterAudioEncoding = reader.ReadByte(); + jT808_0x1003.EnterAudioChannelsNumber = reader.ReadByte(); + jT808_0x1003.EnterAudioSampleRate = reader.ReadByte(); + jT808_0x1003.EnterAudioSampleDigits = reader.ReadByte(); + jT808_0x1003.AudioFrameLength = reader.ReadUInt16(); + jT808_0x1003.IsSupportedAudioOutput = reader.ReadByte(); + jT808_0x1003.VideoEncoding = reader.ReadByte(); + jT808_0x1003.TerminalSupportedMaxNumberOfAudioPhysicalChannels = reader.ReadByte(); + jT808_0x1003.TerminalSupportedMaxNumberOfVideoPhysicalChannels = reader.ReadByte(); + return jT808_0x1003; + } + + public void Serialize(ref JT808MessagePackWriter writer, JT808_0x1003 value, IJT808Config config) + { + writer.WriteByte(value.EnterAudioEncoding); + writer.WriteByte(value.EnterAudioChannelsNumber); + writer.WriteByte(value.EnterAudioSampleRate); + writer.WriteByte(value.EnterAudioSampleDigits); + writer.WriteUInt16(value.AudioFrameLength); + writer.WriteByte(value.IsSupportedAudioOutput); + writer.WriteByte(value.VideoEncoding); + writer.WriteByte(value.TerminalSupportedMaxNumberOfAudioPhysicalChannels); + writer.WriteByte(value.TerminalSupportedMaxNumberOfVideoPhysicalChannels); + } + } +} diff --git a/src/JT808.Protocol.Extensions.JT1078/Formatters/JT808_0x1005_Formatter.cs b/src/JT808.Protocol.Extensions.JT1078/Formatters/JT808_0x1005_Formatter.cs new file mode 100644 index 0000000..334f7ab --- /dev/null +++ b/src/JT808.Protocol.Extensions.JT1078/Formatters/JT808_0x1005_Formatter.cs @@ -0,0 +1,31 @@ +using JT808.Protocol.Extensions.JT1078.MessageBody; +using JT808.Protocol.Formatters; +using JT808.Protocol.Interfaces; +using JT808.Protocol.MessagePack; +using System; +using System.Collections.Generic; +using System.Text; + +namespace JT808.Protocol.Extensions.JT1078.Formatters +{ + public class JT808_0x1005_Formatter : IJT808MessagePackFormatter + { + public JT808_0x1005 Deserialize(ref JT808MessagePackReader reader, IJT808Config config) + { + JT808_0x1005 jT808_0x1005 = new JT808_0x1005(); + jT808_0x1005.BeginTime = reader.ReadDateTime6(); + jT808_0x1005.EndTime = reader.ReadDateTime6(); + jT808_0x1005.GettingOnNumber = reader.ReadUInt16(); + jT808_0x1005.GettingOffNumber = reader.ReadUInt16(); + return jT808_0x1005; + } + + public void Serialize(ref JT808MessagePackWriter writer, JT808_0x1005 value, IJT808Config config) + { + writer.WriteDateTime6(value.BeginTime); + writer.WriteDateTime6(value.EndTime); + writer.WriteUInt16(value.GettingOnNumber); + writer.WriteUInt16(value.GettingOffNumber); + } + } +} diff --git a/src/JT808.Protocol.Extensions.JT1078/Formatters/JT808_0x1205_AVResouce_Formatter.cs b/src/JT808.Protocol.Extensions.JT1078/Formatters/JT808_0x1205_AVResouce_Formatter.cs new file mode 100644 index 0000000..829636a --- /dev/null +++ b/src/JT808.Protocol.Extensions.JT1078/Formatters/JT808_0x1205_AVResouce_Formatter.cs @@ -0,0 +1,39 @@ +using JT808.Protocol.Extensions.JT1078.MessageBody; +using JT808.Protocol.Formatters; +using JT808.Protocol.Interfaces; +using JT808.Protocol.MessagePack; +using System; +using System.Collections.Generic; +using System.Text; + +namespace JT808.Protocol.Extensions.JT1078.Formatters +{ + public class JT808_0x1205_AVResouce_Formatter : IJT808MessagePackFormatter + { + public JT808_0x1205_AVResouce Deserialize(ref JT808MessagePackReader reader, IJT808Config config) + { + JT808_0x1205_AVResouce jT808_0x1205_AVResouce = new JT808_0x1205_AVResouce(); + jT808_0x1205_AVResouce.LogicChannelNo = reader.ReadByte(); + jT808_0x1205_AVResouce.BeginTime = reader.ReadDateTime6(); + jT808_0x1205_AVResouce.EndTime = reader.ReadDateTime6(); + jT808_0x1205_AVResouce.AlarmFlag = reader.ReadUInt32(); + jT808_0x1205_AVResouce.AVResourceType = reader.ReadByte(); + jT808_0x1205_AVResouce.StreamType = reader.ReadByte(); + jT808_0x1205_AVResouce.MemoryType = reader.ReadByte(); + jT808_0x1205_AVResouce.FileSize = reader.ReadUInt32(); + return jT808_0x1205_AVResouce; + } + + public void Serialize(ref JT808MessagePackWriter writer, JT808_0x1205_AVResouce value, IJT808Config config) + { + writer.WriteByte(value.LogicChannelNo); + writer.WriteDateTime6(value.BeginTime); + writer.WriteDateTime6(value.EndTime); + writer.WriteUInt32(value.AlarmFlag); + writer.WriteByte(value.AVResourceType); + writer.WriteByte(value.StreamType); + writer.WriteByte(value.MemoryType); + writer.WriteUInt32(value.FileSize); + } + } +} \ No newline at end of file diff --git a/src/JT808.Protocol.Extensions.JT1078/Formatters/JT808_0x1205_Formatter.cs b/src/JT808.Protocol.Extensions.JT1078/Formatters/JT808_0x1205_Formatter.cs new file mode 100644 index 0000000..3246163 --- /dev/null +++ b/src/JT808.Protocol.Extensions.JT1078/Formatters/JT808_0x1205_Formatter.cs @@ -0,0 +1,46 @@ +using JT808.Protocol.Extensions.JT1078.MessageBody; +using JT808.Protocol.Formatters; +using JT808.Protocol.Interfaces; +using JT808.Protocol.MessagePack; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; + +namespace JT808.Protocol.Extensions.JT1078.Formatters +{ + public class JT808_0x1205_Formatter : IJT808MessagePackFormatter + { + public JT808_0x1205 Deserialize(ref JT808MessagePackReader reader, IJT808Config config) + { + JT808_0x1205 jT808_0x1205 = new JT808_0x1205(); + jT808_0x1205.MsgNum = reader.ReadUInt16(); + jT808_0x1205.AVResouceTotal = reader.ReadUInt32(); + var channelTotal = jT808_0x1205.AVResouceTotal;//音视频资源总数 + if (channelTotal > 0) + { + jT808_0x1205.AVResouces =new List(); + var formatter = config.GetMessagePackFormatter(); + for (int i = 0; i < channelTotal; i++) + { + jT808_0x1205.AVResouces.Add(formatter.Deserialize(ref reader, config)); + } + } + return jT808_0x1205; + } + + public void Serialize(ref JT808MessagePackWriter writer, JT808_0x1205 value, IJT808Config config) + { + writer.WriteUInt16(value.MsgNum); + writer.WriteUInt32(value.AVResouceTotal); + if (value.AVResouces.Any()) + { + var formatter = config.GetMessagePackFormatter(); + foreach (var AVResouce in value.AVResouces) + { + formatter.Serialize(ref writer, AVResouce, config); + } + } + } + } +} \ No newline at end of file diff --git a/src/JT808.Protocol.Extensions.JT1078/Formatters/JT808_0x1206_Formatter.cs b/src/JT808.Protocol.Extensions.JT1078/Formatters/JT808_0x1206_Formatter.cs new file mode 100644 index 0000000..b34958e --- /dev/null +++ b/src/JT808.Protocol.Extensions.JT1078/Formatters/JT808_0x1206_Formatter.cs @@ -0,0 +1,27 @@ +using JT808.Protocol.Extensions.JT1078.MessageBody; +using JT808.Protocol.Formatters; +using JT808.Protocol.Interfaces; +using JT808.Protocol.MessagePack; +using System; +using System.Collections.Generic; +using System.Text; + +namespace JT808.Protocol.Extensions.JT1078.Formatters +{ + public class JT808_0x1206_Formatter : IJT808MessagePackFormatter + { + public JT808_0x1206 Deserialize(ref JT808MessagePackReader reader, IJT808Config config) + { + JT808_0x1206 jT808_0x1206 = new JT808_0x1206(); + jT808_0x1206.MsgNum = reader.ReadUInt16(); + jT808_0x1206.Result = reader.ReadByte(); + return jT808_0x1206; + } + + public void Serialize(ref JT808MessagePackWriter writer, JT808_0x1206 value, IJT808Config config) + { + writer.WriteUInt16(value.MsgNum); + writer.WriteByte(value.Result); + } + } +} \ No newline at end of file diff --git a/src/JT808.Protocol.Extensions.JT1078/Formatters/JT808_0x8103_0x0075_Formatter.cs b/src/JT808.Protocol.Extensions.JT1078/Formatters/JT808_0x8103_0x0075_Formatter.cs new file mode 100644 index 0000000..5be2884 --- /dev/null +++ b/src/JT808.Protocol.Extensions.JT1078/Formatters/JT808_0x8103_0x0075_Formatter.cs @@ -0,0 +1,51 @@ +using JT808.Protocol.Extensions.JT1078.MessageBody; +using JT808.Protocol.Formatters; +using JT808.Protocol.Interfaces; +using JT808.Protocol.MessagePack; +using System; +using System.Collections.Generic; +using System.Text; + +namespace JT808.Protocol.Extensions.JT1078.Formatters +{ + public class JT808_0x8103_0x0075_Formatter : IJT808MessagePackFormatter + { + public JT808_0x8103_0x0075 Deserialize(ref JT808MessagePackReader reader, IJT808Config config) + { + JT808_0x8103_0x0075 jT808_0X8103_0X0075 = new JT808_0x8103_0x0075(); + jT808_0X8103_0X0075.ParamId = reader.ReadUInt32(); + jT808_0X8103_0X0075.ParamLength = reader.ReadByte(); + jT808_0X8103_0X0075.RTS_EncodeMode = reader.ReadByte(); + jT808_0X8103_0X0075.RTS_Resolution = reader.ReadByte(); + jT808_0X8103_0X0075.RTS_KF_Interval = reader.ReadUInt16(); + jT808_0X8103_0X0075.RTS_Target_FPS = reader.ReadByte(); + jT808_0X8103_0X0075.RTS_Target_CodeRate = reader.ReadUInt32(); + jT808_0X8103_0X0075.StreamStore_EncodeMode = reader.ReadByte(); + jT808_0X8103_0X0075.StreamStore_Resolution = reader.ReadByte(); + jT808_0X8103_0X0075.StreamStore_KF_Interval = reader.ReadUInt16(); + jT808_0X8103_0X0075.StreamStore_Target_FPS = reader.ReadByte(); + jT808_0X8103_0X0075.StreamStore_Target_CodeRate = reader.ReadUInt32(); + jT808_0X8103_0X0075.OSD = reader.ReadUInt16(); + jT808_0X8103_0X0075.AudioOutputEnabled = reader.ReadByte(); + return jT808_0X8103_0X0075; + } + + public void Serialize(ref JT808MessagePackWriter writer, JT808_0x8103_0x0075 value, IJT808Config config) + { + writer.WriteUInt32(value.ParamId); + writer.WriteByte(value.ParamLength); + writer.WriteByte(value.RTS_EncodeMode); + writer.WriteByte(value.RTS_Resolution); + writer.WriteUInt16(value.RTS_KF_Interval); + writer.WriteByte(value.RTS_Target_FPS); + writer.WriteUInt32(value.RTS_Target_CodeRate); + writer.WriteByte(value.StreamStore_EncodeMode); + writer.WriteByte(value.StreamStore_Resolution); + writer.WriteUInt16(value.StreamStore_KF_Interval); + writer.WriteByte(value.StreamStore_Target_FPS); + writer.WriteUInt32(value.StreamStore_Target_CodeRate); + writer.WriteUInt16(value.OSD); + writer.WriteByte(value.AudioOutputEnabled); + } + } +} diff --git a/src/JT808.Protocol.Extensions.JT1078/Formatters/JT808_0x8103_0x0076_AVChannelRefTable_Formatter.cs b/src/JT808.Protocol.Extensions.JT1078/Formatters/JT808_0x8103_0x0076_AVChannelRefTable_Formatter.cs new file mode 100644 index 0000000..f7ef183 --- /dev/null +++ b/src/JT808.Protocol.Extensions.JT1078/Formatters/JT808_0x8103_0x0076_AVChannelRefTable_Formatter.cs @@ -0,0 +1,31 @@ +using JT808.Protocol.Extensions.JT1078.MessageBody; +using JT808.Protocol.Formatters; +using JT808.Protocol.Interfaces; +using JT808.Protocol.MessagePack; +using System; +using System.Collections.Generic; +using System.Text; + +namespace JT808.Protocol.Extensions.JT1078.Formatters +{ + public class JT808_0x8103_0x0076_AVChannelRefTable_Formatter : IJT808MessagePackFormatter + { + public JT808_0x8103_0x0076_AVChannelRefTable Deserialize(ref JT808MessagePackReader reader, IJT808Config config) + { + JT808_0x8103_0x0076_AVChannelRefTable jT808_0X8103_0X0076_AVChannelRefTable = new JT808_0x8103_0x0076_AVChannelRefTable(); + jT808_0X8103_0X0076_AVChannelRefTable.PhysicalChannelNo = reader.ReadByte(); + jT808_0X8103_0X0076_AVChannelRefTable.LogicChannelNo = reader.ReadByte(); + jT808_0X8103_0X0076_AVChannelRefTable.ChannelType = reader.ReadByte(); + jT808_0X8103_0X0076_AVChannelRefTable.IsConnectCloudPlat = reader.ReadByte(); + return jT808_0X8103_0X0076_AVChannelRefTable; + } + + public void Serialize(ref JT808MessagePackWriter writer, JT808_0x8103_0x0076_AVChannelRefTable value, IJT808Config config) + { + writer.WriteByte(value.PhysicalChannelNo); + writer.WriteByte(value.LogicChannelNo); + writer.WriteByte(value.ChannelType); + writer.WriteByte(value.IsConnectCloudPlat); + } + } +} diff --git a/src/JT808.Protocol.Extensions.JT1078/Formatters/JT808_0x8103_0x0076_Formatter.cs b/src/JT808.Protocol.Extensions.JT1078/Formatters/JT808_0x8103_0x0076_Formatter.cs new file mode 100644 index 0000000..232776c --- /dev/null +++ b/src/JT808.Protocol.Extensions.JT1078/Formatters/JT808_0x8103_0x0076_Formatter.cs @@ -0,0 +1,51 @@ +using JT808.Protocol.Extensions.JT1078.MessageBody; +using JT808.Protocol.Formatters; +using JT808.Protocol.Interfaces; +using JT808.Protocol.MessagePack; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; + +namespace JT808.Protocol.Extensions.JT1078.Formatters +{ + public class JT808_0x8103_0x0076_Formatter : IJT808MessagePackFormatter + { + public JT808_0x8103_0x0076 Deserialize(ref JT808MessagePackReader reader, IJT808Config config) + { + JT808_0x8103_0x0076 jT808_0X8103_0X0076 = new JT808_0x8103_0x0076(); + jT808_0X8103_0X0076.ParamId = reader.ReadUInt32(); + jT808_0X8103_0X0076.ParamLength = reader.ReadByte(); + jT808_0X8103_0X0076.AVChannelTotal = reader.ReadByte(); + jT808_0X8103_0X0076.AudioChannelTotal = reader.ReadByte(); + jT808_0X8103_0X0076.VudioChannelTotal = reader.ReadByte(); + var channelTotal = jT808_0X8103_0X0076.AVChannelTotal + jT808_0X8103_0X0076.AudioChannelTotal + jT808_0X8103_0X0076.VudioChannelTotal;//通道总数 + if (channelTotal > 0) { + jT808_0X8103_0X0076.AVChannelRefTables = new List(); + var formatter = config.GetMessagePackFormatter(); + for (int i = 0; i < channelTotal; i++) + { + jT808_0X8103_0X0076.AVChannelRefTables.Add(formatter.Deserialize(ref reader, config)); + } + } + return jT808_0X8103_0X0076; + } + + public void Serialize(ref JT808MessagePackWriter writer, JT808_0x8103_0x0076 value, IJT808Config config) + { + writer.WriteUInt32(value.ParamId); + writer.Skip(1,out int position); + writer.WriteByte(value.AVChannelTotal); + writer.WriteByte(value.AudioChannelTotal); + writer.WriteByte(value.VudioChannelTotal); + if (value.AVChannelRefTables.Any()) { + var formatter = config.GetMessagePackFormatter(); + foreach (var AVChannelRefTable in value.AVChannelRefTables) + { + formatter.Serialize(ref writer, AVChannelRefTable, config); + } + } + writer.WriteByteReturn((byte)(writer.GetCurrentPosition()- position-1), position); + } + } +} diff --git a/src/JT808.Protocol.Extensions.JT1078/Formatters/JT808_0x8103_0x0077_Formatter.cs b/src/JT808.Protocol.Extensions.JT1078/Formatters/JT808_0x8103_0x0077_Formatter.cs new file mode 100644 index 0000000..4d87d95 --- /dev/null +++ b/src/JT808.Protocol.Extensions.JT1078/Formatters/JT808_0x8103_0x0077_Formatter.cs @@ -0,0 +1,46 @@ +using JT808.Protocol.Extensions.JT1078.MessageBody; +using JT808.Protocol.Formatters; +using JT808.Protocol.Interfaces; +using JT808.Protocol.MessagePack; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; + +namespace JT808.Protocol.Extensions.JT1078.Formatters +{ + public class JT808_0x8103_0x0077_Formatter : IJT808MessagePackFormatter + { + public JT808_0x8103_0x0077 Deserialize(ref JT808MessagePackReader reader, IJT808Config config) + { + JT808_0x8103_0x0077 jT808_0X8103_0X0077 = new JT808_0x8103_0x0077(); + jT808_0X8103_0X0077.ParamId = reader.ReadUInt32(); + jT808_0X8103_0X0077.ParamLength = reader.ReadByte(); + jT808_0X8103_0X0077.NeedSetChannelTotal = reader.ReadByte(); + if (jT808_0X8103_0X0077.NeedSetChannelTotal > 0) { + jT808_0X8103_0X0077.jT808_0X8103_0X0077_SignalChannels = new List(); + var formatter = config.GetMessagePackFormatter(); + for (int i = 0; i < jT808_0X8103_0X0077.NeedSetChannelTotal; i++) + { + jT808_0X8103_0X0077.jT808_0X8103_0X0077_SignalChannels.Add(formatter.Deserialize(ref reader, config)); + } + } + return jT808_0X8103_0X0077; + } + + public void Serialize(ref JT808MessagePackWriter writer, JT808_0x8103_0x0077 value, IJT808Config config) + { + writer.WriteUInt32(value.ParamId); + writer.Skip(1,out var position); + writer.WriteByte(value.NeedSetChannelTotal); + if (value.jT808_0X8103_0X0077_SignalChannels.Any()) { + var formatter = config.GetMessagePackFormatter(); + foreach (var signalChannel in value.jT808_0X8103_0X0077_SignalChannels) + { + formatter.Serialize(ref writer, signalChannel, config); + } + } + writer.WriteByteReturn((byte)(writer.GetCurrentPosition() - position - 1), position); + } + } +} diff --git a/src/JT808.Protocol.Extensions.JT1078/Formatters/JT808_0x8103_0x0077_SignalChannel_Formatter.cs b/src/JT808.Protocol.Extensions.JT1078/Formatters/JT808_0x8103_0x0077_SignalChannel_Formatter.cs new file mode 100644 index 0000000..3d8f545 --- /dev/null +++ b/src/JT808.Protocol.Extensions.JT1078/Formatters/JT808_0x8103_0x0077_SignalChannel_Formatter.cs @@ -0,0 +1,47 @@ +using JT808.Protocol.Extensions.JT1078.MessageBody; +using JT808.Protocol.Formatters; +using JT808.Protocol.Interfaces; +using JT808.Protocol.MessagePack; +using System; +using System.Collections.Generic; +using System.Text; + +namespace JT808.Protocol.Extensions.JT1078.Formatters +{ + public class JT808_0x8103_0x0077_SignalChannel_Formatter : IJT808MessagePackFormatter + { + public JT808_0x8103_0x0077_SignalChannel Deserialize(ref JT808MessagePackReader reader, IJT808Config config) + { + JT808_0x8103_0x0077_SignalChannel jT808_0X8103_0X0077_SignalChannel = new JT808_0x8103_0x0077_SignalChannel(); + jT808_0X8103_0X0077_SignalChannel.LogicChannelNo= reader.ReadByte(); + jT808_0X8103_0X0077_SignalChannel.RTS_EncodeMode = reader.ReadByte(); + jT808_0X8103_0X0077_SignalChannel.RTS_Resolution = reader.ReadByte(); + jT808_0X8103_0X0077_SignalChannel.RTS_KF_Interval = reader.ReadUInt16(); + jT808_0X8103_0X0077_SignalChannel.RTS_Target_FPS = reader.ReadByte(); + jT808_0X8103_0X0077_SignalChannel.RTS_Target_CodeRate = reader.ReadUInt32(); + jT808_0X8103_0X0077_SignalChannel.StreamStore_EncodeMode = reader.ReadByte(); + jT808_0X8103_0X0077_SignalChannel.StreamStore_Resolution = reader.ReadByte(); + jT808_0X8103_0X0077_SignalChannel.StreamStore_KF_Interval = reader.ReadUInt16(); + jT808_0X8103_0X0077_SignalChannel.StreamStore_Target_FPS = reader.ReadByte(); + jT808_0X8103_0X0077_SignalChannel.StreamStore_Target_CodeRate = reader.ReadUInt32(); + jT808_0X8103_0X0077_SignalChannel.OSD = reader.ReadUInt16(); + return jT808_0X8103_0X0077_SignalChannel; + } + + public void Serialize(ref JT808MessagePackWriter writer, JT808_0x8103_0x0077_SignalChannel value, IJT808Config config) + { + writer.WriteByte(value.LogicChannelNo); + writer.WriteByte(value.RTS_EncodeMode); + writer.WriteByte(value.RTS_Resolution); + writer.WriteUInt16(value.RTS_KF_Interval); + writer.WriteByte(value.RTS_Target_FPS); + writer.WriteUInt32(value.RTS_Target_CodeRate); + writer.WriteByte(value.StreamStore_EncodeMode); + writer.WriteByte(value.StreamStore_Resolution); + writer.WriteUInt16(value.StreamStore_KF_Interval); + writer.WriteByte(value.StreamStore_Target_FPS); + writer.WriteUInt32(value.StreamStore_Target_CodeRate); + writer.WriteUInt16(value.OSD); + } + } +} diff --git a/src/JT808.Protocol.Extensions.JT1078/Formatters/JT808_0x8103_0x0079_Formatter.cs b/src/JT808.Protocol.Extensions.JT1078/Formatters/JT808_0x8103_0x0079_Formatter.cs new file mode 100644 index 0000000..fac6539 --- /dev/null +++ b/src/JT808.Protocol.Extensions.JT1078/Formatters/JT808_0x8103_0x0079_Formatter.cs @@ -0,0 +1,34 @@ +using JT808.Protocol.Extensions.JT1078.MessageBody; +using JT808.Protocol.Formatters; +using JT808.Protocol.Interfaces; +using JT808.Protocol.MessagePack; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; + +namespace JT808.Protocol.Extensions.JT1078.Formatters +{ + public class JT808_0x8103_0x0079_Formatter : IJT808MessagePackFormatter + { + public JT808_0x8103_0x0079 Deserialize(ref JT808MessagePackReader reader, IJT808Config config) + { + JT808_0x8103_0x0079 jT808_0x8103_0x0079 = new JT808_0x8103_0x0079(); + jT808_0x8103_0x0079.ParamId = reader.ReadUInt32(); + jT808_0x8103_0x0079.ParamLength = reader.ReadByte(); + jT808_0x8103_0x0079.StorageThresholds = reader.ReadByte(); + jT808_0x8103_0x0079.Duration = reader.ReadByte(); + jT808_0x8103_0x0079.BeginMinute = reader.ReadByte(); + return jT808_0x8103_0x0079; + } + + public void Serialize(ref JT808MessagePackWriter writer, JT808_0x8103_0x0079 value, IJT808Config config) + { + writer.WriteUInt32(value.ParamId); + writer.WriteByte(value.ParamLength); + writer.WriteByte(value.StorageThresholds); + writer.WriteByte(value.Duration); + writer.WriteByte(value.BeginMinute); + } + } +} diff --git a/src/JT808.Protocol.Extensions.JT1078/Formatters/JT808_0x8103_0x007A_Formatter.cs b/src/JT808.Protocol.Extensions.JT1078/Formatters/JT808_0x8103_0x007A_Formatter.cs new file mode 100644 index 0000000..deb93e0 --- /dev/null +++ b/src/JT808.Protocol.Extensions.JT1078/Formatters/JT808_0x8103_0x007A_Formatter.cs @@ -0,0 +1,30 @@ +using JT808.Protocol.Extensions.JT1078.MessageBody; +using JT808.Protocol.Formatters; +using JT808.Protocol.Interfaces; +using JT808.Protocol.MessagePack; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; + +namespace JT808.Protocol.Extensions.JT1078.Formatters +{ + public class JT808_0x8103_0x007A_Formatter : IJT808MessagePackFormatter + { + public JT808_0x8103_0x007A Deserialize(ref JT808MessagePackReader reader, IJT808Config config) + { + JT808_0x8103_0x007A jT808_0x8103_0x007A = new JT808_0x8103_0x007A(); + jT808_0x8103_0x007A.ParamId = reader.ReadUInt32(); + jT808_0x8103_0x007A.ParamLength = reader.ReadByte(); + jT808_0x8103_0x007A.AlarmShielding = reader.ReadUInt32(); + return jT808_0x8103_0x007A; + } + + public void Serialize(ref JT808MessagePackWriter writer, JT808_0x8103_0x007A value, IJT808Config config) + { + writer.WriteUInt32(value.ParamId); + writer.WriteByte(value.ParamLength); + writer.WriteUInt32(value.AlarmShielding); + } + } +} diff --git a/src/JT808.Protocol.Extensions.JT1078/Formatters/JT808_0x8103_0x007B_Formatter.cs b/src/JT808.Protocol.Extensions.JT1078/Formatters/JT808_0x8103_0x007B_Formatter.cs new file mode 100644 index 0000000..73248f3 --- /dev/null +++ b/src/JT808.Protocol.Extensions.JT1078/Formatters/JT808_0x8103_0x007B_Formatter.cs @@ -0,0 +1,32 @@ +using JT808.Protocol.Extensions.JT1078.MessageBody; +using JT808.Protocol.Formatters; +using JT808.Protocol.Interfaces; +using JT808.Protocol.MessagePack; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; + +namespace JT808.Protocol.Extensions.JT1078.Formatters +{ + public class JT808_0x8103_0x007B_Formatter : IJT808MessagePackFormatter + { + public JT808_0x8103_0x007B Deserialize(ref JT808MessagePackReader reader, IJT808Config config) + { + JT808_0x8103_0x007B jT808_0x8103_0x007B = new JT808_0x8103_0x007B(); + jT808_0x8103_0x007B.ParamId = reader.ReadUInt32(); + jT808_0x8103_0x007B.ParamLength = reader.ReadByte(); + jT808_0x8103_0x007B.NuclearLoadNumber = reader.ReadByte(); + jT808_0x8103_0x007B.FatigueThreshold = reader.ReadByte(); + return jT808_0x8103_0x007B; + } + + public void Serialize(ref JT808MessagePackWriter writer, JT808_0x8103_0x007B value, IJT808Config config) + { + writer.WriteUInt32(value.ParamId); + writer.WriteByte(value.ParamLength); + writer.WriteByte(value.NuclearLoadNumber); + writer.WriteByte(value.FatigueThreshold); + } + } +} diff --git a/src/JT808.Protocol.Extensions.JT1078/Formatters/JT808_0x8103_0x007C_Formatter.cs b/src/JT808.Protocol.Extensions.JT1078/Formatters/JT808_0x8103_0x007C_Formatter.cs new file mode 100644 index 0000000..6835353 --- /dev/null +++ b/src/JT808.Protocol.Extensions.JT1078/Formatters/JT808_0x8103_0x007C_Formatter.cs @@ -0,0 +1,37 @@ +using JT808.Protocol.Extensions.JT1078.MessageBody; +using JT808.Protocol.Formatters; +using JT808.Protocol.Interfaces; +using JT808.Protocol.MessagePack; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; + +namespace JT808.Protocol.Extensions.JT1078.Formatters +{ + public class JT808_0x8103_0x007C_Formatter : IJT808MessagePackFormatter + { + public JT808_0x8103_0x007C Deserialize(ref JT808MessagePackReader reader, IJT808Config config) + { + JT808_0x8103_0x007C jT808_0x8103_0x007C = new JT808_0x8103_0x007C(); + jT808_0x8103_0x007C.ParamId = reader.ReadUInt32(); + jT808_0x8103_0x007C.ParamLength = reader.ReadByte(); + jT808_0x8103_0x007C.SleepWakeMode = reader.ReadByte(); + jT808_0x8103_0x007C.WakeConditionType = reader.ReadByte(); + jT808_0x8103_0x007C.TimerWakeDaySet = reader.ReadByte(); + jT808_0x8103_0x007C.jT808_0X8103_0X007C_TimerWakeDayParamter = config.GetMessagePackFormatter().Deserialize(ref reader, config); + return jT808_0x8103_0x007C; + } + + public void Serialize(ref JT808MessagePackWriter writer, JT808_0x8103_0x007C value, IJT808Config config) + { + writer.WriteUInt32(value.ParamId); + writer.Skip(1, out var position); + writer.WriteByte(value.SleepWakeMode); + writer.WriteByte(value.WakeConditionType); + writer.WriteByte(value.TimerWakeDaySet); + config.GetMessagePackFormatter().Serialize(ref writer, value.jT808_0X8103_0X007C_TimerWakeDayParamter, config); + writer.WriteByteReturn((byte)(writer.GetCurrentPosition()-position-1),position); + } + } +} diff --git a/src/JT808.Protocol.Extensions.JT1078/Formatters/JT808_0x8103_0x007C_TimerWakeDayParamter_Formatter.cs b/src/JT808.Protocol.Extensions.JT1078/Formatters/JT808_0x8103_0x007C_TimerWakeDayParamter_Formatter.cs new file mode 100644 index 0000000..e6a8103 --- /dev/null +++ b/src/JT808.Protocol.Extensions.JT1078/Formatters/JT808_0x8103_0x007C_TimerWakeDayParamter_Formatter.cs @@ -0,0 +1,42 @@ +using JT808.Protocol.Extensions.JT1078.MessageBody; +using JT808.Protocol.Formatters; +using JT808.Protocol.Interfaces; +using JT808.Protocol.MessagePack; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; + +namespace JT808.Protocol.Extensions.JT1078.Formatters +{ + public class JT808_0x8103_0x007C_TimerWakeDayParamter_Formatter : IJT808MessagePackFormatter + { + public JT808_0x8103_0x007C_TimerWakeDayParamter Deserialize(ref JT808MessagePackReader reader, IJT808Config config) + { + JT808_0x8103_0x007C_TimerWakeDayParamter jT808_0x8103_0x007C_TimerWakeDayParamter = new JT808_0x8103_0x007C_TimerWakeDayParamter(); + jT808_0x8103_0x007C_TimerWakeDayParamter.TimerWakeEnableFlag = reader.ReadByte(); + jT808_0x8103_0x007C_TimerWakeDayParamter.TimePeriod1WakeTime = reader.ReadBCD(4); + jT808_0x8103_0x007C_TimerWakeDayParamter.TimePeriod1CloseTime = reader.ReadBCD(4); + jT808_0x8103_0x007C_TimerWakeDayParamter.TimePeriod2WakeTime = reader.ReadBCD(4); + jT808_0x8103_0x007C_TimerWakeDayParamter.TimePeriod2CloseTime = reader.ReadBCD(4); + jT808_0x8103_0x007C_TimerWakeDayParamter.TimePeriod3WakeTime = reader.ReadBCD(4); + jT808_0x8103_0x007C_TimerWakeDayParamter.TimePeriod3CloseTime = reader.ReadBCD(4); + jT808_0x8103_0x007C_TimerWakeDayParamter.TimePeriod4WakeTime = reader.ReadBCD(4); + jT808_0x8103_0x007C_TimerWakeDayParamter.TimePeriod4CloseTime = reader.ReadBCD(4); + return jT808_0x8103_0x007C_TimerWakeDayParamter; + } + + public void Serialize(ref JT808MessagePackWriter writer, JT808_0x8103_0x007C_TimerWakeDayParamter value, IJT808Config config) + { + writer.WriteByte(value.TimerWakeEnableFlag); + writer.WriteBCD(value.TimePeriod1WakeTime, 4); + writer.WriteBCD(value.TimePeriod1CloseTime, 4); + writer.WriteBCD(value.TimePeriod2WakeTime, 4); + writer.WriteBCD(value.TimePeriod2CloseTime, 4); + writer.WriteBCD(value.TimePeriod3WakeTime, 4); + writer.WriteBCD(value.TimePeriod3CloseTime, 4); + writer.WriteBCD(value.TimePeriod4WakeTime, 4); + writer.WriteBCD(value.TimePeriod4CloseTime, 4); + } + } +} diff --git a/src/JT808.Protocol.Extensions.JT1078/Formatters/JT808_0x9101_Formatter.cs b/src/JT808.Protocol.Extensions.JT1078/Formatters/JT808_0x9101_Formatter.cs new file mode 100644 index 0000000..9539979 --- /dev/null +++ b/src/JT808.Protocol.Extensions.JT1078/Formatters/JT808_0x9101_Formatter.cs @@ -0,0 +1,38 @@ +using JT808.Protocol.Extensions.JT1078.MessageBody; +using JT808.Protocol.Formatters; +using JT808.Protocol.Interfaces; +using JT808.Protocol.MessagePack; +using System; +using System.Collections.Generic; +using System.Text; + +namespace JT808.Protocol.Extensions.JT1078.Formatters +{ + public class JT808_0x9101_Formatter : IJT808MessagePackFormatter + { + public JT808_0x9101 Deserialize(ref JT808MessagePackReader reader, IJT808Config config) + { + JT808_0x9101 jT808_0X9101 = new JT808_0x9101(); + jT808_0X9101.ServerIPAddressLength = reader.ReadByte(); + jT808_0X9101.ServerIPAddress = reader.ReadString(jT808_0X9101.ServerIPAddressLength); + jT808_0X9101.ServerVideoChannelTcpPort = reader.ReadUInt16(); + jT808_0X9101.ServerVideoChannelUdpPort = reader.ReadUInt16(); + jT808_0X9101.LogicalChannelNo = reader.ReadByte(); + jT808_0X9101.DataType = reader.ReadByte(); + jT808_0X9101.StreamType = reader.ReadByte(); + return jT808_0X9101; + } + + public void Serialize(ref JT808MessagePackWriter writer, JT808_0x9101 value, IJT808Config config) + { + writer.Skip(1, out int position); + writer.WriteString(value.ServerIPAddress); + writer.WriteByteReturn((byte)(writer.GetCurrentPosition() - position - 1), position); + writer.WriteUInt16(value.ServerVideoChannelTcpPort); + writer.WriteUInt16(value.ServerVideoChannelUdpPort); + writer.WriteByte(value.LogicalChannelNo); + writer.WriteByte(value.DataType); + writer.WriteByte(value.StreamType); + } + } +} diff --git a/src/JT808.Protocol.Extensions.JT1078/Formatters/JT808_0x9102_Formatter.cs b/src/JT808.Protocol.Extensions.JT1078/Formatters/JT808_0x9102_Formatter.cs new file mode 100644 index 0000000..74ace62 --- /dev/null +++ b/src/JT808.Protocol.Extensions.JT1078/Formatters/JT808_0x9102_Formatter.cs @@ -0,0 +1,31 @@ +using JT808.Protocol.Extensions.JT1078.MessageBody; +using JT808.Protocol.Formatters; +using JT808.Protocol.Interfaces; +using JT808.Protocol.MessagePack; +using System; +using System.Collections.Generic; +using System.Text; + +namespace JT808.Protocol.Extensions.JT1078.Formatters +{ + public class JT808_0x9102_Formatter : IJT808MessagePackFormatter + { + public JT808_0x9102 Deserialize(ref JT808MessagePackReader reader, IJT808Config config) + { + JT808_0x9102 jT808_0X9102 = new JT808_0x9102(); + jT808_0X9102.LogicalChannelNo = reader.ReadByte(); + jT808_0X9102.ControlCmd = reader.ReadByte(); + jT808_0X9102.CloseAVData = reader.ReadByte(); + jT808_0X9102.SwitchStreamType = reader.ReadByte(); + return jT808_0X9102; + } + + public void Serialize(ref JT808MessagePackWriter writer, JT808_0x9102 value, IJT808Config config) + { + writer.WriteByte(value.LogicalChannelNo); + writer.WriteByte(value.ControlCmd); + writer.WriteByte(value.CloseAVData); + writer.WriteByte(value.SwitchStreamType); + } + } +} diff --git a/src/JT808.Protocol.Extensions.JT1078/Formatters/JT808_0x9105_Formatter.cs b/src/JT808.Protocol.Extensions.JT1078/Formatters/JT808_0x9105_Formatter.cs new file mode 100644 index 0000000..755178b --- /dev/null +++ b/src/JT808.Protocol.Extensions.JT1078/Formatters/JT808_0x9105_Formatter.cs @@ -0,0 +1,27 @@ +using JT808.Protocol.Extensions.JT1078.MessageBody; +using JT808.Protocol.Formatters; +using JT808.Protocol.Interfaces; +using JT808.Protocol.MessagePack; +using System; +using System.Collections.Generic; +using System.Text; + +namespace JT808.Protocol.Extensions.JT1078.Formatters +{ + public class JT808_0x9105_Formatter : IJT808MessagePackFormatter + { + public JT808_0x9105 Deserialize(ref JT808MessagePackReader reader, IJT808Config config) + { + JT808_0x9105 jT808_0x9105 = new JT808_0x9105(); + jT808_0x9105.LogicChannelNo = reader.ReadByte(); + jT808_0x9105.DropRate = reader.ReadByte(); + return jT808_0x9105; + } + + public void Serialize(ref JT808MessagePackWriter writer, JT808_0x9105 value, IJT808Config config) + { + writer.WriteByte(value.LogicChannelNo); + writer.WriteByte(value.DropRate); + } + } +} diff --git a/src/JT808.Protocol.Extensions.JT1078/Formatters/JT808_0x9201_Formatter.cs b/src/JT808.Protocol.Extensions.JT1078/Formatters/JT808_0x9201_Formatter.cs new file mode 100644 index 0000000..70b6550 --- /dev/null +++ b/src/JT808.Protocol.Extensions.JT1078/Formatters/JT808_0x9201_Formatter.cs @@ -0,0 +1,50 @@ +using JT808.Protocol.Extensions.JT1078.MessageBody; +using JT808.Protocol.Formatters; +using JT808.Protocol.Interfaces; +using JT808.Protocol.MessagePack; +using System; +using System.Collections.Generic; +using System.Text; + +namespace JT808.Protocol.Extensions.JT1078.Formatters +{ + public class JT808_0x9201_Formatter : IJT808MessagePackFormatter + { + public JT808_0x9201 Deserialize(ref JT808MessagePackReader reader, IJT808Config config) + { + JT808_0x9201 jT808_0x9201 = new JT808_0x9201(); + jT808_0x9201.ServerIpLength = reader.ReadByte(); + jT808_0x9201.ServerIp = reader.ReadString(jT808_0x9201.ServerIpLength); + jT808_0x9201.TcpPort = reader.ReadUInt16(); + jT808_0x9201.UdpPort = reader.ReadUInt16(); + jT808_0x9201.LogicChannelNo = reader.ReadByte(); + jT808_0x9201.AVItemType = reader.ReadByte(); + jT808_0x9201.StreamType = reader.ReadByte(); + jT808_0x9201.MemType = reader.ReadByte(); + jT808_0x9201.PlayBackWay = reader.ReadByte(); + jT808_0x9201.FastForwardOrFastRewindMultiples1 = reader.ReadByte(); + jT808_0x9201.FastForwardOrFastRewindMultiples2 = reader.ReadByte(); + jT808_0x9201.BeginTime = reader.ReadDateTime6(); + jT808_0x9201.EndTime = reader.ReadDateTime6(); + return jT808_0x9201; + } + + public void Serialize(ref JT808MessagePackWriter writer, JT808_0x9201 value, IJT808Config config) + { + writer.Skip(1,out int position); + writer.WriteString(value.ServerIp); + writer.WriteByteReturn((byte)(writer.GetCurrentPosition() - position - 1), position);//计算完字符串后,回写字符串长度 + writer.WriteUInt16(value.TcpPort); + writer.WriteUInt16(value.UdpPort); + writer.WriteByte(value.LogicChannelNo); + writer.WriteByte(value.AVItemType); + writer.WriteByte(value.StreamType); + writer.WriteByte(value.MemType); + writer.WriteByte(value.PlayBackWay); + writer.WriteByte(value.FastForwardOrFastRewindMultiples1); + writer.WriteByte(value.FastForwardOrFastRewindMultiples2); + writer.WriteDateTime6(value.BeginTime); + writer.WriteDateTime6(value.EndTime); + } + } +} diff --git a/src/JT808.Protocol.Extensions.JT1078/Formatters/JT808_0x9202_Formatter.cs b/src/JT808.Protocol.Extensions.JT1078/Formatters/JT808_0x9202_Formatter.cs new file mode 100644 index 0000000..ae42bb7 --- /dev/null +++ b/src/JT808.Protocol.Extensions.JT1078/Formatters/JT808_0x9202_Formatter.cs @@ -0,0 +1,31 @@ +using JT808.Protocol.Extensions.JT1078.MessageBody; +using JT808.Protocol.Formatters; +using JT808.Protocol.Interfaces; +using JT808.Protocol.MessagePack; +using System; +using System.Collections.Generic; +using System.Text; + +namespace JT808.Protocol.Extensions.JT1078.Formatters +{ + public class JT808_0x9202_Formatter : IJT808MessagePackFormatter + { + public JT808_0x9202 Deserialize(ref JT808MessagePackReader reader, IJT808Config config) + { + JT808_0x9202 jT808_0x9202 = new JT808_0x9202(); + jT808_0x9202.AVChannelNo = reader.ReadByte(); + jT808_0x9202.PlayBackControl = reader.ReadByte(); + jT808_0x9202.FastForwardOrFastRewindMultiples = reader.ReadByte(); + jT808_0x9202.DragPlaybackPosition = reader.ReadDateTime6(); + return jT808_0x9202; + } + + public void Serialize(ref JT808MessagePackWriter writer, JT808_0x9202 value, IJT808Config config) + { + writer.WriteByte(value.AVChannelNo); + writer.WriteByte(value.PlayBackControl); + writer.WriteByte(value.FastForwardOrFastRewindMultiples); + writer.WriteDateTime6(value.DragPlaybackPosition); + } + } +} diff --git a/src/JT808.Protocol.Extensions.JT1078/Formatters/JT808_0x9205_Formatter.cs b/src/JT808.Protocol.Extensions.JT1078/Formatters/JT808_0x9205_Formatter.cs new file mode 100644 index 0000000..aafd189 --- /dev/null +++ b/src/JT808.Protocol.Extensions.JT1078/Formatters/JT808_0x9205_Formatter.cs @@ -0,0 +1,37 @@ +using JT808.Protocol.Extensions.JT1078.MessageBody; +using JT808.Protocol.Formatters; +using JT808.Protocol.Interfaces; +using JT808.Protocol.MessagePack; +using System; +using System.Collections.Generic; +using System.Text; + +namespace JT808.Protocol.Extensions.JT1078.Formatters +{ + public class JT808_0x9205_Formatter : IJT808MessagePackFormatter + { + public JT808_0x9205 Deserialize(ref JT808MessagePackReader reader, IJT808Config config) + { + JT808_0x9205 jT808_0x9205 = new JT808_0x9205(); + jT808_0x9205.LogicChannelNo = reader.ReadByte(); + jT808_0x9205.BeginTime = reader.ReadDateTime6(); + jT808_0x9205.EndTime = reader.ReadDateTime6(); + jT808_0x9205.AlarmFlag = reader.ReadUInt32(); + jT808_0x9205.AVResourceType = reader.ReadByte(); + jT808_0x9205.StreamType = reader.ReadByte(); + jT808_0x9205.MemoryType = reader.ReadByte(); + return jT808_0x9205; + } + + public void Serialize(ref JT808MessagePackWriter writer, JT808_0x9205 value, IJT808Config config) + { + writer.WriteByte(value.LogicChannelNo); + writer.WriteDateTime6(value.BeginTime); + writer.WriteDateTime6(value.EndTime); + writer.WriteUInt32(value.AlarmFlag); + writer.WriteByte(value.AVResourceType); + writer.WriteByte(value.StreamType); + writer.WriteByte(value.MemoryType); + } + } +} diff --git a/src/JT808.Protocol.Extensions.JT1078/Formatters/JT808_0x9206_Formatter.cs b/src/JT808.Protocol.Extensions.JT1078/Formatters/JT808_0x9206_Formatter.cs new file mode 100644 index 0000000..9859aa4 --- /dev/null +++ b/src/JT808.Protocol.Extensions.JT1078/Formatters/JT808_0x9206_Formatter.cs @@ -0,0 +1,61 @@ +using JT808.Protocol.Extensions.JT1078.MessageBody; +using JT808.Protocol.Formatters; +using JT808.Protocol.Interfaces; +using JT808.Protocol.MessagePack; +using System; +using System.Collections.Generic; +using System.Text; + +namespace JT808.Protocol.Extensions.JT1078.Formatters +{ + public class JT808_0x9206_Formatter : IJT808MessagePackFormatter + { + public JT808_0x9206 Deserialize(ref JT808MessagePackReader reader, IJT808Config config) + { + JT808_0x9206 jT808_0x9206 = new JT808_0x9206(); + jT808_0x9206.ServerIpLength = reader.ReadByte(); + jT808_0x9206.ServerIp = reader.ReadString(jT808_0x9206.ServerIpLength); + jT808_0x9206.Port = reader.ReadUInt16(); + jT808_0x9206.UserNameLength = reader.ReadByte(); + jT808_0x9206.UserName = reader.ReadString(jT808_0x9206.UserNameLength); + jT808_0x9206.PasswordLength = reader.ReadByte(); + jT808_0x9206.Password = reader.ReadString(jT808_0x9206.PasswordLength); + jT808_0x9206.FileUploadPathLength = reader.ReadByte(); + jT808_0x9206.FileUploadPath = reader.ReadString(jT808_0x9206.FileUploadPathLength); + jT808_0x9206.LogicChannelNo = reader.ReadByte(); + jT808_0x9206.BeginTime = reader.ReadDateTime6(); + jT808_0x9206.EndTime = reader.ReadDateTime6(); + jT808_0x9206.AlarmFlag = reader.ReadUInt32(); + jT808_0x9206.AVResourceType = reader.ReadByte(); + jT808_0x9206.StreamType = reader.ReadByte(); + jT808_0x9206.MemoryPositon = reader.ReadByte(); + jT808_0x9206.TaskExcuteCondition = reader.ReadByte(); + return jT808_0x9206; + } + + public void Serialize(ref JT808MessagePackWriter writer, JT808_0x9206 value, IJT808Config config) + { + writer.Skip(1, out int serverIpLengthposition); + writer.WriteString(value.ServerIp); + writer.WriteByteReturn((byte)(writer.GetCurrentPosition() - serverIpLengthposition - 1), serverIpLengthposition); + writer.WriteUInt16(value.Port); + writer.Skip(1, out int userNameLengthposition); + writer.WriteString(value.UserName); + writer.WriteByteReturn((byte)(writer.GetCurrentPosition() - userNameLengthposition - 1), userNameLengthposition); + writer.Skip(1, out int passwordLengthLengthposition); + writer.WriteString(value.Password); + writer.WriteByteReturn((byte)(writer.GetCurrentPosition() - passwordLengthLengthposition - 1), passwordLengthLengthposition); + writer.Skip(1, out int fileUploadPathLengthLengthposition); + writer.WriteString(value.FileUploadPath); + writer.WriteByteReturn((byte)(writer.GetCurrentPosition() - fileUploadPathLengthLengthposition - 1), fileUploadPathLengthLengthposition); + writer.WriteByte(value.LogicChannelNo); + writer.WriteDateTime6(value.BeginTime); + writer.WriteDateTime6(value.EndTime); + writer.WriteUInt32(value.AlarmFlag); + writer.WriteByte(value.AVResourceType); + writer.WriteByte(value.StreamType); + writer.WriteByte(value.MemoryPositon); + writer.WriteByte(value.TaskExcuteCondition); + } + } +} diff --git a/src/JT808.Protocol.Extensions.JT1078/Formatters/JT808_0x9207_Formatter.cs b/src/JT808.Protocol.Extensions.JT1078/Formatters/JT808_0x9207_Formatter.cs new file mode 100644 index 0000000..de43bea --- /dev/null +++ b/src/JT808.Protocol.Extensions.JT1078/Formatters/JT808_0x9207_Formatter.cs @@ -0,0 +1,27 @@ +using JT808.Protocol.Extensions.JT1078.MessageBody; +using JT808.Protocol.Formatters; +using JT808.Protocol.Interfaces; +using JT808.Protocol.MessagePack; +using System; +using System.Collections.Generic; +using System.Text; + +namespace JT808.Protocol.Extensions.JT1078.Formatters +{ + public class JT808_0x9207_Formatter : IJT808MessagePackFormatter + { + public JT808_0x9207 Deserialize(ref JT808MessagePackReader reader, IJT808Config config) + { + JT808_0x9207 jT808_0x9207 = new JT808_0x9207(); + jT808_0x9207.MgsNum = reader.ReadUInt16(); + jT808_0x9207.UploadControl = reader.ReadByte(); + return jT808_0x9207; + } + + public void Serialize(ref JT808MessagePackWriter writer, JT808_0x9207 value, IJT808Config config) + { + writer.WriteUInt16(value.MgsNum); + writer.WriteByte(value.UploadControl); + } + } +} diff --git a/src/JT808.Protocol.Extensions.JT1078/Formatters/JT808_0x9301_Formatter.cs b/src/JT808.Protocol.Extensions.JT1078/Formatters/JT808_0x9301_Formatter.cs new file mode 100644 index 0000000..9a68ce3 --- /dev/null +++ b/src/JT808.Protocol.Extensions.JT1078/Formatters/JT808_0x9301_Formatter.cs @@ -0,0 +1,29 @@ +using JT808.Protocol.Extensions.JT1078.MessageBody; +using JT808.Protocol.Formatters; +using JT808.Protocol.Interfaces; +using JT808.Protocol.MessagePack; +using System; +using System.Collections.Generic; +using System.Text; + +namespace JT808.Protocol.Extensions.JT1078.Formatters +{ + public class JT808_0x9301_Formatter : IJT808MessagePackFormatter + { + public JT808_0x9301 Deserialize(ref JT808MessagePackReader reader, IJT808Config config) + { + JT808_0x9301 jT808_0x9301 = new JT808_0x9301(); + jT808_0x9301.LogicChannelNo = reader.ReadByte(); + jT808_0x9301.Direction = reader.ReadByte(); + jT808_0x9301.Speed = reader.ReadByte(); + return jT808_0x9301; + } + + public void Serialize(ref JT808MessagePackWriter writer, JT808_0x9301 value, IJT808Config config) + { + writer.WriteByte(value.LogicChannelNo); + writer.WriteByte(value.Direction); + writer.WriteByte(value.Speed); + } + } +} diff --git a/src/JT808.Protocol.Extensions.JT1078/Formatters/JT808_0x9302_Formatter.cs b/src/JT808.Protocol.Extensions.JT1078/Formatters/JT808_0x9302_Formatter.cs new file mode 100644 index 0000000..3fc1c3d --- /dev/null +++ b/src/JT808.Protocol.Extensions.JT1078/Formatters/JT808_0x9302_Formatter.cs @@ -0,0 +1,27 @@ +using JT808.Protocol.Extensions.JT1078.MessageBody; +using JT808.Protocol.Formatters; +using JT808.Protocol.Interfaces; +using JT808.Protocol.MessagePack; +using System; +using System.Collections.Generic; +using System.Text; + +namespace JT808.Protocol.Extensions.JT1078.Formatters +{ + public class JT808_0x9302_Formatter : IJT808MessagePackFormatter + { + public JT808_0x9302 Deserialize(ref JT808MessagePackReader reader, IJT808Config config) + { + JT808_0x9302 jT808_0x9302 = new JT808_0x9302(); + jT808_0x9302.LogicChannelNo = reader.ReadByte(); + jT808_0x9302.FocusAdjustmentDirection = reader.ReadByte(); + return jT808_0x9302; + } + + public void Serialize(ref JT808MessagePackWriter writer, JT808_0x9302 value, IJT808Config config) + { + writer.WriteByte(value.LogicChannelNo); + writer.WriteByte(value.FocusAdjustmentDirection); + } + } +} \ No newline at end of file diff --git a/src/JT808.Protocol.Extensions.JT1078/Formatters/JT808_0x9303_Formatter.cs b/src/JT808.Protocol.Extensions.JT1078/Formatters/JT808_0x9303_Formatter.cs new file mode 100644 index 0000000..40b5062 --- /dev/null +++ b/src/JT808.Protocol.Extensions.JT1078/Formatters/JT808_0x9303_Formatter.cs @@ -0,0 +1,27 @@ +using JT808.Protocol.Extensions.JT1078.MessageBody; +using JT808.Protocol.Formatters; +using JT808.Protocol.Interfaces; +using JT808.Protocol.MessagePack; +using System; +using System.Collections.Generic; +using System.Text; + +namespace JT808.Protocol.Extensions.JT1078.Formatters +{ + public class JT808_0x9303_Formatter : IJT808MessagePackFormatter + { + public JT808_0x9303 Deserialize(ref JT808MessagePackReader reader, IJT808Config config) + { + JT808_0x9303 jT808_0x9303 = new JT808_0x9303(); + jT808_0x9303.LogicChannelNo = reader.ReadByte(); + jT808_0x9303.IrisAdjustment = reader.ReadByte(); + return jT808_0x9303; + } + + public void Serialize(ref JT808MessagePackWriter writer, JT808_0x9303 value, IJT808Config config) + { + writer.WriteByte(value.LogicChannelNo); + writer.WriteByte(value.IrisAdjustment); + } + } +} \ No newline at end of file diff --git a/src/JT808.Protocol.Extensions.JT1078/Formatters/JT808_0x9304_Formatter.cs b/src/JT808.Protocol.Extensions.JT1078/Formatters/JT808_0x9304_Formatter.cs new file mode 100644 index 0000000..95af20d --- /dev/null +++ b/src/JT808.Protocol.Extensions.JT1078/Formatters/JT808_0x9304_Formatter.cs @@ -0,0 +1,27 @@ +using JT808.Protocol.Extensions.JT1078.MessageBody; +using JT808.Protocol.Formatters; +using JT808.Protocol.Interfaces; +using JT808.Protocol.MessagePack; +using System; +using System.Collections.Generic; +using System.Text; + +namespace JT808.Protocol.Extensions.JT1078.Formatters +{ + public class JT808_0x9304_Formatter : IJT808MessagePackFormatter + { + public JT808_0x9304 Deserialize(ref JT808MessagePackReader reader, IJT808Config config) + { + JT808_0x9304 jT808_0x9304 = new JT808_0x9304(); + jT808_0x9304.LogicChannelNo = reader.ReadByte(); + jT808_0x9304.StartOrStop = reader.ReadByte(); + return jT808_0x9304; + } + + public void Serialize(ref JT808MessagePackWriter writer, JT808_0x9304 value, IJT808Config config) + { + writer.WriteByte(value.LogicChannelNo); + writer.WriteByte(value.StartOrStop); + } + } +} \ No newline at end of file diff --git a/src/JT808.Protocol.Extensions.JT1078/Formatters/JT808_0x9305_Formatter.cs b/src/JT808.Protocol.Extensions.JT1078/Formatters/JT808_0x9305_Formatter.cs new file mode 100644 index 0000000..0786b17 --- /dev/null +++ b/src/JT808.Protocol.Extensions.JT1078/Formatters/JT808_0x9305_Formatter.cs @@ -0,0 +1,27 @@ +using JT808.Protocol.Extensions.JT1078.MessageBody; +using JT808.Protocol.Formatters; +using JT808.Protocol.Interfaces; +using JT808.Protocol.MessagePack; +using System; +using System.Collections.Generic; +using System.Text; + +namespace JT808.Protocol.Extensions.JT1078.Formatters +{ + public class JT808_0x9305_Formatter : IJT808MessagePackFormatter + { + public JT808_0x9305 Deserialize(ref JT808MessagePackReader reader, IJT808Config config) + { + JT808_0x9305 jT808_0x9305 = new JT808_0x9305(); + jT808_0x9305.LogicChannelNo = reader.ReadByte(); + jT808_0x9305.StartOrStop = reader.ReadByte(); + return jT808_0x9305; + } + + public void Serialize(ref JT808MessagePackWriter writer, JT808_0x9305 value, IJT808Config config) + { + writer.WriteByte(value.LogicChannelNo); + writer.WriteByte(value.StartOrStop); + } + } +} \ No newline at end of file diff --git a/src/JT808.Protocol.Extensions.JT1078/Formatters/JT808_0x9306_Formatter.cs b/src/JT808.Protocol.Extensions.JT1078/Formatters/JT808_0x9306_Formatter.cs new file mode 100644 index 0000000..7eb674c --- /dev/null +++ b/src/JT808.Protocol.Extensions.JT1078/Formatters/JT808_0x9306_Formatter.cs @@ -0,0 +1,27 @@ +using JT808.Protocol.Extensions.JT1078.MessageBody; +using JT808.Protocol.Formatters; +using JT808.Protocol.Interfaces; +using JT808.Protocol.MessagePack; +using System; +using System.Collections.Generic; +using System.Text; + +namespace JT808.Protocol.Extensions.JT1078.Formatters +{ + public class JT808_0x9306_Formatter : IJT808MessagePackFormatter + { + public JT808_0x9306 Deserialize(ref JT808MessagePackReader reader, IJT808Config config) + { + JT808_0x9306 jT808_0x9306 = new JT808_0x9306(); + jT808_0x9306.LogicChannelNo = reader.ReadByte(); + jT808_0x9306.ChangeMultipleControl = reader.ReadByte(); + return jT808_0x9306; + } + + public void Serialize(ref JT808MessagePackWriter writer, JT808_0x9306 value, IJT808Config config) + { + writer.WriteByte(value.LogicChannelNo); + writer.WriteByte(value.ChangeMultipleControl); + } + } +} \ No newline at end of file diff --git a/src/JT808.Protocol.Extensions.JT1078/JT808.Protocol.Extensions.JT1078.csproj b/src/JT808.Protocol.Extensions.JT1078/JT808.Protocol.Extensions.JT1078.csproj new file mode 100644 index 0000000..1afa490 --- /dev/null +++ b/src/JT808.Protocol.Extensions.JT1078/JT808.Protocol.Extensions.JT1078.csproj @@ -0,0 +1,34 @@ + + + + netstandard2.0 + 7.3 + Copyright 2019. + SmallChi(Koike) + JT808.Protocol.Extensions.JT1078 + JT808.Protocol.Extensions.JT1078 + 基于JT808协议、GB808协议扩展的视频消息协议 + 基于JT808协议、GB808协议扩展的视频消息协议 + true + https://github.com/SmallChi/JT1078 + https://github.com/SmallChi/JT1078 + https://github.com/SmallChi/JT1078/blob/master/LICENSE + https://github.com/SmallChi/JT1078/blob/master/LICENSE + false + 1.0.0 + LICENSE + + + + + + + + + + True + + + + + diff --git a/src/JT808.Protocol.Extensions.JT1078/MessageBody/JT808_0x0200_0x14.cs b/src/JT808.Protocol.Extensions.JT1078/MessageBody/JT808_0x0200_0x14.cs new file mode 100644 index 0000000..4f58a6c --- /dev/null +++ b/src/JT808.Protocol.Extensions.JT1078/MessageBody/JT808_0x0200_0x14.cs @@ -0,0 +1,24 @@ +using JT808.Protocol.Attributes; +using JT808.Protocol.Extensions.JT1078.Formatters; +using JT808.Protocol.MessageBody; + +namespace JT808.Protocol.Extensions.JT1078.MessageBody +{ + /// + /// 视频相关报警 + /// 0x0200_0x14 + /// + [JT808Formatter(typeof(JT808_0x0200_0x14_Formatter))] + public class JT808_0x0200_0x14 : JT808_0x0200_CustomBodyBase + { + public override byte AttachInfoId { get; set; } = 0x14; + /// + /// 数据 长度 + /// + public override byte AttachInfoLength { get; set; } = 4; + /// + /// 视频相关报警 + /// + public uint VideoRelateAlarm { get; set; } + } +} diff --git a/src/JT808.Protocol.Extensions.JT1078/MessageBody/JT808_0x0200_0x15.cs b/src/JT808.Protocol.Extensions.JT1078/MessageBody/JT808_0x0200_0x15.cs new file mode 100644 index 0000000..4f08631 --- /dev/null +++ b/src/JT808.Protocol.Extensions.JT1078/MessageBody/JT808_0x0200_0x15.cs @@ -0,0 +1,24 @@ +using JT808.Protocol.Attributes; +using JT808.Protocol.Extensions.JT1078.Formatters; +using JT808.Protocol.MessageBody; + +namespace JT808.Protocol.Extensions.JT1078.MessageBody +{ + /// + /// 视频信号丢失报警状态 + /// 0x0200_0x15 + /// + [JT808Formatter(typeof(JT808_0x0200_0x15_Formatter))] + public class JT808_0x0200_0x15 : JT808_0x0200_CustomBodyBase + { + public override byte AttachInfoId { get; set; } = 0x15; + /// + /// 数据 长度 + /// + public override byte AttachInfoLength { get; set; } = 4; + /// + /// 视频信号丢失报警状态 + /// + public uint VideoSignalLoseAlarmStatus { get; set; } + } +} diff --git a/src/JT808.Protocol.Extensions.JT1078/MessageBody/JT808_0x0200_0x16.cs b/src/JT808.Protocol.Extensions.JT1078/MessageBody/JT808_0x0200_0x16.cs new file mode 100644 index 0000000..01c2600 --- /dev/null +++ b/src/JT808.Protocol.Extensions.JT1078/MessageBody/JT808_0x0200_0x16.cs @@ -0,0 +1,24 @@ +using JT808.Protocol.Attributes; +using JT808.Protocol.Extensions.JT1078.Formatters; +using JT808.Protocol.MessageBody; + +namespace JT808.Protocol.Extensions.JT1078.MessageBody +{ + /// + /// 视频信号遮挡报警状态 + /// 0x0200_0x16 + /// + [JT808Formatter(typeof(JT808_0x0200_0x16_Formatter))] + public class JT808_0x0200_0x16 : JT808_0x0200_CustomBodyBase + { + public override byte AttachInfoId { get; set; } = 0x16; + /// + /// 数据 长度 + /// + public override byte AttachInfoLength { get; set; } = 4; + /// + /// 视频信号遮挡报警状态 + /// + public uint VideoSignalOcclusionAlarmStatus { get; set; } + } +} diff --git a/src/JT808.Protocol.Extensions.JT1078/MessageBody/JT808_0x0200_0x17.cs b/src/JT808.Protocol.Extensions.JT1078/MessageBody/JT808_0x0200_0x17.cs new file mode 100644 index 0000000..1229569 --- /dev/null +++ b/src/JT808.Protocol.Extensions.JT1078/MessageBody/JT808_0x0200_0x17.cs @@ -0,0 +1,24 @@ +using JT808.Protocol.Attributes; +using JT808.Protocol.Extensions.JT1078.Formatters; +using JT808.Protocol.MessageBody; + +namespace JT808.Protocol.Extensions.JT1078.MessageBody +{ + /// + /// 存储器故障报警状态 + /// 0x0200_0x17 + /// + [JT808Formatter(typeof(JT808_0x0200_0x17_Formatter))] + public class JT808_0x0200_0x17 : JT808_0x0200_CustomBodyBase + { + public override byte AttachInfoId { get; set; } = 0x17; + /// + /// 数据 长度 + /// + public override byte AttachInfoLength { get; set; } = 2; + /// + /// 存储器故障报警状态 + /// + public ushort StorageFaultAlarmStatus{ get; set; } + } +} diff --git a/src/JT808.Protocol.Extensions.JT1078/MessageBody/JT808_0x0200_0x18.cs b/src/JT808.Protocol.Extensions.JT1078/MessageBody/JT808_0x0200_0x18.cs new file mode 100644 index 0000000..8693257 --- /dev/null +++ b/src/JT808.Protocol.Extensions.JT1078/MessageBody/JT808_0x0200_0x18.cs @@ -0,0 +1,24 @@ +using JT808.Protocol.Attributes; +using JT808.Protocol.Extensions.JT1078.Formatters; +using JT808.Protocol.MessageBody; + +namespace JT808.Protocol.Extensions.JT1078.MessageBody +{ + /// + /// 异常驾驶行为报警详细描述 + /// 0x0200_0x18 + /// + [JT808Formatter(typeof(JT808_0x0200_0x18_Formatter))] + public class JT808_0x0200_0x18 : JT808_0x0200_CustomBodyBase + { + public override byte AttachInfoId { get; set; } = 0x18; + /// + /// 数据 长度 + /// + public override byte AttachInfoLength { get; set; } = 2; + /// + /// 异常驾驶行为报警详细描述 + /// + public ushort AbnormalDrivingBehaviorAlarmInfo { get; set; } + } +} diff --git a/src/JT808.Protocol.Extensions.JT1078/MessageBody/JT808_0x1003.cs b/src/JT808.Protocol.Extensions.JT1078/MessageBody/JT808_0x1003.cs new file mode 100644 index 0000000..6179d83 --- /dev/null +++ b/src/JT808.Protocol.Extensions.JT1078/MessageBody/JT808_0x1003.cs @@ -0,0 +1,52 @@ +using JT808.Protocol.Attributes; +using JT808.Protocol.Extensions.JT1078.Formatters; +using System; +using System.Collections.Generic; +using System.Text; + +namespace JT808.Protocol.Extensions.JT1078.MessageBody +{ + /// + /// 终端上传音视频属性 + /// + [JT808Formatter(typeof(JT808_0x1003_Formatter))] + public class JT808_0x1003 : JT808Bodies + { + /// + /// 输入音频编码方式 + /// + public byte EnterAudioEncoding { get; set; } + /// + /// 输入音频声道数 + /// + public byte EnterAudioChannelsNumber { get; set; } + /// + /// 输入音频采样率 + /// + public byte EnterAudioSampleRate { get; set; } + /// + /// 输入音频采样位数 + /// + public byte EnterAudioSampleDigits { get; set; } + /// + /// 音频帧长度 + /// + public ushort AudioFrameLength { get; set; } + /// + /// 是否支持音频输出 + /// + public byte IsSupportedAudioOutput { get; set; } + /// + /// 视频编码方式 + /// + public byte VideoEncoding { get; set; } + /// + /// 终端支持的最大音频物理通道数量 + /// + public byte TerminalSupportedMaxNumberOfAudioPhysicalChannels{ get; set; } + /// + /// 终端支持的最大视频物理通道数量 + /// + public byte TerminalSupportedMaxNumberOfVideoPhysicalChannels { get; set; } + } +} diff --git a/src/JT808.Protocol.Extensions.JT1078/MessageBody/JT808_0x1005.cs b/src/JT808.Protocol.Extensions.JT1078/MessageBody/JT808_0x1005.cs new file mode 100644 index 0000000..c76712e --- /dev/null +++ b/src/JT808.Protocol.Extensions.JT1078/MessageBody/JT808_0x1005.cs @@ -0,0 +1,32 @@ +using JT808.Protocol.Attributes; +using JT808.Protocol.Extensions.JT1078.Formatters; +using System; +using System.Collections.Generic; +using System.Text; + +namespace JT808.Protocol.Extensions.JT1078.MessageBody +{ + /// + /// 终端上传乘客流量 + /// + [JT808Formatter(typeof(JT808_0x1005_Formatter))] + public class JT808_0x1005 : JT808Bodies + { + /// + /// 起始时间 + /// + public DateTime BeginTime { get; set; } + /// + /// 结束时间 + /// + public DateTime EndTime { get; set; } + /// + /// 上车人数 + /// + public ushort GettingOnNumber { get; set; } + /// + /// 下车人数 + /// + public ushort GettingOffNumber { get; set; } + } +} diff --git a/src/JT808.Protocol.Extensions.JT1078/MessageBody/JT808_0x1205.cs b/src/JT808.Protocol.Extensions.JT1078/MessageBody/JT808_0x1205.cs new file mode 100644 index 0000000..0b52577 --- /dev/null +++ b/src/JT808.Protocol.Extensions.JT1078/MessageBody/JT808_0x1205.cs @@ -0,0 +1,28 @@ +using JT808.Protocol.Attributes; +using JT808.Protocol.Extensions.JT1078.Formatters; +using System; +using System.Collections.Generic; +using System.Text; + +namespace JT808.Protocol.Extensions.JT1078.MessageBody +{ + /// + /// 终端上传音视频资源列表 + /// + [JT808Formatter(typeof(JT808_0x1205_Formatter))] + public class JT808_0x1205 : JT808Bodies + { + /// + /// 流水号 + /// + public ushort MsgNum { get; set; } + /// + /// 音视频资源总数 + /// + public uint AVResouceTotal{ get; set; } + /// + /// 音视频资源列表 + /// + public List AVResouces { get; set; } + } +} diff --git a/src/JT808.Protocol.Extensions.JT1078/MessageBody/JT808_0x1205_AVResouce.cs b/src/JT808.Protocol.Extensions.JT1078/MessageBody/JT808_0x1205_AVResouce.cs new file mode 100644 index 0000000..8abcb01 --- /dev/null +++ b/src/JT808.Protocol.Extensions.JT1078/MessageBody/JT808_0x1205_AVResouce.cs @@ -0,0 +1,48 @@ +using JT808.Protocol.Attributes; +using JT808.Protocol.Extensions.JT1078.Formatters; +using System; +using System.Collections.Generic; +using System.Text; + +namespace JT808.Protocol.Extensions.JT1078.MessageBody +{ + /// + /// 终端上传音视频资源列表 + /// + [JT808Formatter(typeof(JT808_0x1205_AVResouce_Formatter))] + public class JT808_0x1205_AVResouce + { + /// + /// 逻辑通道号 + /// + public byte LogicChannelNo { get; set; } + /// + /// 开始时间 + /// + public DateTime BeginTime { get; set; } + /// + /// 结束时间 + /// + public DateTime EndTime { get; set; } + /// + /// 报警标志 + /// + public uint AlarmFlag { get; set; } + /// + /// 音视频资源类型 + /// + public byte AVResourceType { get; set; } + /// + /// 码流类型 + /// + public byte StreamType { get; set; } + /// + /// 存储器类型 + /// + public byte MemoryType { get; set; } + /// + /// 文件大小 + /// + public uint FileSize { get; set; } + } +} diff --git a/src/JT808.Protocol.Extensions.JT1078/MessageBody/JT808_0x1206.cs b/src/JT808.Protocol.Extensions.JT1078/MessageBody/JT808_0x1206.cs new file mode 100644 index 0000000..b8f603a --- /dev/null +++ b/src/JT808.Protocol.Extensions.JT1078/MessageBody/JT808_0x1206.cs @@ -0,0 +1,24 @@ +using JT808.Protocol.Attributes; +using JT808.Protocol.Extensions.JT1078.Formatters; +using System; +using System.Collections.Generic; +using System.Text; + +namespace JT808.Protocol.Extensions.JT1078.MessageBody +{ + /// + /// 文件上传完成通知 + /// + [JT808Formatter(typeof(JT808_0x1206_Formatter))] + public class JT808_0x1206 : JT808Bodies + { + /// + /// 流水号 + /// + public ushort MsgNum { get; set; } + /// + /// 结果 + /// + public byte Result{ get; set; } + } +} diff --git a/src/JT808.Protocol.Extensions.JT1078/MessageBody/JT808_0x8103_0x0075.cs b/src/JT808.Protocol.Extensions.JT1078/MessageBody/JT808_0x8103_0x0075.cs new file mode 100644 index 0000000..e29c808 --- /dev/null +++ b/src/JT808.Protocol.Extensions.JT1078/MessageBody/JT808_0x8103_0x0075.cs @@ -0,0 +1,74 @@ +using JT808.Protocol.Attributes; +using JT808.Protocol.Extensions.JT1078.Formatters; +using JT808.Protocol.MessageBody; + +namespace JT808.Protocol.Extensions.JT1078.MessageBody +{ + /// + /// 音视频参数设置 + /// 0x8103_0x0075 + /// + [JT808Formatter(typeof(JT808_0x8103_0x0075_Formatter))] + public class JT808_0x8103_0x0075 : JT808_0x8103_CustomBodyBase + { + public override uint ParamId { get; set; } = 0x0075; + /// + /// 数据 长度 + /// + public override byte ParamLength { get; set; } = 21; + /// + /// 实时流编码模式 + /// + public byte RTS_EncodeMode { get; set; } + /// + /// 实时流分辨率 + /// + public byte RTS_Resolution { get; set; } + /// + /// 实时流关键帧间隔 + /// (范围1-1000)帧 + /// + public ushort RTS_KF_Interval { get; set; } + /// + /// 实时流目标帧率 + /// + public byte RTS_Target_FPS { get; set; } + /// + /// 实时流目标码率 + /// 单位未千位每秒(kbps) + /// + public uint RTS_Target_CodeRate { get; set; } + /// + /// 存储流编码模式 + /// + public byte StreamStore_EncodeMode { get; set; } + /// + /// 存储流分辨率 + /// + public byte StreamStore_Resolution { get; set; } + /// + /// 存储流关键帧间隔 + /// (范围1-1000)帧 + /// + public ushort StreamStore_KF_Interval { get; set; } + /// + /// 存储流目标帧率 + /// + public byte StreamStore_Target_FPS { get; set; } + /// + /// 存储流目标码率 + /// 单位未千位每秒(kbps) + /// + public uint StreamStore_Target_CodeRate { get; set; } + /// + ///OSD字幕叠加设置 + /// + public ushort OSD { get; set; } + /// + ///是否启用音频输出 + ///0:不启用 + ///1:启用 + /// + public byte AudioOutputEnabled { get; set; } + } +} diff --git a/src/JT808.Protocol.Extensions.JT1078/MessageBody/JT808_0x8103_0x0076.cs b/src/JT808.Protocol.Extensions.JT1078/MessageBody/JT808_0x8103_0x0076.cs new file mode 100644 index 0000000..01e6471 --- /dev/null +++ b/src/JT808.Protocol.Extensions.JT1078/MessageBody/JT808_0x8103_0x0076.cs @@ -0,0 +1,42 @@ +using JT808.Protocol.Attributes; +using JT808.Protocol.Extensions.JT1078.Formatters; +using JT808.Protocol.MessageBody; +using System.Collections.Generic; + +namespace JT808.Protocol.Extensions.JT1078.MessageBody +{ +#warning todo:继承非自定义类的时候,没有添加到相应的字典中 + /// + /// 音视频通道列表设置 + /// 0x8103_0x0076 + /// + [JT808Formatter(typeof(JT808_0x8103_0x0076_Formatter))] + public class JT808_0x8103_0x0076 : JT808_0x8103_CustomBodyBase + { + public override uint ParamId { get; set; } = 0x0076; + /// + /// 数据 长度 + /// + public override byte ParamLength { get; set; } + /// + /// 音视频通道总数 + /// l + /// + public byte AVChannelTotal { get; set; } + /// + /// 音频通道总数 + /// m + /// + public byte AudioChannelTotal { get; set; } + /// + /// 视频通道总数 + /// n + /// + public byte VudioChannelTotal { get; set; } + /// + /// 音视频通道对照表 + /// 4*(l+m+n) + /// + public List AVChannelRefTables { get; set; } + } +} diff --git a/src/JT808.Protocol.Extensions.JT1078/MessageBody/JT808_0x8103_0x0076_AVChannelRefTable.cs b/src/JT808.Protocol.Extensions.JT1078/MessageBody/JT808_0x8103_0x0076_AVChannelRefTable.cs new file mode 100644 index 0000000..dd0c5a6 --- /dev/null +++ b/src/JT808.Protocol.Extensions.JT1078/MessageBody/JT808_0x8103_0x0076_AVChannelRefTable.cs @@ -0,0 +1,31 @@ +using JT808.Protocol.Attributes; +using JT808.Protocol.Extensions.JT1078.Formatters; +using JT808.Protocol.MessageBody; + +namespace JT808.Protocol.Extensions.JT1078.MessageBody +{ + /// + /// 音视频通道列表设置 + /// 0x8103_0x0076_AVChannelRefTable + /// + [JT808Formatter(typeof(JT808_0x8103_0x0076_AVChannelRefTable_Formatter))] + public class JT808_0x8103_0x0076_AVChannelRefTable + { + /// + /// 物理通道号 + /// + public byte PhysicalChannelNo { get; set; } + /// + /// 逻辑通道号 + /// + public byte LogicChannelNo { get; set; } + /// + /// 通道类型 + /// + public byte ChannelType { get; set; } + /// + /// 是否链接云台 + /// + public byte IsConnectCloudPlat { get; set; } + } +} diff --git a/src/JT808.Protocol.Extensions.JT1078/MessageBody/JT808_0x8103_0x0077.cs b/src/JT808.Protocol.Extensions.JT1078/MessageBody/JT808_0x8103_0x0077.cs new file mode 100644 index 0000000..d1884f5 --- /dev/null +++ b/src/JT808.Protocol.Extensions.JT1078/MessageBody/JT808_0x8103_0x0077.cs @@ -0,0 +1,27 @@ +using JT808.Protocol.Attributes; +using JT808.Protocol.Extensions.JT1078.Formatters; +using JT808.Protocol.MessageBody; +using System.Collections.Generic; + +namespace JT808.Protocol.Extensions.JT1078.MessageBody +{ + /// + ///单独视频通道参数设置 + /// 0x8103_0x0077 + /// + [JT808Formatter(typeof(JT808_0x8103_0x0077_Formatter))] + public class JT808_0x8103_0x0077 : JT808_0x8103_CustomBodyBase + { + public override uint ParamId { get; set; } = 0x0077; + /// + /// 数据 长度 + /// + public override byte ParamLength { get; set; } + /// + /// 需单独设置视频参数的通道数量 用n表示 + /// + public byte NeedSetChannelTotal { get; set; } + + public List jT808_0X8103_0X0077_SignalChannels { get; set; } + } +} diff --git a/src/JT808.Protocol.Extensions.JT1078/MessageBody/JT808_0x8103_0x0077_SignalChannel.cs b/src/JT808.Protocol.Extensions.JT1078/MessageBody/JT808_0x8103_0x0077_SignalChannel.cs new file mode 100644 index 0000000..754e824 --- /dev/null +++ b/src/JT808.Protocol.Extensions.JT1078/MessageBody/JT808_0x8103_0x0077_SignalChannel.cs @@ -0,0 +1,65 @@ +using JT808.Protocol.Attributes; +using JT808.Protocol.Extensions.JT1078.Formatters; +using System; +using System.Collections.Generic; +using System.Text; + +namespace JT808.Protocol.Extensions.JT1078.MessageBody +{ + [JT808Formatter(typeof(JT808_0x8103_0x0077_SignalChannel_Formatter))] + public class JT808_0x8103_0x0077_SignalChannel + { + /// + /// 逻辑通道号 + /// + public byte LogicChannelNo { get; set; } + /// + /// 实时流编码模式 + /// + public byte RTS_EncodeMode { get; set; } + /// + /// 实时流分辨率 + /// + public byte RTS_Resolution { get; set; } + /// + /// 实时流关键帧间隔 + /// (范围1-1000)帧 + /// + public ushort RTS_KF_Interval { get; set; } + /// + /// 实时流目标帧率 + /// + public byte RTS_Target_FPS { get; set; } + /// + /// 实时流目标码率 + /// 单位未千位每秒(kbps) + /// + public uint RTS_Target_CodeRate { get; set; } + /// + /// 存储流编码模式 + /// + public byte StreamStore_EncodeMode { get; set; } + /// + /// 存储流分辨率 + /// + public byte StreamStore_Resolution { get; set; } + /// + /// 存储流关键帧间隔 + /// (范围1-1000)帧 + /// + public ushort StreamStore_KF_Interval { get; set; } + /// + /// 存储流目标帧率 + /// + public byte StreamStore_Target_FPS { get; set; } + /// + /// 存储流目标码率 + /// 单位未千位每秒(kbps) + /// + public uint StreamStore_Target_CodeRate { get; set; } + /// + ///OSD字幕叠加设置 + /// + public ushort OSD { get; set; } + } +} diff --git a/src/JT808.Protocol.Extensions.JT1078/MessageBody/JT808_0x8103_0x0079.cs b/src/JT808.Protocol.Extensions.JT1078/MessageBody/JT808_0x8103_0x0079.cs new file mode 100644 index 0000000..98aede9 --- /dev/null +++ b/src/JT808.Protocol.Extensions.JT1078/MessageBody/JT808_0x8103_0x0079.cs @@ -0,0 +1,34 @@ +using JT808.Protocol.Attributes; +using JT808.Protocol.Extensions.JT1078.Formatters; +using JT808.Protocol.MessageBody; +using System.Collections.Generic; + +namespace JT808.Protocol.Extensions.JT1078.MessageBody +{ + /// + /// 特殊报警录像参数设置 + /// 0x8103_0x0079 + /// + [JT808Formatter(typeof(JT808_0x8103_0x0079_Formatter))] + public class JT808_0x8103_0x0079 : JT808_0x8103_CustomBodyBase + { + public override uint ParamId { get; set; } = 0x0079; + /// + /// 数据 长度 + /// + public override byte ParamLength { get; set; } = 3; + /// + /// 特殊报警录像存储阈值 + /// + public byte StorageThresholds { get; set; } + /// + /// 特殊报警录像持续时间 + /// + public byte Duration { get; set; } + /// + /// 特殊报警标识起始时间 + /// 分钟min + /// + public byte BeginMinute { get; set; } + } +} diff --git a/src/JT808.Protocol.Extensions.JT1078/MessageBody/JT808_0x8103_0x007A.cs b/src/JT808.Protocol.Extensions.JT1078/MessageBody/JT808_0x8103_0x007A.cs new file mode 100644 index 0000000..19faabf --- /dev/null +++ b/src/JT808.Protocol.Extensions.JT1078/MessageBody/JT808_0x8103_0x007A.cs @@ -0,0 +1,25 @@ +using JT808.Protocol.Attributes; +using JT808.Protocol.Extensions.JT1078.Formatters; +using JT808.Protocol.MessageBody; +using System.Collections.Generic; + +namespace JT808.Protocol.Extensions.JT1078.MessageBody +{ + /// + /// 视频相关报警屏蔽字 + /// 0x8103_0x007A + /// + [JT808Formatter(typeof(JT808_0x8103_0x007A_Formatter))] + public class JT808_0x8103_0x007A : JT808_0x8103_CustomBodyBase + { + public override uint ParamId { get; set; } = 0x007A; + /// + /// 数据 长度 + /// + public override byte ParamLength { get; set; } = 4; + /// + /// 视频相关屏蔽报警字 + /// + public uint AlarmShielding { get; set; } + } +} diff --git a/src/JT808.Protocol.Extensions.JT1078/MessageBody/JT808_0x8103_0x007B.cs b/src/JT808.Protocol.Extensions.JT1078/MessageBody/JT808_0x8103_0x007B.cs new file mode 100644 index 0000000..eeca542 --- /dev/null +++ b/src/JT808.Protocol.Extensions.JT1078/MessageBody/JT808_0x8103_0x007B.cs @@ -0,0 +1,29 @@ +using JT808.Protocol.Attributes; +using JT808.Protocol.Extensions.JT1078.Formatters; +using JT808.Protocol.MessageBody; +using System.Collections.Generic; + +namespace JT808.Protocol.Extensions.JT1078.MessageBody +{ + /// + /// 图像分析报警参数设置 + /// 0x8103_0x007B + /// + [JT808Formatter(typeof(JT808_0x8103_0x007B_Formatter))] + public class JT808_0x8103_0x007B : JT808_0x8103_CustomBodyBase + { + public override uint ParamId { get; set; } = 0x007B; + /// + /// 数据 长度 + /// + public override byte ParamLength { get; set; } = 2; + /// + /// 车辆核载人数 + /// + public byte NuclearLoadNumber { get; set; } + /// + /// 疲劳程度阈值 + /// + public byte FatigueThreshold { get; set; } + } +} diff --git a/src/JT808.Protocol.Extensions.JT1078/MessageBody/JT808_0x8103_0x007C.cs b/src/JT808.Protocol.Extensions.JT1078/MessageBody/JT808_0x8103_0x007C.cs new file mode 100644 index 0000000..f4c881d --- /dev/null +++ b/src/JT808.Protocol.Extensions.JT1078/MessageBody/JT808_0x8103_0x007C.cs @@ -0,0 +1,37 @@ +using JT808.Protocol.Attributes; +using JT808.Protocol.Extensions.JT1078.Formatters; +using JT808.Protocol.MessageBody; +using System.Collections.Generic; + +namespace JT808.Protocol.Extensions.JT1078.MessageBody +{ + /// + ///终端休眠模式唤醒设置 + /// 0x8103_0x007C + /// + [JT808Formatter(typeof(JT808_0x8103_0x007C_Formatter))] + public class JT808_0x8103_0x007C : JT808_0x8103_CustomBodyBase + { + public override uint ParamId { get; set; } = 0x007C; + /// + /// 数据 长度 + /// + public override byte ParamLength { get; set; } = 20; + /// + /// 休眠唤醒模式 + /// + public byte SleepWakeMode { get; set; } + /// + /// 唤醒条件类型 + /// + public byte WakeConditionType { get; set; } + /// + /// 定时唤醒日设置 + /// + public byte TimerWakeDaySet { get; set; } + /// + /// 日定时唤醒参数列表 + /// + public JT808_0x8103_0x007C_TimerWakeDayParamter jT808_0X8103_0X007C_TimerWakeDayParamter { get; set; } + } +} diff --git a/src/JT808.Protocol.Extensions.JT1078/MessageBody/JT808_0x8103_0x007C_TimerWakeDayParamter.cs b/src/JT808.Protocol.Extensions.JT1078/MessageBody/JT808_0x8103_0x007C_TimerWakeDayParamter.cs new file mode 100644 index 0000000..2737967 --- /dev/null +++ b/src/JT808.Protocol.Extensions.JT1078/MessageBody/JT808_0x8103_0x007C_TimerWakeDayParamter.cs @@ -0,0 +1,60 @@ +using JT808.Protocol.Attributes; +using JT808.Protocol.Extensions.JT1078.Formatters; +using JT808.Protocol.MessageBody; +using System.Collections.Generic; + +namespace JT808.Protocol.Extensions.JT1078.MessageBody +{ + /// + ///终端休眠模式唤醒设置 + /// 0x8103_0x007C + /// + [JT808Formatter(typeof(JT808_0x8103_0x007C_TimerWakeDayParamter_Formatter))] + public class JT808_0x8103_0x007C_TimerWakeDayParamter + { + /// + /// 定时唤醒启用标志 + /// + public byte TimerWakeEnableFlag { get; set; } + /// + /// 时间段1唤醒时间 + /// 2 + /// + public string TimePeriod1WakeTime { get; set; } + /// + /// 时间段1关闭时间 + /// 2 + /// + public string TimePeriod1CloseTime { get; set; } + /// + /// 时间段2唤醒时间 + /// 2 + /// + public string TimePeriod2WakeTime { get; set; } + /// + /// 时间段2关闭时间 + /// 2 + /// + public string TimePeriod2CloseTime { get; set; } + /// + /// 时间段3唤醒时间 + /// 2 + /// + public string TimePeriod3WakeTime { get; set; } + /// + /// 时间段3关闭时间 + /// 2 + /// + public string TimePeriod3CloseTime { get; set; } + /// + /// 时间段4唤醒时间 + /// 2 + /// + public string TimePeriod4WakeTime { get; set; } + /// + /// 时间段4关闭时间 + /// 2 + /// + public string TimePeriod4CloseTime { get; set; } + } +} diff --git a/src/JT808.Protocol.Extensions.JT1078/MessageBody/JT808_0x9003.cs b/src/JT808.Protocol.Extensions.JT1078/MessageBody/JT808_0x9003.cs new file mode 100644 index 0000000..1947714 --- /dev/null +++ b/src/JT808.Protocol.Extensions.JT1078/MessageBody/JT808_0x9003.cs @@ -0,0 +1,16 @@ +using JT808.Protocol.Attributes; +using JT808.Protocol.Extensions.JT1078.Formatters; +using System; +using System.Collections.Generic; +using System.Text; + +namespace JT808.Protocol.Extensions.JT1078.MessageBody +{ + /// + /// 查询终端音视频属性 + /// + public class JT808_0x9003:JT808Bodies + { + public override bool SkipSerialization { get; set; } = true; + } +} diff --git a/src/JT808.Protocol.Extensions.JT1078/MessageBody/JT808_0x9101.cs b/src/JT808.Protocol.Extensions.JT1078/MessageBody/JT808_0x9101.cs new file mode 100644 index 0000000..e632360 --- /dev/null +++ b/src/JT808.Protocol.Extensions.JT1078/MessageBody/JT808_0x9101.cs @@ -0,0 +1,52 @@ +using JT808.Protocol.Attributes; +using JT808.Protocol.Extensions.JT1078.Formatters; +using System; +using System.Collections.Generic; +using System.Text; + +namespace JT808.Protocol.Extensions.JT1078.MessageBody +{ + /// + /// 实时音视频传输请求 + /// + [JT808Formatter(typeof(JT808_0x9101_Formatter))] + public class JT808_0x9101:JT808Bodies + { + /// + /// 服务器IP地址长度 + /// + public byte ServerIPAddressLength { get; set; } + /// + /// 服务器IP地址 + /// + public string ServerIPAddress { get; set; } + /// + /// 服务器视频通道监听端口号(TCP) + /// + public ushort ServerVideoChannelTcpPort { get; set; } + /// + /// 服务器视频通道监听端口号(UDP) + /// + public ushort ServerVideoChannelUdpPort { get; set; } + /// + /// 逻辑通道号 + /// + public byte LogicalChannelNo { get; set; } + /// + /// 数据类型 + /// 0:音视频 + /// 1:视频 + /// 2:双向对讲 + /// 3:监听 + /// 4:中心广播 + /// 5:透传 + /// + public byte DataType { get; set; } + /// + /// 码流类型 + /// 0:主码流 + /// 1:子码流 + /// + public byte StreamType { get; set; } + } +} diff --git a/src/JT808.Protocol.Extensions.JT1078/MessageBody/JT808_0x9102.cs b/src/JT808.Protocol.Extensions.JT1078/MessageBody/JT808_0x9102.cs new file mode 100644 index 0000000..3d8718d --- /dev/null +++ b/src/JT808.Protocol.Extensions.JT1078/MessageBody/JT808_0x9102.cs @@ -0,0 +1,45 @@ +using JT808.Protocol.Attributes; +using JT808.Protocol.Extensions.JT1078.Formatters; +using System; +using System.Collections.Generic; +using System.Text; + +namespace JT808.Protocol.Extensions.JT1078.MessageBody +{ + /// + /// 音视频实时传输控制 + /// + [JT808Formatter(typeof(JT808_0x9102_Formatter))] + public class JT808_0x9102:JT808Bodies + { + /// + /// 逻辑通道号 + /// + public byte LogicalChannelNo { get; set; } + /// + /// 控制指令 + /// 平台可以通过该指令对设备的实时音视频进行控制: + /// 0:关闭音视频传输指令 + /// 1:切换码流(增加暂停和继续) + /// 2:暂停该通道所有流的发送 + /// 3:恢复暂停前流的发送,与暂停前的流类型一致 + /// 4:关闭双向对讲 + /// + public byte ControlCmd { get; set; } + /// + /// 关闭音视频类型 + /// 0:关闭该通道有关的音视频数据 + /// 1:只关闭该通道有关的音频,保留该通道有关的视频 + /// 2:只关闭该通道有关的视频,保留该通道有关的音频 + /// + public byte CloseAVData { get; set; } + /// + /// 切换码流类型 + /// 将之前申请的码流切换为新申请的码流,音频与切换前保持一致。 + /// 新申请的码流为: + /// 0:主码流 + /// 1:子码流 + /// + public byte SwitchStreamType { get; set; } + } +} diff --git a/src/JT808.Protocol.Extensions.JT1078/MessageBody/JT808_0x9105.cs b/src/JT808.Protocol.Extensions.JT1078/MessageBody/JT808_0x9105.cs new file mode 100644 index 0000000..fa14385 --- /dev/null +++ b/src/JT808.Protocol.Extensions.JT1078/MessageBody/JT808_0x9105.cs @@ -0,0 +1,24 @@ +using JT808.Protocol.Attributes; +using JT808.Protocol.Extensions.JT1078.Formatters; +using System; +using System.Collections.Generic; +using System.Text; + +namespace JT808.Protocol.Extensions.JT1078.MessageBody +{ + /// + /// 实时音视频传输状态通知 + /// + [JT808Formatter(typeof(JT808_0x9105_Formatter))] + public class JT808_0x9105 : JT808Bodies + { + /// + /// 逻辑通道号 + /// + public byte LogicChannelNo { get; set; } + /// + /// 丢包率 + /// + public byte DropRate { get; set; } + } +} diff --git a/src/JT808.Protocol.Extensions.JT1078/MessageBody/JT808_0x9201.cs b/src/JT808.Protocol.Extensions.JT1078/MessageBody/JT808_0x9201.cs new file mode 100644 index 0000000..1d48b02 --- /dev/null +++ b/src/JT808.Protocol.Extensions.JT1078/MessageBody/JT808_0x9201.cs @@ -0,0 +1,68 @@ +using JT808.Protocol.Attributes; +using JT808.Protocol.Extensions.JT1078.Formatters; +using System; +using System.Collections.Generic; +using System.Text; + +namespace JT808.Protocol.Extensions.JT1078.MessageBody +{ + /// + /// 平台下发远程录像回放请求 + /// + [JT808Formatter(typeof(JT808_0x9201_Formatter))] + public class JT808_0x9201 : JT808Bodies + { + /// + /// 服务器IP地址服务 + /// + public byte ServerIpLength { get; set; } + /// + /// 服务器IP地址 + /// + public string ServerIp { get; set; } + /// + /// 服务器音视频通道监听端口号TCP + /// + public ushort TcpPort { get; set; } + /// + /// 服务器音视频通道监听端口号UDP + /// + public ushort UdpPort { get; set; } + /// + /// 逻辑通道号 + /// + public byte LogicChannelNo { get; set; } + /// + /// 音视频类型 + /// + public byte AVItemType { get; set; } + /// + /// 码流类型 + /// + public byte StreamType { get; set; } + /// + /// 存储器类型 + /// + public byte MemType { get; set; } + /// + /// 回放方式 + /// + public byte PlayBackWay { get; set; } + /// + /// 快进或快退倍数 + /// + public byte FastForwardOrFastRewindMultiples1 { get; set; } + /// + /// 快进或快退倍数 + /// + public byte FastForwardOrFastRewindMultiples2 { get; set; } + /// + /// 起始时间 + /// + public DateTime BeginTime { get; set; } + /// + /// 结束时间 + /// + public DateTime EndTime { get; set; } + } +} diff --git a/src/JT808.Protocol.Extensions.JT1078/MessageBody/JT808_0x9202.cs b/src/JT808.Protocol.Extensions.JT1078/MessageBody/JT808_0x9202.cs new file mode 100644 index 0000000..40a3b60 --- /dev/null +++ b/src/JT808.Protocol.Extensions.JT1078/MessageBody/JT808_0x9202.cs @@ -0,0 +1,32 @@ +using JT808.Protocol.Attributes; +using JT808.Protocol.Extensions.JT1078.Formatters; +using System; +using System.Collections.Generic; +using System.Text; + +namespace JT808.Protocol.Extensions.JT1078.MessageBody +{ + /// + /// 平台下发远程录像回放控制 + /// + [JT808Formatter(typeof(JT808_0x9202_Formatter))] + public class JT808_0x9202 : JT808Bodies + { + /// + /// 音视频通道号 + /// + public byte AVChannelNo { get; set; } + /// + /// 回放控制 + /// + public byte PlayBackControl { get; set; } + /// + /// 快进或快退倍数 + /// + public byte FastForwardOrFastRewindMultiples { get; set; } + /// + /// 拖动回放位置 + /// + public DateTime DragPlaybackPosition { get; set; } + } +} diff --git a/src/JT808.Protocol.Extensions.JT1078/MessageBody/JT808_0x9205.cs b/src/JT808.Protocol.Extensions.JT1078/MessageBody/JT808_0x9205.cs new file mode 100644 index 0000000..6c241e9 --- /dev/null +++ b/src/JT808.Protocol.Extensions.JT1078/MessageBody/JT808_0x9205.cs @@ -0,0 +1,44 @@ +using JT808.Protocol.Attributes; +using JT808.Protocol.Extensions.JT1078.Formatters; +using System; +using System.Collections.Generic; +using System.Text; + +namespace JT808.Protocol.Extensions.JT1078.MessageBody +{ + /// + /// 查询资源列表 + /// + [JT808Formatter(typeof(JT808_0x9205_Formatter))] + public class JT808_0x9205 : JT808Bodies + { + /// + /// 逻辑通道号 + /// + public byte LogicChannelNo { get; set; } + /// + /// 开始时间 + /// + public DateTime BeginTime { get; set; } + /// + /// 结束时间 + /// + public DateTime EndTime { get; set; } + /// + /// 报警标志 + /// + public uint AlarmFlag { get; set; } + /// + /// 音视频资源类型 + /// + public byte AVResourceType { get; set; } + /// + /// 码流类型 + /// + public byte StreamType { get; set; } + /// + /// 存储器类型 + /// + public byte MemoryType { get; set; } + } +} diff --git a/src/JT808.Protocol.Extensions.JT1078/MessageBody/JT808_0x9206.cs b/src/JT808.Protocol.Extensions.JT1078/MessageBody/JT808_0x9206.cs new file mode 100644 index 0000000..dc9092d --- /dev/null +++ b/src/JT808.Protocol.Extensions.JT1078/MessageBody/JT808_0x9206.cs @@ -0,0 +1,84 @@ +using JT808.Protocol.Attributes; +using JT808.Protocol.Extensions.JT1078.Formatters; +using System; +using System.Collections.Generic; +using System.Text; + +namespace JT808.Protocol.Extensions.JT1078.MessageBody +{ + /// + /// 文件上传指令 + /// + [JT808Formatter(typeof(JT808_0x9206_Formatter))] + public class JT808_0x9206 : JT808Bodies + { + /// + /// 服务器IP地址服务 + /// + public byte ServerIpLength { get; set; } + /// + /// 服务器IP地址 + /// + public string ServerIp { get; set; } + /// + /// 服务器端口 + /// + public ushort Port { get; set; } + /// + /// 用户名长度 + /// + public byte UserNameLength { get; set; } + /// + /// 用户名 + /// + public string UserName { get; set; } + /// + /// 密码长度 + /// + public byte PasswordLength { get; set; } + /// + /// 密码 + /// + public string Password { get; set; } + /// + /// 文件上传路径长度 + /// + public byte FileUploadPathLength { get; set; } + /// + /// 文件上传路径 + /// + public string FileUploadPath { get; set; } + /// + /// 逻辑通道号 + /// + public byte LogicChannelNo { get; set; } + /// + /// 起始时间 + /// + public DateTime BeginTime { get; set; } + /// + /// 结束时间 + /// + public DateTime EndTime { get; set; } + /// + /// 报警标志 + /// + public uint AlarmFlag { get; set; } + /// + /// 音视频资源类型 + /// + public byte AVResourceType { get; set; } + /// + /// 码流类型 + /// + public byte StreamType { get; set; } + /// + /// 存储位置 + /// + public byte MemoryPositon { get; set; } + /// + /// 任务执行条件 + /// + public byte TaskExcuteCondition { get; set; } + } +} diff --git a/src/JT808.Protocol.Extensions.JT1078/MessageBody/JT808_0x9207.cs b/src/JT808.Protocol.Extensions.JT1078/MessageBody/JT808_0x9207.cs new file mode 100644 index 0000000..ef51707 --- /dev/null +++ b/src/JT808.Protocol.Extensions.JT1078/MessageBody/JT808_0x9207.cs @@ -0,0 +1,24 @@ +using JT808.Protocol.Attributes; +using JT808.Protocol.Extensions.JT1078.Formatters; +using System; +using System.Collections.Generic; +using System.Text; + +namespace JT808.Protocol.Extensions.JT1078.MessageBody +{ + /// + /// 文件上传控制 + /// + [JT808Formatter(typeof(JT808_0x9207_Formatter))] + public class JT808_0x9207 : JT808Bodies + { + /// + /// 流水号 + /// + public ushort MgsNum { get; set; } + /// + /// 上传控制 + /// + public byte UploadControl { get; set; } + } +} diff --git a/src/JT808.Protocol.Extensions.JT1078/MessageBody/JT808_0x9301.cs b/src/JT808.Protocol.Extensions.JT1078/MessageBody/JT808_0x9301.cs new file mode 100644 index 0000000..6ed163c --- /dev/null +++ b/src/JT808.Protocol.Extensions.JT1078/MessageBody/JT808_0x9301.cs @@ -0,0 +1,28 @@ +using JT808.Protocol.Attributes; +using JT808.Protocol.Extensions.JT1078.Formatters; +using System; +using System.Collections.Generic; +using System.Text; + +namespace JT808.Protocol.Extensions.JT1078.MessageBody +{ + /// + /// 云台旋转 + /// + [JT808Formatter(typeof(JT808_0x9301_Formatter))] + public class JT808_0x9301 : JT808Bodies + { + /// + /// 逻辑通道号 + /// + public byte LogicChannelNo { get; set; } + /// + /// 方向 + /// + public byte Direction { get; set; } + /// + /// 速度 + /// + public byte Speed { get; set; } + } +} diff --git a/src/JT808.Protocol.Extensions.JT1078/MessageBody/JT808_0x9302.cs b/src/JT808.Protocol.Extensions.JT1078/MessageBody/JT808_0x9302.cs new file mode 100644 index 0000000..5b6525d --- /dev/null +++ b/src/JT808.Protocol.Extensions.JT1078/MessageBody/JT808_0x9302.cs @@ -0,0 +1,24 @@ +using JT808.Protocol.Attributes; +using JT808.Protocol.Extensions.JT1078.Formatters; +using System; +using System.Collections.Generic; +using System.Text; + +namespace JT808.Protocol.Extensions.JT1078.MessageBody +{ + /// + /// 云台调整焦距控制 + /// + [JT808Formatter(typeof(JT808_0x9302_Formatter))] + public class JT808_0x9302 : JT808Bodies + { + /// + /// 逻辑通道号 + /// + public byte LogicChannelNo { get; set; } + /// + /// 焦距调整方向 + /// + public byte FocusAdjustmentDirection { get; set; } + } +} diff --git a/src/JT808.Protocol.Extensions.JT1078/MessageBody/JT808_0x9303.cs b/src/JT808.Protocol.Extensions.JT1078/MessageBody/JT808_0x9303.cs new file mode 100644 index 0000000..ffbbf53 --- /dev/null +++ b/src/JT808.Protocol.Extensions.JT1078/MessageBody/JT808_0x9303.cs @@ -0,0 +1,24 @@ +using JT808.Protocol.Attributes; +using JT808.Protocol.Extensions.JT1078.Formatters; +using System; +using System.Collections.Generic; +using System.Text; + +namespace JT808.Protocol.Extensions.JT1078.MessageBody +{ + /// + /// 云台调整光圈控制 + /// + [JT808Formatter(typeof(JT808_0x9303_Formatter))] + public class JT808_0x9303 : JT808Bodies + { + /// + /// 逻辑通道号 + /// + public byte LogicChannelNo { get; set; } + /// + /// 光圈调整方式 + /// + public byte IrisAdjustment { get; set; } + } +} diff --git a/src/JT808.Protocol.Extensions.JT1078/MessageBody/JT808_0x9304.cs b/src/JT808.Protocol.Extensions.JT1078/MessageBody/JT808_0x9304.cs new file mode 100644 index 0000000..7cc1d73 --- /dev/null +++ b/src/JT808.Protocol.Extensions.JT1078/MessageBody/JT808_0x9304.cs @@ -0,0 +1,24 @@ +using JT808.Protocol.Attributes; +using JT808.Protocol.Extensions.JT1078.Formatters; +using System; +using System.Collections.Generic; +using System.Text; + +namespace JT808.Protocol.Extensions.JT1078.MessageBody +{ + /// + /// 云台雨刷控制 + /// + [JT808Formatter(typeof(JT808_0x9304_Formatter))] + public class JT808_0x9304 : JT808Bodies + { + /// + /// 逻辑通道号 + /// + public byte LogicChannelNo { get; set; } + /// + /// 启停标识 + /// + public byte StartOrStop { get; set; } + } +} diff --git a/src/JT808.Protocol.Extensions.JT1078/MessageBody/JT808_0x9305.cs b/src/JT808.Protocol.Extensions.JT1078/MessageBody/JT808_0x9305.cs new file mode 100644 index 0000000..d6268a9 --- /dev/null +++ b/src/JT808.Protocol.Extensions.JT1078/MessageBody/JT808_0x9305.cs @@ -0,0 +1,24 @@ +using JT808.Protocol.Attributes; +using JT808.Protocol.Extensions.JT1078.Formatters; +using System; +using System.Collections.Generic; +using System.Text; + +namespace JT808.Protocol.Extensions.JT1078.MessageBody +{ + /// + /// 红外补光控制 + /// + [JT808Formatter(typeof(JT808_0x9305_Formatter))] + public class JT808_0x9305 : JT808Bodies + { + /// + /// 逻辑通道号 + /// + public byte LogicChannelNo { get; set; } + /// + /// 启停标识 + /// + public byte StartOrStop { get; set; } + } +} diff --git a/src/JT808.Protocol.Extensions.JT1078/MessageBody/JT808_0x9306.cs b/src/JT808.Protocol.Extensions.JT1078/MessageBody/JT808_0x9306.cs new file mode 100644 index 0000000..ec42fc9 --- /dev/null +++ b/src/JT808.Protocol.Extensions.JT1078/MessageBody/JT808_0x9306.cs @@ -0,0 +1,24 @@ +using JT808.Protocol.Attributes; +using JT808.Protocol.Extensions.JT1078.Formatters; +using System; +using System.Collections.Generic; +using System.Text; + +namespace JT808.Protocol.Extensions.JT1078.MessageBody +{ + /// + /// 云台变倍控制 + /// + [JT808Formatter(typeof(JT808_0x9306_Formatter))] + public class JT808_0x9306 : JT808Bodies + { + /// + /// 逻辑通道号 + /// + public byte LogicChannelNo { get; set; } + /// + /// 变倍控制 + /// + public byte ChangeMultipleControl { get; set; } + } +} diff --git a/src/JT808.Protocol.Extensions.WebApiTest/JT808.Protocol.Extensions.WebApiTest.csproj b/src/JT808.Protocol.Extensions.WebApiTest/JT808.Protocol.Extensions.WebApiTest.csproj new file mode 100644 index 0000000..57fa0a6 --- /dev/null +++ b/src/JT808.Protocol.Extensions.WebApiTest/JT808.Protocol.Extensions.WebApiTest.csproj @@ -0,0 +1,18 @@ + + + + Exe + netcoreapp2.2 + + + + + + + + + + + + + diff --git a/src/JT808.Protocol.Extensions.WebApiTest/Program.cs b/src/JT808.Protocol.Extensions.WebApiTest/Program.cs new file mode 100644 index 0000000..7d54844 --- /dev/null +++ b/src/JT808.Protocol.Extensions.WebApiTest/Program.cs @@ -0,0 +1,91 @@ +using JT808.DotNetty.Abstractions.Dtos; +using JT808.DotNetty.WebApiClientTool; +using JT808.Protocol.Extensions.JT1078; +using JT808.Protocol.Extensions.JT1078.MessageBody; +using JT808.Protocol.Interfaces; +using Microsoft.Extensions.DependencyInjection; +using Microsoft.Extensions.Logging; +using Newtonsoft.Json; +using System; +using WebApiClient.Extensions.DependencyInjection; + +namespace JT808.Protocol.Extensions.WebApiTest +{ + class Program + { + static void Main(string[] args) + { + IServiceCollection serviceDescriptors = new ServiceCollection(); + + serviceDescriptors + .AddJT808Configure() + .AddJT1078Configure(); + + serviceDescriptors.AddHttpApi().ConfigureHttpApiConfig((c, p) => + { + c.HttpHost = new Uri("http://localhost:12828/jt808api/"); + c.FormatOptions.DateTimeFormat = "yyyy-MM-dd HH:mm:ss.fff"; + c.LoggerFactory = p.GetRequiredService(); + }); + + IServiceProvider serviceProvider = serviceDescriptors.BuildServiceProvider(); + + IJT808Config config = serviceProvider.GetRequiredService(); + JT808Serializer JT808Serializer = config.GetSerializer(); + + string terminalPhoneNo = ""; + + JT808Package jT808Package = new JT808Package(); + JT808Header header = new JT808Header(); + header.MsgId = 0x9101; + header.MsgNum = 1; + header.TerminalPhoneNo = terminalPhoneNo; + jT808Package.Header = header; + JT808_0x9101 jT808_0X9101 = new JT808_0x9101(); + jT808_0X9101.ServerIPAddress = "127.0.0.1"; + jT808_0X9101.ServerVideoChannelTcpPort = 1888; + jT808_0X9101.ServerVideoChannelUdpPort = 0; + jT808_0X9101.LogicalChannelNo = 1; + jT808_0X9101.DataType = 1; + jT808_0X9101.StreamType = 1; + jT808Package.Bodies = jT808_0X9101; + + var data = JT808Serializer.Serialize(jT808Package); + Console.WriteLine(JsonConvert.SerializeObject(data.ToHexString())); + + IJT808DotNettyWebApi JT808DotNettyWebApiClient = serviceProvider.GetRequiredService(); + var result = JT808DotNettyWebApiClient.UnificationTcpSend(new JT808UnificationSendRequestDto + { + TerminalPhoneNo= terminalPhoneNo, + Data= data + }).GetAwaiter().GetResult(); + + Console.WriteLine(JsonConvert.SerializeObject(result)); + + //JT808Package jT808Package1 = new JT808Package(); + //JT808Header header1 = new JT808Header(); + //header1.MsgId = 0x9102; + //header1.MsgNum = 2; + //header1.TerminalPhoneNo = terminalPhoneNo; + //jT808Package1.Header = header; + //JT808_0x9102 jT808_0X9102 = new JT808_0x9102(); + //jT808_0X9102.LogicalChannelNo = 1; + //jT808_0X9102.ControlCmd = 1; + //jT808_0X9102.CloseAVData = 0; + //jT808_0X9102.SwitchStreamType = 0; + //jT808Package1.Bodies = jT808_0X9102; + //var data1 = JT808Serializer.Serialize(jT808Package1); + //Console.WriteLine(JsonConvert.SerializeObject(data1.ToHexString())); + + //var result1 = JT808DotNettyWebApiClient.UnificationTcpSend(new JT808UnificationSendRequestDto + //{ + // TerminalPhoneNo = terminalPhoneNo, + // Data = data1 + //}).GetAwaiter().GetResult(); + + //Console.WriteLine(JsonConvert.SerializeObject(result1)); + + Console.ReadKey(); + } + } +} diff --git a/src/JT809.Protocol.Extensions.JT1078.Test/JT809.Protocol.Extensions.JT1078.Test.csproj b/src/JT809.Protocol.Extensions.JT1078.Test/JT809.Protocol.Extensions.JT1078.Test.csproj new file mode 100644 index 0000000..f061910 --- /dev/null +++ b/src/JT809.Protocol.Extensions.JT1078.Test/JT809.Protocol.Extensions.JT1078.Test.csproj @@ -0,0 +1,20 @@ + + + + netcoreapp2.2 + + false + + + + + + + + + + + + + + diff --git a/src/JT809.Protocol.Extensions.JT1078.Test/JT809_JT1078_0x1700Test.cs b/src/JT809.Protocol.Extensions.JT1078.Test/JT809_JT1078_0x1700Test.cs new file mode 100644 index 0000000..24fcbc3 --- /dev/null +++ b/src/JT809.Protocol.Extensions.JT1078.Test/JT809_JT1078_0x1700Test.cs @@ -0,0 +1,85 @@ +using JT809.Protocol.Extensions.JT1078.Enums; +using JT809.Protocol.Extensions.JT1078.MessageBody; +using Microsoft.Extensions.DependencyInjection; +using System; +using System.Linq; +using System.Collections.Generic; +using Xunit; + +namespace JT809.Protocol.Extensions.JT1078.Test +{ + public class JT809_JT1078_0x1700Test + { + JT809Serializer JT809Serializer; + public JT809_JT1078_0x1700Test() + { + IServiceCollection serviceDescriptors1 = new ServiceCollection(); + serviceDescriptors1 + .AddJT809Configure() + .AddJT1078Configure(); + var ServiceProvider1 = serviceDescriptors1.BuildServiceProvider(); + var defaultConfig = ServiceProvider1.GetRequiredService(); + JT809Serializer = defaultConfig.GetSerializer(); + } + + + + [Fact] + public void Test1() + { + var PlateFormIds = new byte[11]; + var AuthorizeCode1s = new byte[64]; + var AuthorizeCode2s= new byte[64]; + + PlateFormIds = Enumerable.Range(0, 11).Select(s => (byte)s).ToArray(); + AuthorizeCode1s = Enumerable.Range(0, 64).Select(s => (byte)s).ToArray(); + AuthorizeCode2s = Enumerable.Range(0, 64).Select(s => (byte)s).ToArray(); + + JT809_JT1078_0x1700 jT809_JT1078_0x1700 = new JT809_JT1078_0x1700() + { + VehicleNo="粤B12345", + VehicleColor= Protocol.Enums.JT809VehicleColorType.黄色, + SubBusinessType= (ushort)JT809_JT1078_SubBusinessType.时效口令上报消息, + SubBodies= new JT809_JT1078_0x1700_0x1701() { + PlateFormId= PlateFormIds, + AuthorizeCode1= AuthorizeCode1s, + AuthorizeCode2= AuthorizeCode2s + } + }; + var str = Newtonsoft.Json.JsonConvert.SerializeObject(jT809_JT1078_0x1700); + var hex = JT809Serializer.Serialize(jT809_JT1078_0x1700).ToHexString(); + Assert.Equal("D4C1423132333435000000000000000000000000000217010000008B000102030405060708090A000102030405060708090A0B0C0D0E0F101112131415161718191A1B1C1D1E1F202122232425262728292A2B2C2D2E2F303132333435363738393A3B3C3D3E3F000102030405060708090A0B0C0D0E0F101112131415161718191A1B1C1D1E1F202122232425262728292A2B2C2D2E2F303132333435363738393A3B3C3D3E3F", hex); + } + + [Fact] + public void Test2() + { + var str = "{\"VehicleNo\":\"粤B12345\",\"VehicleColor\":2,\"SubBusinessType\":5889,\"DataLength\":139,\"SubBodies\":{\"PlateFormId\":\"AAECAwQFBgcICQo=\",\"AuthorizeCode1\":\"AAECAwQFBgcICQoLDA0ODxAREhMUFRYXGBkaGxwdHh8gISIjJCUmJygpKissLS4vMDEyMzQ1Njc4OTo7PD0+Pw==\",\"AuthorizeCode2\":\"AAECAwQFBgcICQoLDA0ODxAREhMUFRYXGBkaGxwdHh8gISIjJCUmJygpKissLS4vMDEyMzQ1Njc4OTo7PD0+Pw==\"}}"; + var jT809_JT1078_0x1700 = JT809Serializer.Deserialize("D4C1423132333435000000000000000000000000000217010000008B000102030405060708090A000102030405060708090A0B0C0D0E0F101112131415161718191A1B1C1D1E1F202122232425262728292A2B2C2D2E2F303132333435363738393A3B3C3D3E3F000102030405060708090A0B0C0D0E0F101112131415161718191A1B1C1D1E1F202122232425262728292A2B2C2D2E2F303132333435363738393A3B3C3D3E3F".ToHexBytes()); + Assert.Equal(Newtonsoft.Json.JsonConvert.SerializeObject(jT809_JT1078_0x1700), str); + } + + [Fact] + public void Test3() + { + JT809_JT1078_0x1700 jT809_JT1078_0x1700 = new JT809_JT1078_0x1700() + { + VehicleNo = "粤B12345", + VehicleColor = Protocol.Enums.JT809VehicleColorType.黄色, + SubBusinessType = (ushort)JT809_JT1078_SubBusinessType.时效口令请求消息, + SubBodies = new JT809_JT1078_0x1700_0x1702() + }; + var str = Newtonsoft.Json.JsonConvert.SerializeObject(jT809_JT1078_0x1700); + var hex = JT809Serializer.Serialize(jT809_JT1078_0x1700).ToHexString(); + Assert.Equal("D4C14231323334350000000000000000000000000002170200000000", hex); + } + + [Fact] + public void Test4() + { + var str = "{\"VehicleNo\":\"粤B12345\",\"VehicleColor\":2,\"SubBusinessType\":5890,\"DataLength\":0,\"SubBodies\":{}}"; + var jT809_JT1078_0x1700 = JT809Serializer.Deserialize("D4C14231323334350000000000000000000000000002170200000000".ToHexBytes()); + Assert.Equal(Newtonsoft.Json.JsonConvert.SerializeObject(jT809_JT1078_0x1700), str); + } + } +} diff --git a/src/JT809.Protocol.Extensions.JT1078.Test/JT809_JT1078_0x1800Test.cs b/src/JT809.Protocol.Extensions.JT1078.Test/JT809_JT1078_0x1800Test.cs new file mode 100644 index 0000000..814f522 --- /dev/null +++ b/src/JT809.Protocol.Extensions.JT1078.Test/JT809_JT1078_0x1800Test.cs @@ -0,0 +1,79 @@ +using JT809.Protocol.Extensions.JT1078.Enums; +using JT809.Protocol.Extensions.JT1078.MessageBody; +using Microsoft.Extensions.DependencyInjection; +using System; +using System.Linq; +using System.Collections.Generic; +using Xunit; + +namespace JT809.Protocol.Extensions.JT1078.Test +{ + public class JT809_JT1078_0x1800Test + { + JT809Serializer JT809Serializer; + public JT809_JT1078_0x1800Test() + { + IServiceCollection serviceDescriptors1 = new ServiceCollection(); + serviceDescriptors1 + .AddJT809Configure() + .AddJT1078Configure(); + var ServiceProvider1 = serviceDescriptors1.BuildServiceProvider(); + var defaultConfig = ServiceProvider1.GetRequiredService(); + JT809Serializer = defaultConfig.GetSerializer(); + } + + + + [Fact] + public void Test1() + { + JT809_JT1078_0x1800 jT809_JT1078_0x1800 = new JT809_JT1078_0x1800() + { + VehicleNo="粤B12345", + VehicleColor= Protocol.Enums.JT809VehicleColorType.黄色, + SubBusinessType= (ushort)JT809_JT1078_SubBusinessType.实时音视频请求应答消息, + SubBodies= new JT809_JT1078_0x1800_0x1801() { + ServerIp="127.0.0.1", + ServerPort=8080, + Result=1 + } + }; + var str = Newtonsoft.Json.JsonConvert.SerializeObject(jT809_JT1078_0x1800); + var hex = JT809Serializer.Serialize(jT809_JT1078_0x1800).ToHexString(); + Assert.Equal("D4C142313233343500000000000000000000000000021801000000230100000000000000000000000000000000000000000000003132372E302E302E311F90", hex); + } + + [Fact] + public void Test2() + { + var str = "{\"VehicleNo\":\"粤B12345\",\"VehicleColor\":2,\"SubBusinessType\":6145,\"DataLength\":35,\"SubBodies\":{\"Result\":1,\"ServerIp\":\"127.0.0.1\",\"ServerPort\":8080}}"; + var jT809_JT1078_0x1800 = JT809Serializer.Deserialize("D4C142313233343500000000000000000000000000021801000000230100000000000000000000000000000000000000000000003132372E302E302E311F90".ToHexBytes()); + Assert.Equal(Newtonsoft.Json.JsonConvert.SerializeObject(jT809_JT1078_0x1800), str); + } + + [Fact] + public void Test3() + { + JT809_JT1078_0x1800 jT809_JT1078_0x1800 = new JT809_JT1078_0x1800() + { + VehicleNo = "粤B12345", + VehicleColor = Protocol.Enums.JT809VehicleColorType.黄色, + SubBusinessType = (ushort)JT809_JT1078_SubBusinessType.主动请求停止实时音视频传输应答消息, + SubBodies = new JT809_JT1078_0x1800_0x1802() { + Result=1 + } + }; + var str = Newtonsoft.Json.JsonConvert.SerializeObject(jT809_JT1078_0x1800); + var hex = JT809Serializer.Serialize(jT809_JT1078_0x1800).ToHexString(); + Assert.Equal("D4C1423132333435000000000000000000000000000218020000000101", hex); + } + + [Fact] + public void Test4() + { + var str = "{\"VehicleNo\":\"粤B12345\",\"VehicleColor\":2,\"SubBusinessType\":6146,\"DataLength\":1,\"SubBodies\":{\"Result\":1}}"; + var jT809_JT1078_0x1800 = JT809Serializer.Deserialize("D4C1423132333435000000000000000000000000000218020000000101".ToHexBytes()); + Assert.Equal(Newtonsoft.Json.JsonConvert.SerializeObject(jT809_JT1078_0x1800), str); + } + } +} diff --git a/src/JT809.Protocol.Extensions.JT1078.Test/JT809_JT1078_0x1900Test.cs b/src/JT809.Protocol.Extensions.JT1078.Test/JT809_JT1078_0x1900Test.cs new file mode 100644 index 0000000..ee56033 --- /dev/null +++ b/src/JT809.Protocol.Extensions.JT1078.Test/JT809_JT1078_0x1900Test.cs @@ -0,0 +1,133 @@ +using JT809.Protocol.Extensions.JT1078.Enums; +using JT809.Protocol.Extensions.JT1078.MessageBody; +using Microsoft.Extensions.DependencyInjection; +using System; +using System.Linq; +using System.Collections.Generic; +using Xunit; +using Newtonsoft.Json; + +namespace JT809.Protocol.Extensions.JT1078.Test +{ + public class JT809_JT1078_0x1900Test + { + JT809Serializer JT809Serializer; + public JT809_JT1078_0x1900Test() + { + 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 Test1() + { + JT809_JT1078_0x1900 jT809_JT1078_0x1900 = new JT809_JT1078_0x1900() + { + VehicleNo="粤B12345", + VehicleColor= Protocol.Enums.JT809VehicleColorType.黄色, + SubBusinessType= (ushort)JT809_JT1078_SubBusinessType.主动上传音视频资源目录信息消息, + SubBodies= new JT809_JT1078_0x1900_0x1901() { + ItemNum=2, + ItemList=new List { + new JT809_JT1078_0x1900_Record{ + AlarmType=1, + AVItemType=2, + ChannelId=3, + EndTime=Convert.ToDateTime("2019-07-16 10:10:10"), + FileSize=4, + MemType=5, + StartTime=Convert.ToDateTime("2019-07-15 10:10:10"), + StreamType=6 + }, + new JT809_JT1078_0x1900_Record{ + AlarmType=11, + AVItemType=21, + ChannelId=31, + EndTime=Convert.ToDateTime("2019-06-16 10:10:10"), + FileSize=41, + MemType=51, + StartTime=Convert.ToDateTime("2019-06-15 10:10:10"), + StreamType=61 + } + } + } + }; + var str = Newtonsoft.Json.JsonConvert.SerializeObject(jT809_JT1078_0x1900); + var hex = JT809Serializer.Serialize(jT809_JT1078_0x1900).ToHexString(); + Assert.Equal("D4C142313233343500000000000000000000000000021901000000440000000203000000005D2BE082000000005D2D32020000000000000001020605000000041F000000005D045382000000005D05A502000000000000000B153D3300000029", hex); + } + + [Fact] + public void Test2() + { + var str = "{\"VehicleNo\":\"粤B12345\",\"VehicleColor\":2,\"SubBusinessType\":6401,\"DataLength\":68,\"SubBodies\":{\"ItemNum\":2,\"ItemList\":[{\"ChannelId\":3,\"StartTime\":\"2019-07-15 10:10:10\",\"EndTime\":\"2019-07-16 10:10:10\",\"AlarmType\":1,\"AVItemType\":2,\"StreamType\":6,\"MemType\":5,\"FileSize\":4},{\"ChannelId\":31,\"StartTime\":\"2019-06-15 10:10:10\",\"EndTime\":\"2019-06-16 10:10:10\",\"AlarmType\":11,\"AVItemType\":21,\"StreamType\":61,\"MemType\":51,\"FileSize\":41}]}}"; + var jT809_JT1078_0x1900 = JT809Serializer.Deserialize("D4C142313233343500000000000000000000000000021901000000440000000203000000005D2BE082000000005D2D32020000000000000001020605000000041F000000005D045382000000005D05A502000000000000000B153D3300000029".ToHexBytes()); + Assert.Equal(Newtonsoft.Json.JsonConvert.SerializeObject(jT809_JT1078_0x1900), str); + } + + [Fact] + public void Test3() + { + JT809_JT1078_0x1900 jT809_JT1078_0x1900 = new JT809_JT1078_0x1900() + { + VehicleNo = "粤B12345", + VehicleColor = Protocol.Enums.JT809VehicleColorType.黄色, + SubBusinessType = (ushort)JT809_JT1078_SubBusinessType.查询音视频资源目录应答消息, + SubBodies = new JT809_JT1078_0x1900_0x1902() { + Result=1, + ItemNum=2, + ItemList = new List { + new JT809_JT1078_0x1900_Record{ + AlarmType=1, + AVItemType=2, + ChannelId=3, + EndTime=Convert.ToDateTime("2019-07-16 10:10:10"), + FileSize=4, + MemType=5, + StartTime=Convert.ToDateTime("2019-07-15 10:10:10"), + StreamType=6 + }, + new JT809_JT1078_0x1900_Record{ + AlarmType=11, + AVItemType=21, + ChannelId=31, + EndTime=Convert.ToDateTime("2019-06-16 10:10:10"), + FileSize=41, + MemType=51, + StartTime=Convert.ToDateTime("2019-06-15 10:10:10"), + StreamType=61 + } + } + } + }; + var str = Newtonsoft.Json.JsonConvert.SerializeObject(jT809_JT1078_0x1900); + var hex = JT809Serializer.Serialize(jT809_JT1078_0x1900).ToHexString(); + Assert.Equal("D4C14231323334350000000000000000000000000002190200000045010000000203000000005D2BE082000000005D2D32020000000000000001020605000000041F000000005D045382000000005D05A502000000000000000B153D3300000029", hex); + } + + [Fact] + public void Test4() + { + var str = "{\"VehicleNo\":\"粤B12345\",\"VehicleColor\":2,\"SubBusinessType\":6402,\"DataLength\":69,\"SubBodies\":{\"Result\":1,\"ItemNum\":2,\"ItemList\":[{\"ChannelId\":3,\"StartTime\":\"2019-07-15 10:10:10\",\"EndTime\":\"2019-07-16 10:10:10\",\"AlarmType\":1,\"AVItemType\":2,\"StreamType\":6,\"MemType\":5,\"FileSize\":4},{\"ChannelId\":31,\"StartTime\":\"2019-06-15 10:10:10\",\"EndTime\":\"2019-06-16 10:10:10\",\"AlarmType\":11,\"AVItemType\":21,\"StreamType\":61,\"MemType\":51,\"FileSize\":41}]}}"; + var jT809_JT1078_0x1900 = JT809Serializer.Deserialize("D4C14231323334350000000000000000000000000002190200000045010000000203000000005D2BE082000000005D2D32020000000000000001020605000000041F000000005D045382000000005D05A502000000000000000B153D3300000029".ToHexBytes()); + Assert.Equal(Newtonsoft.Json.JsonConvert.SerializeObject(jT809_JT1078_0x1900), str); + } + } +} diff --git a/src/JT809.Protocol.Extensions.JT1078.Test/JT809_JT1078_0x1A00Test.cs b/src/JT809.Protocol.Extensions.JT1078.Test/JT809_JT1078_0x1A00Test.cs new file mode 100644 index 0000000..8ec78a7 --- /dev/null +++ b/src/JT809.Protocol.Extensions.JT1078.Test/JT809_JT1078_0x1A00Test.cs @@ -0,0 +1,91 @@ +using JT809.Protocol.Extensions.JT1078.Enums; +using JT809.Protocol.Extensions.JT1078.MessageBody; +using Microsoft.Extensions.DependencyInjection; +using System; +using System.Linq; +using System.Collections.Generic; +using Xunit; +using Newtonsoft.Json; + +namespace JT809.Protocol.Extensions.JT1078.Test +{ + public class JT809_JT1078_0x1A00Test + { + JT809Serializer JT809Serializer; + public JT809_JT1078_0x1A00Test() + { + 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 Test1() + { + JT809_JT1078_0x1A00 jT809_JT1078_0x1A00 = new JT809_JT1078_0x1A00() + { + VehicleNo="粤B12345", + VehicleColor= Protocol.Enums.JT809VehicleColorType.黄色, + SubBusinessType= (ushort)JT809_JT1078_SubBusinessType.远程录像回放请求应答消息, + SubBodies= new JT809_JT1078_0x1A00_0x1A01() + { + Result=1, + ServerIp="127.0.0.1", + ServerPort=8080 + } + }; + var str = Newtonsoft.Json.JsonConvert.SerializeObject(jT809_JT1078_0x1A00); + var hex = JT809Serializer.Serialize(jT809_JT1078_0x1A00).ToHexString(); + Assert.Equal("D4C142313233343500000000000000000000000000021A010000002300000000000000000000000000000000000000000000003132372E302E302E311F9001", hex); + } + + [Fact] + public void Test2() + { + var str = "{\"VehicleNo\":\"粤B12345\",\"VehicleColor\":2,\"SubBusinessType\":6657,\"DataLength\":35,\"SubBodies\":{\"ServerIp\":\"127.0.0.1\",\"ServerPort\":8080,\"Result\":1}}"; + var jT809_JT1078_0x1A00 = JT809Serializer.Deserialize("D4C142313233343500000000000000000000000000021A010000002300000000000000000000000000000000000000000000003132372E302E302E311F9001".ToHexBytes()); + Assert.Equal(Newtonsoft.Json.JsonConvert.SerializeObject(jT809_JT1078_0x1A00), str); + } + + [Fact] + public void Test3() + { + JT809_JT1078_0x1A00 jT809_JT1078_0x1A00 = new JT809_JT1078_0x1A00() + { + VehicleNo = "粤B12345", + VehicleColor = Protocol.Enums.JT809VehicleColorType.黄色, + SubBusinessType = (ushort)JT809_JT1078_SubBusinessType.远程录像回放控制应答消息, + SubBodies = new JT809_JT1078_0x1A00_0x1A02() { + Result=1 + } + }; + var str = Newtonsoft.Json.JsonConvert.SerializeObject(jT809_JT1078_0x1A00); + var hex = JT809Serializer.Serialize(jT809_JT1078_0x1A00).ToHexString(); + Assert.Equal("D4C142313233343500000000000000000000000000021A020000000101", hex); + } + + [Fact] + public void Test4() + { + var str = "{\"VehicleNo\":\"粤B12345\",\"VehicleColor\":2,\"SubBusinessType\":6658,\"DataLength\":1,\"SubBodies\":{\"Result\":1}}"; + var jT809_JT1078_0x1A00 = JT809Serializer.Deserialize("D4C142313233343500000000000000000000000000021A020000000101".ToHexBytes()); + Assert.Equal(Newtonsoft.Json.JsonConvert.SerializeObject(jT809_JT1078_0x1A00), str); + } + } +} diff --git a/src/JT809.Protocol.Extensions.JT1078.Test/JT809_JT1078_0x1B00Test.cs b/src/JT809.Protocol.Extensions.JT1078.Test/JT809_JT1078_0x1B00Test.cs new file mode 100644 index 0000000..e82145a --- /dev/null +++ b/src/JT809.Protocol.Extensions.JT1078.Test/JT809_JT1078_0x1B00Test.cs @@ -0,0 +1,122 @@ +using JT809.Protocol.Extensions.JT1078.Enums; +using JT809.Protocol.Extensions.JT1078.MessageBody; +using Microsoft.Extensions.DependencyInjection; +using System; +using System.Linq; +using System.Collections.Generic; +using Xunit; +using Newtonsoft.Json; + +namespace JT809.Protocol.Extensions.JT1078.Test +{ + public class JT809_JT1078_0x1B00Test + { + JT809Serializer JT809Serializer; + public JT809_JT1078_0x1B00Test() + { + 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 Test1() + { + JT809_JT1078_0x1B00 jT809_JT1078_0x1B00 = new JT809_JT1078_0x1B00() + { + VehicleNo="粤B12345", + VehicleColor= Protocol.Enums.JT809VehicleColorType.黄色, + SubBusinessType= (ushort)JT809_JT1078_SubBusinessType.远程录像下载请求应答消息, + SubBodies= new JT809_JT1078_0x1B00_0x1B01() + { + Result=1, + SessionId=2 + } + }; + var str = Newtonsoft.Json.JsonConvert.SerializeObject(jT809_JT1078_0x1B00); + var hex = JT809Serializer.Serialize(jT809_JT1078_0x1B00).ToHexString(); + Assert.Equal("D4C142313233343500000000000000000000000000021B0100000003010002", hex); + } + + [Fact] + public void Test2() + { + var str = "{\"VehicleNo\":\"粤B12345\",\"VehicleColor\":2,\"SubBusinessType\":6913,\"DataLength\":3,\"SubBodies\":{\"Result\":1,\"SessionId\":2}}"; + var jT809_JT1078_0x1B00 = JT809Serializer.Deserialize("D4C142313233343500000000000000000000000000021B0100000003010002".ToHexBytes()); + Assert.Equal(Newtonsoft.Json.JsonConvert.SerializeObject(jT809_JT1078_0x1B00), str); + } + + [Fact] + public void Test3() + { + JT809_JT1078_0x1B00 jT809_JT1078_0x1B00 = new JT809_JT1078_0x1B00() + { + VehicleNo = "粤B12345", + VehicleColor = Protocol.Enums.JT809VehicleColorType.黄色, + SubBusinessType = (ushort)JT809_JT1078_SubBusinessType.远程录像下载通知消息, + SubBodies = new JT809_JT1078_0x1B00_0x1B02() { + Result=1, + UserName="tk", + SessionId=2, + ServerIp="127.0.0.1", + FilePath="D://123/456", + Password="tk123456", + TcpPort=8080 + } + }; + var str = Newtonsoft.Json.JsonConvert.SerializeObject(jT809_JT1078_0x1B00); + var hex = JT809Serializer.Serialize(jT809_JT1078_0x1B00).ToHexString(); + Assert.Equal("D4C142313233343500000000000000000000000000021B020000013401000200000000000000000000000000000000000000000000003132372E302E302E311F900000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000746B0000000000000000000000000000746B313233343536000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000443A2F2F3132332F343536", hex); + } + + [Fact] + public void Test4() + { + var str = "{\"VehicleNo\":\"粤B12345\",\"VehicleColor\":2,\"SubBusinessType\":6914,\"DataLength\":308,\"SubBodies\":{\"Result\":1,\"SessionId\":2,\"ServerIp\":\"127.0.0.1\",\"TcpPort\":8080,\"UserName\":\"tk\",\"Password\":\"tk123456\",\"FilePath\":\"D://123/456\"}}"; + var jT809_JT1078_0x1B00 = JT809Serializer.Deserialize("D4C142313233343500000000000000000000000000021B020000013401000200000000000000000000000000000000000000000000003132372E302E302E311F900000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000746B0000000000000000000000000000746B313233343536000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000443A2F2F3132332F343536".ToHexBytes()); + Assert.Equal(Newtonsoft.Json.JsonConvert.SerializeObject(jT809_JT1078_0x1B00), str); + } + + [Fact] + public void Test5() + { + JT809_JT1078_0x1B00 jT809_JT1078_0x1B00 = new JT809_JT1078_0x1B00() + { + VehicleNo = "粤B12345", + VehicleColor = Protocol.Enums.JT809VehicleColorType.黄色, + SubBusinessType = (ushort)JT809_JT1078_SubBusinessType.远程录像下载控制应答消息, + SubBodies = new JT809_JT1078_0x1B00_0x1B03() + { + Result = 1 + } + }; + var str = Newtonsoft.Json.JsonConvert.SerializeObject(jT809_JT1078_0x1B00); + var hex = JT809Serializer.Serialize(jT809_JT1078_0x1B00).ToHexString(); + Assert.Equal("D4C142313233343500000000000000000000000000021B030000000101", hex); + } + + [Fact] + public void Test6() + { + var str = "{\"VehicleNo\":\"粤B12345\",\"VehicleColor\":2,\"SubBusinessType\":6915,\"DataLength\":1,\"SubBodies\":{\"Result\":1}}"; + var jT809_JT1078_0x1B00 = JT809Serializer.Deserialize("D4C142313233343500000000000000000000000000021B030000000101".ToHexBytes()); + Assert.Equal(Newtonsoft.Json.JsonConvert.SerializeObject(jT809_JT1078_0x1B00), str); + } + } +} diff --git a/src/JT809.Protocol.Extensions.JT1078.Test/JT809_JT1078_0x9700Test.cs b/src/JT809.Protocol.Extensions.JT1078.Test/JT809_JT1078_0x9700Test.cs new file mode 100644 index 0000000..9fbe653 --- /dev/null +++ b/src/JT809.Protocol.Extensions.JT1078.Test/JT809_JT1078_0x9700Test.cs @@ -0,0 +1,50 @@ +using JT809.Protocol.Extensions.JT1078.Enums; +using JT809.Protocol.Extensions.JT1078.MessageBody; +using Microsoft.Extensions.DependencyInjection; +using System; +using System.Linq; +using System.Collections.Generic; +using Xunit; + +namespace JT809.Protocol.Extensions.JT1078.Test +{ + public class JT809_JT1078_0x9700Test + { + JT809Serializer JT809Serializer; + public JT809_JT1078_0x9700Test() + { + IServiceCollection serviceDescriptors1 = new ServiceCollection(); + serviceDescriptors1 + .AddJT809Configure() + .AddJT1078Configure(); + var ServiceProvider1 = serviceDescriptors1.BuildServiceProvider(); + var defaultConfig = ServiceProvider1.GetRequiredService(); + JT809Serializer = defaultConfig.GetSerializer(); + } + + + + [Fact] + public void Test1() + { + JT809_JT1078_0x9700 jT809_JT1078_0x9700 = new JT809_JT1078_0x9700() + { + VehicleNo="粤B12345", + VehicleColor= Protocol.Enums.JT809VehicleColorType.黄色, + SubBusinessType= (ushort)JT809_JT1078_SubBusinessType.时效口令请求应答消息, + SubBodies= new JT809_JT1078_0x9700_0x9702() + }; + var str = Newtonsoft.Json.JsonConvert.SerializeObject(jT809_JT1078_0x9700); + var hex = JT809Serializer.Serialize(jT809_JT1078_0x9700).ToHexString(); + Assert.Equal("D4C14231323334350000000000000000000000000002970200000000", hex); + } + + [Fact] + public void Test2() + { + var str = "{\"VehicleNo\":\"粤B12345\",\"VehicleColor\":2,\"SubBusinessType\":38658,\"DataLength\":0,\"SubBodies\":{}}"; + var jT809_JT1078_0x9700 = JT809Serializer.Deserialize("D4C14231323334350000000000000000000000000002970200000000".ToHexBytes()); + Assert.Equal(Newtonsoft.Json.JsonConvert.SerializeObject(jT809_JT1078_0x9700), str); + } + } +} diff --git a/src/JT809.Protocol.Extensions.JT1078.Test/JT809_JT1078_0x9800Test.cs b/src/JT809.Protocol.Extensions.JT1078.Test/JT809_JT1078_0x9800Test.cs new file mode 100644 index 0000000..b4a7f89 --- /dev/null +++ b/src/JT809.Protocol.Extensions.JT1078.Test/JT809_JT1078_0x9800Test.cs @@ -0,0 +1,83 @@ +using JT809.Protocol.Extensions.JT1078.Enums; +using JT809.Protocol.Extensions.JT1078.MessageBody; +using Microsoft.Extensions.DependencyInjection; +using System; +using System.Linq; +using System.Collections.Generic; +using Xunit; + +namespace JT809.Protocol.Extensions.JT1078.Test +{ + public class JT809_JT1078_0x9800Test + { + JT809Serializer JT809Serializer; + public JT809_JT1078_0x9800Test() + { + IServiceCollection serviceDescriptors1 = new ServiceCollection(); + serviceDescriptors1 + .AddJT809Configure() + .AddJT1078Configure(); + var ServiceProvider1 = serviceDescriptors1.BuildServiceProvider(); + var defaultConfig = ServiceProvider1.GetRequiredService(); + JT809Serializer = defaultConfig.GetSerializer(); + } + + + + [Fact] + 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(); + JT809_JT1078_0x9800 jT809_JT1078_0x9800 = new JT809_JT1078_0x9800() + { + VehicleNo="粤B12345", + VehicleColor= Protocol.Enums.JT809VehicleColorType.黄色, + SubBusinessType= (ushort)JT809_JT1078_SubBusinessType.实时音视频请求消息, + SubBodies= new JT809_JT1078_0x9800_0x9801() { + AVitemType=1, + ChannelId=2, + GnssData= GnssDatas, + AuthorizeCode= AuthorizeCodes + } + }; + var str = Newtonsoft.Json.JsonConvert.SerializeObject(jT809_JT1078_0x9800); + var hex = JT809Serializer.Serialize(jT809_JT1078_0x9800).ToHexString(); + Assert.Equal("D4C142313233343500000000000000000000000000029801000000660201000102030405060708090A0B0C0D0E0F101112131415161718191A1B1C1D1E1F202122232425262728292A2B2C2D2E2F303132333435363738393A3B3C3D3E3F000102030405060708090A0B0C0D0E0F101112131415161718191A1B1C1D1E1F20212223", hex); + } + + [Fact] + public void Test2() + { + var str = "{\"VehicleNo\":\"粤B12345\",\"VehicleColor\":2,\"SubBusinessType\":38913,\"DataLength\":102,\"SubBodies\":{\"ChannelId\":2,\"AVitemType\":1,\"AuthorizeCode\":\"AAECAwQFBgcICQoLDA0ODxAREhMUFRYXGBkaGxwdHh8gISIjJCUmJygpKissLS4vMDEyMzQ1Njc4OTo7PD0+Pw==\",\"GnssData\":\"AAECAwQFBgcICQoLDA0ODxAREhMUFRYXGBkaGxwdHh8gISIj\"}}"; + var jT809_JT1078_0x1900 = JT809Serializer.Deserialize("D4C142313233343500000000000000000000000000029801000000660201000102030405060708090A0B0C0D0E0F101112131415161718191A1B1C1D1E1F202122232425262728292A2B2C2D2E2F303132333435363738393A3B3C3D3E3F000102030405060708090A0B0C0D0E0F101112131415161718191A1B1C1D1E1F20212223".ToHexBytes()); + Assert.Equal(Newtonsoft.Json.JsonConvert.SerializeObject(jT809_JT1078_0x1900), str); + } + + [Fact] + public void Test3() + { + JT809_JT1078_0x9800 jT809_JT1078_0x9800 = new JT809_JT1078_0x9800() + { + VehicleNo = "粤B12345", + VehicleColor = Protocol.Enums.JT809VehicleColorType.黄色, + SubBusinessType = (ushort)JT809_JT1078_SubBusinessType.主动请求停止实时音视频传输消息, + SubBodies = new JT809_JT1078_0x9800_0x9802() { + ChannelId=1, + AVitemType=2 + } + }; + var str = Newtonsoft.Json.JsonConvert.SerializeObject(jT809_JT1078_0x9800); + var hex = JT809Serializer.Serialize(jT809_JT1078_0x9800).ToHexString(); + Assert.Equal("D4C142313233343500000000000000000000000000029802000000020102", hex); + } + + [Fact] + public void Test4() + { + var str = "{\"VehicleNo\":\"粤B12345\",\"VehicleColor\":2,\"SubBusinessType\":38914,\"DataLength\":2,\"SubBodies\":{\"ChannelId\":1,\"AVitemType\":2}}"; + var jT809_JT1078_0x9800 = JT809Serializer.Deserialize("D4C142313233343500000000000000000000000000029802000000020102".ToHexBytes()); + Assert.Equal(Newtonsoft.Json.JsonConvert.SerializeObject(jT809_JT1078_0x9800), str); + } + } +} diff --git a/src/JT809.Protocol.Extensions.JT1078.Test/JT809_JT1078_0x9900Test.cs b/src/JT809.Protocol.Extensions.JT1078.Test/JT809_JT1078_0x9900Test.cs new file mode 100644 index 0000000..55958de --- /dev/null +++ b/src/JT809.Protocol.Extensions.JT1078.Test/JT809_JT1078_0x9900Test.cs @@ -0,0 +1,99 @@ +using JT809.Protocol.Extensions.JT1078.Enums; +using JT809.Protocol.Extensions.JT1078.MessageBody; +using Microsoft.Extensions.DependencyInjection; +using System; +using System.Linq; +using System.Collections.Generic; +using Xunit; +using Newtonsoft.Json; + +namespace JT809.Protocol.Extensions.JT1078.Test +{ + public class JT809_JT1078_0x9900Test + { + JT809Serializer JT809Serializer; + public JT809_JT1078_0x9900Test() + { + 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 Test1() + { + JT809_JT1078_0x9900 jT809_JT1078_0x9900 = new JT809_JT1078_0x9900() + { + VehicleNo="粤B12345", + VehicleColor= Protocol.Enums.JT809VehicleColorType.黄色, + SubBusinessType= (ushort)JT809_JT1078_SubBusinessType.主动上传音视频资源目录信息应答消息, + SubBodies= new JT809_JT1078_0x9900_0x9901() { + Result=1, + ItemNumber=2 + } + }; + var str = Newtonsoft.Json.JsonConvert.SerializeObject(jT809_JT1078_0x9900); + var hex = JT809Serializer.Serialize(jT809_JT1078_0x9900).ToHexString(); + Assert.Equal("D4C142313233343500000000000000000000000000029901000000020102", hex); + } + + [Fact] + public void Test2() + { + var str = "{\"VehicleNo\":\"粤B12345\",\"VehicleColor\":2,\"SubBusinessType\":39169,\"DataLength\":2,\"SubBodies\":{\"Result\":1,\"ItemNumber\":2}}"; + var jT809_JT1078_0x9900 = JT809Serializer.Deserialize("D4C142313233343500000000000000000000000000029901000000020102".ToHexBytes()); + Assert.Equal(Newtonsoft.Json.JsonConvert.SerializeObject(jT809_JT1078_0x9900), str); + } + + [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(); + JT809_JT1078_0x9900 jT809_JT1078_0x9900 = new JT809_JT1078_0x9900() + { + VehicleNo = "粤B12345", + VehicleColor = Protocol.Enums.JT809VehicleColorType.黄色, + SubBusinessType = (ushort)JT809_JT1078_SubBusinessType.查询音视频资源目录请求消息, + SubBodies = new JT809_JT1078_0x9900_0x9902() { + ChannelId = 1, + AlarmType = 2, + AVItemType = 3, + EndTime = Convert.ToDateTime("2017-07-16 10:10:10"), + MemType = 4, + StartTime = Convert.ToDateTime("2017-07-15 10:10:10"), + StreamType=5, + AuthorizeCode= AuthorizeCodes, + GnssData= GnssDatas + } + }; + var str = Newtonsoft.Json.JsonConvert.SerializeObject(jT809_JT1078_0x9900); + var hex = JT809Serializer.Serialize(jT809_JT1078_0x9900).ToHexString(); + Assert.Equal("D4C1423132333435000000000000000000000000000299020000008001000000005969798200000000596ACB020000000000000002030504000102030405060708090A0B0C0D0E0F101112131415161718191A1B1C1D1E1F202122232425262728292A2B2C2D2E2F303132333435363738393A3B3C3D3E3F000102030405060708090A0B0C0D0E0F101112131415161718191A1B1C1D1E1F20212223", hex); + } + + [Fact] + public void Test4() + { + var str = "{\"VehicleNo\":\"粤B12345\",\"VehicleColor\":2,\"SubBusinessType\":39170,\"DataLength\":128,\"SubBodies\":{\"ChannelId\":1,\"StartTime\":\"2017-07-15 10:10:10\",\"EndTime\":\"2017-07-16 10:10:10\",\"AlarmType\":2,\"AVItemType\":3,\"StreamType\":5,\"MemType\":4,\"AuthorizeCode\":\"AAECAwQFBgcICQoLDA0ODxAREhMUFRYXGBkaGxwdHh8gISIjJCUmJygpKissLS4vMDEyMzQ1Njc4OTo7PD0+Pw==\",\"GnssData\":\"AAECAwQFBgcICQoLDA0ODxAREhMUFRYXGBkaGxwdHh8gISIj\"}}"; + var jT809_JT1078_0x9900 = JT809Serializer.Deserialize("D4C1423132333435000000000000000000000000000299020000008001000000005969798200000000596ACB020000000000000002030504000102030405060708090A0B0C0D0E0F101112131415161718191A1B1C1D1E1F202122232425262728292A2B2C2D2E2F303132333435363738393A3B3C3D3E3F000102030405060708090A0B0C0D0E0F101112131415161718191A1B1C1D1E1F20212223".ToHexBytes()); + Assert.Equal(Newtonsoft.Json.JsonConvert.SerializeObject(jT809_JT1078_0x9900), str); + } + } +} diff --git a/src/JT809.Protocol.Extensions.JT1078.Test/JT809_JT1078_0x9A00Test.cs b/src/JT809.Protocol.Extensions.JT1078.Test/JT809_JT1078_0x9A00Test.cs new file mode 100644 index 0000000..4acf7ea --- /dev/null +++ b/src/JT809.Protocol.Extensions.JT1078.Test/JT809_JT1078_0x9A00Test.cs @@ -0,0 +1,101 @@ +using JT809.Protocol.Extensions.JT1078.Enums; +using JT809.Protocol.Extensions.JT1078.MessageBody; +using Microsoft.Extensions.DependencyInjection; +using System; +using System.Linq; +using System.Collections.Generic; +using Xunit; +using Newtonsoft.Json; + +namespace JT809.Protocol.Extensions.JT1078.Test +{ + public class JT809_JT1078_0x9A00Test + { + JT809Serializer JT809Serializer; + public JT809_JT1078_0x9A00Test() + { + 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 Test1() + { + var GnssDatas = Enumerable.Range(0, 36).Select(m => (byte)m).ToArray(); + var AuthorizeCodes = Enumerable.Range(0, 64).Select(m => (byte)m).ToArray(); + JT809_JT1078_0x9A00 jT809_JT1078_0x9A00 = new JT809_JT1078_0x9A00() + { + VehicleNo = "粤B12345", + VehicleColor = Protocol.Enums.JT809VehicleColorType.黄色, + SubBusinessType = (ushort)JT809_JT1078_SubBusinessType.远程录像回放请求消息, + SubBodies = new JT809_JT1078_0x9A00_0x9A01() { + AuthorizeCode = AuthorizeCodes, + GnssData = GnssDatas, + AVItemType = 1, + ChannelId = 2, + MemType = 3, + StreamType = 4, + PlayBackStartTime = Convert.ToDateTime("2017-07-16 10:10:10"), + PlayBackEndTime = Convert.ToDateTime("2017-07-17 10:10:10") + } + }; + var str = Newtonsoft.Json.JsonConvert.SerializeObject(jT809_JT1078_0x9A00); + var hex = JT809Serializer.Serialize(jT809_JT1078_0x9A00).ToHexString(); + Assert.Equal("D4C142313233343500000000000000000000000000029A01000000780201040300000000596ACB0200000000596C1C82000102030405060708090A0B0C0D0E0F101112131415161718191A1B1C1D1E1F202122232425262728292A2B2C2D2E2F303132333435363738393A3B3C3D3E3F000102030405060708090A0B0C0D0E0F101112131415161718191A1B1C1D1E1F20212223", hex); + } + + [Fact] + public void Test2() + { + var str = "{\"VehicleNo\":\"粤B12345\",\"VehicleColor\":2,\"SubBusinessType\":39425,\"DataLength\":120,\"SubBodies\":{\"ChannelId\":2,\"AVItemType\":1,\"StreamType\":4,\"MemType\":3,\"PlayBackStartTime\":\"2017-07-16 10:10:10\",\"PlayBackEndTime\":\"2017-07-17 10:10:10\",\"AuthorizeCode\":\"AAECAwQFBgcICQoLDA0ODxAREhMUFRYXGBkaGxwdHh8gISIjJCUmJygpKissLS4vMDEyMzQ1Njc4OTo7PD0+Pw==\",\"GnssData\":\"AAECAwQFBgcICQoLDA0ODxAREhMUFRYXGBkaGxwdHh8gISIj\"}}"; + var jT809_JT1078_0x9A00 = JT809Serializer.Deserialize("D4C142313233343500000000000000000000000000029A01000000780201040300000000596ACB0200000000596C1C82000102030405060708090A0B0C0D0E0F101112131415161718191A1B1C1D1E1F202122232425262728292A2B2C2D2E2F303132333435363738393A3B3C3D3E3F000102030405060708090A0B0C0D0E0F101112131415161718191A1B1C1D1E1F20212223".ToHexBytes()); + Assert.Equal(Newtonsoft.Json.JsonConvert.SerializeObject(jT809_JT1078_0x9A00), str); + } + + [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(); + JT809_JT1078_0x9A00 jT809_JT1078_0x9A00 = new JT809_JT1078_0x9A00() + { + VehicleNo = "粤B12345", + VehicleColor = Protocol.Enums.JT809VehicleColorType.黄色, + SubBusinessType = (ushort)JT809_JT1078_SubBusinessType.远程录像回放控制消息, + SubBodies = new JT809_JT1078_0x9A00_0x9A02() { + ControlType=1, + DateTime= Convert.ToDateTime("2017-07-17 10:10:10"), + FastTime=1 + } + }; + var str = Newtonsoft.Json.JsonConvert.SerializeObject(jT809_JT1078_0x9A00); + var hex = JT809Serializer.Serialize(jT809_JT1078_0x9A00).ToHexString(); + Assert.Equal("D4C142313233343500000000000000000000000000029A020000000A010100000000596C1C82", hex); + } + + [Fact] + public void Test4() + { + var str = "{\"VehicleNo\":\"粤B12345\",\"VehicleColor\":2,\"SubBusinessType\":39426,\"DataLength\":10,\"SubBodies\":{\"ControlType\":1,\"FastTime\":1,\"DateTime\":\"2017-07-17 10:10:10\"}}"; + var jT809_JT1078_0x9A00 = JT809Serializer.Deserialize("D4C142313233343500000000000000000000000000029A020000000A010100000000596C1C82".ToHexBytes()); + Assert.Equal(Newtonsoft.Json.JsonConvert.SerializeObject(jT809_JT1078_0x9A00), str); + } + } +} diff --git a/src/JT809.Protocol.Extensions.JT1078.Test/JT809_JT1078_0x9B00Test.cs b/src/JT809.Protocol.Extensions.JT1078.Test/JT809_JT1078_0x9B00Test.cs new file mode 100644 index 0000000..73e8398 --- /dev/null +++ b/src/JT809.Protocol.Extensions.JT1078.Test/JT809_JT1078_0x9B00Test.cs @@ -0,0 +1,126 @@ +using JT809.Protocol.Extensions.JT1078.Enums; +using JT809.Protocol.Extensions.JT1078.MessageBody; +using Microsoft.Extensions.DependencyInjection; +using System; +using System.Linq; +using System.Collections.Generic; +using Xunit; +using Newtonsoft.Json; + +namespace JT809.Protocol.Extensions.JT1078.Test +{ + public class JT809_JT1078_0x9B00Test + { + JT809Serializer JT809Serializer; + public JT809_JT1078_0x9B00Test() + { + 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 Test1() + { + var GnssDatas = Enumerable.Range(0, 36).Select(m => (byte)m).ToArray(); + var AuthorizeCodes = Enumerable.Range(0, 64).Select(m => (byte)m).ToArray(); + JT809_JT1078_0x9B00 jT809_JT1078_0x9B00 = new JT809_JT1078_0x9B00() + { + VehicleNo = "粤B12345", + VehicleColor = Protocol.Enums.JT809VehicleColorType.黄色, + SubBusinessType = (ushort)JT809_JT1078_SubBusinessType.远程录像下载请求消息, + SubBodies = new JT809_JT1078_0x9B00_0x9B01() { + AuthorizeCode = AuthorizeCodes, + GnssData = GnssDatas, + AVItemType = 1, + ChannelId = 2, + MemType = 3, + StreamType = 4, + StartTime = Convert.ToDateTime("2017-07-16 10:10:10"), + EndTime = Convert.ToDateTime("2017-07-17 10:10:10"), + AlarmType=5, + FileSize=6 + } + }; + var str = Newtonsoft.Json.JsonConvert.SerializeObject(jT809_JT1078_0x9B00); + var hex = JT809Serializer.Serialize(jT809_JT1078_0x9B00).ToHexString(); + Assert.Equal("D4C142313233343500000000000000000000000000029B01000000840200000000596ACB0200000000596C1C82000000000000000501040300000006000102030405060708090A0B0C0D0E0F101112131415161718191A1B1C1D1E1F202122232425262728292A2B2C2D2E2F303132333435363738393A3B3C3D3E3F000102030405060708090A0B0C0D0E0F101112131415161718191A1B1C1D1E1F20212223", hex); + } + + [Fact] + public void Test2() + { + var str = "{\"VehicleNo\":\"粤B12345\",\"VehicleColor\":2,\"SubBusinessType\":39681,\"DataLength\":132,\"SubBodies\":{\"ChannelId\":2,\"StartTime\":\"2017-07-16 10:10:10\",\"EndTime\":\"2017-07-17 10:10:10\",\"AlarmType\":5,\"AVItemType\":1,\"StreamType\":4,\"MemType\":3,\"FileSize\":6,\"AuthorizeCode\":\"AAECAwQFBgcICQoLDA0ODxAREhMUFRYXGBkaGxwdHh8gISIjJCUmJygpKissLS4vMDEyMzQ1Njc4OTo7PD0+Pw==\",\"GnssData\":\"AAECAwQFBgcICQoLDA0ODxAREhMUFRYXGBkaGxwdHh8gISIj\"}}"; + var jT809_JT1078_0x9B00 = JT809Serializer.Deserialize("D4C142313233343500000000000000000000000000029B01000000840200000000596ACB0200000000596C1C82000000000000000501040300000006000102030405060708090A0B0C0D0E0F101112131415161718191A1B1C1D1E1F202122232425262728292A2B2C2D2E2F303132333435363738393A3B3C3D3E3F000102030405060708090A0B0C0D0E0F101112131415161718191A1B1C1D1E1F20212223".ToHexBytes()); + Assert.Equal(Newtonsoft.Json.JsonConvert.SerializeObject(jT809_JT1078_0x9B00), str); + } + + [Fact] + public void Test3() + { + JT809_JT1078_0x9B00 jT809_JT1078_0x9B00 = new JT809_JT1078_0x9B00() + { + VehicleNo = "粤B12345", + VehicleColor = Protocol.Enums.JT809VehicleColorType.黄色, + SubBusinessType = (ushort)JT809_JT1078_SubBusinessType.远程录像下载完成通知应答消息, + SubBodies = new JT809_JT1078_0x9B00_0x9B02() { + Result=1, + SessionId=2 + } + }; + var str = Newtonsoft.Json.JsonConvert.SerializeObject(jT809_JT1078_0x9B00); + var hex = JT809Serializer.Serialize(jT809_JT1078_0x9B00).ToHexString(); + Assert.Equal("D4C142313233343500000000000000000000000000029B0200000003010002", hex); + } + + [Fact] + public void Test4() + { + var str = "{\"VehicleNo\":\"粤B12345\",\"VehicleColor\":2,\"SubBusinessType\":39682,\"DataLength\":3,\"SubBodies\":{\"Result\":1,\"SessionId\":2}}"; + var jT809_JT1078_0x9B00 = JT809Serializer.Deserialize("D4C142313233343500000000000000000000000000029B0200000003010002".ToHexBytes()); + Assert.Equal(Newtonsoft.Json.JsonConvert.SerializeObject(jT809_JT1078_0x9B00), str); + } + [Fact] + public void Test5() + { + JT809_JT1078_0x9B00 jT809_JT1078_0x9B00 = new JT809_JT1078_0x9B00() + { + VehicleNo = "粤B12345", + VehicleColor = Protocol.Enums.JT809VehicleColorType.黄色, + SubBusinessType = (ushort)JT809_JT1078_SubBusinessType.远程录像下载控制消息, + SubBodies = new JT809_JT1078_0x9B00_0x9B03() + { + Type=1, + SessionId = 2 + } + }; + var str = Newtonsoft.Json.JsonConvert.SerializeObject(jT809_JT1078_0x9B00); + var hex = JT809Serializer.Serialize(jT809_JT1078_0x9B00).ToHexString(); + Assert.Equal("D4C142313233343500000000000000000000000000029B0300000003000201", hex); + } + + [Fact] + public void Test6() + { + var str = "{\"VehicleNo\":\"粤B12345\",\"VehicleColor\":2,\"SubBusinessType\":39683,\"DataLength\":3,\"SubBodies\":{\"SessionId\":2,\"Type\":1}}"; + var jT809_JT1078_0x9B00 = JT809Serializer.Deserialize("D4C142313233343500000000000000000000000000029B0300000003000201".ToHexBytes()); + Assert.Equal(Newtonsoft.Json.JsonConvert.SerializeObject(jT809_JT1078_0x9B00), str); + } + } +} diff --git a/src/JT809.Protocol.Extensions.JT1078/DependencyInjectionExtensions.cs b/src/JT809.Protocol.Extensions.JT1078/DependencyInjectionExtensions.cs new file mode 100644 index 0000000..e98a5c8 --- /dev/null +++ b/src/JT809.Protocol.Extensions.JT1078/DependencyInjectionExtensions.cs @@ -0,0 +1,59 @@ +using JT809.Protocol.Extensions.JT1078.Enums; +using JT809.Protocol.Extensions.JT1078.MessageBody; +using System; +using System.Collections.Generic; +using System.Reflection; +using System.Text; + +namespace JT809.Protocol.Extensions.JT1078 +{ + public static class DependencyInjectionExtensions + { + public static IJT809Builder AddJT1078Configure(this IJT809Builder iJT809Builder) + { + iJT809Builder.Config.Register(Assembly.GetExecutingAssembly()); +#warning 不知道是不是jt1078协议的809结构有问题,先按交换的格式(少了数据交换的头部) + iJT809Builder.Config.BusinessTypeFactory.SetMap((ushort)JT809_JT1078_BusinessType.主链路时效口令业务类); + iJT809Builder.Config.SubBusinessTypeFactory.SetMap((ushort)JT809_JT1078_SubBusinessType.时效口令上报消息); + iJT809Builder.Config.SubBusinessTypeFactory.SetMap((ushort)JT809_JT1078_SubBusinessType.时效口令请求消息); + + iJT809Builder.Config.BusinessTypeFactory.SetMap((ushort)JT809_JT1078_BusinessType.主链路实时音视频业务类); + iJT809Builder.Config.SubBusinessTypeFactory.SetMap((ushort)JT809_JT1078_SubBusinessType.实时音视频请求应答消息); + iJT809Builder.Config.SubBusinessTypeFactory.SetMap((ushort)JT809_JT1078_SubBusinessType.主动请求停止实时音视频传输应答消息); + + iJT809Builder.Config.BusinessTypeFactory.SetMap((ushort)JT809_JT1078_BusinessType.主链路远程录像检索业务类); + iJT809Builder.Config.SubBusinessTypeFactory.SetMap((ushort)JT809_JT1078_SubBusinessType.主动上传音视频资源目录信息消息); + iJT809Builder.Config.SubBusinessTypeFactory.SetMap((ushort)JT809_JT1078_SubBusinessType.查询音视频资源目录应答消息); + + iJT809Builder.Config.BusinessTypeFactory.SetMap((ushort)JT809_JT1078_BusinessType.主链路远程录像回放业务类); + iJT809Builder.Config.SubBusinessTypeFactory.SetMap((ushort)JT809_JT1078_SubBusinessType.远程录像回放请求应答消息); + iJT809Builder.Config.SubBusinessTypeFactory.SetMap((ushort)JT809_JT1078_SubBusinessType.远程录像回放控制应答消息); + + iJT809Builder.Config.BusinessTypeFactory.SetMap((ushort)JT809_JT1078_BusinessType.主链路远程录像下载业务类); + iJT809Builder.Config.SubBusinessTypeFactory.SetMap((ushort)JT809_JT1078_SubBusinessType.远程录像下载请求应答消息); + iJT809Builder.Config.SubBusinessTypeFactory.SetMap((ushort)JT809_JT1078_SubBusinessType.远程录像下载通知消息); + iJT809Builder.Config.SubBusinessTypeFactory.SetMap((ushort)JT809_JT1078_SubBusinessType.远程录像下载控制应答消息); + + iJT809Builder.Config.BusinessTypeFactory.SetMap((ushort)JT809_JT1078_BusinessType.从链路时效口令业务类); + iJT809Builder.Config.SubBusinessTypeFactory.SetMap((ushort)JT809_JT1078_SubBusinessType.时效口令请求应答消息); + + iJT809Builder.Config.BusinessTypeFactory.SetMap((ushort)JT809_JT1078_BusinessType.从链路实时音视频业务类); + iJT809Builder.Config.SubBusinessTypeFactory.SetMap((ushort)JT809_JT1078_SubBusinessType.实时音视频请求消息); + iJT809Builder.Config.SubBusinessTypeFactory.SetMap((ushort)JT809_JT1078_SubBusinessType.主动请求停止实时音视频传输消息); + + iJT809Builder.Config.BusinessTypeFactory.SetMap((ushort)JT809_JT1078_BusinessType.从链路远程录像检索业务类); + iJT809Builder.Config.SubBusinessTypeFactory.SetMap((ushort)JT809_JT1078_SubBusinessType.主动上传音视频资源目录信息应答消息); + iJT809Builder.Config.SubBusinessTypeFactory.SetMap((ushort)JT809_JT1078_SubBusinessType.查询音视频资源目录请求消息); + + iJT809Builder.Config.BusinessTypeFactory.SetMap((ushort)JT809_JT1078_BusinessType.从链路远程录像回放业务类); + iJT809Builder.Config.SubBusinessTypeFactory.SetMap((ushort)JT809_JT1078_SubBusinessType.远程录像回放请求消息); + iJT809Builder.Config.SubBusinessTypeFactory.SetMap((ushort)JT809_JT1078_SubBusinessType.远程录像回放控制消息); + + iJT809Builder.Config.BusinessTypeFactory.SetMap((ushort)JT809_JT1078_BusinessType.从链路远程录像下载业务类); + iJT809Builder.Config.SubBusinessTypeFactory.SetMap((ushort)JT809_JT1078_SubBusinessType.远程录像下载请求消息); + iJT809Builder.Config.SubBusinessTypeFactory.SetMap((ushort)JT809_JT1078_SubBusinessType.远程录像下载完成通知应答消息); + iJT809Builder.Config.SubBusinessTypeFactory.SetMap((ushort)JT809_JT1078_SubBusinessType.远程录像下载控制消息); + return iJT809Builder; + } + } +} diff --git a/src/JT809.Protocol.Extensions.JT1078/Enums/JT809_JT1078_BusinessType.cs b/src/JT809.Protocol.Extensions.JT1078/Enums/JT809_JT1078_BusinessType.cs new file mode 100644 index 0000000..e7659c9 --- /dev/null +++ b/src/JT809.Protocol.Extensions.JT1078/Enums/JT809_JT1078_BusinessType.cs @@ -0,0 +1,93 @@ +using JT809.Protocol.Attributes; +using JT809.Protocol.Extensions.JT1078.MessageBody; +using System; +using System.Collections.Generic; +using System.ComponentModel; +using System.Text; + +namespace JT809.Protocol.Extensions.JT1078.Enums +{ + public enum JT809_JT1078_BusinessType : ushort + { + /// + ///主链路时效口令业务类 + ///UP_AUTHORIZE_MSG + /// + [Description("主链路时效口令业务类")] + [JT809BodiesType(typeof(JT809_JT1078_0x1700))] + [JT809BusinessTypeDescription("UP_AUTHORIZE_MSG", "主链路时效口令业务类")] + 主链路时效口令业务类 = 0x1700, + /// + ///从链路时效口令业务类 + ///DOWN_AUTHORIZE_MSG + /// + [Description("从链路时效口令业务类")] + [JT809BodiesType(typeof(JT809_JT1078_0x9700))] + [JT809BusinessTypeDescription("DOWN_AUTHORIZE_MSG", "从链路时效口令业务类")] + 从链路时效口令业务类 = 0x9700, + /// + ///主链路实时音视频业务类 + ///UP_REALVIDEO_MSG + /// + [Description("主链路实时音视频业务类")] + [JT809BodiesType(typeof(JT809_JT1078_0x1800))] + [JT809BusinessTypeDescription("UP_REALVIDEO_MSG", "主链路实时音视频业务类")] + 主链路实时音视频业务类 = 0x1800, + /// + ///从链路实时音视频业务类 + ///DOWN_REALVIDEO_MSG + /// + [Description("从链路实时音视频业务类")] + [JT809BodiesType(typeof(JT809_JT1078_0x9800))] + [JT809BusinessTypeDescription("DOWN_REALVIDEO_MSG", "从链路实时音视频业务类")] + 从链路实时音视频业务类 = 0x9800, + /// + ///主链路远程录像检索业务类 + ///UP_SEARCH_MSG + /// + [Description("主链路远程录像检索业务类")] + [JT809BodiesType(typeof(JT809_JT1078_0x1900))] + [JT809BusinessTypeDescription("UP_SEARCH_MSG", "主链路远程录像检索业务类")] + 主链路远程录像检索业务类 = 0x1900, + /// + ///从链路远程录像检索业务类 + ///DOWN_SEARCH_MSG + /// + [Description("从链路远程录像检索业务类")] + [JT809BodiesType(typeof(JT809_JT1078_0x9900))] + [JT809BusinessTypeDescription("DOWN_SEARCH_MSG", "从链路远程录像检索业务类")] + 从链路远程录像检索业务类 = 0x9900, + /// + ///主链路远程录像回放业务类 + ///UP_PLAYBACK_MSG + /// + [Description("主链路远程录像回放业务类")] + [JT809BodiesType(typeof(JT809_JT1078_0x1A00))] + [JT809BusinessTypeDescription("UP_PLAYBACK_MSG", "主链路远程录像回放业务类")] + 主链路远程录像回放业务类 = 0x1A00, + /// + ///从链路远程录像回放业务类 + ///DOWN_PLAYBACK_MSG + /// + [Description("从链路远程录像回放业务类")] + [JT809BodiesType(typeof(JT809_JT1078_0x9A00))] + [JT809BusinessTypeDescription("DOWN_PLAYBACK_MSG", "从链路远程录像回放业务类")] + 从链路远程录像回放业务类 = 0x9A00, + /// + ///主链路远程录像下载业务类 + ///UP_DOWNLOAD_MSG + /// + [Description("主链路远程录像下载业务类")] + [JT809BodiesType(typeof(JT809_JT1078_0x1B00))] + [JT809BusinessTypeDescription("UP_DOWNLOAD_MSG", "主链路远程录像下载业务类")] + 主链路远程录像下载业务类 = 0x1B00, + /// + ///从链路远程录像下载业务类 + ///DOWN_DOWNLOAD_MSG + /// + [Description("从链路远程录像下载业务类")] + [JT809BodiesType(typeof(JT809_JT1078_0x9B00))] + [JT809BusinessTypeDescription("DOWN_DOWNLOAD_MSG", "从链路远程录像下载业务类")] + 从链路远程录像下载业务类 = 0x9B00, + } +} diff --git a/src/JT809.Protocol.Extensions.JT1078/Enums/JT809_JT1078_SubBusinessType.cs b/src/JT809.Protocol.Extensions.JT1078/Enums/JT809_JT1078_SubBusinessType.cs new file mode 100644 index 0000000..ada8b14 --- /dev/null +++ b/src/JT809.Protocol.Extensions.JT1078/Enums/JT809_JT1078_SubBusinessType.cs @@ -0,0 +1,181 @@ +using JT809.Protocol.Attributes; +using JT809.Protocol.Extensions.JT1078.MessageBody; +using System; +using System.Collections.Generic; +using System.ComponentModel; +using System.Text; + +namespace JT809.Protocol.Extensions.JT1078.Enums +{ + public enum JT809_JT1078_SubBusinessType : ushort + { + /// + ///时效口令上报消息 + ///UP_AUTHRIZE_MSG_STARTUP + /// + [Description("时效口令上报消息")] + [JT809BodiesType(typeof(JT809_JT1078_0x1700_0x1701))] + [JT809BusinessTypeDescription("UP_AUTHRIZE_MSG_STARTUP", "时效口令上报消息")] + 时效口令上报消息 = 0x1701, + /// + ///时效口令请求消息 + ///UP_AUTHRIZE_MSG_STARTUP_REQ + /// + [Description("时效口令请求消息")] + [JT809BodiesType(typeof(JT809_JT1078_0x1700_0x1702))] + [JT809BusinessTypeDescription("UP_AUTHRIZE_MSG_STARTUP_REQ", "时效口令请求消息")] + 时效口令请求消息 = 0x1702, + /// + ///时效口令请求应答消息 + ///DOWN_AUTHRIZE_MSG_STARTUP_REQ_ACK + /// + [Description("时效口令请求应答消息")] + [JT809BodiesType(typeof(JT809_JT1078_0x9700_0x9702))] + [JT809BusinessTypeDescription("DOWN_AUTHRIZE_MSG_STARTUP_REQ_ACK", "时效口令请求应答消息")] + 时效口令请求应答消息 = 0x9702, + /// + ///实时音视频请求应答消息 + ///UP_REALVIDEO_MSG_STARTUP_ACK + /// + [Description("实时音视频请求应答消息")] + [JT809BodiesType(typeof(JT809_JT1078_0x1800_0x1801))] + [JT809BusinessTypeDescription("UP_REALVIDEO_MSG_STARTUP_ACK", "实时音视频请求应答消息")] + 实时音视频请求应答消息 = 0x1801, + /// + ///主动请求停止实时音视频传输应答消息 + ///UP_REALVIDEO_MSG_END_ACK + /// + [Description("主动请求停止实时音视频传输应答消息")] + [JT809BodiesType(typeof(JT809_JT1078_0x1800_0x1802))] + [JT809BusinessTypeDescription("UP_REALVIDEO_MSG_END_ACK", "主动请求停止实时音视频传输应答消息")] + 主动请求停止实时音视频传输应答消息 = 0x1802, + /// + ///实时音视频请求消息 + ///DOWN_REALVIDEO_MSG_STARTUP + /// + [Description("实时音视频请求消息")] + [JT809BodiesType(typeof(JT809_JT1078_0x9800_0x9801))] + [JT809BusinessTypeDescription("DOWN_REALVIDEO_MSG_STARTUP", "实时音视频请求消息")] + 实时音视频请求消息 = 0x9801, + /// + ///主动请求停止实时音视频传输消息 + ///DOWN_REALVIDEO_MSG_END + /// + [Description("主动请求停止实时音视频传输消息")] + [JT809BodiesType(typeof(JT809_JT1078_0x9800_0x9802))] + [JT809BusinessTypeDescription("DOWN_REALVIDEO_MSG_END", "主动请求停止实时音视频传输消息")] + 主动请求停止实时音视频传输消息 = 0x9802, + /// + ///主动上传音视频资源目录信息消息 + ///UP_FILELIST_MSG + /// + [Description("主动上传音视频资源目录信息消息")] + [JT809BodiesType(typeof(JT809_JT1078_0x1900_0x1901))] + [JT809BusinessTypeDescription("UP_FILELIST_MSG", "主动上传音视频资源目录信息消息")] + 主动上传音视频资源目录信息消息 = 0x1901, + /// + ///查询音视频资源目录应答消息 + ///UP_REALVIDEO_FILELIST_REQ_ACK + /// + [Description("查询音视频资源目录应答消息")] + [JT809BodiesType(typeof(JT809_JT1078_0x1900_0x1902))] + [JT809BusinessTypeDescription("UP_REALVIDEO_FILELIST_REQ_ACK", "查询音视频资源目录应答消息")] + 查询音视频资源目录应答消息 = 0x1902, + /// + ///主动上传音视频资源目录信息应答消息 + ///DOWN_FILELIST_MSG_ACK + /// + [Description("主动上传音视频资源目录信息应答消息")] + [JT809BodiesType(typeof(JT809_JT1078_0x9900_0x9901))] + [JT809BusinessTypeDescription("DOWN_FILELIST_MSG_ACK", "主动上传音视频资源目录信息应答消息")] + 主动上传音视频资源目录信息应答消息 = 0x9901, + /// + /// 查询音视频资源目录请求消息 + ///DOWN_REALVIDEO_FILELIST_REQ + /// + [Description("查询音视频资源目录请求消息")] + [JT809BodiesType(typeof(JT809_JT1078_0x9900_0x9902))] + [JT809BusinessTypeDescription("DOWN_REALVIDEO_FILELIST_REQ", "查询音视频资源目录请求消息")] + 查询音视频资源目录请求消息 = 0x9902, + /// + ///远程录像回放请求应答消息 + ///UP_PLAYBACK_MSG_STARTUP_ACK + /// + [Description("远程录像回放请求应答消息")] + [JT809BodiesType(typeof(JT809_JT1078_0x1A00_0x1A01))] + [JT809BusinessTypeDescription("UP_PLAYBACK_MSG_STARTUP_ACK", "远程录像回放请求应答消息")] + 远程录像回放请求应答消息 = 0x1A01, + /// + ///远程录像回放控制应答消息 + ///UP_PLAYBACK_MSG_CONTROL_ACK + /// + [Description("远程录像回放控制应答消息")] + [JT809BodiesType(typeof(JT809_JT1078_0x1A00_0x1A02))] + [JT809BusinessTypeDescription("UP_PLAYBACK_MSG_CONTROL_ACK", "远程录像回放控制应答消息")] + 远程录像回放控制应答消息 = 0x1A02, + /// + ///远程录像回放请求消息 + ///DOWN_PLAYBACK_MSG_STARTUP + /// + [Description("远程录像回放请求消息")] + [JT809BodiesType(typeof(JT809_JT1078_0x9A00_0x9A01))] + [JT809BusinessTypeDescription("DOWN_PLAYBACK_MSG_STARTUP", "远程录像回放请求消息")] + 远程录像回放请求消息 = 0x9A01, + /// + ///远程录像回放控制消息 + ///DOWN_PLAYBACK_MSG_CONTROL + /// + [Description("远程录像回放控制消息")] + [JT809BodiesType(typeof(JT809_JT1078_0x9A00_0x9A02))] + [JT809BusinessTypeDescription("DOWN_PLAYBACK_MSG_CONTROL", "远程录像回放控制消息")] + 远程录像回放控制消息 = 0x9A02, + /// + ///远程录像下载请求应答消息 + ///UP_DOWNLOAD_MSG_STARTUP_ACK + /// + [Description("远程录像下载请求应答消息")] + [JT809BodiesType(typeof(JT809_JT1078_0x1B00_0x1B01))] + [JT809BusinessTypeDescription("UP_DOWNLOAD_MSG_STARTUP_ACK", "远程录像下载请求应答消息")] + 远程录像下载请求应答消息 = 0x1B01, + /// + ///远程录像下载通知消息 + ///UP_DOWNLOAD_MSG_END_INFORM + /// + [Description("远程录像下载通知消息")] + [JT809BodiesType(typeof(JT809_JT1078_0x1B00_0x1B02))] + [JT809BusinessTypeDescription("UP_DOWNLOAD_MSG_END_INFORM", "远程录像下载通知消息")] + 远程录像下载通知消息 = 0x1B02, + /// + ///远程录像下载控制应答消息 + ///UP_DOWNLOAD_MSG_CONTROL_ACK + /// + [Description("远程录像下载控制应答消息")] + [JT809BodiesType(typeof(JT809_JT1078_0x1B00_0x1B03))] + [JT809BusinessTypeDescription("UP_DOWNLOAD_MSG_CONTROL_ACK", "远程录像下载控制应答消息")] + 远程录像下载控制应答消息 = 0x1B03, + /// + ///远程录像下载请求消息 + ///DOWN_DOWNLOAD_MSG_STARTUP + /// + [Description("远程录像下载请求消息")] + [JT809BodiesType(typeof(JT809_JT1078_0x9B00_0x9B01))] + [JT809BusinessTypeDescription("DOWN_DOWNLOAD_MSG_STARTUP", "远程录像下载请求消息")] + 远程录像下载请求消息 = 0x9B01, + /// + ///远程录像下载完成通知应答消息 + ///UP_DWONLOAD_MSG_END_INFORM_ACK + /// + [Description("远程录像下载完成通知应答消息")] + [JT809BodiesType(typeof(JT809_JT1078_0x9B00_0x9B02))] + [JT809BusinessTypeDescription("UP_DWONLOAD_MSG_END_INFORM_ACK", "远程录像下载完成通知应答消息")] + 远程录像下载完成通知应答消息 = 0x9B02, + /// + ///远程录像下载控制消息 + ///DWON_DOWNLOAD_MSG_CONTROL + /// + [Description("远程录像下载控制消息")] + [JT809BodiesType(typeof(JT809_JT1078_0x9B00_0x9B03))] + [JT809BusinessTypeDescription("DWON_DOWNLOAD_MSG_CONTROL", "远程录像下载控制消息")] + 远程录像下载控制消息 = 0x9B03, + } +} diff --git a/src/JT809.Protocol.Extensions.JT1078/Extensions/JT809MessagePackReaderExtentsion.cs b/src/JT809.Protocol.Extensions.JT1078/Extensions/JT809MessagePackReaderExtentsion.cs new file mode 100644 index 0000000..c395be6 --- /dev/null +++ b/src/JT809.Protocol.Extensions.JT1078/Extensions/JT809MessagePackReaderExtentsion.cs @@ -0,0 +1,12 @@ +using JT809.Protocol.MessagePack; +using System; +using System.Collections.Generic; +using System.Text; + +namespace JT809.Protocol.Extensions.JT1078.Extensions +{ + public static class JT809MessagePackReaderExtentsion + { + + } +} diff --git a/src/JT809.Protocol.Extensions.JT1078/Formatters/JT809_JT1078_0x1700_0x1701_Formatter.cs b/src/JT809.Protocol.Extensions.JT1078/Formatters/JT809_JT1078_0x1700_0x1701_Formatter.cs new file mode 100644 index 0000000..490b1bb --- /dev/null +++ b/src/JT809.Protocol.Extensions.JT1078/Formatters/JT809_JT1078_0x1700_0x1701_Formatter.cs @@ -0,0 +1,28 @@ +using JT809.Protocol.Extensions.JT1078.MessageBody; +using JT809.Protocol.Formatters; +using JT809.Protocol.MessagePack; +using System; +using System.Collections.Generic; +using System.Text; + +namespace JT809.Protocol.Extensions.JT1078.Formatters +{ + public class JT809_JT1078_0x1700_0x1701_Formatter : IJT809MessagePackFormatter + { + 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; + } + + 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); + } + } +} \ No newline at end of file diff --git a/src/JT809.Protocol.Extensions.JT1078/Formatters/JT809_JT1078_0x1700_0x1702_Formatter.cs b/src/JT809.Protocol.Extensions.JT1078/Formatters/JT809_JT1078_0x1700_0x1702_Formatter.cs new file mode 100644 index 0000000..1baf11c --- /dev/null +++ b/src/JT809.Protocol.Extensions.JT1078/Formatters/JT809_JT1078_0x1700_0x1702_Formatter.cs @@ -0,0 +1,22 @@ +using JT809.Protocol.Extensions.JT1078.MessageBody; +using JT809.Protocol.Formatters; +using JT809.Protocol.MessagePack; +using System; +using System.Collections.Generic; +using System.Text; + +namespace JT809.Protocol.Extensions.JT1078.Formatters +{ + public class JT809_JT1078_0x1700_0x1702_Formatter : IJT809MessagePackFormatter + { + public void Serialize(ref JT809MessagePackWriter writer, JT809_JT1078_0x1700_0x1702 value, IJT809Config config) + { + + } + + public JT809_JT1078_0x1700_0x1702 Deserialize(ref JT809MessagePackReader reader, IJT809Config config) + { + return new JT809_JT1078_0x1700_0x1702(); + } + } +} \ No newline at end of file diff --git a/src/JT809.Protocol.Extensions.JT1078/Formatters/JT809_JT1078_0x1800_0x1801_Formatter.cs b/src/JT809.Protocol.Extensions.JT1078/Formatters/JT809_JT1078_0x1800_0x1801_Formatter.cs new file mode 100644 index 0000000..7436eb1 --- /dev/null +++ b/src/JT809.Protocol.Extensions.JT1078/Formatters/JT809_JT1078_0x1800_0x1801_Formatter.cs @@ -0,0 +1,28 @@ +using JT809.Protocol.Extensions.JT1078.MessageBody; +using JT809.Protocol.Formatters; +using JT809.Protocol.MessagePack; +using System; +using System.Collections.Generic; +using System.Text; + +namespace JT809.Protocol.Extensions.JT1078.Formatters +{ + public class JT809_JT1078_0x1800_0x1801_Formatter : IJT809MessagePackFormatter + { + 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; + } + + public void Serialize(ref JT809MessagePackWriter writer, JT809_JT1078_0x1800_0x1801 value, IJT809Config config) + { + writer.WriteByte(value.Result); + writer.WriteStringPadLeft(value.ServerIp,32); + writer.WriteUInt16(value.ServerPort); + } + } +} diff --git a/src/JT809.Protocol.Extensions.JT1078/Formatters/JT809_JT1078_0x1800_0x1802_Formatter.cs b/src/JT809.Protocol.Extensions.JT1078/Formatters/JT809_JT1078_0x1800_0x1802_Formatter.cs new file mode 100644 index 0000000..f930c3a --- /dev/null +++ b/src/JT809.Protocol.Extensions.JT1078/Formatters/JT809_JT1078_0x1800_0x1802_Formatter.cs @@ -0,0 +1,24 @@ +using JT809.Protocol.Extensions.JT1078.MessageBody; +using JT809.Protocol.Formatters; +using JT809.Protocol.MessagePack; +using System; +using System.Collections.Generic; +using System.Text; + +namespace JT809.Protocol.Extensions.JT1078.Formatters +{ + public class JT809_JT1078_0x1800_0x1802_Formatter : IJT809MessagePackFormatter + { + 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; + } + + public void Serialize(ref JT809MessagePackWriter writer, JT809_JT1078_0x1800_0x1802 value, IJT809Config config) + { + writer.WriteByte(value.Result); + } + } +} diff --git a/src/JT809.Protocol.Extensions.JT1078/Formatters/JT809_JT1078_0x1900_0x1901_Formatter.cs b/src/JT809.Protocol.Extensions.JT1078/Formatters/JT809_JT1078_0x1900_0x1901_Formatter.cs new file mode 100644 index 0000000..8f124ae --- /dev/null +++ b/src/JT809.Protocol.Extensions.JT1078/Formatters/JT809_JT1078_0x1900_0x1901_Formatter.cs @@ -0,0 +1,43 @@ +using JT809.Protocol.Extensions.JT1078.MessageBody; +using JT809.Protocol.Formatters; +using JT809.Protocol.MessagePack; +using System; +using System.Collections.Generic; +using System.Text; + +namespace JT809.Protocol.Extensions.JT1078.Formatters +{ + public class JT809_JT1078_0x1900_0x1901_Formatter : IJT809MessagePackFormatter + { + 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) + { + List jT808_JT1078_0x1900_0x1901_RecordList = new List(); + var formatter = config.GetMessagePackFormatter(); + for (int i = 0; i < jT808_JT1078_0x1900_0x1901.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; + } + return jT808_JT1078_0x1900_0x1901; + } + + public void Serialize(ref JT809MessagePackWriter writer, JT809_JT1078_0x1900_0x1901 value, IJT809Config config) + { + writer.WriteUInt32(value.ItemNum); + if (value.ItemList.Count > 0) + { + var formatter = config.GetMessagePackFormatter(); + foreach (var item in value.ItemList) + { + formatter.Serialize(ref writer, item, config); + } + } + } + } +} diff --git a/src/JT809.Protocol.Extensions.JT1078/Formatters/JT809_JT1078_0x1900_0x1901_Record_Formatter.cs b/src/JT809.Protocol.Extensions.JT1078/Formatters/JT809_JT1078_0x1900_0x1901_Record_Formatter.cs new file mode 100644 index 0000000..5116aa0 --- /dev/null +++ b/src/JT809.Protocol.Extensions.JT1078/Formatters/JT809_JT1078_0x1900_0x1901_Record_Formatter.cs @@ -0,0 +1,38 @@ +using JT809.Protocol.Extensions.JT1078.MessageBody; +using JT809.Protocol.Formatters; +using JT809.Protocol.MessagePack; +using System; +using System.Collections.Generic; +using System.Text; + +namespace JT809.Protocol.Extensions.JT1078.Formatters +{ + public class JT809_JT1078_0x1900_0x1901_Record_Formatter : IJT809MessagePackFormatter + { + 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; + } + + public void Serialize(ref JT809MessagePackWriter writer, JT809_JT1078_0x1900_Record value, IJT809Config config) + { + writer.WriteByte(value.ChannelId); + writer.WriteUTCDateTime(value.StartTime); + writer.WriteUTCDateTime(value.EndTime); + writer.WriteUInt64(value.AlarmType); + writer.WriteByte(value.AVItemType); + writer.WriteByte(value.StreamType); + writer.WriteByte(value.MemType); + writer.WriteUInt32(value.FileSize); + } + } +} diff --git a/src/JT809.Protocol.Extensions.JT1078/Formatters/JT809_JT1078_0x1900_0x1902_Formatter.cs b/src/JT809.Protocol.Extensions.JT1078/Formatters/JT809_JT1078_0x1900_0x1902_Formatter.cs new file mode 100644 index 0000000..6527131 --- /dev/null +++ b/src/JT809.Protocol.Extensions.JT1078/Formatters/JT809_JT1078_0x1900_0x1902_Formatter.cs @@ -0,0 +1,45 @@ +using JT809.Protocol.Extensions.JT1078.MessageBody; +using JT809.Protocol.Formatters; +using JT809.Protocol.MessagePack; +using System; +using System.Collections.Generic; +using System.Text; + +namespace JT809.Protocol.Extensions.JT1078.Formatters +{ + public class JT809_JT1078_0x1900_0x1902_Formatter : IJT809MessagePackFormatter + { + 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) + { + List jT808_JT1078_0x1900_0x1901_RecordList = new List(); + var formatter = config.GetMessagePackFormatter(); + for (int i = 0; i < jT808_JT1078_0x1900_0x1902.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; + } + return jT808_JT1078_0x1900_0x1902; + } + + public void Serialize(ref JT809MessagePackWriter writer, JT809_JT1078_0x1900_0x1902 value, IJT809Config config) + { + writer.WriteByte(value.Result); + writer.WriteUInt32(value.ItemNum); + if (value.ItemList.Count > 0) + { + var formatter = config.GetMessagePackFormatter(); + foreach (var item in value.ItemList) + { + formatter.Serialize(ref writer, item, config); + } + } + } + } +} \ No newline at end of file diff --git a/src/JT809.Protocol.Extensions.JT1078/Formatters/JT809_JT1078_0x1A00_0x1A01_Formatter.cs b/src/JT809.Protocol.Extensions.JT1078/Formatters/JT809_JT1078_0x1A00_0x1A01_Formatter.cs new file mode 100644 index 0000000..9b85060 --- /dev/null +++ b/src/JT809.Protocol.Extensions.JT1078/Formatters/JT809_JT1078_0x1A00_0x1A01_Formatter.cs @@ -0,0 +1,28 @@ +using JT809.Protocol.Extensions.JT1078.MessageBody; +using JT809.Protocol.Formatters; +using JT809.Protocol.MessagePack; +using System; +using System.Collections.Generic; +using System.Text; + +namespace JT809.Protocol.Extensions.JT1078.Formatters +{ + public class JT809_JT1078_0x1A00_0x1A01_Formatter : IJT809MessagePackFormatter + { + 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; + } + + 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); + } + } +} diff --git a/src/JT809.Protocol.Extensions.JT1078/Formatters/JT809_JT1078_0x1A00_0x1A02_Formatter.cs b/src/JT809.Protocol.Extensions.JT1078/Formatters/JT809_JT1078_0x1A00_0x1A02_Formatter.cs new file mode 100644 index 0000000..be91c39 --- /dev/null +++ b/src/JT809.Protocol.Extensions.JT1078/Formatters/JT809_JT1078_0x1A00_0x1A02_Formatter.cs @@ -0,0 +1,24 @@ +using JT809.Protocol.Extensions.JT1078.MessageBody; +using JT809.Protocol.Formatters; +using JT809.Protocol.MessagePack; +using System; +using System.Collections.Generic; +using System.Text; + +namespace JT809.Protocol.Extensions.JT1078.Formatters +{ + public class JT809_JT1078_0x1A00_0x1A02_Formatter : IJT809MessagePackFormatter + { + 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; + } + + public void Serialize(ref JT809MessagePackWriter writer, JT809_JT1078_0x1A00_0x1A02 value, IJT809Config config) + { + writer.WriteByte(value.Result); + } + } +} diff --git a/src/JT809.Protocol.Extensions.JT1078/Formatters/JT809_JT1078_0x1B00_0x1B01_Formatter.cs b/src/JT809.Protocol.Extensions.JT1078/Formatters/JT809_JT1078_0x1B00_0x1B01_Formatter.cs new file mode 100644 index 0000000..dc180f2 --- /dev/null +++ b/src/JT809.Protocol.Extensions.JT1078/Formatters/JT809_JT1078_0x1B00_0x1B01_Formatter.cs @@ -0,0 +1,26 @@ +using JT809.Protocol.Extensions.JT1078.MessageBody; +using JT809.Protocol.Formatters; +using JT809.Protocol.MessagePack; +using System; +using System.Collections.Generic; +using System.Text; + +namespace JT809.Protocol.Extensions.JT1078.Formatters +{ + public class JT809_JT1078_0x1B00_0x1B01_Formatter : IJT809MessagePackFormatter + { + 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; + } + + public void Serialize(ref JT809MessagePackWriter writer, JT809_JT1078_0x1B00_0x1B01 value, IJT809Config config) + { + writer.WriteByte(value.Result); + writer.WriteUInt16(value.SessionId); + } + } +} diff --git a/src/JT809.Protocol.Extensions.JT1078/Formatters/JT809_JT1078_0x1B00_0x1B02_Formatter.cs b/src/JT809.Protocol.Extensions.JT1078/Formatters/JT809_JT1078_0x1B00_0x1B02_Formatter.cs new file mode 100644 index 0000000..4d95056 --- /dev/null +++ b/src/JT809.Protocol.Extensions.JT1078/Formatters/JT809_JT1078_0x1B00_0x1B02_Formatter.cs @@ -0,0 +1,36 @@ +using JT809.Protocol.Extensions.JT1078.MessageBody; +using JT809.Protocol.Formatters; +using JT809.Protocol.MessagePack; +using System; +using System.Collections.Generic; +using System.Text; + +namespace JT809.Protocol.Extensions.JT1078.Formatters +{ + public class JT809_JT1078_0x1B00_0x1B02_Formatter : IJT809MessagePackFormatter + { + 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; + } + + public void Serialize(ref JT809MessagePackWriter writer, JT809_JT1078_0x1B00_0x1B02 value, IJT809Config config) + { + writer.WriteByte(value.Result); + writer.WriteUInt16(value.SessionId); + writer.WriteStringPadLeft(value.ServerIp, 32); + writer.WriteUInt16(value.TcpPort); + writer.WriteStringPadLeft(value.UserName, 49); + writer.WriteStringPadLeft(value.Password, 22); + writer.WriteStringPadLeft(value.FilePath, 200); + } + } +} diff --git a/src/JT809.Protocol.Extensions.JT1078/Formatters/JT809_JT1078_0x1B00_0x1B03_Formatter.cs b/src/JT809.Protocol.Extensions.JT1078/Formatters/JT809_JT1078_0x1B00_0x1B03_Formatter.cs new file mode 100644 index 0000000..cd0c6da --- /dev/null +++ b/src/JT809.Protocol.Extensions.JT1078/Formatters/JT809_JT1078_0x1B00_0x1B03_Formatter.cs @@ -0,0 +1,24 @@ +using JT809.Protocol.Extensions.JT1078.MessageBody; +using JT809.Protocol.Formatters; +using JT809.Protocol.MessagePack; +using System; +using System.Collections.Generic; +using System.Text; + +namespace JT809.Protocol.Extensions.JT1078.Formatters +{ + public class JT809_JT1078_0x1B00_0x1B03_Formatter : IJT809MessagePackFormatter + { + 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; + } + + public void Serialize(ref JT809MessagePackWriter writer, JT809_JT1078_0x1B00_0x1B03 value, IJT809Config config) + { + writer.WriteByte(value.Result); + } + } +} \ No newline at end of file diff --git a/src/JT809.Protocol.Extensions.JT1078/Formatters/JT809_JT1078_0x9700_0x9702_Formatter.cs b/src/JT809.Protocol.Extensions.JT1078/Formatters/JT809_JT1078_0x9700_0x9702_Formatter.cs new file mode 100644 index 0000000..08ef42f --- /dev/null +++ b/src/JT809.Protocol.Extensions.JT1078/Formatters/JT809_JT1078_0x9700_0x9702_Formatter.cs @@ -0,0 +1,22 @@ +using JT809.Protocol.Extensions.JT1078.MessageBody; +using JT809.Protocol.Formatters; +using JT809.Protocol.MessagePack; +using System; +using System.Collections.Generic; +using System.Text; + +namespace JT809.Protocol.Extensions.JT1078.Formatters +{ + public class JT809_JT1078_0x9700_0x9702_Formatter : IJT809MessagePackFormatter + { + public void Serialize(ref JT809MessagePackWriter writer, JT809_JT1078_0x9700_0x9702 value, IJT809Config config) + { + + } + + public JT809_JT1078_0x9700_0x9702 Deserialize(ref JT809MessagePackReader reader, IJT809Config config) + { + return new JT809_JT1078_0x9700_0x9702(); + } + } +} \ No newline at end of file diff --git a/src/JT809.Protocol.Extensions.JT1078/Formatters/JT809_JT1078_0x9800_0x9801_Formatter.cs b/src/JT809.Protocol.Extensions.JT1078/Formatters/JT809_JT1078_0x9800_0x9801_Formatter.cs new file mode 100644 index 0000000..de5dc2d --- /dev/null +++ b/src/JT809.Protocol.Extensions.JT1078/Formatters/JT809_JT1078_0x9800_0x9801_Formatter.cs @@ -0,0 +1,30 @@ +using JT809.Protocol.Extensions.JT1078.MessageBody; +using JT809.Protocol.Formatters; +using JT809.Protocol.MessagePack; +using System; +using System.Collections.Generic; +using System.Text; + +namespace JT809.Protocol.Extensions.JT1078.Formatters +{ + public class JT809_JT1078_0x9800_0x9801_Formatter : IJT809MessagePackFormatter + { + 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; + } + + 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.WriteArray(value.GnssData); + } + } +} diff --git a/src/JT809.Protocol.Extensions.JT1078/Formatters/JT809_JT1078_0x9800_0x9802_Formatter.cs b/src/JT809.Protocol.Extensions.JT1078/Formatters/JT809_JT1078_0x9800_0x9802_Formatter.cs new file mode 100644 index 0000000..97fc5ad --- /dev/null +++ b/src/JT809.Protocol.Extensions.JT1078/Formatters/JT809_JT1078_0x9800_0x9802_Formatter.cs @@ -0,0 +1,26 @@ +using JT809.Protocol.Extensions.JT1078.MessageBody; +using JT809.Protocol.Formatters; +using JT809.Protocol.MessagePack; +using System; +using System.Collections.Generic; +using System.Text; + +namespace JT809.Protocol.Extensions.JT1078.Formatters +{ + public class JT809_JT1078_0x9800_0x9802_Formatter : IJT809MessagePackFormatter + { + 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; + } + + public void Serialize(ref JT809MessagePackWriter writer, JT809_JT1078_0x9800_0x9802 value, IJT809Config config) + { + writer.WriteByte(value.ChannelId); + writer.WriteByte(value.AVitemType); + } + } +} diff --git a/src/JT809.Protocol.Extensions.JT1078/Formatters/JT809_JT1078_0x9900_0x9901_Formatter.cs b/src/JT809.Protocol.Extensions.JT1078/Formatters/JT809_JT1078_0x9900_0x9901_Formatter.cs new file mode 100644 index 0000000..a6b9cdc --- /dev/null +++ b/src/JT809.Protocol.Extensions.JT1078/Formatters/JT809_JT1078_0x9900_0x9901_Formatter.cs @@ -0,0 +1,26 @@ +using JT809.Protocol.Extensions.JT1078.MessageBody; +using JT809.Protocol.Formatters; +using JT809.Protocol.MessagePack; +using System; +using System.Collections.Generic; +using System.Text; + +namespace JT809.Protocol.Extensions.JT1078.Formatters +{ + public class JT809_JT1078_0x9900_0x9901_Formatter : IJT809MessagePackFormatter + { + 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; + } + + public void Serialize(ref JT809MessagePackWriter writer, JT809_JT1078_0x9900_0x9901 value, IJT809Config config) + { + writer.WriteByte(value.Result); + writer.WriteByte(value.ItemNumber); + } + } +} diff --git a/src/JT809.Protocol.Extensions.JT1078/Formatters/JT809_JT1078_0x9900_0x9902_Formatter.cs b/src/JT809.Protocol.Extensions.JT1078/Formatters/JT809_JT1078_0x9900_0x9902_Formatter.cs new file mode 100644 index 0000000..edfed9a --- /dev/null +++ b/src/JT809.Protocol.Extensions.JT1078/Formatters/JT809_JT1078_0x9900_0x9902_Formatter.cs @@ -0,0 +1,41 @@ +using JT809.Protocol.Extensions.JT1078.MessageBody; +using JT809.Protocol.Formatters; +using JT809.Protocol.MessagePack; +using System; +using System.Collections.Generic; +using System.Text; + +namespace JT809.Protocol.Extensions.JT1078.Formatters +{ + public class JT809_JT1078_0x9900_0x9902_Formatter : IJT809MessagePackFormatter + { + 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; + } + + public void Serialize(ref JT809MessagePackWriter writer, JT809_JT1078_0x9900_0x9902 value, IJT809Config config) + { + writer.WriteByte(value.ChannelId); + writer.WriteUTCDateTime(value.StartTime); + writer.WriteUTCDateTime(value.EndTime); + writer.WriteUInt64(value.AlarmType); + writer.WriteByte(value.AVItemType); + writer.WriteByte(value.StreamType); + writer.WriteByte(value.MemType); + writer.WriteArray(value.AuthorizeCode); + writer.WriteArray(value.GnssData); + } + } +} diff --git a/src/JT809.Protocol.Extensions.JT1078/Formatters/JT809_JT1078_0x9A00_0x9A01_Formatter.cs b/src/JT809.Protocol.Extensions.JT1078/Formatters/JT809_JT1078_0x9A00_0x9A01_Formatter.cs new file mode 100644 index 0000000..ca8d7c9 --- /dev/null +++ b/src/JT809.Protocol.Extensions.JT1078/Formatters/JT809_JT1078_0x9A00_0x9A01_Formatter.cs @@ -0,0 +1,38 @@ +using JT809.Protocol.Extensions.JT1078.MessageBody; +using JT809.Protocol.Formatters; +using JT809.Protocol.MessagePack; +using System; +using System.Collections.Generic; +using System.Text; + +namespace JT809.Protocol.Extensions.JT1078.Formatters +{ + public class JT809_JT1078_0x9A00_0x9A01_Formatter : IJT809MessagePackFormatter + { + 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; + } + + public void Serialize(ref JT809MessagePackWriter writer, JT809_JT1078_0x9A00_0x9A01 value, IJT809Config config) + { + writer.WriteByte(value.ChannelId); + writer.WriteByte(value.AVItemType); + writer.WriteByte(value.StreamType); + writer.WriteByte(value.MemType); + writer.WriteUTCDateTime(value.PlayBackStartTime); + writer.WriteUTCDateTime(value.PlayBackEndTime); + writer.WriteArray(value.AuthorizeCode); + writer.WriteArray(value.GnssData); + } + } +} \ No newline at end of file diff --git a/src/JT809.Protocol.Extensions.JT1078/Formatters/JT809_JT1078_0x9A00_0x9A02_Formatter.cs b/src/JT809.Protocol.Extensions.JT1078/Formatters/JT809_JT1078_0x9A00_0x9A02_Formatter.cs new file mode 100644 index 0000000..0821743 --- /dev/null +++ b/src/JT809.Protocol.Extensions.JT1078/Formatters/JT809_JT1078_0x9A00_0x9A02_Formatter.cs @@ -0,0 +1,28 @@ +using JT809.Protocol.Extensions.JT1078.MessageBody; +using JT809.Protocol.Formatters; +using JT809.Protocol.MessagePack; +using System; +using System.Collections.Generic; +using System.Text; + +namespace JT809.Protocol.Extensions.JT1078.Formatters +{ + public class JT809_JT1078_0x9A00_0x9A02_Formatter : IJT809MessagePackFormatter + { + 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; + } + + public void Serialize(ref JT809MessagePackWriter writer, JT809_JT1078_0x9A00_0x9A02 value, IJT809Config config) + { + writer.WriteByte(value.ControlType); + writer.WriteByte(value.FastTime); + writer.WriteUTCDateTime(value.DateTime); + } + } +} \ No newline at end of file diff --git a/src/JT809.Protocol.Extensions.JT1078/Formatters/JT809_JT1078_0x9B00_0x9B01_Formatter.cs b/src/JT809.Protocol.Extensions.JT1078/Formatters/JT809_JT1078_0x9B00_0x9B01_Formatter.cs new file mode 100644 index 0000000..d9577a1 --- /dev/null +++ b/src/JT809.Protocol.Extensions.JT1078/Formatters/JT809_JT1078_0x9B00_0x9B01_Formatter.cs @@ -0,0 +1,42 @@ +using JT809.Protocol.Extensions.JT1078.MessageBody; +using JT809.Protocol.Formatters; +using JT809.Protocol.MessagePack; +using System; +using System.Collections.Generic; +using System.Text; + +namespace JT809.Protocol.Extensions.JT1078.Formatters +{ + public class JT809_JT1078_0x9B00_0x9B01_Formatter : IJT809MessagePackFormatter + { + 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; + } + + public void Serialize(ref JT809MessagePackWriter writer, JT809_JT1078_0x9B00_0x9B01 value, IJT809Config config) + { + writer.WriteByte(value.ChannelId); + writer.WriteUTCDateTime(value.StartTime); + writer.WriteUTCDateTime(value.EndTime); + writer.WriteUInt64(value.AlarmType); + writer.WriteByte(value.AVItemType); + writer.WriteByte(value.StreamType); + writer.WriteByte(value.MemType); + writer.WriteUInt32(value.FileSize); + writer.WriteArray(value.AuthorizeCode); + writer.WriteArray(value.GnssData); + } + } +} diff --git a/src/JT809.Protocol.Extensions.JT1078/Formatters/JT809_JT1078_0x9B00_0x9B02_Formatter.cs b/src/JT809.Protocol.Extensions.JT1078/Formatters/JT809_JT1078_0x9B00_0x9B02_Formatter.cs new file mode 100644 index 0000000..d5d2a86 --- /dev/null +++ b/src/JT809.Protocol.Extensions.JT1078/Formatters/JT809_JT1078_0x9B00_0x9B02_Formatter.cs @@ -0,0 +1,26 @@ +using JT809.Protocol.Extensions.JT1078.MessageBody; +using JT809.Protocol.Formatters; +using JT809.Protocol.MessagePack; +using System; +using System.Collections.Generic; +using System.Text; + +namespace JT809.Protocol.Extensions.JT1078.Formatters +{ + public class JT809_JT1078_0x9B00_0x9B02_Formatter : IJT809MessagePackFormatter + { + 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; + } + + public void Serialize(ref JT809MessagePackWriter writer, JT809_JT1078_0x9B00_0x9B02 value, IJT809Config config) + { + writer.WriteByte(value.Result); + writer.WriteUInt16(value.SessionId); + } + } +} 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 new file mode 100644 index 0000000..7277144 --- /dev/null +++ b/src/JT809.Protocol.Extensions.JT1078/Formatters/JT809_JT1078_0x9B00_0x9B03_Formatter.cs @@ -0,0 +1,26 @@ +using JT809.Protocol.Extensions.JT1078.MessageBody; +using JT809.Protocol.Formatters; +using JT809.Protocol.MessagePack; +using System; +using System.Collections.Generic; +using System.Text; + +namespace JT809.Protocol.Extensions.JT1078.Formatters +{ + public class JT809_JT1078_0x9B00_0x9B03_Formatter : IJT809MessagePackFormatter + { + 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; + } + + public void Serialize(ref JT809MessagePackWriter writer, JT809_JT1078_0x9B00_0x9B03 value, IJT809Config config) + { + writer.WriteUInt16(value.SessionId); + writer.WriteByte(value.Type); + } + } +} diff --git a/src/JT809.Protocol.Extensions.JT1078/JT809.Protocol.Extensions.JT1078.csproj b/src/JT809.Protocol.Extensions.JT1078/JT809.Protocol.Extensions.JT1078.csproj new file mode 100644 index 0000000..d7e5944 --- /dev/null +++ b/src/JT809.Protocol.Extensions.JT1078/JT809.Protocol.Extensions.JT1078.csproj @@ -0,0 +1,33 @@ + + + + netstandard2.0 + 7.3 + Copyright 2019. + SmallChi(Koike) + JT809.Protocol.Extensions.JT1078 + JT809.Protocol.Extensions.JT1078 + 基于JT809协议、GB809协议扩展的视频消息协议 + 基于JT809协议、GB809协议扩展的视频消息协议 + true + https://github.com/SmallChi/JT1078 + https://github.com/SmallChi/JT1078 + https://github.com/SmallChi/JT1078/blob/master/LICENSE + https://github.com/SmallChi/JT1078/blob/master/LICENSE + false + 1.0.0 + LICENSE + + + + + True + + + + + + + + + diff --git a/src/JT809.Protocol.Extensions.JT1078/MessageBody/JT809_JT1078_0x1700.cs b/src/JT809.Protocol.Extensions.JT1078/MessageBody/JT809_JT1078_0x1700.cs new file mode 100644 index 0000000..29ef4d3 --- /dev/null +++ b/src/JT809.Protocol.Extensions.JT1078/MessageBody/JT809_JT1078_0x1700.cs @@ -0,0 +1,17 @@ +using JT809.Protocol.Attributes; +using JT809.Protocol.Formatters; +using System; +using System.Collections.Generic; +using System.Text; + +namespace JT809.Protocol.Extensions.JT1078.MessageBody +{ + /// + /// 主链路时效口令交互消息 + /// + [JT809Formatter(typeof(JT809BodiesFormatter))] + public class JT809_JT1078_0x1700 : JT809ExchangeMessageBodies + { + + } +} 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 new file mode 100644 index 0000000..50e11c7 --- /dev/null +++ b/src/JT809.Protocol.Extensions.JT1078/MessageBody/JT809_JT1078_0x1700_0x1701.cs @@ -0,0 +1,28 @@ +using JT809.Protocol.Attributes; +using JT809.Protocol.Extensions.JT1078.Formatters; +using System; +using System.Collections.Generic; +using System.Text; + +namespace JT809.Protocol.Extensions.JT1078.MessageBody +{ + /// + /// 时效口令上报消息 + /// + [JT809Formatter(typeof(JT809_JT1078_0x1700_0x1701_Formatter))] + public class JT809_JT1078_0x1700_0x1701 : JT809SubBodies + { + /// + /// 企业视频监控平台唯一编码,平台所属企业行政区域代码+平台公共编号 + /// + public byte[] PlateFormId { get; set; } + /// + /// 归属地区政府平台使用的时效口令 + /// + public byte[] AuthorizeCode1 { get; set; } + /// + /// 跨域地区政府平台使用的时效口令 + /// + public byte[] AuthorizeCode2 { get; set; } + } +} \ No newline at end of file diff --git a/src/JT809.Protocol.Extensions.JT1078/MessageBody/JT809_JT1078_0x1700_0x1702.cs b/src/JT809.Protocol.Extensions.JT1078/MessageBody/JT809_JT1078_0x1700_0x1702.cs new file mode 100644 index 0000000..c2ee189 --- /dev/null +++ b/src/JT809.Protocol.Extensions.JT1078/MessageBody/JT809_JT1078_0x1700_0x1702.cs @@ -0,0 +1,17 @@ +using JT809.Protocol.Attributes; +using JT809.Protocol.Extensions.JT1078.Formatters; +using System; +using System.Collections.Generic; +using System.Text; + +namespace JT809.Protocol.Extensions.JT1078.MessageBody +{ + /// + /// 时效口令请求消息 + /// + [JT809Formatter(typeof(JT809_JT1078_0x1700_0x1702_Formatter))] + public class JT809_JT1078_0x1700_0x1702 : JT809SubBodies + { + + } +} \ 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 new file mode 100644 index 0000000..98e8a63 --- /dev/null +++ b/src/JT809.Protocol.Extensions.JT1078/MessageBody/JT809_JT1078_0x1800.cs @@ -0,0 +1,17 @@ +using JT809.Protocol.Attributes; +using JT809.Protocol.Formatters; +using System; +using System.Collections.Generic; +using System.Text; + +namespace JT809.Protocol.Extensions.JT1078.MessageBody +{ + /// + /// 主链路实时音视频交互消息 + /// + [JT809Formatter(typeof(JT809BodiesFormatter))] + public class JT809_JT1078_0x1800 : JT809ExchangeMessageBodies + { + + } +} 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 new file mode 100644 index 0000000..dc67303 --- /dev/null +++ b/src/JT809.Protocol.Extensions.JT1078/MessageBody/JT809_JT1078_0x1800_0x1801.cs @@ -0,0 +1,29 @@ +using JT809.Protocol.Attributes; +using JT809.Protocol.Extensions.JT1078.Formatters; +using System; +using System.Collections.Generic; +using System.Text; + +namespace JT809.Protocol.Extensions.JT1078.MessageBody +{ + /// + /// 实时音视频请求应答消息 + /// + [JT809Formatter(typeof(JT809_JT1078_0x1800_0x1801_Formatter))] + public class JT809_JT1078_0x1800_0x1801 : JT809SubBodies + { + /// + /// 应答结果 + /// + public byte Result { get; set; } + /// + /// 企业视频服务器ip地址 + /// 32 + /// + public string ServerIp { get; set; } + /// + /// 企业视频服务器端口号 + /// + public ushort ServerPort { get; set; } + } +} \ No newline at end of file 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 new file mode 100644 index 0000000..d836f57 --- /dev/null +++ b/src/JT809.Protocol.Extensions.JT1078/MessageBody/JT809_JT1078_0x1800_0x1802.cs @@ -0,0 +1,20 @@ +using JT809.Protocol.Attributes; +using JT809.Protocol.Extensions.JT1078.Formatters; +using System; +using System.Collections.Generic; +using System.Text; + +namespace JT809.Protocol.Extensions.JT1078.MessageBody +{ + /// + /// 主动请求停止实时音视频传输应答消息 + /// + [JT809Formatter(typeof(JT809_JT1078_0x1800_0x1802_Formatter))] + public class JT809_JT1078_0x1800_0x1802 : JT809SubBodies + { + /// + /// 应答结果 + /// + public byte Result { get; set; } + } +} \ 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 new file mode 100644 index 0000000..52dcb18 --- /dev/null +++ b/src/JT809.Protocol.Extensions.JT1078/MessageBody/JT809_JT1078_0x1900.cs @@ -0,0 +1,17 @@ +using JT809.Protocol.Attributes; +using JT809.Protocol.Formatters; +using System; +using System.Collections.Generic; +using System.Text; + +namespace JT809.Protocol.Extensions.JT1078.MessageBody +{ + /// + /// 主链路远程录像检索交互消息 + /// + [JT809Formatter(typeof(JT809BodiesFormatter))] + public class JT809_JT1078_0x1900 : JT809ExchangeMessageBodies + { + + } +} 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 new file mode 100644 index 0000000..f41b48b --- /dev/null +++ b/src/JT809.Protocol.Extensions.JT1078/MessageBody/JT809_JT1078_0x1900_0x1901.cs @@ -0,0 +1,24 @@ +using JT809.Protocol.Attributes; +using JT809.Protocol.Extensions.JT1078.Formatters; +using System; +using System.Collections.Generic; +using System.Text; + +namespace JT809.Protocol.Extensions.JT1078.MessageBody +{ + /// + /// 主动上传音视频资源目录信息消息 + /// + [JT809Formatter(typeof(JT809_JT1078_0x1900_0x1901_Formatter))] + public class JT809_JT1078_0x1900_0x1901 : JT809SubBodies + { + /// + /// 资源目录项数目 + /// + public uint ItemNum { get; set; } + /// + /// 资源目录项列表 + /// + public List ItemList { get; set; } + } +} \ No newline at end of file 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 new file mode 100644 index 0000000..3b704e8 --- /dev/null +++ b/src/JT809.Protocol.Extensions.JT1078/MessageBody/JT809_JT1078_0x1900_0x1902.cs @@ -0,0 +1,29 @@ +using JT809.Protocol.Attributes; +using JT809.Protocol.Extensions.JT1078.Formatters; +using System; +using System.Collections.Generic; +using System.Text; + +namespace JT809.Protocol.Extensions.JT1078.MessageBody +{ + /// + /// 查询音视频资源目录应答消息 + /// + [JT809Formatter(typeof(JT809_JT1078_0x1900_0x1902_Formatter))] + public class JT809_JT1078_0x1900_0x1902 : JT809SubBodies + { + /// + /// 应答结果 + /// + public byte Result { get; set; } + /// + /// 资源目录项数目 + /// + public uint ItemNum { get; set; } + /// + /// 资源目录项列表 + /// 与JT808_JT1078_0x1900_0x1901共用同一个子类 + /// + public List ItemList { get; set; } + } +} \ No newline at end of file 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 new file mode 100644 index 0000000..91471aa --- /dev/null +++ b/src/JT809.Protocol.Extensions.JT1078/MessageBody/JT809_JT1078_0x1900_Record.cs @@ -0,0 +1,48 @@ +using JT809.Protocol.Attributes; +using JT809.Protocol.Extensions.JT1078.Formatters; +using System; +using System.Collections.Generic; +using System.Text; + +namespace JT809.Protocol.Extensions.JT1078.MessageBody +{ + /// + /// 上传音视频资源目录项 + /// + [JT809Formatter(typeof(JT809_JT1078_0x1900_0x1901_Record_Formatter))] + public class JT809_JT1078_0x1900_Record + { + /// + /// 逻辑通道号 + /// + public byte ChannelId { get; set; } + /// + /// UTC时间 开始 + /// + public DateTime StartTime { get; set; } + /// + /// UTC时间 结束 + /// + public DateTime EndTime { get; set; } + /// + /// 报警标志物 + /// + public UInt64 AlarmType { get; set; } + /// + /// 音视频类型 + /// + public byte AVItemType { get; set; } + /// + /// 码流类型 + /// + public byte StreamType { get; set; } + /// + /// 存储器类型 + /// + public byte MemType { get; set; } + /// + /// 文件大小 + /// + public uint FileSize { get; set; } + } +} diff --git a/src/JT809.Protocol.Extensions.JT1078/MessageBody/JT809_JT1078_0x1A00.cs b/src/JT809.Protocol.Extensions.JT1078/MessageBody/JT809_JT1078_0x1A00.cs new file mode 100644 index 0000000..e506f8a --- /dev/null +++ b/src/JT809.Protocol.Extensions.JT1078/MessageBody/JT809_JT1078_0x1A00.cs @@ -0,0 +1,17 @@ +using JT809.Protocol.Attributes; +using JT809.Protocol.Formatters; +using System; +using System.Collections.Generic; +using System.Text; + +namespace JT809.Protocol.Extensions.JT1078.MessageBody +{ + /// + /// 主链路远程录像回放交互消息 + /// + [JT809Formatter(typeof(JT809BodiesFormatter))] + public class JT809_JT1078_0x1A00 : JT809ExchangeMessageBodies + { + + } +} 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 new file mode 100644 index 0000000..afcb9df --- /dev/null +++ b/src/JT809.Protocol.Extensions.JT1078/MessageBody/JT809_JT1078_0x1A00_0x1A01.cs @@ -0,0 +1,29 @@ +using JT809.Protocol.Attributes; +using JT809.Protocol.Extensions.JT1078.Formatters; +using System; +using System.Collections.Generic; +using System.Text; + +namespace JT809.Protocol.Extensions.JT1078.MessageBody +{ + /// + /// 远程录像回放请求应答消息 + /// + [JT809Formatter(typeof(JT809_JT1078_0x1A00_0x1A01_Formatter))] + public class JT809_JT1078_0x1A00_0x1A01 : JT809SubBodies + { + /// + /// 企业视频服务器ip地址 + /// 32 + /// + public string ServerIp { get; set; } + /// + /// 企业视频服务器端口号 + /// + public ushort ServerPort { get; set; } + /// + /// 应答结果 + /// + public byte Result { get; set; } + } +} \ 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 new file mode 100644 index 0000000..5e7dc2e --- /dev/null +++ b/src/JT809.Protocol.Extensions.JT1078/MessageBody/JT809_JT1078_0x1A00_0x1A02.cs @@ -0,0 +1,20 @@ +using JT809.Protocol.Attributes; +using JT809.Protocol.Extensions.JT1078.Formatters; +using System; +using System.Collections.Generic; +using System.Text; + +namespace JT809.Protocol.Extensions.JT1078.MessageBody +{ + /// + /// 远程录像回放控制应答消息 + /// + [JT809Formatter(typeof(JT809_JT1078_0x1A00_0x1A02_Formatter))] + public class JT809_JT1078_0x1A00_0x1A02 : JT809SubBodies + { + /// + /// 应答结果 + /// + public byte Result { get; set; } + } +} \ 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 new file mode 100644 index 0000000..6c61496 --- /dev/null +++ b/src/JT809.Protocol.Extensions.JT1078/MessageBody/JT809_JT1078_0x1B00.cs @@ -0,0 +1,17 @@ +using JT809.Protocol.Attributes; +using JT809.Protocol.Formatters; +using System; +using System.Collections.Generic; +using System.Text; + +namespace JT809.Protocol.Extensions.JT1078.MessageBody +{ + /// + /// 主链路远程录像下载交互消息 + /// + [JT809Formatter(typeof(JT809BodiesFormatter))] + public class JT809_JT1078_0x1B00 : JT809ExchangeMessageBodies + { + + } +} 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 new file mode 100644 index 0000000..b4ec493 --- /dev/null +++ b/src/JT809.Protocol.Extensions.JT1078/MessageBody/JT809_JT1078_0x1B00_0x1B01.cs @@ -0,0 +1,24 @@ +using JT809.Protocol.Attributes; +using JT809.Protocol.Extensions.JT1078.Formatters; +using System; +using System.Collections.Generic; +using System.Text; + +namespace JT809.Protocol.Extensions.JT1078.MessageBody +{ + /// + /// 远程录像下载请求应答消息 + /// + [JT809Formatter(typeof(JT809_JT1078_0x1B00_0x1B01_Formatter))] + public class JT809_JT1078_0x1B00_0x1B01 : JT809SubBodies + { + /// + /// 应答结果 + /// + public byte Result { get; set; } + /// + /// 对应平台文件上传消息的流水号 + /// + public ushort SessionId { get; set; } + } +} \ No newline at end of file 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 new file mode 100644 index 0000000..519ce6b --- /dev/null +++ b/src/JT809.Protocol.Extensions.JT1078/MessageBody/JT809_JT1078_0x1B00_0x1B02.cs @@ -0,0 +1,47 @@ +using JT809.Protocol.Attributes; +using JT809.Protocol.Extensions.JT1078.Formatters; +using System; +using System.Collections.Generic; +using System.Text; + +namespace JT809.Protocol.Extensions.JT1078.MessageBody +{ + /// + /// 远程录像下载通知消息 + /// + [JT809Formatter(typeof(JT809_JT1078_0x1B00_0x1B02_Formatter))] + public class JT809_JT1078_0x1B00_0x1B02 : JT809SubBodies + { + /// + /// 应答结果 + /// + public byte Result { get; set; } + /// + /// 对应平台文件上传消息的流水号 + /// + public ushort SessionId { get; set; } + /// + /// FTP服务器ip地址 + /// + public string ServerIp { get; set; } + /// + /// FTP服务器端口 + /// + public ushort TcpPort { get; set; } + /// + /// FTP用户名 + /// 49 + /// + public string UserName { get; set; } + /// + /// FTP密码 + /// 22 + /// + public string Password { get; set; } + /// + /// 文件存储路径 + /// 200 + /// + public string FilePath { get; set; } + } +} \ No newline at end of file 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 new file mode 100644 index 0000000..3593768 --- /dev/null +++ b/src/JT809.Protocol.Extensions.JT1078/MessageBody/JT809_JT1078_0x1B00_0x1B03.cs @@ -0,0 +1,20 @@ +using JT809.Protocol.Attributes; +using JT809.Protocol.Extensions.JT1078.Formatters; +using System; +using System.Collections.Generic; +using System.Text; + +namespace JT809.Protocol.Extensions.JT1078.MessageBody +{ + /// + /// 远程录像下载控制应答消息 + /// + [JT809Formatter(typeof(JT809_JT1078_0x1B00_0x1B03_Formatter))] + public class JT809_JT1078_0x1B00_0x1B03 : JT809SubBodies + { + /// + /// 应答结果 + /// + public byte Result { get; set; } + } +} \ 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 new file mode 100644 index 0000000..c8d2356 --- /dev/null +++ b/src/JT809.Protocol.Extensions.JT1078/MessageBody/JT809_JT1078_0x9700.cs @@ -0,0 +1,17 @@ +using JT809.Protocol.Attributes; +using JT809.Protocol.Formatters; +using System; +using System.Collections.Generic; +using System.Text; + +namespace JT809.Protocol.Extensions.JT1078.MessageBody +{ + /// + /// 从链路时效口令交互消息 + /// + [JT809Formatter(typeof(JT809BodiesFormatter))] + public class JT809_JT1078_0x9700 : JT809ExchangeMessageBodies + { + + } +} diff --git a/src/JT809.Protocol.Extensions.JT1078/MessageBody/JT809_JT1078_0x9700_0x9702.cs b/src/JT809.Protocol.Extensions.JT1078/MessageBody/JT809_JT1078_0x9700_0x9702.cs new file mode 100644 index 0000000..43240a9 --- /dev/null +++ b/src/JT809.Protocol.Extensions.JT1078/MessageBody/JT809_JT1078_0x9700_0x9702.cs @@ -0,0 +1,17 @@ +using JT809.Protocol.Attributes; +using JT809.Protocol.Extensions.JT1078.Formatters; +using System; +using System.Collections.Generic; +using System.Text; + +namespace JT809.Protocol.Extensions.JT1078.MessageBody +{ + /// + /// 时效口令请求应答消息 + /// + [JT809Formatter(typeof(JT809_JT1078_0x9700_0x9702_Formatter))] + public class JT809_JT1078_0x9700_0x9702 : JT809SubBodies + { + + } +} \ No newline at end of file diff --git a/src/JT809.Protocol.Extensions.JT1078/MessageBody/JT809_JT1078_0x9800.cs b/src/JT809.Protocol.Extensions.JT1078/MessageBody/JT809_JT1078_0x9800.cs new file mode 100644 index 0000000..0a4e61a --- /dev/null +++ b/src/JT809.Protocol.Extensions.JT1078/MessageBody/JT809_JT1078_0x9800.cs @@ -0,0 +1,17 @@ +using JT809.Protocol.Attributes; +using JT809.Protocol.Formatters; +using System; +using System.Collections.Generic; +using System.Text; + +namespace JT809.Protocol.Extensions.JT1078.MessageBody +{ + /// + /// 从链路实时音视频交互信息 + /// + [JT809Formatter(typeof(JT809BodiesFormatter))] + public class JT809_JT1078_0x9800 : JT809ExchangeMessageBodies + { + + } +} 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 new file mode 100644 index 0000000..1c2a93c --- /dev/null +++ b/src/JT809.Protocol.Extensions.JT1078/MessageBody/JT809_JT1078_0x9800_0x9801.cs @@ -0,0 +1,32 @@ +using JT809.Protocol.Attributes; +using JT809.Protocol.Extensions.JT1078.Formatters; +using System; +using System.Collections.Generic; +using System.Text; + +namespace JT809.Protocol.Extensions.JT1078.MessageBody +{ + /// + /// 实时音视频请求消息 + /// + [JT809Formatter(typeof(JT809_JT1078_0x9800_0x9801_Formatter))] + public class JT809_JT1078_0x9800_0x9801 : JT809SubBodies + { + /// + /// 逻辑通道号 + /// + public byte ChannelId { get; set; } + /// + /// 音视频类型 + /// + public byte AVitemType { get; set; } + /// + /// 时效口令 + /// + public byte[] AuthorizeCode { get; set; } + /// + /// 车辆进入跨域地区后5min之内的任何位置,仅跨域访问请求时使用此字段 + /// + public byte[] GnssData { get; set; } + } +} \ No newline at end of file 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 new file mode 100644 index 0000000..2c72bc7 --- /dev/null +++ b/src/JT809.Protocol.Extensions.JT1078/MessageBody/JT809_JT1078_0x9800_0x9802.cs @@ -0,0 +1,24 @@ +using JT809.Protocol.Attributes; +using JT809.Protocol.Extensions.JT1078.Formatters; +using System; +using System.Collections.Generic; +using System.Text; + +namespace JT809.Protocol.Extensions.JT1078.MessageBody +{ + /// + /// 主动请求停止实时音视频传输消息 + /// + [JT809Formatter(typeof(JT809_JT1078_0x9800_0x9802_Formatter))] + public class JT809_JT1078_0x9800_0x9802 : JT809SubBodies + { + /// + /// 逻辑通道号 + /// + public byte ChannelId { get; set; } + /// + /// 音视频类型 + /// + public byte AVitemType { get; set; } + } +} \ No newline at end of file diff --git a/src/JT809.Protocol.Extensions.JT1078/MessageBody/JT809_JT1078_0x9900.cs b/src/JT809.Protocol.Extensions.JT1078/MessageBody/JT809_JT1078_0x9900.cs new file mode 100644 index 0000000..0ba950c --- /dev/null +++ b/src/JT809.Protocol.Extensions.JT1078/MessageBody/JT809_JT1078_0x9900.cs @@ -0,0 +1,17 @@ +using JT809.Protocol.Attributes; +using JT809.Protocol.Formatters; +using System; +using System.Collections.Generic; +using System.Text; + +namespace JT809.Protocol.Extensions.JT1078.MessageBody +{ + /// + /// 从链路远程录像检索交互消息 + /// + [JT809Formatter(typeof(JT809BodiesFormatter))] + public class JT809_JT1078_0x9900 : JT809ExchangeMessageBodies + { + + } +} 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 new file mode 100644 index 0000000..8299fc9 --- /dev/null +++ b/src/JT809.Protocol.Extensions.JT1078/MessageBody/JT809_JT1078_0x9900_0x9901.cs @@ -0,0 +1,24 @@ +using JT809.Protocol.Attributes; +using JT809.Protocol.Extensions.JT1078.Formatters; +using System; +using System.Collections.Generic; +using System.Text; + +namespace JT809.Protocol.Extensions.JT1078.MessageBody +{ + /// + /// 主动上传音视频资源目录信息应答消息 + /// + [JT809Formatter(typeof(JT809_JT1078_0x9900_0x9901_Formatter))] + public class JT809_JT1078_0x9900_0x9901 : JT809SubBodies + { + /// + /// 应答结果 + /// + public byte Result { get; set; } + /// + /// 资源目录总数 + /// + public byte ItemNumber { get; set; } + } +} \ No newline at end of file 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 new file mode 100644 index 0000000..606ccc4 --- /dev/null +++ b/src/JT809.Protocol.Extensions.JT1078/MessageBody/JT809_JT1078_0x9900_0x9902.cs @@ -0,0 +1,54 @@ +using JT809.Protocol.Attributes; +using JT809.Protocol.Extensions.JT1078.Formatters; +using System; +using System.Collections.Generic; +using System.Text; + +namespace JT809.Protocol.Extensions.JT1078.MessageBody +{ + /// + /// 查询音视频资源目录请求消息 + /// + [JT809Formatter(typeof(JT809_JT1078_0x9900_0x9902_Formatter))] + public class JT809_JT1078_0x9900_0x9902 : JT809SubBodies + { + /// + /// 逻辑通道号 + /// + public byte ChannelId { get; set; } + /// + /// 起始时间 + /// + public DateTime StartTime { get; set; } + /// + /// 终止时间 + /// + public DateTime EndTime { get; set; } + /// + /// 报警类型 + /// + public UInt64 AlarmType { get; set; } + /// + /// 音视频类型 + /// + public byte AVItemType { get; set; } + /// + /// 码流类型 + /// + public byte StreamType { get; set; } + /// + /// 存储器类型 + /// + public byte MemType { get; set; } + /// + /// 时效口令 + /// 64 + /// + public byte[] AuthorizeCode { get; set; } + /// + /// 车辆进入跨域地区后5min之内任一位置,仅跨域访问请求时,使用此字段 + /// 36 + /// + public byte[] GnssData { get; set; } + } +} \ No newline at end of file diff --git a/src/JT809.Protocol.Extensions.JT1078/MessageBody/JT809_JT1078_0x9A00.cs b/src/JT809.Protocol.Extensions.JT1078/MessageBody/JT809_JT1078_0x9A00.cs new file mode 100644 index 0000000..7b2ac4d --- /dev/null +++ b/src/JT809.Protocol.Extensions.JT1078/MessageBody/JT809_JT1078_0x9A00.cs @@ -0,0 +1,17 @@ +using JT809.Protocol.Attributes; +using JT809.Protocol.Formatters; +using System; +using System.Collections.Generic; +using System.Text; + +namespace JT809.Protocol.Extensions.JT1078.MessageBody +{ + /// + /// 从链路远程录像回放交互消息 + /// + [JT809Formatter(typeof(JT809BodiesFormatter))] + public class JT809_JT1078_0x9A00 : JT809ExchangeMessageBodies + { + + } +} 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 new file mode 100644 index 0000000..3d36426 --- /dev/null +++ b/src/JT809.Protocol.Extensions.JT1078/MessageBody/JT809_JT1078_0x9A00_0x9A01.cs @@ -0,0 +1,50 @@ +using JT809.Protocol.Attributes; +using JT809.Protocol.Extensions.JT1078.Formatters; +using System; +using System.Collections.Generic; +using System.Text; + +namespace JT809.Protocol.Extensions.JT1078.MessageBody +{ + /// + /// 远程录像回放请求消息 + /// + [JT809Formatter(typeof(JT809_JT1078_0x9A00_0x9A01_Formatter))] + public class JT809_JT1078_0x9A00_0x9A01 : JT809SubBodies + { + /// + /// 逻辑通道号 + /// + public byte ChannelId { get; set; } + /// + /// 音视频类型 + /// + public byte AVItemType { get; set; } + /// + /// 码流类型 + /// + public byte StreamType { get; set; } + /// + /// 存储器类型 + /// + public byte MemType { get; set; } + /// + /// 回放起始时间 + /// + public DateTime PlayBackStartTime { get; set; } + /// + /// 回放结束时间 + /// + public DateTime PlayBackEndTime { get; set; } + /// + /// 时效口令 + /// 64 + /// + public byte[] AuthorizeCode { get; set; } + /// + /// 车辆进入跨域地区后5min之内任一位置,仅跨域访问请求时,使用此字段 + /// 36 + /// + public byte[] GnssData { get; set; } + } +} \ No newline at end of file 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 new file mode 100644 index 0000000..77d083f --- /dev/null +++ b/src/JT809.Protocol.Extensions.JT1078/MessageBody/JT809_JT1078_0x9A00_0x9A02.cs @@ -0,0 +1,28 @@ +using JT809.Protocol.Attributes; +using JT809.Protocol.Extensions.JT1078.Formatters; +using System; +using System.Collections.Generic; +using System.Text; + +namespace JT809.Protocol.Extensions.JT1078.MessageBody +{ + /// + /// 远程录像回放控制消息 + /// + [JT809Formatter(typeof(JT809_JT1078_0x9A00_0x9A02_Formatter))] + public class JT809_JT1078_0x9A00_0x9A02 : JT809SubBodies + { + /// + /// 控制类型 + /// + public byte ControlType { get; set; } + /// + /// 快进或倒退倍数 + /// + public byte FastTime { get; set; } + /// + /// 拖动位置 + /// + public DateTime DateTime { get; set; } + } +} \ No newline at end of file diff --git a/src/JT809.Protocol.Extensions.JT1078/MessageBody/JT809_JT1078_0x9B00.cs b/src/JT809.Protocol.Extensions.JT1078/MessageBody/JT809_JT1078_0x9B00.cs new file mode 100644 index 0000000..a9fdff7 --- /dev/null +++ b/src/JT809.Protocol.Extensions.JT1078/MessageBody/JT809_JT1078_0x9B00.cs @@ -0,0 +1,17 @@ +using JT809.Protocol.Attributes; +using JT809.Protocol.Formatters; +using System; +using System.Collections.Generic; +using System.Text; + +namespace JT809.Protocol.Extensions.JT1078.MessageBody +{ + /// + /// 从链路远程录像下载交互消息 + /// + [JT809Formatter(typeof(JT809BodiesFormatter))] + public class JT809_JT1078_0x9B00 : JT809ExchangeMessageBodies + { + + } +} 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 new file mode 100644 index 0000000..d872b6c --- /dev/null +++ b/src/JT809.Protocol.Extensions.JT1078/MessageBody/JT809_JT1078_0x9B00_0x9B01.cs @@ -0,0 +1,58 @@ +using JT809.Protocol.Attributes; +using JT809.Protocol.Extensions.JT1078.Formatters; +using System; +using System.Collections.Generic; +using System.Text; + +namespace JT809.Protocol.Extensions.JT1078.MessageBody +{ + /// + /// 远程录像下载请求消息 + /// + [JT809Formatter(typeof(JT809_JT1078_0x9B00_0x9B01_Formatter))] + public class JT809_JT1078_0x9B00_0x9B01 : JT809SubBodies + { + /// + /// 逻辑通道号 + /// + public byte ChannelId { get; set; } + /// + /// 起始时间 + /// + public DateTime StartTime { get; set; } + /// + /// 终止时间 + /// + public DateTime EndTime { get; set; } + /// + /// 报警类型 + /// + public UInt64 AlarmType { get; set; } + /// + /// 音视频类型 + /// + public byte AVItemType { get; set; } + /// + /// 码流类型 + /// + public byte StreamType { get; set; } + /// + /// 存储器类型 + /// + public byte MemType { get; set; } + /// + /// 文件大小 byte + /// + public uint FileSize { get; set; } + /// + /// 时效口令 + /// 64 + /// + public byte[] AuthorizeCode { get; set; } + /// + /// 车辆进入跨域地区后5min之内任一位置,仅跨域访问请求时,使用此字段 + /// 36 + /// + public byte[] GnssData { get; set; } + } +} \ No newline at end of file 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 new file mode 100644 index 0000000..cf26bf2 --- /dev/null +++ b/src/JT809.Protocol.Extensions.JT1078/MessageBody/JT809_JT1078_0x9B00_0x9B02.cs @@ -0,0 +1,24 @@ +using JT809.Protocol.Attributes; +using JT809.Protocol.Extensions.JT1078.Formatters; +using System; +using System.Collections.Generic; +using System.Text; + +namespace JT809.Protocol.Extensions.JT1078.MessageBody +{ + /// + /// 远程录像下载完成通知应答消息 + /// + [JT809Formatter(typeof(JT809_JT1078_0x9B00_0x9B02_Formatter))] + public class JT809_JT1078_0x9B00_0x9B02 : JT809SubBodies + { + /// + /// 应答结果 + /// + public byte Result { get; set; } + /// + /// 对应平台文件上传消息的流水号 + /// + public ushort SessionId { get; set; } + } +} \ No newline at end of file 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 new file mode 100644 index 0000000..c4e8f67 --- /dev/null +++ b/src/JT809.Protocol.Extensions.JT1078/MessageBody/JT809_JT1078_0x9B00_0x9B03.cs @@ -0,0 +1,24 @@ +using JT809.Protocol.Attributes; +using JT809.Protocol.Extensions.JT1078.Formatters; +using System; +using System.Collections.Generic; +using System.Text; + +namespace JT809.Protocol.Extensions.JT1078.MessageBody +{ + /// + /// 远程录像下载控制消息 + /// + [JT809Formatter(typeof(JT809_JT1078_0x9B00_0x9B03_Formatter))] + public class JT809_JT1078_0x9B00_0x9B03 : JT809SubBodies + { + /// + /// 对应平台文件上传消息的流水号 + /// + public ushort SessionId { get; set; } + /// + /// 控制类型 + /// + public byte Type { get; set; } + } +} \ No newline at end of file