Skip to content

Commit

Permalink
1.JT1078协议
Browse files Browse the repository at this point in the history
2.JT1078中JT808扩展协议
3.JT1078中JT809扩展协议
  • Loading branch information
SmallChi authored and waterliu99 committed Jul 17, 2019
1 parent 0827855 commit c3e77db
Show file tree
Hide file tree
Showing 198 changed files with 9,196 additions and 2 deletions.
19 changes: 19 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
language: csharp
solution: JT1078.sln
dotnet: 2.2.101
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
250 changes: 248 additions & 2 deletions README.md

Large diffs are not rendered by default.

22 changes: 22 additions & 0 deletions src/JT1078.Protocol.Benchmark/JT1078.Protocol.Benchmark.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFrameworks>netcoreapp2.2;net472</TargetFrameworks>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
<PlatformTarget>AnyCPU</PlatformTarget>
<OutputType>Exe</OutputType>
<StartupObject />
</PropertyGroup>
<ItemGroup>
<PackageReference Include="BenchmarkDotNet" Version="0.11.5" />
<PackageReference Include="BenchmarkDotNet.Diagnostics.Windows" Version="0.11.5" />
<PackageReference Include="JT808" Version="2.0.0" />
<PackageReference Include="NETStandard.Library" Version="2.0.3" />
<PackageReference Include="System.Buffers" Version="4.5.0" />
<PackageReference Include="System.Memory" Version="4.5.3" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\JT1078.Protocol\JT1078.Protocol.csproj" />
</ItemGroup>

</Project>
65 changes: 65 additions & 0 deletions src/JT1078.Protocol.Benchmark/JT1078SerializerContext.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
using BenchmarkDotNet.Attributes;
using BenchmarkDotNet.Configs;
using BenchmarkDotNet.Environments;
using BenchmarkDotNet.Jobs;
using BenchmarkDotNet.Toolchains.CsProj;
using JT808.Protocol.Extensions;
using System;
using System.Collections.Generic;
using System.Linq;

