fix(grpc-data): A1 review round 2 F1 + F2 — an ack-revert establishes nothing; every Good edge withdraws; Bad edge forgets unsignalable
F1: RevertNativeAlarmAck projected through WriteAlarmCondition, which re-marked a comms-withdrawn native condition known; with the Good edge's conditional withdrawal skipped (GoodSinceUtc null) it read known-inactive-Good until the replay. AlarmStateUpdate.EstablishesState (false for the revert) rides a new default sink overload WriteAlarmCondition(..., establishesState) through the deferred and SDK sinks to the node manager, and every Good edge now withdraws unconditionally. F2: the Bad edge clears the unsignalable set, so a stale report cannot arm the backstop on the next Good edge. The rig's CollectAlarmTraffic skips withdrawals (every edge now sends one).
This commit is contained in:
@@ -1327,6 +1327,11 @@ public sealed partial class OtOpcUaNodeManager : CustomNodeManager2, INodeManage
|
||||
/// <param name="sourceTimestampUtc">The timestamp of the alarm state change in UTC.</param>
|
||||
/// <param name="realm">The address-space realm (Raw or Uns) the alarm node lives in.</param>
|
||||
public void WriteAlarmCondition(string alarmNodeId, AlarmConditionSnapshot state, DateTime sourceTimestampUtc, AddressSpaceRealm realm)
|
||||
=> WriteAlarmCondition(alarmNodeId, state, sourceTimestampUtc, realm, establishesState: true);
|
||||
|
||||
/// <inheritdoc cref="IOpcUaAddressSpaceSink.WriteAlarmCondition(string, AlarmConditionSnapshot, DateTime, AddressSpaceRealm, bool)"/>
|
||||
public void WriteAlarmCondition(string alarmNodeId, AlarmConditionSnapshot state, DateTime sourceTimestampUtc, AddressSpaceRealm realm,
|
||||
bool establishesState)
|
||||
{
|
||||
ArgumentException.ThrowIfNullOrEmpty(alarmNodeId);
|
||||
ArgumentNullException.ThrowIfNull(state);
|
||||
@@ -1428,7 +1433,8 @@ public sealed partial class OtOpcUaNodeManager : CustomNodeManager2, INodeManage
|
||||
// scripted known-ness comes ONLY from MarkConditionsKnown (the engine's inputs-established flip).
|
||||
// The record is raised by ReportConditionEvent when the gate fires, otherwise here as a state-only
|
||||
// record (ConditionClass and the other silent fields).
|
||||
if (_nativeAlarmNodeIds.Contains(key)) _conditionStateKnown.Add(key);
|
||||
// Review round 2 F1: a projection no source decided (the #760 ack-revert) never establishes state either.
|
||||
if (establishesState && _nativeAlarmNodeIds.Contains(key)) _conditionStateKnown.Add(key);
|
||||
if (fire)
|
||||
{
|
||||
ReportConditionEvent(condition, sourceTimestampUtc);
|
||||
|
||||
@@ -91,6 +91,10 @@ public sealed class SdkAddressSpaceSink : IOpcUaAddressSpaceSink, ISurgicalAddre
|
||||
public void WriteAlarmCondition(string alarmNodeId, AlarmConditionSnapshot state, DateTime sourceTimestampUtc, AddressSpaceRealm realm)
|
||||
=> _nodeManager.WriteAlarmCondition(alarmNodeId, state, sourceTimestampUtc, realm);
|
||||
|
||||
/// <inheritdoc />
|
||||
public void WriteAlarmCondition(string alarmNodeId, AlarmConditionSnapshot state, DateTime sourceTimestampUtc, AddressSpaceRealm realm,
|
||||
bool establishesState) => _nodeManager.WriteAlarmCondition(alarmNodeId, state, sourceTimestampUtc, realm, establishesState);
|
||||
|
||||
/// <inheritdoc />
|
||||
public void WriteAlarmQuality(string alarmNodeId, uint statusCode, DateTime sourceTimestampUtc, AddressSpaceRealm realm)
|
||||
=> _nodeManager.WriteAlarmQuality(alarmNodeId, statusCode, sourceTimestampUtc, realm);
|
||||
|
||||
@@ -78,11 +78,11 @@ public sealed partial class DriverHostActor
|
||||
|
||||
/// <summary>
|
||||
/// A connectivity edge restarts the F5 window (from quality Good) and the backstop; a Bad edge cancels both.
|
||||
/// Review S2: the Bad edge withdraws "known" from the driver's conditions — the source can no longer vouch for
|
||||
/// their state, and an alarm raised during the outage would otherwise read known-inactive, Good after the
|
||||
/// reconnect until the replay. A Good edge withdraws too (ahead of the Good quality annotation) when no Bad edge
|
||||
/// was seen since the previous Good one, or it comes from a new child incarnation. They become known again only
|
||||
/// on the reconnected source's next signal (or transition).
|
||||
/// Review S2 / round 2 F1: every edge withdraws "known" from the driver's conditions — on the Bad edge the source
|
||||
/// can no longer vouch for their state (an alarm raised during the outage would otherwise read known-inactive,
|
||||
/// Good after the reconnect until the replay), and the Good edge withdraws again, unconditionally. They become
|
||||
/// known again only on the reconnected source's next signal (or transition). The Bad edge also forgets the
|
||||
/// unsignalable set (F2).
|
||||
/// </summary>
|
||||
private void OnConditionSignalConnectivity(string driverInstanceId, bool connected, IActorRef sender, long? connectionEpoch)
|
||||
{
|
||||
@@ -99,17 +99,22 @@ public sealed partial class DriverHostActor
|
||||
}
|
||||
|
||||
var t = Tracker(driverInstanceId);
|
||||
// A Good edge with no Bad edge since the previous Good one (or from a new incarnation) — withdraw here instead.
|
||||
var missedBadEdge = connected && (t.GoodSinceUtc is not null || (t.Owner is not null && !Equals(t.Owner, sender)));
|
||||
t.Owner = sender;
|
||||
t.Epoch++;
|
||||
Timers.Cancel(SignalTimeoutKey(driverInstanceId));
|
||||
Timers.Cancel(BackstopKey(driverInstanceId));
|
||||
t.Pending.Clear();
|
||||
t.PendingSinceUtc = null;
|
||||
if (!connected || missedBadEdge) WithdrawDriverConditionsKnown(driverInstanceId);
|
||||
// Review round 2 F1: withdraw on EVERY edge — the Good one too, unconditionally (ahead of the Good quality
|
||||
// annotation): whatever made a condition known since the Bad edge (an ack-revert projection, a missed Bad
|
||||
// edge, a new incarnation) cannot vouch for the reconnected source's state.
|
||||
WithdrawDriverConditionsKnown(driverInstanceId);
|
||||
if (!connected)
|
||||
{
|
||||
// Review round 2 F2: an unsignalable report belongs to the subscription that made it; the reconnected
|
||||
// subscription reports again if it still cannot signal. Kept, it would arm the backstop on the next Good
|
||||
// edge and turn a later FAILED refresh into known-by-timer instead of F5's unknown.
|
||||
t.Unsignalable.Clear();
|
||||
t.GoodSinceUtc = null;
|
||||
t.ConnectionEpoch = null;
|
||||
return;
|
||||
|
||||
@@ -2680,7 +2680,10 @@ public sealed partial class DriverHostActor : ReceiveActor, IWithTimers, IWithUn
|
||||
"reverting the condition to unacknowledged", _localNode, conditionNodeId, reason);
|
||||
// Native conditions live in the Raw realm at their bare NodeId (the apply pass's single raw condition).
|
||||
_opcUaPublishActor?.Tell(new ZB.MOM.WW.OtOpcUa.Runtime.OpcUa.OpcUaPublishActor.AlarmStateUpdate(
|
||||
conditionNodeId, snapshot, DateTime.UtcNow, AddressSpaceRealm.Raw));
|
||||
conditionNodeId, snapshot, DateTime.UtcNow, AddressSpaceRealm.Raw,
|
||||
// Review round 2 F1: the projector's cached prior state, not a driver transition — it establishes nothing
|
||||
// (a condition withdrawn by a comms loss must stay unknown until its driver signals again).
|
||||
EstablishesState: false));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
||||
@@ -79,8 +79,10 @@ public sealed class OpcUaPublishActor : ReceiveActor, IWithTimers
|
||||
/// <param name="Source">A1 (plan §5.1 G3): the emitting source — the driver instance id for a native projection,
|
||||
/// <see cref="ScriptedSource"/> for the scripted host, null when unattributed. Only used to discard a source's
|
||||
/// deferred <see cref="MarkConditionsKnown"/> when one of its deferred projections is dropped or skipped.</param>
|
||||
/// <param name="EstablishesState">A1 review round 2 F1: false for a projection no source decided (the #760 ack-revert),
|
||||
/// which must never make a withdrawn condition known again.</param>
|
||||
public sealed record AlarmStateUpdate(string AlarmNodeId, AlarmConditionSnapshot State, DateTime TimestampUtc, AddressSpaceRealm Realm,
|
||||
string? Source = null);
|
||||
string? Source = null, bool EstablishesState = true);
|
||||
|
||||
/// <summary>The <see cref="AlarmStateUpdate.Source"/> / <see cref="MarkConditionsKnown.Source"/> of the scripted host.</summary>
|
||||
public const string ScriptedSource = "scripted-alarms";
|
||||
@@ -787,7 +789,7 @@ public sealed class OpcUaPublishActor : ReceiveActor, IWithTimers
|
||||
if (PlanPipelineBusy) DeferAlarm(msg);
|
||||
try
|
||||
{
|
||||
_sink.WriteAlarmCondition(msg.AlarmNodeId, msg.State, msg.TimestampUtc, msg.Realm);
|
||||
_sink.WriteAlarmCondition(msg.AlarmNodeId, msg.State, msg.TimestampUtc, msg.Realm, msg.EstablishesState);
|
||||
Interlocked.Increment(ref _writes);
|
||||
OtOpcUaTelemetry.OpcUaSinkWrite.Add(1, new KeyValuePair<string, object?>("kind", "alarm"));
|
||||
}
|
||||
@@ -1156,7 +1158,7 @@ public sealed class OpcUaPublishActor : ReceiveActor, IWithTimers
|
||||
}
|
||||
|
||||
alarms++;
|
||||
try { _sink.WriteAlarmCondition(alarm.AlarmNodeId, alarm.State, alarm.TimestampUtc, alarm.Realm); }
|
||||
try { _sink.WriteAlarmCondition(alarm.AlarmNodeId, alarm.State, alarm.TimestampUtc, alarm.Realm, alarm.EstablishesState); }
|
||||
catch (Exception ex) { _log.Warning(ex, "OpcUaPublish: replaying a deferred alarm write threw for {Node}", alarm.AlarmNodeId); }
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user