Commit Graph

155 Commits

Author SHA1 Message Date
Joseph Doherty e859963853 feat(opcuaclient): add BuildBaseEventFilter + MapHistoryEvents pure cores 2026-06-18 06:02:11 -04:00
Joseph Doherty 15922d8483 test(galaxy): live-gw smoke — writer borrows subscription handle, skips AddItem
Subscribe a real tag, register its gateway item handle, write via the
registry-wired writer: asserts the borrowed-handle write commits Good with
AddItemCallCount==0 (control with no source: ==1). Proves the subscription
handle is usable for a committing no-login supervisory write. Skip-gated on
MXGW_ENDPOINT + GALAXY_MXGW_API_KEY; verified live vs 10.100.0.48:5120 (3/3).
2026-06-18 04:34:11 -04:00
Joseph Doherty e9da9c29d2 fix(galaxy): authoritative handle resolution + review cleanups
Make SubscriptionRegistry.TryResolveItemHandle confirm a live subscription
genuinely binds fullRef->handle (via the reverse index) rather than trusting
the forward-map hint + a bare liveness check. Fixes the cross-ref-same-handle
hazard (wrong-tag borrow) while preserving the legitimate
multiple-subscriptions-per-tag borrow. Adds cross-ref + same-ref-multi-sub
tests; drops a duplicate SubscriptionEntry <summary>; documents the writer's
supervisory-advise reconnect lifecycle.
2026-06-18 04:29:45 -04:00
Joseph Doherty 2e3f528afc feat(galaxy): writer borrows live subscription item handles (skip redundant AddItem)
GatewayGalaxyDataWriter now accepts an optional subscribedHandleSource
delegate; TryResolveCachedOrBorrowed checks _itemHandles first then the
source, so the first write to an already-subscribed tag skips the
AddItem round-trip. Borrowed handles are not cached (subscription
registry owns lifecycle). AddItemCallCount seam confirms gateway calls.
2026-06-18 04:18:35 -04:00
Joseph Doherty 1411950077 feat(galaxy): SubscriptionRegistry.TryResolveItemHandle forward lookup
Add _itemHandleByFullRef (OrdinalIgnoreCase ConcurrentDictionary) maintained
in lock-step with _subscribersByItemHandle across Register/Remove/Rebind.
TryResolveItemHandle cross-checks the authoritative reverse map so a stale
forward entry can never hand out a dead handle. Also wires the scaffolded
_addItemCallCount increment in EnsureItemHandleAsync (field was declared but
never assigned, causing a TreatWarningsAsErrors build failure on the branch).
8 new xUnit + Shouldly facts covering register/case-insensitive/remove/rebind/
failed-handle/liveness-guard paths.
2026-06-18 04:18:01 -04:00
Joseph Doherty 4a7b0fde7b fix(abcip): thread CIP template-instance-id so discovered-UDT expansion works in production (review) 2026-06-17 20:30:12 -04:00
Joseph Doherty fdd6b332fe fix(twincat): update BrowseSymbolsAsync doc + cache adapter fields + Flat-mode note (review)
- ITwinCATClient.BrowseSymbolsAsync XML doc updated: states the implementation now
  expands struct/UDT/FB symbols into atomic member leaves via TwinCATSymbolExpander;
  callers receive only atomic/array leaves with full InstancePaths, never struct containers.
- AdsSymbolNode: cache IsStruct, Mapped, Children, ReadOnly as readonly fields computed
  once in the ctor so repeated property access during recursive expansion doesn't
  re-materialize or re-invoke MapSymbolType/IsSymbolWritable.
- BrowseSymbolsAsync: add operator-gated live risk note next to SymbolsLoadMode.Flat
  warning that a real TC3 target may not populate SubSymbols in Flat mode, with
  guidance to switch to VirtualTree if members don't surface — do not change mode now.
