PLCnext API Documentation  20.3.1.28622
Public Member Functions | List of all members
Arp::System::NmPayload::Alarms::AlarmAccess Class Reference

Access class for the alarm server component. More...

#include <AlarmAccess.hpp>

Public Member Functions

 AlarmAccess (const AlarmAccess &arg)=delete
 
AlarmAccessoperator= (const AlarmAccess &arg)=delete
 
int32 Init (String alarmClientId)
 Initialize the class. More...
 
void Dispose ()
 Diposes all resources of this instance.
 
int32 AddAlarm (AlarmState &alarmState)
 Announce a new alarm to the server (used for browsing in OPC UA). More...
 
int32 NewAlarmState (AlarmState &alarmState)
 Inform the AlarmServer about a new alarm state (comming alarms, going alarms / changes to sub states). More...
 
int32 Acknowledge (const String &alarmId)
 A client can ask for acknowledgement of an alarm instance (if supported by an alarm). More...
 
int32 Confirm (const String &alarmId)
 
int32 SubscribeAddAlarm (std::function< void(const AlarmState &alarmState)> handler)
 A client can subscribe to AddAlarm calls (used e.g. by the OPC-UA Server to show the alarms in the address space). More...
 
int32 SubscribeNewAlarmState (std::function< void(const AlarmState &alarmState)> handler)
 A client can subscribe to NewAlarmState calls to track the state of alarms. More...
 
int32 SubscribeAcknowledge (std::function< void(const String &alarmId, const String &comment, const String &language, const String &user)> handler)
 An alarm source the supports acknowledgeble alarms should subscribe to acknowledge request by a client. More...
 
int32 SubscribeConfirm (std::function< void(const String &alarmId, const String &comment, const String &language, const String &user)> handler)
 An alarm source the supports confirmable alarms should subscribe to confirm request by a client. More...
 

Detailed Description

Access class for the alarm server component.

Instances of this class can be used to connect alarm sources and alarm clients with the alarm server.

The alarm server routes the calls between the instances of the AlarmAccess instances (also cross process) in an asynchronous manner.

The calls the AlarmAccess are non blocking calls and can be called in a realtime process.

Note: The callback functions are executed in a different thread. Thread safety is task of the client code.

Error handling is done via return codes instead of exceptions so that it can safely be used within the realtime app.

Example of subscribing to messages:

alarmAccess.SubscribeAcknowledge([](const Arp::String& alarmId, const Arp::String& comment, const Arp::String& language, const Arp::String& user)
{
//...
});

Member Function Documentation

◆ Acknowledge()

int32 Arp::System::NmPayload::Alarms::AlarmAccess::Acknowledge ( const String alarmId)

A client can ask for acknowledgement of an alarm instance (if supported by an alarm).

Returns
0 if successful, -1 if not initialized, -2 if empty alarmId

◆ AddAlarm()

int32 Arp::System::NmPayload::Alarms::AlarmAccess::AddAlarm ( AlarmState alarmState)

Announce a new alarm to the server (used for browsing in OPC UA).

The following fileds are used:

  • alarmId is a unique name of the alarm instance on the server
  • alarmType is a name of the subtype of DiscreteAlarmType that is generated as a result of this method call
  • severity is a number between 1 and 1000 where 1 is informative and 1000 is a fatal error
  • the user parameters with name and type are mapped to variables of the new AlarmType
    Returns
    0 if successful, -1 if not initialized, -2 if empty string parameters

◆ Confirm()

int32 Arp::System::NmPayload::Alarms::AlarmAccess::Confirm ( const String alarmId)

A client can ask for confirmation of an alarm instance (if supported by an alarm).

Returns
0 if successful, -1 if not initialized, -2 if empty alarmId

◆ Init()

int32 Arp::System::NmPayload::Alarms::AlarmAccess::Init ( String  alarmClientId)

Initialize the class.

Note: This class need to be initialized during startup of the Component.

Parameters
alarmClientIdmust be a unique name of this AlarmAccess instance within the PLCnext instance.
Returns
0 if successful.

◆ NewAlarmState()

int32 Arp::System::NmPayload::Alarms::AlarmAccess::NewAlarmState ( AlarmState alarmState)

Inform the AlarmServer about a new alarm state (comming alarms, going alarms / changes to sub states).

An alarm source can inform about state changes of its alarms. Only the source should call this methods for its alarms.

Returns
0 if successful, -1 if not initialized, -2 if empty alarmId

◆ SubscribeAcknowledge()

int32 Arp::System::NmPayload::Alarms::AlarmAccess::SubscribeAcknowledge ( std::function< void(const String &alarmId, const String &comment, const String &language, const String &user)>  handler)

An alarm source the supports acknowledgeble alarms should subscribe to acknowledge request by a client.

This method can only be used during startup of the Component.

As a result to a call of the handler function the alarm source might change the state of the alarm and call NewAlarmState agein.

Note: The provided handler function is called by a different thread!

Note: comment, language and user is not supported in this version.

Returns
0 if successful, -1 if not initialized, -2 no handler function

◆ SubscribeAddAlarm()

int32 Arp::System::NmPayload::Alarms::AlarmAccess::SubscribeAddAlarm ( std::function< void(const AlarmState &alarmState)>  handler)

A client can subscribe to AddAlarm calls (used e.g. by the OPC-UA Server to show the alarms in the address space).

This method can only be used during startup of the Component.

Note: The provided handler function is called by a different thread!

Returns
0 if successful, -1 if not initialized, -2 no handler function

◆ SubscribeConfirm()

int32 Arp::System::NmPayload::Alarms::AlarmAccess::SubscribeConfirm ( std::function< void(const String &alarmId, const String &comment, const String &language, const String &user)>  handler)

An alarm source the supports confirmable alarms should subscribe to confirm request by a client.

This method can only be used during startup of the Component.

As a result to a call of the handler function the alarm source might change the state of the alarm and call NewAlarmState agein.

Note: The provided handler function is called by a different thread!

Note: comment, language and user is not supported in this version.

Returns
0 if successful, -1 if not initialized, -2 no handler function

◆ SubscribeNewAlarmState()

int32 Arp::System::NmPayload::Alarms::AlarmAccess::SubscribeNewAlarmState ( std::function< void(const AlarmState &alarmState)>  handler)

A client can subscribe to NewAlarmState calls to track the state of alarms.

This method can only be used during startup of the Component.

Note: The provided handler function is called by a different thread!

Returns
0 if successful, -1 if not initialized, -2 no handler function

The documentation for this class was generated from the following file: