Procházet zdrojové kódy

统一0x8900自定义工厂注册接口

tags/v2.6.2
yedajiang44 před 2 roky
rodič
revize
30341f9a2c
7 změnil soubory, kde provedl 67 přidání a 53 odebrání
  1. +12
    -0
      src/JT808.Protocol.Extensions/JT808.Protocol.Extensions.SuBiao/JT808.Protocol.Extensions.SuBiao.xml
  2. +13
    -9
      src/JT808.Protocol.Extensions/JT808.Protocol.Extensions.SuBiao/MessageBody/JT808_0x0200_0x64.cs
  3. +10
    -8
      src/JT808.Protocol.Extensions/JT808.Protocol.Extensions.SuBiao/MessageBody/JT808_0x0200_0x65.cs
  4. +8
    -6
      src/JT808.Protocol.Extensions/JT808.Protocol.Extensions.SuBiao/MessageBody/JT808_0x0200_0x66.cs
  5. +14
    -12
      src/JT808.Protocol.Extensions/JT808.Protocol.Extensions.SuBiao/MessageBody/JT808_0x0200_0x67.cs
  6. +3
    -3
      src/JT808.Protocol/Interfaces/IJT808_0x8900_Custom_Factory.cs
  7. +7
    -15
      src/JT808.Protocol/Internal/JT808_0x8900_Custom_Factory.cs

+ 12
- 0
src/JT808.Protocol.Extensions/JT808.Protocol.Extensions.SuBiao/JT808.Protocol.Extensions.SuBiao.xml Zobrazit soubor

@@ -314,6 +314,9 @@
高级驾驶辅助系统报警信息Id 高级驾驶辅助系统报警信息Id
</summary> </summary>
</member> </member>
<member name="P:JT808.Protocol.Extensions.SuBiao.MessageBody.JT808_0x0200_0x64.PassthroughType">
<inheritdoc/>
</member>
<member name="P:JT808.Protocol.Extensions.SuBiao.MessageBody.JT808_0x0200_0x64.AttachInfoLength"> <member name="P:JT808.Protocol.Extensions.SuBiao.MessageBody.JT808_0x0200_0x64.AttachInfoLength">
<summary> <summary>
高级驾驶辅助系统报警信息附加长度 高级驾驶辅助系统报警信息附加长度
@@ -435,6 +438,9 @@
驾驶员状态监测系统报警信息Id 驾驶员状态监测系统报警信息Id
</summary> </summary>
</member> </member>
<member name="P:JT808.Protocol.Extensions.SuBiao.MessageBody.JT808_0x0200_0x65.PassthroughType">
<inheritdoc/>
</member>
<member name="P:JT808.Protocol.Extensions.SuBiao.MessageBody.JT808_0x0200_0x65.AttachInfoLength"> <member name="P:JT808.Protocol.Extensions.SuBiao.MessageBody.JT808_0x0200_0x65.AttachInfoLength">
<summary> <summary>
驾驶员状态监测系统报警信息长度 驾驶员状态监测系统报警信息长度
@@ -541,6 +547,9 @@
胎压监测系统报警信息Id 胎压监测系统报警信息Id
</summary> </summary>
</member> </member>
<member name="P:JT808.Protocol.Extensions.SuBiao.MessageBody.JT808_0x0200_0x66.PassthroughType">
<inheritdoc/>
</member>
<member name="P:JT808.Protocol.Extensions.SuBiao.MessageBody.JT808_0x0200_0x66.AttachInfoLength"> <member name="P:JT808.Protocol.Extensions.SuBiao.MessageBody.JT808_0x0200_0x66.AttachInfoLength">
<summary> <summary>
胎压监测系统报警信息长度 胎压监测系统报警信息长度
@@ -637,6 +646,9 @@
盲区监测系统报警信息Id 盲区监测系统报警信息Id
</summary> </summary>
</member> </member>
<member name="P:JT808.Protocol.Extensions.SuBiao.MessageBody.JT808_0x0200_0x67.PassthroughType">
<inheritdoc/>
</member>
<member name="P:JT808.Protocol.Extensions.SuBiao.MessageBody.JT808_0x0200_0x67.AttachInfoLength"> <member name="P:JT808.Protocol.Extensions.SuBiao.MessageBody.JT808_0x0200_0x67.AttachInfoLength">
<summary> <summary>
盲区监测系统报警信息长度 盲区监测系统报警信息长度


