From 917429b0485c062852177eb5d6b046238a16c4c4 Mon Sep 17 00:00:00 2001 From: "SmallChi(Koike)" <564952747@qq.com> Date: Sun, 16 Jun 2024 10:57:08 +0800 Subject: [PATCH] =?UTF-8?q?1.=E4=BF=AE=E5=A4=8D=E5=A4=9A=E5=AA=92=E4=BD=93?= =?UTF-8?q?=E4=BA=8B=E4=BB=B6=E4=BF=A1=E6=81=AF=E4=B8=8A=E4=BC=A0=E5=88=86?= =?UTF-8?q?=E6=9E=90=E8=A7=A3=E6=9E=90=E9=94=99=E8=AF=AF=202.=E5=A2=9E?= =?UTF-8?q?=E5=8A=A051gps=E9=80=9A=E7=94=A8=E8=A7=A3=E6=9E=90=E5=BA=93?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/dotnetcore.yml | 2 +- README.en.md | 1 + README.md | 2 + global.json | 2 +- src/.editorconfig | 96 +++++ src/Info.props | 4 +- .../JT808.Protocol.Benchmark.csproj | 4 +- ...T808.Protocol.Extensions.GPS51.Test.csproj | 6 +- .../JT808_0x0200_0x51_Test.cs | 3 +- .../DependencyInjectionExtensions.cs | 2 + .../JT808.Protocol.Extensions.GPS51.csproj | 19 +- .../JT808.Protocol.Extensions.GPS51.xml | 345 ++++++++++++++++++ .../MessageBody/JT808_0x0200_0x2B_Ext.cs | 3 +- .../MessageBody/JT808_0x0200_0x51.cs | 3 +- .../MessageBody/JT808_0x0200_0x52.cs | 95 +++++ ...808.Protocol.Extensions.JT1078.Test.csproj | 6 +- ...808.Protocol.Extensions.SuBiao.Test.csproj | 6 +- ...08.Protocol.Extensions.YueBiao.Test.csproj | 8 +- .../JT808.Protocol.Test.csproj | 10 +- src/JT808.Protocol/JT808.Protocol.csproj | 6 +- .../MessageBody/JT808_0x0800.cs | 2 +- 21 files changed, 593 insertions(+), 32 deletions(-) create mode 100644 src/JT808.Protocol.Extensions/JT808.Protocol.Extensions.GPS51/JT808.Protocol.Extensions.GPS51.xml create mode 100644 src/JT808.Protocol.Extensions/JT808.Protocol.Extensions.GPS51/MessageBody/JT808_0x0200_0x52.cs diff --git a/.github/workflows/dotnetcore.yml b/.github/workflows/dotnetcore.yml index 8f39562e..c6ddae78 100755 --- a/.github/workflows/dotnetcore.yml +++ b/.github/workflows/dotnetcore.yml @@ -12,7 +12,7 @@ jobs: - name: Setup .NET Core uses: actions/setup-dotnet@master with: - dotnet-version: 8.0.100 + dotnet-version: 8.0.203 - name: dotnet info run: dotnet --info - name: dotnet restore diff --git a/README.en.md b/README.en.md index ed50cd60..a626fb4e 100644 --- a/README.en.md +++ b/README.en.md @@ -382,6 +382,7 @@ Due to access many different equipment vendor's agreement, but each protocol doc | Install-Package JT808.Protocol.Extensions.JT1078 | ![JT808.Protocol.Extensions.JT1078](https://img.shields.io/nuget/v/JT808.Protocol.Extensions.JT1078.svg) | ![JT808.Protocol.Extensions.JT1078](https://img.shields.io/nuget/vpre/JT808.Protocol.Extensions.JT1078.svg)|![JT808](https://img.shields.io/nuget/dt/JT808.Protocol.Extensions.JT1078.svg) |JT1078 extension JT808| | Install-Package JT808.Protocol.Extensions.SuBiao| ![JT808.Protocol.Extensions.SuBiao](https://img.shields.io/nuget/v/JT808.Protocol.Extensions.SuBiao.svg) | ![JT808.Protocol.Extensions.SuBiao](https://img.shields.io/nuget/vpre/JT808.Protocol.Extensions.SuBiao.svg)|![JT808](https://img.shields.io/nuget/dt/JT808.Protocol.Extensions.SuBiao.svg) |Active Safety (Su Biao) extension JT808| | Install-Package JT808.Protocol.Extensions.YueBiao| ![JT808.Protocol.Extensions.YueBiao](https://img.shields.io/nuget/v/JT808.Protocol.Extensions.YueBiao.svg) | ![JT808.Protocol.Extensions.YueBiao](https://img.shields.io/nuget/vpre/JT808.Protocol.Extensions.YueBiao.svg)|![JT808](https://img.shields.io/nuget/dt/JT808.Protocol.Extensions.YueBiao.svg) |Active Safety (Yue Biao) extension JT808| +| Install-Package JT808.Protocol.Extensions.GPS51 | ![JT808.Protocol.Extensions.GPS51](https://img.shields.io/nuget/v/JT808.Protocol.Extensions.GPS51.svg) | ![JT808.Protocol.Extensions.GPS51](https://img.shields.io/nuget/vpre/JT808.Protocol.Extensions.GPS51.svg) | ![JT808](https://img.shields.io/nuget/dt/JT808.Protocol.Extensions.GPS51.svg) ## Using BenchmarkDotNet performance test reports (just for fun, not to be taken seriously) diff --git a/README.md b/README.md index 5e62101c..dac0a95d 100644 --- a/README.md +++ b/README.md @@ -398,6 +398,8 @@ JT808Serializer DT2JT808Serializer = new JT808Serializer(DT2JT808Config); | Install-Package JT808.Protocol.Extensions.JT1078 | ![JT808.Protocol.Extensions.JT1078](https://img.shields.io/nuget/v/JT808.Protocol.Extensions.JT1078.svg) | ![JT808.Protocol.Extensions.JT1078](https://img.shields.io/nuget/vpre/JT808.Protocol.Extensions.JT1078.svg) | ![JT808](https://img.shields.io/nuget/dt/JT808.Protocol.Extensions.JT1078.svg) | JT1078 扩展 JT808 | | Install-Package JT808.Protocol.Extensions.SuBiao | ![JT808.Protocol.Extensions.SuBiao](https://img.shields.io/nuget/v/JT808.Protocol.Extensions.SuBiao.svg) | ![JT808.Protocol.Extensions.SuBiao](https://img.shields.io/nuget/vpre/JT808.Protocol.Extensions.SuBiao.svg) | ![JT808](https://img.shields.io/nuget/dt/JT808.Protocol.Extensions.SuBiao.svg) | 主动安全(苏标)扩展 JT808 | | Install-Package JT808.Protocol.Extensions.YueBiao | ![JT808.Protocol.Extensions.YueBiao](https://img.shields.io/nuget/v/JT808.Protocol.Extensions.YueBiao.svg) | ![JT808.Protocol.Extensions.YueBiao](https://img.shields.io/nuget/vpre/JT808.Protocol.Extensions.YueBiao.svg) | ![JT808](https://img.shields.io/nuget/dt/JT808.Protocol.Extensions.YueBiao.svg) | 主动安全(粤标)扩展 JT808 | +| Install-Package JT808.Protocol.Extensions.GPS51 | ![JT808.Protocol.Extensions.GPS51](https://img.shields.io/nuget/v/JT808.Protocol.Extensions.GPS51.svg) | ![JT808.Protocol.Extensions.GPS51](https://img.shields.io/nuget/vpre/JT808.Protocol.Extensions.GPS51.svg) | ![JT808](https://img.shields.io/nuget/dt/JT808.Protocol.Extensions.GPS51.svg) | 主动安全(粤标)扩展 JT808 | + ## 使用 BenchmarkDotNet 性能测试报告(只是玩玩,不能当真) diff --git a/global.json b/global.json index f3365c41..30823add 100644 --- a/global.json +++ b/global.json @@ -1,5 +1,5 @@ { "sdk": { - "version": "8.0.100" + "version": "8.0.203" } } \ No newline at end of file diff --git a/src/.editorconfig b/src/.editorconfig index 1d944d85..37f05333 100644 --- a/src/.editorconfig +++ b/src/.editorconfig @@ -8,3 +8,99 @@ dotnet_diagnostic.IDE0028.severity = none # IDE0059: 不需要赋值 dotnet_diagnostic.IDE0059.severity = none + +[*.cs] +#### 命名样式 #### + +# 命名规则 + +dotnet_naming_rule.interface_should_be_begins_with_i.severity = suggestion +dotnet_naming_rule.interface_should_be_begins_with_i.symbols = interface +dotnet_naming_rule.interface_should_be_begins_with_i.style = begins_with_i + +dotnet_naming_rule.types_should_be_pascal_case.severity = suggestion +dotnet_naming_rule.types_should_be_pascal_case.symbols = types +dotnet_naming_rule.types_should_be_pascal_case.style = pascal_case + +dotnet_naming_rule.non_field_members_should_be_pascal_case.severity = suggestion +dotnet_naming_rule.non_field_members_should_be_pascal_case.symbols = non_field_members +dotnet_naming_rule.non_field_members_should_be_pascal_case.style = pascal_case + +# 符号规范 + +dotnet_naming_symbols.interface.applicable_kinds = interface +dotnet_naming_symbols.interface.applicable_accessibilities = public, internal, private, protected, protected_internal, private_protected +dotnet_naming_symbols.interface.required_modifiers = + +dotnet_naming_symbols.types.applicable_kinds = class, struct, interface, enum +dotnet_naming_symbols.types.applicable_accessibilities = public, internal, private, protected, protected_internal, private_protected +dotnet_naming_symbols.types.required_modifiers = + +dotnet_naming_symbols.non_field_members.applicable_kinds = property, event, method +dotnet_naming_symbols.non_field_members.applicable_accessibilities = public, internal, private, protected, protected_internal, private_protected +dotnet_naming_symbols.non_field_members.required_modifiers = + +# 命名样式 + +dotnet_naming_style.begins_with_i.required_prefix = I +dotnet_naming_style.begins_with_i.required_suffix = +dotnet_naming_style.begins_with_i.word_separator = +dotnet_naming_style.begins_with_i.capitalization = pascal_case + +dotnet_naming_style.pascal_case.required_prefix = +dotnet_naming_style.pascal_case.required_suffix = +dotnet_naming_style.pascal_case.word_separator = +dotnet_naming_style.pascal_case.capitalization = pascal_case + +dotnet_naming_style.pascal_case.required_prefix = +dotnet_naming_style.pascal_case.required_suffix = +dotnet_naming_style.pascal_case.word_separator = +dotnet_naming_style.pascal_case.capitalization = pascal_case + +[*.vb] +#### 命名样式 #### + +# 命名规则 + +dotnet_naming_rule.interface_should_be_以_i_开始.severity = suggestion +dotnet_naming_rule.interface_should_be_以_i_开始.symbols = interface +dotnet_naming_rule.interface_should_be_以_i_开始.style = 以_i_开始 + +dotnet_naming_rule.类型_should_be_帕斯卡拼写法.severity = suggestion +dotnet_naming_rule.类型_should_be_帕斯卡拼写法.symbols = 类型 +dotnet_naming_rule.类型_should_be_帕斯卡拼写法.style = 帕斯卡拼写法 + +dotnet_naming_rule.非字段成员_should_be_帕斯卡拼写法.severity = suggestion +dotnet_naming_rule.非字段成员_should_be_帕斯卡拼写法.symbols = 非字段成员 +dotnet_naming_rule.非字段成员_should_be_帕斯卡拼写法.style = 帕斯卡拼写法 + +# 符号规范 + +dotnet_naming_symbols.interface.applicable_kinds = interface +dotnet_naming_symbols.interface.applicable_accessibilities = public, friend, private, protected, protected_friend, private_protected +dotnet_naming_symbols.interface.required_modifiers = + +dotnet_naming_symbols.类型.applicable_kinds = class, struct, interface, enum +dotnet_naming_symbols.类型.applicable_accessibilities = public, friend, private, protected, protected_friend, private_protected +dotnet_naming_symbols.类型.required_modifiers = + +dotnet_naming_symbols.非字段成员.applicable_kinds = property, event, method +dotnet_naming_symbols.非字段成员.applicable_accessibilities = public, friend, private, protected, protected_friend, private_protected +dotnet_naming_symbols.非字段成员.required_modifiers = + +# 命名样式 + +dotnet_naming_style.以_i_开始.required_prefix = I +dotnet_naming_style.以_i_开始.required_suffix = +dotnet_naming_style.以_i_开始.word_separator = +dotnet_naming_style.以_i_开始.capitalization = pascal_case + +dotnet_naming_style.帕斯卡拼写法.required_prefix = +dotnet_naming_style.帕斯卡拼写法.required_suffix = +dotnet_naming_style.帕斯卡拼写法.word_separator = +dotnet_naming_style.帕斯卡拼写法.capitalization = pascal_case + +dotnet_naming_style.帕斯卡拼写法.required_prefix = +dotnet_naming_style.帕斯卡拼写法.required_suffix = +dotnet_naming_style.帕斯卡拼写法.word_separator = +dotnet_naming_style.帕斯卡拼写法.capitalization = pascal_case diff --git a/src/Info.props b/src/Info.props index 503771dc..5ce0552c 100644 --- a/src/Info.props +++ b/src/Info.props @@ -8,7 +8,7 @@ https://github.com/SmallChi/JT808 https://github.com/SmallChi/JT808/blob/master/LICENSE https://github.com/SmallChi/JT808/blob/master/LICENSE - 2.6.5 + 2.6.6 enable LICENSE true @@ -29,6 +29,6 @@ - + \ No newline at end of file diff --git a/src/JT808.Protocol.Benchmark/JT808.Protocol.Benchmark.csproj b/src/JT808.Protocol.Benchmark/JT808.Protocol.Benchmark.csproj index e97f74ca..7c783850 100644 --- a/src/JT808.Protocol.Benchmark/JT808.Protocol.Benchmark.csproj +++ b/src/JT808.Protocol.Benchmark/JT808.Protocol.Benchmark.csproj @@ -14,8 +14,8 @@ - - + + diff --git a/src/JT808.Protocol.Extensions/JT808.Protocol.Extensions.GPS51.Test/JT808.Protocol.Extensions.GPS51.Test.csproj b/src/JT808.Protocol.Extensions/JT808.Protocol.Extensions.GPS51.Test/JT808.Protocol.Extensions.GPS51.Test.csproj index 500bf2a7..92ec272a 100644 --- a/src/JT808.Protocol.Extensions/JT808.Protocol.Extensions.GPS51.Test/JT808.Protocol.Extensions.GPS51.Test.csproj +++ b/src/JT808.Protocol.Extensions/JT808.Protocol.Extensions.GPS51.Test/JT808.Protocol.Extensions.GPS51.Test.csproj @@ -7,9 +7,9 @@ - - - + + + all runtime; build; native; contentfiles; analyzers; buildtransitive diff --git a/src/JT808.Protocol.Extensions/JT808.Protocol.Extensions.GPS51.Test/JT808_0x0200_0x51_Test.cs b/src/JT808.Protocol.Extensions/JT808.Protocol.Extensions.GPS51.Test/JT808_0x0200_0x51_Test.cs index a295e47c..e3bd4a33 100644 --- a/src/JT808.Protocol.Extensions/JT808.Protocol.Extensions.GPS51.Test/JT808_0x0200_0x51_Test.cs +++ b/src/JT808.Protocol.Extensions/JT808.Protocol.Extensions.GPS51.Test/JT808_0x0200_0x51_Test.cs @@ -14,7 +14,7 @@ public JT808_0x0200_0x51_Test() { ServiceCollection serviceDescriptors = new ServiceCollection(); serviceDescriptors.AddJT808Configure() - .AddGPS51Configure(); + .AddGPS51Configure(); IJT808Config jT808Config = serviceDescriptors.BuildServiceProvider().GetRequiredService(); JT808Serializer = new JT808Serializer(jT808Config); @@ -22,6 +22,7 @@ public JT808_0x0200_0x51_Test() [Fact] public void Serializer() { +#warning JT808_0x0200 jT808UploadLocationRequest = new JT808_0x0200 { AlarmFlag = 1, diff --git a/src/JT808.Protocol.Extensions/JT808.Protocol.Extensions.GPS51/DependencyInjectionExtensions.cs b/src/JT808.Protocol.Extensions/JT808.Protocol.Extensions.GPS51/DependencyInjectionExtensions.cs index 3ef4f84c..0352b267 100644 --- a/src/JT808.Protocol.Extensions/JT808.Protocol.Extensions.GPS51/DependencyInjectionExtensions.cs +++ b/src/JT808.Protocol.Extensions/JT808.Protocol.Extensions.GPS51/DependencyInjectionExtensions.cs @@ -6,11 +6,13 @@ using System.Collections.Generic; using System.Reflection; using System.Text; +using static System.Net.WebRequestMethods; namespace JT808.Protocol.Extensions.GPS51 { /// /// GPS51 extension JT/T808 + /// /// public static class DependencyInjectionExtensions { diff --git a/src/JT808.Protocol.Extensions/JT808.Protocol.Extensions.GPS51/JT808.Protocol.Extensions.GPS51.csproj b/src/JT808.Protocol.Extensions/JT808.Protocol.Extensions.GPS51/JT808.Protocol.Extensions.GPS51.csproj index f07903ec..405fca61 100644 --- a/src/JT808.Protocol.Extensions/JT808.Protocol.Extensions.GPS51/JT808.Protocol.Extensions.GPS51.csproj +++ b/src/JT808.Protocol.Extensions/JT808.Protocol.Extensions.GPS51/JT808.Protocol.Extensions.GPS51.csproj @@ -1,9 +1,26 @@  + - netstandard2.0 + JT808.Protocol.Extensions.GPS51 + JT808.Protocol.Extensions.GPS51 + + JT/T1078 video message protocol based on JT/JT808 protocol and GB808 protocol extension.基于JT808协议、GB808协议扩展的JT1078视频消息协议。 + + + JT/T1078 video message protocol based on JT/JT808 protocol and GB808 protocol extension.基于JT/T808协议、GB808协议扩展的JT/T1078视频消息协议。 + + JT808.Protocol.Extensions.GPS51.xml + True + https://gps51.com/#/jt808add + + + + + + diff --git a/src/JT808.Protocol.Extensions/JT808.Protocol.Extensions.GPS51/JT808.Protocol.Extensions.GPS51.xml b/src/JT808.Protocol.Extensions/JT808.Protocol.Extensions.GPS51/JT808.Protocol.Extensions.GPS51.xml new file mode 100644 index 00000000..07886103 --- /dev/null +++ b/src/JT808.Protocol.Extensions/JT808.Protocol.Extensions.GPS51/JT808.Protocol.Extensions.GPS51.xml @@ -0,0 +1,345 @@ + + + + JT808.Protocol.Extensions.GPS51 + + + + + GPS51 extension JT/T808 + + + + + + 注册GPS51扩展JT/T808 + Register GPS51 extension JT/T808 + + + + + + + 主动拍照策略 + Active photo taking strategy + + + + + 不开启 + Is not enabled + + + + + 定时拍照 + Camera Timer + + + + + 定距拍照 + Distance take photos + + + + + 保留 + reserve + + + + + 不修改参数 + Do not Modify parameters + + + + + 主动安全常量 + + + + + 附加信息ID 多路油耗模拟量, + 2*N + 例子报文:2b049203a46f + 解析结果为:2路 模拟量分别为37379 42095 + + + + + 附加信息ID 2个字节一组温度 0.1度 ffff 代表无效, + 2*N + 04F6代表未接或者传感器掉电, + 第16位代表正负温度 51080134011A04F604F6 + 308=30.8度 282=28.2度 8050=-80=-8度 + + + + + 附加信息ID + 1 + 正反转 0:未知;1:正转(空车)2:反转(重车);3:停转 + 例子解析为:03 + + + + + 附加信息ID + 1+7*N + Wifi数据:第1个字节wifi个数,后面为n个wifi数据; + WIFI数据:6字节 wifiMac 1字节 信号强度 + + + + + 载重扩展 8 + 1/10千克 8 字节 + + + + + 湿度, + 2*N + 精度0.1,0fff 代表无效数据,例子数据: 0012 表示:1.8% + + + + + 电压, + 2 + 单位0.01V,例子报文:61021d74,解析结果7540,最终电压75.40V + + + + + 基站编码 + 4+7*N + 的格式为 MCC MNC LAC CI Signal 2-2-2-4-1-2-4-1, + 其中MCC 2个字节国家编码,MNC 为 2个字节网络编码,LAC为 2个字节地区编码, + CI 为 4个字节蜂窝 ID , + 信号强度 1字节, + 单基站可以不用信号强度 1cc-0-696a-863a8d0-0 + + + + + 版本号, + N + 开机或者重连第一条上报,例子结果:GB201-GSM-21001-1.1.1 + + + + + iccid, + 20 + 一般开机或者重连第一条0200位置信息上报, + 例子报文:f1143839383630343032313032303930393737303032, + 解析结果为:89860402102090977002 + + + + + IMEI数据: + 8字节, + 第1位为0,后面15位为imei的16进制数据 + + + + + 4 + 第0位:震动报警 + 第1位:拆除报警 例子:第0位:震动报警 fa0400000001 第1位:拆除报警 fa0400000002 + 第2位:进入深度休眠 fa0400000004 + 第3位:急加速 fa0400000008 + 第4位:急减速 fa0400000010 + 第5位:急转弯 fa0400000020 + 第6位:acc开报警 fa0400000040 + 第7位:acc关报警 fa0400000080 + 第8位:内部电池电量低fa0400000100 + 第9位:人为关机 + 第10位:低电关机 + + + + + 4 + 电量百分比和外部电压, + 电压精度0.01V,充电状态0未充电 1充电中,没有的数据传00 + 例子:fb045F050701 + 解析结果:电量百分比5F=95 电压:0507=1287 最终显示为12.87V 01:充电中 + + + + + + + + + + + 多路油耗模拟量 + + + + + 多路油耗模拟量,Id + + + + + 多路油耗模拟量信息附加长度 + + + + + 油量数据 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 温度 + + + + + 温度,Id + + + + + 温度信息附加长度 + + + + + 温度数据 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 正反转 + + + + + + + + + + + + + + + 正反转值 + 0:未知;1:正转(空车)2:反转(重车);3:停转 例子解析为:03 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 报警标识号 + + + + + 终端ID + + + + + YY-MM-DD-hh-mm-ss + BCD[6] + + + + + 序号 + + + + + 附件数量 + + + + + 预留 + + + + diff --git a/src/JT808.Protocol.Extensions/JT808.Protocol.Extensions.GPS51/MessageBody/JT808_0x0200_0x2B_Ext.cs b/src/JT808.Protocol.Extensions/JT808.Protocol.Extensions.GPS51/MessageBody/JT808_0x0200_0x2B_Ext.cs index 936ba8c0..3377b549 100644 --- a/src/JT808.Protocol.Extensions/JT808.Protocol.Extensions.GPS51/MessageBody/JT808_0x0200_0x2B_Ext.cs +++ b/src/JT808.Protocol.Extensions/JT808.Protocol.Extensions.GPS51/MessageBody/JT808_0x0200_0x2B_Ext.cs @@ -43,7 +43,8 @@ public void Analyze(ref JT808MessagePackReader reader, Utf8JsonWriter writer, IJ value.AttachInfoLength = reader.ReadByte(); writer.WriteNumber($"[{value.AttachInfoLength.ReadNumber()}]附加信息长度", value.AttachInfoLength); value.Oils = new List(); - for (ushort i = 0; i < value.AttachInfoLength/2; i++) { + for (ushort i = 0; i < value.AttachInfoLength/2; i++) + { value.Oils.Add(reader.ReadUInt16()); } writer.WriteString($"[油量值:{string.Join("", value.Oils.Select(m=>m.ReadNumber()))}]",string.Join(",", value.Oils)); diff --git a/src/JT808.Protocol.Extensions/JT808.Protocol.Extensions.GPS51/MessageBody/JT808_0x0200_0x51.cs b/src/JT808.Protocol.Extensions/JT808.Protocol.Extensions.GPS51/MessageBody/JT808_0x0200_0x51.cs index fd3ee3e1..6355b64f 100644 --- a/src/JT808.Protocol.Extensions/JT808.Protocol.Extensions.GPS51/MessageBody/JT808_0x0200_0x51.cs +++ b/src/JT808.Protocol.Extensions/JT808.Protocol.Extensions.GPS51/MessageBody/JT808_0x0200_0x51.cs @@ -43,7 +43,8 @@ public void Analyze(ref JT808MessagePackReader reader, Utf8JsonWriter writer, IJ value.AttachInfoLength = reader.ReadByte(); writer.WriteNumber($"[{value.AttachInfoLength.ReadNumber()}]附加信息长度", value.AttachInfoLength); value.Temperatures = new List(); - for (ushort i = 0; i < value.AttachInfoLength/2; i++) { + for (ushort i = 0; i < value.AttachInfoLength/2; i++) + { value.Temperatures.Add(reader.ReadInt16()); } writer.WriteString($"[温度值:{string.Join("", value.Temperatures.Select(m=>m.ReadNumber()))}]",string.Join(",", value.Temperatures)); diff --git a/src/JT808.Protocol.Extensions/JT808.Protocol.Extensions.GPS51/MessageBody/JT808_0x0200_0x52.cs b/src/JT808.Protocol.Extensions/JT808.Protocol.Extensions.GPS51/MessageBody/JT808_0x0200_0x52.cs new file mode 100644 index 00000000..8c549476 --- /dev/null +++ b/src/JT808.Protocol.Extensions/JT808.Protocol.Extensions.GPS51/MessageBody/JT808_0x0200_0x52.cs @@ -0,0 +1,95 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Text.Json; +using JT808.Protocol.Extensions.GPS51.Metadata; +using JT808.Protocol.Formatters; +using JT808.Protocol.Interfaces; +using JT808.Protocol.MessageBody; +using JT808.Protocol.MessagePack; + +namespace JT808.Protocol.Extensions.GPS51.MessageBody +{ + /// + /// 正反转 + /// + public class JT808_0x0200_0x52 : JT808MessagePackFormatter, JT808_0x0200_CustomBodyBase, IJT808Analyze + { + /// + /// + /// + public byte AttachInfoId { get; set; } = JT808_GPS51_Constants.JT808_0x0200_0x52; + /// + /// + /// + public byte AttachInfoLength { get; set; } + /// + /// 正反转值 + /// 0:未知;1:正转(空车)2:反转(重车);3:停转 例子解析为:03 + /// + public byte Direction { get; set; } + + /// + /// + /// + /// + /// + /// + public void Analyze(ref JT808MessagePackReader reader, Utf8JsonWriter writer, IJT808Config config) + { + JT808_0x0200_0x52 value = new JT808_0x0200_0x52(); + value.AttachInfoId = reader.ReadByte(); + writer.WriteNumber($"[{value.AttachInfoId.ReadNumber()}]附加信息Id", value.AttachInfoId); + value.AttachInfoLength = reader.ReadByte(); + writer.WriteNumber($"[{value.AttachInfoLength.ReadNumber()}]附加信息长度", value.AttachInfoLength); + value.Direction = reader.ReadByte(); + if (value.Direction == 0) + { + writer.WriteString($"[{value.Direction.ReadNumber()}]正反转", "未知"); + } + else if(value.Direction==1) + { + writer.WriteString($"[{value.Direction.ReadNumber()}]正反转", "正转(空车)"); + } + else if (value.Direction == 2) + { + writer.WriteString($"[{value.Direction.ReadNumber()}]正反转", "反转(重车)"); + } + else if (value.Direction == 3) + { + writer.WriteString($"[{value.Direction.ReadNumber()}]正反转", "停转"); + } + else + { + writer.WriteString($"[{value.Direction.ReadNumber()}]正反转", "未知2"); + } + } + /// + /// + /// + /// + /// + /// + public override JT808_0x0200_0x52 Deserialize(ref JT808MessagePackReader reader, IJT808Config config) + { + JT808_0x0200_0x52 value = new JT808_0x0200_0x52(); + value.AttachInfoId = reader.ReadByte(); + value.AttachInfoLength = reader.ReadByte(); + value.Direction = reader.ReadByte(); + return value; + } + /// + /// + /// + /// + /// + /// + public override void Serialize(ref JT808MessagePackWriter writer, JT808_0x0200_0x52 value, IJT808Config config) + { + writer.WriteByte(value.AttachInfoId); + writer.WriteByte(1); + writer.WriteByte(value.Direction); + } + } +} 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 index b8bbae9e..757ce155 100644 --- 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 @@ -7,9 +7,9 @@ - - - + + + all runtime; build; native; contentfiles; analyzers; buildtransitive diff --git a/src/JT808.Protocol.Extensions/JT808.Protocol.Extensions.SuBiao.Test/JT808.Protocol.Extensions.SuBiao.Test.csproj b/src/JT808.Protocol.Extensions/JT808.Protocol.Extensions.SuBiao.Test/JT808.Protocol.Extensions.SuBiao.Test.csproj index e1964f84..86494ebd 100644 --- a/src/JT808.Protocol.Extensions/JT808.Protocol.Extensions.SuBiao.Test/JT808.Protocol.Extensions.SuBiao.Test.csproj +++ b/src/JT808.Protocol.Extensions/JT808.Protocol.Extensions.SuBiao.Test/JT808.Protocol.Extensions.SuBiao.Test.csproj @@ -8,9 +8,9 @@ - - - + + + all runtime; build; native; contentfiles; analyzers; buildtransitive diff --git a/src/JT808.Protocol.Extensions/JT808.Protocol.Extensions.YueBiao.Test/JT808.Protocol.Extensions.YueBiao.Test.csproj b/src/JT808.Protocol.Extensions/JT808.Protocol.Extensions.YueBiao.Test/JT808.Protocol.Extensions.YueBiao.Test.csproj index 564fe11d..eee84659 100644 --- a/src/JT808.Protocol.Extensions/JT808.Protocol.Extensions.YueBiao.Test/JT808.Protocol.Extensions.YueBiao.Test.csproj +++ b/src/JT808.Protocol.Extensions/JT808.Protocol.Extensions.YueBiao.Test/JT808.Protocol.Extensions.YueBiao.Test.csproj @@ -8,13 +8,13 @@ - - - + + + runtime; build; native; contentfiles; analyzers; buildtransitive all - + runtime; build; native; contentfiles; analyzers; buildtransitive all diff --git a/src/JT808.Protocol.Test/JT808.Protocol.Test.csproj b/src/JT808.Protocol.Test/JT808.Protocol.Test.csproj index 2bb60dbb..5cd78c75 100644 --- a/src/JT808.Protocol.Test/JT808.Protocol.Test.csproj +++ b/src/JT808.Protocol.Test/JT808.Protocol.Test.csproj @@ -108,17 +108,17 @@ - + - + - - + + all runtime; build; native; contentfiles; analyzers - + all runtime; build; native; contentfiles; analyzers diff --git a/src/JT808.Protocol/JT808.Protocol.csproj b/src/JT808.Protocol/JT808.Protocol.csproj index 9f45d83a..648c3776 100644 --- a/src/JT808.Protocol/JT808.Protocol.csproj +++ b/src/JT808.Protocol/JT808.Protocol.csproj @@ -46,9 +46,9 @@ - + - + @@ -57,7 +57,7 @@ - + diff --git a/src/JT808.Protocol/MessageBody/JT808_0x0800.cs b/src/JT808.Protocol/MessageBody/JT808_0x0800.cs index 6facbc51..e179cb5a 100644 --- a/src/JT808.Protocol/MessageBody/JT808_0x0800.cs +++ b/src/JT808.Protocol/MessageBody/JT808_0x0800.cs @@ -74,7 +74,7 @@ public void Analyze(ref JT808MessagePackReader reader, Utf8JsonWriter writer, IJ value.MultimediaCodingFormat = reader.ReadByte(); writer.WriteNumber($"[{value.MultimediaCodingFormat.ReadNumber()}]多媒体格式编码-{((JT808MultimediaCodingFormat)value.MultimediaCodingFormat).ToString()}", value.MultimediaCodingFormat); value.EventItemCoding = reader.ReadByte(); - writer.WriteNumber($"[{value.EventItemCoding.ReadNumber()}]事件项编码-{((JT808EventItemCoding)value.EventItemCoding).ToString()}", value.MultimediaCodingFormat); + writer.WriteNumber($"[{value.EventItemCoding.ReadNumber()}]事件项编码-{((JT808EventItemCoding)value.EventItemCoding).ToString()}", value.EventItemCoding); value.ChannelId = reader.ReadByte(); writer.WriteNumber($"[{value.ChannelId.ReadNumber()}]通道ID", value.ChannelId); }