fix(grpc-data): A1 review round 2 N3 — FOCAS does not signal a condition a truncated alarm list shows inactive
A list cut off at the per-read cap may hide the alarm a selector matches; a condition that matched nothing on such a read stays unknown instead of being signalled known-inactive.
This commit is contained in:
@@ -314,13 +314,16 @@ internal sealed class FocasAlarmProjection : IAsyncDisposable
|
||||
List<string>? established = null;
|
||||
foreach (var tag in deviceTags.Where(t => sub.References.Contains(t.RawPath)))
|
||||
{
|
||||
(established ??= new List<string>()).Add(tag.RawPath);
|
||||
// Lift a Bad this projection put there BEFORE the normal diff, so a recovery that also changed the
|
||||
// alarm state (cleared during the outage) lands as Good then Clear.
|
||||
if (_qualityBadTold.Remove(tag.RawPath, out _))
|
||||
Deliver(handlers, QualityOnly(tag, sub.Handle, QualityGood, now), tag.RawPath);
|
||||
|
||||
var view = FocasAlarmMatcher.Evaluate(tag.Selector, alarms, deviceSelectors, truncated);
|
||||
// A1 review round 2 N3: on a list cut off at the per-read cap, a condition that sees NO matching alarm
|
||||
// may only be missing it (the alarm is past the cap) — its inactive state is not established, so it is
|
||||
// not signalled (it stays unknown). One that matched something is established either way.
|
||||
if (!truncated || view.Matched.Count > 0) (established ??= new List<string>()).Add(tag.RawPath);
|
||||
_told.TryGetValue(tag.RawPath, out var told);
|
||||
var (evt, nowTold) = FocasAlarmConditionMapper.Transition(told, view, tag, sub.Handle, now);
|
||||
_told[tag.RawPath] = nowTold;
|
||||
|
||||
+24
@@ -75,6 +75,30 @@ public sealed class FocasInitialAlarmStateSignalTests
|
||||
signals.ShouldAllBe(s => s == "signal:" + ServoM1, "only the reachable device's condition is established");
|
||||
}
|
||||
|
||||
/// <summary>Review round 2 N3: on an alarm list cut off at the per-read cap, a condition that matched nothing may only
|
||||
/// be missing its alarm past the cap — it is not signalled (stays unknown); one that matched something is.</summary>
|
||||
[Fact]
|
||||
public async Task A_truncated_list_does_not_signal_a_condition_that_matched_nothing()
|
||||
{
|
||||
var (drv, factory) = NewDriver([new FocasDeviceOptions(Host, DeviceName: "m1")],
|
||||
Tag(ServoM1, "ALARM:Servo", "m1"), Tag(AnyM1, "ALARM:Overheat", "m1"));
|
||||
factory.Customise = () =>
|
||||
{
|
||||
var c = new FakeFocasClient();
|
||||
c.SetAlarms([.. Enumerable.Range(0, ZB.MOM.WW.OtOpcUa.Driver.FOCAS.Wire.WireFocasClient.MaxAlarmsPerRead)
|
||||
.Select(i => new FocasActiveAlarm(400 + i, FocasAlarmType.Servo, 1, "SERVO " + i))]);
|
||||
return c;
|
||||
};
|
||||
var trace = Record(drv);
|
||||
await drv.InitializeAsync("{}", Ct);
|
||||
await drv.SubscribeAlarmsAsync([ServoM1, AnyM1], Ct);
|
||||
|
||||
await WaitFor(() => Snapshot(trace).Count(t => t.StartsWith("signal", StringComparison.Ordinal)) >= 2);
|
||||
await drv.ShutdownAsync(Ct);
|
||||
|
||||
Snapshot(trace).Where(t => t.StartsWith("signal", StringComparison.Ordinal)).ShouldAllBe(t => t == "signal:" + ServoM1);
|
||||
}
|
||||
|
||||
/// <summary>(xi) G5: a successful tick with no alarm handler attached raises no signal; with one it does.</summary>
|
||||
[Fact]
|
||||
public async Task No_signal_while_no_alarm_handler_is_attached()
|
||||
|
||||
Reference in New Issue
Block a user