Access to alarms and events
When subscribing to the object and receiving alarms or events, a client must take into account that special object types are used. The respective types are defined as follows:
TcEventLoggerEventType
The TcEventLoggerEventType is derived from the BaseEventType and extends it with TwinCAT EventLogger-specific properties:
NodeID: i=4200
NamespaceName: urn:BeckhoffAutomation:Ua:Types:GlobalTypes
TcEventLoggerAlarmConditionType
The TcEventLoggerAlarmConditionType is derived from the AlarmConditionType and extends it with TwinCAT EventLogger-specific properties:
NodeID: i=4000
NamespaceName: urn:BeckhoffAutomation:Ua:Types:GlobalTypes
Sample
The following sample is based on the standard code sample of the TwinCAT EventLogger, which can be obtained from the Beckhoff Information System. This sample contains code snippets for the PLC, which can be used to fire an event as well as an alarm.
Step 1: Configuration of the server
TwinCAT OPC UA Server and the PLC are now running locally on the same system in this sample. Accordingly, the TcEventLogConfig.xml was also created:
<TcUaEventLogConfig>
<EventLoggerDevice Name="LocalEventLogger" AmsAddr="127.0.0.1.1.1"/>
</TcUaEventLogConfig>
Step 2: Activating the TwinCAT EventLogger sample
Before enabling the TwinCAT EventLogger sample, we first disabled the automatic firing of an event or alarm. In the present sample version this is done by initializing bSend and bAlmRaise with the value FALSE. The project is then activated and executed in the local PLC runtime.
Step 3: Connecting an OPC UA Client to the Server
The UA Expert was selected as the OPC UA client. After establishing a connection with the server, you now add a new "Event View" document in UA Expert. Then drag and drop the configured TwinCAT EventLogger device into the Event View.
In order to receive the TwinCAT EventLogger-specific properties, the UA Expert must filter the corresponding Event or AlarmType. You can find the TcEventLoggerEventType or TcEventLoggerAlarmConditionType in the type list of the Event View. Sample:
By clicking on the Apply button, these filters are applied.
Step 4: Firing an event
In the TwinCAT EventLogger Sample, we set the variable bSend to the value TRUE in order to fire an event. The UA Expert receives this event automatically and displays it in the Event View together with the TwinCAT EventLogger-specific properties.
Step 5: Firing an alarm
In the TwinCAT EventLogger sample, we set the variable bAlmRaise to the value TRUE in order to fire an alarm. The UA Expert receives this alarm automatically and displays it in the Event View together with the TwinCAT EventLogger-specific properties. In addition, the alarm is displayed as a separate object in the namespace below the EventLogger device.
Step 6: Acknowledging an alarm
In addition to receiving an alarm, it can also be acknowledged. The acknowledgement is also reported by the server to the TwinCAT EventLogger. In UA Expert, an alarm can be acknowledged via the context menu in the Event View.
Acknowledge and Confirm Please note that only a Confirm is reported back to the TwinCAT EventLogger. The information about an acknowledge remains in the server, since the TwinCAT EventLogger currently only provides for the concept of a Confirm. |
After a Confirm the corresponding variable eConfirmationState is set in the TwinCAT EventLogger instance of type FB_TcAlarm.