@@ -0,0 +1,31 @@ | |||
name: .NET Core | |||
on: [push] | |||
jobs: | |||
build: | |||
runs-on: ubuntu-latest | |||
steps: | |||
- uses: actions/checkout@master | |||
- name: Setup .NET Core | |||
uses: actions/setup-dotnet@master | |||
with: | |||
dotnet-version: 3.1.101 | |||
- name: dotnet info | |||
run: dotnet --info | |||
- name: dotnet restore | |||
run: dotnet restore ./src/JT1078.sln | |||
- name: dotnet JT1078.Protocol.Test build | |||
run: dotnet build ./src/JT1078.Protocol.Test/JT1078.Protocol.Test.csproj | |||
- name: dotnet JT1078.Protocol.Test test | |||
run: dotnet test ./src/JT1078.Protocol.Test/JT1078.Protocol.Test.csproj | |||
- name: dotnet JT808.Protocol.Extensions.JT1078.Test build | |||
run: dotnet build ./src/JT808.Protocol.Extensions.JT1078.Test/JT808.Protocol.Extensions.JT1078.Test.csproj | |||
- name: dotnet JT808.Protocol.Extensions.JT1078.Test test | |||
run: dotnet test ./src/JT808.Protocol.Extensions.JT1078.Test/JT808.Protocol.Extensions.JT1078.Test.csproj | |||
- name: dotnet JT809.Protocol.Extensions.JT1078.Test build | |||
run: dotnet build ./src/JT809.Protocol.Extensions.JT1078.Test/JT809.Protocol.Extensions.JT1078.Test.csproj | |||
- name: dotnet JT809.Protocol.Extensions.JT1078.Test test | |||
run: dotnet test ./src/JT809.Protocol.Extensions.JT1078.Test/JT809.Protocol.Extensions.JT1078.Test.csproj |
@@ -1,19 +0,0 @@ | |||
language: csharp | |||
solution: JT1078.sln | |||
dotnet: 3.1.100 | |||
os: linux | |||
mono: none | |||
dist: trusty2 | |||
script: | |||
- dotnet restore src/JT1078.sln | |||
- dotnet build src/JT1078.Protocol.Test/JT1078.Protocol.Test.csproj | |||
- dotnet test src/JT1078.Protocol.Test/JT1078.Protocol.Test.csproj | |||
- dotnet build src/JT808.Protocol.Extensions.JT1078.Test/JT808.Protocol.Extensions.JT1078.Test.csproj | |||
- dotnet test src/JT808.Protocol.Extensions.JT1078.Test/JT808.Protocol.Extensions.JT1078.Test.csproj | |||
- dotnet build src/JT809.Protocol.Extensions.JT1078.Test/JT809.Protocol.Extensions.JT1078.Test.csproj | |||
- dotnet test src/JT809.Protocol.Extensions.JT1078.Test/JT809.Protocol.Extensions.JT1078.Test.csproj | |||
after_success: | |||
- echo successful build! | |||
branches: | |||
only: | |||
- master |
@@ -8,7 +8,7 @@ | |||
3.1 [将1078的数据(h264)编码成FLV](#1078flv) | |||
3.2 [将1078的数据(h264)编码成HLS(尚未实现)](#1078HLS) | |||
[](https://github.com/SmallChi/JT1078/blob/master/LICENSE)[](https://travis-ci.org/SmallChi/JT1078) | |||
[](https://github.com/SmallChi/JT1078/blob/master/LICENSE)[]() | |||
## NuGet安装 | |||
@@ -21,7 +21,6 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "JT1078.Protocol.Benchmark", | |||
EndProject | |||
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{E378A80C-5708-4D0C-BA1A-73EEF08957F6}" | |||
ProjectSection(SolutionItems) = preProject | |||
..\.travis.yml = ..\.travis.yml | |||
..\README.md = ..\README.md | |||
EndProjectSection | |||
EndProject | |||
@@ -39,32 +39,33 @@ namespace JT808.Protocol.Extensions.JT1078.Test | |||
}; | |||
jT808UploadLocationRequest.JT808LocationAttachData.Add(0x14, new JT808_0x0200_0x14 | |||
{ | |||
VideoRelateAlarm = 100 | |||
VideoRelateAlarm = 100 | |||
}); | |||
jT808UploadLocationRequest.JT808LocationAttachData.Add(0x15, new JT808_0x0200_0x15 | |||
{ | |||
VideoSignalLoseAlarmStatus = 100 | |||
VideoSignalLoseAlarmStatus = 100 | |||
}); | |||
jT808UploadLocationRequest.JT808LocationAttachData.Add(0x16, new JT808_0x0200_0x16 | |||
{ | |||
VideoSignalOcclusionAlarmStatus = 100 | |||
VideoSignalOcclusionAlarmStatus = 100 | |||
}); | |||
jT808UploadLocationRequest.JT808LocationAttachData.Add(0x17, new JT808_0x0200_0x17 | |||
{ | |||
StorageFaultAlarmStatus = 100 | |||
StorageFaultAlarmStatus = 100 | |||
}); | |||
jT808UploadLocationRequest.JT808LocationAttachData.Add(0x18, new JT808_0x0200_0x18 | |||
{ | |||
AbnormalDrivingBehaviorAlarmInfo = 100 | |||
AbnormalDrivingBehaviorAlarmType = 100, | |||
FatigueLevel = 88 | |||
}); | |||
var hex = JT808Serializer.Serialize(jT808UploadLocationRequest).ToHexString(); | |||
Assert.Equal("000000010000000200BA7F0E07E4F11C0028003C00001807151010101404000000641504000000641604000000641702006418020064", hex); | |||
Assert.Equal("000000010000000200BA7F0E07E4F11C0028003C0000180715101010140400000064150400000064160400000064170200641803006458", hex); | |||
} | |||
[Fact] | |||
public void Test2() | |||
{ | |||
byte[] bodys = "000000010000000200BA7F0E07E4F11C0028003C00001807151010101404000000641504000000641604000000641702006418020064".ToHexBytes(); | |||
byte[] bodys = "000000010000000200BA7F0E07E4F11C0028003C0000180715101010140400000064150400000064160400000064170200641803006458".ToHexBytes(); | |||
JT808_0x0200 jT808UploadLocationRequest = JT808Serializer.Deserialize<JT808_0x0200>(bodys); | |||
Assert.Equal(1u, jT808UploadLocationRequest.AlarmFlag); | |||
Assert.Equal(DateTime.Parse("2018-07-15 10:10:10"), jT808UploadLocationRequest.GPSTime); | |||
@@ -76,7 +77,15 @@ namespace JT808.Protocol.Extensions.JT1078.Test | |||
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]).AbnormalDrivingBehaviorAlarmInfo); | |||
Assert.Equal(100u, ((JT808_0x0200_0x18)jT808UploadLocationRequest.JT808LocationAttachData[0x18]).AbnormalDrivingBehaviorAlarmType); | |||
Assert.Equal(88, ((JT808_0x0200_0x18)jT808UploadLocationRequest.JT808LocationAttachData[0x18]).FatigueLevel); | |||
} | |||
[Fact] | |||
public void Test3() | |||
{ | |||
byte[] bodys = "000000010000000200BA7F0E07E4F11C0028003C0000180715101010140400000064150400000064160400000064170200641803006458".ToHexBytes(); | |||
string json = JT808Serializer.Analyze<JT808_0x0200>(bodys); | |||
} | |||
} | |||
} |
@@ -0,0 +1,114 @@ | |||
using JT808.Protocol.Extensions.JT1078.MessageBody; | |||
using JT808.Protocol.Extensions.JT1078.Enums; | |||
using JT808.Protocol.MessageBody; | |||
using Microsoft.Extensions.DependencyInjection; | |||
using System; | |||
using System.Collections.Generic; | |||
using System.Text; | |||
using Xunit; | |||
namespace JT808.Protocol.Extensions.JT1078.Test | |||
{ | |||
public class JT808_0x0200Test | |||
{ | |||
JT808Serializer JT808Serializer; | |||
public JT808_0x0200Test() | |||
{ | |||
IServiceCollection serviceDescriptors1 = new ServiceCollection(); | |||
serviceDescriptors1 | |||
.AddJT808Configure() | |||
.AddJT1078Configure(); | |||
var ServiceProvider1 = serviceDescriptors1.BuildServiceProvider(); | |||
var defaultConfig = ServiceProvider1.GetRequiredService<IJT808Config>(); | |||
JT808Serializer = defaultConfig.GetSerializer(); | |||
} | |||
[Fact] | |||
public void Test_0x14_1() | |||
{ | |||
JT808_0x0200 jT808UploadLocationRequest = new JT808_0x0200 | |||
{ | |||
AlarmFlag = 1, | |||
Altitude = 40, | |||
GPSTime = DateTime.Parse("2020-01-31 20:20:20"), | |||
Lat = 12222222, | |||
Lng = 132444444, | |||
Speed = 60, | |||
Direction = 0, | |||
StatusFlag = 2, | |||
JT808LocationAttachData = new Dictionary<byte, JT808_0x0200_BodyBase>() | |||
}; | |||
jT808UploadLocationRequest.JT808LocationAttachData.Add(JT808_JT1078_Constants.JT808_0X0200_0x14, new JT808_0x0200_0x14 | |||
{ | |||
VideoRelateAlarm = (uint)(VideoRelateAlarmType.视频信号遮挡报警 | VideoRelateAlarmType.其他视频设备故障报警) | |||
}); | |||
var hex = JT808Serializer.Serialize(jT808UploadLocationRequest).ToHexString(); | |||
Assert.Equal("000000010000000200BA7F0E07E4F11C0028003C000020013120202014040000000A", hex); | |||
} | |||
[Fact] | |||
public void Test_0x14_2() | |||
{ | |||
byte[] bodys = "000000010000000200BA7F0E07E4F11C0028003C000020013120202014040000000A".ToHexBytes(); | |||
JT808_0x0200 jT808UploadLocationRequest = JT808Serializer.Deserialize<JT808_0x0200>(bodys); | |||
Assert.Equal((uint)1, jT808UploadLocationRequest.AlarmFlag); | |||
Assert.Equal(DateTime.Parse("2020-01-31 20:20:20"), jT808UploadLocationRequest.GPSTime); | |||
Assert.Equal(12222222, jT808UploadLocationRequest.Lat); | |||
Assert.Equal(132444444, jT808UploadLocationRequest.Lng); | |||
Assert.Equal(60, jT808UploadLocationRequest.Speed); | |||
Assert.Equal((uint)2, jT808UploadLocationRequest.StatusFlag); | |||
Assert.Equal((uint)(VideoRelateAlarmType.视频信号遮挡报警 | VideoRelateAlarmType.其他视频设备故障报警), ((JT808_0x0200_0x14)jT808UploadLocationRequest.JT808LocationAttachData[JT808_JT1078_Constants.JT808_0X0200_0x14]).VideoRelateAlarm); | |||
} | |||
[Fact] | |||
public void Test_0x14_3() | |||
{ | |||
byte[] bodys = "000000010000000200BA7F0E07E4F11C0028003C000020013120202014040000000A".ToHexBytes(); | |||
string json = JT808Serializer.Analyze<JT808_0x0200>(bodys); | |||
} | |||
[Fact] | |||
public void Test_0x15_1() | |||
{ | |||
JT808_0x0200 jT808UploadLocationRequest = new JT808_0x0200 | |||
{ | |||
AlarmFlag = 1, | |||
Altitude = 40, | |||
GPSTime = DateTime.Parse("2020-01-31 20:20:20"), | |||
Lat = 12222222, | |||
Lng = 132444444, | |||
Speed = 60, | |||
Direction = 0, | |||
StatusFlag = 2, | |||
JT808LocationAttachData = new Dictionary<byte, JT808_0x0200_BodyBase>() | |||
}; | |||
jT808UploadLocationRequest.JT808LocationAttachData.Add(JT808_JT1078_Constants.JT808_0X0200_0x15, new JT808_0x0200_0x15 | |||
{ | |||
VideoSignalLoseAlarmStatus=3 | |||
}); | |||
var hex = JT808Serializer.Serialize(jT808UploadLocationRequest).ToHexString(); | |||
Assert.Equal("000000010000000200BA7F0E07E4F11C0028003C0000200131202020150400000003", hex); | |||
} | |||
[Fact] | |||
public void Test_0x15_2() | |||
{ | |||
byte[] bodys = "000000010000000200BA7F0E07E4F11C0028003C0000200131202020150400000003".ToHexBytes(); | |||
JT808_0x0200 jT808UploadLocationRequest = JT808Serializer.Deserialize<JT808_0x0200>(bodys); | |||
Assert.Equal((uint)1, jT808UploadLocationRequest.AlarmFlag); | |||
Assert.Equal(DateTime.Parse("2020-01-31 20:20:20"), jT808UploadLocationRequest.GPSTime); | |||
Assert.Equal(12222222, jT808UploadLocationRequest.Lat); | |||
Assert.Equal(132444444, jT808UploadLocationRequest.Lng); | |||
Assert.Equal(60, jT808UploadLocationRequest.Speed); | |||
Assert.Equal((uint)2, jT808UploadLocationRequest.StatusFlag); | |||
Assert.Equal(3u, ((JT808_0x0200_0x15)jT808UploadLocationRequest.JT808LocationAttachData[JT808_JT1078_Constants.JT808_0X0200_0x15]).VideoSignalLoseAlarmStatus); | |||
} | |||
[Fact] | |||
public void Test_0x15_3() | |||
{ | |||
byte[] bodys = "000000010000000200BA7F0E07E4F11C0028003C0000200131202020150400000003".ToHexBytes(); | |||
string json = JT808Serializer.Analyze<JT808_0x0200>(bodys); | |||
} | |||
} | |||
} |
@@ -0,0 +1,18 @@ | |||
using System; | |||
using System.Collections.Generic; | |||
using System.Text; | |||
namespace JT808.Protocol.Extensions.JT1078.Enums | |||
{ | |||
[Flags] | |||
public enum VideoRelateAlarmType:uint | |||
{ | |||
视频信号丢失报警=0, | |||
视频信号遮挡报警=2, | |||
存储单元故障报警=4, | |||
其他视频设备故障报警=8, | |||
客车超员报警=16, | |||
异常驾驶行为报警=32, | |||
特殊报警录像达到存储阈值报警=64, | |||
} | |||
} |
@@ -15,7 +15,7 @@ | |||
<licenseUrl>https://github.com/SmallChi/JT1078/blob/master/LICENSE</licenseUrl> | |||
<license>https://github.com/SmallChi/JT1078/blob/master/LICENSE</license> | |||
<GeneratePackageOnBuild>false</GeneratePackageOnBuild> | |||
<Version>2.2.5</Version> | |||
<Version>2.2.6</Version> | |||
<PackageLicenseFile>LICENSE</PackageLicenseFile> | |||
</PropertyGroup> | |||
@@ -28,7 +28,7 @@ | |||
</PropertyGroup> | |||
<ItemGroup> | |||
<PackageReference Include="JT808" Version="2.2.5" /> | |||
<PackageReference Include="JT808" Version="2.2.6" /> | |||
</ItemGroup> | |||
<ItemGroup> | |||
@@ -78,6 +78,7 @@ | |||
<member name="P:JT808.Protocol.Extensions.JT1078.MessageBody.JT808_0x0200_0x14.VideoRelateAlarm"> | |||
<summary> | |||
视频相关报警 | |||
<see cref="T:JT808.Protocol.Extensions.JT1078.Enums.VideoRelateAlarmType"/> | |||
</summary> | |||
</member> | |||
<member name="T:JT808.Protocol.Extensions.JT1078.MessageBody.JT808_0x0200_0x15"> | |||
@@ -139,9 +140,14 @@ | |||
数据 长度 | |||
</summary> | |||
</member> | |||
<member name="P:JT808.Protocol.Extensions.JT1078.MessageBody.JT808_0x0200_0x18.AbnormalDrivingBehaviorAlarmInfo"> | |||
<member name="P:JT808.Protocol.Extensions.JT1078.MessageBody.JT808_0x0200_0x18.AbnormalDrivingBehaviorAlarmType"> | |||
<summary> | |||
异常驾驶行为报警详细描述 | |||
异常驾驶行为报警类型 | |||
</summary> | |||
</member> | |||
<member name="P:JT808.Protocol.Extensions.JT1078.MessageBody.JT808_0x0200_0x18.FatigueLevel"> | |||
<summary> | |||
疲劳程度 | |||
</summary> | |||
</member> | |||
<member name="T:JT808.Protocol.Extensions.JT1078.MessageBody.JT808_0x1003"> | |||
@@ -1,6 +1,10 @@ | |||
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 | |||
{ | |||
@@ -8,7 +12,7 @@ namespace JT808.Protocol.Extensions.JT1078.MessageBody | |||
/// 视频相关报警 | |||
/// 0x0200_0x14 | |||
/// </summary> | |||
public class JT808_0x0200_0x14 : JT808_0x0200_BodyBase, IJT808MessagePackFormatter<JT808_0x0200_0x14> | |||
public class JT808_0x0200_0x14 : JT808_0x0200_BodyBase, IJT808MessagePackFormatter<JT808_0x0200_0x14>,IJT808Analyze | |||
{ | |||
public override byte AttachInfoId { get; set; } = 0x14; | |||
/// <summary> | |||
@@ -17,16 +21,38 @@ namespace JT808.Protocol.Extensions.JT1078.MessageBody | |||
public override byte AttachInfoLength { get; set; } = 4; | |||
/// <summary> | |||
/// 视频相关报警 | |||
/// <see cref="JT808.Protocol.Extensions.JT1078.Enums.VideoRelateAlarmType"/> | |||
/// </summary> | |||
public uint VideoRelateAlarm { get; set; } | |||
public void Analyze(ref JT808MessagePackReader reader, Utf8JsonWriter writer, IJT808Config config) | |||
{ | |||
JT808_0x0200_0x14 value = new JT808_0x0200_0x14(); | |||
value.AttachInfoId = reader.ReadByte(); | |||
writer.WriteNumber($"[{value.AttachInfoId.ReadNumber()}]附加信息Id", value.AttachInfoId); | |||
value.AttachInfoLength = reader.ReadByte(); | |||
writer.WriteNumber($"[{value.AttachInfoLength.ReadNumber()}]附加信息长度", value.AttachInfoLength); | |||
value.VideoRelateAlarm = reader.ReadUInt32(); | |||
writer.WriteNumber($"[{value.VideoRelateAlarm.ReadNumber()}]视频相关报警", value.VideoRelateAlarm); | |||
var videoRelateAlarmFlags = JT808EnumExtensions.GetEnumTypes<VideoRelateAlarmType>((int)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 jT808_0x0200_0x14 = new JT808_0x0200_0x14(); | |||
jT808_0x0200_0x14.AttachInfoId = reader.ReadByte(); | |||
jT808_0x0200_0x14.AttachInfoLength = reader.ReadByte(); | |||
jT808_0x0200_0x14.VideoRelateAlarm = reader.ReadUInt32(); | |||
return jT808_0x0200_0x14; | |||
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) | |||
@@ -1,6 +1,9 @@ | |||
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 | |||
{ | |||
@@ -8,7 +11,7 @@ namespace JT808.Protocol.Extensions.JT1078.MessageBody | |||
/// 视频信号丢失报警状态 | |||
/// 0x0200_0x15 | |||
/// </summary> | |||
public class JT808_0x0200_0x15 : JT808_0x0200_BodyBase, IJT808MessagePackFormatter<JT808_0x0200_0x15> | |||
public class JT808_0x0200_0x15 : JT808_0x0200_BodyBase, IJT808MessagePackFormatter<JT808_0x0200_0x15>, IJT808Analyze | |||
{ | |||
public override byte AttachInfoId { get; set; } = 0x15; | |||
/// <summary> | |||
@@ -20,13 +23,40 @@ namespace JT808.Protocol.Extensions.JT1078.MessageBody | |||
/// </summary> | |||
public uint VideoSignalLoseAlarmStatus { get; set; } | |||
public void Analyze(ref JT808MessagePackReader reader, Utf8JsonWriter writer, IJT808Config config) | |||
{ | |||
JT808_0x0200_0x15 value = new JT808_0x0200_0x15(); | |||
value.AttachInfoId = reader.ReadByte(); | |||
writer.WriteNumber($"[{value.AttachInfoId.ReadNumber()}]附加信息Id", value.AttachInfoId); | |||
value.AttachInfoLength = reader.ReadByte(); | |||
writer.WriteNumber($"[{value.AttachInfoLength.ReadNumber()}]附加信息长度", value.AttachInfoLength); | |||
value.VideoSignalLoseAlarmStatus = reader.ReadUInt32(); | |||
writer.WriteNumber($"[{value.VideoSignalLoseAlarmStatus.ReadNumber()}]视频信号丢失报警状态", value.VideoSignalLoseAlarmStatus); | |||
var videoSignalLoseAlarmStatusSpan = Convert.ToString(value.VideoSignalLoseAlarmStatus, 2).PadLeft(32, '0').AsSpan(); | |||
writer.WriteStartArray("视频信号丢失报警状态集合"); | |||
int index = 0; | |||
foreach (var item in videoSignalLoseAlarmStatusSpan) | |||
{ | |||
if (item == '1') | |||
{ | |||
writer.WriteStringValue($"{index}通道视频信号丢失"); | |||
} | |||
else | |||
{ | |||
writer.WriteStringValue($"{index}通道视频正常"); | |||
} | |||
index++; | |||
} | |||
writer.WriteEndArray(); | |||
} | |||
public JT808_0x0200_0x15 Deserialize(ref JT808MessagePackReader reader, IJT808Config config) | |||
{ | |||
JT808_0x0200_0x15 jT808_0x0200_0x15 = new JT808_0x0200_0x15(); | |||
jT808_0x0200_0x15.AttachInfoId = reader.ReadByte(); | |||
jT808_0x0200_0x15.AttachInfoLength = reader.ReadByte(); | |||
jT808_0x0200_0x15.VideoSignalLoseAlarmStatus = reader.ReadUInt32(); | |||
return jT808_0x0200_0x15; | |||
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) | |||
@@ -1,6 +1,9 @@ | |||
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 | |||
{ | |||
@@ -8,7 +11,7 @@ namespace JT808.Protocol.Extensions.JT1078.MessageBody | |||
/// 视频信号遮挡报警状态 | |||
/// 0x0200_0x16 | |||
/// </summary> | |||
public class JT808_0x0200_0x16 : JT808_0x0200_BodyBase, IJT808MessagePackFormatter<JT808_0x0200_0x16> | |||
public class JT808_0x0200_0x16 : JT808_0x0200_BodyBase, IJT808MessagePackFormatter<JT808_0x0200_0x16>, IJT808Analyze | |||
{ | |||
public override byte AttachInfoId { get; set; } = 0x16; | |||
/// <summary> | |||
@@ -20,13 +23,40 @@ namespace JT808.Protocol.Extensions.JT1078.MessageBody | |||
/// </summary> | |||
public uint VideoSignalOcclusionAlarmStatus { get; set; } | |||
public void Analyze(ref JT808MessagePackReader reader, Utf8JsonWriter writer, IJT808Config config) | |||
{ | |||
JT808_0x0200_0x16 value = new JT808_0x0200_0x16(); | |||
value.AttachInfoId = reader.ReadByte(); | |||
writer.WriteNumber($"[{value.AttachInfoId.ReadNumber()}]附加信息Id", value.AttachInfoId); | |||
value.AttachInfoLength = reader.ReadByte(); | |||
writer.WriteNumber($"[{value.AttachInfoLength.ReadNumber()}]附加信息长度", value.AttachInfoLength); | |||
value.VideoSignalOcclusionAlarmStatus = reader.ReadUInt32(); | |||
writer.WriteNumber($"[{value.VideoSignalOcclusionAlarmStatus.ReadNumber()}]视频信号遮挡报警状态", value.VideoSignalOcclusionAlarmStatus); | |||
var videoSignalOcclusionAlarmStatusSpan = Convert.ToString(value.VideoSignalOcclusionAlarmStatus, 2).PadLeft(32, '0').AsSpan(); | |||
writer.WriteStartArray("视频信号遮挡报警状态集合"); | |||
int index = 0; | |||
foreach (var item in videoSignalOcclusionAlarmStatusSpan) | |||
{ | |||
if (item == '1') | |||
{ | |||
writer.WriteStringValue($"{index}通道视频信号遮挡"); | |||
} | |||
else | |||
{ | |||
writer.WriteStringValue($"{index}通道视频正常"); | |||
} | |||
index++; | |||
} | |||
writer.WriteEndArray(); | |||
} | |||
public JT808_0x0200_0x16 Deserialize(ref JT808MessagePackReader reader, IJT808Config config) | |||
{ | |||
JT808_0x0200_0x16 jT808_0x0200_0x16 = new JT808_0x0200_0x16(); | |||
jT808_0x0200_0x16.AttachInfoId = reader.ReadByte(); | |||
jT808_0x0200_0x16.AttachInfoLength = reader.ReadByte(); | |||
jT808_0x0200_0x16.VideoSignalOcclusionAlarmStatus = reader.ReadUInt32(); | |||
return jT808_0x0200_0x16; | |||
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) | |||
@@ -1,6 +1,9 @@ | |||
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 | |||
{ | |||
@@ -8,7 +11,7 @@ namespace JT808.Protocol.Extensions.JT1078.MessageBody | |||
/// 存储器故障报警状态 | |||
/// 0x0200_0x17 | |||
/// </summary> | |||
public class JT808_0x0200_0x17 : JT808_0x0200_BodyBase, IJT808MessagePackFormatter<JT808_0x0200_0x17> | |||
public class JT808_0x0200_0x17 : JT808_0x0200_BodyBase, IJT808MessagePackFormatter<JT808_0x0200_0x17>, IJT808Analyze | |||
{ | |||
public override byte AttachInfoId { get; set; } = 0x17; | |||
/// <summary> | |||
@@ -20,13 +23,54 @@ namespace JT808.Protocol.Extensions.JT1078.MessageBody | |||
/// </summary> | |||
public ushort StorageFaultAlarmStatus{ get; set; } | |||
public void Analyze(ref JT808MessagePackReader reader, Utf8JsonWriter writer, IJT808Config config) | |||
{ | |||
JT808_0x0200_0x17 value = new JT808_0x0200_0x17(); | |||
value.AttachInfoId = reader.ReadByte(); | |||
writer.WriteNumber($"[{value.AttachInfoId.ReadNumber()}]附加信息Id", value.AttachInfoId); | |||
value.AttachInfoLength = reader.ReadByte(); | |||
writer.WriteNumber($"[{value.AttachInfoLength.ReadNumber()}]附加信息长度", value.AttachInfoLength); | |||
value.StorageFaultAlarmStatus = reader.ReadUInt16(); | |||
writer.WriteNumber($"[{value.StorageFaultAlarmStatus.ReadNumber()}]存储器故障报警状态", value.StorageFaultAlarmStatus); | |||
var storageFaultAlarmStatusSpan = Convert.ToString(value.StorageFaultAlarmStatus, 2).PadLeft(16, '0').AsSpan(); | |||
writer.WriteStartArray("存储器故障报警状态集合"); | |||
int index = 0; | |||
foreach (var item in storageFaultAlarmStatusSpan) | |||
{ | |||
if (index < 4) | |||
{ | |||
if (item == '1') | |||
{ | |||
writer.WriteStringValue($"{index}灾备存储装置故障"); | |||
} | |||
else | |||
{ | |||
writer.WriteStringValue($"{index}灾备存储装置正常"); | |||
} | |||
} | |||
else | |||
{ | |||
if (item == '1') | |||
{ | |||
writer.WriteStringValue($"{index}主存储器故障"); | |||
} | |||
else | |||
{ | |||
writer.WriteStringValue($"{index}主存储器正常"); | |||
} | |||
} | |||
index++; | |||
} | |||
writer.WriteEndArray(); | |||
} | |||
public JT808_0x0200_0x17 Deserialize(ref JT808MessagePackReader reader, IJT808Config config) | |||
{ | |||
JT808_0x0200_0x17 jT808_0x0200_0x17 = new JT808_0x0200_0x17(); | |||
jT808_0x0200_0x17.AttachInfoId = reader.ReadByte(); | |||
jT808_0x0200_0x17.AttachInfoLength = reader.ReadByte(); | |||
jT808_0x0200_0x17.StorageFaultAlarmStatus = reader.ReadUInt16(); | |||
return jT808_0x0200_0x17; | |||
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) | |||
@@ -1,6 +1,9 @@ | |||
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 | |||
{ | |||
@@ -8,31 +11,80 @@ namespace JT808.Protocol.Extensions.JT1078.MessageBody | |||
/// 异常驾驶行为报警详细描述 | |||
/// 0x0200_0x18 | |||
/// </summary> | |||
public class JT808_0x0200_0x18 : JT808_0x0200_BodyBase, IJT808MessagePackFormatter<JT808_0x0200_0x18> | |||
public class JT808_0x0200_0x18 : JT808_0x0200_BodyBase, IJT808MessagePackFormatter<JT808_0x0200_0x18>, IJT808Analyze | |||
{ | |||
public override byte AttachInfoId { get; set; } = 0x18; | |||
/// <summary> | |||
/// 数据 长度 | |||
/// </summary> | |||
public override byte AttachInfoLength { get; set; } = 2; | |||
public override byte AttachInfoLength { get; set; } = 3; | |||
/// <summary> | |||
/// 异常驾驶行为报警详细描述 | |||
/// 异常驾驶行为报警类型 | |||
/// </summary> | |||
public ushort AbnormalDrivingBehaviorAlarmInfo { get; set; } | |||
public ushort AbnormalDrivingBehaviorAlarmType{ get; set; } | |||
/// <summary> | |||
/// 疲劳程度 | |||
/// </summary> | |||
public byte FatigueLevel { get; set; } | |||
public void Analyze(ref JT808MessagePackReader reader, Utf8JsonWriter writer, IJT808Config config) | |||
{ | |||
JT808_0x0200_0x18 value = new JT808_0x0200_0x18(); | |||
value.AttachInfoId = reader.ReadByte(); | |||
writer.WriteNumber($"[{value.AttachInfoId.ReadNumber()}]附加信息Id", value.AttachInfoId); | |||
value.AttachInfoLength = reader.ReadByte(); | |||
writer.WriteNumber($"[{value.AttachInfoLength.ReadNumber()}]附加信息长度", value.AttachInfoLength); | |||
value.AbnormalDrivingBehaviorAlarmType = reader.ReadUInt16(); | |||
writer.WriteNumber($"[{value.AbnormalDrivingBehaviorAlarmType.ReadNumber()}]异常驾驶行为报警类型", value.AbnormalDrivingBehaviorAlarmType); | |||
writer.WriteStartArray("视频信号遮挡报警状态集合"); | |||
var abnormalDrivingBehaviorAlarmTypeSpan = Convert.ToString(value.AbnormalDrivingBehaviorAlarmType, 2).PadLeft(16, '0').AsSpan(); | |||
int index = 0; | |||
foreach (var item in abnormalDrivingBehaviorAlarmTypeSpan) | |||
{ | |||
string tmpResult = item == '1' ? "有" : "无"; | |||
if (index == 0) | |||
{ | |||
writer.WriteStringValue($"[bit{index}疲劳]_{tmpResult}"); | |||
} | |||
else if (index == 1) | |||
{ | |||
writer.WriteStringValue($"[bit{index}打电话]_{tmpResult}"); | |||
} | |||
else if (index == 2) | |||
{ | |||
writer.WriteStringValue($"[bit{index}抽烟]_{tmpResult}"); | |||
} | |||
else if (index>=3 && index<=10) | |||
{ | |||
writer.WriteStringValue($"[bit{index}保留]_{tmpResult}"); | |||
} | |||
else | |||
{ | |||
writer.WriteStringValue($"[bit{index}自定义]_{tmpResult}"); | |||
} | |||
index++; | |||
} | |||
writer.WriteEndArray(); | |||
value.FatigueLevel = reader.ReadByte(); | |||
writer.WriteNumber($"[{value.FatigueLevel.ReadNumber()}]疲劳程度", value.FatigueLevel); | |||
} | |||
public JT808_0x0200_0x18 Deserialize(ref JT808MessagePackReader reader, IJT808Config config) | |||
{ | |||
JT808_0x0200_0x18 jT808_0x0200_0x18 = new JT808_0x0200_0x18(); | |||
jT808_0x0200_0x18.AttachInfoId = reader.ReadByte(); | |||
jT808_0x0200_0x18.AttachInfoLength = reader.ReadByte(); | |||
jT808_0x0200_0x18.AbnormalDrivingBehaviorAlarmInfo = reader.ReadUInt16(); | |||
return jT808_0x0200_0x18; | |||
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.AbnormalDrivingBehaviorAlarmInfo); | |||
writer.WriteUInt16(value.AbnormalDrivingBehaviorAlarmType); | |||
writer.WriteByte(value.FatigueLevel); | |||
} | |||
} | |||
} |