S2OPC OPCUA Toolkit
Loading...
Searching...
No Matches
sopc_event.h File Reference

Interface to manipulate and customize OPC UA event instances. More...

#include "sopc_types.h"

Go to the source code of this file.

Typedefs

typedef struct _SOPC_Event SOPC_Event
 The abstract structure type for an OpcUa event instance that might be triggered from nodes.
 
typedef void SOPC_Event_ForEachVar_Fct(const char *qnPath, SOPC_Variant *var, const SOPC_NodeId *dataType, int32_t valueRank, uintptr_t user_data)
 Type of callback functions for SOPC_Event. The value of user_data is set when calling SOPC_Event_ForEachVar.
 

Functions

void SOPC_Event_Clear (SOPC_Event *pEvent)
 Clears the content of an Event.
 
void SOPC_Event_Delete (SOPC_Event **ppEvent)
 Deletes the content of an Event.
 
SOPC_EventSOPC_Event_CreateCopy (const SOPC_Event *pEvent, bool genNewId)
 Copies the provided event in a newly created event.
 
const SOPC_NodeIdSOPC_Event_GetEventTypeId (const SOPC_Event *pEvent)
 Get the EventTypeId for the given event.
 
SOPC_ReturnStatus SOPC_Event_SetEventId (SOPC_Event *pEvent, const SOPC_ByteString *pEventId)
 Sets the given EventId for the given event.
 
SOPC_ReturnStatus SOPC_Event_SetSourceName (SOPC_Event *pEvent, const SOPC_String *pSourceName)
 Sets the given SourceName for the given event indicating the name of the event source.
 
SOPC_ReturnStatus SOPC_Event_SetSourceNode (SOPC_Event *pEvent, const SOPC_NodeId *pSourceNode)
 Sets the given SourceNode for the given event indicating the node of the event source.
 
SOPC_DateTime SOPC_Event_GetTime (const SOPC_Event *pEvent)
 Get the Time for the given event.
 
SOPC_ReturnStatus SOPC_Event_SetTime (SOPC_Event *pEvent, SOPC_DateTime time)
 Sets the given Time for the given event indicating the time the event occurred.
 
SOPC_ReturnStatus SOPC_Event_SetReceiveTime (SOPC_Event *pEvent, SOPC_DateTime receiveTime)
 (Internal purpose only) Sets the given ReceiveTime for the given event indicating the time the event was received by server (time it is triggered).
 
SOPC_ReturnStatus SOPC_Event_SetLocalTime (SOPC_Event *pEvent, const OpcUa_TimeZoneDataType *pLocalTime)
 Sets the given LocalTime for the given event indicating the Offset and the DaylightSavingInOffset of the event.
 
SOPC_ReturnStatus SOPC_Event_SetMessage (SOPC_Event *pEvent, const SOPC_LocalizedText *pMessage)
 Sets the given Message for the given event indicating a human-readable and localizable text description of the event.
 
SOPC_ReturnStatus SOPC_Event_SetSeverity (SOPC_Event *pEvent, uint16_t severity)
 Sets the given Severity for the given event indicating the urgency of the event.
 
SOPC_ReturnStatus SOPC_Event_SetVariable (SOPC_Event *pEvent, uint16_t nbQnPath, SOPC_QualifiedName *qualifiedNamePathArray, const SOPC_Variant *var)
 Sets the given variable value for the given browse path in the given event.
 
SOPC_ReturnStatus SOPC_Event_SetVariableFromStrPath (SOPC_Event *pEvent, const char *qnPath, const SOPC_Variant *var)
 Sets the given variable value for the given browse path (as a string) in the given event.
 
const SOPC_VariantSOPC_Event_GetVariableFromStrPath (const SOPC_Event *pEvent, const char *qnPath)
 Gets the variable value for the given browse path (as a string) in the given event.
 
const SOPC_VariantSOPC_Event_GetVariableAndType (const SOPC_Event *pEvent, uint16_t nbQnPath, SOPC_QualifiedName *qualifiedNamePathArray, const SOPC_NodeId **outDataType, int32_t *outValueRank)
 Gets the variable value and type information for the given browse path in the given event.
 
