feat(opcua): FB-7 surgical DataType/array-shape in-place tag writes
Widen the F10b surgical address-space path so a changed equipment tag whose only differences are DataType / IsArray / ArrayLength (on top of the existing Writable / Historizing) is applied IN PLACE on the live node instead of forcing a full RebuildAddressSpace that drops every client's subscriptions server-wide. ISurgicalAddressSpaceSink.UpdateTagAttributes gains (dataType, isArray, arrayLength); the DeferredAddressSpaceSink wrapper forwards all six args (the prod-inertness seam). OtOpcUaNodeManager swaps DataType + ValueRank + ArrayDimensions in place, and on a real shape change (a) resets the node to BadWaitingForInitialData so no stale wrong-typed value is exposed (closes the prior brief-value-type-mismatch objection) and (b) raises a Part 3 GeneralModelChangeEvent (verb=DataTypeChanged) so model-aware clients re-read the definition. A Writable/Historizing-only change leaves the shape untouched (no reset, no model event) — original behaviour preserved byte-for-byte. AddressSpaceApplier.TagDeltaIsSurgicalEligible adds the three shape fields to its whitelist; FullName/Name/DriverInstanceId/alarm differences still rebuild. Tests: new NodeManagerSurgicalShapeUpdateTests boots a real server to prove the in-place swap + value reset + the no-reset backward-compat path + the model-event builder; AddressSpaceApplierTests invert the two former DataType/IsArray-rebuild cases to surgical and assert the shape args land; DeferredAddressSpaceSinkTests assert the shape args forward. 273/273 OpcUaServer.Tests green; full solution builds.
This commit is contained in:
@@ -95,13 +95,15 @@ public sealed class AddressSpaceApplier
|
||||
// respawn (DriverHostActor → ApplyVirtualTags), so it skips the rebuild and PRESERVES every
|
||||
// client's server-wide subscriptions. Any structural / node-affecting vtag change (Name/
|
||||
// FolderPath/DataType) — or any non-vtag change anywhere — still forces a full rebuild.
|
||||
// F10b (surgical tag write): a CHANGED equipment tag whose ONLY differences are Writable /
|
||||
// IsHistorized / HistorianTagname (a plain value variable — no alarm condition node) can be
|
||||
// updated IN PLACE on the existing node via ISurgicalAddressSpaceSink.UpdateTagAttributes
|
||||
// (see TagDeltaIsSurgicalEligible), again avoiding the full rebuild and preserving subscriptions.
|
||||
// Any other tag difference (DataType/IsArray/ArrayLength/FullName/identity/alarm) — or a sink
|
||||
// that lacks the surgical capability, or a node that turns out missing — falls back to a full
|
||||
// rebuild (safe default).
|
||||
// F10b + FB-7 (surgical tag write): a CHANGED equipment tag whose ONLY differences are Writable /
|
||||
// IsHistorized / HistorianTagname / DataType / IsArray / ArrayLength (a plain value variable — no
|
||||
// alarm condition node) can be updated IN PLACE on the existing node via
|
||||
// ISurgicalAddressSpaceSink.UpdateTagAttributes (see TagDeltaIsSurgicalEligible), avoiding the full
|
||||
// rebuild and preserving subscriptions. The shape fields (DataType/IsArray/ArrayLength) are now
|
||||
// surgical because the sink swaps DataType + ValueRank + ArrayDimensions in place and raises a
|
||||
// GeneralModelChangeEvent. Any other tag difference (FullName/Name/DriverInstanceId/identity/alarm) —
|
||||
// or a sink that lacks the surgical capability, or a node that turns out missing — falls back to a
|
||||
// full rebuild (safe default).
|
||||
var structuralRebuild =
|
||||
plan.AddedEquipment.Count > 0 || plan.RemovedEquipment.Count > 0 || plan.ChangedEquipment.Count > 0 ||
|
||||
plan.AddedAlarms.Count > 0 || plan.RemovedAlarms.Count > 0 || plan.ChangedAlarms.Count > 0 ||
|
||||
@@ -125,15 +127,16 @@ public sealed class AddressSpaceApplier
|
||||
var allApplied = true;
|
||||
foreach (var d in surgicalTagDeltas)
|
||||
{
|
||||
// Compute the node id + writable + historian EXACTLY as MaterialiseEquipmentTags would
|
||||
// so the in-place update matches what a rebuild would have produced.
|
||||
// Compute the node id + writable + historian + shape EXACTLY as MaterialiseEquipmentTags
|
||||
// would so the in-place update matches what a rebuild would have produced. Array tags are
|
||||
// forced read-only (same as EnsureVariable: the driver write path doesn't handle arrays).
|
||||
var nodeId = EquipmentNodeIds.Variable(d.Current.EquipmentId, d.Current.FolderPath, d.Current.Name);
|
||||
var writable = d.Current.Writable && !d.Current.IsArray;
|
||||
var historian = d.Current.IsHistorized
|
||||
? (string.IsNullOrWhiteSpace(d.Current.HistorianTagname) ? d.Current.FullName : d.Current.HistorianTagname)
|
||||
: null;
|
||||
bool ok;
|
||||
try { ok = surgical.UpdateTagAttributes(nodeId, writable, historian); }
|
||||
try { ok = surgical.UpdateTagAttributes(nodeId, writable, historian, d.Current.DataType, d.Current.IsArray, d.Current.ArrayLength); }
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, "AddressSpaceApplier: surgical UpdateTagAttributes threw for {Node}", nodeId);
|
||||
@@ -389,11 +392,15 @@ public sealed class AddressSpaceApplier
|
||||
Historize = d.Current.Historize,
|
||||
}).Equals(d.Current);
|
||||
|
||||
// F10b: a CHANGED equipment tag whose ONLY differences are Writable / IsHistorized / HistorianTagname
|
||||
// (a plain value variable — no alarm condition node) can be updated IN PLACE on the existing node via
|
||||
// ISurgicalAddressSpaceSink.UpdateTagAttributes, avoiding a full rebuild (preserving subscriptions).
|
||||
// DataType / IsArray / ArrayLength / FullName / DriverInstanceId / identity / alarm differences fall
|
||||
// through to a rebuild — the override-unequal default also covers any future field.
|
||||
// F10b + FB-7: a CHANGED equipment tag whose ONLY differences are Writable / IsHistorized /
|
||||
// HistorianTagname / DataType / IsArray / ArrayLength (a plain value variable — no alarm condition node)
|
||||
// can be updated IN PLACE on the existing node via ISurgicalAddressSpaceSink.UpdateTagAttributes,
|
||||
// avoiding a full rebuild (preserving subscriptions). The presentation-shape fields (DataType / IsArray /
|
||||
// ArrayLength) join the whitelist now that the surgical sink swaps DataType + ValueRank + ArrayDimensions
|
||||
// in place (and raises a GeneralModelChangeEvent). FullName / DriverInstanceId / Name / identity / alarm
|
||||
// differences still fall through to a rebuild — FullName/DriverInstanceId re-route the node to a different
|
||||
// driver point, Name re-derives the NodeId, and an alarm flip turns the node into a Part 9 condition. The
|
||||
// override-unequal default also covers any future field.
|
||||
private static bool TagDeltaIsSurgicalEligible(AddressSpacePlan.EquipmentTagDelta d) =>
|
||||
d.Previous.Alarm is null && d.Current.Alarm is null &&
|
||||
(d.Previous with
|
||||
@@ -401,6 +408,9 @@ public sealed class AddressSpaceApplier
|
||||
Writable = d.Current.Writable,
|
||||
IsHistorized = d.Current.IsHistorized,
|
||||
HistorianTagname = d.Current.HistorianTagname,
|
||||
DataType = d.Current.DataType,
|
||||
IsArray = d.Current.IsArray,
|
||||
ArrayLength = d.Current.ArrayLength,
|
||||
}).Equals(d.Current);
|
||||
|
||||
/// <summary>The "no-event" condition state written to a removed equipment / alarm node before the
|
||||
|
||||
Reference in New Issue
Block a user