[focas] FOCAS — DIAG: address scheme #354

Merged
dohertj2 merged 1 commits from auto/focas/F2-a into auto/driver-gaps 2026-04-25 19:34:10 -04:00
Owner

Summary

DIAG: address scheme for FOCAS — whole-CNC and per-axis diagnostic data.

  • FocasAreaKind.Diagnostic — parsed from DIAG:nnn (whole-CNC) and DIAG:nnn/axis (per-axis, axis index encoded in BitIndex).
  • FocasCapabilityMatrix — new per-series DiagnosticRange table:
    • 16i → 0..499
    • 0i-F family → 0..999
    • 30i / 31i / 32i → 0..1023
    • Power Motion i → 0..255
    • Unknown → permissive (matches existing matrix convention)
  • New ValidateDiagnostic helper on the matrix.
  • IFocasClient.ReadDiagnosticAsync(diagNumber, axisOrZero, type, ct) — default returns BadNotSupported so older transports (e.g. IPC) degrade gracefully.
  • FwlibFocasClient implements via new cnc_rddiag P/Invoke (reusing IODBPSD).
  • FocasDriver.ReadAsync dispatches Diagnostic addresses through the new path.
  • FakeFocasClient extended for tests.

Test plan

  • dotnet build src/ZB.MOM.WW.OtOpcUa.Driver.FOCAS — clean (0 / 0)
  • dotnet test tests/ZB.MOM.WW.OtOpcUa.Driver.FOCAS.Tests266 / 266 passed (30 new in FocasDiagnosticAddressTests: parser positives + negatives, capability boundaries, driver dispatch with axis threading, init-time range rejection, BadNotSupported fallback)
  • Integration tests — skipped (live CNC required)

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

Closes #263

## Summary `DIAG:` address scheme for FOCAS — whole-CNC and per-axis diagnostic data. - **`FocasAreaKind.Diagnostic`** — parsed from `DIAG:nnn` (whole-CNC) and `DIAG:nnn/axis` (per-axis, axis index encoded in `BitIndex`). - **`FocasCapabilityMatrix`** — new per-series `DiagnosticRange` table: - 16i → 0..499 - 0i-F family → 0..999 - 30i / 31i / 32i → 0..1023 - Power Motion i → 0..255 - Unknown → permissive (matches existing matrix convention) - New `ValidateDiagnostic` helper on the matrix. - **`IFocasClient.ReadDiagnosticAsync(diagNumber, axisOrZero, type, ct)`** — default returns `BadNotSupported` so older transports (e.g. IPC) degrade gracefully. - **`FwlibFocasClient`** implements via new `cnc_rddiag` P/Invoke (reusing `IODBPSD`). - **`FocasDriver.ReadAsync`** dispatches Diagnostic addresses through the new path. - **`FakeFocasClient`** extended for tests. ## 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` — **266 / 266 passed** (30 new in `FocasDiagnosticAddressTests`: parser positives + negatives, capability boundaries, driver dispatch with axis threading, init-time range rejection, `BadNotSupported` fallback) - [ ] Integration tests — skipped (live CNC required) 🤖 Auto-generated by the Mode-B execution loop. Closes #263. Closes #263
dohertj2 added 1 commit 2026-04-25 19:34:05 -04:00
New FocasAreaKind.Diagnostic parsed from DIAG:nnn (whole-CNC) and
DIAG:nnn/axis (per-axis), validated against a per-series
FocasCapabilityMatrix.DiagnosticRange table (16i: 0-499; 0i-F family:
0-999; 30i/31i/32i: 0-1023; Power Motion i: 0-255; Unknown: permissive
per existing matrix convention).

IFocasClient gains ReadDiagnosticAsync(diagNumber, axisOrZero, type,
ct) with a default returning BadNotSupported so older transport
variants degrade gracefully. FwlibFocasClient implements it via a new
cnc_rddiag P/Invoke that reuses the IODBPSD struct (same shape as
cnc_rdparam). FocasDriver.ReadAsync dispatches Diagnostic addresses
through the new path; non-Diagnostic kinds keep the existing
ReadAsync route unchanged.

Tests: parser positives (DIAG:1031, DIAG:280/2, case-insensitive,
zero, axis-8) + negatives (malformed, axis>31), capability matrix
boundaries per series, driver-level dispatch verifying axis index
threads through, init-time rejection on out-of-range, and
BadNotSupported fallback when the wire client doesn't override the
default. 266/266 pass in Driver.FOCAS.Tests.

Closes #263

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
dohertj2 merged commit 3b82f4f5fb into auto/driver-gaps 2026-04-25 19:34:10 -04:00
dohertj2 deleted branch auto/focas/F2-a 2026-04-25 19:34:10 -04:00
Sign in to join this conversation.