- TwinCATSymbolExpanderTests: simplify confusing `new string('.', 0)` no-op to `""`.
2026-06-17 20:22:45 -04:00
Joseph Doherty 4e1414026e feat(abcip): expand controller-discovered UDTs into addressable member variables 2026-06-17 20:11:41 -04:00
Joseph Doherty 3699fc16a8 feat(twincat): expand discovered struct/UDT symbols into addressable member leaves 2026-06-17 20:05:01 -04:00
Joseph Doherty 098adf43d0 fix(ablegacy): dispose per-parent RMW locks on teardown (review symmetry)
DisposeRuntimes() now disposes and clears _rmwLocks, _creationLocks, and
_runtimeLocks so ReinitializeAsync/ShutdownAsync cycles don't orphan their
SemaphoreSlim instances. Mirrors the TwinCAT _bitRmwLocks fix already shipped.
2026-06-17 12:10:42 -04:00
Joseph Doherty c48f299994 test(ablegacy): bit write surfaces device rejection status (review)
Adds `Bit_write_surfaces_device_rejection_status` to AbLegacyBitRmwTests,
verifying that a non-zero libplctag status returned by the parent-word write
in WriteBitInWordAsync propagates as a non-Good OPC UA StatusCode rather than
being silently swallowed. Added a minimal `WriteStatusOverride` hook to
FakeAbLegacyTag (test-project-only) so the read half of the RMW still
returns 0/Good while the write half returns the seeded error code.
2026-06-17 12:02:10 -04:00
Joseph Doherty 340c145e87 fix(twincat): dispose bit-RMW locks on shutdown + guard null parent read (review) 2026-06-17 12:01:55 -04:00
Joseph Doherty a73e20fb28 feat(twincat): BOOL-within-word writes via driver-level parent-word RMW 2026-06-17 11:55:44 -04:00
Joseph Doherty 5c6b7cd6f9 feat(ablegacy): B/I/O-file bit-within-word writes via existing RMW path 2026-06-17 11:54:03 -04:00
Joseph Doherty 988a7a938f fix(s7): UInt64 box cast + Timer/Counter transient-write returns BadNotWritable (final review)
M1: add missing (object) cast to UInt64 arm of DecodeScalarBlock switch expression,
matching the Int64 arm style and the comment that each arm is boxed explicitly.
M2: short-circuit Timer/Counter writes in WriteAsync to BadNotWritable before
WriteOneAsync, so transient equipment-tag refs (Writable=true from parser) return
the same status code as authored tags rejected at init — documented in the docs.
Adds 6 pure unit tests pinning the area-detection precondition the guard relies on.
EncodeScalarBlock Timer/Counter throws remain as the defensive backstop.
2026-06-17 06:31:41 -04:00
Joseph Doherty 11e8e4302d fix(s7): Counter raw-word note + reject Writable Timer/Counter + Timer time-base tests (bundle review) 2026-06-17 06:18:48 -04:00
Joseph Doherty 8cfb8e920e feat(s7): Timer/Counter read (read-only) + route Timer/Counter through buffer path 2026-06-17 06:03:47 -04:00
Joseph Doherty 5db08e9e85 feat(s7): DateTime (S7 DATE_AND_TIME) scalar read+write via S7.Net.Types.DateTime 2026-06-17 05:54:08 -04:00
Joseph Doherty 1e5fec2f85 feat(s7): String (S7 STRING) scalar read+write via S7.Net.Types.S7String 2026-06-17 05:50:49 -04:00
Joseph Doherty 286be5df88 feat(s7): byte-buffer codec dispatch + Int64/UInt64/LReal scalar read+write 2026-06-17 05:38:18 -04:00
Joseph Doherty 06b858eb02 feat(s7): unblock wide-type/Timer-Counter init guards + fix Int64/UInt64 node mapping 2026-06-17 05:24:48 -04:00
Joseph Doherty 5f7a2acd27 fix(abcip): isArray:true without a positive arrayLength is scalar (review I-2 consistency) 2026-06-16 22:30:11 -04:00
Joseph Doherty 94e8c55b5c fix(abcip): explicit IsArray flag so 1-element arrays read as arrays (review I-1) 2026-06-16 22:14:41 -04:00
Joseph Doherty ce5d46be08 fix(ablegacy): gate array read on isArray:true; 1-element arrays + assumption comments (review C-2/I-3) 2026-06-16 22:14:36 -04:00
Joseph Doherty 3bbe39c166 fix(s7): treat ArrayCount>=1 as array so 1-element arrays read as arrays (review I-2) 2026-06-16 22:12:30 -04:00
Joseph Doherty 49ac1392a8 fix(modbus): gate array read on isArray:true; 1-element arrays (review C-1) 2026-06-16 22:12:18 -04:00
Joseph Doherty 3e74239532 feat(twincat): 1-D array symbol read via ADS + IsArray discovery 2026-06-16 21:59:17 -04:00
Joseph Doherty 950069392c feat(ablegacy): PCCC multi-element file array read + IsArray discovery 2026-06-16 21:55:41 -04:00
Joseph Doherty f4d5a5ee9c feat(abcip): 1-D array read via libplctag + IsArray discovery 2026-06-16 21:55:20 -04:00
Joseph Doherty a82c22c645 feat(s7): 1-D array block read + decode loop + IsArray discovery 2026-06-16 21:54:50 -04:00
Joseph Doherty 8d3dc32148 feat(modbus): String + BitInRegister array decode + equipment-tag arrayLength
- DecodeRegisterArray: add String and BitInRegister cases replacing the
  default:throw; each element decoded by reusing DecodeRegister on its
  contiguous register slice → string[] / bool[]