const SOPC_VariantSOPC_Event_GetVariableAndTypeFromStrPath (const SOPC_Event *pEvent, const char *qnPath, const SOPC_NodeId **outDataType, int32_t *outValueRank)
 Gets the variable value and type information for the given browse path (as a string) in the given event.
 
void SOPC_Event_ForEachVar (SOPC_Event *event, SOPC_Event_ForEachVar_Fct *func, uintptr_t user_data)
 Iterates over the event variables, calling the given function for each event variable.
 

Detailed Description

Interface to manipulate and customize OPC UA event instances.

  The initial instance should be created using ::SOPC_ServerHelper_CreateEvent
  using an existing event type id in the configured address space.
  Once the event has been customized, it might be triggered using ::SOPC_ServerHelper_TriggerEvent.

  This module provides dedicated functions to access the variables of base event type easily,
  including EventId, EventType, Time, Severity and Source.
  For other variables of known event subtypes, the generic access functions should be used
  to set variable value (::SOPC_Event_SetVariable or ::SOPC_Event_SetVariableFromStrPath)
  or to get variable value (::SOPC_Event_GetVariableAndType or ::SOPC_Event_GetVariableAndTypeFromStrPath).
Note
It is only possible to access variables defined in the event type of the event instance, otherwise access will fail when using generic access functions.

Typedef Documentation

◆ SOPC_Event

typedef struct _SOPC_Event SOPC_Event

The abstract structure type for an OpcUa event instance that might be triggered from nodes.

◆ SOPC_Event_ForEachVar_Fct

typedef void SOPC_Event_ForEachVar_Fct(const char *qnPath, SOPC_Variant *var, const SOPC_NodeId *dataType, int32_t valueRank, uintptr_t user_data)

Type of callback functions for SOPC_Event. The value of user_data is set when calling SOPC_Event_ForEachVar.

Function Documentation

◆ SOPC_Event_Clear()

void SOPC_Event_Clear ( SOPC_Event * pEvent)

Clears the content of an Event.

Parameters
pEventpointer to the event to clear

◆ SOPC_Event_Delete()

void SOPC_Event_Delete ( SOPC_Event ** ppEvent)

Deletes the content of an Event.

Parameters
ppEventreference on the pointer to the event to clear

◆ SOPC_Event_CreateCopy()

SOPC_Event * SOPC_Event_CreateCopy ( const SOPC_Event * pEvent,
bool genNewId )

Copies the provided event in a newly created event.

Parameters
pEventpointer to the event to copy
genNewIdflag to set to indicate a new eventId shall be generated
Returns
a newly allocated event which is a copy of the provided pEvent or NULL in case of invalid parameter or allocation failure.

◆ SOPC_Event_GetEventTypeId()

const SOPC_NodeId * SOPC_Event_GetEventTypeId ( const SOPC_Event * pEvent)

Get the EventTypeId for the given event.

Parameters
pEventpointer to the event from which EventTypeId shall be retrieved
Returns
the event type NodeId or NULL in case of error

◆ SOPC_Event_SetEventId()

SOPC_ReturnStatus SOPC_Event_SetEventId ( SOPC_Event * pEvent,
const SOPC_ByteString * pEventId )

Sets the given EventId for the given event.

Note
Events created using SOPC_EventManager_CreateEventInstance have an already defined unique identifier.
Parameters
pEventpointer to the event for which EventId shall be set
pEventIdpointer to the byte string to set as EventId content
Returns
SOPC_STATUS_OK in case of success, SOPC_STATUS_INVALID parameter or SOPC_STATUS_OUT_OF_MEMORY otherwise.

◆ SOPC_Event_SetSourceName()

SOPC_ReturnStatus SOPC_Event_SetSourceName ( SOPC_Event * pEvent,
const SOPC_String * pSourceName )

Sets the given SourceName for the given event indicating the name of the event source.

