- device: read-only scale block (holding registers 1000..5095) + scale_set control action - seed: GRPC_DATA_SCALE=N adds SOURCE driver modscale/dev with N UInt16 tags in TagGroups small (first 160) / large (rest), one RawTagGroup export + CONSUMER mapping each (map-scale-small|large); fixture.json records the counts - rig.py: seed --scale N; deploy trigger gets a 60 s socket timeout (the AdminUI's StartDeployment ask waits up to 45 s; a 2048-tag snapshot read took ~25 s, so the general 15 s cap aborted the POST) - scale_gate.py: opens a >128 and a >1024-item mapping via Client CLI recursive subscribes on CONSUMER, requires all Good, churns the block, restarts the SOURCE pair, requires all Good with a post-restart value, checks the consumer ResetHistory counter and the container logs for 'history expired'; PASS/FAIL + evidence/S1026-results.json Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
@@ -49,6 +49,17 @@ string HistoryConfig(string name, string tagConfig)
|
||||
// A2a smoke profile (opt-in, `rig.py up --conditions`): SOURCE exports gain AlarmSubscribe and the SOURCE equipment gets
|
||||
// one scripted alarm, ScalarHigh (scalar > 100), so a condition stream sees a snapshot and a delta. Unset ⇒ v1 fixture.
|
||||
var conditions = Environment.GetEnvironmentVariable("GRPC_DATA_CONDITIONS") == "1";
|
||||
// #1115 scale profile (opt-in, `rig.py seed --scale N`): a second SOURCE Modbus driver `modscale` → device `dev` with N
|
||||
// read-only UInt16 tags on the device fixture's scale block (holding registers 1000..), split into TagGroup `small`
|
||||
// (the first min(N, 160)) and `large` (the rest). Each group is its own Raw export and CONSUMER mapping
|
||||
// (`map-scale-small` / `map-scale-large`), so a gate can open a >128-item and a >1024-item mapping. Unset ⇒ unchanged.
|
||||
const int ScaleRegisterBase = 1000, ScaleMaxCount = 4096, ScaleSmallCount = 160;
|
||||
var scaleText = Environment.GetEnvironmentVariable("GRPC_DATA_SCALE");
|
||||
var scale = string.IsNullOrEmpty(scaleText) ? 0
|
||||
: int.TryParse(scaleText, out var parsedScale) && parsedScale is >= 1 and <= ScaleMaxCount ? parsedScale
|
||||
: throw new InvalidOperationException("GRPC_DATA_SCALE must be 1..4096");
|
||||
var scaleSmall = Math.Min(scale, ScaleSmallCount);
|
||||
const DataOperations scaleOperations = DataOperations.Browse | DataOperations.Metadata | DataOperations.Read | DataOperations.Subscribe;
|
||||
try
|
||||
{
|
||||
if (args.Length == 0) return 2;
|
||||
@@ -441,6 +452,25 @@ try
|
||||
db.UnsTagReferences.Add(new() { UnsTagReferenceRowId = Guid.NewGuid(), UnsTagReferenceId = "ref-" + pump + "-yellow", EquipmentId = pumpId, TagId = "source-opcua-yellow" });
|
||||
}
|
||||
}
|
||||
if (scale > 0)
|
||||
{
|
||||
db.DriverInstances.Add(new() { DriverInstanceRowId = Guid.NewGuid(), DriverInstanceId = "source-modscale", ClusterId = "SOURCE", Name = "modscale", DriverType = "Modbus",
|
||||
DriverConfig = $$$"""{"TimeoutMs":2000,"AutoReconnect":true,"Probe":{"Enabled":true,"ProbeAddress":{{{ScaleRegisterBase}}}}}""" });
|
||||
db.Devices.Add(new() { DeviceRowId = Guid.NewGuid(), DeviceId = "source-scale-device", DriverInstanceId = "source-modscale", Name = "dev",
|
||||
DeviceConfig = """{"Host":"device","Port":5020,"UnitId":1}""" });
|
||||
db.PollGroups.Add(new() { PollGroupRowId = Guid.NewGuid(), PollGroupId = "source-scale-poll", DriverInstanceId = "source-modscale", Name = "scale", IntervalMs = 250 });
|
||||
foreach (var (group, order) in new[] { ("small", 0), ("large", 1) })
|
||||
if (group == "small" || scale > scaleSmall)
|
||||
db.TagGroups.Add(new() { TagGroupRowId = Guid.NewGuid(), TagGroupId = "source-scale-" + group, DeviceId = "source-scale-device", Name = group, SortOrder = order });
|
||||
for (var index = 0; index < scale; index++)
|
||||
{
|
||||
var address = ScaleRegisterBase + index;
|
||||
db.Tags.Add(new() { TagRowId = Guid.NewGuid(), TagId = $"source-scale-t{index:D4}", DeviceId = "source-scale-device",
|
||||
TagGroupId = index < scaleSmall ? "source-scale-small" : "source-scale-large", Name = $"t{index:D4}", DataType = "UInt16",
|
||||
AccessLevel = TagAccessLevel.Read, WriteIdempotent = false, PollGroupId = "source-scale-poll",
|
||||
TagConfig = JsonSerializer.Serialize(new { region = "HoldingRegisters", address, dataType = "UInt16", writable = false }) });
|
||||
}
|
||||
}
|
||||
db.NodeAcls.Add(new() { NodeAclRowId = Guid.NewGuid(), NodeAclId = "source-peer", ClusterId = "SOURCE", Principal = "fixture-consumer",
|
||||
ScopeKind = NodeAclScopeKind.Cluster, PermissionFlags = NodePermissions.Admin });
|
||||
db.DataConnections.Add(new() { DataConnectionRowId = Guid.NewGuid(), DataConnectionId = "consumer-source", ClusterId = "CONSUMER", Enabled = true,
|
||||
@@ -473,6 +503,18 @@ try
|
||||
db.NodeAcls.Add(new() { NodeAclRowId = Guid.NewGuid(), NodeAclId = "cli-history-map-" + name, ClusterId = "CONSUMER", Principal = "fixture-cli",
|
||||
ScopeKind = NodeAclScopeKind.RemoteNamespaceMapping, ScopeId = "map-" + name, PermissionFlags = NodePermissions.Browse | NodePermissions.HistoryRead });
|
||||
}
|
||||
if (scale > 0)
|
||||
foreach (var group in scale > scaleSmall ? new[] { "small", "large" } : new[] { "small" })
|
||||
{
|
||||
db.DataExports.Add(new() { DataExportRowId = Guid.NewGuid(), DataExportId = "export-scale-" + group, ClusterId = "SOURCE", Enabled = true,
|
||||
Realm = DataRealm.Raw, RootKind = "RawTagGroup", RootEntityId = "source-scale-" + group, PrincipalId = "fixture-consumer",
|
||||
AllowedOperations = scaleOperations });
|
||||
db.RemoteNamespaceMappings.Add(new() { RemoteNamespaceMappingRowId = Guid.NewGuid(), RemoteNamespaceMappingId = "map-scale-" + group,
|
||||
ClusterId = "CONSUMER", DataConnectionId = "consumer-source", Enabled = true, ConsumerNodeIds = ["consumer-1:4053", "consumer-2:4053"],
|
||||
Realm = DataRealm.Raw, RemoteRealm = DataRealm.Raw, LocalParentKind = "Cluster", LocalParentId = "CONSUMER", BranchName = "remote-scale-" + group,
|
||||
RemoteRootEntityId = "source-scale-" + group, RemoteNamespaceUri = V3NodeIds.RawNamespaceUri,
|
||||
RemoteIdentifierKind = "string", RemoteIdentifier = "modscale/dev/" + group, AllowedOperations = scaleOperations, WriteThrough = false });
|
||||
}
|
||||
if (conditions)
|
||||
{
|
||||
// A4: exports + CONSUMER mappings for the native alarm's three placements — the Raw opc-plc device and the two
|
||||
@@ -540,7 +582,12 @@ try
|
||||
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 });
|
||||
branches = new { raw = "remote-opc", pumpa = "remote-pumpa", pumpb = "remote-pumpb" } } } : null,
|
||||
// #1115 scale profile: where the N tags live and which CONSUMER mapping covers each group.
|
||||
scale = scale > 0 ? new { count = scale, register_base = ScaleRegisterBase, raw_root = "modscale/dev", poll_ms = 250,
|
||||
mappings = (scale > scaleSmall ? new[] { ("small", scaleSmall), ("large", scale - scaleSmall) } : new[] { ("small", scaleSmall) })
|
||||
.Select(entry => new { id = "map-scale-" + entry.Item1, branch = "remote-scale-" + entry.Item1, raw_path = "modscale/dev/" + entry.Item1,
|
||||
first_index = entry.Item1 == "small" ? 0 : scaleSmall, items = entry.Item2 }).ToArray() } : null });
|
||||
return 0;
|
||||
}
|
||||
catch (Exception error)
|
||||
|
||||
Reference in New Issue
Block a user