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 and select .
Prerequisites
Set the default external code editor. See Set the default code editor.
- In theProject viewpane, right-clickAlarmGridPaneand select .
- Hover-over the NetLogic, select , and enterAlarmsGridNetLogic
- Double-click the NetLogic.The external code editor opens.
- 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(); RegisterObserverOnSessionLocaleIdChanged(alarmsDatagrid.Context); } 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; }
- Save the code.
Provide Feedback