Skip to main content

Using Events and Alarms

The CODESYS OPC UA Server provides the capability of sending standard OPC UA events and mapping alarms in a simplified form.

Caution

In CODESYS Communication version 4.6.0.0 (and higher) and CODESYS Development System version 3.5.21.0 (and higher), the ACK_REP acknowledgment method complies with the OPC UA standard.

All other acknowledgment methods do not meet the requirements of the OPC UA specification. In these cases, the state machines in particular are different and no comments can be assigned. The mapping of these alarms is used to provide the possibility of basic interaction between an OPC UA Client and the alarm management.

For more information about alarm management and alarm visualization, see the following: Alarm Management and Alarm Visualization

Creating alarms and events

  1. Create a new project with a CODESYS Control Win controller.

  2. Insert an Alarm configuration object below the application.

  3. Add the library CmpOPCUAProviderAlarmConfiguration to the Library Manager.

    In CODESYS Development System version 3.5.21.0 and higher, the CompatibleAlarmManagerToOpcUaConnector library must be integrated instead of the CmpOPCUAProviderAlarmConfiguration library.

    When the library is added, it connects automatically as a client to the alarm configuration and sends the events to the OPC UA Server.

  4. Insert a Symbol Configuration object below the application.

  5. Insert a Visualization object below the Application.

  6. Download the project to the controller and start it.

Alarms are used and generated normally. No special steps are required here.

Implementing event calls in the IEC code

If you want to create events, then the following additional steps are required.

  1. Insert an AlarmClass object below the Alarm Configuration. Specify a name (example: Event).

    The new alarm class opens in the editor.

  2. Select the acknowledgment method REP.

  3. Insert an Alarm Group object below the Alarm Configuration. Specify a name (example: ApplicationEvent).

    The new alarm group opens in the editor.

  4. . Change the following parameters:
    • Observation type: Event

    • Class: Event

    • Message: "Message 1"

  5. In a program (for example, POU PLC_PRG), add a program call for triggering the event alarm.

Call in code

AlarmManager.AlarmGlobals.g_AlarmHandler.RaiseEvent(Alm_AlarmConfiguration_Alarmgroup_IDs.ID_ApplicationEvent, Alm_ApplicationEvent_Alarm_IDs.ID_0);

Monitoring an event via the UaExpert OPC UA Client

This is how you observe and monitor occurring events via an OPC UA connection on the UaExpert client.

  1. Start the UaExpert program.

  2. Click the Server → Add command.

    The Add Server dialog opens.

  3. In the tree view, expand Local → OPCUAServer@.

  4. Select the connection type None and click OK to close the dialog.

  5. Click the Server → Connect command.

    An object tree is displayed in the Address Space view.

  6. Click the Documents → Add command.

    The Add Document dialog opens.

  7. Select the Event View as the "Document Type".

    The Event View tab opens.

  8. In the Address Space view, expand the Objects → DeviceSet CODESYSCODESYS Control Win object.

  9. In Address Space, select the "CODESYS Control Win V3" object and drag it to the Event View.

    The events are displayed.

    _cds_img_uaexpert_3.png