@@ -211,6 +211,13 @@ namespace JT808.Protocol.Test.MessageBody | |||||
Assert.Equal(75, jT808_0X8606.InflectionPointItems[1].SectionWidth); | Assert.Equal(75, jT808_0X8606.InflectionPointItems[1].SectionWidth); | ||||
} | } | ||||
[Fact] | |||||
public void Test5() | |||||
{ | |||||
byte[] bytes = "0000270F00331811200000121811210000120002000003E800000507075BCD15075BCD1438030032007B004517000003E900002EE7075BCD0C075BCD0D4B03003A007C002A1A".ToHexBytes(); | |||||
string json = JT808Serializer.Analyze<JT808_0x8606>(bytes); | |||||
} | |||||
[Fact] | [Fact] | ||||
public void Test5_2019() | public void Test5_2019() | ||||
{ | { | ||||
@@ -0,0 +1,21 @@ | |||||
using System; | |||||
using System.Collections.Generic; | |||||
using System.Text; | |||||
namespace JT808.Protocol.Enums | |||||
{ | |||||
/// <summary> | |||||
/// 摄像头分辨率 | |||||
/// </summary> | |||||
public enum JT808CameraResolutionType:byte | |||||
{ | |||||
x320_240 = 0x01, | |||||
x640_480 = 0x02, | |||||
x800_600 = 0x03, | |||||
x1020_768 = 0x04, | |||||
x176_144_Qcif = 0x05, | |||||
x352_288_Cif = 0x06, | |||||
x704_288_HALF_D1 = 0x07, | |||||
x704_576_D1 = 0x07, | |||||
} | |||||
} |
@@ -200,9 +200,7 @@ namespace JT808.Protocol.MessageBody | |||||
writer.WriteString($"[bit0]{areaPropertyBits[0]}", areaPropertyBits[0] == '1' ? "根据时间" : "无"); | writer.WriteString($"[bit0]{areaPropertyBits[0]}", areaPropertyBits[0] == '1' ? "根据时间" : "无"); | ||||
} | } | ||||
writer.WriteEndObject(); | writer.WriteEndObject(); | ||||
ReadOnlySpan<char> areaProperty16Bit = Convert.ToString(value.AreaProperty, 2).PadLeft(16, '0').AsSpan(); | |||||
bool bit0Flag = areaProperty16Bit.Slice(areaProperty16Bit.Length - 1).ToString().Equals("0"); | |||||
bool bit0Flag = areaPropertyBits.Slice(areaPropertyBits.Length - 1).ToString().Equals("0"); | |||||
if (!bit0Flag) | if (!bit0Flag) | ||||
{ | { | ||||
value.StartTime = reader.ReadDateTime6(); | value.StartTime = reader.ReadDateTime6(); | ||||
@@ -210,7 +208,7 @@ namespace JT808.Protocol.MessageBody | |||||
value.EndTime = reader.ReadDateTime6(); | value.EndTime = reader.ReadDateTime6(); | ||||
writer.WriteString($"[{ value.EndTime.Value.ToString("yyMMddHHmmss")}]结束时间", value.EndTime.Value.ToString("yyyy-MM-dd HH:mm:ss")); | writer.WriteString($"[{ value.EndTime.Value.ToString("yyMMddHHmmss")}]结束时间", value.EndTime.Value.ToString("yyyy-MM-dd HH:mm:ss")); | ||||
} | } | ||||
bool bit1Flag = areaProperty16Bit.Slice(areaProperty16Bit.Length - 2, 1).ToString().Equals("0"); | |||||
bool bit1Flag = areaPropertyBits.Slice(areaPropertyBits.Length - 2, 1).ToString().Equals("0"); | |||||
if (!bit1Flag) | if (!bit1Flag) | ||||
{ | { | ||||
value.HighestSpeed = reader.ReadUInt16(); | value.HighestSpeed = reader.ReadUInt16(); | ||||
@@ -169,6 +169,28 @@ namespace JT808.Protocol.MessageBody | |||||
value.RouteProperty = reader.ReadUInt16(); | value.RouteProperty = reader.ReadUInt16(); | ||||
writer.WriteNumber($"[{ value.RouteProperty.ReadNumber()}]路线属性", value.RouteProperty); | writer.WriteNumber($"[{ value.RouteProperty.ReadNumber()}]路线属性", value.RouteProperty); | ||||
ReadOnlySpan<char> routeProperty16Bit = Convert.ToString(value.RouteProperty, 2).PadLeft(16, '0').AsSpan(); | ReadOnlySpan<char> routeProperty16Bit = Convert.ToString(value.RouteProperty, 2).PadLeft(16, '0').AsSpan(); | ||||
writer.WriteStartObject($"路线属性对象[{routeProperty16Bit.ToString()}]"); | |||||
if (reader.Version == JT808Version.JTT2019) | |||||
{ | |||||
writer.WriteString($"[bit6~bit15]保留", routeProperty16Bit.Slice(6,10).ToString()); | |||||
writer.WriteString($"[bit5]出路线是否报警给平台-{routeProperty16Bit[5]}", routeProperty16Bit[5] == '0' ? "否" : "是"); | |||||
writer.WriteString($"[bit4]出路线是否报警给平驾驶员-{routeProperty16Bit[4]}", routeProperty16Bit[4] == '0' ? "否" : "是"); | |||||
writer.WriteString($"[bit3]进路线是否报警给平台-{routeProperty16Bit[3]}", routeProperty16Bit[3] == '0' ? "否" : "是"); | |||||
writer.WriteString($"[bit2]进路线是否报警给驾驶员-{routeProperty16Bit[2]}", routeProperty16Bit[2] == '0' ? "否" : "是"); | |||||
writer.WriteString($"[bit1]保留", routeProperty16Bit[1] == '0' ? "否" : "是"); | |||||
writer.WriteString($"[bit0]是否启用起始时间与结束时间的判断规则-{routeProperty16Bit[0]}", routeProperty16Bit[0] == '0' ? "否" : "是"); | |||||
} | |||||
else | |||||
{ | |||||
writer.WriteString($"[bit6~bit15]保留", routeProperty16Bit.Slice(6, 10).ToString()); | |||||
writer.WriteString($"[bit5]{routeProperty16Bit[5]}", routeProperty16Bit[5] == '1' ? "出路线报警给平台" : "无"); | |||||
writer.WriteString($"[bit4]{routeProperty16Bit[4]}", routeProperty16Bit[4] == '1' ? "出路线报警给驾驶员" : "无"); | |||||
writer.WriteString($"[bit3]{routeProperty16Bit[3]}", routeProperty16Bit[3] == '1' ? "进路线报警给平台" : "无"); | |||||
writer.WriteString($"[bit2]{routeProperty16Bit[2]}", routeProperty16Bit[2] == '1' ? "进路线报警给驾驶员" : "无"); | |||||
writer.WriteString($"[bit1]保留", $"{routeProperty16Bit[1]}"); | |||||
writer.WriteString($"[bit0]{routeProperty16Bit[0]}", routeProperty16Bit[0] == '1' ? "根据时间" : "无"); | |||||
} | |||||
writer.WriteEndObject(); | |||||
bool bit0Flag = routeProperty16Bit.Slice(routeProperty16Bit.Length - 1).ToString().Equals("0"); | bool bit0Flag = routeProperty16Bit.Slice(routeProperty16Bit.Length - 1).ToString().Equals("0"); | ||||
if (!bit0Flag) | if (!bit0Flag) | ||||
{ | { | ||||
@@ -196,8 +218,15 @@ namespace JT808.Protocol.MessageBody | |||||
writer.WriteNumber($"[{ jT808InflectionPointProperty.SectionWidth.ReadNumber()}]路段宽度", jT808InflectionPointProperty.SectionWidth); | writer.WriteNumber($"[{ jT808InflectionPointProperty.SectionWidth.ReadNumber()}]路段宽度", jT808InflectionPointProperty.SectionWidth); | ||||
jT808InflectionPointProperty.SectionProperty = reader.ReadByte(); | jT808InflectionPointProperty.SectionProperty = reader.ReadByte(); | ||||
writer.WriteNumber($"[{ jT808InflectionPointProperty.SectionProperty.ReadNumber()}]路段属性", jT808InflectionPointProperty.SectionProperty); | writer.WriteNumber($"[{ jT808InflectionPointProperty.SectionProperty.ReadNumber()}]路段属性", jT808InflectionPointProperty.SectionProperty); | ||||
ReadOnlySpan<char> sectionProperty16Bit = Convert.ToString(jT808InflectionPointProperty.SectionProperty, 2).PadLeft(16, '0').AsSpan(); | |||||
bool sectionBit0Flag = sectionProperty16Bit.Slice(sectionProperty16Bit.Length - 1).ToString().Equals("0"); | |||||
ReadOnlySpan<char> sectionProperty8Bit = Convert.ToString(jT808InflectionPointProperty.SectionProperty, 2).PadLeft(8, '0').AsSpan(); | |||||
writer.WriteStartObject($"路段属性对象[{sectionProperty8Bit.ToString()}]"); | |||||
writer.WriteString($"[bit4~bit7]保留", sectionProperty8Bit.Slice(4, 4).ToString()); | |||||
writer.WriteString($"[bit3]进路线是否报警给平台-{sectionProperty8Bit[3]}", sectionProperty8Bit[3] == '0' ? "无" : "限速"); | |||||
writer.WriteString($"[bit2]进路线是否报警给驾驶员-{sectionProperty8Bit[2]}", sectionProperty8Bit[2] == '0' ? "北纬" : "南纬"); | |||||
writer.WriteString($"[bit1]{sectionProperty8Bit[1]}", sectionProperty8Bit[1] == '0' ? "东经" : "西经"); | |||||
writer.WriteString($"[bit0]{sectionProperty8Bit[0]}", sectionProperty8Bit[0] == '0' ? "无" : "行驶时间"); | |||||
writer.WriteEndObject(); | |||||
bool sectionBit0Flag = sectionProperty8Bit.Slice(sectionProperty8Bit.Length - 1).ToString().Equals("0"); | |||||
if (!sectionBit0Flag) | if (!sectionBit0Flag) | ||||
{ | { | ||||
jT808InflectionPointProperty.SectionLongDrivingThreshold = reader.ReadUInt16(); | jT808InflectionPointProperty.SectionLongDrivingThreshold = reader.ReadUInt16(); | ||||
@@ -205,7 +234,7 @@ namespace JT808.Protocol.MessageBody | |||||
jT808InflectionPointProperty.SectionDrivingUnderThreshold = reader.ReadUInt16(); | jT808InflectionPointProperty.SectionDrivingUnderThreshold = reader.ReadUInt16(); | ||||
writer.WriteNumber($"[{ jT808InflectionPointProperty.SectionDrivingUnderThreshold.Value.ReadNumber()}]路段行驶不足阈值", jT808InflectionPointProperty.SectionDrivingUnderThreshold.Value); | writer.WriteNumber($"[{ jT808InflectionPointProperty.SectionDrivingUnderThreshold.Value.ReadNumber()}]路段行驶不足阈值", jT808InflectionPointProperty.SectionDrivingUnderThreshold.Value); | ||||
} | } | ||||
bool sectionBit1Flag = sectionProperty16Bit.Slice(sectionProperty16Bit.Length - 2, 1).ToString().Equals("0"); | |||||
bool sectionBit1Flag = sectionProperty8Bit.Slice(sectionProperty8Bit.Length - 2, 1).ToString().Equals("0"); | |||||
if (!sectionBit1Flag) | if (!sectionBit1Flag) | ||||
{ | { | ||||
jT808InflectionPointProperty.SectionHighestSpeed = reader.ReadUInt16(); | jT808InflectionPointProperty.SectionHighestSpeed = reader.ReadUInt16(); | ||||
@@ -1,4 +1,5 @@ | |||||
using JT808.Protocol.Extensions; | |||||
using JT808.Protocol.Enums; | |||||
using JT808.Protocol.Extensions; | |||||
using JT808.Protocol.Formatters; | using JT808.Protocol.Formatters; | ||||
using JT808.Protocol.Interfaces; | using JT808.Protocol.Interfaces; | ||||
using JT808.Protocol.MessagePack; | using JT808.Protocol.MessagePack; | ||||
@@ -35,14 +36,7 @@ namespace JT808.Protocol.MessageBody | |||||
public byte SaveFlag { get; set; } | public byte SaveFlag { get; set; } | ||||
/// <summary> | /// <summary> | ||||
/// 分辨率 | /// 分辨率 | ||||
/// 0x01:320*240; | |||||
/// 0x02:640*480; | |||||
/// 0x03:800*600; | |||||
/// 0x04:1024*768; | |||||
/// 0x05:176*144;[Qcif]; | |||||
/// 0x06:352*288;[Cif]; | |||||
/// 0x07:704*288;[HALF D1]; | |||||
/// 0x08:704*576;[D1]; | |||||
/// <see cref="JT808.Protocol.Enums.JT808CameraResolutionType"/> | |||||
/// </summary> | /// </summary> | ||||
public byte Resolution { get; set; } | public byte Resolution { get; set; } | ||||
/// <summary> | /// <summary> | ||||
@@ -104,22 +98,22 @@ namespace JT808.Protocol.MessageBody | |||||
public void Analyze(ref JT808MessagePackReader reader, Utf8JsonWriter writer, IJT808Config config) | public void Analyze(ref JT808MessagePackReader reader, Utf8JsonWriter writer, IJT808Config config) | ||||
{ | { | ||||
JT808_0x8801 value = new JT808_0x8801(); | JT808_0x8801 value = new JT808_0x8801(); | ||||
value.ChannelId = reader.ReadByte(); | |||||
value.ShootingCommand = reader.ReadUInt16(); | |||||
value.VideoTime = reader.ReadUInt16(); | |||||
value.SaveFlag = reader.ReadByte(); | |||||
value.Resolution = reader.ReadByte(); | |||||
value.VideoQuality = reader.ReadByte(); | |||||
value.Lighting = reader.ReadByte(); | |||||
value.Contrast = reader.ReadByte(); | |||||
value.Saturability = reader.ReadByte(); | |||||
value.Chroma = reader.ReadByte(); | |||||
value.ChannelId = reader.ReadByte(); | |||||
value.ShootingCommand = reader.ReadUInt16(); | |||||
value.VideoTime = reader.ReadUInt16(); | |||||
value.SaveFlag = reader.ReadByte(); | |||||
value.Resolution = reader.ReadByte(); | |||||
value.VideoQuality = reader.ReadByte(); | |||||
value.Lighting = reader.ReadByte(); | |||||
value.Contrast = reader.ReadByte(); | |||||
value.Saturability = reader.ReadByte(); | |||||
value.Chroma = reader.ReadByte(); | |||||
JT808CameraResolutionType jT808CameraResolutionType = (JT808CameraResolutionType)value.Resolution; | |||||
writer.WriteNumber($"[{ value.ChannelId.ReadNumber()}]通道ID", value.ChannelId); | writer.WriteNumber($"[{ value.ChannelId.ReadNumber()}]通道ID", value.ChannelId); | ||||
writer.WriteNumber($"[{ value.ShootingCommand.ReadNumber()}]拍摄命令", value.ShootingCommand); | writer.WriteNumber($"[{ value.ShootingCommand.ReadNumber()}]拍摄命令", value.ShootingCommand); | ||||
writer.WriteNumber($"[{ value.VideoTime.ReadNumber()}]拍照间隔_录像时间", value.VideoTime); | writer.WriteNumber($"[{ value.VideoTime.ReadNumber()}]拍照间隔_录像时间", value.VideoTime); | ||||
writer.WriteNumber($"[{ value.SaveFlag.ReadNumber()}]保存标志", value.SaveFlag); | |||||
writer.WriteNumber($"[{ value.Resolution.ReadNumber()}]分辨率", value.Resolution); | |||||
writer.WriteString($"[{ value.SaveFlag.ReadNumber()}]保存标志-{value.SaveFlag}", value.SaveFlag==1? "保存" : "实时上传"); | |||||
writer.WriteNumber($"[{ value.Resolution.ReadNumber()}]分辨率-{jT808CameraResolutionType.ToString()}", value.Resolution); | |||||
writer.WriteNumber($"[{ value.VideoQuality.ReadNumber()}]图像_视频质量", value.VideoQuality); | writer.WriteNumber($"[{ value.VideoQuality.ReadNumber()}]图像_视频质量", value.VideoQuality); | ||||
writer.WriteNumber($"[{ value.Lighting.ReadNumber()}]亮度", value.Lighting); | writer.WriteNumber($"[{ value.Lighting.ReadNumber()}]亮度", value.Lighting); | ||||
writer.WriteNumber($"[{ value.Contrast.ReadNumber()}]对比度", value.Contrast); | writer.WriteNumber($"[{ value.Contrast.ReadNumber()}]对比度", value.Contrast); | ||||