diff --git a/.github/workflows/dotnetcore.yml b/.github/workflows/dotnetcore.yml index becb70f..71a6b9e 100755 --- a/.github/workflows/dotnetcore.yml +++ b/.github/workflows/dotnetcore.yml @@ -17,7 +17,15 @@ jobs: run: dotnet --info - name: dotnet restore 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 - - name: dotnet test + - name: dotnet jt808 test 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 diff --git a/README.md b/README.md index a673d6d..6d9bb6b 100644 --- a/README.md +++ b/README.md @@ -420,3 +420,79 @@ Platform=AnyCpu Server=False Toolchain=.NET Core 5.0 | 73 | 0x0608 | √ | √ | 查询区域或线路数据应答 |新增| | 74 | 0xE000~0xEFFF | 保留 | 保留 | 厂商自定义上行消息 |新增| | 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(); +``` diff --git a/src/JT808.Protocol.Extensions/JT808.Protocol.Extensions.JT1078.Test/JT808.Protocol.Extensions.JT1078.Test.csproj b/src/JT808.Protocol.Extensions/JT808.Protocol.Extensions.JT1078.Test/JT808.Protocol.Extensions.JT1078.Test.csproj new file mode 100644 index 0000000..445b395 --- /dev/null +++ b/src/JT808.Protocol.Extensions/JT808.Protocol.Extensions.JT1078.Test/JT808.Protocol.Extensions.JT1078.Test.csproj @@ -0,0 +1,22 @@ + + + + net5.0 + + + + + + + + + all + runtime; build; native; contentfiles; analyzers; buildtransitive + + + + + + + + diff --git a/src/JT808.Protocol.Extensions/JT808.Protocol.Extensions.JT1078.Test/JT808LocationAttach.cs b/src/JT808.Protocol.Extensions/JT808.Protocol.Extensions.JT1078.Test/JT808LocationAttach.cs new file mode 100644 index 0000000..9f94c3b --- /dev/null +++ b/src/JT808.Protocol.Extensions/JT808.Protocol.Extensions.JT1078.Test/JT808LocationAttach.cs @@ -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(); + 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() + }; + 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(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(bodys); + } + } +} diff --git a/src/JT808.Protocol.Extensions/JT808.Protocol.Extensions.JT1078.Test/JT808_0x0200Test.cs b/src/JT808.Protocol.Extensions/JT808.Protocol.Extensions.JT1078.Test/JT808_0x0200Test.cs new file mode 100644 index 0000000..0158215 --- /dev/null +++ b/src/JT808.Protocol.Extensions/JT808.Protocol.Extensions.JT1078.Test/JT808_0x0200Test.cs @@ -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(); + 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() + }; + 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(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(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() + }; + 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(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(bodys); + } + } +} diff --git a/src/JT808.Protocol.Extensions/JT808.Protocol.Extensions.JT1078.Test/JT808_0x1003Test.cs b/src/JT808.Protocol.Extensions/JT808.Protocol.Extensions.JT1078.Test/JT808_0x1003Test.cs new file mode 100644 index 0000000..d8bbffe --- /dev/null +++ b/src/JT808.Protocol.Extensions/JT808.Protocol.Extensions.JT1078.Test/JT808_0x1003Test.cs @@ -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(); + 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("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("03020504000101060708".ToHexBytes()); + } + } +} diff --git a/src/JT808.Protocol.Extensions/JT808.Protocol.Extensions.JT1078.Test/JT808_0x1005Test.cs b/src/JT808.Protocol.Extensions/JT808.Protocol.Extensions.JT1078.Test/JT808_0x1005Test.cs new file mode 100644 index 0000000..626c3e3 --- /dev/null +++ b/src/JT808.Protocol.Extensions/JT808.Protocol.Extensions.JT1078.Test/JT808_0x1005Test.cs @@ -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(); + JT808Serializer = defaultConfig.GetSerializer(); + + Newtonsoft.Json.JsonConvert.DefaultSettings = new Func(() => + { + //日期类型默认格式化处理 + return new Newtonsoft.Json.JsonSerializerSettings + { + DateFormatHandling = Newtonsoft.Json.DateFormatHandling.MicrosoftDateFormat, + DateFormatString = "yyyy-MM-dd HH:mm:ss" + }; + }); + } + + [Fact] + public void Test1() + { + JT808_0x1005 jT808_0x1005 = new JT808_0x1005() + { + BeginTime=Convert.ToDateTime("2019-07-16 10:20:01"), + EndTime= Convert.ToDateTime("2019-07-16 10:25:02"), + GettingOffNumber=1, + GettingOnNumber=1 + }; + var hex = JT808Serializer.Serialize(jT808_0x1005).ToHexString(); + Assert.Equal("19071610200119071610250200010001", hex); + } + + [Fact] + public void Test2() + { + var jT808_0x1005 = JT808Serializer.Deserialize("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("19071610200119071610250200010001".ToHexBytes()); + } + } +} diff --git a/src/JT808.Protocol.Extensions/JT808.Protocol.Extensions.JT1078.Test/JT808_0x1205Test.cs b/src/JT808.Protocol.Extensions/JT808.Protocol.Extensions.JT1078.Test/JT808_0x1205Test.cs new file mode 100644 index 0000000..0c3e16a --- /dev/null +++ b/src/JT808.Protocol.Extensions/JT808.Protocol.Extensions.JT1078.Test/JT808_0x1205Test.cs @@ -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(); + JT808Serializer = defaultConfig.GetSerializer(); + + Newtonsoft.Json.JsonConvert.DefaultSettings = new Func(() => + { + //日期类型默认格式化处理 + return new Newtonsoft.Json.JsonSerializerSettings + { + DateFormatHandling = Newtonsoft.Json.DateFormatHandling.MicrosoftDateFormat, + DateFormatString = "yyyy-MM-dd HH:mm:ss" + }; + }); + } + + [Fact] + public void Test1() + { + JT808_0x1205 jT808_0x1205 = new JT808_0x1205() + { + MsgNum = 1, + AVResouceTotal = 2, + AVResouces = new List { + new JT808_0x1205_AVResouce{ + AlarmFlag=1, + AVResourceType=2, + BeginTime=Convert.ToDateTime("2019-07-16 10:20:01"), + EndTime=Convert.ToDateTime("2019-07-16 10:25:01"), + FileSize=3, + LogicChannelNo=4, + MemoryType=5, + StreamType=6 + }, + new JT808_0x1205_AVResouce{ + AlarmFlag=11, + AVResourceType=21, + BeginTime=Convert.ToDateTime("2019-07-16 11:20:01"), + EndTime=Convert.ToDateTime("2019-07-16 11:25:02"), + FileSize=31, + LogicChannelNo=41, + MemoryType=51, + StreamType=61 + } + } + }; + var hex = JT808Serializer.Serialize(jT808_0x1205).ToHexString(); + Assert.Equal("0001000000020419071610200119071610250100000000000000010206050000000329190716112001190716112502000000000000000B153D330000001F", hex); + } + + [Fact] + public void Test2() + { + var jT808_0x1205 = JT808Serializer.Deserialize("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("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(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(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); + } + } +} diff --git a/src/JT808.Protocol.Extensions/JT808.Protocol.Extensions.JT1078.Test/JT808_0x1206Test.cs b/src/JT808.Protocol.Extensions/JT808.Protocol.Extensions.JT1078.Test/JT808_0x1206Test.cs new file mode 100644 index 0000000..115369c --- /dev/null +++ b/src/JT808.Protocol.Extensions/JT808.Protocol.Extensions.JT1078.Test/JT808_0x1206Test.cs @@ -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(); + JT808Serializer = defaultConfig.GetSerializer(); + + Newtonsoft.Json.JsonConvert.DefaultSettings = new Func(() => + { + //日期类型默认格式化处理 + return new Newtonsoft.Json.JsonSerializerSettings + { + DateFormatHandling = Newtonsoft.Json.DateFormatHandling.MicrosoftDateFormat, + DateFormatString = "yyyy-MM-dd HH:mm:ss" + }; + }); + } + + [Fact] + public void Test1() + { + JT808_0x1206 jT808_0x1206 = new JT808_0x1206() + { + MsgNum=1, + Result=1 + }; + var hex = JT808Serializer.Serialize(jT808_0x1206).ToHexString(); + Assert.Equal("000101", hex); + } + + [Fact] + public void Test2() + { + var jT808_0x1206 = JT808Serializer.Deserialize("000101".ToHexBytes()); + Assert.Equal(1, jT808_0x1206.MsgNum); + Assert.Equal(1, jT808_0x1206.Result); + } + [Fact] + public void Test3() + { + var jT808_0x1206 = JT808Serializer.Analyze("000101".ToHexBytes()); + } + } +} diff --git a/src/JT808.Protocol.Extensions/JT808.Protocol.Extensions.JT1078.Test/JT808_0x8103CustomId.cs b/src/JT808.Protocol.Extensions/JT808.Protocol.Extensions.JT1078.Test/JT808_0x8103CustomId.cs new file mode 100644 index 0000000..480eb2d --- /dev/null +++ b/src/JT808.Protocol.Extensions/JT808.Protocol.Extensions.JT1078.Test/JT808_0x8103CustomId.cs @@ -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(); + 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 { + new JT808_0x8103_0x0075 { + AudioOutputEnabled=1, + OSD=2, + RTS_EncodeMode=3, + RTS_KF_Interval=4, + RTS_Resolution=5, + RTS_Target_CodeRate=6, + RTS_Target_FPS=7, + StreamStore_EncodeMode=8, + StreamStore_KF_Interval=9, + StreamStore_Resolution=10, + StreamStore_Target_CodeRate=11, + StreamStore_Target_FPS=12 + }, + new JT808_0x8103_0x0076 { + AudioChannelTotal=1, + AVChannelTotal=2, + VudioChannelTotal=3, + ParamLength=27, + AVChannelRefTables=new List{ + new JT808_0x8103_0x0076_AVChannelRefTable{ + ChannelType =0, + IsConnectCloudPlat =1, + LogicChannelNo =2, + PhysicalChannelNo =3 }, + new JT808_0x8103_0x0076_AVChannelRefTable{ + ChannelType =4, + IsConnectCloudPlat =5, + LogicChannelNo =6, + PhysicalChannelNo =7 }, + new JT808_0x8103_0x0076_AVChannelRefTable{ + ChannelType =8, + IsConnectCloudPlat =9, + LogicChannelNo =10, + PhysicalChannelNo =11 }, + new JT808_0x8103_0x0076_AVChannelRefTable{ + ChannelType =12, + IsConnectCloudPlat =13, + LogicChannelNo =14, + PhysicalChannelNo =15 }, + new JT808_0x8103_0x0076_AVChannelRefTable{ + ChannelType =16, + IsConnectCloudPlat =17, + LogicChannelNo =18, + PhysicalChannelNo =19 }, + new JT808_0x8103_0x0076_AVChannelRefTable{ + ChannelType =20, + IsConnectCloudPlat =21, + LogicChannelNo =22, + PhysicalChannelNo =23 } + } + }, + new JT808_0x8103_0x0077{ + NeedSetChannelTotal=2, + ParamLength=43, + SignalChannels=new List{ + new JT808_0x8103_0x0077_SignalChannel{ + LogicChannelNo =1, + OSD =2, + RTS_EncodeMode =3, + RTS_KF_Interval =4, + RTS_Resolution =5, + RTS_Target_CodeRate =6, + RTS_Target_FPS =7, + StreamStore_EncodeMode =8, + StreamStore_KF_Interval =9, + StreamStore_Resolution =10, + StreamStore_Target_CodeRate=11, + StreamStore_Target_FPS =12 + }, + new JT808_0x8103_0x0077_SignalChannel{ + LogicChannelNo=1, + OSD =2, + RTS_EncodeMode =3, + RTS_KF_Interval =4, + RTS_Resolution =5, + RTS_Target_CodeRate =6, + RTS_Target_FPS =7, + StreamStore_EncodeMode =8, + StreamStore_KF_Interval =9, + StreamStore_Resolution =10, + StreamStore_Target_CodeRate=11, + StreamStore_Target_FPS =12 + } + } + }, + new JT808_0x8103_0x0079{ + BeginMinute=1, + Duration =2, + StorageThresholds =3 + }, + new JT808_0x8103_0x007A{ + AlarmShielding=1 + }, + new JT808_0x8103_0x007B{ + NuclearLoadNumber=1, + FatigueThreshold =2 + }, + new JT808_0x8103_0x007C{ + SleepWakeMode=1, + TimerWakeDaySet =2, + WakeConditionType =3, + 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"; + } +} diff --git a/src/JT808.Protocol.Extensions/JT808.Protocol.Extensions.JT1078.Test/JT808_0x9101Test.cs b/src/JT808.Protocol.Extensions/JT808.Protocol.Extensions.JT1078.Test/JT808_0x9101Test.cs new file mode 100644 index 0000000..7dad73f --- /dev/null +++ b/src/JT808.Protocol.Extensions/JT808.Protocol.Extensions.JT1078.Test/JT808_0x9101Test.cs @@ -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(); + 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("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("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(); + } + } +} diff --git a/src/JT808.Protocol.Extensions/JT808.Protocol.Extensions.JT1078.Test/JT808_0x9102Test.cs b/src/JT808.Protocol.Extensions/JT808.Protocol.Extensions.JT1078.Test/JT808_0x9102Test.cs new file mode 100644 index 0000000..6ed77e8 --- /dev/null +++ b/src/JT808.Protocol.Extensions/JT808.Protocol.Extensions.JT1078.Test/JT808_0x9102Test.cs @@ -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(); + 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("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("01010000".ToHexBytes()); + } + } +} diff --git a/src/JT808.Protocol.Extensions/JT808.Protocol.Extensions.JT1078.Test/JT808_0x9105Test.cs b/src/JT808.Protocol.Extensions/JT808.Protocol.Extensions.JT1078.Test/JT808_0x9105Test.cs new file mode 100644 index 0000000..34fc0c4 --- /dev/null +++ b/src/JT808.Protocol.Extensions/JT808.Protocol.Extensions.JT1078.Test/JT808_0x9105Test.cs @@ -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(); + JT808Serializer = defaultConfig.GetSerializer(); + + Newtonsoft.Json.JsonConvert.DefaultSettings = new Func(() => + { + //日期类型默认格式化处理 + return new Newtonsoft.Json.JsonSerializerSettings + { + DateFormatHandling = Newtonsoft.Json.DateFormatHandling.MicrosoftDateFormat, + DateFormatString = "yyyy-MM-dd HH:mm:ss" + }; + }); + } + + [Fact] + public void Test1() + { + JT808_0x9105 jT808_0x9105 = new JT808_0x9105() + { + ChannelNo=1, + DropRate=2 + }; + var hex = JT808Serializer.Serialize(jT808_0x9105).ToHexString(); + Assert.Equal("0102", hex); + } + + [Fact] + public void Test2() + { + var jT808_0x9105 = JT808Serializer.Deserialize("0102".ToHexBytes()); + Assert.Equal(1, jT808_0x9105.ChannelNo); + Assert.Equal(2, jT808_0x9105.DropRate); + } + [Fact] + public void Test3() + { + var jT808_0x9105 = JT808Serializer.Analyze("0102".ToHexBytes()); + } + } +} \ No newline at end of file diff --git a/src/JT808.Protocol.Extensions/JT808.Protocol.Extensions.JT1078.Test/JT808_0x9201Test.cs b/src/JT808.Protocol.Extensions/JT808.Protocol.Extensions.JT1078.Test/JT808_0x9201Test.cs new file mode 100644 index 0000000..2f9bea7 --- /dev/null +++ b/src/JT808.Protocol.Extensions/JT808.Protocol.Extensions.JT1078.Test/JT808_0x9201Test.cs @@ -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(); + JT808Serializer = defaultConfig.GetSerializer(); + + Newtonsoft.Json.JsonConvert.DefaultSettings = new Func(() => + { + //日期类型默认格式化处理 + return new Newtonsoft.Json.JsonSerializerSettings + { + DateFormatHandling = Newtonsoft.Json.DateFormatHandling.MicrosoftDateFormat, + DateFormatString = "yyyy-MM-dd HH:mm:ss" + }; + }); + } + + [Fact] + public void Test1() + { + JT808_0x9201 jT808_0x9201 = new JT808_0x9201() + { + 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("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("093132372E302E302E3100501F90010207050603190716101010190716101010".ToHexBytes()); + } + } +} \ No newline at end of file diff --git a/src/JT808.Protocol.Extensions/JT808.Protocol.Extensions.JT1078.Test/JT808_0x9202Test.cs b/src/JT808.Protocol.Extensions/JT808.Protocol.Extensions.JT1078.Test/JT808_0x9202Test.cs new file mode 100644 index 0000000..3c2829e --- /dev/null +++ b/src/JT808.Protocol.Extensions/JT808.Protocol.Extensions.JT1078.Test/JT808_0x9202Test.cs @@ -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(); + JT808Serializer = defaultConfig.GetSerializer(); + + Newtonsoft.Json.JsonConvert.DefaultSettings = new Func(() => + { + //日期类型默认格式化处理 + return new Newtonsoft.Json.JsonSerializerSettings + { + DateFormatHandling = Newtonsoft.Json.DateFormatHandling.MicrosoftDateFormat, + DateFormatString = "yyyy-MM-dd HH:mm:ss" + }; + }); + } + + [Fact] + public void Test1() + { + JT808_0x9202 jT808_0x9202 = new JT808_0x9202() + { + 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("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("010302190716101010".ToHexBytes()); + } + } +} \ No newline at end of file diff --git a/src/JT808.Protocol.Extensions/JT808.Protocol.Extensions.JT1078.Test/JT808_0x9205Test.cs b/src/JT808.Protocol.Extensions/JT808.Protocol.Extensions.JT1078.Test/JT808_0x9205Test.cs new file mode 100644 index 0000000..7598a6f --- /dev/null +++ b/src/JT808.Protocol.Extensions/JT808.Protocol.Extensions.JT1078.Test/JT808_0x9205Test.cs @@ -0,0 +1,72 @@ +using JT808.Protocol.Extensions.JT1078.MessageBody; +using JT808.Protocol.Interfaces; +using Microsoft.Extensions.DependencyInjection; +using System; +using System.Collections.Generic; +using System.Text; +using Xunit; +using Microsoft.Extensions.Logging; +using Newtonsoft.Json; + +namespace JT808.Protocol.Extensions.JT1078.Test +{ + public class JT808_0x9205Test + { + JT808Serializer JT808Serializer; + public JT808_0x9205Test() + { + IServiceCollection serviceDescriptors1 = new ServiceCollection(); + serviceDescriptors1 + .AddJT808Configure() + .AddJT1078Configure(); + var ServiceProvider1 = serviceDescriptors1.BuildServiceProvider(); + var defaultConfig = ServiceProvider1.GetRequiredService(); + JT808Serializer = defaultConfig.GetSerializer(); + + Newtonsoft.Json.JsonConvert.DefaultSettings = new Func(() => + { + //日期类型默认格式化处理 + return new Newtonsoft.Json.JsonSerializerSettings + { + DateFormatHandling = Newtonsoft.Json.DateFormatHandling.MicrosoftDateFormat, + DateFormatString = "yyyy-MM-dd HH:mm:ss" + }; + }); + } + + [Fact] + public void Test1() + { + JT808_0x9205 jT808_0x9205 = new JT808_0x9205() + { + AlarmFlag=1, + 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("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("031907161010101907161010110000000000000001020504".ToHexBytes()); + } + } +} \ No newline at end of file diff --git a/src/JT808.Protocol.Extensions/JT808.Protocol.Extensions.JT1078.Test/JT808_0x9206Test.cs b/src/JT808.Protocol.Extensions/JT808.Protocol.Extensions.JT1078.Test/JT808_0x9206Test.cs new file mode 100644 index 0000000..7fa3a03 --- /dev/null +++ b/src/JT808.Protocol.Extensions/JT808.Protocol.Extensions.JT1078.Test/JT808_0x9206Test.cs @@ -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(); + JT808Serializer = defaultConfig.GetSerializer(); + + Newtonsoft.Json.JsonConvert.DefaultSettings = new Func(() => + { + //日期类型默认格式化处理 + return new Newtonsoft.Json.JsonSerializerSettings + { + DateFormatHandling = Newtonsoft.Json.DateFormatHandling.MicrosoftDateFormat, + DateFormatString = "yyyy-MM-dd HH:mm:ss" + }; + }); + } + + [Fact] + public void Test1() + { + JT808_0x9206 jT808_0x9206 = new JT808_0x9206() + { + AlarmFlag=1, + 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("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("093132372E302E302E31032802746B0631323334353608443A2F2F31313132031907161010101907161010110000000102050407".ToHexBytes()); + } + } +} \ No newline at end of file diff --git a/src/JT808.Protocol.Extensions/JT808.Protocol.Extensions.JT1078.Test/JT808_0x9207Test.cs b/src/JT808.Protocol.Extensions/JT808.Protocol.Extensions.JT1078.Test/JT808_0x9207Test.cs new file mode 100644 index 0000000..78e8e05 --- /dev/null +++ b/src/JT808.Protocol.Extensions/JT808.Protocol.Extensions.JT1078.Test/JT808_0x9207Test.cs @@ -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(); + JT808Serializer = defaultConfig.GetSerializer(); + + Newtonsoft.Json.JsonConvert.DefaultSettings = new Func(() => + { + //日期类型默认格式化处理 + return new Newtonsoft.Json.JsonSerializerSettings + { + DateFormatHandling = Newtonsoft.Json.DateFormatHandling.MicrosoftDateFormat, + DateFormatString = "yyyy-MM-dd HH:mm:ss" + }; + }); + } + + [Fact] + public void Test1() + { + JT808_0x9207 jT808_0x9207 = new JT808_0x9207() + { + MgsNum=1, + UploadControl=2 + }; + var hex = JT808Serializer.Serialize(jT808_0x9207).ToHexString(); + Assert.Equal("000102", hex); + } + + [Fact] + public void Test2() + { + var jT808_0x9207 = JT808Serializer.Deserialize("000102".ToHexBytes()); + Assert.Equal(1, jT808_0x9207.MgsNum); + Assert.Equal(2, jT808_0x9207.UploadControl); + } + [Fact] + public void Test3() + { + var jT808_0x9207 = JT808Serializer.Analyze("000102".ToHexBytes()); + } + } +} \ No newline at end of file diff --git a/src/JT808.Protocol.Extensions/JT808.Protocol.Extensions.JT1078.Test/JT808_0x9301Test.cs b/src/JT808.Protocol.Extensions/JT808.Protocol.Extensions.JT1078.Test/JT808_0x9301Test.cs new file mode 100644 index 0000000..bab269f --- /dev/null +++ b/src/JT808.Protocol.Extensions/JT808.Protocol.Extensions.JT1078.Test/JT808_0x9301Test.cs @@ -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(); + JT808Serializer = defaultConfig.GetSerializer(); + + Newtonsoft.Json.JsonConvert.DefaultSettings = new Func(() => + { + //日期类型默认格式化处理 + return new Newtonsoft.Json.JsonSerializerSettings + { + DateFormatHandling = Newtonsoft.Json.DateFormatHandling.MicrosoftDateFormat, + DateFormatString = "yyyy-MM-dd HH:mm:ss" + }; + }); + } + + [Fact] + public void Test1() + { + JT808_0x9301 jT808_0x9301 = new JT808_0x9301() + { + 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("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("010302".ToHexBytes()); + + } + } +} \ No newline at end of file diff --git a/src/JT808.Protocol.Extensions/JT808.Protocol.Extensions.JT1078.Test/JT808_0x9302Test.cs b/src/JT808.Protocol.Extensions/JT808.Protocol.Extensions.JT1078.Test/JT808_0x9302Test.cs new file mode 100644 index 0000000..bce0e56 --- /dev/null +++ b/src/JT808.Protocol.Extensions/JT808.Protocol.Extensions.JT1078.Test/JT808_0x9302Test.cs @@ -0,0 +1,63 @@ +using JT808.Protocol.Extensions.JT1078.MessageBody; +using JT808.Protocol.Interfaces; +using Microsoft.Extensions.DependencyInjection; +using System; +using System.Collections.Generic; +using System.Text; +using Xunit; +using Microsoft.Extensions.Logging; +using Newtonsoft.Json; + +namespace JT808.Protocol.Extensions.JT1078.Test +{ + public class JT808_0x9302Test + { + JT808Serializer JT808Serializer; + public JT808_0x9302Test() + { + IServiceCollection serviceDescriptors1 = new ServiceCollection(); + serviceDescriptors1 + .AddJT808Configure() + .AddJT1078Configure(); + var ServiceProvider1 = serviceDescriptors1.BuildServiceProvider(); + var defaultConfig = ServiceProvider1.GetRequiredService(); + JT808Serializer = defaultConfig.GetSerializer(); + + Newtonsoft.Json.JsonConvert.DefaultSettings = new Func(() => + { + //日期类型默认格式化处理 + return new Newtonsoft.Json.JsonSerializerSettings + { + DateFormatHandling = Newtonsoft.Json.DateFormatHandling.MicrosoftDateFormat, + DateFormatString = "yyyy-MM-dd HH:mm:ss" + }; + }); + } + + [Fact] + public void Test1() + { + JT808_0x9302 jT808_0x9302 = new JT808_0x9302() + { + LogicChannelNo=1, + FocusAdjustmentDirection=2 + }; + var hex = JT808Serializer.Serialize(jT808_0x9302).ToHexString(); + Assert.Equal("0102", hex); + } + + [Fact] + public void Test2() + { + var jT808_0x9302 = JT808Serializer.Deserialize("0102".ToHexBytes()); + Assert.Equal(1, jT808_0x9302.LogicChannelNo); + Assert.Equal(2, jT808_0x9302.FocusAdjustmentDirection); + } + [Fact] + public void Test3() + { + var jT808_0x9302 = JT808Serializer.Analyze("0102".ToHexBytes()); + + } + } +} \ No newline at end of file diff --git a/src/JT808.Protocol.Extensions/JT808.Protocol.Extensions.JT1078.Test/JT808_0x9303Test.cs b/src/JT808.Protocol.Extensions/JT808.Protocol.Extensions.JT1078.Test/JT808_0x9303Test.cs new file mode 100644 index 0000000..d72ac0c --- /dev/null +++ b/src/JT808.Protocol.Extensions/JT808.Protocol.Extensions.JT1078.Test/JT808_0x9303Test.cs @@ -0,0 +1,63 @@ +using JT808.Protocol.Extensions.JT1078.MessageBody; +using JT808.Protocol.Interfaces; +using Microsoft.Extensions.DependencyInjection; +using System; +using System.Collections.Generic; +using System.Text; +using Xunit; +using Microsoft.Extensions.Logging; +using Newtonsoft.Json; + +namespace JT808.Protocol.Extensions.JT1078.Test +{ + public class JT808_0x9303Test + { + JT808Serializer JT808Serializer; + public JT808_0x9303Test() + { + IServiceCollection serviceDescriptors1 = new ServiceCollection(); + serviceDescriptors1 + .AddJT808Configure() + .AddJT1078Configure(); + var ServiceProvider1 = serviceDescriptors1.BuildServiceProvider(); + var defaultConfig = ServiceProvider1.GetRequiredService(); + JT808Serializer = defaultConfig.GetSerializer(); + + Newtonsoft.Json.JsonConvert.DefaultSettings = new Func(() => + { + //日期类型默认格式化处理 + return new Newtonsoft.Json.JsonSerializerSettings + { + DateFormatHandling = Newtonsoft.Json.DateFormatHandling.MicrosoftDateFormat, + DateFormatString = "yyyy-MM-dd HH:mm:ss" + }; + }); + } + + [Fact] + public void Test1() + { + JT808_0x9303 jT808_0x9303 = new JT808_0x9303() + { + ChannelNo=1, + IrisAdjustment=2 + }; + var hex = JT808Serializer.Serialize(jT808_0x9303).ToHexString(); + Assert.Equal("0102", hex); + } + + [Fact] + public void Test2() + { + var jT808_0x9303 = JT808Serializer.Deserialize("0102".ToHexBytes()); + Assert.Equal(1, jT808_0x9303.ChannelNo); + Assert.Equal(2, jT808_0x9303.IrisAdjustment); + } + [Fact] + public void Test3() + { + var jT808_0x9303 = JT808Serializer.Analyze("0102".ToHexBytes()); + + } + } +} \ No newline at end of file diff --git a/src/JT808.Protocol.Extensions/JT808.Protocol.Extensions.JT1078.Test/JT808_0x9304Test.cs b/src/JT808.Protocol.Extensions/JT808.Protocol.Extensions.JT1078.Test/JT808_0x9304Test.cs new file mode 100644 index 0000000..5cb9962 --- /dev/null +++ b/src/JT808.Protocol.Extensions/JT808.Protocol.Extensions.JT1078.Test/JT808_0x9304Test.cs @@ -0,0 +1,63 @@ +using JT808.Protocol.Extensions.JT1078.MessageBody; +using JT808.Protocol.Interfaces; +using Microsoft.Extensions.DependencyInjection; +using System; +using System.Collections.Generic; +using System.Text; +using Xunit; +using Microsoft.Extensions.Logging; +using Newtonsoft.Json; + +namespace JT808.Protocol.Extensions.JT1078.Test +{ + public class JT808_0x9304Test + { + JT808Serializer JT808Serializer; + public JT808_0x9304Test() + { + IServiceCollection serviceDescriptors1 = new ServiceCollection(); + serviceDescriptors1 + .AddJT808Configure() + .AddJT1078Configure(); + var ServiceProvider1 = serviceDescriptors1.BuildServiceProvider(); + var defaultConfig = ServiceProvider1.GetRequiredService(); + JT808Serializer = defaultConfig.GetSerializer(); + + Newtonsoft.Json.JsonConvert.DefaultSettings = new Func(() => + { + //日期类型默认格式化处理 + return new Newtonsoft.Json.JsonSerializerSettings + { + DateFormatHandling = Newtonsoft.Json.DateFormatHandling.MicrosoftDateFormat, + DateFormatString = "yyyy-MM-dd HH:mm:ss" + }; + }); + } + + [Fact] + public void Test1() + { + JT808_0x9304 jT808_0x9304 = new JT808_0x9304() + { + ChannelNo=1, + StartOrStop=2 + }; + var hex = JT808Serializer.Serialize(jT808_0x9304).ToHexString(); + Assert.Equal("0102", hex); + } + + [Fact] + public void Test2() + { + var jT808_0x9304 = JT808Serializer.Deserialize("0102".ToHexBytes()); + Assert.Equal(1, jT808_0x9304.ChannelNo); + Assert.Equal(2, jT808_0x9304.StartOrStop); + } + [Fact] + public void Test3() + { + var jT808_0x9304 = JT808Serializer.Analyze("0102".ToHexBytes()); + + } + } +} \ No newline at end of file diff --git a/src/JT808.Protocol.Extensions/JT808.Protocol.Extensions.JT1078.Test/JT808_0x9305Test.cs b/src/JT808.Protocol.Extensions/JT808.Protocol.Extensions.JT1078.Test/JT808_0x9305Test.cs new file mode 100644 index 0000000..7dd7751 --- /dev/null +++ b/src/JT808.Protocol.Extensions/JT808.Protocol.Extensions.JT1078.Test/JT808_0x9305Test.cs @@ -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(); + JT808Serializer = defaultConfig.GetSerializer(); + + Newtonsoft.Json.JsonConvert.DefaultSettings = new Func(() => + { + //日期类型默认格式化处理 + return new Newtonsoft.Json.JsonSerializerSettings + { + DateFormatHandling = Newtonsoft.Json.DateFormatHandling.MicrosoftDateFormat, + DateFormatString = "yyyy-MM-dd HH:mm:ss" + }; + }); + } + + [Fact] + public void Test1() + { + JT808_0x9305 jT808_0x9305 = new JT808_0x9305() + { + ChannelNo=1, + StartOrStop=2 + }; + var hex = JT808Serializer.Serialize(jT808_0x9305).ToHexString(); + Assert.Equal("0102", hex); + } + + [Fact] + public void Test2() + { + var jT808_0x9305 = JT808Serializer.Analyze("0102".ToHexBytes()); + + } + } +} \ No newline at end of file diff --git a/src/JT808.Protocol.Extensions/JT808.Protocol.Extensions.JT1078.Test/JT808_0x9306Test.cs b/src/JT808.Protocol.Extensions/JT808.Protocol.Extensions.JT1078.Test/JT808_0x9306Test.cs new file mode 100644 index 0000000..3f3c633 --- /dev/null +++ b/src/JT808.Protocol.Extensions/JT808.Protocol.Extensions.JT1078.Test/JT808_0x9306Test.cs @@ -0,0 +1,63 @@ +using JT808.Protocol.Extensions.JT1078.MessageBody; +using JT808.Protocol.Interfaces; +using Microsoft.Extensions.DependencyInjection; +using System; +using System.Collections.Generic; +using System.Text; +using Xunit; +using Microsoft.Extensions.Logging; +using Newtonsoft.Json; + +namespace JT808.Protocol.Extensions.JT1078.Test +{ + public class JT808_0x9306Test + { + JT808Serializer JT808Serializer; + public JT808_0x9306Test() + { + IServiceCollection serviceDescriptors1 = new ServiceCollection(); + serviceDescriptors1 + .AddJT808Configure() + .AddJT1078Configure(); + var ServiceProvider1 = serviceDescriptors1.BuildServiceProvider(); + var defaultConfig = ServiceProvider1.GetRequiredService(); + JT808Serializer = defaultConfig.GetSerializer(); + + Newtonsoft.Json.JsonConvert.DefaultSettings = new Func(() => + { + //日期类型默认格式化处理 + return new Newtonsoft.Json.JsonSerializerSettings + { + DateFormatHandling = Newtonsoft.Json.DateFormatHandling.MicrosoftDateFormat, + DateFormatString = "yyyy-MM-dd HH:mm:ss" + }; + }); + } + + [Fact] + public void Test1() + { + JT808_0x9306 jT808_0x9306 = new JT808_0x9306() + { + ChannelNo=1, + ChangeMultipleControl=2 + }; + var hex = JT808Serializer.Serialize(jT808_0x9306).ToHexString(); + Assert.Equal("0102", hex); + } + + [Fact] + public void Test2() + { + var jT808_0x9306 = JT808Serializer.Deserialize("0102".ToHexBytes()); + Assert.Equal(1, jT808_0x9306.ChannelNo); + Assert.Equal(2, jT808_0x9306.ChangeMultipleControl); + } + [Fact] + public void Test3() + { + var jT808_0x9306 = JT808Serializer.Analyze("0102".ToHexBytes()); + + } + } +} \ No newline at end of file diff --git a/src/JT808.Protocol.Extensions/JT808.Protocol.Extensions.JT1078/DependencyInjectionExtensions.cs b/src/JT808.Protocol.Extensions/JT808.Protocol.Extensions.JT1078/DependencyInjectionExtensions.cs new file mode 100644 index 0000000..c188a55 --- /dev/null +++ b/src/JT808.Protocol.Extensions/JT808.Protocol.Extensions.JT1078/DependencyInjectionExtensions.cs @@ -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; + } + } +} diff --git a/src/JT808.Protocol.Extensions/JT808.Protocol.Extensions.JT1078/Enums/JT808_JT1078_MsgId.cs b/src/JT808.Protocol.Extensions/JT808.Protocol.Extensions.JT1078/Enums/JT808_JT1078_MsgId.cs new file mode 100644 index 0000000..6d916c8 --- /dev/null +++ b/src/JT808.Protocol.Extensions/JT808.Protocol.Extensions.JT1078/Enums/JT808_JT1078_MsgId.cs @@ -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 注释 +} diff --git a/src/JT808.Protocol.Extensions/JT808.Protocol.Extensions.JT1078/Enums/VideoRelateAlarmType.cs b/src/JT808.Protocol.Extensions/JT808.Protocol.Extensions.JT1078/Enums/VideoRelateAlarmType.cs new file mode 100644 index 0000000..b4641ab --- /dev/null +++ b/src/JT808.Protocol.Extensions/JT808.Protocol.Extensions.JT1078/Enums/VideoRelateAlarmType.cs @@ -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 注释 +} diff --git a/src/JT808.Protocol.Extensions/JT808.Protocol.Extensions.JT1078/JT808.Protocol.Extensions.JT1078.csproj b/src/JT808.Protocol.Extensions/JT808.Protocol.Extensions.JT1078/JT808.Protocol.Extensions.JT1078.csproj new file mode 100644 index 0000000..ffd0c10 --- /dev/null +++ b/src/JT808.Protocol.Extensions/JT808.Protocol.Extensions.JT1078/JT808.Protocol.Extensions.JT1078.csproj @@ -0,0 +1,35 @@ + + + + netstandard2.0;netstandard2.1;net5.0; + 8.0 + Copyright 2019. + SmallChi(Koike) + JT808.Protocol.Extensions.JT1078 + JT808.Protocol.Extensions.JT1078 + 基于JT808协议、GB808协议扩展的视频消息协议 + 基于JT808协议、GB808协议扩展的视频消息协议 + true + https://github.com/SmallChi/JT1078 + https://github.com/SmallChi/JT1078 + https://github.com/SmallChi/JT808/blob/master/LICENSE + https://github.com/SmallChi/JT808/blob/master/LICENSE + false + 2.3.7 + LICENSE + JT808.Protocol.Extensions.JT1078.xml + + + + + True + + + + + + + + + + diff --git a/src/JT808.Protocol.Extensions/JT808.Protocol.Extensions.JT1078/JT808.Protocol.Extensions.JT1078.xml b/src/JT808.Protocol.Extensions/JT808.Protocol.Extensions.JT1078/JT808.Protocol.Extensions.JT1078.xml new file mode 100644 index 0000000..ced8b64 --- /dev/null +++ b/src/JT808.Protocol.Extensions/JT808.Protocol.Extensions.JT1078/JT808.Protocol.Extensions.JT1078.xml @@ -0,0 +1,1289 @@ + + + + JT808.Protocol.Extensions.JT1078 + + + + + 视频相关报警 + + + + + 视频信号丢失报警状态 + + + + + 视频信号遮挡报警状态 + + + + + 存储器故障报警状态 + + + + + 异常驾驶行为报警详细描述 + + + + + 音视频参数设置 + + + + + 音视频通道列表设置 + + + + + 单独视频通道参数设置 + + + + + 特殊报警录像参数设置 + + + + + 视频相关报警屏蔽字 + + + + + 图像分析报警参数设置 + + + + + 终端休眠模式唤醒设置 + + + + + 视频相关报警 + 0x0200_0x14 + + + + + 数据 长度 + + + + + 视频相关报警 + + + + + + 视频信号丢失报警状态 + 0x0200_0x15 + + + + + 数据 长度 + + + + + 视频信号丢失报警状态 + + + + + 视频信号遮挡报警状态 + 0x0200_0x16 + + + + + 数据 长度 + + + + + 视频信号遮挡报警状态 + + + + + 存储器故障报警状态 + 0x0200_0x17 + + + + + 数据 长度 + + + + + 存储器故障报警状态 + + + + + 异常驾驶行为报警详细描述 + 0x0200_0x18 + + + + + 数据 长度 + + + + + 异常驾驶行为报警类型 + + + + + 疲劳程度 + + + + + 终端上传音视频属性 + + + + + 输入音频编码方式 + + + + + 输入音频声道数 + + + + + 输入音频采样率 + + + + + 输入音频采样位数 + + + + + 音频帧长度 + + + + + 是否支持音频输出 + + + + + 视频编码方式 + + + + + 终端支持的最大音频物理通道数量 + + + + + 终端支持的最大视频物理通道数量 + + + + + 终端上传乘客流量 + + + + + 起始时间 + + + + + 结束时间 + + + + + 上车人数 + + + + + 下车人数 + + + + + 终端上传音视频资源列表 + + + + + 流水号 + + + + + 音视频资源总数 + + + + + 音视频资源列表 + + + + + 终端上传音视频资源列表 + + + + + 逻辑通道号 + + + + + 开始时间 + + + + + 结束时间 + + + + + 报警标志 + + + + + 音视频资源类型 + + + + + 码流类型 + + + + + 存储器类型 + + + + + 文件大小 + + + + + 文件上传完成通知 + + + + + 流水号 + + + + + 结果 + + + + + 音视频参数设置 + 0x8103_0x0075 + + + + + 数据 长度 + + + + + 实时流编码模式 + + + + + 实时流分辨率 + + + + + 实时流关键帧间隔 + (范围1-1000)帧 + + + + + 实时流目标帧率 + + + + + 实时流目标码率 + 单位未千位每秒(kbps) + + + + + 存储流编码模式 + + + + + 存储流分辨率 + + + + + 存储流关键帧间隔 + (范围1-1000)帧 + + + + + 存储流目标帧率 + + + + + 存储流目标码率 + 单位未千位每秒(kbps) + + + + + OSD字幕叠加设置 + + + + + 是否启用音频输出 + 0:不启用 + 1:启用 + + + + + 音视频通道列表设置 + 0x8103_0x0076 + + + + + 数据 长度 + + + + + 音视频通道总数 + l + + + + + 音频通道总数 + m + + + + + 视频通道总数 + n + + + + + 音视频通道对照表 + 4*(l+m+n) + + + + + 音视频通道列表设置 + 0x8103_0x0076_AVChannelRefTable + + + + + 物理通道号 + + + + + 逻辑通道号 + + + + + 通道类型 + + + + + 是否链接云台 + + + + + 单独视频通道参数设置 + 0x8103_0x0077 + + + + + 数据 长度 + + + + + 需单独设置视频参数的通道数量 用n表示 + + + + + 逻辑通道号 + + + + + 实时流编码模式 + + + + + 实时流分辨率 + + + + + 实时流关键帧间隔 + (范围1-1000)帧 + + + + + 实时流目标帧率 + + + + + 实时流目标码率 + 单位未千位每秒(kbps) + + + + + 存储流编码模式 + + + + + 存储流分辨率 + + + + + 存储流关键帧间隔 + (范围1-1000)帧 + + + + + 存储流目标帧率 + + + + + 存储流目标码率 + 单位未千位每秒(kbps) + + + + + OSD字幕叠加设置 + + + + + 特殊报警录像参数设置 + 0x8103_0x0079 + + + + + 数据 长度 + + + + + 特殊报警录像存储阈值 + + + + + 特殊报警录像持续时间 + + + + + 特殊报警标识起始时间 + 分钟min + + + + + 视频相关报警屏蔽字 + 0x8103_0x007A + + + + + 数据 长度 + + + + + 视频相关屏蔽报警字 + + + + + 图像分析报警参数设置 + 0x8103_0x007B + + + + + 数据 长度 + + + + + 车辆核载人数 + + + + + 疲劳程度阈值 + + + + + 终端休眠模式唤醒设置 + 0x8103_0x007C + + + + + 数据 长度 + + + + + 休眠唤醒模式 + + + + + 唤醒条件类型 + + + + + 定时唤醒日设置 + + + + + 日定时唤醒参数列表 + + + + + 终端休眠模式唤醒设置 + 0x8103_0x007C + + + + + 定时唤醒启用标志 + + + + + 时间段1唤醒时间 + 2 + + + + + 时间段1关闭时间 + 2 + + + + + 时间段2唤醒时间 + 2 + + + + + 时间段2关闭时间 + 2 + + + + + 时间段3唤醒时间 + 2 + + + + + 时间段3关闭时间 + 2 + + + + + 时间段4唤醒时间 + 2 + + + + + 时间段4关闭时间 + 2 + + + + + 查询终端音视频属性 + + + + + 实时音视频传输请求(live、talk、listen、fanout、passThrough直播、对讲、监听、广播、透传请求) + + + + + 视频服务器IP地址长度 + + + + + 视频服务器IP地址 + + + + + 视频服务器TCP端口号,不使用TCP协议传输时保持默认值0即可(TCP和UDP二选一,当TCP和UDP均非默认值时一般以TCP为准) + + + + + 视频服务器UDP端口号,不使用UDP协议传输时保持默认值0即可(TCP和UDP二选一,当TCP和UDP均非默认值时一般以TCP为准) + + + + + 逻辑通道号 + + + + + 数据类型 + 0:音视频 + 1:视频 + 2:双向对讲 + 3:监听 + 4:中心广播 + 5:透传 + + + + + 码流类型 + 0:主码流 + 1:子码流 + + + + + 格式分析 + + + + + + + + 反序列化 + + + + + + + + 序列化 + + + + + + + + 音视频实时传输控制(LiveControl直播控制) + + + + + 逻辑通道号 + + + + + 控制指令 + 平台可以通过该指令对设备的实时音视频进行控制: + 0:关闭音视频传输指令 + 1:切换码流(增加暂停和继续) + 2:暂停该通道所有流的发送 + 3:恢复暂停前流的发送,与暂停前的流类型一致 + 4:关闭双向对讲 + + + + + 关闭音视频类型 + 0:关闭该通道有关的音视频数据 + 1:只关闭该通道有关的音频,保留该通道有关的视频 + 2:只关闭该通道有关的视频,保留该通道有关的音频 + + + + + 切换码流类型 + 将之前申请的码流切换为新申请的码流,音频与切换前保持一致。 + 新申请的码流为: + 0:主码流 + 1:子码流 + + + + + 格式分析 + + + + + + + + 反序列化 + + + + + + + + 序列化 + + + + + + + + 实时音视频传输状态通知 + + + + + 逻辑通道号 + + + + + 丢包率 + 当前传输通道的丢包率,数值乘以100之后取整部分 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 平台下发远程录像回放请求(vod点播请求) + + + + + 服务器IP地址长度 + + + + + 服务器IP地址 + + + + + 视频服务器TCP端口号,不使用TCP协议传输时保持默认值0即可(TCP和UDP二选一,当TCP和UDP均非默认值时一般以TCP为准) + + + + + 视频服务器UDP端口号,不使用UDP协议传输时保持默认值0即可(TCP和UDP二选一,当TCP和UDP均非默认值时一般以TCP为准) + + + + + 逻辑通道号 + + + + + 音视频类型(媒体类型) + 0:audio and video + 1:audio + 2:video + 3:audio or video + + + + + 码流类型 + 0:主或子码流 + 1:主 + 2:子 + 如果此通道只传输音频,置为0 + + + + + 存储器类型 + 0:主或灾备存储器 + 1:主存储器 + 2:灾备存储器 + + + + + 回放方式 + 0:正常 + 1:快进 + 2:关键帧快退回放 + 3:关键帧播放 + 4:单帧上传 + + + + + 快进或快退倍数,当为1和2时,此字段有效,否则置0 + 0:无效 + 1:1倍 + 2:2倍 + 3:4倍 + 4:8倍 + 5:16倍 + + + + + 开始时间,当为4时,该字段表示单帧上传时间 + + + + + 结束时间,当为4时,该字段无效 + + + + + 格式分析 + + + + + + + + 反序列化 + + + + + + + + 序列化 + + + + + + + + 平台下发远程录像回放控制(VodControl点播控制) + + + + + 音视频通道号 + + + + + 回放控制 + 0:开始 + 1:暂停 + 2:结束 + 3:快进 + 4:关键帧快退播放 + 5:拖动(到指定位置) + 6:关键帧播放 + + + + + 快进或快退倍数,当为3和4时,此字段有效,否则置0 + 0:无效 + 1:1倍 + 2:2倍 + 3:4倍 + 4:8倍 + 5:16倍 + + + + + 拖动回放位置,当为5时有效(必须) + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 查询资源列表 + + + + + 逻辑通道号 + + + + + 开始时间 + + + + + 结束时间 + + + + + 报警标志 + + + + + 音视频资源类型 + 0:audio and video + 1:audio + 2:video + 3:audio or video + + + + + 码流类型 + 0:主或子码流 + 1:主 + 2:子 + + + + + 存储器类型 + 0:主或灾备存储器 + 1:主存储器 + 2:灾备存储器 + + + + + 文件上传指令 + + + + + 服务器IP地址服务 + + + + + 服务器IP地址 + + + + + 服务器端口 + + + + + 用户名长度 + + + + + 用户名 + + + + + 密码长度 + + + + + 密码 + + + + + 文件上传路径长度 + + + + + 文件上传路径 + + + + + 逻辑通道号 + + + + + 起始时间 + + + + + 结束时间 + + + + + 报警标志 + + + + + 音视频资源类型 + + + + + 码流类型 + + + + + 存储位置 + + + + + 任务执行条件 + + + + + 文件上传控制 + + + + + 流水号 + + + + + 上传控制 + + + + + 云台旋转 + + + + + 逻辑通道号 + + + + + 方向 + 0:停止 + 1:上 + 2:下 + 3:左 + 4:右 + + + + + 速度 + 0-255 + + + + + 云台调整焦距控制 + + + + + 逻辑通道号 + + + + + 焦距调整方向 + + + + + 云台调整光圈控制 + + + + + 逻辑通道号 + + + + + 光圈调整方式 + + + + + 云台雨刷控制 + + + + + 逻辑通道号 + + + + + 启停标识 + + + + + 红外补光控制 + + + + + 逻辑通道号 + + + + + 启停标识 + + + + + 云台变倍控制 + + + + + 逻辑通道号 + + + + + 变倍控制 + + + + diff --git a/src/JT808.Protocol.Extensions/JT808.Protocol.Extensions.JT1078/JT808_JT1078_Constants.cs b/src/JT808.Protocol.Extensions/JT808.Protocol.Extensions.JT1078/JT808_JT1078_Constants.cs new file mode 100644 index 0000000..40406b2 --- /dev/null +++ b/src/JT808.Protocol.Extensions/JT808.Protocol.Extensions.JT1078/JT808_JT1078_Constants.cs @@ -0,0 +1,59 @@ +using System; +using System.Collections.Generic; +using System.Text; + +namespace JT808.Protocol.Extensions.JT1078 +{ + public static class JT808_JT1078_Constants + { + /// + /// 视频相关报警 + /// + public const byte JT808_0X0200_0x14 = 0x14; + /// + /// 视频信号丢失报警状态 + /// + public const byte JT808_0X0200_0x15 = 0x15; + /// + /// 视频信号遮挡报警状态 + /// + public const byte JT808_0X0200_0x16 = 0x16; + /// + /// 存储器故障报警状态 + /// + public const byte JT808_0X0200_0x17 = 0x17; + /// + /// 异常驾驶行为报警详细描述 + /// + public const byte JT808_0X0200_0x18 = 0x18; + + /// + /// 音视频参数设置 + /// + public const uint JT808_0X8103_0x0075 = 0x0075; + /// + /// 音视频通道列表设置 + /// + public const uint JT808_0X8103_0x0076 = 0x0076; + /// + /// 单独视频通道参数设置 + /// + public const uint JT808_0X8103_0x0077 = 0x0077; + /// + /// 特殊报警录像参数设置 + /// + public const uint JT808_0X8103_0x0079 = 0x0079; + /// + /// 视频相关报警屏蔽字 + /// + public const uint JT808_0X8103_0x007A = 0x007A; + /// + /// 图像分析报警参数设置 + /// + public const uint JT808_0X8103_0x007B = 0x007B; + /// + /// 终端休眠模式唤醒设置 + /// + public const uint JT808_0X8103_0x007C = 0x007C; + } +} diff --git a/src/JT808.Protocol.Extensions/JT808.Protocol.Extensions.JT1078/MessageBody/JT808_0x0200_0x14.cs b/src/JT808.Protocol.Extensions/JT808.Protocol.Extensions.JT1078/MessageBody/JT808_0x0200_0x14.cs new file mode 100644 index 0000000..b06c751 --- /dev/null +++ b/src/JT808.Protocol.Extensions/JT808.Protocol.Extensions.JT1078/MessageBody/JT808_0x0200_0x14.cs @@ -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 +{ + /// + /// 视频相关报警 + /// 0x0200_0x14 + /// + public class JT808_0x0200_0x14 : JT808_0x0200_BodyBase, IJT808MessagePackFormatter,IJT808Analyze + { + public override byte AttachInfoId { get; set; } = 0x14; + /// + /// 数据 长度 + /// + public override byte AttachInfoLength { get; set; } = 4; + /// + /// 视频相关报警 + /// + /// + 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(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); + } + } +} diff --git a/src/JT808.Protocol.Extensions/JT808.Protocol.Extensions.JT1078/MessageBody/JT808_0x0200_0x15.cs b/src/JT808.Protocol.Extensions/JT808.Protocol.Extensions.JT1078/MessageBody/JT808_0x0200_0x15.cs new file mode 100644 index 0000000..db886b9 --- /dev/null +++ b/src/JT808.Protocol.Extensions/JT808.Protocol.Extensions.JT1078/MessageBody/JT808_0x0200_0x15.cs @@ -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 +{ + /// + /// 视频信号丢失报警状态 + /// 0x0200_0x15 + /// + public class JT808_0x0200_0x15 : JT808_0x0200_BodyBase, IJT808MessagePackFormatter, IJT808Analyze + { + public override byte AttachInfoId { get; set; } = 0x15; + /// + /// 数据 长度 + /// + public override byte AttachInfoLength { get; set; } = 4; + /// + /// 视频信号丢失报警状态 + /// + 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); + } + } +} diff --git a/src/JT808.Protocol.Extensions/JT808.Protocol.Extensions.JT1078/MessageBody/JT808_0x0200_0x16.cs b/src/JT808.Protocol.Extensions/JT808.Protocol.Extensions.JT1078/MessageBody/JT808_0x0200_0x16.cs new file mode 100644 index 0000000..5602d06 --- /dev/null +++ b/src/JT808.Protocol.Extensions/JT808.Protocol.Extensions.JT1078/MessageBody/JT808_0x0200_0x16.cs @@ -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 +{ + /// + /// 视频信号遮挡报警状态 + /// 0x0200_0x16 + /// + public class JT808_0x0200_0x16 : JT808_0x0200_BodyBase, IJT808MessagePackFormatter, IJT808Analyze + { + public override byte AttachInfoId { get; set; } = 0x16; + /// + /// 数据 长度 + /// + public override byte AttachInfoLength { get; set; } = 4; + /// + /// 视频信号遮挡报警状态 + /// + 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); + } + } +} diff --git a/src/JT808.Protocol.Extensions/JT808.Protocol.Extensions.JT1078/MessageBody/JT808_0x0200_0x17.cs b/src/JT808.Protocol.Extensions/JT808.Protocol.Extensions.JT1078/MessageBody/JT808_0x0200_0x17.cs new file mode 100644 index 0000000..373b8b9 --- /dev/null +++ b/src/JT808.Protocol.Extensions/JT808.Protocol.Extensions.JT1078/MessageBody/JT808_0x0200_0x17.cs @@ -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 +{ + /// + /// 存储器故障报警状态 + /// 0x0200_0x17 + /// + public class JT808_0x0200_0x17 : JT808_0x0200_BodyBase, IJT808MessagePackFormatter, IJT808Analyze + { + public override byte AttachInfoId { get; set; } = 0x17; + /// + /// 数据 长度 + /// + public override byte AttachInfoLength { get; set; } = 2; + /// + /// 存储器故障报警状态 + /// + 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); + } + } +} diff --git a/src/JT808.Protocol.Extensions/JT808.Protocol.Extensions.JT1078/MessageBody/JT808_0x0200_0x18.cs b/src/JT808.Protocol.Extensions/JT808.Protocol.Extensions.JT1078/MessageBody/JT808_0x0200_0x18.cs new file mode 100644 index 0000000..a71c553 --- /dev/null +++ b/src/JT808.Protocol.Extensions/JT808.Protocol.Extensions.JT1078/MessageBody/JT808_0x0200_0x18.cs @@ -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 +{ + /// + /// 异常驾驶行为报警详细描述 + /// 0x0200_0x18 + /// + public class JT808_0x0200_0x18 : JT808_0x0200_BodyBase, IJT808MessagePackFormatter, IJT808Analyze + { + public override byte AttachInfoId { get; set; } = 0x18; + /// + /// 数据 长度 + /// + public override byte AttachInfoLength { get; set; } = 3; + /// + /// 异常驾驶行为报警类型 + /// + public ushort AbnormalDrivingBehaviorAlarmType{ get; set; } + /// + /// 疲劳程度 + /// + 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); + } + } +} diff --git a/src/JT808.Protocol.Extensions/JT808.Protocol.Extensions.JT1078/MessageBody/JT808_0x1003.cs b/src/JT808.Protocol.Extensions/JT808.Protocol.Extensions.JT1078/MessageBody/JT808_0x1003.cs new file mode 100644 index 0000000..165c6cc --- /dev/null +++ b/src/JT808.Protocol.Extensions/JT808.Protocol.Extensions.JT1078/MessageBody/JT808_0x1003.cs @@ -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 +{ + /// + /// 终端上传音视频属性 + /// + public class JT808_0x1003 : JT808Bodies, IJT808MessagePackFormatter, IJT808Analyze + { + /// + /// 输入音频编码方式 + /// + public byte EnterAudioEncoding { get; set; } + /// + /// 输入音频声道数 + /// + public byte EnterAudioChannelsNumber { get; set; } + /// + /// 输入音频采样率 + /// + public byte EnterAudioSampleRate { get; set; } + /// + /// 输入音频采样位数 + /// + public byte EnterAudioSampleDigits { get; set; } + /// + /// 音频帧长度 + /// + public ushort AudioFrameLength { get; set; } + /// + /// 是否支持音频输出 + /// + public byte IsSupportedAudioOutput { get; set; } + /// + /// 视频编码方式 + /// + public byte VideoEncoding { get; set; } + /// + /// 终端支持的最大音频物理通道数量 + /// + public byte TerminalSupportedMaxNumberOfAudioPhysicalChannels{ get; set; } + /// + /// 终端支持的最大视频物理通道数量 + /// + public byte TerminalSupportedMaxNumberOfVideoPhysicalChannels { get; set; } + + 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); + } + } +} diff --git a/src/JT808.Protocol.Extensions/JT808.Protocol.Extensions.JT1078/MessageBody/JT808_0x1005.cs b/src/JT808.Protocol.Extensions/JT808.Protocol.Extensions.JT1078/MessageBody/JT808_0x1005.cs new file mode 100644 index 0000000..48bfc00 --- /dev/null +++ b/src/JT808.Protocol.Extensions/JT808.Protocol.Extensions.JT1078/MessageBody/JT808_0x1005.cs @@ -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 +{ + /// + /// 终端上传乘客流量 + /// + public class JT808_0x1005 : JT808Bodies, IJT808MessagePackFormatter, IJT808Analyze + { + public override string Description => "终端上传乘客流量"; + public override ushort MsgId => 0x1005; + /// + /// 起始时间 + /// + public DateTime BeginTime { get; set; } + /// + /// 结束时间 + /// + public DateTime EndTime { get; set; } + /// + /// 上车人数 + /// + public ushort GettingOnNumber { get; set; } + /// + /// 下车人数 + /// + 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); + } + } +} diff --git a/src/JT808.Protocol.Extensions/JT808.Protocol.Extensions.JT1078/MessageBody/JT808_0x1205.cs b/src/JT808.Protocol.Extensions/JT808.Protocol.Extensions.JT1078/MessageBody/JT808_0x1205.cs new file mode 100644 index 0000000..47a4df5 --- /dev/null +++ b/src/JT808.Protocol.Extensions/JT808.Protocol.Extensions.JT1078/MessageBody/JT808_0x1205.cs @@ -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 +{ + /// + /// 终端上传音视频资源列表 + /// + public class JT808_0x1205 : JT808Bodies, IJT808MessagePackFormatter, IJT808Analyze + { + public override string Description => "终端上传音视频资源列表"; + public override ushort MsgId => 0x1205; + /// + /// 流水号 + /// + public ushort MsgNum { get; set; } + /// + /// 音视频资源总数 + /// + public uint AVResouceTotal{ get; set; } + /// + /// 音视频资源列表 + /// + public List 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(); + 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(); + var formatter = config.GetMessagePackFormatter(); + for (int i = 0; i < channelTotal; i++) + { + jT808_0x1205.AVResouces.Add(formatter.Deserialize(ref reader, config)); + } + } + return jT808_0x1205; + } + + public void Serialize(ref JT808MessagePackWriter writer, JT808_0x1205 value, IJT808Config config) + { + writer.WriteUInt16(value.MsgNum); + writer.WriteUInt32(value.AVResouceTotal); + if (value.AVResouces.Any()) + { + var formatter = config.GetMessagePackFormatter(); + foreach (var AVResouce in value.AVResouces) + { + formatter.Serialize(ref writer, AVResouce, config); + } + } + } + } +} diff --git a/src/JT808.Protocol.Extensions/JT808.Protocol.Extensions.JT1078/MessageBody/JT808_0x1205_AVResouce.cs b/src/JT808.Protocol.Extensions/JT808.Protocol.Extensions.JT1078/MessageBody/JT808_0x1205_AVResouce.cs new file mode 100644 index 0000000..9dec3df --- /dev/null +++ b/src/JT808.Protocol.Extensions/JT808.Protocol.Extensions.JT1078/MessageBody/JT808_0x1205_AVResouce.cs @@ -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 +{ + /// + /// 终端上传音视频资源列表 + /// + public class JT808_0x1205_AVResouce:IJT808MessagePackFormatter, IJT808Analyze + { + /// + /// 逻辑通道号 + /// + public byte LogicChannelNo { get; set; } + /// + /// 开始时间 + /// + public DateTime BeginTime { get; set; } + /// + /// 结束时间 + /// + public DateTime EndTime { get; set; } + /// + /// 报警标志 + /// + public ulong AlarmFlag { get; set; } + /// + /// 音视频资源类型 + /// + public byte AVResourceType { get; set; } + /// + /// 码流类型 + /// + public byte StreamType { get; set; } + /// + /// 存储器类型 + /// + public byte MemoryType { get; set; } + /// + /// 文件大小 + /// + 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); + } + } +} diff --git a/src/JT808.Protocol.Extensions/JT808.Protocol.Extensions.JT1078/MessageBody/JT808_0x1206.cs b/src/JT808.Protocol.Extensions/JT808.Protocol.Extensions.JT1078/MessageBody/JT808_0x1206.cs new file mode 100644 index 0000000..9a761c1 --- /dev/null +++ b/src/JT808.Protocol.Extensions/JT808.Protocol.Extensions.JT1078/MessageBody/JT808_0x1206.cs @@ -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 +{ + /// + /// 文件上传完成通知 + /// + public class JT808_0x1206 : JT808Bodies, IJT808MessagePackFormatter, IJT808Analyze + { + public override string Description => "文件上传完成通知"; + public override ushort MsgId => 0x1206; + /// + /// 流水号 + /// + public ushort MsgNum { get; set; } + /// + /// 结果 + /// + 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); + } + } +} diff --git a/src/JT808.Protocol.Extensions/JT808.Protocol.Extensions.JT1078/MessageBody/JT808_0x8103_0x0075.cs b/src/JT808.Protocol.Extensions/JT808.Protocol.Extensions.JT1078/MessageBody/JT808_0x8103_0x0075.cs new file mode 100644 index 0000000..4a4633d --- /dev/null +++ b/src/JT808.Protocol.Extensions/JT808.Protocol.Extensions.JT1078/MessageBody/JT808_0x8103_0x0075.cs @@ -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 +{ + /// + /// 音视频参数设置 + /// 0x8103_0x0075 + /// + public class JT808_0x8103_0x0075 : JT808_0x8103_BodyBase, IJT808MessagePackFormatter, IJT808Analyze + { + public override uint ParamId { get; set; } = 0x0075; + /// + /// 数据 长度 + /// + public override byte ParamLength { get; set; } = 21; + /// + /// 实时流编码模式 + /// + public byte RTS_EncodeMode { get; set; } + /// + /// 实时流分辨率 + /// + public byte RTS_Resolution { get; set; } + /// + /// 实时流关键帧间隔 + /// (范围1-1000)帧 + /// + public ushort RTS_KF_Interval { get; set; } + /// + /// 实时流目标帧率 + /// + public byte RTS_Target_FPS { get; set; } + /// + /// 实时流目标码率 + /// 单位未千位每秒(kbps) + /// + public uint RTS_Target_CodeRate { get; set; } + /// + /// 存储流编码模式 + /// + public byte StreamStore_EncodeMode { get; set; } + /// + /// 存储流分辨率 + /// + public byte StreamStore_Resolution { get; set; } + /// + /// 存储流关键帧间隔 + /// (范围1-1000)帧 + /// + public ushort StreamStore_KF_Interval { get; set; } + /// + /// 存储流目标帧率 + /// + public byte StreamStore_Target_FPS { get; set; } + /// + /// 存储流目标码率 + /// 单位未千位每秒(kbps) + /// + public uint StreamStore_Target_CodeRate { get; set; } + /// + ///OSD字幕叠加设置 + /// + public ushort OSD { get; set; } + /// + ///是否启用音频输出 + ///0:不启用 + ///1:启用 + /// + public byte AudioOutputEnabled { get; set; } + + 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); + } + } +} diff --git a/src/JT808.Protocol.Extensions/JT808.Protocol.Extensions.JT1078/MessageBody/JT808_0x8103_0x0076.cs b/src/JT808.Protocol.Extensions/JT808.Protocol.Extensions.JT1078/MessageBody/JT808_0x8103_0x0076.cs new file mode 100644 index 0000000..2681c49 --- /dev/null +++ b/src/JT808.Protocol.Extensions/JT808.Protocol.Extensions.JT1078/MessageBody/JT808_0x8103_0x0076.cs @@ -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 +{ + /// + /// 音视频通道列表设置 + /// 0x8103_0x0076 + /// + public class JT808_0x8103_0x0076 : JT808_0x8103_BodyBase, IJT808MessagePackFormatter, IJT808Analyze + { + public override uint ParamId { get; set; } = 0x0076; + /// + /// 数据 长度 + /// + public override byte ParamLength { get; set; } + /// + /// 音视频通道总数 + /// l + /// + public byte AVChannelTotal { get; set; } + /// + /// 音频通道总数 + /// m + /// + public byte AudioChannelTotal { get; set; } + /// + /// 视频通道总数 + /// n + /// + public byte VudioChannelTotal { get; set; } + /// + /// 音视频通道对照表 + /// 4*(l+m+n) + /// + public List AVChannelRefTables { get; set; } + + 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(); + 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(); + var formatter = config.GetMessagePackFormatter(); + for (int i = 0; i < channelTotal; i++) + { + jT808_0X8103_0X0076.AVChannelRefTables.Add(formatter.Deserialize(ref reader, config)); + } + } + return jT808_0X8103_0X0076; + } + + public void Serialize(ref JT808MessagePackWriter writer, JT808_0x8103_0x0076 value, IJT808Config config) + { + writer.WriteUInt32(value.ParamId); + writer.Skip(1, out int position); + writer.WriteByte(value.AVChannelTotal); + writer.WriteByte(value.AudioChannelTotal); + writer.WriteByte(value.VudioChannelTotal); + if (value.AVChannelRefTables.Any()) + { + var formatter = config.GetMessagePackFormatter(); + foreach (var AVChannelRefTable in value.AVChannelRefTables) + { + formatter.Serialize(ref writer, AVChannelRefTable, config); + } + } + writer.WriteByteReturn((byte)(writer.GetCurrentPosition() - position - 1), position); + } + } +} diff --git a/src/JT808.Protocol.Extensions/JT808.Protocol.Extensions.JT1078/MessageBody/JT808_0x8103_0x0076_AVChannelRefTable.cs b/src/JT808.Protocol.Extensions/JT808.Protocol.Extensions.JT1078/MessageBody/JT808_0x8103_0x0076_AVChannelRefTable.cs new file mode 100644 index 0000000..92e9186 --- /dev/null +++ b/src/JT808.Protocol.Extensions/JT808.Protocol.Extensions.JT1078/MessageBody/JT808_0x8103_0x0076_AVChannelRefTable.cs @@ -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 +{ + /// + /// 音视频通道列表设置 + /// 0x8103_0x0076_AVChannelRefTable + /// + public class JT808_0x8103_0x0076_AVChannelRefTable: IJT808MessagePackFormatter, IJT808Analyze + { + /// + /// 物理通道号 + /// + public byte PhysicalChannelNo { get; set; } + /// + /// 逻辑通道号 + /// + public byte LogicChannelNo { get; set; } + /// + /// 通道类型 + /// + public byte ChannelType { get; set; } + /// + /// 是否链接云台 + /// + 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); + } + } +} diff --git a/src/JT808.Protocol.Extensions/JT808.Protocol.Extensions.JT1078/MessageBody/JT808_0x8103_0x0077.cs b/src/JT808.Protocol.Extensions/JT808.Protocol.Extensions.JT1078/MessageBody/JT808_0x8103_0x0077.cs new file mode 100644 index 0000000..06ba2e8 --- /dev/null +++ b/src/JT808.Protocol.Extensions/JT808.Protocol.Extensions.JT1078/MessageBody/JT808_0x8103_0x0077.cs @@ -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 +{ + /// + ///单独视频通道参数设置 + /// 0x8103_0x0077 + /// + public class JT808_0x8103_0x0077 : JT808_0x8103_BodyBase, IJT808MessagePackFormatter, IJT808Analyze + { + public override uint ParamId { get; set; } = 0x0077; + /// + /// 数据 长度 + /// + public override byte ParamLength { get; set; } + /// + /// 需单独设置视频参数的通道数量 用n表示 + /// + public byte NeedSetChannelTotal { get; set; } + + public List 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(); + 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(); + var formatter = config.GetMessagePackFormatter(); + 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(); + foreach (var signalChannel in value.SignalChannels) + { + formatter.Serialize(ref writer, signalChannel, config); + } + } + writer.WriteByteReturn((byte)(writer.GetCurrentPosition() - position - 1), position); + } + } +} diff --git a/src/JT808.Protocol.Extensions/JT808.Protocol.Extensions.JT1078/MessageBody/JT808_0x8103_0x0077_SignalChannel.cs b/src/JT808.Protocol.Extensions/JT808.Protocol.Extensions.JT1078/MessageBody/JT808_0x8103_0x0077_SignalChannel.cs new file mode 100644 index 0000000..a02c570 --- /dev/null +++ b/src/JT808.Protocol.Extensions/JT808.Protocol.Extensions.JT1078/MessageBody/JT808_0x8103_0x0077_SignalChannel.cs @@ -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, IJT808Analyze + { + /// + /// 逻辑通道号 + /// + public byte LogicChannelNo { get; set; } + /// + /// 实时流编码模式 + /// + public byte RTS_EncodeMode { get; set; } + /// + /// 实时流分辨率 + /// + public byte RTS_Resolution { get; set; } + /// + /// 实时流关键帧间隔 + /// (范围1-1000)帧 + /// + public ushort RTS_KF_Interval { get; set; } + /// + /// 实时流目标帧率 + /// + public byte RTS_Target_FPS { get; set; } + /// + /// 实时流目标码率 + /// 单位未千位每秒(kbps) + /// + public uint RTS_Target_CodeRate { get; set; } + /// + /// 存储流编码模式 + /// + public byte StreamStore_EncodeMode { get; set; } + /// + /// 存储流分辨率 + /// + public byte StreamStore_Resolution { get; set; } + /// + /// 存储流关键帧间隔 + /// (范围1-1000)帧 + /// + public ushort StreamStore_KF_Interval { get; set; } + /// + /// 存储流目标帧率 + /// + public byte StreamStore_Target_FPS { get; set; } + /// + /// 存储流目标码率 + /// 单位未千位每秒(kbps) + /// + public uint StreamStore_Target_CodeRate { get; set; } + /// + ///OSD字幕叠加设置 + /// + public ushort OSD { get; set; } + + 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); + } + } +} diff --git a/src/JT808.Protocol.Extensions/JT808.Protocol.Extensions.JT1078/MessageBody/JT808_0x8103_0x0079.cs b/src/JT808.Protocol.Extensions/JT808.Protocol.Extensions.JT1078/MessageBody/JT808_0x8103_0x0079.cs new file mode 100644 index 0000000..3df22d9 --- /dev/null +++ b/src/JT808.Protocol.Extensions/JT808.Protocol.Extensions.JT1078/MessageBody/JT808_0x8103_0x0079.cs @@ -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 +{ + /// + /// 特殊报警录像参数设置 + /// 0x8103_0x0079 + /// + public class JT808_0x8103_0x0079 : JT808_0x8103_BodyBase, IJT808MessagePackFormatter, IJT808Analyze + { + public override uint ParamId { get; set; } = 0x0079; + /// + /// 数据 长度 + /// + public override byte ParamLength { get; set; } = 3; + /// + /// 特殊报警录像存储阈值 + /// + public byte StorageThresholds { get; set; } + /// + /// 特殊报警录像持续时间 + /// + public byte Duration { get; set; } + /// + /// 特殊报警标识起始时间 + /// 分钟min + /// + public byte BeginMinute { get; set; } + + 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); + } + } +} diff --git a/src/JT808.Protocol.Extensions/JT808.Protocol.Extensions.JT1078/MessageBody/JT808_0x8103_0x007A.cs b/src/JT808.Protocol.Extensions/JT808.Protocol.Extensions.JT1078/MessageBody/JT808_0x8103_0x007A.cs new file mode 100644 index 0000000..0a8884a --- /dev/null +++ b/src/JT808.Protocol.Extensions/JT808.Protocol.Extensions.JT1078/MessageBody/JT808_0x8103_0x007A.cs @@ -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 +{ + /// + /// 视频相关报警屏蔽字 + /// 0x8103_0x007A + /// + public class JT808_0x8103_0x007A : JT808_0x8103_BodyBase, IJT808MessagePackFormatter, IJT808Analyze + { + public override uint ParamId { get; set; } = 0x007A; + /// + /// 数据 长度 + /// + public override byte ParamLength { get; set; } = 4; + /// + /// 视频相关屏蔽报警字 + /// + 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); + } + } +} diff --git a/src/JT808.Protocol.Extensions/JT808.Protocol.Extensions.JT1078/MessageBody/JT808_0x8103_0x007B.cs b/src/JT808.Protocol.Extensions/JT808.Protocol.Extensions.JT1078/MessageBody/JT808_0x8103_0x007B.cs new file mode 100644 index 0000000..56308e3 --- /dev/null +++ b/src/JT808.Protocol.Extensions/JT808.Protocol.Extensions.JT1078/MessageBody/JT808_0x8103_0x007B.cs @@ -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 +{ + /// + /// 图像分析报警参数设置 + /// 0x8103_0x007B + /// + public class JT808_0x8103_0x007B : JT808_0x8103_BodyBase, IJT808MessagePackFormatter, IJT808Analyze + { + public override uint ParamId { get; set; } = 0x007B; + /// + /// 数据 长度 + /// + public override byte ParamLength { get; set; } = 2; + /// + /// 车辆核载人数 + /// + public byte NuclearLoadNumber { get; set; } + /// + /// 疲劳程度阈值 + /// + 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); + } + } +} diff --git a/src/JT808.Protocol.Extensions/JT808.Protocol.Extensions.JT1078/MessageBody/JT808_0x8103_0x007C.cs b/src/JT808.Protocol.Extensions/JT808.Protocol.Extensions.JT1078/MessageBody/JT808_0x8103_0x007C.cs new file mode 100644 index 0000000..efd7070 --- /dev/null +++ b/src/JT808.Protocol.Extensions/JT808.Protocol.Extensions.JT1078/MessageBody/JT808_0x8103_0x007C.cs @@ -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 +{ + /// + ///终端休眠模式唤醒设置 + /// 0x8103_0x007C + /// + public class JT808_0x8103_0x007C : JT808_0x8103_BodyBase, IJT808MessagePackFormatter, IJT808Analyze + { + public override uint ParamId { get; set; } = 0x007C; + /// + /// 数据 长度 + /// + public override byte ParamLength { get; set; } = 20; + /// + /// 休眠唤醒模式 + /// + public byte SleepWakeMode { get; set; } + /// + /// 唤醒条件类型 + /// + public byte WakeConditionType { get; set; } + /// + /// 定时唤醒日设置 + /// + public byte TimerWakeDaySet { get; set; } + /// + /// 日定时唤醒参数列表 + /// + public JT808_0x8103_0x007C_TimerWakeDayParamter 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().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().Deserialize(ref reader, config); + return jT808_0x8103_0x007C; + } + + public void Serialize(ref JT808MessagePackWriter writer, JT808_0x8103_0x007C value, IJT808Config config) + { + writer.WriteUInt32(value.ParamId); + writer.Skip(1, out var position); + writer.WriteByte(value.SleepWakeMode); + writer.WriteByte(value.WakeConditionType); + writer.WriteByte(value.TimerWakeDaySet); + config.GetMessagePackFormatter().Serialize(ref writer, value.TimerWakeDayParamter, config); + writer.WriteByteReturn((byte)(writer.GetCurrentPosition() - position - 1), position); + } + } +} diff --git a/src/JT808.Protocol.Extensions/JT808.Protocol.Extensions.JT1078/MessageBody/JT808_0x8103_0x007C_TimerWakeDayParamter.cs b/src/JT808.Protocol.Extensions/JT808.Protocol.Extensions.JT1078/MessageBody/JT808_0x8103_0x007C_TimerWakeDayParamter.cs new file mode 100644 index 0000000..ab60bb7 --- /dev/null +++ b/src/JT808.Protocol.Extensions/JT808.Protocol.Extensions.JT1078/MessageBody/JT808_0x8103_0x007C_TimerWakeDayParamter.cs @@ -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 +{ + /// + ///终端休眠模式唤醒设置 + /// 0x8103_0x007C + /// + public class JT808_0x8103_0x007C_TimerWakeDayParamter:IJT808MessagePackFormatter, IJT808Analyze + { + /// + /// 定时唤醒启用标志 + /// + public byte TimerWakeEnableFlag { get; set; } + /// + /// 时间段1唤醒时间 + /// 2 + /// + public string TimePeriod1WakeTime { get; set; } + /// + /// 时间段1关闭时间 + /// 2 + /// + public string TimePeriod1CloseTime { get; set; } + /// + /// 时间段2唤醒时间 + /// 2 + /// + public string TimePeriod2WakeTime { get; set; } + /// + /// 时间段2关闭时间 + /// 2 + /// + public string TimePeriod2CloseTime { get; set; } + /// + /// 时间段3唤醒时间 + /// 2 + /// + public string TimePeriod3WakeTime { get; set; } + /// + /// 时间段3关闭时间 + /// 2 + /// + public string TimePeriod3CloseTime { get; set; } + /// + /// 时间段4唤醒时间 + /// 2 + /// + public string TimePeriod4WakeTime { get; set; } + /// + /// 时间段4关闭时间 + /// 2 + /// + public string TimePeriod4CloseTime { get; set; } + + 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); + } + } +} diff --git a/src/JT808.Protocol.Extensions/JT808.Protocol.Extensions.JT1078/MessageBody/JT808_0x9003.cs b/src/JT808.Protocol.Extensions/JT808.Protocol.Extensions.JT1078/MessageBody/JT808_0x9003.cs new file mode 100644 index 0000000..fc04943 --- /dev/null +++ b/src/JT808.Protocol.Extensions/JT808.Protocol.Extensions.JT1078/MessageBody/JT808_0x9003.cs @@ -0,0 +1,19 @@ +using System; +using System.Collections.Generic; +using System.Text; + +namespace JT808.Protocol.Extensions.JT1078.MessageBody +{ + /// + /// 查询终端音视频属性 + /// + 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 注释 + } +} diff --git a/src/JT808.Protocol.Extensions/JT808.Protocol.Extensions.JT1078/MessageBody/JT808_0x9101.cs b/src/JT808.Protocol.Extensions/JT808.Protocol.Extensions.JT1078/MessageBody/JT808_0x9101.cs new file mode 100644 index 0000000..3473455 --- /dev/null +++ b/src/JT808.Protocol.Extensions/JT808.Protocol.Extensions.JT1078/MessageBody/JT808_0x9101.cs @@ -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 +{ + /// + /// 实时音视频传输请求(live、talk、listen、fanout、passThrough直播、对讲、监听、广播、透传请求) + /// + public class JT808_0x9101: JT808Bodies, IJT808MessagePackFormatter, IJT808Analyze + { +#pragma warning disable CS1591 // 缺少对公共可见类型或成员的 XML 注释 + public override string Description => "实时音视频传输请求"; + public override ushort MsgId => 0x9101; +#pragma warning restore CS1591 // 缺少对公共可见类型或成员的 XML 注释 + + /// + /// 视频服务器IP地址长度 + /// + public byte ServerIpLength { get;internal set; } + /// + /// 视频服务器IP地址 + /// + public string ServerIp { get; set; } + /// + /// 视频服务器TCP端口号,不使用TCP协议传输时保持默认值0即可(TCP和UDP二选一,当TCP和UDP均非默认值时一般以TCP为准) + /// + public ushort TcpPort { get; set; } + /// + /// 视频服务器UDP端口号,不使用UDP协议传输时保持默认值0即可(TCP和UDP二选一,当TCP和UDP均非默认值时一般以TCP为准) + /// + public ushort UdpPort { get; set; } + /// + /// 逻辑通道号 + /// + public byte ChannelNo { get; set; } + /// + /// 数据类型 + /// 0:音视频 + /// 1:视频 + /// 2:双向对讲 + /// 3:监听 + /// 4:中心广播 + /// 5:透传 + /// + public byte DataType { get; set; } + /// + /// 码流类型 + /// 0:主码流 + /// 1:子码流 + /// + public byte StreamType { get; set; } + + /// + /// 格式分析 + /// + /// + /// + /// + 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 => "车厢后部", + _ => "预留", + }; + } + } + + /// + /// 反序列化 + /// + /// + /// + /// + 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; + } + + /// + /// 序列化 + /// + /// + /// + /// + 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); + } + } +} diff --git a/src/JT808.Protocol.Extensions/JT808.Protocol.Extensions.JT1078/MessageBody/JT808_0x9102.cs b/src/JT808.Protocol.Extensions/JT808.Protocol.Extensions.JT1078/MessageBody/JT808_0x9102.cs new file mode 100644 index 0000000..fd4a5e1 --- /dev/null +++ b/src/JT808.Protocol.Extensions/JT808.Protocol.Extensions.JT1078/MessageBody/JT808_0x9102.cs @@ -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 +{ + /// + /// 音视频实时传输控制(LiveControl直播控制) + /// + public class JT808_0x9102 : JT808Bodies, IJT808MessagePackFormatter, IJT808Analyze + { +#pragma warning disable CS1591 // 缺少对公共可见类型或成员的 XML 注释 + public override string Description => "音视频实时传输控制"; + public override ushort MsgId => 0x9102; +#pragma warning restore CS1591 // 缺少对公共可见类型或成员的 XML 注释 + /// + /// 逻辑通道号 + /// + public byte ChannelNo { get; set; } + /// + /// 控制指令 + /// 平台可以通过该指令对设备的实时音视频进行控制: + /// 0:关闭音视频传输指令 + /// 1:切换码流(增加暂停和继续) + /// 2:暂停该通道所有流的发送 + /// 3:恢复暂停前流的发送,与暂停前的流类型一致 + /// 4:关闭双向对讲 + /// + public byte ControlCmd { get; set; } + /// + /// 关闭音视频类型 + /// 0:关闭该通道有关的音视频数据 + /// 1:只关闭该通道有关的音频,保留该通道有关的视频 + /// 2:只关闭该通道有关的视频,保留该通道有关的音频 + /// + public byte CloseAVData { get; set; } + /// + /// 切换码流类型 + /// 将之前申请的码流切换为新申请的码流,音频与切换前保持一致。 + /// 新申请的码流为: + /// 0:主码流 + /// 1:子码流 + /// + public byte StreamType { get; set; } + + /// + /// 格式分析 + /// + /// + /// + /// + 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 => "车厢后部", + _ => "预留", + }; + } + } + /// + /// 反序列化 + /// + /// + /// + /// + 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; + } + /// + /// 序列化 + /// + /// + /// + /// + 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); + } + } +} diff --git a/src/JT808.Protocol.Extensions/JT808.Protocol.Extensions.JT1078/MessageBody/JT808_0x9105.cs b/src/JT808.Protocol.Extensions/JT808.Protocol.Extensions.JT1078/MessageBody/JT808_0x9105.cs new file mode 100644 index 0000000..9f10bc9 --- /dev/null +++ b/src/JT808.Protocol.Extensions/JT808.Protocol.Extensions.JT1078/MessageBody/JT808_0x9105.cs @@ -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 +{ + /// + /// 实时音视频传输状态通知 + /// + public class JT808_0x9105 : JT808Bodies, IJT808MessagePackFormatter, IJT808Analyze + { +#pragma warning disable CS1591 // 缺少对公共可见类型或成员的 XML 注释 + public override string Description => "实时音视频传输状态通知"; + public override ushort MsgId => 0x9105; +#pragma warning restore CS1591 // 缺少对公共可见类型或成员的 XML 注释 + /// + /// 逻辑通道号 + /// + public byte ChannelNo { get; set; } + /// + /// 丢包率 + /// 当前传输通道的丢包率,数值乘以100之后取整部分 + /// + public byte DropRate { get; set; } + + /// + /// + /// + /// + /// + /// + 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 => "车厢后部", + _ => "预留", + }; + } + } + + /// + /// + /// + /// + /// + /// + 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; + } + /// + /// + /// + /// + /// + /// + public void Serialize(ref JT808MessagePackWriter writer, JT808_0x9105 value, IJT808Config config) + { + writer.WriteByte(value.ChannelNo); + writer.WriteByte(value.DropRate); + } + } +} diff --git a/src/JT808.Protocol.Extensions/JT808.Protocol.Extensions.JT1078/MessageBody/JT808_0x9201.cs b/src/JT808.Protocol.Extensions/JT808.Protocol.Extensions.JT1078/MessageBody/JT808_0x9201.cs new file mode 100644 index 0000000..3aeff31 --- /dev/null +++ b/src/JT808.Protocol.Extensions/JT808.Protocol.Extensions.JT1078/MessageBody/JT808_0x9201.cs @@ -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 +{ + /// + /// 平台下发远程录像回放请求(vod点播请求) + /// + public class JT808_0x9201 : JT808Bodies, IJT808MessagePackFormatter, IJT808Analyze + { +#pragma warning disable CS1591 // 缺少对公共可见类型或成员的 XML 注释 + public override string Description => "平台下发远程录像回放请求"; + public override ushort MsgId => 0x9201; +#pragma warning restore CS1591 // 缺少对公共可见类型或成员的 XML 注释 + /// + /// 服务器IP地址长度 + /// + public byte ServerIpLength { get; set; } + /// + /// 服务器IP地址 + /// + public string ServerIp { get; set; } + /// + /// 视频服务器TCP端口号,不使用TCP协议传输时保持默认值0即可(TCP和UDP二选一,当TCP和UDP均非默认值时一般以TCP为准) + /// + public ushort TcpPort { get; set; } + /// + /// 视频服务器UDP端口号,不使用UDP协议传输时保持默认值0即可(TCP和UDP二选一,当TCP和UDP均非默认值时一般以TCP为准) + /// + public ushort UdpPort { get; set; } + /// + /// 逻辑通道号 + /// + public byte ChannelNo { get; set; } + /// + /// 音视频类型(媒体类型) + /// 0:audio and video + /// 1:audio + /// 2:video + /// 3:audio or video + /// + public byte MediaType { get; set; } + /// + /// 码流类型 + /// 0:主或子码流 + /// 1:主 + /// 2:子 + /// 如果此通道只传输音频,置为0 + /// + public byte StreamType { get; set; } + /// + /// 存储器类型 + /// 0:主或灾备存储器 + /// 1:主存储器 + /// 2:灾备存储器 + /// + public byte MemoryType { get; set; } + /// + /// 回放方式 + /// 0:正常 + /// 1:快进 + /// 2:关键帧快退回放 + /// 3:关键帧播放 + /// 4:单帧上传 + /// + public byte PlaybackWay { get; set; } + /// + /// 快进或快退倍数,当为1和2时,此字段有效,否则置0 + /// 0:无效 + /// 1:1倍 + /// 2:2倍 + /// 3:4倍 + /// 4:8倍 + /// 5:16倍 + /// + public byte PlaySpeed { get; set; } + /// + /// 开始时间,当为4时,该字段表示单帧上传时间 + /// + public DateTime BeginTime { get; set; } + /// + /// 结束时间,当为4时,该字段无效 + /// + public DateTime EndTime { get; set; } + + /// + /// 格式分析 + /// + /// + /// + /// + 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 => "车厢后部", + _ => "预留", + }; + } + } + /// + /// 反序列化 + /// + /// + /// + /// + 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; + } + + /// + /// 序列化 + /// + /// + /// + /// + 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); + } + } +} diff --git a/src/JT808.Protocol.Extensions/JT808.Protocol.Extensions.JT1078/MessageBody/JT808_0x9202.cs b/src/JT808.Protocol.Extensions/JT808.Protocol.Extensions.JT1078/MessageBody/JT808_0x9202.cs new file mode 100644 index 0000000..f7a67fe --- /dev/null +++ b/src/JT808.Protocol.Extensions/JT808.Protocol.Extensions.JT1078/MessageBody/JT808_0x9202.cs @@ -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 +{ + /// + /// 平台下发远程录像回放控制(VodControl点播控制) + /// + public class JT808_0x9202 : JT808Bodies, IJT808MessagePackFormatter, IJT808Analyze + { +#pragma warning disable CS1591 // 缺少对公共可见类型或成员的 XML 注释 + public override string Description => "平台下发远程录像回放控制"; + public override ushort MsgId => 0x9202; +#pragma warning restore CS1591 // 缺少对公共可见类型或成员的 XML 注释 + /// + /// 音视频通道号 + /// + public byte ChannelNo { get; set; } + /// + /// 回放控制 + /// 0:开始 + /// 1:暂停 + /// 2:结束 + /// 3:快进 + /// 4:关键帧快退播放 + /// 5:拖动(到指定位置) + /// 6:关键帧播放 + /// + public byte PlayControl { get; set; } + /// + /// 快进或快退倍数,当为3和4时,此字段有效,否则置0 + /// 0:无效 + /// 1:1倍 + /// 2:2倍 + /// 3:4倍 + /// 4:8倍 + /// 5:16倍 + /// + public byte PlaySpeed { get; set; } + /// + /// 拖动回放位置,当为5时有效(必须) + /// + public DateTime DragPlayPosition { get; set; } + /// + /// + /// + /// + /// + /// + 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倍", + _ => "未知", + }; + } + } + /// + /// + /// + /// + /// + /// + 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; + } + /// + /// + /// + /// + /// + /// + 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); + } + } +} diff --git a/src/JT808.Protocol.Extensions/JT808.Protocol.Extensions.JT1078/MessageBody/JT808_0x9205.cs b/src/JT808.Protocol.Extensions/JT808.Protocol.Extensions.JT1078/MessageBody/JT808_0x9205.cs new file mode 100644 index 0000000..a882789 --- /dev/null +++ b/src/JT808.Protocol.Extensions/JT808.Protocol.Extensions.JT1078/MessageBody/JT808_0x9205.cs @@ -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 +{ + /// + /// 查询资源列表 + /// + public class JT808_0x9205 : JT808Bodies, IJT808MessagePackFormatter, IJT808Analyze + { +#pragma warning disable CS1591 // 缺少对公共可见类型或成员的 XML 注释 + public override string Description => "查询资源列表"; + public override ushort MsgId => 0x9205; +#pragma warning restore CS1591 // 缺少对公共可见类型或成员的 XML 注释 + /// + /// 逻辑通道号 + /// + public byte ChannelNo { get; set; } + /// + /// 开始时间 + /// + public DateTime BeginTime { get; set; } + /// + /// 结束时间 + /// + public DateTime EndTime { get; set; } + /// + /// 报警标志 + /// + public ulong AlarmFlag { get; set; } + /// + /// 音视频资源类型 + /// 0:audio and video + /// 1:audio + /// 2:video + /// 3:audio or video + /// + public byte MediaType { get; set; } + /// + /// 码流类型 + /// 0:主或子码流 + /// 1:主 + /// 2:子 + /// + public byte StreamType { get; set; } + /// + /// 存储器类型 + /// 0:主或灾备存储器 + /// 1:主存储器 + /// 2:灾备存储器 + /// + 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 注释 + } +} diff --git a/src/JT808.Protocol.Extensions/JT808.Protocol.Extensions.JT1078/MessageBody/JT808_0x9206.cs b/src/JT808.Protocol.Extensions/JT808.Protocol.Extensions.JT1078/MessageBody/JT808_0x9206.cs new file mode 100644 index 0000000..87c5a41 --- /dev/null +++ b/src/JT808.Protocol.Extensions/JT808.Protocol.Extensions.JT1078/MessageBody/JT808_0x9206.cs @@ -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 +{ + /// + /// 文件上传指令 + /// + public class JT808_0x9206 : JT808Bodies, IJT808MessagePackFormatter, IJT808Analyze + { +#pragma warning disable CS1591 // 缺少对公共可见类型或成员的 XML 注释 + public override string Description => "文件上传指令"; + public override ushort MsgId => 0x9206; +#pragma warning restore CS1591 // 缺少对公共可见类型或成员的 XML 注释 + /// + /// 服务器IP地址服务 + /// + public byte ServerIpLength { get; set; } + /// + /// 服务器IP地址 + /// + public string ServerIp { get; set; } + /// + /// 服务器端口 + /// + public ushort Port { get; set; } + /// + /// 用户名长度 + /// + public byte UserNameLength { get; set; } + /// + /// 用户名 + /// + public string UserName { get; set; } + /// + /// 密码长度 + /// + public byte PasswordLength { get; set; } + /// + /// 密码 + /// + public string Password { get; set; } + /// + /// 文件上传路径长度 + /// + public byte FileUploadPathLength { get; set; } + /// + /// 文件上传路径 + /// + public string FileUploadPath { get; set; } + /// + /// 逻辑通道号 + /// + public byte ChannelNo { get; set; } + /// + /// 起始时间 + /// + public DateTime BeginTime { get; set; } + /// + /// 结束时间 + /// + public DateTime EndTime { get; set; } + /// + /// 报警标志 + /// + public uint AlarmFlag { get; set; } + /// + /// 音视频资源类型 + /// + public byte MediaType { get; set; } + /// + /// 码流类型 + /// + public byte StreamType { get; set; } + /// + /// 存储位置 + /// + public byte MemoryPositon { get; set; } + /// + /// 任务执行条件 + /// + 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 注释 + } +} diff --git a/src/JT808.Protocol.Extensions/JT808.Protocol.Extensions.JT1078/MessageBody/JT808_0x9207.cs b/src/JT808.Protocol.Extensions/JT808.Protocol.Extensions.JT1078/MessageBody/JT808_0x9207.cs new file mode 100644 index 0000000..0867ffd --- /dev/null +++ b/src/JT808.Protocol.Extensions/JT808.Protocol.Extensions.JT1078/MessageBody/JT808_0x9207.cs @@ -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 +{ + /// + /// 文件上传控制 + /// + public class JT808_0x9207 : JT808Bodies, IJT808MessagePackFormatter, IJT808Analyze + { +#pragma warning disable CS1591 // 缺少对公共可见类型或成员的 XML 注释 + public override string Description => "文件上传控制"; + public override ushort MsgId => 0x9207; +#pragma warning restore CS1591 // 缺少对公共可见类型或成员的 XML 注释 + /// + /// 流水号 + /// + public ushort MgsNum { get; set; } + /// + /// 上传控制 + /// + 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 注释 + } +} diff --git a/src/JT808.Protocol.Extensions/JT808.Protocol.Extensions.JT1078/MessageBody/JT808_0x9301.cs b/src/JT808.Protocol.Extensions/JT808.Protocol.Extensions.JT1078/MessageBody/JT808_0x9301.cs new file mode 100644 index 0000000..bbc7737 --- /dev/null +++ b/src/JT808.Protocol.Extensions/JT808.Protocol.Extensions.JT1078/MessageBody/JT808_0x9301.cs @@ -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 +{ + /// + /// 云台旋转 + /// + public class JT808_0x9301 : JT808Bodies, IJT808MessagePackFormatter, IJT808Analyze + { +#pragma warning disable CS1591 // 缺少对公共可见类型或成员的 XML 注释 + public override string Description => "云台旋转"; + public override ushort MsgId => 0x9301; +#pragma warning restore CS1591 // 缺少对公共可见类型或成员的 XML 注释 + /// + /// 逻辑通道号 + /// + public byte ChannelNo { get; set; } + /// + /// 方向 + /// 0:停止 + /// 1:上 + /// 2:下 + /// 3:左 + /// 4:右 + /// + public byte Direction { get; set; } + /// + /// 速度 + /// 0-255 + /// + 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 注释 + } +} diff --git a/src/JT808.Protocol.Extensions/JT808.Protocol.Extensions.JT1078/MessageBody/JT808_0x9302.cs b/src/JT808.Protocol.Extensions/JT808.Protocol.Extensions.JT1078/MessageBody/JT808_0x9302.cs new file mode 100644 index 0000000..27802fb --- /dev/null +++ b/src/JT808.Protocol.Extensions/JT808.Protocol.Extensions.JT1078/MessageBody/JT808_0x9302.cs @@ -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 +{ + /// + /// 云台调整焦距控制 + /// + public class JT808_0x9302 : JT808Bodies, IJT808MessagePackFormatter, IJT808Analyze + { +#pragma warning disable CS1591 // 缺少对公共可见类型或成员的 XML 注释 + public override string Description => "云台调整焦距控制"; + public override ushort MsgId => 0x9302; +#pragma warning restore CS1591 // 缺少对公共可见类型或成员的 XML 注释 + + /// + /// 逻辑通道号 + /// + public byte LogicChannelNo { get; set; } + /// + /// 焦距调整方向 + /// + 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 注释 + } +} diff --git a/src/JT808.Protocol.Extensions/JT808.Protocol.Extensions.JT1078/MessageBody/JT808_0x9303.cs b/src/JT808.Protocol.Extensions/JT808.Protocol.Extensions.JT1078/MessageBody/JT808_0x9303.cs new file mode 100644 index 0000000..7776400 --- /dev/null +++ b/src/JT808.Protocol.Extensions/JT808.Protocol.Extensions.JT1078/MessageBody/JT808_0x9303.cs @@ -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 +{ + /// + /// 云台调整光圈控制 + /// + public class JT808_0x9303 : JT808Bodies, IJT808MessagePackFormatter, IJT808Analyze + { +#pragma warning disable CS1591 // 缺少对公共可见类型或成员的 XML 注释 + public override string Description => "云台调整光圈控制"; + public override ushort MsgId => 0x9303; +#pragma warning restore CS1591 // 缺少对公共可见类型或成员的 XML 注释 + /// + /// 逻辑通道号 + /// + public byte ChannelNo { get; set; } + /// + /// 光圈调整方式 + /// + 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 注释 + } +} diff --git a/src/JT808.Protocol.Extensions/JT808.Protocol.Extensions.JT1078/MessageBody/JT808_0x9304.cs b/src/JT808.Protocol.Extensions/JT808.Protocol.Extensions.JT1078/MessageBody/JT808_0x9304.cs new file mode 100644 index 0000000..8b01d6e --- /dev/null +++ b/src/JT808.Protocol.Extensions/JT808.Protocol.Extensions.JT1078/MessageBody/JT808_0x9304.cs @@ -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 +{ + /// + /// 云台雨刷控制 + /// + public class JT808_0x9304 : JT808Bodies, IJT808MessagePackFormatter, IJT808Analyze + { +#pragma warning disable CS1591 // 缺少对公共可见类型或成员的 XML 注释 + public override string Description => "云台雨刷控制"; + public override ushort MsgId => 0x9304; + /// + /// 逻辑通道号 + /// + public byte ChannelNo { get; set; } + /// + /// 启停标识 + /// + 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 注释 + } +} diff --git a/src/JT808.Protocol.Extensions/JT808.Protocol.Extensions.JT1078/MessageBody/JT808_0x9305.cs b/src/JT808.Protocol.Extensions/JT808.Protocol.Extensions.JT1078/MessageBody/JT808_0x9305.cs new file mode 100644 index 0000000..aa2aa33 --- /dev/null +++ b/src/JT808.Protocol.Extensions/JT808.Protocol.Extensions.JT1078/MessageBody/JT808_0x9305.cs @@ -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 +{ + /// + /// 红外补光控制 + /// + public class JT808_0x9305 : JT808Bodies, IJT808MessagePackFormatter, IJT808Analyze + { +#pragma warning disable CS1591 // 缺少对公共可见类型或成员的 XML 注释 + public override string Description => "红外补光控制"; + public override ushort MsgId => 0x9305; + /// + /// 逻辑通道号 + /// + public byte ChannelNo { get; set; } + /// + /// 启停标识 + /// + 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 注释 + } +} diff --git a/src/JT808.Protocol.Extensions/JT808.Protocol.Extensions.JT1078/MessageBody/JT808_0x9306.cs b/src/JT808.Protocol.Extensions/JT808.Protocol.Extensions.JT1078/MessageBody/JT808_0x9306.cs new file mode 100644 index 0000000..c0f7f79 --- /dev/null +++ b/src/JT808.Protocol.Extensions/JT808.Protocol.Extensions.JT1078/MessageBody/JT808_0x9306.cs @@ -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 +{ + /// + /// 云台变倍控制 + /// + public class JT808_0x9306 : JT808Bodies, IJT808MessagePackFormatter, IJT808Analyze + { +#pragma warning disable CS1591 // 缺少对公共可见类型或成员的 XML 注释 + public override string Description => "云台变倍控制"; + + public override ushort MsgId => 0x9306; + /// + /// 逻辑通道号 + /// + public byte ChannelNo { get; set; } + /// + /// 变倍控制 + /// + 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 注释 + } +} diff --git a/src/JT808.Protocol.Extensions/JT808.Protocol.Extensions.JTActiveSafety.Test/JT808.Protocol.Extensions.JTActiveSafety.Test.csproj b/src/JT808.Protocol.Extensions/JT808.Protocol.Extensions.JTActiveSafety.Test/JT808.Protocol.Extensions.JTActiveSafety.Test.csproj new file mode 100644 index 0000000..c7ce9d9 --- /dev/null +++ b/src/JT808.Protocol.Extensions/JT808.Protocol.Extensions.JTActiveSafety.Test/JT808.Protocol.Extensions.JTActiveSafety.Test.csproj @@ -0,0 +1,30 @@ + + + + net5.0 + + false + + + + + + True + + + + + + + + + all + runtime; build; native; contentfiles; analyzers; buildtransitive + + + + + + + + diff --git a/src/JT808.Protocol.Extensions/JT808.Protocol.Extensions.JTActiveSafety.Test/JT808_0x0200_0x64_Test.cs b/src/JT808.Protocol.Extensions/JT808.Protocol.Extensions.JTActiveSafety.Test/JT808_0x0200_0x64_Test.cs new file mode 100644 index 0000000..91f92d8 --- /dev/null +++ b/src/JT808.Protocol.Extensions/JT808.Protocol.Extensions.JTActiveSafety.Test/JT808_0x0200_0x64_Test.cs @@ -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(); + 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() + }; + 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("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("000000010000000200BA7F0E07E4F11C0028003C00001807151010106420000000010C0605120A0B100F1100070000000D0000000E191211183100001334343434343434191210183100030200".ToHexBytes()); + } + } +} diff --git a/src/JT808.Protocol.Extensions/JT808.Protocol.Extensions.JTActiveSafety.Test/JT808_0x0200_0x65_Test.cs b/src/JT808.Protocol.Extensions/JT808.Protocol.Extensions.JTActiveSafety.Test/JT808_0x0200_0x65_Test.cs new file mode 100644 index 0000000..ccef77b --- /dev/null +++ b/src/JT808.Protocol.Extensions/JT808.Protocol.Extensions.JTActiveSafety.Test/JT808_0x0200_0x65_Test.cs @@ -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(); + 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() + }; + 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("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("000000010000000200BA7F0E07E4F11C0028003C00001807151010106520000000010C060512010203041100070000000D0000000E191211183100001334343434343434191210183100030200".ToHexBytes()); + } + } +} diff --git a/src/JT808.Protocol.Extensions/JT808.Protocol.Extensions.JTActiveSafety.Test/JT808_0x0200_0x66_Test.cs b/src/JT808.Protocol.Extensions/JT808.Protocol.Extensions.JTActiveSafety.Test/JT808_0x0200_0x66_Test.cs new file mode 100644 index 0000000..76cb5ca --- /dev/null +++ b/src/JT808.Protocol.Extensions/JT808.Protocol.Extensions.JTActiveSafety.Test/JT808_0x0200_0x66_Test.cs @@ -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(); + 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() + }; + 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 { + 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("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("000000010000000200BA7F0E07E4F11C0028003C0000180715101010663B000000010C1100070000000D0000000E191211183100001334343434343434191210183100030200020400010003000500020900060008000A0007".ToHexBytes()); + } + } +} diff --git a/src/JT808.Protocol.Extensions/JT808.Protocol.Extensions.JTActiveSafety.Test/JT808_0x0200_0x67_Test.cs b/src/JT808.Protocol.Extensions/JT808.Protocol.Extensions.JTActiveSafety.Test/JT808_0x0200_0x67_Test.cs new file mode 100644 index 0000000..ac19c82 --- /dev/null +++ b/src/JT808.Protocol.Extensions/JT808.Protocol.Extensions.JTActiveSafety.Test/JT808_0x0200_0x67_Test.cs @@ -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(); + 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() + }; + 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("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("000000010000000200BA7F0E07E4F11C0028003C0000180715101010671A000000010C09081100070000000D0000000E191211183100001334343434343434191210183100030200".ToHexBytes()); + } + } +} diff --git a/src/JT808.Protocol.Extensions/JT808.Protocol.Extensions.JTActiveSafety.Test/JT808_0x0900_Test.cs b/src/JT808.Protocol.Extensions/JT808.Protocol.Extensions.JTActiveSafety.Test/JT808_0x0900_Test.cs new file mode 100644 index 0000000..1cffc5e --- /dev/null +++ b/src/JT808.Protocol.Extensions/JT808.Protocol.Extensions.JTActiveSafety.Test/JT808_0x0900_Test.cs @@ -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(); + 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 { + 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("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("020105020000000102050200000001".ToHexBytes()); + } + + [Fact] + public void Test_0xF8_1() + { + JT808_0x0900_0xF8 jT808_0x0900_0xF8 = new JT808_0x0900_0xF8 + { + USBMessageCount = 1, + USBMessages = new List { + 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("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("01015C0B436F6D70616E744E616D650C50726F647563744D6F64656C15486172647761726556657273696F6E4E756D62657215536F66747761726556657273696F6E4E756D626572094465766963657349440C437573746F6D6572436F6465".ToHexBytes()); + } + } +} diff --git a/src/JT808.Protocol.Extensions/JT808.Protocol.Extensions.JTActiveSafety.Test/JT808_0x1210_Test.cs b/src/JT808.Protocol.Extensions/JT808.Protocol.Extensions.JTActiveSafety.Test/JT808_0x1210_Test.cs new file mode 100644 index 0000000..f250bf5 --- /dev/null +++ b/src/JT808.Protocol.Extensions/JT808.Protocol.Extensions.JTActiveSafety.Test/JT808_0x1210_Test.cs @@ -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(); + 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 { + 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("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("3434343434343434343434343434191210183100030201313131313131313131313131313131313131313131313131313131313131313100020866696C656E616D65000000090966696C656E616D65310000000A".ToHexBytes()); + } + } +} diff --git a/src/JT808.Protocol.Extensions/JT808.Protocol.Extensions.JTActiveSafety.Test/JT808_0x1211_Test.cs b/src/JT808.Protocol.Extensions/JT808.Protocol.Extensions.JTActiveSafety.Test/JT808_0x1211_Test.cs new file mode 100644 index 0000000..96f24a0 --- /dev/null +++ b/src/JT808.Protocol.Extensions/JT808.Protocol.Extensions.JTActiveSafety.Test/JT808_0x1211_Test.cs @@ -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(); + 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("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("0846696C654E616D650200000001".ToHexBytes()); + } + } +} diff --git a/src/JT808.Protocol.Extensions/JT808.Protocol.Extensions.JTActiveSafety.Test/JT808_0x1212_Test.cs b/src/JT808.Protocol.Extensions/JT808.Protocol.Extensions.JTActiveSafety.Test/JT808_0x1212_Test.cs new file mode 100644 index 0000000..f91515f --- /dev/null +++ b/src/JT808.Protocol.Extensions/JT808.Protocol.Extensions.JTActiveSafety.Test/JT808_0x1212_Test.cs @@ -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(); + 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("0846696C654E616D650200000001".ToHexBytes()); + Assert.Equal("FileName", jT808UploadLocationRequest.FileName); + Assert.Equal(1u, jT808UploadLocationRequest.FileSize); + Assert.Equal(2, jT808UploadLocationRequest.FileType); + Assert.Equal("FileName".Length, jT808UploadLocationRequest.FileNameLength); + } + } +} diff --git a/src/JT808.Protocol.Extensions/JT808.Protocol.Extensions.JTActiveSafety.Test/JT808_0x8103_0xF364_Test.cs b/src/JT808.Protocol.Extensions/JT808.Protocol.Extensions.JTActiveSafety.Test/JT808_0x8103_0xF364_Test.cs new file mode 100644 index 0000000..d00b610 --- /dev/null +++ b/src/JT808.Protocol.Extensions/JT808.Protocol.Extensions.JTActiveSafety.Test/JT808_0x8103_0xF364_Test.cs @@ -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(); + JT808Serializer = new JT808Serializer(jT808Config); + } + [Fact] + public void Serializer() + { + JT808_0x8103 jT808UploadLocationRequest = new JT808_0x8103 + { + ParamList=new List { + 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("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("010000F36438052D030002000122231D26000000040000000A1E09152B08180F0E14291011122A16170D13280C0B1C192C1B1A2425270607202101020304".ToHexBytes()); + } + } +} diff --git a/src/JT808.Protocol.Extensions/JT808.Protocol.Extensions.JTActiveSafety.Test/JT808_0x8103_0xF365_Test.cs b/src/JT808.Protocol.Extensions/JT808.Protocol.Extensions.JTActiveSafety.Test/JT808_0x8103_0xF365_Test.cs new file mode 100644 index 0000000..9e1e511 --- /dev/null +++ b/src/JT808.Protocol.Extensions/JT808.Protocol.Extensions.JTActiveSafety.Test/JT808_0x8103_0xF365_Test.cs @@ -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(); + JT808Serializer = new JT808Serializer(jT808Config); + } + [Fact] + public void Serializer() + { + JT808_0x8103 jT808UploadLocationRequest = new JT808_0x8103 + { + ParamList=new List { + 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("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("010000F3652F052D030002000122231D26000000040000000A003E002E0102033941373831402F3033423C3D3234353F3A3B360506".ToHexBytes()); + } + } +} diff --git a/src/JT808.Protocol.Extensions/JT808.Protocol.Extensions.JTActiveSafety.Test/JT808_0x8103_0xF366_Test.cs b/src/JT808.Protocol.Extensions/JT808.Protocol.Extensions.JTActiveSafety.Test/JT808_0x8103_0xF366_Test.cs new file mode 100644 index 0000000..68047b3 --- /dev/null +++ b/src/JT808.Protocol.Extensions/JT808.Protocol.Extensions.JTActiveSafety.Test/JT808_0x8103_0xF366_Test.cs @@ -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(); + JT808Serializer = new JT808Serializer(jT808Config); + } + [Fact] + public void Serializer() + { + JT808_0x8103 jT808UploadLocationRequest = new JT808_0x8103 + { + ParamList=new List { + 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("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("010000F366243939393939393939393939390008000400060005000300020001000A0007010203040506".ToHexBytes()); + } + } +} diff --git a/src/JT808.Protocol.Extensions/JT808.Protocol.Extensions.JTActiveSafety.Test/JT808_0x8103_0xF367_Test.cs b/src/JT808.Protocol.Extensions/JT808.Protocol.Extensions.JTActiveSafety.Test/JT808_0x8103_0xF367_Test.cs new file mode 100644 index 0000000..4f0867e --- /dev/null +++ b/src/JT808.Protocol.Extensions/JT808.Protocol.Extensions.JTActiveSafety.Test/JT808_0x8103_0xF367_Test.cs @@ -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(); + JT808Serializer = new JT808Serializer(jT808Config); + } + [Fact] + public void Serializer() + { + JT808_0x8103 jT808UploadLocationRequest = new JT808_0x8103 + { + ParamList=new List { + 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("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("010000F367020201".ToHexBytes()); + } + } +} diff --git a/src/JT808.Protocol.Extensions/JT808.Protocol.Extensions.JTActiveSafety.Test/JT808_0x8900_Test.cs b/src/JT808.Protocol.Extensions/JT808.Protocol.Extensions.JTActiveSafety.Test/JT808_0x8900_Test.cs new file mode 100644 index 0000000..4061b7d --- /dev/null +++ b/src/JT808.Protocol.Extensions/JT808.Protocol.Extensions.JTActiveSafety.Test/JT808_0x8900_Test.cs @@ -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(); + JT808Serializer = new JT808Serializer(jT808Config); + } + [Fact] + public void Serializer() + { + JT808_0x8900_0xF7 jT808UploadLocationRequest = new JT808_0x8900_0xF7 + { + USBCount=2, + MultipleUSB=new List {1,2 } + }; + var hex = JT808Serializer.Serialize(jT808UploadLocationRequest).ToHexString(); + Assert.Equal("020102", hex); + } + [Fact] + public void Deserialize() + { + var jT808UploadLocationRequest = JT808Serializer.Deserialize("020102".ToHexBytes()); + Assert.Equal(2, jT808UploadLocationRequest.USBCount); + Assert.Equal(new List { 1, 2 }.ToArray().ToHexString(), jT808UploadLocationRequest.MultipleUSB.ToArray().ToHexString()); + } + [Fact] + public void Json() + { + var json = JT808Serializer.Analyze("020102".ToHexBytes()); + } + } +} diff --git a/src/JT808.Protocol.Extensions/JT808.Protocol.Extensions.JTActiveSafety.Test/JT808_0x9208_Test.cs b/src/JT808.Protocol.Extensions/JT808.Protocol.Extensions.JTActiveSafety.Test/JT808_0x9208_Test.cs new file mode 100644 index 0000000..f5bbd0a --- /dev/null +++ b/src/JT808.Protocol.Extensions/JT808.Protocol.Extensions.JTActiveSafety.Test/JT808_0x9208_Test.cs @@ -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(); + 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("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("0B3139322E3136382E312E311388138934343434343434191210183100030201313131313131313131313131313131313131313131313131313131313131313100000000000000000000000000000000".ToHexBytes()); + } + } +} diff --git a/src/JT808.Protocol.Extensions/JT808.Protocol.Extensions.JTActiveSafety.Test/JT808_0x9212_Test.cs b/src/JT808.Protocol.Extensions/JT808.Protocol.Extensions.JTActiveSafety.Test/JT808_0x9212_Test.cs new file mode 100644 index 0000000..dc9a03a --- /dev/null +++ b/src/JT808.Protocol.Extensions/JT808.Protocol.Extensions.JTActiveSafety.Test/JT808_0x9212_Test.cs @@ -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(); + JT808Serializer = new JT808Serializer(jT808Config); + } + [Fact] + public void Serializer() + { + JT808_0x9212 jT808UploadLocationRequest = new JT808_0x9212 + { + DataPackageCount=2, + DataPackages=new List { + 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("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("0846696C654E616D65010202000000140000000A000000280000001E".ToHexBytes()); + } + } +} diff --git a/src/JT808.Protocol.Extensions/JT808.Protocol.Extensions.JTActiveSafety/Enums/ActivePhotographyStrategyType.cs b/src/JT808.Protocol.Extensions/JT808.Protocol.Extensions.JTActiveSafety/Enums/ActivePhotographyStrategyType.cs new file mode 100644 index 0000000..e1c0367 --- /dev/null +++ b/src/JT808.Protocol.Extensions/JT808.Protocol.Extensions.JTActiveSafety/Enums/ActivePhotographyStrategyType.cs @@ -0,0 +1,33 @@ +using System; +using System.Collections.Generic; +using System.Text; + +namespace JT808.Protocol.Extensions.JTActiveSafety.Enums +{ + /// + /// 主动拍照策略 + /// + public enum ActivePhotographyStrategyType:byte + { + /// + /// 不开启 + /// + 不开启 = 0x00, + /// + /// 定时拍照 + /// + 定时拍照 = 0x01, + /// + /// 定距拍照 + /// + 定距拍照 = 0x02, + /// + /// 保留 + /// + 保留 = 0x03, + /// + /// 不修改参数 + /// + 不修改参数 = 0xFF + } +} diff --git a/src/JT808.Protocol.Extensions/JT808.Protocol.Extensions.JTActiveSafety/Enums/JT808_JTActiveSafety_MsgId.cs b/src/JT808.Protocol.Extensions/JT808.Protocol.Extensions.JTActiveSafety/Enums/JT808_JTActiveSafety_MsgId.cs new file mode 100644 index 0000000..e1167c8 --- /dev/null +++ b/src/JT808.Protocol.Extensions/JT808.Protocol.Extensions.JTActiveSafety/Enums/JT808_JTActiveSafety_MsgId.cs @@ -0,0 +1,33 @@ +using System; +using System.Collections.Generic; +using System.Text; + +namespace JT808.Protocol.Extensions.JTActiveSafety.Enums +{ + /// + /// 主动安全消息Id + /// + public enum JT808_JTActiveSafety_MsgId : ushort + { + /// + /// 报警附件信息消息 + /// + 报警附件信息消息 = 0x1210, + /// + /// 文件信息上传 + /// + 文件信息上传 = 0x1211, + /// + /// 文件上传完成消息 + /// + 文件上传完成消息 = 0x1212, + /// + /// 报警附件上传指令 + /// + 报警附件上传指令 = 0x9208, + /// + /// 文件上传完成消息应答 + /// + 文件上传完成消息应答 = 0x9212, + } +} diff --git a/src/JT808.Protocol.Extensions/JT808.Protocol.Extensions.JTActiveSafety/Enums/PhotoResolutionType.cs b/src/JT808.Protocol.Extensions/JT808.Protocol.Extensions.JTActiveSafety/Enums/PhotoResolutionType.cs new file mode 100644 index 0000000..e9b4d17 --- /dev/null +++ b/src/JT808.Protocol.Extensions/JT808.Protocol.Extensions.JTActiveSafety/Enums/PhotoResolutionType.cs @@ -0,0 +1,41 @@ +using System; +using System.Collections.Generic; +using System.Text; + +namespace JT808.Protocol.Extensions.JTActiveSafety.Enums +{ + /// + /// 拍照分辨率 + /// + public enum PhotoResolutionType:byte + { + /// + /// 352x288 + /// + x352_288 = 0x01, + /// + /// 704x288 + /// + x704_288 = 0x02, + /// + /// 704x576 + /// + x704_576 = 0x03, + /// + /// 640x480 + /// + x640_480 = 0x04, + /// + /// 1280x720 + /// + x1280_720 = 0x05, + /// + /// 1920x1080 + /// + x1920_1080 = 0x06, + /// + /// 不修改参数 + /// + 不修改参数 = 0xFF + } +} diff --git a/src/JT808.Protocol.Extensions/JT808.Protocol.Extensions.JTActiveSafety/Enums/USBIDType.cs b/src/JT808.Protocol.Extensions/JT808.Protocol.Extensions.JTActiveSafety/Enums/USBIDType.cs new file mode 100644 index 0000000..79b6b9f --- /dev/null +++ b/src/JT808.Protocol.Extensions/JT808.Protocol.Extensions.JTActiveSafety/Enums/USBIDType.cs @@ -0,0 +1,29 @@ +using System; +using System.Collections.Generic; +using System.Text; + +namespace JT808.Protocol.Extensions.JTActiveSafety.Enums +{ + /// + /// USB编号类型 + /// + public enum USBIDType:byte + { + /// + /// 高级驾驶辅助系统 + /// + ADAS = 0x64, + /// + /// 驾驶员状态监控系统 + /// + DSM = 0x65, + /// + /// 轮胎气压监测系统 + /// + TPMS = 0x66, + /// + /// 盲点监测系统 + /// + BSD = 0x67 + } +} diff --git a/src/JT808.Protocol.Extensions/JT808.Protocol.Extensions.JTActiveSafety/Enums/VideoRecordingResolutionType.cs b/src/JT808.Protocol.Extensions/JT808.Protocol.Extensions.JTActiveSafety/Enums/VideoRecordingResolutionType.cs new file mode 100644 index 0000000..3d4026f --- /dev/null +++ b/src/JT808.Protocol.Extensions/JT808.Protocol.Extensions.JTActiveSafety/Enums/VideoRecordingResolutionType.cs @@ -0,0 +1,45 @@ +using System; +using System.Collections.Generic; +using System.Text; + +namespace JT808.Protocol.Extensions.JTActiveSafety.Enums +{ + /// + /// 视频录制分辨率 + /// + public enum VideoRecordingResolutionType:byte + { + /// + /// CIF + /// + CIF = 0x01, + /// + /// HD1 + /// + HD1 = 0x02, + /// + /// D1 + /// + D1 = 0x03, + /// + /// WD1 + /// + WD1 = 0x04, + /// + /// VGA + /// + VGA = 0x05, + /// + /// 720P + /// + _720P = 0x06, + /// + /// 1080P + /// + _1080P = 0x07, + /// + /// 不修改参数 + /// + 不修改参数 = 0xFF + } +} diff --git a/src/JT808.Protocol.Extensions/JT808.Protocol.Extensions.JTActiveSafety/Enums/WorkingConditionType.cs b/src/JT808.Protocol.Extensions/JT808.Protocol.Extensions.JTActiveSafety/Enums/WorkingConditionType.cs new file mode 100644 index 0000000..724ae2d --- /dev/null +++ b/src/JT808.Protocol.Extensions/JT808.Protocol.Extensions.JTActiveSafety/Enums/WorkingConditionType.cs @@ -0,0 +1,33 @@ +using System; +using System.Collections.Generic; +using System.Text; + +namespace JT808.Protocol.Extensions.JTActiveSafety.Enums +{ + /// + /// 工作状态 + /// + public enum WorkingConditionType:byte + { + /// + /// 正常工作 + /// + 正常工作 = 0x01, + /// + /// 待机状态 + /// + 待机状态 = 0x02, + /// + /// 升级维护 + /// + 升级维护 = 0x03, + /// + /// 设备异常 + /// + 设备异常 = 0x04, + /// + /// 断开连接 + /// + 断开连接 = 0x10, + } +} diff --git a/src/JT808.Protocol.Extensions/JT808.Protocol.Extensions.JTActiveSafety/JT808.Protocol.Extensions.JTActiveSafety.csproj b/src/JT808.Protocol.Extensions/JT808.Protocol.Extensions.JTActiveSafety/JT808.Protocol.Extensions.JTActiveSafety.csproj new file mode 100644 index 0000000..d950721 --- /dev/null +++ b/src/JT808.Protocol.Extensions/JT808.Protocol.Extensions.JTActiveSafety/JT808.Protocol.Extensions.JTActiveSafety.csproj @@ -0,0 +1,36 @@ + + + + netstandard2.0;netstandard2.1;net5.0; + 9.0 + Copyright 2019. + SmallChi(Koike) + JT808.Protocol.Extensions.JTActiveSafety + JT808.Protocol.Extensions.JTActiveSafety + 基于JT808协议、GB808协议扩展的主动安全消息协议(苏标) + 基于JT808协议、GB808协议扩展的主动安全消息协议(苏标) + true + https://github.com/SmallChi/JTActiveSafety + https://github.com/SmallChi/JTActiveSafety + https://github.com/SmallChi/JT808/blob/master/LICENSE + https://github.com/SmallChi/JT808/blob/master/LICENSE + false + JT808.Protocol.Extensions.JTActiveSafety.xml + 1.1.7 + LICENSE + + + + + True + + + + + + + + + + + diff --git a/src/JT808.Protocol.Extensions/JT808.Protocol.Extensions.JTActiveSafety/JT808.Protocol.Extensions.JTActiveSafety.xml b/src/JT808.Protocol.Extensions/JT808.Protocol.Extensions.JTActiveSafety/JT808.Protocol.Extensions.JTActiveSafety.xml new file mode 100644 index 0000000..8986e83 --- /dev/null +++ b/src/JT808.Protocol.Extensions/JT808.Protocol.Extensions.JTActiveSafety/JT808.Protocol.Extensions.JTActiveSafety.xml @@ -0,0 +1,2028 @@ + + + + JT808.Protocol.Extensions.JTActiveSafety + + + + + 主动拍照策略 + + + + + 不开启 + + + + + 定时拍照 + + + + + 定距拍照 + + + + + 保留 + + + + + 不修改参数 + + + + + 主动安全消息Id + + + + + 报警附件信息消息 + + + + + 文件信息上传 + + + + + 文件上传完成消息 + + + + + 报警附件上传指令 + + + + + 文件上传完成消息应答 + + + + + 拍照分辨率 + + + + + 352x288 + + + + + 704x288 + + + + + 704x576 + + + + + 640x480 + + + + + 1280x720 + + + + + 1920x1080 + + + + + 不修改参数 + + + + + USB编号类型 + + + + + 高级驾驶辅助系统 + + + + + 驾驶员状态监控系统 + + + + + 轮胎气压监测系统 + + + + + 盲点监测系统 + + + + + 视频录制分辨率 + + + + + CIF + + + + + HD1 + + + + + D1 + + + + + WD1 + + + + + VGA + + + + + 720P + + + + + 1080P + + + + + 不修改参数 + + + + + 工作状态 + + + + + 正常工作 + + + + + 待机状态 + + + + + 升级维护 + + + + + 设备异常 + + + + + 断开连接 + + + + + 主动安全常量 + + + + + 附加信息ID 高级驾驶辅助系统报警信息 + + + + + 附加信息ID 驾驶员状态监测系统报警信息 + + + + + 附加信息ID 胎压监测系统报警信息 + + + + + 附加信息ID 盲区监测系统报警信息 + + + + + 高级驾驶辅助系统参数设置 + + + + + 驾驶员状态监测系统参数设置 + + + + + 胎压监测系统参数设置 + + + + + 盲区监测系统参数设置 + + + + + 状态查询 + + + + + 信息查询 + + + + + 主动安全扩展 + + + + + 添加主动安全 + + + + + + + 高级驾驶辅助系统报警信息 + + + + + 高级驾驶辅助系统报警信息Id + + + + + 高级驾驶辅助系统报警信息附加长度 + + + + + 报警ID + + + + + 标志状态 + + + + + 报警/事件类型 + + + + + 报警/事件类型 + + + + + 前车车速 + + + + + 前车/行人距离 + + + + + 偏离类型 + + + + + 道路标志识别类型 + + + + + 道路标志识别类型 + + + + + 车速 + + + + + 高程 + + + + + 纬度 + + + + + 经度 + + + + + 日期时间 + YYMMDDhhmmss + BCD[6] + + + + + 车辆状态 + + + + + 报警标识号 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 驾驶员状态监测系统报警信息 + + + + + 驾驶员状态监测系统报警信息Id + + + + + 驾驶员状态监测系统报警信息长度 + + + + + 报警ID + + + + + 标志状态 + + + + + 报警/事件类型 + + + + + 报警级别 + + + + + 疲劳程度 + + + + + 预留 + + + + + 车速 + + + + + 高程 + + + + + 纬度 + + + + + 经度 + + + + + 日期时间 + YYMMDDhhmmss + BCD[6] + + + + + 车辆状态 + + + + + 报警标识号 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 胎压监测系统报警信息 + + + + + 胎压监测系统报警信息Id + + + + + 胎压监测系统报警信息长度 + + + + + 报警ID + + + + + 标志状态 + + + + + 车速 + + + + + 高程 + + + + + 纬度 + + + + + 经度 + + + + + 日期时间 + YYMMDDhhmmss + BCD[6] + + + + + 车辆状态 + + + + + 报警标识号 + + + + + 报警/事件列表总数 + + + + + 报警/事件信息列表 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 盲区监测系统报警信息 + + + + + 盲区监测系统报警信息Id + + + + + 盲区监测系统报警信息长度 + + + + + 报警ID + + + + + 标志状态 + + + + + 报警/事件类型 + + + + + 报警/事件类型 + + + + + 车速 + + + + + 高程 + + + + + 纬度 + + + + + 经度 + + + + + 日期时间 + YYMMDDhhmmss + BCD[6] + + + + + 车辆状态 + + + + + 报警标识号 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 透传数据 + + + + + 透传类型 + + + + + 消息列表总数 + + + + + 消息列表数据 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 透传数据 + + + + + 透传类型 + + + + + 消息列表总数 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 报警附件信息消息 + + + + + 制造商Id + 7 个字节,由大写字母和数字组成,此终端ID 由制造商自行定义,位数不足时,后补“0x00” + + + + + 报警标识号 + + + + + 平台给报警分配的唯一编号 + 32 + + + + + 信息类型 + 0x00:正常报警文件信息 + 0x01:补传报警文件信息 + + + + + 附件数量 + + + + + 附件信息列表 + + + + + 报警附件信息消息Id + + + + + 报警附件信息消息 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 文件信息上传 + + + + + 文件信息上传 + + + + + 文件名称长度 + + + + + 文件名称 + 形如:文件类型_通道号_报警类型_序号_报警编号.后缀名 + + + + + 文件类型 + + + + + 文件大小 + + + + + 文件信息上传Id + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 文件上传完成消息 + + + + + 文件上传完成消息 + + + + + 文件名称长度 + + + + + 文件名称 + 形如:文件类型_通道号_报警类型_序号_报警编号.后缀名 + + + + + 文件类型 + + + + + 文件大小 + + + + + 文件上传完成消息 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 高级驾驶辅助系统参数 + + + + + 高级驾驶辅助系统参数 + + + + + 高级驾驶辅助系统参数长度 + + + + + 报警判断速度阈值 + + + + + 报警提示音量 + + + + + 主动拍照策略 + + + + + + 主动定时拍照时间间隔 + + + + + 主动定距拍照距离间隔 + + + + + 单次主动拍照张数 + + + + + 单次主动拍照时间间隔 + + + + + 拍照分辨率 + + + + + + 视频录制分辨率 + + + + + 报警使能 + + + + + 事件使能 + + + + + 预留字段 + + + + + 障碍物报警距离阈值 + + + + + 障碍物报警分级速度阈值 + + + + + 障碍物报警前后视频录制时间 + + + + + 障碍物报警拍照张数 + + + + + 障碍物报警拍照间隔 + + + + + 频繁变道报警判断时间段 + + + + + 频繁变道报警判断次数 + + + + + 频繁变道报警分级速度阈值 + + + + + 频繁变道报警前后视频录制时间 + + + + + 频繁变道报警拍照张数 + + + + + 频繁变道报警拍照间隔 + + + + + 车道偏离报警分级速度阈值 + + + + + 车道偏离报警前后视频录制时间 + + + + + 车道偏离报警拍照张数 + + + + + 车道偏离报警拍照间隔 + + + + + 前向碰撞报警时间阈值 + + + + + 前向碰撞报警分级速度阈值 + + + + + 前向碰撞报警前后视频录制时间 + + + + + 前向碰撞报警拍照张数 + + + + + 前向碰撞报警拍照间隔 + + + + + 行人碰撞报警时间阈值 + + + + + 行人碰撞报警使能速度阈值 + + + + + 行人碰撞报警前后视频录制时间 + + + + + 行人碰撞报警拍照张数 + + + + + 行人碰撞报警拍照间隔 + + + + + 车距监控报警距离阈值 + + + + + 车距监控报警分级速度阈值 + + + + + 车距过近报警前后视频录制时间 + + + + + 车距过近报警拍照张数 + + + + + 车距过近报警拍照间隔 + + + + + 道路标志识别拍照张数 + + + + + 道路标志识别拍照间隔 + + + + + 保留字段 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 驾驶员状态监测系统参数 + + + + + 驾驶员状态监测系统参数 + + + + + 驾驶员状态监测系统参数长度 + + + + + 报警判断速度阈值 + + + + + 报警提示音量 + + + + + 主动拍照策略 + + + + + 主动定时拍照时间间隔 + + + + + 主动定距拍照距离间隔 + + + + + 单次主动拍照张数 + + + + + 单次主动拍照时间间隔 + + + + + 拍照分辨率 + + + + + 视频录制分辨率 + + + + + 报警使能 + + + + + 事件使能 + + + + + 吸烟报警判断时间间隔 + + + + + 接打电话报警判断时间间隔 + + + + + 预留字段 + + + + + 疲劳驾驶报警分级速度阈值 + + + + + 疲劳驾驶报警前后视频录制时间 + + + + + 疲劳驾驶报警拍照张数 + + + + + 疲劳驾驶报警拍照间隔时间 + + + + + 接打电话报警分级速度阈值 + + + + + 接打电话报警前后视频录制时间 + + + + + 接打电话报警拍驾驶员面部特征照片张数 + + + + + 接打电话报警拍驾驶员面部特征照片间隔时间 + + + + + 抽烟报警分级车速阈值 + + + + + 抽烟报警前后视频录制时间 + + + + + 抽烟报警拍驾驶员面部特征照片张数 + + + + + 抽烟报警拍驾驶员面部特征照片间隔时间 + + + + + 分神驾驶报警分级车速阈值 + + + + + 分神驾驶报警拍照张数 + + + + + 分神驾驶报警拍照间隔时间 + + + + + 驾驶行为异常视频录制时间 + + + + + 驾驶行为异常抓拍照片张数 + + + + + 驾驶行为异常拍照间隔 + + + + + 驾驶员身份识别触发 + + + + + 保留字段 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 胎压监测系统参数 + + + + + 胎压监测系统参数Id + + + + + 胎压监测系统参数长度 + + + + + 轮胎规格型号 12位 + + + + + 胎压单位 + + + + + 正常胎压值 + + + + + 胎压不平衡门限 + + + + + 慢漏气门限 + + + + + 低压阈值 + + + + + 高压阈值 + + + + + 高温阈值 + + + + + 电压阈值 + + + + + 定时上报时间间隔 + + + + + 保留项 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 盲区监测系统参数 + + + + + 盲区监测系统参数Id + + + + + 盲区监测系统参数长度 + + + + + 后方接近报警时间阈值 + + + + + 侧后方接近报警时间阈值 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 查询基本信息 + + + + + 查询基本信息类型 + + + + + 外设ID列表总数 + + + + + 外设ID + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 查询基本信息 + + + + + 查询基本信息透传类型 + + + + + 外设ID列表总数 + + + + + 外设ID + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 报警附件上传指令 + + + + + Description + + + + + 服务IP地址长度 + + + + + 服务IP地址 + + + + + TCP端口 + + + + + UDP端口 + + + + + 报警标识号 + + + + + 平台给报警分配的唯一编号 + 32 + + + + + 预留 + + + + + 报警附件上传指令Id + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 文件上传完成消息应答 + + + + + 文件上传完成消息应答 + + + + + 文件名称长度 + + + + + 文件名称 + + + + + 文件类型 + + + + + 上传结果 + + + + + 补传数据包数量 + 需要补传的数据包数量,无补传时该值为0 + + + + + 补传数据包列表 + + + + + 文件上传完成消息应答Id + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 报警标识号 + + + + + 终端ID + + + + + YY-MM-DD-hh-mm-ss + BCD[6] + + + + + 序号 + + + + + 附件数量 + + + + + 预留 + + + + + 胎压监测系统报警/事件信息 + + + + + 胎压报警位置 + + + + + 报警/事件类型 + + + + + 胎压 + + + + + 胎温 + + + + + 电池电量 + + + + + 附件信息 + + + + + 文件名称长度 + + + + + 文件名称 + 形如:文件类型_通道号_报警类型_序号_报警编号.后缀名 + + + + + 文件大小 + + + + + 补传数据包信息 + + + + + 数据偏移量 + + + + + 数据长度 + + + + + + + + + + 外设ID + + + + + + 消息长度 + + + + + 工作状态 + + + + + + 报警状态 + + + + + + + + + + 外设ID + + + + + + 消息长度 + + + + + 公司名称长度 + + + + + 公司名称 + + + + + 产品型号长度 + + + + + 产品型号 + + + + + 硬件版本号长度 + + + + + 硬件版本号 + ASCII + + + + + 软件版本号长度 + + + + + 软件版本号 + ASCII + + + + + 设备ID长度 + + + + + 设备ID + + + + + 客户代码长度 + + + + + 客户代码 + + + + diff --git a/src/JT808.Protocol.Extensions/JT808.Protocol.Extensions.JTActiveSafety/JT808_JTActiveSafety_Constants.cs b/src/JT808.Protocol.Extensions/JT808.Protocol.Extensions.JTActiveSafety/JT808_JTActiveSafety_Constants.cs new file mode 100644 index 0000000..9b8a148 --- /dev/null +++ b/src/JT808.Protocol.Extensions/JT808.Protocol.Extensions.JTActiveSafety/JT808_JTActiveSafety_Constants.cs @@ -0,0 +1,53 @@ +using System; +using System.Collections.Generic; +using System.Text; + +namespace JT808.Protocol.Extensions.JTActiveSafety +{ + /// + /// 主动安全常量 + /// + public static class JT808_JTActiveSafety_Constants + { + /// + /// 附加信息ID 高级驾驶辅助系统报警信息 + /// + public const byte JT808_0X0200_0x64 = 0x64; + /// + /// 附加信息ID 驾驶员状态监测系统报警信息 + /// + public const byte JT808_0X0200_0x65 = 0x65; + /// + /// 附加信息ID 胎压监测系统报警信息 + /// + public const byte JT808_0X0200_0x66 = 0x66; + /// + /// 附加信息ID 盲区监测系统报警信息 + /// + public const byte JT808_0X0200_0x67 = 0x67; + /// + /// 高级驾驶辅助系统参数设置 + /// + public const uint JT808_0X8103_0xF364 = 0xF364; + /// + /// 驾驶员状态监测系统参数设置 + /// + public const uint JT808_0X8103_0xF365 = 0xF365; + /// + /// 胎压监测系统参数设置 + /// + public const uint JT808_0X8103_0xF366 = 0xF366; + /// + /// 盲区监测系统参数设置 + /// + public const uint JT808_0X8103_0xF367 = 0xF367; + /// + /// 状态查询 + /// + public const byte JT808_0X0900_0xF7 = 0xF7; + /// + /// 信息查询 + /// + public const byte JT808_0X0900_0xF8 = 0xF8; + } +} diff --git a/src/JT808.Protocol.Extensions/JT808.Protocol.Extensions.JTActiveSafety/JTActiveSafetyDependencyInjectionExtensions.cs b/src/JT808.Protocol.Extensions/JT808.Protocol.Extensions.JTActiveSafety/JTActiveSafetyDependencyInjectionExtensions.cs new file mode 100644 index 0000000..f066aa4 --- /dev/null +++ b/src/JT808.Protocol.Extensions/JT808.Protocol.Extensions.JTActiveSafety/JTActiveSafetyDependencyInjectionExtensions.cs @@ -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 +{ + /// + /// 主动安全扩展 + /// + public static class JTActiveSafetyDependencyInjectionExtensions + { + /// + /// 添加主动安全 + /// + /// + /// + public static IJT808Builder AddJTActiveSafetyConfigure(this IJT808Builder jT808Builder) + { + jT808Builder.Config.Register(Assembly.GetExecutingAssembly()); + return jT808Builder; + } + } +} diff --git a/src/JT808.Protocol.Extensions/JT808.Protocol.Extensions.JTActiveSafety/MessageBody/JT808_0x0200_0x64.cs b/src/JT808.Protocol.Extensions/JT808.Protocol.Extensions.JTActiveSafety/MessageBody/JT808_0x0200_0x64.cs new file mode 100644 index 0000000..eb195fe --- /dev/null +++ b/src/JT808.Protocol.Extensions/JT808.Protocol.Extensions.JTActiveSafety/MessageBody/JT808_0x0200_0x64.cs @@ -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 +{ + /// + /// 高级驾驶辅助系统报警信息 + /// + public class JT808_0x0200_0x64 : JT808_0x0200_BodyBase, IJT808MessagePackFormatter, IJT808Analyze + { + /// + /// 高级驾驶辅助系统报警信息Id + /// + public override byte AttachInfoId { get; set; } = JT808_JTActiveSafety_Constants.JT808_0X0200_0x64; + /// + /// 高级驾驶辅助系统报警信息附加长度 + /// + public override byte AttachInfoLength { get; set; } = 32; + /// + /// 报警ID + /// + public uint AlarmId { get; set; } + /// + /// 标志状态 + /// + public byte FlagState { get; set; } + /// + /// 报警/事件类型 + /// + public byte AlarmOrEventType{ get; set; } + /// + /// 报警/事件类型 + /// + public byte AlarmLevel { get; set; } + /// + /// 前车车速 + /// + public byte VehicleSpeed { get; set; } + /// + /// 前车/行人距离 + /// + public byte CarOrPedestrianDistanceAhead { get; set; } + /// + /// 偏离类型 + /// + public byte DeviateType { get; set; } + /// + /// 道路标志识别类型 + /// + public byte RoadSignIdentificationType { get; set; } + /// + /// 道路标志识别类型 + /// + public byte RoadSignIdentificationData { get; set; } + /// + /// 车速 + /// + public byte Speed { get; set; } + /// + /// 高程 + /// + public ushort Altitude { get; set; } + /// + /// 纬度 + /// + public int Latitude { get; set; } + /// + /// 经度 + /// + public int Longitude { get; set; } + /// + /// 日期时间 + /// YYMMDDhhmmss + /// BCD[6] + /// + public DateTime AlarmTime { get; set; } + /// + /// 车辆状态 + /// + public ushort VehicleState { get; set; } + /// + /// 报警标识号 + /// + public AlarmIdentificationProperty AlarmIdentification { get; set; } + /// + /// + /// + /// + /// + /// + 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); + } + /// + /// + /// + /// + /// + /// + 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; + } + /// + /// + /// + /// + /// + /// + 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); + } + } +} diff --git a/src/JT808.Protocol.Extensions/JT808.Protocol.Extensions.JTActiveSafety/MessageBody/JT808_0x0200_0x65.cs b/src/JT808.Protocol.Extensions/JT808.Protocol.Extensions.JTActiveSafety/MessageBody/JT808_0x0200_0x65.cs new file mode 100644 index 0000000..95ec9da --- /dev/null +++ b/src/JT808.Protocol.Extensions/JT808.Protocol.Extensions.JTActiveSafety/MessageBody/JT808_0x0200_0x65.cs @@ -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 +{ + /// + /// 驾驶员状态监测系统报警信息 + /// + public class JT808_0x0200_0x65 : JT808_0x0200_BodyBase, IJT808MessagePackFormatter, IJT808Analyze + { + /// + /// 驾驶员状态监测系统报警信息Id + /// + public override byte AttachInfoId { get; set; } = JT808_JTActiveSafety_Constants.JT808_0X0200_0x65; + /// + /// 驾驶员状态监测系统报警信息长度 + /// + public override byte AttachInfoLength { get; set; } = 47; + /// + /// 报警ID + /// + public uint AlarmId { get; set; } + /// + /// 标志状态 + /// + public byte FlagState { get; set; } + /// + /// 报警/事件类型 + /// + public byte AlarmOrEventType{ get; set; } + /// + /// 报警级别 + /// + public byte AlarmLevel { get; set; } + /// + /// 疲劳程度 + /// + public byte Fatigue { get; set; } + /// + /// 预留 + /// + public byte[] Retain { get; set; } = new byte[4]; + /// + /// 车速 + /// + public byte Speed { get; set; } + /// + /// 高程 + /// + public ushort Altitude { get; set; } + /// + /// 纬度 + /// + public int Latitude { get; set; } + /// + /// 经度 + /// + public int Longitude { get; set; } + /// + /// 日期时间 + /// YYMMDDhhmmss + /// BCD[6] + /// + public DateTime AlarmTime { get; set; } + /// + /// 车辆状态 + /// + public ushort VehicleState { get; set; } + /// + /// 报警标识号 + /// + public AlarmIdentificationProperty AlarmIdentification { get; set; } + /// + /// + /// + /// + /// + /// + 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); + } + /// + /// + /// + /// + /// + /// + 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; + } + /// + /// + /// + /// + /// + /// + 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); + } + } +} diff --git a/src/JT808.Protocol.Extensions/JT808.Protocol.Extensions.JTActiveSafety/MessageBody/JT808_0x0200_0x66.cs b/src/JT808.Protocol.Extensions/JT808.Protocol.Extensions.JTActiveSafety/MessageBody/JT808_0x0200_0x66.cs new file mode 100644 index 0000000..d42f267 --- /dev/null +++ b/src/JT808.Protocol.Extensions/JT808.Protocol.Extensions.JTActiveSafety/MessageBody/JT808_0x0200_0x66.cs @@ -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 +{ + /// + /// 胎压监测系统报警信息 + /// + public class JT808_0x0200_0x66 : JT808_0x0200_BodyBase, IJT808MessagePackFormatter, IJT808Analyze + { + /// + /// 胎压监测系统报警信息Id + /// + public override byte AttachInfoId { get; set; } = JT808_JTActiveSafety_Constants.JT808_0X0200_0x66; + /// + /// 胎压监测系统报警信息长度 + /// + public override byte AttachInfoLength { get; set; } + /// + /// 报警ID + /// + public uint AlarmId { get; set; } + /// + /// 标志状态 + /// + public byte FlagState { get; set; } + /// + /// 车速 + /// + public byte Speed { get; set; } + /// + /// 高程 + /// + public ushort Altitude { get; set; } + /// + /// 纬度 + /// + public int Latitude { get; set; } + /// + /// 经度 + /// + public int Longitude { get; set; } + /// + /// 日期时间 + /// YYMMDDhhmmss + /// BCD[6] + /// + public DateTime AlarmTime { get; set; } + /// + /// 车辆状态 + /// + public ushort VehicleState { get; set; } + /// + /// 报警标识号 + /// + public AlarmIdentificationProperty AlarmIdentification { get; set; } + /// + /// 报警/事件列表总数 + /// + public byte AlarmOrEventCount { get; set; } + /// + /// 报警/事件信息列表 + /// + public List AlarmOrEvents { get; set; } + /// + /// + /// + /// + /// + /// + 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(); + } + } + /// + /// + /// + /// + /// + /// + 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(); + 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; + } + /// + /// + /// + /// + /// + /// + 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); + } + } +} diff --git a/src/JT808.Protocol.Extensions/JT808.Protocol.Extensions.JTActiveSafety/MessageBody/JT808_0x0200_0x67.cs b/src/JT808.Protocol.Extensions/JT808.Protocol.Extensions.JTActiveSafety/MessageBody/JT808_0x0200_0x67.cs new file mode 100644 index 0000000..c6c5d57 --- /dev/null +++ b/src/JT808.Protocol.Extensions/JT808.Protocol.Extensions.JTActiveSafety/MessageBody/JT808_0x0200_0x67.cs @@ -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 +{ + /// + /// 盲区监测系统报警信息 + /// + public class JT808_0x0200_0x67 : JT808_0x0200_BodyBase, IJT808MessagePackFormatter, IJT808Analyze + { + /// + /// 盲区监测系统报警信息Id + /// + public override byte AttachInfoId { get; set; } = JT808_JTActiveSafety_Constants.JT808_0X0200_0x67; + /// + /// 盲区监测系统报警信息长度 + /// + public override byte AttachInfoLength { get; set; } = 26; + /// + /// 报警ID + /// + public uint AlarmId { get; set; } + /// + /// 标志状态 + /// + public byte FlagState { get; set; } + /// + /// 报警/事件类型 + /// + public byte AlarmOrEventType{ get; set; } + /// + /// 报警/事件类型 + /// + public byte AlarmLevel { get; set; } + /// + /// 车速 + /// + public byte Speed { get; set; } + /// + /// 高程 + /// + public ushort Altitude { get; set; } + /// + /// 纬度 + /// + public int Latitude { get; set; } + /// + /// 经度 + /// + public int Longitude { get; set; } + /// + /// 日期时间 + /// YYMMDDhhmmss + /// BCD[6] + /// + public DateTime AlarmTime { get; set; } + /// + /// 车辆状态 + /// + public ushort VehicleState { get; set; } + /// + /// 报警标识号 + /// + public AlarmIdentificationProperty AlarmIdentification { get; set; } + /// + /// + /// + /// + /// + /// + 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); + } + /// + /// + /// + /// + /// + /// + 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; + } + /// + /// + /// + /// + /// + /// + 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); + } + } +} diff --git a/src/JT808.Protocol.Extensions/JT808.Protocol.Extensions.JTActiveSafety/MessageBody/JT808_0x0900_0xF7.cs b/src/JT808.Protocol.Extensions/JT808.Protocol.Extensions.JTActiveSafety/MessageBody/JT808_0x0900_0xF7.cs new file mode 100644 index 0000000..b4c9888 --- /dev/null +++ b/src/JT808.Protocol.Extensions/JT808.Protocol.Extensions.JTActiveSafety/MessageBody/JT808_0x0900_0xF7.cs @@ -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 +{ + /// + /// 透传数据 + /// + public class JT808_0x0900_0xF7 : JT808_0x0900_BodyBase, IJT808MessagePackFormatter, IJT808Analyze + { + /// + /// 透传类型 + /// + public override byte PassthroughType { get; set; } = JT808_JTActiveSafety_Constants.JT808_0X0900_0xF7; + /// + /// 消息列表总数 + /// + public byte USBMessageCount { get; set; } + /// + /// 消息列表数据 + /// + public List USBMessages { get; set; } + /// + /// + /// + /// + /// + /// + 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(); + } + } + /// + /// + /// + /// + /// + /// + 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(); + 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; + } + /// + /// + /// + /// + /// + /// + 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); + } + } + } + } +} diff --git a/src/JT808.Protocol.Extensions/JT808.Protocol.Extensions.JTActiveSafety/MessageBody/JT808_0x0900_0xF8.cs b/src/JT808.Protocol.Extensions/JT808.Protocol.Extensions.JTActiveSafety/MessageBody/JT808_0x0900_0xF8.cs new file mode 100644 index 0000000..6198167 --- /dev/null +++ b/src/JT808.Protocol.Extensions/JT808.Protocol.Extensions.JTActiveSafety/MessageBody/JT808_0x0900_0xF8.cs @@ -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 +{ + /// + /// 透传数据 + /// + public class JT808_0x0900_0xF8 : JT808_0x0900_BodyBase, IJT808MessagePackFormatter, IJT808Analyze + { + /// + /// 透传类型 + /// + public override byte PassthroughType { get; set; } = JT808_JTActiveSafety_Constants.JT808_0X0900_0xF8; + /// + /// 消息列表总数 + /// + public byte USBMessageCount { get; set; } + /// + /// + /// + public List USBMessages { get; set; } + /// + /// + /// + /// + /// + /// + 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(); + } + } + /// + /// + /// + /// + /// + /// + 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(); + 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; + } + /// + /// + /// + /// + /// + /// + 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); + } + } + } + } +} diff --git a/src/JT808.Protocol.Extensions/JT808.Protocol.Extensions.JTActiveSafety/MessageBody/JT808_0x1210.cs b/src/JT808.Protocol.Extensions/JT808.Protocol.Extensions.JTActiveSafety/MessageBody/JT808_0x1210.cs new file mode 100644 index 0000000..4a6d105 --- /dev/null +++ b/src/JT808.Protocol.Extensions/JT808.Protocol.Extensions.JTActiveSafety/MessageBody/JT808_0x1210.cs @@ -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 +{ + /// + /// 报警附件信息消息 + /// + public class JT808_0x1210: JT808Bodies, IJT808MessagePackFormatter, IJT808Analyze + { + /// + /// 制造商Id + /// 7 个字节,由大写字母和数字组成,此终端ID 由制造商自行定义,位数不足时,后补“0x00” + /// + public string MakerID { get; set; } + /// + /// 报警标识号 + /// + public AlarmIdentificationProperty AlarmIdentification { get; set; } + /// + /// 平台给报警分配的唯一编号 + /// 32 + /// + public string AlarmId { get; set; } + /// + /// 信息类型 + /// 0x00:正常报警文件信息 + /// 0x01:补传报警文件信息 + /// + public byte InfoType { get; set; } + /// + /// 附件数量 + /// + public byte AttachCount { get; set; } + /// + /// 附件信息列表 + /// + public List AttachInfos { get; set; } + /// + /// 报警附件信息消息Id + /// + public override ushort MsgId => 0x1210; + /// + /// 报警附件信息消息 + /// + public override string Description => "报警附件信息消息"; + /// + /// + /// + /// + /// + /// + 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(); + } + } + /// + /// + /// + /// + /// + /// + 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(); + 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; + } + /// + /// + /// + /// + /// + /// + 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); + } + } + } +} diff --git a/src/JT808.Protocol.Extensions/JT808.Protocol.Extensions.JTActiveSafety/MessageBody/JT808_0x1211.cs b/src/JT808.Protocol.Extensions/JT808.Protocol.Extensions.JTActiveSafety/MessageBody/JT808_0x1211.cs new file mode 100644 index 0000000..8f071f2 --- /dev/null +++ b/src/JT808.Protocol.Extensions/JT808.Protocol.Extensions.JTActiveSafety/MessageBody/JT808_0x1211.cs @@ -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 +{ + /// + /// 文件信息上传 + /// + public class JT808_0x1211 : JT808Bodies, IJT808MessagePackFormatter, IJT808Analyze + { + /// + /// 文件信息上传 + /// + public override string Description => "文件信息上传"; + /// + /// 文件名称长度 + /// + public byte FileNameLength { get; set; } + /// + /// 文件名称 + /// 形如:文件类型_通道号_报警类型_序号_报警编号.后缀名 + /// + public string FileName { get; set; } + /// + /// 文件类型 + /// + public byte FileType { get; set; } + /// + /// 文件大小 + /// + public uint FileSize { get; set; } + /// + /// 文件信息上传Id + /// + public override ushort MsgId => 0x1211; + /// + /// + /// + /// + /// + /// + 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); + } + /// + /// + /// + /// + /// + /// + 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; + } + /// + /// + /// + /// + /// + /// + 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); + } + } +} diff --git a/src/JT808.Protocol.Extensions/JT808.Protocol.Extensions.JTActiveSafety/MessageBody/JT808_0x1212.cs b/src/JT808.Protocol.Extensions/JT808.Protocol.Extensions.JTActiveSafety/MessageBody/JT808_0x1212.cs new file mode 100644 index 0000000..afbf5dd --- /dev/null +++ b/src/JT808.Protocol.Extensions/JT808.Protocol.Extensions.JTActiveSafety/MessageBody/JT808_0x1212.cs @@ -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 +{ + /// + /// 文件上传完成消息 + /// + public class JT808_0x1212 : JT808Bodies, IJT808MessagePackFormatter, IJT808Analyze + { + /// + /// 文件上传完成消息 + /// + public override string Description => "文件上传完成消息"; + /// + /// 文件名称长度 + /// + public byte FileNameLength { get; set; } + /// + /// 文件名称 + /// 形如:文件类型_通道号_报警类型_序号_报警编号.后缀名 + /// + public string FileName { get; set; } + /// + /// 文件类型 + /// + public byte FileType { get; set; } + /// + /// 文件大小 + /// + public uint FileSize { get; set; } + /// + /// 文件上传完成消息 + /// + public override ushort MsgId => 0x1212; + /// + /// + /// + /// + /// + /// + 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); + } + /// + /// + /// + /// + /// + /// + 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; + } + /// + /// + /// + /// + /// + /// + 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); + } + } +} diff --git a/src/JT808.Protocol.Extensions/JT808.Protocol.Extensions.JTActiveSafety/MessageBody/JT808_0x8103_0xF364.cs b/src/JT808.Protocol.Extensions/JT808.Protocol.Extensions.JTActiveSafety/MessageBody/JT808_0x8103_0xF364.cs new file mode 100644 index 0000000..f5b2952 --- /dev/null +++ b/src/JT808.Protocol.Extensions/JT808.Protocol.Extensions.JTActiveSafety/MessageBody/JT808_0x8103_0xF364.cs @@ -0,0 +1,456 @@ +using JT808.Protocol.Extensions.JTActiveSafety.Enums; +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.JTActiveSafety.MessageBody +{ + /// + /// 高级驾驶辅助系统参数 + /// + public class JT808_0x8103_0xF364 : JT808_0x8103_BodyBase, IJT808MessagePackFormatter, IJT808Analyze + { + /// + /// 高级驾驶辅助系统参数 + /// + public override uint ParamId { get; set; } = JT808_JTActiveSafety_Constants.JT808_0X8103_0xF364; + /// + /// 高级驾驶辅助系统参数长度 + /// + public override byte ParamLength { get; set; } + /// + /// 报警判断速度阈值 + /// + public byte AlarmJudgeSpeedThreshold { get; set; } + /// + /// 报警提示音量 + /// + public byte WarningVolume { get; set; } + /// + /// 主动拍照策略 + /// + /// + public byte ActivePhotographyStrategy { get; set; } + /// + /// 主动定时拍照时间间隔 + /// + public ushort ActivelyTimePhotoInterval { get; set; } + /// + /// 主动定距拍照距离间隔 + /// + public ushort ActiveDistancePhotographyDistanceInterval { get; set; } + /// + /// 单次主动拍照张数 + /// + public byte SingleInitiativePhotos { get; set; } + /// + /// 单次主动拍照时间间隔 + /// + public byte SingleInitiativePhotosInterval { get; set; } + /// + /// 拍照分辨率 + /// + /// + public byte PhotoResolution { get; set; } + /// + /// 视频录制分辨率 + /// + public byte VideoRecordingResolution { get; set; } + /// + /// 报警使能 + /// + public uint AlarmEnable { get; set; } + /// + /// 事件使能 + /// + public uint EventEnable { get; set; } + /// + /// 预留字段 + /// + public byte Placeholder1 { get; set; } + /// + /// 障碍物报警距离阈值 + /// + public byte DistanceThresholdObstacleAlarm { get; set; } + /// + /// 障碍物报警分级速度阈值 + /// + public byte HierarchicalSpeedThresholdObstacleAlarm { get; set; } + /// + /// 障碍物报警前后视频录制时间 + /// + public byte VideoRecordingTimeBeforeAndAfterObstacleAlarm { get; set; } + /// + /// 障碍物报警拍照张数 + /// + public byte BarrierAlarmPhotographs { get; set; } + /// + /// 障碍物报警拍照间隔 + /// + public byte ObstacleAlarmInterval { get; set; } + /// + /// 频繁变道报警判断时间段 + /// + public byte FrequentChannelChangeAlarmJudgmentTimePeriod { get; set; } + + /// + /// 频繁变道报警判断次数 + /// + public byte FrequentAlarmJudgmentNumberChannelChange { get; set; } + /// + /// 频繁变道报警分级速度阈值 + /// + public byte HierarchicalSpeedThresholdFrequentChannelChangeAlarm { get; set; } + /// + /// 频繁变道报警前后视频录制时间 + /// + public byte VideoRecordingTimeBeforeAndAfterFrequentLaneChangeAlarm { get; set; } + /// + /// 频繁变道报警拍照张数 + /// + public byte FrequentChannelChangeAlarmPhotos { get; set; } + /// + /// 频繁变道报警拍照间隔 + /// + public byte FrequentLaneChangeAlarmInterval { get; set; } + /// + /// 车道偏离报警分级速度阈值 + /// + public byte GradedSpeedThresholdLaneDeviationAlarm { get; set; } + /// + /// 车道偏离报警前后视频录制时间 + /// + public byte VideoRecordingTimeBeforeAndAfterLaneDepartureAlarm { get; set; } + /// + /// 车道偏离报警拍照张数 + /// + public byte LaneDepartureAlarmPhoto { get; set; } + /// + /// 车道偏离报警拍照间隔 + /// + public byte LaneDepartureAlarmPhotoInterval { get; set; } + /// + /// 前向碰撞报警时间阈值 + /// + public byte ForwardCollisionWarningTimeThreshold { get; set; } + /// + /// 前向碰撞报警分级速度阈值 + /// + public byte HierarchicalSpeedThresholdForwardCollisionWarning { get; set; } + /// + /// 前向碰撞报警前后视频录制时间 + /// + public byte VideoRecordingTimeBeforeAndAfterForwardCollisionAlarm { get; set; } + /// + /// 前向碰撞报警拍照张数 + /// + public byte ForwardCollisionAlarmPhotographs { get; set; } + /// + /// 前向碰撞报警拍照间隔 + /// + public byte ForwardCollisionAlarmInterval { get; set; } + /// + /// 行人碰撞报警时间阈值 + /// + public byte PedestrianCollisionAlarmTimeThreshold { get; set; } + /// + /// 行人碰撞报警使能速度阈值 + /// + public byte PedestrianCollisionAlarmEnablingSpeedThreshold { get; set; } + /// + /// 行人碰撞报警前后视频录制时间 + /// + public byte VideoRecordingTimeBeforeAndAfterPedestrianCollisionAlarm { get; set; } + /// + /// 行人碰撞报警拍照张数 + /// + public byte PedestrianCollisionAlarmPhotos { get; set; } + /// + /// 行人碰撞报警拍照间隔 + /// + public byte PedestrianCollisionAlarmInterval { get; set; } + /// + /// 车距监控报警距离阈值 + /// + public byte VehicleDistanceMonitoringAlarmDistanceThreshold { get; set; } + /// + /// 车距监控报警分级速度阈值 + /// + public byte VehicleDistanceMonitoringAndAlarmClassificationSpeedThreshold { get; set; } + /// + /// 车距过近报警前后视频录制时间 + /// + public byte VideoRecordingTimeBeforeAndAfterAlarmVehicleProximity { get; set; } + /// + /// 车距过近报警拍照张数 + /// + public byte AlarmPhotoVehicleCloseDistance { get; set; } + /// + /// 车距过近报警拍照间隔 + /// + public byte AlarmPhotoVehicleCloseDistanceInterval { get; set; } + /// + /// 道路标志识别拍照张数 + /// + public byte RoadSignRecognitionPhotographs { get; set; } + /// + /// 道路标志识别拍照间隔 + /// + public byte RoadSignRecognitionPhotographsInterval { get; set; } + /// + /// 保留字段 + /// + public byte[] Placeholder2 { get; set; } = new byte[4]; + /// + /// + /// + /// + /// + /// + public void Analyze(ref JT808MessagePackReader reader, Utf8JsonWriter writer, IJT808Config config) + { + JT808_0x8103_0xF364 value = new JT808_0x8103_0xF364(); + value.ParamId = reader.ReadUInt32(); + value.ParamLength = reader.ReadByte(); + writer.WriteNumber($"[{value.ParamId.ReadNumber()}]参数ID", value.ParamId); + writer.WriteNumber($"[{value.ParamLength.ReadNumber()}]参数长度", value.ParamLength); + value.AlarmJudgeSpeedThreshold = reader.ReadByte(); + writer.WriteNumber($"[{value.AlarmJudgeSpeedThreshold.ReadNumber()}]报警判断速度阈值", value.AlarmJudgeSpeedThreshold); + value.WarningVolume = reader.ReadByte(); + writer.WriteNumber($"[{value.WarningVolume.ReadNumber()}]报警提示音量", value.WarningVolume); + value.ActivePhotographyStrategy = reader.ReadByte(); + var activePhotographyStrategy = (ActivePhotographyStrategyType)ActivePhotographyStrategy; + writer.WriteNumber($"[{value.ActivePhotographyStrategy.ReadNumber()}]主动拍照策略-{activePhotographyStrategy.ToString()}", value.ActivePhotographyStrategy); + value.ActivelyTimePhotoInterval = reader.ReadUInt16(); + writer.WriteNumber($"[{value.ActivelyTimePhotoInterval.ReadNumber()}]主动定时拍照时间间隔", value.ActivelyTimePhotoInterval); + value.ActiveDistancePhotographyDistanceInterval = reader.ReadUInt16(); + writer.WriteNumber($"[{value.ActiveDistancePhotographyDistanceInterval.ReadNumber()}]主动定距拍照距离间隔", value.ActiveDistancePhotographyDistanceInterval); + value.SingleInitiativePhotos = reader.ReadByte(); + writer.WriteNumber($"[{value.SingleInitiativePhotos.ReadNumber()}]单次主动拍照张数", value.SingleInitiativePhotos); + value.SingleInitiativePhotosInterval = reader.ReadByte(); + writer.WriteNumber($"[{value.SingleInitiativePhotosInterval.ReadNumber()}]单次主动拍照时间间隔", value.SingleInitiativePhotosInterval); + value.PhotoResolution = reader.ReadByte(); + var photoResolutionType = (PhotoResolutionType)value.PhotoResolution; + writer.WriteNumber($"[{value.PhotoResolution.ReadNumber()}]拍照分辨率-{photoResolutionType.ToString()}", value.PhotoResolution); + value.VideoRecordingResolution = reader.ReadByte(); + var videoRecordingResolution = (VideoRecordingResolutionType)value.VideoRecordingResolution; + writer.WriteNumber($"[{value.VideoRecordingResolution.ReadNumber()}]视频录制分辨率-{videoRecordingResolution.ToString()}", value.VideoRecordingResolution); + value.AlarmEnable = reader.ReadUInt32(); + writer.WriteNumber($"[{value.AlarmEnable.ReadNumber()}]报警使能", value.AlarmEnable); + var alarmEnableBits = Convert.ToString(value.AlarmEnable, 2).PadLeft(32, '0').AsSpan(); + writer.WriteStartObject("报警使能对象"); + writer.WriteString("[bit30~bit31]预留", alarmEnableBits.Slice(30,2).ToString()); + writer.WriteString("[bit17~bit29]用户自定义", alarmEnableBits.Slice(17, 13).ToString()); + writer.WriteString("[bit16]道路标识超限报警", alarmEnableBits[16]=='0'?"关闭":"打开"); + writer.WriteString("[bit12~bit15]道路标识超限报警", alarmEnableBits.Slice(12, 4).ToString()); + writer.WriteString("[bit11]车距过近二级报警", alarmEnableBits[11] == '0' ? "关闭" : "打开"); + writer.WriteString("[bit10]车距过近一级报警", alarmEnableBits[10] == '0' ? "关闭" : "打开"); + writer.WriteString("[bit9]行人碰撞二级报警", alarmEnableBits[9] == '0' ? "关闭" : "打开"); + writer.WriteString("[bit8]行人碰撞一级报警", alarmEnableBits[8] == '0' ? "关闭" : "打开"); + writer.WriteString("[bit7]前向碰撞二级报警", alarmEnableBits[7] == '0' ? "关闭" : "打开"); + writer.WriteString("[bit6]前向碰撞一级报警", alarmEnableBits[6] == '0' ? "关闭" : "打开"); + writer.WriteString("[bit5]车道偏离二级报警", alarmEnableBits[5] == '0' ? "关闭" : "打开"); + writer.WriteString("[bit4]车道偏离一级报警", alarmEnableBits[4] == '0' ? "关闭" : "打开"); + writer.WriteString("[bit3]频繁变道二级报警", alarmEnableBits[3] == '0' ? "关闭" : "打开"); + writer.WriteString("[bit2]频繁变道一级报警", alarmEnableBits[2] == '0' ? "关闭" : "打开"); + writer.WriteString("[bit1]障碍检测二级报警", alarmEnableBits[1] == '0' ? "关闭" : "打开"); + writer.WriteString("[bit0]障碍检测一级报警", alarmEnableBits[0] == '0' ? "关闭" : "打开"); + writer.WriteEndObject(); + value.EventEnable = reader.ReadUInt32(); + writer.WriteNumber($"[{value.EventEnable.ReadNumber()}]事件使能", value.EventEnable); + var eventEnableBits = Convert.ToString(value.EventEnable, 2).PadLeft(32, '0').AsSpan(); + writer.WriteStartObject("事件使能对象"); + writer.WriteString("[bit30~bit31]预留", eventEnableBits.Slice(30, 2).ToString()); + writer.WriteString("[bit2~bit29]用户自定义", alarmEnableBits.Slice(2, 28).ToString()); + writer.WriteString("[bit1]主动拍照", alarmEnableBits[1] == '0' ? "关闭" : "打开"); + writer.WriteString("[bit0]道路标识识别", alarmEnableBits[0] == '0' ? "关闭" : "打开"); + writer.WriteEndObject(); + value.Placeholder1 = reader.ReadByte(); + writer.WriteNumber($"[{value.Placeholder1.ReadNumber()}]预留字段", value.Placeholder1); + value.DistanceThresholdObstacleAlarm = reader.ReadByte(); + writer.WriteNumber($"[{value.DistanceThresholdObstacleAlarm.ReadNumber()}]障碍物报警距离阈值", value.DistanceThresholdObstacleAlarm); + value.HierarchicalSpeedThresholdObstacleAlarm = reader.ReadByte(); + writer.WriteNumber($"[{value.HierarchicalSpeedThresholdObstacleAlarm.ReadNumber()}]障碍物报警分级速度阈值", value.HierarchicalSpeedThresholdObstacleAlarm); + value.VideoRecordingTimeBeforeAndAfterObstacleAlarm = reader.ReadByte(); + writer.WriteNumber($"[{value.VideoRecordingTimeBeforeAndAfterObstacleAlarm.ReadNumber()}]障碍物报警前后视频录制时间", value.VideoRecordingTimeBeforeAndAfterObstacleAlarm); + value.BarrierAlarmPhotographs = reader.ReadByte(); + writer.WriteNumber($"[{value.BarrierAlarmPhotographs.ReadNumber()}]障碍物报警拍照张数", value.BarrierAlarmPhotographs); + value.ObstacleAlarmInterval = reader.ReadByte(); + writer.WriteNumber($"[{value.ObstacleAlarmInterval.ReadNumber()}]障碍物报警拍照间隔", value.ObstacleAlarmInterval); + value.FrequentChannelChangeAlarmJudgmentTimePeriod = reader.ReadByte(); + writer.WriteNumber($"[{value.FrequentChannelChangeAlarmJudgmentTimePeriod.ReadNumber()}]频繁变道报警判断时间段", value.FrequentChannelChangeAlarmJudgmentTimePeriod); + value.FrequentAlarmJudgmentNumberChannelChange = reader.ReadByte(); + writer.WriteNumber($"[{value.FrequentAlarmJudgmentNumberChannelChange.ReadNumber()}]频繁变道报警判断次数", value.FrequentAlarmJudgmentNumberChannelChange); + value.HierarchicalSpeedThresholdFrequentChannelChangeAlarm = reader.ReadByte(); + writer.WriteNumber($"[{value.HierarchicalSpeedThresholdFrequentChannelChangeAlarm.ReadNumber()}]频繁变道报警分级速度阈值", value.HierarchicalSpeedThresholdFrequentChannelChangeAlarm); + value.VideoRecordingTimeBeforeAndAfterFrequentLaneChangeAlarm = reader.ReadByte(); + writer.WriteNumber($"[{value.VideoRecordingTimeBeforeAndAfterFrequentLaneChangeAlarm.ReadNumber()}]频繁变道报警前后视频录制时间", value.VideoRecordingTimeBeforeAndAfterFrequentLaneChangeAlarm); + value.FrequentChannelChangeAlarmPhotos = reader.ReadByte(); + writer.WriteNumber($"[{value.FrequentChannelChangeAlarmPhotos.ReadNumber()}]频繁变道报警拍照张数", value.FrequentChannelChangeAlarmPhotos); + value.FrequentLaneChangeAlarmInterval = reader.ReadByte(); + writer.WriteNumber($"[{value.FrequentLaneChangeAlarmInterval.ReadNumber()}]频繁变道报警拍照间隔", value.FrequentLaneChangeAlarmInterval); + value.GradedSpeedThresholdLaneDeviationAlarm = reader.ReadByte(); + writer.WriteNumber($"[{value.GradedSpeedThresholdLaneDeviationAlarm.ReadNumber()}]车道偏离报警分级速度阈值", value.GradedSpeedThresholdLaneDeviationAlarm); + value.VideoRecordingTimeBeforeAndAfterLaneDepartureAlarm = reader.ReadByte(); + writer.WriteNumber($"[{value.VideoRecordingTimeBeforeAndAfterLaneDepartureAlarm.ReadNumber()}]车道偏离报警前后视频录制时间", value.VideoRecordingTimeBeforeAndAfterLaneDepartureAlarm); + value.LaneDepartureAlarmPhoto = reader.ReadByte(); + writer.WriteNumber($"[{value.LaneDepartureAlarmPhoto.ReadNumber()}]车道偏离报警拍照张数", value.LaneDepartureAlarmPhoto); + value.LaneDepartureAlarmPhotoInterval = reader.ReadByte(); + writer.WriteNumber($"[{value.LaneDepartureAlarmPhotoInterval.ReadNumber()}]车道偏离报警拍照间隔", value.LaneDepartureAlarmPhotoInterval); + value.ForwardCollisionWarningTimeThreshold = reader.ReadByte(); + writer.WriteNumber($"[{value.ForwardCollisionWarningTimeThreshold.ReadNumber()}]前向碰撞报警时间阈值", value.ForwardCollisionWarningTimeThreshold); + value.HierarchicalSpeedThresholdForwardCollisionWarning = reader.ReadByte(); + writer.WriteNumber($"[{value.HierarchicalSpeedThresholdForwardCollisionWarning.ReadNumber()}]前向碰撞报警分级速度阈值", value.HierarchicalSpeedThresholdForwardCollisionWarning); + value.VideoRecordingTimeBeforeAndAfterForwardCollisionAlarm = reader.ReadByte(); + writer.WriteNumber($"[{value.VideoRecordingTimeBeforeAndAfterForwardCollisionAlarm.ReadNumber()}]前向碰撞报警前后视频录制时间", value.VideoRecordingTimeBeforeAndAfterForwardCollisionAlarm); + value.ForwardCollisionAlarmPhotographs = reader.ReadByte(); + writer.WriteNumber($"[{value.ForwardCollisionAlarmPhotographs.ReadNumber()}]前向碰撞报警拍照张数", value.ForwardCollisionAlarmPhotographs); + value.ForwardCollisionAlarmInterval = reader.ReadByte(); + writer.WriteNumber($"[{value.ForwardCollisionAlarmInterval.ReadNumber()}]前向碰撞报警拍照间隔", value.ForwardCollisionAlarmInterval); + value.PedestrianCollisionAlarmTimeThreshold = reader.ReadByte(); + writer.WriteNumber($"[{value.PedestrianCollisionAlarmTimeThreshold.ReadNumber()}]行人碰撞报警时间阈值", value.PedestrianCollisionAlarmTimeThreshold); + value.PedestrianCollisionAlarmEnablingSpeedThreshold = reader.ReadByte(); + writer.WriteNumber($"[{value.PedestrianCollisionAlarmEnablingSpeedThreshold.ReadNumber()}]行人碰撞报警使能速度阈值", value.PedestrianCollisionAlarmEnablingSpeedThreshold); + value.VideoRecordingTimeBeforeAndAfterPedestrianCollisionAlarm = reader.ReadByte(); + writer.WriteNumber($"[{value.VideoRecordingTimeBeforeAndAfterPedestrianCollisionAlarm.ReadNumber()}]行人碰撞报警前后视频录制时间", value.VideoRecordingTimeBeforeAndAfterPedestrianCollisionAlarm); + value.PedestrianCollisionAlarmPhotos = reader.ReadByte(); + writer.WriteNumber($"[{value.PedestrianCollisionAlarmPhotos.ReadNumber()}]行人碰撞报警拍照张数", value.PedestrianCollisionAlarmPhotos); + value.PedestrianCollisionAlarmInterval = reader.ReadByte(); + writer.WriteNumber($"[{value.PedestrianCollisionAlarmInterval.ReadNumber()}]行人碰撞报警拍照间隔", value.PedestrianCollisionAlarmInterval); + value.VehicleDistanceMonitoringAlarmDistanceThreshold = reader.ReadByte(); + writer.WriteNumber($"[{value.VehicleDistanceMonitoringAlarmDistanceThreshold.ReadNumber()}]车距监控报警距离阈值", value.VehicleDistanceMonitoringAlarmDistanceThreshold); + value.VehicleDistanceMonitoringAndAlarmClassificationSpeedThreshold = reader.ReadByte(); + writer.WriteNumber($"[{value.VehicleDistanceMonitoringAndAlarmClassificationSpeedThreshold.ReadNumber()}]车距监控报警分级速度阈值", value.VehicleDistanceMonitoringAndAlarmClassificationSpeedThreshold); + value.VideoRecordingTimeBeforeAndAfterAlarmVehicleProximity = reader.ReadByte(); + writer.WriteNumber($"[{value.VideoRecordingTimeBeforeAndAfterAlarmVehicleProximity.ReadNumber()}]车距过近报警前后视频录制时间", value.VideoRecordingTimeBeforeAndAfterAlarmVehicleProximity); + value.AlarmPhotoVehicleCloseDistance = reader.ReadByte(); + writer.WriteNumber($"[{value.AlarmPhotoVehicleCloseDistance.ReadNumber()}]车距过近报警拍照张数", value.AlarmPhotoVehicleCloseDistance); + value.AlarmPhotoVehicleCloseDistanceInterval = reader.ReadByte(); + writer.WriteNumber($"[{value.AlarmPhotoVehicleCloseDistanceInterval.ReadNumber()}]车距过近报警拍照间隔", value.AlarmPhotoVehicleCloseDistanceInterval); + value.RoadSignRecognitionPhotographs = reader.ReadByte(); + writer.WriteNumber($"[{value.RoadSignRecognitionPhotographs.ReadNumber()}]道路标志识别拍照张数", value.RoadSignRecognitionPhotographs); + value.RoadSignRecognitionPhotographsInterval = reader.ReadByte(); + writer.WriteNumber($"[{value.RoadSignRecognitionPhotographsInterval.ReadNumber()}]道路标志识别拍照间隔", value.RoadSignRecognitionPhotographsInterval); + value.Placeholder2 = reader.ReadArray(4).ToArray(); + writer.WriteString("保留字段", value.Placeholder2.ToHexString()); + } + /// + /// + /// + /// + /// + /// + public JT808_0x8103_0xF364 Deserialize(ref JT808MessagePackReader reader, IJT808Config config) + { + JT808_0x8103_0xF364 value = new JT808_0x8103_0xF364(); + value.ParamId = reader.ReadUInt32(); + value.ParamLength = reader.ReadByte(); + value.AlarmJudgeSpeedThreshold = reader.ReadByte(); + value.WarningVolume = reader.ReadByte(); + value.ActivePhotographyStrategy = reader.ReadByte(); + value.ActivelyTimePhotoInterval = reader.ReadUInt16(); + value.ActiveDistancePhotographyDistanceInterval = reader.ReadUInt16(); + value.SingleInitiativePhotos = reader.ReadByte(); + value.SingleInitiativePhotosInterval = reader.ReadByte(); + value.PhotoResolution = reader.ReadByte(); + value.VideoRecordingResolution = reader.ReadByte(); + value.AlarmEnable = reader.ReadUInt32(); + value.EventEnable = reader.ReadUInt32(); + value.Placeholder1 = reader.ReadByte(); + value.DistanceThresholdObstacleAlarm = reader.ReadByte(); + value.HierarchicalSpeedThresholdObstacleAlarm = reader.ReadByte(); + value.VideoRecordingTimeBeforeAndAfterObstacleAlarm = reader.ReadByte(); + value.BarrierAlarmPhotographs = reader.ReadByte(); + value.ObstacleAlarmInterval = reader.ReadByte(); + value.FrequentChannelChangeAlarmJudgmentTimePeriod = reader.ReadByte(); + value.FrequentAlarmJudgmentNumberChannelChange = reader.ReadByte(); + value.HierarchicalSpeedThresholdFrequentChannelChangeAlarm = reader.ReadByte(); + value.VideoRecordingTimeBeforeAndAfterFrequentLaneChangeAlarm = reader.ReadByte(); + value.FrequentChannelChangeAlarmPhotos = reader.ReadByte(); + value.FrequentLaneChangeAlarmInterval = reader.ReadByte(); + value.GradedSpeedThresholdLaneDeviationAlarm = reader.ReadByte(); + value.VideoRecordingTimeBeforeAndAfterLaneDepartureAlarm = reader.ReadByte(); + value.LaneDepartureAlarmPhoto = reader.ReadByte(); + value.LaneDepartureAlarmPhotoInterval = reader.ReadByte(); + value.ForwardCollisionWarningTimeThreshold = reader.ReadByte(); + value.HierarchicalSpeedThresholdForwardCollisionWarning = reader.ReadByte(); + value.VideoRecordingTimeBeforeAndAfterForwardCollisionAlarm = reader.ReadByte(); + value.ForwardCollisionAlarmPhotographs = reader.ReadByte(); + value.ForwardCollisionAlarmInterval = reader.ReadByte(); + value.PedestrianCollisionAlarmTimeThreshold = reader.ReadByte(); + value.PedestrianCollisionAlarmEnablingSpeedThreshold = reader.ReadByte(); + value.VideoRecordingTimeBeforeAndAfterPedestrianCollisionAlarm = reader.ReadByte(); + value.PedestrianCollisionAlarmPhotos = reader.ReadByte(); + value.PedestrianCollisionAlarmInterval = reader.ReadByte(); + value.VehicleDistanceMonitoringAlarmDistanceThreshold = reader.ReadByte(); + value.VehicleDistanceMonitoringAndAlarmClassificationSpeedThreshold = reader.ReadByte(); + value.VideoRecordingTimeBeforeAndAfterAlarmVehicleProximity = reader.ReadByte(); + value.AlarmPhotoVehicleCloseDistance = reader.ReadByte(); + value.AlarmPhotoVehicleCloseDistanceInterval = reader.ReadByte(); + value.RoadSignRecognitionPhotographs = reader.ReadByte(); + value.RoadSignRecognitionPhotographsInterval = reader.ReadByte(); + value.Placeholder2 = reader.ReadArray(4).ToArray(); + return value; + } + /// + /// + /// + /// + /// + /// + public void Serialize(ref JT808MessagePackWriter writer, JT808_0x8103_0xF364 value, IJT808Config config) + { + writer.WriteUInt32(value.ParamId); + writer.Skip(1, out int ParamLengthPosition); + writer.WriteByte(value.AlarmJudgeSpeedThreshold); + writer.WriteByte(value.WarningVolume); + writer.WriteByte(value.ActivePhotographyStrategy); + writer.WriteUInt16(value.ActivelyTimePhotoInterval); + writer.WriteUInt16(value.ActiveDistancePhotographyDistanceInterval); + writer.WriteByte(value.SingleInitiativePhotos); + writer.WriteByte(value.SingleInitiativePhotosInterval); + writer.WriteByte(value.PhotoResolution); + writer.WriteByte(value.VideoRecordingResolution); + writer.WriteUInt32(value.AlarmEnable); + writer.WriteUInt32(value.EventEnable); + writer.WriteByte(value.Placeholder1); + writer.WriteByte(value.DistanceThresholdObstacleAlarm); + writer.WriteByte(value.HierarchicalSpeedThresholdObstacleAlarm); + writer.WriteByte(value.VideoRecordingTimeBeforeAndAfterObstacleAlarm); + writer.WriteByte(value.BarrierAlarmPhotographs); + writer.WriteByte(value.ObstacleAlarmInterval); + writer.WriteByte(value.FrequentChannelChangeAlarmJudgmentTimePeriod); + writer.WriteByte(value.FrequentAlarmJudgmentNumberChannelChange); + writer.WriteByte(value.HierarchicalSpeedThresholdFrequentChannelChangeAlarm); + writer.WriteByte(value.VideoRecordingTimeBeforeAndAfterFrequentLaneChangeAlarm); + writer.WriteByte(value.FrequentChannelChangeAlarmPhotos); + writer.WriteByte(value.FrequentLaneChangeAlarmInterval); + writer.WriteByte(value.GradedSpeedThresholdLaneDeviationAlarm); + writer.WriteByte(value.VideoRecordingTimeBeforeAndAfterLaneDepartureAlarm); + writer.WriteByte(value.LaneDepartureAlarmPhoto); + writer.WriteByte(value.LaneDepartureAlarmPhotoInterval); + writer.WriteByte(value.ForwardCollisionWarningTimeThreshold); + writer.WriteByte(value.HierarchicalSpeedThresholdForwardCollisionWarning); + writer.WriteByte(value.VideoRecordingTimeBeforeAndAfterForwardCollisionAlarm); + writer.WriteByte(value.ForwardCollisionAlarmPhotographs); + writer.WriteByte(value.ForwardCollisionAlarmInterval); + writer.WriteByte(value.PedestrianCollisionAlarmTimeThreshold); + writer.WriteByte(value.PedestrianCollisionAlarmEnablingSpeedThreshold); + writer.WriteByte(value.VideoRecordingTimeBeforeAndAfterPedestrianCollisionAlarm); + writer.WriteByte(value.PedestrianCollisionAlarmPhotos); + writer.WriteByte(value.PedestrianCollisionAlarmInterval); + writer.WriteByte(value.VehicleDistanceMonitoringAlarmDistanceThreshold); + writer.WriteByte(value.VehicleDistanceMonitoringAndAlarmClassificationSpeedThreshold); + writer.WriteByte(value.VideoRecordingTimeBeforeAndAfterAlarmVehicleProximity); + writer.WriteByte(value.AlarmPhotoVehicleCloseDistance); + writer.WriteByte(value.AlarmPhotoVehicleCloseDistanceInterval); + writer.WriteByte(value.RoadSignRecognitionPhotographs); + writer.WriteByte(value.RoadSignRecognitionPhotographsInterval); + writer.WriteArray(value.Placeholder2); + writer.WriteByteReturn((byte)(writer.GetCurrentPosition() - ParamLengthPosition - 1), ParamLengthPosition); + } + } +} diff --git a/src/JT808.Protocol.Extensions/JT808.Protocol.Extensions.JTActiveSafety/MessageBody/JT808_0x8103_0xF365.cs b/src/JT808.Protocol.Extensions/JT808.Protocol.Extensions.JTActiveSafety/MessageBody/JT808_0x8103_0xF365.cs new file mode 100644 index 0000000..d082995 --- /dev/null +++ b/src/JT808.Protocol.Extensions/JT808.Protocol.Extensions.JTActiveSafety/MessageBody/JT808_0x8103_0xF365.cs @@ -0,0 +1,365 @@ +using JT808.Protocol.Extensions.JTActiveSafety.Enums; +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.JTActiveSafety.MessageBody +{ + /// + /// 驾驶员状态监测系统参数 + /// + public class JT808_0x8103_0xF365 : JT808_0x8103_BodyBase, IJT808MessagePackFormatter, IJT808Analyze + { + /// + /// 驾驶员状态监测系统参数 + /// + public override uint ParamId { get; set; } = JT808_JTActiveSafety_Constants.JT808_0X8103_0xF365; + /// + /// 驾驶员状态监测系统参数长度 + /// + public override byte ParamLength { get; set; } + /// + /// 报警判断速度阈值 + /// + public byte AlarmJudgeSpeedThreshold { get; set; } + /// + /// 报警提示音量 + /// + public byte WarningVolume { get; set; } + /// + /// 主动拍照策略 + /// + public byte ActivePhotographyStrategy { get; set; } + /// + /// 主动定时拍照时间间隔 + /// + public ushort ActivelyTimePhotoInterval { get; set; } + /// + /// 主动定距拍照距离间隔 + /// + public ushort ActiveDistancePhotographyDistanceInterval { get; set; } + /// + /// 单次主动拍照张数 + /// + public byte SingleInitiativePhotos { get; set; } + /// + /// 单次主动拍照时间间隔 + /// + public byte SingleInitiativePhotosInterval { get; set; } + /// + /// 拍照分辨率 + /// + public byte PhotoResolution { get; set; } + /// + /// 视频录制分辨率 + /// + public byte VideoRecordingResolution { get; set; } + /// + /// 报警使能 + /// + public uint AlarmEnable { get; set; } + /// + /// 事件使能 + /// + public uint EventEnable { get; set; } + /// + /// 吸烟报警判断时间间隔 + /// + public ushort TimeIntervalSmokingAlarmJudgment { get; set; } + /// + /// 接打电话报警判断时间间隔 + /// + public ushort CallAlarmDetermineTimeInterval{ get; set; } + /// + /// 预留字段 + /// + public byte[] Reserve { get; set; } = new byte[3]; + /// + /// 疲劳驾驶报警分级速度阈值 + /// + public byte GradedSpeedThresholdFatigueDrivingAlarm { get; set; } + /// + /// 疲劳驾驶报警前后视频录制时间 + /// + public byte VideoRecordingTimeBeforeAndAfterFatigueDrivingAlarm { get; set; } + /// + /// 疲劳驾驶报警拍照张数 + /// + public byte FatigueDrivingAlarmPhotograph { get; set; } + /// + /// 疲劳驾驶报警拍照间隔时间 + /// + public byte FatigueDrivingAlarmPhotographInterval { get; set; } + /// + /// 接打电话报警分级速度阈值 + /// + public byte ClassifiedSpeedThresholdCallAlarm{ get; set; } + /// + /// 接打电话报警前后视频录制时间 + /// + public byte VideoRecordingTimeBeforeAndAfterCallAlarm{ get; set; } + /// + /// 接打电话报警拍驾驶员面部特征照片张数 + /// + public byte CallAlarmTakePicturesDriverFacialFeatures{ get; set; } + /// + /// 接打电话报警拍驾驶员面部特征照片间隔时间 + /// + public byte CallAlarmTakePicturesDriverFacialFeaturesInterval { get; set; } + /// + /// 抽烟报警分级车速阈值 + /// + public byte ClassifiedSpeedThresholdSmokingAlarm{ get; set; } + /// + /// 抽烟报警前后视频录制时间 + /// + public byte VideoRecordingTimeBeforeAndAfterSmokingAlarm{ get; set; } + /// + /// 抽烟报警拍驾驶员面部特征照片张数 + /// + public byte SmokingAlarmPhotographsDriverFaceCharacteristics { get; set; } + /// + /// 抽烟报警拍驾驶员面部特征照片间隔时间 + /// + public byte SmokingAlarmPhotographsDriverFaceCharacteristicsInterval { get; set; } + /// + /// 分神驾驶报警分级车速阈值 + /// + public byte ClassifiedSpeedThresholdDistractedDrivingAlarm { get; set; } + /// + /// 分神驾驶报警拍照张数 + /// + public byte DistractedDrivingAlarmPhotography{ get; set; } + /// + /// 分神驾驶报警拍照间隔时间 + /// + public byte DistractedDrivingAlarmPhotographyInterval { get; set; } + /// + /// 驾驶行为异常视频录制时间 + /// + public byte VideoRecordingTimeAbnormalDrivingBehavior{ get; set; } + /// + /// 驾驶行为异常抓拍照片张数 + /// + public byte PhotographsAbnormalDrivingBehavior{ get; set; } + /// + /// 驾驶行为异常拍照间隔 + /// + public byte PictureIntervalAbnormalDrivingBehavior{ get; set; } + /// + /// 驾驶员身份识别触发 + /// + public byte DriverIdentificationTrigger { get; set; } + /// + /// 保留字段 + /// + public byte[] Retain { get; set; } = new byte[2]; + /// + /// + /// + /// + /// + /// + public void Analyze(ref JT808MessagePackReader reader, Utf8JsonWriter writer, IJT808Config config) + { + JT808_0x8103_0xF365 value = new JT808_0x8103_0xF365(); + value.ParamId = reader.ReadUInt32(); + value.ParamLength = reader.ReadByte(); + writer.WriteNumber($"[{value.ParamId.ReadNumber()}]参数ID", value.ParamId); + writer.WriteNumber($"[{value.ParamLength.ReadNumber()}]参数长度", value.ParamLength); + value.AlarmJudgeSpeedThreshold = reader.ReadByte(); + writer.WriteNumber($"[{value.AlarmJudgeSpeedThreshold.ReadNumber()}]报警判断速度阈值", value.AlarmJudgeSpeedThreshold); + value.WarningVolume = reader.ReadByte(); + writer.WriteNumber($"[{value.WarningVolume.ReadNumber()}]报警提示音量", value.WarningVolume); + value.ActivePhotographyStrategy = reader.ReadByte(); + var activePhotographyStrategy = (ActivePhotographyStrategyType)ActivePhotographyStrategy; + writer.WriteNumber($"[{value.ActivePhotographyStrategy.ReadNumber()}]主动拍照策略-{activePhotographyStrategy.ToString()}", value.ActivePhotographyStrategy); + value.ActivelyTimePhotoInterval = reader.ReadUInt16(); + writer.WriteNumber($"[{value.ActivelyTimePhotoInterval.ReadNumber()}]主动定时拍照时间间隔", value.ActivelyTimePhotoInterval); + value.ActiveDistancePhotographyDistanceInterval = reader.ReadUInt16(); + writer.WriteNumber($"[{value.ActiveDistancePhotographyDistanceInterval.ReadNumber()}]主动定距拍照距离间隔", value.ActiveDistancePhotographyDistanceInterval); + value.SingleInitiativePhotos = reader.ReadByte(); + writer.WriteNumber($"[{value.SingleInitiativePhotos.ReadNumber()}]单次主动拍照张数", value.SingleInitiativePhotos); + value.SingleInitiativePhotosInterval = reader.ReadByte(); + writer.WriteNumber($"[{value.SingleInitiativePhotosInterval.ReadNumber()}]单次主动拍照时间间隔", value.SingleInitiativePhotosInterval); + value.PhotoResolution = reader.ReadByte(); + var photoResolutionType = (PhotoResolutionType)value.PhotoResolution; + writer.WriteNumber($"[{value.PhotoResolution.ReadNumber()}]拍照分辨率-{photoResolutionType.ToString()}", value.PhotoResolution); + value.VideoRecordingResolution = reader.ReadByte(); + var videoRecordingResolution = (VideoRecordingResolutionType)value.VideoRecordingResolution; + writer.WriteNumber($"[{value.VideoRecordingResolution.ReadNumber()}]视频录制分辨率-{videoRecordingResolution.ToString()}", value.VideoRecordingResolution); + value.AlarmEnable = reader.ReadUInt32(); + writer.WriteNumber($"[{value.AlarmEnable.ReadNumber()}]报警使能", value.AlarmEnable); + var alarmEnableBits = Convert.ToString(value.AlarmEnable, 2).PadLeft(32, '0').AsSpan(); + writer.WriteStartObject("报警使能对象"); + writer.WriteString("[bit30~bit31]预留", alarmEnableBits.Slice(30, 2).ToString()); + writer.WriteString("[bit17~bit29]用户自定义", alarmEnableBits.Slice(17, 13).ToString()); + writer.WriteString("[bit16]道路标识超限报警", alarmEnableBits[16] == '0' ? "关闭" : "打开"); + writer.WriteString("[bit12~bit15]道路标识超限报警", alarmEnableBits.Slice(12, 4).ToString()); + writer.WriteString("[bit11]车距过近二级报警", alarmEnableBits[11] == '0' ? "关闭" : "打开"); + writer.WriteString("[bit10]车距过近一级报警", alarmEnableBits[10] == '0' ? "关闭" : "打开"); + writer.WriteString("[bit9]行人碰撞二级报警", alarmEnableBits[9] == '0' ? "关闭" : "打开"); + writer.WriteString("[bit8]行人碰撞一级报警", alarmEnableBits[8] == '0' ? "关闭" : "打开"); + writer.WriteString("[bit7]前向碰撞二级报警", alarmEnableBits[7] == '0' ? "关闭" : "打开"); + writer.WriteString("[bit6]前向碰撞一级报警", alarmEnableBits[6] == '0' ? "关闭" : "打开"); + writer.WriteString("[bit5]车道偏离二级报警", alarmEnableBits[5] == '0' ? "关闭" : "打开"); + writer.WriteString("[bit4]车道偏离一级报警", alarmEnableBits[4] == '0' ? "关闭" : "打开"); + writer.WriteString("[bit3]频繁变道二级报警", alarmEnableBits[3] == '0' ? "关闭" : "打开"); + writer.WriteString("[bit2]频繁变道一级报警", alarmEnableBits[2] == '0' ? "关闭" : "打开"); + writer.WriteString("[bit1]障碍检测二级报警", alarmEnableBits[1] == '0' ? "关闭" : "打开"); + writer.WriteString("[bit0]障碍检测一级报警", alarmEnableBits[0] == '0' ? "关闭" : "打开"); + writer.WriteEndObject(); + value.EventEnable = reader.ReadUInt32(); + writer.WriteNumber($"[{value.EventEnable.ReadNumber()}]事件使能", value.EventEnable); + var eventEnableBits = Convert.ToString(value.EventEnable, 2).PadLeft(32, '0').AsSpan(); + writer.WriteStartObject("事件使能对象"); + writer.WriteString("[bit30~bit31]预留", eventEnableBits.Slice(30, 2).ToString()); + writer.WriteString("[bit2~bit29]用户自定义", alarmEnableBits.Slice(2, 28).ToString()); + writer.WriteString("[bit1]主动拍照", alarmEnableBits[1] == '0' ? "关闭" : "打开"); + writer.WriteString("[bit0]道路标识识别", alarmEnableBits[0] == '0' ? "关闭" : "打开"); + writer.WriteEndObject(); + value.TimeIntervalSmokingAlarmJudgment = reader.ReadUInt16(); + writer.WriteNumber($"[{value.TimeIntervalSmokingAlarmJudgment.ReadNumber()}]吸烟报警判断时间间隔", value.TimeIntervalSmokingAlarmJudgment); + value.CallAlarmDetermineTimeInterval = reader.ReadUInt16(); + writer.WriteNumber($"[{value.CallAlarmDetermineTimeInterval.ReadNumber()}]接打电话报警判断时间间隔", value.CallAlarmDetermineTimeInterval); + value.Reserve = reader.ReadArray(3).ToArray(); + writer.WriteString("预留字段", value.Reserve.ToHexString()); + value.GradedSpeedThresholdFatigueDrivingAlarm = reader.ReadByte(); + writer.WriteNumber($"[{value.GradedSpeedThresholdFatigueDrivingAlarm.ReadNumber()}]疲劳驾驶报警分级速度阈值", value.GradedSpeedThresholdFatigueDrivingAlarm); + value.VideoRecordingTimeBeforeAndAfterFatigueDrivingAlarm = reader.ReadByte(); + writer.WriteNumber($"[{value.VideoRecordingTimeBeforeAndAfterFatigueDrivingAlarm.ReadNumber()}]疲劳驾驶报警前后视频录制时间", value.VideoRecordingTimeBeforeAndAfterFatigueDrivingAlarm); + value.FatigueDrivingAlarmPhotograph = reader.ReadByte(); + writer.WriteNumber($"[{value.FatigueDrivingAlarmPhotograph.ReadNumber()}]疲劳驾驶报警拍照张数", value.FatigueDrivingAlarmPhotograph); + value.FatigueDrivingAlarmPhotographInterval = reader.ReadByte(); + writer.WriteNumber($"[{value.FatigueDrivingAlarmPhotographInterval.ReadNumber()}]疲劳驾驶报警拍照间隔时间", value.FatigueDrivingAlarmPhotographInterval); + value.ClassifiedSpeedThresholdCallAlarm = reader.ReadByte(); + writer.WriteNumber($"[{value.ClassifiedSpeedThresholdCallAlarm.ReadNumber()}]接打电话报警分级速度阈值", value.ClassifiedSpeedThresholdCallAlarm); + value.VideoRecordingTimeBeforeAndAfterCallAlarm = reader.ReadByte(); + writer.WriteNumber($"[{value.VideoRecordingTimeBeforeAndAfterCallAlarm.ReadNumber()}]接打电话报警前后视频录制时间", value.VideoRecordingTimeBeforeAndAfterCallAlarm); + value.CallAlarmTakePicturesDriverFacialFeatures = reader.ReadByte(); + writer.WriteNumber($"[{value.CallAlarmTakePicturesDriverFacialFeatures.ReadNumber()}]接打电话报警拍驾驶员面部特征照片张数", value.CallAlarmTakePicturesDriverFacialFeatures); + value.CallAlarmTakePicturesDriverFacialFeaturesInterval = reader.ReadByte(); + writer.WriteNumber($"[{value.CallAlarmTakePicturesDriverFacialFeaturesInterval.ReadNumber()}]接打电话报警拍驾驶员面部特征照片间隔时间", value.CallAlarmTakePicturesDriverFacialFeaturesInterval); + value.ClassifiedSpeedThresholdSmokingAlarm = reader.ReadByte(); + writer.WriteNumber($"[{value.ClassifiedSpeedThresholdSmokingAlarm.ReadNumber()}]抽烟报警分级车速阈值", value.ClassifiedSpeedThresholdSmokingAlarm); + value.VideoRecordingTimeBeforeAndAfterSmokingAlarm = reader.ReadByte(); + writer.WriteNumber($"[{value.VideoRecordingTimeBeforeAndAfterSmokingAlarm.ReadNumber()}]抽烟报警前后视频录制时间", value.VideoRecordingTimeBeforeAndAfterSmokingAlarm); + value.SmokingAlarmPhotographsDriverFaceCharacteristics = reader.ReadByte(); + writer.WriteNumber($"[{value.SmokingAlarmPhotographsDriverFaceCharacteristics.ReadNumber()}]抽烟报警拍驾驶员面部特征照片张数", value.SmokingAlarmPhotographsDriverFaceCharacteristics); + value.SmokingAlarmPhotographsDriverFaceCharacteristicsInterval = reader.ReadByte(); + writer.WriteNumber($"[{value.SmokingAlarmPhotographsDriverFaceCharacteristicsInterval.ReadNumber()}]抽烟报警拍驾驶员面部特征照片间隔时间", value.SmokingAlarmPhotographsDriverFaceCharacteristicsInterval); + value.ClassifiedSpeedThresholdDistractedDrivingAlarm = reader.ReadByte(); + writer.WriteNumber($"[{value.ClassifiedSpeedThresholdDistractedDrivingAlarm.ReadNumber()}]分神驾驶报警分级车速阈值", value.ClassifiedSpeedThresholdDistractedDrivingAlarm); + value.DistractedDrivingAlarmPhotography = reader.ReadByte(); + writer.WriteNumber($"[{value.DistractedDrivingAlarmPhotography.ReadNumber()}]分神驾驶报警拍照张数", value.DistractedDrivingAlarmPhotography); + value.DistractedDrivingAlarmPhotographyInterval = reader.ReadByte(); + writer.WriteNumber($"[{value.DistractedDrivingAlarmPhotographyInterval.ReadNumber()}]分神驾驶报警拍照间隔时间", value.DistractedDrivingAlarmPhotographyInterval); + value.VideoRecordingTimeAbnormalDrivingBehavior = reader.ReadByte(); + writer.WriteNumber($"[{value.VideoRecordingTimeAbnormalDrivingBehavior.ReadNumber()}]驾驶行为异常视频录制时间", value.VideoRecordingTimeAbnormalDrivingBehavior); + value.PhotographsAbnormalDrivingBehavior = reader.ReadByte(); + writer.WriteNumber($"[{value.PhotographsAbnormalDrivingBehavior.ReadNumber()}]驾驶行为异常抓拍照片张数", value.PhotographsAbnormalDrivingBehavior); + value.PictureIntervalAbnormalDrivingBehavior = reader.ReadByte(); + writer.WriteNumber($"[{value.PictureIntervalAbnormalDrivingBehavior.ReadNumber()}]驾驶行为异常拍照间隔", value.PictureIntervalAbnormalDrivingBehavior); + value.DriverIdentificationTrigger = reader.ReadByte(); + writer.WriteNumber($"[{value.DriverIdentificationTrigger.ReadNumber()}]驾驶员身份识别触发", value.DriverIdentificationTrigger); + value.Retain = reader.ReadArray(reader.ReadCurrentRemainContentLength()).ToArray(); + writer.WriteString("保留字段", value.Retain.ToHexString()); + } + /// + /// + /// + /// + /// + /// + public JT808_0x8103_0xF365 Deserialize(ref JT808MessagePackReader reader, IJT808Config config) + { + JT808_0x8103_0xF365 value = new JT808_0x8103_0xF365(); + value.ParamId = reader.ReadUInt32(); + value.ParamLength = reader.ReadByte(); + value.AlarmJudgeSpeedThreshold = reader.ReadByte(); + value.WarningVolume = reader.ReadByte(); + value.ActivePhotographyStrategy = reader.ReadByte(); + value.ActivelyTimePhotoInterval = reader.ReadUInt16(); + value.ActiveDistancePhotographyDistanceInterval = reader.ReadUInt16(); + value.SingleInitiativePhotos = reader.ReadByte(); + value.SingleInitiativePhotosInterval = reader.ReadByte(); + value.PhotoResolution = reader.ReadByte(); + value.VideoRecordingResolution = reader.ReadByte(); + value.AlarmEnable = reader.ReadUInt32(); + value.EventEnable = reader.ReadUInt32(); + value.TimeIntervalSmokingAlarmJudgment = reader.ReadUInt16(); + value.CallAlarmDetermineTimeInterval = reader.ReadUInt16(); + value.Reserve = reader.ReadArray(3).ToArray(); + value.GradedSpeedThresholdFatigueDrivingAlarm = reader.ReadByte(); + value.VideoRecordingTimeBeforeAndAfterFatigueDrivingAlarm = reader.ReadByte(); + value.FatigueDrivingAlarmPhotograph = reader.ReadByte(); + value.FatigueDrivingAlarmPhotographInterval = reader.ReadByte(); + value.ClassifiedSpeedThresholdCallAlarm = reader.ReadByte(); + value.VideoRecordingTimeBeforeAndAfterCallAlarm = reader.ReadByte(); + value.CallAlarmTakePicturesDriverFacialFeatures = reader.ReadByte(); + value.CallAlarmTakePicturesDriverFacialFeaturesInterval = reader.ReadByte(); + value.ClassifiedSpeedThresholdSmokingAlarm = reader.ReadByte(); + value.VideoRecordingTimeBeforeAndAfterSmokingAlarm = reader.ReadByte(); + value.SmokingAlarmPhotographsDriverFaceCharacteristics = reader.ReadByte(); + value.SmokingAlarmPhotographsDriverFaceCharacteristicsInterval = reader.ReadByte(); + value.ClassifiedSpeedThresholdDistractedDrivingAlarm = reader.ReadByte(); + value.DistractedDrivingAlarmPhotography = reader.ReadByte(); + value.DistractedDrivingAlarmPhotographyInterval = reader.ReadByte(); + value.VideoRecordingTimeAbnormalDrivingBehavior = reader.ReadByte(); + value.PhotographsAbnormalDrivingBehavior = reader.ReadByte(); + value.PictureIntervalAbnormalDrivingBehavior = reader.ReadByte(); + value.DriverIdentificationTrigger = reader.ReadByte(); + value.Retain = reader.ReadArray(reader.ReadCurrentRemainContentLength()).ToArray(); + return value; + } + /// + /// + /// + /// + /// + /// + public void Serialize(ref JT808MessagePackWriter writer, JT808_0x8103_0xF365 value, IJT808Config config) + { + writer.WriteUInt32(value.ParamId); + writer.Skip(1, out int ParamLengthPosition); + writer.WriteByte(value.AlarmJudgeSpeedThreshold); + writer.WriteByte(value.WarningVolume); + writer.WriteByte(value.ActivePhotographyStrategy); + writer.WriteUInt16(value.ActivelyTimePhotoInterval); + writer.WriteUInt16(value.ActiveDistancePhotographyDistanceInterval); + writer.WriteByte(value.SingleInitiativePhotos); + writer.WriteByte(value.SingleInitiativePhotosInterval); + writer.WriteByte(value.PhotoResolution); + writer.WriteByte(value.VideoRecordingResolution); + writer.WriteUInt32(value.AlarmEnable); + writer.WriteUInt32(value.EventEnable); + writer.WriteUInt16(value.TimeIntervalSmokingAlarmJudgment); + writer.WriteUInt16(value.CallAlarmDetermineTimeInterval); + writer.WriteArray(value.Reserve); + writer.WriteByte(value.GradedSpeedThresholdFatigueDrivingAlarm); + writer.WriteByte(value.VideoRecordingTimeBeforeAndAfterFatigueDrivingAlarm); + writer.WriteByte(value.FatigueDrivingAlarmPhotograph); + writer.WriteByte(value.FatigueDrivingAlarmPhotographInterval); + writer.WriteByte(value.ClassifiedSpeedThresholdCallAlarm); + writer.WriteByte(value.VideoRecordingTimeBeforeAndAfterCallAlarm); + writer.WriteByte(value.CallAlarmTakePicturesDriverFacialFeatures); + writer.WriteByte(value.CallAlarmTakePicturesDriverFacialFeaturesInterval); + writer.WriteByte(value.ClassifiedSpeedThresholdSmokingAlarm); + writer.WriteByte(value.VideoRecordingTimeBeforeAndAfterSmokingAlarm); + writer.WriteByte(value.SmokingAlarmPhotographsDriverFaceCharacteristics); + writer.WriteByte(value.SmokingAlarmPhotographsDriverFaceCharacteristicsInterval); + writer.WriteByte(value.ClassifiedSpeedThresholdDistractedDrivingAlarm); + writer.WriteByte(value.DistractedDrivingAlarmPhotography); + writer.WriteByte(value.DistractedDrivingAlarmPhotographyInterval); + writer.WriteByte(value.VideoRecordingTimeAbnormalDrivingBehavior); + writer.WriteByte(value.PhotographsAbnormalDrivingBehavior); + writer.WriteByte(value.PictureIntervalAbnormalDrivingBehavior); + writer.WriteByte(value.DriverIdentificationTrigger); + writer.WriteArray(value.Retain); + writer.WriteByteReturn((byte)(writer.GetCurrentPosition() - ParamLengthPosition - 1), ParamLengthPosition); + } + } +} diff --git a/src/JT808.Protocol.Extensions/JT808.Protocol.Extensions.JTActiveSafety/MessageBody/JT808_0x8103_0xF366.cs b/src/JT808.Protocol.Extensions/JT808.Protocol.Extensions.JTActiveSafety/MessageBody/JT808_0x8103_0xF366.cs new file mode 100644 index 0000000..649c5b2 --- /dev/null +++ b/src/JT808.Protocol.Extensions/JT808.Protocol.Extensions.JTActiveSafety/MessageBody/JT808_0x8103_0xF366.cs @@ -0,0 +1,151 @@ +using JT808.Protocol.Formatters; +using JT808.Protocol.Interfaces; +using JT808.Protocol.MessageBody; +using JT808.Protocol.MessagePack; +using System.Text.Json; + +namespace JT808.Protocol.Extensions.JTActiveSafety.MessageBody +{ + /// + /// 胎压监测系统参数 + /// + public class JT808_0x8103_0xF366 : JT808_0x8103_BodyBase, IJT808MessagePackFormatter, IJT808Analyze + { + /// + /// 胎压监测系统参数Id + /// + public override uint ParamId { get; set; } = JT808_JTActiveSafety_Constants.JT808_0X8103_0xF366; + /// + /// 胎压监测系统参数长度 + /// + public override byte ParamLength { get; set; } = 46; + /// + /// 轮胎规格型号 12位 + /// + public string TyreSpecificationType { get; set; } + /// + /// 胎压单位 + /// + public ushort TyrePressureUnit { get; set; } + /// + /// 正常胎压值 + /// + public ushort NormalFetalPressure { get; set; } + /// + /// 胎压不平衡门限 + /// + public ushort ThresholdUnbalancedTirePressure { get; set; } + /// + /// 慢漏气门限 + /// + public ushort SlowLeakageThreshold { get; set; } + /// + /// 低压阈值 + /// + public ushort LowVoltageThreshold { get; set; } + /// + /// 高压阈值 + /// + public ushort HighVoltageThreshold { get; set; } + /// + /// 高温阈值 + /// + public ushort HighTemperatureThreshold { get; set; } + /// + /// 电压阈值 + /// + public ushort VoltageThreshold { get; set; } + /// + /// 定时上报时间间隔 + /// + public ushort TimedReportingInterval { get; set; } + /// + /// 保留项 + /// + public byte[] Retain { get; set; } = new byte[6]; + /// + /// + /// + /// + /// + /// + public void Analyze(ref JT808MessagePackReader reader, Utf8JsonWriter writer, IJT808Config config) + { + JT808_0x8103_0xF366 value = new JT808_0x8103_0xF366(); + value.ParamId = reader.ReadUInt32(); + value.ParamLength = reader.ReadByte(); + writer.WriteNumber($"[{value.ParamId.ReadNumber()}]参数ID", value.ParamId); + writer.WriteNumber($"[{value.ParamLength.ReadNumber()}]参数长度", value.ParamLength); + string tyreSpecificationTypeHex = reader.ReadVirtualArray(12).ToArray().ToHexString(); + value.TyreSpecificationType = reader.ReadString(12); + writer.WriteString($"[{tyreSpecificationTypeHex}]轮胎规格型号", value.TyreSpecificationType); + value.TyrePressureUnit = reader.ReadUInt16(); + writer.WriteNumber($"[{value.TyrePressureUnit.ReadNumber()}]胎压单位", value.TyrePressureUnit); + value.NormalFetalPressure = reader.ReadUInt16(); + writer.WriteNumber($"[{value.NormalFetalPressure.ReadNumber()}]正常胎压值", value.NormalFetalPressure); + value.ThresholdUnbalancedTirePressure = reader.ReadUInt16(); + writer.WriteNumber($"[{value.ThresholdUnbalancedTirePressure.ReadNumber()}]胎压不平衡门限", value.ThresholdUnbalancedTirePressure); + value.SlowLeakageThreshold = reader.ReadUInt16(); + writer.WriteNumber($"[{value.SlowLeakageThreshold.ReadNumber()}]慢漏气门限", value.SlowLeakageThreshold); + value.LowVoltageThreshold = reader.ReadUInt16(); + writer.WriteNumber($"[{value.LowVoltageThreshold.ReadNumber()}]低压阈值", value.LowVoltageThreshold); + value.HighVoltageThreshold = reader.ReadUInt16(); + writer.WriteNumber($"[{value.HighVoltageThreshold.ReadNumber()}]高压阈值", value.HighVoltageThreshold); + value.HighTemperatureThreshold = reader.ReadUInt16(); + writer.WriteNumber($"[{value.HighTemperatureThreshold.ReadNumber()}]高温阈值", value.HighTemperatureThreshold); + value.VoltageThreshold = reader.ReadUInt16(); + writer.WriteNumber($"[{value.VoltageThreshold.ReadNumber()}]电压阈值", value.VoltageThreshold); + value.TimedReportingInterval = reader.ReadUInt16(); + writer.WriteNumber($"[{value.TimedReportingInterval.ReadNumber()}]定时上报时间间隔", value.TimedReportingInterval); + value.Retain = reader.ReadArray(reader.ReadCurrentRemainContentLength()).ToArray(); + writer.WriteString("保留项", value.Retain.ToHexString()); + } + /// + /// + /// + /// + /// + /// + public JT808_0x8103_0xF366 Deserialize(ref JT808MessagePackReader reader, IJT808Config config) + { + JT808_0x8103_0xF366 value = new JT808_0x8103_0xF366(); + value.ParamId = reader.ReadUInt32(); + value.ParamLength = reader.ReadByte(); + value.TyreSpecificationType = reader.ReadString(12); + value.TyrePressureUnit = reader.ReadUInt16(); + value.NormalFetalPressure = reader.ReadUInt16(); + value.ThresholdUnbalancedTirePressure = reader.ReadUInt16(); + value.SlowLeakageThreshold = reader.ReadUInt16(); + value.LowVoltageThreshold = reader.ReadUInt16(); + value.HighVoltageThreshold = reader.ReadUInt16(); + value.HighTemperatureThreshold = reader.ReadUInt16(); + value.VoltageThreshold = reader.ReadUInt16(); + value.TimedReportingInterval = reader.ReadUInt16(); + value.Retain = reader.ReadArray(reader.ReadCurrentRemainContentLength()).ToArray(); + return value; + } + /// + /// + /// + /// + /// + /// + public void Serialize(ref JT808MessagePackWriter writer, JT808_0x8103_0xF366 value, IJT808Config config) + { + writer.WriteUInt32(value.ParamId); + writer.Skip(1, out int ParamLengthPosition); + writer.WriteString(value.TyreSpecificationType); + writer.WriteUInt16(value.TyrePressureUnit); + writer.WriteUInt16(value.NormalFetalPressure); + writer.WriteUInt16(value.ThresholdUnbalancedTirePressure); + writer.WriteUInt16(value.SlowLeakageThreshold); + writer.WriteUInt16(value.LowVoltageThreshold); + writer.WriteUInt16(value.HighVoltageThreshold); + writer.WriteUInt16(value.HighTemperatureThreshold); + writer.WriteUInt16(value.VoltageThreshold); + writer.WriteUInt16(value.TimedReportingInterval); + writer.WriteArray(value.Retain); + writer.WriteByteReturn((byte)(writer.GetCurrentPosition() - ParamLengthPosition - 1), ParamLengthPosition); + } + } +} diff --git a/src/JT808.Protocol.Extensions/JT808.Protocol.Extensions.JTActiveSafety/MessageBody/JT808_0x8103_0xF367.cs b/src/JT808.Protocol.Extensions/JT808.Protocol.Extensions.JTActiveSafety/MessageBody/JT808_0x8103_0xF367.cs new file mode 100644 index 0000000..c8b0aab --- /dev/null +++ b/src/JT808.Protocol.Extensions/JT808.Protocol.Extensions.JTActiveSafety/MessageBody/JT808_0x8103_0xF367.cs @@ -0,0 +1,77 @@ +using JT808.Protocol.Formatters; +using JT808.Protocol.Interfaces; +using JT808.Protocol.MessageBody; +using JT808.Protocol.MessagePack; +using System.Text.Json; + +namespace JT808.Protocol.Extensions.JTActiveSafety.MessageBody +{ + /// + /// 盲区监测系统参数 + /// + public class JT808_0x8103_0xF367 : JT808_0x8103_BodyBase, IJT808MessagePackFormatter, IJT808Analyze + { + /// + /// 盲区监测系统参数Id + /// + public override uint ParamId { get; set; } = JT808_JTActiveSafety_Constants.JT808_0X8103_0xF367; + /// + /// 盲区监测系统参数长度 + /// + public override byte ParamLength { get; set; } = 2; + /// + /// 后方接近报警时间阈值 + /// + public byte RearApproachAlarmTimeThreshold { get; set; } + /// + /// 侧后方接近报警时间阈值 + /// + public byte LateralRearApproachAlarmTimeThreshold { get; set; } + /// + /// + /// + /// + /// + /// + public void Analyze(ref JT808MessagePackReader reader, Utf8JsonWriter writer, IJT808Config config) + { + JT808_0x8103_0xF367 value = new JT808_0x8103_0xF367(); + value.ParamId = reader.ReadUInt32(); + value.ParamLength = reader.ReadByte(); + writer.WriteNumber($"[{ value.ParamId.ReadNumber()}]参数ID", value.ParamId); + writer.WriteNumber($"[{value.ParamLength.ReadNumber()}]参数长度", value.ParamLength); + value.RearApproachAlarmTimeThreshold = reader.ReadByte(); + writer.WriteNumber($"[{value.RearApproachAlarmTimeThreshold.ReadNumber()}]后方接近报警时间阈值", value.RearApproachAlarmTimeThreshold); + value.LateralRearApproachAlarmTimeThreshold = reader.ReadByte(); + writer.WriteNumber($"[{value.LateralRearApproachAlarmTimeThreshold.ReadNumber()}]侧后方接近报警时间阈值", value.LateralRearApproachAlarmTimeThreshold); + } + /// + /// + /// + /// + /// + /// + public JT808_0x8103_0xF367 Deserialize(ref JT808MessagePackReader reader, IJT808Config config) + { + JT808_0x8103_0xF367 value = new JT808_0x8103_0xF367(); + value.ParamId = reader.ReadUInt32(); + value.ParamLength = reader.ReadByte(); + value.RearApproachAlarmTimeThreshold = reader.ReadByte(); + value.LateralRearApproachAlarmTimeThreshold = reader.ReadByte(); + return value; + } + /// + /// + /// + /// + /// + /// + public void Serialize(ref JT808MessagePackWriter writer, JT808_0x8103_0xF367 value, IJT808Config config) + { + writer.WriteUInt32(value.ParamId); + writer.WriteByte(2); + writer.WriteByte(value.RearApproachAlarmTimeThreshold); + writer.WriteByte(value.LateralRearApproachAlarmTimeThreshold); + } + } +} diff --git a/src/JT808.Protocol.Extensions/JT808.Protocol.Extensions.JTActiveSafety/MessageBody/JT808_0x8900_0xF7.cs b/src/JT808.Protocol.Extensions/JT808.Protocol.Extensions.JTActiveSafety/MessageBody/JT808_0x8900_0xF7.cs new file mode 100644 index 0000000..bede06a --- /dev/null +++ b/src/JT808.Protocol.Extensions/JT808.Protocol.Extensions.JTActiveSafety/MessageBody/JT808_0x8900_0xF7.cs @@ -0,0 +1,89 @@ +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.JTActiveSafety.MessageBody +{ + /// + /// 查询基本信息 + /// + public class JT808_0x8900_0xF7 : JT808_0x8900_BodyBase, IJT808MessagePackFormatter, IJT808Analyze + { + /// + /// 查询基本信息类型 + /// + public override byte PassthroughType { get; set; } = JT808_JTActiveSafety_Constants.JT808_0X0900_0xF7; + /// + /// 外设ID列表总数 + /// + public byte USBCount { get; set; } + /// + /// 外设ID + /// + public List MultipleUSB { get; set; } + /// + /// + /// + /// + /// + /// + public void Analyze(ref JT808MessagePackReader reader, Utf8JsonWriter writer, IJT808Config config) + { + JT808_0x8900_0xF7 value = new JT808_0x8900_0xF7(); + value.USBCount = reader.ReadByte(); + writer.WriteNumber($"[{value.USBCount.ReadNumber()}]外设ID列表总数", value.USBCount); + if (value.USBCount > 0) + { + writer.WriteStartArray("外设ID列表"); + for (int i = 0; i < value.USBCount; i++) + { + writer.WriteStartObject(); + byte usbId = reader.ReadByte(); + writer.WriteNumber($"[{usbId.ReadNumber()}]外设ID", usbId); + writer.WriteEndObject(); + } + writer.WriteEndArray(); + } + } + /// + /// + /// + /// + /// + /// + public JT808_0x8900_0xF7 Deserialize(ref JT808MessagePackReader reader, IJT808Config config) + { + JT808_0x8900_0xF7 value = new JT808_0x8900_0xF7(); + value.USBCount = reader.ReadByte(); + if (value.USBCount > 0) + { + value.MultipleUSB = new List(); + for (int i = 0; i < value.USBCount; i++) + { + value.MultipleUSB.Add(reader.ReadByte()); + } + } + return value; + } + /// + /// + /// + /// + /// + /// + public void Serialize(ref JT808MessagePackWriter writer, JT808_0x8900_0xF7 value, IJT808Config config) + { + if (value.MultipleUSB != null && value.MultipleUSB.Count > 0) + { + writer.WriteByte((byte)value.MultipleUSB.Count); + foreach (var item in value.MultipleUSB) + { + writer.WriteByte(item); + } + } + } + } +} diff --git a/src/JT808.Protocol.Extensions/JT808.Protocol.Extensions.JTActiveSafety/MessageBody/JT808_0x8900_0xF8.cs b/src/JT808.Protocol.Extensions/JT808.Protocol.Extensions.JTActiveSafety/MessageBody/JT808_0x8900_0xF8.cs new file mode 100644 index 0000000..b7514ac --- /dev/null +++ b/src/JT808.Protocol.Extensions/JT808.Protocol.Extensions.JTActiveSafety/MessageBody/JT808_0x8900_0xF8.cs @@ -0,0 +1,89 @@ +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.JTActiveSafety.MessageBody +{ + /// + /// 查询基本信息 + /// + public class JT808_0x8900_0xF8 : JT808_0x8900_BodyBase, IJT808MessagePackFormatter, IJT808Analyze + { + /// + /// 查询基本信息透传类型 + /// + public override byte PassthroughType { get; set; } = JT808_JTActiveSafety_Constants.JT808_0X0900_0xF8; + /// + /// 外设ID列表总数 + /// + public byte USBCount { get; set; } + /// + /// 外设ID + /// + public List MultipleUSB { get; set; } + /// + /// + /// + /// + /// + /// + public void Analyze(ref JT808MessagePackReader reader, Utf8JsonWriter writer, IJT808Config config) + { + JT808_0x8900_0xF8 value = new JT808_0x8900_0xF8(); + value.USBCount = reader.ReadByte(); + writer.WriteNumber($"[{value.USBCount.ReadNumber()}]外设ID列表总数", value.USBCount); + if (value.USBCount > 0) + { + writer.WriteStartArray("外设ID列表"); + for (int i = 0; i < value.USBCount; i++) + { + writer.WriteStartObject(); + byte usbId = reader.ReadByte(); + writer.WriteNumber($"[{usbId.ReadNumber()}]外设ID", usbId); + writer.WriteEndObject(); + } + writer.WriteEndArray(); + } + } + /// + /// + /// + /// + /// + /// + public JT808_0x8900_0xF8 Deserialize(ref JT808MessagePackReader reader, IJT808Config config) + { + JT808_0x8900_0xF8 value = new JT808_0x8900_0xF8(); + value.USBCount = reader.ReadByte(); + if (value.USBCount > 0) + { + value.MultipleUSB = new List(); + for (int i = 0; i < value.USBCount; i++) + { + value.MultipleUSB.Add(reader.ReadByte()); + } + } + return value; + } + /// + /// + /// + /// + /// + /// + public void Serialize(ref JT808MessagePackWriter writer, JT808_0x8900_0xF8 value, IJT808Config config) + { + if (value.MultipleUSB != null && value.MultipleUSB.Count > 0) + { + writer.WriteByte((byte)value.MultipleUSB.Count); + foreach (var item in value.MultipleUSB) + { + writer.WriteByte(item); + } + } + } + } +} diff --git a/src/JT808.Protocol.Extensions/JT808.Protocol.Extensions.JTActiveSafety/MessageBody/JT808_0x9208.cs b/src/JT808.Protocol.Extensions/JT808.Protocol.Extensions.JTActiveSafety/MessageBody/JT808_0x9208.cs new file mode 100644 index 0000000..f34de32 --- /dev/null +++ b/src/JT808.Protocol.Extensions/JT808.Protocol.Extensions.JTActiveSafety/MessageBody/JT808_0x9208.cs @@ -0,0 +1,139 @@ +using JT808.Protocol.Extensions.JTActiveSafety.Metadata; +using JT808.Protocol.Formatters; +using JT808.Protocol.Interfaces; +using JT808.Protocol.MessagePack; +using System; +using System.Text.Json; + +namespace JT808.Protocol.Extensions.JTActiveSafety.MessageBody +{ + /// + /// 报警附件上传指令 + /// + public class JT808_0x9208: JT808Bodies, IJT808MessagePackFormatter, IJT808Analyze + { + /// + /// Description + /// + public override string Description => "报警附件上传指令"; + /// + /// 服务IP地址长度 + /// + public byte AttachmentServerIPLength { get; set; } + /// + /// 服务IP地址 + /// + public string AttachmentServerIP { get; set; } + /// + /// TCP端口 + /// + public ushort AttachmentServerIPTcpPort { get; set; } + /// + /// UDP端口 + /// + public ushort AttachmentServerIPUdpPort { get; set; } + /// + /// 报警标识号 + /// + public AlarmIdentificationProperty AlarmIdentification { get; set; } + /// + /// 平台给报警分配的唯一编号 + /// 32 + /// + public string AlarmId { get; set; } + /// + /// 预留 + /// + public byte[] Retain { get; set; } = new byte[16]; + /// + /// 报警附件上传指令Id + /// + public override ushort MsgId => 0x9208; + /// + /// + /// + /// + /// + /// + public void Analyze(ref JT808MessagePackReader reader, Utf8JsonWriter writer, IJT808Config config) + { + JT808_0x9208 value = new JT808_0x9208(); + value.AttachmentServerIPLength = reader.ReadByte(); + writer.WriteNumber($"[{value.AttachmentServerIPLength.ReadNumber()}]服务IP地址长度", value.AttachmentServerIPLength); + string attachmentServerIPHex = reader.ReadVirtualArray(value.AttachmentServerIPLength).ToArray().ToHexString(); + value.AttachmentServerIP = reader.ReadString(value.AttachmentServerIPLength); + writer.WriteString($"[{AttachmentServerIP}]服务IP地址", value.AttachmentServerIP); + value.AttachmentServerIPTcpPort = reader.ReadUInt16(); + writer.WriteNumber($"[{value.AttachmentServerIPTcpPort.ReadNumber()}]TCP端口", value.AttachmentServerIPTcpPort); + value.AttachmentServerIPUdpPort = reader.ReadUInt16(); + writer.WriteNumber($"[{value.AttachmentServerIPUdpPort.ReadNumber()}]UDP端口", value.AttachmentServerIPUdpPort); + 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); + string retainHex = reader.ReadVirtualArray(16).ToArray().ToHexString(); + writer.WriteString($"预留", retainHex); + } + /// + /// + /// + /// + /// + /// + public JT808_0x9208 Deserialize(ref JT808MessagePackReader reader, IJT808Config config) + { + JT808_0x9208 value = new JT808_0x9208(); + value.AttachmentServerIPLength = reader.ReadByte(); + value.AttachmentServerIP = reader.ReadString(value.AttachmentServerIPLength); + value.AttachmentServerIPTcpPort = reader.ReadUInt16(); + value.AttachmentServerIPUdpPort = reader.ReadUInt16(); + 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.Retain = reader.ReadArray(16).ToArray(); + return value; + } + /// + /// + /// + /// + /// + /// + public void Serialize(ref JT808MessagePackWriter writer, JT808_0x9208 value, IJT808Config config) + { + writer.Skip(1, out int AttachmentServerIPLengthPosition); + writer.WriteString(value.AttachmentServerIP); + writer.WriteByteReturn((byte)(writer.GetCurrentPosition() - AttachmentServerIPLengthPosition - 1), AttachmentServerIPLengthPosition); + writer.WriteUInt16(value.AttachmentServerIPTcpPort); + writer.WriteUInt16(value.AttachmentServerIPUdpPort); + 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.WriteArray(value.Retain); + } + } +} diff --git a/src/JT808.Protocol.Extensions/JT808.Protocol.Extensions.JTActiveSafety/MessageBody/JT808_0x9212.cs b/src/JT808.Protocol.Extensions/JT808.Protocol.Extensions.JTActiveSafety/MessageBody/JT808_0x9212.cs new file mode 100644 index 0000000..a3a667d --- /dev/null +++ b/src/JT808.Protocol.Extensions/JT808.Protocol.Extensions.JTActiveSafety/MessageBody/JT808_0x9212.cs @@ -0,0 +1,139 @@ +using JT808.Protocol.Extensions.JTActiveSafety.Metadata; +using JT808.Protocol.Formatters; +using JT808.Protocol.Interfaces; +using JT808.Protocol.MessagePack; +using System.Collections.Generic; +using System.Text.Json; + +namespace JT808.Protocol.Extensions.JTActiveSafety.MessageBody +{ + /// + /// 文件上传完成消息应答 + /// + public class JT808_0x9212: JT808Bodies, IJT808MessagePackFormatter, IJT808Analyze + { + /// + /// 文件上传完成消息应答 + /// + public override string Description => "文件上传完成消息应答"; + /// + /// 文件名称长度 + /// + public byte FileNameLength { get; set; } + /// + /// 文件名称 + /// + public string FileName { get; set; } + /// + /// 文件类型 + /// + public byte FileType { get; set; } + /// + /// 上传结果 + /// + public byte UploadResult { get; set; } + /// + /// 补传数据包数量 + /// 需要补传的数据包数量,无补传时该值为0 + /// + public byte DataPackageCount { get; set; } + /// + /// 补传数据包列表 + /// + public List DataPackages { get; set; } + /// + /// 文件上传完成消息应答Id + /// + public override ushort MsgId => 0x9212; + /// + /// + /// + /// + /// + /// + public void Analyze(ref JT808MessagePackReader reader, Utf8JsonWriter writer, IJT808Config config) + { + JT808_0x9212 value = new JT808_0x9212(); + 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.UploadResult = reader.ReadByte(); + writer.WriteNumber($"[{value.UploadResult.ReadNumber()}]上传结果", value.UploadResult); + value.DataPackageCount = reader.ReadByte(); + writer.WriteNumber($"[{value.DataPackageCount.ReadNumber()}]补传数据包数量", value.DataPackageCount); + if (value.DataPackageCount > 0) + { + writer.WriteStartArray("补传数据包列表"); + for (int i = 0; i < value.DataPackageCount; i++) + { + writer.WriteStartObject(); + DataPackageProperty dataPackageProperty = new DataPackageProperty(); + dataPackageProperty.Offset = reader.ReadUInt32(); + writer.WriteNumber($"[{dataPackageProperty.Offset.ReadNumber()}]数据偏移量", dataPackageProperty.Offset); + dataPackageProperty.Length = reader.ReadUInt32(); + writer.WriteNumber($"[{dataPackageProperty.Length.ReadNumber()}]数据长度", dataPackageProperty.Length); + writer.WriteEndObject(); + } + writer.WriteEndArray(); + } + } + /// + /// + /// + /// + /// + /// + public JT808_0x9212 Deserialize(ref JT808MessagePackReader reader, IJT808Config config) + { + JT808_0x9212 value = new JT808_0x9212(); + value.FileNameLength = reader.ReadByte(); + value.FileName = reader.ReadString(value.FileNameLength); + value.FileType = reader.ReadByte(); + value.UploadResult = reader.ReadByte(); + value.DataPackageCount = reader.ReadByte(); + if (value.DataPackageCount > 0) + { + value.DataPackages = new List(); + for (int i = 0; i < value.DataPackageCount; i++) + { + DataPackageProperty dataPackageProperty = new DataPackageProperty(); + dataPackageProperty.Offset = reader.ReadUInt32(); + dataPackageProperty.Length = reader.ReadUInt32(); + value.DataPackages.Add(dataPackageProperty); + } + } + return value; + } + /// + /// + /// + /// + /// + /// + public void Serialize(ref JT808MessagePackWriter writer, JT808_0x9212 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.WriteByte(value.UploadResult); + if (value.DataPackages != null && value.DataPackages.Count > 0) + { + writer.WriteByte((byte)value.DataPackages.Count); + foreach (var item in value.DataPackages) + { + writer.WriteUInt32(item.Offset); + writer.WriteUInt32(item.Length); + } + } + else + { + writer.WriteByte(0); + } + } + } +} diff --git a/src/JT808.Protocol.Extensions/JT808.Protocol.Extensions.JTActiveSafety/Metadata/AlarmIdentificationProperty.cs b/src/JT808.Protocol.Extensions/JT808.Protocol.Extensions.JTActiveSafety/Metadata/AlarmIdentificationProperty.cs new file mode 100644 index 0000000..085ccb0 --- /dev/null +++ b/src/JT808.Protocol.Extensions/JT808.Protocol.Extensions.JTActiveSafety/Metadata/AlarmIdentificationProperty.cs @@ -0,0 +1,34 @@ +using System; +using System.Collections.Generic; +using System.Text; + +namespace JT808.Protocol.Extensions.JTActiveSafety.Metadata +{ + /// + /// 报警标识号 + /// + public class AlarmIdentificationProperty + { + /// + /// 终端ID + /// + public string TerminalID { get; set; } + /// + /// YY-MM-DD-hh-mm-ss + /// BCD[6] + /// + public DateTime Time { get; set; } + /// + /// 序号 + /// + public byte SN { get; set; } + /// + /// 附件数量 + /// + public byte AttachCount { get; set; } + /// + /// 预留 + /// + public byte Retain { get; set; } + } +} diff --git a/src/JT808.Protocol.Extensions/JT808.Protocol.Extensions.JTActiveSafety/Metadata/AlarmOrEventProperty.cs b/src/JT808.Protocol.Extensions/JT808.Protocol.Extensions.JTActiveSafety/Metadata/AlarmOrEventProperty.cs new file mode 100644 index 0000000..91977cb --- /dev/null +++ b/src/JT808.Protocol.Extensions/JT808.Protocol.Extensions.JTActiveSafety/Metadata/AlarmOrEventProperty.cs @@ -0,0 +1,33 @@ +using System; +using System.Collections.Generic; +using System.Text; + +namespace JT808.Protocol.Extensions.JTActiveSafety.Metadata +{ + /// + /// 胎压监测系统报警/事件信息 + /// + public class AlarmOrEventProperty + { + /// + /// 胎压报警位置 + /// + public byte TirePressureAlarmPosition { get; set; } + /// + /// 报警/事件类型 + /// + public ushort AlarmOrEventType { get; set; } + /// + /// 胎压 + /// + public ushort TirePressure { get; set; } + /// + /// 胎温 + /// + public ushort TireTemperature { get; set; } + /// + /// 电池电量 + /// + public ushort BatteryLevel { get; set; } + } +} diff --git a/src/JT808.Protocol.Extensions/JT808.Protocol.Extensions.JTActiveSafety/Metadata/AttachProperty.cs b/src/JT808.Protocol.Extensions/JT808.Protocol.Extensions.JTActiveSafety/Metadata/AttachProperty.cs new file mode 100644 index 0000000..516c8e3 --- /dev/null +++ b/src/JT808.Protocol.Extensions/JT808.Protocol.Extensions.JTActiveSafety/Metadata/AttachProperty.cs @@ -0,0 +1,26 @@ +using System; +using System.Collections.Generic; +using System.Text; + +namespace JT808.Protocol.Extensions.JTActiveSafety.Metadata +{ + /// + /// 附件信息 + /// + public class AttachProperty + { + /// + /// 文件名称长度 + /// + public byte FileNameLength { get; set; } + /// + /// 文件名称 + /// 形如:文件类型_通道号_报警类型_序号_报警编号.后缀名 + /// + public string FileName{ get; set; } + /// + /// 文件大小 + /// + public uint FileSize { get; set; } + } +} diff --git a/src/JT808.Protocol.Extensions/JT808.Protocol.Extensions.JTActiveSafety/Metadata/DataPackageProperty.cs b/src/JT808.Protocol.Extensions/JT808.Protocol.Extensions.JTActiveSafety/Metadata/DataPackageProperty.cs new file mode 100644 index 0000000..f336dc2 --- /dev/null +++ b/src/JT808.Protocol.Extensions/JT808.Protocol.Extensions.JTActiveSafety/Metadata/DataPackageProperty.cs @@ -0,0 +1,21 @@ +using System; +using System.Collections.Generic; +using System.Text; + +namespace JT808.Protocol.Extensions.JTActiveSafety.Metadata +{ + /// + /// 补传数据包信息 + /// + public class DataPackageProperty + { + /// + /// 数据偏移量 + /// + public uint Offset { get; set; } + /// + /// 数据长度 + /// + public uint Length { get; set; } + } +} diff --git a/src/JT808.Protocol.Extensions/JT808.Protocol.Extensions.JTActiveSafety/Metadata/JT808_0x0900_0xF7_USB.cs b/src/JT808.Protocol.Extensions/JT808.Protocol.Extensions.JTActiveSafety/Metadata/JT808_0x0900_0xF7_USB.cs new file mode 100644 index 0000000..1f2f6de --- /dev/null +++ b/src/JT808.Protocol.Extensions/JT808.Protocol.Extensions.JTActiveSafety/Metadata/JT808_0x0900_0xF7_USB.cs @@ -0,0 +1,31 @@ +using System; +using System.Collections.Generic; +using System.Text; + +namespace JT808.Protocol.Extensions.JTActiveSafety.Metadata +{ + /// + /// + /// + public class JT808_0x0900_0xF7_USB + { + /// + /// 外设ID + /// + /// + public byte USBID { get; set; } + /// + /// 消息长度 + /// + public byte MessageLength { get; set; } + /// + /// 工作状态 + /// + /// + public byte WorkingCondition { get; set; } + /// + /// 报警状态 + /// + public uint AlarmStatus { get; set; } + } +} diff --git a/src/JT808.Protocol.Extensions/JT808.Protocol.Extensions.JTActiveSafety/Metadata/JT808_0x0900_0xF8_USB.cs b/src/JT808.Protocol.Extensions/JT808.Protocol.Extensions.JTActiveSafety/Metadata/JT808_0x0900_0xF8_USB.cs new file mode 100644 index 0000000..611538d --- /dev/null +++ b/src/JT808.Protocol.Extensions/JT808.Protocol.Extensions.JTActiveSafety/Metadata/JT808_0x0900_0xF8_USB.cs @@ -0,0 +1,72 @@ +using System; +using System.Collections.Generic; +using System.Text; + +namespace JT808.Protocol.Extensions.JTActiveSafety.Metadata +{ + /// + /// + /// + public class JT808_0x0900_0xF8_USB + { + /// + /// 外设ID + /// + /// + public byte USBID { get; set; } + /// + /// 消息长度 + /// + public byte MessageLength { get; set; } + /// + /// 公司名称长度 + /// + public byte CompantNameLength { get; set; } + /// + /// 公司名称 + /// + public string CompantName { get; set; } + /// + /// 产品型号长度 + /// + public byte ProductModelLength { get; set; } + /// + /// 产品型号 + /// + public string ProductModel { get; set; } + /// + /// 硬件版本号长度 + /// + public byte HardwareVersionNumberLength { get; set; } + /// + /// 硬件版本号 + /// ASCII + /// + public string HardwareVersionNumber { get; set; } + /// + /// 软件版本号长度 + /// + public byte SoftwareVersionNumberLength { get; set; } + /// + /// 软件版本号 + /// ASCII + /// + public string SoftwareVersionNumber { get; set; } + /// + /// 设备ID长度 + /// + public byte DevicesIDLength { get; set; } + /// + /// 设备ID + /// + public string DevicesID { get; set; } + /// + /// 客户代码长度 + /// + public byte CustomerCodeLength { get; set; } + /// + /// 客户代码 + /// + public string CustomerCode { get; set; } + } +} diff --git a/src/JT808.Protocol.sln b/src/JT808.Protocol.sln index bcc480f..35bf9f2 100644 --- a/src/JT808.Protocol.sln +++ b/src/JT808.Protocol.sln @@ -15,6 +15,16 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "JT808.Protocol.Benchmark", "JT808.Protocol.Benchmark\JT808.Protocol.Benchmark.csproj", "{04966672-8FC4-42F2-BF0F-9E367A8FC5AF}" EndProject +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Extensions", "Extensions", "{3A0EEA9A-9667-4386-BB46-4A9CB319CE30}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "JT808.Protocol.Extensions.JT1078", "JT808.Protocol.Extensions\JT808.Protocol.Extensions.JT1078\JT808.Protocol.Extensions.JT1078.csproj", "{8A18863F-44AB-4779-A501-D15C97205EA9}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "JT808.Protocol.Extensions.JT1078.Test", "JT808.Protocol.Extensions\JT808.Protocol.Extensions.JT1078.Test\JT808.Protocol.Extensions.JT1078.Test.csproj", "{852751C5-9069-4B2D-9489-C3AB1A8C6EAD}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "JT808.Protocol.Extensions.JTActiveSafety", "JT808.Protocol.Extensions\JT808.Protocol.Extensions.JTActiveSafety\JT808.Protocol.Extensions.JTActiveSafety.csproj", "{FDCB70AD-6F3D-4A48-9DB9-46D969C088FF}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "JT808.Protocol.Extensions.JTActiveSafety.Test", "JT808.Protocol.Extensions\JT808.Protocol.Extensions.JTActiveSafety.Test\JT808.Protocol.Extensions.JTActiveSafety.Test.csproj", "{A9625B48-BD87-45B1-9881-2A9F32B21B07}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -33,10 +43,32 @@ Global {04966672-8FC4-42F2-BF0F-9E367A8FC5AF}.Debug|Any CPU.Build.0 = Debug|Any CPU {04966672-8FC4-42F2-BF0F-9E367A8FC5AF}.Release|Any CPU.ActiveCfg = Release|Any CPU {04966672-8FC4-42F2-BF0F-9E367A8FC5AF}.Release|Any CPU.Build.0 = Release|Any CPU + {8A18863F-44AB-4779-A501-D15C97205EA9}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {8A18863F-44AB-4779-A501-D15C97205EA9}.Debug|Any CPU.Build.0 = Debug|Any CPU + {8A18863F-44AB-4779-A501-D15C97205EA9}.Release|Any CPU.ActiveCfg = Release|Any CPU + {8A18863F-44AB-4779-A501-D15C97205EA9}.Release|Any CPU.Build.0 = Release|Any CPU + {852751C5-9069-4B2D-9489-C3AB1A8C6EAD}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {852751C5-9069-4B2D-9489-C3AB1A8C6EAD}.Debug|Any CPU.Build.0 = Debug|Any CPU + {852751C5-9069-4B2D-9489-C3AB1A8C6EAD}.Release|Any CPU.ActiveCfg = Release|Any CPU + {852751C5-9069-4B2D-9489-C3AB1A8C6EAD}.Release|Any CPU.Build.0 = Release|Any CPU + {FDCB70AD-6F3D-4A48-9DB9-46D969C088FF}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {FDCB70AD-6F3D-4A48-9DB9-46D969C088FF}.Debug|Any CPU.Build.0 = Debug|Any CPU + {FDCB70AD-6F3D-4A48-9DB9-46D969C088FF}.Release|Any CPU.ActiveCfg = Release|Any CPU + {FDCB70AD-6F3D-4A48-9DB9-46D969C088FF}.Release|Any CPU.Build.0 = Release|Any CPU + {A9625B48-BD87-45B1-9881-2A9F32B21B07}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {A9625B48-BD87-45B1-9881-2A9F32B21B07}.Debug|Any CPU.Build.0 = Debug|Any CPU + {A9625B48-BD87-45B1-9881-2A9F32B21B07}.Release|Any CPU.ActiveCfg = Release|Any CPU + {A9625B48-BD87-45B1-9881-2A9F32B21B07}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE EndGlobalSection + GlobalSection(NestedProjects) = preSolution + {8A18863F-44AB-4779-A501-D15C97205EA9} = {3A0EEA9A-9667-4386-BB46-4A9CB319CE30} + {852751C5-9069-4B2D-9489-C3AB1A8C6EAD} = {3A0EEA9A-9667-4386-BB46-4A9CB319CE30} + {FDCB70AD-6F3D-4A48-9DB9-46D969C088FF} = {3A0EEA9A-9667-4386-BB46-4A9CB319CE30} + {A9625B48-BD87-45B1-9881-2A9F32B21B07} = {3A0EEA9A-9667-4386-BB46-4A9CB319CE30} + EndGlobalSection GlobalSection(ExtensibilityGlobals) = postSolution SolutionGuid = {D58CCAA8-ED94-4048-A6DE-55A84814DF17} EndGlobalSection