test(grpc-data): A4 scenarios — native alarm on EastTank?Yellow (cycles live), condition mappings WriteThrough (DataMappingOperationsInvalid), folders subscribe after demand opens, ConfirmedState read, origin audit for A08 denial

This commit is contained in:
Joseph Doherty
2026-11-25 01:23:14 -05:00
parent 304e8b1b7d
commit 6bf7dc8930
2 changed files with 47 additions and 45 deletions
+9 -7
View File
@@ -384,8 +384,10 @@ try
db.ScriptedAlarms.Add(new() { ScriptedAlarmRowId = Guid.NewGuid(), ScriptedAlarmId = "source-scalar-high", EquipmentId = equipment,
Name = "ScalarHigh", AlarmType = "AlarmCondition", MessageTemplate = "scalar high", PredicateScriptId = "source-scalar-high" });
// A4 live scenarios (A02/A04): an OpcUaClient driver against the run-owned opc-plc `--alm` container (compose.conditions.yml),
// one native alarm tag bound 1:1 to the upstream CONDITION node EastTank?Red (several conditions share the EastTank source,
// so the source node would fold them; docs/drivers/OpcUaClient.md "Native alarms"), and a value control tag. The alarm tag is
// one native alarm tag bound 1:1 to the upstream CONDITION node EastTank?Yellow (several conditions share the EastTank source,
// so the source node would fold them; docs/drivers/OpcUaClient.md "Native alarms"), and a value control tag. Yellow, not Red:
// opc-plc's Yellow cycles Active (~40 s) / Inactive (~8 s) on its own, so the origin re-reports it live; Red never leaves
// Active and its heartbeats repeat the last-told state, so once acked it goes silent (live run a4s-1). The alarm tag is
// referenced by two NEW equipment (pumpa, pumpb) so the A2a/A3 smokes' `plc` equipment view is unchanged.
db.DriverInstances.Add(new() { DriverInstanceRowId = Guid.NewGuid(), DriverInstanceId = "source-opcua", ClusterId = "SOURCE", Name = "opcua", DriverType = "OpcUaClient",
DriverConfig = """{"SecurityPolicy":"None","SecurityMode":"None","AuthType":"Anonymous","AutoAcceptCertificates":true}""" });
@@ -393,16 +395,16 @@ try
DeviceConfig = """{"EndpointUrl":"opc.tcp://opcplc:50000"}""" });
db.Tags.Add(new() { TagRowId = Guid.NewGuid(), TagId = "source-opcua-fast", DeviceId = "source-opcplc", Name = "FastUInt1", DataType = "UInt32",
AccessLevel = TagAccessLevel.Read, WriteIdempotent = false, TagConfig = """{"nodeId":"ns=3;s=FastUInt1"}""" });
db.Tags.Add(new() { TagRowId = Guid.NewGuid(), TagId = "source-opcua-red", DeviceId = "source-opcplc", Name = "EastTankRed", DataType = "Boolean",
db.Tags.Add(new() { TagRowId = Guid.NewGuid(), TagId = "source-opcua-yellow", DeviceId = "source-opcplc", Name = "EastTankYellow", DataType = "Boolean",
AccessLevel = TagAccessLevel.Read, WriteIdempotent = false,
TagConfig = """{"nodeId":"ns=6;s=1:Colours/EastTank?Red","alarm":{"alarmType":"AlarmCondition","severity":500}}""" });
TagConfig = """{"nodeId":"ns=6;s=1:Colours/EastTank?Yellow","alarm":{"alarmType":"AlarmCondition","severity":500}}""" });
foreach (var pump in new[] { "pumpa", "pumpb" })
{
var pumpUuid = Guid.NewGuid();
var pumpId = DraftValidator.DeriveEquipmentId(pumpUuid);
pumpEquipment[pump] = pumpId;
db.Equipment.Add(new() { EquipmentRowId = Guid.NewGuid(), EquipmentId = pumpId, EquipmentUuid = pumpUuid, UnsLineId = "source-line", Name = pump, MachineCode = "fixture-" + pump });
db.UnsTagReferences.Add(new() { UnsTagReferenceRowId = Guid.NewGuid(), UnsTagReferenceId = "ref-" + pump + "-red", EquipmentId = pumpId, TagId = "source-opcua-red" });
db.UnsTagReferences.Add(new() { UnsTagReferenceRowId = Guid.NewGuid(), UnsTagReferenceId = "ref-" + pump + "-yellow", EquipmentId = pumpId, TagId = "source-opcua-yellow" });
}
}
db.NodeAcls.Add(new() { NodeAclRowId = Guid.NewGuid(), NodeAclId = "source-peer", ClusterId = "SOURCE", Principal = "fixture-consumer",
@@ -453,7 +455,7 @@ try
ClusterId = "CONSUMER", DataConnectionId = "consumer-source", Enabled = true, ConsumerNodeIds = ["consumer-1:4053", "consumer-2:4053"],
Realm = realm, RemoteRealm = realm, LocalParentKind = "Cluster", LocalParentId = "CONSUMER", BranchName = "remote-" + id,
RemoteRootEntityId = entity, RemoteNamespaceUri = realm == DataRealm.Raw ? V3NodeIds.RawNamespaceUri : V3NodeIds.UnsNamespaceUri,
RemoteIdentifierKind = "string", RemoteIdentifier = identifier, AllowedOperations = conditionOps, WriteThrough = false });
RemoteIdentifierKind = "string", RemoteIdentifier = identifier, AllowedOperations = conditionOps, WriteThrough = true });
}
// A04: a UNS-ONLY origin principal (one UNS export, no Raw export) — its condition records must carry no RawPath.
db.DataExports.Add(new() { DataExportRowId = Guid.NewGuid(), DataExportId = "export-pumpa-unsonly", ClusterId = "SOURCE", Enabled = true,
@@ -496,7 +498,7 @@ try
historized_string = new { raw = "modbus/plc/text", uns = "area/line/plc/text" } } : null,
// A4 live scenarios: where the native alarm lives (origin RawPath + equipment) and which consumer mappings place it.
conditions = conditions ? new { scripted = new { condition = "ScalarHigh", origin_id = "source-scalar-high", mapping = "map-uns", branch = "remote-source" },
native = new { condition = "EastTankRed", raw_path = "opcua/opcplc/EastTankRed", upstream = "ns=6;s=1:Colours/EastTank?Red",
native = new { condition = "EastTankYellow", raw_path = "opcua/opcplc/EastTankYellow", upstream = "ns=6;s=1:Colours/EastTank?Yellow",
equipment = pumpEquipment, subjects = new { pumpa = "area/line/pumpa", pumpb = "area/line/pumpb" }, raw_root = "opcua/opcplc",
mappings = new { raw = "map-opc", pumpa = "map-pumpa", pumpb = "map-pumpb" },
branches = new { raw = "remote-opc", pumpa = "remote-pumpa", pumpb = "remote-pumpb" } } } : null });