@@ -0,0 +1,22 @@ | |||
using System; | |||
using System.Collections.Generic; | |||
using System.Linq; | |||
using System.Text.Encodings.Web; | |||
using System.Text.Json; | |||
using System.Text.Unicode; | |||
using System.Threading.Tasks; | |||
namespace JTTools.Configs | |||
{ | |||
public static class JTJsonWriterOptions | |||
{ | |||
/// <summary> | |||
/// 汉字编码 | |||
/// </summary> | |||
public readonly static JsonWriterOptions Instance = new System.Text.Json.JsonWriterOptions | |||
{ | |||
Indented = true, | |||
Encoder = JavaScriptEncoder.Create(UnicodeRanges.All) | |||
}; | |||
} | |||
} |
@@ -1,7 +1,5 @@ | |||
@page "/" | |||
<h1>Hello, world!</h1> | |||
<h1>JTTools</h1> | |||
Welcome to your new app. | |||
<SurveyPrompt Title="How is Blazor working for you?" /> | |||
JT808、JT809、JT1078、JT19056、JTNE(新能源)、主动安全(苏标)解析工具 |
@@ -4,15 +4,11 @@ | |||
@using JT1078.Protocol.Extensions; | |||
@using Newtonsoft.Json; | |||
<h3>JT1078Parse</h3> | |||
<p>Hex: @HexData</p> | |||
<button class="btn btn-primary" @onclick="Query">解析</button> | |||
<div class="right"> | |||
@Json | |||
<textarea class="form-control" @bind="HexData" rows="10"></textarea> | |||
<textarea class="form-control" @bind="Json" rows="10"></textarea> | |||
</div> | |||
@code { | |||
@@ -25,6 +21,6 @@ | |||
private void Query() | |||
{ | |||
var data = HexData.ToHexBytes(); | |||
Json = JsonConvert.SerializeObject(JT1078Serializer.Deserialize(data)); | |||
Json = JsonConvert.SerializeObject(JT1078Serializer.Deserialize(data), Formatting.Indented); | |||
} | |||
} |
@@ -1,48 +1,65 @@ | |||
@page "/jt19056analyze" | |||
@page "/jt19056" | |||
@using JT808.Protocol; | |||
@using JT808.Protocol.Extensions; | |||
@using Newtonsoft.Json; | |||
@using JTTools.Configs; | |||
@inject IJT808Config Config | |||
<h3>jt808analyze</h3> | |||
<p>Up Hex: @UpHexData</p> | |||
<p>Down Hex: @DownHexData</p> | |||
<button class="btn btn-primary" @onclick="UpQuery">上行分析</button> | |||
<button class="btn btn-primary" @onclick="DownQuery">下行分析</button> | |||
<select class="btn-success" @onchange="@OnSelectWayType"> | |||
<option value="up">上行</option> | |||
<option value="down">下行</option> | |||
</select> | |||
<button class="btn btn-primary" @onclick="Query">分析</button> | |||
<div class="right"> | |||
@UpJson | |||
<br /> | |||
@DownJson | |||
<textarea class="form-control" @bind="HexData" rows="10"></textarea> | |||
<textarea class="form-control" @bind="Json" rows="10"></textarea> | |||
</div> | |||
@code { | |||
private JT808CarDVRSerializer Serializer; | |||
private string UpHexData = "7E 02 00 00 26 12 34 56 78 90 12 00 7D 02 00 00 00 01 00 00 00 02 00 BA 7F 0E 07 E4 F1 1C 00 28 00 3C 00 00 18 10 15 10 10 10 01 04 00 00 00 64 02 02 00 7D 01 13 7E"; | |||
private string DownHexData = "7E 02 00 00 26 12 34 56 78 90 12 00 7D 02 00 00 00 01 00 00 00 02 00 BA 7F 0E 07 E4 F1 1C 00 28 00 3C 00 00 18 10 15 10 10 10 01 04 00 00 00 64 02 02 00 7D 01 13 7E"; | |||
private static string UpHexData = "55 7A C4 00 00 00 EB"; | |||
private string UpJson; | |||
private string DownJson; | |||
private static string DownHexData = "55 7A C4 00 14 00 20 03 25 10 26 01 20 03 25 10 26 01 00 00 12 34 00 12 34 56 A9"; | |||
protected override void OnInitialized() | |||
private string HexData = UpHexData; | |||
string wayType = "up"; | |||
private void OnSelectWayType(ChangeEventArgs e) | |||
{ | |||
Serializer = Config.GetCarDVRSerializer(); | |||
wayType = e.Value.ToString(); | |||
switch (wayType) | |||
{ | |||
case "up": | |||
HexData = UpHexData; | |||
break; | |||
case "down": | |||
HexData = DownHexData; | |||
break; | |||
} | |||
} | |||
private void UpQuery() | |||
private string Json; | |||
protected override void OnInitialized() | |||
{ | |||
var data = UpHexData.ToHexBytes(); | |||
UpJson = Serializer.UpAnalyze(data); | |||
Serializer = Config.GetCarDVRSerializer(); | |||
} | |||
private void DownQuery() | |||
private void Query() | |||
{ | |||
var data = DownHexData.ToHexBytes(); | |||
DownJson = Serializer.UpAnalyze(data); | |||
var data = HexData.ToHexBytes(); | |||
switch (wayType) | |||
{ | |||
case "up": | |||
#warning UpAnalyze bug | |||
Json = Serializer.UpAnalyze(data, options: JTJsonWriterOptions.Instance); | |||
break; | |||
case "down": | |||
#warning DownAnalyze bug | |||
Json = Serializer.DownAnalyze(data, options: JTJsonWriterOptions.Instance); | |||
break; | |||
} | |||
} | |||
} |
@@ -1,13 +1,14 @@ | |||
@page "/jt808analyze" | |||
@page "/jt808" | |||
@using JT808.Protocol; | |||
@using JT808.Protocol.Extensions; | |||
@using Newtonsoft.Json; | |||
@using JTTools.Configs; | |||
@using System.Text; | |||
@using System.Text.Encodings.Web; | |||
@using System.Text.Unicode; | |||
@inject IJT808Config config | |||
@inject JT808_JT1078_Config jT808_JT1078_Config | |||
@inject JT808_JTActiveSafety_Config jT808_JTActiveSafety_Config | |||
<h3>jt808analyze</h3> | |||
<select class="btn-success" @onchange="@OnSelectProtocolType"> | |||
<option value="JT808">国标</option> | |||
@@ -15,20 +16,19 @@ | |||
<option value="JT808_JTAS">国标扩展主动安全(苏标)</option> | |||
</select> | |||
<p>@protocolType</p> | |||
<p>Hex: @HexData</p> | |||
<button class="btn btn-primary" @onclick="Query">分析</button> | |||
<div class="right"> | |||
@Json | |||
<textarea class="form-control" @bind="HexData" rows="10"></textarea> | |||
<textarea class="form-control" @bind="Json" rows="10"></textarea> | |||
</div> | |||
@code { | |||
private JT808Serializer Serializer; | |||
private JT808Serializer JTAS_Serializer; | |||
private JT808Serializer JT1078Serializer; | |||
string protocolType = "JT808"; | |||
@@ -55,13 +55,13 @@ | |||
switch (protocolType) | |||
{ | |||
case "JT808": | |||
Json = Serializer.Analyze(data); | |||
Json = Serializer.Analyze(data,options: JTJsonWriterOptions.Instance); | |||
break; | |||
case "JT808_JT1078": | |||
Json = JT1078Serializer.Analyze(data); | |||
Json = JT1078Serializer.Analyze(data, options: JTJsonWriterOptions.Instance); | |||
break; | |||
case "JT808_JTAS": | |||
Json = JTAS_Serializer.Analyze(data); | |||
Json = JTAS_Serializer.Analyze(data, options: JTJsonWriterOptions.Instance); | |||
break; | |||
} | |||
} | |||
@@ -1,35 +0,0 @@ | |||
@page "/jt808" | |||
@using JT808.Protocol; | |||
@using JT808.Protocol.Extensions; | |||
@using Newtonsoft.Json; | |||
@inject IJT808Config Config | |||
<h3>JT808Parse</h3> | |||
<p>Hex: @HexData</p> | |||
<button class="btn btn-primary" @onclick="Query">解析</button> | |||
<div class="right"> | |||
@Json | |||
</div> | |||
@code { | |||
private JT808Serializer Serializer; | |||
private string HexData = "7E 02 00 00 26 12 34 56 78 90 12 00 7D 02 00 00 00 01 00 00 00 02 00 BA 7F 0E 07 E4 F1 1C 00 28 00 3C 00 00 18 10 15 10 10 10 01 04 00 00 00 64 02 02 00 7D 01 13 7E"; | |||
private string Json; | |||
protected override void OnInitialized() | |||
{ | |||
Serializer = Config.GetSerializer(); | |||
} | |||
private void Query() | |||
{ | |||
var data = HexData.ToHexBytes(); | |||
Json = JsonConvert.SerializeObject(Serializer.Deserialize(data)); | |||
} | |||
} |
@@ -5,14 +5,11 @@ | |||
@using Newtonsoft.Json; | |||
@inject IJT809Config Config | |||
<h3>JT809Parse</h3> | |||
<p>Hex: @HexData</p> | |||
<button class="btn btn-primary" @onclick="Query">解析</button> | |||
<div class="right"> | |||
@Json | |||
<textarea class="form-control" @bind="HexData" rows="10"></textarea> | |||
<textarea class="form-control" @bind="Json" rows="10"></textarea> | |||
</div> | |||
@code { | |||
@@ -30,6 +27,6 @@ | |||
private void Query() | |||
{ | |||
var data = HexData.ToHexBytes(); | |||
Json = JsonConvert.SerializeObject(Serializer.Deserialize(data)); | |||
Json = JsonConvert.SerializeObject(Serializer.Deserialize(data), Formatting.Indented); | |||
} | |||
} |
@@ -13,23 +13,23 @@ | |||
</NavLink> | |||
</li> | |||
<li class="nav-item px-3"> | |||
<NavLink class="nav-link" href="jt808analyze"> | |||
<span class="oi oi-plus" aria-hidden="true"></span>JT808分析工具 | |||
<NavLink class="nav-link" href="jt808"> | |||
<span aria-hidden="true"></span>JT808分析工具 | |||
</NavLink> | |||
</li> | |||
<li class="nav-item px-3"> | |||
<NavLink class="nav-link" href="jt809"> | |||
<span class="oi oi-plus" aria-hidden="true"></span>JT809解析工具 | |||
<span aria-hidden="true"></span>JT809解析工具 | |||
</NavLink> | |||
</li> | |||
<li class="nav-item px-3"> | |||
<NavLink class="nav-link" href="jt1078"> | |||
<span class="oi oi-plus" aria-hidden="true"></span>JT1078解析工具 | |||
<span aria-hidden="true"></span>JT1078解析工具 | |||
</NavLink> | |||
</li> | |||
<li class="nav-item px-3"> | |||
<NavLink class="nav-link" href="jt19056analyze"> | |||
<span class="oi oi-plus" aria-hidden="true"></span>JT19056分析工具 | |||
<NavLink class="nav-link" href="jt19056"> | |||
<span aria-hidden="true"></span>JT19056分析工具 | |||
</NavLink> | |||
</li> | |||
</ul> | |||