@@ -17,7 +17,15 @@ jobs: | |||||
run: dotnet --info | run: dotnet --info | ||||
- name: dotnet restore | - name: dotnet restore | ||||
run: dotnet restore ./src/JT808.Protocol.sln | run: dotnet restore ./src/JT808.Protocol.sln | ||||
- name: dotnet build | |||||
- name: dotnet jt808 build | |||||
run: dotnet build ./src/JT808.Protocol.Test/JT808.Protocol.Test.csproj | run: dotnet build ./src/JT808.Protocol.Test/JT808.Protocol.Test.csproj | ||||
- name: dotnet test | |||||
- name: dotnet jt808 test | |||||
run: dotnet test ./src/JT808.Protocol.Test/JT808.Protocol.Test.csproj | run: dotnet test ./src/JT808.Protocol.Test/JT808.Protocol.Test.csproj | ||||
- name: dotnet jt808_jt1078 build | |||||
run: dotnet build ./src/JT808.Protocol.Extensions/JT808.Protocol.Extensions.JT1078/JT808.Protocol.Extensions.JT1078.Test.csproj | |||||
- name: dotnet jt808_jt1078 test | |||||
run: dotnet test ./src/JT808.Protocol.Extensions/JT808.Protocol.Extensions.JT1078/JT808.Protocol.Extensions.JT1078.Test.csproj | |||||
- name: dotnet jt808_jtas build | |||||
run: dotnet build ./src/JT808.Protocol.Extensions/JT808.Protocol.Extensions.JTActiveSafety/JT808.Protocol.Extensions.JTActiveSafety.Test.csproj | |||||
- name: dotnet jt808_jtas test | |||||
run: dotnet test ./src/JT808.Protocol.Extensions/JT808.Protocol.Extensions.JTActiveSafety/JT808.Protocol.Extensions.JTActiveSafety.Test.csproj |
@@ -420,3 +420,79 @@ Platform=AnyCpu Server=False Toolchain=.NET Core 5.0 | |||||
| 73 | 0x0608 | √ | √ | 查询区域或线路数据应答 |新增| | | 73 | 0x0608 | √ | √ | 查询区域或线路数据应答 |新增| | ||||
| 74 | 0xE000~0xEFFF | 保留 | 保留 | 厂商自定义上行消息 |新增| | | 74 | 0xE000~0xEFFF | 保留 | 保留 | 厂商自定义上行消息 |新增| | ||||
| 75 | 0xF000~0xFFFF | 保留 | 保留 | 厂商自定义下行消息 |新增| | | 75 | 0xF000~0xFFFF | 保留 | 保留 | 厂商自定义下行消息 |新增| | ||||
## 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(); | |||||
``` | |||||
## 主动安全(苏标)扩展JT808协议消息对照表 | |||||
| 序号 | 消息ID | 完成情况 | 测试情况 | 消息体名称 | | |||||
| :---: | :---: | :---: | :---: | :---:| | |||||
| 1 | 0x1210 | √ | √ | 报警附件信息消息 | | |||||
| 2 | 0x1211 | √ | √ | 文件信息上传 | | |||||
| 3 | 0x1212 | √ | √ | 文件上传完成消息 | | |||||
| 4 | 0x9208 | √ | √ | 报警附件上传指令 | | |||||
| 5 | 0x9212 | √ | √ | 文件上传完成消息应答 | | |||||
| 6 | 0x0200_0x64 | √ | √ | 高级驾驶辅助系统报警信息 | | |||||
| 7 | 0x0200_0x65 | √ | √ | 驾驶员状态监测系统报警信息 | | |||||
| 8 | 0x0200_0x66 | √ | √ | 胎压监测系统报警信息 | | |||||
| 9 | 0x0200_0x67 | √ | √ | 盲区监测系统报警信息 | | |||||
| 10 | 0x8103_0xF364 | √ | √ | 高级驾驶辅助系统参数 | | |||||
| 11 | 0x8103_0xF365 | √ | √ | 驾驶员状态监测系统参数 | | |||||
| 12 | 0x8103_0xF366 | √ | √ | 胎压监测系统参数 | | |||||
| 13 | 0x8103_0xF367 | √ | √ | 盲区监测系统参数 | | |||||
| 14 | 0x0900 | √ | √ | 上传基本信息 | | |||||
| 15 | 0x0900_0xF7 | √ | √ | 外设工作状态 | | |||||
| 16 | 0x0900_0xF8 | √ | √ | 外设系统信息 | | |||||
| 17 | 0x8900 | √ | √ | 查询基本信息 | | |||||
| 18 | 0x8900_0xF7 | √ | √ | 外设工作状态 | | |||||
| 19 | 0x8900_0xF8 | √ | √ | 外设系统信息 | | |||||
## 使用方法 | |||||
```dotnet | |||||
IServiceCollection serviceDescriptors1 = new ServiceCollection(); | |||||
serviceDescriptors1.AddJT808Configure() | |||||
.AddJTActiveSafetyConfigure(); | |||||
``` |
@@ -0,0 +1,22 @@ | |||||
<Project Sdk="Microsoft.NET.Sdk"> | |||||
<PropertyGroup> | |||||
<TargetFramework>net5.0</TargetFramework> | |||||
</PropertyGroup> | |||||
<ItemGroup> | |||||
<PackageReference Include="Microsoft.Extensions.DependencyInjection" Version="5.0.1" /> | |||||
<PackageReference Include="Microsoft.Extensions.Logging" Version="5.0.0" /> | |||||
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.8.3" /> | |||||
<PackageReference Include="xunit" Version="2.4.1" /> | |||||
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.3"> | |||||
<PrivateAssets>all</PrivateAssets> | |||||
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets> | |||||
</PackageReference> | |||||
</ItemGroup> | |||||
<ItemGroup> | |||||
<ProjectReference Include="..\JT808.Protocol.Extensions.JT1078\JT808.Protocol.Extensions.JT1078.csproj" /> | |||||
</ItemGroup> | |||||
</Project> |
@@ -0,0 +1,91 @@ | |||||
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<DefaultGlobalConfig>(); | |||||
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, | |||||
JT808LocationAttachData = new Dictionary<byte, JT808_0x0200_BodyBase>() | |||||
}; | |||||
jT808UploadLocationRequest.JT808LocationAttachData.Add(0x14, new JT808_0x0200_0x14 | |||||
{ | |||||
VideoRelateAlarm = 100 | |||||
}); | |||||
jT808UploadLocationRequest.JT808LocationAttachData.Add(0x15, new JT808_0x0200_0x15 | |||||
{ | |||||
VideoSignalLoseAlarmStatus = 100 | |||||
}); | |||||
jT808UploadLocationRequest.JT808LocationAttachData.Add(0x16, new JT808_0x0200_0x16 | |||||
{ | |||||
VideoSignalOcclusionAlarmStatus = 100 | |||||
}); | |||||
jT808UploadLocationRequest.JT808LocationAttachData.Add(0x17, new JT808_0x0200_0x17 | |||||
{ | |||||
StorageFaultAlarmStatus = 100 | |||||
}); | |||||
jT808UploadLocationRequest.JT808LocationAttachData.Add(0x18, new JT808_0x0200_0x18 | |||||
{ | |||||
AbnormalDrivingBehaviorAlarmType = 100, | |||||
FatigueLevel = 88 | |||||
}); | |||||
var hex = JT808Serializer.Serialize(jT808UploadLocationRequest).ToHexString(); | |||||
Assert.Equal("000000010000000200BA7F0E07E4F11C0028003C0000180715101010140400000064150400000064160400000064170200641803006458", hex); | |||||
} | |||||
[Fact] | |||||
public void Test2() | |||||
{ | |||||
byte[] bodys = "000000010000000200BA7F0E07E4F11C0028003C0000180715101010140400000064150400000064160400000064170200641803006458".ToHexBytes(); | |||||
JT808_0x0200 jT808UploadLocationRequest = JT808Serializer.Deserialize<JT808_0x0200>(bodys); | |||||
Assert.Equal(1u, 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(2u, jT808UploadLocationRequest.StatusFlag); | |||||
Assert.Equal(100u, ((JT808_0x0200_0x14)jT808UploadLocationRequest.JT808LocationAttachData[0x14]).VideoRelateAlarm); | |||||
Assert.Equal(100u, ((JT808_0x0200_0x15)jT808UploadLocationRequest.JT808LocationAttachData[0x15]).VideoSignalLoseAlarmStatus); | |||||
Assert.Equal(100u, ((JT808_0x0200_0x16)jT808UploadLocationRequest.JT808LocationAttachData[0x16]).VideoSignalOcclusionAlarmStatus); | |||||
Assert.Equal(100u, ((JT808_0x0200_0x17)jT808UploadLocationRequest.JT808LocationAttachData[0x17]).StorageFaultAlarmStatus); | |||||
Assert.Equal(100u, ((JT808_0x0200_0x18)jT808UploadLocationRequest.JT808LocationAttachData[0x18]).AbnormalDrivingBehaviorAlarmType); | |||||
Assert.Equal(88, ((JT808_0x0200_0x18)jT808UploadLocationRequest.JT808LocationAttachData[0x18]).FatigueLevel); | |||||
} | |||||
[Fact] | |||||
public void Test3() | |||||
{ | |||||
byte[] bodys = "000000010000000200BA7F0E07E4F11C0028003C0000180715101010140400000064150400000064160400000064170200641803006458".ToHexBytes(); | |||||
string json = JT808Serializer.Analyze<JT808_0x0200>(bodys); | |||||
} | |||||
} | |||||
} |
@@ -0,0 +1,114 @@ | |||||
using JT808.Protocol.Extensions.JT1078.MessageBody; | |||||
using JT808.Protocol.Extensions.JT1078.Enums; | |||||
using JT808.Protocol.MessageBody; | |||||
using Microsoft.Extensions.DependencyInjection; | |||||
using System; | |||||
using System.Collections.Generic; | |||||
using System.Text; | |||||
using Xunit; | |||||
namespace JT808.Protocol.Extensions.JT1078.Test | |||||
{ | |||||
public class JT808_0x0200Test | |||||
{ | |||||
JT808Serializer JT808Serializer; | |||||
public JT808_0x0200Test() | |||||
{ | |||||
IServiceCollection serviceDescriptors1 = new ServiceCollection(); | |||||
serviceDescriptors1 | |||||
.AddJT808Configure() | |||||
.AddJT1078Configure(); | |||||
var ServiceProvider1 = serviceDescriptors1.BuildServiceProvider(); | |||||
var defaultConfig = ServiceProvider1.GetRequiredService<IJT808Config>(); | |||||
JT808Serializer = defaultConfig.GetSerializer(); | |||||
} | |||||
[Fact] | |||||
public void Test_0x14_1() | |||||
{ | |||||
JT808_0x0200 jT808UploadLocationRequest = new JT808_0x0200 | |||||
{ | |||||
AlarmFlag = 1, | |||||
Altitude = 40, | |||||
GPSTime = DateTime.Parse("2020-01-31 20:20:20"), | |||||
Lat = 12222222, | |||||
Lng = 132444444, | |||||
Speed = 60, | |||||
Direction = 0, | |||||
StatusFlag = 2, | |||||
JT808LocationAttachData = new Dictionary<byte, JT808_0x0200_BodyBase>() | |||||
}; | |||||
jT808UploadLocationRequest.JT808LocationAttachData.Add(JT808_JT1078_Constants.JT808_0X0200_0x14, new JT808_0x0200_0x14 | |||||
{ | |||||
VideoRelateAlarm = (uint)(VideoRelateAlarmType.视频信号遮挡报警 | VideoRelateAlarmType.其他视频设备故障报警) | |||||
}); | |||||
var hex = JT808Serializer.Serialize(jT808UploadLocationRequest).ToHexString(); | |||||
Assert.Equal("000000010000000200BA7F0E07E4F11C0028003C000020013120202014040000000A", hex); | |||||
} | |||||
[Fact] | |||||
public void Test_0x14_2() | |||||
{ | |||||
byte[] bodys = "000000010000000200BA7F0E07E4F11C0028003C000020013120202014040000000A".ToHexBytes(); | |||||
JT808_0x0200 jT808UploadLocationRequest = JT808Serializer.Deserialize<JT808_0x0200>(bodys); | |||||
Assert.Equal((uint)1, jT808UploadLocationRequest.AlarmFlag); | |||||
Assert.Equal(DateTime.Parse("2020-01-31 20:20:20"), 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)(VideoRelateAlarmType.视频信号遮挡报警 | VideoRelateAlarmType.其他视频设备故障报警), ((JT808_0x0200_0x14)jT808UploadLocationRequest.JT808LocationAttachData[JT808_JT1078_Constants.JT808_0X0200_0x14]).VideoRelateAlarm); | |||||
} | |||||
[Fact] | |||||
public void Test_0x14_3() | |||||
{ | |||||
byte[] bodys = "000000010000000200BA7F0E07E4F11C0028003C000020013120202014040000000A".ToHexBytes(); | |||||
string json = JT808Serializer.Analyze<JT808_0x0200>(bodys); | |||||
} | |||||
[Fact] | |||||
public void Test_0x15_1() | |||||
{ | |||||
JT808_0x0200 jT808UploadLocationRequest = new JT808_0x0200 | |||||
{ | |||||
AlarmFlag = 1, | |||||
Altitude = 40, | |||||
GPSTime = DateTime.Parse("2020-01-31 20:20:20"), | |||||
Lat = 12222222, | |||||
Lng = 132444444, | |||||
Speed = 60, | |||||
Direction = 0, | |||||
StatusFlag = 2, | |||||
JT808LocationAttachData = new Dictionary<byte, JT808_0x0200_BodyBase>() | |||||
}; | |||||
jT808UploadLocationRequest.JT808LocationAttachData.Add(JT808_JT1078_Constants.JT808_0X0200_0x15, new JT808_0x0200_0x15 | |||||
{ | |||||
VideoSignalLoseAlarmStatus=3 | |||||
}); | |||||
var hex = JT808Serializer.Serialize(jT808UploadLocationRequest).ToHexString(); | |||||
Assert.Equal("000000010000000200BA7F0E07E4F11C0028003C0000200131202020150400000003", hex); | |||||
} | |||||
[Fact] | |||||
public void Test_0x15_2() | |||||
{ | |||||
byte[] bodys = "000000010000000200BA7F0E07E4F11C0028003C0000200131202020150400000003".ToHexBytes(); | |||||
JT808_0x0200 jT808UploadLocationRequest = JT808Serializer.Deserialize<JT808_0x0200>(bodys); | |||||
Assert.Equal((uint)1, jT808UploadLocationRequest.AlarmFlag); | |||||
Assert.Equal(DateTime.Parse("2020-01-31 20:20:20"), 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(3u, ((JT808_0x0200_0x15)jT808UploadLocationRequest.JT808LocationAttachData[JT808_JT1078_Constants.JT808_0X0200_0x15]).VideoSignalLoseAlarmStatus); | |||||
} | |||||
[Fact] | |||||
public void Test_0x15_3() | |||||
{ | |||||
byte[] bodys = "000000010000000200BA7F0E07E4F11C0028003C0000200131202020150400000003".ToHexBytes(); | |||||
string json = JT808Serializer.Analyze<JT808_0x0200>(bodys); | |||||
} | |||||
} | |||||
} |
@@ -0,0 +1,65 @@ | |||||
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 hex = JT808Serializer.Serialize(jT808_0x1003).ToHexString(); | |||||
Assert.Equal("03020504000101060708", hex); | |||||
} | |||||
[Fact] | |||||
public void Test2() | |||||
{ | |||||
JT808_0x1003 jT808_0x1003 = JT808Serializer.Deserialize<JT808_0x1003>("03020504000101060708".ToHexBytes()); | |||||
Assert.Equal(1,jT808_0x1003.AudioFrameLength); | |||||
Assert.Equal(2, jT808_0x1003.EnterAudioChannelsNumber); | |||||
Assert.Equal(3, jT808_0x1003.EnterAudioEncoding); | |||||
Assert.Equal(4, jT808_0x1003.EnterAudioSampleDigits); | |||||
Assert.Equal(5, jT808_0x1003.EnterAudioSampleRate); | |||||
Assert.Equal(1, jT808_0x1003.IsSupportedAudioOutput); | |||||
Assert.Equal(6, jT808_0x1003.VideoEncoding); | |||||
Assert.Equal(7, jT808_0x1003.TerminalSupportedMaxNumberOfAudioPhysicalChannels); | |||||
Assert.Equal(8, jT808_0x1003.TerminalSupportedMaxNumberOfVideoPhysicalChannels); | |||||
} | |||||
[Fact] | |||||
public void Test3() | |||||
{ | |||||
var json = JT808Serializer.Analyze<JT808_0x1003>("03020504000101060708".ToHexBytes()); | |||||
} | |||||
} | |||||
} |
@@ -0,0 +1,66 @@ | |||||
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 hex = JT808Serializer.Serialize(jT808_0x1005).ToHexString(); | |||||
Assert.Equal("19071610200119071610250200010001", hex); | |||||
} | |||||
[Fact] | |||||
public void Test2() | |||||
{ | |||||
var jT808_0x1005 = JT808Serializer.Deserialize<JT808_0x1005>("19071610200119071610250200010001".ToHexBytes()); | |||||
Assert.Equal(Convert.ToDateTime("2019-07-16 10:20:01"),jT808_0x1005.BeginTime); | |||||
Assert.Equal(Convert.ToDateTime("2019-07-16 10:25:02"),jT808_0x1005.EndTime); | |||||
Assert.Equal(1, jT808_0x1005.GettingOffNumber); | |||||
Assert.Equal(1, jT808_0x1005.GettingOnNumber); | |||||
} | |||||
[Fact] | |||||
public void Test3() | |||||
{ | |||||
var json = JT808Serializer.Analyze<JT808_0x1005>("19071610200119071610250200010001".ToHexBytes()); | |||||
} | |||||
} | |||||
} |
@@ -0,0 +1,141 @@ | |||||
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; | |||||
using System.Linq; | |||||
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 hex = JT808Serializer.Serialize(jT808_0x1205).ToHexString(); | |||||
Assert.Equal("0001000000020419071610200119071610250100000000000000010206050000000329190716112001190716112502000000000000000B153D330000001F", hex); | |||||
} | |||||
[Fact] | |||||
public void Test2() | |||||
{ | |||||
var jT808_0x1205 = JT808Serializer.Deserialize<JT808_0x1205>("0001000000020419071610200119071610250100000000000000010206050000000329190716112001190716112502000000000000000B153D330000001F".ToHexBytes()); | |||||
Assert.Equal(1, jT808_0x1205.MsgNum); | |||||
Assert.Equal(2u, jT808_0x1205.AVResouceTotal); | |||||
Assert.Equal(1u, jT808_0x1205.AVResouces[0].AlarmFlag); | |||||
Assert.Equal(2, jT808_0x1205.AVResouces[0].AVResourceType); | |||||
Assert.Equal(Convert.ToDateTime("2019-07-16 10:20:01"),jT808_0x1205.AVResouces[0].BeginTime); | |||||
Assert.Equal(Convert.ToDateTime("2019-07-16 10:25:01"),jT808_0x1205.AVResouces[0].EndTime); | |||||
Assert.Equal(3u, jT808_0x1205.AVResouces[0].FileSize); | |||||
Assert.Equal(4, jT808_0x1205.AVResouces[0].LogicChannelNo); | |||||
Assert.Equal(5, jT808_0x1205.AVResouces[0].MemoryType); | |||||
Assert.Equal(6, jT808_0x1205.AVResouces[0].StreamType); | |||||
Assert.Equal(11u, jT808_0x1205.AVResouces[1].AlarmFlag); | |||||
Assert.Equal(21, jT808_0x1205.AVResouces[1].AVResourceType); | |||||
Assert.Equal(Convert.ToDateTime("2019-07-16 11:20:01"),jT808_0x1205.AVResouces[1].BeginTime); | |||||
Assert.Equal(Convert.ToDateTime("2019-07-16 11:25:02"),jT808_0x1205.AVResouces[1].EndTime); | |||||
Assert.Equal(31u, jT808_0x1205.AVResouces[1].FileSize); | |||||
Assert.Equal(41, jT808_0x1205.AVResouces[1].LogicChannelNo); | |||||
Assert.Equal(51, jT808_0x1205.AVResouces[1].MemoryType); | |||||
Assert.Equal(61, jT808_0x1205.AVResouces[1].StreamType); | |||||
} | |||||
[Fact] | |||||
public void Test3() | |||||
{ | |||||
var json = JT808Serializer.Analyze<JT808_0x1205>("000100000002041907161020011907161025010000000102060500000003291907161120011907161125020000000B153D330000001F".ToHexBytes()); | |||||
} | |||||
[Fact] | |||||
public void Test4() | |||||
{ | |||||
var data1 = JT808Serializer.HeaderDeserialize("7E120523A204066657506200EB00020001015A00000023012012191042052012191050190000000000000000000101064446D10120121910221720121910420500000000000000000001010F1FE8EB0120121910023420121910221700000000000000000001010F182D5C0120121909471120121910015500000000000000000001010B38F2430120121909274020121909471100000000000000000001010F056DB40120121909080920121909274000000000000000000001010F0724380120121908483820121909080900000000000000000001010F0530AB0120121908290720121908483800000000000000000001010F05896C0120121908093720121908290700000000000000000001010F02CD3B0120121907500520121908093700000000000000000001010F056FEF0120121907303420121907500500000000000000000001010F043C3401201219072541201219073034000000000000000000010103C26C5F0120121907061120121907254100000000000000000001010F03F0C10120121906464220121907061100000000000000000001010F02F6330120121906271220121906464200000000000000000001010F02E43B0120121906074220121906271200000000000000000001010F033D670120121905481120121906074200000000000000000001010F088BF20120121905284120121905481100000000000000000001010F03F9FE0120121905091020121905284100000000000000000001010F05B1040120121904494020121905091000000000000000000001010F02B3540120121904301020121904494000000000000000000001010F0417B00120121904103920121904301000000000000000000001010F0538970120121903510820121904103900000000000000000001010F054E9E0120121903313820121903510800000000000000000001010F016ECB0120121903120820121903313800000000000000000001010F0333C00120121902523820121903120700000000000000000001010F029D230120121902330720121902523700000000000000000001010F0354E40120121902133720121902330700000000000000000001010F03303D0120121901540720121902133700000000000000000001010F04981E0120121901343720121901540700000000000000000001010F02AD940120121901150820121901343700000000000000000001010EFFD7CF0120121900553720121901150800000000000000000001010F07D9330120121900360720121900553700000000000000000001010F040E740C7E".ToHexBytes()); | |||||
var data2 = JT808Serializer.HeaderDeserialize("7E1205203804066657506200EC000200020120121900163320121900360700000000000000000001010F0CE4CD0120121900002220121900163300000000000000000001010C6F9E7B5D7E".ToHexBytes()); | |||||
var realBody = data1.Bodies.Concat(data2.Bodies).ToArray(); | |||||
var result = JT808Serializer.Deserialize<JT808_0x1205>(realBody); | |||||
} | |||||
[Fact] | |||||
public void Test5() | |||||
{ | |||||
var data1 = JT808Serializer.Deserialize("7E120523A204066657506200EB00020001015A00000023012012191042052012191050190000000000000000000101064446D10120121910221720121910420500000000000000000001010F1FE8EB0120121910023420121910221700000000000000000001010F182D5C0120121909471120121910015500000000000000000001010B38F2430120121909274020121909471100000000000000000001010F056DB40120121909080920121909274000000000000000000001010F0724380120121908483820121909080900000000000000000001010F0530AB0120121908290720121908483800000000000000000001010F05896C0120121908093720121908290700000000000000000001010F02CD3B0120121907500520121908093700000000000000000001010F056FEF0120121907303420121907500500000000000000000001010F043C3401201219072541201219073034000000000000000000010103C26C5F0120121907061120121907254100000000000000000001010F03F0C10120121906464220121907061100000000000000000001010F02F6330120121906271220121906464200000000000000000001010F02E43B0120121906074220121906271200000000000000000001010F033D670120121905481120121906074200000000000000000001010F088BF20120121905284120121905481100000000000000000001010F03F9FE0120121905091020121905284100000000000000000001010F05B1040120121904494020121905091000000000000000000001010F02B3540120121904301020121904494000000000000000000001010F0417B00120121904103920121904301000000000000000000001010F0538970120121903510820121904103900000000000000000001010F054E9E0120121903313820121903510800000000000000000001010F016ECB0120121903120820121903313800000000000000000001010F0333C00120121902523820121903120700000000000000000001010F029D230120121902330720121902523700000000000000000001010F0354E40120121902133720121902330700000000000000000001010F03303D0120121901540720121902133700000000000000000001010F04981E0120121901343720121901540700000000000000000001010F02AD940120121901150820121901343700000000000000000001010EFFD7CF0120121900553720121901150800000000000000000001010F07D9330120121900360720121900553700000000000000000001010F040E740C7E".ToHexBytes()); | |||||
var data2 = JT808Serializer.Deserialize("7E1205203804066657506200EC000200020120121900163320121900360700000000000000000001010F0CE4CD0120121900002220121900163300000000000000000001010C6F9E7B5D7E".ToHexBytes()); | |||||
var realBody = data1.SubDataBodies.Concat(data2.SubDataBodies).ToArray(); | |||||
var result = JT808Serializer.Deserialize<JT808_0x1205>(realBody); | |||||
} | |||||
[Fact] | |||||
public void Test6() | |||||
{ | |||||
var pack1 = JT808Serializer.Deserialize("7E120523A204066657506200EB00020001015A00000023012012191042052012191050190000000000000000000101064446D10120121910221720121910420500000000000000000001010F1FE8EB0120121910023420121910221700000000000000000001010F182D5C0120121909471120121910015500000000000000000001010B38F2430120121909274020121909471100000000000000000001010F056DB40120121909080920121909274000000000000000000001010F0724380120121908483820121909080900000000000000000001010F0530AB0120121908290720121908483800000000000000000001010F05896C0120121908093720121908290700000000000000000001010F02CD3B0120121907500520121908093700000000000000000001010F056FEF0120121907303420121907500500000000000000000001010F043C3401201219072541201219073034000000000000000000010103C26C5F0120121907061120121907254100000000000000000001010F03F0C10120121906464220121907061100000000000000000001010F02F6330120121906271220121906464200000000000000000001010F02E43B0120121906074220121906271200000000000000000001010F033D670120121905481120121906074200000000000000000001010F088BF20120121905284120121905481100000000000000000001010F03F9FE0120121905091020121905284100000000000000000001010F05B1040120121904494020121905091000000000000000000001010F02B3540120121904301020121904494000000000000000000001010F0417B00120121904103920121904301000000000000000000001010F0538970120121903510820121904103900000000000000000001010F054E9E0120121903313820121903510800000000000000000001010F016ECB0120121903120820121903313800000000000000000001010F0333C00120121902523820121903120700000000000000000001010F029D230120121902330720121902523700000000000000000001010F0354E40120121902133720121902330700000000000000000001010F03303D0120121901540720121902133700000000000000000001010F04981E0120121901343720121901540700000000000000000001010F02AD940120121901150820121901343700000000000000000001010EFFD7CF0120121900553720121901150800000000000000000001010F07D9330120121900360720121900553700000000000000000001010F040E740C7E".ToHexBytes()); | |||||
var pack2 = JT808Serializer.Deserialize("7E1205203804066657506200EC000200020120121900163320121900360700000000000000000001010F0CE4CD0120121900002220121900163300000000000000000001010C6F9E7B5D7E".ToHexBytes()); | |||||
var realBody = pack1.SubDataBodies.Concat(pack2.SubDataBodies).ToArray(); | |||||
var result = JT808Serializer.Analyze(pack1.Header.MsgId,realBody); | |||||
} | |||||
[Fact] | |||||
public void Test7() | |||||
{ | |||||
var pack1 = JT808Serializer.Deserialize("7E120523A204066657506200EB00020001015A00000023012012191042052012191050190000000000000000000101064446D10120121910221720121910420500000000000000000001010F1FE8EB0120121910023420121910221700000000000000000001010F182D5C0120121909471120121910015500000000000000000001010B38F2430120121909274020121909471100000000000000000001010F056DB40120121909080920121909274000000000000000000001010F0724380120121908483820121909080900000000000000000001010F0530AB0120121908290720121908483800000000000000000001010F05896C0120121908093720121908290700000000000000000001010F02CD3B0120121907500520121908093700000000000000000001010F056FEF0120121907303420121907500500000000000000000001010F043C3401201219072541201219073034000000000000000000010103C26C5F0120121907061120121907254100000000000000000001010F03F0C10120121906464220121907061100000000000000000001010F02F6330120121906271220121906464200000000000000000001010F02E43B0120121906074220121906271200000000000000000001010F033D670120121905481120121906074200000000000000000001010F088BF20120121905284120121905481100000000000000000001010F03F9FE0120121905091020121905284100000000000000000001010F05B1040120121904494020121905091000000000000000000001010F02B3540120121904301020121904494000000000000000000001010F0417B00120121904103920121904301000000000000000000001010F0538970120121903510820121904103900000000000000000001010F054E9E0120121903313820121903510800000000000000000001010F016ECB0120121903120820121903313800000000000000000001010F0333C00120121902523820121903120700000000000000000001010F029D230120121902330720121902523700000000000000000001010F0354E40120121902133720121902330700000000000000000001010F03303D0120121901540720121902133700000000000000000001010F04981E0120121901343720121901540700000000000000000001010F02AD940120121901150820121901343700000000000000000001010EFFD7CF0120121900553720121901150800000000000000000001010F07D9330120121900360720121900553700000000000000000001010F040E740C7E".ToHexBytes()); | |||||
var pack2 = JT808Serializer.Deserialize("7E1205203804066657506200EC000200020120121900163320121900360700000000000000000001010F0CE4CD0120121900002220121900163300000000000000000001010C6F9E7B5D7E".ToHexBytes()); | |||||
var realBody = pack1.SubDataBodies.Concat(pack2.SubDataBodies).ToArray(); | |||||
var result = JT808Serializer.AnalyzeJsonBuffer(pack1.Header.MsgId, realBody); | |||||
string json = Encoding.UTF8.GetString(result); | |||||
} | |||||
} | |||||
} |
@@ -0,0 +1,62 @@ | |||||
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 hex = JT808Serializer.Serialize(jT808_0x1206).ToHexString(); | |||||
Assert.Equal("000101", hex); | |||||
} | |||||
[Fact] | |||||
public void Test2() | |||||
{ | |||||
var jT808_0x1206 = JT808Serializer.Deserialize<JT808_0x1206>("000101".ToHexBytes()); | |||||
Assert.Equal(1, jT808_0x1206.MsgNum); | |||||
Assert.Equal(1, jT808_0x1206.Result); | |||||
} | |||||
[Fact] | |||||
public void Test3() | |||||
{ | |||||
var jT808_0x1206 = JT808Serializer.Analyze<JT808_0x1206>("000101".ToHexBytes()); | |||||
} | |||||
} | |||||
} |
@@ -0,0 +1,300 @@ | |||||
using JT808.Protocol.Enums; | |||||
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<DefaultGlobalConfig>(); | |||||
JT808Serializer = new JT808Serializer(defaultConfig); | |||||
} | |||||
[Fact] | |||||
public void Test1() | |||||
{ | |||||
JT808Package jT808Package = new JT808Package | |||||
{ | |||||
Header = new JT808Header | |||||
{ | |||||
MsgId = JT808MsgId.设置终端参数.ToUInt16Value(), | |||||
ManualMsgNum = 10, | |||||
TerminalPhoneNo = "123456789", | |||||
}, | |||||
Bodies = new JT808_0x8103 | |||||
{ | |||||
ParamList = new List<JT808_0x8103_BodyBase> { | |||||
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, | |||||
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, | |||||
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 hex = JT808Serializer.Serialize(jT808Package).ToHexString(); | |||||
Assert.Equal("7E8103009C000123456789000A070000007515030500040700000006080A00090C0000000B000201000000761B02010303020001070604050B0A08090F0E0C0D1312101117161415000000772B0201030500040700000006080A00090C0000000B000201030500040700000006080A00090C0000000B000200000079030302010000007A04000000010000007B0201020000007C140103020A00230012004500340067005600890078587E", hex); | |||||
} | |||||
[Fact] | |||||
public void Test2() | |||||
{ | |||||
byte[] bytes = "7E8103009C000123456789000A070000007515030500040700000006080A00090C0000000B000201000000761B02010303020001070604050B0A08090F0E0C0D1312101117161415000000772B0201030500040700000006080A00090C0000000B000201030500040700000006080A00090C0000000B000200000079030302010000007A04000000010000007B0201020000007C140103020A00230012004500340067005600890078587E".ToHexBytes(); | |||||
JT808Package jT808_0X8103 = JT808Serializer.Deserialize(bytes); | |||||
Assert.Equal(JT808MsgId.设置终端参数.ToUInt16Value(), jT808_0X8103.Header.MsgId); | |||||
Assert.Equal(10, jT808_0X8103.Header.MsgNum); | |||||
Assert.Equal("123456789", jT808_0X8103.Header.TerminalPhoneNo); | |||||
JT808_0x8103 jT808_0x8103 = (JT808_0x8103)jT808_0X8103.Bodies; | |||||
foreach (var item in jT808_0x8103.ParamList) | |||||
{ | |||||
switch (item) | |||||
{ | |||||
case JT808_0x8103_0x0075 jT808_0x8103_0x0075: | |||||
Assert.Equal(1,jT808_0x8103_0x0075.AudioOutputEnabled); | |||||
Assert.Equal(2,jT808_0x8103_0x0075.OSD); | |||||
Assert.Equal(3,jT808_0x8103_0x0075.RTS_EncodeMode); | |||||
Assert.Equal(4,jT808_0x8103_0x0075.RTS_KF_Interval); | |||||
Assert.Equal(5,jT808_0x8103_0x0075.RTS_Resolution); | |||||
Assert.Equal(6u,jT808_0x8103_0x0075.RTS_Target_CodeRate); | |||||
Assert.Equal(7,jT808_0x8103_0x0075.RTS_Target_FPS); | |||||
Assert.Equal(8,jT808_0x8103_0x0075.StreamStore_EncodeMode); | |||||
Assert.Equal(9,jT808_0x8103_0x0075.StreamStore_KF_Interval); | |||||
Assert.Equal(10,jT808_0x8103_0x0075.StreamStore_Resolution); | |||||
Assert.Equal(11u,jT808_0x8103_0x0075.StreamStore_Target_CodeRate); | |||||
Assert.Equal(12u,jT808_0x8103_0x0075.StreamStore_Target_FPS); | |||||
break; | |||||
case JT808_0x8103_0x0076 jT808_0x8103_0x0076: | |||||
Assert.Equal(1,jT808_0x8103_0x0076.AudioChannelTotal); | |||||
Assert.Equal(2, jT808_0x8103_0x0076.AVChannelTotal); | |||||
Assert.Equal(3,jT808_0x8103_0x0076.VudioChannelTotal); | |||||
Assert.Equal(27,jT808_0x8103_0x0076.ParamLength); | |||||
Assert.Equal(0,jT808_0x8103_0x0076.AVChannelRefTables[0].ChannelType); | |||||
Assert.Equal(1,jT808_0x8103_0x0076.AVChannelRefTables[0].IsConnectCloudPlat); | |||||
Assert.Equal(2,jT808_0x8103_0x0076.AVChannelRefTables[0].LogicChannelNo); | |||||
Assert.Equal(3,jT808_0x8103_0x0076.AVChannelRefTables[0].PhysicalChannelNo); | |||||
Assert.Equal(4,jT808_0x8103_0x0076.AVChannelRefTables[1].ChannelType); | |||||
Assert.Equal(5,jT808_0x8103_0x0076.AVChannelRefTables[1].IsConnectCloudPlat); | |||||
Assert.Equal(6,jT808_0x8103_0x0076.AVChannelRefTables[1].LogicChannelNo); | |||||
Assert.Equal(7,jT808_0x8103_0x0076.AVChannelRefTables[1].PhysicalChannelNo); | |||||
Assert.Equal(8,jT808_0x8103_0x0076.AVChannelRefTables[2].ChannelType); | |||||
Assert.Equal(9,jT808_0x8103_0x0076.AVChannelRefTables[2].IsConnectCloudPlat); | |||||
Assert.Equal(10,jT808_0x8103_0x0076.AVChannelRefTables[2].LogicChannelNo); | |||||
Assert.Equal(11,jT808_0x8103_0x0076.AVChannelRefTables[2].PhysicalChannelNo); | |||||
Assert.Equal(12,jT808_0x8103_0x0076.AVChannelRefTables[3].ChannelType); | |||||
Assert.Equal(13,jT808_0x8103_0x0076.AVChannelRefTables[3].IsConnectCloudPlat); | |||||
Assert.Equal(14,jT808_0x8103_0x0076.AVChannelRefTables[3].LogicChannelNo); | |||||
Assert.Equal(15,jT808_0x8103_0x0076.AVChannelRefTables[3].PhysicalChannelNo); | |||||
Assert.Equal(16,jT808_0x8103_0x0076.AVChannelRefTables[4].ChannelType); | |||||
Assert.Equal(17,jT808_0x8103_0x0076.AVChannelRefTables[4].IsConnectCloudPlat); | |||||
Assert.Equal(18,jT808_0x8103_0x0076.AVChannelRefTables[4].LogicChannelNo); | |||||
Assert.Equal(19,jT808_0x8103_0x0076.AVChannelRefTables[4].PhysicalChannelNo); | |||||
Assert.Equal(20,jT808_0x8103_0x0076.AVChannelRefTables[5].ChannelType); | |||||
Assert.Equal(21,jT808_0x8103_0x0076.AVChannelRefTables[5].IsConnectCloudPlat); | |||||
Assert.Equal(22,jT808_0x8103_0x0076.AVChannelRefTables[5].LogicChannelNo); | |||||
Assert.Equal(23,jT808_0x8103_0x0076.AVChannelRefTables[5].PhysicalChannelNo); | |||||
break; | |||||
case JT808_0x8103_0x0077 jT808_0x8103_0x0077: | |||||
Assert.Equal(2,jT808_0x8103_0x0077.NeedSetChannelTotal); | |||||
Assert.Equal(43,jT808_0x8103_0x0077.ParamLength); | |||||
Assert.Equal(1,jT808_0x8103_0x0077.SignalChannels[0].LogicChannelNo); | |||||
Assert.Equal(2,jT808_0x8103_0x0077.SignalChannels[0].OSD); | |||||
Assert.Equal(3,jT808_0x8103_0x0077.SignalChannels[0].RTS_EncodeMode); | |||||
Assert.Equal(4,jT808_0x8103_0x0077.SignalChannels[0].RTS_KF_Interval); | |||||
Assert.Equal(5,jT808_0x8103_0x0077.SignalChannels[0].RTS_Resolution); | |||||
Assert.Equal(6u,jT808_0x8103_0x0077.SignalChannels[0].RTS_Target_CodeRate); | |||||
Assert.Equal(7,jT808_0x8103_0x0077.SignalChannels[0].RTS_Target_FPS); | |||||
Assert.Equal(8,jT808_0x8103_0x0077.SignalChannels[0].StreamStore_EncodeMode); | |||||
Assert.Equal(9,jT808_0x8103_0x0077.SignalChannels[0].StreamStore_KF_Interval); | |||||
Assert.Equal(10,jT808_0x8103_0x0077.SignalChannels[0].StreamStore_Resolution); | |||||
Assert.Equal(11u,jT808_0x8103_0x0077.SignalChannels[0].StreamStore_Target_CodeRate); | |||||
Assert.Equal(12,jT808_0x8103_0x0077.SignalChannels[0].StreamStore_Target_FPS); | |||||
Assert.Equal(1,jT808_0x8103_0x0077.SignalChannels[1].LogicChannelNo); | |||||
Assert.Equal(2,jT808_0x8103_0x0077.SignalChannels[1].OSD); | |||||
Assert.Equal(3,jT808_0x8103_0x0077.SignalChannels[1].RTS_EncodeMode); | |||||
Assert.Equal(4,jT808_0x8103_0x0077.SignalChannels[1].RTS_KF_Interval); | |||||
Assert.Equal(5,jT808_0x8103_0x0077.SignalChannels[1].RTS_Resolution); | |||||
Assert.Equal(6u,jT808_0x8103_0x0077.SignalChannels[1].RTS_Target_CodeRate); | |||||
Assert.Equal(7,jT808_0x8103_0x0077.SignalChannels[1].RTS_Target_FPS); | |||||
Assert.Equal(8,jT808_0x8103_0x0077.SignalChannels[1].StreamStore_EncodeMode); | |||||
Assert.Equal(9,jT808_0x8103_0x0077.SignalChannels[1].StreamStore_KF_Interval); | |||||
Assert.Equal(10,jT808_0x8103_0x0077.SignalChannels[1].StreamStore_Resolution); | |||||
Assert.Equal(11u,jT808_0x8103_0x0077.SignalChannels[1].StreamStore_Target_CodeRate); | |||||
Assert.Equal(12,jT808_0x8103_0x0077.SignalChannels[1].StreamStore_Target_FPS); | |||||
break; | |||||
case JT808_0x8103_0x0079 jT808_0x8103_0x0079: | |||||
Assert.Equal(1,jT808_0x8103_0x0079.BeginMinute); | |||||
Assert.Equal(2,jT808_0x8103_0x0079.Duration); | |||||
Assert.Equal(3,jT808_0x8103_0x0079.StorageThresholds); | |||||
break; | |||||
case JT808_0x8103_0x007A jT808_0x8103_0x007A: | |||||
Assert.Equal(1u,jT808_0x8103_0x007A.AlarmShielding); | |||||
break; | |||||
case JT808_0x8103_0x007B jT808_0x8103_0x007B: | |||||
Assert.Equal(1,jT808_0x8103_0x007B.NuclearLoadNumber); | |||||
Assert.Equal(2,jT808_0x8103_0x007B.FatigueThreshold); | |||||
break; | |||||
case JT808_0x8103_0x007C jT808_0x8103_0x007C: | |||||
Assert.Equal(1,jT808_0x8103_0x007C.SleepWakeMode); | |||||
Assert.Equal(2,jT808_0x8103_0x007C.TimerWakeDaySet); | |||||
Assert.Equal(3,jT808_0x8103_0x007C.WakeConditionType); | |||||
Assert.Equal("12", jT808_0x8103_0x007C.TimerWakeDayParamter.TimePeriod1CloseTime); | |||||
Assert.Equal("23",jT808_0x8103_0x007C.TimerWakeDayParamter.TimePeriod1WakeTime); | |||||
Assert.Equal("34",jT808_0x8103_0x007C.TimerWakeDayParamter.TimePeriod2CloseTime); | |||||
Assert.Equal("45",jT808_0x8103_0x007C.TimerWakeDayParamter.TimePeriod2WakeTime); | |||||
Assert.Equal("56",jT808_0x8103_0x007C.TimerWakeDayParamter.TimePeriod3CloseTime); | |||||
Assert.Equal("67",jT808_0x8103_0x007C.TimerWakeDayParamter.TimePeriod3WakeTime); | |||||
Assert.Equal("78",jT808_0x8103_0x007C.TimerWakeDayParamter.TimePeriod4CloseTime); | |||||
Assert.Equal("89", jT808_0x8103_0x007C.TimerWakeDayParamter.TimePeriod4WakeTime); | |||||
Assert.Equal(10,jT808_0x8103_0x007C.TimerWakeDayParamter.TimerWakeEnableFlag); | |||||
break; | |||||
default: | |||||
break; | |||||
} | |||||
} | |||||
} | |||||
[Fact] | |||||
public void Test3() | |||||
{ | |||||
byte[] bytes = "7E8103009C000123456789000A070000007515030500040700000006080A00090C0000000B000201000000761B02010303020001070604050B0A08090F0E0C0D1312101117161415000000772B0201030500040700000006080A00090C0000000B000201030500040700000006080A00090C0000000B000200000079030302010000007A04000000010000007B0201020000007C140103020A00230012004500340067005600890078587E".ToHexBytes(); | |||||
var jT808_0X8103 = JT808Serializer.Analyze(bytes); | |||||
} | |||||
} | |||||
class DefaultGlobalConfig : GlobalConfigBase | |||||
{ | |||||
public override string ConfigId { protected set; get; } = "Default"; | |||||
} | |||||
} |
@@ -0,0 +1,101 @@ | |||||
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.ServerIp = "127.0.0.1"; | |||||
jT808_0X9101.TcpPort = 1888; | |||||
jT808_0X9101.UdpPort = 0; | |||||
jT808_0X9101.ChannelNo= 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.ServerIp); | |||||
Assert.Equal(9, jT808_0X9101.ServerIpLength); | |||||
Assert.Equal(1888, jT808_0X9101.TcpPort); | |||||
Assert.Equal(0, jT808_0X9101.UdpPort); | |||||
Assert.Equal(1, jT808_0X9101.ChannelNo); | |||||
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.ServerIp = "127.0.0.1"; | |||||
jT808_0X9101.TcpPort = 1888; | |||||
jT808_0X9101.UdpPort = 0; | |||||
jT808_0X9101.ChannelNo = 1; | |||||
jT808_0X9101.DataType = 1; | |||||
jT808_0X9101.StreamType = 1; | |||||
jT808Package.Bodies = jT808_0X9101; | |||||
var hex = JT808Serializer.Serialize(jT808Package).ToHexString(); | |||||
Assert.Equal("7E910100110123456798100001093132372E302E302E31076000000101014C7E", hex); | |||||
//7E910100110123456798100001093132372E302E302E31076000000101014C7E | |||||
} | |||||
[Fact] | |||||
public void Test4() | |||||
{ | |||||
var jT808_0X9101 = JT808Serializer.Analyze<JT808_0x9101>("093132372E302E302E3107600000010101".ToHexBytes()); | |||||
} | |||||
[Fact] | |||||
public void Test5() | |||||
{ | |||||
JT808Package jT808Package = new JT808Package(); | |||||
JT808Header header = new JT808Header(); | |||||
header.MsgId = 0x9101; | |||||
header.MsgNum = 1; | |||||
header.TerminalPhoneNo = ""; | |||||
jT808Package.Header = header; | |||||
JT808_0x9101 jT808_0X9101 = new JT808_0x9101(); | |||||
jT808_0X9101.ServerIp = ""; | |||||
jT808_0X9101.TcpPort = 1078; | |||||
jT808_0X9101.UdpPort = 0; | |||||
jT808_0X9101.ChannelNo = 3; | |||||
jT808_0X9101.DataType = 1; | |||||
jT808_0X9101.StreamType = 1; | |||||
jT808Package.Bodies = jT808_0X9101; | |||||
var hex = JT808Serializer.Serialize(jT808Package).ToHexString(); | |||||
} | |||||
} | |||||
} |
@@ -0,0 +1,73 @@ | |||||
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.ChannelNo = 1; | |||||
jT808_0X9102.ControlCmd = 1; | |||||
jT808_0X9102.CloseAVData = 0; | |||||
jT808_0X9102.StreamType = 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.ChannelNo); | |||||
Assert.Equal(1, jT808_0X9102.ControlCmd); | |||||
Assert.Equal(0, jT808_0X9102.CloseAVData); | |||||
Assert.Equal(0, jT808_0X9102.StreamType); | |||||
} | |||||
[Fact] | |||||
public void Test3() | |||||
{ | |||||
JT808Package jT808Package = new JT808Package(); | |||||
JT808Header header = new JT808Header(); | |||||
header.MsgId = 0x9102; | |||||
header.ManualMsgNum = 1; | |||||
header.TerminalPhoneNo = "12345679810"; | |||||
jT808Package.Header = header; | |||||
JT808_0x9102 jT808_0X9102 = new JT808_0x9102(); | |||||
jT808_0X9102.ChannelNo = 1; | |||||
jT808_0X9102.ControlCmd = 1; | |||||
jT808_0X9102.CloseAVData = 0; | |||||
jT808_0X9102.StreamType = 0; | |||||
jT808Package.Bodies = jT808_0X9102; | |||||
var hex = JT808Serializer.Serialize(jT808Package).ToHexString(); | |||||
//7E910200040123456798100001010100001E7E | |||||
Assert.Equal("7E910200040123456798100001010100001E7E", hex); | |||||
} | |||||
[Fact] | |||||
public void Test4() | |||||
{ | |||||
var jT808_0rX9102 = JT808Serializer.Analyze<JT808_0x9102>("01010000".ToHexBytes()); | |||||
} | |||||
} | |||||
} |
@@ -0,0 +1,62 @@ | |||||
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() | |||||
{ | |||||
ChannelNo=1, | |||||
DropRate=2 | |||||
}; | |||||
var hex = JT808Serializer.Serialize(jT808_0x9105).ToHexString(); | |||||
Assert.Equal("0102", hex); | |||||
} | |||||
[Fact] | |||||
public void Test2() | |||||
{ | |||||
var jT808_0x9105 = JT808Serializer.Deserialize<JT808_0x9105>("0102".ToHexBytes()); | |||||
Assert.Equal(1, jT808_0x9105.ChannelNo); | |||||
Assert.Equal(2, jT808_0x9105.DropRate); | |||||
} | |||||
[Fact] | |||||
public void Test3() | |||||
{ | |||||
var jT808_0x9105 = JT808Serializer.Analyze<JT808_0x9105>("0102".ToHexBytes()); | |||||
} | |||||
} | |||||
} |
@@ -0,0 +1,82 @@ | |||||
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() | |||||
{ | |||||
ChannelNo = 1, | |||||
MediaType = 2, | |||||
BeginTime = Convert.ToDateTime("2019-07-16 10:10:10"), | |||||
EndTime = Convert.ToDateTime("2019-07-16 10:10:10"), | |||||
PlaySpeed=3, | |||||
MemoryType=5, | |||||
PlaybackWay=6, | |||||
ServerIp="127.0.0.1", | |||||
ServerIpLength=9, | |||||
StreamType=7, | |||||
TcpPort=80, | |||||
UdpPort=8080 | |||||
}; | |||||
var hex = JT808Serializer.Serialize(jT808_0x9201).ToHexString(); | |||||
Assert.Equal("093132372E302E302E3100501F90010207050603190716101010190716101010", hex); | |||||
} | |||||
[Fact] | |||||
public void Test2() | |||||
{ | |||||
var jT808_0x9201 = JT808Serializer.Deserialize<JT808_0x9201>("093132372E302E302E3100501F90010207050603190716101010190716101010".ToHexBytes()); | |||||
Assert.Equal(1, jT808_0x9201.ChannelNo); | |||||
Assert.Equal(2, jT808_0x9201.MediaType); | |||||
Assert.Equal(Convert.ToDateTime("2019-07-16 10:10:10"), jT808_0x9201.BeginTime); | |||||
Assert.Equal(Convert.ToDateTime("2019-07-16 10:10:10"), jT808_0x9201.EndTime); | |||||
Assert.Equal(3, jT808_0x9201.PlaySpeed); | |||||
Assert.Equal(5, jT808_0x9201.MemoryType); | |||||
Assert.Equal(6, jT808_0x9201.PlaybackWay); | |||||
Assert.Equal("127.0.0.1", jT808_0x9201.ServerIp); | |||||
Assert.Equal(9, jT808_0x9201.ServerIpLength); | |||||
Assert.Equal(7, jT808_0x9201.StreamType); | |||||
Assert.Equal(80, jT808_0x9201.TcpPort); | |||||
Assert.Equal(8080, jT808_0x9201.UdpPort); | |||||
} | |||||
[Fact] | |||||
public void Test3() | |||||
{ | |||||
var jT808_0x9201 = JT808Serializer.Analyze<JT808_0x9201>("093132372E302E302E3100501F90010207050603190716101010190716101010".ToHexBytes()); | |||||
} | |||||
} | |||||
} |
@@ -0,0 +1,66 @@ | |||||
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() | |||||
{ | |||||
ChannelNo=1, | |||||
DragPlayPosition=Convert.ToDateTime("2019-07-16 10:10:10"), | |||||
PlaySpeed=2, | |||||
PlayControl=3 | |||||
}; | |||||
var hex = JT808Serializer.Serialize(jT808_0x9202).ToHexString(); | |||||
Assert.Equal("010302190716101010", hex); | |||||
} | |||||
[Fact] | |||||
public void Test2() | |||||
{ | |||||
var jT808_0x9202 = JT808Serializer.Deserialize<JT808_0x9202>("010302190716101010".ToHexBytes()); | |||||
Assert.Equal(1, jT808_0x9202.ChannelNo); | |||||
Assert.Equal(Convert.ToDateTime("2019-07-16 10:10:10"), jT808_0x9202.DragPlayPosition); | |||||
Assert.Equal(2, jT808_0x9202.PlaySpeed); | |||||
Assert.Equal(3, jT808_0x9202.PlayControl); | |||||
} | |||||
[Fact] | |||||
public void Test3() | |||||
{ | |||||
var jT808_0x9202 = JT808Serializer.Analyze<JT808_0x9202>("010302190716101010".ToHexBytes()); | |||||
} | |||||
} | |||||
} |
@@ -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_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, | |||||
MediaType=2, | |||||
BeginTime= Convert.ToDateTime("2019-07-16 10:10:10"), | |||||
EndTime= Convert.ToDateTime("2019-07-16 10:10:11"), | |||||
ChannelNo=3, | |||||
MemoryType=4, | |||||
StreamType =5 | |||||
}; | |||||
var hex = JT808Serializer.Serialize(jT808_0x9205).ToHexString(); | |||||
Assert.Equal("031907161010101907161010110000000000000001020504", hex); | |||||
} | |||||
[Fact] | |||||
public void Test2() | |||||
{ | |||||
var jT808_0x9205 = JT808Serializer.Deserialize<JT808_0x9205>("031907161010101907161010110000000000000001020504".ToHexBytes()); | |||||
Assert.Equal(1u, jT808_0x9205.AlarmFlag); | |||||
Assert.Equal(2, jT808_0x9205.MediaType); | |||||
Assert.Equal(Convert.ToDateTime("2019-07-16 10:10:10"), jT808_0x9205.BeginTime); | |||||
Assert.Equal(Convert.ToDateTime("2019-07-16 10:10:11"), jT808_0x9205.EndTime); | |||||
Assert.Equal(3, jT808_0x9205.ChannelNo); | |||||
Assert.Equal(4, jT808_0x9205.MemoryType); | |||||
Assert.Equal(5, jT808_0x9205.StreamType); | |||||
} | |||||
[Fact] | |||||
public void Test3() | |||||
{ | |||||
var jT808_0x9205 = JT808Serializer.Analyze<JT808_0x9205>("031907161010101907161010110000000000000001020504".ToHexBytes()); | |||||
} | |||||
} | |||||
} |
@@ -0,0 +1,92 @@ | |||||
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, | |||||
MediaType=2, | |||||
BeginTime= Convert.ToDateTime("2019-07-16 10:10:10"), | |||||
EndTime= Convert.ToDateTime("2019-07-16 10:10:11"), | |||||
ChannelNo=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 hex = JT808Serializer.Serialize(jT808_0x9206).ToHexString(); | |||||
Assert.Equal("093132372E302E302E31032802746B0631323334353608443A2F2F31313132031907161010101907161010110000000102050407", hex); | |||||
} | |||||
[Fact] | |||||
public void Test2() | |||||
{ | |||||
var jT808_0x9206 = JT808Serializer.Deserialize<JT808_0x9206>("093132372E302E302E31032802746B0631323334353608443A2F2F31313132031907161010101907161010110000000102050407".ToHexBytes()); | |||||
Assert.Equal(1u, jT808_0x9206.AlarmFlag); | |||||
Assert.Equal(2, jT808_0x9206.MediaType); | |||||
Assert.Equal(Convert.ToDateTime("2019-07-16 10:10:10"), jT808_0x9206.BeginTime); | |||||
Assert.Equal(Convert.ToDateTime("2019-07-16 10:10:11"), jT808_0x9206.EndTime); | |||||
Assert.Equal(3, jT808_0x9206.ChannelNo); | |||||
Assert.Equal(5, jT808_0x9206.StreamType); | |||||
Assert.Equal("D://1112", jT808_0x9206.FileUploadPath); | |||||
Assert.Equal(8, jT808_0x9206.FileUploadPathLength); | |||||
Assert.Equal(4, jT808_0x9206.MemoryPositon); | |||||
Assert.Equal("123456", jT808_0x9206.Password); | |||||
Assert.Equal(6, jT808_0x9206.PasswordLength); | |||||
Assert.Equal(808, jT808_0x9206.Port); | |||||
Assert.Equal("127.0.0.1", jT808_0x9206.ServerIp); | |||||
Assert.Equal(9, jT808_0x9206.ServerIpLength); | |||||
Assert.Equal(7, jT808_0x9206.TaskExcuteCondition); | |||||
Assert.Equal("tk", jT808_0x9206.UserName); | |||||
Assert.Equal(2, jT808_0x9206.UserNameLength); | |||||
} | |||||
[Fact] | |||||
public void Test3() | |||||
{ | |||||
var jT808_0x9206 = JT808Serializer.Analyze<JT808_0x9206>("093132372E302E302E31032802746B0631323334353608443A2F2F31313132031907161010101907161010110000000102050407".ToHexBytes()); | |||||
} | |||||
} | |||||
} |
@@ -0,0 +1,62 @@ | |||||
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 hex = JT808Serializer.Serialize(jT808_0x9207).ToHexString(); | |||||
Assert.Equal("000102", hex); | |||||
} | |||||
[Fact] | |||||
public void Test2() | |||||
{ | |||||
var jT808_0x9207 = JT808Serializer.Deserialize<JT808_0x9207>("000102".ToHexBytes()); | |||||
Assert.Equal(1, jT808_0x9207.MgsNum); | |||||
Assert.Equal(2, jT808_0x9207.UploadControl); | |||||
} | |||||
[Fact] | |||||
public void Test3() | |||||
{ | |||||
var jT808_0x9207 = JT808Serializer.Analyze<JT808_0x9207>("000102".ToHexBytes()); | |||||
} | |||||
} | |||||
} |
@@ -0,0 +1,65 @@ | |||||
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() | |||||
{ | |||||
ChannelNo=1, | |||||
Speed=2, | |||||
Direction=3 | |||||
}; | |||||
var hex = JT808Serializer.Serialize(jT808_0x9301).ToHexString(); | |||||
Assert.Equal("010302", hex); | |||||
} | |||||
[Fact] | |||||
public void Test2() | |||||
{ | |||||
var jT808_0x9301 = JT808Serializer.Deserialize<JT808_0x9301>("010302".ToHexBytes()); | |||||
Assert.Equal(1, jT808_0x9301.ChannelNo); | |||||
Assert.Equal(2, jT808_0x9301.Speed); | |||||
Assert.Equal(3, jT808_0x9301.Direction); | |||||
} | |||||
[Fact] | |||||
public void Test3() | |||||
{ | |||||
var jT808_0x9301 = JT808Serializer.Analyze<JT808_0x9301>("010302".ToHexBytes()); | |||||
} | |||||
} | |||||
} |
@@ -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_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 hex = JT808Serializer.Serialize(jT808_0x9302).ToHexString(); | |||||
Assert.Equal("0102", hex); | |||||
} | |||||
[Fact] | |||||
public void Test2() | |||||
{ | |||||
var jT808_0x9302 = JT808Serializer.Deserialize<JT808_0x9302>("0102".ToHexBytes()); | |||||
Assert.Equal(1, jT808_0x9302.LogicChannelNo); | |||||
Assert.Equal(2, jT808_0x9302.FocusAdjustmentDirection); | |||||
} | |||||
[Fact] | |||||
public void Test3() | |||||
{ | |||||
var jT808_0x9302 = JT808Serializer.Analyze<JT808_0x9302>("0102".ToHexBytes()); | |||||
} | |||||
} | |||||
} |
@@ -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_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() | |||||
{ | |||||
ChannelNo=1, | |||||
IrisAdjustment=2 | |||||
}; | |||||
var hex = JT808Serializer.Serialize(jT808_0x9303).ToHexString(); | |||||
Assert.Equal("0102", hex); | |||||
} | |||||
[Fact] | |||||
public void Test2() | |||||
{ | |||||
var jT808_0x9303 = JT808Serializer.Deserialize<JT808_0x9303>("0102".ToHexBytes()); | |||||
Assert.Equal(1, jT808_0x9303.ChannelNo); | |||||
Assert.Equal(2, jT808_0x9303.IrisAdjustment); | |||||
} | |||||
[Fact] | |||||
public void Test3() | |||||
{ | |||||
var jT808_0x9303 = JT808Serializer.Analyze<JT808_0x9303>("0102".ToHexBytes()); | |||||
} | |||||
} | |||||
} |
@@ -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_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() | |||||
{ | |||||
ChannelNo=1, | |||||
StartOrStop=2 | |||||
}; | |||||
var hex = JT808Serializer.Serialize(jT808_0x9304).ToHexString(); | |||||
Assert.Equal("0102", hex); | |||||
} | |||||
[Fact] | |||||
public void Test2() | |||||
{ | |||||
var jT808_0x9304 = JT808Serializer.Deserialize<JT808_0x9304>("0102".ToHexBytes()); | |||||
Assert.Equal(1, jT808_0x9304.ChannelNo); | |||||
Assert.Equal(2, jT808_0x9304.StartOrStop); | |||||
} | |||||
[Fact] | |||||
public void Test3() | |||||
{ | |||||
var jT808_0x9304 = JT808Serializer.Analyze<JT808_0x9304>("0102".ToHexBytes()); | |||||
} | |||||
} | |||||
} |
@@ -0,0 +1,56 @@ | |||||
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() | |||||
{ | |||||
ChannelNo=1, | |||||
StartOrStop=2 | |||||
}; | |||||
var hex = JT808Serializer.Serialize(jT808_0x9305).ToHexString(); | |||||
Assert.Equal("0102", hex); | |||||
} | |||||
[Fact] | |||||
public void Test2() | |||||
{ | |||||
var jT808_0x9305 = JT808Serializer.Analyze<JT808_0x9305>("0102".ToHexBytes()); | |||||
} | |||||
} | |||||
} |
@@ -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_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() | |||||
{ | |||||
ChannelNo=1, | |||||
ChangeMultipleControl=2 | |||||
}; | |||||
var hex = JT808Serializer.Serialize(jT808_0x9306).ToHexString(); | |||||
Assert.Equal("0102", hex); | |||||
} | |||||
[Fact] | |||||
public void Test2() | |||||
{ | |||||
var jT808_0x9306 = JT808Serializer.Deserialize<JT808_0x9306>("0102".ToHexBytes()); | |||||
Assert.Equal(1, jT808_0x9306.ChannelNo); | |||||
Assert.Equal(2, jT808_0x9306.ChangeMultipleControl); | |||||
} | |||||
[Fact] | |||||
public void Test3() | |||||
{ | |||||
var jT808_0x9306 = JT808Serializer.Analyze<JT808_0x9306>("0102".ToHexBytes()); | |||||
} | |||||
} | |||||
} |
@@ -0,0 +1,20 @@ | |||||
using JT808.Protocol.Extensions.JT1078.Enums; | |||||
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()); | |||||
return jT808Builder; | |||||
} | |||||
} | |||||
} |
@@ -0,0 +1,28 @@ | |||||
namespace JT808.Protocol.Extensions.JT1078.Enums | |||||
{ | |||||
#pragma warning disable CS1591 // 缺少对公共可见类型或成员的 XML 注释 | |||||
public enum JT808_JT1078_MsgId:ushort | |||||
{ | |||||
终端上传音视频属性 = 0x1003, | |||||
终端上传乘客流量 = 0x1005, | |||||
终端上传音视频资源列表 = 0x1205, | |||||
文件上传完成通知 = 0x1206, | |||||
查询终端音视频属性 = 0x9003, | |||||
实时音视频传输请求 = 0x9101, | |||||
音视频实时传输控制 = 0x9102, | |||||
实时音视频传输状态通知 = 0x9105, | |||||
平台下发远程录像回放请求 = 0x9201, | |||||
平台下发远程录像回放控制 = 0x9202, | |||||
查询资源列表 = 0x9205, | |||||
文件上传指令 = 0x9206, | |||||
文件上传控制 = 0x9207, | |||||
云台旋转 = 0x9301, | |||||
云台调整焦距控制 = 0x9302, | |||||
云台调整光圈控制 = 0x9303, | |||||
云台雨刷控制 = 0x9304, | |||||
红外补光控制 = 0x9305, | |||||
云台变倍控制 = 0x9306 | |||||
} | |||||
#pragma warning restore CS1591 // 缺少对公共可见类型或成员的 XML 注释 | |||||
} |
@@ -0,0 +1,18 @@ | |||||
using System; | |||||
namespace JT808.Protocol.Extensions.JT1078.Enums | |||||
{ | |||||
[Flags] | |||||
#pragma warning disable CS1591 // 缺少对公共可见类型或成员的 XML 注释 | |||||
public enum VideoRelateAlarmType:uint | |||||
{ | |||||
视频信号丢失报警=0, | |||||
视频信号遮挡报警=2, | |||||
存储单元故障报警=4, | |||||
其他视频设备故障报警=8, | |||||
客车超员报警=16, | |||||
异常驾驶行为报警=32, | |||||
特殊报警录像达到存储阈值报警=64, | |||||
} | |||||
#pragma warning restore CS1591 // 缺少对公共可见类型或成员的 XML 注释 | |||||
} |
@@ -0,0 +1,35 @@ | |||||
<Project Sdk="Microsoft.NET.Sdk"> | |||||
<PropertyGroup> | |||||
<TargetFrameworks>netstandard2.0;netstandard2.1;net5.0;</TargetFrameworks> | |||||
<LangVersion>8.0</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/JT808/blob/master/LICENSE</licenseUrl> | |||||
<license>https://github.com/SmallChi/JT808/blob/master/LICENSE</license> | |||||
<GeneratePackageOnBuild>false</GeneratePackageOnBuild> | |||||
<Version>2.3.7</Version> | |||||
<PackageLicenseFile>LICENSE</PackageLicenseFile> | |||||
<DocumentationFile>JT808.Protocol.Extensions.JT1078.xml</DocumentationFile> | |||||
</PropertyGroup> | |||||
<ItemGroup> | |||||
<None Include="..\..\..\LICENSE"> | |||||
<Pack>True</Pack> | |||||
<PackagePath></PackagePath> | |||||
</None> | |||||
</ItemGroup> | |||||
<ItemGroup> | |||||
<ProjectReference Include="..\..\JT808.Protocol\JT808.Protocol.csproj" /> | |||||
</ItemGroup> | |||||
</Project> |
@@ -0,0 +1,59 @@ | |||||
using System; | |||||
using System.Collections.Generic; | |||||
using System.Text; | |||||
namespace JT808.Protocol.Extensions.JT1078 | |||||
{ | |||||
public static class JT808_JT1078_Constants | |||||
{ | |||||
/// <summary> | |||||
/// 视频相关报警 | |||||
/// </summary> | |||||
public const byte JT808_0X0200_0x14 = 0x14; | |||||
/// <summary> | |||||
/// 视频信号丢失报警状态 | |||||
/// </summary> | |||||
public const byte JT808_0X0200_0x15 = 0x15; | |||||
/// <summary> | |||||
/// 视频信号遮挡报警状态 | |||||
/// </summary> | |||||
public const byte JT808_0X0200_0x16 = 0x16; | |||||
/// <summary> | |||||
/// 存储器故障报警状态 | |||||
/// </summary> | |||||
public const byte JT808_0X0200_0x17 = 0x17; | |||||
/// <summary> | |||||
/// 异常驾驶行为报警详细描述 | |||||
/// </summary> | |||||
public const byte JT808_0X0200_0x18 = 0x18; | |||||
/// <summary> | |||||
/// 音视频参数设置 | |||||
/// </summary> | |||||
public const uint JT808_0X8103_0x0075 = 0x0075; | |||||
/// <summary> | |||||
/// 音视频通道列表设置 | |||||
/// </summary> | |||||
public const uint JT808_0X8103_0x0076 = 0x0076; | |||||
/// <summary> | |||||
/// 单独视频通道参数设置 | |||||
/// </summary> | |||||
public const uint JT808_0X8103_0x0077 = 0x0077; | |||||
/// <summary> | |||||
/// 特殊报警录像参数设置 | |||||
/// </summary> | |||||
public const uint JT808_0X8103_0x0079 = 0x0079; | |||||
/// <summary> | |||||
/// 视频相关报警屏蔽字 | |||||
/// </summary> | |||||
public const uint JT808_0X8103_0x007A = 0x007A; | |||||
/// <summary> | |||||
/// 图像分析报警参数设置 | |||||
/// </summary> | |||||
public const uint JT808_0X8103_0x007B = 0x007B; | |||||
/// <summary> | |||||
/// 终端休眠模式唤醒设置 | |||||
/// </summary> | |||||
public const uint JT808_0X8103_0x007C = 0x007C; | |||||
} | |||||
} |
@@ -0,0 +1,65 @@ | |||||
using JT808.Protocol.Formatters; | |||||
using JT808.Protocol.MessageBody; | |||||
using JT808.Protocol.MessagePack; | |||||
using JT808.Protocol.Interfaces; | |||||
using System.Text.Json; | |||||
using JT808.Protocol.Extensions.JT1078.Enums; | |||||
using System.Linq; | |||||
namespace JT808.Protocol.Extensions.JT1078.MessageBody | |||||
{ | |||||
/// <summary> | |||||
/// 视频相关报警 | |||||
/// 0x0200_0x14 | |||||
/// </summary> | |||||
public class JT808_0x0200_0x14 : JT808_0x0200_BodyBase, IJT808MessagePackFormatter<JT808_0x0200_0x14>,IJT808Analyze | |||||
{ | |||||
public override byte AttachInfoId { get; set; } = 0x14; | |||||
/// <summary> | |||||
/// 数据 长度 | |||||
/// </summary> | |||||
public override byte AttachInfoLength { get; set; } = 4; | |||||
/// <summary> | |||||
/// 视频相关报警 | |||||
/// <see cref="JT808.Protocol.Extensions.JT1078.Enums.VideoRelateAlarmType"/> | |||||
/// </summary> | |||||
public uint VideoRelateAlarm { get; set; } | |||||
public void Analyze(ref JT808MessagePackReader reader, Utf8JsonWriter writer, IJT808Config config) | |||||
{ | |||||
JT808_0x0200_0x14 value = new JT808_0x0200_0x14(); | |||||
value.AttachInfoId = reader.ReadByte(); | |||||
writer.WriteNumber($"[{value.AttachInfoId.ReadNumber()}]附加信息Id", value.AttachInfoId); | |||||
value.AttachInfoLength = reader.ReadByte(); | |||||
writer.WriteNumber($"[{value.AttachInfoLength.ReadNumber()}]附加信息长度", value.AttachInfoLength); | |||||
value.VideoRelateAlarm = reader.ReadUInt32(); | |||||
writer.WriteNumber($"[{value.VideoRelateAlarm.ReadNumber()}]视频相关报警", value.VideoRelateAlarm); | |||||
var videoRelateAlarmFlags = JT808EnumExtensions.GetEnumTypes<VideoRelateAlarmType>(value.VideoRelateAlarm, 32); | |||||
if (videoRelateAlarmFlags.Any()) | |||||
{ | |||||
writer.WriteStartArray("视频报警集合"); | |||||
foreach (var item in videoRelateAlarmFlags) | |||||
{ | |||||
writer.WriteStringValue(item.ToString()); | |||||
} | |||||
writer.WriteEndArray(); | |||||
} | |||||
} | |||||
public JT808_0x0200_0x14 Deserialize(ref JT808MessagePackReader reader, IJT808Config config) | |||||
{ | |||||
JT808_0x0200_0x14 value = new JT808_0x0200_0x14(); | |||||
value.AttachInfoId = reader.ReadByte(); | |||||
value.AttachInfoLength = reader.ReadByte(); | |||||
value.VideoRelateAlarm = reader.ReadUInt32(); | |||||
return value; | |||||
} | |||||
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,69 @@ | |||||
using JT808.Protocol.Formatters; | |||||
using JT808.Protocol.Interfaces; | |||||
using JT808.Protocol.MessageBody; | |||||
using JT808.Protocol.MessagePack; | |||||
using System; | |||||
using System.Text.Json; | |||||
namespace JT808.Protocol.Extensions.JT1078.MessageBody | |||||
{ | |||||
/// <summary> | |||||
/// 视频信号丢失报警状态 | |||||
/// 0x0200_0x15 | |||||
/// </summary> | |||||
public class JT808_0x0200_0x15 : JT808_0x0200_BodyBase, IJT808MessagePackFormatter<JT808_0x0200_0x15>, IJT808Analyze | |||||
{ | |||||
public override byte AttachInfoId { get; set; } = 0x15; | |||||
/// <summary> | |||||
/// 数据 长度 | |||||
/// </summary> | |||||
public override byte AttachInfoLength { get; set; } = 4; | |||||
/// <summary> | |||||
/// 视频信号丢失报警状态 | |||||
/// </summary> | |||||
public uint VideoSignalLoseAlarmStatus { get; set; } | |||||
public void Analyze(ref JT808MessagePackReader reader, Utf8JsonWriter writer, IJT808Config config) | |||||
{ | |||||
JT808_0x0200_0x15 value = new JT808_0x0200_0x15(); | |||||
value.AttachInfoId = reader.ReadByte(); | |||||
writer.WriteNumber($"[{value.AttachInfoId.ReadNumber()}]附加信息Id", value.AttachInfoId); | |||||
value.AttachInfoLength = reader.ReadByte(); | |||||
writer.WriteNumber($"[{value.AttachInfoLength.ReadNumber()}]附加信息长度", value.AttachInfoLength); | |||||
value.VideoSignalLoseAlarmStatus = reader.ReadUInt32(); | |||||
writer.WriteNumber($"[{value.VideoSignalLoseAlarmStatus.ReadNumber()}]视频信号丢失报警状态", value.VideoSignalLoseAlarmStatus); | |||||
var videoSignalLoseAlarmStatusSpan = Convert.ToString(value.VideoSignalLoseAlarmStatus, 2).PadLeft(32, '0').AsSpan(); | |||||
writer.WriteStartArray("视频信号丢失报警状态集合"); | |||||
int index = 0; | |||||
foreach (var item in videoSignalLoseAlarmStatusSpan) | |||||
{ | |||||
if (item == '1') | |||||
{ | |||||
writer.WriteStringValue($"{index}通道视频信号丢失"); | |||||
} | |||||
else | |||||
{ | |||||
writer.WriteStringValue($"{index}通道视频正常"); | |||||
} | |||||
index++; | |||||
} | |||||
writer.WriteEndArray(); | |||||
} | |||||
public JT808_0x0200_0x15 Deserialize(ref JT808MessagePackReader reader, IJT808Config config) | |||||
{ | |||||
JT808_0x0200_0x15 value = new JT808_0x0200_0x15(); | |||||
value.AttachInfoId = reader.ReadByte(); | |||||
value.AttachInfoLength = reader.ReadByte(); | |||||
value.VideoSignalLoseAlarmStatus = reader.ReadUInt32(); | |||||
return value; | |||||
} | |||||
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,69 @@ | |||||
using JT808.Protocol.Formatters; | |||||
using JT808.Protocol.Interfaces; | |||||
using JT808.Protocol.MessageBody; | |||||
using JT808.Protocol.MessagePack; | |||||
using System; | |||||
using System.Text.Json; | |||||
namespace JT808.Protocol.Extensions.JT1078.MessageBody | |||||
{ | |||||
/// <summary> | |||||
/// 视频信号遮挡报警状态 | |||||
/// 0x0200_0x16 | |||||
/// </summary> | |||||
public class JT808_0x0200_0x16 : JT808_0x0200_BodyBase, IJT808MessagePackFormatter<JT808_0x0200_0x16>, IJT808Analyze | |||||
{ | |||||
public override byte AttachInfoId { get; set; } = 0x16; | |||||
/// <summary> | |||||
/// 数据 长度 | |||||
/// </summary> | |||||
public override byte AttachInfoLength { get; set; } = 4; | |||||
/// <summary> | |||||
/// 视频信号遮挡报警状态 | |||||
/// </summary> | |||||
public uint VideoSignalOcclusionAlarmStatus { get; set; } | |||||
public void Analyze(ref JT808MessagePackReader reader, Utf8JsonWriter writer, IJT808Config config) | |||||
{ | |||||
JT808_0x0200_0x16 value = new JT808_0x0200_0x16(); | |||||
value.AttachInfoId = reader.ReadByte(); | |||||
writer.WriteNumber($"[{value.AttachInfoId.ReadNumber()}]附加信息Id", value.AttachInfoId); | |||||
value.AttachInfoLength = reader.ReadByte(); | |||||
writer.WriteNumber($"[{value.AttachInfoLength.ReadNumber()}]附加信息长度", value.AttachInfoLength); | |||||
value.VideoSignalOcclusionAlarmStatus = reader.ReadUInt32(); | |||||
writer.WriteNumber($"[{value.VideoSignalOcclusionAlarmStatus.ReadNumber()}]视频信号遮挡报警状态", value.VideoSignalOcclusionAlarmStatus); | |||||
var videoSignalOcclusionAlarmStatusSpan = Convert.ToString(value.VideoSignalOcclusionAlarmStatus, 2).PadLeft(32, '0').AsSpan(); | |||||
writer.WriteStartArray("视频信号遮挡报警状态集合"); | |||||
int index = 0; | |||||
foreach (var item in videoSignalOcclusionAlarmStatusSpan) | |||||
{ | |||||
if (item == '1') | |||||
{ | |||||
writer.WriteStringValue($"{index}通道视频信号遮挡"); | |||||
} | |||||
else | |||||
{ | |||||
writer.WriteStringValue($"{index}通道视频正常"); | |||||
} | |||||
index++; | |||||
} | |||||
writer.WriteEndArray(); | |||||
} | |||||
public JT808_0x0200_0x16 Deserialize(ref JT808MessagePackReader reader, IJT808Config config) | |||||
{ | |||||
JT808_0x0200_0x16 value = new JT808_0x0200_0x16(); | |||||
value.AttachInfoId = reader.ReadByte(); | |||||
value.AttachInfoLength = reader.ReadByte(); | |||||
value.VideoSignalOcclusionAlarmStatus = reader.ReadUInt32(); | |||||
return value; | |||||
} | |||||
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,83 @@ | |||||
using JT808.Protocol.Formatters; | |||||
using JT808.Protocol.Interfaces; | |||||
using JT808.Protocol.MessageBody; | |||||
using JT808.Protocol.MessagePack; | |||||
using System; | |||||
using System.Text.Json; | |||||
namespace JT808.Protocol.Extensions.JT1078.MessageBody | |||||
{ | |||||
/// <summary> | |||||
/// 存储器故障报警状态 | |||||
/// 0x0200_0x17 | |||||
/// </summary> | |||||
public class JT808_0x0200_0x17 : JT808_0x0200_BodyBase, IJT808MessagePackFormatter<JT808_0x0200_0x17>, IJT808Analyze | |||||
{ | |||||
public override byte AttachInfoId { get; set; } = 0x17; | |||||
/// <summary> | |||||
/// 数据 长度 | |||||
/// </summary> | |||||
public override byte AttachInfoLength { get; set; } = 2; | |||||
/// <summary> | |||||
/// 存储器故障报警状态 | |||||
/// </summary> | |||||
public ushort StorageFaultAlarmStatus{ get; set; } | |||||
public void Analyze(ref JT808MessagePackReader reader, Utf8JsonWriter writer, IJT808Config config) | |||||
{ | |||||
JT808_0x0200_0x17 value = new JT808_0x0200_0x17(); | |||||
value.AttachInfoId = reader.ReadByte(); | |||||
writer.WriteNumber($"[{value.AttachInfoId.ReadNumber()}]附加信息Id", value.AttachInfoId); | |||||
value.AttachInfoLength = reader.ReadByte(); | |||||
writer.WriteNumber($"[{value.AttachInfoLength.ReadNumber()}]附加信息长度", value.AttachInfoLength); | |||||
value.StorageFaultAlarmStatus = reader.ReadUInt16(); | |||||
writer.WriteNumber($"[{value.StorageFaultAlarmStatus.ReadNumber()}]存储器故障报警状态", value.StorageFaultAlarmStatus); | |||||
var storageFaultAlarmStatusSpan = Convert.ToString(value.StorageFaultAlarmStatus, 2).PadLeft(16, '0').AsSpan(); | |||||
writer.WriteStartArray("存储器故障报警状态集合"); | |||||
int index = 0; | |||||
foreach (var item in storageFaultAlarmStatusSpan) | |||||
{ | |||||
if (index < 4) | |||||
{ | |||||
if (item == '1') | |||||
{ | |||||
writer.WriteStringValue($"{index}灾备存储装置故障"); | |||||
} | |||||
else | |||||
{ | |||||
writer.WriteStringValue($"{index}灾备存储装置正常"); | |||||
} | |||||
} | |||||
else | |||||
{ | |||||
if (item == '1') | |||||
{ | |||||
writer.WriteStringValue($"{index}主存储器故障"); | |||||
} | |||||
else | |||||
{ | |||||
writer.WriteStringValue($"{index}主存储器正常"); | |||||
} | |||||
} | |||||
index++; | |||||
} | |||||
writer.WriteEndArray(); | |||||
} | |||||
public JT808_0x0200_0x17 Deserialize(ref JT808MessagePackReader reader, IJT808Config config) | |||||
{ | |||||
JT808_0x0200_0x17 value = new JT808_0x0200_0x17(); | |||||
value.AttachInfoId = reader.ReadByte(); | |||||
value.AttachInfoLength = reader.ReadByte(); | |||||
value.StorageFaultAlarmStatus = reader.ReadUInt16(); | |||||
return value; | |||||
} | |||||
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,90 @@ | |||||
using JT808.Protocol.Formatters; | |||||
using JT808.Protocol.Interfaces; | |||||
using JT808.Protocol.MessageBody; | |||||
using JT808.Protocol.MessagePack; | |||||
using System; | |||||
using System.Text.Json; | |||||
namespace JT808.Protocol.Extensions.JT1078.MessageBody | |||||
{ | |||||
/// <summary> | |||||
/// 异常驾驶行为报警详细描述 | |||||
/// 0x0200_0x18 | |||||
/// </summary> | |||||
public class JT808_0x0200_0x18 : JT808_0x0200_BodyBase, IJT808MessagePackFormatter<JT808_0x0200_0x18>, IJT808Analyze | |||||
{ | |||||
public override byte AttachInfoId { get; set; } = 0x18; | |||||
/// <summary> | |||||
/// 数据 长度 | |||||
/// </summary> | |||||
public override byte AttachInfoLength { get; set; } = 3; | |||||
/// <summary> | |||||
/// 异常驾驶行为报警类型 | |||||
/// </summary> | |||||
public ushort AbnormalDrivingBehaviorAlarmType{ get; set; } | |||||
/// <summary> | |||||
/// 疲劳程度 | |||||
/// </summary> | |||||
public byte FatigueLevel { get; set; } | |||||
public void Analyze(ref JT808MessagePackReader reader, Utf8JsonWriter writer, IJT808Config config) | |||||
{ | |||||
JT808_0x0200_0x18 value = new JT808_0x0200_0x18(); | |||||
value.AttachInfoId = reader.ReadByte(); | |||||
writer.WriteNumber($"[{value.AttachInfoId.ReadNumber()}]附加信息Id", value.AttachInfoId); | |||||
value.AttachInfoLength = reader.ReadByte(); | |||||
writer.WriteNumber($"[{value.AttachInfoLength.ReadNumber()}]附加信息长度", value.AttachInfoLength); | |||||
value.AbnormalDrivingBehaviorAlarmType = reader.ReadUInt16(); | |||||
writer.WriteNumber($"[{value.AbnormalDrivingBehaviorAlarmType.ReadNumber()}]异常驾驶行为报警类型", value.AbnormalDrivingBehaviorAlarmType); | |||||
writer.WriteStartArray("视频信号遮挡报警状态集合"); | |||||
var abnormalDrivingBehaviorAlarmTypeSpan = Convert.ToString(value.AbnormalDrivingBehaviorAlarmType, 2).PadLeft(16, '0').AsSpan(); | |||||
int index = 0; | |||||
foreach (var item in abnormalDrivingBehaviorAlarmTypeSpan) | |||||
{ | |||||
string tmpResult = item == '1' ? "有" : "无"; | |||||
if (index == 0) | |||||
{ | |||||
writer.WriteStringValue($"[bit{index}疲劳]_{tmpResult}"); | |||||
} | |||||
else if (index == 1) | |||||
{ | |||||
writer.WriteStringValue($"[bit{index}打电话]_{tmpResult}"); | |||||
} | |||||
else if (index == 2) | |||||
{ | |||||
writer.WriteStringValue($"[bit{index}抽烟]_{tmpResult}"); | |||||
} | |||||
else if (index>=3 && index<=10) | |||||
{ | |||||
writer.WriteStringValue($"[bit{index}保留]_{tmpResult}"); | |||||
} | |||||
else | |||||
{ | |||||
writer.WriteStringValue($"[bit{index}自定义]_{tmpResult}"); | |||||
} | |||||
index++; | |||||
} | |||||
writer.WriteEndArray(); | |||||
value.FatigueLevel = reader.ReadByte(); | |||||
writer.WriteNumber($"[{value.FatigueLevel.ReadNumber()}]疲劳程度", value.FatigueLevel); | |||||
} | |||||
public JT808_0x0200_0x18 Deserialize(ref JT808MessagePackReader reader, IJT808Config config) | |||||
{ | |||||
JT808_0x0200_0x18 value = new JT808_0x0200_0x18(); | |||||
value.AttachInfoId = reader.ReadByte(); | |||||
value.AttachInfoLength = reader.ReadByte(); | |||||
value.AbnormalDrivingBehaviorAlarmType = reader.ReadUInt16(); | |||||
value.FatigueLevel = reader.ReadByte(); | |||||
return value; | |||||
} | |||||
public void Serialize(ref JT808MessagePackWriter writer, JT808_0x0200_0x18 value, IJT808Config config) | |||||
{ | |||||
writer.WriteByte(value.AttachInfoId); | |||||
writer.WriteByte(value.AttachInfoLength); | |||||
writer.WriteUInt16(value.AbnormalDrivingBehaviorAlarmType); | |||||
writer.WriteByte(value.FatigueLevel); | |||||
} | |||||
} | |||||
} |
@@ -0,0 +1,159 @@ | |||||
using JT808.Protocol.Formatters; | |||||
using JT808.Protocol.Interfaces; | |||||
using JT808.Protocol.MessagePack; | |||||
using System; | |||||
using System.Collections.Generic; | |||||
using System.Text; | |||||
using System.Text.Json; | |||||
namespace JT808.Protocol.Extensions.JT1078.MessageBody | |||||
{ | |||||
/// <summary> | |||||
/// 终端上传音视频属性 | |||||
/// </summary> | |||||
public class JT808_0x1003 : JT808Bodies, IJT808MessagePackFormatter<JT808_0x1003>, IJT808Analyze | |||||
{ | |||||
/// <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; } | |||||
public override ushort MsgId => 0x1003; | |||||
public override string Description => "终端上传音视频属性"; | |||||
public void Analyze(ref JT808MessagePackReader reader, Utf8JsonWriter writer, IJT808Config config) | |||||
{ | |||||
JT808_0x1003 value = new JT808_0x1003(); | |||||
value.EnterAudioEncoding = reader.ReadByte(); | |||||
writer.WriteString($"[{value.EnterAudioEncoding.ReadNumber()}]输入音频编码方式", AudioVideoEncodingDisplay(value.EnterAudioEncoding)); | |||||
value.EnterAudioChannelsNumber = reader.ReadByte(); | |||||
writer.WriteNumber($"[{value.EnterAudioChannelsNumber.ReadNumber()}]输入音频声道数", value.EnterAudioChannelsNumber); | |||||
value.EnterAudioSampleRate = reader.ReadByte(); | |||||
writer.WriteString($"[{value.EnterAudioSampleRate.ReadNumber()}]输入音频采样率", AudioSampleRateDisplay(value.EnterAudioSampleRate)); | |||||
value.EnterAudioSampleDigits = reader.ReadByte(); | |||||
writer.WriteString($"[{value.EnterAudioSampleDigits.ReadNumber()}]输入音频采样位数", AudioSampleDigitsDisplay(value.EnterAudioSampleDigits)); | |||||
value.AudioFrameLength = reader.ReadUInt16(); | |||||
writer.WriteNumber($"[{value.AudioFrameLength.ReadNumber()}]音频帧长度", value.AudioFrameLength); | |||||
value.IsSupportedAudioOutput = reader.ReadByte(); | |||||
writer.WriteString($"[{value.IsSupportedAudioOutput.ReadNumber()}]是否支持音频输出", value.IsSupportedAudioOutput==0?"不支持":"支持"); | |||||
value.VideoEncoding = reader.ReadByte(); | |||||
writer.WriteString($"[{value.VideoEncoding.ReadNumber()}]视频编码方式", AudioVideoEncodingDisplay(value.VideoEncoding)); | |||||
value.TerminalSupportedMaxNumberOfAudioPhysicalChannels = reader.ReadByte(); | |||||
writer.WriteNumber($"[{value.TerminalSupportedMaxNumberOfAudioPhysicalChannels.ReadNumber()}]终端支持的最大音频物理通道数量", value.TerminalSupportedMaxNumberOfAudioPhysicalChannels); | |||||
value.TerminalSupportedMaxNumberOfVideoPhysicalChannels = reader.ReadByte(); | |||||
writer.WriteNumber($"[{value.TerminalSupportedMaxNumberOfVideoPhysicalChannels.ReadNumber()}]终端支持的最大视频物理通道数量", value.TerminalSupportedMaxNumberOfVideoPhysicalChannels); | |||||
string AudioVideoEncodingDisplay(byte AudioVideoEncoding) { | |||||
switch (AudioVideoEncoding) | |||||
{ | |||||
case 19: | |||||
return "AAC"; | |||||
case 25: | |||||
return "MP3"; | |||||
case 91: | |||||
return "透传"; | |||||
case 98: | |||||
return "H.264"; | |||||
case 99: | |||||
return "H.265"; | |||||
default: | |||||
break; | |||||
} | |||||
return "未解析"; | |||||
} | |||||
string AudioSampleRateDisplay(byte AudioSampleRate) { | |||||
switch (AudioSampleRate) | |||||
{ | |||||
case 0: | |||||
return "8 kHz"; | |||||
case 1: | |||||
return "22.05 kHz"; | |||||
case 2: | |||||
return "44.1 kHz"; | |||||
case 3: | |||||
return "48 kHz"; | |||||
default: | |||||
break; | |||||
} | |||||
return "未知"; | |||||
} | |||||
string AudioSampleDigitsDisplay(byte AudioSampleDigits) { | |||||
switch (AudioSampleDigits) | |||||
{ | |||||
case 0: | |||||
return "8 位"; | |||||
case 1: | |||||
return "16 位"; | |||||
case 2: | |||||
return "32 位"; | |||||
default: | |||||
break; | |||||
} | |||||
return "未知"; | |||||
} | |||||
} | |||||
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,66 @@ | |||||
using JT808.Protocol.Formatters; | |||||
using JT808.Protocol.Interfaces; | |||||
using JT808.Protocol.MessagePack; | |||||
using System; | |||||
using System.Collections.Generic; | |||||
using System.Text; | |||||
using System.Text.Json; | |||||
namespace JT808.Protocol.Extensions.JT1078.MessageBody | |||||
{ | |||||
/// <summary> | |||||
/// 终端上传乘客流量 | |||||
/// </summary> | |||||
public class JT808_0x1005 : JT808Bodies, IJT808MessagePackFormatter<JT808_0x1005>, IJT808Analyze | |||||
{ | |||||
public override string Description => "终端上传乘客流量"; | |||||
public override ushort MsgId => 0x1005; | |||||
/// <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; } | |||||
public void Analyze(ref JT808MessagePackReader reader, Utf8JsonWriter writer, IJT808Config config) | |||||
{ | |||||
JT808_0x1005 value = new JT808_0x1005(); | |||||
value.BeginTime = reader.ReadDateTime6(); | |||||
writer.WriteString($"[{value.BeginTime.ToString("yyMMddHHmmss")}]开始时间", value.BeginTime.ToString("yyyy-MM-dd HH:mm:ss")); | |||||
value.EndTime = reader.ReadDateTime6(); | |||||
writer.WriteString($"[{value.EndTime.ToString("yyMMddHHmmss")}]结束时间", value.EndTime.ToString("yyyy-MM-dd HH:mm:ss")); | |||||
value.GettingOnNumber = reader.ReadUInt16(); | |||||
writer.WriteNumber($"[{value.GettingOnNumber.ReadNumber()}]从开始时间到结束时间的上车人数",value.GettingOnNumber); | |||||
value.GettingOffNumber = reader.ReadUInt16(); | |||||
writer.WriteNumber($"[{value.GettingOffNumber.ReadNumber()}]从开始时间到结束时间的下车人数", value.GettingOffNumber); | |||||
} | |||||
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,82 @@ | |||||
using JT808.Protocol.Formatters; | |||||
using JT808.Protocol.Interfaces; | |||||
using JT808.Protocol.MessagePack; | |||||
using System; | |||||
using System.Collections.Generic; | |||||
using System.Linq; | |||||
using System.Text; | |||||
using System.Text.Json; | |||||
namespace JT808.Protocol.Extensions.JT1078.MessageBody | |||||
{ | |||||
/// <summary> | |||||
/// 终端上传音视频资源列表 | |||||
/// </summary> | |||||
public class JT808_0x1205 : JT808Bodies, IJT808MessagePackFormatter<JT808_0x1205>, IJT808Analyze | |||||
{ | |||||
public override string Description => "终端上传音视频资源列表"; | |||||
public override ushort MsgId => 0x1205; | |||||
/// <summary> | |||||
/// 流水号 | |||||
/// </summary> | |||||
public ushort MsgNum { get; set; } | |||||
/// <summary> | |||||
/// 音视频资源总数 | |||||
/// </summary> | |||||
public uint AVResouceTotal{ get; set; } | |||||
/// <summary> | |||||
/// 音视频资源列表 | |||||
/// </summary> | |||||
public List<JT808_0x1205_AVResouce> AVResouces { get; set; } | |||||
public void Analyze(ref JT808MessagePackReader reader, Utf8JsonWriter writer, IJT808Config config) | |||||
{ | |||||
JT808_0x1205 value = new JT808_0x1205(); | |||||
value.MsgNum = reader.ReadUInt16(); | |||||
writer.WriteNumber($"[{value.MsgNum.ReadNumber()}]流水号", value.MsgNum); | |||||
value.AVResouceTotal = reader.ReadUInt32(); | |||||
writer.WriteNumber($"[{value.AVResouceTotal.ReadNumber()}]音视频资源总数", value.AVResouceTotal); | |||||
writer.WriteStartArray("音视频资源列表"); | |||||
var formatter = config.GetMessagePackFormatter<JT808_0x1205_AVResouce>(); | |||||
for (int i = 0; i < value.AVResouceTotal; i++) | |||||
{ | |||||
writer.WriteStartObject(); | |||||
formatter.Analyze(ref reader, writer, config); | |||||
writer.WriteEndObject(); | |||||
} | |||||
writer.WriteEndArray(); | |||||
} | |||||
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,171 @@ | |||||
using JT808.Protocol.Formatters; | |||||
using JT808.Protocol.Interfaces; | |||||
using JT808.Protocol.MessagePack; | |||||
using System; | |||||
using System.Collections.Generic; | |||||
using System.Text; | |||||
using System.Text.Json; | |||||
namespace JT808.Protocol.Extensions.JT1078.MessageBody | |||||
{ | |||||
/// <summary> | |||||
/// 终端上传音视频资源列表 | |||||
/// </summary> | |||||
public class JT808_0x1205_AVResouce:IJT808MessagePackFormatter<JT808_0x1205_AVResouce>, IJT808Analyze | |||||
{ | |||||
/// <summary> | |||||
/// 逻辑通道号 | |||||
/// </summary> | |||||
public byte LogicChannelNo { get; set; } | |||||
/// <summary> | |||||
/// 开始时间 | |||||
/// </summary> | |||||
public DateTime BeginTime { get; set; } | |||||
/// <summary> | |||||
/// 结束时间 | |||||
/// </summary> | |||||
public DateTime EndTime { get; set; } | |||||
/// <summary> | |||||
/// 报警标志 | |||||
/// </summary> | |||||
public ulong 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; } | |||||
public void Analyze(ref JT808MessagePackReader reader, Utf8JsonWriter writer, IJT808Config config) | |||||
{ | |||||
JT808_0x1205_AVResouce value = new JT808_0x1205_AVResouce(); | |||||
value.LogicChannelNo = reader.ReadByte(); | |||||
writer.WriteString($"[{value.LogicChannelNo.ReadNumber()}]逻辑通道号", LogicalChannelNoDisplay(value.LogicChannelNo)); | |||||
value.BeginTime = reader.ReadDateTime6(); | |||||
writer.WriteString($"[{value.BeginTime.ToString("yyMMddHHmmss")}]开始时间", value.BeginTime.ToString("yyyy-MM-dd HH:mm:ss")); | |||||
value.BeginTime = reader.ReadDateTime6(); | |||||
writer.WriteString($"[{value.BeginTime.ToString("yyMMddHHmmss")}]开始时间", value.BeginTime.ToString("yyyy-MM-dd HH:mm:ss")); | |||||
value.AlarmFlag = reader.ReadUInt32(); | |||||
writer.WriteNumber($"[{value.AlarmFlag.ReadNumber()}]报警标志", value.AlarmFlag);//此处的报警标志不是很明白 | |||||
value.AVResourceType = reader.ReadByte(); | |||||
writer.WriteString($"[{value.AVResourceType.ReadNumber()}]音视频资源类型", AVResourceTypeDisplay(value.AVResourceType)); | |||||
value.StreamType = reader.ReadByte(); | |||||
writer.WriteString($"[{value.StreamType.ReadNumber()}]码流类型", StreamTypeDisplay(value.StreamType)); | |||||
value.MemoryType = reader.ReadByte(); | |||||
writer.WriteString($"[{value.MemoryType.ReadNumber()}]存储器类型", MemoryTypeDisplay(value.MemoryType)); | |||||
value.FileSize = reader.ReadUInt32(); | |||||
writer.WriteNumber($"[{value.FileSize.ReadNumber()}]文件大小(B)", value.FileSize); | |||||
string LogicalChannelNoDisplay(byte LogicalChannelNo) | |||||
{ | |||||
switch (LogicalChannelNo) | |||||
{ | |||||
case 1: | |||||
return "驾驶员"; | |||||
case 2: | |||||
return "车辆正前方"; | |||||
case 3: | |||||
return "车前门"; | |||||
case 4: | |||||
return "车厢前部"; | |||||
case 5: | |||||
return "车厢后部"; | |||||
case 7: | |||||
return "行李舱"; | |||||
case 8: | |||||
return "车辆左侧"; | |||||
case 9: | |||||
return "车辆右侧"; | |||||
case 10: | |||||
return "车辆正后方"; | |||||
case 11: | |||||
return "车厢中部"; | |||||
case 12: | |||||
return "车中门"; | |||||
case 13: | |||||
return "驾驶席车门"; | |||||
case 33: | |||||
return "驾驶员"; | |||||
case 36: | |||||
return "车厢前部"; | |||||
case 37: | |||||
return "车厢后部"; | |||||
default: | |||||
return "预留"; | |||||
} | |||||
} | |||||
string AVResourceTypeDisplay(byte AVResourceType) { | |||||
switch (AVResourceType) | |||||
{ | |||||
case 0: | |||||
return "音视频"; | |||||
case 1: | |||||
return "音频"; | |||||
case 2: | |||||
return "视频"; | |||||
default: | |||||
break; | |||||
} | |||||
return "未知"; | |||||
} | |||||
string StreamTypeDisplay(byte StreamType) { | |||||
switch (StreamType) | |||||
{ | |||||
case 1: | |||||
return "主码流"; | |||||
case 2: | |||||
return "子码流"; | |||||
default: | |||||
return "未知"; | |||||
} | |||||
} | |||||
string MemoryTypeDisplay(byte MemoryType) | |||||
{ | |||||
switch (MemoryType) | |||||
{ | |||||
case 1: | |||||
return "主存储器"; | |||||
case 2: | |||||
return "灾备存储器"; | |||||
default: | |||||
return "未知"; | |||||
} | |||||
} | |||||
} | |||||
public 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.ReadUInt64(); | |||||
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.WriteUInt64(value.AlarmFlag); | |||||
writer.WriteByte(value.AVResourceType); | |||||
writer.WriteByte(value.StreamType); | |||||
writer.WriteByte(value.MemoryType); | |||||
writer.WriteUInt32(value.FileSize); | |||||
} | |||||
} | |||||
} |
@@ -0,0 +1,61 @@ | |||||
using JT808.Protocol.Formatters; | |||||
using JT808.Protocol.Interfaces; | |||||
using JT808.Protocol.MessagePack; | |||||
using System; | |||||
using System.Collections.Generic; | |||||
using System.Text; | |||||
using System.Text.Json; | |||||
namespace JT808.Protocol.Extensions.JT1078.MessageBody | |||||
{ | |||||
/// <summary> | |||||
/// 文件上传完成通知 | |||||
/// </summary> | |||||
public class JT808_0x1206 : JT808Bodies, IJT808MessagePackFormatter<JT808_0x1206>, IJT808Analyze | |||||
{ | |||||
public override string Description => "文件上传完成通知"; | |||||
public override ushort MsgId => 0x1206; | |||||
/// <summary> | |||||
/// 流水号 | |||||
/// </summary> | |||||
public ushort MsgNum { get; set; } | |||||
/// <summary> | |||||
/// 结果 | |||||
/// </summary> | |||||
public byte Result{ get; set; } | |||||
public void Analyze(ref JT808MessagePackReader reader, Utf8JsonWriter writer, IJT808Config config) | |||||
{ | |||||
JT808_0x1206 value = new JT808_0x1206(); | |||||
value.MsgNum = reader.ReadUInt16(); | |||||
writer.WriteNumber($"[{value.MsgNum.ReadNumber()}]流水号", value.MsgNum); | |||||
value.Result = reader.ReadByte(); | |||||
writer.WriteString($"[{value.Result.ReadNumber()}]结果", ResultDisplay(value.Result)); | |||||
string ResultDisplay(byte Result) { | |||||
switch (Result) | |||||
{ | |||||
case 0: | |||||
return "成功"; | |||||
case 1: | |||||
return "失败"; | |||||
default: | |||||
return "未知"; | |||||
} | |||||
} | |||||
} | |||||
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,232 @@ | |||||
using JT808.Protocol.Formatters; | |||||
using JT808.Protocol.Interfaces; | |||||
using JT808.Protocol.MessageBody; | |||||
using JT808.Protocol.MessagePack; | |||||
using System; | |||||
using System.Text.Json; | |||||
namespace JT808.Protocol.Extensions.JT1078.MessageBody | |||||
{ | |||||
/// <summary> | |||||
/// 音视频参数设置 | |||||
/// 0x8103_0x0075 | |||||
/// </summary> | |||||
public class JT808_0x8103_0x0075 : JT808_0x8103_BodyBase, IJT808MessagePackFormatter<JT808_0x8103_0x0075>, IJT808Analyze | |||||
{ | |||||
public override uint ParamId { get; set; } = 0x0075; | |||||
/// <summary> | |||||
/// 数据 长度 | |||||
/// </summary> | |||||
public override byte ParamLength { get; set; } = 21; | |||||
/// <summary> | |||||
/// 实时流编码模式 | |||||
/// </summary> | |||||
public byte RTS_EncodeMode { get; set; } | |||||
/// <summary> | |||||
/// 实时流分辨率 | |||||
/// </summary> | |||||
public byte RTS_Resolution { get; set; } | |||||
/// <summary> | |||||
/// 实时流关键帧间隔 | |||||
/// (范围1-1000)帧 | |||||
/// </summary> | |||||
public ushort RTS_KF_Interval { get; set; } | |||||
/// <summary> | |||||
/// 实时流目标帧率 | |||||
/// </summary> | |||||
public byte RTS_Target_FPS { get; set; } | |||||
/// <summary> | |||||
/// 实时流目标码率 | |||||
/// 单位未千位每秒(kbps) | |||||
/// </summary> | |||||
public uint RTS_Target_CodeRate { get; set; } | |||||
/// <summary> | |||||
/// 存储流编码模式 | |||||
/// </summary> | |||||
public byte StreamStore_EncodeMode { get; set; } | |||||
/// <summary> | |||||
/// 存储流分辨率 | |||||
/// </summary> | |||||
public byte StreamStore_Resolution { get; set; } | |||||
/// <summary> | |||||
/// 存储流关键帧间隔 | |||||
/// (范围1-1000)帧 | |||||
/// </summary> | |||||
public ushort StreamStore_KF_Interval { get; set; } | |||||
/// <summary> | |||||
/// 存储流目标帧率 | |||||
/// </summary> | |||||
public byte StreamStore_Target_FPS { get; set; } | |||||
/// <summary> | |||||
/// 存储流目标码率 | |||||
/// 单位未千位每秒(kbps) | |||||
/// </summary> | |||||
public uint StreamStore_Target_CodeRate { get; set; } | |||||
/// <summary> | |||||
///OSD字幕叠加设置 | |||||
/// </summary> | |||||
public ushort OSD { get; set; } | |||||
/// <summary> | |||||
///是否启用音频输出 | |||||
///0:不启用 | |||||
///1:启用 | |||||
/// </summary> | |||||
public byte AudioOutputEnabled { get; set; } | |||||
public void Analyze(ref JT808MessagePackReader reader, Utf8JsonWriter writer, IJT808Config config) | |||||
{ | |||||
JT808_0x8103_0x0075 value = new JT808_0x8103_0x0075(); | |||||
value.ParamId = reader.ReadUInt32(); | |||||
writer.WriteNumber($"[{value.ParamId.ReadNumber()}]参数 ID", value.ParamId); | |||||
value.ParamLength = reader.ReadByte(); | |||||
writer.WriteNumber($"[{value.ParamLength.ReadNumber()}]数据长度", value.ParamLength); | |||||
value.RTS_EncodeMode = reader.ReadByte(); | |||||
writer.WriteString($"[{value.RTS_EncodeMode.ReadNumber()}]实时流编码模式", RTS_EncodeModeDisplay(value.RTS_EncodeMode)); | |||||
value.RTS_Resolution = reader.ReadByte(); | |||||
writer.WriteString($"[{value.RTS_Resolution.ReadNumber()}]实时流分辨率", RTS_ResolutionDisplay(value.RTS_Resolution)); | |||||
value.RTS_KF_Interval = reader.ReadUInt16(); | |||||
writer.WriteNumber($"[{value.RTS_KF_Interval.ReadNumber()}]实时流关键帧间隔(帧)", value.RTS_KF_Interval); | |||||
value.RTS_Target_FPS = reader.ReadByte(); | |||||
writer.WriteNumber($"[{value.RTS_Target_FPS.ReadNumber()}]实时流目标帧率(帧/s)", value.RTS_Target_FPS); | |||||
value.RTS_Target_CodeRate = reader.ReadUInt32(); | |||||
writer.WriteNumber($"[{value.RTS_Target_CodeRate.ReadNumber()}]实时流目标码流(kbps)", value.RTS_Target_CodeRate); | |||||
value.StreamStore_EncodeMode = reader.ReadByte(); | |||||
writer.WriteString($"[{value.StreamStore_EncodeMode.ReadNumber()}]存储量编码模式", StreamStore_EncodeModeDisplay(value.StreamStore_EncodeMode)); | |||||
value.StreamStore_Resolution = reader.ReadByte(); | |||||
writer.WriteString($"[{value.StreamStore_Resolution.ReadNumber()}]存储流分辨率", StreamStore_ResolutionDisplay(value.StreamStore_Resolution)); | |||||
value.StreamStore_KF_Interval = reader.ReadUInt16(); | |||||
writer.WriteNumber($"[{value.StreamStore_KF_Interval.ReadNumber()}]存储流关键帧间隔(帧)", value.StreamStore_KF_Interval); | |||||
value.StreamStore_Target_FPS = reader.ReadByte(); | |||||
writer.WriteNumber($"[{value.StreamStore_Target_FPS.ReadNumber()}]存储流目标帧率(帧/s)", value.StreamStore_Target_FPS); | |||||
value.StreamStore_Target_CodeRate = reader.ReadUInt32(); | |||||
writer.WriteNumber($"[{value.StreamStore_Target_CodeRate.ReadNumber()}]存储流目标码流(kbps)", value.StreamStore_Target_CodeRate); | |||||
value.OSD = reader.ReadUInt16(); | |||||
writer.WriteString($"[{value.OSD.ReadNumber()}]OBD字幕叠加设置", OBDDisplay(value.OSD)); | |||||
value.AudioOutputEnabled = reader.ReadByte(); | |||||
writer.WriteString($"[{value.AudioOutputEnabled.ReadNumber()}]是否启用音频输出", value.AudioOutputEnabled == 0 ? "不启用" : "启用"); | |||||
string RTS_EncodeModeDisplay(byte RTS_EncodeMode) { | |||||
switch (RTS_EncodeMode) | |||||
{ | |||||
case 0: | |||||
return "CBR固定码流"; | |||||
case 1: | |||||
return "VBR可变码流"; | |||||
case 2: | |||||
return "ABR平均码流"; | |||||
default: | |||||
break; | |||||
} | |||||
return "未知"; | |||||
} | |||||
string RTS_ResolutionDisplay(byte RTS_Resolution) { | |||||
switch (RTS_Resolution) | |||||
{ | |||||
case 0: | |||||
return "QCIF"; | |||||
case 1: | |||||
return "CIF"; | |||||
case 2: | |||||
return "WCIF"; | |||||
case 3: | |||||
return "D1"; | |||||
case 4: | |||||
return "WD1"; | |||||
case 5: | |||||
return "720P"; | |||||
case 6: | |||||
return "1080P"; | |||||
default: | |||||
break; | |||||
} | |||||
return "未知"; | |||||
} | |||||
string StreamStore_EncodeModeDisplay(byte StreamStore_EncodeMode) { | |||||
{ | |||||
switch (RTS_EncodeMode) | |||||
{ | |||||
case 0: | |||||
return "CBR固定码流"; | |||||
case 1: | |||||
return "VBR可变码流"; | |||||
case 2: | |||||
return "ABR平均码流"; | |||||
default: | |||||
break; | |||||
} | |||||
return "未知"; | |||||
} | |||||
} | |||||
string StreamStore_ResolutionDisplay(byte StreamStore_Resolution) { | |||||
switch (RTS_Resolution) | |||||
{ | |||||
case 0: | |||||
return "QCIF"; | |||||
case 1: | |||||
return "CIF"; | |||||
case 2: | |||||
return "WCIF"; | |||||
case 3: | |||||
return "D1"; | |||||
case 4: | |||||
return "WD1"; | |||||
case 5: | |||||
return "720P"; | |||||
case 6: | |||||
return "1080P"; | |||||
default: | |||||
break; | |||||
} | |||||
return "未知"; | |||||
} | |||||
string OBDDisplay(ushort OBD) { | |||||
string obdDisplay = string.Empty; | |||||
obdDisplay += ((OBD & 0x0001) == 1) ? ",日期和时间" : ""; | |||||
obdDisplay += ((OBD >> 1 & 0x0001) == 1) ? ",车牌号码" : ""; | |||||
obdDisplay += ((OBD >> 2 & 0x0001) == 1) ? ",逻辑通道号" : ""; | |||||
obdDisplay += ((OBD >> 3 & 0x0001) == 1) ? ",经纬度" : ""; | |||||
obdDisplay += ((OBD >> 4 & 0x0001) == 1) ? ",行驶记录速度" : ""; | |||||
obdDisplay += ((OBD >> 5 & 0x0001) == 1) ? ",卫星定位速度" : ""; | |||||
obdDisplay += ((OBD >> 6 & 0x0001) == 1) ? ",连续驾驶时间" : ""; | |||||
return obdDisplay.Length>0? obdDisplay.Substring(1):""; | |||||
} | |||||
} | |||||
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,108 @@ | |||||
using JT808.Protocol.Formatters; | |||||
using JT808.Protocol.Interfaces; | |||||
using JT808.Protocol.MessageBody; | |||||
using JT808.Protocol.MessagePack; | |||||
using System.Collections.Generic; | |||||
using System.Linq; | |||||
using System.Text.Json; | |||||
namespace JT808.Protocol.Extensions.JT1078.MessageBody | |||||
{ | |||||
/// <summary> | |||||
/// 音视频通道列表设置 | |||||
/// 0x8103_0x0076 | |||||
/// </summary> | |||||
public class JT808_0x8103_0x0076 : JT808_0x8103_BodyBase, IJT808MessagePackFormatter<JT808_0x8103_0x0076>, IJT808Analyze | |||||
{ | |||||
public override uint ParamId { get; set; } = 0x0076; | |||||
/// <summary> | |||||
/// 数据 长度 | |||||
/// </summary> | |||||
public override byte ParamLength { get; set; } | |||||
/// <summary> | |||||
/// 音视频通道总数 | |||||
/// l | |||||
/// </summary> | |||||
public byte AVChannelTotal { get; set; } | |||||
/// <summary> | |||||
/// 音频通道总数 | |||||
/// m | |||||
/// </summary> | |||||
public byte AudioChannelTotal { get; set; } | |||||
/// <summary> | |||||
/// 视频通道总数 | |||||
/// n | |||||
/// </summary> | |||||
public byte VudioChannelTotal { get; set; } | |||||
/// <summary> | |||||
/// 音视频通道对照表 | |||||
/// 4*(l+m+n) | |||||
/// </summary> | |||||
public List<JT808_0x8103_0x0076_AVChannelRefTable> AVChannelRefTables { get; set; } | |||||
public void Analyze(ref JT808MessagePackReader reader, Utf8JsonWriter writer, IJT808Config config) | |||||
{ | |||||
JT808_0x8103_0x0076 value = new JT808_0x8103_0x0076(); | |||||
value.ParamId = reader.ReadUInt32(); | |||||
writer.WriteNumber($"[{value.ParamId.ReadNumber()}]参数 ID", value.ParamId); | |||||
value.ParamLength = reader.ReadByte(); | |||||
writer.WriteNumber($"[{value.ParamLength.ReadNumber()}]数据长度", value.ParamLength); | |||||
value.AVChannelTotal = reader.ReadByte(); | |||||
writer.WriteNumber($"[{value.AVChannelTotal.ReadNumber()}]音视频通道总数", value.AVChannelTotal); | |||||
value.AudioChannelTotal = reader.ReadByte(); | |||||
writer.WriteNumber($"[{value.AudioChannelTotal.ReadNumber()}]音频通道总数", value.AudioChannelTotal); | |||||
value.VudioChannelTotal = reader.ReadByte(); | |||||
writer.WriteNumber($"[{value.VudioChannelTotal.ReadNumber()}]视频通道总数", value.VudioChannelTotal); | |||||
var channelTotal = value.AVChannelTotal + value.AudioChannelTotal + value.VudioChannelTotal;//通道总数 | |||||
writer.WriteStartArray("音视频通道对照表"); | |||||
for (int i = 0; i < channelTotal; i++) | |||||
{ | |||||
writer.WriteStartObject(); | |||||
var formatter = config.GetMessagePackFormatter<JT808_0x8103_0x0076_AVChannelRefTable>(); | |||||
formatter.Analyze(ref reader, writer, config); | |||||
writer.WriteEndObject(); | |||||
} | |||||
writer.WriteEndArray(); | |||||
} | |||||
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,124 @@ | |||||
using JT808.Protocol.Formatters; | |||||
using JT808.Protocol.Interfaces; | |||||
using JT808.Protocol.MessagePack; | |||||
using System.Text.Json; | |||||
namespace JT808.Protocol.Extensions.JT1078.MessageBody | |||||
{ | |||||
/// <summary> | |||||
/// 音视频通道列表设置 | |||||
/// 0x8103_0x0076_AVChannelRefTable | |||||
/// </summary> | |||||
public class JT808_0x8103_0x0076_AVChannelRefTable: IJT808MessagePackFormatter<JT808_0x8103_0x0076_AVChannelRefTable>, IJT808Analyze | |||||
{ | |||||
/// <summary> | |||||
/// 物理通道号 | |||||
/// </summary> | |||||
public byte PhysicalChannelNo { get; set; } | |||||
/// <summary> | |||||
/// 逻辑通道号 | |||||
/// </summary> | |||||
public byte LogicChannelNo { get; set; } | |||||
/// <summary> | |||||
/// 通道类型 | |||||
/// </summary> | |||||
public byte ChannelType { get; set; } | |||||
/// <summary> | |||||
/// 是否链接云台 | |||||
/// </summary> | |||||
public byte IsConnectCloudPlat { get; set; } | |||||
public void Analyze(ref JT808MessagePackReader reader, Utf8JsonWriter writer, IJT808Config config) | |||||
{ | |||||
JT808_0x8103_0x0076_AVChannelRefTable value = new JT808_0x8103_0x0076_AVChannelRefTable(); | |||||
value.PhysicalChannelNo = reader.ReadByte(); | |||||
writer.WriteNumber($"[{value.PhysicalChannelNo.ReadNumber()}]物理通道号", value.PhysicalChannelNo); | |||||
value.LogicChannelNo = reader.ReadByte(); | |||||
writer.WriteString($"[{value.LogicChannelNo.ReadNumber()}]逻辑通道号", LogicalChannelNoDisplay(value.LogicChannelNo)); | |||||
value.ChannelType = reader.ReadByte(); | |||||
writer.WriteString($"[{value.ChannelType.ReadNumber()}]通道类型", ChannelTypeDisplay(value.ChannelType)); | |||||
value.IsConnectCloudPlat = reader.ReadByte(); | |||||
writer.WriteString($"[{value.IsConnectCloudPlat.ReadNumber()}]是否链接云台", IsConnectCloudPlatDisplay(value.IsConnectCloudPlat)); | |||||
string LogicalChannelNoDisplay(byte LogicalChannelNo) | |||||
{ | |||||
switch (LogicalChannelNo) | |||||
{ | |||||
case 1: | |||||
return "驾驶员"; | |||||
case 2: | |||||
return "车辆正前方"; | |||||
case 3: | |||||
return "车前门"; | |||||
case 4: | |||||
return "车厢前部"; | |||||
case 5: | |||||
return "车厢后部"; | |||||
case 7: | |||||
return "行李舱"; | |||||
case 8: | |||||
return "车辆左侧"; | |||||
case 9: | |||||
return "车辆右侧"; | |||||
case 10: | |||||
return "车辆正后方"; | |||||
case 11: | |||||
return "车厢中部"; | |||||
case 12: | |||||
return "车中门"; | |||||
case 13: | |||||
return "驾驶席车门"; | |||||
case 33: | |||||
return "驾驶员"; | |||||
case 36: | |||||
return "车厢前部"; | |||||
case 37: | |||||
return "车厢后部"; | |||||
default: | |||||
return "预留"; | |||||
} | |||||
} | |||||
string ChannelTypeDisplay(byte ChannelType) { | |||||
switch (ChannelType) | |||||
{ | |||||
case 0: | |||||
return "音视频"; | |||||
case 1: | |||||
return "音频"; | |||||
case 2: | |||||
return "视频"; | |||||
default: | |||||
return "未知"; | |||||
} | |||||
} | |||||
string IsConnectCloudPlatDisplay(byte IsConnectCloudPlat) { | |||||
switch (IsConnectCloudPlat) | |||||
{ | |||||
case 0: | |||||
return "未连接"; | |||||
case 1: | |||||
return "连接"; | |||||
default: | |||||
return "未知"; | |||||
} | |||||
} | |||||
} | |||||
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,83 @@ | |||||
using JT808.Protocol.Formatters; | |||||
using JT808.Protocol.Interfaces; | |||||
using JT808.Protocol.MessageBody; | |||||
using JT808.Protocol.MessagePack; | |||||
using System.Collections.Generic; | |||||
using System.Linq; | |||||
using System.Text.Json; | |||||
namespace JT808.Protocol.Extensions.JT1078.MessageBody | |||||
{ | |||||
/// <summary> | |||||
///单独视频通道参数设置 | |||||
/// 0x8103_0x0077 | |||||
/// </summary> | |||||
public class JT808_0x8103_0x0077 : JT808_0x8103_BodyBase, IJT808MessagePackFormatter<JT808_0x8103_0x0077>, IJT808Analyze | |||||
{ | |||||
public override uint ParamId { get; set; } = 0x0077; | |||||
/// <summary> | |||||
/// 数据 长度 | |||||
/// </summary> | |||||
public override byte ParamLength { get; set; } | |||||
/// <summary> | |||||
/// 需单独设置视频参数的通道数量 用n表示 | |||||
/// </summary> | |||||
public byte NeedSetChannelTotal { get; set; } | |||||
public List<JT808_0x8103_0x0077_SignalChannel> SignalChannels { get; set; } | |||||
public void Analyze(ref JT808MessagePackReader reader, Utf8JsonWriter writer, IJT808Config config) | |||||
{ | |||||
JT808_0x8103_0x0077 value = new JT808_0x8103_0x0077(); | |||||
value.ParamId = reader.ReadUInt32(); | |||||
writer.WriteNumber($"[{value.ParamId.ReadNumber()}]参数 ID", value.ParamId); | |||||
value.ParamLength = reader.ReadByte(); | |||||
writer.WriteNumber($"[{value.ParamLength.ReadNumber()}]数据长度", value.ParamLength); | |||||
value.NeedSetChannelTotal = reader.ReadByte(); | |||||
writer.WriteNumber($"[{value.NeedSetChannelTotal.ReadNumber()}]需单独设置视频参数的通道数量", value.NeedSetChannelTotal); | |||||
writer.WriteStartArray("音视频通道对照表"); | |||||
for (int i = 0; i < value.NeedSetChannelTotal; i++) | |||||
{ | |||||
writer.WriteStartObject(); | |||||
var formatter = config.GetMessagePackFormatter<JT808_0x8103_0x0077_SignalChannel>(); | |||||
formatter.Analyze(ref reader, writer, config); | |||||
writer.WriteEndObject(); | |||||
} | |||||
writer.WriteEndArray(); | |||||
} | |||||
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.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.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.SignalChannels.Any()) | |||||
{ | |||||
var formatter = config.GetMessagePackFormatter<JT808_0x8103_0x0077_SignalChannel>(); | |||||
foreach (var signalChannel in value.SignalChannels) | |||||
{ | |||||
formatter.Serialize(ref writer, signalChannel, config); | |||||
} | |||||
} | |||||
writer.WriteByteReturn((byte)(writer.GetCurrentPosition() - position - 1), position); | |||||
} | |||||
} | |||||
} |
@@ -0,0 +1,257 @@ | |||||
using JT808.Protocol.Formatters; | |||||
using JT808.Protocol.Interfaces; | |||||
using JT808.Protocol.MessagePack; | |||||
using System; | |||||
using System.Collections.Generic; | |||||
using System.Text; | |||||
using System.Text.Json; | |||||
namespace JT808.Protocol.Extensions.JT1078.MessageBody | |||||
{ | |||||
public class JT808_0x8103_0x0077_SignalChannel: IJT808MessagePackFormatter<JT808_0x8103_0x0077_SignalChannel>, IJT808Analyze | |||||
{ | |||||
/// <summary> | |||||
/// 逻辑通道号 | |||||
/// </summary> | |||||
public byte LogicChannelNo { get; set; } | |||||
/// <summary> | |||||
/// 实时流编码模式 | |||||
/// </summary> | |||||
public byte RTS_EncodeMode { get; set; } | |||||
/// <summary> | |||||
/// 实时流分辨率 | |||||
/// </summary> | |||||
public byte RTS_Resolution { get; set; } | |||||
/// <summary> | |||||
/// 实时流关键帧间隔 | |||||
/// (范围1-1000)帧 | |||||
/// </summary> | |||||
public ushort RTS_KF_Interval { get; set; } | |||||
/// <summary> | |||||
/// 实时流目标帧率 | |||||
/// </summary> | |||||
public byte RTS_Target_FPS { get; set; } | |||||
/// <summary> | |||||
/// 实时流目标码率 | |||||
/// 单位未千位每秒(kbps) | |||||
/// </summary> | |||||
public uint RTS_Target_CodeRate { get; set; } | |||||
/// <summary> | |||||
/// 存储流编码模式 | |||||
/// </summary> | |||||
public byte StreamStore_EncodeMode { get; set; } | |||||
/// <summary> | |||||
/// 存储流分辨率 | |||||
/// </summary> | |||||
public byte StreamStore_Resolution { get; set; } | |||||
/// <summary> | |||||
/// 存储流关键帧间隔 | |||||
/// (范围1-1000)帧 | |||||
/// </summary> | |||||
public ushort StreamStore_KF_Interval { get; set; } | |||||
/// <summary> | |||||
/// 存储流目标帧率 | |||||
/// </summary> | |||||
public byte StreamStore_Target_FPS { get; set; } | |||||
/// <summary> | |||||
/// 存储流目标码率 | |||||
/// 单位未千位每秒(kbps) | |||||
/// </summary> | |||||
public uint StreamStore_Target_CodeRate { get; set; } | |||||
/// <summary> | |||||
///OSD字幕叠加设置 | |||||
/// </summary> | |||||
public ushort OSD { get; set; } | |||||
public void Analyze(ref JT808MessagePackReader reader, Utf8JsonWriter writer, IJT808Config config) | |||||
{ | |||||
JT808_0x8103_0x0077_SignalChannel value = new JT808_0x8103_0x0077_SignalChannel(); | |||||
value.LogicChannelNo = reader.ReadByte(); | |||||
writer.WriteString($"[{value.LogicChannelNo.ReadNumber()}]逻辑通道号", LogicalChannelNoDisplay(value.LogicChannelNo)); | |||||
value.RTS_EncodeMode = reader.ReadByte(); | |||||
writer.WriteString($"[{value.RTS_EncodeMode.ReadNumber()}]实时流编码模式", RTS_EncodeModeDisplay(value.RTS_EncodeMode)); | |||||
value.RTS_Resolution = reader.ReadByte(); | |||||
writer.WriteString($"[{value.RTS_Resolution.ReadNumber()}]实时流分辨率", RTS_ResolutionDisplay(value.RTS_Resolution)); | |||||
value.RTS_KF_Interval = reader.ReadUInt16(); | |||||
writer.WriteNumber($"[{value.RTS_KF_Interval.ReadNumber()}]实时流关键帧间隔(帧)", value.RTS_KF_Interval); | |||||
value.RTS_Target_FPS = reader.ReadByte(); | |||||
writer.WriteNumber($"[{value.RTS_Target_FPS.ReadNumber()}]实时流目标帧率(帧/s)", value.RTS_Target_FPS); | |||||
value.RTS_Target_CodeRate = reader.ReadUInt32(); | |||||
writer.WriteNumber($"[{value.RTS_Target_CodeRate.ReadNumber()}]实时流目标码率(kbps)", value.RTS_Target_CodeRate); | |||||
value.StreamStore_EncodeMode = reader.ReadByte(); | |||||
writer.WriteString($"[{value.StreamStore_EncodeMode.ReadNumber()}]存储流编码模式", StreamStore_EncodeModeDisplay(value.StreamStore_EncodeMode)); | |||||
value.StreamStore_Resolution = reader.ReadByte(); | |||||
writer.WriteString($"[{value.StreamStore_Resolution.ReadNumber()}]存储流分辨率", StreamStore_ResolutionDisplay(value.StreamStore_Resolution)); | |||||
value.StreamStore_KF_Interval = reader.ReadUInt16(); | |||||
writer.WriteNumber($"[{value.StreamStore_KF_Interval.ReadNumber()}]存储流关键帧间隔(帧)", value.StreamStore_KF_Interval); | |||||
value.StreamStore_Target_FPS = reader.ReadByte(); | |||||
writer.WriteNumber($"[{value.StreamStore_Target_FPS.ReadNumber()}]存储流目标帧率(帧/s)", value.StreamStore_Target_FPS); | |||||
value.StreamStore_Target_CodeRate = reader.ReadUInt32(); | |||||
writer.WriteNumber($"[{value.StreamStore_Target_CodeRate.ReadNumber()}]存储流目标码率(kbps)", value.StreamStore_Target_CodeRate); | |||||
value.OSD = reader.ReadUInt16(); | |||||
writer.WriteString($"[{value.OSD.ReadNumber()}]OSD字幕叠加设置", OBDDisplay(value.OSD)); | |||||
string LogicalChannelNoDisplay(byte LogicalChannelNo) | |||||
{ | |||||
switch (LogicalChannelNo) | |||||
{ | |||||
case 1: | |||||
return "驾驶员"; | |||||
case 2: | |||||
return "车辆正前方"; | |||||
case 3: | |||||
return "车前门"; | |||||
case 4: | |||||
return "车厢前部"; | |||||
case 5: | |||||
return "车厢后部"; | |||||
case 7: | |||||
return "行李舱"; | |||||
case 8: | |||||
return "车辆左侧"; | |||||
case 9: | |||||
return "车辆右侧"; | |||||
case 10: | |||||
return "车辆正后方"; | |||||
case 11: | |||||
return "车厢中部"; | |||||
case 12: | |||||
return "车中门"; | |||||
case 13: | |||||
return "驾驶席车门"; | |||||
case 33: | |||||
return "驾驶员"; | |||||
case 36: | |||||
return "车厢前部"; | |||||
case 37: | |||||
return "车厢后部"; | |||||
default: | |||||
return "预留"; | |||||
} | |||||
} | |||||
string RTS_EncodeModeDisplay(byte RTS_EncodeMode) | |||||
{ | |||||
switch (RTS_EncodeMode) | |||||
{ | |||||
case 0: | |||||
return "CBR固定码流"; | |||||
case 1: | |||||
return "VBR可变码流"; | |||||
case 2: | |||||
return "ABR平均码流"; | |||||
default: | |||||
break; | |||||
} | |||||
return "未知"; | |||||
} | |||||
string RTS_ResolutionDisplay(byte RTS_Resolution) | |||||
{ | |||||
switch (RTS_Resolution) | |||||
{ | |||||
case 0: | |||||
return "QCIF"; | |||||
case 1: | |||||
return "CIF"; | |||||
case 2: | |||||
return "WCIF"; | |||||
case 3: | |||||
return "D1"; | |||||
case 4: | |||||
return "WD1"; | |||||
case 5: | |||||
return "720P"; | |||||
case 6: | |||||
return "1080P"; | |||||
default: | |||||
break; | |||||
} | |||||
return "未知"; | |||||
} | |||||
string StreamStore_EncodeModeDisplay(byte StreamStore_EncodeMode) | |||||
{ | |||||
{ | |||||
switch (StreamStore_EncodeMode) | |||||
{ | |||||
case 0: | |||||
return "CBR固定码流"; | |||||
case 1: | |||||
return "VBR可变码流"; | |||||
case 2: | |||||
return "ABR平均码流"; | |||||
default: | |||||
break; | |||||
} | |||||
return "未知"; | |||||
} | |||||
} | |||||
string StreamStore_ResolutionDisplay(byte StreamStore_Resolution) | |||||
{ | |||||
switch (StreamStore_Resolution) | |||||
{ | |||||
case 0: | |||||
return "QCIF"; | |||||
case 1: | |||||
return "CIF"; | |||||
case 2: | |||||
return "WCIF"; | |||||
case 3: | |||||
return "D1"; | |||||
case 4: | |||||
return "WD1"; | |||||
case 5: | |||||
return "720P"; | |||||
case 6: | |||||
return "1080P"; | |||||
default: | |||||
break; | |||||
} | |||||
return "未知"; | |||||
} | |||||
string OBDDisplay(ushort OBD) | |||||
{ | |||||
string obdDisplay = string.Empty; | |||||
obdDisplay += ((OBD & 0x0001) == 1) ? ",日期和时间" : ""; | |||||
obdDisplay += ((OBD >> 1 & 0x0001) == 1) ? ",车牌号码" : ""; | |||||
obdDisplay += ((OBD >> 2 & 0x0001) == 1) ? ",逻辑通道号" : ""; | |||||
obdDisplay += ((OBD >> 3 & 0x0001) == 1) ? ",经纬度" : ""; | |||||
obdDisplay += ((OBD >> 4 & 0x0001) == 1) ? ",行驶记录速度" : ""; | |||||
obdDisplay += ((OBD >> 5 & 0x0001) == 1) ? ",卫星定位速度" : ""; | |||||
obdDisplay += ((OBD >> 6 & 0x0001) == 1) ? ",连续驾驶时间" : ""; | |||||
return obdDisplay.Length > 0 ? obdDisplay.Substring(1) : ""; | |||||
} | |||||
} | |||||
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,70 @@ | |||||
using JT808.Protocol.Formatters; | |||||
using JT808.Protocol.Interfaces; | |||||
using JT808.Protocol.MessageBody; | |||||
using JT808.Protocol.MessagePack; | |||||
using System.Collections.Generic; | |||||
using System.Text.Json; | |||||
namespace JT808.Protocol.Extensions.JT1078.MessageBody | |||||
{ | |||||
/// <summary> | |||||
/// 特殊报警录像参数设置 | |||||
/// 0x8103_0x0079 | |||||
/// </summary> | |||||
public class JT808_0x8103_0x0079 : JT808_0x8103_BodyBase, IJT808MessagePackFormatter<JT808_0x8103_0x0079>, IJT808Analyze | |||||
{ | |||||
public override uint ParamId { get; set; } = 0x0079; | |||||
/// <summary> | |||||
/// 数据 长度 | |||||
/// </summary> | |||||
public override byte ParamLength { get; set; } = 3; | |||||
/// <summary> | |||||
/// 特殊报警录像存储阈值 | |||||
/// </summary> | |||||
public byte StorageThresholds { get; set; } | |||||
/// <summary> | |||||
/// 特殊报警录像持续时间 | |||||
/// </summary> | |||||
public byte Duration { get; set; } | |||||
/// <summary> | |||||
/// 特殊报警标识起始时间 | |||||
/// 分钟min | |||||
/// </summary> | |||||
public byte BeginMinute { get; set; } | |||||
public void Analyze(ref JT808MessagePackReader reader, Utf8JsonWriter writer, IJT808Config config) | |||||
{ | |||||
JT808_0x8103_0x0079 value = new JT808_0x8103_0x0079(); | |||||
value.ParamId = reader.ReadUInt32(); | |||||
writer.WriteNumber($"[{value.ParamId.ReadNumber()}]参数 ID", value.ParamId); | |||||
value.ParamLength = reader.ReadByte(); | |||||
writer.WriteNumber($"[{value.ParamLength.ReadNumber()}]数据长度", value.ParamLength); | |||||
value.StorageThresholds = reader.ReadByte(); | |||||
writer.WriteNumber($"[{value.StorageThresholds.ReadNumber()}]特殊报警录像存储阈值(百分比)", value.StorageThresholds); | |||||
value.Duration = reader.ReadByte(); | |||||
writer.WriteNumber($"[{value.Duration.ReadNumber()}]特殊报警录像持续时间(分钟)", value.Duration); | |||||
value.BeginMinute = reader.ReadByte(); | |||||
writer.WriteNumber($"[{value.BeginMinute.ReadNumber()}]特殊报警标识起始时间(分钟)", value.BeginMinute); | |||||
} | |||||
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,72 @@ | |||||
using JT808.Protocol.Formatters; | |||||
using JT808.Protocol.Interfaces; | |||||
using JT808.Protocol.MessageBody; | |||||
using JT808.Protocol.MessagePack; | |||||
using System.Collections.Generic; | |||||
using System.Text.Json; | |||||
namespace JT808.Protocol.Extensions.JT1078.MessageBody | |||||
{ | |||||
/// <summary> | |||||
/// 视频相关报警屏蔽字 | |||||
/// 0x8103_0x007A | |||||
/// </summary> | |||||
public class JT808_0x8103_0x007A : JT808_0x8103_BodyBase, IJT808MessagePackFormatter<JT808_0x8103_0x007A>, IJT808Analyze | |||||
{ | |||||
public override uint ParamId { get; set; } = 0x007A; | |||||
/// <summary> | |||||
/// 数据 长度 | |||||
/// </summary> | |||||
public override byte ParamLength { get; set; } = 4; | |||||
/// <summary> | |||||
/// 视频相关屏蔽报警字 | |||||
/// </summary> | |||||
public uint AlarmShielding { get; set; } | |||||
public void Analyze(ref JT808MessagePackReader reader, Utf8JsonWriter writer, IJT808Config config) | |||||
{ | |||||
JT808_0x8103_0x007A value = new JT808_0x8103_0x007A(); | |||||
value.ParamId = reader.ReadUInt32(); | |||||
writer.WriteNumber($"[{value.ParamId.ReadNumber()}]参数 ID", value.ParamId); | |||||
value.ParamLength = reader.ReadByte(); | |||||
writer.WriteNumber($"[{value.ParamLength.ReadNumber()}]数据长度", value.ParamLength); | |||||
value.AlarmShielding = reader.ReadUInt32(); | |||||
writer.WriteString($"[{value.AlarmShielding.ReadNumber()}]视频相关屏蔽报警字", AlarmShieldingDisplay(value.AlarmShielding)); | |||||
string AlarmShieldingDisplay(uint AlarmShielding) | |||||
{ | |||||
switch (AlarmShielding) | |||||
{ | |||||
case 0x14: | |||||
return "视频相关报警"; | |||||
case 0x15: | |||||
return "视频信号丢失报警状态"; | |||||
case 0x16: | |||||
return "视频信号遮挡报警状态"; | |||||
case 0x17: | |||||
return "存储器故障报警状态"; | |||||
case 0x18: | |||||
return "异常驾驶行为详细描述"; | |||||
default: | |||||
break; | |||||
} | |||||
return "未知"; | |||||
} | |||||
} | |||||
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,61 @@ | |||||
using JT808.Protocol.Formatters; | |||||
using JT808.Protocol.Interfaces; | |||||
using JT808.Protocol.MessageBody; | |||||
using JT808.Protocol.MessagePack; | |||||
using System.Collections.Generic; | |||||
using System.Text.Json; | |||||
namespace JT808.Protocol.Extensions.JT1078.MessageBody | |||||
{ | |||||
/// <summary> | |||||
/// 图像分析报警参数设置 | |||||
/// 0x8103_0x007B | |||||
/// </summary> | |||||
public class JT808_0x8103_0x007B : JT808_0x8103_BodyBase, IJT808MessagePackFormatter<JT808_0x8103_0x007B>, IJT808Analyze | |||||
{ | |||||
public override uint ParamId { get; set; } = 0x007B; | |||||
/// <summary> | |||||
/// 数据 长度 | |||||
/// </summary> | |||||
public override byte ParamLength { get; set; } = 2; | |||||
/// <summary> | |||||
/// 车辆核载人数 | |||||
/// </summary> | |||||
public byte NuclearLoadNumber { get; set; } | |||||
/// <summary> | |||||
/// 疲劳程度阈值 | |||||
/// </summary> | |||||
public byte FatigueThreshold { get; set; } | |||||
public void Analyze(ref JT808MessagePackReader reader, Utf8JsonWriter writer, IJT808Config config) | |||||
{ | |||||
JT808_0x8103_0x007B value = new JT808_0x8103_0x007B(); | |||||
value.ParamId = reader.ReadUInt32(); | |||||
writer.WriteNumber($"[{value.ParamId.ReadNumber()}]参数 ID", value.ParamId); | |||||
value.ParamLength = reader.ReadByte(); | |||||
writer.WriteNumber($"[{value.ParamLength.ReadNumber()}]数据长度", value.ParamLength); | |||||
value.NuclearLoadNumber = reader.ReadByte(); | |||||
writer.WriteNumber($"[{value.NuclearLoadNumber.ReadNumber()}]车辆核载人数", value.NuclearLoadNumber); | |||||
value.FatigueThreshold = reader.ReadByte(); | |||||
writer.WriteNumber($"[{value.FatigueThreshold.ReadNumber()}]疲劳程度阈值", value.FatigueThreshold); | |||||
} | |||||
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,106 @@ | |||||
using JT808.Protocol.Formatters; | |||||
using JT808.Protocol.Interfaces; | |||||
using JT808.Protocol.MessageBody; | |||||
using JT808.Protocol.MessagePack; | |||||
using System.Collections.Generic; | |||||
using System.Text.Json; | |||||
namespace JT808.Protocol.Extensions.JT1078.MessageBody | |||||
{ | |||||
/// <summary> | |||||
///终端休眠模式唤醒设置 | |||||
/// 0x8103_0x007C | |||||
/// </summary> | |||||
public class JT808_0x8103_0x007C : JT808_0x8103_BodyBase, IJT808MessagePackFormatter<JT808_0x8103_0x007C>, IJT808Analyze | |||||
{ | |||||
public override uint ParamId { get; set; } = 0x007C; | |||||
/// <summary> | |||||
/// 数据 长度 | |||||
/// </summary> | |||||
public override byte ParamLength { get; set; } = 20; | |||||
/// <summary> | |||||
/// 休眠唤醒模式 | |||||
/// </summary> | |||||
public byte SleepWakeMode { get; set; } | |||||
/// <summary> | |||||
/// 唤醒条件类型 | |||||
/// </summary> | |||||
public byte WakeConditionType { get; set; } | |||||
/// <summary> | |||||
/// 定时唤醒日设置 | |||||
/// </summary> | |||||
public byte TimerWakeDaySet { get; set; } | |||||
/// <summary> | |||||
/// 日定时唤醒参数列表 | |||||
/// </summary> | |||||
public JT808_0x8103_0x007C_TimerWakeDayParamter TimerWakeDayParamter { get; set; } | |||||
public void Analyze(ref JT808MessagePackReader reader, Utf8JsonWriter writer, IJT808Config config) | |||||
{ | |||||
JT808_0x8103_0x007C value = new JT808_0x8103_0x007C(); | |||||
value.ParamId = reader.ReadUInt32(); | |||||
writer.WriteNumber($"[{value.ParamId.ReadNumber()}]参数 ID", value.ParamId); | |||||
value.ParamLength = reader.ReadByte(); | |||||
writer.WriteNumber($"[{value.ParamLength.ReadNumber()}]数据长度", value.ParamLength); | |||||
value.SleepWakeMode = reader.ReadByte(); | |||||
writer.WriteString($"[{value.SleepWakeMode.ReadNumber()}]休眠唤醒模式", SleepWakeModeDisplay(value.SleepWakeMode)); | |||||
value.WakeConditionType = reader.ReadByte(); | |||||
writer.WriteString($"[{value.WakeConditionType.ReadNumber()}]唤醒条件类型", WakeConditionTypeDisplay(value.WakeConditionType)); | |||||
value.TimerWakeDaySet = reader.ReadByte(); | |||||
writer.WriteString($"[{value.TimerWakeDaySet.ReadNumber()}]定时唤醒日设置", TimerWakeDaySetDisplay(value.TimerWakeDaySet)); | |||||
writer.WriteStartObject("日定时唤醒参数列表"); | |||||
config.GetMessagePackFormatter<JT808_0x8103_0x007C_TimerWakeDayParamter>().Analyze(ref reader,writer, config); | |||||
writer.WriteEndObject(); | |||||
string SleepWakeModeDisplay(byte SleepWakeMode) { | |||||
string sleepWakeModeDisplay = string.Empty; | |||||
sleepWakeModeDisplay += (SleepWakeMode & 0x01) == 1 ? ",条件唤醒" : ""; | |||||
sleepWakeModeDisplay += (SleepWakeMode>>1 & 0x01) == 1 ? ",定时唤醒" : ""; | |||||
sleepWakeModeDisplay += (SleepWakeMode>>2 & 0x01) == 1 ? ",手动唤醒" : ""; | |||||
return sleepWakeModeDisplay.Length>0? sleepWakeModeDisplay.Substring(1):""; | |||||
} | |||||
string WakeConditionTypeDisplay(byte WakeConditionType) | |||||
{ | |||||
string wakeConditionTypeDisplay = string.Empty; | |||||
wakeConditionTypeDisplay += (WakeConditionType & 0x01) == 1 ? ",紧急报警" : ""; | |||||
wakeConditionTypeDisplay += (WakeConditionType >> 1 & 0x01) == 1 ? ",碰撞侧翻报警" : ""; | |||||
wakeConditionTypeDisplay += (WakeConditionType >> 2 & 0x01) == 1 ? ",车辆开门" : ""; | |||||
return wakeConditionTypeDisplay.Length>0? wakeConditionTypeDisplay.Substring(1):""; | |||||
} | |||||
string TimerWakeDaySetDisplay(byte TimerWakeDaySet) | |||||
{ | |||||
string timerWakeDaySetDisplay = string.Empty; | |||||
timerWakeDaySetDisplay+= (TimerWakeDaySet & 0x01) == 1 ? ",周一":""; | |||||
timerWakeDaySetDisplay+= (TimerWakeDaySet >> 1 & 0x01) == 1 ? ",周二" :""; | |||||
timerWakeDaySetDisplay+= (TimerWakeDaySet >> 1 & 0x02) == 1 ? ",周三" :""; | |||||
timerWakeDaySetDisplay+= (TimerWakeDaySet >> 1 & 0x03) == 1 ? ",周四" :""; | |||||
timerWakeDaySetDisplay+= (TimerWakeDaySet >> 1 & 0x04) == 1 ? ",周五" :""; | |||||
timerWakeDaySetDisplay+= (TimerWakeDaySet >> 1 & 0x05) == 1 ? ",周六" :""; | |||||
timerWakeDaySetDisplay += (TimerWakeDaySet >> 1 & 0x06) == 1 ? ",周日" : ""; | |||||
return timerWakeDaySetDisplay.Length>0? timerWakeDaySetDisplay.Substring(1):""; | |||||
} | |||||
} | |||||
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.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.TimerWakeDayParamter, config); | |||||
writer.WriteByteReturn((byte)(writer.GetCurrentPosition() - position - 1), position); | |||||
} | |||||
} | |||||
} |
@@ -0,0 +1,120 @@ | |||||
using JT808.Protocol.Formatters; | |||||
using JT808.Protocol.Interfaces; | |||||
using JT808.Protocol.MessageBody; | |||||
using JT808.Protocol.MessagePack; | |||||
using System.Collections.Generic; | |||||
using System.Text.Json; | |||||
namespace JT808.Protocol.Extensions.JT1078.MessageBody | |||||
{ | |||||
/// <summary> | |||||
///终端休眠模式唤醒设置 | |||||
/// 0x8103_0x007C | |||||
/// </summary> | |||||
public class JT808_0x8103_0x007C_TimerWakeDayParamter:IJT808MessagePackFormatter<JT808_0x8103_0x007C_TimerWakeDayParamter>, IJT808Analyze | |||||
{ | |||||
/// <summary> | |||||
/// 定时唤醒启用标志 | |||||
/// </summary> | |||||
public byte TimerWakeEnableFlag { get; set; } | |||||
/// <summary> | |||||
/// 时间段1唤醒时间 | |||||
/// 2 | |||||
/// </summary> | |||||
public string TimePeriod1WakeTime { get; set; } | |||||
/// <summary> | |||||
/// 时间段1关闭时间 | |||||
/// 2 | |||||
/// </summary> | |||||
public string TimePeriod1CloseTime { get; set; } | |||||
/// <summary> | |||||
/// 时间段2唤醒时间 | |||||
/// 2 | |||||
/// </summary> | |||||
public string TimePeriod2WakeTime { get; set; } | |||||
/// <summary> | |||||
/// 时间段2关闭时间 | |||||
/// 2 | |||||
/// </summary> | |||||
public string TimePeriod2CloseTime { get; set; } | |||||
/// <summary> | |||||
/// 时间段3唤醒时间 | |||||
/// 2 | |||||
/// </summary> | |||||
public string TimePeriod3WakeTime { get; set; } | |||||
/// <summary> | |||||
/// 时间段3关闭时间 | |||||
/// 2 | |||||
/// </summary> | |||||
public string TimePeriod3CloseTime { get; set; } | |||||
/// <summary> | |||||
/// 时间段4唤醒时间 | |||||
/// 2 | |||||
/// </summary> | |||||
public string TimePeriod4WakeTime { get; set; } | |||||
/// <summary> | |||||
/// 时间段4关闭时间 | |||||
/// 2 | |||||
/// </summary> | |||||
public string TimePeriod4CloseTime { get; set; } | |||||
public void Analyze(ref JT808MessagePackReader reader, Utf8JsonWriter writer, IJT808Config config) | |||||
{ | |||||
JT808_0x8103_0x007C_TimerWakeDayParamter value = new JT808_0x8103_0x007C_TimerWakeDayParamter(); | |||||
value.TimerWakeEnableFlag = reader.ReadByte(); | |||||
writer.WriteString($"[{value.TimerWakeEnableFlag.ReadNumber()}]定时唤醒启用标志", TimerWakeEnableFlagDisplay(value.TimerWakeEnableFlag)); | |||||
value.TimePeriod1WakeTime = reader.ReadBCD(4); | |||||
writer.WriteString($"[{value.TimePeriod1WakeTime}]时间段1唤醒时间", value.TimePeriod1WakeTime); | |||||
value.TimePeriod1CloseTime = reader.ReadBCD(4); | |||||
writer.WriteString($"[{value.TimePeriod1CloseTime}]时间段1关闭时间", value.TimePeriod1CloseTime); | |||||
value.TimePeriod2WakeTime = reader.ReadBCD(4); | |||||
writer.WriteString($"[{value.TimePeriod2WakeTime}]时间段2唤醒时间", value.TimePeriod2WakeTime); | |||||
value.TimePeriod2CloseTime = reader.ReadBCD(4); | |||||
writer.WriteString($"[{value.TimePeriod2CloseTime}]时间段2关闭时间", value.TimePeriod2CloseTime); | |||||
value.TimePeriod3WakeTime = reader.ReadBCD(4); | |||||
writer.WriteString($"[{value.TimePeriod3WakeTime}]时间段3唤醒时间", value.TimePeriod3WakeTime); | |||||
value.TimePeriod3CloseTime = reader.ReadBCD(4); | |||||
writer.WriteString($"[{value.TimePeriod3CloseTime}]时间段3关闭时间", value.TimePeriod3CloseTime); | |||||
value.TimePeriod4WakeTime = reader.ReadBCD(4); | |||||
writer.WriteString($"[{value.TimePeriod4WakeTime}]时间段4唤醒时间", value.TimePeriod4WakeTime); | |||||
value.TimePeriod4CloseTime = reader.ReadBCD(4); | |||||
writer.WriteString($"[{value.TimePeriod4CloseTime}]时间段4关闭时间", value.TimePeriod4CloseTime); | |||||
string TimerWakeEnableFlagDisplay(byte TimerWakeEnableFlag) { | |||||
string timerWakeEnableFlagDisplay = string.Empty; | |||||
timerWakeEnableFlagDisplay += (TimerWakeEnableFlag & 0x01) == 1 ? ",时间段1唤醒时间启用" : ""; | |||||
timerWakeEnableFlagDisplay += (TimerWakeEnableFlag & 0x01) == 1 ? ",时间段2唤醒时间启用" : ""; | |||||
timerWakeEnableFlagDisplay += (TimerWakeEnableFlag & 0x01) == 1 ? ",时间段3唤醒时间启用" : ""; | |||||
timerWakeEnableFlagDisplay += (TimerWakeEnableFlag & 0x01) == 1 ? ",时间段4唤醒时间启用" : ""; | |||||
return timerWakeEnableFlagDisplay.Length > 0 ? timerWakeEnableFlagDisplay.Substring(1) : ""; | |||||
} | |||||
} | |||||
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,19 @@ | |||||
using System; | |||||
using System.Collections.Generic; | |||||
using System.Text; | |||||
namespace JT808.Protocol.Extensions.JT1078.MessageBody | |||||
{ | |||||
/// <summary> | |||||
/// 查询终端音视频属性 | |||||
/// </summary> | |||||
public class JT808_0x9003:JT808Bodies | |||||
{ | |||||
#pragma warning disable CS1591 // 缺少对公共可见类型或成员的 XML 注释 | |||||
public override string Description => "查询终端音视频属性"; | |||||
public override ushort MsgId => 0x9003; | |||||
public override bool SkipSerialization { get; set; } = true; | |||||
#pragma warning restore CS1591 // 缺少对公共可见类型或成员的 XML 注释 | |||||
} | |||||
} |
@@ -0,0 +1,154 @@ | |||||
using JT808.Protocol.Formatters; | |||||
using JT808.Protocol.Interfaces; | |||||
using JT808.Protocol.MessagePack; | |||||
using System; | |||||
using System.Collections.Generic; | |||||
using System.Text; | |||||
using System.Text.Json; | |||||
namespace JT808.Protocol.Extensions.JT1078.MessageBody | |||||
{ | |||||
/// <summary> | |||||
/// 实时音视频传输请求(live、talk、listen、fanout、passThrough直播、对讲、监听、广播、透传请求) | |||||
/// </summary> | |||||
public class JT808_0x9101: JT808Bodies, IJT808MessagePackFormatter<JT808_0x9101>, IJT808Analyze | |||||
{ | |||||
#pragma warning disable CS1591 // 缺少对公共可见类型或成员的 XML 注释 | |||||
public override string Description => "实时音视频传输请求"; | |||||
public override ushort MsgId => 0x9101; | |||||
#pragma warning restore CS1591 // 缺少对公共可见类型或成员的 XML 注释 | |||||
/// <summary> | |||||
/// 视频服务器IP地址长度 | |||||
/// </summary> | |||||
public byte ServerIpLength { get;internal set; } | |||||
/// <summary> | |||||
/// 视频服务器IP地址 | |||||
/// </summary> | |||||
public string ServerIp { get; set; } | |||||
/// <summary> | |||||
/// 视频服务器TCP端口号,不使用TCP协议传输时保持默认值0即可(TCP和UDP二选一,当TCP和UDP均非默认值时一般以TCP为准) | |||||
/// </summary> | |||||
public ushort TcpPort { get; set; } | |||||
/// <summary> | |||||
/// 视频服务器UDP端口号,不使用UDP协议传输时保持默认值0即可(TCP和UDP二选一,当TCP和UDP均非默认值时一般以TCP为准) | |||||
/// </summary> | |||||
public ushort UdpPort { get; set; } | |||||
/// <summary> | |||||
/// 逻辑通道号 | |||||
/// </summary> | |||||
public byte ChannelNo { get; set; } | |||||
/// <summary> | |||||
/// 数据类型 | |||||
/// 0:音视频 | |||||
/// 1:视频 | |||||
/// 2:双向对讲 | |||||
/// 3:监听 | |||||
/// 4:中心广播 | |||||
/// 5:透传 | |||||
/// </summary> | |||||
public byte DataType { get; set; } | |||||
/// <summary> | |||||
/// 码流类型 | |||||
/// 0:主码流 | |||||
/// 1:子码流 | |||||
/// </summary> | |||||
public byte StreamType { get; set; } | |||||
/// <summary> | |||||
/// 格式分析 | |||||
/// </summary> | |||||
/// <param name="reader"></param> | |||||
/// <param name="writer"></param> | |||||
/// <param name="config"></param> | |||||
public void Analyze(ref JT808MessagePackReader reader, Utf8JsonWriter writer, IJT808Config config) | |||||
{ | |||||
var value = new JT808_0x9101(); | |||||
value.ServerIpLength = reader.ReadByte(); | |||||
writer.WriteNumber($"[{value.ServerIpLength.ReadNumber()}]服务器IP地址长度", value.ServerIpLength); | |||||
string ipHex = reader.ReadVirtualArray(value.ServerIpLength).ToArray().ToHexString(); | |||||
value.ServerIp = reader.ReadString(value.ServerIpLength); | |||||
writer.WriteString($"[{ipHex}]服务器IP地址", value.ServerIp); | |||||
value.TcpPort = reader.ReadUInt16(); | |||||
writer.WriteNumber($"[{value.TcpPort.ReadNumber()}]服务器视频通道监听端口号(TCP)", value.TcpPort); | |||||
value.UdpPort = reader.ReadUInt16(); | |||||
writer.WriteNumber($"[{value.UdpPort.ReadNumber()}]服务器视频通道监听端口号(UDP)", value.UdpPort); | |||||
value.ChannelNo = reader.ReadByte(); | |||||
writer.WriteString($"[{value.ChannelNo.ReadNumber()}]逻辑通道号", LogicalChannelNoDisplay(value.ChannelNo)); | |||||
value.DataType = reader.ReadByte(); | |||||
writer.WriteString($"[{value.DataType.ReadNumber()}]数据类型", DataTypeDisplay(value.DataType)); | |||||
value.StreamType = reader.ReadByte(); | |||||
writer.WriteString($"[{value.StreamType.ReadNumber()}]码流类型", value.StreamType==0?"主码流":"子码流"); | |||||
string DataTypeDisplay(byte DataType) { | |||||
return DataType switch | |||||
{ | |||||
0 => "音视频", | |||||
1 => "视频", | |||||
2 => "双向对讲", | |||||
3 => "监听", | |||||
4 => "中心广播", | |||||
5 => "透传", | |||||
_ => "未知", | |||||
}; | |||||
} | |||||
string LogicalChannelNoDisplay(byte LogicalChannelNo) { | |||||
return LogicalChannelNo switch | |||||
{ | |||||
1 => "驾驶员", | |||||
2 => "车辆正前方", | |||||
3 => "车前门", | |||||
4 => "车厢前部", | |||||
5 => "车厢后部", | |||||
7 => "行李舱", | |||||
8 => "车辆左侧", | |||||
9 => "车辆右侧", | |||||
10 => "车辆正后方", | |||||
11 => "车厢中部", | |||||
12 => "车中门", | |||||
13 => "驾驶席车门", | |||||
33 => "驾驶员", | |||||
36 => "车厢前部", | |||||
37 => "车厢后部", | |||||
_ => "预留", | |||||
}; | |||||
} | |||||
} | |||||
/// <summary> | |||||
/// 反序列化 | |||||
/// </summary> | |||||
/// <param name="reader"></param> | |||||
/// <param name="config"></param> | |||||
/// <returns></returns> | |||||
public JT808_0x9101 Deserialize(ref JT808MessagePackReader reader, IJT808Config config) | |||||
{ | |||||
var jT808_0x9101 = new JT808_0x9101(); | |||||
jT808_0x9101.ServerIpLength = reader.ReadByte(); | |||||
jT808_0x9101.ServerIp = reader.ReadString(jT808_0x9101.ServerIpLength); | |||||
jT808_0x9101.TcpPort = reader.ReadUInt16(); | |||||
jT808_0x9101.UdpPort = reader.ReadUInt16(); | |||||
jT808_0x9101.ChannelNo = reader.ReadByte(); | |||||
jT808_0x9101.DataType = reader.ReadByte(); | |||||
jT808_0x9101.StreamType = reader.ReadByte(); | |||||
return jT808_0x9101; | |||||
} | |||||
/// <summary> | |||||
/// 序列化 | |||||
/// </summary> | |||||
/// <param name="writer"></param> | |||||
/// <param name="value"></param> | |||||
/// <param name="config"></param> | |||||
public void Serialize(ref JT808MessagePackWriter writer, JT808_0x9101 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.ChannelNo); | |||||
writer.WriteByte(value.DataType); | |||||
writer.WriteByte(value.StreamType); | |||||
} | |||||
} | |||||
} |
@@ -0,0 +1,142 @@ | |||||
using JT808.Protocol.Formatters; | |||||
using JT808.Protocol.Interfaces; | |||||
using JT808.Protocol.MessagePack; | |||||
using System; | |||||
using System.Collections.Generic; | |||||
using System.Text; | |||||
using System.Text.Json; | |||||
namespace JT808.Protocol.Extensions.JT1078.MessageBody | |||||
{ | |||||
/// <summary> | |||||
/// 音视频实时传输控制(LiveControl直播控制) | |||||
/// </summary> | |||||
public class JT808_0x9102 : JT808Bodies, IJT808MessagePackFormatter<JT808_0x9102>, IJT808Analyze | |||||
{ | |||||
#pragma warning disable CS1591 // 缺少对公共可见类型或成员的 XML 注释 | |||||
public override string Description => "音视频实时传输控制"; | |||||
public override ushort MsgId => 0x9102; | |||||
#pragma warning restore CS1591 // 缺少对公共可见类型或成员的 XML 注释 | |||||
/// <summary> | |||||
/// 逻辑通道号 | |||||
/// </summary> | |||||
public byte ChannelNo { get; set; } | |||||
/// <summary> | |||||
/// 控制指令 | |||||
/// 平台可以通过该指令对设备的实时音视频进行控制: | |||||
/// 0:关闭音视频传输指令 | |||||
/// 1:切换码流(增加暂停和继续) | |||||
/// 2:暂停该通道所有流的发送 | |||||
/// 3:恢复暂停前流的发送,与暂停前的流类型一致 | |||||
/// 4:关闭双向对讲 | |||||
/// </summary> | |||||
public byte ControlCmd { get; set; } | |||||
/// <summary> | |||||
/// 关闭音视频类型 | |||||
/// 0:关闭该通道有关的音视频数据 | |||||
/// 1:只关闭该通道有关的音频,保留该通道有关的视频 | |||||
/// 2:只关闭该通道有关的视频,保留该通道有关的音频 | |||||
/// </summary> | |||||
public byte CloseAVData { get; set; } | |||||
/// <summary> | |||||
/// 切换码流类型 | |||||
/// 将之前申请的码流切换为新申请的码流,音频与切换前保持一致。 | |||||
/// 新申请的码流为: | |||||
/// 0:主码流 | |||||
/// 1:子码流 | |||||
/// </summary> | |||||
public byte StreamType { get; set; } | |||||
/// <summary> | |||||
/// 格式分析 | |||||
/// </summary> | |||||
/// <param name="reader"></param> | |||||
/// <param name="writer"></param> | |||||
/// <param name="config"></param> | |||||
public void Analyze(ref JT808MessagePackReader reader, Utf8JsonWriter writer, IJT808Config config) | |||||
{ | |||||
JT808_0x9102 value = new JT808_0x9102(); | |||||
value.ChannelNo = reader.ReadByte(); | |||||
writer.WriteString($"[{value.ChannelNo.ReadNumber()}]逻辑通道号", LogicalChannelNoDisplay(value.ChannelNo)); | |||||
value.ControlCmd = reader.ReadByte(); | |||||
writer.WriteString($"[{value.ControlCmd.ReadNumber()}]控制指令", ControlCmdDisplay(value.ControlCmd)); | |||||
value.CloseAVData = reader.ReadByte(); | |||||
writer.WriteString($"[{value.CloseAVData.ReadNumber()}]关闭音视频类型", CloseAVDataDisplay(value.CloseAVData)); | |||||
value.StreamType = reader.ReadByte(); | |||||
writer.WriteString($"[{value.StreamType.ReadNumber()}]切换码流类型", value.StreamType == 0 ? "主码流" : "子码流"); | |||||
string CloseAVDataDisplay(byte CloseAVData) | |||||
{ | |||||
return CloseAVData switch | |||||
{ | |||||
0 => "关闭该通道有关的音视频数据", | |||||
1 => "只关闭该通道有关的音频,保留该通道有关的视频", | |||||
2 => "只关闭该通道有关的视频,保留该通道有关的音频", | |||||
_ => "未知", | |||||
}; | |||||
} | |||||
string ControlCmdDisplay(byte ControlCmd) | |||||
{ | |||||
return ControlCmd switch | |||||
{ | |||||
0 => "关闭音视频传输指令", | |||||
1 => "切换码流(增加暂停和继续)", | |||||
2 => "暂停该通道所有流的发送", | |||||
3 => "恢复暂停前流的发送,与暂停前的流类型一致", | |||||
4 => "关闭双向对讲", | |||||
_ => "未知", | |||||
}; | |||||
} | |||||
string LogicalChannelNoDisplay(byte LogicalChannelNo) | |||||
{ | |||||
return LogicalChannelNo switch | |||||
{ | |||||
1 => "驾驶员", | |||||
2 => "车辆正前方", | |||||
3 => "车前门", | |||||
4 => "车厢前部", | |||||
5 => "车厢后部", | |||||
7 => "行李舱", | |||||
8 => "车辆左侧", | |||||
9 => "车辆右侧", | |||||
10 => "车辆正后方", | |||||
11 => "车厢中部", | |||||
12 => "车中门", | |||||
13 => "驾驶席车门", | |||||
33 => "驾驶员", | |||||
36 => "车厢前部", | |||||
37 => "车厢后部", | |||||
_ => "预留", | |||||
}; | |||||
} | |||||
} | |||||
/// <summary> | |||||
/// 反序列化 | |||||
/// </summary> | |||||
/// <param name="reader"></param> | |||||
/// <param name="config"></param> | |||||
/// <returns></returns> | |||||
public JT808_0x9102 Deserialize(ref JT808MessagePackReader reader, IJT808Config config) | |||||
{ | |||||
var jT808_0X9102 = new JT808_0x9102(); | |||||
jT808_0X9102.ChannelNo = reader.ReadByte(); | |||||
jT808_0X9102.ControlCmd = reader.ReadByte(); | |||||
jT808_0X9102.CloseAVData = reader.ReadByte(); | |||||
jT808_0X9102.StreamType = reader.ReadByte(); | |||||
return jT808_0X9102; | |||||
} | |||||
/// <summary> | |||||
/// 序列化 | |||||
/// </summary> | |||||
/// <param name="writer"></param> | |||||
/// <param name="value"></param> | |||||
/// <param name="config"></param> | |||||
public void Serialize(ref JT808MessagePackWriter writer, JT808_0x9102 value, IJT808Config config) | |||||
{ | |||||
writer.WriteByte(value.ChannelNo); | |||||
writer.WriteByte(value.ControlCmd); | |||||
writer.WriteByte(value.CloseAVData); | |||||
writer.WriteByte(value.StreamType); | |||||
} | |||||
} | |||||
} |
@@ -0,0 +1,92 @@ | |||||
using JT808.Protocol.Formatters; | |||||
using JT808.Protocol.Interfaces; | |||||
using JT808.Protocol.MessagePack; | |||||
using System; | |||||
using System.Collections.Generic; | |||||
using System.Text; | |||||
using System.Text.Json; | |||||
namespace JT808.Protocol.Extensions.JT1078.MessageBody | |||||
{ | |||||
/// <summary> | |||||
/// 实时音视频传输状态通知 | |||||
/// </summary> | |||||
public class JT808_0x9105 : JT808Bodies, IJT808MessagePackFormatter<JT808_0x9105>, IJT808Analyze | |||||
{ | |||||
#pragma warning disable CS1591 // 缺少对公共可见类型或成员的 XML 注释 | |||||
public override string Description => "实时音视频传输状态通知"; | |||||
public override ushort MsgId => 0x9105; | |||||
#pragma warning restore CS1591 // 缺少对公共可见类型或成员的 XML 注释 | |||||
/// <summary> | |||||
/// 逻辑通道号 | |||||
/// </summary> | |||||
public byte ChannelNo { get; set; } | |||||
/// <summary> | |||||
/// 丢包率 | |||||
/// 当前传输通道的丢包率,数值乘以100之后取整部分 | |||||
/// </summary> | |||||
public byte DropRate { get; set; } | |||||
/// <summary> | |||||
/// | |||||
/// </summary> | |||||
/// <param name="reader"></param> | |||||
/// <param name="writer"></param> | |||||
/// <param name="config"></param> | |||||
public void Analyze(ref JT808MessagePackReader reader, Utf8JsonWriter writer, IJT808Config config) | |||||
{ | |||||
JT808_0x9105 value = new JT808_0x9105(); | |||||
value.ChannelNo = reader.ReadByte(); | |||||
writer.WriteString($"[{value.ChannelNo.ReadNumber()}]逻辑通道号", LogicalChannelNoDisplay(value.ChannelNo)); | |||||
value.DropRate = reader.ReadByte(); | |||||
writer.WriteNumber($"[{value.DropRate.ReadNumber()}]丢包率", value.DropRate); | |||||
string LogicalChannelNoDisplay(byte LogicalChannelNo) | |||||
{ | |||||
return LogicalChannelNo switch | |||||
{ | |||||
1 => "驾驶员", | |||||
2 => "车辆正前方", | |||||
3 => "车前门", | |||||
4 => "车厢前部", | |||||
5 => "车厢后部", | |||||
7 => "行李舱", | |||||
8 => "车辆左侧", | |||||
9 => "车辆右侧", | |||||
10 => "车辆正后方", | |||||
11 => "车厢中部", | |||||
12 => "车中门", | |||||
13 => "驾驶席车门", | |||||
33 => "驾驶员", | |||||
36 => "车厢前部", | |||||
37 => "车厢后部", | |||||
_ => "预留", | |||||
}; | |||||
} | |||||
} | |||||
/// <summary> | |||||
/// | |||||
/// </summary> | |||||
/// <param name="reader"></param> | |||||
/// <param name="config"></param> | |||||
/// <returns></returns> | |||||
public JT808_0x9105 Deserialize(ref JT808MessagePackReader reader, IJT808Config config) | |||||
{ | |||||
JT808_0x9105 jT808_0x9105 = new JT808_0x9105(); | |||||
jT808_0x9105.ChannelNo = reader.ReadByte(); | |||||
jT808_0x9105.DropRate = reader.ReadByte(); | |||||
return jT808_0x9105; | |||||
} | |||||
/// <summary> | |||||
/// | |||||
/// </summary> | |||||
/// <param name="writer"></param> | |||||
/// <param name="value"></param> | |||||
/// <param name="config"></param> | |||||
public void Serialize(ref JT808MessagePackWriter writer, JT808_0x9105 value, IJT808Config config) | |||||
{ | |||||
writer.WriteByte(value.ChannelNo); | |||||
writer.WriteByte(value.DropRate); | |||||
} | |||||
} | |||||
} |
@@ -0,0 +1,251 @@ | |||||
using JT808.Protocol.Formatters; | |||||
using JT808.Protocol.Interfaces; | |||||
using JT808.Protocol.MessagePack; | |||||
using System; | |||||
using System.Collections.Generic; | |||||
using System.Text; | |||||
using System.Text.Json; | |||||
namespace JT808.Protocol.Extensions.JT1078.MessageBody | |||||
{ | |||||
/// <summary> | |||||
/// 平台下发远程录像回放请求(vod点播请求) | |||||
/// </summary> | |||||
public class JT808_0x9201 : JT808Bodies, IJT808MessagePackFormatter<JT808_0x9201>, IJT808Analyze | |||||
{ | |||||
#pragma warning disable CS1591 // 缺少对公共可见类型或成员的 XML 注释 | |||||
public override string Description => "平台下发远程录像回放请求"; | |||||
public override ushort MsgId => 0x9201; | |||||
#pragma warning restore CS1591 // 缺少对公共可见类型或成员的 XML 注释 | |||||
/// <summary> | |||||
/// 服务器IP地址长度 | |||||
/// </summary> | |||||
public byte ServerIpLength { get; set; } | |||||
/// <summary> | |||||
/// 服务器IP地址 | |||||
/// </summary> | |||||
public string ServerIp { get; set; } | |||||
/// <summary> | |||||
/// 视频服务器TCP端口号,不使用TCP协议传输时保持默认值0即可(TCP和UDP二选一,当TCP和UDP均非默认值时一般以TCP为准) | |||||
/// </summary> | |||||
public ushort TcpPort { get; set; } | |||||
/// <summary> | |||||
/// 视频服务器UDP端口号,不使用UDP协议传输时保持默认值0即可(TCP和UDP二选一,当TCP和UDP均非默认值时一般以TCP为准) | |||||
/// </summary> | |||||
public ushort UdpPort { get; set; } | |||||
/// <summary> | |||||
/// 逻辑通道号 | |||||
/// </summary> | |||||
public byte ChannelNo { get; set; } | |||||
/// <summary> | |||||
/// 音视频类型(媒体类型) | |||||
/// 0:audio and video | |||||
/// 1:audio | |||||
/// 2:video | |||||
/// 3:audio or video | |||||
/// </summary> | |||||
public byte MediaType { get; set; } | |||||
/// <summary> | |||||
/// 码流类型 | |||||
/// 0:主或子码流 | |||||
/// 1:主 | |||||
/// 2:子 | |||||
/// 如果此通道只传输音频,置为0 | |||||
/// </summary> | |||||
public byte StreamType { get; set; } | |||||
/// <summary> | |||||
/// 存储器类型 | |||||
/// 0:主或灾备存储器 | |||||
/// 1:主存储器 | |||||
/// 2:灾备存储器 | |||||
/// </summary> | |||||
public byte MemoryType { get; set; } | |||||
/// <summary> | |||||
/// 回放方式 | |||||
/// 0:正常 | |||||
/// 1:快进 | |||||
/// 2:关键帧快退回放 | |||||
/// 3:关键帧播放 | |||||
/// 4:单帧上传 | |||||
/// </summary> | |||||
public byte PlaybackWay { get; set; } | |||||
/// <summary> | |||||
/// 快进或快退倍数,当<see cref="PlaybackWay"/>为1和2时,此字段有效,否则置0 | |||||
/// 0:无效 | |||||
/// 1:1倍 | |||||
/// 2:2倍 | |||||
/// 3:4倍 | |||||
/// 4:8倍 | |||||
/// 5:16倍 | |||||
/// </summary> | |||||
public byte PlaySpeed { get; set; } | |||||
/// <summary> | |||||
/// 开始时间,当<see cref="PlaybackWay"/>为4时,该字段表示单帧上传时间 | |||||
/// </summary> | |||||
public DateTime BeginTime { get; set; } | |||||
/// <summary> | |||||
/// 结束时间,当<see cref="PlaybackWay"/>为4时,该字段无效 | |||||
/// </summary> | |||||
public DateTime EndTime { get; set; } | |||||
/// <summary> | |||||
/// 格式分析 | |||||
/// </summary> | |||||
/// <param name="reader"></param> | |||||
/// <param name="writer"></param> | |||||
/// <param name="config"></param> | |||||
public void Analyze(ref JT808MessagePackReader reader, Utf8JsonWriter writer, IJT808Config config) | |||||
{ | |||||
var value = new JT808_0x9201(); | |||||
value.ServerIpLength = reader.ReadByte(); | |||||
writer.WriteNumber($"[{value.ServerIpLength.ReadNumber()}]服务器IP地址长度", value.ServerIpLength); | |||||
string ipHex = reader.ReadVirtualArray(value.ServerIpLength).ToArray().ToHexString(); | |||||
value.ServerIp = reader.ReadString(value.ServerIpLength); | |||||
writer.WriteString($"[{ipHex}]服务器IP地址", value.ServerIp); | |||||
value.TcpPort = reader.ReadUInt16(); | |||||
writer.WriteNumber($"[{value.TcpPort.ReadNumber()}]服务器视频通道监听端口号(TCP)", value.TcpPort); | |||||
value.UdpPort = reader.ReadUInt16(); | |||||
writer.WriteNumber($"[{value.UdpPort.ReadNumber()}]服务器视频通道监听端口号(UDP)", value.UdpPort); | |||||
value.ChannelNo = reader.ReadByte(); | |||||
writer.WriteString($"[{value.ChannelNo.ReadNumber()}]逻辑通道号", LogicalChannelNoDisplay(value.ChannelNo)); | |||||
value.MediaType = reader.ReadByte(); | |||||
writer.WriteString($"[{value.MediaType.ReadNumber()}]音视频类型", AVItemTypeDisplay(value.MediaType)); | |||||
value.StreamType = reader.ReadByte(); | |||||
writer.WriteString($"[{value.StreamType.ReadNumber()}]码流类型", StreamTypeDisplay(value.StreamType)); | |||||
value.MemoryType = reader.ReadByte(); | |||||
writer.WriteString($"[{value.MemoryType.ReadNumber()}]存储器类型", MemTypeDisplay(value.MemoryType)); | |||||
value.PlaybackWay = reader.ReadByte(); | |||||
writer.WriteString($"[{value.PlaybackWay.ReadNumber()}]回访方式", PlayBackWayDisplay(value.PlaybackWay)); | |||||
value.PlaySpeed = reader.ReadByte(); | |||||
writer.WriteString($"[{value.PlaySpeed.ReadNumber()}]快进或快退倍数", FastForwardOrFastRewindMultiplesDisplay(value.PlaySpeed)); | |||||
value.BeginTime = reader.ReadDateTime6(); | |||||
writer.WriteString($"[{value.BeginTime:yyMMddHHmmss}]起始时间", value.BeginTime.ToString("yyyy-MM-dd HH:mm:ss")); | |||||
value.EndTime = reader.ReadDateTime6(); | |||||
writer.WriteString($"[{value.EndTime:yyMMddHHmmss}]结束时间", value.EndTime.ToString("yyyy-MM-dd HH:mm:ss")); | |||||
static string AVItemTypeDisplay(byte AVItemType) | |||||
{ | |||||
return AVItemType switch | |||||
{ | |||||
0 => "音视频", | |||||
1 => "音频", | |||||
2 => "视频", | |||||
3 => "音频或视频", | |||||
_ => "未知", | |||||
}; | |||||
} | |||||
static string StreamTypeDisplay(byte StreamType) | |||||
{ | |||||
return StreamType switch | |||||
{ | |||||
0 => "主码流或子码流", | |||||
1 => "主码流", | |||||
2 => "子码流", | |||||
_ => "未知", | |||||
}; | |||||
} | |||||
static string MemTypeDisplay(byte MemType) | |||||
{ | |||||
return MemType switch | |||||
{ | |||||
0 => "主存储器或灾备服务器", | |||||
1 => "主存储器", | |||||
2 => "灾备服务器", | |||||
_ => "未知", | |||||
}; | |||||
} | |||||
static string PlayBackWayDisplay(byte PlayBackWay) | |||||
{ | |||||
return PlayBackWay switch | |||||
{ | |||||
0 => "正常回放", | |||||
1 => "快进回放", | |||||
2 => "关键帧快退回访", | |||||
3 => "关键帧播放", | |||||
4 => "单帧上传", | |||||
_ => "未知", | |||||
}; | |||||
} | |||||
static string FastForwardOrFastRewindMultiplesDisplay(byte FastForwardOrFastRewindMultiples) | |||||
{ | |||||
return FastForwardOrFastRewindMultiples switch | |||||
{ | |||||
0 => "无效", | |||||
1 => "1倍", | |||||
2 => "2倍", | |||||
3 => "4倍", | |||||
4 => "8倍", | |||||
5 => "16倍", | |||||
_ => "未知", | |||||
}; | |||||
} | |||||
static string LogicalChannelNoDisplay(byte LogicalChannelNo) | |||||
{ | |||||
return LogicalChannelNo switch | |||||
{ | |||||
1 => "驾驶员", | |||||
2 => "车辆正前方", | |||||
3 => "车前门", | |||||
4 => "车厢前部", | |||||
5 => "车厢后部", | |||||
7 => "行李舱", | |||||
8 => "车辆左侧", | |||||
9 => "车辆右侧", | |||||
10 => "车辆正后方", | |||||
11 => "车厢中部", | |||||
12 => "车中门", | |||||
13 => "驾驶席车门", | |||||
33 => "驾驶员", | |||||
36 => "车厢前部", | |||||
37 => "车厢后部", | |||||
_ => "预留", | |||||
}; | |||||
} | |||||
} | |||||
/// <summary> | |||||
/// 反序列化 | |||||
/// </summary> | |||||
/// <param name="reader"></param> | |||||
/// <param name="config"></param> | |||||
/// <returns></returns> | |||||
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.ChannelNo = reader.ReadByte(); | |||||
jT808_0x9201.MediaType = reader.ReadByte(); | |||||
jT808_0x9201.StreamType = reader.ReadByte(); | |||||
jT808_0x9201.MemoryType = reader.ReadByte(); | |||||
jT808_0x9201.PlaybackWay = reader.ReadByte(); | |||||
jT808_0x9201.PlaySpeed = reader.ReadByte(); | |||||
jT808_0x9201.BeginTime = reader.ReadDateTime6(); | |||||
jT808_0x9201.EndTime = reader.ReadDateTime6(); | |||||
return jT808_0x9201; | |||||
} | |||||
/// <summary> | |||||
/// 序列化 | |||||
/// </summary> | |||||
/// <param name="writer"></param> | |||||
/// <param name="value"></param> | |||||
/// <param name="config"></param> | |||||
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.ChannelNo); | |||||
writer.WriteByte(value.MediaType); | |||||
writer.WriteByte(value.StreamType); | |||||
writer.WriteByte(value.MemoryType); | |||||
writer.WriteByte(value.PlaybackWay); | |||||
writer.WriteByte(value.PlaySpeed); | |||||
writer.WriteDateTime6(value.BeginTime); | |||||
writer.WriteDateTime6(value.EndTime); | |||||
} | |||||
} | |||||
} |
@@ -0,0 +1,144 @@ | |||||
using JT808.Protocol.Formatters; | |||||
using JT808.Protocol.Interfaces; | |||||
using JT808.Protocol.MessagePack; | |||||
using System; | |||||
using System.Collections.Generic; | |||||
using System.Text; | |||||
using System.Text.Json; | |||||
namespace JT808.Protocol.Extensions.JT1078.MessageBody | |||||
{ | |||||
/// <summary> | |||||
/// 平台下发远程录像回放控制(VodControl点播控制) | |||||
/// </summary> | |||||
public class JT808_0x9202 : JT808Bodies, IJT808MessagePackFormatter<JT808_0x9202>, IJT808Analyze | |||||
{ | |||||
#pragma warning disable CS1591 // 缺少对公共可见类型或成员的 XML 注释 | |||||
public override string Description => "平台下发远程录像回放控制"; | |||||
public override ushort MsgId => 0x9202; | |||||
#pragma warning restore CS1591 // 缺少对公共可见类型或成员的 XML 注释 | |||||
/// <summary> | |||||
/// 音视频通道号 | |||||
/// </summary> | |||||
public byte ChannelNo { get; set; } | |||||
/// <summary> | |||||
/// 回放控制 | |||||
/// 0:开始 | |||||
/// 1:暂停 | |||||
/// 2:结束 | |||||
/// 3:快进 | |||||
/// 4:关键帧快退播放 | |||||
/// 5:拖动(到指定位置) | |||||
/// 6:关键帧播放 | |||||
/// </summary> | |||||
public byte PlayControl { get; set; } | |||||
/// <summary> | |||||
/// 快进或快退倍数,当<see cref="PlayControl"/>为3和4时,此字段有效,否则置0 | |||||
/// 0:无效 | |||||
/// 1:1倍 | |||||
/// 2:2倍 | |||||
/// 3:4倍 | |||||
/// 4:8倍 | |||||
/// 5:16倍 | |||||
/// </summary> | |||||
public byte PlaySpeed { get; set; } | |||||
/// <summary> | |||||
/// 拖动回放位置,当<see cref="PlayControl"/>为5时有效(必须) | |||||
/// </summary> | |||||
public DateTime DragPlayPosition { get; set; } | |||||
/// <summary> | |||||
/// | |||||
/// </summary> | |||||
/// <param name="reader"></param> | |||||
/// <param name="writer"></param> | |||||
/// <param name="config"></param> | |||||
public void Analyze(ref JT808MessagePackReader reader, Utf8JsonWriter writer, IJT808Config config) | |||||
{ | |||||
JT808_0x9202 value = new JT808_0x9202(); | |||||
value.ChannelNo = reader.ReadByte(); | |||||
writer.WriteString($"[{value.ChannelNo.ReadNumber()}]音视频通道号", AVChannelNoDisplay(value.ChannelNo)); | |||||
value.PlayControl = reader.ReadByte(); | |||||
writer.WriteString($"[{value.PlayControl.ReadNumber()}]回放控制", PlayBackControlDisplay(value.PlayControl)); | |||||
value.PlaySpeed = reader.ReadByte(); | |||||
writer.WriteString($"[{value.PlaySpeed.ReadNumber()}]快进或快退倍数", FastForwardOrFastRewindMultiplesDisplay(value.PlaySpeed)); | |||||
value.DragPlayPosition = reader.ReadDateTime6(); | |||||
writer.WriteString($"[{value.DragPlayPosition.ToString("yyMMddHHmmss")}]拖动回放位置", value.DragPlayPosition.ToString("yyyy-MM-dd HH:mm:ss")); | |||||
static string AVChannelNoDisplay(byte LogicalChannelNo) | |||||
{ | |||||
return LogicalChannelNo switch | |||||
{ | |||||
1 => "驾驶员", | |||||
2 => "车辆正前方", | |||||
3 => "车前门", | |||||
4 => "车厢前部", | |||||
5 => "车厢后部", | |||||
7 => "行李舱", | |||||
8 => "车辆左侧", | |||||
9 => "车辆右侧", | |||||
10 => "车辆正后方", | |||||
11 => "车厢中部", | |||||
12 => "车中门", | |||||
13 => "驾驶席车门", | |||||
33 => "驾驶员", | |||||
36 => "车厢前部", | |||||
37 => "车厢后部", | |||||
_ => "预留", | |||||
}; | |||||
} | |||||
static string PlayBackControlDisplay(byte PlayBackControl) { | |||||
return PlayBackControl switch | |||||
{ | |||||
0 => "开始回放", | |||||
1 => "暂停回放", | |||||
2 => "结束回放", | |||||
3 => "快进回放", | |||||
4 => "关键帧快退回放", | |||||
5 => "拖动回放", | |||||
6 => "关键帧播放", | |||||
_ => "未知", | |||||
}; | |||||
} | |||||
static string FastForwardOrFastRewindMultiplesDisplay(byte FastForwardOrFastRewindMultiples) | |||||
{ | |||||
return FastForwardOrFastRewindMultiples switch | |||||
{ | |||||
0 => "无效", | |||||
1 => "1倍", | |||||
2 => "2倍", | |||||
3 => "4倍", | |||||
4 => "8倍", | |||||
5 => "16倍", | |||||
_ => "未知", | |||||
}; | |||||
} | |||||
} | |||||
/// <summary> | |||||
/// | |||||
/// </summary> | |||||
/// <param name="reader"></param> | |||||
/// <param name="config"></param> | |||||
/// <returns></returns> | |||||
public JT808_0x9202 Deserialize(ref JT808MessagePackReader reader, IJT808Config config) | |||||
{ | |||||
var jT808_0x9202 = new JT808_0x9202(); | |||||
jT808_0x9202.ChannelNo = reader.ReadByte(); | |||||
jT808_0x9202.PlayControl = reader.ReadByte(); | |||||
jT808_0x9202.PlaySpeed = reader.ReadByte(); | |||||
jT808_0x9202.DragPlayPosition = reader.ReadDateTime6(); | |||||
return jT808_0x9202; | |||||
} | |||||
/// <summary> | |||||
/// | |||||
/// </summary> | |||||
/// <param name="writer"></param> | |||||
/// <param name="value"></param> | |||||
/// <param name="config"></param> | |||||
public void Serialize(ref JT808MessagePackWriter writer, JT808_0x9202 value, IJT808Config config) | |||||
{ | |||||
writer.WriteByte(value.ChannelNo); | |||||
writer.WriteByte(value.PlayControl); | |||||
writer.WriteByte(value.PlaySpeed); | |||||
writer.WriteDateTime6(value.DragPlayPosition); | |||||
} | |||||
} | |||||
} |
@@ -0,0 +1,157 @@ | |||||
using JT808.Protocol.Formatters; | |||||
using JT808.Protocol.Interfaces; | |||||
using JT808.Protocol.MessagePack; | |||||
using System; | |||||
using System.Collections.Generic; | |||||
using System.Text; | |||||
using System.Text.Json; | |||||
namespace JT808.Protocol.Extensions.JT1078.MessageBody | |||||
{ | |||||
/// <summary> | |||||
/// 查询资源列表 | |||||
/// </summary> | |||||
public class JT808_0x9205 : JT808Bodies, IJT808MessagePackFormatter<JT808_0x9205>, IJT808Analyze | |||||
{ | |||||
#pragma warning disable CS1591 // 缺少对公共可见类型或成员的 XML 注释 | |||||
public override string Description => "查询资源列表"; | |||||
public override ushort MsgId => 0x9205; | |||||
#pragma warning restore CS1591 // 缺少对公共可见类型或成员的 XML 注释 | |||||
/// <summary> | |||||
/// 逻辑通道号 | |||||
/// </summary> | |||||
public byte ChannelNo { get; set; } | |||||
/// <summary> | |||||
/// 开始时间 | |||||
/// </summary> | |||||
public DateTime BeginTime { get; set; } | |||||
/// <summary> | |||||
/// 结束时间 | |||||
/// </summary> | |||||
public DateTime EndTime { get; set; } | |||||
/// <summary> | |||||
/// 报警标志 | |||||
/// </summary> | |||||
public ulong AlarmFlag { get; set; } | |||||
/// <summary> | |||||
/// 音视频资源类型 | |||||
/// 0:audio and video | |||||
/// 1:audio | |||||
/// 2:video | |||||
/// 3:audio or video | |||||
/// </summary> | |||||
public byte MediaType { get; set; } | |||||
/// <summary> | |||||
/// 码流类型 | |||||
/// 0:主或子码流 | |||||
/// 1:主 | |||||
/// 2:子 | |||||
/// </summary> | |||||
public byte StreamType { get; set; } | |||||
/// <summary> | |||||
/// 存储器类型 | |||||
/// 0:主或灾备存储器 | |||||
/// 1:主存储器 | |||||
/// 2:灾备存储器 | |||||
/// </summary> | |||||
public byte MemoryType { get; set; } | |||||
#pragma warning disable CS1591 // 缺少对公共可见类型或成员的 XML 注释 | |||||
public void Analyze(ref JT808MessagePackReader reader, Utf8JsonWriter writer, IJT808Config config) | |||||
{ | |||||
JT808_0x9205 value = new JT808_0x9205(); | |||||
value.ChannelNo = reader.ReadByte(); | |||||
writer.WriteString($"[{value.ChannelNo.ReadNumber()}]逻辑通道号", LogicalChannelNoDisplay(value.ChannelNo)); | |||||
value.BeginTime = reader.ReadDateTime6(); | |||||
writer.WriteString($"[{value.BeginTime.ToString("yyMMddHHmmss")}]起始时间", value.BeginTime.ToString("yyyy-MM-dd HH:mm:ss")); | |||||
value.EndTime = reader.ReadDateTime6(); | |||||
writer.WriteString($"[{value.EndTime.ToString("yyMMddHHmmss")}]起始时间", value.EndTime.ToString("yyyy-MM-dd HH:mm:ss")); | |||||
value.AlarmFlag = reader.ReadUInt64(); | |||||
writer.WriteNumber($"[{value.AlarmFlag.ReadNumber()}]报警标志", value.AlarmFlag); | |||||
value.MediaType = reader.ReadByte(); | |||||
writer.WriteString($"[{value.MediaType.ReadNumber()}]音视频类型", AVResourceTypeDisplay(value.MediaType)); | |||||
value.StreamType = reader.ReadByte(); | |||||
writer.WriteString($"[{value.StreamType.ReadNumber()}]码流类型", StreamTypeDisplay(value.StreamType)); | |||||
value.MemoryType = reader.ReadByte(); | |||||
writer.WriteString($"[{value.MemoryType.ReadNumber()}]存储器类型", MemoryTypeDisplay(value.MemoryType)); | |||||
static string AVResourceTypeDisplay(byte AVResourceType) | |||||
{ | |||||
return AVResourceType switch | |||||
{ | |||||
0 => "音视频", | |||||
1 => "音频", | |||||
2 => "视频", | |||||
3 => "音频或视频", | |||||
_ => "未知", | |||||
}; | |||||
} | |||||
static string StreamTypeDisplay(byte StreamType) | |||||
{ | |||||
return StreamType switch | |||||
{ | |||||
0 => "所有码流", | |||||
1 => "主码流", | |||||
2 => "子码流", | |||||
_ => "未知", | |||||
}; | |||||
} | |||||
static string MemoryTypeDisplay(byte MemType) | |||||
{ | |||||
return MemType switch | |||||
{ | |||||
0 => "所有存储器", | |||||
1 => "主存储器", | |||||
2 => "灾备服务器", | |||||
_ => "未知", | |||||
}; | |||||
} | |||||
static string LogicalChannelNoDisplay(byte LogicalChannelNo) | |||||
{ | |||||
return LogicalChannelNo switch | |||||
{ | |||||
1 => "驾驶员", | |||||
2 => "车辆正前方", | |||||
3 => "车前门", | |||||
4 => "车厢前部", | |||||
5 => "车厢后部", | |||||
7 => "行李舱", | |||||
8 => "车辆左侧", | |||||
9 => "车辆右侧", | |||||
10 => "车辆正后方", | |||||
11 => "车厢中部", | |||||
12 => "车中门", | |||||
13 => "驾驶席车门", | |||||
33 => "驾驶员", | |||||
36 => "车厢前部", | |||||
37 => "车厢后部", | |||||
_ => "预留", | |||||
}; | |||||
} | |||||
} | |||||
public JT808_0x9205 Deserialize(ref JT808MessagePackReader reader, IJT808Config config) | |||||
{ | |||||
var jT808_0x9205 = new JT808_0x9205(); | |||||
jT808_0x9205.ChannelNo = reader.ReadByte(); | |||||
jT808_0x9205.BeginTime = reader.ReadDateTime6(); | |||||
jT808_0x9205.EndTime = reader.ReadDateTime6(); | |||||
jT808_0x9205.AlarmFlag = reader.ReadUInt64(); | |||||
jT808_0x9205.MediaType = 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.ChannelNo); | |||||
writer.WriteDateTime6(value.BeginTime); | |||||
writer.WriteDateTime6(value.EndTime); | |||||
writer.WriteUInt64(value.AlarmFlag); | |||||
writer.WriteByte(value.MediaType); | |||||
writer.WriteByte(value.StreamType); | |||||
writer.WriteByte(value.MemoryType); | |||||
} | |||||
#pragma warning restore CS1591 // 缺少对公共可见类型或成员的 XML 注释 | |||||
} | |||||
} |
@@ -0,0 +1,244 @@ | |||||
using JT808.Protocol.Formatters; | |||||
using JT808.Protocol.Interfaces; | |||||
using JT808.Protocol.MessagePack; | |||||
using System; | |||||
using System.Collections.Generic; | |||||
using System.Text; | |||||
using System.Text.Json; | |||||
namespace JT808.Protocol.Extensions.JT1078.MessageBody | |||||
{ | |||||
/// <summary> | |||||
/// 文件上传指令 | |||||
/// </summary> | |||||
public class JT808_0x9206 : JT808Bodies, IJT808MessagePackFormatter<JT808_0x9206>, IJT808Analyze | |||||
{ | |||||
#pragma warning disable CS1591 // 缺少对公共可见类型或成员的 XML 注释 | |||||
public override string Description => "文件上传指令"; | |||||
public override ushort MsgId => 0x9206; | |||||
#pragma warning restore CS1591 // 缺少对公共可见类型或成员的 XML 注释 | |||||
/// <summary> | |||||
/// 服务器IP地址服务 | |||||
/// </summary> | |||||
public byte ServerIpLength { get; set; } | |||||
/// <summary> | |||||
/// 服务器IP地址 | |||||
/// </summary> | |||||
public string ServerIp { get; set; } | |||||
/// <summary> | |||||
/// 服务器端口 | |||||
/// </summary> | |||||
public ushort Port { get; set; } | |||||
/// <summary> | |||||
/// 用户名长度 | |||||
/// </summary> | |||||
public byte UserNameLength { get; set; } | |||||
/// <summary> | |||||
/// 用户名 | |||||
/// </summary> | |||||
public string UserName { get; set; } | |||||
/// <summary> | |||||
/// 密码长度 | |||||
/// </summary> | |||||
public byte PasswordLength { get; set; } | |||||
/// <summary> | |||||
/// 密码 | |||||
/// </summary> | |||||
public string Password { get; set; } | |||||
/// <summary> | |||||
/// 文件上传路径长度 | |||||
/// </summary> | |||||
public byte FileUploadPathLength { get; set; } | |||||
/// <summary> | |||||
/// 文件上传路径 | |||||
/// </summary> | |||||
public string FileUploadPath { get; set; } | |||||
/// <summary> | |||||
/// 逻辑通道号 | |||||
/// </summary> | |||||
public byte ChannelNo { 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 MediaType { get; set; } | |||||
/// <summary> | |||||
/// 码流类型 | |||||
/// </summary> | |||||
public byte StreamType { get; set; } | |||||
/// <summary> | |||||
/// 存储位置 | |||||
/// </summary> | |||||
public byte MemoryPositon { get; set; } | |||||
/// <summary> | |||||
/// 任务执行条件 | |||||
/// </summary> | |||||
public byte TaskExcuteCondition { get; set; } | |||||
#pragma warning disable CS1591 // 缺少对公共可见类型或成员的 XML 注释 | |||||
public void Analyze(ref JT808MessagePackReader reader, Utf8JsonWriter writer, IJT808Config config) | |||||
{ | |||||
JT808_0x9206 value = new JT808_0x9206(); | |||||
value.ServerIpLength = reader.ReadByte(); | |||||
writer.WriteNumber($"[{value.ServerIpLength.ReadNumber()}]服务器IP地址长度", value.ServerIpLength); | |||||
string ipHex = reader.ReadVirtualArray(value.ServerIpLength).ToArray().ToHexString(); | |||||
value.ServerIp = reader.ReadString(value.ServerIpLength); | |||||
writer.WriteString($"[{ipHex}]服务器IP地址", value.ServerIp); | |||||
value.Port = reader.ReadUInt16(); | |||||
writer.WriteNumber($"[{value.Port.ReadNumber()}]服务器端口", value.Port); | |||||
value.UserNameLength = reader.ReadByte(); | |||||
writer.WriteNumber($"[{value.UserNameLength.ReadNumber()}]用户名长度", value.UserNameLength); | |||||
string userNameHex = reader.ReadVirtualArray(value.UserNameLength).ToArray().ToHexString(); | |||||
value.UserName = reader.ReadString(value.UserNameLength); | |||||
writer.WriteString($"[{userNameHex}]用户名", value.UserName); | |||||
value.PasswordLength = reader.ReadByte(); | |||||
writer.WriteNumber($"[{value.PasswordLength.ReadNumber()}]密码长度", value.PasswordLength); | |||||
string passwordHex = reader.ReadVirtualArray(value.PasswordLength).ToArray().ToHexString(); | |||||
value.Password = reader.ReadString(value.PasswordLength); | |||||
writer.WriteString($"[{passwordHex}]密码", value.Password); | |||||
value.FileUploadPathLength = reader.ReadByte(); | |||||
writer.WriteNumber($"[{value.FileUploadPathLength.ReadNumber()}]文件上传路径长度", value.FileUploadPathLength); | |||||
string fileUploadPathHex = reader.ReadVirtualArray(value.FileUploadPathLength).ToArray().ToHexString(); | |||||
value.FileUploadPath = reader.ReadString(value.FileUploadPathLength); | |||||
writer.WriteString($"[{fileUploadPathHex}]文件上传路径", value.FileUploadPath); | |||||
value.ChannelNo = reader.ReadByte(); | |||||
writer.WriteString($"[{value.ChannelNo.ReadNumber()}]逻辑通道号", LogicalChannelNoDisplay(value.ChannelNo)); | |||||
value.BeginTime = reader.ReadDateTime6(); | |||||
writer.WriteString($"[{value.BeginTime.ToString("yyMMddHHmmss")}]起始时间", value.BeginTime.ToString("yyyy-MM-dd HH:mm:ss")); | |||||
value.EndTime = reader.ReadDateTime6(); | |||||
writer.WriteString($"[{value.EndTime.ToString("yyMMddHHmmss")}]起始时间", value.EndTime.ToString("yyyy-MM-dd HH:mm:ss")); | |||||
value.AlarmFlag = reader.ReadUInt32(); | |||||
writer.WriteNumber($"[{value.AlarmFlag.ReadNumber()}]报警标志", value.AlarmFlag); | |||||
value.MediaType = reader.ReadByte(); | |||||
writer.WriteString($"[{value.MediaType.ReadNumber()}]音视频类型", AVResourceTypeDisplay(value.MediaType)); | |||||
value.StreamType = reader.ReadByte(); | |||||
writer.WriteString($"[{value.StreamType.ReadNumber()}]码流类型", StreamTypeDisplay(value.StreamType)); | |||||
value.MemoryPositon = reader.ReadByte(); | |||||
writer.WriteString($"[{value.MemoryPositon.ReadNumber()}]存储器类型", MemoryPositonDisplay(value.MemoryPositon)); | |||||
value.TaskExcuteCondition = reader.ReadByte(); | |||||
writer.WriteString($"[{value.TaskExcuteCondition.ReadNumber()}]任务执行条件", TaskExcuteConditionDisplay(value.TaskExcuteCondition)); | |||||
static string AVResourceTypeDisplay(byte AVResourceType) | |||||
{ | |||||
return AVResourceType switch | |||||
{ | |||||
0 => "音视频", | |||||
1 => "音频", | |||||
2 => "视频", | |||||
3 => "音频或视频", | |||||
_ => "未知", | |||||
}; | |||||
} | |||||
static string StreamTypeDisplay(byte StreamType) | |||||
{ | |||||
return StreamType switch | |||||
{ | |||||
0 => "所有码流", | |||||
1 => "主码流", | |||||
2 => "子码流", | |||||
_ => "未知", | |||||
}; | |||||
} | |||||
static string MemoryPositonDisplay(byte MemoryPositon) | |||||
{ | |||||
return MemoryPositon switch | |||||
{ | |||||
0 => "主存储器或灾备服务器", | |||||
1 => "主存储器", | |||||
2 => "灾备服务器", | |||||
_ => "未知", | |||||
}; | |||||
} | |||||
static string LogicalChannelNoDisplay(byte LogicalChannelNo) | |||||
{ | |||||
return LogicalChannelNo switch | |||||
{ | |||||
1 => "驾驶员", | |||||
2 => "车辆正前方", | |||||
3 => "车前门", | |||||
4 => "车厢前部", | |||||
5 => "车厢后部", | |||||
7 => "行李舱", | |||||
8 => "车辆左侧", | |||||
9 => "车辆右侧", | |||||
10 => "车辆正后方", | |||||
11 => "车厢中部", | |||||
12 => "车中门", | |||||
13 => "驾驶席车门", | |||||
33 => "驾驶员", | |||||
36 => "车厢前部", | |||||
37 => "车厢后部", | |||||
_ => "预留", | |||||
}; | |||||
} | |||||
static string TaskExcuteConditionDisplay(byte TaskExcuteCondition) { | |||||
var taskExcuteConditionDisplay = string.Empty; | |||||
taskExcuteConditionDisplay += (TaskExcuteCondition & 0x01) == 1 ? ",WIFI":""; | |||||
taskExcuteConditionDisplay += (TaskExcuteCondition & 0x01) == 1 ? ",LAN" : ""; | |||||
taskExcuteConditionDisplay += (TaskExcuteCondition & 0x01) == 1 ? ",3G/4G" : ""; | |||||
return taskExcuteConditionDisplay.Length > 0 ? taskExcuteConditionDisplay.Substring(1) : ""; | |||||
} | |||||
} | |||||
public JT808_0x9206 Deserialize(ref JT808MessagePackReader reader, IJT808Config config) | |||||
{ | |||||
var 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.ChannelNo = reader.ReadByte(); | |||||
jT808_0x9206.BeginTime = reader.ReadDateTime6(); | |||||
jT808_0x9206.EndTime = reader.ReadDateTime6(); | |||||
jT808_0x9206.AlarmFlag = reader.ReadUInt32(); | |||||
jT808_0x9206.MediaType = 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.ChannelNo); | |||||
writer.WriteDateTime6(value.BeginTime); | |||||
writer.WriteDateTime6(value.EndTime); | |||||
writer.WriteUInt32(value.AlarmFlag); | |||||
writer.WriteByte(value.MediaType); | |||||
writer.WriteByte(value.StreamType); | |||||
writer.WriteByte(value.MemoryPositon); | |||||
writer.WriteByte(value.TaskExcuteCondition); | |||||
} | |||||
#pragma warning restore CS1591 // 缺少对公共可见类型或成员的 XML 注释 | |||||
} | |||||
} |
@@ -0,0 +1,63 @@ | |||||
using JT808.Protocol.Formatters; | |||||
using JT808.Protocol.Interfaces; | |||||
using JT808.Protocol.MessagePack; | |||||
using System; | |||||
using System.Collections.Generic; | |||||
using System.Text; | |||||
using System.Text.Json; | |||||
namespace JT808.Protocol.Extensions.JT1078.MessageBody | |||||
{ | |||||
/// <summary> | |||||
/// 文件上传控制 | |||||
/// </summary> | |||||
public class JT808_0x9207 : JT808Bodies, IJT808MessagePackFormatter<JT808_0x9207>, IJT808Analyze | |||||
{ | |||||
#pragma warning disable CS1591 // 缺少对公共可见类型或成员的 XML 注释 | |||||
public override string Description => "文件上传控制"; | |||||
public override ushort MsgId => 0x9207; | |||||
#pragma warning restore CS1591 // 缺少对公共可见类型或成员的 XML 注释 | |||||
/// <summary> | |||||
/// 流水号 | |||||
/// </summary> | |||||
public ushort MgsNum { get; set; } | |||||
/// <summary> | |||||
/// 上传控制 | |||||
/// </summary> | |||||
public byte UploadControl { get; set; } | |||||
#pragma warning disable CS1591 // 缺少对公共可见类型或成员的 XML 注释 | |||||
public void Analyze(ref JT808MessagePackReader reader, Utf8JsonWriter writer, IJT808Config config) | |||||
{ | |||||
JT808_0x9207 value = new JT808_0x9207(); | |||||
value.MgsNum = reader.ReadUInt16(); | |||||
writer.WriteNumber($"[{value.MgsNum.ReadNumber()}]流水号", value.MgsNum); | |||||
value.UploadControl = reader.ReadByte(); | |||||
writer.WriteString($"[{value.UploadControl.ReadNumber()}]上传控制", UploadControlDisplay(value.UploadControl)); | |||||
static string UploadControlDisplay(byte UploadControl) { | |||||
return UploadControl switch | |||||
{ | |||||
0 => "暂停", | |||||
1 => "继续", | |||||
2 => "取消", | |||||
_ => "未知", | |||||
}; | |||||
} | |||||
} | |||||
public JT808_0x9207 Deserialize(ref JT808MessagePackReader reader, IJT808Config config) | |||||
{ | |||||
var 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); | |||||
} | |||||
#pragma warning restore CS1591 // 缺少对公共可见类型或成员的 XML 注释 | |||||
} | |||||
} |
@@ -0,0 +1,100 @@ | |||||
using JT808.Protocol.Formatters; | |||||
using JT808.Protocol.Interfaces; | |||||
using JT808.Protocol.MessagePack; | |||||
using System; | |||||
using System.Collections.Generic; | |||||
using System.Text; | |||||
using System.Text.Json; | |||||
namespace JT808.Protocol.Extensions.JT1078.MessageBody | |||||
{ | |||||
/// <summary> | |||||
/// 云台旋转 | |||||
/// </summary> | |||||
public class JT808_0x9301 : JT808Bodies, IJT808MessagePackFormatter<JT808_0x9301>, IJT808Analyze | |||||
{ | |||||
#pragma warning disable CS1591 // 缺少对公共可见类型或成员的 XML 注释 | |||||
public override string Description => "云台旋转"; | |||||
public override ushort MsgId => 0x9301; | |||||
#pragma warning restore CS1591 // 缺少对公共可见类型或成员的 XML 注释 | |||||
/// <summary> | |||||
/// 逻辑通道号 | |||||
/// </summary> | |||||
public byte ChannelNo { get; set; } | |||||
/// <summary> | |||||
/// 方向 | |||||
/// 0:停止 | |||||
/// 1:上 | |||||
/// 2:下 | |||||
/// 3:左 | |||||
/// 4:右 | |||||
/// </summary> | |||||
public byte Direction { get; set; } | |||||
/// <summary> | |||||
/// 速度 | |||||
/// 0-255 | |||||
/// </summary> | |||||
public byte Speed { get; set; } | |||||
#pragma warning disable CS1591 // 缺少对公共可见类型或成员的 XML 注释 | |||||
public void Analyze(ref JT808MessagePackReader reader, Utf8JsonWriter writer, IJT808Config config) | |||||
{ | |||||
JT808_0x9301 value = new JT808_0x9301(); | |||||
value.ChannelNo = reader.ReadByte(); | |||||
writer.WriteString($"[{value.ChannelNo.ReadNumber()}]逻辑通道号", LogicalChannelNoDisplay(value.ChannelNo)); | |||||
value.Direction = reader.ReadByte(); | |||||
writer.WriteString($"[{value.Direction.ReadNumber()}]方向", DirectionDisplay(value.Direction)); | |||||
value.Speed = reader.ReadByte(); | |||||
writer.WriteNumber($"[{value.Speed.ReadNumber()}]速度", value.Speed); | |||||
static string LogicalChannelNoDisplay(byte LogicalChannelNo) | |||||
{ | |||||
return LogicalChannelNo switch | |||||
{ | |||||
1 => "驾驶员", | |||||
2 => "车辆正前方", | |||||
3 => "车前门", | |||||
4 => "车厢前部", | |||||
5 => "车厢后部", | |||||
7 => "行李舱", | |||||
8 => "车辆左侧", | |||||
9 => "车辆右侧", | |||||
10 => "车辆正后方", | |||||
11 => "车厢中部", | |||||
12 => "车中门", | |||||
13 => "驾驶席车门", | |||||
33 => "驾驶员", | |||||
36 => "车厢前部", | |||||
37 => "车厢后部", | |||||
_ => "预留", | |||||
}; | |||||
} | |||||
static string DirectionDisplay(byte Direction) { | |||||
return Direction switch | |||||
{ | |||||
0 => "停止", | |||||
1 => "上", | |||||
2 => "下", | |||||
3 => "左", | |||||
4 => "右", | |||||
_ => "未知", | |||||
}; | |||||
} | |||||
} | |||||
public JT808_0x9301 Deserialize(ref JT808MessagePackReader reader, IJT808Config config) | |||||
{ | |||||
var jT808_0x9301 = new JT808_0x9301(); | |||||
jT808_0x9301.ChannelNo = 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.ChannelNo); | |||||
writer.WriteByte(value.Direction); | |||||
writer.WriteByte(value.Speed); | |||||
} | |||||
#pragma warning restore CS1591 // 缺少对公共可见类型或成员的 XML 注释 | |||||
} | |||||
} |
@@ -0,0 +1,78 @@ | |||||
using JT808.Protocol.Formatters; | |||||
using JT808.Protocol.Interfaces; | |||||
using JT808.Protocol.MessagePack; | |||||
using System; | |||||
using System.Collections.Generic; | |||||
using System.Text; | |||||
using System.Text.Json; | |||||
namespace JT808.Protocol.Extensions.JT1078.MessageBody | |||||
{ | |||||
/// <summary> | |||||
/// 云台调整焦距控制 | |||||
/// </summary> | |||||
public class JT808_0x9302 : JT808Bodies, IJT808MessagePackFormatter<JT808_0x9302>, IJT808Analyze | |||||
{ | |||||
#pragma warning disable CS1591 // 缺少对公共可见类型或成员的 XML 注释 | |||||
public override string Description => "云台调整焦距控制"; | |||||
public override ushort MsgId => 0x9302; | |||||
#pragma warning restore CS1591 // 缺少对公共可见类型或成员的 XML 注释 | |||||
/// <summary> | |||||
/// 逻辑通道号 | |||||
/// </summary> | |||||
public byte LogicChannelNo { get; set; } | |||||
/// <summary> | |||||
/// 焦距调整方向 | |||||
/// </summary> | |||||
public byte FocusAdjustmentDirection { get; set; } | |||||
#pragma warning disable CS1591 // 缺少对公共可见类型或成员的 XML 注释 | |||||
public void Analyze(ref JT808MessagePackReader reader, Utf8JsonWriter writer, IJT808Config config) | |||||
{ | |||||
var value = new JT808_0x9302(); | |||||
value.LogicChannelNo = reader.ReadByte(); | |||||
writer.WriteString($"[{value.LogicChannelNo.ReadNumber()}]逻辑通道号", LogicalChannelNoDisplay(value.LogicChannelNo)); | |||||
value.FocusAdjustmentDirection = reader.ReadByte(); | |||||
writer.WriteString($"[{value.FocusAdjustmentDirection.ReadNumber()}]焦距调整方向", value.FocusAdjustmentDirection==0?"焦距调大":"焦距调小"); | |||||
static string LogicalChannelNoDisplay(byte LogicalChannelNo) | |||||
{ | |||||
return LogicalChannelNo switch | |||||
{ | |||||
1 => "驾驶员", | |||||
2 => "车辆正前方", | |||||
3 => "车前门", | |||||
4 => "车厢前部", | |||||
5 => "车厢后部", | |||||
7 => "行李舱", | |||||
8 => "车辆左侧", | |||||
9 => "车辆右侧", | |||||
10 => "车辆正后方", | |||||
11 => "车厢中部", | |||||
12 => "车中门", | |||||
13 => "驾驶席车门", | |||||
33 => "驾驶员", | |||||
36 => "车厢前部", | |||||
37 => "车厢后部", | |||||
_ => "预留", | |||||
}; | |||||
} | |||||
} | |||||
public JT808_0x9302 Deserialize(ref JT808MessagePackReader reader, IJT808Config config) | |||||
{ | |||||
var 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); | |||||
} | |||||
#pragma warning restore CS1591 // 缺少对公共可见类型或成员的 XML 注释 | |||||
} | |||||
} |
@@ -0,0 +1,76 @@ | |||||
using JT808.Protocol.Formatters; | |||||
using JT808.Protocol.Interfaces; | |||||
using JT808.Protocol.MessagePack; | |||||
using System; | |||||
using System.Collections.Generic; | |||||
using System.Text; | |||||
using System.Text.Json; | |||||
namespace JT808.Protocol.Extensions.JT1078.MessageBody | |||||
{ | |||||
/// <summary> | |||||
/// 云台调整光圈控制 | |||||
/// </summary> | |||||
public class JT808_0x9303 : JT808Bodies, IJT808MessagePackFormatter<JT808_0x9303>, IJT808Analyze | |||||
{ | |||||
#pragma warning disable CS1591 // 缺少对公共可见类型或成员的 XML 注释 | |||||
public override string Description => "云台调整光圈控制"; | |||||
public override ushort MsgId => 0x9303; | |||||
#pragma warning restore CS1591 // 缺少对公共可见类型或成员的 XML 注释 | |||||
/// <summary> | |||||
/// 逻辑通道号 | |||||
/// </summary> | |||||
public byte ChannelNo { get; set; } | |||||
/// <summary> | |||||
/// 光圈调整方式 | |||||
/// </summary> | |||||
public byte IrisAdjustment { get; set; } | |||||
#pragma warning disable CS1591 // 缺少对公共可见类型或成员的 XML 注释 | |||||
public void Analyze(ref JT808MessagePackReader reader, Utf8JsonWriter writer, IJT808Config config) | |||||
{ | |||||
JT808_0x9303 value = new JT808_0x9303(); | |||||
value.ChannelNo = reader.ReadByte(); | |||||
writer.WriteString($"[{value.ChannelNo.ReadNumber()}]逻辑通道号", LogicalChannelNoDisplay(value.ChannelNo)); | |||||
value.IrisAdjustment = reader.ReadByte(); | |||||
writer.WriteString($"[{value.IrisAdjustment.ReadNumber()}]光圈调整方式", value.IrisAdjustment == 0 ? "调大" : "调小"); | |||||
static string LogicalChannelNoDisplay(byte LogicalChannelNo) | |||||
{ | |||||
return LogicalChannelNo switch | |||||
{ | |||||
1 => "驾驶员", | |||||
2 => "车辆正前方", | |||||
3 => "车前门", | |||||
4 => "车厢前部", | |||||
5 => "车厢后部", | |||||
7 => "行李舱", | |||||
8 => "车辆左侧", | |||||
9 => "车辆右侧", | |||||
10 => "车辆正后方", | |||||
11 => "车厢中部", | |||||
12 => "车中门", | |||||
13 => "驾驶席车门", | |||||
33 => "驾驶员", | |||||
36 => "车厢前部", | |||||
37 => "车厢后部", | |||||
_ => "预留", | |||||
}; | |||||
} | |||||
} | |||||
public JT808_0x9303 Deserialize(ref JT808MessagePackReader reader, IJT808Config config) | |||||
{ | |||||
var jT808_0x9303 = new JT808_0x9303(); | |||||
jT808_0x9303.ChannelNo = reader.ReadByte(); | |||||
jT808_0x9303.IrisAdjustment = reader.ReadByte(); | |||||
return jT808_0x9303; | |||||
} | |||||
public void Serialize(ref JT808MessagePackWriter writer, JT808_0x9303 value, IJT808Config config) | |||||
{ | |||||
writer.WriteByte(value.ChannelNo); | |||||
writer.WriteByte(value.IrisAdjustment); | |||||
} | |||||
#pragma warning restore CS1591 // 缺少对公共可见类型或成员的 XML 注释 | |||||
} | |||||
} |
@@ -0,0 +1,75 @@ | |||||
using JT808.Protocol.Formatters; | |||||
using JT808.Protocol.Interfaces; | |||||
using JT808.Protocol.MessagePack; | |||||
using System; | |||||
using System.Collections.Generic; | |||||
using System.Text; | |||||
using System.Text.Json; | |||||
namespace JT808.Protocol.Extensions.JT1078.MessageBody | |||||
{ | |||||
/// <summary> | |||||
/// 云台雨刷控制 | |||||
/// </summary> | |||||
public class JT808_0x9304 : JT808Bodies, IJT808MessagePackFormatter<JT808_0x9304>, IJT808Analyze | |||||
{ | |||||
#pragma warning disable CS1591 // 缺少对公共可见类型或成员的 XML 注释 | |||||
public override string Description => "云台雨刷控制"; | |||||
public override ushort MsgId => 0x9304; | |||||
/// <summary> | |||||
/// 逻辑通道号 | |||||
/// </summary> | |||||
public byte ChannelNo { get; set; } | |||||
/// <summary> | |||||
/// 启停标识 | |||||
/// </summary> | |||||
public byte StartOrStop { get; set; } | |||||
public void Analyze(ref JT808MessagePackReader reader, Utf8JsonWriter writer, IJT808Config config) | |||||
{ | |||||
JT808_0x9304 value = new JT808_0x9304(); | |||||
value.ChannelNo = reader.ReadByte(); | |||||
writer.WriteString($"[{value.ChannelNo.ReadNumber()}]逻辑通道号", LogicalChannelNoDisplay(value.ChannelNo)); | |||||
value.StartOrStop = reader.ReadByte(); | |||||
writer.WriteString($"[{value.StartOrStop.ReadNumber()}]启停标识", value.StartOrStop == 0 ? "停止" : "启动"); | |||||
static string LogicalChannelNoDisplay(byte LogicalChannelNo) | |||||
{ | |||||
return LogicalChannelNo switch | |||||
{ | |||||
1 => "驾驶员", | |||||
2 => "车辆正前方", | |||||
3 => "车前门", | |||||
4 => "车厢前部", | |||||
5 => "车厢后部", | |||||
7 => "行李舱", | |||||
8 => "车辆左侧", | |||||
9 => "车辆右侧", | |||||
10 => "车辆正后方", | |||||
11 => "车厢中部", | |||||
12 => "车中门", | |||||
13 => "驾驶席车门", | |||||
33 => "驾驶员", | |||||
36 => "车厢前部", | |||||
37 => "车厢后部", | |||||
_ => "预留", | |||||
}; | |||||
} | |||||
} | |||||
public JT808_0x9304 Deserialize(ref JT808MessagePackReader reader, IJT808Config config) | |||||
{ | |||||
var jT808_0x9304 = new JT808_0x9304(); | |||||
jT808_0x9304.ChannelNo = reader.ReadByte(); | |||||
jT808_0x9304.StartOrStop = reader.ReadByte(); | |||||
return jT808_0x9304; | |||||
} | |||||
public void Serialize(ref JT808MessagePackWriter writer, JT808_0x9304 value, IJT808Config config) | |||||
{ | |||||
writer.WriteByte(value.ChannelNo); | |||||
writer.WriteByte(value.StartOrStop); | |||||
} | |||||
#pragma warning restore CS1591 // 缺少对公共可见类型或成员的 XML 注释 | |||||
} | |||||
} |
@@ -0,0 +1,75 @@ | |||||
using JT808.Protocol.Formatters; | |||||
using JT808.Protocol.Interfaces; | |||||
using JT808.Protocol.MessagePack; | |||||
using System; | |||||
using System.Collections.Generic; | |||||
using System.Text; | |||||
using System.Text.Json; | |||||
namespace JT808.Protocol.Extensions.JT1078.MessageBody | |||||
{ | |||||
/// <summary> | |||||
/// 红外补光控制 | |||||
/// </summary> | |||||
public class JT808_0x9305 : JT808Bodies, IJT808MessagePackFormatter<JT808_0x9305>, IJT808Analyze | |||||
{ | |||||
#pragma warning disable CS1591 // 缺少对公共可见类型或成员的 XML 注释 | |||||
public override string Description => "红外补光控制"; | |||||
public override ushort MsgId => 0x9305; | |||||
/// <summary> | |||||
/// 逻辑通道号 | |||||
/// </summary> | |||||
public byte ChannelNo { get; set; } | |||||
/// <summary> | |||||
/// 启停标识 | |||||
/// </summary> | |||||
public byte StartOrStop { get; set; } | |||||
public void Analyze(ref JT808MessagePackReader reader, Utf8JsonWriter writer, IJT808Config config) | |||||
{ | |||||
JT808_0x9305 value = new JT808_0x9305(); | |||||
value.ChannelNo = reader.ReadByte(); | |||||
writer.WriteString($"[{value.ChannelNo.ReadNumber()}]逻辑通道号", LogicalChannelNoDisplay(value.ChannelNo)); | |||||
value.StartOrStop = reader.ReadByte(); | |||||
writer.WriteString($"[{value.StartOrStop.ReadNumber()}]启停标识", value.StartOrStop == 0 ? "停止" : "启动"); | |||||
static string LogicalChannelNoDisplay(byte LogicalChannelNo) | |||||
{ | |||||
return LogicalChannelNo switch | |||||
{ | |||||
1 => "驾驶员", | |||||
2 => "车辆正前方", | |||||
3 => "车前门", | |||||
4 => "车厢前部", | |||||
5 => "车厢后部", | |||||
7 => "行李舱", | |||||
8 => "车辆左侧", | |||||
9 => "车辆右侧", | |||||
10 => "车辆正后方", | |||||
11 => "车厢中部", | |||||
12 => "车中门", | |||||
13 => "驾驶席车门", | |||||
33 => "驾驶员", | |||||
36 => "车厢前部", | |||||
37 => "车厢后部", | |||||
_ => "预留", | |||||
}; | |||||
} | |||||
} | |||||
public JT808_0x9305 Deserialize(ref JT808MessagePackReader reader, IJT808Config config) | |||||
{ | |||||
var jT808_0x9305 = new JT808_0x9305(); | |||||
jT808_0x9305.ChannelNo = reader.ReadByte(); | |||||
jT808_0x9305.StartOrStop = reader.ReadByte(); | |||||
return jT808_0x9305; | |||||
} | |||||
public void Serialize(ref JT808MessagePackWriter writer, JT808_0x9305 value, IJT808Config config) | |||||
{ | |||||
writer.WriteByte(value.ChannelNo); | |||||
writer.WriteByte(value.StartOrStop); | |||||
} | |||||
#pragma warning restore CS1591 // 缺少对公共可见类型或成员的 XML 注释 | |||||
} | |||||
} |
@@ -0,0 +1,76 @@ | |||||
using JT808.Protocol.Formatters; | |||||
using JT808.Protocol.Interfaces; | |||||
using JT808.Protocol.MessagePack; | |||||
using System; | |||||
using System.Collections.Generic; | |||||
using System.Text; | |||||
using System.Text.Json; | |||||
namespace JT808.Protocol.Extensions.JT1078.MessageBody | |||||
{ | |||||
/// <summary> | |||||
/// 云台变倍控制 | |||||
/// </summary> | |||||
public class JT808_0x9306 : JT808Bodies, IJT808MessagePackFormatter<JT808_0x9306>, IJT808Analyze | |||||
{ | |||||
#pragma warning disable CS1591 // 缺少对公共可见类型或成员的 XML 注释 | |||||
public override string Description => "云台变倍控制"; | |||||
public override ushort MsgId => 0x9306; | |||||
/// <summary> | |||||
/// 逻辑通道号 | |||||
/// </summary> | |||||
public byte ChannelNo { get; set; } | |||||
/// <summary> | |||||
/// 变倍控制 | |||||
/// </summary> | |||||
public byte ChangeMultipleControl { get; set; } | |||||
public void Analyze(ref JT808MessagePackReader reader, Utf8JsonWriter writer, IJT808Config config) | |||||
{ | |||||
var value = new JT808_0x9306(); | |||||
value.ChannelNo = reader.ReadByte(); | |||||
writer.WriteString($"[{value.ChannelNo.ReadNumber()}]逻辑通道号", LogicalChannelNoDisplay(value.ChannelNo)); | |||||
value.ChangeMultipleControl = reader.ReadByte(); | |||||
writer.WriteString($"[{value.ChangeMultipleControl.ReadNumber()}]变倍控制", value.ChangeMultipleControl == 0 ? "调大" : "调小"); | |||||
static string LogicalChannelNoDisplay(byte LogicalChannelNo) | |||||
{ | |||||
return LogicalChannelNo switch | |||||
{ | |||||
1 => "驾驶员", | |||||
2 => "车辆正前方", | |||||
3 => "车前门", | |||||
4 => "车厢前部", | |||||
5 => "车厢后部", | |||||
7 => "行李舱", | |||||
8 => "车辆左侧", | |||||
9 => "车辆右侧", | |||||
10 => "车辆正后方", | |||||
11 => "车厢中部", | |||||
12 => "车中门", | |||||
13 => "驾驶席车门", | |||||
33 => "驾驶员", | |||||
36 => "车厢前部", | |||||
37 => "车厢后部", | |||||
_ => "预留", | |||||
}; | |||||
} | |||||
} | |||||
public JT808_0x9306 Deserialize(ref JT808MessagePackReader reader, IJT808Config config) | |||||
{ | |||||
var jT808_0x9306 = new JT808_0x9306(); | |||||
jT808_0x9306.ChannelNo = reader.ReadByte(); | |||||
jT808_0x9306.ChangeMultipleControl = reader.ReadByte(); | |||||
return jT808_0x9306; | |||||
} | |||||
public void Serialize(ref JT808MessagePackWriter writer, JT808_0x9306 value, IJT808Config config) | |||||
{ | |||||
writer.WriteByte(value.ChannelNo); | |||||
writer.WriteByte(value.ChangeMultipleControl); | |||||
} | |||||
#pragma warning restore CS1591 // 缺少对公共可见类型或成员的 XML 注释 | |||||
} | |||||
} |
@@ -0,0 +1,30 @@ | |||||
<Project Sdk="Microsoft.NET.Sdk"> | |||||
<PropertyGroup> | |||||
<TargetFramework>net5.0</TargetFramework> | |||||
<IsPackable>false</IsPackable> | |||||
</PropertyGroup> | |||||
<ItemGroup> | |||||
<None Include="..\..\LICENSE" Link="LICENSE"> | |||||
<PackagePath></PackagePath> | |||||
<Pack>True</Pack> | |||||
</None> | |||||
</ItemGroup> | |||||
<ItemGroup> | |||||
<PackageReference Include="Microsoft.Extensions.DependencyInjection" Version="5.0.1" /> | |||||
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.8.3" /> | |||||
<PackageReference Include="xunit" Version="2.4.1" /> | |||||
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.3"> | |||||
<PrivateAssets>all</PrivateAssets> | |||||
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets> | |||||
</PackageReference> | |||||
</ItemGroup> | |||||
<ItemGroup> | |||||
<ProjectReference Include="..\JT808.Protocol.Extensions.JTActiveSafety\JT808.Protocol.Extensions.JTActiveSafety.csproj" /> | |||||
</ItemGroup> | |||||
</Project> |
@@ -0,0 +1,100 @@ | |||||
using JT808.Protocol.Extensions.JTActiveSafety.MessageBody; | |||||
using JT808.Protocol.MessageBody; | |||||
using Microsoft.Extensions.DependencyInjection; | |||||
using System; | |||||
using System.Collections.Generic; | |||||
using System.Text; | |||||
using Xunit; | |||||
namespace JT808.Protocol.Extensions.JTActiveSafety.Test | |||||
{ | |||||
public class JT808_0x0200_0x64_Test | |||||
{ | |||||
JT808Serializer JT808Serializer; | |||||
public JT808_0x0200_0x64_Test() | |||||
{ | |||||
ServiceCollection serviceDescriptors = new ServiceCollection(); | |||||
serviceDescriptors.AddJT808Configure() | |||||
.AddJTActiveSafetyConfigure(); | |||||
IJT808Config jT808Config = serviceDescriptors.BuildServiceProvider().GetRequiredService<IJT808Config>(); | |||||
JT808Serializer = new JT808Serializer(jT808Config); | |||||
} | |||||
[Fact] | |||||
public void Serializer() | |||||
{ | |||||
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, | |||||
JT808LocationAttachData = new Dictionary<byte, JT808_0x0200_BodyBase>() | |||||
}; | |||||
jT808UploadLocationRequest.JT808LocationAttachData.Add(JT808_JTActiveSafety_Constants.JT808_0X0200_0x64, new JT808_0x0200_0x64 | |||||
{ | |||||
AlarmId = 1, | |||||
AlarmIdentification = new Metadata.AlarmIdentificationProperty | |||||
{ | |||||
AttachCount = 2, | |||||
SN = 3, | |||||
TerminalID = "4444444", | |||||
Time = Convert.ToDateTime("2019-12-10 18:31:00") | |||||
}, | |||||
AlarmLevel = 5, | |||||
AlarmOrEventType = 6, | |||||
AlarmTime = Convert.ToDateTime("2019-12-11 18:31:00"), | |||||
Altitude = 7, | |||||
CarOrPedestrianDistanceAhead = 10, | |||||
DeviateType = 11, | |||||
FlagState = 12, | |||||
Latitude = 13, | |||||
Longitude = 14, | |||||
RoadSignIdentificationData = 15, | |||||
RoadSignIdentificationType = 16, | |||||
Speed = 17, | |||||
VehicleSpeed = 18, | |||||
VehicleState = 19 | |||||
}); | |||||
var hex = JT808Serializer.Serialize(jT808UploadLocationRequest).ToHexString(); | |||||
Assert.Equal("000000010000000200BA7F0E07E4F11C0028003C00001807151010106420000000010C0605120A0B100F1100070000000D0000000E191211183100001334343434343434191210183100030200", hex); | |||||
} | |||||
[Fact] | |||||
public void Deserialize() | |||||
{ | |||||
var jT808UploadLocationRequest = JT808Serializer.Deserialize<JT808_0x0200>("000000010000000200BA7F0E07E4F11C0028003C00001807151010106420000000010C0605120A0B100F1100070000000D0000000E191211183100001334343434343434191210183100030200".ToHexBytes()); | |||||
jT808UploadLocationRequest.JT808LocationAttachData.TryGetValue(JT808_JTActiveSafety_Constants.JT808_0X0200_0x64, out var value); | |||||
JT808_0x0200_0x64 jT808_0X0200_0X64 = value as JT808_0x0200_0x64; | |||||
Assert.Equal(1u, jT808_0X0200_0X64.AlarmId); | |||||
Assert.Equal(2, jT808_0X0200_0X64.AlarmIdentification.AttachCount); | |||||
Assert.Equal(3, jT808_0X0200_0X64.AlarmIdentification.SN); | |||||
Assert.Equal("4444444", jT808_0X0200_0X64.AlarmIdentification.TerminalID); | |||||
Assert.Equal(Convert.ToDateTime("2019-12-10 18:31:00"), jT808_0X0200_0X64.AlarmIdentification.Time); | |||||
Assert.Equal(5, jT808_0X0200_0X64.AlarmLevel); | |||||
Assert.Equal(6, jT808_0X0200_0X64.AlarmOrEventType); | |||||
Assert.Equal(Convert.ToDateTime("2019-12-11 18:31:00"), jT808_0X0200_0X64.AlarmTime); | |||||
Assert.Equal(7, jT808_0X0200_0X64.Altitude); | |||||
Assert.Equal(0x64, jT808_0X0200_0X64.AttachInfoId); | |||||
Assert.Equal(32, jT808_0X0200_0X64.AttachInfoLength); | |||||
Assert.Equal(10, jT808_0X0200_0X64.CarOrPedestrianDistanceAhead); | |||||
Assert.Equal(11, jT808_0X0200_0X64.DeviateType); | |||||
Assert.Equal(12, jT808_0X0200_0X64.FlagState); | |||||
Assert.Equal(13, jT808_0X0200_0X64.Latitude); | |||||
Assert.Equal(14, jT808_0X0200_0X64.Longitude); | |||||
Assert.Equal(15, jT808_0X0200_0X64.RoadSignIdentificationData); | |||||
Assert.Equal(16, jT808_0X0200_0X64.RoadSignIdentificationType); | |||||
Assert.Equal(17, jT808_0X0200_0X64.Speed); | |||||
Assert.Equal(18, jT808_0X0200_0X64.VehicleSpeed); | |||||
Assert.Equal(19, jT808_0X0200_0X64.VehicleState); | |||||
} | |||||
[Fact] | |||||
public void Deserialize1() | |||||
{ | |||||
var json = JT808Serializer.Analyze<JT808_0x0200>("000000010000000200BA7F0E07E4F11C0028003C00001807151010106420000000010C0605120A0B100F1100070000000D0000000E191211183100001334343434343434191210183100030200".ToHexBytes()); | |||||
} | |||||
} | |||||
} |
@@ -0,0 +1,94 @@ | |||||
using JT808.Protocol.Extensions.JTActiveSafety.MessageBody; | |||||
using JT808.Protocol.MessageBody; | |||||
using Microsoft.Extensions.DependencyInjection; | |||||
using System; | |||||
using System.Collections.Generic; | |||||
using System.Text; | |||||
using Xunit; | |||||
namespace JT808.Protocol.Extensions.JTActiveSafety.Test | |||||
{ | |||||
public class JT808_0x0200_0x65_Test | |||||
{ | |||||
JT808Serializer JT808Serializer; | |||||
public JT808_0x0200_0x65_Test() | |||||
{ | |||||
ServiceCollection serviceDescriptors = new ServiceCollection(); | |||||
serviceDescriptors.AddJT808Configure() | |||||
.AddJTActiveSafetyConfigure(); | |||||
IJT808Config jT808Config = serviceDescriptors.BuildServiceProvider().GetRequiredService<IJT808Config>(); | |||||
JT808Serializer = new JT808Serializer(jT808Config); | |||||
} | |||||
[Fact] | |||||
public void Serializer() | |||||
{ | |||||
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, | |||||
JT808LocationAttachData = new Dictionary<byte, JT808_0x0200_BodyBase>() | |||||
}; | |||||
jT808UploadLocationRequest.JT808LocationAttachData.Add(JT808_JTActiveSafety_Constants.JT808_0X0200_0x65, new JT808_0x0200_0x65 | |||||
{ | |||||
AlarmId = 1, | |||||
AlarmIdentification = new Metadata.AlarmIdentificationProperty | |||||
{ | |||||
AttachCount = 2, | |||||
SN = 3, | |||||
TerminalID = "4444444", | |||||
Time = Convert.ToDateTime("2019-12-10 18:31:00") | |||||
}, | |||||
AlarmLevel = 5, | |||||
AlarmOrEventType = 6, | |||||
AlarmTime = Convert.ToDateTime("2019-12-11 18:31:00"), | |||||
Altitude = 7, | |||||
Retain=new byte[] { 1, 2, 3, 4 }, | |||||
FlagState = 12, | |||||
Latitude = 13, | |||||
Longitude = 14, | |||||
Speed = 17, | |||||
Fatigue=18, | |||||
VehicleState = 19 | |||||
}); | |||||
var hex = JT808Serializer.Serialize(jT808UploadLocationRequest).ToHexString(); | |||||
Assert.Equal("000000010000000200BA7F0E07E4F11C0028003C0000180715101010652F000000010C060512010203041100070000000D0000000E191211183100001334343434343434191210183100030200", hex); | |||||
} | |||||
[Fact] | |||||
public void Deserialize() | |||||
{ | |||||
var jT808UploadLocationRequest = JT808Serializer.Deserialize<JT808_0x0200>("000000010000000200BA7F0E07E4F11C0028003C00001807151010106520000000010C060512010203041100070000000D0000000E191211183100001334343434343434191210183100030200".ToHexBytes()); | |||||
jT808UploadLocationRequest.JT808LocationAttachData.TryGetValue(JT808_JTActiveSafety_Constants.JT808_0X0200_0x65, out var value); | |||||
JT808_0x0200_0x65 jT808_0X0200_0X65 = value as JT808_0x0200_0x65; | |||||
Assert.Equal(1u, jT808_0X0200_0X65.AlarmId); | |||||
Assert.Equal(2, jT808_0X0200_0X65.AlarmIdentification.AttachCount); | |||||
Assert.Equal(3, jT808_0X0200_0X65.AlarmIdentification.SN); | |||||
Assert.Equal("4444444", jT808_0X0200_0X65.AlarmIdentification.TerminalID); | |||||
Assert.Equal(Convert.ToDateTime("2019-12-10 18:31:00"), jT808_0X0200_0X65.AlarmIdentification.Time); | |||||
Assert.Equal(5, jT808_0X0200_0X65.AlarmLevel); | |||||
Assert.Equal(6, jT808_0X0200_0X65.AlarmOrEventType); | |||||
Assert.Equal(Convert.ToDateTime("2019-12-11 18:31:00"), jT808_0X0200_0X65.AlarmTime); | |||||
Assert.Equal(7, jT808_0X0200_0X65.Altitude); | |||||
Assert.Equal(0x65, jT808_0X0200_0X65.AttachInfoId); | |||||
Assert.Equal(32, jT808_0X0200_0X65.AttachInfoLength); | |||||
Assert.Equal(new byte[] { 1, 2, 3, 4 }.ToHexString(), jT808_0X0200_0X65.Retain.ToHexString()); | |||||
Assert.Equal(12, jT808_0X0200_0X65.FlagState); | |||||
Assert.Equal(13, jT808_0X0200_0X65.Latitude); | |||||
Assert.Equal(14, jT808_0X0200_0X65.Longitude); | |||||
Assert.Equal(17, jT808_0X0200_0X65.Speed); | |||||
Assert.Equal(18, jT808_0X0200_0X65.Fatigue); | |||||
Assert.Equal(19, jT808_0X0200_0X65.VehicleState); | |||||
} | |||||
[Fact] | |||||
public void Json() | |||||
{ | |||||
var json = JT808Serializer.Analyze<JT808_0x0200>("000000010000000200BA7F0E07E4F11C0028003C00001807151010106520000000010C060512010203041100070000000D0000000E191211183100001334343434343434191210183100030200".ToHexBytes()); | |||||
} | |||||
} | |||||
} |
@@ -0,0 +1,114 @@ | |||||
using JT808.Protocol.Extensions.JTActiveSafety.MessageBody; | |||||
using JT808.Protocol.MessageBody; | |||||
using Microsoft.Extensions.DependencyInjection; | |||||
using System; | |||||
using System.Collections.Generic; | |||||
using System.Text; | |||||
using Xunit; | |||||
namespace JT808.Protocol.Extensions.JTActiveSafety.Test | |||||
{ | |||||
public class JT808_0x0200_0x66_Test | |||||
{ | |||||
JT808Serializer JT808Serializer; | |||||
public JT808_0x0200_0x66_Test() | |||||
{ | |||||
ServiceCollection serviceDescriptors = new ServiceCollection(); | |||||
serviceDescriptors.AddJT808Configure() | |||||
.AddJTActiveSafetyConfigure(); | |||||
IJT808Config jT808Config = serviceDescriptors.BuildServiceProvider().GetRequiredService<IJT808Config>(); | |||||
JT808Serializer = new JT808Serializer(jT808Config); | |||||
} | |||||
[Fact] | |||||
public void Serializer() | |||||
{ | |||||
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, | |||||
JT808LocationAttachData = new Dictionary<byte, JT808_0x0200_BodyBase>() | |||||
}; | |||||
jT808UploadLocationRequest.JT808LocationAttachData.Add(JT808_JTActiveSafety_Constants.JT808_0X0200_0x66, new JT808_0x0200_0x66 | |||||
{ | |||||
AlarmId = 1, | |||||
AlarmIdentification = new Metadata.AlarmIdentificationProperty | |||||
{ | |||||
AttachCount = 2, | |||||
SN = 3, | |||||
TerminalID = "4444444", | |||||
Time = Convert.ToDateTime("2019-12-10 18:31:00") | |||||
}, | |||||
AlarmTime = Convert.ToDateTime("2019-12-11 18:31:00"), | |||||
Altitude = 7, | |||||
AlarmOrEventCount = 2, | |||||
AlarmOrEvents = new List<Metadata.AlarmOrEventProperty> { | |||||
new Metadata.AlarmOrEventProperty{ | |||||
AlarmOrEventType=1, | |||||
BatteryLevel=2, | |||||
TirePressure=3, | |||||
TirePressureAlarmPosition=4, | |||||
TireTemperature=5 | |||||
}, | |||||
new Metadata.AlarmOrEventProperty{ | |||||
AlarmOrEventType=6, | |||||
BatteryLevel=7, | |||||
TirePressure=8, | |||||
TirePressureAlarmPosition=9, | |||||
TireTemperature=10 | |||||
} | |||||
}, | |||||
FlagState = 12, | |||||
Latitude = 13, | |||||
Longitude = 14, | |||||
Speed = 17, | |||||
VehicleState = 19 | |||||
}); | |||||
var hex = JT808Serializer.Serialize(jT808UploadLocationRequest).ToHexString(); | |||||
Assert.Equal("000000010000000200BA7F0E07E4F11C0028003C0000180715101010663B000000010C1100070000000D0000000E191211183100001334343434343434191210183100030200020400010003000500020900060008000A0007", hex); | |||||
} | |||||
[Fact] | |||||
public void Deserialize() | |||||
{ | |||||
var jT808UploadLocationRequest = JT808Serializer.Deserialize<JT808_0x0200>("000000010000000200BA7F0E07E4F11C0028003C0000180715101010663B000000010C1100070000000D0000000E191211183100001334343434343434191210183100030200020400010003000500020900060008000A0007".ToHexBytes()); | |||||
jT808UploadLocationRequest.JT808LocationAttachData.TryGetValue(JT808_JTActiveSafety_Constants.JT808_0X0200_0x66, out var value); | |||||
JT808_0x0200_0x66 jT808_0X0200_0X66 = value as JT808_0x0200_0x66; | |||||
Assert.Equal(1u, jT808_0X0200_0X66.AlarmId); | |||||
Assert.Equal(2, jT808_0X0200_0X66.AlarmIdentification.AttachCount); | |||||
Assert.Equal(3, jT808_0X0200_0X66.AlarmIdentification.SN); | |||||
Assert.Equal("4444444", jT808_0X0200_0X66.AlarmIdentification.TerminalID); | |||||
Assert.Equal(Convert.ToDateTime("2019-12-10 18:31:00"), jT808_0X0200_0X66.AlarmIdentification.Time); | |||||
Assert.Equal(Convert.ToDateTime("2019-12-11 18:31:00"), jT808_0X0200_0X66.AlarmTime); | |||||
Assert.Equal(7, jT808_0X0200_0X66.Altitude); | |||||
Assert.Equal(2, jT808_0X0200_0X66.AlarmOrEventCount); | |||||
Assert.Equal(1, jT808_0X0200_0X66.AlarmOrEvents[0].AlarmOrEventType); | |||||
Assert.Equal(2, jT808_0X0200_0X66.AlarmOrEvents[0].BatteryLevel); | |||||
Assert.Equal(3, jT808_0X0200_0X66.AlarmOrEvents[0].TirePressure); | |||||
Assert.Equal(4, jT808_0X0200_0X66.AlarmOrEvents[0].TirePressureAlarmPosition); | |||||
Assert.Equal(5, jT808_0X0200_0X66.AlarmOrEvents[0].TireTemperature); | |||||
Assert.Equal(6, jT808_0X0200_0X66.AlarmOrEvents[1].AlarmOrEventType); | |||||
Assert.Equal(7, jT808_0X0200_0X66.AlarmOrEvents[1].BatteryLevel); | |||||
Assert.Equal(8, jT808_0X0200_0X66.AlarmOrEvents[1].TirePressure); | |||||
Assert.Equal(9, jT808_0X0200_0X66.AlarmOrEvents[1].TirePressureAlarmPosition); | |||||
Assert.Equal(10, jT808_0X0200_0X66.AlarmOrEvents[1].TireTemperature); | |||||
Assert.Equal(0x66, jT808_0X0200_0X66.AttachInfoId); | |||||
Assert.Equal(12, jT808_0X0200_0X66.FlagState); | |||||
Assert.Equal(13, jT808_0X0200_0X66.Latitude); | |||||
Assert.Equal(14, jT808_0X0200_0X66.Longitude); | |||||
Assert.Equal(17, jT808_0X0200_0X66.Speed); | |||||
Assert.Equal(19, jT808_0X0200_0X66.VehicleState); | |||||
} | |||||
[Fact] | |||||
public void Json() | |||||
{ | |||||
var json = JT808Serializer.Analyze<JT808_0x0200>("000000010000000200BA7F0E07E4F11C0028003C0000180715101010663B000000010C1100070000000D0000000E191211183100001334343434343434191210183100030200020400010003000500020900060008000A0007".ToHexBytes()); | |||||
} | |||||
} | |||||
} |
@@ -0,0 +1,89 @@ | |||||
using JT808.Protocol.Extensions.JTActiveSafety.MessageBody; | |||||
using JT808.Protocol.MessageBody; | |||||
using Microsoft.Extensions.DependencyInjection; | |||||
using System; | |||||
using System.Collections.Generic; | |||||
using System.Text; | |||||
using Xunit; | |||||
namespace JT808.Protocol.Extensions.JTActiveSafety.Test | |||||
{ | |||||
public class JT808_0x0200_0x67_Test | |||||
{ | |||||
JT808Serializer JT808Serializer; | |||||
public JT808_0x0200_0x67_Test() | |||||
{ | |||||
ServiceCollection serviceDescriptors = new ServiceCollection(); | |||||
serviceDescriptors.AddJT808Configure() | |||||
.AddJTActiveSafetyConfigure(); | |||||
IJT808Config jT808Config = serviceDescriptors.BuildServiceProvider().GetRequiredService<IJT808Config>(); | |||||
JT808Serializer = new JT808Serializer(jT808Config); | |||||
} | |||||
[Fact] | |||||
public void Serializer() | |||||
{ | |||||
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, | |||||
JT808LocationAttachData = new Dictionary<byte, JT808_0x0200_BodyBase>() | |||||
}; | |||||
jT808UploadLocationRequest.JT808LocationAttachData.Add(JT808_JTActiveSafety_Constants.JT808_0X0200_0x67, new JT808_0x0200_0x67 | |||||
{ | |||||
AlarmId = 1, | |||||
AlarmIdentification = new Metadata.AlarmIdentificationProperty | |||||
{ | |||||
AttachCount = 2, | |||||
SN = 3, | |||||
TerminalID = "4444444", | |||||
Time = Convert.ToDateTime("2019-12-10 18:31:00") | |||||
}, | |||||
AlarmTime = Convert.ToDateTime("2019-12-11 18:31:00"), | |||||
Altitude = 7, | |||||
AlarmLevel=8, | |||||
AlarmOrEventType=9, | |||||
FlagState = 12, | |||||
Latitude = 13, | |||||
Longitude = 14, | |||||
Speed = 17, | |||||
VehicleState = 19 | |||||
}); | |||||
var hex = JT808Serializer.Serialize(jT808UploadLocationRequest).ToHexString(); | |||||
Assert.Equal("000000010000000200BA7F0E07E4F11C0028003C0000180715101010671A000000010C09081100070000000D0000000E191211183100001334343434343434191210183100030200", hex); | |||||
} | |||||
[Fact] | |||||
public void Deserialize() | |||||
{ | |||||
var jT808UploadLocationRequest = JT808Serializer.Deserialize<JT808_0x0200>("000000010000000200BA7F0E07E4F11C0028003C0000180715101010671A000000010C09081100070000000D0000000E191211183100001334343434343434191210183100030200".ToHexBytes()); | |||||
jT808UploadLocationRequest.JT808LocationAttachData.TryGetValue(JT808_JTActiveSafety_Constants.JT808_0X0200_0x67, out var value); | |||||
JT808_0x0200_0x67 jT808_0X0200_0X67 = value as JT808_0x0200_0x67; | |||||
Assert.Equal(1u, jT808_0X0200_0X67.AlarmId); | |||||
Assert.Equal(2, jT808_0X0200_0X67.AlarmIdentification.AttachCount); | |||||
Assert.Equal(3, jT808_0X0200_0X67.AlarmIdentification.SN); | |||||
Assert.Equal("4444444", jT808_0X0200_0X67.AlarmIdentification.TerminalID); | |||||
Assert.Equal(Convert.ToDateTime("2019-12-10 18:31:00"), jT808_0X0200_0X67.AlarmIdentification.Time); | |||||
Assert.Equal(Convert.ToDateTime("2019-12-11 18:31:00"), jT808_0X0200_0X67.AlarmTime); | |||||
Assert.Equal(7, jT808_0X0200_0X67.Altitude); | |||||
Assert.Equal(8, jT808_0X0200_0X67.AlarmLevel); | |||||
Assert.Equal(9, jT808_0X0200_0X67.AlarmOrEventType); | |||||
Assert.Equal(0x67, jT808_0X0200_0X67.AttachInfoId); | |||||
Assert.Equal(26, jT808_0X0200_0X67.AttachInfoLength); | |||||
Assert.Equal(12, jT808_0X0200_0X67.FlagState); | |||||
Assert.Equal(13, jT808_0X0200_0X67.Latitude); | |||||
Assert.Equal(14, jT808_0X0200_0X67.Longitude); | |||||
Assert.Equal(17, jT808_0X0200_0X67.Speed); | |||||
Assert.Equal(19, jT808_0X0200_0X67.VehicleState); | |||||
} | |||||
[Fact] | |||||
public void Json() | |||||
{ | |||||
var json = JT808Serializer.Analyze<JT808_0x0200>("000000010000000200BA7F0E07E4F11C0028003C0000180715101010671A000000010C09081100070000000D0000000E191211183100001334343434343434191210183100030200".ToHexBytes()); | |||||
} | |||||
} | |||||
} |
@@ -0,0 +1,120 @@ | |||||
using JT808.Protocol.Extensions.JTActiveSafety.MessageBody; | |||||
using JT808.Protocol.Extensions.JTActiveSafety.Metadata; | |||||
using JT808.Protocol.MessageBody; | |||||
using Microsoft.Extensions.DependencyInjection; | |||||
using System; | |||||
using System.Collections.Generic; | |||||
using System.Text; | |||||
using Xunit; | |||||
namespace JT808.Protocol.Extensions.JTActiveSafety.Test | |||||
{ | |||||
public class JT808_0x0900_Test | |||||
{ | |||||
JT808Serializer JT808Serializer; | |||||
public JT808_0x0900_Test() | |||||
{ | |||||
ServiceCollection serviceDescriptors = new ServiceCollection(); | |||||
serviceDescriptors.AddJT808Configure() | |||||
.AddJTActiveSafetyConfigure(); | |||||
IJT808Config jT808Config = serviceDescriptors.BuildServiceProvider().GetRequiredService<IJT808Config>(); | |||||
JT808Serializer = new JT808Serializer(jT808Config); | |||||
} | |||||
[Fact] | |||||
public void Test_0xF7_1() | |||||
{ | |||||
JT808_0x0900_0xF7 jT808_0x0900_0xF7 = new JT808_0x0900_0xF7 | |||||
{ | |||||
USBMessageCount = 2, | |||||
USBMessages = new List<JT808_0x0900_0xF7_USB> { | |||||
new JT808_0x0900_0xF7_USB { | |||||
USBID = 1, | |||||
AlarmStatus = 1, | |||||
WorkingCondition = 2 | |||||
}, | |||||
new JT808_0x0900_0xF7_USB { | |||||
USBID = 2, | |||||
AlarmStatus = 1, | |||||
WorkingCondition = 2 | |||||
} | |||||
} | |||||
}; | |||||
var hex = JT808Serializer.Serialize(jT808_0x0900_0xF7).ToHexString(); | |||||
Assert.Equal("020105020000000102050200000001", hex); | |||||
} | |||||
[Fact] | |||||
public void Test_0xF7_2() | |||||
{ | |||||
var jT808_0x0900_0xF7 = JT808Serializer.Deserialize<JT808_0x0900_0xF7>("020105020000000102050200000001".ToHexBytes()); | |||||
Assert.Equal(JT808_JTActiveSafety_Constants.JT808_0X0900_0xF7, jT808_0x0900_0xF7.PassthroughType); | |||||
Assert.Equal(2, jT808_0x0900_0xF7.USBMessageCount); | |||||
Assert.Equal(1, jT808_0x0900_0xF7.USBMessages[0].USBID); | |||||
Assert.Equal(5, jT808_0x0900_0xF7.USBMessages[0].MessageLength); | |||||
Assert.Equal(2, jT808_0x0900_0xF7.USBMessages[0].WorkingCondition); | |||||
Assert.Equal(1u, jT808_0x0900_0xF7.USBMessages[0].AlarmStatus); | |||||
Assert.Equal(2, jT808_0x0900_0xF7.USBMessages[1].USBID); | |||||
Assert.Equal(5, jT808_0x0900_0xF7.USBMessages[1].MessageLength); | |||||
Assert.Equal(2, jT808_0x0900_0xF7.USBMessages[1].WorkingCondition); | |||||
Assert.Equal(1u, jT808_0x0900_0xF7.USBMessages[1].AlarmStatus); | |||||
} | |||||
[Fact] | |||||
public void Test_0xF7_3() | |||||
{ | |||||
var json = JT808Serializer.Analyze<JT808_0x0900_0xF7>("020105020000000102050200000001".ToHexBytes()); | |||||
} | |||||
[Fact] | |||||
public void Test_0xF8_1() | |||||
{ | |||||
JT808_0x0900_0xF8 jT808_0x0900_0xF8 = new JT808_0x0900_0xF8 | |||||
{ | |||||
USBMessageCount = 1, | |||||
USBMessages = new List<JT808_0x0900_0xF8_USB> { | |||||
new JT808_0x0900_0xF8_USB { | |||||
USBID = 1, | |||||
CompantName = "CompantName", | |||||
CustomerCode = "CustomerCode", | |||||
DevicesID = "DevicesID", | |||||
HardwareVersionNumber = "HardwareVersionNumber", | |||||
ProductModel = "ProductModel", | |||||
SoftwareVersionNumber = "SoftwareVersionNumber" | |||||
} | |||||
} | |||||
}; | |||||
var hex = JT808Serializer.Serialize(jT808_0x0900_0xF8).ToHexString(); | |||||
Assert.Equal("01015C0B436F6D70616E744E616D650C50726F647563744D6F64656C15486172647761726556657273696F6E4E756D62657215536F66747761726556657273696F6E4E756D626572094465766963657349440C437573746F6D6572436F6465", hex); | |||||
} | |||||
[Fact] | |||||
public void Test_0xF8_2() | |||||
{ | |||||
var jT808_0x0900_0xF8 = JT808Serializer.Deserialize<JT808_0x0900_0xF8>("01015C0B436F6D70616E744E616D650C50726F647563744D6F64656C15486172647761726556657273696F6E4E756D62657215536F66747761726556657273696F6E4E756D626572094465766963657349440C437573746F6D6572436F6465".ToHexBytes()); | |||||
Assert.Equal(JT808_JTActiveSafety_Constants.JT808_0X0900_0xF8, jT808_0x0900_0xF8.PassthroughType); | |||||
Assert.Equal(1, jT808_0x0900_0xF8.USBMessageCount); | |||||
Assert.Equal(1, jT808_0x0900_0xF8.USBMessages[0].USBID); | |||||
Assert.Equal("CompantName", jT808_0x0900_0xF8.USBMessages[0].CompantName); | |||||
Assert.Equal("CompantName".Length, jT808_0x0900_0xF8.USBMessages[0].CompantNameLength); | |||||
Assert.Equal("CustomerCode", jT808_0x0900_0xF8.USBMessages[0].CustomerCode); | |||||
Assert.Equal("CustomerCode".Length, jT808_0x0900_0xF8.USBMessages[0].CustomerCodeLength); | |||||
Assert.Equal("DevicesID", jT808_0x0900_0xF8.USBMessages[0].DevicesID); | |||||
Assert.Equal("DevicesID".Length, jT808_0x0900_0xF8.USBMessages[0].DevicesIDLength); | |||||
Assert.Equal("HardwareVersionNumber", jT808_0x0900_0xF8.USBMessages[0].HardwareVersionNumber); | |||||
Assert.Equal("HardwareVersionNumber".Length, jT808_0x0900_0xF8.USBMessages[0].HardwareVersionNumberLength); | |||||
Assert.Equal("ProductModel", jT808_0x0900_0xF8.USBMessages[0].ProductModel); | |||||
Assert.Equal("ProductModel".Length, jT808_0x0900_0xF8.USBMessages[0].ProductModelLength); | |||||
Assert.Equal("SoftwareVersionNumber", jT808_0x0900_0xF8.USBMessages[0].SoftwareVersionNumber); | |||||
Assert.Equal("SoftwareVersionNumber".Length, jT808_0x0900_0xF8.USBMessages[0].SoftwareVersionNumberLength); | |||||
} | |||||
[Fact] | |||||
public void Test_0xF8_3() | |||||
{ | |||||
var json = JT808Serializer.Analyze<JT808_0x0900_0xF8>("01015C0B436F6D70616E744E616D650C50726F647563744D6F64656C15486172647761726556657273696F6E4E756D62657215536F66747761726556657273696F6E4E756D626572094465766963657349440C437573746F6D6572436F6465".ToHexBytes()); | |||||
} | |||||
} | |||||
} |
@@ -0,0 +1,81 @@ | |||||
using JT808.Protocol.Extensions.JTActiveSafety.MessageBody; | |||||
using JT808.Protocol.MessageBody; | |||||
using Microsoft.Extensions.DependencyInjection; | |||||
using System; | |||||
using System.Collections.Generic; | |||||
using System.Text; | |||||
using Xunit; | |||||
namespace JT808.Protocol.Extensions.JTActiveSafety.Test | |||||
{ | |||||
public class JT808_0x1210_Test | |||||
{ | |||||
JT808Serializer JT808Serializer; | |||||
public JT808_0x1210_Test() | |||||
{ | |||||
ServiceCollection serviceDescriptors = new ServiceCollection(); | |||||
serviceDescriptors.AddJT808Configure() | |||||
.AddJTActiveSafetyConfigure(); | |||||
IJT808Config jT808Config = serviceDescriptors.BuildServiceProvider().GetRequiredService<IJT808Config>(); | |||||
JT808Serializer = new JT808Serializer(jT808Config); | |||||
} | |||||
[Fact] | |||||
public void Serializer() | |||||
{ | |||||
JT808_0x1210 jT808UploadLocationRequest = new JT808_0x1210 | |||||
{ | |||||
AlarmId = "11111111111111111111111111111111", | |||||
AlarmIdentification = new Metadata.AlarmIdentificationProperty | |||||
{ | |||||
Retain = 1, | |||||
AttachCount = 2, | |||||
SN = 3, | |||||
TerminalID = "4444444", | |||||
Time = Convert.ToDateTime("2019-12-10 18:31:00") | |||||
}, | |||||
AttachInfos = new List<Metadata.AttachProperty> { | |||||
new Metadata.AttachProperty{ | |||||
FileName="filename", | |||||
FileSize=9 | |||||
}, | |||||
new Metadata.AttachProperty{ | |||||
FileName="filename1", | |||||
FileSize=10 | |||||
} | |||||
}, | |||||
MakerID = "4444444", | |||||
InfoType = 0 | |||||
}; | |||||
var hex = JT808Serializer.Serialize(jT808UploadLocationRequest).ToHexString(); | |||||
Assert.Equal("3434343434343434343434343434191210183100030201313131313131313131313131313131313131313131313131313131313131313100020866696C656E616D65000000090966696C656E616D65310000000A", hex); | |||||
} | |||||
[Fact] | |||||
public void Deserialize() | |||||
{ | |||||
var jT808UploadLocationRequest = JT808Serializer.Deserialize<JT808_0x1210>("3434343434343434343434343434191210183100030201313131313131313131313131313131313131313131313131313131313131313100020866696C656E616D65000000090966696C656E616D65310000000A".ToHexBytes()); | |||||
Assert.Equal("11111111111111111111111111111111", jT808UploadLocationRequest.AlarmId); | |||||
Assert.Equal(2, jT808UploadLocationRequest.AlarmIdentification.AttachCount); | |||||
Assert.Equal(3, jT808UploadLocationRequest.AlarmIdentification.SN); | |||||
Assert.Equal("4444444", jT808UploadLocationRequest.AlarmIdentification.TerminalID); | |||||
Assert.Equal(Convert.ToDateTime("2019-12-10 18:31:00"), jT808UploadLocationRequest.AlarmIdentification.Time); | |||||
Assert.Equal(2, jT808UploadLocationRequest.AttachCount); | |||||
Assert.Equal("filename", jT808UploadLocationRequest.AttachInfos[0].FileName); | |||||
Assert.Equal(8, jT808UploadLocationRequest.AttachInfos[0].FileNameLength); | |||||
Assert.Equal(9u, jT808UploadLocationRequest.AttachInfos[0].FileSize); | |||||
Assert.Equal("filename1", jT808UploadLocationRequest.AttachInfos[1].FileName); | |||||
Assert.Equal(9, jT808UploadLocationRequest.AttachInfos[1].FileNameLength); | |||||
Assert.Equal(10u, jT808UploadLocationRequest.AttachInfos[1].FileSize); | |||||
Assert.Equal("4444444", jT808UploadLocationRequest.MakerID); | |||||
Assert.Equal(0, jT808UploadLocationRequest.InfoType); | |||||
} | |||||
[Fact] | |||||
public void Json() | |||||
{ | |||||
var json = JT808Serializer.Analyze<JT808_0x1210>("3434343434343434343434343434191210183100030201313131313131313131313131313131313131313131313131313131313131313100020866696C656E616D65000000090966696C656E616D65310000000A".ToHexBytes()); | |||||
} | |||||
} | |||||
} |
@@ -0,0 +1,50 @@ | |||||
using JT808.Protocol.Extensions.JTActiveSafety.MessageBody; | |||||
using JT808.Protocol.MessageBody; | |||||
using Microsoft.Extensions.DependencyInjection; | |||||
using System; | |||||
using System.Collections.Generic; | |||||
using System.Text; | |||||
using Xunit; | |||||
namespace JT808.Protocol.Extensions.JTActiveSafety.Test | |||||
{ | |||||
public class JT808_0x1211_Test | |||||
{ | |||||
JT808Serializer JT808Serializer; | |||||
public JT808_0x1211_Test() | |||||
{ | |||||
ServiceCollection serviceDescriptors = new ServiceCollection(); | |||||
serviceDescriptors.AddJT808Configure() | |||||
.AddJTActiveSafetyConfigure(); | |||||
IJT808Config jT808Config = serviceDescriptors.BuildServiceProvider().GetRequiredService<IJT808Config>(); | |||||
JT808Serializer = new JT808Serializer(jT808Config); | |||||
} | |||||
[Fact] | |||||
public void Serializer() | |||||
{ | |||||
JT808_0x1211 jT808UploadLocationRequest = new JT808_0x1211 | |||||
{ | |||||
FileName= "FileName", | |||||
FileSize=1, | |||||
FileType=2 | |||||
}; | |||||
var hex = JT808Serializer.Serialize(jT808UploadLocationRequest).ToHexString(); | |||||
Assert.Equal("0846696C654E616D650200000001", hex); | |||||
} | |||||
[Fact] | |||||
public void Deserialize() | |||||
{ | |||||
var jT808UploadLocationRequest = JT808Serializer.Deserialize<JT808_0x1211>("0846696C654E616D650200000001".ToHexBytes()); | |||||
Assert.Equal("FileName", jT808UploadLocationRequest.FileName); | |||||
Assert.Equal(1u, jT808UploadLocationRequest.FileSize); | |||||
Assert.Equal(2, jT808UploadLocationRequest.FileType); | |||||
Assert.Equal("FileName".Length, jT808UploadLocationRequest.FileNameLength); | |||||
} | |||||
[Fact] | |||||
public void Json() | |||||
{ | |||||
var json = JT808Serializer.Analyze<JT808_0x1211>("0846696C654E616D650200000001".ToHexBytes()); | |||||
} | |||||
} | |||||
} |
@@ -0,0 +1,44 @@ | |||||
using JT808.Protocol.Extensions.JTActiveSafety.MessageBody; | |||||
using JT808.Protocol.MessageBody; | |||||
using Microsoft.Extensions.DependencyInjection; | |||||
using System; | |||||
using System.Collections.Generic; | |||||
using System.Text; | |||||
using Xunit; | |||||
namespace JT808.Protocol.Extensions.JTActiveSafety.Test | |||||
{ | |||||
public class JT808_0x1212_Test | |||||
{ | |||||
JT808Serializer JT808Serializer; | |||||
public JT808_0x1212_Test() | |||||
{ | |||||
ServiceCollection serviceDescriptors = new ServiceCollection(); | |||||
serviceDescriptors.AddJT808Configure() | |||||
.AddJTActiveSafetyConfigure(); | |||||
IJT808Config jT808Config = serviceDescriptors.BuildServiceProvider().GetRequiredService<IJT808Config>(); | |||||
JT808Serializer = new JT808Serializer(jT808Config); | |||||
} | |||||
[Fact] | |||||
public void Serializer() | |||||
{ | |||||
JT808_0x1212 jT808UploadLocationRequest = new JT808_0x1212 | |||||
{ | |||||
FileName= "FileName", | |||||
FileSize=1, | |||||
FileType=2 | |||||
}; | |||||
var hex = JT808Serializer.Serialize(jT808UploadLocationRequest).ToHexString(); | |||||
Assert.Equal("0846696C654E616D650200000001", hex); | |||||
} | |||||
[Fact] | |||||
public void Deserialize() | |||||
{ | |||||
var jT808UploadLocationRequest = JT808Serializer.Deserialize<JT808_0x1212>("0846696C654E616D650200000001".ToHexBytes()); | |||||
Assert.Equal("FileName", jT808UploadLocationRequest.FileName); | |||||
Assert.Equal(1u, jT808UploadLocationRequest.FileSize); | |||||
Assert.Equal(2, jT808UploadLocationRequest.FileType); | |||||
Assert.Equal("FileName".Length, jT808UploadLocationRequest.FileNameLength); | |||||
} | |||||
} | |||||
} |
@@ -0,0 +1,139 @@ | |||||
using JT808.Protocol.Extensions.JTActiveSafety.MessageBody; | |||||
using JT808.Protocol.MessageBody; | |||||
using Microsoft.Extensions.DependencyInjection; | |||||
using System; | |||||
using System.Collections.Generic; | |||||
using System.Text; | |||||
using Xunit; | |||||
namespace JT808.Protocol.Extensions.JTActiveSafety.Test | |||||
{ | |||||
public class JT808_0x8103_0xF364_Test | |||||
{ | |||||
JT808Serializer JT808Serializer; | |||||
public JT808_0x8103_0xF364_Test() | |||||
{ | |||||
ServiceCollection serviceDescriptors = new ServiceCollection(); | |||||
serviceDescriptors.AddJT808Configure() | |||||
.AddJTActiveSafetyConfigure(); | |||||
IJT808Config jT808Config = serviceDescriptors.BuildServiceProvider().GetRequiredService<IJT808Config>(); | |||||
JT808Serializer = new JT808Serializer(jT808Config); | |||||
} | |||||
[Fact] | |||||
public void Serializer() | |||||
{ | |||||
JT808_0x8103 jT808UploadLocationRequest = new JT808_0x8103 | |||||
{ | |||||
ParamList=new List<JT808_0x8103_BodyBase> { | |||||
new JT808_0x8103_0xF364{ | |||||
ActiveDistancePhotographyDistanceInterval=1, | |||||
ActivelyTimePhotoInterval=2, | |||||
ActivePhotographyStrategy=3, | |||||
AlarmEnable=4, | |||||
AlarmJudgeSpeedThreshold=5, | |||||
AlarmPhotoVehicleCloseDistance=6, | |||||
AlarmPhotoVehicleCloseDistanceInterval=7, | |||||
BarrierAlarmPhotographs=8, | |||||
DistanceThresholdObstacleAlarm=9, | |||||
EventEnable=10, | |||||
ForwardCollisionAlarmInterval=11, | |||||
ForwardCollisionAlarmPhotographs=12, | |||||
ForwardCollisionWarningTimeThreshold=13, | |||||
FrequentAlarmJudgmentNumberChannelChange=14, | |||||
FrequentChannelChangeAlarmJudgmentTimePeriod=15, | |||||
FrequentChannelChangeAlarmPhotos=16, | |||||
FrequentLaneChangeAlarmInterval=17, | |||||
GradedSpeedThresholdLaneDeviationAlarm=18, | |||||
HierarchicalSpeedThresholdForwardCollisionWarning=19, | |||||
HierarchicalSpeedThresholdFrequentChannelChangeAlarm=20, | |||||
HierarchicalSpeedThresholdObstacleAlarm=21, | |||||
LaneDepartureAlarmPhoto=22, | |||||
LaneDepartureAlarmPhotoInterval=23, | |||||
ObstacleAlarmInterval=24, | |||||
PedestrianCollisionAlarmEnablingSpeedThreshold=25, | |||||
PedestrianCollisionAlarmInterval=26, | |||||
PedestrianCollisionAlarmPhotos=27, | |||||
PedestrianCollisionAlarmTimeThreshold=28, | |||||
PhotoResolution=29, | |||||
Placeholder1=30, | |||||
Placeholder2=new byte[]{1,2,3,4 }, | |||||
RoadSignRecognitionPhotographs=32, | |||||
RoadSignRecognitionPhotographsInterval=33, | |||||
SingleInitiativePhotos=34, | |||||
SingleInitiativePhotosInterval=35, | |||||
VehicleDistanceMonitoringAlarmDistanceThreshold=36, | |||||
VehicleDistanceMonitoringAndAlarmClassificationSpeedThreshold=37, | |||||
VideoRecordingResolution=38, | |||||
VideoRecordingTimeBeforeAndAfterAlarmVehicleProximity=39, | |||||
VideoRecordingTimeBeforeAndAfterForwardCollisionAlarm=40, | |||||
VideoRecordingTimeBeforeAndAfterFrequentLaneChangeAlarm=41, | |||||
VideoRecordingTimeBeforeAndAfterLaneDepartureAlarm=42, | |||||
VideoRecordingTimeBeforeAndAfterObstacleAlarm=43, | |||||
VideoRecordingTimeBeforeAndAfterPedestrianCollisionAlarm=44, | |||||
WarningVolume=45 | |||||
} | |||||
} | |||||
}; | |||||
var hex = JT808Serializer.Serialize(jT808UploadLocationRequest).ToHexString(); | |||||
Assert.Equal("010000F36438052D030002000122231D26000000040000000A1E09152B08180F0E14291011122A16170D13280C0B1C192C1B1A2425270607202101020304", hex); | |||||
} | |||||
[Fact] | |||||
public void Deserialize() | |||||
{ | |||||
var jT808UploadLocationRequest = JT808Serializer.Deserialize<JT808_0x8103>("010000F36438052D030002000122231D26000000040000000A1E09152B08180F0E14291011122A16170D13280C0B1C192C1B1A2425270607202101020304".ToHexBytes()); | |||||
JT808_0x8103_0xF364 jT808_0X8103_0XF364 = jT808UploadLocationRequest.ParamList[0] as JT808_0x8103_0xF364; | |||||
Assert.Equal(1, jT808_0X8103_0XF364.ActiveDistancePhotographyDistanceInterval); | |||||
Assert.Equal(2, jT808_0X8103_0XF364.ActivelyTimePhotoInterval); | |||||
Assert.Equal(3, jT808_0X8103_0XF364.ActivePhotographyStrategy); | |||||
Assert.Equal(4u, jT808_0X8103_0XF364.AlarmEnable); | |||||
Assert.Equal(5, jT808_0X8103_0XF364.AlarmJudgeSpeedThreshold); | |||||
Assert.Equal(6, jT808_0X8103_0XF364.AlarmPhotoVehicleCloseDistance); | |||||
Assert.Equal(7, jT808_0X8103_0XF364.AlarmPhotoVehicleCloseDistanceInterval); | |||||
Assert.Equal(8, jT808_0X8103_0XF364.BarrierAlarmPhotographs); | |||||
Assert.Equal(9, jT808_0X8103_0XF364.DistanceThresholdObstacleAlarm); | |||||
Assert.Equal(10u, jT808_0X8103_0XF364.EventEnable); | |||||
Assert.Equal(11, jT808_0X8103_0XF364.ForwardCollisionAlarmInterval); | |||||
Assert.Equal(12, jT808_0X8103_0XF364.ForwardCollisionAlarmPhotographs); | |||||
Assert.Equal(13, jT808_0X8103_0XF364.ForwardCollisionWarningTimeThreshold); | |||||
Assert.Equal(14, jT808_0X8103_0XF364.FrequentAlarmJudgmentNumberChannelChange); | |||||
Assert.Equal(15, jT808_0X8103_0XF364.FrequentChannelChangeAlarmJudgmentTimePeriod); | |||||
Assert.Equal(16, jT808_0X8103_0XF364.FrequentChannelChangeAlarmPhotos); | |||||
Assert.Equal(17, jT808_0X8103_0XF364.FrequentLaneChangeAlarmInterval); | |||||
Assert.Equal(18, jT808_0X8103_0XF364.GradedSpeedThresholdLaneDeviationAlarm); | |||||
Assert.Equal(19, jT808_0X8103_0XF364.HierarchicalSpeedThresholdForwardCollisionWarning); | |||||
Assert.Equal(20, jT808_0X8103_0XF364.HierarchicalSpeedThresholdFrequentChannelChangeAlarm); | |||||
Assert.Equal(21, jT808_0X8103_0XF364.HierarchicalSpeedThresholdObstacleAlarm); | |||||
Assert.Equal(22, jT808_0X8103_0XF364.LaneDepartureAlarmPhoto); | |||||
Assert.Equal(23, jT808_0X8103_0XF364.LaneDepartureAlarmPhotoInterval); | |||||
Assert.Equal(24, jT808_0X8103_0XF364.ObstacleAlarmInterval); | |||||
Assert.Equal(25, jT808_0X8103_0XF364.PedestrianCollisionAlarmEnablingSpeedThreshold); | |||||
Assert.Equal(26, jT808_0X8103_0XF364.PedestrianCollisionAlarmInterval); | |||||
Assert.Equal(27, jT808_0X8103_0XF364.PedestrianCollisionAlarmPhotos); | |||||
Assert.Equal(28, jT808_0X8103_0XF364.PedestrianCollisionAlarmTimeThreshold); | |||||
Assert.Equal(29, jT808_0X8103_0XF364.PhotoResolution); | |||||
Assert.Equal(30, jT808_0X8103_0XF364.Placeholder1); | |||||
Assert.Equal(new byte[] { 1, 2, 3, 4 }.ToHexString(), jT808_0X8103_0XF364.Placeholder2.ToHexString()); | |||||
Assert.Equal(32, jT808_0X8103_0XF364.RoadSignRecognitionPhotographs); | |||||
Assert.Equal(33, jT808_0X8103_0XF364.RoadSignRecognitionPhotographsInterval); | |||||
Assert.Equal(34, jT808_0X8103_0XF364.SingleInitiativePhotos); | |||||
Assert.Equal(35, jT808_0X8103_0XF364.SingleInitiativePhotosInterval); | |||||
Assert.Equal(36, jT808_0X8103_0XF364.VehicleDistanceMonitoringAlarmDistanceThreshold); | |||||
Assert.Equal(37, jT808_0X8103_0XF364.VehicleDistanceMonitoringAndAlarmClassificationSpeedThreshold); | |||||
Assert.Equal(38, jT808_0X8103_0XF364.VideoRecordingResolution); | |||||
Assert.Equal(39, jT808_0X8103_0XF364.VideoRecordingTimeBeforeAndAfterAlarmVehicleProximity); | |||||
Assert.Equal(40, jT808_0X8103_0XF364.VideoRecordingTimeBeforeAndAfterForwardCollisionAlarm); | |||||
Assert.Equal(41, jT808_0X8103_0XF364.VideoRecordingTimeBeforeAndAfterFrequentLaneChangeAlarm); | |||||
Assert.Equal(42, jT808_0X8103_0XF364.VideoRecordingTimeBeforeAndAfterLaneDepartureAlarm); | |||||
Assert.Equal(43, jT808_0X8103_0XF364.VideoRecordingTimeBeforeAndAfterObstacleAlarm); | |||||
Assert.Equal(44, jT808_0X8103_0XF364.VideoRecordingTimeBeforeAndAfterPedestrianCollisionAlarm); | |||||
Assert.Equal(45, jT808_0X8103_0XF364.WarningVolume); | |||||
Assert.Equal(JT808_JTActiveSafety_Constants.JT808_0X8103_0xF364, jT808_0X8103_0XF364.ParamId); | |||||
} | |||||
[Fact] | |||||
public void Json() | |||||
{ | |||||
var json = JT808Serializer.Analyze<JT808_0x8103>("010000F36438052D030002000122231D26000000040000000A1E09152B08180F0E14291011122A16170D13280C0B1C192C1B1A2425270607202101020304".ToHexBytes()); | |||||
} | |||||
} | |||||
} |
@@ -0,0 +1,116 @@ | |||||
using JT808.Protocol.Extensions.JTActiveSafety.MessageBody; | |||||
using JT808.Protocol.MessageBody; | |||||
using Microsoft.Extensions.DependencyInjection; | |||||
using System; | |||||
using System.Collections.Generic; | |||||
using System.Text; | |||||
using Xunit; | |||||
namespace JT808.Protocol.Extensions.JTActiveSafety.Test | |||||
{ | |||||
public class JT808_0x8103_0xF365_Test | |||||
{ | |||||
JT808Serializer JT808Serializer; | |||||
public JT808_0x8103_0xF365_Test() | |||||
{ | |||||
ServiceCollection serviceDescriptors = new ServiceCollection(); | |||||
serviceDescriptors.AddJT808Configure() | |||||
.AddJTActiveSafetyConfigure(); | |||||
IJT808Config jT808Config = serviceDescriptors.BuildServiceProvider().GetRequiredService<IJT808Config>(); | |||||
JT808Serializer = new JT808Serializer(jT808Config); | |||||
} | |||||
[Fact] | |||||
public void Serializer() | |||||
{ | |||||
JT808_0x8103 jT808UploadLocationRequest = new JT808_0x8103 | |||||
{ | |||||
ParamList=new List<JT808_0x8103_BodyBase> { | |||||
new JT808_0x8103_0xF365{ | |||||
ActiveDistancePhotographyDistanceInterval=1, | |||||
ActivelyTimePhotoInterval=2, | |||||
ActivePhotographyStrategy=3, | |||||
AlarmEnable=4, | |||||
AlarmJudgeSpeedThreshold=5, | |||||
EventEnable=10, | |||||
PhotoResolution=29, | |||||
SingleInitiativePhotos=34, | |||||
SingleInitiativePhotosInterval=35, | |||||
VideoRecordingResolution=38, | |||||
WarningVolume=45, | |||||
CallAlarmDetermineTimeInterval=46, | |||||
CallAlarmTakePicturesDriverFacialFeatures=47, | |||||
CallAlarmTakePicturesDriverFacialFeaturesInterval=48, | |||||
ClassifiedSpeedThresholdCallAlarm=49, | |||||
ClassifiedSpeedThresholdDistractedDrivingAlarm=50, | |||||
ClassifiedSpeedThresholdSmokingAlarm=51, | |||||
DistractedDrivingAlarmPhotography=52, | |||||
DistractedDrivingAlarmPhotographyInterval=53, | |||||
DriverIdentificationTrigger=54, | |||||
FatigueDrivingAlarmPhotograph=55, | |||||
FatigueDrivingAlarmPhotographInterval=56, | |||||
GradedSpeedThresholdFatigueDrivingAlarm=57, | |||||
PhotographsAbnormalDrivingBehavior=58, | |||||
PictureIntervalAbnormalDrivingBehavior=59, | |||||
Reserve=new byte[]{1,2,3 }, | |||||
Retain=new byte[]{5,6 }, | |||||
SmokingAlarmPhotographsDriverFaceCharacteristics=60, | |||||
SmokingAlarmPhotographsDriverFaceCharacteristicsInterval=61, | |||||
TimeIntervalSmokingAlarmJudgment=62, | |||||
VideoRecordingTimeAbnormalDrivingBehavior=63, | |||||
VideoRecordingTimeBeforeAndAfterCallAlarm=64, | |||||
VideoRecordingTimeBeforeAndAfterFatigueDrivingAlarm=65, | |||||
VideoRecordingTimeBeforeAndAfterSmokingAlarm=66 | |||||
} | |||||
} | |||||
}; | |||||
var hex = JT808Serializer.Serialize(jT808UploadLocationRequest).ToHexString(); | |||||
Assert.Equal("010000F3652F052D030002000122231D26000000040000000A003E002E0102033941373831402F3033423C3D3234353F3A3B360506", hex); | |||||
} | |||||
[Fact] | |||||
public void Deserialize() | |||||
{ | |||||
var jT808UploadLocationRequest = JT808Serializer.Deserialize<JT808_0x8103>("010000F3652F052D030002000122231D26000000040000000A003E002E0102033941373831402F3033423C3D3234353F3A3B360506".ToHexBytes()); | |||||
JT808_0x8103_0xF365 jT808_0X8103_0XF365 = jT808UploadLocationRequest.ParamList[0] as JT808_0x8103_0xF365; | |||||
Assert.Equal(1, jT808_0X8103_0XF365.ActiveDistancePhotographyDistanceInterval); | |||||
Assert.Equal(2, jT808_0X8103_0XF365.ActivelyTimePhotoInterval); | |||||
Assert.Equal(3, jT808_0X8103_0XF365.ActivePhotographyStrategy); | |||||
Assert.Equal(4u, jT808_0X8103_0XF365.AlarmEnable); | |||||
Assert.Equal(5, jT808_0X8103_0XF365.AlarmJudgeSpeedThreshold); | |||||
Assert.Equal(10u, jT808_0X8103_0XF365.EventEnable); | |||||
Assert.Equal(29, jT808_0X8103_0XF365.PhotoResolution); | |||||
Assert.Equal(34, jT808_0X8103_0XF365.SingleInitiativePhotos); | |||||
Assert.Equal(35, jT808_0X8103_0XF365.SingleInitiativePhotosInterval); | |||||
Assert.Equal(38, jT808_0X8103_0XF365.VideoRecordingResolution); | |||||
Assert.Equal(45, jT808_0X8103_0XF365.WarningVolume); | |||||
Assert.Equal(46, jT808_0X8103_0XF365.CallAlarmDetermineTimeInterval); | |||||
Assert.Equal(47, jT808_0X8103_0XF365.CallAlarmTakePicturesDriverFacialFeatures); | |||||
Assert.Equal(48, jT808_0X8103_0XF365.CallAlarmTakePicturesDriverFacialFeaturesInterval); | |||||
Assert.Equal(49, jT808_0X8103_0XF365.ClassifiedSpeedThresholdCallAlarm); | |||||
Assert.Equal(50, jT808_0X8103_0XF365.ClassifiedSpeedThresholdDistractedDrivingAlarm); | |||||
Assert.Equal(51, jT808_0X8103_0XF365.ClassifiedSpeedThresholdSmokingAlarm); | |||||
Assert.Equal(52, jT808_0X8103_0XF365.DistractedDrivingAlarmPhotography); | |||||
Assert.Equal(53, jT808_0X8103_0XF365.DistractedDrivingAlarmPhotographyInterval); | |||||
Assert.Equal(54, jT808_0X8103_0XF365.DriverIdentificationTrigger); | |||||
Assert.Equal(55, jT808_0X8103_0XF365.FatigueDrivingAlarmPhotograph); | |||||
Assert.Equal(56, jT808_0X8103_0XF365.FatigueDrivingAlarmPhotographInterval); | |||||
Assert.Equal(57, jT808_0X8103_0XF365.GradedSpeedThresholdFatigueDrivingAlarm); | |||||
Assert.Equal(58, jT808_0X8103_0XF365.PhotographsAbnormalDrivingBehavior); | |||||
Assert.Equal(59, jT808_0X8103_0XF365.PictureIntervalAbnormalDrivingBehavior); | |||||
Assert.Equal(new byte[] { 1, 2, 3 }.ToHexString(), jT808_0X8103_0XF365.Reserve.ToHexString()); | |||||
Assert.Equal(new byte[] { 5, 6 }.ToHexString(), jT808_0X8103_0XF365.Retain.ToHexString()); | |||||
Assert.Equal(60, jT808_0X8103_0XF365.SmokingAlarmPhotographsDriverFaceCharacteristics); | |||||
Assert.Equal(61, jT808_0X8103_0XF365.SmokingAlarmPhotographsDriverFaceCharacteristicsInterval); | |||||
Assert.Equal(62, jT808_0X8103_0XF365.TimeIntervalSmokingAlarmJudgment); | |||||
Assert.Equal(63, jT808_0X8103_0XF365.VideoRecordingTimeAbnormalDrivingBehavior); | |||||
Assert.Equal(64, jT808_0X8103_0XF365.VideoRecordingTimeBeforeAndAfterCallAlarm); | |||||
Assert.Equal(65, jT808_0X8103_0XF365.VideoRecordingTimeBeforeAndAfterFatigueDrivingAlarm); | |||||
Assert.Equal(66, jT808_0X8103_0XF365.VideoRecordingTimeBeforeAndAfterSmokingAlarm); | |||||
Assert.Equal(JT808_JTActiveSafety_Constants.JT808_0X8103_0xF365, jT808_0X8103_0XF365.ParamId); | |||||
} | |||||
[Fact] | |||||
public void Json() | |||||
{ | |||||
var json = JT808Serializer.Analyze<JT808_0x8103>("010000F3652F052D030002000122231D26000000040000000A003E002E0102033941373831402F3033423C3D3234353F3A3B360506".ToHexBytes()); | |||||
} | |||||
} | |||||
} |
@@ -0,0 +1,69 @@ | |||||
using JT808.Protocol.Extensions.JTActiveSafety.MessageBody; | |||||
using JT808.Protocol.MessageBody; | |||||
using Microsoft.Extensions.DependencyInjection; | |||||
using System; | |||||
using System.Collections.Generic; | |||||
using System.Text; | |||||
using Xunit; | |||||
namespace JT808.Protocol.Extensions.JTActiveSafety.Test | |||||
{ | |||||
public class JT808_0x8103_0xF366_Test | |||||
{ | |||||
JT808Serializer JT808Serializer; | |||||
public JT808_0x8103_0xF366_Test() | |||||
{ | |||||
ServiceCollection serviceDescriptors = new ServiceCollection(); | |||||
serviceDescriptors.AddJT808Configure() | |||||
.AddJTActiveSafetyConfigure(); | |||||
IJT808Config jT808Config = serviceDescriptors.BuildServiceProvider().GetRequiredService<IJT808Config>(); | |||||
JT808Serializer = new JT808Serializer(jT808Config); | |||||
} | |||||
[Fact] | |||||
public void Serializer() | |||||
{ | |||||
JT808_0x8103 jT808UploadLocationRequest = new JT808_0x8103 | |||||
{ | |||||
ParamList=new List<JT808_0x8103_BodyBase> { | |||||
new JT808_0x8103_0xF366{ | |||||
HighTemperatureThreshold=1, | |||||
HighVoltageThreshold=2, | |||||
LowVoltageThreshold=3, | |||||
NormalFetalPressure=4, | |||||
Retain=new byte[]{1,2,3,4,5,6 }, | |||||
SlowLeakageThreshold=5, | |||||
ThresholdUnbalancedTirePressure=6, | |||||
TimedReportingInterval=7, | |||||
TyrePressureUnit=8, | |||||
TyreSpecificationType="999999999999", | |||||
VoltageThreshold=10 | |||||
} | |||||
} | |||||
}; | |||||
var hex = JT808Serializer.Serialize(jT808UploadLocationRequest).ToHexString(); | |||||
Assert.Equal("010000F366243939393939393939393939390008000400060005000300020001000A0007010203040506", hex); | |||||
} | |||||
[Fact] | |||||
public void Deserialize() | |||||
{ | |||||
var jT808UploadLocationRequest = JT808Serializer.Deserialize<JT808_0x8103>("010000F366243939393939393939393939390008000400060005000300020001000A0007010203040506".ToHexBytes()); | |||||
JT808_0x8103_0xF366 jT808_0x8103_0xF366 = jT808UploadLocationRequest.ParamList[0] as JT808_0x8103_0xF366; | |||||
Assert.Equal(1, jT808_0x8103_0xF366.HighTemperatureThreshold); | |||||
Assert.Equal(2, jT808_0x8103_0xF366.HighVoltageThreshold); | |||||
Assert.Equal(3, jT808_0x8103_0xF366.LowVoltageThreshold); | |||||
Assert.Equal(4, jT808_0x8103_0xF366.NormalFetalPressure); | |||||
Assert.Equal(new byte[] { 1, 2, 3, 4, 5, 6 }.ToHexString(), jT808_0x8103_0xF366.Retain.ToHexString()); | |||||
Assert.Equal(5, jT808_0x8103_0xF366.SlowLeakageThreshold); | |||||
Assert.Equal(6, jT808_0x8103_0xF366.ThresholdUnbalancedTirePressure); | |||||
Assert.Equal(7, jT808_0x8103_0xF366.TimedReportingInterval); | |||||
Assert.Equal(8, jT808_0x8103_0xF366.TyrePressureUnit); | |||||
Assert.Equal("999999999999", jT808_0x8103_0xF366.TyreSpecificationType); | |||||
Assert.Equal(10, jT808_0x8103_0xF366.VoltageThreshold); | |||||
} | |||||
[Fact] | |||||
public void Json() | |||||
{ | |||||
var json = JT808Serializer.Analyze<JT808_0x8103>("010000F366243939393939393939393939390008000400060005000300020001000A0007010203040506".ToHexBytes()); | |||||
} | |||||
} | |||||
} |
@@ -0,0 +1,51 @@ | |||||
using JT808.Protocol.Extensions.JTActiveSafety.MessageBody; | |||||
using JT808.Protocol.MessageBody; | |||||
using Microsoft.Extensions.DependencyInjection; | |||||
using System; | |||||
using System.Collections.Generic; | |||||
using System.Text; | |||||
using Xunit; | |||||
namespace JT808.Protocol.Extensions.JTActiveSafety.Test | |||||
{ | |||||
public class JT808_0x8103_0xF367_Test | |||||
{ | |||||
JT808Serializer JT808Serializer; | |||||
public JT808_0x8103_0xF367_Test() | |||||
{ | |||||
ServiceCollection serviceDescriptors = new ServiceCollection(); | |||||
serviceDescriptors.AddJT808Configure() | |||||
.AddJTActiveSafetyConfigure(); | |||||
IJT808Config jT808Config = serviceDescriptors.BuildServiceProvider().GetRequiredService<IJT808Config>(); | |||||
JT808Serializer = new JT808Serializer(jT808Config); | |||||
} | |||||
[Fact] | |||||
public void Serializer() | |||||
{ | |||||
JT808_0x8103 jT808UploadLocationRequest = new JT808_0x8103 | |||||
{ | |||||
ParamList=new List<JT808_0x8103_BodyBase> { | |||||
new JT808_0x8103_0xF367{ | |||||
LateralRearApproachAlarmTimeThreshold=1, | |||||
RearApproachAlarmTimeThreshold=2 | |||||
} | |||||
} | |||||
}; | |||||
var hex = JT808Serializer.Serialize(jT808UploadLocationRequest).ToHexString(); | |||||
Assert.Equal("010000F367020201", hex); | |||||
} | |||||
[Fact] | |||||
public void Deserialize() | |||||
{ | |||||
var jT808UploadLocationRequest = JT808Serializer.Deserialize<JT808_0x8103>("010000F367020201".ToHexBytes()); | |||||
JT808_0x8103_0xF367 jT808_0x8103_0xF367 = jT808UploadLocationRequest.ParamList[0] as JT808_0x8103_0xF367; | |||||
Assert.Equal(1, jT808_0x8103_0xF367.LateralRearApproachAlarmTimeThreshold); | |||||
Assert.Equal(2, jT808_0x8103_0xF367.RearApproachAlarmTimeThreshold); | |||||
} | |||||
[Fact] | |||||
public void Json() | |||||
{ | |||||
var json = JT808Serializer.Analyze<JT808_0x8103>("010000F367020201".ToHexBytes()); | |||||
} | |||||
} | |||||
} |
@@ -0,0 +1,46 @@ | |||||
using JT808.Protocol.Extensions.JTActiveSafety.MessageBody; | |||||
using JT808.Protocol.MessageBody; | |||||
using Microsoft.Extensions.DependencyInjection; | |||||
using System; | |||||
using System.Collections.Generic; | |||||
using System.Text; | |||||
using Xunit; | |||||
namespace JT808.Protocol.Extensions.JTActiveSafety.Test | |||||
{ | |||||
public class JT808_0x8900_Test | |||||
{ | |||||
JT808Serializer JT808Serializer; | |||||
public JT808_0x8900_Test() | |||||
{ | |||||
ServiceCollection serviceDescriptors = new ServiceCollection(); | |||||
serviceDescriptors.AddJT808Configure() | |||||
.AddJTActiveSafetyConfigure(); | |||||
IJT808Config jT808Config = serviceDescriptors.BuildServiceProvider().GetRequiredService<IJT808Config>(); | |||||
JT808Serializer = new JT808Serializer(jT808Config); | |||||
} | |||||
[Fact] | |||||
public void Serializer() | |||||
{ | |||||
JT808_0x8900_0xF7 jT808UploadLocationRequest = new JT808_0x8900_0xF7 | |||||
{ | |||||
USBCount=2, | |||||
MultipleUSB=new List<byte> {1,2 } | |||||
}; | |||||
var hex = JT808Serializer.Serialize(jT808UploadLocationRequest).ToHexString(); | |||||
Assert.Equal("020102", hex); | |||||
} | |||||
[Fact] | |||||
public void Deserialize() | |||||
{ | |||||
var jT808UploadLocationRequest = JT808Serializer.Deserialize<JT808_0x8900_0xF7>("020102".ToHexBytes()); | |||||
Assert.Equal(2, jT808UploadLocationRequest.USBCount); | |||||
Assert.Equal(new List<byte> { 1, 2 }.ToArray().ToHexString(), jT808UploadLocationRequest.MultipleUSB.ToArray().ToHexString()); | |||||
} | |||||
[Fact] | |||||
public void Json() | |||||
{ | |||||
var json = JT808Serializer.Analyze<JT808_0x8900_0xF7>("020102".ToHexBytes()); | |||||
} | |||||
} | |||||
} |
@@ -0,0 +1,64 @@ | |||||
using JT808.Protocol.Extensions.JTActiveSafety.MessageBody; | |||||
using JT808.Protocol.MessageBody; | |||||
using Microsoft.Extensions.DependencyInjection; | |||||
using System; | |||||
using System.Collections.Generic; | |||||
using System.Text; | |||||
using Xunit; | |||||
namespace JT808.Protocol.Extensions.JTActiveSafety.Test | |||||
{ | |||||
public class JT808_0x9208_Test | |||||
{ | |||||
JT808Serializer JT808Serializer; | |||||
public JT808_0x9208_Test() | |||||
{ | |||||
ServiceCollection serviceDescriptors = new ServiceCollection(); | |||||
serviceDescriptors.AddJT808Configure() | |||||
.AddJTActiveSafetyConfigure(); | |||||
IJT808Config jT808Config = serviceDescriptors.BuildServiceProvider().GetRequiredService<IJT808Config>(); | |||||
JT808Serializer = new JT808Serializer(jT808Config); | |||||
} | |||||
[Fact] | |||||
public void Serializer() | |||||
{ | |||||
JT808_0x9208 jT808UploadLocationRequest = new JT808_0x9208 | |||||
{ | |||||
AlarmId="11111111111111111111111111111111", | |||||
AlarmIdentification=new Metadata.AlarmIdentificationProperty { | |||||
Retain=1, | |||||
AttachCount = 2, | |||||
SN = 3, | |||||
TerminalID = "4444444", | |||||
Time = Convert.ToDateTime("2019-12-10 18:31:00") | |||||
}, | |||||
AttachmentServerIP="192.168.1.1", | |||||
AttachmentServerIPTcpPort=5000, | |||||
AttachmentServerIPUdpPort=5001 | |||||
}; | |||||
var hex = JT808Serializer.Serialize(jT808UploadLocationRequest).ToHexString(); | |||||
Assert.Equal("0B3139322E3136382E312E311388138934343434343434191210183100030201313131313131313131313131313131313131313131313131313131313131313100000000000000000000000000000000", hex); | |||||
} | |||||
[Fact] | |||||
public void Deserialize() | |||||
{ | |||||
var jT808UploadLocationRequest = JT808Serializer.Deserialize<JT808_0x9208>("0B3139322E3136382E312E311388138934343434343434191210183100030201313131313131313131313131313131313131313131313131313131313131313100000000000000000000000000000000".ToHexBytes()); | |||||
Assert.Equal("11111111111111111111111111111111", jT808UploadLocationRequest.AlarmId); | |||||
Assert.Equal(1, jT808UploadLocationRequest.AlarmIdentification.Retain); | |||||
Assert.Equal(2, jT808UploadLocationRequest.AlarmIdentification.AttachCount); | |||||
Assert.Equal(3, jT808UploadLocationRequest.AlarmIdentification.SN); | |||||
Assert.Equal("4444444", jT808UploadLocationRequest.AlarmIdentification.TerminalID); | |||||
Assert.Equal(Convert.ToDateTime("2019-12-10 18:31:00"), jT808UploadLocationRequest.AlarmIdentification.Time); | |||||
Assert.Equal("192.168.1.1", jT808UploadLocationRequest.AttachmentServerIP); | |||||
Assert.Equal("192.168.1.1".Length, jT808UploadLocationRequest.AttachmentServerIPLength); | |||||
Assert.Equal(5000, jT808UploadLocationRequest.AttachmentServerIPTcpPort); | |||||
Assert.Equal(5001, jT808UploadLocationRequest.AttachmentServerIPUdpPort); | |||||
} | |||||
[Fact] | |||||
public void Json() | |||||
{ | |||||
var json = JT808Serializer.Analyze<JT808_0x9208>("0B3139322E3136382E312E311388138934343434343434191210183100030201313131313131313131313131313131313131313131313131313131313131313100000000000000000000000000000000".ToHexBytes()); | |||||
} | |||||
} | |||||
} |
@@ -0,0 +1,66 @@ | |||||
using JT808.Protocol.Extensions.JTActiveSafety.MessageBody; | |||||
using JT808.Protocol.MessageBody; | |||||
using Microsoft.Extensions.DependencyInjection; | |||||
using System; | |||||
using System.Collections.Generic; | |||||
using System.Text; | |||||
using Xunit; | |||||
namespace JT808.Protocol.Extensions.JTActiveSafety.Test | |||||
{ | |||||
public class JT808_0x9212_Test | |||||
{ | |||||
JT808Serializer JT808Serializer; | |||||
public JT808_0x9212_Test() | |||||
{ | |||||
ServiceCollection serviceDescriptors = new ServiceCollection(); | |||||
serviceDescriptors.AddJT808Configure() | |||||
.AddJTActiveSafetyConfigure(); | |||||
IJT808Config jT808Config = serviceDescriptors.BuildServiceProvider().GetRequiredService<IJT808Config>(); | |||||
JT808Serializer = new JT808Serializer(jT808Config); | |||||
} | |||||
[Fact] | |||||
public void Serializer() | |||||
{ | |||||
JT808_0x9212 jT808UploadLocationRequest = new JT808_0x9212 | |||||
{ | |||||
DataPackageCount=2, | |||||
DataPackages=new List<Metadata.DataPackageProperty> { | |||||
new Metadata.DataPackageProperty{ | |||||
Length=10, | |||||
Offset=20 | |||||
}, | |||||
new Metadata.DataPackageProperty{ | |||||
Length=30, | |||||
Offset=40 | |||||
} | |||||
}, | |||||
FileName= "FileName", | |||||
FileType=1, | |||||
UploadResult=2 | |||||
}; | |||||
var hex = JT808Serializer.Serialize(jT808UploadLocationRequest).ToHexString(); | |||||
Assert.Equal("0846696C654E616D65010202000000140000000A000000280000001E", hex); | |||||
} | |||||
[Fact] | |||||
public void Deserialize() | |||||
{ | |||||
var jT808UploadLocationRequest = JT808Serializer.Deserialize<JT808_0x9212>("0846696C654E616D65010202000000140000000A000000280000001E".ToHexBytes()); | |||||
Assert.Equal(2, jT808UploadLocationRequest.DataPackageCount); | |||||
Assert.Equal("FileName", jT808UploadLocationRequest.FileName); | |||||
Assert.Equal(1, jT808UploadLocationRequest.FileType); | |||||
Assert.Equal(2, jT808UploadLocationRequest.UploadResult); | |||||
Assert.Equal(10u, jT808UploadLocationRequest.DataPackages[0].Length); | |||||
Assert.Equal(20u, jT808UploadLocationRequest.DataPackages[0].Offset); | |||||
Assert.Equal(30u, jT808UploadLocationRequest.DataPackages[1].Length); | |||||
Assert.Equal(40u, jT808UploadLocationRequest.DataPackages[1].Offset); | |||||
} | |||||
[Fact] | |||||
public void Json() | |||||
{ | |||||
var json = JT808Serializer.Analyze<JT808_0x9212>("0846696C654E616D65010202000000140000000A000000280000001E".ToHexBytes()); | |||||
} | |||||
} | |||||
} |
@@ -0,0 +1,33 @@ | |||||
using System; | |||||
using System.Collections.Generic; | |||||
using System.Text; | |||||
namespace JT808.Protocol.Extensions.JTActiveSafety.Enums | |||||
{ | |||||
/// <summary> | |||||
/// 主动拍照策略 | |||||
/// </summary> | |||||
public enum ActivePhotographyStrategyType:byte | |||||
{ | |||||
/// <summary> | |||||
/// 不开启 | |||||
/// </summary> | |||||
不开启 = 0x00, | |||||
/// <summary> | |||||
/// 定时拍照 | |||||
/// </summary> | |||||
定时拍照 = 0x01, | |||||
/// <summary> | |||||
/// 定距拍照 | |||||
/// </summary> | |||||
定距拍照 = 0x02, | |||||
/// <summary> | |||||
/// 保留 | |||||
/// </summary> | |||||
保留 = 0x03, | |||||
/// <summary> | |||||
/// 不修改参数 | |||||
/// </summary> | |||||
不修改参数 = 0xFF | |||||
} | |||||
} |
@@ -0,0 +1,33 @@ | |||||
using System; | |||||
using System.Collections.Generic; | |||||
using System.Text; | |||||
namespace JT808.Protocol.Extensions.JTActiveSafety.Enums | |||||
{ | |||||
/// <summary> | |||||
/// 主动安全消息Id | |||||
/// </summary> | |||||
public enum JT808_JTActiveSafety_MsgId : ushort | |||||
{ | |||||
/// <summary> | |||||
/// 报警附件信息消息 | |||||
/// </summary> | |||||
报警附件信息消息 = 0x1210, | |||||
/// <summary> | |||||
/// 文件信息上传 | |||||
/// </summary> | |||||
文件信息上传 = 0x1211, | |||||
/// <summary> | |||||
/// 文件上传完成消息 | |||||
/// </summary> | |||||
文件上传完成消息 = 0x1212, | |||||
/// <summary> | |||||
/// 报警附件上传指令 | |||||
/// </summary> | |||||
报警附件上传指令 = 0x9208, | |||||
/// <summary> | |||||
/// 文件上传完成消息应答 | |||||
/// </summary> | |||||
文件上传完成消息应答 = 0x9212, | |||||
} | |||||
} |
@@ -0,0 +1,41 @@ | |||||
using System; | |||||
using System.Collections.Generic; | |||||
using System.Text; | |||||
namespace JT808.Protocol.Extensions.JTActiveSafety.Enums | |||||
{ | |||||
/// <summary> | |||||
/// 拍照分辨率 | |||||
/// </summary> | |||||
public enum PhotoResolutionType:byte | |||||
{ | |||||
/// <summary> | |||||
/// 352x288 | |||||
/// </summary> | |||||
x352_288 = 0x01, | |||||
/// <summary> | |||||
/// 704x288 | |||||
/// </summary> | |||||
x704_288 = 0x02, | |||||
/// <summary> | |||||
/// 704x576 | |||||
/// </summary> | |||||
x704_576 = 0x03, | |||||
/// <summary> | |||||
/// 640x480 | |||||
/// </summary> | |||||
x640_480 = 0x04, | |||||
/// <summary> | |||||
/// 1280x720 | |||||
/// </summary> | |||||
x1280_720 = 0x05, | |||||
/// <summary> | |||||
/// 1920x1080 | |||||
/// </summary> | |||||
x1920_1080 = 0x06, | |||||
/// <summary> | |||||
/// 不修改参数 | |||||
/// </summary> | |||||
不修改参数 = 0xFF | |||||
} | |||||
} |
@@ -0,0 +1,29 @@ | |||||
using System; | |||||
using System.Collections.Generic; | |||||
using System.Text; | |||||
namespace JT808.Protocol.Extensions.JTActiveSafety.Enums | |||||
{ | |||||
/// <summary> | |||||
/// USB编号类型 | |||||
/// </summary> | |||||
public enum USBIDType:byte | |||||
{ | |||||
/// <summary> | |||||
/// 高级驾驶辅助系统 | |||||
/// </summary> | |||||
ADAS = 0x64, | |||||
/// <summary> | |||||
/// 驾驶员状态监控系统 | |||||
/// </summary> | |||||
DSM = 0x65, | |||||
/// <summary> | |||||
/// 轮胎气压监测系统 | |||||
/// </summary> | |||||
TPMS = 0x66, | |||||
/// <summary> | |||||
/// 盲点监测系统 | |||||
/// </summary> | |||||
BSD = 0x67 | |||||
} | |||||
} |
@@ -0,0 +1,45 @@ | |||||
using System; | |||||
using System.Collections.Generic; | |||||
using System.Text; | |||||
namespace JT808.Protocol.Extensions.JTActiveSafety.Enums | |||||
{ | |||||
/// <summary> | |||||
/// 视频录制分辨率 | |||||
/// </summary> | |||||
public enum VideoRecordingResolutionType:byte | |||||
{ | |||||
/// <summary> | |||||
/// CIF | |||||
/// </summary> | |||||
CIF = 0x01, | |||||
/// <summary> | |||||
/// HD1 | |||||
/// </summary> | |||||
HD1 = 0x02, | |||||
/// <summary> | |||||
/// D1 | |||||
/// </summary> | |||||
D1 = 0x03, | |||||
/// <summary> | |||||
/// WD1 | |||||
/// </summary> | |||||
WD1 = 0x04, | |||||
/// <summary> | |||||
/// VGA | |||||
/// </summary> | |||||
VGA = 0x05, | |||||
/// <summary> | |||||
/// 720P | |||||
/// </summary> | |||||
_720P = 0x06, | |||||
/// <summary> | |||||
/// 1080P | |||||
/// </summary> | |||||
_1080P = 0x07, | |||||
/// <summary> | |||||
/// 不修改参数 | |||||
/// </summary> | |||||
不修改参数 = 0xFF | |||||
} | |||||
} |
@@ -0,0 +1,33 @@ | |||||
using System; | |||||
using System.Collections.Generic; | |||||
using System.Text; | |||||
namespace JT808.Protocol.Extensions.JTActiveSafety.Enums | |||||
{ | |||||
/// <summary> | |||||
/// 工作状态 | |||||
/// </summary> | |||||
public enum WorkingConditionType:byte | |||||
{ | |||||
/// <summary> | |||||
/// 正常工作 | |||||
/// </summary> | |||||
正常工作 = 0x01, | |||||
/// <summary> | |||||
/// 待机状态 | |||||
/// </summary> | |||||
待机状态 = 0x02, | |||||
/// <summary> | |||||
/// 升级维护 | |||||
/// </summary> | |||||
升级维护 = 0x03, | |||||
/// <summary> | |||||
/// 设备异常 | |||||
/// </summary> | |||||
设备异常 = 0x04, | |||||
/// <summary> | |||||
/// 断开连接 | |||||
/// </summary> | |||||
断开连接 = 0x10, | |||||
} | |||||
} |
@@ -0,0 +1,36 @@ | |||||
<Project Sdk="Microsoft.NET.Sdk"> | |||||
<PropertyGroup> | |||||
<TargetFrameworks>netstandard2.0;netstandard2.1;net5.0;</TargetFrameworks> | |||||
<LangVersion>9.0</LangVersion> | |||||
<Copyright>Copyright 2019.</Copyright> | |||||
<Authors>SmallChi(Koike)</Authors> | |||||
<PackageId>JT808.Protocol.Extensions.JTActiveSafety</PackageId> | |||||
<Product>JT808.Protocol.Extensions.JTActiveSafety</Product> | |||||
<Description>基于JT808协议、GB808协议扩展的主动安全消息协议(苏标)</Description> | |||||
<PackageReleaseNotes>基于JT808协议、GB808协议扩展的主动安全消息协议(苏标)</PackageReleaseNotes> | |||||
<PackageRequireLicenseAcceptance>true</PackageRequireLicenseAcceptance> | |||||
<RepositoryUrl>https://github.com/SmallChi/JTActiveSafety</RepositoryUrl> | |||||
<PackageProjectUrl>https://github.com/SmallChi/JTActiveSafety</PackageProjectUrl> | |||||
<licenseUrl>https://github.com/SmallChi/JT808/blob/master/LICENSE</licenseUrl> | |||||
<license>https://github.com/SmallChi/JT808/blob/master/LICENSE</license> | |||||
<GeneratePackageOnBuild>false</GeneratePackageOnBuild> | |||||
<DocumentationFile>JT808.Protocol.Extensions.JTActiveSafety.xml</DocumentationFile> | |||||
<Version>1.1.7</Version> | |||||
<PackageLicenseFile>LICENSE</PackageLicenseFile> | |||||
</PropertyGroup> | |||||
<ItemGroup> | |||||
<None Include="..\..\..\LICENSE"> | |||||
<Pack>True</Pack> | |||||
<PackagePath></PackagePath> | |||||
</None> | |||||
</ItemGroup> | |||||
<ItemGroup> | |||||
<ProjectReference Include="..\..\JT808.Protocol\JT808.Protocol.csproj" /> | |||||
</ItemGroup> | |||||
</Project> |
@@ -0,0 +1,53 @@ | |||||
using System; | |||||
using System.Collections.Generic; | |||||
using System.Text; | |||||
namespace JT808.Protocol.Extensions.JTActiveSafety | |||||
{ | |||||
/// <summary> | |||||
/// 主动安全常量 | |||||
/// </summary> | |||||
public static class JT808_JTActiveSafety_Constants | |||||
{ | |||||
/// <summary> | |||||
/// 附加信息ID 高级驾驶辅助系统报警信息 | |||||
/// </summary> | |||||
public const byte JT808_0X0200_0x64 = 0x64; | |||||
/// <summary> | |||||
/// 附加信息ID 驾驶员状态监测系统报警信息 | |||||
/// </summary> | |||||
public const byte JT808_0X0200_0x65 = 0x65; | |||||
/// <summary> | |||||
/// 附加信息ID 胎压监测系统报警信息 | |||||
/// </summary> | |||||
public const byte JT808_0X0200_0x66 = 0x66; | |||||
/// <summary> | |||||
/// 附加信息ID 盲区监测系统报警信息 | |||||
/// </summary> | |||||
public const byte JT808_0X0200_0x67 = 0x67; | |||||
/// <summary> | |||||
/// 高级驾驶辅助系统参数设置 | |||||
/// </summary> | |||||
public const uint JT808_0X8103_0xF364 = 0xF364; | |||||
/// <summary> | |||||
/// 驾驶员状态监测系统参数设置 | |||||
/// </summary> | |||||
public const uint JT808_0X8103_0xF365 = 0xF365; | |||||
/// <summary> | |||||
/// 胎压监测系统参数设置 | |||||
/// </summary> | |||||
public const uint JT808_0X8103_0xF366 = 0xF366; | |||||
/// <summary> | |||||
/// 盲区监测系统参数设置 | |||||
/// </summary> | |||||
public const uint JT808_0X8103_0xF367 = 0xF367; | |||||
/// <summary> | |||||
/// 状态查询 | |||||
/// </summary> | |||||
public const byte JT808_0X0900_0xF7 = 0xF7; | |||||
/// <summary> | |||||
/// 信息查询 | |||||
/// </summary> | |||||
public const byte JT808_0X0900_0xF8 = 0xF8; | |||||
} | |||||
} |
@@ -0,0 +1,28 @@ | |||||
using JT808.Protocol.Extensions.JTActiveSafety.Enums; | |||||
using JT808.Protocol.Extensions.JTActiveSafety.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.JTActiveSafety | |||||
{ | |||||
/// <summary> | |||||
/// 主动安全扩展 | |||||
/// </summary> | |||||
public static class JTActiveSafetyDependencyInjectionExtensions | |||||
{ | |||||
/// <summary> | |||||
/// 添加主动安全 | |||||
/// </summary> | |||||
/// <param name="jT808Builder"></param> | |||||
/// <returns></returns> | |||||
public static IJT808Builder AddJTActiveSafetyConfigure(this IJT808Builder jT808Builder) | |||||
{ | |||||
jT808Builder.Config.Register(Assembly.GetExecutingAssembly()); | |||||
return jT808Builder; | |||||
} | |||||
} | |||||
} |
@@ -0,0 +1,344 @@ | |||||
using JT808.Protocol.Extensions.JTActiveSafety.Metadata; | |||||
using JT808.Protocol.Formatters; | |||||
using JT808.Protocol.Interfaces; | |||||
using JT808.Protocol.MessageBody; | |||||
using JT808.Protocol.MessagePack; | |||||
using System; | |||||
using System.Collections.Generic; | |||||
using System.Text; | |||||
using System.Text.Json; | |||||
namespace JT808.Protocol.Extensions.JTActiveSafety.MessageBody | |||||
{ | |||||
/// <summary> | |||||
/// 高级驾驶辅助系统报警信息 | |||||
/// </summary> | |||||
public class JT808_0x0200_0x64 : JT808_0x0200_BodyBase, IJT808MessagePackFormatter<JT808_0x0200_0x64>, IJT808Analyze | |||||
{ | |||||
/// <summary> | |||||
/// 高级驾驶辅助系统报警信息Id | |||||
/// </summary> | |||||
public override byte AttachInfoId { get; set; } = JT808_JTActiveSafety_Constants.JT808_0X0200_0x64; | |||||
/// <summary> | |||||
/// 高级驾驶辅助系统报警信息附加长度 | |||||
/// </summary> | |||||
public override byte AttachInfoLength { get; set; } = 32; | |||||
/// <summary> | |||||
/// 报警ID | |||||
/// </summary> | |||||
public uint AlarmId { get; set; } | |||||
/// <summary> | |||||
/// 标志状态 | |||||
/// </summary> | |||||
public byte FlagState { get; set; } | |||||
/// <summary> | |||||
/// 报警/事件类型 | |||||
/// </summary> | |||||
public byte AlarmOrEventType{ get; set; } | |||||
/// <summary> | |||||
/// 报警/事件类型 | |||||
/// </summary> | |||||
public byte AlarmLevel { get; set; } | |||||
/// <summary> | |||||
/// 前车车速 | |||||
/// </summary> | |||||
public byte VehicleSpeed { get; set; } | |||||
/// <summary> | |||||
/// 前车/行人距离 | |||||
/// </summary> | |||||
public byte CarOrPedestrianDistanceAhead { get; set; } | |||||
/// <summary> | |||||
/// 偏离类型 | |||||
/// </summary> | |||||
public byte DeviateType { get; set; } | |||||
/// <summary> | |||||
/// 道路标志识别类型 | |||||
/// </summary> | |||||
public byte RoadSignIdentificationType { get; set; } | |||||
/// <summary> | |||||
/// 道路标志识别类型 | |||||
/// </summary> | |||||
public byte RoadSignIdentificationData { get; set; } | |||||
/// <summary> | |||||
/// 车速 | |||||
/// </summary> | |||||
public byte Speed { get; set; } | |||||
/// <summary> | |||||
/// 高程 | |||||
/// </summary> | |||||
public ushort Altitude { get; set; } | |||||
/// <summary> | |||||
/// 纬度 | |||||
/// </summary> | |||||
public int Latitude { get; set; } | |||||
/// <summary> | |||||
/// 经度 | |||||
/// </summary> | |||||
public int Longitude { get; set; } | |||||
/// <summary> | |||||
/// 日期时间 | |||||
/// YYMMDDhhmmss | |||||
/// BCD[6] | |||||
/// </summary> | |||||
public DateTime AlarmTime { get; set; } | |||||
/// <summary> | |||||
/// 车辆状态 | |||||
/// </summary> | |||||
public ushort VehicleState { get; set; } | |||||
/// <summary> | |||||
/// 报警标识号 | |||||
/// </summary> | |||||
public AlarmIdentificationProperty AlarmIdentification { get; set; } | |||||
/// <summary> | |||||
/// | |||||
/// </summary> | |||||
/// <param name="reader"></param> | |||||
/// <param name="writer"></param> | |||||
/// <param name="config"></param> | |||||
public void Analyze(ref JT808MessagePackReader reader, Utf8JsonWriter writer, IJT808Config config) | |||||
{ | |||||
JT808_0x0200_0x64 value = new JT808_0x0200_0x64(); | |||||
value.AttachInfoId = reader.ReadByte(); | |||||
writer.WriteNumber($"[{value.AttachInfoId.ReadNumber()}]附加信息Id", value.AttachInfoId); | |||||
value.AttachInfoLength = reader.ReadByte(); | |||||
writer.WriteNumber($"[{value.AttachInfoLength.ReadNumber()}]附加信息长度", value.AttachInfoLength); | |||||
value.AlarmId = reader.ReadUInt32(); | |||||
writer.WriteNumber($"[{value.AlarmId.ReadNumber()}]报警ID", value.AlarmId); | |||||
value.FlagState = reader.ReadByte(); | |||||
string flagStateString = "未知"; | |||||
switch (value.FlagState) | |||||
{ | |||||
case 0: | |||||
flagStateString = "不可用"; | |||||
break; | |||||
case 1: | |||||
flagStateString = "开始标志"; | |||||
break; | |||||
case 2: | |||||
flagStateString = "结束标志"; | |||||
break; | |||||
} | |||||
writer.WriteNumber($"[{value.FlagState.ReadNumber()}]标志状态-{flagStateString}", value.FlagState); | |||||
value.AlarmOrEventType = reader.ReadByte(); | |||||
string alarmOrEventTypeString = ""; | |||||
string vehicleSpeedString = "无效"; | |||||
string carOrPedestrianDistanceAheadString = "无效"; | |||||
string deviateTypeString = "无效"; | |||||
string roadSignIdentificationTypeString = "无效"; | |||||
switch (value.AlarmOrEventType) | |||||
{ | |||||
case 0x01: | |||||
alarmOrEventTypeString = "前向碰撞报警"; | |||||
vehicleSpeedString = "有效"; | |||||
carOrPedestrianDistanceAheadString = "有效"; | |||||
break; | |||||
case 0x02: | |||||
alarmOrEventTypeString = "车道偏离报警"; | |||||
vehicleSpeedString = "有效"; | |||||
carOrPedestrianDistanceAheadString = "有效"; | |||||
deviateTypeString = "有效"; | |||||
break; | |||||
case 0x03: | |||||
alarmOrEventTypeString = "车距过近报警"; | |||||
break; | |||||
case 0x04: | |||||
alarmOrEventTypeString = "行人碰撞报警"; | |||||
vehicleSpeedString = "有效"; | |||||
break; | |||||
case 0x05: | |||||
alarmOrEventTypeString = "频繁变道报警"; | |||||
break; | |||||
case 0x06: | |||||
alarmOrEventTypeString = "道路标识超限报警"; | |||||
roadSignIdentificationTypeString = "有效"; | |||||
break; | |||||
case 0x07: | |||||
alarmOrEventTypeString = "障碍物报警"; | |||||
break; | |||||
case 0x08: | |||||
case 0x09: | |||||
case 0x0A: | |||||
case 0x0B: | |||||
case 0x0C: | |||||
case 0x0D: | |||||
case 0x0E: | |||||
case 0x0F: | |||||
alarmOrEventTypeString = "用户自定义"; | |||||
break; | |||||
case 0x10: | |||||
roadSignIdentificationTypeString = "有效"; | |||||
alarmOrEventTypeString = "道路标志识别事件"; | |||||
break; | |||||
case 0x11: | |||||
alarmOrEventTypeString = "主动抓拍事件"; | |||||
break; | |||||
case 0x12: | |||||
case 0x13: | |||||
case 0x14: | |||||
case 0x15: | |||||
case 0x16: | |||||
case 0x17: | |||||
case 0x18: | |||||
case 0x19: | |||||
case 0x1A: | |||||
case 0x1B: | |||||
case 0x1C: | |||||
case 0x1D: | |||||
case 0x1E: | |||||
case 0x1F: | |||||
alarmOrEventTypeString = "用户自定义"; | |||||
break; | |||||
} | |||||
writer.WriteNumber($"[{value.AlarmOrEventType.ReadNumber()}]报警_事件类型-{alarmOrEventTypeString}", value.AlarmOrEventType); | |||||
value.AlarmLevel = reader.ReadByte(); | |||||
string alarmLevelString = "未知"; | |||||
switch (value.AlarmLevel) | |||||
{ | |||||
case 0x01: | |||||
alarmLevelString = "一级报警"; | |||||
break; | |||||
case 0x02: | |||||
alarmLevelString = "二级报警"; | |||||
break; | |||||
} | |||||
writer.WriteNumber($"[{value.AlarmLevel.ReadNumber()}]报警级别-{alarmLevelString}", value.AlarmLevel); | |||||
value.VehicleSpeed = reader.ReadByte(); | |||||
writer.WriteNumber($"[{value.VehicleSpeed.ReadNumber()}]前车车速-{vehicleSpeedString}", value.VehicleSpeed); | |||||
value.CarOrPedestrianDistanceAhead = reader.ReadByte(); | |||||
writer.WriteNumber($"[{value.CarOrPedestrianDistanceAhead.ReadNumber()}]前车_行人距离-{carOrPedestrianDistanceAheadString}", value.CarOrPedestrianDistanceAhead); | |||||
value.DeviateType = reader.ReadByte(); | |||||
string deviateType = value.DeviateType == 0x01 ? "左侧偏离" : "右侧偏离"; | |||||
writer.WriteNumber($"[{value.DeviateType.ReadNumber()}]偏离类型-{deviateType}-{deviateTypeString}", value.DeviateType); | |||||
value.RoadSignIdentificationType = reader.ReadByte(); | |||||
string roadSignIdentificationType = "未知标志"; | |||||
if (value.RoadSignIdentificationType == 0x01) | |||||
{ | |||||
roadSignIdentificationType = "限速标志"; | |||||
} | |||||
else if (value.RoadSignIdentificationType == 0x02) | |||||
{ | |||||
roadSignIdentificationType = "限高标志"; | |||||
} | |||||
else if (value.RoadSignIdentificationType == 0x03) | |||||
{ | |||||
roadSignIdentificationType = "限重标志"; | |||||
} | |||||
writer.WriteNumber($"[{value.RoadSignIdentificationType.ReadNumber()}]道路标志识别类型-{roadSignIdentificationType}-{roadSignIdentificationTypeString}", value.RoadSignIdentificationType); | |||||
value.RoadSignIdentificationData = reader.ReadByte(); | |||||
writer.WriteNumber($"[{value.RoadSignIdentificationData.ReadNumber()}]道路标志识别数据", value.RoadSignIdentificationData); | |||||
value.Speed = reader.ReadByte(); | |||||
writer.WriteNumber($"[{value.Speed.ReadNumber()}]车速", value.Speed); | |||||
value.Altitude = reader.ReadUInt16(); | |||||
writer.WriteNumber($"[{value.Altitude.ReadNumber()}]高程", value.Altitude); | |||||
value.Latitude = (int)reader.ReadUInt32(); | |||||
writer.WriteNumber($"[{value.Latitude.ReadNumber()}]纬度", value.Latitude); | |||||
value.Longitude = (int)reader.ReadUInt32(); | |||||
writer.WriteNumber($"[{value.Longitude.ReadNumber()}]经度", value.Longitude); | |||||
value.AlarmTime = reader.ReadDateTime6(); | |||||
writer.WriteString($"[{value.AlarmTime.ToString("yyMMddHHmmss")}]日期时间", value.AlarmTime.ToString("yyyy-MM-dd HH:mm:ss")); | |||||
value.VehicleState = reader.ReadUInt16(); | |||||
writer.WriteNumber($"[{value.VehicleState.ReadNumber()}]车辆状态", value.VehicleState); | |||||
var vehicleStateBits = Convert.ToString(value.VehicleState, 2).PadLeft(16, '0'); | |||||
writer.WriteStartObject($"车辆状态对象[{vehicleStateBits}]"); | |||||
writer.WriteString($"[{vehicleStateBits[15]}]Bit0ACC状态", vehicleStateBits[15] == '0' ? "关闭" : "打开"); | |||||
writer.WriteString($"[{vehicleStateBits[14]}]Bit1左转向状态", vehicleStateBits[14] == '0' ? "关闭" : "打开"); | |||||
writer.WriteString($"[{vehicleStateBits[13]}]Bit2右转向状态", vehicleStateBits[13] == '0' ? "关闭" : "打开"); | |||||
writer.WriteString($"[{vehicleStateBits[12]}]Bit3雨刮器状态", vehicleStateBits[12] == '0' ? "关闭" : "打开"); | |||||
writer.WriteString($"[{vehicleStateBits[11]}]Bit4制动状态", vehicleStateBits[11] == '0' ? "未制动" : "制动"); | |||||
writer.WriteString($"[{vehicleStateBits[10]}]Bit5插卡状态", vehicleStateBits[10] == '0' ? "未插卡" : "已插卡"); | |||||
writer.WriteString($"[{vehicleStateBits[9]}]Bit6自定义", vehicleStateBits[9].ToString()); | |||||
writer.WriteString($"[{vehicleStateBits[8]}]Bit7自定义", vehicleStateBits[8].ToString()); | |||||
writer.WriteString($"[{vehicleStateBits[7]}]Bit8自定义", vehicleStateBits[7].ToString()); | |||||
writer.WriteString($"[{vehicleStateBits[6]}]Bit9自定义", vehicleStateBits[6].ToString()); | |||||
writer.WriteString($"[{vehicleStateBits[5]}]Bit10定位状态", vehicleStateBits[5] == '0' ? "未定位" : "已定位"); | |||||
writer.WriteString($"[{vehicleStateBits[4]}]Bit11自定义", vehicleStateBits[4].ToString()); | |||||
writer.WriteString($"[{vehicleStateBits[3]}]Bit12自定义", vehicleStateBits[3].ToString()); | |||||
writer.WriteString($"[{vehicleStateBits[2]}]Bit13自定义", vehicleStateBits[2].ToString()); | |||||
writer.WriteString($"[{vehicleStateBits[1]}]Bit14自定义", vehicleStateBits[1].ToString()); | |||||
writer.WriteString($"[{vehicleStateBits[0]}]Bit15自定义", vehicleStateBits[0].ToString()); | |||||
writer.WriteEndObject(); | |||||
value.AlarmIdentification = new AlarmIdentificationProperty(); | |||||
string terminalIDHex = reader.ReadVirtualArray(7).ToArray().ToHexString(); | |||||
value.AlarmIdentification.TerminalID = reader.ReadString(7); | |||||
value.AlarmIdentification.Time = reader.ReadDateTime6(); | |||||
value.AlarmIdentification.SN = reader.ReadByte(); | |||||
value.AlarmIdentification.AttachCount = reader.ReadByte(); | |||||
value.AlarmIdentification.Retain = reader.ReadByte(); | |||||
writer.WriteString($"[{terminalIDHex}]终端ID", value.AlarmIdentification.TerminalID); | |||||
writer.WriteString($"[{value.AlarmIdentification.Time.ToString("yyMMddHHmmss")}]日期时间", value.AlarmIdentification.Time.ToString("yyyy-MM-dd HH:mm:ss")); | |||||
writer.WriteNumber($"[{value.AlarmIdentification.SN.ReadNumber()}]序号", value.AlarmIdentification.SN); | |||||
writer.WriteNumber($"[{value.AlarmIdentification.AttachCount.ReadNumber()}]附件数量", value.AlarmIdentification.AttachCount); | |||||
writer.WriteNumber($"[{value.AlarmIdentification.Retain.ReadNumber()}]预留", value.AlarmIdentification.Retain); | |||||
} | |||||
/// <summary> | |||||
/// | |||||
/// </summary> | |||||
/// <param name="reader"></param> | |||||
/// <param name="config"></param> | |||||
/// <returns></returns> | |||||
public JT808_0x0200_0x64 Deserialize(ref JT808MessagePackReader reader, IJT808Config config) | |||||
{ | |||||
JT808_0x0200_0x64 value = new JT808_0x0200_0x64(); | |||||
value.AttachInfoId = reader.ReadByte(); | |||||
value.AttachInfoLength = reader.ReadByte(); | |||||
value.AlarmId = reader.ReadUInt32(); | |||||
value.FlagState = reader.ReadByte(); | |||||
value.AlarmOrEventType = reader.ReadByte(); | |||||
value.AlarmLevel = reader.ReadByte(); | |||||
value.VehicleSpeed = reader.ReadByte(); | |||||
value.CarOrPedestrianDistanceAhead = reader.ReadByte(); | |||||
value.DeviateType = reader.ReadByte(); | |||||
value.RoadSignIdentificationType = reader.ReadByte(); | |||||
value.RoadSignIdentificationData = reader.ReadByte(); | |||||
value.Speed = reader.ReadByte(); | |||||
value.Altitude = reader.ReadUInt16(); | |||||
value.Latitude = (int)reader.ReadUInt32(); | |||||
value.Longitude = (int)reader.ReadUInt32(); | |||||
value.AlarmTime = reader.ReadDateTime6(); | |||||
value.VehicleState = reader.ReadUInt16(); | |||||
value.AlarmIdentification = new AlarmIdentificationProperty | |||||
{ | |||||
TerminalID = reader.ReadString(7), | |||||
Time = reader.ReadDateTime6(), | |||||
SN = reader.ReadByte(), | |||||
AttachCount = reader.ReadByte(), | |||||
Retain = reader.ReadByte() | |||||
}; | |||||
return value; | |||||
} | |||||
/// <summary> | |||||
/// | |||||
/// </summary> | |||||
/// <param name="writer"></param> | |||||
/// <param name="value"></param> | |||||
/// <param name="config"></param> | |||||
public void Serialize(ref JT808MessagePackWriter writer, JT808_0x0200_0x64 value, IJT808Config config) | |||||
{ | |||||
writer.WriteByte(value.AttachInfoId); | |||||
writer.WriteByte(value.AttachInfoLength); | |||||
writer.WriteUInt32(value.AlarmId); | |||||
writer.WriteByte(value.FlagState); | |||||
writer.WriteByte(value.AlarmOrEventType); | |||||
writer.WriteByte(value.AlarmLevel); | |||||
writer.WriteByte(value.VehicleSpeed); | |||||
writer.WriteByte(value.CarOrPedestrianDistanceAhead); | |||||
writer.WriteByte(value.DeviateType); | |||||
writer.WriteByte(value.RoadSignIdentificationType); | |||||
writer.WriteByte(value.RoadSignIdentificationData); | |||||
writer.WriteByte(value.Speed); | |||||
writer.WriteUInt16(value.Altitude); | |||||
writer.WriteUInt32((uint)value.Latitude); | |||||
writer.WriteUInt32((uint)value.Longitude); | |||||
writer.WriteDateTime6(value.AlarmTime); | |||||
writer.WriteUInt16(value.VehicleState); | |||||
if (value.AlarmIdentification == null) { | |||||
throw new NullReferenceException($"{nameof(AlarmIdentificationProperty)}不为空"); | |||||
} | |||||
writer.WriteString(value.AlarmIdentification.TerminalID); | |||||
writer.WriteDateTime6(value.AlarmIdentification.Time); | |||||
writer.WriteByte(value.AlarmIdentification.SN); | |||||
writer.WriteByte(value.AlarmIdentification.AttachCount); | |||||
writer.WriteByte(value.AlarmIdentification.Retain); | |||||
} | |||||
} | |||||
} |
@@ -0,0 +1,295 @@ | |||||
using JT808.Protocol.Extensions.JTActiveSafety.Metadata; | |||||
using JT808.Protocol.Formatters; | |||||
using JT808.Protocol.Interfaces; | |||||
using JT808.Protocol.MessageBody; | |||||
using JT808.Protocol.MessagePack; | |||||
using System; | |||||
using System.Collections.Generic; | |||||
using System.Text; | |||||
using System.Text.Json; | |||||
namespace JT808.Protocol.Extensions.JTActiveSafety.MessageBody | |||||
{ | |||||
/// <summary> | |||||
/// 驾驶员状态监测系统报警信息 | |||||
/// </summary> | |||||
public class JT808_0x0200_0x65 : JT808_0x0200_BodyBase, IJT808MessagePackFormatter<JT808_0x0200_0x65>, IJT808Analyze | |||||
{ | |||||
/// <summary> | |||||
/// 驾驶员状态监测系统报警信息Id | |||||
/// </summary> | |||||
public override byte AttachInfoId { get; set; } = JT808_JTActiveSafety_Constants.JT808_0X0200_0x65; | |||||
/// <summary> | |||||
/// 驾驶员状态监测系统报警信息长度 | |||||
/// </summary> | |||||
public override byte AttachInfoLength { get; set; } = 47; | |||||
/// <summary> | |||||
/// 报警ID | |||||
/// </summary> | |||||
public uint AlarmId { get; set; } | |||||
/// <summary> | |||||
/// 标志状态 | |||||
/// </summary> | |||||
public byte FlagState { get; set; } | |||||
/// <summary> | |||||
/// 报警/事件类型 | |||||
/// </summary> | |||||
public byte AlarmOrEventType{ get; set; } | |||||
/// <summary> | |||||
/// 报警级别 | |||||
/// </summary> | |||||
public byte AlarmLevel { get; set; } | |||||
/// <summary> | |||||
/// 疲劳程度 | |||||
/// </summary> | |||||
public byte Fatigue { get; set; } | |||||
/// <summary> | |||||
/// 预留 | |||||
/// </summary> | |||||
public byte[] Retain { get; set; } = new byte[4]; | |||||
/// <summary> | |||||
/// 车速 | |||||
/// </summary> | |||||
public byte Speed { get; set; } | |||||
/// <summary> | |||||
/// 高程 | |||||
/// </summary> | |||||
public ushort Altitude { get; set; } | |||||
/// <summary> | |||||
/// 纬度 | |||||
/// </summary> | |||||
public int Latitude { get; set; } | |||||
/// <summary> | |||||
/// 经度 | |||||
/// </summary> | |||||
public int Longitude { get; set; } | |||||
/// <summary> | |||||
/// 日期时间 | |||||
/// YYMMDDhhmmss | |||||
/// BCD[6] | |||||
/// </summary> | |||||
public DateTime AlarmTime { get; set; } | |||||
/// <summary> | |||||
/// 车辆状态 | |||||
/// </summary> | |||||
public ushort VehicleState { get; set; } | |||||
/// <summary> | |||||
/// 报警标识号 | |||||
/// </summary> | |||||
public AlarmIdentificationProperty AlarmIdentification { get; set; } | |||||
/// <summary> | |||||
/// | |||||
/// </summary> | |||||
/// <param name="reader"></param> | |||||
/// <param name="writer"></param> | |||||
/// <param name="config"></param> | |||||
public void Analyze(ref JT808MessagePackReader reader, Utf8JsonWriter writer, IJT808Config config) | |||||
{ | |||||
JT808_0x0200_0x65 value = new JT808_0x0200_0x65(); | |||||
value.AttachInfoId = reader.ReadByte(); | |||||
writer.WriteNumber($"[{value.AttachInfoId.ReadNumber()}]附加信息Id", value.AttachInfoId); | |||||
value.AttachInfoLength = reader.ReadByte(); | |||||
writer.WriteNumber($"[{value.AttachInfoLength.ReadNumber()}]附加信息长度", value.AttachInfoLength); | |||||
value.AlarmId = reader.ReadUInt32(); | |||||
writer.WriteNumber($"[{value.AlarmId.ReadNumber()}]报警ID", value.AlarmId); | |||||
value.FlagState = reader.ReadByte(); | |||||
string flagStateString = "未知"; | |||||
switch (value.FlagState) | |||||
{ | |||||
case 0: | |||||
flagStateString = "不可用"; | |||||
break; | |||||
case 1: | |||||
flagStateString = "开始标志"; | |||||
break; | |||||
case 2: | |||||
flagStateString = "结束标志"; | |||||
break; | |||||
} | |||||
writer.WriteNumber($"[{value.FlagState.ReadNumber()}]标志状态-{flagStateString}", value.FlagState); | |||||
value.AlarmOrEventType = reader.ReadByte(); | |||||
string alarmOrEventTypeString = ""; | |||||
switch (value.AlarmOrEventType) | |||||
{ | |||||
case 0x01: | |||||
alarmOrEventTypeString = "疲劳驾驶报警"; | |||||
break; | |||||
case 0x02: | |||||
alarmOrEventTypeString = "接打电话报警"; | |||||
break; | |||||
case 0x03: | |||||
alarmOrEventTypeString = "抽烟报警"; | |||||
break; | |||||
case 0x04: | |||||
alarmOrEventTypeString = "分神驾驶报警"; | |||||
break; | |||||
case 0x05: | |||||
alarmOrEventTypeString = "驾驶员异常报警"; | |||||
break; | |||||
case 0x06: | |||||
case 0x07: | |||||
case 0x08: | |||||
case 0x09: | |||||
case 0x0A: | |||||
case 0x0B: | |||||
case 0x0C: | |||||
case 0x0D: | |||||
case 0x0E: | |||||
case 0x0F: | |||||
alarmOrEventTypeString = "用户自定义"; | |||||
break; | |||||
case 0x10: | |||||
alarmOrEventTypeString = "自动抓拍事件"; | |||||
break; | |||||
case 0x11: | |||||
alarmOrEventTypeString = "驾驶员变更事件"; | |||||
break; | |||||
case 0x12: | |||||
case 0x13: | |||||
case 0x14: | |||||
case 0x15: | |||||
case 0x16: | |||||
case 0x17: | |||||
case 0x18: | |||||
case 0x19: | |||||
case 0x1A: | |||||
case 0x1B: | |||||
case 0x1C: | |||||
case 0x1D: | |||||
case 0x1E: | |||||
case 0x1F: | |||||
alarmOrEventTypeString = "用户自定义"; | |||||
break; | |||||
} | |||||
writer.WriteNumber($"[{value.AlarmOrEventType.ReadNumber()}]报警_事件类型-{alarmOrEventTypeString}", value.AlarmOrEventType); | |||||
value.AlarmLevel = reader.ReadByte(); | |||||
string alarmLevelString = "未知"; | |||||
switch (value.AlarmLevel) | |||||
{ | |||||
case 0x01: | |||||
alarmLevelString = "一级报警"; | |||||
break; | |||||
case 0x02: | |||||
alarmLevelString = "二级报警"; | |||||
break; | |||||
} | |||||
writer.WriteNumber($"[{value.AlarmLevel.ReadNumber()}]报警级别-{alarmLevelString}", value.AlarmLevel); | |||||
value.Fatigue = reader.ReadByte(); | |||||
writer.WriteNumber($"[{value.Fatigue.ReadNumber()}]疲劳程度", value.Fatigue); | |||||
value.Retain = reader.ReadArray(4).ToArray(); | |||||
writer.WriteString("预留", value.Retain.ToHexString()); | |||||
value.Speed = reader.ReadByte(); | |||||
writer.WriteNumber($"[{value.Speed.ReadNumber()}]车速", value.Speed); | |||||
value.Altitude = reader.ReadUInt16(); | |||||
writer.WriteNumber($"[{value.Altitude.ReadNumber()}]高程", value.Altitude); | |||||
value.Latitude = (int)reader.ReadUInt32(); | |||||
writer.WriteNumber($"[{value.Latitude.ReadNumber()}]纬度", value.Latitude); | |||||
value.Longitude = (int)reader.ReadUInt32(); | |||||
writer.WriteNumber($"[{value.Longitude.ReadNumber()}]经度", value.Longitude); | |||||
value.AlarmTime = reader.ReadDateTime6(); | |||||
writer.WriteString($"[{value.AlarmTime.ToString("yyMMddHHmmss")}]日期时间", value.AlarmTime.ToString("yyyy-MM-dd HH:mm:ss")); | |||||
value.VehicleState = reader.ReadUInt16(); | |||||
writer.WriteNumber($"[{value.VehicleState.ReadNumber()}]车辆状态", value.VehicleState); | |||||
var vehicleStateBits = Convert.ToString(value.VehicleState, 2).PadLeft(16, '0'); | |||||
writer.WriteStartObject($"车辆状态对象[{vehicleStateBits}]"); | |||||
writer.WriteString($"[{vehicleStateBits[15]}]Bit0ACC状态", vehicleStateBits[15] == '0' ? "关闭" : "打开"); | |||||
writer.WriteString($"[{vehicleStateBits[14]}]Bit1左转向状态", vehicleStateBits[14] == '0' ? "关闭" : "打开"); | |||||
writer.WriteString($"[{vehicleStateBits[13]}]Bit2右转向状态", vehicleStateBits[13] == '0' ? "关闭" : "打开"); | |||||
writer.WriteString($"[{vehicleStateBits[12]}]Bit3雨刮器状态", vehicleStateBits[12] == '0' ? "关闭" : "打开"); | |||||
writer.WriteString($"[{vehicleStateBits[11]}]Bit4制动状态", vehicleStateBits[11] == '0' ? "未制动" : "制动"); | |||||
writer.WriteString($"[{vehicleStateBits[10]}]Bit5插卡状态", vehicleStateBits[10] == '0' ? "未插卡" : "已插卡"); | |||||
writer.WriteString($"[{vehicleStateBits[9]}]Bit6自定义", vehicleStateBits[9].ToString()); | |||||
writer.WriteString($"[{vehicleStateBits[8]}]Bit7自定义", vehicleStateBits[8].ToString()); | |||||
writer.WriteString($"[{vehicleStateBits[7]}]Bit8自定义", vehicleStateBits[7].ToString()); | |||||
writer.WriteString($"[{vehicleStateBits[6]}]Bit9自定义", vehicleStateBits[6].ToString()); | |||||
writer.WriteString($"[{vehicleStateBits[5]}]Bit10定位状态", vehicleStateBits[5] == '0' ? "未定位" : "已定位"); | |||||
writer.WriteString($"[{vehicleStateBits[4]}]Bit11自定义", vehicleStateBits[4].ToString()); | |||||
writer.WriteString($"[{vehicleStateBits[3]}]Bit12自定义", vehicleStateBits[3].ToString()); | |||||
writer.WriteString($"[{vehicleStateBits[2]}]Bit13自定义", vehicleStateBits[2].ToString()); | |||||
writer.WriteString($"[{vehicleStateBits[1]}]Bit14自定义", vehicleStateBits[1].ToString()); | |||||
writer.WriteString($"[{vehicleStateBits[0]}]Bit15自定义", vehicleStateBits[0].ToString()); | |||||
writer.WriteEndObject(); | |||||
value.AlarmIdentification = new AlarmIdentificationProperty(); | |||||
string terminalIDHex = reader.ReadVirtualArray(7).ToArray().ToHexString(); | |||||
value.AlarmIdentification.TerminalID = reader.ReadString(7); | |||||
value.AlarmIdentification.Time = reader.ReadDateTime6(); | |||||
value.AlarmIdentification.SN = reader.ReadByte(); | |||||
value.AlarmIdentification.AttachCount = reader.ReadByte(); | |||||
value.AlarmIdentification.Retain = reader.ReadByte(); | |||||
writer.WriteString($"[{terminalIDHex}]终端ID", value.AlarmIdentification.TerminalID); | |||||
writer.WriteString($"[{value.AlarmIdentification.Time.ToString("yyMMddHHmmss")}]日期时间", value.AlarmIdentification.Time.ToString("yyyy-MM-dd HH:mm:ss")); | |||||
writer.WriteNumber($"[{value.AlarmIdentification.SN.ReadNumber()}]序号", value.AlarmIdentification.SN); | |||||
writer.WriteNumber($"[{value.AlarmIdentification.AttachCount.ReadNumber()}]附件数量", value.AlarmIdentification.AttachCount); | |||||
writer.WriteNumber($"[{value.AlarmIdentification.Retain.ReadNumber()}]预留", value.AlarmIdentification.Retain); | |||||
} | |||||
/// <summary> | |||||
/// | |||||
/// </summary> | |||||
/// <param name="reader"></param> | |||||
/// <param name="config"></param> | |||||
/// <returns></returns> | |||||
public JT808_0x0200_0x65 Deserialize(ref JT808MessagePackReader reader, IJT808Config config) | |||||
{ | |||||
JT808_0x0200_0x65 value = new JT808_0x0200_0x65(); | |||||
value.AttachInfoId = reader.ReadByte(); | |||||
value.AttachInfoLength = reader.ReadByte(); | |||||
value.AlarmId = reader.ReadUInt32(); | |||||
value.FlagState = reader.ReadByte(); | |||||
value.AlarmOrEventType = reader.ReadByte(); | |||||
value.AlarmLevel = reader.ReadByte(); | |||||
value.Fatigue = reader.ReadByte(); | |||||
value.Retain = reader.ReadArray(4).ToArray(); | |||||
value.Speed = reader.ReadByte(); | |||||
value.Altitude = reader.ReadUInt16(); | |||||
value.Latitude = (int)reader.ReadUInt32(); | |||||
value.Longitude = (int)reader.ReadUInt32(); | |||||
value.AlarmTime = reader.ReadDateTime6(); | |||||
value.VehicleState = reader.ReadUInt16(); | |||||
value.AlarmIdentification = new AlarmIdentificationProperty | |||||
{ | |||||
TerminalID = reader.ReadString(7), | |||||
Time = reader.ReadDateTime6(), | |||||
SN = reader.ReadByte(), | |||||
AttachCount = reader.ReadByte(), | |||||
Retain = reader.ReadByte() | |||||
}; | |||||
return value; | |||||
} | |||||
/// <summary> | |||||
/// | |||||
/// </summary> | |||||
/// <param name="writer"></param> | |||||
/// <param name="value"></param> | |||||
/// <param name="config"></param> | |||||
public void Serialize(ref JT808MessagePackWriter writer, JT808_0x0200_0x65 value, IJT808Config config) | |||||
{ | |||||
writer.WriteByte(value.AttachInfoId); | |||||
writer.WriteByte(value.AttachInfoLength); | |||||
writer.WriteUInt32(value.AlarmId); | |||||
writer.WriteByte(value.FlagState); | |||||
writer.WriteByte(value.AlarmOrEventType); | |||||
writer.WriteByte(value.AlarmLevel); | |||||
writer.WriteByte(value.Fatigue); | |||||
if (value.Retain.Length != 4) | |||||
{ | |||||
throw new ArgumentOutOfRangeException($"{nameof(JT808_0x0200_0x65.Retain)} length==4"); | |||||
} | |||||
writer.WriteArray(value.Retain); | |||||
writer.WriteByte(value.Speed); | |||||
writer.WriteUInt16(value.Altitude); | |||||
writer.WriteUInt32((uint)value.Latitude); | |||||
writer.WriteUInt32((uint)value.Longitude); | |||||
writer.WriteDateTime6(value.AlarmTime); | |||||
writer.WriteUInt16(value.VehicleState); | |||||
if (value.AlarmIdentification == null) | |||||
{ | |||||
throw new NullReferenceException($"{nameof(AlarmIdentificationProperty)}不为空"); | |||||
} | |||||
writer.WriteString(value.AlarmIdentification.TerminalID); | |||||
writer.WriteDateTime6(value.AlarmIdentification.Time); | |||||
writer.WriteByte(value.AlarmIdentification.SN); | |||||
writer.WriteByte(value.AlarmIdentification.AttachCount); | |||||
writer.WriteByte(value.AlarmIdentification.Retain); | |||||
} | |||||
} | |||||
} |
@@ -0,0 +1,312 @@ | |||||
using JT808.Protocol.Extensions.JTActiveSafety.Metadata; | |||||
using JT808.Protocol.Formatters; | |||||
using JT808.Protocol.Interfaces; | |||||
using JT808.Protocol.MessageBody; | |||||
using JT808.Protocol.MessagePack; | |||||
using System; | |||||
using System.Collections.Generic; | |||||
using System.Text; | |||||
using System.Text.Json; | |||||
namespace JT808.Protocol.Extensions.JTActiveSafety.MessageBody | |||||
{ | |||||
/// <summary> | |||||
/// 胎压监测系统报警信息 | |||||
/// </summary> | |||||
public class JT808_0x0200_0x66 : JT808_0x0200_BodyBase, IJT808MessagePackFormatter<JT808_0x0200_0x66>, IJT808Analyze | |||||
{ | |||||
/// <summary> | |||||
/// 胎压监测系统报警信息Id | |||||
/// </summary> | |||||
public override byte AttachInfoId { get; set; } = JT808_JTActiveSafety_Constants.JT808_0X0200_0x66; | |||||
/// <summary> | |||||
/// 胎压监测系统报警信息长度 | |||||
/// </summary> | |||||
public override byte AttachInfoLength { get; set; } | |||||
/// <summary> | |||||
/// 报警ID | |||||
/// </summary> | |||||
public uint AlarmId { get; set; } | |||||
/// <summary> | |||||
/// 标志状态 | |||||
/// </summary> | |||||
public byte FlagState { get; set; } | |||||
/// <summary> | |||||
/// 车速 | |||||
/// </summary> | |||||
public byte Speed { get; set; } | |||||
/// <summary> | |||||
/// 高程 | |||||
/// </summary> | |||||
public ushort Altitude { get; set; } | |||||
/// <summary> | |||||
/// 纬度 | |||||
/// </summary> | |||||
public int Latitude { get; set; } | |||||
/// <summary> | |||||
/// 经度 | |||||
/// </summary> | |||||
public int Longitude { get; set; } | |||||
/// <summary> | |||||
/// 日期时间 | |||||
/// YYMMDDhhmmss | |||||
/// BCD[6] | |||||
/// </summary> | |||||
public DateTime AlarmTime { get; set; } | |||||
/// <summary> | |||||
/// 车辆状态 | |||||
/// </summary> | |||||
public ushort VehicleState { get; set; } | |||||
/// <summary> | |||||
/// 报警标识号 | |||||
/// </summary> | |||||
public AlarmIdentificationProperty AlarmIdentification { get; set; } | |||||
/// <summary> | |||||
/// 报警/事件列表总数 | |||||
/// </summary> | |||||
public byte AlarmOrEventCount { get; set; } | |||||
/// <summary> | |||||
/// 报警/事件信息列表 | |||||
/// </summary> | |||||
public List<AlarmOrEventProperty> AlarmOrEvents { get; set; } | |||||
/// <summary> | |||||
/// | |||||
/// </summary> | |||||
/// <param name="reader"></param> | |||||
/// <param name="writer"></param> | |||||
/// <param name="config"></param> | |||||
public void Analyze(ref JT808MessagePackReader reader, Utf8JsonWriter writer, IJT808Config config) | |||||
{ | |||||
JT808_0x0200_0x66 value = new JT808_0x0200_0x66(); | |||||
value.AttachInfoId = reader.ReadByte(); | |||||
writer.WriteNumber($"[{value.AttachInfoId.ReadNumber()}]附加信息Id", value.AttachInfoId); | |||||
value.AttachInfoLength = reader.ReadByte(); | |||||
writer.WriteNumber($"[{value.AttachInfoLength.ReadNumber()}]附加信息长度", value.AttachInfoLength); | |||||
value.AlarmId = reader.ReadUInt32(); | |||||
writer.WriteNumber($"[{value.AlarmId.ReadNumber()}]报警ID", value.AlarmId); | |||||
value.FlagState = reader.ReadByte(); | |||||
string flagStateString = "未知"; | |||||
switch (value.FlagState) | |||||
{ | |||||
case 0: | |||||
flagStateString = "不可用"; | |||||
break; | |||||
case 1: | |||||
flagStateString = "开始标志"; | |||||
break; | |||||
case 2: | |||||
flagStateString = "结束标志"; | |||||
break; | |||||
} | |||||
writer.WriteNumber($"[{value.FlagState.ReadNumber()}]标志状态-{flagStateString}", value.FlagState); | |||||
value.Speed = reader.ReadByte(); | |||||
writer.WriteNumber($"[{value.Speed.ReadNumber()}]车速", value.Speed); | |||||
value.Altitude = reader.ReadUInt16(); | |||||
writer.WriteNumber($"[{value.Altitude.ReadNumber()}]高程", value.Altitude); | |||||
value.Latitude = (int)reader.ReadUInt32(); | |||||
writer.WriteNumber($"[{value.Latitude.ReadNumber()}]纬度", value.Latitude); | |||||
value.Longitude = (int)reader.ReadUInt32(); | |||||
writer.WriteNumber($"[{value.Longitude.ReadNumber()}]经度", value.Longitude); | |||||
value.AlarmTime = reader.ReadDateTime6(); | |||||
writer.WriteString($"[{value.AlarmTime.ToString("yyMMddHHmmss")}]日期时间", value.AlarmTime.ToString("yyyy-MM-dd HH:mm:ss")); | |||||
value.VehicleState = reader.ReadUInt16(); | |||||
writer.WriteNumber($"[{value.VehicleState.ReadNumber()}]车辆状态", value.VehicleState); | |||||
var vehicleStateBits = Convert.ToString(value.VehicleState, 2).PadLeft(16, '0'); | |||||
writer.WriteStartObject($"车辆状态对象[{vehicleStateBits}]"); | |||||
writer.WriteString($"[{vehicleStateBits[15]}]Bit0ACC状态", vehicleStateBits[15] == '0' ? "关闭" : "打开"); | |||||
writer.WriteString($"[{vehicleStateBits[14]}]Bit1左转向状态", vehicleStateBits[14] == '0' ? "关闭" : "打开"); | |||||
writer.WriteString($"[{vehicleStateBits[13]}]Bit2右转向状态", vehicleStateBits[13] == '0' ? "关闭" : "打开"); | |||||
writer.WriteString($"[{vehicleStateBits[12]}]Bit3雨刮器状态", vehicleStateBits[12] == '0' ? "关闭" : "打开"); | |||||
writer.WriteString($"[{vehicleStateBits[11]}]Bit4制动状态", vehicleStateBits[11] == '0' ? "未制动" : "制动"); | |||||
writer.WriteString($"[{vehicleStateBits[10]}]Bit5插卡状态", vehicleStateBits[10] == '0' ? "未插卡" : "已插卡"); | |||||
writer.WriteString($"[{vehicleStateBits[9]}]Bit6自定义", vehicleStateBits[9].ToString()); | |||||
writer.WriteString($"[{vehicleStateBits[8]}]Bit7自定义", vehicleStateBits[8].ToString()); | |||||
writer.WriteString($"[{vehicleStateBits[7]}]Bit8自定义", vehicleStateBits[7].ToString()); | |||||
writer.WriteString($"[{vehicleStateBits[6]}]Bit9自定义", vehicleStateBits[6].ToString()); | |||||
writer.WriteString($"[{vehicleStateBits[5]}]Bit10定位状态", vehicleStateBits[5] == '0' ? "未定位" : "已定位"); | |||||
writer.WriteString($"[{vehicleStateBits[4]}]Bit11自定义", vehicleStateBits[4].ToString()); | |||||
writer.WriteString($"[{vehicleStateBits[3]}]Bit12自定义", vehicleStateBits[3].ToString()); | |||||
writer.WriteString($"[{vehicleStateBits[2]}]Bit13自定义", vehicleStateBits[2].ToString()); | |||||
writer.WriteString($"[{vehicleStateBits[1]}]Bit14自定义", vehicleStateBits[1].ToString()); | |||||
writer.WriteString($"[{vehicleStateBits[0]}]Bit15自定义", vehicleStateBits[0].ToString()); | |||||
writer.WriteEndObject(); | |||||
value.AlarmIdentification = new AlarmIdentificationProperty(); | |||||
string terminalIDHex = reader.ReadVirtualArray(7).ToArray().ToHexString(); | |||||
value.AlarmIdentification.TerminalID = reader.ReadString(7); | |||||
value.AlarmIdentification.Time = reader.ReadDateTime6(); | |||||
value.AlarmIdentification.SN = reader.ReadByte(); | |||||
value.AlarmIdentification.AttachCount = reader.ReadByte(); | |||||
value.AlarmIdentification.Retain = reader.ReadByte(); | |||||
writer.WriteString($"[{terminalIDHex}]终端ID", value.AlarmIdentification.TerminalID); | |||||
writer.WriteString($"[{value.AlarmIdentification.Time.ToString("yyMMddHHmmss")}]日期时间", value.AlarmIdentification.Time.ToString("yyyy-MM-dd HH:mm:ss")); | |||||
writer.WriteNumber($"[{value.AlarmIdentification.SN.ReadNumber()}]序号", value.AlarmIdentification.SN); | |||||
writer.WriteNumber($"[{value.AlarmIdentification.AttachCount.ReadNumber()}]附件数量", value.AlarmIdentification.AttachCount); | |||||
writer.WriteNumber($"[{value.AlarmIdentification.Retain.ReadNumber()}]预留", value.AlarmIdentification.Retain); | |||||
value.AlarmOrEventCount = reader.ReadByte(); | |||||
writer.WriteNumber($"[{value.AlarmOrEventCount.ReadNumber()}]报警_事件列表总数", value.AlarmOrEventCount); | |||||
if (value.AlarmOrEventCount > 0) | |||||
{ | |||||
writer.WriteStartArray("报警_事件列表"); | |||||
for (int i = 0; i < value.AlarmOrEventCount; i++) | |||||
{ | |||||
writer.WriteStartObject(); | |||||
AlarmOrEventProperty item = new AlarmOrEventProperty(); | |||||
item.TirePressureAlarmPosition = reader.ReadByte(); | |||||
writer.WriteNumber($"[{item.TirePressureAlarmPosition.ReadNumber()}]胎压报警位置", item.TirePressureAlarmPosition); | |||||
item.AlarmOrEventType = reader.ReadUInt16(); | |||||
string alarmOrEventTypeString = ""; | |||||
switch (item.AlarmOrEventType) | |||||
{ | |||||
case 0x01: | |||||
alarmOrEventTypeString = "前向碰撞报警"; | |||||
break; | |||||
case 0x02: | |||||
alarmOrEventTypeString = "车道偏离报警"; | |||||
break; | |||||
case 0x03: | |||||
alarmOrEventTypeString = "车距过近报警"; | |||||
break; | |||||
case 0x04: | |||||
alarmOrEventTypeString = "行人碰撞报警"; | |||||
break; | |||||
case 0x05: | |||||
alarmOrEventTypeString = "频繁变道报警"; | |||||
break; | |||||
case 0x06: | |||||
alarmOrEventTypeString = "道路标识超限报警"; | |||||
break; | |||||
case 0x07: | |||||
alarmOrEventTypeString = "障碍物报警"; | |||||
break; | |||||
case 0x08: | |||||
case 0x09: | |||||
case 0x0A: | |||||
case 0x0B: | |||||
case 0x0C: | |||||
case 0x0D: | |||||
case 0x0E: | |||||
case 0x0F: | |||||
alarmOrEventTypeString = "用户自定义"; | |||||
break; | |||||
case 0x10: | |||||
alarmOrEventTypeString = "道路标志识别事件"; | |||||
break; | |||||
case 0x11: | |||||
alarmOrEventTypeString = "主动抓拍事件"; | |||||
break; | |||||
case 0x12: | |||||
case 0x13: | |||||
case 0x14: | |||||
case 0x15: | |||||
case 0x16: | |||||
case 0x17: | |||||
case 0x18: | |||||
case 0x19: | |||||
case 0x1A: | |||||
case 0x1B: | |||||
case 0x1C: | |||||
case 0x1D: | |||||
case 0x1E: | |||||
case 0x1F: | |||||
alarmOrEventTypeString = "用户自定义"; | |||||
break; | |||||
} | |||||
writer.WriteNumber($"[{item.AlarmOrEventType.ReadNumber()}]报警_事件类型-{alarmOrEventTypeString}", item.AlarmOrEventType); | |||||
item.TirePressure = reader.ReadUInt16(); | |||||
writer.WriteNumber($"[{item.TirePressure.ReadNumber()}]胎压Kpa", item.TirePressure); | |||||
item.TireTemperature = reader.ReadUInt16(); | |||||
writer.WriteNumber($"[{item.TireTemperature.ReadNumber()}]胎温℃", item.TireTemperature); | |||||
item.BatteryLevel = reader.ReadUInt16(); | |||||
writer.WriteNumber($"[{item.BatteryLevel.ReadNumber()}]电池电量%", item.BatteryLevel); | |||||
writer.WriteEndObject(); | |||||
} | |||||
writer.WriteEndArray(); | |||||
} | |||||
} | |||||
/// <summary> | |||||
/// | |||||
/// </summary> | |||||
/// <param name="reader"></param> | |||||
/// <param name="config"></param> | |||||
/// <returns></returns> | |||||
public JT808_0x0200_0x66 Deserialize(ref JT808MessagePackReader reader, IJT808Config config) | |||||
{ | |||||
JT808_0x0200_0x66 value = new JT808_0x0200_0x66(); | |||||
value.AttachInfoId = reader.ReadByte(); | |||||
value.AttachInfoLength = reader.ReadByte(); | |||||
value.AlarmId = reader.ReadUInt32(); | |||||
value.FlagState = reader.ReadByte(); | |||||
value.Speed = reader.ReadByte(); | |||||
value.Altitude = reader.ReadUInt16(); | |||||
value.Latitude = (int)reader.ReadUInt32(); | |||||
value.Longitude = (int)reader.ReadUInt32(); | |||||
value.AlarmTime = reader.ReadDateTime6(); | |||||
value.VehicleState = reader.ReadUInt16(); | |||||
value.AlarmIdentification = new AlarmIdentificationProperty | |||||
{ | |||||
TerminalID = reader.ReadString(7), | |||||
Time = reader.ReadDateTime6(), | |||||
SN = reader.ReadByte(), | |||||
AttachCount = reader.ReadByte(), | |||||
Retain = reader.ReadByte() | |||||
}; | |||||
value.AlarmOrEventCount = reader.ReadByte(); | |||||
if (value.AlarmOrEventCount > 0) | |||||
{ | |||||
value.AlarmOrEvents = new List<AlarmOrEventProperty>(); | |||||
for (int i = 0; i < value.AlarmOrEventCount; i++) | |||||
{ | |||||
AlarmOrEventProperty alarmOrEventProperty = new AlarmOrEventProperty(); | |||||
alarmOrEventProperty.TirePressureAlarmPosition = reader.ReadByte(); | |||||
alarmOrEventProperty.AlarmOrEventType = reader.ReadUInt16(); | |||||
alarmOrEventProperty.TirePressure = reader.ReadUInt16(); | |||||
alarmOrEventProperty.TireTemperature = reader.ReadUInt16(); | |||||
alarmOrEventProperty.BatteryLevel = reader.ReadUInt16(); | |||||
value.AlarmOrEvents.Add(alarmOrEventProperty); | |||||
} | |||||
} | |||||
return value; | |||||
} | |||||
/// <summary> | |||||
/// | |||||
/// </summary> | |||||
/// <param name="writer"></param> | |||||
/// <param name="value"></param> | |||||
/// <param name="config"></param> | |||||
public void Serialize(ref JT808MessagePackWriter writer, JT808_0x0200_0x66 value, IJT808Config config) | |||||
{ | |||||
writer.WriteByte(value.AttachInfoId); | |||||
writer.Skip(1, out int AttachInfoLengthPosition); | |||||
writer.WriteUInt32(value.AlarmId); | |||||
writer.WriteByte(value.FlagState); | |||||
writer.WriteByte(value.Speed); | |||||
writer.WriteUInt16(value.Altitude); | |||||
writer.WriteUInt32((uint)value.Latitude); | |||||
writer.WriteUInt32((uint)value.Longitude); | |||||
writer.WriteDateTime6(value.AlarmTime); | |||||
writer.WriteUInt16(value.VehicleState); | |||||
if (value.AlarmIdentification == null) | |||||
{ | |||||
throw new NullReferenceException($"{nameof(AlarmIdentificationProperty)}不为空"); | |||||
} | |||||
writer.WriteString(value.AlarmIdentification.TerminalID); | |||||
writer.WriteDateTime6(value.AlarmIdentification.Time); | |||||
writer.WriteByte(value.AlarmIdentification.SN); | |||||
writer.WriteByte(value.AlarmIdentification.AttachCount); | |||||
writer.WriteByte(value.AlarmIdentification.Retain); | |||||
if (value.AlarmOrEvents.Count > 0) | |||||
{ | |||||
writer.WriteByte((byte)value.AlarmOrEvents.Count); | |||||
foreach (var item in value.AlarmOrEvents) | |||||
{ | |||||
writer.WriteByte(item.TirePressureAlarmPosition); | |||||
writer.WriteUInt16(item.AlarmOrEventType); | |||||
writer.WriteUInt16(item.TirePressure); | |||||
writer.WriteUInt16(item.TireTemperature); | |||||
writer.WriteUInt16(item.BatteryLevel); | |||||
} | |||||
} | |||||
writer.WriteByteReturn((byte)(writer.GetCurrentPosition() - AttachInfoLengthPosition - 1), AttachInfoLengthPosition); | |||||
} | |||||
} | |||||
} |
@@ -0,0 +1,279 @@ | |||||
using JT808.Protocol.Extensions.JTActiveSafety.Metadata; | |||||
using JT808.Protocol.Formatters; | |||||
using JT808.Protocol.Interfaces; | |||||
using JT808.Protocol.MessageBody; | |||||
using JT808.Protocol.MessagePack; | |||||
using System; | |||||
using System.Collections.Generic; | |||||
using System.Text; | |||||
using System.Text.Json; | |||||
namespace JT808.Protocol.Extensions.JTActiveSafety.MessageBody | |||||
{ | |||||
/// <summary> | |||||
/// 盲区监测系统报警信息 | |||||
/// </summary> | |||||
public class JT808_0x0200_0x67 : JT808_0x0200_BodyBase, IJT808MessagePackFormatter<JT808_0x0200_0x67>, IJT808Analyze | |||||
{ | |||||
/// <summary> | |||||
/// 盲区监测系统报警信息Id | |||||
/// </summary> | |||||
public override byte AttachInfoId { get; set; } = JT808_JTActiveSafety_Constants.JT808_0X0200_0x67; | |||||
/// <summary> | |||||
/// 盲区监测系统报警信息长度 | |||||
/// </summary> | |||||
public override byte AttachInfoLength { get; set; } = 26; | |||||
/// <summary> | |||||
/// 报警ID | |||||
/// </summary> | |||||
public uint AlarmId { get; set; } | |||||
/// <summary> | |||||
/// 标志状态 | |||||
/// </summary> | |||||
public byte FlagState { get; set; } | |||||
/// <summary> | |||||
/// 报警/事件类型 | |||||
/// </summary> | |||||
public byte AlarmOrEventType{ get; set; } | |||||
/// <summary> | |||||
/// 报警/事件类型 | |||||
/// </summary> | |||||
public byte AlarmLevel { get; set; } | |||||
/// <summary> | |||||
/// 车速 | |||||
/// </summary> | |||||
public byte Speed { get; set; } | |||||
/// <summary> | |||||
/// 高程 | |||||
/// </summary> | |||||
public ushort Altitude { get; set; } | |||||
/// <summary> | |||||
/// 纬度 | |||||
/// </summary> | |||||
public int Latitude { get; set; } | |||||
/// <summary> | |||||
/// 经度 | |||||
/// </summary> | |||||
public int Longitude { get; set; } | |||||
/// <summary> | |||||
/// 日期时间 | |||||
/// YYMMDDhhmmss | |||||
/// BCD[6] | |||||
/// </summary> | |||||
public DateTime AlarmTime { get; set; } | |||||
/// <summary> | |||||
/// 车辆状态 | |||||
/// </summary> | |||||
public ushort VehicleState { get; set; } | |||||
/// <summary> | |||||
/// 报警标识号 | |||||
/// </summary> | |||||
public AlarmIdentificationProperty AlarmIdentification { get; set; } | |||||
/// <summary> | |||||
/// | |||||
/// </summary> | |||||
/// <param name="reader"></param> | |||||
/// <param name="writer"></param> | |||||
/// <param name="config"></param> | |||||
public void Analyze(ref JT808MessagePackReader reader, Utf8JsonWriter writer, IJT808Config config) | |||||
{ | |||||
JT808_0x0200_0x67 value = new JT808_0x0200_0x67(); | |||||
value.AttachInfoId = reader.ReadByte(); | |||||
writer.WriteNumber($"[{value.AttachInfoId.ReadNumber()}]附加信息Id", value.AttachInfoId); | |||||
value.AttachInfoLength = reader.ReadByte(); | |||||
writer.WriteNumber($"[{value.AttachInfoLength.ReadNumber()}]附加信息长度", value.AttachInfoLength); | |||||
value.AlarmId = reader.ReadUInt32(); | |||||
writer.WriteNumber($"[{value.AlarmId.ReadNumber()}]报警ID", value.AlarmId); | |||||
value.FlagState = reader.ReadByte(); | |||||
string flagStateString = "未知"; | |||||
switch (value.FlagState) | |||||
{ | |||||
case 0: | |||||
flagStateString = "不可用"; | |||||
break; | |||||
case 1: | |||||
flagStateString = "开始标志"; | |||||
break; | |||||
case 2: | |||||
flagStateString = "结束标志"; | |||||
break; | |||||
} | |||||
writer.WriteNumber($"[{value.FlagState.ReadNumber()}]标志状态-{flagStateString}", value.FlagState); | |||||
value.AlarmOrEventType = reader.ReadByte(); | |||||
string alarmOrEventTypeString = ""; | |||||
switch (value.AlarmOrEventType) | |||||
{ | |||||
case 0x01: | |||||
alarmOrEventTypeString = "前向碰撞报警"; | |||||
break; | |||||
case 0x02: | |||||
alarmOrEventTypeString = "车道偏离报警"; | |||||
break; | |||||
case 0x03: | |||||
alarmOrEventTypeString = "车距过近报警"; | |||||
break; | |||||
case 0x04: | |||||
alarmOrEventTypeString = "行人碰撞报警"; | |||||
break; | |||||
case 0x05: | |||||
alarmOrEventTypeString = "频繁变道报警"; | |||||
break; | |||||
case 0x06: | |||||
alarmOrEventTypeString = "道路标识超限报警"; | |||||
break; | |||||
case 0x07: | |||||
alarmOrEventTypeString = "障碍物报警"; | |||||
break; | |||||
case 0x08: | |||||
case 0x09: | |||||
case 0x0A: | |||||
case 0x0B: | |||||
case 0x0C: | |||||
case 0x0D: | |||||
case 0x0E: | |||||
case 0x0F: | |||||
alarmOrEventTypeString = "用户自定义"; | |||||
break; | |||||
case 0x10: | |||||
alarmOrEventTypeString = "道路标志识别事件"; | |||||
break; | |||||
case 0x11: | |||||
alarmOrEventTypeString = "主动抓拍事件"; | |||||
break; | |||||
case 0x12: | |||||
case 0x13: | |||||
case 0x14: | |||||
case 0x15: | |||||
case 0x16: | |||||
case 0x17: | |||||
case 0x18: | |||||
case 0x19: | |||||
case 0x1A: | |||||
case 0x1B: | |||||
case 0x1C: | |||||
case 0x1D: | |||||
case 0x1E: | |||||
case 0x1F: | |||||
alarmOrEventTypeString = "用户自定义"; | |||||
break; | |||||
} | |||||
writer.WriteNumber($"[{value.AlarmOrEventType.ReadNumber()}]报警_事件类型-{alarmOrEventTypeString}", value.AlarmOrEventType); | |||||
value.AlarmLevel = reader.ReadByte(); | |||||
string alarmLevelString = "未知"; | |||||
switch (value.AlarmLevel) | |||||
{ | |||||
case 0x01: | |||||
alarmLevelString = "一级报警"; | |||||
break; | |||||
case 0x02: | |||||
alarmLevelString = "二级报警"; | |||||
break; | |||||
} | |||||
writer.WriteNumber($"[{value.AlarmLevel.ReadNumber()}]报警级别-{alarmLevelString}", value.AlarmLevel); | |||||
value.Speed = reader.ReadByte(); | |||||
writer.WriteNumber($"[{value.Speed.ReadNumber()}]车速", value.Speed); | |||||
value.Altitude = reader.ReadUInt16(); | |||||
writer.WriteNumber($"[{value.Altitude.ReadNumber()}]高程", value.Altitude); | |||||
value.Latitude = (int)reader.ReadUInt32(); | |||||
writer.WriteNumber($"[{value.Latitude.ReadNumber()}]纬度", value.Latitude); | |||||
value.Longitude = (int)reader.ReadUInt32(); | |||||
writer.WriteNumber($"[{value.Longitude.ReadNumber()}]经度", value.Longitude); | |||||
value.AlarmTime = reader.ReadDateTime6(); | |||||
writer.WriteString($"[{value.AlarmTime.ToString("yyMMddHHmmss")}]日期时间", value.AlarmTime.ToString("yyyy-MM-dd HH:mm:ss")); | |||||
value.VehicleState = reader.ReadUInt16(); | |||||
writer.WriteNumber($"[{value.VehicleState.ReadNumber()}]车辆状态", value.VehicleState); | |||||
var vehicleStateBits=Convert.ToString(value.VehicleState, 2).PadLeft(16, '0'); | |||||
writer.WriteStartObject($"车辆状态对象[{vehicleStateBits}]"); | |||||
writer.WriteString($"[{vehicleStateBits[15]}]Bit0ACC状态", vehicleStateBits[15]=='0'?"关闭":"打开"); | |||||
writer.WriteString($"[{vehicleStateBits[14]}]Bit1左转向状态", vehicleStateBits[14]=='0'?"关闭":"打开"); | |||||
writer.WriteString($"[{vehicleStateBits[13]}]Bit2右转向状态", vehicleStateBits[13]=='0'?"关闭":"打开"); | |||||
writer.WriteString($"[{vehicleStateBits[12]}]Bit3雨刮器状态", vehicleStateBits[12]=='0'?"关闭":"打开"); | |||||
writer.WriteString($"[{vehicleStateBits[11]}]Bit4制动状态", vehicleStateBits[11] == '0' ? "未制动" : "制动"); | |||||
writer.WriteString($"[{vehicleStateBits[10]}]Bit5插卡状态", vehicleStateBits[10] == '0' ? "未插卡" : "已插卡"); | |||||
writer.WriteString($"[{vehicleStateBits[9]}]Bit6自定义", vehicleStateBits[9].ToString()); | |||||
writer.WriteString($"[{vehicleStateBits[8]}]Bit7自定义", vehicleStateBits[8].ToString()); | |||||
writer.WriteString($"[{vehicleStateBits[7]}]Bit8自定义", vehicleStateBits[7].ToString()); | |||||
writer.WriteString($"[{vehicleStateBits[6]}]Bit9自定义", vehicleStateBits[6].ToString()); | |||||
writer.WriteString($"[{vehicleStateBits[5]}]Bit10定位状态", vehicleStateBits[5] == '0' ? "未定位" : "已定位"); | |||||
writer.WriteString($"[{vehicleStateBits[4]}]Bit11自定义", vehicleStateBits[4].ToString()); | |||||
writer.WriteString($"[{vehicleStateBits[3]}]Bit12自定义", vehicleStateBits[3].ToString()); | |||||
writer.WriteString($"[{vehicleStateBits[2]}]Bit13自定义", vehicleStateBits[2].ToString()); | |||||
writer.WriteString($"[{vehicleStateBits[1]}]Bit14自定义", vehicleStateBits[1].ToString()); | |||||
writer.WriteString($"[{vehicleStateBits[0]}]Bit15自定义", vehicleStateBits[0].ToString()); | |||||
writer.WriteEndObject(); | |||||
value.AlarmIdentification = new AlarmIdentificationProperty(); | |||||
string terminalIDHex = reader.ReadVirtualArray(7).ToArray().ToHexString(); | |||||
value.AlarmIdentification.TerminalID = reader.ReadString(7); | |||||
value.AlarmIdentification.Time = reader.ReadDateTime6(); | |||||
value.AlarmIdentification.SN = reader.ReadByte(); | |||||
value.AlarmIdentification.AttachCount = reader.ReadByte(); | |||||
value.AlarmIdentification.Retain = reader.ReadByte(); | |||||
writer.WriteString($"[{terminalIDHex}]终端ID", value.AlarmIdentification.TerminalID); | |||||
writer.WriteString($"[{value.AlarmIdentification.Time.ToString("yyMMddHHmmss")}]日期时间", value.AlarmIdentification.Time.ToString("yyyy-MM-dd HH:mm:ss")); | |||||
writer.WriteNumber($"[{value.AlarmIdentification.SN.ReadNumber()}]序号", value.AlarmIdentification.SN); | |||||
writer.WriteNumber($"[{value.AlarmIdentification.AttachCount.ReadNumber()}]附件数量", value.AlarmIdentification.AttachCount); | |||||
writer.WriteNumber($"[{value.AlarmIdentification.Retain.ReadNumber()}]预留", value.AlarmIdentification.Retain); | |||||
} | |||||
/// <summary> | |||||
/// | |||||
/// </summary> | |||||
/// <param name="reader"></param> | |||||
/// <param name="config"></param> | |||||
/// <returns></returns> | |||||
public JT808_0x0200_0x67 Deserialize(ref JT808MessagePackReader reader, IJT808Config config) | |||||
{ | |||||
JT808_0x0200_0x67 value = new JT808_0x0200_0x67(); | |||||
value.AttachInfoId = reader.ReadByte(); | |||||
value.AttachInfoLength = reader.ReadByte(); | |||||
value.AlarmId = reader.ReadUInt32(); | |||||
value.FlagState = reader.ReadByte(); | |||||
value.AlarmOrEventType = reader.ReadByte(); | |||||
value.AlarmLevel = reader.ReadByte(); | |||||
value.Speed = reader.ReadByte(); | |||||
value.Altitude = reader.ReadUInt16(); | |||||
value.Latitude = (int)reader.ReadUInt32(); | |||||
value.Longitude = (int)reader.ReadUInt32(); | |||||
value.AlarmTime = reader.ReadDateTime6(); | |||||
value.VehicleState = reader.ReadUInt16(); | |||||
value.AlarmIdentification = new AlarmIdentificationProperty | |||||
{ | |||||
TerminalID = reader.ReadString(7), | |||||
Time = reader.ReadDateTime6(), | |||||
SN = reader.ReadByte(), | |||||
AttachCount = reader.ReadByte(), | |||||
Retain = reader.ReadByte() | |||||
}; | |||||
return value; | |||||
} | |||||
/// <summary> | |||||
/// | |||||
/// </summary> | |||||
/// <param name="writer"></param> | |||||
/// <param name="value"></param> | |||||
/// <param name="config"></param> | |||||
public void Serialize(ref JT808MessagePackWriter writer, JT808_0x0200_0x67 value, IJT808Config config) | |||||
{ | |||||
writer.WriteByte(value.AttachInfoId); | |||||
writer.WriteByte(value.AttachInfoLength); | |||||
writer.WriteUInt32(value.AlarmId); | |||||
writer.WriteByte(value.FlagState); | |||||
writer.WriteByte(value.AlarmOrEventType); | |||||
writer.WriteByte(value.AlarmLevel); | |||||
writer.WriteByte(value.Speed); | |||||
writer.WriteUInt16(value.Altitude); | |||||
writer.WriteUInt32((uint)value.Latitude); | |||||
writer.WriteUInt32((uint)value.Longitude); | |||||
writer.WriteDateTime6(value.AlarmTime); | |||||
writer.WriteUInt16(value.VehicleState); | |||||
if (value.AlarmIdentification == null) | |||||
{ | |||||
throw new NullReferenceException($"{nameof(AlarmIdentificationProperty)}不为空"); | |||||
} | |||||
writer.WriteString(value.AlarmIdentification.TerminalID); | |||||
writer.WriteDateTime6(value.AlarmIdentification.Time); | |||||
writer.WriteByte(value.AlarmIdentification.SN); | |||||
writer.WriteByte(value.AlarmIdentification.AttachCount); | |||||
writer.WriteByte(value.AlarmIdentification.Retain); | |||||
} | |||||
} | |||||
} |
@@ -0,0 +1,122 @@ | |||||
using JT808.Protocol.Extensions.JTActiveSafety.Enums; | |||||
using JT808.Protocol.Extensions.JTActiveSafety.Metadata; | |||||
using JT808.Protocol.Formatters; | |||||
using JT808.Protocol.Interfaces; | |||||
using JT808.Protocol.MessageBody; | |||||
using JT808.Protocol.MessagePack; | |||||
using System; | |||||
using System.Collections.Generic; | |||||
using System.Text; | |||||
using System.Text.Json; | |||||
namespace JT808.Protocol.Extensions.JTActiveSafety.MessageBody | |||||
{ | |||||
/// <summary> | |||||
/// 透传数据 | |||||
/// </summary> | |||||
public class JT808_0x0900_0xF7 : JT808_0x0900_BodyBase, IJT808MessagePackFormatter<JT808_0x0900_0xF7>, IJT808Analyze | |||||
{ | |||||
/// <summary> | |||||
/// 透传类型 | |||||
/// </summary> | |||||
public override byte PassthroughType { get; set; } = JT808_JTActiveSafety_Constants.JT808_0X0900_0xF7; | |||||
/// <summary> | |||||
/// 消息列表总数 | |||||
/// </summary> | |||||
public byte USBMessageCount { get; set; } | |||||
/// <summary> | |||||
/// 消息列表数据 | |||||
/// </summary> | |||||
public List<JT808_0x0900_0xF7_USB> USBMessages { get; set; } | |||||
/// <summary> | |||||
/// | |||||
/// </summary> | |||||
/// <param name="reader"></param> | |||||
/// <param name="writer"></param> | |||||
/// <param name="config"></param> | |||||
public void Analyze(ref JT808MessagePackReader reader, Utf8JsonWriter writer, IJT808Config config) | |||||
{ | |||||
JT808_0x0900_0xF7 value = new JT808_0x0900_0xF7(); | |||||
value.USBMessageCount = reader.ReadByte(); | |||||
writer.WriteNumber($"[{value.USBMessageCount.ReadNumber()}]消息列表总数", value.USBMessageCount); | |||||
if (value.USBMessageCount > 0) | |||||
{ | |||||
writer.WriteStartArray("消息列表"); | |||||
for (int i = 0; i < value.USBMessageCount; i++) | |||||
{ | |||||
writer.WriteStartObject(); | |||||
JT808_0x0900_0xF7_USB item = new JT808_0x0900_0xF7_USB(); | |||||
item.USBID = reader.ReadByte(); | |||||
writer.WriteNumber($"[{item.USBID.ReadNumber()}]外设ID", item.USBID); | |||||
item.MessageLength = reader.ReadByte(); | |||||
writer.WriteNumber($"[{item.MessageLength.ReadNumber()}]消息长度", item.MessageLength); | |||||
item.WorkingCondition = reader.ReadByte(); | |||||
var workingCondition = (WorkingConditionType)item.WorkingCondition; | |||||
writer.WriteNumber($"[{item.WorkingCondition.ReadNumber()}]工作状态-{workingCondition.ToString()}", item.WorkingCondition); | |||||
item.AlarmStatus = reader.ReadUInt32(); | |||||
writer.WriteNumber($"[{item.AlarmStatus.ReadNumber()}]报警状态", item.AlarmStatus); | |||||
var alarmStatusBits = Convert.ToString(item.AlarmStatus, 2).PadLeft(32, '0').AsSpan(); | |||||
writer.WriteStartObject($"报警状态对象[{alarmStatusBits.ToString()}]"); | |||||
writer.WriteString($"[bit12~bit31]预留", alarmStatusBits.Slice(12).ToString()); | |||||
writer.WriteString($"]bit11]定位模块异常", alarmStatusBits[11].ToString()); | |||||
writer.WriteString($"[bit10]通讯模块异常", alarmStatusBits[10].ToString()); | |||||
writer.WriteString($"[bit6~bit9]预留", alarmStatusBits.Slice(6,4).ToString()); | |||||
writer.WriteString($"[bit5]电池异常", alarmStatusBits[5].ToString()); | |||||
writer.WriteString($"[bit4]扬声器异常", alarmStatusBits[4].ToString()); | |||||
writer.WriteString($"[bit3]红外补光异常", alarmStatusBits[3].ToString()); | |||||
writer.WriteString($"[bit2]辅存储器异常", alarmStatusBits[2].ToString()); | |||||
writer.WriteString($"[bit1]主存储器异常", alarmStatusBits[1].ToString()); | |||||
writer.WriteString($"[bit0]摄像头异常", alarmStatusBits[0].ToString()); | |||||
writer.WriteEndObject(); | |||||
writer.WriteEndObject(); | |||||
} | |||||
writer.WriteEndArray(); | |||||
} | |||||
} | |||||
/// <summary> | |||||
/// | |||||
/// </summary> | |||||
/// <param name="reader"></param> | |||||
/// <param name="config"></param> | |||||
/// <returns></returns> | |||||
public JT808_0x0900_0xF7 Deserialize(ref JT808MessagePackReader reader, IJT808Config config) | |||||
{ | |||||
JT808_0x0900_0xF7 value = new JT808_0x0900_0xF7(); | |||||
value.USBMessageCount = reader.ReadByte(); | |||||
if (value.USBMessageCount > 0) | |||||
{ | |||||
value.USBMessages = new List<JT808_0x0900_0xF7_USB>(); | |||||
for (int i = 0; i < value.USBMessageCount; i++) | |||||
{ | |||||
JT808_0x0900_0xF7_USB item = new JT808_0x0900_0xF7_USB(); | |||||
item.USBID = reader.ReadByte(); | |||||
item.MessageLength = reader.ReadByte(); | |||||
item.WorkingCondition = reader.ReadByte(); | |||||
item.AlarmStatus = reader.ReadUInt32(); | |||||
value.USBMessages.Add(item); | |||||
} | |||||
} | |||||
return value; | |||||
} | |||||
/// <summary> | |||||
/// | |||||
/// </summary> | |||||
/// <param name="writer"></param> | |||||
/// <param name="value"></param> | |||||
/// <param name="config"></param> | |||||
public void Serialize(ref JT808MessagePackWriter writer, JT808_0x0900_0xF7 value, IJT808Config config) | |||||
{ | |||||
if (value.USBMessages != null && value.USBMessages.Count > 0) | |||||
{ | |||||
writer.WriteByte((byte)value.USBMessages.Count); | |||||
foreach (var item in value.USBMessages) | |||||
{ | |||||
writer.WriteByte(item.USBID); | |||||
writer.WriteByte(5); | |||||
writer.WriteByte(item.WorkingCondition); | |||||
writer.WriteUInt32(item.AlarmStatus); | |||||
} | |||||
} | |||||
} | |||||
} | |||||
} |
@@ -0,0 +1,175 @@ | |||||
using JT808.Protocol.Extensions.JTActiveSafety.Metadata; | |||||
using JT808.Protocol.Formatters; | |||||
using JT808.Protocol.Interfaces; | |||||
using JT808.Protocol.MessageBody; | |||||
using JT808.Protocol.MessagePack; | |||||
using System; | |||||
using System.Collections.Generic; | |||||
using System.Text; | |||||
using System.Text.Json; | |||||
namespace JT808.Protocol.Extensions.JTActiveSafety.MessageBody | |||||
{ | |||||
/// <summary> | |||||
/// 透传数据 | |||||
/// </summary> | |||||
public class JT808_0x0900_0xF8 : JT808_0x0900_BodyBase, IJT808MessagePackFormatter<JT808_0x0900_0xF8>, IJT808Analyze | |||||
{ | |||||
/// <summary> | |||||
/// 透传类型 | |||||
/// </summary> | |||||
public override byte PassthroughType { get; set; } = JT808_JTActiveSafety_Constants.JT808_0X0900_0xF8; | |||||
/// <summary> | |||||
/// 消息列表总数 | |||||
/// </summary> | |||||
public byte USBMessageCount { get; set; } | |||||
/// <summary> | |||||
/// | |||||
/// </summary> | |||||
public List<JT808_0x0900_0xF8_USB> USBMessages { get; set; } | |||||
/// <summary> | |||||
/// | |||||
/// </summary> | |||||
/// <param name="reader"></param> | |||||
/// <param name="writer"></param> | |||||
/// <param name="config"></param> | |||||
public void Analyze(ref JT808MessagePackReader reader, Utf8JsonWriter writer, IJT808Config config) | |||||
{ | |||||
JT808_0x0900_0xF8 value = new JT808_0x0900_0xF8(); | |||||
value.USBMessageCount = reader.ReadByte(); | |||||
writer.WriteNumber($"[{value.USBMessageCount.ReadNumber()}]消息列表总数", value.USBMessageCount); | |||||
if (value.USBMessageCount > 0) | |||||
{ | |||||
writer.WriteStartArray("消息列表"); | |||||
for (int i = 0; i < value.USBMessageCount; i++) | |||||
{ | |||||
writer.WriteStartObject(); | |||||
JT808_0x0900_0xF8_USB item = new JT808_0x0900_0xF8_USB(); | |||||
item.USBID = reader.ReadByte(); | |||||
writer.WriteNumber($"[{item.USBID.ReadNumber()}]外设ID", item.USBID); | |||||
item.MessageLength = reader.ReadByte(); | |||||
writer.WriteNumber($"[{item.MessageLength.ReadNumber()}]消息长度", item.MessageLength); | |||||
item.CompantNameLength = reader.ReadByte(); | |||||
writer.WriteNumber($"[{item.CompantNameLength.ReadNumber()}]公司名称长度", item.CompantNameLength); | |||||
string compantNameHex = reader.ReadVirtualArray(item.CompantNameLength).ToArray().ToHexString(); | |||||
item.CompantName = reader.ReadString(item.CompantNameLength); | |||||
writer.WriteString($"[{compantNameHex}]公司名称", item.CompantName); | |||||
item.ProductModelLength = reader.ReadByte(); | |||||
writer.WriteNumber($"[{item.ProductModelLength.ReadNumber()}]产品型号长度", item.ProductModelLength); | |||||
string productModelHex = reader.ReadVirtualArray(item.ProductModelLength).ToArray().ToHexString(); | |||||
item.ProductModel = reader.ReadString(item.ProductModelLength); | |||||
writer.WriteString($"[{productModelHex}]产品型号", item.ProductModel); | |||||
item.HardwareVersionNumberLength = reader.ReadByte(); | |||||
writer.WriteNumber($"[{item.HardwareVersionNumberLength.ReadNumber()}]硬件版本号长度", item.HardwareVersionNumberLength); | |||||
string hardwareVersionNumberHex = reader.ReadVirtualArray(item.HardwareVersionNumberLength).ToArray().ToHexString(); | |||||
item.HardwareVersionNumber = reader.ReadString(item.HardwareVersionNumberLength); | |||||
writer.WriteString($"[{hardwareVersionNumberHex}]硬件版本号", item.HardwareVersionNumber); | |||||
item.SoftwareVersionNumberLength = reader.ReadByte(); | |||||
writer.WriteNumber($"[{item.SoftwareVersionNumberLength.ReadNumber()}]软件版本号长度", item.SoftwareVersionNumberLength); | |||||
string softwareVersionNumberHex = reader.ReadVirtualArray(item.SoftwareVersionNumberLength).ToArray().ToHexString(); | |||||
item.SoftwareVersionNumber = reader.ReadString(item.SoftwareVersionNumberLength); | |||||
writer.WriteString($"[{softwareVersionNumberHex}]软件版本号", item.SoftwareVersionNumber); | |||||
item.DevicesIDLength = reader.ReadByte(); | |||||
writer.WriteNumber($"[{item.DevicesIDLength.ReadNumber()}]设备ID长度", item.DevicesIDLength); | |||||
string devicesIDHex = reader.ReadVirtualArray(item.DevicesIDLength).ToArray().ToHexString(); | |||||
item.DevicesID = reader.ReadString(item.DevicesIDLength); | |||||
writer.WriteString($"[{devicesIDHex}]设备ID", item.DevicesID); | |||||
item.CustomerCodeLength = reader.ReadByte(); | |||||
writer.WriteNumber($"[{item.CustomerCodeLength.ReadNumber()}]客户代码长度", item.CustomerCodeLength); | |||||
string customerCodeHex = reader.ReadVirtualArray(item.CustomerCodeLength).ToArray().ToHexString(); | |||||
item.CustomerCode = reader.ReadString(item.CustomerCodeLength); | |||||
writer.WriteString($"[{customerCodeHex}]客户代码", item.CustomerCode); | |||||
writer.WriteEndObject(); | |||||
} | |||||
writer.WriteEndArray(); | |||||
} | |||||
} | |||||
/// <summary> | |||||
/// | |||||
/// </summary> | |||||
/// <param name="reader"></param> | |||||
/// <param name="config"></param> | |||||
/// <returns></returns> | |||||
public JT808_0x0900_0xF8 Deserialize(ref JT808MessagePackReader reader, IJT808Config config) | |||||
{ | |||||
JT808_0x0900_0xF8 value = new JT808_0x0900_0xF8(); | |||||
value.USBMessageCount = reader.ReadByte(); | |||||
if (value.USBMessageCount > 0) | |||||
{ | |||||
value.USBMessages = new List<JT808_0x0900_0xF8_USB>(); | |||||
for (int i = 0; i < value.USBMessageCount; i++) | |||||
{ | |||||
JT808_0x0900_0xF8_USB item = new JT808_0x0900_0xF8_USB(); | |||||
item.USBID = reader.ReadByte(); | |||||
item.MessageLength = reader.ReadByte(); | |||||
item.CompantNameLength = reader.ReadByte(); | |||||
item.CompantName = reader.ReadString(item.CompantNameLength); | |||||
item.ProductModelLength = reader.ReadByte(); | |||||
item.ProductModel = reader.ReadString(item.ProductModelLength); | |||||
item.HardwareVersionNumberLength = reader.ReadByte(); | |||||
item.HardwareVersionNumber = reader.ReadString(item.HardwareVersionNumberLength); | |||||
item.SoftwareVersionNumberLength = reader.ReadByte(); | |||||
item.SoftwareVersionNumber = reader.ReadString(item.SoftwareVersionNumberLength); | |||||
item.DevicesIDLength = reader.ReadByte(); | |||||
item.DevicesID = reader.ReadString(item.DevicesIDLength); | |||||
item.CustomerCodeLength = reader.ReadByte(); | |||||
item.CustomerCode = reader.ReadString(item.CustomerCodeLength); | |||||
value.USBMessages.Add(item); | |||||
} | |||||
} | |||||
return value; | |||||
} | |||||
/// <summary> | |||||
/// | |||||
/// </summary> | |||||
/// <param name="writer"></param> | |||||
/// <param name="value"></param> | |||||
/// <param name="config"></param> | |||||
public void Serialize(ref JT808MessagePackWriter writer, JT808_0x0900_0xF8 value, IJT808Config config) | |||||
{ | |||||
if (value.USBMessages != null && value.USBMessages.Count > 0) | |||||
{ | |||||
writer.WriteByte((byte)value.USBMessages.Count); | |||||
foreach (var item in value.USBMessages) | |||||
{ | |||||
writer.WriteByte(item.USBID); | |||||
writer.Skip(1,out int messageLengthPosition); | |||||
writer.Skip(1, out int CompantNameLengthPosition); | |||||
writer.WriteString(item.CompantName); | |||||
writer.WriteByteReturn((byte)(writer.GetCurrentPosition() - CompantNameLengthPosition - 1), CompantNameLengthPosition); | |||||
writer.Skip(1, out int ProductModelLengthPosition); | |||||
writer.WriteString(item.ProductModel); | |||||
writer.WriteByteReturn((byte)(writer.GetCurrentPosition() - ProductModelLengthPosition - 1), ProductModelLengthPosition); | |||||
writer.Skip(1, out int HardwareVersionNumberLengthPosition); | |||||
writer.WriteString(item.HardwareVersionNumber); | |||||
writer.WriteByteReturn((byte)(writer.GetCurrentPosition() - HardwareVersionNumberLengthPosition - 1), HardwareVersionNumberLengthPosition); | |||||
writer.Skip(1, out int SoftwareVersionNumberLengthPosition); | |||||
writer.WriteString(item.SoftwareVersionNumber); | |||||
writer.WriteByteReturn((byte)(writer.GetCurrentPosition() - SoftwareVersionNumberLengthPosition - 1), SoftwareVersionNumberLengthPosition); | |||||
writer.Skip(1, out int DevicesIDLengthPosition); | |||||
writer.WriteString(item.DevicesID); | |||||
writer.WriteByteReturn((byte)(writer.GetCurrentPosition() - DevicesIDLengthPosition - 1), DevicesIDLengthPosition); | |||||
writer.Skip(1, out int CustomerCodeLengthPosition); | |||||
writer.WriteString(item.CustomerCode); | |||||
writer.WriteByteReturn((byte)(writer.GetCurrentPosition() - CustomerCodeLengthPosition - 1), CustomerCodeLengthPosition); | |||||
writer.WriteByteReturn((byte)(writer.GetCurrentPosition() - messageLengthPosition - 1), messageLengthPosition); | |||||
} | |||||
} | |||||
} | |||||
} | |||||
} |
@@ -0,0 +1,175 @@ | |||||
using JT808.Protocol.Extensions.JTActiveSafety.Metadata; | |||||
using JT808.Protocol.Formatters; | |||||
using JT808.Protocol.Interfaces; | |||||
using JT808.Protocol.MessagePack; | |||||
using System; | |||||
using System.Collections.Generic; | |||||
using System.Text; | |||||
using System.Text.Json; | |||||
namespace JT808.Protocol.Extensions.JTActiveSafety.MessageBody | |||||
{ | |||||
/// <summary> | |||||
/// 报警附件信息消息 | |||||
/// </summary> | |||||
public class JT808_0x1210: JT808Bodies, IJT808MessagePackFormatter<JT808_0x1210>, IJT808Analyze | |||||
{ | |||||
/// <summary> | |||||
/// 制造商Id | |||||
/// 7 个字节,由大写字母和数字组成,此终端ID 由制造商自行定义,位数不足时,后补“0x00” | |||||
/// </summary> | |||||
public string MakerID { get; set; } | |||||
/// <summary> | |||||
/// 报警标识号 | |||||
/// </summary> | |||||
public AlarmIdentificationProperty AlarmIdentification { get; set; } | |||||
/// <summary> | |||||
/// 平台给报警分配的唯一编号 | |||||
/// 32 | |||||
/// </summary> | |||||
public string AlarmId { get; set; } | |||||
/// <summary> | |||||
/// 信息类型 | |||||
/// 0x00:正常报警文件信息 | |||||
/// 0x01:补传报警文件信息 | |||||
/// </summary> | |||||
public byte InfoType { get; set; } | |||||
/// <summary> | |||||
/// 附件数量 | |||||
/// </summary> | |||||
public byte AttachCount { get; set; } | |||||
/// <summary> | |||||
/// 附件信息列表 | |||||
/// </summary> | |||||
public List<AttachProperty> AttachInfos { get; set; } | |||||
/// <summary> | |||||
/// 报警附件信息消息Id | |||||
/// </summary> | |||||
public override ushort MsgId => 0x1210; | |||||
/// <summary> | |||||
/// 报警附件信息消息 | |||||
/// </summary> | |||||
public override string Description => "报警附件信息消息"; | |||||
/// <summary> | |||||
/// | |||||
/// </summary> | |||||
/// <param name="reader"></param> | |||||
/// <param name="writer"></param> | |||||
/// <param name="config"></param> | |||||
public void Analyze(ref JT808MessagePackReader reader, Utf8JsonWriter writer, IJT808Config config) | |||||
{ | |||||
JT808_0x1210 value = new JT808_0x1210(); | |||||
string makerIdHex=reader.ReadVirtualArray(7).ToArray().ToHexString(); | |||||
value.MakerID = reader.ReadString(7); | |||||
writer.WriteString($"[{makerIdHex}]制造商Id", value.MakerID); | |||||
value.AlarmIdentification = new AlarmIdentificationProperty(); | |||||
string terminalIDHex = reader.ReadVirtualArray(7).ToArray().ToHexString(); | |||||
value.AlarmIdentification.TerminalID = reader.ReadString(7); | |||||
value.AlarmIdentification.Time = reader.ReadDateTime6(); | |||||
value.AlarmIdentification.SN = reader.ReadByte(); | |||||
value.AlarmIdentification.AttachCount = reader.ReadByte(); | |||||
value.AlarmIdentification.Retain = reader.ReadByte(); | |||||
writer.WriteString($"[{terminalIDHex}]终端ID", value.AlarmIdentification.TerminalID); | |||||
writer.WriteString($"[{value.AlarmIdentification.Time.ToString("yyMMddHHmmss")}]日期时间", value.AlarmIdentification.Time.ToString("yyyy-MM-dd HH:mm:ss")); | |||||
writer.WriteNumber($"[{value.AlarmIdentification.SN.ReadNumber()}]序号", value.AlarmIdentification.SN); | |||||
writer.WriteNumber($"[{value.AlarmIdentification.AttachCount.ReadNumber()}]附件数量", value.AlarmIdentification.AttachCount); | |||||
writer.WriteNumber($"[{value.AlarmIdentification.Retain.ReadNumber()}]预留", value.AlarmIdentification.Retain); | |||||
string alarmIdHex = reader.ReadVirtualArray(32).ToArray().ToHexString(); | |||||
value.AlarmId = reader.ReadString(32); | |||||
writer.WriteString($"[{alarmIdHex}]平台给报警分配的唯一编号", value.AlarmId); | |||||
value.InfoType = reader.ReadByte(); | |||||
writer.WriteNumber($"[{value.InfoType.ReadNumber()}]信息类型", value.InfoType); | |||||
value.AttachCount = reader.ReadByte(); | |||||
writer.WriteNumber($"[{value.AttachCount.ReadNumber()}]附件数量", value.AttachCount); | |||||
if (value.AttachCount > 0) | |||||
{ | |||||
writer.WriteStartArray("附件信息列表"); | |||||
for (int i = 0; i < value.AttachCount; i++) | |||||
{ | |||||
writer.WriteStartObject(); | |||||
AttachProperty attachProperty = new AttachProperty(); | |||||
attachProperty.FileNameLength = reader.ReadByte(); | |||||
writer.WriteNumber($"[{attachProperty.FileNameLength.ReadNumber()}]文件名称长度", attachProperty.FileNameLength); | |||||
string fileNameHex = reader.ReadVirtualArray(attachProperty.FileNameLength).ToArray().ToHexString(); | |||||
attachProperty.FileName = reader.ReadString(attachProperty.FileNameLength); | |||||
writer.WriteString($"[{fileNameHex}]文件名称", attachProperty.FileName); | |||||
attachProperty.FileSize = reader.ReadUInt32(); | |||||
writer.WriteNumber($"[{ attachProperty.FileSize.ReadNumber()}]文件大小", attachProperty.FileSize); | |||||
writer.WriteEndObject(); | |||||
} | |||||
writer.WriteEndArray(); | |||||
} | |||||
} | |||||
/// <summary> | |||||
/// | |||||
/// </summary> | |||||
/// <param name="reader"></param> | |||||
/// <param name="config"></param> | |||||
/// <returns></returns> | |||||
public JT808_0x1210 Deserialize(ref JT808MessagePackReader reader, IJT808Config config) | |||||
{ | |||||
JT808_0x1210 value = new JT808_0x1210(); | |||||
value.MakerID = reader.ReadString(7); | |||||
value.AlarmIdentification = new AlarmIdentificationProperty | |||||
{ | |||||
TerminalID = reader.ReadString(7), | |||||
Time = reader.ReadDateTime6(), | |||||
SN = reader.ReadByte(), | |||||
AttachCount = reader.ReadByte(), | |||||
Retain = reader.ReadByte() | |||||
}; | |||||
value.AlarmId = reader.ReadString(32); | |||||
value.InfoType = reader.ReadByte(); | |||||
value.AttachCount = reader.ReadByte(); | |||||
if (value.AttachCount > 0) | |||||
{ | |||||
value.AttachInfos = new List<AttachProperty>(); | |||||
for (int i = 0; i < value.AttachCount; i++) | |||||
{ | |||||
AttachProperty attachProperty = new AttachProperty(); | |||||
attachProperty.FileNameLength = reader.ReadByte(); | |||||
attachProperty.FileName = reader.ReadString(attachProperty.FileNameLength); | |||||
attachProperty.FileSize = reader.ReadUInt32(); | |||||
value.AttachInfos.Add(attachProperty); | |||||
} | |||||
} | |||||
return value; | |||||
} | |||||
/// <summary> | |||||
/// | |||||
/// </summary> | |||||
/// <param name="writer"></param> | |||||
/// <param name="value"></param> | |||||
/// <param name="config"></param> | |||||
public void Serialize(ref JT808MessagePackWriter writer, JT808_0x1210 value, IJT808Config config) | |||||
{ | |||||
writer.WriteString(value.MakerID.PadRight(7, '\0')); | |||||
if (value.AlarmIdentification == null) | |||||
{ | |||||
throw new NullReferenceException($"{nameof(AlarmIdentificationProperty)}不为空"); | |||||
} | |||||
writer.WriteString(value.AlarmIdentification.TerminalID); | |||||
writer.WriteDateTime6(value.AlarmIdentification.Time); | |||||
writer.WriteByte(value.AlarmIdentification.SN); | |||||
writer.WriteByte(value.AlarmIdentification.AttachCount); | |||||
writer.WriteByte(value.AlarmIdentification.Retain); | |||||
writer.WriteString(value.AlarmId); | |||||
writer.WriteByte(value.InfoType); | |||||
if (value.AttachInfos != null && value.AttachInfos.Count > 0) | |||||
{ | |||||
writer.WriteByte((byte)value.AttachInfos.Count); | |||||
foreach (var item in value.AttachInfos) | |||||
{ | |||||
writer.Skip(1, out int FileNameLengthPosition); | |||||
writer.WriteString(item.FileName); | |||||
writer.WriteByteReturn((byte)(writer.GetCurrentPosition() - FileNameLengthPosition - 1), FileNameLengthPosition); | |||||
writer.WriteUInt32(item.FileSize); | |||||
} | |||||
} | |||||
else | |||||
{ | |||||
writer.WriteByte(0); | |||||
} | |||||
} | |||||
} | |||||
} |
@@ -0,0 +1,87 @@ | |||||
using JT808.Protocol.Formatters; | |||||
using JT808.Protocol.Interfaces; | |||||
using JT808.Protocol.MessagePack; | |||||
using System.Text.Json; | |||||
namespace JT808.Protocol.Extensions.JTActiveSafety.MessageBody | |||||
{ | |||||
/// <summary> | |||||
/// 文件信息上传 | |||||
/// </summary> | |||||
public class JT808_0x1211 : JT808Bodies, IJT808MessagePackFormatter<JT808_0x1211>, IJT808Analyze | |||||
{ | |||||
/// <summary> | |||||
/// 文件信息上传 | |||||
/// </summary> | |||||
public override string Description => "文件信息上传"; | |||||
/// <summary> | |||||
/// 文件名称长度 | |||||
/// </summary> | |||||
public byte FileNameLength { get; set; } | |||||
/// <summary> | |||||
/// 文件名称 | |||||
/// 形如:文件类型_通道号_报警类型_序号_报警编号.后缀名 | |||||
/// </summary> | |||||
public string FileName { get; set; } | |||||
/// <summary> | |||||
/// 文件类型 | |||||
/// </summary> | |||||
public byte FileType { get; set; } | |||||
/// <summary> | |||||
/// 文件大小 | |||||
/// </summary> | |||||
public uint FileSize { get; set; } | |||||
/// <summary> | |||||
/// 文件信息上传Id | |||||
/// </summary> | |||||
public override ushort MsgId => 0x1211; | |||||
/// <summary> | |||||
/// | |||||
/// </summary> | |||||
/// <param name="reader"></param> | |||||
/// <param name="writer"></param> | |||||
/// <param name="config"></param> | |||||
public void Analyze(ref JT808MessagePackReader reader, Utf8JsonWriter writer, IJT808Config config) | |||||
{ | |||||
JT808_0x1211 value = new JT808_0x1211(); | |||||
value.FileNameLength = reader.ReadByte(); | |||||
writer.WriteNumber($"[{value.FileNameLength.ReadNumber()}]文件名称长度", value.FileNameLength); | |||||
string fileNameHex = reader.ReadVirtualArray(value.FileNameLength).ToArray().ToHexString(); | |||||
value.FileName = reader.ReadString(value.FileNameLength); | |||||
writer.WriteString($"[{fileNameHex}]文件名称", value.FileName); | |||||
value.FileType = reader.ReadByte(); | |||||
writer.WriteNumber($"[{value.FileType.ReadNumber()}]文件类型", value.FileType); | |||||
value.FileSize = reader.ReadUInt32(); | |||||
writer.WriteNumber($"[{value.FileSize.ReadNumber()}]文件大小", value.FileSize); | |||||
} | |||||
/// <summary> | |||||
/// | |||||
/// </summary> | |||||
/// <param name="reader"></param> | |||||
/// <param name="config"></param> | |||||
/// <returns></returns> | |||||
public JT808_0x1211 Deserialize(ref JT808MessagePackReader reader, IJT808Config config) | |||||
{ | |||||
JT808_0x1211 value = new JT808_0x1211(); | |||||
value.FileNameLength = reader.ReadByte(); | |||||
value.FileName = reader.ReadString(value.FileNameLength); | |||||
value.FileType = reader.ReadByte(); | |||||
value.FileSize = reader.ReadUInt32(); | |||||
return value; | |||||
} | |||||
/// <summary> | |||||
/// | |||||
/// </summary> | |||||
/// <param name="writer"></param> | |||||
/// <param name="value"></param> | |||||
/// <param name="config"></param> | |||||
public void Serialize(ref JT808MessagePackWriter writer, JT808_0x1211 value, IJT808Config config) | |||||
{ | |||||
writer.Skip(1, out int FileNameLengthPosition); | |||||
writer.WriteString(value.FileName); | |||||
writer.WriteByteReturn((byte)(writer.GetCurrentPosition() - FileNameLengthPosition - 1), FileNameLengthPosition); | |||||
writer.WriteByte(value.FileType); | |||||
writer.WriteUInt32(value.FileSize); | |||||
} | |||||
} | |||||
} |
@@ -0,0 +1,87 @@ | |||||
using JT808.Protocol.Formatters; | |||||
using JT808.Protocol.Interfaces; | |||||
using JT808.Protocol.MessagePack; | |||||
using System.Text.Json; | |||||
namespace JT808.Protocol.Extensions.JTActiveSafety.MessageBody | |||||
{ | |||||
/// <summary> | |||||
/// 文件上传完成消息 | |||||
/// </summary> | |||||
public class JT808_0x1212 : JT808Bodies, IJT808MessagePackFormatter<JT808_0x1212>, IJT808Analyze | |||||
{ | |||||
/// <summary> | |||||
/// 文件上传完成消息 | |||||
/// </summary> | |||||
public override string Description => "文件上传完成消息"; | |||||
/// <summary> | |||||
/// 文件名称长度 | |||||
/// </summary> | |||||
public byte FileNameLength { get; set; } | |||||
/// <summary> | |||||
/// 文件名称 | |||||
/// 形如:文件类型_通道号_报警类型_序号_报警编号.后缀名 | |||||
/// </summary> | |||||
public string FileName { get; set; } | |||||
/// <summary> | |||||
/// 文件类型 | |||||
/// </summary> | |||||
public byte FileType { get; set; } | |||||
/// <summary> | |||||
/// 文件大小 | |||||
/// </summary> | |||||
public uint FileSize { get; set; } | |||||
/// <summary> | |||||
/// 文件上传完成消息 | |||||
/// </summary> | |||||
public override ushort MsgId => 0x1212; | |||||
/// <summary> | |||||
/// | |||||
/// </summary> | |||||
/// <param name="reader"></param> | |||||
/// <param name="writer"></param> | |||||
/// <param name="config"></param> | |||||
public void Analyze(ref JT808MessagePackReader reader, Utf8JsonWriter writer, IJT808Config config) | |||||
{ | |||||
JT808_0x1212 value = new JT808_0x1212(); | |||||
value.FileNameLength = reader.ReadByte(); | |||||
writer.WriteNumber($"[{value.FileNameLength.ReadNumber()}]文件名称长度", value.FileNameLength); | |||||
string fileNameHex = reader.ReadVirtualArray(value.FileNameLength).ToArray().ToHexString(); | |||||
value.FileName = reader.ReadString(value.FileNameLength); | |||||
writer.WriteString($"[{fileNameHex}]文件名称", value.FileName); | |||||
value.FileType = reader.ReadByte(); | |||||
writer.WriteNumber($"[{value.FileType.ReadNumber()}]文件类型", value.FileType); | |||||
value.FileSize = reader.ReadUInt32(); | |||||
writer.WriteNumber($"[{value.FileSize.ReadNumber()}]文件大小", value.FileSize); | |||||
} | |||||
/// <summary> | |||||
/// | |||||
/// </summary> | |||||
/// <param name="reader"></param> | |||||
/// <param name="config"></param> | |||||
/// <returns></returns> | |||||
public JT808_0x1212 Deserialize(ref JT808MessagePackReader reader, IJT808Config config) | |||||
{ | |||||
JT808_0x1212 value = new JT808_0x1212(); | |||||
value.FileNameLength = reader.ReadByte(); | |||||
value.FileName = reader.ReadString(value.FileNameLength); | |||||
value.FileType = reader.ReadByte(); | |||||
value.FileSize = reader.ReadUInt32(); | |||||
return value; | |||||
} | |||||
/// <summary> | |||||
/// | |||||
/// </summary> | |||||
/// <param name="writer"></param> | |||||
/// <param name="value"></param> | |||||
/// <param name="config"></param> | |||||
public void Serialize(ref JT808MessagePackWriter writer, JT808_0x1212 value, IJT808Config config) | |||||
{ | |||||
writer.Skip(1, out int FileNameLengthPosition); | |||||
writer.WriteString(value.FileName); | |||||
writer.WriteByteReturn((byte)(writer.GetCurrentPosition() - FileNameLengthPosition - 1), FileNameLengthPosition); | |||||
writer.WriteByte(value.FileType); | |||||
writer.WriteUInt32(value.FileSize); | |||||
} | |||||
} | |||||
} |