Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 17 additions & 0 deletions docs/IEC101_WPF_TEXT_AND_BYTE_INSPECTOR_20261029.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# WPF Trace readability + byte-true IEC-101 Inspector (2026-10-29)

## Screenshot reproduction
At 1526x955, live Trace labels and HEX looked jagged/faint. Existing XAML directly overrode the theme's ClearType/Ideal text default with `TextFormattingMode="Display"` and ~10.5 DIP monospaced font across explanatory prose; Inspector used tiny two-column labels, noisy generic prose and fake raw chips (e.g. `L=105,CA=1,IOA=...` instead of hex).

## Fix
- Trace title/meaning rendered in normal AppFont (Segoe UI/Aptos), 12.8/12.2 DIP, 18-DIP lines, darker ink and **Ideal + ClearType**, preserving light ListBox virtualized 1200-row bounded display; raw HEX uses Cascadia Mono/Consolas 11.6 DIP with Ideal + ClearType and no shadow, animation or per-frame additional UI.
- Inspector uses neutral white background; larger 11.9-12.2 DIP type and simple compact field + HEX + decoded value layout, not a large lecture-style two-column table.

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Update the required responsive layout policy

This change replaces the inspector's two-column field layout with stacked field/hex/meaning rows and changes trace sizing, but only adds a standalone FAT document. The root AGENTS.md explicitly requires updating docs/RESPONSIVE_LAYOUT_POLICY.md whenever layout changes; that policy is untouched in this commit. Update the canonical policy to describe the revised inspector layout and its bounded scrolling behavior rather than documenting the change only in this dated checklist.

AGENTS.md reference: AGENTS.md:L215-L215

Useful? React with 👍 / 👎.

- New **pure `Iec101FrameByteInspector.Explain`**, invoked only when a frame is selected, maps actual FT1.2 byte offsets and already-decoded ASDU information-object offsets into linked field/HEX groups; WPF receives one identical list as both HEX highlights and field explanations. Shows Start/L, Control (PRM/FCB/FCV or ACD/DFC), Link Address, Type ID, VSQ, COT, CA, *each* IOA, value/quality/CP56 time and checksum/integrity. It never invents an address string as HEX, and never reparses the original serial telegram.
- Each chip/field has a stable shared key, including object-N/value-N for multiple IOAs. Default focus is first value if decoded, else control. Typed check and raw byte length guard prevents out-of-bounds extraction. Unknown fields explicitly remain unknown; invalid checksum/length cannot become Good.
- Copy decoded frame uses the same field map as Inspector, not generic prose.
- IEC-103/104 Inspector branches remain unchanged; no changes to serial/TCP I/O, polling, FCB, passive RX-only or backpressure semantics.

## Performance / FAT
Layout/font-only WPF changes; decoder usage restricted to selected Inspector frame. No new timers, repeated UI updates, polling, font dependencies, animations or bitmap buffers. 1200-row virtualization and 75ms batching unchanged.

**Field FAT required**: test Windows display scaling 100%, 125%, 150% with COM 1200 bps and same SICAM setup, immediate Trace first paint, long streaming readability/no stutter; select 1-octet and 2-octet address frames, multi-IOA, FC9/ACD, Type30/CP56, invalid checksums; every HEX chip must match exact raw slice and update linked field highlight. Test screenshot legibility and compare ASE2000. CI is not visual proof of hardware rendered text.
62 changes: 43 additions & 19 deletions src/ARIEC60870.Desktop/Features/MainWindow.FrameInspector.cs
Original file line number Diff line number Diff line change
Expand Up @@ -82,8 +82,12 @@ private void ApplySelectedEvidenceRowToInspector(object? selectedItem)
SelectedRawText.Text = row.RawHex;
_selectedFrameExplanation = explanation;
SelectedLineSummaryText.Text = "Hover or click a protocol group. The panel stays stable; linked raw/meaning groups are highlighted without rewriting the inspector.";
SelectedLineDirectionText.Text = BuildLineMonitorTitle(row);
SelectedLineSummaryText.Text = BuildLineMonitorSummary(row);
SelectedLineDirectionText.Text = row.ProtocolMode == "101"
? row.ProtocolTraceTitle
: BuildLineMonitorTitle(row);
SelectedLineSummaryText.Text = row.ProtocolMode == "101"
? row.ProtocolTraceMeaning.Split('\n')[0]
: BuildLineMonitorSummary(row);
UpdateFrameInterpreterTone(row);
RebuildProtocolMap(row);
ActivateDefaultProtocolMapGroup(row);
Expand All @@ -102,8 +106,9 @@ private void ActivateDefaultProtocolMapGroup(EvidenceRow row)
{
"104" when row.ApciFormat == "I" && row.IoAddress != "-" => "object",
"104" => "apci",
"101" when row.IoAddress != "-" => "object",
"101" when row.TypeId != "-" => "asdu",
"101" when row.Source.AsduDetails?.Objects.Count > 0 => "value-1",
"101" when row.Source.AsduDetails is not null => "asdu-type",
"101" => "control",
"103" when row.FunInf != "-" => "asdu",
_ => "raw"
};
Expand All @@ -121,6 +126,8 @@ private static string DescribeProtocolMapKey(string key)
"asdu" => "ASDU header selected",
"cot" => "COT and flags selected",
"object" => "object address selected",
_ when key.StartsWith("object-", StringComparison.OrdinalIgnoreCase) => "IOA bytes selected",
_ when key.StartsWith("value-", StringComparison.OrdinalIgnoreCase) => "value bytes selected",
"payload" => "payload selected",
"value" => "value selected",
"check" => "integrity selected",
Expand All @@ -138,20 +145,10 @@ private void UpdateFrameInterpreterTone(EvidenceRow? row)
}

