From 57867a227eac67c7c71db51fb7f99126660bcb24 Mon Sep 17 00:00:00 2001
From: smallchi <564952747@qq.com>
Date: Wed, 4 Sep 2019 14:20:10 +0800
Subject: [PATCH] =?UTF-8?q?v2.1.6=201.=E5=B0=86=E5=A4=B4=E9=83=A8=E5=8C=85?=
=?UTF-8?q?=E5=BA=8F=E5=88=97=E5=8C=96=E5=99=A8=E5=88=86=E9=A1=B5=E5=B1=9E?=
=?UTF-8?q?=E6=80=A7=E5=8E=BB=E6=8E=89=202.=E5=A2=9E=E5=8A=A0Demo7?=
=?UTF-8?q?=E7=9A=84DI=E7=9A=84=E6=B5=8B=E8=AF=95=E7=94=A8=E4=BE=8B=203.?=
=?UTF-8?q?=E5=8E=BB=E6=8E=89=E6=97=A0=E7=94=A8=E9=A1=B9=E7=9B=AE=E4=BB=A5?=
=?UTF-8?q?=E5=8F=8A=E6=97=A0=E5=85=B3=E6=96=87=E4=BB=B6?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
...Extensions.DependencyInjection.Test.csproj | 27 --
.../JT808_0x0200_0x06Formatter.cs | 30 ---
.../JT808_0x0701TestBodiesImplFormatter.cs | 28 ---
.../JT808LocationAttachImpl0x06.cs | 21 --
.../JT808_0x0701TestBodiesImpl.cs | 16 --
.../Program.cs | 73 ------
.../appsettings.json | 5 -
.../DependencyInjectionExtensions.cs | 26 --
...ocol.Extensions.DependencyInjection.csproj | 31 ---
.../JT808.Protocol.Test.csproj | 1 +
src/JT808.Protocol.Test/Simples/Demo7.cs | 84 +++++++
src/JT808.Protocol.sln | 6 -
.../Formatters/JT808HeaderPackageFormatter.cs | 4 +-
src/JT808.Protocol/IJT808Builder.cs | 3 +-
src/JT808.Protocol/Internal/DefaultBuilder.cs | 2 -
src/JT808.Protocol/JT808.Protocol.csproj | 2 +-
src/JT808.Protocol/JT808GlobalConfig.cs | 140 -----------
src/JT808.Protocol/JT808HeaderPackage.cs | 8 -
.../Metadata/JT808AlarmProperty.cs | 237 ------------------
.../Metadata/JT808StatusProperty.cs | 236 -----------------
20 files changed, 89 insertions(+), 891 deletions(-)
delete mode 100644 src/JT808.Protocol.Extensions.DependencyInjection.Test/JT808.Protocol.Extensions.DependencyInjection.Test.csproj
delete mode 100644 src/JT808.Protocol.Extensions.DependencyInjection.Test/JT808Formatters/JT808_0x0200_0x06Formatter.cs
delete mode 100644 src/JT808.Protocol.Extensions.DependencyInjection.Test/JT808Formatters/JT808_0x0701TestBodiesImplFormatter.cs
delete mode 100644 src/JT808.Protocol.Extensions.DependencyInjection.Test/JT808LocationAttachExtensions/JT808LocationAttachImpl0x06.cs
delete mode 100644 src/JT808.Protocol.Extensions.DependencyInjection.Test/JT808LocationAttachExtensions/JT808_0x0701TestBodiesImpl.cs
delete mode 100644 src/JT808.Protocol.Extensions.DependencyInjection.Test/Program.cs
delete mode 100644 src/JT808.Protocol.Extensions.DependencyInjection.Test/appsettings.json
delete mode 100644 src/JT808.Protocol.Extensions.DependencyInjection/DependencyInjectionExtensions.cs
delete mode 100644 src/JT808.Protocol.Extensions.DependencyInjection/JT808.Protocol.Extensions.DependencyInjection.csproj
create mode 100644 src/JT808.Protocol.Test/Simples/Demo7.cs
delete mode 100644 src/JT808.Protocol/JT808GlobalConfig.cs
delete mode 100644 src/JT808.Protocol/Metadata/JT808AlarmProperty.cs
delete mode 100644 src/JT808.Protocol/Metadata/JT808StatusProperty.cs
diff --git a/src/JT808.Protocol.Extensions.DependencyInjection.Test/JT808.Protocol.Extensions.DependencyInjection.Test.csproj b/src/JT808.Protocol.Extensions.DependencyInjection.Test/JT808.Protocol.Extensions.DependencyInjection.Test.csproj
deleted file mode 100644
index 5fa242c..0000000
--- a/src/JT808.Protocol.Extensions.DependencyInjection.Test/JT808.Protocol.Extensions.DependencyInjection.Test.csproj
+++ /dev/null
@@ -1,27 +0,0 @@
-
-
-
- Exe
- netcoreapp2.2
- latest
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- Always
-
-
-
-
diff --git a/src/JT808.Protocol.Extensions.DependencyInjection.Test/JT808Formatters/JT808_0x0200_0x06Formatter.cs b/src/JT808.Protocol.Extensions.DependencyInjection.Test/JT808Formatters/JT808_0x0200_0x06Formatter.cs
deleted file mode 100644
index 5bd47f6..0000000
--- a/src/JT808.Protocol.Extensions.DependencyInjection.Test/JT808Formatters/JT808_0x0200_0x06Formatter.cs
+++ /dev/null
@@ -1,30 +0,0 @@
-using JT808.Protocol.Formatters;
-using JT808.Protocol.Interfaces;
-using JT808.Protocol.MessagePack;
-using System;
-
-namespace JT808.Protocol.Extensions.DependencyInjection.Test.JT808LocationAttach
-{
- public class JT808_0x0200_0x06Formatter : IJT808MessagePackFormatter
- {
- public JT808LocationAttachImpl0x06 Deserialize(ref JT808MessagePackReader reader, IJT808Config config)
- {
- JT808LocationAttachImpl0x06 jT808LocationAttachImpl0x06 = new JT808LocationAttachImpl0x06() { };
- jT808LocationAttachImpl0x06.AttachInfoId = reader.ReadByte();
- jT808LocationAttachImpl0x06.AttachInfoLength = reader.ReadByte();
- jT808LocationAttachImpl0x06.Age = reader.ReadInt32();
- jT808LocationAttachImpl0x06.Gender = reader.ReadByte();
- jT808LocationAttachImpl0x06.UserName = reader.ReadRemainStringContent();
- return jT808LocationAttachImpl0x06;
- }
-
- public void Serialize(ref JT808MessagePackWriter writer, JT808LocationAttachImpl0x06 value, IJT808Config config)
- {
- writer.WriteByte(value.AttachInfoId);
- writer.WriteByte( value.AttachInfoLength);
- writer.WriteInt32(value.Age);
- writer.WriteByte(value.Gender);
- writer.WriteString(value.UserName);
- }
- }
-}
diff --git a/src/JT808.Protocol.Extensions.DependencyInjection.Test/JT808Formatters/JT808_0x0701TestBodiesImplFormatter.cs b/src/JT808.Protocol.Extensions.DependencyInjection.Test/JT808Formatters/JT808_0x0701TestBodiesImplFormatter.cs
deleted file mode 100644
index a47c564..0000000
--- a/src/JT808.Protocol.Extensions.DependencyInjection.Test/JT808Formatters/JT808_0x0701TestBodiesImplFormatter.cs
+++ /dev/null
@@ -1,28 +0,0 @@
-using JT808.Protocol.Extensions.DependencyInjection.Test.JT808_0x0701BodiesImpl;
-using JT808.Protocol.Formatters;
-using JT808.Protocol.Interfaces;
-using JT808.Protocol.MessagePack;
-using System;
-
-namespace JT808.Protocol.Extensions.DependencyInjection.Test.JT808Formatters
-{
- public class JT808_0x0701TestBodiesImplFormatter : IJT808MessagePackFormatter
- {
- public JT808_0x0701TestBodiesImpl Deserialize(ref JT808MessagePackReader reader, IJT808Config config)
- {
- JT808_0x0701TestBodiesImpl jT808_0X0701TestBodiesImpl = new JT808_0x0701TestBodiesImpl();
- jT808_0X0701TestBodiesImpl.Id = reader.ReadUInt32();
- jT808_0X0701TestBodiesImpl.UserNameLength = reader.ReadUInt16();
- return jT808_0X0701TestBodiesImpl;
- }
-
- public void Serialize(ref JT808MessagePackWriter writer, JT808_0x0701TestBodiesImpl value, IJT808Config config)
- {
- writer.WriteUInt32(value.Id);
- // 先计算内容长度(汉字为两个字节)
- writer.Skip(2, out int position);
- writer.WriteString(value.UserName);
- writer.WriteUInt16Return((ushort)(writer.GetCurrentPosition()- position-2), position);
- }
- }
-}
diff --git a/src/JT808.Protocol.Extensions.DependencyInjection.Test/JT808LocationAttachExtensions/JT808LocationAttachImpl0x06.cs b/src/JT808.Protocol.Extensions.DependencyInjection.Test/JT808LocationAttachExtensions/JT808LocationAttachImpl0x06.cs
deleted file mode 100644
index 8a3dba7..0000000
--- a/src/JT808.Protocol.Extensions.DependencyInjection.Test/JT808LocationAttachExtensions/JT808LocationAttachImpl0x06.cs
+++ /dev/null
@@ -1,21 +0,0 @@
-using JT808.Protocol.Attributes;
-using JT808.Protocol.MessageBody;
-
-namespace JT808.Protocol.Extensions.DependencyInjection.Test.JT808LocationAttach
-{
- ///
- /// 自定义附加信息
- /// Age-word-2
- /// UserName-BCD(10)
- /// Gerder-byte-1
- ///
- [JT808Formatter(typeof(JT808_0x0200_0x06Formatter))]
- public class JT808LocationAttachImpl0x06 : JT808_0x0200_BodyBase
- {
- public override byte AttachInfoId { get; set; } = 0x06;
- public override byte AttachInfoLength { get; set; } = 13;
- public int Age { get; set; }
- public byte Gender { get; set; }
- public string UserName { get; set; }
- }
-}
diff --git a/src/JT808.Protocol.Extensions.DependencyInjection.Test/JT808LocationAttachExtensions/JT808_0x0701TestBodiesImpl.cs b/src/JT808.Protocol.Extensions.DependencyInjection.Test/JT808LocationAttachExtensions/JT808_0x0701TestBodiesImpl.cs
deleted file mode 100644
index 771fdd5..0000000
--- a/src/JT808.Protocol.Extensions.DependencyInjection.Test/JT808LocationAttachExtensions/JT808_0x0701TestBodiesImpl.cs
+++ /dev/null
@@ -1,16 +0,0 @@
-using JT808.Protocol.Attributes;
-using JT808.Protocol.Extensions.DependencyInjection.Test.JT808Formatters;
-using JT808.Protocol.MessageBody;
-
-namespace JT808.Protocol.Extensions.DependencyInjection.Test.JT808_0x0701BodiesImpl
-{
- [JT808Formatter(typeof(JT808_0x0701TestBodiesImplFormatter))]
- public class JT808_0x0701TestBodiesImpl : JT808_0x0701_CustomBodyBase
- {
- public uint Id { get; set; }
-
- public ushort UserNameLength { get; set; }
-
- public string UserName { get; set; }
- }
-}
diff --git a/src/JT808.Protocol.Extensions.DependencyInjection.Test/Program.cs b/src/JT808.Protocol.Extensions.DependencyInjection.Test/Program.cs
deleted file mode 100644
index f634060..0000000
--- a/src/JT808.Protocol.Extensions.DependencyInjection.Test/Program.cs
+++ /dev/null
@@ -1,73 +0,0 @@
-using Microsoft.Extensions.Configuration;
-using Microsoft.Extensions.Hosting;
-using Microsoft.Extensions.DependencyInjection;
-using System;
-using System.Threading.Tasks;
-using System.Linq;
-using JT808.Protocol.Extensions.DependencyInjection.Test.JT808LocationAttach;
-using JT808.Protocol.Extensions.DependencyInjection.Test.JT808_0x0701BodiesImpl;
-using System.Reflection;
-using JT808.Protocol.Interfaces;
-
-namespace JT808.Protocol.Extensions.DependencyInjection.Test
-{
- class Program
- {
- static void Main(string[] args)
- {
- //单个
- IServiceCollection serviceDescriptors1 = new ServiceCollection();
- serviceDescriptors1.AddJT808Configure(new DefaultConfig());
- var ServiceProvider1 = serviceDescriptors1.BuildServiceProvider();
- var defaultConfig = ServiceProvider1.GetRequiredService();
-
- //多个
- IServiceCollection serviceDescriptors2 = new ServiceCollection();
- serviceDescriptors2.AddJT808Configure(new Config1());
- serviceDescriptors2.AddJT808Configure(new Config2());
- serviceDescriptors2.AddSingleton(factory =>
- {
- Func accesor = key =>
- {
- if (key.Equals("Config1"))
- {
- return factory.GetService();
- }
- else if (key.Equals("Config2"))
- {
- return factory.GetService();
- }
- else
- {
- throw new ArgumentException($"Not Support key : {key}");
- }
- };
- return accesor;
- });
-
- var ServiceProvider2 = serviceDescriptors2.BuildServiceProvider();
-
- var config1 = ServiceProvider2.GetRequiredService>()("Config1");
- var flag21 = config1.GetSerializer().SerializerId == "Config1";
-
- var config2 = ServiceProvider2.GetRequiredService>()("Config2");
- var flag22 = config2.GetSerializer().SerializerId == "Config2";
- }
- }
-
- public class DefaultConfig : GlobalConfigBase
- {
- public override string ConfigId => "test";
- }
-
- public class Config1 : GlobalConfigBase
- {
- public override string ConfigId => "Config1";
- }
-
- public class Config2 : GlobalConfigBase
- {
- public override string ConfigId => "Config2";
- }
-}
-
diff --git a/src/JT808.Protocol.Extensions.DependencyInjection.Test/appsettings.json b/src/JT808.Protocol.Extensions.DependencyInjection.Test/appsettings.json
deleted file mode 100644
index bf7af53..0000000
--- a/src/JT808.Protocol.Extensions.DependencyInjection.Test/appsettings.json
+++ /dev/null
@@ -1,5 +0,0 @@
-{
- "JT809Options": {
- "SkipCRCCode": false
- }
-}
diff --git a/src/JT808.Protocol.Extensions.DependencyInjection/DependencyInjectionExtensions.cs b/src/JT808.Protocol.Extensions.DependencyInjection/DependencyInjectionExtensions.cs
deleted file mode 100644
index 261b33b..0000000
--- a/src/JT808.Protocol.Extensions.DependencyInjection/DependencyInjectionExtensions.cs
+++ /dev/null
@@ -1,26 +0,0 @@
-using JT808.Protocol.Interfaces;
-using Microsoft.Extensions.DependencyInjection;
-
-namespace JT808.Protocol.Extensions.DependencyInjection
-{
- public static class DependencyInjectionExtensions
- {
- public static IServiceCollection AddJT808Configure(this IServiceCollection services, IJT808Config jT808Config)
- {
- services.AddSingleton(jT808Config.GetType(), jT808Config);
- services.AddSingleton(jT808Config);
- return services;
- }
-
- public static IServiceCollection AddJT808Configure(this IServiceCollection services)
- {
- services.AddSingleton(new DefaultGlobalConfig());
- return services;
- }
-
- class DefaultGlobalConfig : GlobalConfigBase
- {
- public override string ConfigId => "default";
- }
- }
-}
diff --git a/src/JT808.Protocol.Extensions.DependencyInjection/JT808.Protocol.Extensions.DependencyInjection.csproj b/src/JT808.Protocol.Extensions.DependencyInjection/JT808.Protocol.Extensions.DependencyInjection.csproj
deleted file mode 100644
index 223b4d4..0000000
--- a/src/JT808.Protocol.Extensions.DependencyInjection/JT808.Protocol.Extensions.DependencyInjection.csproj
+++ /dev/null
@@ -1,31 +0,0 @@
-
-
-
- netcoreapp2.2
- 7.3
- Copyright 2018.
- SmallChi
- JT808.Extensions.DependencyInjection
- JT808.Extensions.DependencyInjection
- JT808协议依赖注入扩展包
- JT808协议依赖注入扩展包
- false
- https://github.com/SmallChi/JT808
- https://github.com/SmallChi/JT808
- https://github.com/SmallChi/JT808/blob/master/LICENSE
- true
- 2.0.0
-
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/src/JT808.Protocol.Test/JT808.Protocol.Test.csproj b/src/JT808.Protocol.Test/JT808.Protocol.Test.csproj
index a22cc5d..24ac33b 100644
--- a/src/JT808.Protocol.Test/JT808.Protocol.Test.csproj
+++ b/src/JT808.Protocol.Test/JT808.Protocol.Test.csproj
@@ -102,6 +102,7 @@
+
diff --git a/src/JT808.Protocol.Test/Simples/Demo7.cs b/src/JT808.Protocol.Test/Simples/Demo7.cs
new file mode 100644
index 0000000..11176b5
--- /dev/null
+++ b/src/JT808.Protocol.Test/Simples/Demo7.cs
@@ -0,0 +1,84 @@
+using JT808.Protocol.Interfaces;
+using Microsoft.Extensions.DependencyInjection;
+using System;
+using System.Collections.Generic;
+using System.Text;
+using Xunit;
+
+namespace JT808.Protocol.Test.Simples
+{
+ public class Demo7
+ {
+ ///
+ /// 单个
+ ///
+ [Fact]
+ public void Test1()
+ {
+ IServiceCollection serviceDescriptors1 = new ServiceCollection();
+ serviceDescriptors1.AddJT808Configure(new DefaultConfig());
+ var serviceProvider1 = serviceDescriptors1.BuildServiceProvider();
+ var config = serviceProvider1.GetRequiredService();
+ var defaultConfig = (DefaultConfig)config;
+ Assert.Equal("test", defaultConfig.ConfigId);
+ Assert.Equal("smallchi", defaultConfig.Test());
+ }
+
+ ///
+ /// 多个
+ ///
+ [Fact]
+ public void Test2()
+ {
+ IServiceCollection serviceDescriptors2 = new ServiceCollection();
+ serviceDescriptors2.AddJT808Configure(new Config1());
+ serviceDescriptors2.AddJT808Configure(new Config2());
+ serviceDescriptors2.AddSingleton(factory =>
+ {
+ Func accesor = key =>
+ {
+ if (key.Equals("Config1"))
+ {
+ return factory.GetService();
+ }
+ else if (key.Equals("Config2"))
+ {
+ return factory.GetService();
+ }
+ else
+ {
+ throw new ArgumentException($"Not Support key : {key}");
+ }
+ };
+ return accesor;
+ });
+ var ServiceProvider2 = serviceDescriptors2.BuildServiceProvider();
+ var config1 = ServiceProvider2.GetRequiredService>()("Config1");
+ Assert.Equal("Config1", config1.ConfigId);
+ Assert.Equal("Config1", config1.GetSerializer().SerializerId);
+ var config2 = ServiceProvider2.GetRequiredService>()("Config2");
+ Assert.Equal("Config2", config2.ConfigId);
+ Assert.Equal("Config2", config2.GetSerializer().SerializerId);
+ }
+
+ public class DefaultConfig : GlobalConfigBase
+ {
+ public override string ConfigId => "test";
+
+ public string Test()
+ {
+ return "smallchi";
+ }
+ }
+
+ public class Config1 : GlobalConfigBase
+ {
+ public override string ConfigId => "Config1";
+ }
+
+ public class Config2 : GlobalConfigBase
+ {
+ public override string ConfigId => "Config2";
+ }
+ }
+}
diff --git a/src/JT808.Protocol.sln b/src/JT808.Protocol.sln
index 968c2e7..47ea931 100644
--- a/src/JT808.Protocol.sln
+++ b/src/JT808.Protocol.sln
@@ -15,8 +15,6 @@ 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("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "JT808.Protocol.Extensions.DependencyInjection.Test", "JT808.Protocol.Extensions.DependencyInjection.Test\JT808.Protocol.Extensions.DependencyInjection.Test.csproj", "{B5B337C9-5C40-4DFD-BC8D-B0EA7F2F2F15}"
-EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
@@ -35,10 +33,6 @@ 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
- {B5B337C9-5C40-4DFD-BC8D-B0EA7F2F2F15}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
- {B5B337C9-5C40-4DFD-BC8D-B0EA7F2F2F15}.Debug|Any CPU.Build.0 = Debug|Any CPU
- {B5B337C9-5C40-4DFD-BC8D-B0EA7F2F2F15}.Release|Any CPU.ActiveCfg = Release|Any CPU
- {B5B337C9-5C40-4DFD-BC8D-B0EA7F2F2F15}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
diff --git a/src/JT808.Protocol/Formatters/JT808HeaderPackageFormatter.cs b/src/JT808.Protocol/Formatters/JT808HeaderPackageFormatter.cs
index 418af5b..f678d22 100644
--- a/src/JT808.Protocol/Formatters/JT808HeaderPackageFormatter.cs
+++ b/src/JT808.Protocol/Formatters/JT808HeaderPackageFormatter.cs
@@ -39,9 +39,9 @@ namespace JT808.Protocol.Formatters
if (jT808Package.Header.MessageBodyProperty.IsPackage)
{
//3.5.1.读取消息包总数
- jT808Package.PackgeCount = reader.ReadUInt16();
+ jT808Package.Header.PackgeCount = reader.ReadUInt16();
//3.5.2.读取消息包序号
- jT808Package.PackageIndex = reader.ReadUInt16();
+ jT808Package.Header.PackageIndex = reader.ReadUInt16();
}
// 4.处理数据体
// 4.1.判断有无数据体
diff --git a/src/JT808.Protocol/IJT808Builder.cs b/src/JT808.Protocol/IJT808Builder.cs
index fee3826..25ef952 100644
--- a/src/JT808.Protocol/IJT808Builder.cs
+++ b/src/JT808.Protocol/IJT808Builder.cs
@@ -8,8 +8,7 @@ namespace JT808.Protocol
{
public interface IJT808Builder
{
- IServiceCollection Services { get; }
-
IJT808Config Config { get; }
+ IServiceCollection Services { get; }
}
}
diff --git a/src/JT808.Protocol/Internal/DefaultBuilder.cs b/src/JT808.Protocol/Internal/DefaultBuilder.cs
index 65e0d01..f57b170 100644
--- a/src/JT808.Protocol/Internal/DefaultBuilder.cs
+++ b/src/JT808.Protocol/Internal/DefaultBuilder.cs
@@ -9,9 +9,7 @@ namespace JT808.Protocol.Internal
class DefaultBuilder : IJT808Builder
{
public IServiceCollection Services { get; }
-
public IJT808Config Config { get; }
-
public DefaultBuilder(IServiceCollection services, IJT808Config config)
{
Services = services;
diff --git a/src/JT808.Protocol/JT808.Protocol.csproj b/src/JT808.Protocol/JT808.Protocol.csproj
index 5a1c864..d20656a 100644
--- a/src/JT808.Protocol/JT808.Protocol.csproj
+++ b/src/JT808.Protocol/JT808.Protocol.csproj
@@ -14,7 +14,7 @@
https://github.com/SmallChi/JT808/blob/master/LICENSE
https://github.com/SmallChi/JT808/blob/master/LICENSE
false
- 2.1.3
+ 2.1.6
LICENSE
diff --git a/src/JT808.Protocol/JT808GlobalConfig.cs b/src/JT808.Protocol/JT808GlobalConfig.cs
deleted file mode 100644
index bd3e6e9..0000000
--- a/src/JT808.Protocol/JT808GlobalConfig.cs
+++ /dev/null
@@ -1,140 +0,0 @@
-using JT808.Protocol.Formatters;
-using JT808.Protocol.Interfaces;
-using JT808.Protocol.Internal;
-using System;
-using System.Reflection;
-using System.Runtime.CompilerServices;
-using System.Text;
-
-[assembly: InternalsVisibleTo("JT808.Protocol.Benchmark")]
-[assembly: InternalsVisibleTo("JT808.Protocol.Test")]
-namespace JT808.Protocol
-{
- public class JT808GlobalConfig
- {
- public static readonly JT808GlobalConfig Instance = new JT808GlobalConfig();
-
- public JT808GlobalConfig()
- {
- Encoding.RegisterProvider(CodePagesEncodingProvider.Instance);
- MsgSNDistributed = new DefaultMsgSNDistributedImpl();
- Compress = new JT808GZipCompressImpl();
- SplitPackageStrategy = new DefaultSplitPackageStrategyImpl();
- SkipCRCCode = false;
- MsgIdFactory = new JT808MsgIdFactory();
- Encoding = Encoding.GetEncoding("GBK");
- FormatterFactory = new JT808FormatterFactory();
- JT808_0X0200_Custom_Factory = new JT808_0x0200_Custom_Factory();
- JT808_0X8103_Custom_Factory = new JT808_0x8103_Custom_Factory();
- }
-
- public IJT808MsgSNDistributed MsgSNDistributed { get; private set; }
-
- public IJT808Compress Compress { get; private set; }
-
- public IJT808SplitPackageStrategy SplitPackageStrategy { get; private set; }
-
- public IJT808MsgIdFactory MsgIdFactory { get; private set; }
-
- public Encoding Encoding;
-
- ///
- /// 序列化器工厂
- ///
- internal IJT808FormatterFactory FormatterFactory { get; }
-
- ///
- /// 自定义附加信息工厂
- ///
- internal IJT808_0x0200_Custom_Factory JT808_0X0200_Custom_Factory { get; }
-
- ///
- ///自定义设置终端参数工厂
- ///
- internal IJT808_0x8103_Custom_Factory JT808_0X8103_Custom_Factory { get; }
-
- ///
- /// 跳过校验码
- /// 测试的时候需要手动修改值,避免验证
- /// 默认:false
- ///
- public bool SkipCRCCode { get; private set; }
-
-
- ///
- /// 设置消息序列号
- ///
- ///
- ///
- public JT808GlobalConfig SetMsgSNDistributed(IJT808MsgSNDistributed msgSNDistributed)
- {
- Instance.MsgSNDistributed = msgSNDistributed;
- return this;
- }
-
- ///
- /// 设置压缩算法
- /// 默认GZip
- ///
- ///
- ///
- public JT808GlobalConfig SetCompress(IJT808Compress compressImpl)
- {
- Instance.Compress = compressImpl;
- return this;
- }
- ///
- /// 设置分包算法
- /// 默认3*256
- ///
- ///
- ///
- public JT808GlobalConfig SetSplitPackageStrategy(IJT808SplitPackageStrategy splitPackageStrategy)
- {
- Instance.SplitPackageStrategy = splitPackageStrategy;
- return this;
- }
- ///
- /// 设置跳过校验码
- /// 场景:测试的时候,可能需要手动改数据,所以测试的时候有用
- ///
- ///
- ///
- public JT808GlobalConfig SetSkipCRCCode(bool skipCRCCode)
- {
- Instance.SkipCRCCode = skipCRCCode;
- return this;
- }
- ///
- /// 设置消息工厂的实现
- ///
- ///
- ///
- public JT808GlobalConfig SetMsgIdFactory(IJT808MsgIdFactory msgIdFactory)
- {
- if (msgIdFactory != null)
- {
- Instance.MsgIdFactory = msgIdFactory;
- }
- return this;
- }
- ///
- /// 全局注册外部程序集
- ///
- ///
- ///
- public JT808GlobalConfig Register(params Assembly[] externalAssemblies)
- {
- if (externalAssemblies != null)
- {
- foreach(var easb in externalAssemblies)
- {
- FormatterFactory.Register(easb);
- JT808_0X0200_Custom_Factory.Register(easb);
- JT808_0X8103_Custom_Factory.Register(easb);
- }
- }
- return this;
- }
- }
-}
diff --git a/src/JT808.Protocol/JT808HeaderPackage.cs b/src/JT808.Protocol/JT808HeaderPackage.cs
index 5dad03c..e648389 100644
--- a/src/JT808.Protocol/JT808HeaderPackage.cs
+++ b/src/JT808.Protocol/JT808HeaderPackage.cs
@@ -30,13 +30,5 @@ namespace JT808.Protocol
/// 终止符
///
public byte End { get; set; }
- ///
- /// 消息总包数
- ///
- public ushort PackgeCount { get; set; }
- ///
- /// 报序号 从1开始
- ///
- public ushort PackageIndex { get; set; }
}
}
diff --git a/src/JT808.Protocol/Metadata/JT808AlarmProperty.cs b/src/JT808.Protocol/Metadata/JT808AlarmProperty.cs
deleted file mode 100644
index 3f4bc8a..0000000
--- a/src/JT808.Protocol/Metadata/JT808AlarmProperty.cs
+++ /dev/null
@@ -1,237 +0,0 @@
-using System;
-
-namespace JT808.Protocol.Metadata
-{
- ///
- /// 报警标志位定义
- ///
- public class JT808AlarmProperty
- {
- private const int bitCount = 32;
- ///
- /// 初始化读取报警标志位
- ///
- ///
- public JT808AlarmProperty(string alarmStr)
- {
- Bit0 = alarmStr[0];
- Bit1 = alarmStr[1];
- Bit2 = alarmStr[2];
- Bit3 = alarmStr[3];
- Bit4 = alarmStr[4];
- Bit5 = alarmStr[5];
- Bit6 = alarmStr[6];
- Bit7 = alarmStr[7];
- Bit8 = alarmStr[8];
- Bit9 = alarmStr[9];
- Bit10 = alarmStr[10];
- Bit11 = alarmStr[11];
- Bit12 = alarmStr[12];
- Bit13 = alarmStr[13];
- Bit14 = alarmStr[14];
- Bit15 = alarmStr[15];
- Bit16 = alarmStr[16];
- Bit17 = alarmStr[17];
- Bit18 = alarmStr[18];
- Bit19 = alarmStr[19];
- Bit20 = alarmStr[20];
- Bit21 = alarmStr[21];
- Bit22 = alarmStr[22];
- Bit23 = alarmStr[23];
- Bit24 = alarmStr[24];
- Bit25 = alarmStr[25];
- Bit26 = alarmStr[26];
- Bit27 = alarmStr[27];
- Bit28 = alarmStr[28];
- Bit29 = alarmStr[29];
- Bit30 = alarmStr[30];
- Bit31 = alarmStr[31];
- }
-
- ///
- /// 写入报警标志位
- /// 从左开始写入,不满32位自动补'0'
- ///
- ///
- public JT808AlarmProperty(params char[] alarmChar)
- {
- alarmChar = alarmChar ?? new char[32];
- ReadOnlySpan span = alarmChar.ToString().PadRight(32, '0').AsSpan();
- Bit0 = span[0];
- Bit1 = span[1];
- Bit2 = span[2];
- Bit3 = span[3];
- Bit4 = span[4];
- Bit5 = span[5];
- Bit6 = span[6];
- Bit7 = span[7];
- Bit8 = span[8];
- Bit9 = span[9];
- Bit10 = span[10];
- Bit11 = span[11];
- Bit12 = span[12];
- Bit13 = span[13];
- Bit14 = span[14];
- Bit15 = span[15];
- Bit16 = span[16];
- Bit17 = span[17];
- Bit18 = span[18];
- Bit19 = span[19];
- Bit20 = span[20];
- Bit21 = span[21];
- Bit22 = span[22];
- Bit23 = span[23];
- Bit24 = span[24];
- Bit25 = span[25];
- Bit26 = span[26];
- Bit27 = span[27];
- Bit28 = span[28];
- Bit29 = span[29];
- Bit30 = span[30];
- Bit31 = span[31];
- }
-
- ///
- /// 1:紧急报警,触动报警开关后触发 收到应答后清零
- ///
- public char Bit0 { get; set; }
- ///
- /// 1:超速报警 标志维持至报警条件解除
- ///
- public char Bit1 { get; set; }
- ///
- /// 1:疲劳驾驶 标志维持至报警条件解除
- ///
- public char Bit2 { get; set; }
- ///
- /// 1:危险预警 收到应答后清零
- ///
- public char Bit3 { get; set; }
- ///
- /// GNSS模块发生故障 标志维持至报警条件解除
- ///
- public char Bit4 { get; set; }
- ///
- /// GNSS天线未接或被剪断 标志维持至报警条件解除
- ///
- public char Bit5 { get; set; }
- ///
- /// GNSS天线短路 标志维持至报警条件解除
- ///
- public char Bit6 { get; set; }
- ///
- /// 终端主电源欠压 标志维持至报警条件解除
- ///
- public char Bit7 { get; set; }
- ///
- /// 终端主电源掉电 标志维持至报警条件解除
- ///
- public char Bit8 { get; set; }
- ///
- /// 终端LCD或显示器故障 标志维持至报警条件解除
- ///
- public char Bit9 { get; set; }
- ///
- /// TTS模块故障 标志维持至报警条件解除
- ///
- public char Bit10 { get; set; }
- ///
- /// 摄像头故障 标志维持至报警条件解除
- ///
- public char Bit11 { get; set; }
- ///
- /// 道路运输证IC卡模块故障 标志维持至报警条件解除
- ///
- public char Bit12 { get; set; }
- ///
- /// 超速预警 标志维持至报警条件解除
- ///
- public char Bit13 { get; set; }
- ///
- /// 疲劳驾驶预警 标志维持至报警条件解除
- ///
- public char Bit14 { get; set; }
- ///
- /// 保留15
- ///
- public char Bit15 { get; set; }
- ///
- /// 保留16
- ///
- public char Bit16 { get; set; }
- ///
- /// 保留17
- ///
- public char Bit17 { get; set; }
- ///
- /// 当天累计驾驶超时 标志维持至报警条件解除
- ///
- public char Bit18 { get; set; }
- ///
- /// 超时停车 标志维持至报警条件解除
- ///
- public char Bit19 { get; set; }
- ///
- /// 进出区域 收到应答后清零
- ///
- public char Bit20 { get; set; }
- ///
- /// 进出路线 收到应答后清零
- ///
- public char Bit21 { get; set; }
- ///
- /// 路段行驶时间不足或过长 收到应答后清零
- ///
- public char Bit22 { get; set; }
- ///
- /// 路线偏离报警 标志维持至报警条件解除
- ///
- public char Bit23 { get; set; }
- ///
- /// 车辆VSS故障 标志维持至报警条件解除
- ///
- public char Bit24 { get; set; }
- ///
- /// 车辆油量异常 标志维持至报警条件解除
- ///
- public char Bit25 { get; set; }
- ///
- /// 车辆被盗通过车辆防盗器 标志维持至报警条件解除
- ///
- public char Bit26 { get; set; }
- ///
- /// 车辆非法点火
- ///
- public char Bit27 { get; set; }
- ///
- /// 车辆非法位移 收到应答后清零
- ///
- public char Bit28 { get; set; }
- ///
- /// 碰撞预警 标志维持至报警条件解除
- ///
- public char Bit29 { get; set; }
- ///
- /// 侧翻预警 标志维持至报警条件解除
- ///
- public char Bit30 { get; set; }
- ///
- /// 非法开门报警 (终端未设置区域时,不判断非法开门)收到应答后清零
- ///
- public char Bit31 { get; set; }
-
- ///
- /// 报警标志位
- ///
- ///
- public override string ToString()
- {
- Span span = new char[bitCount];
- for (int i = 0; i < span.Length; i++)
- {
- span[i] = (char)this.GetType().GetProperty("Bit" + i.ToString()).GetValue(this);
- }
- return span.ToString();
- }
- }
-}
diff --git a/src/JT808.Protocol/Metadata/JT808StatusProperty.cs b/src/JT808.Protocol/Metadata/JT808StatusProperty.cs
deleted file mode 100644
index 9598219..0000000
--- a/src/JT808.Protocol/Metadata/JT808StatusProperty.cs
+++ /dev/null
@@ -1,236 +0,0 @@
-using System;
-
-namespace JT808.Protocol.Metadata
-{
- ///
- /// 状态位
- ///
- public struct JT808StatusProperty
- {
- ///
- /// 初始化读取状态位
- ///
- ///
- public JT808StatusProperty(string alarmStr)
- {
- Bit0 = alarmStr[0];
- Bit1 = alarmStr[1];
- Bit2 = alarmStr[2];
- Bit3 = alarmStr[3];
- Bit4 = alarmStr[4];
- Bit5 = alarmStr[5];
- Bit6 = alarmStr[6];
- Bit7 = alarmStr[7];
- Bit8 = alarmStr[8];
- Bit9 = alarmStr[9];
- Bit10 = alarmStr[10];
- Bit11 = alarmStr[11];
- Bit12 = alarmStr[12];
- Bit13 = alarmStr[13];
- Bit14 = alarmStr[14];
- Bit15 = alarmStr[15];
- Bit16 = alarmStr[16];
- Bit17 = alarmStr[17];
- Bit18 = alarmStr[18];
- Bit19 = alarmStr[19];
- Bit20 = alarmStr[20];
- Bit21 = alarmStr[21];
- Bit22 = alarmStr[22];
- Bit23 = alarmStr[23];
- Bit24 = alarmStr[24];
- Bit25 = alarmStr[25];
- Bit26 = alarmStr[26];
- Bit27 = alarmStr[27];
- Bit28 = alarmStr[28];
- Bit29 = alarmStr[29];
- Bit30 = alarmStr[30];
- Bit31 = alarmStr[31];
- }
-
- ///
- /// 写入状态位
- /// 从左开始写入,不满32位自动补'0'
- ///
- ///
- public JT808StatusProperty(params char[] alarmChar)
- {
- alarmChar = alarmChar ?? new char[32];
- ReadOnlySpan span = alarmChar.ToString().PadRight(32, '0').AsSpan();
- Bit0 = span[0];
- Bit1 = span[1];
- Bit2 = span[2];
- Bit3 = span[3];
- Bit4 = span[4];
- Bit5 = span[5];
- Bit6 = span[6];
- Bit7 = span[7];
- Bit8 = span[8];
- Bit9 = span[9];
- Bit10 = span[10];
- Bit11 = span[11];
- Bit12 = span[12];
- Bit13 = span[13];
- Bit14 = span[14];
- Bit15 = span[15];
- Bit16 = span[16];
- Bit17 = span[17];
- Bit18 = span[18];
- Bit19 = span[19];
- Bit20 = span[20];
- Bit21 = span[21];
- Bit22 = span[22];
- Bit23 = span[23];
- Bit24 = span[24];
- Bit25 = span[25];
- Bit26 = span[26];
- Bit27 = span[27];
- Bit28 = span[28];
- Bit29 = span[29];
- Bit30 = span[30];
- Bit31 = span[31];
- }
-
- ///
- /// 0:ACC 关;1: ACC 开
- ///
- public char Bit0 { get; set; }
- ///
- /// 0:未定位;1:定位
- ///
- public char Bit1 { get; set; }
- ///
- /// 0:北纬;1:南纬
- ///
- public char Bit2 { get; set; }
- ///
- /// 0:东经;1:西经
- ///
- public char Bit3 { get; set; }
- ///
- /// 0:运营状态;1:停运状态
- ///
- public char Bit4 { get; set; }
- ///
- /// 0:经纬度未经保密插件加密;1:经纬度已经保密插件加密
- ///
- public char Bit5 { get; set; }
- ///
- /// 保留
- ///
- public char Bit6 { get; set; }
- ///
- /// 保留
- ///
- public char Bit7 { get; set; }
- ///
- /// 00:空车;01:半载;10:保留;11:满载(可用于客车的空、重车及货车的空载、满载状态表示,人工输入或传感器获取)
- ///
- public char Bit8 { get; set; }
- ///
- /// 00:空车;01:半载;10:保留;11:满载(可用于客车的空、重车及货车的空载、满载状态表示,人工输入或传感器获取)
- ///
- public char Bit9 { get; set; }
- ///
- /// 0:车辆油路正常;1:车辆油路断开
- ///
- public char Bit10 { get; set; }
- ///
- /// 0:车辆电路正常;1:车辆电路断开
- ///
- public char Bit11 { get; set; }
- ///
- /// 0:车门解锁;1:车门加锁
- ///
- public char Bit12 { get; set; }
- ///
- /// 0:门 1 关;1:门 1 开(前门)
- ///
- public char Bit13 { get; set; }
- ///
- /// 0:门 2 关;1:门 2 开(中门)
- ///
- public char Bit14 { get; set; }
- ///
- /// 0:门 3 关;1:门 3 开(后门)
- ///
- public char Bit15 { get; set; }
- ///
- /// 0:门 4 关;1:门 4 开(驾驶席门)
- ///
- public char Bit16 { get; set; }
- ///
- /// 0:门 5 关;1:门 5 开(自定义)
- ///
- public char Bit17 { get; set; }
- ///
- /// 0:未使用 GPS 卫星进行定位;1:使用 GPS 卫星进行定位
- ///
- public char Bit18 { get; set; }
- ///
- /// 0:未使用北斗卫星进行定位;1:使用北斗卫星进行定位
- ///
- public char Bit19 { get; set; }
- ///
- /// 0:未使用 GLONASS 卫星进行定位;1:使用 GLONASS 卫星进行定位
- ///
- public char Bit20 { get; set; }
- ///
- /// 0:未使用 Galileo 卫星进行定位;1:使用 Galileo 卫星进行定位
- ///
- public char Bit21 { get; set; }
- ///
- /// 保留
- ///
- public char Bit22 { get; set; }
- ///
- /// 保留
- ///
- public char Bit23 { get; set; }
- ///
- /// 保留
- ///
- public char Bit24 { get; set; }
- ///
- /// 保留
- ///
- public char Bit25 { get; set; }
- ///
- /// 保留
- ///
- public char Bit26 { get; set; }
- ///
- /// 保留
- ///
- public char Bit27 { get; set; }
- ///
- /// 保留
- ///
- public char Bit28 { get; set; }
- ///
- /// 保留
- ///
- public char Bit29 { get; set; }
- ///
- /// 保留
- ///
- public char Bit30 { get; set; }
- ///
- /// 保留
- ///
- public char Bit31 { get; set; }
-
- ///
- /// 状态位
- ///
- ///
- public override string ToString()
- {
- Span span = new char[32];
- for (int i = 0; i < span.Length; i++)
- {
- span[i] = (char)this.GetType().GetProperty("Bit" + i.ToString()).GetValue(this);
- }
- return span.ToString();
- }
- }
-}