Compare commits
16 Commits
4af8e65af1
...
7eeb9fb0f5
| Author | SHA1 | Date | |
|---|---|---|---|
| 7eeb9fb0f5 | |||
| 8899d6e091 | |||
| db22c2b19a | |||
| 30315185a3 | |||
| 93d9160dae | |||
| 87dd65b97a | |||
| a6d9de091b | |||
| be6858baa1 | |||
| 328bd1b9ee | |||
| 226587d817 | |||
| 2423edf232 | |||
| 418663b359 | |||
| ed941c51da | |||
| c236263e8d | |||
| 6ab3d8630b | |||
| 40b883effe |
@@ -79,6 +79,49 @@ the dedup.
|
||||
|
||||
## Acknowledge routing — Galaxy / driver alarms
|
||||
|
||||
### Native alarm acknowledge → AVEVA
|
||||
|
||||
When an OPC UA client Acknowledges a **native** (driver-fed, e.g. Galaxy)
|
||||
`AlarmConditionState` node, the node manager's `OnAcknowledge` handler
|
||||
branches on native-ness and routes through a dedicated path — separate
|
||||
from the scripted `AlarmCommandRouter`:
|
||||
|
||||
1. **`OtOpcUaNodeManager.HandleNativeAlarmAck`** — gates on the caller's
|
||||
`AlarmAck` role (fails closed: no role → `BadUserAccessDenied`), then
|
||||
dispatches a `NativeAlarmAck(ConditionNodeId, Comment, OperatorUser)`
|
||||
to the `NativeAlarmAckRouter` seam (fire-and-forget, non-blocking under
|
||||
the node-manager Lock). `OperatorUser` carries the authenticated
|
||||
session principal's display name.
|
||||
2. **`DriverHostActor.HandleRouteNativeAlarmAck`** — receives a
|
||||
`RouteNativeAlarmAck` message (the host maps `NativeAlarmAck` at the
|
||||
wiring boundary to keep Runtime Akka-free of the OPC UA layer). Applied
|
||||
**Primary-gate first**: a Secondary or Detached node drops the message
|
||||
silently. On Primary, resolves the condition NodeId from the
|
||||
`_driverRefByAlarmNodeId` inverse map (NodeId → `(DriverInstanceId,
|
||||
FullName)`) and Tells the owning `DriverInstanceActor` a
|
||||
`RouteAlarmAck(FullName, Comment, OperatorUser)`.
|
||||
3. **Galaxy driver** — `DriverInstanceActor` calls the driver's
|
||||
`IAlarmSource.AcknowledgeAsync` with an `AlarmAcknowledgeRequest`
|
||||
carrying the authored `FullName` as the `ConditionId` and the
|
||||
authenticated `OperatorUser`. The driver forwards this to the Galaxy
|
||||
gateway → AVEVA via `GatewayGalaxyAlarmAcknowledger`.
|
||||
**Fire-and-forget** — a failed upstream ack is not surfaced back to the
|
||||
OPC UA client (mirrors the Galaxy write-outcome limitation; the local
|
||||
`AlarmConditionState` SDK update already committed at step 1).
|
||||
|
||||
Only the **Acknowledge** is routed to the driver. `Confirm` / `AddComment`
|
||||
/ `Shelve` operations on a native condition stay on the scripted
|
||||
`AlarmCommandRouter` path (Phase 3 scope is Acknowledge → AVEVA only).
|
||||
|
||||
> **Best-effort during reconnect.** If a native ack arrives while the owning
|
||||
> driver is `Connecting`/`Reconnecting` (or on a non-Primary node), it is
|
||||
> dropped with a debug log and **not** retried upstream — the OPC UA Part 9
|
||||
> `AlarmConditionState` was already committed locally at step 1, so the rare
|
||||
> outcome is "acked locally but not propagated to AVEVA." Re-issue the ack once
|
||||
> the driver is reconnected if upstream propagation is required.
|
||||
|
||||
### Legacy sub-attribute path
|
||||
|
||||
`DriverNodeManager` picks the acknowledger when registering each
|
||||
condition (PR B.3 logic):
|
||||
|
||||
|
||||
+25
-9
@@ -109,7 +109,7 @@ Every mutation the state machine produces is immediately persisted inside the en
|
||||
Two mapping notes specific to this adapter:
|
||||
|
||||
- `SubscribeAlarmsAsync` accepts a list of source-node-id filters, interpreted as Equipment-path prefixes. Empty list matches every alarm. Each emission is matched against every live subscription — the adapter keeps no per-subscription cursor.
|
||||
- `IAlarmSource.AcknowledgeAsync` does not carry a user identity. The adapter defaults the audit user to `"opcua-client"` so callers using the base interface still produce an audit entry. The server's Part 9 method handlers call the engine's richer `AcknowledgeAsync` / `ConfirmAsync` / `OneShotShelveAsync` / `TimedShelveAsync` / `UnshelveAsync` / `AddCommentAsync` directly with the authenticated principal instead.
|
||||
- `IAlarmSource.AcknowledgeAsync` accepts an `AlarmAcknowledgeRequest` list; the `OperatorUser` field carries the authenticated principal when available. The adapter passes `OperatorUser` through to the engine's `AcknowledgeAsync`; when `OperatorUser` is null (non-OPC-UA callers using the raw interface) it falls back to `"opcua-client"` so callers still produce an audit entry. The server's Part 9 method handlers call the engine's richer `AcknowledgeAsync` / `ConfirmAsync` / `OneShotShelveAsync` / `TimedShelveAsync` / `UnshelveAsync` / `AddCommentAsync` directly with the authenticated principal instead of going through this adapter.
|
||||
|
||||
## Native driver alarms (equipment-tag path)
|
||||
|
||||
@@ -193,15 +193,27 @@ The alarm is authored on the `Tags` tab of the equipment page (`/uns/equipment/{
|
||||
by editing the tag's raw `TagConfig` JSON to include the `"alarm"` object. No
|
||||
other configuration is required.
|
||||
|
||||
### Deferred follow-ups
|
||||
### Native-alarm OPC UA operator operations
|
||||
|
||||
Two items are explicitly out of scope for Phase B:
|
||||
An OPC UA client can **Acknowledge** a native (e.g. Galaxy) condition and the ack
|
||||
now propagates to the device. The `OnAcknowledge` handler on a native condition
|
||||
routes through a separate `NativeAlarmAckRouter` seam (instead of the scripted
|
||||
`AlarmCommandRouter`) → `DriverHostActor` (a condition NodeId → `(DriverInstanceId,
|
||||
FullName)` inverse map, Primary-gated) → the owning driver's
|
||||
`IAlarmSource.AcknowledgeAsync` → Galaxy gateway → AVEVA. The call carries the
|
||||
authenticated operator's display name via the `AlarmAcknowledgeRequest.OperatorUser`
|
||||
field. This is fire-and-forget — a failed upstream ack is not surfaced back to the
|
||||
OPC UA client (mirrors the Galaxy write-outcome limitation). See [AlarmTracking.md
|
||||
§Native alarm acknowledge → AVEVA](AlarmTracking.md#native-alarm-acknowledge--aveva)
|
||||
for the full routing diagram.
|
||||
|
||||
1. **Inbound device-ack**: an OPC UA client `Acknowledge` currently updates the
|
||||
local `AlarmConditionState` but does **not** yet propagate back to the device
|
||||
via `IAlarmSource.AcknowledgeAsync` (→ AVEVA). Device-ack round-trip is a
|
||||
deferred follow-up.
|
||||
2. **AdminUI Galaxy address-picker pre-fill**: the `alarm` object must be authored
|
||||
**Enable/Disable** on a native condition returns `BadNotSupported` — the driver
|
||||
backing a native alarm has no enable/disable surface distinct from OPC UA; the
|
||||
Part 9 enable/disable concept maps to the scripted-alarm engine only.
|
||||
|
||||
One item remains explicitly out of scope:
|
||||
|
||||
1. **AdminUI Galaxy address-picker pre-fill**: the `alarm` object must be authored
|
||||
by editing the tag's raw `TagConfig` JSON today; a future picker enhancement
|
||||
could pre-fill `alarmType` / `severity` from driver discovery
|
||||
(`DriverAttributeInfo.IsAlarm`).
|
||||
@@ -212,10 +224,14 @@ Operators interact with active scripted alarms through two surfaces — both con
|
||||
|
||||
### AlarmAck gate (OPC UA method path)
|
||||
|
||||
`OtOpcUaNodeManager` wires the OPC UA Part 9 condition methods (Acknowledge / Confirm / AddComment / OneShotShelve / TimedShelve / Unshelve) on each `AlarmConditionState` node. Every method call is gated on the `AlarmAck` LDAP role — fail-closed: a session with no resolved roles or no `AlarmAck` group membership receives `BadUserAccessDenied` immediately without reaching the engine. The role is carried on the session by `RoleCarryingUserIdentity` (a `UserIdentity` subclass that preserves the LDAP-resolved role set past `OpcUaApplicationHost`).
|
||||
`OtOpcUaNodeManager` wires the OPC UA Part 9 condition methods (Acknowledge / Confirm / AddComment / OneShotShelve / TimedShelve / Unshelve / Enable / Disable) on each `AlarmConditionState` node. Every method call is gated on the `AlarmAck` LDAP role — fail-closed: a session with no resolved roles or no `AlarmAck` group membership receives `BadUserAccessDenied` immediately without reaching the engine. The role is carried on the session by `RoleCarryingUserIdentity` (a `UserIdentity` subclass that preserves the LDAP-resolved role set past `OpcUaApplicationHost`).
|
||||
|
||||
On allow, the handler publishes a `Commons.OpcUa.AlarmCommand` (containing command kind, condition id, comment, and operator principal) onto the `alarm-commands` DPS topic. The node manager itself stays Akka-free: the dispatch action is a settable `Action<AlarmCommand>` injected at boot by the hosted service.
|
||||
|
||||
**Scripted vs native conditions — Enable/Disable and Acknowledge:**
|
||||
- **Scripted conditions** — all eight Part 9 operations (including Enable/Disable) route through `AlarmCommandRouter` onto the `alarm-commands` topic, which `ScriptedAlarmHostActor` dispatches to the engine (`EnableAsync` / `DisableAsync` / `AcknowledgeAsync` / …). On enable, `ActiveState` is re-derived from the next predicate evaluation.
|
||||
- **Native (driver-fed) conditions** — `OnAcknowledge` branches to `NativeAlarmAckRouter` and routes the ack to the owning driver rather than the scripted engine (see §[Native-alarm OPC UA operator operations](#native-alarm-opc-ua-operator-operations) above). `OnEnableDisable` returns `BadNotSupported` immediately — native conditions have no engine-side enable/disable surface.
|
||||
|
||||
`OnTimedUnshelve` (the SDK's internal auto-unshelve timer) bypasses the client gate — it is system-initiated and not subject to operator role checks.
|
||||
|
||||
### Delta-gate de-duplication
|
||||
|
||||
@@ -0,0 +1,173 @@
|
||||
# Phase 3 — OPC UA standards completeness (H4 + H2-bit + H6) — design
|
||||
|
||||
> **Status:** approved 2026-06-15. Parent roadmap: `docs/plans/2026-06-15-stillpending-backlog-design.md`
|
||||
> (Phase 3). Backlog items **H4 + H2 + H6** in `stillpending.md` §1.
|
||||
> **Branch:** `feat/stillpending-phase-3-opcua-standards` off master `4af8e65a`.
|
||||
> **Classification:** high-risk (touches the OPC UA node-manager method seam, the alarm command path,
|
||||
> the driver inbound-ack route, and the authorization permission model).
|
||||
|
||||
## Problem
|
||||
|
||||
Three OPC UA standards gaps remain in the alarm + authorization surface:
|
||||
|
||||
- **H4 — alarm `Enable`/`Disable` not callable over OPC UA.** The node manager wires
|
||||
`OnAcknowledge`/`OnConfirm`/`OnAddComment`/`OnShelve`/`OnTimedUnshelve` but **not** `OnEnableDisable`
|
||||
(`AlarmCommand.cs` itself flags it as "a future task"). The engine side is **already done**
|
||||
(`ScriptedAlarmEngine.EnableAsync`/`DisableAsync`, dispatched at `ScriptedAlarmHostActor.cs:408-412`) and
|
||||
the `AlarmCommand` vocabulary already includes `Enable`/`Disable` — only the node-manager delegate is missing.
|
||||
- **H2 (permission bit only) — `NodePermissions.HistoryUpdate` missing.** The flags enum has no
|
||||
`HistoryUpdate` member, so `TriePermissionEvaluator.cs:86` maps `OpcUaOperation.HistoryUpdate → the
|
||||
HistoryRead bit`. A read-only HistoryRead grant would therefore also authorize a future HistoryUpdate. The
|
||||
full HistoryUpdate **service** stays **deferred** (infra-gated — no backend insert/replace/delete RPC).
|
||||
- **H6 — inbound ack of a NATIVE (Galaxy) alarm never reaches the driver / AVEVA.**
|
||||
`MaterialiseAlarmCondition` is the **single shared** materializer; both native and scripted conditions get
|
||||
`OnAcknowledge` wired to the **scripted** `AlarmCommandRouter` → `ScriptedAlarmHostActor` → engine. For a
|
||||
native alarm the engine doesn't own it, so the ack updates only the local `AlarmConditionState` and never
|
||||
flows through `IAlarmSource.AcknowledgeAsync` → AVEVA. There is currently **no** inbound path from an OPC UA
|
||||
ack to a driver. (The authenticated principal is *already* carried on the scripted path —
|
||||
`AlarmCommand.User = identity.DisplayName`; the generic `"opcua-client"` lives only in the raw
|
||||
`IAlarmSource` fallback in `ScriptedAlarmSource.cs:75`.)
|
||||
|
||||
## Goal
|
||||
|
||||
Make an OPC UA client able to Enable/Disable a Part 9 condition (H4); give HistoryUpdate its own permission
|
||||
bit so a HistoryRead grant can't authorize it (H2-bit); and route a native-condition Acknowledge to the
|
||||
owning driver (→ AVEVA) carrying the authenticated principal (H6). No EF migration; the only contract
|
||||
touches are additive (a sink-seam bool, a Core.Abstractions record field).
|
||||
|
||||
## Locked decisions (brainstorming 2026-06-15)
|
||||
|
||||
1. **H6 native-ack routing = a new `NativeAlarmAckRouter` seam** on the node manager (a second `Action`,
|
||||
mirroring `AlarmCommandRouter`). Native conditions wire `OnAcknowledge` to it; scripted conditions keep the
|
||||
existing router. Rejected: a single router disambiguated downstream (couples the scripted host to native
|
||||
routing).
|
||||
2. **H4 scoped to scripted alarms only.** Enable/Disable has clear engine semantics there. Native-alarm
|
||||
Enable/Disable is deferred — the driver has no enable/disable surface; a native condition's
|
||||
`OnEnableDisable` returns `BadNotSupported` (honest) rather than a silent no-op.
|
||||
3. **H6 live-provability accepted as code+unit-proven locally; the AVEVA round-trip is operator-gated.** The
|
||||
route is driver-agnostic via `IAlarmSource`, verified with **Galaxy** (the only real native-alarm source,
|
||||
with `GatewayGalaxyAlarmAcknowledger`). The gateway ack→AVEVA commit needs the real gateway
|
||||
(`10.100.0.48`), the same infra-gating class as H5's durable sink / the Galaxy live-gw smokes.
|
||||
4. **Sequencing:** all three this phase, increasing risk — **H2-bit → H4 → H6.**
|
||||
|
||||
## Architecture
|
||||
|
||||
### H2-bit (small, independent)
|
||||
- `NodePermissions`: add `HistoryUpdate = 1 << 12` (next free bit after `MethodCall = 1 << 11`). Optionally
|
||||
fold into the `Admin` composite (write-side history op); leave `Engineer`/`Operator` without it.
|
||||
- `TriePermissionEvaluator.MapOperationToPermission`: `OpcUaOperation.HistoryUpdate => NodePermissions.HistoryUpdate`
|
||||
(was `HistoryRead`). Drop the stale TODO comment.
|
||||
- Pure mapping change — fully unit-testable; the HistoryUpdate **service** remains unimplemented (a client
|
||||
calling HistoryUpdate still gets the SDK's default reject — unchanged).
|
||||
|
||||
### H4 (small-medium) — wire `OnEnableDisable`
|
||||
- In `MaterialiseAlarmCondition`, for **scripted** conditions wire
|
||||
`alarm.OnEnableDisable = (context, condition, enabling) => HandleAlarmCommand(context, condition,
|
||||
enabling ? "Enable" : "Disable", comment: null, unshelveAt: null);` — reusing the existing AlarmAck-gated
|
||||
`HandleAlarmCommand` (which builds `AlarmCommand(Enable|Disable)` and routes via `AlarmCommandRouter`).
|
||||
`ScriptedAlarmHostActor:408-412` already dispatches those to `ScriptedAlarmEngine.Enable/DisableAsync`.
|
||||
- For **native** conditions, `OnEnableDisable` returns `BadNotSupported` (decision #2).
|
||||
- Verify the SDK `OnEnableDisable` delegate's exact signature against the decompiled
|
||||
`AlarmConditionState`/`ConditionState` (the `OnShelve` wiring was verified the same way) and that the
|
||||
enable-state round-trips to the node (the engine re-projects via `WriteAlarmCondition`, whose delta-gate
|
||||
suppresses the double-event — same mechanism the ack path documents at `:591`).
|
||||
- **Authz:** AlarmAck (consistent with the other Part 9 alarm commands).
|
||||
|
||||
### H6 (the meaty one) — native ack → driver → AVEVA + principal
|
||||
Four moving parts:
|
||||
|
||||
1. **Mark native conditions at materialization.** Add `bool isNative` to
|
||||
`IOpcUaAddressSpaceSink.MaterialiseAlarmCondition` (+ `DeferredAddressSpaceSink`, `SdkAddressSpaceSink`,
|
||||
`NullOpcUaAddressSpaceSink`, `OtOpcUaNodeManager`). `Phase7Applier` already knows which is which: pass
|
||||
`isNative: true` at the native equipment-tag-alarm site (`:204`) and `false` at the scripted site (`:295`).
|
||||
The node manager tracks native node ids (e.g. a `_nativeAlarmNodeIds` set) and wires their `OnAcknowledge`
|
||||
(and `OnEnableDisable`) accordingly.
|
||||
2. **`NativeAlarmAckRouter` seam.** A new `Action<NativeAlarmAck>?` on the node manager (mirrors
|
||||
`AlarmCommandRouter`). A native condition's `OnAcknowledge` → resolve the AlarmAck-gated principal the same
|
||||
way `HandleAlarmCommand` does (fail-closed) → invoke the router with
|
||||
`NativeAlarmAck(ConditionNodeId, Comment, OperatorUser = identity.DisplayName)` → return `Good`.
|
||||
3. **Reverse map in `DriverHostActor`.** `DriverHostActor` already builds the forward map
|
||||
`_alarmNodeIdByDriverRef: (DriverInstanceId, FullName) → condition NodeId(s)` (`:127`, rebuilt at `:902`).
|
||||
Build the **inverse** in the same clear-and-rebuild pass: `conditionNodeId → (DriverInstanceId, FullName)`.
|
||||
The host wires the `NativeAlarmAckRouter` to a fire-and-forget `Tell` into `DriverHostActor`; on receipt it
|
||||
looks up the inverse map → `(driverId, alarmRef)` → routes to the `DriverInstanceActor` →
|
||||
`driver.AcknowledgeAsync([ new AlarmAcknowledgeRequest(SourceNodeId, ConditionId: alarmRef, Comment,
|
||||
OperatorUser) ], ct)`.
|
||||
4. **Carry the principal to the driver.** `AlarmAcknowledgeRequest(SourceNodeId, ConditionId, Comment?)` gains
|
||||
`string? OperatorUser` (the field the base-interface comment already anticipated — "Stream G provides the
|
||||
authenticated principal"). `GalaxyDriver.AcknowledgeAsync` passes it to
|
||||
`IGalaxyAlarmAcknowledger.AcknowledgeAsync(alarmFullReference, comment, operatorUser, ct)` → gateway → AVEVA.
|
||||
Also tidy `ScriptedAlarmSource.cs:75`'s `"opcua-client"` default to honor a supplied principal.
|
||||
|
||||
Native-alarm-source drivers that don't implement a real acknowledger (AbCip/FOCAS projections) accept the
|
||||
request as today (no behavioral regression); only Galaxy commits to its upstream.
|
||||
|
||||
```
|
||||
OPC UA client Acknowledge on a NATIVE condition
|
||||
→ OtOpcUaNodeManager.OnAcknowledge (native) [AlarmAck gate, fail-closed]
|
||||
→ NativeAlarmAckRouter(NativeAlarmAck{node, comment, operatorUser})
|
||||
→ DriverHostActor [inverse map conditionNodeId → (driverId, alarmRef)]
|
||||
→ DriverInstanceActor → driver.AcknowledgeAsync(AlarmAcknowledgeRequest{…, OperatorUser})
|
||||
→ GalaxyDriver → GatewayGalaxyAlarmAcknowledger → gateway → AVEVA
|
||||
```
|
||||
|
||||
## Error handling / edge cases
|
||||
|
||||
- **Anonymous / missing AlarmAck role** on any of H4/H6 → `BadUserAccessDenied` (fail-closed, same as the
|
||||
existing alarm methods).
|
||||
- **Native ack with no driver match** (condition node not in the inverse map — e.g. a scripted alarm wrongly
|
||||
routed) → log + drop; never throw under the node-manager Lock. The router `Tell` is fire-and-forget (safe
|
||||
under Lock, like `AlarmCommandRouter`).
|
||||
- **Driver faulted / reconnecting** → `AcknowledgeAsync` fails or no-ops per the driver; the local condition
|
||||
state still reflects the SDK-applied ack (the OPC UA client sees Good). Surfacing a *failed* upstream ack
|
||||
back to the client is out of scope (mirrors the Galaxy write-outcome fire-and-forget limitation).
|
||||
- **H4 native Enable/Disable** → `BadNotSupported` (decision #2).
|
||||
- **H2-bit:** no runtime behavior change for existing grants except closing the HistoryRead⇒HistoryUpdate
|
||||
authorization hole; the service itself stays rejected.
|
||||
|
||||
## Testing strategy (xUnit + Shouldly, TDD; NO bUnit)
|
||||
|
||||
- **H2-bit:** `TriePermissionEvaluator` test — a node granting only `HistoryRead` does **not** authorize
|
||||
`OpcUaOperation.HistoryUpdate` (now `NotGranted`); a grant including the new `HistoryUpdate` bit does. Enum
|
||||
bit-value/round-trip test (no collision with `MethodCall`).
|
||||
- **H4:** node-manager test — `OnEnableDisable` with an AlarmAck identity routes an `Enable`/`Disable`
|
||||
`AlarmCommand` through a captured `AlarmCommandRouter`; anonymous → `BadUserAccessDenied`, no route; a native
|
||||
condition → `BadNotSupported`. Engine path (`ScriptedAlarmHostActor` Enable/Disable → `ScriptedAlarmEngine`)
|
||||
is already covered.
|
||||
- **H6:** node-manager test — a **native** condition's `OnAcknowledge` (AlarmAck identity) invokes the
|
||||
`NativeAlarmAckRouter` with the right `(node, comment, operatorUser=DisplayName)` and **not** the scripted
|
||||
`AlarmCommandRouter`; a **scripted** condition still uses `AlarmCommandRouter`. `DriverHostActor` test — the
|
||||
inverse map resolves a condition node → `(driverId, alarmRef)` and a `NativeAlarmAck` routes to a stub
|
||||
driver's `AcknowledgeAsync` with `OperatorUser` populated. `AlarmAcknowledgeRequest` byte/field test for the
|
||||
new `OperatorUser`. Galaxy: a unit test that `GalaxyDriver.AcknowledgeAsync` forwards `OperatorUser` to the
|
||||
acknowledger; the live AVEVA commit is the existing skip-gated `GatewayGalaxy…LiveTests` pattern.
|
||||
- **Live `/run`:** H4 Enable/Disable proven end-to-end on docker-dev (author a scripted alarm, Disable via
|
||||
Client.CLI, confirm the condition disables); H6's local half proven (native ack routes to the driver — log
|
||||
evidence), the **AVEVA round-trip operator-gated** against `10.100.0.48` (decision #3).
|
||||
|
||||
## Verification per item
|
||||
|
||||
- `dotnet build` clean (TreatWarningsAsErrors on production); full `dotnet test` green.
|
||||
- High-risk review chain (serial spec → code) per task + a final integration review.
|
||||
- Live `/run`: H4 driven by the agent on docker-dev (login disabled); H6 local route agent-driven, AVEVA
|
||||
commit recorded as operator-gated (or driven against the reachable gateway if feasible this session).
|
||||
|
||||
## Alternatives considered
|
||||
|
||||
- **Single command router, disambiguate native vs scripted in the host** — rejected (decision #1): pushes
|
||||
native routing knowledge into the scripted host; the dual-router split keeps each path's concern local.
|
||||
- **Native Enable/Disable now** — rejected (decision #2): no driver enable/disable surface; murky semantics
|
||||
(the driver keeps producing events).
|
||||
- **Add the HistoryUpdate *service*** — out of scope / deferred (infra-gated; on the roadmap defer list).
|
||||
- **Pass the principal out-of-band instead of on `AlarmAcknowledgeRequest`** — rejected: the record is the
|
||||
natural carrier and the base-interface comment already anticipated it; an additive field is the least
|
||||
surprising.
|
||||
|
||||
## Hard constraints (carried from the roadmap)
|
||||
|
||||
NO Configuration entity / EF migration. The only contract touches are additive: a `bool isNative` on the
|
||||
internal `IOpcUaAddressSpaceSink` sink seam, and `string? OperatorUser` on the `AlarmAcknowledgeRequest`
|
||||
Core.Abstractions record. Stage by path — never `git add .`; never stage `sql_login.txt`,
|
||||
`src/Server/.../Host/pki/`, `pending.md`, `current.md`, `docker-dev/docker-compose.yml`, `stillpending.md`.
|
||||
Never echo or commit secrets (gateway API key). No force-push, no `--no-verify`. Razor/runtime behavior proven
|
||||
only by live `/run`, never bUnit.
|
||||
@@ -0,0 +1,417 @@
|
||||
# Phase 3 — OPC UA standards completeness (H4 + H2-bit + H6) Implementation Plan
|
||||
|
||||
> **For Claude:** REQUIRED SUB-SKILL: Use superpowers-extended-cc:subagent-driven-development to implement this plan task-by-task.
|
||||
|
||||
**Goal:** Let an OPC UA client Enable/Disable a Part 9 condition (H4); give `HistoryUpdate` its own
|
||||
permission bit so a HistoryRead grant can't authorize it (H2-bit); route a *native* (Galaxy) condition's
|
||||
Acknowledge to the owning driver → AVEVA, carrying the authenticated principal (H6).
|
||||
|
||||
**Architecture:** All in the OPC UA node-manager + alarm command path + driver inbound-ack route. The engine
|
||||
already handles Enable/Disable; only the `OnEnableDisable` node-manager delegate is missing. Native vs scripted
|
||||
conditions are distinguished by a new `bool isNative` threaded through the single shared
|
||||
`MaterialiseAlarmCondition` (Phase7Applier already knows which is which); native acks route through a new
|
||||
`NativeAlarmAckRouter` → `DriverHostActor` (inverse condition→driver map) → `driver.AcknowledgeAsync`.
|
||||
|
||||
**Tech Stack:** C# / .NET 10, OPC UA Foundation UA-.NETStandard (CustomNodeManager2 / AlarmConditionState),
|
||||
Akka.NET, xUnit + Shouldly. Design: `docs/plans/2026-06-15-stillpending-phase-3-opcua-standards-design.md`.
|
||||
|
||||
**Branch:** `feat/stillpending-phase-3-opcua-standards` (created off master `4af8e65a`; design committed `40b883ef`).
|
||||
|
||||
---
|
||||
|
||||
## Hard rules (every task)
|
||||
|
||||
- Stage **by path** — never `git add .`. Never stage `sql_login.txt`, `src/Server/.../Host/pki/`,
|
||||
`pending.md`, `current.md`, `docker-dev/docker-compose.yml`, `stillpending.md`. Never echo/commit secrets
|
||||
(gateway API key). No force-push, no `--no-verify`.
|
||||
- **NO** Configuration entity / EF migration. The ONLY contract touches are additive: `bool isNative` on the
|
||||
internal `IOpcUaAddressSpaceSink.MaterialiseAlarmCondition` seam, and `string? OperatorUser` on the
|
||||
`AlarmAcknowledgeRequest` Core.Abstractions record. **`NodePermissions` is an int-backed `[Flags]` enum
|
||||
(`NodeAcl.PermissionFlags` is an int column) — adding a member is NOT a schema change and needs NO migration.**
|
||||
- TDD fail-then-pass. xUnit + Shouldly. **NO bUnit.** Cross-node/runtime behavior proven only by live `/run`.
|
||||
- Production projects are `TreatWarningsAsErrors` — fix all warnings (incl. XML docs on new public members).
|
||||
|
||||
## Verified facts the implementer needs
|
||||
|
||||
- `NodePermissions` (`src/Core/ZB.MOM.WW.OtOpcUa.Configuration/Enums/NodePermissions.cs`): `Browse=1<<0` …
|
||||
`MethodCall=1<<11`; composites `ReadOnly/Operator/Engineer/Admin`. Highest used bit is `1<<11`.
|
||||
- `OpcUaOperation` (`src/Core/ZB.MOM.WW.OtOpcUa.Core.Abstractions/OpcUaOperation.cs`) ALREADY has a
|
||||
`HistoryUpdate` member.
|
||||
- `TriePermissionEvaluator.MapOperationToPermission` (`src/Core/ZB.MOM.WW.OtOpcUa.Core/Authorization/TriePermissionEvaluator.cs:78-86`)
|
||||
maps `HistoryUpdate => NodePermissions.HistoryRead` with a `// TODO` — the bug.
|
||||
- `MaterialiseAlarmCondition` is the SINGLE shared materializer. Interface
|
||||
`IOpcUaAddressSpaceSink.MaterialiseAlarmCondition(alarmNodeId, equipmentNodeId, displayName, alarmType, severity)`;
|
||||
impls: `DeferredAddressSpaceSink.cs:47`, `SdkAddressSpaceSink.cs:45`, `NullOpcUaAddressSpaceSink` (in
|
||||
Commons/OpcUa), `OtOpcUaNodeManager.cs:538`. Phase7Applier calls it at `:204` (native equipment-tag alarms,
|
||||
`tag.Alarm`) and `:295` (scripted, `alarm.ScriptedAlarmId`).
|
||||
- `OtOpcUaNodeManager.MaterialiseAlarmCondition` wires the inbound method delegates at `:594-624`
|
||||
(`OnAcknowledge`/`OnConfirm`/`OnAddComment`/`OnShelve`/`OnTimedUnshelve` → `HandleAlarmCommand`). `OnEnableDisable`
|
||||
is absent. `HandleAlarmCommand` (`:654-679`) AlarmAck-gates via `RoleCarryingUserIdentity` and routes via the
|
||||
`Action<AlarmCommand>? AlarmCommandRouter` property (`:91`). `AlarmCommand` vocab already has `Enable`/`Disable`.
|
||||
- The engine already handles them: `ScriptedAlarmEngine.EnableAsync/DisableAsync`,
|
||||
dispatched in `ScriptedAlarmHostActor.cs:408-412` on `AlarmCommand` `"Enable"`/`"Disable"`.
|
||||
- `DriverHostActor` forward map `_alarmNodeIdByDriverRef: (DriverInstanceId, FullName) → condition NodeId(s)`
|
||||
(field `:127`, cleared+rebuilt `:902-904`); `ForwardNativeAlarm` (`:537`) resolves on `msg.Args.ConditionId`
|
||||
(= dotted FullName). No inbound OPC-UA-ack→driver path exists.
|
||||
- `AlarmAcknowledgeRequest` (`src/Core/ZB.MOM.WW.OtOpcUa.Core.Abstractions/IAlarmSource.cs:44`) =
|
||||
`(string SourceNodeId, string ConditionId, string? Comment)` — NO principal field.
|
||||
- `GalaxyDriver.AcknowledgeAsync` (`src/Drivers/ZB.MOM.WW.OtOpcUa.Driver.Galaxy/GalaxyDriver.cs:1095`) forwards
|
||||
to `IGalaxyAlarmAcknowledger.AcknowledgeAsync(alarmFullReference, comment, operatorUser, ct)` (which already
|
||||
takes `operatorUser`). `ScriptedAlarmSource.cs:75` hardcodes `"opcua-client"`.
|
||||
- Test homes: `tests/Core/.../Authorization/TriePermissionEvaluatorTests.cs` (H2);
|
||||
`tests/Server/ZB.MOM.WW.OtOpcUa.OpcUaServer.Tests/AlarmCommandRouterTests.cs` (H4/H6 node-manager seam);
|
||||
`tests/Server/ZB.MOM.WW.OtOpcUa.Runtime.Tests/...` (DriverHostActor). Galaxy: `tests/Drivers/...Driver.Galaxy.Tests`.
|
||||
|
||||
---
|
||||
|
||||
### Task 1: H2-bit — `NodePermissions.HistoryUpdate` + evaluator mapping
|
||||
|
||||
**Classification:** small
|
||||
**Estimated implement time:** ~3 min
|
||||
**Parallelizable with:** Task 2
|
||||
|
||||
**Files:**
|
||||
- Modify: `src/Core/ZB.MOM.WW.OtOpcUa.Configuration/Enums/NodePermissions.cs`
|
||||
- Modify: `src/Core/ZB.MOM.WW.OtOpcUa.Core/Authorization/TriePermissionEvaluator.cs:86`
|
||||
- Test: `tests/Core/ZB.MOM.WW.OtOpcUa.Core.Tests/Authorization/TriePermissionEvaluatorTests.cs`
|
||||
|
||||
**Step 1: Failing tests** (add to `TriePermissionEvaluatorTests.cs`):
|
||||
- `HistoryRead_grant_does_not_authorize_HistoryUpdate`: build a scope/ACL granting only
|
||||
`NodePermissions.HistoryRead`; `Authorize(session, OpcUaOperation.HistoryUpdate, scope)` → NOT Allow
|
||||
(NotGranted). (Mirror an existing test's ACL/session construction.)
|
||||
- `HistoryUpdate_grant_authorizes_HistoryUpdate`: a scope granting the new `NodePermissions.HistoryUpdate` bit →
|
||||
`Authorize(…, HistoryUpdate, …)` → Allow.
|
||||
- `HistoryUpdate_bit_does_not_collide`: `((int)NodePermissions.HistoryUpdate).ShouldBe(1 << 12)` and
|
||||
`(NodePermissions.HistoryUpdate & NodePermissions.MethodCall).ShouldBe(NodePermissions.None)`.
|
||||
|
||||
**Step 2: Run, expect FAIL** (the bit doesn't exist / HistoryUpdate currently maps to the HistoryRead bit so the
|
||||
first test wrongly passes-as-Allow):
|
||||
`dotnet test tests/Core/ZB.MOM.WW.OtOpcUa.Core.Tests --filter "FullyQualifiedName~TriePermissionEvaluator"`
|
||||
|
||||
**Step 3: Implement.**
|
||||
- In `NodePermissions.cs` add `HistoryUpdate = 1 << 12,` after `MethodCall = 1 << 11,` (with an XML/`//` doc).
|
||||
Do NOT add it to any composite (`ReadOnly/Operator/Engineer/Admin`) — the HistoryUpdate *service* is deferred,
|
||||
so no role needs to grant it yet; the bit exists only to close the HistoryRead⇒HistoryUpdate hole.
|
||||
- In `TriePermissionEvaluator.cs:86` change `OpcUaOperation.HistoryUpdate => NodePermissions.HistoryRead,` to
|
||||
`OpcUaOperation.HistoryUpdate => NodePermissions.HistoryUpdate,` and delete the stale `// TODO` comment.
|
||||
|
||||
**Step 4: Run, expect PASS.** Also `dotnet build ZB.MOM.WW.OtOpcUa.slnx` clean.
|
||||
|
||||
**Step 5: Commit**
|
||||
```bash
|
||||
git add src/Core/ZB.MOM.WW.OtOpcUa.Configuration/Enums/NodePermissions.cs \
|
||||
src/Core/ZB.MOM.WW.OtOpcUa.Core/Authorization/TriePermissionEvaluator.cs \
|
||||
tests/Core/ZB.MOM.WW.OtOpcUa.Core.Tests/Authorization/TriePermissionEvaluatorTests.cs
|
||||
git commit -m "fix(authz): give HistoryUpdate its own NodePermissions bit (was aliased to HistoryRead) [H2]"
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
### Task 2: H6a — mark native conditions (`isNative` through the sink)
|
||||
|
||||
**Classification:** high-risk
|
||||
**Estimated implement time:** ~5 min
|
||||
**Parallelizable with:** Task 1, Task 4
|
||||
|
||||
**Files:**
|
||||
- Modify: `src/Core/ZB.MOM.WW.OtOpcUa.Core.Abstractions/IOpcUaAddressSpaceSink.cs` (or wherever the interface
|
||||
lives — `grep -rn "void MaterialiseAlarmCondition" src --include=*.cs` to confirm; the design noted the sink
|
||||
interface declares it)
|
||||
- Modify: `src/Server/ZB.MOM.WW.OtOpcUa.OpcUaServer/SdkAddressSpaceSink.cs:45`
|
||||
- Modify: `src/Core/ZB.MOM.WW.OtOpcUa.Commons/OpcUa/DeferredAddressSpaceSink.cs:47`
|
||||
- Modify: `src/Core/ZB.MOM.WW.OtOpcUa.Commons/OpcUa/NullOpcUaAddressSpaceSink.cs` (no-op impl)
|
||||
- Modify: `src/Server/ZB.MOM.WW.OtOpcUa.OpcUaServer/OtOpcUaNodeManager.cs:538` (signature + `_nativeAlarmNodeIds` set)
|
||||
- Modify: `src/Server/ZB.MOM.WW.OtOpcUa.OpcUaServer/Phase7Applier.cs:204,295,336-339` (`SafeMaterialiseAlarmCondition`)
|
||||
- Test: `tests/Server/ZB.MOM.WW.OtOpcUa.OpcUaServer.Tests/AlarmCommandRouterTests.cs` (+ `SdkAddressSpaceSinkTests` if it asserts the signature)
|
||||
|
||||
**Step 1: Failing test.** In `AlarmCommandRouterTests.cs`, add a test that a condition materialised with
|
||||
`isNative: true` is tracked as native (assert via behavior introduced in this task: e.g. a public/internal
|
||||
`IsNativeAlarm(nodeId)` test hook on the node manager, OR defer the behavioral assertion to Task 5 and here
|
||||
just assert the signature compiles + Phase7Applier passes the flag). Prefer adding an `internal bool
|
||||
IsNativeAlarmNode(string alarmNodeId)` test accessor on `OtOpcUaNodeManager` and asserting
|
||||
`true` after a native materialise / `false` after a scripted one.
|
||||
|
||||
**Step 2: Run, expect FAIL** (param/accessor missing).
|
||||
|
||||
**Step 3: Implement.**
|
||||
- Add `bool isNative = false` as the LAST, defaulted param to `MaterialiseAlarmCondition` on the interface +
|
||||
every impl. Defaulted so no other caller breaks.
|
||||
- `OtOpcUaNodeManager`: add `private readonly HashSet<string> _nativeAlarmNodeIds = new();`; when
|
||||
`isNative`, `_nativeAlarmNodeIds.Add(alarmNodeId)`. Add `internal bool IsNativeAlarmNode(string alarmNodeId) =>
|
||||
_nativeAlarmNodeIds.Contains(alarmNodeId);`. (Clear the set on address-space rebuild if the manager resets
|
||||
`_alarmConditions` — match that lifecycle.)
|
||||
- `Phase7Applier.SafeMaterialiseAlarmCondition`: add a `bool isNative` param; pass `isNative: true` at the
|
||||
native equipment-tag-alarm call (`:204`) and `isNative: false` at the scripted call (`:295`).
|
||||
|
||||
**Step 4: Run, expect PASS** + `dotnet build ZB.MOM.WW.OtOpcUa.slnx` clean (all sink impls updated).
|
||||
|
||||
**Step 5: Commit** (stage each modified file by path).
|
||||
`git commit -m "feat(alarms): thread isNative through MaterialiseAlarmCondition; node manager tracks native conditions [H6a]"`
|
||||
|
||||
---
|
||||
|
||||
### Task 3: H4 — wire `OnEnableDisable`
|
||||
|
||||
**Classification:** high-risk
|
||||
**Estimated implement time:** ~5 min
|
||||
**Parallelizable with:** none
|
||||
|
||||
**Files:**
|
||||
- Modify: `src/Server/ZB.MOM.WW.OtOpcUa.OpcUaServer/OtOpcUaNodeManager.cs` (in `MaterialiseAlarmCondition`, near `:594-624`)
|
||||
- Test: `tests/Server/ZB.MOM.WW.OtOpcUa.OpcUaServer.Tests/AlarmCommandRouterTests.cs`
|
||||
|
||||
**Step 0 — VERIFY the SDK delegate.** Confirm `AlarmConditionState`/`ConditionState` exposes
|
||||
`OnEnableDisable` and its exact delegate signature (likely `ServiceResult (ISystemContext context,
|
||||
ConditionState condition, bool enabling)`, matching the `OnShelve`/`OnAcknowledge` settable-handler pattern).
|
||||
Use IntelliSense/decompile (`Opc.Ua.Server` 1.5.x). If the SDK instead exposes separate `OnEnable`/`OnDisable`
|
||||
handlers, adapt — wire both to the same body with the right `enabling` value. If `OnEnableDisable` genuinely
|
||||
does not exist on this SDK version, STOP and report (the design assumed it per `AlarmCommand.cs:37`).
|
||||
|
||||
**Step 1: Failing tests** (mirror the existing `OnAcknowledge`/`OnShelve` tests in `AlarmCommandRouterTests.cs`):
|
||||
- `OnEnableDisable_with_AlarmAck_routes_Disable_command`: materialise a SCRIPTED condition (`isNative:false`);
|
||||
capture `AlarmCommandRouter`; invoke `OnEnableDisable(ctx-with-AlarmAck-RoleCarryingUserIdentity, condition,
|
||||
enabling:false)` → result `Good`, captured `AlarmCommand.Operation == "Disable"`, `User == DisplayName`.
|
||||
- `OnEnableDisable_enabling_routes_Enable_command`: same with `enabling:true` → `"Enable"`.
|
||||
- `OnEnableDisable_anonymous_is_denied`: no/role-less identity → `BadUserAccessDenied`, no route.
|
||||
- `OnEnableDisable_on_native_condition_is_BadNotSupported`: materialise with `isNative:true`; invoke
|
||||
`OnEnableDisable` → `BadNotSupported`, no route. (Uses Task 2's `_nativeAlarmNodeIds`.)
|
||||
|
||||
**Step 2: Run, expect FAIL.**
|
||||
|
||||
**Step 3: Implement.** In `MaterialiseAlarmCondition`, after the `OnShelve`/`OnTimedUnshelve` wiring:
|
||||
```csharp
|
||||
alarm.OnEnableDisable = (context, condition, enabling) =>
|
||||
{
|
||||
// Native (driver-fed) conditions have no engine enable/disable surface (decision #2).
|
||||
if (_nativeAlarmNodeIds.Contains(alarmNodeId))
|
||||
return new ServiceResult(StatusCodes.BadNotSupported);
|
||||
return HandleAlarmCommand(context, condition, enabling ? "Enable" : "Disable", comment: null, unshelveAt: null);
|
||||
};
|
||||
```
|
||||
(Adapt the delegate shape to Step 0's finding. `_nativeAlarmNodeIds` is populated in Task 2 — this task is
|
||||
ordered after Task 2.)
|
||||
|
||||
**Step 4: Run, expect PASS** + full build clean. Note: `ScriptedAlarmHostActor` Enable/Disable dispatch is
|
||||
already covered — no engine change needed.
|
||||
|
||||
**Step 5: Commit**
|
||||
`git commit -m "feat(alarms): wire OnEnableDisable over OPC UA (AlarmAck-gated; native→BadNotSupported) [H4]"`
|
||||
|
||||
---
|
||||
|
||||
### Task 4: H6b — `AlarmAcknowledgeRequest.OperatorUser` + Galaxy forwarding + ScriptedAlarmSource tidy
|
||||
|
||||
**Classification:** standard
|
||||
**Estimated implement time:** ~4 min
|
||||
**Parallelizable with:** Task 1, Task 2
|
||||
|
||||
**Files:**
|
||||
- Modify: `src/Core/ZB.MOM.WW.OtOpcUa.Core.Abstractions/IAlarmSource.cs:44` (record)
|
||||
- Modify: `src/Drivers/ZB.MOM.WW.OtOpcUa.Driver.Galaxy/GalaxyDriver.cs:1095` (forward `OperatorUser`)
|
||||
- Modify: `src/Core/ZB.MOM.WW.OtOpcUa.Core.ScriptedAlarms/ScriptedAlarmSource.cs:65-78`
|
||||
- Test: `tests/Drivers/ZB.MOM.WW.OtOpcUa.Driver.Galaxy.Tests/...` (Galaxy ack forwarding) + a Core.Abstractions or
|
||||
ScriptedAlarms test for the record/`ScriptedAlarmSource` principal.
|
||||
|
||||
**Step 1: Failing tests.**
|
||||
- `GalaxyDriver_AcknowledgeAsync_forwards_OperatorUser`: with a fake `IGalaxyAlarmAcknowledger`, call
|
||||
`AcknowledgeAsync([ new AlarmAcknowledgeRequest("src","cond.alarm","cmt"){ OperatorUser="alice" } ])` (or
|
||||
positional) → the fake received `operatorUser == "alice"`. (Find the existing Galaxy acknowledger test/fake.)
|
||||
- `ScriptedAlarmSource_uses_supplied_principal_else_opcua_client`: a request with `OperatorUser="bob"` →
|
||||
engine.AcknowledgeAsync called with `"bob"`; with `OperatorUser=null` → `"opcua-client"`.
|
||||
|
||||
**Step 2: Run, expect FAIL** (the field doesn't exist).
|
||||
|
||||
**Step 3: Implement.**
|
||||
- `AlarmAcknowledgeRequest` → add `string? OperatorUser = null` as the LAST positional param (keeps existing
|
||||
positional construction working). XML-doc it ("authenticated principal; null on the raw path").
|
||||
- `GalaxyDriver.AcknowledgeAsync`: pass `a.OperatorUser ?? <existing-fallback>` as `operatorUser` to the
|
||||
acknowledger (preserve whatever it currently passes when null).
|
||||
- `ScriptedAlarmSource.AcknowledgeAsync` (`:75`): `await _engine.AcknowledgeAsync(a.ConditionId,
|
||||
a.OperatorUser ?? "opcua-client", a.Comment, ct)`.
|
||||
- AbCip/FOCAS `AcknowledgeAsync` need no change (they ignore the new field) — confirm they still compile.
|
||||
|
||||
**Step 4: Run, expect PASS** + full build clean.
|
||||
|
||||
**Step 5: Commit**
|
||||
`git commit -m "feat(alarms): AlarmAcknowledgeRequest carries OperatorUser; Galaxy/ScriptedAlarmSource honor it [H6b]"`
|
||||
|
||||
---
|
||||
|
||||
### Task 5: H6c — `NativeAlarmAckRouter` seam + native `OnAcknowledge` routing
|
||||
|
||||
**Classification:** high-risk
|
||||
**Estimated implement time:** ~5 min
|
||||
**Parallelizable with:** none (needs Task 2's `_nativeAlarmNodeIds`)
|
||||
|
||||
**Files:**
|
||||
- Create: `src/Server/ZB.MOM.WW.OtOpcUa.OpcUaServer/NativeAlarmAck.cs` (small record — OpcUaServer-local, smallest scope)
|
||||
- Modify: `src/Server/ZB.MOM.WW.OtOpcUa.OpcUaServer/OtOpcUaNodeManager.cs` (`NativeAlarmAckRouter` property + native `OnAcknowledge`)
|
||||
- Test: `tests/Server/ZB.MOM.WW.OtOpcUa.OpcUaServer.Tests/AlarmCommandRouterTests.cs`
|
||||
|
||||
**Step 1: Failing tests.**
|
||||
- `Native_OnAcknowledge_routes_to_NativeAlarmAckRouter_not_scripted`: materialise `isNative:true`; capture both
|
||||
routers; invoke `OnAcknowledge(ctx-with-AlarmAck, condition, _, comment)` → `Good`; the `NativeAlarmAckRouter`
|
||||
got `NativeAlarmAck(conditionNodeId, comment, OperatorUser=DisplayName)`; the scripted `AlarmCommandRouter`
|
||||
got NOTHING.
|
||||
- `Scripted_OnAcknowledge_still_uses_AlarmCommandRouter`: `isNative:false` → `AlarmCommandRouter` gets the
|
||||
`AlarmCommand`, `NativeAlarmAckRouter` gets nothing.
|
||||
- `Native_OnAcknowledge_anonymous_is_denied`: no AlarmAck role → `BadUserAccessDenied`, neither router invoked.
|
||||
|
||||
**Step 2: Run, expect FAIL.**
|
||||
|
||||
**Step 3: Implement.**
|
||||
- `NativeAlarmAck.cs`: `public sealed record NativeAlarmAck(string ConditionNodeId, string? Comment, string OperatorUser);`
|
||||
- `OtOpcUaNodeManager`: add `public Action<NativeAlarmAck>? NativeAlarmAckRouter { get; set; }`.
|
||||
- In `MaterialiseAlarmCondition`, set `OnAcknowledge` based on native-ness:
|
||||
```csharp
|
||||
alarm.OnAcknowledge = isNative
|
||||
? (context, condition, _, comment) => HandleNativeAlarmAck(context, condition, comment)
|
||||
: (context, condition, _, comment) => HandleAlarmCommand(context, condition, "Acknowledge", comment, null);
|
||||
```
|
||||
(Capture `isNative` per-condition; don't rely on the set lookup inside the closure unless you prefer it —
|
||||
either is fine, but the set lookup also works: `_nativeAlarmNodeIds.Contains(alarmNodeId)`.)
|
||||
- Add `HandleNativeAlarmAck`: resolve the AlarmAck-gated `RoleCarryingUserIdentity` EXACTLY like
|
||||
`HandleAlarmCommand` (fail-closed → `BadUserAccessDenied`); else
|
||||
`NativeAlarmAckRouter?.Invoke(new NativeAlarmAck(condition.NodeId.Identifier?.ToString() ?? "",
|
||||
comment?.Text, identity.DisplayName ?? ""))`; return `Good`. (Confirm whether the native condition's NodeId
|
||||
identifier is the folder-scoped condition node id the inverse map in Task 6 will key by — align with
|
||||
`_alarmNodeIdByDriverRef`'s value set.)
|
||||
|
||||
**Step 4: Run, expect PASS** + full build clean.
|
||||
|
||||
**Step 5: Commit**
|
||||
`git commit -m "feat(alarms): native condition Acknowledge routes to NativeAlarmAckRouter with principal [H6c]"`
|
||||
|
||||
---
|
||||
|
||||
### Task 6: H6d — `DriverHostActor` inverse map + native-ack route to the driver
|
||||
|
||||
**Classification:** high-risk
|
||||
**Estimated implement time:** ~5 min
|
||||
**Parallelizable with:** none (needs Task 4 `OperatorUser` + Task 5 `NativeAlarmAck`)
|
||||
|
||||
**Files:**
|
||||
- Modify: `src/Server/ZB.MOM.WW.OtOpcUa.Runtime/Drivers/DriverHostActor.cs` (inverse map + `Receive<NativeAlarmAck-or-RouteNativeAck>`)
|
||||
- Modify: `src/Server/ZB.MOM.WW.OtOpcUa.Runtime/Drivers/DriverInstanceActor.cs` (a `RouteAlarmAck` receive → `driver.AcknowledgeAsync`) — only if the host routes via the instance actor; otherwise the host calls the driver via its existing handle
|
||||
- Test: `tests/Server/ZB.MOM.WW.OtOpcUa.Runtime.Tests/Drivers/...` (mirror an existing DriverHostActor test)
|
||||
|
||||
**Step 1: Failing tests.**
|
||||
- `Inverse_map_resolves_condition_node_to_driver_ref`: after an `ApplyDelta`/composition with a native alarm
|
||||
tag, the inverse map yields `(DriverInstanceId, FullName)` for the materialised condition node id.
|
||||
- `NativeAlarmAck_routes_to_driver_AcknowledgeAsync_with_OperatorUser`: feed the host a native-ack message
|
||||
(the Runtime-side envelope the host wires the `NativeAlarmAckRouter` to) referencing a known condition node;
|
||||
a stub `IAlarmSource` driver receives `AcknowledgeAsync` with `ConditionId == alarmRef`,
|
||||
`OperatorUser == "alice"`, `Comment` passed through. Use the shared `StubDrivers.cs` harness.
|
||||
- `NativeAlarmAck_unknown_node_is_dropped`: an ack for an unmapped node → logged + dropped, no throw.
|
||||
|
||||
**Step 2: Run, expect FAIL.**
|
||||
|
||||
**Step 3: Implement.**
|
||||
- Build the inverse `Dictionary<string, (string DriverInstanceId, string FullName)> _driverRefByAlarmNodeId`
|
||||
in the SAME clear-and-rebuild pass that builds `_alarmNodeIdByDriverRef` (`:902-904`): for each
|
||||
`(driverId, fullName) → {nodeIds}`, add each `nodeId → (driverId, fullName)`.
|
||||
- Decide the host's inbound envelope: the node manager's `NativeAlarmAckRouter` is `Action<NativeAlarmAck>`
|
||||
wired (in Task 7) to `Tell` a Runtime message into `DriverHostActor`. Define that Runtime message
|
||||
(e.g. `DriverHostActor.RouteNativeAlarmAck(string ConditionNodeId, string? Comment, string OperatorUser)`)
|
||||
— do NOT reference the OpcUaServer `NativeAlarmAck` type from Runtime if it creates a bad dependency; map at
|
||||
the wiring boundary (Task 7). `Receive<RouteNativeAlarmAck>`: look up `_driverRefByAlarmNodeId`; on miss →
|
||||
`_log.Debug` + return; on hit → route to the driver via the same mechanism `ForwardNativeAlarm`/the write
|
||||
path uses (Tell the `DriverInstanceActor` a `RouteAlarmAck` it turns into
|
||||
`driver.AcknowledgeAsync([ new AlarmAcknowledgeRequest(SourceNodeId: <owning object or fullName>, ConditionId:
|
||||
fullName, Comment, OperatorUser) ], CancellationToken.None)`, fire-and-forget). Mirror the primary-gating
|
||||
the write/ack paths use if applicable.
|
||||
|
||||
**Step 4: Run, expect PASS** + full build clean.
|
||||
|
||||
**Step 5: Commit**
|
||||
`git commit -m "feat(alarms): DriverHostActor routes native-condition acks to the owning driver [H6d]"`
|
||||
|
||||
---
|
||||
|
||||
### Task 7: H6e — wire `NativeAlarmAckRouter` in host DI
|
||||
|
||||
**Classification:** high-risk
|
||||
**Estimated implement time:** ~3 min
|
||||
**Parallelizable with:** none
|
||||
|
||||
**Files:**
|
||||
- Modify: the host wiring that sets `AlarmCommandRouter` today (`grep -rn "AlarmCommandRouter =" src --include=*.cs`
|
||||
— likely `OtOpcUaServerHostedService` / a DI/bootstrap seam). Set `NativeAlarmAckRouter` analogously to a
|
||||
fire-and-forget `Tell` of the Runtime `RouteNativeAlarmAck` into the `DriverHostActor` (resolve its `IActorRef`
|
||||
the same way the AlarmCommandRouter resolves the ScriptedAlarmHost / mediator).
|
||||
- Test: extend the existing wiring/smoke test if one asserts `AlarmCommandRouter` is set; else none (covered by
|
||||
the live `/run`).
|
||||
|
||||
**Step 1: Implement** the router assignment (map `NativeAlarmAck` → the Runtime `RouteNativeAlarmAck` at this
|
||||
boundary so Runtime needn't reference OpcUaServer's record). Confirm the `DriverHostActor` ref is available at
|
||||
the wiring site (it's registered in the actor registry).
|
||||
|
||||
**Step 2: Build + full test.** `dotnet build ZB.MOM.WW.OtOpcUa.slnx` clean; `dotnet test` on the affected
|
||||
projects green.
|
||||
|
||||
**Step 3: Commit**
|
||||
`git commit -m "feat(alarms): wire NativeAlarmAckRouter to DriverHostActor in host DI [H6e]"`
|
||||
|
||||
---
|
||||
|
||||
### Task 8: Docs
|
||||
|
||||
**Classification:** small
|
||||
**Estimated implement time:** ~3 min
|
||||
**Parallelizable with:** Task 7
|
||||
|
||||
**Files:**
|
||||
- Modify: `docs/ScriptedAlarms.md`, `docs/AlarmTracking.md`
|
||||
- Modify: `docs/security.md` (HistoryUpdate permission bit note, if the § on NodePermissions warrants it)
|
||||
|
||||
**Step 1:** Document: H4 — OPC UA clients can now Enable/Disable Part 9 conditions (AlarmAck-gated; the engine
|
||||
applies it; native conditions return `BadNotSupported`). H6 — an inbound Acknowledge on a *native* (Galaxy)
|
||||
condition now routes to the owning driver → AVEVA, carrying the authenticated principal (not the generic
|
||||
`opcua-client`); `AlarmAcknowledgeRequest` gained `OperatorUser`. H2 — `HistoryUpdate` has its own permission
|
||||
bit (a HistoryRead grant no longer authorizes it); the HistoryUpdate *service* remains deferred (infra-gated).
|
||||
|
||||
**Step 2:** No build needed. Grep for now-false claims (e.g. `AlarmCommand.cs`'s "OnEnableDisable … future
|
||||
task" comment — update it; `ScriptedAlarmSource.cs`'s "opcua-client" remark).
|
||||
|
||||
**Step 3: Commit** by path.
|
||||
`git commit -m "docs(alarms): OPC UA Enable/Disable wired + native-ack→AVEVA + HistoryUpdate permission bit"`
|
||||
|
||||
---
|
||||
|
||||
### Task 9: Full build + test + final integration review
|
||||
|
||||
**Classification:** high-risk
|
||||
**Estimated implement time:** ~4 min
|
||||
**Parallelizable with:** none
|
||||
|
||||
**Step 1:** `dotnet build ZB.MOM.WW.OtOpcUa.slnx` clean (TreatWarningsAsErrors).
|
||||
**Step 2:** `dotnet test` on Core.Tests, OpcUaServer.Tests, Runtime.Tests, Driver.Galaxy.Tests — all green.
|
||||
**Step 3:** Final integration reviewer: confirm (a) no EF/Configuration migration; the only contract touches are
|
||||
the `isNative` sink param + `AlarmAcknowledgeRequest.OperatorUser` (both additive/defaulted); (b) native acks
|
||||
route to the driver and scripted acks/enable-disable still route to the engine (no cross-wiring); (c) the
|
||||
AlarmAck fail-closed gate holds on every new path (H4 Enable/Disable + H6 native ack); (d) the `NativeAlarmAck`
|
||||
→ Runtime `RouteNativeAlarmAck` boundary doesn't create a Runtime→OpcUaServer bad dependency; (e) staging
|
||||
by-path only. Apply actionable findings.
|
||||
**Step 4:** Update `pending.md` (working-tree only, never staged).
|
||||
|
||||
---
|
||||
|
||||
### Task 10: Live `/run`
|
||||
|
||||
**Classification:** high-risk (verification)
|
||||
**Estimated implement time:** ~6 min (agent-driven on docker-dev; login disabled — do NOT sign in)
|
||||
|
||||
**H4 (fully local-provable):** ensure a scripted alarm exists on the dev config (or author one), deploy, then
|
||||
`dotnet run --project src/Client/ZB.MOM.WW.OtOpcUa.Client.CLI -- ...` — Disable the condition via the Part 9
|
||||
Disable method (Client.CLI `shelve`/`ack` style command, or a `call` on the Disable method node) **as a
|
||||
user holding the AlarmAck role** (LDAP `opc-...` per the data-plane role map) → confirm the condition's
|
||||
`EnabledState` goes Disabled in the server log / a follow-up read; anon → `BadUserAccessDenied`.
|
||||
|
||||
**H6 (local half):** trip a native (Galaxy) alarm, Acknowledge it over OPC UA as an AlarmAck user → confirm
|
||||
from the central-1 log that the ack ROUTED to the driver (`DriverHostActor` native-ack route log line) with the
|
||||
authenticated principal. The **AVEVA commit** (gateway → Historian on `10.100.0.48`) is operator-gated — drive
|
||||
it against the reachable gateway if feasible this session (the Galaxy live-gw smokes pattern), else record it
|
||||
as operator-gated (like H5).
|
||||
|
||||
**Done when:** build clean + `dotnet test` green + H4 live-proven + H6 local route proven (AVEVA commit recorded
|
||||
as driven-or-operator-gated). Then `finishing-a-development-branch` → merge to master + push.
|
||||
@@ -0,0 +1,17 @@
|
||||
{
|
||||
"planPath": "docs/plans/2026-06-15-stillpending-phase-3-opcua-standards.md",
|
||||
"branch": "feat/stillpending-phase-3-opcua-standards",
|
||||
"tasks": [
|
||||
{"id": 423, "subject": "P3 Task 1: H2-bit — NodePermissions.HistoryUpdate + evaluator mapping", "status": "pending"},
|
||||
{"id": 424, "subject": "P3 Task 2: H6a — mark native conditions (isNative through the sink)", "status": "pending"},
|
||||
{"id": 425, "subject": "P3 Task 3: H4 — wire OnEnableDisable over OPC UA", "status": "pending", "blockedBy": [424]},
|
||||
{"id": 426, "subject": "P3 Task 4: H6b — AlarmAcknowledgeRequest.OperatorUser + Galaxy/ScriptedAlarmSource", "status": "pending"},
|
||||
{"id": 427, "subject": "P3 Task 5: H6c — NativeAlarmAckRouter seam + native OnAcknowledge routing", "status": "pending", "blockedBy": [424]},
|
||||
{"id": 428, "subject": "P3 Task 6: H6d — DriverHostActor inverse map + native-ack route to driver", "status": "pending", "blockedBy": [426, 427]},
|
||||
{"id": 429, "subject": "P3 Task 7: H6e — wire NativeAlarmAckRouter in host DI", "status": "pending", "blockedBy": [427, 428]},
|
||||
{"id": 430, "subject": "P3 Task 8: Docs — Enable/Disable + native-ack→AVEVA + HistoryUpdate bit", "status": "pending"},
|
||||
{"id": 431, "subject": "P3 Task 9: Full build + test + final integration review", "status": "pending", "blockedBy": [423, 425, 429, 430]},
|
||||
{"id": 432, "subject": "P3 Task 10: Live /run — H4 Enable/Disable + H6 native-ack route", "status": "pending", "blockedBy": [431]}
|
||||
],
|
||||
"lastUpdated": "2026-06-15"
|
||||
}
|
||||
@@ -205,6 +205,7 @@ public enum NodePermissions : int
|
||||
AlarmConfirm = 1 << 9,
|
||||
AlarmShelve = 1 << 10,
|
||||
MethodCall = 1 << 11,
|
||||
HistoryUpdate = 1 << 12, // OPC UA annotation / insert / delete (separate from HistoryRead)
|
||||
|
||||
ReadOnly = Browse | Read | Subscribe | HistoryRead | AlarmRead,
|
||||
Operator = ReadOnly | WriteOperate | AlarmAcknowledge | AlarmConfirm,
|
||||
@@ -215,6 +216,8 @@ public enum NodePermissions : int
|
||||
|
||||
The three Write tiers map to Galaxy's v1 `SecurityClassification` — `FreeAccess`/`Operate` → `WriteOperate`, `Tune` → `WriteTune`, `Configure` → `WriteConfigure`. `SecuredWrite` / `VerifiedWrite` / `ViewOnly` classifications remain read-only from OPC UA regardless of grant.
|
||||
|
||||
`HistoryUpdate` (bit 12) is a **separate** permission from `HistoryRead` so a read-only grant cannot also authorize OPC UA HistoryUpdate (annotation / insert / delete) operations. `TriePermissionEvaluator` maps `OpcUaOperation.HistoryUpdate` to this bit, closing the read⇒update hole that existed when the only history permission was `HistoryRead`. Note: `HistoryUpdate` is **not** included in any composite bundle (`ReadOnly` / `Operator` / `Engineer` / `Admin`) because the HistoryUpdate service surface (the actual insert/replace/delete backend RPC) is not yet implemented — a client calling HistoryUpdate still receives the SDK's default reject regardless of the grant.
|
||||
|
||||
### Evaluator — `PermissionTrie`
|
||||
|
||||
`src/Core/ZB.MOM.WW.OtOpcUa.Core/Authorization/`:
|
||||
|
||||
@@ -32,9 +32,9 @@ public static class AlarmCommandsTopic
|
||||
/// The Part 9 operation, one of: <c>Acknowledge</c>, <c>Confirm</c>, <c>OneShotShelve</c>,
|
||||
/// <c>TimedShelve</c>, <c>Unshelve</c>, <c>Enable</c>, <c>Disable</c>, <c>AddComment</c>. These map
|
||||
/// 1:1 onto the engine's <c>Part9StateMachine.Apply*</c> calls on the consuming side (T19).
|
||||
/// Note: <c>Enable</c> and <c>Disable</c> are part of the vocabulary but are not yet wired at the
|
||||
/// node-manager seam (T18 wired Acknowledge/Confirm/AddComment/Shelve/TimedUnshelve only);
|
||||
/// <c>OnEnableDisable</c> delegate wiring is a future task.
|
||||
/// All of <c>Acknowledge</c>/<c>Confirm</c>/<c>AddComment</c>/<c>Shelve</c>/<c>TimedUnshelve</c>/
|
||||
/// <c>Enable</c>/<c>Disable</c> are wired at the node-manager seam; the <c>Enable</c>/<c>Disable</c>
|
||||
/// operations are produced by the condition's <c>OnEnableDisable</c> delegate.
|
||||
/// </param>
|
||||
/// <param name="User">The acting user — the authenticated session identity's display/name.</param>
|
||||
/// <param name="Comment">
|
||||
|
||||
@@ -43,8 +43,9 @@ public sealed class DeferredAddressSpaceSink : IOpcUaAddressSpaceSink
|
||||
/// <param name="displayName">The human-readable condition name.</param>
|
||||
/// <param name="alarmType">The domain alarm type.</param>
|
||||
/// <param name="severity">The domain severity.</param>
|
||||
public void MaterialiseAlarmCondition(string alarmNodeId, string equipmentNodeId, string displayName, string alarmType, int severity)
|
||||
=> _inner.MaterialiseAlarmCondition(alarmNodeId, equipmentNodeId, displayName, alarmType, severity);
|
||||
/// <param name="isNative">True for a driver-fed (native) equipment-tag alarm; false (default) for a scripted alarm.</param>
|
||||
public void MaterialiseAlarmCondition(string alarmNodeId, string equipmentNodeId, string displayName, string alarmType, int severity, bool isNative = false)
|
||||
=> _inner.MaterialiseAlarmCondition(alarmNodeId, equipmentNodeId, displayName, alarmType, severity, isNative);
|
||||
|
||||
/// <summary>Ensures a folder exists in the address space through the inner sink.</summary>
|
||||
/// <param name="folderNodeId">The node ID of the folder.</param>
|
||||
|
||||
@@ -38,7 +38,10 @@ public interface IOpcUaAddressSpaceSink
|
||||
/// <param name="displayName">Human-readable condition name (BrowseName / DisplayName / Message).</param>
|
||||
/// <param name="alarmType">Domain alarm type — mapped to the SDK condition subtype by the sink.</param>
|
||||
/// <param name="severity">Domain severity (OPC UA 1..1000 scale); mapped to the SDK severity buckets.</param>
|
||||
void MaterialiseAlarmCondition(string alarmNodeId, string equipmentNodeId, string displayName, string alarmType, int severity);
|
||||
/// <param name="isNative">When true this is a driver-fed (native, e.g. Galaxy) equipment-tag alarm; when
|
||||
/// false (default) it is a scripted alarm. The node manager tracks native condition node ids so a later
|
||||
/// task can route a native condition's inbound Acknowledge to the driver instead of the scripted engine.</param>
|
||||
void MaterialiseAlarmCondition(string alarmNodeId, string equipmentNodeId, string displayName, string alarmType, int severity, bool isNative = false);
|
||||
|
||||
/// <summary>
|
||||
/// Ensure a folder node exists under the given parent. Used by <c>Phase7Applier</c> to
|
||||
@@ -95,7 +98,7 @@ public sealed class NullOpcUaAddressSpaceSink : IOpcUaAddressSpaceSink
|
||||
public void WriteAlarmCondition(string alarmNodeId, AlarmConditionSnapshot state, DateTime sourceTimestampUtc) { }
|
||||
|
||||
/// <inheritdoc />
|
||||
public void MaterialiseAlarmCondition(string alarmNodeId, string equipmentNodeId, string displayName, string alarmType, int severity) { }
|
||||
public void MaterialiseAlarmCondition(string alarmNodeId, string equipmentNodeId, string displayName, string alarmType, int severity, bool isNative = false) { }
|
||||
|
||||
/// <inheritdoc />
|
||||
public void EnsureFolder(string folderNodeId, string? parentNodeId, string displayName) { }
|
||||
|
||||
@@ -29,6 +29,11 @@ public enum NodePermissions : int
|
||||
// OPC UA Part 4 §5.11
|
||||
MethodCall = 1 << 11,
|
||||
|
||||
// OPC UA HistoryUpdate (annotation / insert / delete) — separate from HistoryRead so a
|
||||
// read-only grant cannot authorize historian writes. Not included in any composite bundle
|
||||
// until the HistoryUpdate service surface is implemented.
|
||||
HistoryUpdate = 1 << 12,
|
||||
|
||||
// Bundles (one-click grants in Admin UI)
|
||||
ReadOnly = Browse | Read | Subscribe | HistoryRead | AlarmRead,
|
||||
Operator = ReadOnly | WriteOperate | AlarmAcknowledge | AlarmConfirm,
|
||||
|
||||
@@ -41,10 +41,15 @@ public interface IAlarmSubscriptionHandle
|
||||
}
|
||||
|
||||
/// <summary>One alarm acknowledgement in a batch.</summary>
|
||||
/// <param name="SourceNodeId">Driver-side identifier for the alarm source.</param>
|
||||
/// <param name="ConditionId">Stable id correlating raise / ack / clear of the same condition.</param>
|
||||
/// <param name="Comment">Operator-supplied comment forwarded to the upstream alarm system.</param>
|
||||
/// <param name="OperatorUser">Authenticated principal performing the ack; null on the raw/non-OPC-UA path.</param>
|
||||
public sealed record AlarmAcknowledgeRequest(
|
||||
string SourceNodeId,
|
||||
string ConditionId,
|
||||
string? Comment);
|
||||
string? Comment,
|
||||
string? OperatorUser = null);
|
||||
|
||||
/// <summary>Event payload for <see cref="IAlarmSource.OnAlarmEvent"/>.</summary>
|
||||
/// <param name="SubscriptionHandle">Subscription this event belongs to.</param>
|
||||
|
||||
@@ -68,11 +68,11 @@ public sealed class ScriptedAlarmSource : IAlarmSource, IDisposable
|
||||
if (acknowledgements is null) throw new ArgumentNullException(nameof(acknowledgements));
|
||||
foreach (var a in acknowledgements)
|
||||
{
|
||||
// The base interface doesn't carry a user identity — Stream G provides the
|
||||
// authenticated principal at the OPC UA dispatch layer + proxies through
|
||||
// the engine's richer AcknowledgeAsync. Here we default to "opcua-client"
|
||||
// so callers using the raw IAlarmSource still produce an audit entry.
|
||||
await _engine.AcknowledgeAsync(a.ConditionId, "opcua-client", a.Comment, cancellationToken)
|
||||
// Honor the authenticated principal carried on the request when present
|
||||
// (the OPC UA dispatch layer / Stream G threads it through). When absent —
|
||||
// the raw/non-OPC-UA path — default to "opcua-client" so the ack still
|
||||
// produces an audit entry.
|
||||
await _engine.AcknowledgeAsync(a.ConditionId, a.OperatorUser ?? "opcua-client", a.Comment, cancellationToken)
|
||||
.ConfigureAwait(false);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -83,7 +83,7 @@ public sealed class TriePermissionEvaluator : IPermissionEvaluator
|
||||
OpcUaOperation.WriteTune => NodePermissions.WriteTune,
|
||||
OpcUaOperation.WriteConfigure => NodePermissions.WriteConfigure,
|
||||
OpcUaOperation.HistoryRead => NodePermissions.HistoryRead,
|
||||
OpcUaOperation.HistoryUpdate => NodePermissions.HistoryRead, // HistoryUpdate bit not yet in NodePermissions; TODO Stream C follow-up
|
||||
OpcUaOperation.HistoryUpdate => NodePermissions.HistoryUpdate,
|
||||
OpcUaOperation.CreateMonitoredItems => NodePermissions.Subscribe,
|
||||
OpcUaOperation.TransferSubscriptions=> NodePermissions.Subscribe,
|
||||
OpcUaOperation.Call => NodePermissions.MethodCall,
|
||||
|
||||
@@ -1122,7 +1122,9 @@ public sealed class GalaxyDriver
|
||||
await _alarmAcknowledger.AcknowledgeAsync(
|
||||
alarmFullReference,
|
||||
ack.Comment ?? string.Empty,
|
||||
operatorUser: string.Empty, // server-side ACL fills this from the OPC UA session
|
||||
// Honor the authenticated principal carried on the request when present;
|
||||
// fall back to empty (server-side ACL fills this from the OPC UA session).
|
||||
operatorUser: ack.OperatorUser ?? string.Empty,
|
||||
cancellationToken).ConfigureAwait(false);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -139,6 +139,45 @@ public sealed class OtOpcUaServerHostedService : IHostedService, IAsyncDisposabl
|
||||
}
|
||||
});
|
||||
|
||||
// Wire the reverse-path native-alarm-ack router (H6e): a client Acknowledge of a NATIVE (driver-fed,
|
||||
// e.g. Galaxy) Part 9 condition that passes the node manager's AlarmAck gate routes the acknowledge to
|
||||
// the owning driver child. The node manager maps the inbound ack to an OpcUaServer-local NativeAlarmAck;
|
||||
// HERE the host maps that to the Runtime DriverHostActor.RouteNativeAlarmAck (field-for-field) and Tells
|
||||
// it into the local DriverHostActor, which Primary-gates + resolves the owning DriverInstanceActor. The
|
||||
// mapping happens at this boundary so Runtime stays free of an OpcUaServer dependency. The Tell is
|
||||
// fire-and-forget so the handler — which runs under the SDK's Lock — never blocks. The DriverHostActor
|
||||
// ref is resolved LAZILY per ack (this StartAsync runs before the Akka DriverHostActor registers, so a
|
||||
// one-shot resolve here would always miss); by ack time the registry has it, mirroring the node-write
|
||||
// gateway below.
|
||||
_server.SetNativeAlarmAckRouter(nativeAck =>
|
||||
{
|
||||
try
|
||||
{
|
||||
if (_actorRegistry.TryGet<DriverHostActorKey>(out var driverHost))
|
||||
{
|
||||
driverHost.Tell(new DriverHostActor.RouteNativeAlarmAck(
|
||||
nativeAck.ConditionNodeId, nativeAck.Comment, nativeAck.OperatorUser));
|
||||
}
|
||||
else
|
||||
{
|
||||
// No driver host registered yet (admin-only node, or pre-registration race). The Part 9 ack
|
||||
// already committed the local condition state; the missed routing surfaces as a non-applied
|
||||
// upstream acknowledge, not a client-visible error.
|
||||
_logger.LogWarning(
|
||||
"OtOpcUaServerHostedService: native alarm ack for {ConditionNodeId} dropped — no DriverHostActor registered",
|
||||
nativeAck.ConditionNodeId);
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
// The router runs under the SDK Lock on a server thread; a hiccup must not escape into the SDK's
|
||||
// Call path. Log + drop — the client still gets Good for the condition-state change.
|
||||
_logger.LogWarning(ex,
|
||||
"OtOpcUaServerHostedService: failed to route native alarm ack for {ConditionNodeId}",
|
||||
nativeAck.ConditionNodeId);
|
||||
}
|
||||
});
|
||||
|
||||
// Wire the reverse-path inbound operator-write gateway: a client write to a writable equipment-tag
|
||||
// node that passes the node manager's WriteOperate gate routes the write to the owning driver child
|
||||
// (RouteNodeWrite → NodeWriteResult) via the local DriverHostActor. The node manager calls the
|
||||
@@ -185,6 +224,8 @@ public sealed class OtOpcUaServerHostedService : IHostedService, IAsyncDisposabl
|
||||
_deferredServiceLevel.SetInner(null);
|
||||
// Restore the Null write gateway so a late client write doesn't Ask a stopping DriverHostActor.
|
||||
_server?.SetNodeWriteGateway(null);
|
||||
// Clear the native-alarm-ack router so a late ack doesn't Tell a stopping DriverHostActor.
|
||||
_server?.SetNativeAlarmAckRouter(null);
|
||||
// Restore the Null historian so a late HistoryRead doesn't hit a disposed read client.
|
||||
_server?.SetHistorianDataSource(null);
|
||||
return Task.CompletedTask;
|
||||
|
||||
@@ -0,0 +1,20 @@
|
||||
namespace ZB.MOM.WW.OtOpcUa.OpcUaServer;
|
||||
|
||||
/// <summary>
|
||||
/// H6c — the payload routed when an OPC UA client Acknowledges a NATIVE (driver-fed, e.g. Galaxy)
|
||||
/// Part 9 condition. The scripted-alarm engine does not own native conditions, so the node manager
|
||||
/// branches a native condition's inbound Acknowledge to a separate
|
||||
/// <see cref="OtOpcUaNodeManager.NativeAlarmAckRouter"/> seam (the host later wires it to the backing
|
||||
/// driver) instead of the scripted <see cref="OtOpcUaNodeManager.AlarmCommandRouter"/>.
|
||||
/// <para>
|
||||
/// This record is intentionally OpcUaServer-local (the smallest scope) and Akka-free: it carries
|
||||
/// exactly what the driver-bound router needs — the condition node id to resolve back to a driver
|
||||
/// ref, the operator's acknowledge comment, and the authenticated operator's display name.
|
||||
/// </para>
|
||||
/// </summary>
|
||||
/// <param name="ConditionNodeId">The folder-scoped condition NodeId identifier string — the same value
|
||||
/// stored in <c>DriverHostActor._alarmNodeIdByDriverRef</c> (keyed by <c>(DriverInstanceId, FullName)</c>),
|
||||
/// used to resolve the ack back to its backing driver.</param>
|
||||
/// <param name="Comment">The operator's acknowledge comment text, or <c>null</c> when none was supplied.</param>
|
||||
/// <param name="OperatorUser">The authenticated operator's display name (empty when none resolves).</param>
|
||||
public sealed record NativeAlarmAck(string ConditionNodeId, string? Comment, string OperatorUser);
|
||||
@@ -36,6 +36,13 @@ public sealed class OtOpcUaNodeManager : CustomNodeManager2
|
||||
private readonly ConcurrentDictionary<string, BaseDataVariableState> _variables = new(StringComparer.Ordinal);
|
||||
private readonly ConcurrentDictionary<string, FolderState> _folders = new(StringComparer.Ordinal);
|
||||
private readonly ConcurrentDictionary<string, AlarmConditionState> _alarmConditions = new(StringComparer.Ordinal);
|
||||
/// <summary>H6a: the subset of <see cref="_alarmConditions"/> node ids materialised as NATIVE
|
||||
/// (driver-fed, e.g. Galaxy equipment-tag alarms) rather than scripted. A later task routes a native
|
||||
/// condition's inbound Acknowledge to the driver instead of the scripted engine, so the node manager
|
||||
/// must know which conditions are native. Maintained in lock-step with <see cref="_alarmConditions"/>:
|
||||
/// a native re-materialise adds, and <see cref="RebuildAddressSpace"/> clears it alongside
|
||||
/// <see cref="_alarmConditions"/> so a re-materialise as the other kind is correct.</summary>
|
||||
private readonly HashSet<string> _nativeAlarmNodeIds = new(StringComparer.Ordinal);
|
||||
/// <summary>Phase C: NodeId → resolved historian tagname for every variable materialised
|
||||
/// Historizing. Populated by <see cref="EnsureVariable"/> when a historian tagname is supplied; the
|
||||
/// (later) HistoryRead override resolves a HistoryRead request's NodeId against this map. Cleared on
|
||||
@@ -90,6 +97,26 @@ public sealed class OtOpcUaNodeManager : CustomNodeManager2
|
||||
/// </summary>
|
||||
public Action<AlarmCommand>? AlarmCommandRouter { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// H6c — reverse-path sink for an inbound OPC UA Acknowledge on a NATIVE (driver-fed, e.g. Galaxy)
|
||||
/// Part 9 condition. The scripted-alarm engine does not own native conditions, so when a client
|
||||
/// Acknowledges one, the condition's <c>OnAcknowledge</c> handler (wired in
|
||||
/// <see cref="MaterialiseAlarmCondition"/>) branches on <see cref="IsNativeAlarmNode"/> and — after
|
||||
/// the same <c>AlarmAck</c> role gate as <see cref="AlarmCommandRouter"/> — invokes THIS delegate
|
||||
/// with a <see cref="NativeAlarmAck"/> instead of routing an <see cref="AlarmCommand"/> to the
|
||||
/// scripted engine. The host sets it at boot to a non-blocking dispatch toward the backing driver
|
||||
/// (a later task wires the driver linkage).
|
||||
/// <para>
|
||||
/// Like <see cref="AlarmCommandRouter"/>, the handler delegate runs under the manager's
|
||||
/// <c>Lock</c>, so the invoked action MUST be non-blocking (fire-and-forget). Null (the default)
|
||||
/// makes the native-ack handler a safe no-op — it still gates + returns, just routes nowhere.
|
||||
/// Only the Acknowledge of a native condition uses this seam; Confirm/AddComment/Shelve on a
|
||||
/// native condition stay on the scripted <see cref="AlarmCommandRouter"/> path (H6c scope is the
|
||||
/// Acknowledge → driver path only).
|
||||
/// </para>
|
||||
/// </summary>
|
||||
public Action<NativeAlarmAck>? NativeAlarmAckRouter { get; set; }
|
||||
|
||||
private volatile IOpcUaNodeWriteGateway _nodeWriteGateway = NullOpcUaNodeWriteGateway.Instance;
|
||||
|
||||
/// <summary>
|
||||
@@ -535,7 +562,7 @@ public sealed class OtOpcUaNodeManager : CustomNodeManager2
|
||||
/// <see cref="AlarmConditionState"/>. LimitAlarm deliberately falls back to base per the T13
|
||||
/// notes — a script alarm carries no High/Low limits to populate.</para>
|
||||
/// </remarks>
|
||||
public void MaterialiseAlarmCondition(string alarmNodeId, string equipmentNodeId, string displayName, string alarmType, int severity)
|
||||
public void MaterialiseAlarmCondition(string alarmNodeId, string equipmentNodeId, string displayName, string alarmType, int severity, bool isNative = false)
|
||||
{
|
||||
ArgumentException.ThrowIfNullOrEmpty(alarmNodeId);
|
||||
ArgumentException.ThrowIfNullOrEmpty(displayName);
|
||||
@@ -550,6 +577,10 @@ public sealed class OtOpcUaNodeManager : CustomNodeManager2
|
||||
PredefinedNodes?.Remove(existing.NodeId);
|
||||
}
|
||||
|
||||
// H6a: re-materialising the same id as the OTHER kind (native↔scripted) must reflect the new
|
||||
// kind, so always drop the stale native flag first and only re-add it below when isNative.
|
||||
_nativeAlarmNodeIds.Remove(alarmNodeId);
|
||||
|
||||
var parent = ResolveParentFolder(equipmentNodeId);
|
||||
|
||||
AlarmConditionState alarm = CreateAlarmConditionOfType(alarmType, parent);
|
||||
@@ -591,8 +622,14 @@ public sealed class OtOpcUaNodeManager : CustomNodeManager2
|
||||
// T20: the engine re-projects that same logical transition through WriteAlarmCondition; its
|
||||
// delta-gate (compares against the node's current state, which the SDK already pre-applied)
|
||||
// sees no change and suppresses the would-be second event (E3) — so no double-emit.
|
||||
// H6c — a NATIVE (driver-fed) condition's Acknowledge belongs to the backing driver, NOT the
|
||||
// scripted engine, so branch on native-ness (via the lock-guarded accessor) and route a native
|
||||
// ack to NativeAlarmAckRouter instead of the scripted AlarmCommandRouter. Confirm/AddComment/
|
||||
// Shelve stay on the scripted path even for native conditions (H6c scope is Acknowledge only).
|
||||
alarm.OnAcknowledge = (context, condition, _, comment) =>
|
||||
HandleAlarmCommand(context, condition, "Acknowledge", comment, unshelveAt: null);
|
||||
IsNativeAlarmNode(alarmNodeId)
|
||||
? HandleNativeAlarmAck(context, condition, comment)
|
||||
: HandleAlarmCommand(context, condition, "Acknowledge", comment, unshelveAt: null);
|
||||
alarm.OnConfirm = (context, condition, _, comment) =>
|
||||
HandleAlarmCommand(context, condition, "Confirm", comment, unshelveAt: null);
|
||||
alarm.OnAddComment = (context, condition, _, comment) =>
|
||||
@@ -623,6 +660,19 @@ public sealed class OtOpcUaNodeManager : CustomNodeManager2
|
||||
return ServiceResult.Good;
|
||||
};
|
||||
|
||||
// H4 — inbound Part 9 Enable/Disable (the condition type's built-in Enable/Disable methods route
|
||||
// here via this delegate). The engine handles Enable/Disable for SCRIPTED alarms
|
||||
// (ScriptedAlarmEngine.EnableAsync/DisableAsync, dispatched by ScriptedAlarmHostActor on the
|
||||
// "Enable"/"Disable" AlarmCommand operations), so a scripted condition routes through the same
|
||||
// AlarmAck-gated HandleAlarmCommand as the other handlers. NATIVE (driver-fed) conditions have no
|
||||
// engine enable/disable surface (Phase 3 decision #2) — they short-circuit to BadNotSupported.
|
||||
alarm.OnEnableDisable = (context, condition, enabling) =>
|
||||
{
|
||||
if (IsNativeAlarmNode(alarmNodeId))
|
||||
return new ServiceResult(StatusCodes.BadNotSupported);
|
||||
return HandleAlarmCommand(context, condition, enabling ? "Enable" : "Disable", comment: null, unshelveAt: null);
|
||||
};
|
||||
|
||||
parent.AddChild(alarm);
|
||||
|
||||
// Promote the equipment folder to an event notifier + register it as a root notifier so
|
||||
@@ -632,9 +682,23 @@ public sealed class OtOpcUaNodeManager : CustomNodeManager2
|
||||
|
||||
AddPredefinedNode(SystemContext, alarm);
|
||||
_alarmConditions[alarmNodeId] = alarm;
|
||||
// H6a: record native (driver-fed) conditions so a later task can route their inbound
|
||||
// Acknowledge to the driver rather than the scripted engine.
|
||||
if (isNative) _nativeAlarmNodeIds.Add(alarmNodeId);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>H6a — true if the condition materialised at <paramref name="alarmNodeId"/> is a NATIVE
|
||||
/// (driver-fed) alarm rather than a scripted one. A later task uses this to route a native condition's
|
||||
/// inbound Acknowledge to the driver instead of the scripted engine.</summary>
|
||||
/// <param name="alarmNodeId">The alarm condition node id.</param>
|
||||
internal bool IsNativeAlarmNode(string alarmNodeId)
|
||||
{
|
||||
// _nativeAlarmNodeIds is a plain HashSet mutated only under Lock (in MaterialiseAlarmCondition /
|
||||
// RebuildAddressSpace), so guard the read with the same Lock rather than risk a torn concurrent read.
|
||||
lock (Lock) return _nativeAlarmNodeIds.Contains(alarmNodeId);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Shared body for every inbound Part 9 alarm method handler (T18). Resolves the calling
|
||||
/// principal off the SDK <paramref name="context"/>, applies the <c>AlarmAck</c> role gate
|
||||
@@ -678,6 +742,45 @@ public sealed class OtOpcUaNodeManager : CustomNodeManager2
|
||||
return ServiceResult.Good;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// H6c — handler body for an inbound OPC UA Acknowledge on a NATIVE (driver-fed) condition. The
|
||||
/// scripted engine does not own native conditions, so this routes a <see cref="NativeAlarmAck"/> to
|
||||
/// <see cref="NativeAlarmAckRouter"/> (the driver-bound seam) rather than a scripted
|
||||
/// <see cref="AlarmCommand"/> to <see cref="AlarmCommandRouter"/>. The calling principal is resolved
|
||||
/// and the <c>AlarmAck</c> role gate applied EXACTLY as in <see cref="HandleAlarmCommand"/>
|
||||
/// (<b>fails closed</b>: a missing identity or missing role is denied — no route, no state mutation).
|
||||
/// </summary>
|
||||
/// <param name="context">The SDK context the handler delegate was invoked with — a
|
||||
/// <c>ServerSystemContext</c> (an <see cref="ISessionOperationContext"/>) carrying the session identity
|
||||
/// (T17 attached the LDAP roles as a <see cref="RoleCarryingUserIdentity"/>).</param>
|
||||
/// <param name="condition">The condition the Acknowledge targets; its <c>NodeId</c> identifier is the
|
||||
/// folder-scoped condition node id the driver-bound router resolves back to a driver ref.</param>
|
||||
/// <param name="comment">The acknowledge comment text, or <c>null</c> when none was supplied.</param>
|
||||
/// <returns><c>ServiceResult.Good</c> when allowed (the SDK then applies state + auto-fires its event);
|
||||
/// <c>BadUserAccessDenied</c> when the gate vetoes (no route, no state mutation).</returns>
|
||||
private ServiceResult HandleNativeAlarmAck(ISystemContext context, ConditionState condition, LocalizedText? comment)
|
||||
{
|
||||
// Resolve + gate the SAME way HandleAlarmCommand does so native and scripted acks share one authz
|
||||
// contract. Anonymous / non-role-carrying identities ⇒ null ⇒ denied (fail closed, never route).
|
||||
var identity = (context as ISessionOperationContext)?.UserIdentity as RoleCarryingUserIdentity;
|
||||
if (identity is null || !identity.Roles.Contains(OpcUaDataPlaneRoles.AlarmAck, StringComparer.OrdinalIgnoreCase))
|
||||
{
|
||||
return new ServiceResult(StatusCodes.BadUserAccessDenied);
|
||||
}
|
||||
|
||||
// Same condition-node-id extraction HandleAlarmCommand uses (condition.NodeId.Identifier?.ToString()):
|
||||
// for a native condition this is the folder-scoped NodeId string the DriverHostActor inverse map
|
||||
// (_alarmNodeIdByDriverRef value set) keys by, so the next task can resolve it back to (driver, ref).
|
||||
// Non-blocking by contract (host wires a fire-and-forget dispatch); safe to call under Lock.
|
||||
NativeAlarmAckRouter?.Invoke(new NativeAlarmAck(
|
||||
ConditionNodeId: condition.NodeId.Identifier?.ToString() ?? string.Empty,
|
||||
Comment: comment?.Text,
|
||||
OperatorUser: identity.DisplayName ?? string.Empty));
|
||||
|
||||
// Good ⇒ the SDK applies the node-state change + auto-fires its own condition event.
|
||||
return ServiceResult.Good;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The <see cref="NodeValueEventHandler"/> attached to a writable equipment-tag variable by
|
||||
/// <see cref="EnsureVariable"/> (Task 11). The OPC UA SDK invokes it when a client writes the
|
||||
@@ -1289,6 +1392,9 @@ public sealed class OtOpcUaNodeManager : CustomNodeManager2
|
||||
PredefinedNodes?.Remove(alarm.NodeId);
|
||||
}
|
||||
_alarmConditions.Clear();
|
||||
// H6a: drop the native-alarm flags in lock-step with the conditions they classify, so a
|
||||
// re-materialise on the next apply (possibly as the other kind) starts from a clean slate.
|
||||
_nativeAlarmNodeIds.Clear();
|
||||
|
||||
foreach (var f in _folders.Values)
|
||||
{
|
||||
|
||||
@@ -37,6 +37,27 @@ public sealed class OtOpcUaSdkServer : StandardServer
|
||||
return true;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Wire the reverse-path router for inbound Part 9 Acknowledge of a NATIVE (driver-fed, e.g. Galaxy)
|
||||
/// condition onto the created <see cref="OtOpcUaNodeManager"/>. The host calls this after start with a
|
||||
/// non-blocking router that Tells a <c>DriverHostActor.RouteNativeAlarmAck</c> into the local
|
||||
/// <c>DriverHostActor</c>, which (Primary-gated) routes the acknowledge to the owning driver child.
|
||||
/// Native conditions are not owned by the scripted-alarm engine, so the node manager branches their
|
||||
/// inbound Acknowledge to this seam instead of the scripted <see cref="SetAlarmCommandRouter"/> path.
|
||||
/// Passing <c>null</c> clears it. No-op (returns <c>false</c>) when the node manager has not been
|
||||
/// created yet, so the caller can detect a too-early call (mirrors <see cref="SetAlarmCommandRouter"/>).
|
||||
/// </summary>
|
||||
/// <param name="router">The router invoked by the native condition's Acknowledge handler once the
|
||||
/// <c>AlarmAck</c> gate passes; may be <c>null</c> to clear it.</param>
|
||||
/// <returns><c>true</c> when the router was set on a live node manager; <c>false</c> when no node
|
||||
/// manager exists yet.</returns>
|
||||
public bool SetNativeAlarmAckRouter(Action<NativeAlarmAck>? router)
|
||||
{
|
||||
if (_otOpcUaNodeManager is null) return false;
|
||||
_otOpcUaNodeManager.NativeAlarmAckRouter = router;
|
||||
return true;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Wire the reverse-path gateway for inbound operator writes to writable equipment-tag nodes onto the
|
||||
/// created <see cref="OtOpcUaNodeManager"/>. The host calls this after start with an
|
||||
|
||||
@@ -201,7 +201,7 @@ public sealed class Phase7Applier
|
||||
{
|
||||
// Native alarm tag → a real Part 9 condition node (reuses the scripted-alarm path),
|
||||
// NOT a value variable. Parent is the sub-folder when set, else the equipment folder.
|
||||
SafeMaterialiseAlarmCondition(nodeId, parent, tag.Name, tag.Alarm.AlarmType, tag.Alarm.Severity);
|
||||
SafeMaterialiseAlarmCondition(nodeId, parent, tag.Name, tag.Alarm.AlarmType, tag.Alarm.Severity, isNative: true);
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -292,7 +292,7 @@ public sealed class Phase7Applier
|
||||
foreach (var alarm in composition.EquipmentScriptedAlarms)
|
||||
{
|
||||
if (!alarm.Enabled) continue;
|
||||
SafeMaterialiseAlarmCondition(alarm.ScriptedAlarmId, alarm.EquipmentId, alarm.Name, alarm.AlarmType, alarm.Severity);
|
||||
SafeMaterialiseAlarmCondition(alarm.ScriptedAlarmId, alarm.EquipmentId, alarm.Name, alarm.AlarmType, alarm.Severity, isNative: false);
|
||||
materialised++;
|
||||
}
|
||||
|
||||
@@ -333,9 +333,9 @@ public sealed class Phase7Applier
|
||||
catch (Exception ex) { _logger.LogWarning(ex, "Phase7Applier: WriteAlarmCondition threw for {Node}", nodeId); }
|
||||
}
|
||||
|
||||
private void SafeMaterialiseAlarmCondition(string alarmNodeId, string equipmentNodeId, string displayName, string alarmType, int severity)
|
||||
private void SafeMaterialiseAlarmCondition(string alarmNodeId, string equipmentNodeId, string displayName, string alarmType, int severity, bool isNative)
|
||||
{
|
||||
try { _sink.MaterialiseAlarmCondition(alarmNodeId, equipmentNodeId, displayName, alarmType, severity); }
|
||||
try { _sink.MaterialiseAlarmCondition(alarmNodeId, equipmentNodeId, displayName, alarmType, severity, isNative); }
|
||||
catch (Exception ex) { _logger.LogWarning(ex, "Phase7Applier: MaterialiseAlarmCondition threw for {Node}", alarmNodeId); }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -41,8 +41,9 @@ public sealed class SdkAddressSpaceSink : IOpcUaAddressSpaceSink
|
||||
/// <param name="displayName">The human-readable condition name.</param>
|
||||
/// <param name="alarmType">The domain alarm type.</param>
|
||||
/// <param name="severity">The domain severity.</param>
|
||||
public void MaterialiseAlarmCondition(string alarmNodeId, string equipmentNodeId, string displayName, string alarmType, int severity)
|
||||
=> _nodeManager.MaterialiseAlarmCondition(alarmNodeId, equipmentNodeId, displayName, alarmType, severity);
|
||||
/// <param name="isNative">True for a driver-fed (native) equipment-tag alarm; false (default) for a scripted alarm.</param>
|
||||
public void MaterialiseAlarmCondition(string alarmNodeId, string equipmentNodeId, string displayName, string alarmType, int severity, bool isNative = false)
|
||||
=> _nodeManager.MaterialiseAlarmCondition(alarmNodeId, equipmentNodeId, displayName, alarmType, severity, isNative);
|
||||
|
||||
/// <summary>Ensures a folder node exists in the address space.</summary>
|
||||
/// <param name="folderNodeId">The folder node identifier.</param>
|
||||
|
||||
@@ -126,6 +126,19 @@ public sealed class DriverHostActor : ReceiveActor, IWithTimers
|
||||
/// value variables, so they are kept OUT of the value maps + value-subscription set.</summary>
|
||||
private readonly Dictionary<(string DriverInstanceId, string FullName), HashSet<string>> _alarmNodeIdByDriverRef = new();
|
||||
|
||||
/// <summary>
|
||||
/// Inverse of <see cref="_alarmNodeIdByDriverRef"/>: <c>folder-scoped condition NodeId →
|
||||
/// (DriverInstanceId, FullName = alarm ConditionId/AlarmFullReference)</c>. Built in the SAME apply
|
||||
/// pass from the alarm-bearing EquipmentTags, and resolved by <see cref="HandleRouteNativeAlarmAck"/>
|
||||
/// so an inbound OPC UA acknowledge of a native condition (resolved to the condition's NodeId by the
|
||||
/// node manager) is forwarded to the owning driver child as an acknowledge of its wire-ref
|
||||
/// <c>FullName</c>. Each condition NodeId maps to exactly one driver ref (a condition is backed by a
|
||||
/// single driver alarm), so this is a flat 1:1 map (the forward map fans out 1:N because one ref can
|
||||
/// back several conditions on identical machines).
|
||||
/// </summary>
|
||||
private readonly Dictionary<string, (string DriverInstanceId, string FullName)> _driverRefByAlarmNodeId =
|
||||
new(StringComparer.Ordinal);
|
||||
|
||||
/// <summary>Condition NodeId → (EquipmentId, tag Name, OPC UA alarm type) for building the
|
||||
/// AlarmTransitionEvent fan-out. Built in the same PushDesiredSubscriptions alarm branch.</summary>
|
||||
private readonly Dictionary<string, (string EquipmentId, string Name, string AlarmType)> _alarmMetaByNodeId =
|
||||
@@ -168,6 +181,21 @@ public sealed class DriverHostActor : ReceiveActor, IWithTimers
|
||||
/// <param name="Reason">Failure detail when <paramref name="Success"/> is false; null on success.</param>
|
||||
public sealed record NodeWriteResult(bool Success, string? Reason);
|
||||
|
||||
/// <summary>
|
||||
/// Routes an inbound native-condition acknowledge to the owning driver child. The host wires the
|
||||
/// OPC UA node manager's <c>NativeAlarmAckRouter</c> to Tell this in when a client Acknowledges a
|
||||
/// NATIVE Part 9 condition; <see cref="HandleRouteNativeAlarmAck"/> applies the same Primary gate the
|
||||
/// inbound write path uses, resolves the <see cref="_driverRefByAlarmNodeId"/> inverse map, and Tells
|
||||
/// the owning <see cref="DriverInstanceActor"/> a <see cref="DriverInstanceActor.RouteAlarmAck"/>
|
||||
/// carrying the principal — fire-and-forget (the Part 9 ack already committed the local condition
|
||||
/// state). Deliberately decoupled from the OpcUaServer <c>NativeAlarmAck</c> type: the host maps
|
||||
/// NativeAlarmAck → this at the wiring boundary so Runtime does not depend on the OPC UA layer.
|
||||
/// </summary>
|
||||
/// <param name="ConditionNodeId">The folder-scoped condition NodeId the operator acknowledged.</param>
|
||||
/// <param name="Comment">Operator-supplied comment forwarded to the upstream alarm system; null when none.</param>
|
||||
/// <param name="OperatorUser">The authenticated principal performing the acknowledge.</param>
|
||||
public sealed record RouteNativeAlarmAck(string ConditionNodeId, string? Comment, string OperatorUser);
|
||||
|
||||
private sealed record ChildEntry(IActorRef Actor, DriverInstanceSpec Spec, bool Stubbed)
|
||||
{
|
||||
// Convenience accessors for sites that don't need the full spec.
|
||||
@@ -454,6 +482,7 @@ public sealed class DriverHostActor : ReceiveActor, IWithTimers
|
||||
Receive<RestartDriver>(HandleRestartDriver);
|
||||
Receive<ReconnectDriver>(HandleReconnectDriver);
|
||||
Receive<RouteNodeWrite>(HandleRouteNodeWrite);
|
||||
Receive<RouteNativeAlarmAck>(HandleRouteNativeAlarmAck);
|
||||
Receive<RedundancyStateChanged>(OnRedundancyStateChanged);
|
||||
Receive<SubscribeAck>(_ => { /* PubSub ack */ });
|
||||
}
|
||||
@@ -478,6 +507,7 @@ public sealed class DriverHostActor : ReceiveActor, IWithTimers
|
||||
Receive<RestartDriver>(HandleRestartDriver);
|
||||
Receive<ReconnectDriver>(HandleReconnectDriver);
|
||||
Receive<RouteNodeWrite>(HandleRouteNodeWrite);
|
||||
Receive<RouteNativeAlarmAck>(HandleRouteNativeAlarmAck);
|
||||
Receive<RedundancyStateChanged>(OnRedundancyStateChanged);
|
||||
Receive<SubscribeAck>(_ => { /* PubSub ack */ });
|
||||
}
|
||||
@@ -650,6 +680,55 @@ public sealed class DriverHostActor : ReceiveActor, IWithTimers
|
||||
.PipeTo(replyTo);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Routes an inbound native-condition acknowledge (the host Tells this from the OPC UA node-manager
|
||||
/// side when a client Acknowledges a NATIVE Part 9 condition) to the owning driver child. Mirrors
|
||||
/// <see cref="HandleRouteNodeWrite"/>'s order + gating, but the ack is fire-and-forget (no reply):
|
||||
/// the OPC UA Part 9 acknowledge already committed the local condition state and the driver's
|
||||
/// <see cref="IAlarmSource.AcknowledgeAsync"/> returns no per-condition status.
|
||||
/// <list type="number">
|
||||
/// <item>PRIMARY gate FIRST — reuses the same <see cref="_localRole"/> redundancy signal as the
|
||||
/// inbound-write gate. Only the Primary pushes the ack to the shared upstream alarm system
|
||||
/// (default-allow while the role is unknown). A Secondary/Detached node keeps its condition
|
||||
/// state warm for failover but must NOT push the command. Drop (debug-log) on non-primary.</item>
|
||||
/// <item>Resolve the <see cref="_driverRefByAlarmNodeId"/> inverse map to the owning
|
||||
/// <c>(DriverInstanceId, FullName = ConditionId)</c>; an unmapped node is debug-logged + dropped
|
||||
/// (no throw) — mirrors <see cref="ForwardNativeAlarm"/>'s unknown-ref drop.</item>
|
||||
/// <item>Resolve the running driver child and Tell it a
|
||||
/// <see cref="DriverInstanceActor.RouteAlarmAck"/> carrying the wire-ref FullName + principal.</item>
|
||||
/// </list>
|
||||
/// </summary>
|
||||
private void HandleRouteNativeAlarmAck(RouteNativeAlarmAck msg)
|
||||
{
|
||||
// PRIMARY GATE FIRST — only the Primary services operator acks (same signal as the inbound-write +
|
||||
// alarm-emit gates; unknown role ⇒ treated as Primary so single-node deploys + the boot window aren't blocked).
|
||||
if (_localRole is RedundancyRole.Secondary or RedundancyRole.Detached)
|
||||
{
|
||||
_log.Debug("DriverHost {Node}: dropping native-alarm ack for {Cond} — not primary",
|
||||
_localNode, msg.ConditionNodeId);
|
||||
return;
|
||||
}
|
||||
|
||||
if (!_driverRefByAlarmNodeId.TryGetValue(msg.ConditionNodeId, out var target))
|
||||
{
|
||||
_log.Debug("DriverHost {Node}: no driver mapping for alarm condition node {Cond} — ack dropped",
|
||||
_localNode, msg.ConditionNodeId);
|
||||
return;
|
||||
}
|
||||
|
||||
if (!_children.TryGetValue(target.DriverInstanceId, out var entry))
|
||||
{
|
||||
_log.Debug("DriverHost {Node}: driver {Driver} not running for alarm ack of {Cond} — dropped",
|
||||
_localNode, target.DriverInstanceId, msg.ConditionNodeId);
|
||||
return;
|
||||
}
|
||||
|
||||
// Fire-and-forget: the OPC UA Part 9 ack already committed the local condition state, and the
|
||||
// driver's AcknowledgeAsync surfaces no per-condition status, so there is nothing to reply. The
|
||||
// driver correlates on ConditionId (= the authored alarm FullName the inverse map keyed on).
|
||||
entry.Actor.Tell(new DriverInstanceActor.RouteAlarmAck(target.FullName, msg.Comment, msg.OperatorUser));
|
||||
}
|
||||
|
||||
/// <summary>Caches this node's <see cref="RedundancyRole"/> from a cluster redundancy snapshot so
|
||||
/// <see cref="HandleRouteNodeWrite"/> can gate inbound writes to the Primary. A snapshot that doesn't
|
||||
/// mention this node leaves the cached role unchanged ⇒ default-allow. Mirrors
|
||||
@@ -678,6 +757,12 @@ public sealed class DriverHostActor : ReceiveActor, IWithTimers
|
||||
// node-manager's bounded Ask gets an immediate clear status instead of dead-lettering into a timeout.
|
||||
Receive<RouteNodeWrite>(_ =>
|
||||
Sender.Tell(new NodeWriteResult(false, "driver host stale (config DB unreachable)")));
|
||||
// An inbound native-condition ack can't be serviced while Stale either (the alarm inverse map is
|
||||
// empty until an apply runs). The ack is fire-and-forget (no reply), so just drop it with a log —
|
||||
// the local OPC UA condition state already committed on the Part 9 ack.
|
||||
Receive<RouteNativeAlarmAck>(msg =>
|
||||
_log.Debug("DriverHost {Node}: dropping native-alarm ack for {Node2} while Stale (config DB unreachable)",
|
||||
_localNode, msg.ConditionNodeId));
|
||||
Receive<SubscribeAck>(_ => { /* PubSub ack */ });
|
||||
Timers.StartPeriodicTimer("retry-db", RetryConfigDbConnection.Instance, ReconnectInterval);
|
||||
}
|
||||
@@ -905,6 +990,13 @@ public sealed class DriverHostActor : ReceiveActor, IWithTimers
|
||||
// every apply; the projector is Clear()'d too so stale per-condition state never leaks across
|
||||
// redeploys (renames/removals/address-space rebuilds).
|
||||
_alarmNodeIdByDriverRef.Clear();
|
||||
// Inverse alarm map for the inbound native-condition ack path (condition NodeId → (DriverInstanceId,
|
||||
// FullName)): an OPC UA client acknowledges the condition's folder-scoped NodeId, but the driver
|
||||
// acknowledges by its wire-ref FullName (= ConditionId). Cleared + repopulated from the SAME
|
||||
// alarm-bearing EquipmentTags pass so renames/removals are reflected. Each condition NodeId maps to
|
||||
// exactly one driver ref (a condition is backed by a single driver alarm), so last-writer-wins on the
|
||||
// rare duplicate is harmless.
|
||||
_driverRefByAlarmNodeId.Clear();
|
||||
// Per-condition metadata (EquipmentId / Name / OPC UA alarm type) for the alerts fan-out, built in
|
||||
// the SAME alarm branch as the node map so a redeploy can't leave it out of sync. Cleared alongside it.
|
||||
_alarmMetaByNodeId.Clear();
|
||||
@@ -921,6 +1013,10 @@ public sealed class DriverHostActor : ReceiveActor, IWithTimers
|
||||
if (!_alarmNodeIdByDriverRef.TryGetValue(key, out var aset))
|
||||
_alarmNodeIdByDriverRef[key] = aset = new HashSet<string>(StringComparer.Ordinal);
|
||||
aset.Add(nodeId);
|
||||
// Inverse 1:1 map for the inbound native-condition ack path: the materialised condition
|
||||
// NodeId routes back to the owning (DriverInstanceId, FullName=ConditionId) so an OPC UA
|
||||
// acknowledge of this condition reaches the right driver child.
|
||||
_driverRefByAlarmNodeId[nodeId] = key;
|
||||
// Capture the per-condition metadata the alerts fan-out (ForwardNativeAlarm) needs to build
|
||||
// the AlarmTransitionEvent: the equipment path, the operator-visible alarm name, and the
|
||||
// OPC UA Part 9 subtype. Keyed by the condition NodeId (the projection's own key).
|
||||
|
||||
@@ -40,6 +40,20 @@ public sealed class DriverInstanceActor : ReceiveActor, IWithTimers
|
||||
public sealed record ApplyResult(bool Success, string? Reason, CorrelationId Correlation);
|
||||
public sealed record WriteAttribute(string TagId, object Value);
|
||||
public sealed record WriteAttributeResult(bool Success, string? Reason);
|
||||
/// <summary>
|
||||
/// Sent by <see cref="DriverHostActor"/> when an OPC UA client Acknowledges a NATIVE Part 9
|
||||
/// condition (resolved from the condition NodeId to this driver via the host's alarm inverse map).
|
||||
/// The actor forwards it to the driver's <see cref="IAlarmSource.AcknowledgeAsync"/>, carrying the
|
||||
/// authored alarm full-reference (= the driver's <c>ConditionId</c>/AlarmFullReference) and the
|
||||
/// authenticated principal. Mirrors <see cref="WriteAttribute"/>, but the ack is fire-and-forget:
|
||||
/// the driver's <see cref="IAlarmSource.AcknowledgeAsync"/> returns no per-condition status and the
|
||||
/// OPC UA Part 9 ack already committed the local condition state, so there is no reply to surface.
|
||||
/// </summary>
|
||||
/// <param name="ConditionId">The authored alarm full-reference the driver correlates the ack on
|
||||
/// (= the equipment tag's <c>FullName</c>/AlarmFullReference).</param>
|
||||
/// <param name="Comment">Operator-supplied comment forwarded to the upstream alarm system; null when none.</param>
|
||||
/// <param name="OperatorUser">The authenticated principal performing the acknowledge.</param>
|
||||
public sealed record RouteAlarmAck(string ConditionId, string? Comment, string OperatorUser);
|
||||
public sealed record Subscribe(IReadOnlyList<string> FullReferences, TimeSpan PublishingInterval);
|
||||
/// <summary>
|
||||
/// Sets the set of references this driver should keep subscribed for the lifetime of the
|
||||
@@ -240,6 +254,8 @@ public sealed class DriverInstanceActor : ReceiveActor, IWithTimers
|
||||
Receive<InitializeRequested>(_ => { /* no-op */ });
|
||||
Receive<ApplyDelta>(msg => Sender.Tell(new ApplyResult(true, "stubbed", msg.Correlation)));
|
||||
Receive<WriteAttribute>(_ => Sender.Tell(new WriteAttributeResult(true, "stubbed")));
|
||||
// Stubbed drivers have no upstream alarm system — swallow the ack (it's fire-and-forget, no reply).
|
||||
Receive<RouteAlarmAck>(_ => { /* stubbed drivers have no alarm backend */ });
|
||||
Receive<DisconnectObserved>(_ => { /* stubbed drivers don't disconnect */ });
|
||||
Receive<ForceReconnect>(_ => { /* stubbed drivers don't reconnect */ });
|
||||
Receive<SetDesiredSubscriptions>(StoreDesiredSubscriptions);
|
||||
@@ -254,6 +270,10 @@ public sealed class DriverInstanceActor : ReceiveActor, IWithTimers
|
||||
// "write timeout". Synchronous Receive: Sender.Tell on the actor thread is safe (#4a-instance).
|
||||
Receive<WriteAttribute>(_ =>
|
||||
Sender.Tell(new WriteAttributeResult(false, "driver not connected")));
|
||||
// An ack arriving while still connecting can't reach the upstream alarm system; drop it (the ack is
|
||||
// fire-and-forget — no reply to surface — and the OPC UA condition state already committed locally).
|
||||
Receive<RouteAlarmAck>(_ =>
|
||||
_log.Debug("DriverInstance {Id}: alarm ack arrived during connect — dropped (driver not connected)", _driverInstanceId));
|
||||
Receive<ApplyDelta>(AdoptConfigDuringInit);
|
||||
Receive<InitializeSucceeded>(msg =>
|
||||
{
|
||||
@@ -314,6 +334,7 @@ public sealed class DriverInstanceActor : ReceiveActor, IWithTimers
|
||||
PublishHealthSnapshot();
|
||||
});
|
||||
ReceiveAsync<WriteAttribute>(HandleWriteAsync);
|
||||
ReceiveAsync<RouteAlarmAck>(HandleAcknowledgeAsync);
|
||||
ReceiveAsync<Subscribe>(HandleSubscribeAsync);
|
||||
ReceiveAsync<Unsubscribe>(_ => UnsubscribeAsync());
|
||||
Receive<SetDesiredSubscriptions>(msg =>
|
||||
@@ -354,6 +375,10 @@ public sealed class DriverInstanceActor : ReceiveActor, IWithTimers
|
||||
// timeout on an inbound write to a transiently-down driver). Synchronous Receive (#4a-instance).
|
||||
Receive<WriteAttribute>(_ =>
|
||||
Sender.Tell(new WriteAttributeResult(false, "driver not connected")));
|
||||
// An ack arriving while reconnecting can't reach the upstream alarm system; drop it (fire-and-forget,
|
||||
// no reply — the OPC UA condition state already committed locally on the Part 9 ack).
|
||||
Receive<RouteAlarmAck>(_ =>
|
||||
_log.Debug("DriverInstance {Id}: alarm ack arrived during reconnect — dropped (driver not connected)", _driverInstanceId));
|
||||
Receive<ApplyDelta>(AdoptConfigDuringInit);
|
||||
Receive<InitializeSucceeded>(msg =>
|
||||
{
|
||||
@@ -473,6 +498,46 @@ public sealed class DriverInstanceActor : ReceiveActor, IWithTimers
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Forwards an inbound native-condition acknowledge (routed by <see cref="DriverHostActor"/> from a
|
||||
/// resolved condition NodeId) to the driver's <see cref="IAlarmSource.AcknowledgeAsync"/>. The driver
|
||||
/// correlates on <see cref="AlarmAcknowledgeRequest.ConditionId"/> (= the authored alarm
|
||||
/// full-reference); <see cref="AlarmAcknowledgeRequest.SourceNodeId"/> carries the same reference (the
|
||||
/// driver's ack path keys on ConditionId). Bounded to 5s so a hung backend can't pin this actor.
|
||||
/// Fire-and-forget — the OPC UA Part 9 ack already committed the local condition state and
|
||||
/// <see cref="IAlarmSource.AcknowledgeAsync"/> returns no per-condition status — so there is no reply;
|
||||
/// a failure is logged and dropped (the local condition stays Acknowledged regardless).
|
||||
/// </summary>
|
||||
private async Task HandleAcknowledgeAsync(RouteAlarmAck msg)
|
||||
{
|
||||
if (_driver is not IAlarmSource src)
|
||||
{
|
||||
_log.Warning("DriverInstance {Id}: alarm ack dropped — driver does not implement IAlarmSource", _driverInstanceId);
|
||||
return;
|
||||
}
|
||||
|
||||
var request = new[]
|
||||
{
|
||||
new AlarmAcknowledgeRequest(
|
||||
SourceNodeId: msg.ConditionId,
|
||||
ConditionId: msg.ConditionId,
|
||||
Comment: msg.Comment,
|
||||
OperatorUser: msg.OperatorUser),
|
||||
};
|
||||
using var cts = new CancellationTokenSource(TimeSpan.FromSeconds(5));
|
||||
try
|
||||
{
|
||||
await src.AcknowledgeAsync(request, cts.Token);
|
||||
_log.Info("DriverInstance {Id}: acknowledged native condition {Cond} by {User}",
|
||||
_driverInstanceId, msg.ConditionId, msg.OperatorUser);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_log.Warning(ex, "DriverInstance {Id}: native-alarm acknowledge of {Cond} failed",
|
||||
_driverInstanceId, msg.ConditionId);
|
||||
}
|
||||
}
|
||||
|
||||
private async Task HandleSubscribeAsync(Subscribe msg)
|
||||
{
|
||||
// Capture Sender/Self BEFORE any await. The re-subscribe path below awaits
|
||||
|
||||
@@ -129,6 +129,37 @@ public sealed class ScriptedAlarmSourceTests
|
||||
state.LastAckComment.ShouldBe("ack via opcua");
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Verifies that AcknowledgeAsync honors a supplied authenticated principal
|
||||
/// (<see cref="AlarmAcknowledgeRequest.OperatorUser"/>) and falls back to
|
||||
/// <c>"opcua-client"</c> only when none is supplied.
|
||||
/// </summary>
|
||||
[Fact]
|
||||
public async Task ScriptedAlarmSource_uses_supplied_principal_else_default()
|
||||
{
|
||||
var (engine, source, up) = await BuildAsync();
|
||||
using var _e = engine;
|
||||
using var _s = source;
|
||||
|
||||
// Supplied principal -> honored.
|
||||
up.Push("Temp", 150);
|
||||
await Task.Delay(200);
|
||||
await source.AcknowledgeAsync([new AlarmAcknowledgeRequest(
|
||||
"Plant/Line1", "Plant/Line1::HighTemp", "ack as bob", "bob")],
|
||||
TestContext.Current.CancellationToken);
|
||||
engine.GetState("Plant/Line1::HighTemp")!.LastAckUser.ShouldBe("bob");
|
||||
|
||||
// No principal -> default audit identity.
|
||||
up.Push("Temp", 50);
|
||||
await Task.Delay(200);
|
||||
up.Push("Temp", 150);
|
||||
await Task.Delay(200);
|
||||
await source.AcknowledgeAsync([new AlarmAcknowledgeRequest(
|
||||
"Plant/Line1", "Plant/Line1::HighTemp", "ack anon", null)],
|
||||
TestContext.Current.CancellationToken);
|
||||
engine.GetState("Plant/Line1::HighTemp")!.LastAckUser.ShouldBe("opcua-client");
|
||||
}
|
||||
|
||||
/// <summary>Verifies that null arguments are rejected.</summary>
|
||||
[Fact]
|
||||
public async Task Null_arguments_rejected()
|
||||
|
||||
@@ -191,6 +191,38 @@ public sealed class TriePermissionEvaluatorTests
|
||||
"a session bound to a generation absent from the cache must fail closed");
|
||||
}
|
||||
|
||||
/// <summary>Verifies that a HistoryRead-only grant does NOT authorize HistoryUpdate.</summary>
|
||||
[Fact]
|
||||
public void HistoryRead_grant_does_not_authorize_HistoryUpdate()
|
||||
{
|
||||
// Before the fix HistoryUpdate was mapped to the HistoryRead bit, so a read-only grant
|
||||
// would wrongly authorise a write operation.
|
||||
var evaluator = MakeEvaluator([Row("cn=ops", NodeAclScopeKind.Cluster, null, NodePermissions.HistoryRead)]);
|
||||
|
||||
var decision = evaluator.Authorize(Session(["cn=ops"]), OpcUaOperation.HistoryUpdate, Scope());
|
||||
|
||||
decision.IsAllowed.ShouldBeFalse("HistoryRead grant must NOT imply HistoryUpdate");
|
||||
}
|
||||
|
||||
/// <summary>Verifies that a HistoryUpdate grant authorizes HistoryUpdate.</summary>
|
||||
[Fact]
|
||||
public void HistoryUpdate_grant_authorizes_HistoryUpdate()
|
||||
{
|
||||
var evaluator = MakeEvaluator([Row("cn=ops", NodeAclScopeKind.Cluster, null, NodePermissions.HistoryUpdate)]);
|
||||
|
||||
var decision = evaluator.Authorize(Session(["cn=ops"]), OpcUaOperation.HistoryUpdate, Scope());
|
||||
|
||||
decision.IsAllowed.ShouldBeTrue("HistoryUpdate grant must authorize HistoryUpdate operation");
|
||||
}
|
||||
|
||||
/// <summary>Verifies that the HistoryUpdate bit is 1<<12 and does not collide with MethodCall.</summary>
|
||||
[Fact]
|
||||
public void HistoryUpdate_bit_value_and_no_collision()
|
||||
{
|
||||
((int)NodePermissions.HistoryUpdate).ShouldBe(1 << 12);
|
||||
(NodePermissions.HistoryUpdate & NodePermissions.MethodCall).ShouldBe(NodePermissions.None);
|
||||
}
|
||||
|
||||
/// <summary>Verifies that the operation-to-permission mapping is total.</summary>
|
||||
[Fact]
|
||||
public void OperationToPermission_Mapping_IsTotal()
|
||||
|
||||
@@ -192,6 +192,7 @@ public sealed class GalaxyDriverAlarmSourceTests
|
||||
ack.Calls.Count.ShouldBe(2);
|
||||
ack.Calls[0].AlarmRef.ShouldBe("Tank01.Level.HiHi");
|
||||
ack.Calls[0].Comment.ShouldBe("shift handover");
|
||||
ack.Calls[0].Operator.ShouldBe(string.Empty); // null OperatorUser must fall back to empty string
|
||||
ack.Calls[1].AlarmRef.ShouldBe("Tank02.Level.HiHi");
|
||||
}
|
||||
|
||||
@@ -210,6 +211,26 @@ public sealed class GalaxyDriverAlarmSourceTests
|
||||
ack.Calls[0].AlarmRef.ShouldBe("Tank01.Level.HiHi");
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Verifies that AcknowledgeAsync forwards the request's authenticated principal
|
||||
/// (<see cref="AlarmAcknowledgeRequest.OperatorUser"/>) to the acknowledger so the
|
||||
/// gateway records WHO acked, rather than the generic empty-string fallback.
|
||||
/// </summary>
|
||||
[Fact]
|
||||
public async Task AcknowledgeAsync_forwards_OperatorUser()
|
||||
{
|
||||
var feed = new FakeAlarmFeed();
|
||||
var ack = new RecordingAcknowledger();
|
||||
using var driver = NewDriver(feed, ack);
|
||||
|
||||
await driver.AcknowledgeAsync(
|
||||
[new AlarmAcknowledgeRequest("src", "Obj.Alarm", "cmt", "alice")],
|
||||
CancellationToken.None);
|
||||
|
||||
ack.Calls.ShouldHaveSingleItem();
|
||||
ack.Calls[0].Operator.ShouldBe("alice");
|
||||
}
|
||||
|
||||
/// <summary>Verifies that AcknowledgeAsync throws NotSupportedException without an acknowledger.</summary>
|
||||
[Fact]
|
||||
public async Task AcknowledgeAsync_throws_NotSupported_without_acknowledger()
|
||||
|
||||
+1
-1
@@ -245,7 +245,7 @@ public sealed class GalaxyDriverSubscribeTests
|
||||
using var driver = new GalaxyDriver("g", Opts());
|
||||
var ex = await Should.ThrowAsync<NotSupportedException>(() =>
|
||||
driver.SubscribeAsync(["x"], TimeSpan.FromSeconds(1), CancellationToken.None));
|
||||
ex.Message.ShouldContain("PR 4.W");
|
||||
ex.Message.ShouldContain("GalaxyDriver.SubscribeAsync requires");
|
||||
}
|
||||
|
||||
/// <summary>Verifies subscription falls back to configured interval when zero is passed.</summary>
|
||||
|
||||
+3
-3
@@ -188,15 +188,15 @@ public sealed class GalaxyDriverWriteTests
|
||||
writer.Calls.ShouldBeEmpty();
|
||||
}
|
||||
|
||||
/// <summary>Verifies that WriteAsync throws when no writer is configured, referencing PR 4.4.</summary>
|
||||
/// <summary>Verifies that WriteAsync throws a clear guard error when no writer is configured.</summary>
|
||||
[Fact]
|
||||
public async Task WriteAsync_NoWriter_Throws_PointingAtPR44()
|
||||
public async Task WriteAsync_NoWriter_Throws()
|
||||
{
|
||||
var driver = new GalaxyDriver("g", Opts());
|
||||
|
||||
var ex = await Should.ThrowAsync<NotSupportedException>(() =>
|
||||
driver.WriteAsync([new WriteRequest("x", 1)], CancellationToken.None));
|
||||
ex.Message.ShouldContain("PR 4.4");
|
||||
ex.Message.ShouldContain("GalaxyDriver.WriteAsync requires");
|
||||
}
|
||||
|
||||
/// <summary>Verifies that WriteAsync throws ObjectDisposedException after the driver is disposed.</summary>
|
||||
|
||||
@@ -302,6 +302,242 @@ public sealed class AlarmCommandRouterTests : IDisposable
|
||||
await host.DisposeAsync();
|
||||
}
|
||||
|
||||
/// <summary>H4 — OnEnableDisable with <c>enabling:false</c> and the <c>AlarmAck</c> role on a SCRIPTED
|
||||
/// condition returns Good and routes exactly one <see cref="AlarmCommand"/> with Operation == "Disable"
|
||||
/// and User == the caller's DisplayName.</summary>
|
||||
[Fact]
|
||||
public async Task OnEnableDisable_disabling_with_AlarmAck_routes_Disable()
|
||||
{
|
||||
var (host, server) = await BootAsync();
|
||||
var nm = server.NodeManager!;
|
||||
var captured = new List<AlarmCommand>();
|
||||
nm.AlarmCommandRouter = captured.Add;
|
||||
|
||||
nm.EnsureFolder("eq-ed1", parentNodeId: null, displayName: "Equipment ED1");
|
||||
nm.MaterialiseAlarmCondition("alm-ed1", "eq-ed1", "HighTemp", "OffNormalAlarm", severity: 700, isNative: false);
|
||||
var condition = nm.TryGetAlarmCondition("alm-ed1");
|
||||
condition.ShouldNotBeNull();
|
||||
condition!.OnEnableDisable.ShouldNotBeNull();
|
||||
|
||||
var ctx = SessionContext(server, "ivan", OpcUaDataPlaneRoles.AlarmAck);
|
||||
// SDK Disable invokes OnEnableDisable(ctx, condition, enabling:false).
|
||||
var result = condition.OnEnableDisable!(ctx, condition, enabling: false);
|
||||
|
||||
result.ShouldBe(ServiceResult.Good);
|
||||
captured.Count.ShouldBe(1);
|
||||
captured[0].AlarmId.ShouldBe("alm-ed1");
|
||||
captured[0].Operation.ShouldBe("Disable");
|
||||
captured[0].User.ShouldBe("ivan");
|
||||
captured[0].UnshelveAtUtc.ShouldBeNull();
|
||||
|
||||
await host.DisposeAsync();
|
||||
}
|
||||
|
||||
/// <summary>H4 — OnEnableDisable with <c>enabling:true</c> maps to the Enable operation.</summary>
|
||||
[Fact]
|
||||
public async Task OnEnableDisable_enabling_routes_Enable()
|
||||
{
|
||||
var (host, server) = await BootAsync();
|
||||
var nm = server.NodeManager!;
|
||||
var captured = new List<AlarmCommand>();
|
||||
nm.AlarmCommandRouter = captured.Add;
|
||||
|
||||
nm.EnsureFolder("eq-ed2", parentNodeId: null, displayName: "Equipment ED2");
|
||||
nm.MaterialiseAlarmCondition("alm-ed2", "eq-ed2", "HighTemp", "OffNormalAlarm", severity: 700, isNative: false);
|
||||
var condition = nm.TryGetAlarmCondition("alm-ed2");
|
||||
condition.ShouldNotBeNull();
|
||||
condition!.OnEnableDisable.ShouldNotBeNull();
|
||||
|
||||
var ctx = SessionContext(server, "jane", OpcUaDataPlaneRoles.AlarmAck);
|
||||
// SDK Enable invokes OnEnableDisable(ctx, condition, enabling:true).
|
||||
var result = condition.OnEnableDisable!(ctx, condition, enabling: true);
|
||||
|
||||
result.ShouldBe(ServiceResult.Good);
|
||||
captured.Count.ShouldBe(1);
|
||||
captured[0].Operation.ShouldBe("Enable");
|
||||
captured[0].User.ShouldBe("jane");
|
||||
|
||||
await host.DisposeAsync();
|
||||
}
|
||||
|
||||
/// <summary>H4 — OnEnableDisable from an anonymous / role-less identity is vetoed
|
||||
/// (BadUserAccessDenied) and the router is NOT invoked — the gate fails closed.</summary>
|
||||
[Fact]
|
||||
public async Task OnEnableDisable_anonymous_is_denied()
|
||||
{
|
||||
var (host, server) = await BootAsync();
|
||||
var nm = server.NodeManager!;
|
||||
var captured = new List<AlarmCommand>();
|
||||
nm.AlarmCommandRouter = captured.Add;
|
||||
|
||||
nm.EnsureFolder("eq-ed3", parentNodeId: null, displayName: "Equipment ED3");
|
||||
nm.MaterialiseAlarmCondition("alm-ed3", "eq-ed3", "HighTemp", "OffNormalAlarm", severity: 700, isNative: false);
|
||||
var condition = nm.TryGetAlarmCondition("alm-ed3");
|
||||
condition.ShouldNotBeNull();
|
||||
|
||||
// ServerSystemContext with no UserIdentity ⇒ anonymous / no role-carrying identity.
|
||||
var ctx = new ServerSystemContext(server.CurrentInstance);
|
||||
var result = condition!.OnEnableDisable!(ctx, condition, enabling: false);
|
||||
|
||||
result.StatusCode.Code.ShouldBe(StatusCodes.BadUserAccessDenied);
|
||||
captured.ShouldBeEmpty();
|
||||
|
||||
await host.DisposeAsync();
|
||||
}
|
||||
|
||||
/// <summary>H4 — OnEnableDisable on a NATIVE (driver-fed) condition returns BadNotSupported and does
|
||||
/// NOT route — native conditions have no engine enable/disable surface (Phase 3 decision #2). The gate
|
||||
/// short-circuits on the native flag before the role check, so even an AlarmAck caller gets BadNotSupported.</summary>
|
||||
[Fact]
|
||||
public async Task OnEnableDisable_on_native_condition_is_BadNotSupported()
|
||||
{
|
||||
var (host, server) = await BootAsync();
|
||||
var nm = server.NodeManager!;
|
||||
var captured = new List<AlarmCommand>();
|
||||
nm.AlarmCommandRouter = captured.Add;
|
||||
|
||||
nm.EnsureFolder("eq-ed4", parentNodeId: null, displayName: "Equipment ED4");
|
||||
nm.MaterialiseAlarmCondition("alm-ed4", "eq-ed4", "HighTemp", "OffNormalAlarm", severity: 700, isNative: true);
|
||||
var condition = nm.TryGetAlarmCondition("alm-ed4");
|
||||
condition.ShouldNotBeNull();
|
||||
condition!.OnEnableDisable.ShouldNotBeNull();
|
||||
|
||||
var ctx = SessionContext(server, "kara", OpcUaDataPlaneRoles.AlarmAck);
|
||||
var result = condition.OnEnableDisable!(ctx, condition, enabling: false);
|
||||
|
||||
result.StatusCode.Code.ShouldBe(StatusCodes.BadNotSupported);
|
||||
captured.ShouldBeEmpty();
|
||||
|
||||
await host.DisposeAsync();
|
||||
}
|
||||
|
||||
/// <summary>H6c — a NATIVE (driver-fed) condition's Acknowledge routes to <see
|
||||
/// cref="OtOpcUaNodeManager.NativeAlarmAckRouter"/> (the driver-bound seam), NOT the scripted
|
||||
/// <see cref="OtOpcUaNodeManager.AlarmCommandRouter"/>. With the AlarmAck role present, OnAcknowledge
|
||||
/// returns Good, the captured <see cref="NativeAlarmAck"/> carries the condition NodeId, the operator
|
||||
/// DisplayName, and the comment text, and the scripted router is NOT invoked.</summary>
|
||||
[Fact]
|
||||
public async Task Native_OnAcknowledge_routes_to_NativeAlarmAckRouter_not_scripted()
|
||||
{
|
||||
var (host, server) = await BootAsync();
|
||||
var nm = server.NodeManager!;
|
||||
|
||||
var scripted = new List<AlarmCommand>();
|
||||
var native = new List<NativeAlarmAck>();
|
||||
nm.AlarmCommandRouter = scripted.Add;
|
||||
nm.NativeAlarmAckRouter = native.Add;
|
||||
|
||||
nm.EnsureFolder("eq-nak1", parentNodeId: null, displayName: "Equipment NAK1");
|
||||
nm.MaterialiseAlarmCondition("alm-nak1", "eq-nak1", "HighTemp", "OffNormalAlarm", severity: 700, isNative: true);
|
||||
var condition = nm.TryGetAlarmCondition("alm-nak1");
|
||||
condition.ShouldNotBeNull();
|
||||
condition!.OnAcknowledge.ShouldNotBeNull();
|
||||
|
||||
var ctx = SessionContext(server, "nora", OpcUaDataPlaneRoles.AlarmAck);
|
||||
var result = condition.OnAcknowledge!(ctx, condition, EventIdBytes(), new LocalizedText("native ack"));
|
||||
|
||||
result.ShouldBe(ServiceResult.Good);
|
||||
native.Count.ShouldBe(1);
|
||||
native[0].ConditionNodeId.ShouldBe("alm-nak1"); // folder-scoped condition NodeId identifier
|
||||
native[0].OperatorUser.ShouldBe("nora");
|
||||
native[0].Comment.ShouldBe("native ack");
|
||||
scripted.ShouldBeEmpty(); // scripted engine NOT involved
|
||||
|
||||
await host.DisposeAsync();
|
||||
}
|
||||
|
||||
/// <summary>H6c — a SCRIPTED condition's Acknowledge still routes through the scripted
|
||||
/// <see cref="OtOpcUaNodeManager.AlarmCommandRouter"/> (Operation == "Acknowledge"); the native
|
||||
/// router is NOT invoked.</summary>
|
||||
[Fact]
|
||||
public async Task Scripted_OnAcknowledge_still_uses_AlarmCommandRouter()
|
||||
{
|
||||
var (host, server) = await BootAsync();
|
||||
var nm = server.NodeManager!;
|
||||
|
||||
var scripted = new List<AlarmCommand>();
|
||||
var native = new List<NativeAlarmAck>();
|
||||
nm.AlarmCommandRouter = scripted.Add;
|
||||
nm.NativeAlarmAckRouter = native.Add;
|
||||
|
||||
nm.EnsureFolder("eq-nak2", parentNodeId: null, displayName: "Equipment NAK2");
|
||||
nm.MaterialiseAlarmCondition("alm-nak2", "eq-nak2", "HighTemp", "OffNormalAlarm", severity: 700, isNative: false);
|
||||
var condition = nm.TryGetAlarmCondition("alm-nak2");
|
||||
condition.ShouldNotBeNull();
|
||||
condition!.OnAcknowledge.ShouldNotBeNull();
|
||||
|
||||
var ctx = SessionContext(server, "owen", OpcUaDataPlaneRoles.AlarmAck);
|
||||
var result = condition.OnAcknowledge!(ctx, condition, EventIdBytes(), new LocalizedText("scripted ack"));
|
||||
|
||||
result.ShouldBe(ServiceResult.Good);
|
||||
scripted.Count.ShouldBe(1);
|
||||
scripted[0].AlarmId.ShouldBe("alm-nak2");
|
||||
scripted[0].Operation.ShouldBe("Acknowledge");
|
||||
scripted[0].User.ShouldBe("owen");
|
||||
scripted[0].Comment.ShouldBe("scripted ack");
|
||||
native.ShouldBeEmpty(); // native seam NOT involved
|
||||
|
||||
await host.DisposeAsync();
|
||||
}
|
||||
|
||||
/// <summary>H6c — a NATIVE condition's Acknowledge from a non-null identity that lacks the
|
||||
/// <c>AlarmAck</c> role is vetoed (BadUserAccessDenied) and NEITHER router is invoked — the gate
|
||||
/// fails closed before any route, exactly as for scripted conditions.</summary>
|
||||
[Fact]
|
||||
public async Task Native_OnAcknowledge_without_AlarmAck_returns_denied_and_routes_nothing()
|
||||
{
|
||||
var (host, server) = await BootAsync();
|
||||
var nm = server.NodeManager!;
|
||||
|
||||
var scripted = new List<AlarmCommand>();
|
||||
var native = new List<NativeAlarmAck>();
|
||||
nm.AlarmCommandRouter = scripted.Add;
|
||||
nm.NativeAlarmAckRouter = native.Add;
|
||||
|
||||
nm.EnsureFolder("eq-nak4", parentNodeId: null, displayName: "Equipment NAK4");
|
||||
nm.MaterialiseAlarmCondition("alm-nak4", "eq-nak4", "HighTemp", "OffNormalAlarm", severity: 700, isNative: true);
|
||||
var condition = nm.TryGetAlarmCondition("alm-nak4");
|
||||
condition.ShouldNotBeNull();
|
||||
|
||||
var ctx = SessionContext(server, "pete", "ReadOnly"); // non-null identity, but no AlarmAck
|
||||
var result = condition!.OnAcknowledge!(ctx, condition, EventIdBytes(), new LocalizedText("nope"));
|
||||
|
||||
result.StatusCode.Code.ShouldBe(StatusCodes.BadUserAccessDenied);
|
||||
native.ShouldBeEmpty();
|
||||
scripted.ShouldBeEmpty();
|
||||
|
||||
await host.DisposeAsync();
|
||||
}
|
||||
|
||||
/// <summary>H6c — a NATIVE condition's Acknowledge from an anonymous / role-less identity is vetoed
|
||||
/// (BadUserAccessDenied) and NEITHER router is invoked — the gate fails closed before any route.</summary>
|
||||
[Fact]
|
||||
public async Task Native_OnAcknowledge_anonymous_is_denied()
|
||||
{
|
||||
var (host, server) = await BootAsync();
|
||||
var nm = server.NodeManager!;
|
||||
|
||||
var scripted = new List<AlarmCommand>();
|
||||
var native = new List<NativeAlarmAck>();
|
||||
nm.AlarmCommandRouter = scripted.Add;
|
||||
nm.NativeAlarmAckRouter = native.Add;
|
||||
|
||||
nm.EnsureFolder("eq-nak3", parentNodeId: null, displayName: "Equipment NAK3");
|
||||
nm.MaterialiseAlarmCondition("alm-nak3", "eq-nak3", "HighTemp", "OffNormalAlarm", severity: 700, isNative: true);
|
||||
var condition = nm.TryGetAlarmCondition("alm-nak3");
|
||||
condition.ShouldNotBeNull();
|
||||
|
||||
// ServerSystemContext with no UserIdentity ⇒ anonymous / no role-carrying identity.
|
||||
var ctx = new ServerSystemContext(server.CurrentInstance);
|
||||
var result = condition!.OnAcknowledge!(ctx, condition, EventIdBytes(), new LocalizedText("x"));
|
||||
|
||||
result.StatusCode.Code.ShouldBe(StatusCodes.BadUserAccessDenied);
|
||||
native.ShouldBeEmpty();
|
||||
scripted.ShouldBeEmpty();
|
||||
|
||||
await host.DisposeAsync();
|
||||
}
|
||||
|
||||
/// <summary>A null router is a safe no-op: handler still gates + returns Good, just routes nowhere.</summary>
|
||||
[Fact]
|
||||
public async Task OnAcknowledge_with_null_router_is_safe_noop_and_returns_good()
|
||||
@@ -323,6 +559,87 @@ public sealed class AlarmCommandRouterTests : IDisposable
|
||||
await host.DisposeAsync();
|
||||
}
|
||||
|
||||
/// <summary>H6a — a condition materialised with <c>isNative:true</c> is tracked so later inbound-ack
|
||||
/// routing can dispatch its Acknowledge to the driver rather than the scripted engine.</summary>
|
||||
[Fact]
|
||||
public async Task Native_materialise_is_tracked_as_native()
|
||||
{
|
||||
var (host, server) = await BootAsync();
|
||||
var nm = server.NodeManager!;
|
||||
|
||||
nm.EnsureFolder("eq", parentNodeId: null, displayName: "Equipment");
|
||||
nm.MaterialiseAlarmCondition("a1", "eq", "d", "OffNormalAlarm", 700, isNative: true);
|
||||
|
||||
nm.IsNativeAlarmNode("a1").ShouldBeTrue();
|
||||
|
||||
await host.DisposeAsync();
|
||||
}
|
||||
|
||||
/// <summary>H6a — a scripted condition (the default, <c>isNative:false</c>) is NOT tracked as native.</summary>
|
||||
[Fact]
|
||||
public async Task Scripted_materialise_is_not_native()
|
||||
{
|
||||
var (host, server) = await BootAsync();
|
||||
var nm = server.NodeManager!;
|
||||
|
||||
nm.EnsureFolder("eq", parentNodeId: null, displayName: "Equipment");
|
||||
nm.MaterialiseAlarmCondition("a2", "eq", "d", "OffNormalAlarm", 700, isNative: false);
|
||||
|
||||
nm.IsNativeAlarmNode("a2").ShouldBeFalse();
|
||||
|
||||
await host.DisposeAsync();
|
||||
}
|
||||
|
||||
/// <summary>H6a lifecycle — the native flag is NOT sticky across a rebuild + kind flip. Materialise an
|
||||
/// id as native (flag true), <see cref="OtOpcUaNodeManager.RebuildAddressSpace"/> (which clears the
|
||||
/// folder + condition + native-flag sets), re-ensure the equipment folder, then re-materialise the
|
||||
/// SAME id as scripted (<c>isNative:false</c>). The flag must read false — the rebuild dropped it and
|
||||
/// the scripted re-materialise did NOT re-add it. Guards against a stale-native leak that would route a
|
||||
/// now-scripted alarm's inbound ack to the driver.</summary>
|
||||
[Fact]
|
||||
public async Task Native_flag_clears_on_rebuild_then_kind_flip()
|
||||
{
|
||||
var (host, server) = await BootAsync();
|
||||
var nm = server.NodeManager!;
|
||||
|
||||
nm.EnsureFolder("eq", parentNodeId: null, displayName: "Equipment");
|
||||
nm.MaterialiseAlarmCondition("a1", "eq", "d", "OffNormalAlarm", 700, isNative: true);
|
||||
nm.IsNativeAlarmNode("a1").ShouldBeTrue();
|
||||
|
||||
// RebuildAddressSpace clears the folder set too, so the equipment folder must be re-ensured
|
||||
// before the same id can be re-materialised (ResolveParentFolder needs the parent back).
|
||||
nm.RebuildAddressSpace();
|
||||
nm.EnsureFolder("eq", parentNodeId: null, displayName: "Equipment");
|
||||
nm.MaterialiseAlarmCondition("a1", "eq", "d", "OffNormalAlarm", 700, isNative: false);
|
||||
|
||||
nm.IsNativeAlarmNode("a1").ShouldBeFalse();
|
||||
|
||||
await host.DisposeAsync();
|
||||
}
|
||||
|
||||
/// <summary>H6a lifecycle (converse) — a scripted condition can flip TO native across a rebuild.
|
||||
/// Materialise an id as scripted (flag false), rebuild, re-ensure the folder, re-materialise the SAME
|
||||
/// id as native (<c>isNative:true</c>). The flag must read true — the native re-materialise re-adds it
|
||||
/// cleanly after the rebuild cleared the slate.</summary>
|
||||
[Fact]
|
||||
public async Task Scripted_flag_can_flip_to_native_across_rebuild()
|
||||
{
|
||||
var (host, server) = await BootAsync();
|
||||
var nm = server.NodeManager!;
|
||||
|
||||
nm.EnsureFolder("eq", parentNodeId: null, displayName: "Equipment");
|
||||
nm.MaterialiseAlarmCondition("a1", "eq", "d", "OffNormalAlarm", 700, isNative: false);
|
||||
nm.IsNativeAlarmNode("a1").ShouldBeFalse();
|
||||
|
||||
nm.RebuildAddressSpace();
|
||||
nm.EnsureFolder("eq", parentNodeId: null, displayName: "Equipment");
|
||||
nm.MaterialiseAlarmCondition("a1", "eq", "d", "OffNormalAlarm", 700, isNative: true);
|
||||
|
||||
nm.IsNativeAlarmNode("a1").ShouldBeTrue();
|
||||
|
||||
await host.DisposeAsync();
|
||||
}
|
||||
|
||||
/// <summary>Builds a <see cref="ServerSystemContext"/> (an <see cref="ISessionOperationContext"/>)
|
||||
/// carrying a <see cref="RoleCarryingUserIdentity"/> with the given name + roles — the exact seam the
|
||||
/// gate reads via <c>(context as ISessionOperationContext)?.UserIdentity as RoleCarryingUserIdentity</c>.</summary>
|
||||
|
||||
@@ -109,7 +109,7 @@ public sealed class DeferredAddressSpaceSinkTests
|
||||
public void WriteAlarmCondition(string alarmNodeId, AlarmConditionSnapshot state, DateTime sourceTimestampUtc)
|
||||
=> CallQueue.Enqueue($"WA:{alarmNodeId}");
|
||||
/// <inheritdoc />
|
||||
public void MaterialiseAlarmCondition(string alarmNodeId, string equipmentNodeId, string displayName, string alarmType, int severity)
|
||||
public void MaterialiseAlarmCondition(string alarmNodeId, string equipmentNodeId, string displayName, string alarmType, int severity, bool isNative = false)
|
||||
=> CallQueue.Enqueue($"MA:{alarmNodeId}");
|
||||
/// <inheritdoc />
|
||||
public void EnsureFolder(string folderNodeId, string? parentNodeId, string displayName)
|
||||
|
||||
@@ -252,7 +252,7 @@ public sealed class Phase7ApplierHierarchyTests : IDisposable
|
||||
/// <param name="displayName">The condition display name.</param>
|
||||
/// <param name="alarmType">The domain alarm type.</param>
|
||||
/// <param name="severity">The domain severity.</param>
|
||||
public void MaterialiseAlarmCondition(string alarmNodeId, string equipmentNodeId, string displayName, string alarmType, int severity) { }
|
||||
public void MaterialiseAlarmCondition(string alarmNodeId, string equipmentNodeId, string displayName, string alarmType, int severity, bool isNative = false) { }
|
||||
/// <summary>Records a folder creation request.</summary>
|
||||
/// <param name="folderNodeId">The node ID of the folder.</param>
|
||||
/// <param name="parentNodeId">The node ID of the parent folder, or null for root.</param>
|
||||
|
||||
@@ -228,8 +228,9 @@ public sealed class Phase7ApplierTests
|
||||
// The alarm tag drove MaterialiseAlarmCondition (folder-scoped NodeId, equipment parent,
|
||||
// matching display/type/severity) and did NOT drive EnsureVariable.
|
||||
var alarmNodeId = EquipmentNodeIds.Variable("eq-1", "", "OverTemp");
|
||||
// A native equipment-tag alarm: the call-site threads isNative: true.
|
||||
sink.AlarmConditionCalls.ShouldHaveSingleItem()
|
||||
.ShouldBe((alarmNodeId, "eq-1", "OverTemp", "OffNormalAlarm", 700));
|
||||
.ShouldBe((alarmNodeId, "eq-1", "OverTemp", "OffNormalAlarm", 700, true));
|
||||
sink.VariableCalls.ShouldNotContain(v => v.NodeId == alarmNodeId);
|
||||
}
|
||||
|
||||
@@ -257,8 +258,9 @@ public sealed class Phase7ApplierTests
|
||||
sink.FolderCalls.ShouldHaveSingleItem().ShouldBe(("eq-1/Diagnostics", "eq-1", "Diagnostics"));
|
||||
// Condition is parented to the sub-folder, with the folder-scoped NodeId. No value variable.
|
||||
var alarmNodeId = EquipmentNodeIds.Variable("eq-1", "Diagnostics", "OverTemp");
|
||||
// A native equipment-tag alarm (with a FolderPath): the call-site still threads isNative: true.
|
||||
sink.AlarmConditionCalls.ShouldHaveSingleItem()
|
||||
.ShouldBe((alarmNodeId, "eq-1/Diagnostics", "OverTemp", "OffNormalAlarm", 500));
|
||||
.ShouldBe((alarmNodeId, "eq-1/Diagnostics", "OverTemp", "OffNormalAlarm", 500, true));
|
||||
sink.VariableCalls.ShouldBeEmpty();
|
||||
}
|
||||
|
||||
@@ -445,8 +447,9 @@ public sealed class Phase7ApplierTests
|
||||
applier.MaterialiseScriptedAlarms(composition);
|
||||
|
||||
// Only the enabled alarm is materialised; the disabled one is skipped entirely.
|
||||
// A SCRIPTED alarm: the call-site threads isNative: false (guards against a native/scripted swap).
|
||||
sink.AlarmConditionCalls.ShouldHaveSingleItem()
|
||||
.ShouldBe(("alm-1", "eq-1", "HighTemp", "OffNormalAlarm", 700));
|
||||
.ShouldBe(("alm-1", "eq-1", "HighTemp", "OffNormalAlarm", 700, false));
|
||||
}
|
||||
|
||||
/// <summary>Verifies that added equipment tags in an otherwise-empty plan trigger an
|
||||
@@ -717,7 +720,7 @@ public sealed class Phase7ApplierTests
|
||||
/// keyed by NodeId (null ⇒ that call passed not-historized).</summary>
|
||||
public ConcurrentQueue<(string NodeId, string? HistorianTagname)> HistorianQueue { get; } = new();
|
||||
/// <summary>Gets the queue of alarm-condition materialise calls.</summary>
|
||||
public ConcurrentQueue<(string AlarmNodeId, string EquipmentNodeId, string DisplayName, string AlarmType, int Severity)> AlarmConditionQueue { get; } = new();
|
||||
public ConcurrentQueue<(string AlarmNodeId, string EquipmentNodeId, string DisplayName, string AlarmType, int Severity, bool IsNative)> AlarmConditionQueue { get; } = new();
|
||||
/// <summary>Gets the number of rebuild calls made on this sink.</summary>
|
||||
public int RebuildCalls;
|
||||
|
||||
@@ -730,7 +733,7 @@ public sealed class Phase7ApplierTests
|
||||
/// <summary>Gets the list of recorded (NodeId, historian-tagname) pairs captured per EnsureVariable call.</summary>
|
||||
public List<(string NodeId, string? HistorianTagname)> HistorianCalls => HistorianQueue.ToList();
|
||||
/// <summary>Gets the list of recorded alarm-condition materialise calls.</summary>
|
||||
public List<(string AlarmNodeId, string EquipmentNodeId, string DisplayName, string AlarmType, int Severity)> AlarmConditionCalls => AlarmConditionQueue.ToList();
|
||||
public List<(string AlarmNodeId, string EquipmentNodeId, string DisplayName, string AlarmType, int Severity, bool IsNative)> AlarmConditionCalls => AlarmConditionQueue.ToList();
|
||||
|
||||
/// <summary>Records a value write (no-op in this recording sink).</summary>
|
||||
/// <param name="nodeId">The node ID.</param>
|
||||
@@ -750,8 +753,8 @@ public sealed class Phase7ApplierTests
|
||||
/// <param name="displayName">The condition display name.</param>
|
||||
/// <param name="alarmType">The domain alarm type.</param>
|
||||
/// <param name="severity">The domain severity.</param>
|
||||
public void MaterialiseAlarmCondition(string alarmNodeId, string equipmentNodeId, string displayName, string alarmType, int severity)
|
||||
=> AlarmConditionQueue.Enqueue((alarmNodeId, equipmentNodeId, displayName, alarmType, severity));
|
||||
public void MaterialiseAlarmCondition(string alarmNodeId, string equipmentNodeId, string displayName, string alarmType, int severity, bool isNative = false)
|
||||
=> AlarmConditionQueue.Enqueue((alarmNodeId, equipmentNodeId, displayName, alarmType, severity, isNative));
|
||||
/// <summary>Records a folder creation call.</summary>
|
||||
/// <param name="folderNodeId">The folder node ID.</param>
|
||||
/// <param name="parentNodeId">The parent folder node ID, if any.</param>
|
||||
@@ -802,7 +805,7 @@ public sealed class Phase7ApplierTests
|
||||
/// <param name="displayName">The condition display name.</param>
|
||||
/// <param name="alarmType">The domain alarm type.</param>
|
||||
/// <param name="severity">The domain severity.</param>
|
||||
public void MaterialiseAlarmCondition(string alarmNodeId, string equipmentNodeId, string displayName, string alarmType, int severity) { }
|
||||
public void MaterialiseAlarmCondition(string alarmNodeId, string equipmentNodeId, string displayName, string alarmType, int severity, bool isNative = false) { }
|
||||
/// <summary>No-op folder creation call.</summary>
|
||||
/// <param name="folderNodeId">The folder node ID.</param>
|
||||
/// <param name="parentNodeId">The parent folder node ID, if any.</param>
|
||||
|
||||
+282
@@ -0,0 +1,282 @@
|
||||
using System.Collections.Concurrent;
|
||||
using System.Text.Json;
|
||||
using Akka.Actor;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Shouldly;
|
||||
using Xunit;
|
||||
using ZB.MOM.WW.OtOpcUa.Commons.Engines;
|
||||
using ZB.MOM.WW.OtOpcUa.Commons.Messages.Deploy;
|
||||
using ZB.MOM.WW.OtOpcUa.Commons.Messages.Fleet;
|
||||
using ZB.MOM.WW.OtOpcUa.Commons.Messages.Redundancy;
|
||||
using ZB.MOM.WW.OtOpcUa.Commons.Types;
|
||||
using ZB.MOM.WW.OtOpcUa.Configuration;
|
||||
using ZB.MOM.WW.OtOpcUa.Configuration.Entities;
|
||||
using ZB.MOM.WW.OtOpcUa.Configuration.Enums;
|
||||
using ZB.MOM.WW.OtOpcUa.Core.Abstractions;
|
||||
using ZB.MOM.WW.OtOpcUa.Runtime.Drivers;
|
||||
using ZB.MOM.WW.OtOpcUa.Runtime.Tests.Harness;
|
||||
|
||||
namespace ZB.MOM.WW.OtOpcUa.Runtime.Tests.Drivers;
|
||||
|
||||
/// <summary>
|
||||
/// Verifies the inbound native-condition <b>acknowledge</b> routing wired into
|
||||
/// <see cref="DriverHostActor"/> (H6d): an OPC UA client Acknowledges a NATIVE condition, the
|
||||
/// node manager invokes <c>NativeAlarmAckRouter</c>, and the host (NEXT task) Tells a
|
||||
/// <see cref="DriverHostActor.RouteNativeAlarmAck"/> in. The host resolves the condition NodeId →
|
||||
/// owning <c>(DriverInstanceId, FullName)</c> via the <c>_driverRefByAlarmNodeId</c> inverse map
|
||||
/// (built alongside the alarm forward map in <c>PushDesiredSubscriptions</c>), applies the SAME
|
||||
/// primary gate the inbound write path uses, and routes to the owning driver child's
|
||||
/// <see cref="IAlarmSource.AcknowledgeAsync"/> carrying the principal.
|
||||
///
|
||||
/// <para>
|
||||
/// Mirrors <c>DriverHostActorWriteRoutingTests</c>: a real apply through the existing harness
|
||||
/// spawns a real (non-stubbed) <see cref="DriverInstanceActor"/> child backed by a recording
|
||||
/// <see cref="IAlarmSource"/> driver, so the inverse map is populated authentically and the
|
||||
/// forwarded acknowledge request can be observed. The seeded tag carries an <c>alarm</c> object so
|
||||
/// it materialises as a Part 9 condition (folder-scoped condition NodeId), not a value variable.
|
||||
/// </para>
|
||||
/// </summary>
|
||||
public sealed class DriverHostActorNativeAlarmAckRoutingTests : RuntimeActorTestBase
|
||||
{
|
||||
private static readonly NodeId TestNode = NodeId.Parse("driver-ack-test");
|
||||
private static readonly RevisionHash RevA = RevisionHash.Parse(new string('a', 64));
|
||||
private static readonly TimeSpan Timeout = TimeSpan.FromSeconds(5);
|
||||
|
||||
/// <summary>On the PRIMARY (role unknown ⇒ Primary), a RouteNativeAlarmAck for a mapped condition NodeId
|
||||
/// forwards exactly one <see cref="AlarmAcknowledgeRequest"/> to the owning driver's
|
||||
/// <see cref="IAlarmSource.AcknowledgeAsync"/>, with <c>ConditionId == FullName</c>, the operator
|
||||
/// principal, and the comment.</summary>
|
||||
[Fact]
|
||||
public void RouteNativeAlarmAck_routes_to_driver_AcknowledgeAsync_with_principal()
|
||||
{
|
||||
var db = NewInMemoryDbFactory();
|
||||
var recorder = new RecordingAlarmDriverFactory("GalaxyMxGateway");
|
||||
// One alarm-bearing equipment tag: eq-1, drv-1, FullName "Temp.HiHi", no folder, Name "temp_hi"
|
||||
// → condition NodeId "eq-1/temp_hi".
|
||||
var deploymentId = SeedDeploymentWithAlarmTag(db, RevA,
|
||||
Equip: "eq-1", Driver: "drv-1", FullName: "Temp.HiHi", Folder: null, Name: "temp_hi");
|
||||
|
||||
var actor = SpawnHostAndApply(db, deploymentId, recorder);
|
||||
|
||||
// Local role unknown ⇒ treated as Primary ⇒ ack allowed (default-allow semantics).
|
||||
actor.Tell(new DriverHostActor.RouteNativeAlarmAck("eq-1/temp_hi", "cmt", "alice"));
|
||||
|
||||
// The driver received exactly one acknowledge, correlated on its wire-ref FullName, with principal.
|
||||
AwaitAssert(() =>
|
||||
{
|
||||
recorder.Acks.Count.ShouldBe(1);
|
||||
recorder.Acks[0].ConditionId.ShouldBe("Temp.HiHi");
|
||||
recorder.Acks[0].SourceNodeId.ShouldBe("Temp.HiHi");
|
||||
recorder.Acks[0].Comment.ShouldBe("cmt");
|
||||
recorder.Acks[0].OperatorUser.ShouldBe("alice");
|
||||
}, duration: Timeout);
|
||||
}
|
||||
|
||||
/// <summary>An ack for an unmapped condition NodeId is dropped: no throw, and the driver's
|
||||
/// <see cref="IAlarmSource.AcknowledgeAsync"/> is never called.</summary>
|
||||
[Fact]
|
||||
public void RouteNativeAlarmAck_unknown_node_is_dropped()
|
||||
{
|
||||
var db = NewInMemoryDbFactory();
|
||||
var recorder = new RecordingAlarmDriverFactory("GalaxyMxGateway");
|
||||
var deploymentId = SeedDeploymentWithAlarmTag(db, RevA,
|
||||
Equip: "eq-1", Driver: "drv-1", FullName: "Temp.HiHi", Folder: null, Name: "temp_hi");
|
||||
|
||||
var actor = SpawnHostAndApply(db, deploymentId, recorder);
|
||||
|
||||
actor.Tell(new DriverHostActor.RouteNativeAlarmAck("eq-1/does-not-exist", "cmt", "alice"));
|
||||
|
||||
// Give the (fire-and-forget) handler time to run; the unmapped node must produce no ack.
|
||||
AwaitAssert(() => recorder.Acks.ShouldBeEmpty(), duration: TimeSpan.FromMilliseconds(800));
|
||||
}
|
||||
|
||||
/// <summary>On a SECONDARY node the ack is gated off (same primary gate as the inbound write path): the
|
||||
/// driver's <see cref="IAlarmSource.AcknowledgeAsync"/> is NOT called — a secondary keeps its address
|
||||
/// space warm but must not push commands to the shared upstream alarm system.</summary>
|
||||
[Fact]
|
||||
public void RouteNativeAlarmAck_on_non_primary_is_dropped()
|
||||
{
|
||||
var db = NewInMemoryDbFactory();
|
||||
var recorder = new RecordingAlarmDriverFactory("GalaxyMxGateway");
|
||||
var deploymentId = SeedDeploymentWithAlarmTag(db, RevA,
|
||||
Equip: "eq-1", Driver: "drv-1", FullName: "Temp.HiHi", Folder: null, Name: "temp_hi");
|
||||
|
||||
var actor = SpawnHostAndApply(db, deploymentId, recorder);
|
||||
|
||||
// Force this node Secondary so the primary gate rejects the ack.
|
||||
actor.Tell(new RedundancyStateChanged(
|
||||
new[]
|
||||
{
|
||||
new NodeRedundancyState(TestNode, RedundancyRole.Secondary,
|
||||
IsClusterLeader: false, IsRoleLeaderForDriver: false, AsOfUtc: DateTime.UtcNow),
|
||||
},
|
||||
CorrelationId.NewId()));
|
||||
|
||||
actor.Tell(new DriverHostActor.RouteNativeAlarmAck("eq-1/temp_hi", "cmt", "alice"));
|
||||
|
||||
// No ack reached the driver — the gate short-circuited before the inverse-map lookup.
|
||||
AwaitAssert(() => recorder.Acks.ShouldBeEmpty(), duration: TimeSpan.FromMilliseconds(800));
|
||||
}
|
||||
|
||||
/// <summary>Spawns the host with the recording alarm-driver factory, dispatches the deployment, and waits
|
||||
/// for the Applied ACK so the apply (and thus the inverse-map build in PushDesiredSubscriptions) has
|
||||
/// completed before the test routes an ack.</summary>
|
||||
private IActorRef SpawnHostAndApply(
|
||||
IDbContextFactory<OtOpcUaConfigDbContext> db, DeploymentId deploymentId, IDriverFactory factory)
|
||||
{
|
||||
var coordinator = CreateTestProbe();
|
||||
var actor = Sys.ActorOf(DriverHostActor.Props(
|
||||
db, TestNode, coordinator.Ref,
|
||||
driverFactory: factory,
|
||||
localRoles: new HashSet<string> { "driver" }));
|
||||
|
||||
actor.Tell(new DispatchDeployment(deploymentId, RevA, CorrelationId.NewId()));
|
||||
coordinator.ExpectMsg<ApplyAck>(Timeout).Outcome.ShouldBe(ApplyAckOutcome.Applied);
|
||||
|
||||
return actor;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Seeds a Sealed deployment whose artifact carries one alarm-bearing equipment tag: the tag's
|
||||
/// <c>TagConfig</c> carries both a <c>FullName</c> and an <c>alarm</c> object so
|
||||
/// <c>DeploymentArtifact.ExtractTagAlarm</c> projects a non-null <c>EquipmentTagAlarmInfo</c> —
|
||||
/// making the tag a condition (folder-scoped condition NodeId) rather than a value variable. The
|
||||
/// <c>DriverInstances</c> row carries a non-Windows-only <c>DriverType</c> ("GalaxyMxGateway") + an
|
||||
/// Enabled flag so a REAL (non-stubbed) <see cref="DriverInstanceActor"/> child is spawned.
|
||||
/// </summary>
|
||||
private static DeploymentId SeedDeploymentWithAlarmTag(
|
||||
IDbContextFactory<OtOpcUaConfigDbContext> db, RevisionHash rev,
|
||||
string Equip, string Driver, string FullName, string? Folder, string Name)
|
||||
{
|
||||
var artifact = JsonSerializer.SerializeToUtf8Bytes(new
|
||||
{
|
||||
Namespaces = new[]
|
||||
{
|
||||
new { NamespaceId = "ns-eq", Kind = 0 }, // NamespaceKind.Equipment = 0
|
||||
},
|
||||
DriverInstances = new[]
|
||||
{
|
||||
new
|
||||
{
|
||||
DriverInstanceRowId = Guid.NewGuid(),
|
||||
DriverInstanceId = Driver,
|
||||
Name = Driver,
|
||||
DriverType = "GalaxyMxGateway", // not Windows-only ⇒ a real child is spawned (not stubbed)
|
||||
Enabled = true,
|
||||
DriverConfig = "{}",
|
||||
NamespaceId = "ns-eq",
|
||||
},
|
||||
},
|
||||
Tags = new[]
|
||||
{
|
||||
new
|
||||
{
|
||||
TagId = "tag-0",
|
||||
EquipmentId = Equip,
|
||||
DriverInstanceId = Driver,
|
||||
Name,
|
||||
FolderPath = Folder,
|
||||
DataType = "Boolean",
|
||||
TagConfig = JsonSerializer.Serialize(new
|
||||
{
|
||||
FullName,
|
||||
alarm = new { alarmType = "OffNormalAlarm", severity = 700 },
|
||||
}),
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
var id = DeploymentId.NewId();
|
||||
using var ctx = db.CreateDbContext();
|
||||
ctx.Deployments.Add(new Deployment
|
||||
{
|
||||
DeploymentId = id.Value,
|
||||
RevisionHash = rev.Value,
|
||||
Status = DeploymentStatus.Sealed,
|
||||
CreatedBy = "test",
|
||||
SealedAtUtc = DateTime.UtcNow,
|
||||
ArtifactBlob = artifact,
|
||||
});
|
||||
ctx.SaveChanges();
|
||||
return id;
|
||||
}
|
||||
|
||||
/// <summary>Factory producing a single <see cref="RecordingAlarmDriver"/> for the supported type, whose
|
||||
/// recorded acknowledge list is exposed for assertions.</summary>
|
||||
private sealed class RecordingAlarmDriverFactory : IDriverFactory
|
||||
{
|
||||
private readonly string _supportedType;
|
||||
private readonly RecordingAlarmDriver _driver = new();
|
||||
public RecordingAlarmDriverFactory(string supportedType) { _supportedType = supportedType; }
|
||||
|
||||
/// <summary>The acknowledge requests the spawned driver received (thread-safe — AcknowledgeAsync runs
|
||||
/// off the actor thread).</summary>
|
||||
public IReadOnlyList<AlarmAcknowledgeRequest> Acks => _driver.Acks;
|
||||
|
||||
/// <inheritdoc />
|
||||
public IDriver? TryCreate(string driverType, string driverInstanceId, string driverConfigJson)
|
||||
{
|
||||
if (!string.Equals(driverType, _supportedType, StringComparison.Ordinal)) return null;
|
||||
_driver.Bind(driverInstanceId, driverType);
|
||||
return _driver;
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public IReadOnlyCollection<string> SupportedTypes => new[] { _supportedType };
|
||||
}
|
||||
|
||||
/// <summary>An <see cref="IDriver"/> + <see cref="IAlarmSource"/> that records every acknowledge.</summary>
|
||||
private sealed class RecordingAlarmDriver : IDriver, IAlarmSource
|
||||
{
|
||||
private readonly ConcurrentQueue<AlarmAcknowledgeRequest> _acks = new();
|
||||
/// <inheritdoc />
|
||||
public string DriverInstanceId { get; private set; } = string.Empty;
|
||||
/// <inheritdoc />
|
||||
public string DriverType { get; private set; } = string.Empty;
|
||||
/// <summary>The acknowledge requests received so far.</summary>
|
||||
public IReadOnlyList<AlarmAcknowledgeRequest> Acks => _acks.ToArray();
|
||||
/// <summary>Sets the identity once the factory is asked to create it.</summary>
|
||||
public void Bind(string id, string type) { DriverInstanceId = id; DriverType = type; }
|
||||
/// <inheritdoc />
|
||||
public Task InitializeAsync(string driverConfigJson, CancellationToken cancellationToken) => Task.CompletedTask;
|
||||
/// <inheritdoc />
|
||||
public Task ReinitializeAsync(string driverConfigJson, CancellationToken cancellationToken) => Task.CompletedTask;
|
||||
/// <inheritdoc />
|
||||
public Task ShutdownAsync(CancellationToken cancellationToken) => Task.CompletedTask;
|
||||
/// <inheritdoc />
|
||||
public DriverHealth GetHealth() => new(DriverState.Healthy, DateTime.UtcNow, LastError: null);
|
||||
/// <inheritdoc />
|
||||
public long GetMemoryFootprint() => 0;
|
||||
/// <inheritdoc />
|
||||
public Task FlushOptionalCachesAsync(CancellationToken cancellationToken) => Task.CompletedTask;
|
||||
|
||||
/// <inheritdoc />
|
||||
public Task<IAlarmSubscriptionHandle> SubscribeAlarmsAsync(
|
||||
IReadOnlyList<string> sourceNodeIds, CancellationToken cancellationToken) =>
|
||||
Task.FromResult<IAlarmSubscriptionHandle>(new StubAlarmHandle());
|
||||
|
||||
/// <inheritdoc />
|
||||
public Task UnsubscribeAlarmsAsync(IAlarmSubscriptionHandle handle, CancellationToken cancellationToken) =>
|
||||
Task.CompletedTask;
|
||||
|
||||
/// <inheritdoc />
|
||||
public Task AcknowledgeAsync(
|
||||
IReadOnlyList<AlarmAcknowledgeRequest> acknowledgements, CancellationToken cancellationToken)
|
||||
{
|
||||
foreach (var a in acknowledgements) _acks.Enqueue(a);
|
||||
return Task.CompletedTask;
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public event EventHandler<AlarmEventArgs>? OnAlarmEvent
|
||||
{
|
||||
add { }
|
||||
remove { }
|
||||
}
|
||||
|
||||
private sealed class StubAlarmHandle : IAlarmSubscriptionHandle
|
||||
{
|
||||
public string DiagnosticId => "stub-alarm-sub";
|
||||
}
|
||||
}
|
||||
}
|
||||
+1
-1
@@ -206,7 +206,7 @@ public sealed class OtOpcUaTelemetryHookTests : RuntimeActorTestBase
|
||||
/// <param name="displayName">The condition display name.</param>
|
||||
/// <param name="alarmType">The domain alarm type.</param>
|
||||
/// <param name="severity">The domain severity.</param>
|
||||
public void MaterialiseAlarmCondition(string alarmNodeId, string equipmentNodeId, string displayName, string alarmType, int severity) { }
|
||||
public void MaterialiseAlarmCondition(string alarmNodeId, string equipmentNodeId, string displayName, string alarmType, int severity, bool isNative = false) { }
|
||||
/// <summary>Ensures folder exists (stub implementation).</summary>
|
||||
/// <param name="folderNodeId">The folder node identifier.</param>
|
||||
/// <param name="parentNodeId">The parent folder node identifier.</param>
|
||||
|
||||
@@ -274,7 +274,7 @@ public sealed class OpcUaPublishActorRebuildTests : RuntimeActorTestBase
|
||||
/// <param name="displayName">The condition display name.</param>
|
||||
/// <param name="alarmType">The domain alarm type.</param>
|
||||
/// <param name="severity">The domain severity.</param>
|
||||
public void MaterialiseAlarmCondition(string alarmNodeId, string equipmentNodeId, string displayName, string alarmType, int severity)
|
||||
public void MaterialiseAlarmCondition(string alarmNodeId, string equipmentNodeId, string displayName, string alarmType, int severity, bool isNative = false)
|
||||
=> Calls.Enqueue($"MA:{alarmNodeId}");
|
||||
/// <summary>Records a folder ensure call.</summary>
|
||||
/// <param name="folderNodeId">The folder node ID.</param>
|
||||
|
||||
@@ -577,7 +577,7 @@ public sealed class OpcUaPublishActorTests : RuntimeActorTestBase
|
||||
/// <param name="displayName">The condition display name.</param>
|
||||
/// <param name="alarmType">The domain alarm type.</param>
|
||||
/// <param name="severity">The domain severity.</param>
|
||||
public void MaterialiseAlarmCondition(string alarmNodeId, string equipmentNodeId, string displayName, string alarmType, int severity) { }
|
||||
public void MaterialiseAlarmCondition(string alarmNodeId, string equipmentNodeId, string displayName, string alarmType, int severity, bool isNative = false) { }
|
||||
|
||||
/// <summary>Ensures a folder exists (no-op in test).</summary>
|
||||
/// <param name="folderNodeId">The OPC UA folder node identifier.</param>
|
||||
|
||||
Reference in New Issue
Block a user