+ 13
- 9
src/JT808.Protocol.Extensions/JT808.Protocol.Extensions.SuBiao/MessageBody/JT808_0x0200_0x64.cs Zobrazit soubor

@@ -1,24 +1,26 @@
using JT808.Protocol.Extensions.SuBiao.Metadata;
using System;
using System.Collections.Generic;
using System.Text;
using System.Text.Json;
using JT808.Protocol.Extensions.SuBiao.Metadata;
using JT808.Protocol.Formatters; using JT808.Protocol.Formatters;
using JT808.Protocol.Interfaces; using JT808.Protocol.Interfaces;
using JT808.Protocol.MessageBody; using JT808.Protocol.MessageBody;
using JT808.Protocol.MessagePack; using JT808.Protocol.MessagePack;
using System;
using System.Collections.Generic;
using System.Text;
using System.Text.Json;


namespace JT808.Protocol.Extensions.SuBiao.MessageBody namespace JT808.Protocol.Extensions.SuBiao.MessageBody
{ {
/// <summary> /// <summary>
/// 高级驾驶辅助系统报警信息 /// 高级驾驶辅助系统报警信息
/// </summary> /// </summary>
public class JT808_0x0200_0x64 : JT808MessagePackFormatter<JT808_0x0200_0x64>, JT808_0x0200_CustomBodyBase, IJT808Analyze
public class JT808_0x0200_0x64 : JT808MessagePackFormatter<JT808_0x0200_0x64>, JT808_0x0200_CustomBodyBase, JT808_0x8900_BodyBase, IJT808Analyze
{ {
/// <summary> /// <summary>
/// 高级驾驶辅助系统报警信息Id /// 高级驾驶辅助系统报警信息Id
/// </summary> /// </summary>
public byte AttachInfoId { get; set; } = JT808_SuBiao_Constants.JT808_0X0200_0x64; public byte AttachInfoId { get; set; } = JT808_SuBiao_Constants.JT808_0X0200_0x64;
/// <inheritdoc/>
public byte PassthroughType { get; set; } = JT808_SuBiao_Constants.JT808_0X0200_0x64;
/// <summary> /// <summary>
/// 高级驾驶辅助系统报警信息附加长度 /// 高级驾驶辅助系统报警信息附加长度
/// </summary> /// </summary>
@@ -34,7 +36,7 @@ namespace JT808.Protocol.Extensions.SuBiao.MessageBody
/// <summary> /// <summary>
/// 报警/事件类型 /// 报警/事件类型
/// </summary> /// </summary>
public byte AlarmOrEventType{ get; set; }
public byte AlarmOrEventType { get; set; }
/// <summary> /// <summary>
/// 报警/事件类型 /// 报警/事件类型
/// </summary> /// </summary>
@@ -89,6 +91,7 @@ namespace JT808.Protocol.Extensions.SuBiao.MessageBody
/// 报警标识号 /// 报警标识号
/// </summary> /// </summary>
public AlarmIdentificationProperty AlarmIdentification { get; set; } public AlarmIdentificationProperty AlarmIdentification { get; set; }

/// <summary> /// <summary>
/// ///
/// </summary> /// </summary>
@@ -277,7 +280,7 @@ namespace JT808.Protocol.Extensions.SuBiao.MessageBody
/// <param name="config"></param> /// <param name="config"></param>
/// <returns></returns> /// <returns></returns>
public override JT808_0x0200_0x64 Deserialize(ref JT808MessagePackReader reader, IJT808Config config) public override JT808_0x0200_0x64 Deserialize(ref JT808MessagePackReader reader, IJT808Config config)
{
{
JT808_0x0200_0x64 value = new JT808_0x0200_0x64(); JT808_0x0200_0x64 value = new JT808_0x0200_0x64();
value.AttachInfoId = reader.ReadByte(); value.AttachInfoId = reader.ReadByte();
value.AttachInfoLength = reader.ReadByte(); value.AttachInfoLength = reader.ReadByte();
@@ -331,7 +334,8 @@ namespace JT808.Protocol.Extensions.SuBiao.MessageBody
writer.WriteUInt32((uint)value.Longitude); writer.WriteUInt32((uint)value.Longitude);
writer.WriteDateTime_yyMMddHHmmss(value.AlarmTime); writer.WriteDateTime_yyMMddHHmmss(value.AlarmTime);
writer.WriteUInt16(value.VehicleState); writer.WriteUInt16(value.VehicleState);
if (value.AlarmIdentification == null) {
if (value.AlarmIdentification == null)
{
throw new NullReferenceException($"{nameof(AlarmIdentificationProperty)}不为空"); throw new NullReferenceException($"{nameof(AlarmIdentificationProperty)}不为空");
} }
writer.WriteString(value.AlarmIdentification.TerminalID); writer.WriteString(value.AlarmIdentification.TerminalID);


+ 10
- 8
src/JT808.Protocol.Extensions/JT808.Protocol.Extensions.SuBiao/MessageBody/JT808_0x0200_0x65.cs Zobrazit soubor

@@ -1,24 +1,26 @@
using JT808.Protocol.Extensions.SuBiao.Metadata;
using System;
using System.Collections.Generic;
using System.Text;
using System.Text.Json;
using JT808.Protocol.Extensions.SuBiao.Metadata;
using JT808.Protocol.Formatters; using JT808.Protocol.Formatters;
using JT808.Protocol.Interfaces; using JT808.Protocol.Interfaces;
using JT808.Protocol.MessageBody; using JT808.Protocol.MessageBody;
using JT808.Protocol.MessagePack; using JT808.Protocol.MessagePack;
using System;
using System.Collections.Generic;
using System.Text;
using System.Text.Json;


namespace JT808.Protocol.Extensions.SuBiao.MessageBody namespace JT808.Protocol.Extensions.SuBiao.MessageBody
{ {
/// <summary> /// <summary>
/// 驾驶员状态监测系统报警信息 /// 驾驶员状态监测系统报警信息
/// </summary> /// </summary>
public class JT808_0x0200_0x65 : JT808MessagePackFormatter<JT808_0x0200_0x65>, JT808_0x0200_CustomBodyBase, IJT808Analyze
public class JT808_0x0200_0x65 : JT808MessagePackFormatter<JT808_0x0200_0x65>, JT808_0x0200_CustomBodyBase, JT808_0x8900_BodyBase, IJT808Analyze
{ {
/// <summary> /// <summary>
/// 驾驶员状态监测系统报警信息Id /// 驾驶员状态监测系统报警信息Id
/// </summary> /// </summary>
public byte AttachInfoId { get; set; } = JT808_SuBiao_Constants.JT808_0X0200_0x65; public byte AttachInfoId { get; set; } = JT808_SuBiao_Constants.JT808_0X0200_0x65;
/// <inheritdoc/>
public byte PassthroughType { get; set; } = JT808_SuBiao_Constants.JT808_0X0200_0x65;
/// <summary> /// <summary>
/// 驾驶员状态监测系统报警信息长度 /// 驾驶员状态监测系统报警信息长度
/// </summary> /// </summary>
@@ -34,7 +36,7 @@ namespace JT808.Protocol.Extensions.SuBiao.MessageBody
/// <summary> /// <summary>
/// 报警/事件类型 /// 报警/事件类型
/// </summary> /// </summary>
public byte AlarmOrEventType{ get; set; }
public byte AlarmOrEventType { get; set; }
/// <summary> /// <summary>
/// 报警级别 /// 报警级别
/// </summary> /// </summary>
@@ -86,7 +88,7 @@ namespace JT808.Protocol.Extensions.SuBiao.MessageBody
public void Analyze(ref JT808MessagePackReader reader, Utf8JsonWriter writer, IJT808Config config) public void Analyze(ref JT808MessagePackReader reader, Utf8JsonWriter writer, IJT808Config config)
{ {
JT808_0x0200_0x65 value = new JT808_0x0200_0x65(); JT808_0x0200_0x65 value = new JT808_0x0200_0x65();
value.AttachInfoId = reader.ReadByte();
value.AttachInfoId = reader.ReadByte();
writer.WriteNumber($"[{value.AttachInfoId.ReadNumber()}]附加信息Id", value.AttachInfoId); writer.WriteNumber($"[{value.AttachInfoId.ReadNumber()}]附加信息Id", value.AttachInfoId);
value.AttachInfoLength = reader.ReadByte(); value.AttachInfoLength = reader.ReadByte();
writer.WriteNumber($"[{value.AttachInfoLength.ReadNumber()}]附加信息长度", value.AttachInfoLength); writer.WriteNumber($"[{value.AttachInfoLength.ReadNumber()}]附加信息长度", value.AttachInfoLength);


+ 8
- 6
src/JT808.Protocol.Extensions/JT808.Protocol.Extensions.SuBiao/MessageBody/JT808_0x0200_0x66.cs Zobrazit soubor

@@ -1,24 +1,26 @@
using JT808.Protocol.Extensions.SuBiao.Metadata;
using System;
using System.Collections.Generic;
using System.Text;
using System.Text.Json;
using JT808.Protocol.Extensions.SuBiao.Metadata;
using JT808.Protocol.Formatters; using JT808.Protocol.Formatters;
using JT808.Protocol.Interfaces; using JT808.Protocol.Interfaces;
using JT808.Protocol.MessageBody; using JT808.Protocol.MessageBody;
using JT808.Protocol.MessagePack; using JT808.Protocol.MessagePack;
using System;
using System.Collections.Generic;
using System.Text;
using System.Text.Json;


namespace JT808.Protocol.Extensions.SuBiao.MessageBody namespace JT808.Protocol.Extensions.SuBiao.MessageBody
{ {
/// <summary> /// <summary>
/// 胎压监测系统报警信息 /// 胎压监测系统报警信息
/// </summary> /// </summary>
public class JT808_0x0200_0x66 : JT808MessagePackFormatter<JT808_0x0200_0x66>, JT808_0x0200_CustomBodyBase, IJT808Analyze
public class JT808_0x0200_0x66 : JT808MessagePackFormatter<JT808_0x0200_0x66>, JT808_0x0200_CustomBodyBase, JT808_0x8900_BodyBase, IJT808Analyze
{ {
/// <summary> /// <summary>
/// 胎压监测系统报警信息Id /// 胎压监测系统报警信息Id
/// </summary> /// </summary>
public byte AttachInfoId { get; set; } = JT808_SuBiao_Constants.JT808_0X0200_0x66; public byte AttachInfoId { get; set; } = JT808_SuBiao_Constants.JT808_0X0200_0x66;
/// <inheritdoc/>
public byte PassthroughType { get; set; } = JT808_SuBiao_Constants.JT808_0X0200_0x66;
/// <summary> /// <summary>
/// 胎压监测系统报警信息长度 /// 胎压监测系统报警信息长度
/// </summary> /// </summary>


+ 14
- 12
src/JT808.Protocol.Extensions/JT808.Protocol.Extensions.SuBiao/MessageBody/JT808_0x0200_0x67.cs Zobrazit soubor

@@ -1,24 +1,26 @@
using JT808.Protocol.Extensions.SuBiao.Metadata;
using System;
using System.Collections.Generic;
using System.Text;
using System.Text.Json;
using JT808.Protocol.Extensions.SuBiao.Metadata;
using JT808.Protocol.Formatters; using JT808.Protocol.Formatters;
using JT808.Protocol.Interfaces; using JT808.Protocol.Interfaces;
using JT808.Protocol.MessageBody; using JT808.Protocol.MessageBody;
using JT808.Protocol.MessagePack; using JT808.Protocol.MessagePack;
using System;
using System.Collections.Generic;
using System.Text;
using System.Text.Json;


namespace JT808.Protocol.Extensions.SuBiao.MessageBody namespace JT808.Protocol.Extensions.SuBiao.MessageBody
{ {
/// <summary> /// <summary>
/// 盲区监测系统报警信息 /// 盲区监测系统报警信息
/// </summary> /// </summary>
public class JT808_0x0200_0x67 : JT808MessagePackFormatter<JT808_0x0200_0x67>, JT808_0x0200_CustomBodyBase, IJT808Analyze
public class JT808_0x0200_0x67 : JT808MessagePackFormatter<JT808_0x0200_0x67>, JT808_0x0200_CustomBodyBase, JT808_0x8900_BodyBase, IJT808Analyze
{ {
/// <summary> /// <summary>
/// 盲区监测系统报警信息Id /// 盲区监测系统报警信息Id
/// </summary> /// </summary>
public byte AttachInfoId { get; set; } = JT808_SuBiao_Constants.JT808_0X0200_0x67; public byte AttachInfoId { get; set; } = JT808_SuBiao_Constants.JT808_0X0200_0x67;
/// <inheritdoc/>
public byte PassthroughType { get; set; } = JT808_SuBiao_Constants.JT808_0X0200_0x67;
/// <summary> /// <summary>
/// 盲区监测系统报警信息长度 /// 盲区监测系统报警信息长度
/// </summary> /// </summary>
@@ -34,7 +36,7 @@ namespace JT808.Protocol.Extensions.SuBiao.MessageBody
/// <summary> /// <summary>
/// 报警/事件类型 /// 报警/事件类型
/// </summary> /// </summary>
public byte AlarmOrEventType{ get; set; }
public byte AlarmOrEventType { get; set; }
/// <summary> /// <summary>
/// 报警/事件类型 /// 报警/事件类型
/// </summary> /// </summary>
@@ -182,12 +184,12 @@ namespace JT808.Protocol.Extensions.SuBiao.MessageBody
writer.WriteString($"[{value.AlarmTime.ToString("yyMMddHHmmss")}]日期时间", value.AlarmTime.ToString("yyyy-MM-dd HH:mm:ss")); writer.WriteString($"[{value.AlarmTime.ToString("yyMMddHHmmss")}]日期时间", value.AlarmTime.ToString("yyyy-MM-dd HH:mm:ss"));
value.VehicleState = reader.ReadUInt16(); value.VehicleState = reader.ReadUInt16();
writer.WriteNumber($"[{value.VehicleState.ReadNumber()}]车辆状态", value.VehicleState); writer.WriteNumber($"[{value.VehicleState.ReadNumber()}]车辆状态", value.VehicleState);
var vehicleStateBits=Convert.ToString(value.VehicleState, 2).PadLeft(16, '0');
var vehicleStateBits = Convert.ToString(value.VehicleState, 2).PadLeft(16, '0');
writer.WriteStartObject($"车辆状态对象[{vehicleStateBits}]"); 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[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[11]}]Bit4制动状态", vehicleStateBits[11] == '0' ? "未制动" : "制动");
writer.WriteString($"[{vehicleStateBits[10]}]Bit5插卡状态", vehicleStateBits[10] == '0' ? "未插卡" : "已插卡"); writer.WriteString($"[{vehicleStateBits[10]}]Bit5插卡状态", vehicleStateBits[10] == '0' ? "未插卡" : "已插卡");
writer.WriteString($"[{vehicleStateBits[9]}]Bit6自定义", vehicleStateBits[9].ToString()); writer.WriteString($"[{vehicleStateBits[9]}]Bit6自定义", vehicleStateBits[9].ToString());


+ 3
- 3
src/JT808.Protocol/Interfaces/IJT808_0x8900_Custom_Factory.cs Zobrazit soubor

@@ -1,7 +1,7 @@
using System;
using JT808.Protocol.MessageBody;
using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Text; using System.Text;
using JT808.Protocol.MessageBody;


namespace JT808.Protocol.Interfaces namespace JT808.Protocol.Interfaces
{ {
@@ -19,6 +19,6 @@ namespace JT808.Protocol.Interfaces
/// </summary> /// </summary>
/// <typeparam name="TJT808_0x8900_BodyBase"></typeparam> /// <typeparam name="TJT808_0x8900_BodyBase"></typeparam>
/// <returns></returns> /// <returns></returns>
IJT808_0x8900_Custom_Factory SetMap<TJT808_0x8900_BodyBase>();
IJT808_0x8900_Custom_Factory SetMap<TJT808_0x8900_BodyBase>() where TJT808_0x8900_BodyBase : JT808_0x8900_BodyBase;
} }
} }

+ 7
- 15
src/JT808.Protocol/Internal/JT808_0x8900_Custom_Factory.cs Zobrazit soubor

@@ -15,15 +15,15 @@ namespace JT808.Protocol.Internal


public void Register(Assembly externalAssembly) public void Register(Assembly externalAssembly)
{ {
foreach (var item in externalAssembly.GetTypes().Where(x => x.GetConstructor(Type.EmptyTypes) != default))
foreach (var item in externalAssembly.GetTypes().Where(x => x is JT808_0x8900_BodyBase && x.GetConstructor(Type.EmptyTypes) != default))
{ {
Register(item); Register(item);
} }
} }


public IJT808_0x8900_Custom_Factory SetMap<T>()
public IJT808_0x8900_Custom_Factory SetMap<TJT808_0x8900_BodyBase>() where TJT808_0x8900_BodyBase : JT808_0x8900_BodyBase
{ {
var type = typeof(T);
var type = typeof(TJT808_0x8900_BodyBase);
if (type.GetConstructor(Type.EmptyTypes) != default) if (type.GetConstructor(Type.EmptyTypes) != default)
{ {
Register(type); Register(type);
@@ -38,9 +38,9 @@ namespace JT808.Protocol.Internal
void Register(Type type) void Register(Type type)
{ {
var instance = Activator.CreateInstance(type); var instance = Activator.CreateInstance(type);
if (instance is JT808_0x0200_CustomBodyBase jT808_0X0200_Custom)
if (instance is JT808_0x8900_BodyBase jT808_0X8900_Custom)
{ {
var key = jT808_0X0200_Custom.AttachInfoId;
var key = jT808_0X8900_Custom.PassthroughType;
if (Map.ContainsKey(key)) if (Map.ContainsKey(key))
{ {
throw new ArgumentException($"{type.FullName} {key} An element with the same key already exists."); throw new ArgumentException($"{type.FullName} {key} An element with the same key already exists.");
@@ -50,17 +50,9 @@ namespace JT808.Protocol.Internal
Map.Add(key, instance); Map.Add(key, instance);
} }
} }
else if (instance is JT808_0x8900_BodyBase jT808_0X8900_Custom)
else
{ {
var key = jT808_0X8900_Custom.PassthroughType;
if (Map.ContainsKey(key))
{
throw new ArgumentException($"{type.FullName} {key} An element with the same key already exists.");
}
else
{
Map.Add(key, instance);
}
throw new ArgumentException($"{type.FullName} must be implement of {typeof(JT808_0x8900_BodyBase).FullName}.");
} }
} }
} }


Načítá se…
Zrušit
Uložit