@@ -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 |
@@ -1,2 +1,248 @@ | |||
# JT1078 | |||
道路运输车辆卫星定位系统-视频通讯协议 | |||
# JT1078 | |||
道路运输车辆卫星定位系统-视频通讯协议主要分为三大部分。 | |||
1. 设备终端到平台的通信也就是JT808 | |||
2. 企业平台到政府监管的通信也就是JT809 | |||
3. 设备终端上传的实时音视频流数据也就是视频服务器 | |||
[](https://github.com/SmallChi/JT1078/blob/master/LICENSE)[](https://travis-ci.org/SmallChi/JT1078) | |||
## NuGet安装 | |||
| Package Name | Version | Downloads | | |||
| --------------------- | -------------------------------------------------- | --------------------------------------------------- | | |||
| Install-Package JT1078 |  |  | | |||
| Install-Package JT808.Protocol.Extensions.JT1078 |  |  | | |||
| Install-Package JT809.Protocol.Extensions.JT1078 |  |  | | |||
## 基于JT1078音视频流数据的RTP协议 | |||
### 前提条件 | |||
1. 掌握进制转换:二进制转十六进制; | |||
2. 掌握BCD编码、Hex编码; | |||
3. 掌握各种位移、异或; | |||
4. 掌握快速ctrl+c、ctrl+v; | |||
5. 掌握Span\<T\>的基本用法 | |||
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(); | |||
``` |
@@ -0,0 +1,22 @@ | |||
<Project Sdk="Microsoft.NET.Sdk"> | |||
<PropertyGroup> | |||
<TargetFrameworks>netcoreapp2.2;net472</TargetFrameworks> | |||
<AllowUnsafeBlocks>true</AllowUnsafeBlocks> | |||
<PlatformTarget>AnyCPU</PlatformTarget> | |||
<OutputType>Exe</OutputType> | |||
<StartupObject /> | |||
</PropertyGroup> | |||
<ItemGroup> | |||
<PackageReference Include="BenchmarkDotNet" Version="0.11.5" /> | |||
<PackageReference Include="BenchmarkDotNet.Diagnostics.Windows" Version="0.11.5" /> | |||
<PackageReference Include="JT808" Version="2.0.0" /> | |||
<PackageReference Include="NETStandard.Library" Version="2.0.3" /> | |||
<PackageReference Include="System.Buffers" Version="4.5.0" /> | |||
<PackageReference Include="System.Memory" Version="4.5.3" /> | |||
</ItemGroup> | |||
<ItemGroup> | |||
<ProjectReference Include="..\JT1078.Protocol\JT1078.Protocol.csproj" /> | |||
</ItemGroup> | |||
</Project> |
@@ -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)); | |||
} | |||
} | |||
} |
@@ -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<JT1078SerializerContext>(); | |||
//Summary summary1 = BenchmarkRunner.Run<JT808DeEscapeContext>(); | |||
//Summary summary2 = BenchmarkRunner.Run<JT808EscapeContext>(); | |||
} | |||
} | |||
} |
@@ -0,0 +1,20 @@ | |||
<Project Sdk="Microsoft.NET.Sdk"> | |||
<PropertyGroup> | |||
<TargetFramework>netcoreapp2.2</TargetFramework> | |||
<IsPackable>false</IsPackable> | |||
</PropertyGroup> | |||
<ItemGroup> | |||
<PackageReference Include="JT808" Version="2.0.0" /> | |||
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.0.1" /> | |||
<PackageReference Include="xunit" Version="2.4.0" /> | |||
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.0" /> | |||
</ItemGroup> | |||
<ItemGroup> | |||
<ProjectReference Include="..\JT1078.Protocol\JT1078.Protocol.csproj" /> | |||
</ItemGroup> | |||
</Project> |
@@ -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); | |||
} | |||
} | |||
} |
@@ -0,0 +1,18 @@ | |||
<?xml version="1.0" encoding="utf-8"?> | |||
<configuration> | |||
<startup> | |||
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.7.2" /> | |||
</startup> | |||
<runtime> | |||
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1"> | |||
<dependentAssembly> | |||
<assemblyIdentity name="System.Buffers" publicKeyToken="cc7b13ffcd2ddd51" culture="neutral" /> | |||
<bindingRedirect oldVersion="0.0.0.0-4.0.3.0" newVersion="4.0.3.0" /> | |||
</dependentAssembly> | |||
<dependentAssembly> | |||
<assemblyIdentity name="System.Numerics.Vectors" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" /> | |||
<bindingRedirect oldVersion="0.0.0.0-4.1.4.0" newVersion="4.1.4.0" /> | |||
</dependentAssembly> | |||
</assemblyBinding> | |||
</runtime> | |||
</configuration> |
@@ -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); | |||
} | |||
} | |||
} |
@@ -0,0 +1,87 @@ | |||
namespace JT1078.Protocol.Tools | |||
{ | |||
partial class JT1078Form | |||
{ | |||
/// <summary> | |||
/// 必需的设计器变量。 | |||
/// </summary> | |||
private System.ComponentModel.IContainer components = null; | |||
/// <summary> | |||
/// 清理所有正在使用的资源。 | |||
/// </summary> | |||
/// <param name="disposing">如果应释放托管资源,为 true;否则为 false。</param> | |||
protected override void Dispose(bool disposing) | |||
{ | |||
if (disposing && (components != null)) | |||
{ | |||
components.Dispose(); | |||
} | |||
base.Dispose(disposing); | |||
} | |||
#region Windows 窗体设计器生成的代码 | |||
/// <summary> | |||
/// 设计器支持所需的方法 - 不要修改 | |||
/// 使用代码编辑器修改此方法的内容。 | |||
/// </summary> | |||
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; | |||
} | |||
} | |||
@@ -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<JsonSerializerSettings>(() => | |||
{ | |||
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); | |||
} | |||
} | |||
} | |||
} |
@@ -0,0 +1,120 @@ | |||
<?xml version="1.0" encoding="utf-8"?> | |||
<root> | |||
<!-- | |||
Microsoft ResX Schema | |||
Version 2.0 | |||
The primary goals of this format is to allow a simple XML format | |||
that is mostly human readable. The generation and parsing of the | |||
various data types are done through the TypeConverter classes | |||
associated with the data types. | |||
Example: | |||
... ado.net/XML headers & schema ... | |||
<resheader name="resmimetype">text/microsoft-resx</resheader> | |||
<resheader name="version">2.0</resheader> | |||
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader> | |||
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader> | |||
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data> | |||
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data> | |||
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64"> | |||
<value>[base64 mime encoded serialized .NET Framework object]</value> | |||
</data> | |||
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64"> | |||
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value> | |||
<comment>This is a comment</comment> | |||
</data> | |||
There are any number of "resheader" rows that contain simple | |||
name/value pairs. | |||
Each data row contains a name, and value. The row also contains a | |||
type or mimetype. Type corresponds to a .NET class that support | |||
text/value conversion through the TypeConverter architecture. | |||
Classes that don't support this are serialized and stored with the | |||
mimetype set. | |||
The mimetype is used for serialized objects, and tells the | |||
ResXResourceReader how to depersist the object. This is currently not | |||
extensible. For a given mimetype the value must be set accordingly: | |||
Note - application/x-microsoft.net.object.binary.base64 is the format | |||
that the ResXResourceWriter will generate, however the reader can | |||
read any of the formats listed below. | |||
mimetype: application/x-microsoft.net.object.binary.base64 | |||
value : The object must be serialized with | |||
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter | |||
: and then encoded with base64 encoding. | |||
mimetype: application/x-microsoft.net.object.soap.base64 | |||
value : The object must be serialized with | |||
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter | |||
: and then encoded with base64 encoding. | |||
mimetype: application/x-microsoft.net.object.bytearray.base64 | |||
value : The object must be serialized into a byte array | |||
: using a System.ComponentModel.TypeConverter | |||
: and then encoded with base64 encoding. | |||
--> | |||
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata"> | |||
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" /> | |||
<xsd:element name="root" msdata:IsDataSet="true"> | |||
<xsd:complexType> | |||
<xsd:choice maxOccurs="unbounded"> | |||
<xsd:element name="metadata"> | |||
<xsd:complexType> | |||
<xsd:sequence> | |||
<xsd:element name="value" type="xsd:string" minOccurs="0" /> | |||
</xsd:sequence> | |||
<xsd:attribute name="name" use="required" type="xsd:string" /> | |||
<xsd:attribute name="type" type="xsd:string" /> | |||
<xsd:attribute name="mimetype" type="xsd:string" /> | |||
<xsd:attribute ref="xml:space" /> | |||
</xsd:complexType> | |||
</xsd:element> | |||
<xsd:element name="assembly"> | |||
<xsd:complexType> | |||
<xsd:attribute name="alias" type="xsd:string" /> | |||
<xsd:attribute name="name" type="xsd:string" /> | |||
</xsd:complexType> | |||
</xsd:element> | |||
<xsd:element name="data"> | |||
<xsd:complexType> | |||
<xsd:sequence> | |||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" /> | |||
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" /> | |||
</xsd:sequence> | |||
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" /> | |||
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" /> | |||
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" /> | |||
<xsd:attribute ref="xml:space" /> | |||
</xsd:complexType> | |||
</xsd:element> | |||
<xsd:element name="resheader"> | |||
<xsd:complexType> | |||
<xsd:sequence> | |||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" /> | |||
</xsd:sequence> | |||
<xsd:attribute name="name" type="xsd:string" use="required" /> | |||
</xsd:complexType> | |||
</xsd:element> | |||
</xsd:choice> | |||
</xsd:complexType> | |||
</xsd:element> | |||
</xsd:schema> | |||
<resheader name="resmimetype"> | |||
<value>text/microsoft-resx</value> | |||
</resheader> | |||
<resheader name="version"> | |||
<value>2.0</value> | |||
</resheader> | |||
<resheader name="reader"> | |||
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value> | |||
</resheader> | |||
<resheader name="writer"> | |||
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value> | |||
</resheader> | |||
</root> |
@@ -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(); | |||
} | |||
/// <summary> | |||
/// 16进制字符串转16进制数组 | |||
/// </summary> | |||
/// <param name="hexString"></param> | |||
/// <param name="separator"></param> | |||
/// <returns></returns> | |||
public static byte[] ToHexBytes(this string hexString) | |||
{ | |||
hexString = hexString.Replace(" ", ""); | |||
byte[] buf = new byte[hexString.Length / 2]; | |||
ReadOnlySpan<char> 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<byte> 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); | |||
} | |||
} | |||
} |
@@ -0,0 +1,148 @@ | |||
<?xml version="1.0" encoding="utf-8"?> | |||
<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> | |||
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" /> | |||
<PropertyGroup> | |||
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> | |||
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform> | |||
<ProjectGuid>{97C4DE73-E41C-4026-B97B-79ECC8A71C91}</ProjectGuid> | |||
<OutputType>WinExe</OutputType> | |||
<RootNamespace>JT1078.Protocol.Tools</RootNamespace> | |||
<AssemblyName>JT1078.Protocol.Tools</AssemblyName> | |||
<TargetFrameworkVersion>v4.7.2</TargetFrameworkVersion> | |||
<FileAlignment>512</FileAlignment> | |||
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects> | |||
<Deterministic>true</Deterministic> | |||
<IsWebBootstrapper>false</IsWebBootstrapper> | |||
<PublishUrl>publish\</PublishUrl> | |||
<Install>true</Install> | |||
<InstallFrom>Disk</InstallFrom> | |||
<UpdateEnabled>false</UpdateEnabled> | |||
<UpdateMode>Foreground</UpdateMode> | |||
<UpdateInterval>7</UpdateInterval> | |||
<UpdateIntervalUnits>Days</UpdateIntervalUnits> | |||
<UpdatePeriodically>false</UpdatePeriodically> | |||
<UpdateRequired>false</UpdateRequired> | |||
<MapFileExtensions>true</MapFileExtensions> | |||
<ApplicationRevision>1</ApplicationRevision> | |||
<ApplicationVersion>1.0.0.%2a</ApplicationVersion> | |||
<UseApplicationTrust>false</UseApplicationTrust> | |||
<PublishWizardCompleted>true</PublishWizardCompleted> | |||
<BootstrapperEnabled>true</BootstrapperEnabled> | |||
</PropertyGroup> | |||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "> | |||
<PlatformTarget>AnyCPU</PlatformTarget> | |||
<DebugSymbols>true</DebugSymbols> | |||
<DebugType>full</DebugType> | |||
<Optimize>false</Optimize> | |||
<OutputPath>bin\Debug\</OutputPath> | |||
<DefineConstants>DEBUG;TRACE</DefineConstants> | |||
<ErrorReport>prompt</ErrorReport> | |||
<WarningLevel>4</WarningLevel> | |||
</PropertyGroup> | |||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' "> | |||
<PlatformTarget>AnyCPU</PlatformTarget> | |||
<DebugType>pdbonly</DebugType> | |||
<Optimize>true</Optimize> | |||
<OutputPath>bin\Release\</OutputPath> | |||
<DefineConstants>TRACE</DefineConstants> | |||
<ErrorReport>prompt</ErrorReport> | |||
<WarningLevel>4</WarningLevel> | |||
</PropertyGroup> | |||
<PropertyGroup> | |||
<ManifestCertificateThumbprint>EF6E3B26CE85A0FC7A8A4536400E8FC8108FF04F</ManifestCertificateThumbprint> | |||
</PropertyGroup> | |||
<PropertyGroup> | |||
<ManifestKeyFile>JT1078.Protocol.Tools_TemporaryKey.pfx</ManifestKeyFile> | |||
</PropertyGroup> | |||
<PropertyGroup> | |||
<GenerateManifests>true</GenerateManifests> | |||
</PropertyGroup> | |||
<PropertyGroup> | |||
<SignManifests>false</SignManifests> | |||
</PropertyGroup> | |||
<ItemGroup> | |||
<Reference Include="Newtonsoft.Json, Version=12.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL"> | |||
<HintPath>..\packages\Newtonsoft.Json.12.0.2\lib\net45\Newtonsoft.Json.dll</HintPath> | |||
</Reference> | |||
<Reference Include="System" /> | |||
<Reference Include="System.Buffers, Version=4.0.3.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL"> | |||
<HintPath>..\packages\System.Buffers.4.5.0\lib\netstandard2.0\System.Buffers.dll</HintPath> | |||
</Reference> | |||
<Reference Include="System.Core" /> | |||
<Reference Include="System.Memory, Version=4.0.1.1, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL"> | |||
<HintPath>..\packages\System.Memory.4.5.3\lib\netstandard2.0\System.Memory.dll</HintPath> | |||
</Reference> | |||
<Reference Include="System.Numerics" /> | |||
<Reference Include="System.Numerics.Vectors, Version=4.1.4.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL"> | |||
<HintPath>..\packages\System.Numerics.Vectors.4.5.0\lib\net46\System.Numerics.Vectors.dll</HintPath> | |||
</Reference> | |||
<Reference Include="System.Runtime.CompilerServices.Unsafe, Version=4.0.4.1, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL"> | |||
<HintPath>..\packages\System.Runtime.CompilerServices.Unsafe.4.5.2\lib\netstandard2.0\System.Runtime.CompilerServices.Unsafe.dll</HintPath> | |||
</Reference> | |||
<Reference Include="System.Xml.Linq" /> | |||
<Reference Include="System.Data.DataSetExtensions" /> | |||
<Reference Include="Microsoft.CSharp" /> | |||
<Reference Include="System.Data" /> | |||
<Reference Include="System.Deployment" /> | |||
<Reference Include="System.Drawing" /> | |||
<Reference Include="System.Net.Http" /> | |||
<Reference Include="System.Windows.Forms" /> | |||
<Reference Include="System.Xml" /> | |||
</ItemGroup> | |||
<ItemGroup> | |||
<Compile Include="ByteArrayHexConverter.cs" /> | |||
<Compile Include="Form1.cs"> | |||
<SubType>Form</SubType> | |||
</Compile> | |||
<Compile Include="Form1.Designer.cs"> | |||
<DependentUpon>Form1.cs</DependentUpon> | |||
</Compile> | |||
<Compile Include="HexExtensions.cs" /> | |||
<Compile Include="Program.cs" /> | |||
<Compile Include="Properties\AssemblyInfo.cs" /> | |||
<EmbeddedResource Include="Form1.resx"> | |||
<DependentUpon>Form1.cs</DependentUpon> | |||
</EmbeddedResource> | |||
<EmbeddedResource Include="Properties\Resources.resx"> | |||
<Generator>ResXFileCodeGenerator</Generator> | |||
<LastGenOutput>Resources.Designer.cs</LastGenOutput> | |||
<SubType>Designer</SubType> | |||
</EmbeddedResource> | |||
<Compile Include="Properties\Resources.Designer.cs"> | |||
<AutoGen>True</AutoGen> | |||
<DependentUpon>Resources.resx</DependentUpon> | |||
</Compile> | |||
<None Include="packages.config" /> | |||
<None Include="Properties\Settings.settings"> | |||
<Generator>SettingsSingleFileGenerator</Generator> | |||
<LastGenOutput>Settings.Designer.cs</LastGenOutput> | |||
</None> | |||
<Compile Include="Properties\Settings.Designer.cs"> | |||
<AutoGen>True</AutoGen> | |||
<DependentUpon>Settings.settings</DependentUpon> | |||
<DesignTimeSharedInput>True</DesignTimeSharedInput> | |||
</Compile> | |||
</ItemGroup> | |||
<ItemGroup> | |||
<None Include="App.config" /> | |||
</ItemGroup> | |||
<ItemGroup> | |||
<BootstrapperPackage Include=".NETFramework,Version=v4.7.2"> | |||
<Visible>False</Visible> | |||
<ProductName>Microsoft .NET Framework 4.7.2 %28x86 和 x64%29</ProductName> | |||
<Install>true</Install> | |||
</BootstrapperPackage> | |||
<BootstrapperPackage Include="Microsoft.Net.Framework.3.5.SP1"> | |||
<Visible>False</Visible> | |||
<ProductName>.NET Framework 3.5 SP1</ProductName> | |||
<Install>false</Install> | |||
</BootstrapperPackage> | |||
</ItemGroup> | |||
<ItemGroup> | |||
<ProjectReference Include="..\JT1078.Protocol\JT1078.Protocol.csproj"> | |||
<Project>{60cac24b-7317-48bf-9dbf-7f3eca3689a4}</Project> | |||
<Name>JT1078.Protocol</Name> | |||
</ProjectReference> | |||
</ItemGroup> | |||
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" /> | |||
</Project> |
@@ -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 | |||
{ | |||
/// <summary> | |||
/// 应用程序的主入口点。 | |||
/// </summary> | |||
[STAThread] | |||
static void Main() | |||
{ | |||
Application.EnableVisualStyles(); | |||
Application.SetCompatibleTextRenderingDefault(false); | |||
Application.Run(new JT1078Form()); | |||
} | |||
} | |||
} |
@@ -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")] |
@@ -0,0 +1,71 @@ | |||
//------------------------------------------------------------------------------ | |||
// <auto-generated> | |||
// 此代码由工具生成。 | |||
// 运行时版本: 4.0.30319.42000 | |||
// | |||
// 对此文件的更改可能导致不正确的行为,如果 | |||
// 重新生成代码,则所做更改将丢失。 | |||
// </auto-generated> | |||
//------------------------------------------------------------------------------ | |||
namespace JT1078.Protocol.Tools.Properties | |||
{ | |||
/// <summary> | |||
/// 强类型资源类,用于查找本地化字符串等。 | |||
/// </summary> | |||
// 此类是由 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() | |||
{ | |||
} | |||
/// <summary> | |||
/// 返回此类使用的缓存 ResourceManager 实例。 | |||
/// </summary> | |||
[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; | |||
} | |||
} | |||
/// <summary> | |||
/// 覆盖当前线程的 CurrentUICulture 属性 | |||
/// 使用此强类型的资源类的资源查找。 | |||
/// </summary> | |||
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] | |||
internal static global::System.Globalization.CultureInfo Culture | |||
{ | |||
get | |||
{ | |||
return resourceCulture; | |||
} | |||
set | |||
{ | |||
resourceCulture = value; | |||
} | |||
} | |||
} | |||
} |
@@ -0,0 +1,117 @@ | |||
<?xml version="1.0" encoding="utf-8"?> | |||
<root> | |||
<!-- | |||
Microsoft ResX Schema | |||
Version 2.0 | |||
The primary goals of this format is to allow a simple XML format | |||
that is mostly human readable. The generation and parsing of the | |||
various data types are done through the TypeConverter classes | |||
associated with the data types. | |||
Example: | |||
... ado.net/XML headers & schema ... | |||
<resheader name="resmimetype">text/microsoft-resx</resheader> | |||
<resheader name="version">2.0</resheader> | |||
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader> | |||
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader> | |||
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data> | |||
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data> | |||
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64"> | |||
<value>[base64 mime encoded serialized .NET Framework object]</value> | |||
</data> | |||
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64"> | |||
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value> | |||
<comment>This is a comment</comment> | |||
</data> | |||
There are any number of "resheader" rows that contain simple | |||
name/value pairs. | |||
Each data row contains a name, and value. The row also contains a | |||
type or mimetype. Type corresponds to a .NET class that support | |||
text/value conversion through the TypeConverter architecture. | |||
Classes that don't support this are serialized and stored with the | |||
mimetype set. | |||
The mimetype is used for serialized objects, and tells the | |||
ResXResourceReader how to depersist the object. This is currently not | |||
extensible. For a given mimetype the value must be set accordingly: | |||
Note - application/x-microsoft.net.object.binary.base64 is the format | |||
that the ResXResourceWriter will generate, however the reader can | |||
read any of the formats listed below. | |||
mimetype: application/x-microsoft.net.object.binary.base64 | |||
value : The object must be serialized with | |||
: System.Serialization.Formatters.Binary.BinaryFormatter | |||
: and then encoded with base64 encoding. | |||
mimetype: application/x-microsoft.net.object.soap.base64 | |||
value : The object must be serialized with | |||
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter | |||
: and then encoded with base64 encoding. | |||
mimetype: application/x-microsoft.net.object.bytearray.base64 | |||
value : The object must be serialized into a byte array | |||
: using a System.ComponentModel.TypeConverter | |||
: and then encoded with base64 encoding. | |||
--> | |||
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata"> | |||
<xsd:element name="root" msdata:IsDataSet="true"> | |||
<xsd:complexType> | |||
<xsd:choice maxOccurs="unbounded"> | |||
<xsd:element name="metadata"> | |||
<xsd:complexType> | |||
<xsd:sequence> | |||
<xsd:element name="value" type="xsd:string" minOccurs="0" /> | |||
</xsd:sequence> | |||
<xsd:attribute name="name" type="xsd:string" /> | |||
<xsd:attribute name="type" type="xsd:string" /> | |||
<xsd:attribute name="mimetype" type="xsd:string" /> | |||
</xsd:complexType> | |||
</xsd:element> | |||
<xsd:element name="assembly"> | |||
<xsd:complexType> | |||
<xsd:attribute name="alias" type="xsd:string" /> | |||
<xsd:attribute name="name" type="xsd:string" /> | |||
</xsd:complexType> | |||
</xsd:element> | |||
<xsd:element name="data"> | |||
<xsd:complexType> | |||
<xsd:sequence> | |||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" /> | |||
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" /> | |||
</xsd:sequence> | |||
<xsd:attribute name="name" type="xsd:string" msdata:Ordinal="1" /> | |||
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" /> | |||
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" /> | |||
</xsd:complexType> | |||
</xsd:element> | |||
<xsd:element name="resheader"> | |||
<xsd:complexType> | |||
<xsd:sequence> | |||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" /> | |||
</xsd:sequence> | |||
<xsd:attribute name="name" type="xsd:string" use="required" /> | |||
</xsd:complexType> | |||
</xsd:element> | |||
</xsd:choice> | |||
</xsd:complexType> | |||
</xsd:element> | |||
</xsd:schema> | |||
<resheader name="resmimetype"> | |||
<value>text/microsoft-resx</value> | |||
</resheader> | |||
<resheader name="version"> | |||
<value>2.0</value> | |||
</resheader> | |||
<resheader name="reader"> | |||
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value> | |||
</resheader> | |||
<resheader name="writer"> | |||
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value> | |||
</resheader> | |||
</root> |
@@ -0,0 +1,30 @@ | |||
//------------------------------------------------------------------------------ | |||
// <auto-generated> | |||
// 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. | |||
// </auto-generated> | |||
//------------------------------------------------------------------------------ | |||
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; | |||
} | |||
} | |||
} | |||
} |
@@ -0,0 +1,7 @@ | |||
<?xml version='1.0' encoding='utf-8'?> | |||
<SettingsFile xmlns="http://schemas.microsoft.com/VisualStudio/2004/01/settings" CurrentProfile="(Default)"> | |||
<Profiles> | |||
<Profile Name="(Default)" /> | |||
</Profiles> | |||
<Settings /> | |||
</SettingsFile> |
@@ -0,0 +1,8 @@ | |||
<?xml version="1.0" encoding="utf-8"?> | |||
<packages> | |||
<package id="Newtonsoft.Json" version="12.0.2" targetFramework="net472" /> | |||
<package id="System.Buffers" version="4.5.0" targetFramework="net472" /> | |||
<package id="System.Memory" version="4.5.3" targetFramework="net472" /> | |||
<package id="System.Numerics.Vectors" version="4.5.0" targetFramework="net472" /> | |||
<package id="System.Runtime.CompilerServices.Unsafe" version="4.5.2" targetFramework="net472" /> | |||
</packages> |
@@ -0,0 +1,24 @@ | |||
using System; | |||
namespace JT1078.Protocol.Buffers | |||
{ | |||
/// <summary> | |||
/// <see cref="System.Buffers.Writer"/> | |||
/// </summary> | |||
ref partial struct JT1078BufferWriter | |||
{ | |||
private Span<byte> _buffer; | |||
public JT1078BufferWriter(Span<byte> buffer) | |||
{ | |||
_buffer = buffer; | |||
WrittenCount = 0; | |||
} | |||
public Span<byte> Free => _buffer.Slice(WrittenCount); | |||
public Span<byte> Written => _buffer.Slice(0, WrittenCount); | |||
public int WrittenCount { get; private set; } | |||
public void Advance(int count) | |||
{ | |||
WrittenCount += count; | |||
} | |||
} | |||
} |
@@ -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, | |||
} | |||
} |
@@ -0,0 +1,17 @@ | |||
using System; | |||
using System.Collections.Generic; | |||
using System.Text; | |||
namespace JT1078.Protocol.Enums | |||
{ | |||
/// <summary> | |||
/// 分包处理标记 | |||
/// </summary> | |||
public enum JT1078SubPackageType:byte | |||
{ | |||
原子包_不可被拆分=0, | |||
分包处理时的第一个包=1, | |||
分包处理时的最后一个包=2, | |||
分包处理时的中间包=3 | |||
} | |||
} |
@@ -0,0 +1,34 @@ | |||
<Project Sdk="Microsoft.NET.Sdk"> | |||
<PropertyGroup> | |||
<TargetFramework>netstandard2.0</TargetFramework> | |||
<LangVersion>7.3</LangVersion> | |||
<Copyright>Copyright 2019.</Copyright> | |||
<Authors>SmallChi(Koike)</Authors> | |||
<PackageId>JT1078</PackageId> | |||
<Product>JT1078</Product> | |||
<Description>基于JT1078的RTP协议</Description> | |||
<PackageReleaseNotes>基于JT1078的RTP协议</PackageReleaseNotes> | |||
<RepositoryUrl>https://github.com/SmallChi/JT1078</RepositoryUrl> | |||
<PackageProjectUrl>https://github.com/SmallChi/JT1078</PackageProjectUrl> | |||
<licenseUrl>https://github.com/SmallChi/JT1078/blob/master/LICENSE</licenseUrl> | |||
<license>https://github.com/SmallChi/JT1078/blob/master/LICENSE</license> | |||
<GeneratePackageOnBuild>false</GeneratePackageOnBuild> | |||
<Version>1.0.0</Version> | |||
<SignAssembly>false</SignAssembly> | |||
<PackageRequireLicenseAcceptance>true</PackageRequireLicenseAcceptance> | |||
<PackageLicenseFile>LICENSE</PackageLicenseFile> | |||
</PropertyGroup> | |||
<ItemGroup> | |||
<PackageReference Include="System.Memory" Version="4.5.3" /> | |||
</ItemGroup> | |||
<ItemGroup> | |||
<None Include="..\..\LICENSE"> | |||
<Pack>True</Pack> | |||
<PackagePath></PackagePath> | |||
</None> | |||
</ItemGroup> | |||
</Project> |
@@ -0,0 +1,24 @@ | |||
using System.Buffers; | |||
namespace JT1078.Protocol | |||
{ | |||
internal static class JT1078ArrayPool | |||
{ | |||
private readonly static ArrayPool<byte> ArrayPool; | |||
static JT1078ArrayPool() | |||
{ | |||
ArrayPool = ArrayPool<byte>.Create(); | |||
} | |||
public static byte[] Rent(int minimumLength) | |||
{ | |||
return ArrayPool.Rent(minimumLength); | |||
} | |||
public static void Return(byte[] array, bool clearArray = false) | |||
{ | |||
ArrayPool.Return(array, clearArray); | |||
} | |||
} | |||
} |
@@ -0,0 +1,50 @@ | |||
using System; | |||
using System.Collections.Generic; | |||
using System.Text; | |||
namespace JT1078.Protocol | |||
{ | |||
/// <summary> | |||
/// V - 2 - 固定为2 | |||
/// P - 1 - 固定为0 | |||
/// X - 1 - RTP头是否需要扩展位,固定为0 | |||
/// CC - 4 - 固定为1 | |||
/// </summary> | |||
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); | |||
} | |||
/// <summary> | |||
/// | |||
/// </summary> | |||
/// <param name="v">0-3</param> | |||
/// <param name="p">0-1</param> | |||
/// <param name="x">0-1</param> | |||
/// <param name="cc">0-15</param> | |||
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'); | |||
} | |||
} | |||
} |
@@ -0,0 +1,50 @@ | |||
using System; | |||
using System.Text; | |||
namespace JT1078.Protocol | |||
{ | |||
/// <summary> | |||
/// M - 1 - 标志位,确定是否是完整数据帧的边界 | |||
/// PT - 7 - 负载类型 | |||
/// </summary> | |||
public class JT1078Label2 | |||
{ | |||
public JT1078Label2(byte value) | |||
{ | |||
M = (byte)(value >> 7); | |||
PT = (byte)(value & 0x7f); | |||
} | |||
/// <summary> | |||
/// | |||
/// </summary> | |||
/// <param name="m">0-1</param> | |||
/// <param name="pt">0-127</param> | |||
public JT1078Label2(byte m,byte pt) | |||
{ | |||
M = m; | |||
PT = pt; | |||
} | |||
/// <summary> | |||
/// M - 1 - 标志位,确定是否是完整数据帧的边界 | |||
/// </summary> | |||
public byte M { get; set; } | |||
/// <summary> | |||
/// PT - 7 - 负载类型 | |||
/// 用于说明RTP报文中有效载荷的类型,如GSM音频、JPEM图像等 | |||
/// </summary> | |||
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'); | |||
} | |||
} | |||
} |
@@ -0,0 +1,42 @@ | |||
using JT1078.Protocol.Enums; | |||
using System; | |||
using System.Collections.Generic; | |||
using System.Text; | |||
namespace JT1078.Protocol | |||
{ | |||
/// <summary> | |||
/// 数据类型 | |||
/// 分包处理标记 | |||
/// </summary> | |||
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; | |||
} | |||
/// <summary> | |||
/// 数据类型 | |||
/// </summary> | |||
public JT1078DataType DataType { get; set; } | |||
/// <summary> | |||
/// 分包处理标记 | |||
/// </summary> | |||
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'); | |||
} | |||
} | |||
} |
@@ -0,0 +1,90 @@ | |||
using System; | |||
using System.Collections.Generic; | |||
using System.Text; | |||
namespace JT1078.Protocol | |||
{ | |||
public class JT1078Package | |||
{ | |||
/// <summary> | |||
/// 帧头标识 | |||
/// </summary> | |||
public static byte[] FH_Bytes = new byte[] { 0x30, 0x31, 0x63, 0x64 }; | |||
/// <summary> | |||
/// 帧头标识 | |||
/// </summary> | |||
public const uint FH = 0x30316364; | |||
public static JT1078Label1 DefaultLabel1 = new JT1078Label1(10, 0, 0, 1); | |||
/// <summary> | |||
/// 帧头标识 | |||
/// 固定为0x30 0x31 0x63 0x64 | |||
/// </summary> | |||
public uint FH_Flag { get; set; } = FH; | |||
/// <summary> | |||
/// V - 2 - 固定为2 | |||
/// P - 1 - 固定为0 | |||
/// X - 1 - RTP头是否需要扩展位,固定为0 | |||
/// CC - 4 - 固定为1 | |||
/// 01000001 | |||
/// </summary> | |||
public JT1078Label1 Label1 { get; set; } = DefaultLabel1; | |||
/// <summary> | |||
/// M - 1 - 标志位,确定是否是完整数据帧的边界 | |||
/// PT - 7 - 负载类型 | |||
/// </summary> | |||
public JT1078Label2 Label2 { get; set; } | |||
/// <summary> | |||
/// 初始化为0,每发送一个RTP数据包,序列号加1 | |||
/// </summary> | |||
public ushort SN { get; set; } | |||
/// <summary> | |||
/// 终端设备SIM卡号 | |||
/// BCD[6] | |||
/// </summary> | |||
public string SIM { get; set; } | |||
/// <summary> | |||
/// 逻辑通道号 | |||
/// </summary> | |||
public byte LogicChannelNumber { get; set; } | |||
/// <summary> | |||
/// 数据类型 | |||
/// 0000:视频I帧 | |||
/// 0001:视频P帧 | |||
/// 0010:视频B帧 | |||
/// 0011:音频帧 | |||
/// 0100:透传数据 | |||
/// | |||
/// 0000:原子包,不可被拆分 | |||
/// 0001:分包处理时的第一个包 | |||
/// 0010:分包处理是的最后一个包 | |||
/// 0011:分包处理时间的中间包 | |||
/// </summary> | |||
public JT1078Label3 Label3 { get; set; } | |||
/// <summary> | |||
/// 时间戳 | |||
/// 标识此RTP数据包当前帧的相对时间,单位毫秒(ms)。 | |||
/// 当数据类型为01000时,则没有该字段 | |||
/// </summary> | |||
public ulong Timestamp { get; set; } | |||
/// <summary> | |||
/// 该帧与上一个关键帧之间的时间间隔,单位毫秒(ms), | |||
/// 当数据类型为非视频帧时,则没有该字段 | |||
/// </summary> | |||
public ushort LastIFrameInterval { get; set; } | |||
/// <summary> | |||
/// 该帧与上一个关键帧之间的时间间隔,单位毫秒(ms), | |||
/// 当数据类型为非视频帧时,则没有该字段 | |||
/// </summary> | |||
public ushort LastFrameInterval { get; set; } | |||
/// <summary> | |||
/// 后续数据体长度,不含此字段 | |||
/// </summary> | |||
public ushort DataBodyLength { get; set; } | |||
/// <summary> | |||
/// 数据体 | |||
/// </summary> | |||
public byte[] Bodies{ get; set; } | |||
} | |||
} |
@@ -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<byte> 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; | |||
} | |||
} | |||
} |
@@ -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<byte> Reader { get; private set; } | |||
public ReadOnlySpan<byte> SrcBuffer { get; } | |||
public int ReaderCount { get; private set; } | |||
public JT1078MessagePackReader(ReadOnlySpan<byte> 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]; | |||
} | |||
/// <summary> | |||
/// 数字编码 大端模式、高位在前 | |||
/// </summary> | |||
/// <param name="len"></param> | |||
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<byte> 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<byte> ReadRemainArray() | |||
{ | |||
return Reader.Slice(ReaderCount); | |||
} | |||
private ReadOnlySpan<byte> GetReadOnlySpan(int count) | |||
{ | |||
ReaderCount += count; | |||
return Reader.Slice(ReaderCount - count); | |||
} | |||
} | |||
} |
@@ -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<byte> 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<byte> 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); | |||
} | |||
/// <summary> | |||
/// 数字编码 大端模式、高位在前 | |||
/// </summary> | |||
/// <param name="value"></param> | |||
/// <param name="len"></param> | |||
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; | |||
} | |||
} | |||
} |
@@ -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 |
@@ -0,0 +1,20 @@ | |||
<Project Sdk="Microsoft.NET.Sdk"> | |||
<PropertyGroup> | |||
<TargetFramework>netcoreapp2.2</TargetFramework> | |||
<IsPackable>false</IsPackable> | |||
</PropertyGroup> | |||
<ItemGroup> | |||
<PackageReference Include="Microsoft.Extensions.DependencyInjection" Version="2.2.0" /> | |||
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.0.1" /> | |||
<PackageReference Include="xunit" Version="2.4.0" /> | |||
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.0" /> | |||
</ItemGroup> | |||
<ItemGroup> | |||
<ProjectReference Include="..\JT808.Protocol.Extensions.JT1078\JT808.Protocol.Extensions.JT1078.csproj" /> | |||
</ItemGroup> | |||
</Project> |
@@ -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<IJT808Config>(); | |||
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<byte, JT808_0x0200_CustomBodyBase>() | |||
}; | |||
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<JT808_0x0200>(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<JT808_0x0200_0x14>(jT808UploadLocationRequest.JT808CustomLocationAttachOriginalData[0x14]).VideoRelateAlarm); | |||
Assert.Equal((uint)100, JT808Serializer.Deserialize<JT808_0x0200_0x15>(jT808UploadLocationRequest.JT808CustomLocationAttachOriginalData[0x15]).VideoSignalLoseAlarmStatus); | |||
Assert.Equal((uint)100, JT808Serializer.Deserialize<JT808_0x0200_0x16>(jT808UploadLocationRequest.JT808CustomLocationAttachOriginalData[0x16]).VideoSignalOcclusionAlarmStatus); | |||
Assert.Equal((uint)100, JT808Serializer.Deserialize<JT808_0x0200_0x17>(jT808UploadLocationRequest.JT808CustomLocationAttachOriginalData[0x17]).StorageFaultAlarmStatus); | |||
Assert.Equal((uint)100, JT808Serializer.Deserialize<JT808_0x0200_0x18>(jT808UploadLocationRequest.JT808CustomLocationAttachOriginalData[0x17]).AbnormalDrivingBehaviorAlarmInfo); | |||
} | |||
} | |||
} |
@@ -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<IJT808Config>(); | |||
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<JT808_0x1003>("03020504000101060708".ToHexBytes()); | |||
Assert.Equal(Newtonsoft.Json.JsonConvert.SerializeObject(jT808_0x1003), str); | |||
} | |||
} | |||
} |
@@ -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<IJT808Config>(); | |||
JT808Serializer = defaultConfig.GetSerializer(); | |||
Newtonsoft.Json.JsonConvert.DefaultSettings = new Func<JsonSerializerSettings>(() => | |||
{ | |||
//日期类型默认格式化处理 | |||
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<JT808_0x1005>("19071610200119071610250200010001".ToHexBytes()); | |||
Assert.Equal(Newtonsoft.Json.JsonConvert.SerializeObject(jT808_0x1005), str); | |||
} | |||
} | |||
} |
@@ -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<IJT808Config>(); | |||
JT808Serializer = defaultConfig.GetSerializer(); | |||
Newtonsoft.Json.JsonConvert.DefaultSettings = new Func<JsonSerializerSettings>(() => | |||
{ | |||
//日期类型默认格式化处理 | |||
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<JT808_0x1205_AVResouce> { | |||
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<JT808_0x1205>("000100000002041907161020011907161025010000000102060500000003291907161120011907161125020000000B153D330000001F".ToHexBytes()); | |||
Assert.Equal(Newtonsoft.Json.JsonConvert.SerializeObject(jT808_0x1205), str); | |||
} | |||
} | |||
} |
@@ -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<IJT808Config>(); | |||
JT808Serializer = defaultConfig.GetSerializer(); | |||
Newtonsoft.Json.JsonConvert.DefaultSettings = new Func<JsonSerializerSettings>(() => | |||
{ | |||
//日期类型默认格式化处理 | |||
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<JT808_0x1206>("000101".ToHexBytes()); | |||
Assert.Equal(Newtonsoft.Json.JsonConvert.SerializeObject(jT808_0x1206), str); | |||
} | |||
} | |||
} |
@@ -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<IJT808Config>(); | |||
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<JT808_0x8103_BodyBase>(), | |||
CustomParamList = new List<JT808_0x8103_CustomBodyBase> { | |||
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<JT808_0x8103_0x0076_AVChannelRefTable>{ | |||
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<JT808_0x8103_0x0077_SignalChannel>{ | |||
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<JT808_0x8103_BodyBase>(), | |||
CustomParamList = new List<JT808_0x8103_CustomBodyBase> { | |||
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<JT808_0x8103_0x0076_AVChannelRefTable>{ | |||
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<JT808_0x8103_0x0077_SignalChannel>{ | |||
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<JT808_0x8103>(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"; | |||
} | |||
} |
@@ -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<IJT808Config>(); | |||
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<JT808_0x9101>("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 | |||
} | |||
} | |||
} |
@@ -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<IJT808Config>(); | |||
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<JT808_0x9102>("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); | |||
} | |||
} | |||
} |
@@ -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<IJT808Config>(); | |||
JT808Serializer = defaultConfig.GetSerializer(); | |||
Newtonsoft.Json.JsonConvert.DefaultSettings = new Func<JsonSerializerSettings>(() => | |||
{ | |||
//日期类型默认格式化处理 | |||
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<JT808_0x9105>("0102".ToHexBytes()); | |||
Assert.Equal(Newtonsoft.Json.JsonConvert.SerializeObject(jT808_0x9105), str); | |||
} | |||
} | |||
} |
@@ -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<IJT808Config>(); | |||
JT808Serializer = defaultConfig.GetSerializer(); | |||
Newtonsoft.Json.JsonConvert.DefaultSettings = new Func<JsonSerializerSettings>(() => | |||
{ | |||
//日期类型默认格式化处理 | |||
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<JT808_0x9201>("093132372E302E302E3100501F9001020705060304190716101010190716101010".ToHexBytes()); | |||
Assert.Equal(Newtonsoft.Json.JsonConvert.SerializeObject(jT808_0x9201), str); | |||
} | |||
} | |||
} |
@@ -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<IJT808Config>(); | |||
JT808Serializer = defaultConfig.GetSerializer(); | |||
Newtonsoft.Json.JsonConvert.DefaultSettings = new Func<JsonSerializerSettings>(() => | |||
{ | |||
//日期类型默认格式化处理 | |||
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<JT808_0x9202>("010302190716101010".ToHexBytes()); | |||
Assert.Equal(Newtonsoft.Json.JsonConvert.SerializeObject(jT808_0x9202), str); | |||
} | |||
} | |||
} |
@@ -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<IJT808Config>(); | |||
JT808Serializer = defaultConfig.GetSerializer(); | |||
Newtonsoft.Json.JsonConvert.DefaultSettings = new Func<JsonSerializerSettings>(() => | |||
{ | |||
//日期类型默认格式化处理 | |||
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<JT808_0x9205>("0319071610101019071610101100000001020504".ToHexBytes()); | |||
Assert.Equal(Newtonsoft.Json.JsonConvert.SerializeObject(jT808_0x9205), str); | |||
} | |||
} | |||
} |
@@ -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<IJT808Config>(); | |||
JT808Serializer = defaultConfig.GetSerializer(); | |||
Newtonsoft.Json.JsonConvert.DefaultSettings = new Func<JsonSerializerSettings>(() => | |||
{ | |||
//日期类型默认格式化处理 | |||
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<JT808_0x9206>("093132372E302E302E31032802746B0631323334353608443A2F2F31313132031907161010101907161010110000000102050407".ToHexBytes()); | |||
Assert.Equal(Newtonsoft.Json.JsonConvert.SerializeObject(jT808_0x9206), str); | |||
} | |||
} | |||
} |
@@ -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<IJT808Config>(); | |||
JT808Serializer = defaultConfig.GetSerializer(); | |||
Newtonsoft.Json.JsonConvert.DefaultSettings = new Func<JsonSerializerSettings>(() => | |||
{ | |||
//日期类型默认格式化处理 | |||
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<JT808_0x9207>("000102".ToHexBytes()); | |||
Assert.Equal(Newtonsoft.Json.JsonConvert.SerializeObject(jT808_0x9207), str); | |||
} | |||
} | |||
} |
@@ -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<IJT808Config>(); | |||
JT808Serializer = defaultConfig.GetSerializer(); | |||
Newtonsoft.Json.JsonConvert.DefaultSettings = new Func<JsonSerializerSettings>(() => | |||
{ | |||
//日期类型默认格式化处理 | |||
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<JT808_0x9301>("010302".ToHexBytes()); | |||
Assert.Equal(Newtonsoft.Json.JsonConvert.SerializeObject(jT808_0x9301), str); | |||
} | |||
} | |||
} |
@@ -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<IJT808Config>(); | |||
JT808Serializer = defaultConfig.GetSerializer(); | |||
Newtonsoft.Json.JsonConvert.DefaultSettings = new Func<JsonSerializerSettings>(() => | |||
{ | |||
//日期类型默认格式化处理 | |||
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<JT808_0x9302>("0102".ToHexBytes()); | |||
Assert.Equal(Newtonsoft.Json.JsonConvert.SerializeObject(jT808_0x9302), str); | |||
} | |||
} | |||
} |
@@ -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<IJT808Config>(); | |||
JT808Serializer = defaultConfig.GetSerializer(); | |||
Newtonsoft.Json.JsonConvert.DefaultSettings = new Func<JsonSerializerSettings>(() => | |||
{ | |||
//日期类型默认格式化处理 | |||
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<JT808_0x9303>("0102".ToHexBytes()); | |||
Assert.Equal(Newtonsoft.Json.JsonConvert.SerializeObject(jT808_0x9303), str); | |||
} | |||
} | |||
} |
@@ -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<IJT808Config>(); | |||
JT808Serializer = defaultConfig.GetSerializer(); | |||
Newtonsoft.Json.JsonConvert.DefaultSettings = new Func<JsonSerializerSettings>(() => | |||
{ | |||
//日期类型默认格式化处理 | |||
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<JT808_0x9304>("0102".ToHexBytes()); | |||
Assert.Equal(Newtonsoft.Json.JsonConvert.SerializeObject(jT808_0x9304), str); | |||
} | |||
} | |||
} |
@@ -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<IJT808Config>(); | |||
JT808Serializer = defaultConfig.GetSerializer(); | |||
Newtonsoft.Json.JsonConvert.DefaultSettings = new Func<JsonSerializerSettings>(() => | |||
{ | |||
//日期类型默认格式化处理 | |||
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<JT808_0x9305>("0102".ToHexBytes()); | |||
Assert.Equal(Newtonsoft.Json.JsonConvert.SerializeObject(jT808_0x9305), str); | |||
} | |||
} | |||
} |
@@ -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<IJT808Config>(); | |||
JT808Serializer = defaultConfig.GetSerializer(); | |||
Newtonsoft.Json.JsonConvert.DefaultSettings = new Func<JsonSerializerSettings>(() => | |||
{ | |||
//日期类型默认格式化处理 | |||
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<JT808_0x9306>("0102".ToHexBytes()); | |||
Assert.Equal(Newtonsoft.Json.JsonConvert.SerializeObject(jT808_0x9306), str); | |||
} | |||
} | |||
} |
@@ -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<JT808_0x1003>(0x1003, ""); | |||
jT808Builder.Config.MsgIdFactory.SetMap<JT808_0x1005>(0x1005, ""); | |||
jT808Builder.Config.MsgIdFactory.SetMap<JT808_0x1205>(0x1205, ""); | |||
jT808Builder.Config.MsgIdFactory.SetMap<JT808_0x1206>(0x1206, ""); | |||
jT808Builder.Config.MsgIdFactory.SetMap<JT808_0x9003>(0x9003, ""); | |||
jT808Builder.Config.MsgIdFactory.SetMap<JT808_0x9101>(0x9101, ""); | |||
jT808Builder.Config.MsgIdFactory.SetMap<JT808_0x9102>(0x9102, ""); | |||
jT808Builder.Config.MsgIdFactory.SetMap<JT808_0x9105>(0x9105, ""); | |||
jT808Builder.Config.MsgIdFactory.SetMap<JT808_0x9201>(0x9201, ""); | |||
jT808Builder.Config.MsgIdFactory.SetMap<JT808_0x9202>(0x9202, ""); | |||
jT808Builder.Config.MsgIdFactory.SetMap<JT808_0x9205>(0x9205, ""); | |||
jT808Builder.Config.MsgIdFactory.SetMap<JT808_0x9206>(0x9206, ""); | |||
jT808Builder.Config.MsgIdFactory.SetMap<JT808_0x9207>(0x9207, ""); | |||
jT808Builder.Config.MsgIdFactory.SetMap<JT808_0x9301>(0x9301, ""); | |||
jT808Builder.Config.MsgIdFactory.SetMap<JT808_0x9302>(0x9302, ""); | |||
jT808Builder.Config.MsgIdFactory.SetMap<JT808_0x9303>(0x9303, ""); | |||
jT808Builder.Config.MsgIdFactory.SetMap<JT808_0x9304>(0x9304, ""); | |||
jT808Builder.Config.MsgIdFactory.SetMap<JT808_0x9305>(0x9305, ""); | |||
jT808Builder.Config.MsgIdFactory.SetMap<JT808_0x9306>(0x9306, ""); | |||
return jT808Builder; | |||
} | |||
} | |||
} |
@@ -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<JT808_0x0200_0x14> | |||
{ | |||
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); | |||
} | |||
} | |||
} |
@@ -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<JT808_0x0200_0x15> | |||
{ | |||
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); | |||
} | |||
} | |||
} |
@@ -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<JT808_0x0200_0x16> | |||
{ | |||
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); | |||
} | |||
} | |||
} |
@@ -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<JT808_0x0200_0x17> | |||
{ | |||
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); | |||
} | |||
} | |||
} |
@@ -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<JT808_0x0200_0x18> | |||
{ | |||
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); | |||
} | |||
} | |||
} |
@@ -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<JT808_0x1003> | |||
{ | |||
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); | |||
} | |||
} | |||
} |
@@ -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<JT808_0x1005> | |||
{ | |||
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); | |||
} | |||
} | |||
} |
@@ -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<JT808_0x1205_AVResouce> | |||
{ | |||
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); | |||
} | |||
} | |||
} |
@@ -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<JT808_0x1205> | |||
{ | |||
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<JT808_0x1205_AVResouce>(); | |||
var formatter = config.GetMessagePackFormatter<JT808_0x1205_AVResouce>(); | |||
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<JT808_0x1205_AVResouce>(); | |||
foreach (var AVResouce in value.AVResouces) | |||
{ | |||
formatter.Serialize(ref writer, AVResouce, config); | |||
} | |||
} | |||
} | |||
} | |||
} |
@@ -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<JT808_0x1206> | |||
{ | |||
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); | |||
} | |||
} | |||
} |
@@ -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<JT808_0x8103_0x0075> | |||
{ | |||
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); | |||
} | |||
} | |||
} |
@@ -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<JT808_0x8103_0x0076_AVChannelRefTable> | |||
{ | |||
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); | |||
} | |||
} | |||
} |
@@ -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<JT808_0x8103_0x0076> | |||
{ | |||
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<JT808_0x8103_0x0076_AVChannelRefTable>(); | |||
var formatter = config.GetMessagePackFormatter<JT808_0x8103_0x0076_AVChannelRefTable>(); | |||
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<JT808_0x8103_0x0076_AVChannelRefTable>(); | |||
foreach (var AVChannelRefTable in value.AVChannelRefTables) | |||
{ | |||
formatter.Serialize(ref writer, AVChannelRefTable, config); | |||
} | |||
} | |||
writer.WriteByteReturn((byte)(writer.GetCurrentPosition()- position-1), position); | |||
} | |||
} | |||
} |
@@ -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<JT808_0x8103_0x0077> | |||
{ | |||
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<JT808_0x8103_0x0077_SignalChannel>(); | |||
var formatter = config.GetMessagePackFormatter<JT808_0x8103_0x0077_SignalChannel>(); | |||
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<JT808_0x8103_0x0077_SignalChannel>(); | |||
foreach (var signalChannel in value.jT808_0X8103_0X0077_SignalChannels) | |||
{ | |||
formatter.Serialize(ref writer, signalChannel, config); | |||
} | |||
} | |||
writer.WriteByteReturn((byte)(writer.GetCurrentPosition() - position - 1), position); | |||
} | |||
} | |||
} |
@@ -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<JT808_0x8103_0x0077_SignalChannel> | |||
{ | |||
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); | |||
} | |||
} | |||
} |
@@ -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<JT808_0x8103_0x0079> | |||
{ | |||
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); | |||
} | |||
} | |||
} |
@@ -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<JT808_0x8103_0x007A> | |||
{ | |||
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); | |||
} | |||
} | |||
} |
@@ -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<JT808_0x8103_0x007B> | |||
{ | |||
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); | |||
} | |||
} | |||
} |
@@ -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<JT808_0x8103_0x007C> | |||
{ | |||
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<JT808_0x8103_0x007C_TimerWakeDayParamter>().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<JT808_0x8103_0x007C_TimerWakeDayParamter>().Serialize(ref writer, value.jT808_0X8103_0X007C_TimerWakeDayParamter, config); | |||
writer.WriteByteReturn((byte)(writer.GetCurrentPosition()-position-1),position); | |||
} | |||
} | |||
} |
@@ -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<JT808_0x8103_0x007C_TimerWakeDayParamter> | |||
{ | |||
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); | |||
} | |||
} | |||
} |
@@ -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<JT808_0x9101> | |||
{ | |||
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); | |||
} | |||
} | |||
} |
@@ -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<JT808_0x9102> | |||
{ | |||
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); | |||
} | |||
} | |||
} |
@@ -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<JT808_0x9105> | |||
{ | |||
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); | |||
} | |||
} | |||
} |
@@ -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<JT808_0x9201> | |||
{ | |||
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); | |||
} | |||
} | |||
} |
@@ -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<JT808_0x9202> | |||
{ | |||
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); | |||
} | |||
} | |||
} |
@@ -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<JT808_0x9205> | |||
{ | |||
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); | |||
} | |||
} | |||
} |
@@ -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<JT808_0x9206> | |||
{ | |||
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); | |||
} | |||
} | |||
} |
@@ -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<JT808_0x9207> | |||
{ | |||
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); | |||
} | |||
} | |||
} |
@@ -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<JT808_0x9301> | |||
{ | |||
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); | |||
} | |||
} | |||
} |
@@ -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<JT808_0x9302> | |||
{ | |||
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); | |||
} | |||
} | |||
} |
@@ -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<JT808_0x9303> | |||
{ | |||
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); | |||
} | |||
} | |||
} |
@@ -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<JT808_0x9304> | |||
{ | |||
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); | |||
} | |||
} | |||
} |
@@ -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<JT808_0x9305> | |||
{ | |||
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); | |||
} | |||
} | |||
} |
@@ -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<JT808_0x9306> | |||
{ | |||
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); | |||
} | |||
} | |||
} |
@@ -0,0 +1,34 @@ | |||
<Project Sdk="Microsoft.NET.Sdk"> | |||
<PropertyGroup> | |||
<TargetFramework>netstandard2.0</TargetFramework> | |||
<LangVersion>7.3</LangVersion> | |||
<Copyright>Copyright 2019.</Copyright> | |||
<Authors>SmallChi(Koike)</Authors> | |||
<PackageId>JT808.Protocol.Extensions.JT1078</PackageId> | |||
<Product>JT808.Protocol.Extensions.JT1078</Product> | |||
<Description>基于JT808协议、GB808协议扩展的视频消息协议</Description> | |||
<PackageReleaseNotes>基于JT808协议、GB808协议扩展的视频消息协议</PackageReleaseNotes> | |||
<PackageRequireLicenseAcceptance>true</PackageRequireLicenseAcceptance> | |||
<RepositoryUrl>https://github.com/SmallChi/JT1078</RepositoryUrl> | |||
<PackageProjectUrl>https://github.com/SmallChi/JT1078</PackageProjectUrl> | |||
<licenseUrl>https://github.com/SmallChi/JT1078/blob/master/LICENSE</licenseUrl> | |||
<license>https://github.com/SmallChi/JT1078/blob/master/LICENSE</license> | |||
<GeneratePackageOnBuild>false</GeneratePackageOnBuild> | |||
<Version>1.0.0</Version> | |||
<PackageLicenseFile>LICENSE</PackageLicenseFile> | |||
</PropertyGroup> | |||
<ItemGroup> | |||
<PackageReference Include="JT808" Version="2.1.0" /> | |||
<PackageReference Include="Microsoft.Extensions.Hosting.Abstractions" Version="2.2.0" /> | |||
</ItemGroup> | |||
<ItemGroup> | |||
<None Include="..\..\LICENSE"> | |||
<Pack>True</Pack> | |||
<PackagePath></PackagePath> | |||
</None> | |||
</ItemGroup> | |||
</Project> |
@@ -0,0 +1,24 @@ | |||
using JT808.Protocol.Attributes; | |||
using JT808.Protocol.Extensions.JT1078.Formatters; | |||
using JT808.Protocol.MessageBody; | |||
namespace JT808.Protocol.Extensions.JT1078.MessageBody | |||
{ | |||
/// <summary> | |||
/// 视频相关报警 | |||
/// 0x0200_0x14 | |||
/// </summary> | |||
[JT808Formatter(typeof(JT808_0x0200_0x14_Formatter))] | |||
public class JT808_0x0200_0x14 : JT808_0x0200_CustomBodyBase | |||
{ | |||
public override byte AttachInfoId { get; set; } = 0x14; | |||
/// <summary> | |||
/// 数据 长度 | |||
/// </summary> | |||
public override byte AttachInfoLength { get; set; } = 4; | |||
/// <summary> | |||
/// 视频相关报警 | |||
/// </summary> | |||
public uint VideoRelateAlarm { get; set; } | |||
} | |||
} |
@@ -0,0 +1,24 @@ | |||
using JT808.Protocol.Attributes; | |||
using JT808.Protocol.Extensions.JT1078.Formatters; | |||
using JT808.Protocol.MessageBody; | |||
namespace JT808.Protocol.Extensions.JT1078.MessageBody | |||
{ | |||
/// <summary> | |||
/// 视频信号丢失报警状态 | |||
/// 0x0200_0x15 | |||
/// </summary> | |||
[JT808Formatter(typeof(JT808_0x0200_0x15_Formatter))] | |||
public class JT808_0x0200_0x15 : JT808_0x0200_CustomBodyBase | |||
{ | |||
public override byte AttachInfoId { get; set; } = 0x15; | |||
/// <summary> | |||
/// 数据 长度 | |||
/// </summary> | |||
public override byte AttachInfoLength { get; set; } = 4; | |||
/// <summary> | |||
/// 视频信号丢失报警状态 | |||
/// </summary> | |||
public uint VideoSignalLoseAlarmStatus { get; set; } | |||
} | |||
} |
@@ -0,0 +1,24 @@ | |||
using JT808.Protocol.Attributes; | |||
using JT808.Protocol.Extensions.JT1078.Formatters; | |||
using JT808.Protocol.MessageBody; | |||
namespace JT808.Protocol.Extensions.JT1078.MessageBody | |||
{ | |||
/// <summary> | |||
/// 视频信号遮挡报警状态 | |||
/// 0x0200_0x16 | |||
/// </summary> | |||
[JT808Formatter(typeof(JT808_0x0200_0x16_Formatter))] | |||
public class JT808_0x0200_0x16 : JT808_0x0200_CustomBodyBase | |||
{ | |||
public override byte AttachInfoId { get; set; } = 0x16; | |||
/// <summary> | |||
/// 数据 长度 | |||
/// </summary> | |||
public override byte AttachInfoLength { get; set; } = 4; | |||
/// <summary> | |||
/// 视频信号遮挡报警状态 | |||
/// </summary> | |||
public uint VideoSignalOcclusionAlarmStatus { get; set; } | |||
} | |||
} |
@@ -0,0 +1,24 @@ | |||
using JT808.Protocol.Attributes; | |||
using JT808.Protocol.Extensions.JT1078.Formatters; | |||
using JT808.Protocol.MessageBody; | |||
namespace JT808.Protocol.Extensions.JT1078.MessageBody | |||
{ | |||
/// <summary> | |||
/// 存储器故障报警状态 | |||
/// 0x0200_0x17 | |||
/// </summary> | |||
[JT808Formatter(typeof(JT808_0x0200_0x17_Formatter))] | |||
public class JT808_0x0200_0x17 : JT808_0x0200_CustomBodyBase | |||
{ | |||
public override byte AttachInfoId { get; set; } = 0x17; | |||
/// <summary> | |||
/// 数据 长度 | |||
/// </summary> | |||
public override byte AttachInfoLength { get; set; } = 2; | |||
/// <summary> | |||
/// 存储器故障报警状态 | |||
/// </summary> | |||
public ushort StorageFaultAlarmStatus{ get; set; } | |||
} | |||
} |
@@ -0,0 +1,24 @@ | |||
using JT808.Protocol.Attributes; | |||
using JT808.Protocol.Extensions.JT1078.Formatters; | |||
using JT808.Protocol.MessageBody; | |||
namespace JT808.Protocol.Extensions.JT1078.MessageBody | |||
{ | |||
/// <summary> | |||
/// 异常驾驶行为报警详细描述 | |||
/// 0x0200_0x18 | |||
/// </summary> | |||
[JT808Formatter(typeof(JT808_0x0200_0x18_Formatter))] | |||
public class JT808_0x0200_0x18 : JT808_0x0200_CustomBodyBase | |||
{ | |||
public override byte AttachInfoId { get; set; } = 0x18; | |||
/// <summary> | |||
/// 数据 长度 | |||
/// </summary> | |||
public override byte AttachInfoLength { get; set; } = 2; | |||
/// <summary> | |||
/// 异常驾驶行为报警详细描述 | |||
/// </summary> | |||
public ushort AbnormalDrivingBehaviorAlarmInfo { get; set; } | |||
} | |||
} |
@@ -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 | |||
{ | |||
/// <summary> | |||
/// 终端上传音视频属性 | |||
/// </summary> | |||
[JT808Formatter(typeof(JT808_0x1003_Formatter))] | |||
public class JT808_0x1003 : JT808Bodies | |||
{ | |||
/// <summary> | |||
/// 输入音频编码方式 | |||
/// </summary> | |||
public byte EnterAudioEncoding { get; set; } | |||
/// <summary> | |||
/// 输入音频声道数 | |||
/// </summary> | |||
public byte EnterAudioChannelsNumber { get; set; } | |||
/// <summary> | |||
/// 输入音频采样率 | |||
/// </summary> | |||
public byte EnterAudioSampleRate { get; set; } | |||
/// <summary> | |||
/// 输入音频采样位数 | |||
/// </summary> | |||
public byte EnterAudioSampleDigits { get; set; } | |||
/// <summary> | |||
/// 音频帧长度 | |||
/// </summary> | |||
public ushort AudioFrameLength { get; set; } | |||
/// <summary> | |||
/// 是否支持音频输出 | |||
/// </summary> | |||
public byte IsSupportedAudioOutput { get; set; } | |||
/// <summary> | |||
/// 视频编码方式 | |||
/// </summary> | |||
public byte VideoEncoding { get; set; } | |||
/// <summary> | |||
/// 终端支持的最大音频物理通道数量 | |||
/// </summary> | |||
public byte TerminalSupportedMaxNumberOfAudioPhysicalChannels{ get; set; } | |||
/// <summary> | |||
/// 终端支持的最大视频物理通道数量 | |||
/// </summary> | |||
public byte TerminalSupportedMaxNumberOfVideoPhysicalChannels { get; set; } | |||
} | |||
} |
@@ -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 | |||
{ | |||
/// <summary> | |||
/// 终端上传乘客流量 | |||
/// </summary> | |||
[JT808Formatter(typeof(JT808_0x1005_Formatter))] | |||
public class JT808_0x1005 : JT808Bodies | |||
{ | |||
/// <summary> | |||
/// 起始时间 | |||
/// </summary> | |||
public DateTime BeginTime { get; set; } | |||
/// <summary> | |||
/// 结束时间 | |||
/// </summary> | |||
public DateTime EndTime { get; set; } | |||
/// <summary> | |||
/// 上车人数 | |||
/// </summary> | |||
public ushort GettingOnNumber { get; set; } | |||
/// <summary> | |||
/// 下车人数 | |||
/// </summary> | |||
public ushort GettingOffNumber { get; set; } | |||
} | |||
} |
@@ -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 | |||
{ | |||
/// <summary> | |||
/// 终端上传音视频资源列表 | |||
/// </summary> | |||
[JT808Formatter(typeof(JT808_0x1205_Formatter))] | |||
public class JT808_0x1205 : JT808Bodies | |||
{ | |||
/// <summary> | |||
/// 流水号 | |||
/// </summary> | |||
public ushort MsgNum { get; set; } | |||
/// <summary> | |||
/// 音视频资源总数 | |||
/// </summary> | |||
public uint AVResouceTotal{ get; set; } | |||
/// <summary> | |||
/// 音视频资源列表 | |||
/// </summary> | |||
public List<JT808_0x1205_AVResouce> AVResouces { get; set; } | |||
} | |||
} |
@@ -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 | |||
{ | |||
/// <summary> | |||
/// 终端上传音视频资源列表 | |||
/// </summary> | |||
[JT808Formatter(typeof(JT808_0x1205_AVResouce_Formatter))] | |||
public class JT808_0x1205_AVResouce | |||
{ | |||
/// <summary> | |||
/// 逻辑通道号 | |||
/// </summary> | |||
public byte LogicChannelNo { get; set; } | |||
/// <summary> | |||
/// 开始时间 | |||
/// </summary> | |||
public DateTime BeginTime { get; set; } | |||
/// <summary> | |||
/// 结束时间 | |||
/// </summary> | |||
public DateTime EndTime { get; set; } | |||
/// <summary> | |||
/// 报警标志 | |||
/// </summary> | |||
public uint AlarmFlag { get; set; } | |||
/// <summary> | |||
/// 音视频资源类型 | |||
/// </summary> | |||
public byte AVResourceType { get; set; } | |||
/// <summary> | |||
/// 码流类型 | |||
/// </summary> | |||
public byte StreamType { get; set; } | |||
/// <summary> | |||
/// 存储器类型 | |||
/// </summary> | |||
public byte MemoryType { get; set; } | |||
/// <summary> | |||
/// 文件大小 | |||
/// </summary> | |||
public uint FileSize { get; set; } | |||
} | |||
} |