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:
@@ -68,6 +68,10 @@ print(next((str(c["id"]) for c in (t.get(coll) or []) if c.get("name")==name), "
|
||||
# (AlarmConditionStateFactory.ForComputed) — there is no ack-back for them — so StatusCode
|
||||
# reads "Triggered.Acked" and AckDT is null on this demo. Native (mirrored) conditions are
|
||||
# where the ack fields carry real source data.
|
||||
# MES `Severity` / `MinSeverity` / `MaxSeverity` are the raw 0-999 priority, read from
|
||||
# `ScriptAlarm.Priority` — NOT `ScriptAlarm.Severity`, which since Gitea #129 is the banded,
|
||||
# higher-is-more-urgent severity (priority 1-250 -> 1000 ... 751-999 -> 250). Priority keeps the
|
||||
# value Severity carried before #129, so MES sees exactly the same numbers and filters as before.
|
||||
read -r -d '' SITE_SCRIPT_CODE <<'CS' || true
|
||||
var code = Parameters["MachineCode"]?.ToString() ?? "";
|
||||
var flaggedOnly = Parameters.Get<bool?>("FlaggedOnly") ?? false;
|
||||
@@ -79,8 +83,8 @@ try {
|
||||
var alarms = flaggedOnly ? await Alarms.MesReportableAsync() : await Alarms.CurrentAsync();
|
||||
var infos = alarms
|
||||
.Where(a => a.Active && !a.IsConfiguredPlaceholder)
|
||||
.Where(a => minSev == null || a.Severity >= minSev)
|
||||
.Where(a => maxSev == null || a.Severity <= maxSev)
|
||||
.Where(a => minSev == null || a.Priority >= minSev)
|
||||
.Where(a => maxSev == null || a.Priority <= maxSev)
|
||||
.Where(a => string.IsNullOrEmpty(nameFilter) || a.Name.Contains(nameFilter, StringComparison.OrdinalIgnoreCase))
|
||||
.Where(a => includeAck || !a.Acknowledged)
|
||||
.Select(a => new {
|
||||
@@ -88,7 +92,7 @@ try {
|
||||
HierarchicalName = code + "." + a.Name,
|
||||
Description = string.IsNullOrEmpty(a.Message) ? a.AlarmTypeName : a.Message,
|
||||
IsFlaggedForMES = a.IsMesReportable,
|
||||
Severity = a.Severity,
|
||||
Severity = a.Priority, // MES Severity = the raw 0-999 priority (ScriptAlarm.Priority, #129)
|
||||
StatusCode = a.Acknowledged ? "Triggered.Acked" : "Triggered",
|
||||
TriggeredDT = (a.OriginalRaiseTime ?? a.Timestamp).ToString("o"),
|
||||
AckDT = a.AckTime?.ToString("o"),
|
||||
|
||||
@@ -302,6 +302,10 @@ CS
|
||||
# The MES alarm-status projection (same as docker/seed-mes-alarm-demo.sh). Computed alarms report
|
||||
# Acknowledged=true / AckTime=null by construction, so StatusCode reads "Triggered.Acked" and
|
||||
# IncludeAcked=false drops every computed alarm (it only bites on mirrored native conditions).
|
||||
# MES `Severity` / `MinSeverity` / `MaxSeverity` are the raw 0-999 priority, read from
|
||||
# `ScriptAlarm.Priority` — NOT `ScriptAlarm.Severity`, which since Gitea #129 is the banded,
|
||||
# higher-is-more-urgent severity (priority 1-250 -> 1000 ... 751-999 -> 250). Priority keeps the
|
||||
# value Severity carried before #129, so MES sees exactly the same numbers and filters as before.
|
||||
read -r -d '' ALARM_CODE <<'CS' || true
|
||||
var code = Parameters["MachineCode"]?.ToString() ?? "";
|
||||
var flaggedOnly = Parameters.Get<bool?>("FlaggedOnly") ?? false;
|
||||
@@ -313,8 +317,8 @@ try {
|
||||
var alarms = flaggedOnly ? await Alarms.MesReportableAsync() : await Alarms.CurrentAsync();
|
||||
var infos = alarms
|
||||
.Where(a => a.Active && !a.IsConfiguredPlaceholder)
|
||||
.Where(a => minSev == null || a.Severity >= minSev)
|
||||
.Where(a => maxSev == null || a.Severity <= maxSev)
|
||||
.Where(a => minSev == null || a.Priority >= minSev)
|
||||
.Where(a => maxSev == null || a.Priority <= maxSev)
|
||||
.Where(a => string.IsNullOrEmpty(nameFilter) || a.Name.Contains(nameFilter, StringComparison.OrdinalIgnoreCase))
|
||||
.Where(a => includeAck || !a.Acknowledged)
|
||||
.Select(a => new {
|
||||
@@ -322,7 +326,7 @@ try {
|
||||
HierarchicalName = code + "." + a.Name,
|
||||
Description = !string.IsNullOrEmpty(a.Message) ? a.Message : !string.IsNullOrEmpty(a.AlarmTypeName) ? a.AlarmTypeName : a.Name,
|
||||
IsFlaggedForMES = a.IsMesReportable,
|
||||
Severity = a.Severity,
|
||||
Severity = a.Priority, // MES Severity = the raw 0-999 priority (ScriptAlarm.Priority, #129)
|
||||
StatusCode = a.Acknowledged ? "Triggered.Acked" : "Triggered",
|
||||
TriggeredDT = (a.OriginalRaiseTime ?? a.Timestamp).ToString("o"),
|
||||
AckDT = a.AckTime?.ToString("o"),
|
||||
|
||||
Reference in New Issue
Block a user