Auto: ablegacy-5 — PD/MG/PLS/BT structure files

Adds PD (PID), MG (Message), PLS (Programmable Limit Switch) and BT
(Block Transfer) file types to the PCCC parser. New AbLegacyDataType
enum members (PidElement / MessageElement / PlsElement /
BlockTransferElement) plus per-type sub-element catalogue:

  - PD: SP/PV/CV/KP/KI/KD/MAXS/MINS/DB/OUT as Float32; EN/DN/MO/PE/
        AUTO/MAN/SP_VAL/SP_LL/SP_HL as Boolean (word-0 status bits).
  - MG: RBE/MS/SIZE/LEN as Int32; EN/EW/ER/DN/ST/CO/NR/TO as Boolean.
  - PLS: LEN as Int32 (bit table varies per PLC).
  - BT: RLEN/DLEN as Int32; EN/ST/DN/ER/CO/EW/TO/NR as Boolean.

Per-family flags on AbLegacyPlcFamilyProfile gate availability:

  - PD/MG: SLC500 + PLC-5 (operator + status bits both present).
  - PLS/BT: PLC-5 only (chassis-IO block transfer is PLC-5-specific).
  - MicroLogix + LogixPccc: rejected — no legacy file-letter form.

Status-bit indices match Rockwell DTAM / 1747-RM001 / 1785-6.5.12:
PD word 0 bits 0-8, MG/BT word 0 bits 8-15. PLC-set status bits
(PE/DN/SP_*; ST/DN/ER/CO/EW/NR/TO) are surfaced as ViewOnly via
IsPlcSetStatusBit, matching the Timer/Counter/Control pattern from
ablegacy-3.

LibplctagLegacyTagRuntime decodes PD non-bit members as Float32 and
MG/BT/PLS non-bit members as Int32; status bits route through GetBit
with the bit-position encoded by the driver via StatusBitIndex.

Tests: parser positive cases per family + negative cases per family,
catalogue + bit-index + read-only-bit assertions.

Closes #248
This commit is contained in:
Joseph Doherty
2026-04-25 19:08:51 -04:00
parent 5ca2ad83cd
commit 286ab3ba41
5 changed files with 365 additions and 6 deletions

View File

@@ -48,6 +48,17 @@ internal sealed class LibplctagLegacyTagRuntime : IAbLegacyTagRuntime
or AbLegacyDataType.ControlElement => bitIndex is int statusBit
? _tag.GetBit(statusBit)
: _tag.GetInt32(0),
// PD-file (PID): non-bit members (SP/PV/CV/KP/KI/KD/MAXS/MINS/DB/OUT) are 32-bit floats.
// Status bits (EN/DN/MO/PE/AUTO/MAN/SP_VAL/SP_LL/SP_HL) live in the parent control word
// and read through GetBit — the driver encodes the position via StatusBitIndex.
AbLegacyDataType.PidElement => bitIndex is int pidBit
? _tag.GetBit(pidBit)
: _tag.GetFloat32(0),
// MG/BT/PLS: non-bit members (RBE/MS/SIZE/LEN, RLEN/DLEN) are word-sized integers.
AbLegacyDataType.MessageElement or AbLegacyDataType.BlockTransferElement
or AbLegacyDataType.PlsElement => bitIndex is int statusBit2
? _tag.GetBit(statusBit2)
: _tag.GetInt32(0),
_ => null,
};
@@ -83,6 +94,18 @@ internal sealed class LibplctagLegacyTagRuntime : IAbLegacyTagRuntime
case AbLegacyDataType.ControlElement:
_tag.SetInt32(0, Convert.ToInt32(value));
break;
// PD-file non-bit writes route to the Float backing store. Status-bit writes within
// the parent word are blocked at the driver layer (PLC-set bits are read-only and
// operator-controllable bits go through the bit-RMW path with the parent word typed
// as Int).
case AbLegacyDataType.PidElement:
_tag.SetFloat32(0, Convert.ToSingle(value));
break;
case AbLegacyDataType.MessageElement:
case AbLegacyDataType.BlockTransferElement:
case AbLegacyDataType.PlsElement:
_tag.SetInt32(0, Convert.ToInt32(value));
break;
default:
throw new NotSupportedException($"AbLegacyDataType {type} not writable.");
}