Develop an alarm grid NetLogic

Create a NetLogic that populates the alarm grid.
TIP: You can use a preconfigured alarm grid instead of creating it from scratch. For more information, select
Template Libraries
Template Libraries
and select
Widgets
Alarm Grid
.
Prerequisites
Set the default external code editor. See Set the default code editor.
  1. In the pane, right-click
    AlarmGridPane
    and select
    New
    Runtime NetLogic
    .
  2. Hover-over the NetLogic, select
    Edit
    Edit
    , and enter
    AlarmsGridNetLogic
  3. Double-click the NetLogic.
    The external code editor opens.
  4. Replace the existing code with the following code:
    #region StandardUsing using System; using FTOptix.Core; using FTOptix.CoreBase; using FTOptix.HMIProject; using UAManagedCore; using OpcUa = UAManagedCore.OpcUa; using FTOptix.NetLogic; using FTOptix.OPCUAServer; using FTOptix.UI; using FTOptix.Alarm; #endregion public class AlarmsGridNetLogic : FTOptix.NetLogic.BaseNetLogic { public override void Start() { alarmsDatagrid = Owner.Children.Get<DataGrid>("AlarmsGrid"); alarmsDatagridModel = alarmsDatagrid.Children.GetVariable("Model"); affinityId = alarmsDatagrid.Context.AssignAffinityId(); try { RegisterObserverOnSessionLocaleIdChanged(alarmsDatagrid.Context); } catch (NullReferenceException){} } public override void Stop() { if (localeIdsRegistration != null) { localeIdsRegistration.Dispose(); localeIdsRegistration = null; } if (localeIdChangedObserver != null) localeIdChangedObserver = null; } public void RegisterObserverOnSessionLocaleIdChanged(IContext context) { var currentSessionLocaleIds = context.Sessions.CurrentSessionInfo.SessionObject.Children["ActualLocaleIds"]; localeIdChangedObserver = new CallbackVariableChangeObserver((IUAVariable variable, UAValue newValue, UAValue oldValue, uint[] _, ulong __) => { //reset datagrid model variable to trigger locale changed event var dynamicLink = alarmsDatagridModel.GetVariable("DynamicLink"); if (dynamicLink == null) return; string dynamicLinkValue = dynamicLink.Value; dynamicLink.Value = string.Empty; dynamicLink.Value = dynamicLinkValue; }); localeIdsRegistration = currentSessionLocaleIds.RegisterEventObserver( localeIdChangedObserver, EventType.VariableValueChanged, affinityId); } IEventRegistration localeIdsRegistration; IEventObserver localeIdChangedObserver; uint affinityId; DataGrid alarmsDatagrid; IUAVariable alarmsDatagridModel; }
  5. Save the code.
Provide Feedback
Have questions or feedback about this documentation? Please submit your feedback here.