namespace JT1078.Protocol.Benchmark
{
[Config(typeof(JT1078SerializerConfig))]
[MarkdownExporterAttribute.GitHub]
[MemoryDiagnoser]
public class JT1078SerializerContext
{
private byte[] JT1078Bytes;

[Params(100, 10000, 100000)]
public int N;

[GlobalSetup]
public void Setup()
{
JT1078Bytes = "303163648188113501123456781001300000016BB392DA0503840102030405060708090A0B0C0D0E0F101112131415161718191A1B1C1D1E1F202122232425262728292A2B2C2D2E2F303132333435363738393A3B3C3D3E3F404142434445464748494A4B4C4D4E4F505152535455565758595A5B5C5D5E5F606162636465666768696A6B6C6D6E6F707172737475767778797A7B7C7D7E7F808182838485868788898A8B8C8D8E8F909192939495969798999A9B9C9D9E9FA0A1A2A3A4A5A6A7A8A9AAABACADAEAFB0B1B2B3B4B5B6B7B8B9BABBBCBDBEBFC0C1C2C3C4C5C6C7C8C9CACBCCCDCECFD0D1D2D3D4D5D6D7D8D9DADBDCDDDEDFE0E1E2E3E4E5E6E7E8E9EAEBECEDEEEFF0F1F2F3F4F5F6F7F8F9FAFBFCFDFEFF000102030405060708090A0B0C0D0E0F101112131415161718191A1B1C1D1E1F202122232425262728292A2B2C2D2E2F303132333435363738393A3B3C3D3E3F404142434445464748494A4B4C4D4E4F505152535455565758595A5B5C5D5E5F606162636465666768696A6B6C6D6E6F707172737475767778797A7B7C7D7E7F808182838485868788898A8B8C8D8E8F909192939495969798999A9B9C9D9E9FA0A1A2A3A4A5A6A7A8A9AAABACADAEAFB0B1B2B3B4B5B6B7B8B9BABBBCBDBEBFC0C1C2C3C4C5C6C7C8C9CACBCCCDCECFD0D1D2D3D4D5D6D7D8D9DADBDCDDDEDFE0E1E2E3E4E5E6E7E8E9EAEBECEDEEEFF0F1F2F3F4F5F6F7F8F9FAFBFCFDFEFF000102030405060708090A0B0C0D0E0F101112131415161718191A1B1C1D1E1F202122232425262728292A2B2C2D2E2F303132333435363738393A3B3C3D3E3F404142434445464748494A4B4C4D4E4F505152535455565758595A5B5C5D5E5F606162636465666768696A6B6C6D6E6F707172737475767778797A7B7C7D7E7F808182838485868788898A8B8C8D8E8F909192939495969798999A9B9C9D9E9FA0A1A2A3A4A5A6A7A8A9AAABACADAEAFB0B1B2B3B4B5B6B7B8B9BABBBCBDBEBFC0C1C2C3C4C5C6C7C8C9CACBCCCDCECFD0D1D2D3D4D5D6D7D8D9DADBDCDDDEDFE0E1E2E3E4E5E6E7E8E9EAEBECEDEEEFF0F1F2F3F4F5F6F7F8F9FAFBFCFDFEFF000102030405060708090A0B0C0D0E0F101112131415161718191A1B1C1D1E1F202122232425262728292A2B2C2D2E2F303132333435363738393A3B3C3D3E3F404142434445464748494A4B4C4D4E4F505152535455565758595A5B5C5D5E5F606162636465666768696A6B6C6D6E6F707172737475767778797A7B7C7D7E7F8081828384".ToHexBytes();
}

[Benchmark(Description = "JT1078Serializer")]
public void JT1078SerializeTest()
{
for (int i = 0; i < N; i++)
{
JT1078Package jT1078Package = new JT1078Package();
jT1078Package.Label1 = new JT1078Label1(0x81);
jT1078Package.Label2 = new JT1078Label2(0x88);
jT1078Package.SN = 0x1135;
jT1078Package.SIM = "11234567810";
jT1078Package.LogicChannelNumber = 0x01;
jT1078Package.Label3 = new JT1078Label3(0x30);
jT1078Package.Timestamp = 1562085874181;
jT1078Package.Bodies = Enumerable.Range(0, 900).Select(s => (byte)(s + 1)).ToArray();
var hex = JT1078Serializer.Serialize(jT1078Package);
}
}

[Benchmark(Description = "JT1078Deserialize")]
public void TestJT808_0x0200_Deserialize()
{
for (int i = 0; i < N; i++)
{
JT1078Package package = JT1078Serializer.Deserialize(JT1078Bytes);
}
}
}

public class JT1078SerializerConfig : ManualConfig
{
public JT1078SerializerConfig()
{
Add(Job.Default.WithGcServer(false).With(Runtime.Clr).With(Platform.AnyCpu));
Add(Job.Default.WithGcServer(false).With(CsProjCoreToolchain.NetCoreApp22).With(Platform.AnyCpu));
}
}
}
26 changes: 26 additions & 0 deletions src/JT1078.Protocol.Benchmark/Program.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
using BenchmarkDotNet.Attributes;
using BenchmarkDotNet.Configs;
using BenchmarkDotNet.Environments;
using BenchmarkDotNet.Exporters;
using BenchmarkDotNet.Jobs;
using BenchmarkDotNet.Reports;
using BenchmarkDotNet.Running;
using BenchmarkDotNet.Toolchains.CsProj;
using System;
using System.Collections.Generic;
using System.Threading.Tasks;

namespace JT1078.Protocol.Benchmark
{
class Program
{
static void Main(string[] args)
{
//安装NuGet包,BenchmarkDotNet
//在需要做性能测试的方法前加上属性[Benchmark]。
Summary summary = BenchmarkRunner.Run<JT1078SerializerContext>();
//Summary summary1 = BenchmarkRunner.Run<JT808DeEscapeContext>();
//Summary summary2 = BenchmarkRunner.Run<JT808EscapeContext>();
}
}
}
20 changes: 20 additions & 0 deletions src/JT1078.Protocol.Test/JT1078.Protocol.Test.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>netcoreapp2.2</TargetFramework>

<IsPackable>false</IsPackable>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="JT808" Version="2.0.0" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.0.1" />
<PackageReference Include="xunit" Version="2.4.0" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.0" />
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\JT1078.Protocol\JT1078.Protocol.csproj" />
</ItemGroup>

</Project>
Loading

0 comments on commit c3e77db

Please sign in to comment.