@page "/scripted-alarms" @attribute [Microsoft.AspNetCore.Authorization.Authorize] @rendermode RenderMode.InteractiveServer @using Microsoft.AspNetCore.Components.Web @using ZB.MOM.WW.OtOpcUa.Admin.Services @using ZB.MOM.WW.OtOpcUa.Configuration.Entities @using ZB.MOM.WW.OtOpcUa.Configuration.Enums @inject ScriptedAlarmService AlarmSvc @inject GenerationService GenerationSvc @inject ClusterService ClusterSvc @inject NavigationManager Nav

Scripted Alarms

OPC UA Part 9 alarms raised by C# predicate scripts. To author scripted alarms, open a cluster draft and use the Scripted Alarms tab in the draft editor. This view lists all scripted alarms across clusters and generations for reference.

@if (_alarms is not null) { @_alarms.Count alarm@(_alarms.Count == 1 ? "" : "s") }
@if (_loading) {

Loading…

} else if (_alarms is null || _alarms.Count == 0) {
No scripted alarms found for the selected filter. Open a cluster draft and use the Scripted Alarms tab to author scripted alarms.
} else {
Scripted alarms
@foreach (var a in _alarms) { }
Name Equipment Type Severity Message template Predicate script Historize Retain Enabled Generation
@a.Name @a.EquipmentId @a.AlarmType @a.Severity @SeverityBand(a.Severity) @a.MessageTemplate @a.PredicateScriptId @if (a.HistorizeToAveva) { Aveva } else { } @if (a.Retain) { yes } else { } @if (a.Enabled) { enabled } else { disabled } @a.GenerationId @if (DraftLink(a.GenerationId) is { } link) { Edit draft }
} @code { private List _clusters = []; private List _generations = []; private List? _alarms; private string _filterClusterId = string.Empty; private long _filterGenerationId; private bool _loading; private Dictionary _genMap = []; protected override async Task OnInitializedAsync() { _clusters = await ClusterSvc.ListAsync(CancellationToken.None); await LoadAlarmsAsync(); } private async Task OnClusterChangedAsync() { _filterGenerationId = 0; _generations = string.IsNullOrEmpty(_filterClusterId) ? [] : await GenerationSvc.ListRecentAsync(_filterClusterId, 20, CancellationToken.None); await LoadAlarmsAsync(); } private async Task LoadAlarmsAsync() { _loading = true; _alarms = null; try { var all = new List(); _genMap = []; IEnumerable gens; if (!string.IsNullOrEmpty(_filterClusterId) && _filterGenerationId != 0) { gens = _generations.Where(g => g.GenerationId == _filterGenerationId); } else if (!string.IsNullOrEmpty(_filterClusterId)) { gens = await GenerationSvc.ListRecentAsync(_filterClusterId, 20, CancellationToken.None); _generations = gens.ToList(); } else { var allGens = new List(); foreach (var c in _clusters) { var cGens = await GenerationSvc.ListRecentAsync(c.ClusterId, 5, CancellationToken.None); allGens.AddRange(cGens); } gens = allGens; } foreach (var g in gens) { _genMap[g.GenerationId] = (g.ClusterId, g.Status == GenerationStatus.Draft); var alarms = await AlarmSvc.ListAsync(g.GenerationId, CancellationToken.None); all.AddRange(alarms); } _alarms = all; } finally { _loading = false; } } private string? DraftLink(long generationId) { if (_genMap.TryGetValue(generationId, out var info) && info.isDraft) return $"/clusters/{info.clusterId}/draft/{generationId}"; return null; } private static string SeverityBand(int s) => s switch { <= 250 => "(Low)", <= 500 => "(Medium)", <= 750 => "(High)", _ => "(Critical)", }; }