@@ -9,8 +9,8 @@ | |||||
<ItemGroup> | <ItemGroup> | ||||
<PackageReference Include="JT1078" Version="1.0.2" /> | <PackageReference Include="JT1078" Version="1.0.2" /> | ||||
<PackageReference Include="JT808" Version="2.2.10" /> | <PackageReference Include="JT808" Version="2.2.10" /> | ||||
<PackageReference Include="JT808.Protocol.Extensions.JT1078" Version="2.2.8" /> | |||||
<PackageReference Include="JT808.Protocol.Extensions.JTActiveSafety" Version="1.0.3" /> | |||||
<PackageReference Include="JT808.Protocol.Extensions.JT1078" Version="2.2.9" /> | |||||
<PackageReference Include="JT808.Protocol.Extensions.JTActiveSafety" Version="1.0.4" /> | |||||
<PackageReference Include="JT809" Version="2.1.3" /> | <PackageReference Include="JT809" Version="2.1.3" /> | ||||
<PackageReference Include="JT809.Protocol.Extensions.JT1078" Version="2.1.3" /> | <PackageReference Include="JT809.Protocol.Extensions.JT1078" Version="2.1.3" /> | ||||
<PackageReference Include="Microsoft.AspNetCore.Mvc.NewtonsoftJson" Version="3.1.3" /> | <PackageReference Include="Microsoft.AspNetCore.Mvc.NewtonsoftJson" Version="3.1.3" /> | ||||
@@ -1,5 +1,7 @@ | |||||
@page "/" | @page "/" | ||||
<h1>JTTools</h1> | |||||
JT808、JT809、JT1078、JT19056、JTNE(新能源)、主动安全(苏标)解析工具 | |||||
<div class="jumbotron"> | |||||
<h1 class="display-4">JTTools(alpha)</h1> | |||||
<p class="lead">JT808、JT809、JT1078、JT19056、JTNE(新能源)、主动安全(苏标)解析工具</p> | |||||
</div> |
@@ -8,7 +8,9 @@ | |||||
<div class="right"> | <div class="right"> | ||||
<textarea class="form-control" @bind="HexData" rows="10"></textarea> | <textarea class="form-control" @bind="HexData" rows="10"></textarea> | ||||
<textarea class="form-control" @bind="Json" rows="10"></textarea> | |||||
<pre> | |||||
@Json | |||||
</pre> | |||||
</div> | </div> | ||||
@code { | @code { | ||||
@@ -12,7 +12,9 @@ | |||||
<button class="btn btn-primary" @onclick="Query">分析</button> | <button class="btn btn-primary" @onclick="Query">分析</button> | ||||
<div class="right"> | <div class="right"> | ||||
<textarea class="form-control" @bind="HexData" rows="10"></textarea> | <textarea class="form-control" @bind="HexData" rows="10"></textarea> | ||||
<textarea class="form-control" @bind="Json" rows="10"></textarea> | |||||
<pre> | |||||
@Json | |||||
</pre> | |||||
</div> | </div> | ||||
@code { | @code { | ||||
@@ -10,7 +10,7 @@ | |||||
@inject JT808_JT1078_Config jT808_JT1078_Config | @inject JT808_JT1078_Config jT808_JT1078_Config | ||||
@inject JT808_JTActiveSafety_Config jT808_JTActiveSafety_Config | @inject JT808_JTActiveSafety_Config jT808_JTActiveSafety_Config | ||||
<select class="btn-success" @onchange="@OnSelectProtocolType"> | |||||
<select class="form-control" @onchange="@OnSelectProtocolType"> | |||||
<option value="JT808">国标</option> | <option value="JT808">国标</option> | ||||
<option value="JT808_JT1078">国标扩展JT1078</option> | <option value="JT808_JT1078">国标扩展JT1078</option> | ||||
<option value="JT808_JTAS">国标扩展主动安全(苏标)</option> | <option value="JT808_JTAS">国标扩展主动安全(苏标)</option> | ||||
@@ -20,7 +20,9 @@ | |||||
<div class="right"> | <div class="right"> | ||||
<textarea class="form-control" @bind="HexData" rows="10"></textarea> | <textarea class="form-control" @bind="HexData" rows="10"></textarea> | ||||
<textarea class="form-control" @bind="Json" rows="10"></textarea> | |||||
<pre> | |||||
@Json | |||||
</pre> | |||||
</div> | </div> | ||||
@code { | @code { | ||||
@@ -3,13 +3,30 @@ | |||||
@using JT809.Protocol; | @using JT809.Protocol; | ||||
@using JT809.Protocol.Extensions; | @using JT809.Protocol.Extensions; | ||||
@using Newtonsoft.Json; | @using Newtonsoft.Json; | ||||
@using JT809.Protocol.Configs; | |||||
@using JT809.Protocol.Interfaces; | |||||
@inject IJT809Config Config | @inject IJT809Config Config | ||||
<select class="form-control" @onchange="@OnSelectEncryptType"> | |||||
<option value="none">未加密</option> | |||||
<option value="encrypt">加密</option> | |||||
</select> | |||||
@if (encryptType == "encrypt") | |||||
{ | |||||
<div class="form-group"> | |||||
<input type="text" class="form-control" placeholder="M1" @bind="EncryptOptions.M1"> | |||||
<input type="text" class="form-control" placeholder="IA1" @bind="EncryptOptions.IA1"> | |||||
<input type="text" class="form-control" placeholder="IC1" @bind="EncryptOptions.IC1"> | |||||
</div> | |||||
} | |||||
<button class="btn btn-primary" @onclick="Query">解析</button> | <button class="btn btn-primary" @onclick="Query">解析</button> | ||||
<div class="right"> | <div class="right"> | ||||
<textarea class="form-control" @bind="HexData" rows="10"></textarea> | <textarea class="form-control" @bind="HexData" rows="10"></textarea> | ||||
<textarea class="form-control" @bind="Json" rows="10"></textarea> | |||||
<pre> | |||||
@Json | |||||
</pre> | |||||
</div> | </div> | ||||
@code { | @code { | ||||
@@ -19,14 +36,44 @@ | |||||
private string Json; | private string Json; | ||||
string encryptType = "none"; | |||||
JT809EncryptOptions EncryptOptions; | |||||
private void OnSelectEncryptType(ChangeEventArgs e) | |||||
{ | |||||
encryptType = e.Value.ToString(); | |||||
} | |||||
protected override void OnInitialized() | protected override void OnInitialized() | ||||
{ | { | ||||
Serializer = Config.GetSerializer(); | Serializer = Config.GetSerializer(); | ||||
EncryptOptions = new JT809EncryptOptions(); | |||||
} | } | ||||
private void Query() | private void Query() | ||||
{ | { | ||||
var data = HexData.ToHexBytes(); | var data = HexData.ToHexBytes(); | ||||
Json = JsonConvert.SerializeObject(Serializer.Deserialize(data), Formatting.Indented); | |||||
if (encryptType == "none") | |||||
{ | |||||
Json = JsonConvert.SerializeObject(Serializer.Deserialize(data), Formatting.Indented); | |||||
} | |||||
else | |||||
{ | |||||
IJT809Config jt809ConfigInternal = new JT809Config(Guid.NewGuid().ToString()); | |||||
jt809ConfigInternal.EncryptOptions = EncryptOptions; | |||||
JT809Serializer jT809SerializerInternal = new JT809Serializer(jt809ConfigInternal); | |||||
Json = JsonConvert.SerializeObject(jT809SerializerInternal.Deserialize(data), Formatting.Indented); | |||||
} | |||||
} | |||||
class JT809Config : JT809GlobalConfigBase | |||||
{ | |||||
public JT809Config(string configId) | |||||
{ | |||||
ConfigId = configId; | |||||
} | |||||
public override string ConfigId { get; } | |||||
} | } | ||||
} | } |
@@ -0,0 +1,13 @@ | |||||
<div class="alert alert-warning alert-dismissible fade show" role="alert"> | |||||
<strong>@Title</strong>@ErrorMessage | |||||
<button type="button" class="close" data-dismiss="alert" aria-label="Close"> | |||||
<span aria-hidden="true">×</span> | |||||
</button> | |||||
</div> | |||||
@code { | |||||
[Parameter] | |||||
public string Title { get; set; } | |||||
[Parameter] | |||||
public string ErrorMessage { get; set; } | |||||
} |