273 lines
13 KiB
Plaintext
273 lines
13 KiB
Plaintext
@page "/diagnostics"
|
||
@inject DiagnosticPageViewModel Diagnostics
|
||
|
||
<PageTitle>Synthetic diagnostics - AutoForge</PageTitle>
|
||
|
||
<h1>Synthetic module diagnostics</h1>
|
||
<p>
|
||
This workflow sends synthetic protocol v1 requests through the selected in-process
|
||
virtual transport. It is not a real vehicle connection, vehicle compatibility
|
||
determination, live capture or physical operation.
|
||
</p>
|
||
|
||
<StatusNotice Tone="@Diagnostics.StatusTone" Message="@Diagnostics.StatusMessage" />
|
||
|
||
@if (Diagnostics.Providers.Count == 0)
|
||
{
|
||
<p>No diagnostic provider is available. Replay and physical providers are not substituted.</p>
|
||
}
|
||
|
||
<section aria-labelledby="diagnostic-session-heading">
|
||
<h2 id="diagnostic-session-heading">Explicit profile and provider selection</h2>
|
||
<button id="load-synthetic-example" type="button" disabled="@Diagnostics.IsBusy"
|
||
@onclick="Diagnostics.LoadSyntheticExample">
|
||
Load synthetic truck example
|
||
</button>
|
||
<p>The example import does not select the profile or open a session.</p>
|
||
|
||
<label for="diagnostic-profile">Saved profile identifier</label>
|
||
<select id="diagnostic-profile" @bind="Diagnostics.SelectedProfileIdentifier"
|
||
disabled="@(Diagnostics.ActiveSession is not null || Diagnostics.IsBusy)">
|
||
<option value="">Choose an exact saved profile</option>
|
||
@foreach (var identifier in Diagnostics.AvailableProfiles.Select(profile => profile.ProfileIdentifier).Distinct(StringComparer.OrdinalIgnoreCase))
|
||
{
|
||
<option value="@identifier">@identifier</option>
|
||
}
|
||
</select>
|
||
|
||
<label for="diagnostic-revision">Saved profile revision</label>
|
||
<select id="diagnostic-revision" @bind="Diagnostics.SelectedProfileRevision"
|
||
disabled="@(Diagnostics.ActiveSession is not null || Diagnostics.IsBusy || Diagnostics.SelectedProfileIdentifier is null)">
|
||
<option value="">Choose an exact revision</option>
|
||
@foreach (var profile in Diagnostics.AvailableProfiles.Where(profile =>
|
||
StringComparer.OrdinalIgnoreCase.Equals(profile.ProfileIdentifier, Diagnostics.SelectedProfileIdentifier)))
|
||
{
|
||
<option value="@profile.Revision">revision @profile.Revision</option>
|
||
}
|
||
</select>
|
||
|
||
<label for="diagnostic-provider">Diagnostic provider</label>
|
||
<select id="diagnostic-provider" @bind="Diagnostics.SelectedProviderIdentifier"
|
||
disabled="@(Diagnostics.ActiveSession is not null || Diagnostics.IsBusy)">
|
||
<option value="">Choose an explicit provider</option>
|
||
@foreach (var provider in Diagnostics.Providers)
|
||
{
|
||
<option value="@provider.Target.ProviderIdentifier">@provider.Target.ProviderIdentifier (@provider.Target.Kind)</option>
|
||
}
|
||
</select>
|
||
|
||
<label for="diagnostic-target-kind">Operational target kind</label>
|
||
<select id="diagnostic-target-kind" @bind="Diagnostics.SelectedTargetKind"
|
||
disabled="@(Diagnostics.ActiveSession is not null || Diagnostics.IsBusy)">
|
||
<option value="">Choose an explicit kind</option>
|
||
<option value="@ExecutionTargetKind.Simulation">Simulation</option>
|
||
</select>
|
||
|
||
@if (Diagnostics.ActiveSession is null)
|
||
{
|
||
<button id="open-diagnostic-session" type="button" disabled="@Diagnostics.IsBusy"
|
||
@onclick="Diagnostics.OpenSessionAsync">
|
||
Open simulation session
|
||
</button>
|
||
}
|
||
else
|
||
{
|
||
<p id="active-diagnostic-session">
|
||
@Diagnostics.ActiveSession.Identity.Target.Kind target @Diagnostics.ActiveSession.Identity.Target.ProviderIdentifier;
|
||
session @Diagnostics.ActiveSession.Identity.SessionIdentifier;
|
||
profile @Diagnostics.ActiveSession.Identity.ProfileIdentifier revision
|
||
@Diagnostics.ActiveSession.Identity.ProfileRevision;
|
||
configuration @Diagnostics.ActiveSession.Identity.ConfigurationIdentifier.
|
||
</p>
|
||
<button id="discover-modules" type="button" disabled="@Diagnostics.IsBusy"
|
||
@onclick="Diagnostics.DiscoverAsync">
|
||
Probe virtual modules
|
||
</button>
|
||
<button id="reset-diagnostic-session" type="button" disabled="@Diagnostics.IsBusy"
|
||
@onclick="Diagnostics.ResetSessionAsync">
|
||
Reset to synthetic initial state
|
||
</button>
|
||
<button id="close-diagnostic-session" type="button" disabled="@Diagnostics.IsBusy"
|
||
@onclick="Diagnostics.CloseSessionAsync">
|
||
Close session
|
||
</button>
|
||
@if (Diagnostics.IsBusy)
|
||
{
|
||
<button id="cancel-diagnostic-operation" type="button" @onclick="Diagnostics.CancelPending">
|
||
Cancel pending operation
|
||
</button>
|
||
}
|
||
}
|
||
</section>
|
||
|
||
@if (Diagnostics.OperationMessages.Count > 0)
|
||
{
|
||
<section aria-labelledby="diagnostic-messages-heading">
|
||
<h2 id="diagnostic-messages-heading">Operation outcomes</h2>
|
||
<ul id="diagnostic-operation-messages">
|
||
@foreach (var message in Diagnostics.OperationMessages)
|
||
{
|
||
<li>@message</li>
|
||
}
|
||
</ul>
|
||
</section>
|
||
}
|
||
|
||
@if (Diagnostics.ActiveSession is { } session)
|
||
{
|
||
<section aria-labelledby="discovered-modules-heading">
|
||
<h2 id="discovered-modules-heading">Expected endpoints, validated probes and identified modules</h2>
|
||
@if (Diagnostics.DiscoverySummary is { } discoverySummary)
|
||
{
|
||
<p id="diagnostic-discovery-summary">@discoverySummary</p>
|
||
}
|
||
@if (Diagnostics.DiscoveredModules.Count == 0)
|
||
{
|
||
<p>Module discovery has not been run for this session.</p>
|
||
}
|
||
else
|
||
{
|
||
<ul id="discovered-modules">
|
||
@foreach (var module in Diagnostics.DiscoveredModules)
|
||
{
|
||
<li data-module="@module.Endpoint.ModuleIdentifier"
|
||
data-outcome="@module.ProbeOutcome"
|
||
data-probe-outcome="@module.ProbeOutcome"
|
||
data-identity-status="@module.IdentityStatus"
|
||
data-identity-outcome="@module.IdentityOutcome">
|
||
<h3>@module.Endpoint.ModuleIdentifier at 0x@(module.Endpoint.Address) — Probe: @module.ProbeOutcome; identity: @module.IdentityStatus</h3>
|
||
@if (module.Identity is { } identity)
|
||
{
|
||
<dl>
|
||
<dt>Role and name</dt>
|
||
<dd>@identity.Role — @identity.Name</dd>
|
||
<dt>Hardware/software/firmware/calibration identity</dt>
|
||
<dd>@(identity.HardwareIdentifier ?? "unknown") / @(identity.SoftwareIdentifier ?? "unknown") / @(identity.FirmwareIdentifier ?? "unknown") / @(identity.CalibrationIdentifier ?? "unknown")</dd>
|
||
</dl>
|
||
}
|
||
else
|
||
{
|
||
<p>
|
||
Identity is unavailable or unverified.
|
||
@if (module.IdentityOutcome is { } identityOutcome)
|
||
{
|
||
<span> Identity exchange outcome: @identityOutcome.</span>
|
||
}
|
||
@module.IdentityError
|
||
@if (module.ProbeSucceeded)
|
||
{
|
||
<span> A positive probe confirms only the advertised synthetic services, not identity or authorization.</span>
|
||
}
|
||
</p>
|
||
}
|
||
|
||
@if (module.ProbeError is { } probeError)
|
||
{
|
||
<p>Probe detail: @probeError</p>
|
||
}
|
||
|
||
@if (module.ProbeSucceeded)
|
||
{
|
||
<p>Validated probe advertised virtual services: @string.Join(", ", module.ImplementedServices).</p>
|
||
}
|
||
|
||
@if (module.ImplementedServices.Contains(DiagnosticServices.ReadTroubleCodes, StringComparer.Ordinal) ||
|
||
module.ImplementedServices.Contains(DiagnosticServices.ReadSignals, StringComparer.Ordinal))
|
||
{
|
||
<button type="button" disabled="@(Diagnostics.IsBusy || module.Identity is null)"
|
||
@onclick="() => Diagnostics.ReadModuleAsync(module.Endpoint.ModuleIdentifier)">
|
||
Read DTCs and static signals
|
||
</button>
|
||
}
|
||
@if (module.ImplementedServices.Contains(DiagnosticServices.ClearTroubleCodes, StringComparer.Ordinal))
|
||
{
|
||
<button type="button" disabled="@(Diagnostics.IsBusy || module.Identity is null)"
|
||
@onclick="() => Diagnostics.ClearTroubleCodesAsync(module.Endpoint.ModuleIdentifier)">
|
||
Clear this module's virtual DTCs
|
||
</button>
|
||
}
|
||
@if (module.Identity is null &&
|
||
(module.ImplementedServices.Contains(DiagnosticServices.ReadTroubleCodes, StringComparer.Ordinal) ||
|
||
module.ImplementedServices.Contains(DiagnosticServices.ReadSignals, StringComparer.Ordinal) ||
|
||
module.ImplementedServices.Contains(DiagnosticServices.ClearTroubleCodes, StringComparer.Ordinal)))
|
||
{
|
||
<p>Identity-dependent read and clear actions are disabled until profile identity is validated.</p>
|
||
}
|
||
|
||
@if (Diagnostics.TroubleCodes.TryGetValue(module.Endpoint.ModuleIdentifier, out var dtcs))
|
||
{
|
||
<h4>Synthetic DTCs returned by this module</h4>
|
||
@if (dtcs.Codes.Count == 0)
|
||
{
|
||
<p>Valid diagnostic response: no DTCs are currently stored in this virtual module.</p>
|
||
}
|
||
else
|
||
{
|
||
<ul>
|
||
@foreach (var code in dtcs.Codes)
|
||
{
|
||
<li>@(code.Code) — @(code.Description) (source @(code.SourceModuleIdentifier))</li>
|
||
}
|
||
</ul>
|
||
}
|
||
}
|
||
|
||
@if (Diagnostics.Signals.TryGetValue(module.Endpoint.ModuleIdentifier, out var signals))
|
||
{
|
||
<h4>Static synthetic signal snapshot</h4>
|
||
<ul>
|
||
@foreach (var signal in signals.Signals)
|
||
{
|
||
<li data-signal="@signal.SignalIdentifier">
|
||
@signal.SignalIdentifier: @signal.Value (@signal.Unit), @signal.Quality,
|
||
logical tick @signal.LogicalTimeTicks, origin @signal.Origin,
|
||
source @signal.ModuleIdentifier.
|
||
</li>
|
||
}
|
||
</ul>
|
||
}
|
||
</li>
|
||
}
|
||
</ul>
|
||
}
|
||
</section>
|
||
|
||
<LiveDashboardPanel Session="session" HeadingId="diagnostic-live-dashboard-heading" />
|
||
|
||
<section aria-labelledby="diagnostic-trace-heading">
|
||
<h2 id="diagnostic-trace-heading">Bounded session communication trace</h2>
|
||
<p id="trace-loss">Retained @session.Trace.Entries.Count records; dropped @session.Trace.DroppedRecordCount.</p>
|
||
<ol id="diagnostic-trace">
|
||
@foreach (var entry in session.Trace.Entries)
|
||
{
|
||
<li data-outcome="@entry.Outcome" data-service="@entry.Service">
|
||
<strong>@entry.Outcome — @entry.Service</strong>;
|
||
@entry.ModuleIdentifier at 0x@(entry.Address);
|
||
correlation @entry.CorrelationIdentifier;
|
||
logical ticks @entry.StartLogicalTicks–@entry.EndLogicalTicks.
|
||
@if (entry.DecodedSummary is not null)
|
||
{
|
||
<span>Decoded: @entry.DecodedSummary.</span>
|
||
}
|
||
@if (entry.Error is not null)
|
||
{
|
||
<span>Error: @entry.Error</span>
|
||
}
|
||
<details>
|
||
<summary>Raw synthetic protocol v1 payloads</summary>
|
||
<pre>Request: @System.Text.Encoding.UTF8.GetString(entry.RequestPayload.Span)</pre>
|
||
@if (entry.ResponsePayload is { } response)
|
||
{
|
||
<pre>Response: @System.Text.Encoding.UTF8.GetString(response.Span)</pre>
|
||
}
|
||
else
|
||
{
|
||
<p>No response payload was received.</p>
|
||
}
|
||
</details>
|
||
</li>
|
||
}
|
||
</ol>
|
||
</section>
|
||
}
|