fix(alarms): Severity runs one direction, higher = more urgent; raw priority kept (#129)
AlarmConditionState.Severity mixed two conventions: OPC UA rows carried Part 9 Severity (higher = more severe) while MxGateway native alarms and computed alarms carried a raw AVEVA-style priority (1 = most urgent). Every consumer ranks higher as worse, so Worst Severity, the severity filter/sort and the site event-log Error threshold picked the LEAST urgent MxGateway/computed alarms. - AlarmPriorityBands: the OtOpcUa GalaxyAlarmPriority table (lmxopcua#887, b61f3e05), value for value: 1-250 -> 1000, 251-500 -> 750, 501-750 -> 500, 751-999 -> 250; <= 0 clamps to Critical, > 999 to Low. - MxGatewayAlarmMapper bands the gateway severity (= AVEVA priority); AlarmConditionStateFactory.ForComputed bands PriorityLevel. OPC UA unchanged. - AlarmConditionState gains trailing Priority (int?): the raw source number, exactly the pre-#129 Severity. AlarmStateChanged.Priority and the wire AlarmStateUpdate.priority keep that meaning (no proto change); central derives Severity by kind (SeverityFromPriority), so an older site decodes correctly. - ScriptAlarm gains trailing Priority. The native MES 900-999 band and the MES API Severity/MinSeverity/MaxSeverity key off Priority; rig seed scripts moved from a.Severity to a.Priority, so MES output is unchanged. - AlarmActor raise logs Error when the banded severity >= 700 (same threshold as NativeAlarmActor): priority 1-500 Error, 501+ Warning (was raw >= 700). - NativeAlarmActor upgrades pre-#129 native_alarm_state rows on rehydrate. - Debug snapshot decode restores Condition.Priority from the row's priority. - Docs: Commons, DCL, SiteRuntime, Communication, CentralUI, InboundAPI, HighLevelReqs, MES alarm-status plan, CLAUDE.md. Claude-Session: https://claude.ai/code/session_01GT67ACmpMR7b9LGRPLijMi
This commit is contained in:
@@ -121,8 +121,9 @@ public class AlarmActorTests : TestKit, IDisposable
|
||||
|
||||
var msg = instanceProbe.ExpectMsg<AlarmStateChanged>(TimeSpan.FromSeconds(5));
|
||||
Assert.Equal(AlarmKind.Computed, msg.Kind); // computed origin
|
||||
Assert.Equal(msg.Priority, msg.Condition.Severity); // severity tracks priority
|
||||
Assert.Equal(700, msg.Condition.Severity);
|
||||
Assert.Equal(700, msg.Priority); // raw PriorityLevel on the record
|
||||
Assert.Equal(700, msg.Condition.Priority); // ...and on the condition (#129)
|
||||
Assert.Equal(500, msg.Condition.Severity); // banded: 501–750 = Medium → 500
|
||||
Assert.True(msg.Condition.Active); // active alarm → condition active
|
||||
Assert.True(msg.Condition.Acknowledged); // computed alarms are auto-acked
|
||||
Assert.Equal(string.Empty, msg.SourceReference); // no native source reference
|
||||
@@ -935,7 +936,7 @@ public class AlarmActorTests : TestKit, IDisposable
|
||||
CanonicalName = "HighTemp",
|
||||
TriggerType = "ValueMatch",
|
||||
TriggerConfiguration = "{\"attributeName\":\"Status\",\"matchValue\":\"Critical\"}",
|
||||
PriorityLevel = 800
|
||||
PriorityLevel = 100
|
||||
};
|
||||
|
||||
var instanceProbe = CreateTestProbe();
|
||||
@@ -954,7 +955,7 @@ public class AlarmActorTests : TestKit, IDisposable
|
||||
var rows = siteLog.OfType("alarm");
|
||||
Assert.Single(rows);
|
||||
var row = rows[0];
|
||||
Assert.Equal("Error", row.Severity); // priority 800 → Error
|
||||
Assert.Equal("Error", row.Severity); // priority 100 = AVEVA Critical → Error (#129)
|
||||
Assert.Equal("Pump1", row.InstanceId);
|
||||
Assert.Equal("AlarmActor:HighTemp", row.Source);
|
||||
}, TimeSpan.FromSeconds(2));
|
||||
@@ -972,7 +973,7 @@ public class AlarmActorTests : TestKit, IDisposable
|
||||
CanonicalName = "MinorTemp",
|
||||
TriggerType = "ValueMatch",
|
||||
TriggerConfiguration = "{\"attributeName\":\"Status\",\"matchValue\":\"Warn\"}",
|
||||
PriorityLevel = 100
|
||||
PriorityLevel = 800
|
||||
};
|
||||
|
||||
var instanceProbe = CreateTestProbe();
|
||||
@@ -989,7 +990,7 @@ public class AlarmActorTests : TestKit, IDisposable
|
||||
{
|
||||
var rows = siteLog.OfType("alarm");
|
||||
Assert.Single(rows);
|
||||
Assert.Equal("Warning", rows[0].Severity); // priority 100 → Warning
|
||||
Assert.Equal("Warning", rows[0].Severity); // priority 800 = AVEVA Low → Warning (#129)
|
||||
}, TimeSpan.FromSeconds(2));
|
||||
}
|
||||
|
||||
@@ -1005,7 +1006,7 @@ public class AlarmActorTests : TestKit, IDisposable
|
||||
CanonicalName = "HighTemp",
|
||||
TriggerType = "ValueMatch",
|
||||
TriggerConfiguration = "{\"attributeName\":\"Status\",\"matchValue\":\"Critical\"}",
|
||||
PriorityLevel = 800
|
||||
PriorityLevel = 100
|
||||
};
|
||||
|
||||
var instanceProbe = CreateTestProbe();
|
||||
@@ -1030,6 +1031,22 @@ public class AlarmActorTests : TestKit, IDisposable
|
||||
}, TimeSpan.FromSeconds(2));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gitea #129: a computed raise's event-log severity follows the priority banded onto the unified
|
||||
/// Severity (lower priority = more urgent), with the same 700 threshold NativeAlarmActor uses.
|
||||
/// </summary>
|
||||
[Theory]
|
||||
[InlineData(0, "Error")]
|
||||
[InlineData(1, "Error")]
|
||||
[InlineData(250, "Error")]
|
||||
[InlineData(500, "Error")]
|
||||
[InlineData(501, "Warning")]
|
||||
[InlineData(700, "Warning")]
|
||||
[InlineData(999, "Warning")]
|
||||
[InlineData(1000, "Warning")]
|
||||
public void RaiseSeverity_FollowsTheBandedPriority(int priority, string expected) =>
|
||||
Assert.Equal(expected, AlarmActor.RaiseSeverity(priority));
|
||||
|
||||
/// <summary>Verifies that a malformed trigger configuration does not crash the alarm actor.</summary>
|
||||
[Fact]
|
||||
public void AlarmActor_MalformedTriggerConfig_DoesNotCrash()
|
||||
|
||||
Reference in New Issue
Block a user