Parameters
pEventpointer to the event for which SourceName shall be set
pSourceNamepointer to the string to set as source name
Returns
SOPC_STATUS_OK in case of success, SOPC_STATUS_INVALID parameter or SOPC_STATUS_OUT_OF_MEMORY otherwise.

◆ SOPC_Event_SetSourceNode()

SOPC_ReturnStatus SOPC_Event_SetSourceNode ( SOPC_Event * pEvent,
const SOPC_NodeId * pSourceNode )

Sets the given SourceNode for the given event indicating the node of the event source.

Parameters
pEventpointer to the event for which SourceNode shall be set
pSourceNodepointer to the node id to set as source node
Returns
SOPC_STATUS_OK in case of success, SOPC_STATUS_INVALID parameter or SOPC_STATUS_OUT_OF_MEMORY otherwise.

◆ SOPC_Event_GetTime()

SOPC_DateTime SOPC_Event_GetTime ( const SOPC_Event * pEvent)

Get the Time for the given event.

Parameters
pEventpointer to the event from which Time shall be retrieved
Returns
the event type Time or -1 in case of error

◆ SOPC_Event_SetTime()

SOPC_ReturnStatus SOPC_Event_SetTime ( SOPC_Event * pEvent,
SOPC_DateTime time )

Sets the given Time for the given event indicating the time the event occurred.

Note
If it is not set by user application, it will have the same value as the ReceiveTime (time it is triggered).
Parameters
pEventpointer to the event for which Time shall be set
timetime value of the event to set
Returns
SOPC_STATUS_OK in case of success, SOPC_STATUS_INVALID parameter or SOPC_STATUS_OUT_OF_MEMORY otherwise.

◆ SOPC_Event_SetReceiveTime()

SOPC_ReturnStatus SOPC_Event_SetReceiveTime ( SOPC_Event * pEvent,
SOPC_DateTime receiveTime )

(Internal purpose only) Sets the given ReceiveTime for the given event indicating the time the event was received by server (time it is triggered).

Note
It should not be set by user application, its value will be overwritten by server anyway.
Parameters
pEventpointer to the event for which Time shall be set
receiveTimereceive time value of the event by the server
Returns
SOPC_STATUS_OK in case of success, SOPC_STATUS_INVALID parameter or SOPC_STATUS_OUT_OF_MEMORY otherwise.

◆ SOPC_Event_SetLocalTime()

SOPC_ReturnStatus SOPC_Event_SetLocalTime ( SOPC_Event * pEvent,
const OpcUa_TimeZoneDataType * pLocalTime )

Sets the given LocalTime for the given event indicating the Offset and the DaylightSavingInOffset of the event.

Parameters
pEventpointer to the event for which SourceNode shall be set
pLocalTimepointer to the time zone data to set as local time
Returns
SOPC_STATUS_OK in case of success, SOPC_STATUS_INVALID parameter or SOPC_STATUS_OUT_OF_MEMORY otherwise.

◆ SOPC_Event_SetMessage()

SOPC_ReturnStatus SOPC_Event_SetMessage ( SOPC_Event * pEvent,
const SOPC_LocalizedText * pMessage )

Sets the given Message for the given event indicating a human-readable and localizable text description of the event.

Parameters
pEventpointer to the event for which Message shall be set
pMessagepointer to the message to set as message description
Returns
SOPC_STATUS_OK in case of success, SOPC_STATUS_INVALID parameter or SOPC_STATUS_OUT_OF_MEMORY otherwise.

◆ SOPC_Event_SetSeverity()

SOPC_ReturnStatus SOPC_Event_SetSeverity ( SOPC_Event * pEvent,
uint16_t severity )

Sets the given Severity for the given event indicating the urgency of the event.

Parameters
pEventpointer to the event for which SourceNode shall be set
severityseverity value to set for the given event
Returns
SOPC_STATUS_OK in case of success, SOPC_STATUS_INVALID parameter or SOPC_STATUS_OUT_OF_MEMORY otherwise.

◆ SOPC_Event_SetVariable()

SOPC_ReturnStatus SOPC_Event_SetVariable ( SOPC_Event * pEvent,
uint16_t nbQnPath,
SOPC_QualifiedName * qualifiedNamePathArray,
const SOPC_Variant * var )

