@@ -7,6 +7,7 @@ | |||
</PropertyGroup> | |||
<ItemGroup> | |||
<PackageReference Include="BlazorStrap" Version="1.3.1" /> | |||
<PackageReference Include="JT1078" Version="1.0.2" /> | |||
<PackageReference Include="JT808" Version="2.2.10" /> | |||
<PackageReference Include="JT808.Protocol.Extensions.JT1078" Version="2.2.9" /> | |||
@@ -2,6 +2,6 @@ | |||
<div class="jumbotron"> | |||
<h1 class="display-4">JTTools(alpha)</h1> | |||
<h1 class="display-5">JTTools(alpha)</h1> | |||
<p class="lead">JT808、JT809、JT1078、JT19056、JTNE(新能源)、主动安全(苏标)解析工具</p> | |||
</div> |
@@ -5,7 +5,9 @@ | |||
@using Newtonsoft.Json; | |||
<button class="btn btn-primary" @onclick="Query">解析</button> | |||
<BSAlert Color="Color.Danger" IsOpen="@isOpen" IsDismissible="true" OnDismiss="@OnDismiss"> | |||
@ErrerMessage | |||
</BSAlert> | |||
<div class="right"> | |||
<textarea class="form-control" @bind="HexData" rows="10"></textarea> | |||
<pre> | |||
@@ -19,10 +21,29 @@ | |||
private string Json; | |||
private string ErrerMessage; | |||
private bool isOpen = false; | |||
void OnDismiss() | |||
{ | |||
isOpen = !isOpen; | |||
StateHasChanged(); | |||
} | |||
private void Query() | |||
{ | |||
var data = HexData.ToHexBytes(); | |||
Json = JsonConvert.SerializeObject(JT1078Serializer.Deserialize(data), Formatting.Indented); | |||
try | |||
{ | |||
isOpen = false; | |||
var data = HexData.ToHexBytes(); | |||
Json = JsonConvert.SerializeObject(JT1078Serializer.Deserialize(data), Formatting.Indented); | |||
} | |||
catch (Exception ex) | |||
{ | |||
isOpen = !isOpen; | |||
Json = ""; | |||
ErrerMessage = ex.StackTrace; | |||
} | |||
} | |||
} |
@@ -5,11 +5,14 @@ | |||
@using JTTools.Configs; | |||
@inject IJT808Config Config | |||
<select class="btn-success" @onchange="@OnSelectWayType"> | |||
<select class="form-control" @onchange="@OnSelectWayType"> | |||
<option value="up">上行</option> | |||
<option value="down">下行</option> | |||
</select> | |||
<button class="btn btn-primary" @onclick="Query">分析</button> | |||
<BSAlert Color="Color.Danger" IsOpen="@isOpen" IsDismissible="true" OnDismiss="@OnDismiss"> | |||
@ErrerMessage | |||
</BSAlert> | |||
<div class="right"> | |||
<textarea class="form-control" @bind="HexData" rows="10"></textarea> | |||
<pre> | |||
@@ -46,6 +49,16 @@ | |||
private string Json; | |||
private string ErrerMessage; | |||
private bool isOpen = false; | |||
void OnDismiss() | |||
{ | |||
isOpen = !isOpen; | |||
StateHasChanged(); | |||
} | |||
protected override void OnInitialized() | |||
{ | |||
Serializer = Config.GetCarDVRSerializer(); | |||
@@ -53,15 +66,25 @@ | |||
private void Query() | |||
{ | |||
var data = HexData.ToHexBytes(); | |||
switch (wayType) | |||
try | |||
{ | |||
case "up": | |||
Json = Serializer.UpAnalyze(data, options: JTJsonWriterOptions.Instance); | |||
break; | |||
case "down": | |||
Json = Serializer.DownAnalyze(data, options: JTJsonWriterOptions.Instance); | |||
break; | |||
isOpen = false; | |||
var data = HexData.ToHexBytes(); | |||
switch (wayType) | |||
{ | |||
case "up": | |||
Json = Serializer.UpAnalyze(data, options: JTJsonWriterOptions.Instance); | |||
break; | |||
case "down": | |||
Json = Serializer.DownAnalyze(data, options: JTJsonWriterOptions.Instance); | |||
break; | |||
} | |||
} | |||
catch (Exception ex) | |||
{ | |||
isOpen = !isOpen; | |||
Json = ""; | |||
ErrerMessage = ex.StackTrace; | |||
} | |||
} | |||
} | |||
} |
@@ -17,11 +17,13 @@ | |||
</select> | |||
<button class="btn btn-primary" @onclick="Query">分析</button> | |||
<BSAlert Color="Color.Danger" IsOpen="@isOpen" IsDismissible="true" OnDismiss="@OnDismiss"> | |||
@ErrerMessage | |||
</BSAlert> | |||
<div class="right"> | |||
<textarea class="form-control" @bind="HexData" rows="10"></textarea> | |||
<pre> | |||
@Json | |||
@Json | |||
</pre> | |||
</div> | |||
@@ -39,6 +41,16 @@ | |||
private string Json; | |||
private string ErrerMessage; | |||
private bool isOpen = false; | |||
void OnDismiss() | |||
{ | |||
isOpen = !isOpen; | |||
StateHasChanged(); | |||
} | |||
private void OnSelectProtocolType(ChangeEventArgs e) | |||
{ | |||
protocolType = e.Value.ToString(); | |||
@@ -53,18 +65,29 @@ | |||
private void Query() | |||
{ | |||
var data = HexData.ToHexBytes(); | |||
switch (protocolType) | |||
try | |||
{ | |||
isOpen = false; | |||
var data = HexData.ToHexBytes(); | |||
switch (protocolType) | |||
{ | |||
case "JT808": | |||
Json = Serializer.Analyze(data, options: JTJsonWriterOptions.Instance); | |||
break; | |||
case "JT808_JT1078": | |||
Json = JT1078Serializer.Analyze(data, options: JTJsonWriterOptions.Instance); | |||
break; | |||
case "JT808_JTAS": | |||
Json = JTAS_Serializer.Analyze(data, options: JTJsonWriterOptions.Instance); | |||
break; | |||
} | |||
} | |||
catch (Exception ex) | |||
{ | |||
case "JT808": | |||
Json = Serializer.Analyze(data,options: JTJsonWriterOptions.Instance); | |||
break; | |||
case "JT808_JT1078": | |||
Json = JT1078Serializer.Analyze(data, options: JTJsonWriterOptions.Instance); | |||
break; | |||
case "JT808_JTAS": | |||
Json = JTAS_Serializer.Analyze(data, options: JTJsonWriterOptions.Instance); | |||
break; | |||
isOpen = !isOpen; | |||
Json = ""; | |||
ErrerMessage = ex.StackTrace; | |||
} | |||
} | |||
} |
@@ -21,7 +21,9 @@ | |||
</div> | |||
} | |||
<button class="btn btn-primary" @onclick="Query">解析</button> | |||
<BSAlert Color="Color.Danger" IsOpen="@isOpen" IsDismissible="true" OnDismiss="@OnDismiss"> | |||
@ErrerMessage | |||
</BSAlert> | |||
<div class="right"> | |||
<textarea class="form-control" @bind="HexData" rows="10"></textarea> | |||
<pre> | |||
@@ -40,6 +42,16 @@ | |||
JT809EncryptOptions EncryptOptions; | |||
private string ErrerMessage; | |||
private bool isOpen = false; | |||
void OnDismiss() | |||
{ | |||
isOpen = !isOpen; | |||
StateHasChanged(); | |||
} | |||
private void OnSelectEncryptType(ChangeEventArgs e) | |||
{ | |||
encryptType = e.Value.ToString(); | |||
@@ -53,17 +65,27 @@ | |||
private void Query() | |||
{ | |||
var data = HexData.ToHexBytes(); | |||
if (encryptType == "none") | |||
try | |||
{ | |||
Json = JsonConvert.SerializeObject(Serializer.Deserialize(data), Formatting.Indented); | |||
isOpen = false; | |||
var data = HexData.ToHexBytes(); | |||
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); | |||
} | |||
} | |||
else | |||
catch(Exception ex) | |||
{ | |||
IJT809Config jt809ConfigInternal = new JT809Config(Guid.NewGuid().ToString()); | |||
jt809ConfigInternal.EncryptOptions = EncryptOptions; | |||
JT809Serializer jT809SerializerInternal = new JT809Serializer(jt809ConfigInternal); | |||
Json = JsonConvert.SerializeObject(jT809SerializerInternal.Deserialize(data), Formatting.Indented); | |||
isOpen = !isOpen; | |||
Json = ""; | |||
ErrerMessage = ex.StackTrace; | |||
} | |||
} | |||
@@ -11,6 +11,7 @@ using Microsoft.AspNetCore.Builder; | |||
using Microsoft.Extensions.DependencyInjection; | |||
using Newtonsoft.Json.Serialization; | |||
using JTTools.Configs; | |||
using BlazorStrap; | |||
namespace JTTools | |||
{ | |||
@@ -46,7 +47,7 @@ namespace JTTools | |||
.AllowAnyMethod() | |||
.AllowAnyHeader() | |||
.AllowAnyOrigin())); | |||
services.AddBootstrapCss(); | |||
}) | |||
.ConfigureKestrel(ksOptions => | |||
{ | |||
@@ -1,13 +0,0 @@ | |||
<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; } | |||
} |
@@ -7,3 +7,4 @@ | |||
@using Microsoft.JSInterop | |||
@using JTTools | |||
@using JTTools.Shared | |||
@using BlazorStrap |