PLCnext API Documentation 25.0.2.69
Public Types | 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 Types

using Mutex = Arp::System::Commons::Threading::Mutex
 

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 AcknowledgeWithComment (const String &alarmId, const String &comment="", const String &language="", const String &user="")
 A client can ask for acknowledgement of an alarm instance (if supported by an alarm). More...
 
int32 Confirm (const String &alarmId)
 
int32 ConfirmWithComment (const String &alarmId, const String &comment="", const String &language="", const String &user="")
 
int32 AddComment (const String &alarmId, const String &comment, const String &language="", const String &user="")
 
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 that 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 that supports confirmable alarms should subscribe to confirm request by a client. More...
 
int32 SubscribeAddComment (std::function< void(const String &alarmId, const String &comment, const String &language, const String &user)> handler)
 An alarm source that supports acknowledgeble or confirmable alarms should subscribe to add comment 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)
{
//...
});
This class represents the Arp String. The implementation is based on std::string.
Definition: String.hpp:39

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).

Parameters
alarmIdunique Id of the alarm as specified during NewAlarmState.
Returns
0 if successful, -1 if not initialized, -2 if empty alarmId

◆ AcknowledgeWithComment()

int32 Arp::System::NmPayload::Alarms::AlarmAccess::AcknowledgeWithComment ( const String alarmId,
const String comment = "",
const String language = "",
const String user = "" 
)

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

Parameters
alarmIdunique Id of the alarm as specified during NewAlarmState.
commentoptional user comment for the acknowledgement.
languageoptional language of the user comment.
useroptional user that provided the comment.
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).

Parameters
alarmStatealarm structure with fields for the alarm. 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

◆ AddComment()

int32 Arp::System::NmPayload::Alarms::AlarmAccess::AddComment ( const String alarmId,
const String comment,
const String language = "",
const String user = "" 
)

A client can add a comment to an alarm instance (if supported by an alarm).

Parameters
alarmIdunique Id of the alarm as specified during NewAlarmState.
commentuser comment for the acknowledgement / confirmation.
languageoptional language of the user comment.
useroptional user that provided the comment.
Returns
0 if successful, -1 if not initialized, -2 if empty alarmId

◆ 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).

Parameters
alarmIdunique Id of the alarm as specified during NewAlarmState.
Returns
0 if successful, -1 if not initialized, -2 if empty alarmId

◆ ConfirmWithComment()

int32 Arp::System::NmPayload::Alarms::AlarmAccess::ConfirmWithComment ( const String alarmId,
const String comment = "",
const String language = "",
const String user = "" 
)

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

Parameters
alarmIdunique Id of the alarm as specified during NewAlarmState.
commentoptional user comment for the confirmation.
languageoptional language of the user comment.
useroptional user that provided the comment.
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.

Parameters
alarmStatealarm structure with fields for the updated state of the alarm.
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 that 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!

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

◆ SubscribeAddComment()

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

An alarm source that supports acknowledgeble or confirmable alarms should subscribe to add comment 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!

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 that 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!

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 files: