fix(focas): decode all four bytes of an axis/spindle name record, up to the first NUL

ReadNameRecord read only the first 2 bytes of each 4-byte 0x0089/0x008A record,
so the real 31i-B's paired axes 'AA6'/'AA7' (live capture ref-axisname-0x0089.bin)
both decoded as 'AA' -- the 'Makino with two AA axes' that #548 then had to
disambiguate as AA_1/AA_2. The name is now the record's ASCII up to its FIRST
NUL (not trailing-NUL trimming), so buffer residue such as Z-34184's spindle
record 53 31 00 4e ('S1' + an 'N' left from an earlier 'CNC') is discarded.

Client-visible: on such a machine Axes/AA_1 and Axes/AA_2 become Axes/AA6 and
Axes/AA7 (the old names were a decode artefact). #548's disambiguation stays as
the guard for genuinely duplicate names.

Ported from the sister ignitionoee FOCAS driver (Focas.Wire-001, Focas.Wire-022
/ v0.18.1).
This commit is contained in:
Joseph Doherty
2026-10-07 13:58:40 -04:00
parent 665ecd55c2
commit 9460da513c
5 changed files with 127 additions and 16 deletions
@@ -41,11 +41,18 @@ namespace ZB.MOM.WW.OtOpcUa.Driver.FOCAS;
/// config redeploy).
/// </para>
/// <para>
/// Suffix collisions with genuine names are structurally impossible for axes (FOCAS axis
/// displays are at most two characters — name + suffix — so they cannot contain <c>_</c>),
/// but the generator still checks: a generated segment that would collide with anything
/// else in the set escalates its ordinal until unique, so the output is always
/// collision-free whatever the input.
/// Suffix collisions with genuine names are not expected (a FOCAS name record is at most four
/// ASCII characters and controls do not use <c>_</c>), but the generator still checks: a
/// generated segment that would collide with anything else in the set escalates its ordinal
/// until unique, so the output is always collision-free whatever the input.
/// </para>
/// <para>
/// <b>Note on the Makino that motivated this.</b> Its two "AA" axes were a decode artefact:
/// the name records actually read <c>"AA6"</c> and <c>"AA7"</c>, and the wire layer read only
/// the first two bytes of each 4-byte record. With the full record decoded
/// (<see cref="Wire.FocasWireProtocol.ReadNameRecord"/>) that machine reports unique names and
/// its axes publish bare (<c>Axes/AA6</c>, <c>Axes/AA7</c>). This disambiguation remains as the
/// guard for a control that genuinely reports duplicates.
/// </para>
/// </remarks>
internal static class FixedTreeNames