Sets the given variable value for the given browse path in the given event.

Warning
This API does not typecheck the variant value type, it is caller responsibility to be consistent with EventType description
Parameters
pEventpointer to the event for which variable value shall be set
nbQnPathnumber of qualified name in the browse path
qualifiedNamePathArrayqualified name path array containing the nbQnPath path elements (e.g.: ['0:EnabledState', '0:Id'])
varvariable to set in the given event for the given browse path
Returns
SOPC_STATUS_OK in case of success, SOPC_STATUS_INVALID parameter or SOPC_STATUS_OUT_OF_MEMORY otherwise.

◆ SOPC_Event_SetVariableFromStrPath()

SOPC_ReturnStatus SOPC_Event_SetVariableFromStrPath ( SOPC_Event * pEvent,
const char * qnPath,
const SOPC_Variant * var )

Sets the given variable value for the given browse path (as a string) in the given event.

Warning
This API does not typecheck the variant value type, it is caller responsibility to be consistent with EventType description
Parameters
pEventpointer to the event for which variable value shall be set
qnPathqualified name path separated by '~' as a string (e.g.: '0:EnabledState~0:Id')
varvariable to set in the given event for the given browse path
Returns
SOPC_STATUS_OK in case of success, SOPC_STATUS_INVALID parameter or SOPC_STATUS_OUT_OF_MEMORY otherwise.

◆ SOPC_Event_GetVariableFromStrPath()

const SOPC_Variant * SOPC_Event_GetVariableFromStrPath ( const SOPC_Event * pEvent,
const char * qnPath )

Gets the variable value for the given browse path (as a string) in the given event.

Parameters
pEventpointer to the event for which variable value shall be set
qnPathqualified name path separated by '~' as a string (e.g.: '0:EnabledState~0:Id')
Returns
The variable value for the given browse path in case of success, NULL otherwise

◆ SOPC_Event_GetVariableAndType()

const SOPC_Variant * SOPC_Event_GetVariableAndType ( const SOPC_Event * pEvent,
uint16_t nbQnPath,
SOPC_QualifiedName * qualifiedNamePathArray,
const SOPC_NodeId ** outDataType,
int32_t * outValueRank )

Gets the variable value and type information for the given browse path in the given event.

Parameters
pEventpointer to the event for which variable value shall be set
nbQnPathnumber of qualified name in the browse path
qualifiedNamePathArrayqualified name path array containing the nbQnPath path elements (e.g.: ['0:EnabledState', '0:Id'])
[out]outDataType(optional) the pointer is set with the data type of the returned value (if pointer provided)
[out]outValueRank(optional) the pointer is set with the value rank of the returned value (if pointer provided)
Returns
The variable value for the given browse path in case of success, NULL otherwise

◆ SOPC_Event_GetVariableAndTypeFromStrPath()

const SOPC_Variant * SOPC_Event_GetVariableAndTypeFromStrPath ( const SOPC_Event * pEvent,
const char * qnPath,
const SOPC_NodeId ** outDataType,
int32_t * outValueRank )

Gets the variable value and type information for the given browse path (as a string) in the given event.

Parameters
pEventpointer to the event for which variable value shall be set
qnPathqualified name path separated by '~' as a string (e.g.: '0:EnabledState~0:Id')
[out]outDataType(optional) the pointer is set with the data type of the returned value (if pointer provided)
[out]outValueRank(optional) the pointer is set with the value rank of the returned value (if pointer provided)
Returns
The variable value for the given browse path in case of success, NULL otherwise

◆ SOPC_Event_ForEachVar()

void SOPC_Event_ForEachVar ( SOPC_Event * event,
SOPC_Event_ForEachVar_Fct * func,
uintptr_t user_data )

Iterates over the event variables, calling the given function for each event variable.

Parameters
eventThe event to iterate on
funcThe function to call on each event variable
user_dataA user chose pointer to pass as last parameter to the callback function.
Note
The order of the iteration is implementation defined, and should not be relied on