.NET Based OPC UA Client/Server SDK
3.1.3.516
|
In this example we extend the ControllerType defined in Lesson 2 by adding an instance of an alarm: We add a new Object called StateCondition having the TypeDefinition OffNodemalAlarmType (see Figure 6.1).
Open the UaModeler project created in Lesson 2. Add a new Object called “StateCondition” as a child of ControllerType and choose “OffNormalAlarmType” as TypeDefinition (see Figure 6.2).
Then regenerate the source files, export the model as xml file and replace the files BAIdentifiers.cs and buildingautomation.xml in your project.
After adding the controller object, we create an instance of the OffNormalAlarmModel. This class is used to store all data related to the OffNormalAlarmType. With LinkModelToNode the SDK maps the data defined in the instance to the nodes in the address space.
We change the state of the alarm in the BlockStateChanged EventHandler.
Finally, we have to add handling for Acknowledge calls by clients. Therefore, we need to override the Acknowledge method defined at the BaseNodeManager.
To test the alarm, open a new Event View in UaExpert and change to the “Alarms” tab (see Figure 6.3). The alarm can be triggered by calling the methods “Start” and “Stop”. Right click on an Alarm to acknowledge, confirm, or add a comment.