var tone = row?.TrafficTone ?? string.Empty;
var background = tone switch
{
"Tx" => Color.FromRgb(245, 250, 255),
"Rx" => Color.FromRgb(244, 255, 249),
"Error" => Color.FromRgb(255, 245, 245),
_ => Color.FromRgb(248, 251, 255)
};
var border = tone switch
{
"Tx" => Color.FromRgb(191, 219, 254),
"Rx" => Color.FromRgb(187, 247, 208),
"Error" => Color.FromRgb(254, 202, 202),
_ => Color.FromRgb(226, 232, 240)
};
// Neutral inspector surface: meaning is conveyed by exact byte groups,
// not a full-height green/blue panel whose color competes with the text.
var background = tone == "Error" ? Color.FromRgb(255, 249, 249) : Color.FromRgb(255, 255, 255);
var border = tone == "Error" ? Color.FromRgb(254, 202, 202) : Color.FromRgb(226, 232, 240);

FrameInterpreterPanel.Background = new SolidColorBrush(background);
FrameInterpreterPanel.BorderBrush = new SolidColorBrush(border);
Expand Down Expand Up @@ -250,6 +247,25 @@ private void RebuildProtocolMap(EvidenceRow row)
SelectedProtocolMapLines.Clear();
SelectedHexSegments.Clear();

// IEC-101: one exact offset/range SSOT for BOTH decoded field rows and
// linked raw HEX groups. No made-up "L=...,CA=..." as a HEX segment.
if (row.ProtocolMode == "101")
{
var fields = Iec101FrameByteInspector.Explain(row.Source);
if (fields.Count > 0)
{
foreach (var field in fields)
{
SelectedProtocolMapLines.Add(new ProtocolMapLine(field.Key,
field.Title, field.Meaning, field.Hex));
if (field.Count > 0)
SelectedHexSegments.Add(new HexSegment(field.Key,
field.Hex, field.Title, field.Meaning));
}
return;
}
}

foreach (var line in BuildProtocolMapLines(row))
{
SelectedProtocolMapLines.Add(line);
Expand Down Expand Up @@ -672,7 +688,15 @@ private void CopySelectedFrameDecode_Click(object sender, RoutedEventArgs e)

var builder = new StringBuilder();
builder.AppendLine($"Frame #{_selectedFrameRow.Sequence} {BuildLineMonitorTitle(_selectedFrameRow)}");
builder.AppendLine(BuildCompactFrameExplanation(_selectedFrameRow));
if (_selectedFrameRow.ProtocolMode == "101")
{
foreach (var field in Iec101FrameByteInspector.Explain(_selectedFrameRow.Source))
builder.AppendLine($"{field.Hex} → {field.Title}: {field.Meaning}");
}
else
{
builder.AppendLine(BuildCompactFrameExplanation(_selectedFrameRow));
}
builder.AppendLine();
builder.AppendLine("Raw: " + _selectedFrameRow.RawHex);
Clipboard.SetText(builder.ToString());
Expand Down
Loading
Loading