[focas] FOCAS — Modal codes + overrides #327

Merged
dohertj2 merged 1 commits from auto/focas/F1-c into auto/driver-gaps 2026-04-25 14:29:14 -04:00
Owner

Summary

Two new fixed-tree subfolders per FOCAS device, mirroring the Status/ + Production/ pattern from f1a/f1b:

Modal/MCode, SCode, TCode, BCode (Int16, ViewOnly) read via cnc_modal(type=100..103).

Override/Feed, Rapid, Spindle, Jog (Int16, ViewOnly) read via cnc_rdparam against per-device-configurable parameter numbers (FocasDeviceOptions.OverrideParameters, defaults 6010/6011/6014/6015 — MTB-specific). When OverrideParameters is null, the entire subfolder is omitted; when an individual field's parameter is null, just that field is omitted.

  • New FocasModalInfo / FocasOverrideInfo / FocasOverrideParameters records.
  • IFocasClient.GetModalAsync and GetOverrideAsync (default-null).
  • FwlibFocasClient implementation with new TryReadInt16Param helper.
  • FwlibNative.cs — new cnc_modal P/Invoke + ODBMDL struct.
  • Cache + probe-tick refresh + ReadAsync dispatch follow the established f1a/f1b pattern.

G-groups (1..21) deferred per the issue body's explicit fallback — the ODBMDL union differs per series + group and would balloon the diff. All wire-level scaffolding (cnc_modal P/Invoke, ODBMDL) is in place so the follow-up can add G-groups without new framing logic.

Test plan

  • dotnet build src/ZB.MOM.WW.OtOpcUa.Driver.FOCAS — clean (0 / 0)
  • dotnet test tests/ZB.MOM.WW.OtOpcUa.Driver.FOCAS.Tests217 / 217 passed (6 new in FocasModalOverrideFixedTreeTests: discovery shape, Override-omission paths, cached reads, Bad before first refresh, disconnected FwlibFocasClient short-circuit)
  • Integration tests — skipped (live CNC required)

🤖 Auto-generated by the Mode-B execution loop. Closes #259.

Closes #259

## Summary Two new fixed-tree subfolders per FOCAS device, mirroring the Status/ + Production/ pattern from f1a/f1b: **`Modal/`** — `MCode`, `SCode`, `TCode`, `BCode` (Int16, ViewOnly) read via `cnc_modal(type=100..103)`. **`Override/`** — `Feed`, `Rapid`, `Spindle`, `Jog` (Int16, ViewOnly) read via `cnc_rdparam` against per-device-configurable parameter numbers (`FocasDeviceOptions.OverrideParameters`, defaults 6010/6011/6014/6015 — MTB-specific). When `OverrideParameters` is null, the entire subfolder is omitted; when an individual field's parameter is null, just that field is omitted. - New `FocasModalInfo` / `FocasOverrideInfo` / `FocasOverrideParameters` records. - `IFocasClient.GetModalAsync` and `GetOverrideAsync` (default-null). - `FwlibFocasClient` implementation with new `TryReadInt16Param` helper. - `FwlibNative.cs` — new `cnc_modal` P/Invoke + `ODBMDL` struct. - Cache + probe-tick refresh + `ReadAsync` dispatch follow the established f1a/f1b pattern. > **G-groups (1..21) deferred** per the issue body's explicit fallback — the `ODBMDL` union differs per series + group and would balloon the diff. All wire-level scaffolding (cnc_modal P/Invoke, ODBMDL) is in place so the follow-up can add G-groups without new framing logic. ## Test plan - [x] `dotnet build src/ZB.MOM.WW.OtOpcUa.Driver.FOCAS` — clean (0 / 0) - [x] `dotnet test tests/ZB.MOM.WW.OtOpcUa.Driver.FOCAS.Tests` — **217 / 217 passed** (6 new in `FocasModalOverrideFixedTreeTests`: discovery shape, Override-omission paths, cached reads, Bad before first refresh, disconnected `FwlibFocasClient` short-circuit) - [ ] Integration tests — skipped (live CNC required) 🤖 Auto-generated by the Mode-B execution loop. Closes #259. Closes #259
dohertj2 added 1 commit 2026-04-25 14:29:10 -04:00
Closes #259

Adds Modal/ + Override/ fixed-tree subfolders per FOCAS device, mirroring the
pattern established by Status/ (#257) and Production/ (#258): cached snapshots
refreshed on the probe tick, served from cache on read, no extra wire traffic
on top of user-driven tag reads.

Modal/ surfaces the four universally-present aux modal codes M/S/T/B from
cnc_modal(type=100..103) as Int16. **G-group decoding (groups 1..21) is deferred
to a follow-up** — the FWLIB ODBMDL union differs per series + group and the
issue body explicitly permits this scoping. Adds the cnc_modal P/Invoke +
ODBMDL struct + a generic int16 cnc_rdparam helper so the follow-up can add
G-groups without further wire-level scaffolding.

Override/ surfaces Feed/Rapid/Spindle/Jog from cnc_rdparam at MTB-specific
parameter numbers (FocasDeviceOptions.OverrideParameters; defaults to 30i:
6010/6011/6014/6015). Per-field nullable params let a deployment hide overrides
their MTB doesn't wire up; passing OverrideParameters=null suppresses the entire
Override/ subfolder for that device.

6 unit tests cover discovery shape, omitted Override folder when unconfigured,
partial Override field selection, cached-snapshot reads (Modal + Override),
BadCommunicationError before first refresh, and the FwlibFocasClient
disconnected short-circuit.
dohertj2 merged commit 49fc23adc6 into auto/driver-gaps 2026-04-25 14:29:14 -04:00
dohertj2 deleted branch auto/focas/F1-c 2026-04-25 14:29:14 -04:00
Sign in to join this conversation.