- ModbusEquipmentTagParser.TryParse: read optional arrayLength key from
  TagConfig JSON and thread it into ModbusTagDefinition.ArrayCount
  (null when absent or zero, preserving scalar behaviour)
- ModbusArrayTests: 8 new tests covering the two decode cases and the
  equipment-tag parser/resolver path; 285/285 green
2026-06-16 21:51:55 -04:00
Joseph Doherty 6855be288f feat(focas): per-axis auto-scale from cnc_getfigure figures (manual config = fallback) 2026-06-16 19:52:45 -04:00
Joseph Doherty bec37848d5 fix(galaxy): degrade all parent-cycle members to root (review) 2026-06-16 19:51:20 -04:00
Joseph Doherty 21c7645da8 feat(galaxy): nest gobject browse tree by parent_gobject_id (degrade-to-flat) 2026-06-16 19:41:26 -04:00
Joseph Doherty 3fcbc70cba feat(focas): add cnc_getfigure per-axis position-figure client binding 2026-06-16 19:38:49 -04:00
Joseph Doherty 2d688c2a6d feat(probe): Galaxy Test-Connect does a gRPC ping (auth-rejection counts as reachable) 2026-06-16 06:48:40 -04:00
Joseph Doherty b663ae6eff feat(probe): TwinCAT Test-Connect does an ADS ReadState (degrade-guarded) 2026-06-16 06:48:22 -04:00
Joseph Doherty 5ed0276ffb feat(probe): FOCAS Test-Connect attempts a cnc_allclibhndl3 handshake (degrade-guarded) 2026-06-16 06:45:19 -04:00
Joseph Doherty 21f3e8feab feat(probe): AbLegacy Test-Connect opens a real PCCC session (libplctag init)
Replaces the bare-TCP AbLegacyDriverProbe with a two-phase probe:
Phase 1 is the existing TCP preflight; Phase 2 initialises a
LibplctagLegacyTagRuntime (Protocol.ab_eip + per-family PlcType) to
open a real PCCC-over-EIP session, using AbLegacyProbeOptions.ProbeAddress
("S:0") as the probe tag. Status-code discrimination mirrors the AbCip
probe: ErrorNotFound/ErrorNoMatch/ErrorBadDevice → Ok=true "controller
reachable"; transport errors → Ok=false "handshake failed".
Adds AbLegacyDriverProbeTests (5 unit tests, all green, 168 total).
2026-06-16 06:44:15 -04:00
Joseph Doherty 0c08b152c2 feat(probe): AbCip Test-Connect opens a real CIP session (libplctag init)
Replace the bare-TCP-only AbCipDriverProbe with a two-phase check:
Phase 1 keeps the existing TCP preflight; Phase 2 initialises a
LibplctagTagRuntime against the first device to open a real EIP session
and CIP Forward Open, so a live-but-rejecting CIP endpoint reads red
instead of a false-positive green.

Status mapping: ErrorNotFound / ErrorNoMatch / ErrorBadDevice → reachable
(controller answered CIP, probe tag absent); ErrorTimeout / ErrorBadConnection
/ ErrorBadGateway / ErrorWinsock / ErrorOpen / ErrorClose / ErrorRead /
ErrorWrite / ErrorBadReply / ErrorRemoteErr / ErrorPartial / ErrorAbort →
handshake failed. LibPlcTagException message text is used as a secondary
signal for the reachable-exception path. All other statuses default to
handshake-failed (conservative).

Add AbCipDriverProbeTests: invalid JSON, no devices, malformed host address,
closed-port TCP rejection, and black-hole timeout — all offline-determinable.
Happy path + CIP-error path covered live against the CIP sim.
2026-06-16 06:39:46 -04:00
Joseph Doherty 957a63cfdb feat(probe): OpcUaClient Test-Connect does a GetEndpoints discovery handshake
Replace the bare TCP-connect return in OpcUaClientDriverProbe with a real
OPC UA GetEndpoints discovery handshake (mirroring SelectMatchingEndpointAsync
in the driver). TCP preflight still fast-fails closed ports; the handshake
confirms the remote is actually an OPC UA server, so a live-but-rejecting
non-OPC-UA process now reads RED instead of a false-healthy green.
2026-06-16 06:39:27 -04:00
Joseph Doherty 9a8336ff6e feat(probe): S7 Test-Connect does a real ISO-on-TCP + S7 setup handshake
Replace bare TCP-connect with a two-phase probe: Phase 1 keeps the
existing SocketException / timeout / generic preflight paths unchanged;
Phase 2 runs Plc.OpenAsync (COTP CR/CC + S7 setup-communication) so a
device that accepts TCP but is not an S7 PLC reads red instead of green.
A linked CTS distinguishes caller cancellation ("timed out") from the
S7netplus internal read-timeout OCE ("handshake failed: timed out").
2026-06-16 06:38:51 -04:00
Joseph Doherty 9b909002be feat(probe): Modbus Test-Connect does a real FC03 handshake
Replace the bare TCP-connect probe in ModbusDriverProbe with a two-phase
check: TCP connect via ModbusTcpTransport (keeps the same SocketException /
timeout / generic error paths and messages), then a one-shot FC03 Read
Holding Registers (qty 1 @ addr 0). A normal response → Ok=true "Modbus
FC03 OK"; a Modbus exception PDU → Ok=true "Modbus FC03 OK (device
returned exception PDU)"; any other failure after TCP succeeds → Ok=false
"Reachable at host:port but Modbus FC03 handshake failed: …".

Add ModbusDriverProbeTests (6 tests) covering invalid JSON, missing
host/port, closed port, TCP-accept-then-close, canned MBAP happy path,
and Modbus exception PDU path. All 277 Modbus tests green.
2026-06-16 06:36:48 -04:00
Joseph Doherty 4973075291 feat(focas): scale axis positions by 10^PositionDecimalPlaces (config-supplied) 2026-06-16 05:32:36 -04:00
Joseph Doherty 5e27b5f708 feat(historian): support Total aggregate (client-side Average x interval-seconds) 2026-06-16 05:24:56 -04:00
Joseph Doherty 5c5aaef609 fix(focas): fail-fast at init on unimplemented backend (operator footgun)
Add IFocasClientFactory.EnsureUsable() — a config-time probe called by
FocasDriver.InitializeAsync before any background loops start. The
UnimplementedFocasClientFactory throws NotSupportedException immediately
(faulting the driver at init), eliminating the footgun where a driver on
the 'unimplemented' backend appeared Healthy then failed every read/write/
subscribe silently. WireFocasClientFactory and FakeFocasClientFactory are
no-ops. Backstop Create() throw remains in place.
2026-06-16 05:24:41 -04:00
Joseph Doherty bd8fee610b fix(modbus): surface Int64/UInt64 node DataType (Driver.Modbus-007)
Make MapDataType internal, split the combined Int64/UInt64 arm to return
DriverDataType.Int64 and DriverDataType.UInt64 respectively, and remove
the now-stale Driver.Modbus-007 caveat doc block and inline comment.
Add a Theory covering both cases; full suite 271/271 green.
2026-06-16 05:23:47 -04:00
Joseph Doherty 8899d6e091 test(galaxy): assert current Write/Subscribe guard text (PR 4.4/4.W refs removed in Phase 0 b4af9e7f) 2026-06-15 15:03:38 -04:00
Joseph Doherty 2423edf232 test(alarms): assert Galaxy ack null-OperatorUser falls back to empty (code-review) 2026-06-15 14:18:57 -04:00
Joseph Doherty ed941c51da feat(alarms): AlarmAcknowledgeRequest carries OperatorUser; Galaxy/ScriptedAlarmSource honor it [H6b] 2026-06-15 14:11:40 -04:00