High Performance OPC UA Server SDK  1.7.1.383

Create/Delete an event and access its fields. More...

Functions

UA_BEGIN_EXTERN_C SERVER_EXPORT struct uaserver_eventuaserver_event_create (ua_node_t event_type, ua_node_t source_node)
 Create a new event object. More...
 
SERVER_EXPORT void uaserver_event_delete (struct uaserver_event *event)
 Delete the event and all related data.
 
SERVER_EXPORT const struct ua_variantuaserver_event_get_field_value (struct uaserver_event *event, int global_handle)
 Get the value of a eventfield. More...
 
SERVER_EXPORT int uaserver_event_overwrite_field (struct uaserver_event *event, int global_handle, const struct ua_variant *value)
 Overwrite the value of an eventfield. More...
 
SERVER_EXPORT int uaserver_event_add_field (struct uaserver_event *event, int global_handle, const struct ua_variant *value)
 Add a new eventfield with value to the event. More...
 
SERVER_EXPORT int uaserver_event_set_event_id (struct uaserver_event *event, const struct ua_bytestring *event_id)
 Set the field EventId of the event. More...
 
SERVER_EXPORT int uaserver_event_update_event_id (struct uaserver_event *event)
 Update the EventId with a new randomly generated EventId. More...
 
SERVER_EXPORT int uaserver_event_set_time (struct uaserver_event *event, ua_datetime time)
 Set the field Time of the event. More...
 
SERVER_EXPORT int uaserver_event_set_local_time (struct uaserver_event *event, const struct ua_timezonedatatype *tz)
 Set the field LocalTime of the event. More...
 
SERVER_EXPORT int uaserver_event_set_receive_time (struct uaserver_event *event, ua_datetime receive_time)
 Set the field ReceiveTime of the event. More...
 
SERVER_EXPORT int uaserver_event_set_message (struct uaserver_event *event, const char *locale, const char *message_text)
 Set the field Message of the event. More...
 
SERVER_EXPORT int uaserver_event_set_severity (struct uaserver_event *event, uint16_t)
 Set the field Severity of the event. More...
 
SERVER_EXPORT int uaserver_event_set_source_name (struct uaserver_event *event, const char *source_name)
 Set the field SourceName of the event. More...
 
SERVER_NO_EXPORT int uaserver_event_fill_eventfieldlist (struct uaserver_event *event, const struct uaserver_selectclause *sc, struct ua_eventfieldlist *field_list)
 
SERVER_NO_EXPORT struct ua_eventfieldlistuaserver_event_create_overfloweventfieldlist (const struct uaserver_selectclause *sc)
 
SERVER_EXPORT bool uaserver_event_is_condition (struct uaserver_event *event)
 Returns true if the given event is a subtype of ConditionType.
 
SERVER_EXPORT bool uaserver_event_is_refresh (struct uaserver_event *event)
 Returns true if the given event is a Refreshstarteventtype or Refreshendeventtype.
 
SERVER_EXPORT int uaserver_event_set_bool (struct uaserver_event *e, int handle, bool value)
 Convenience function to set a boolean value in an event field. More...
 
SERVER_EXPORT int uaserver_event_set_string (struct uaserver_event *e, int handle, const char *value)
 Convenience function to set a string value in an event field. More...
 
SERVER_EXPORT int uaserver_event_set_uint16 (struct uaserver_event *e, int handle, uint16_t value)
 Convenience function to set an uint16 value in an event field. More...
 
SERVER_EXPORT int uaserver_event_set_uint32 (struct uaserver_event *e, int handle, uint32_t value)
 Convenience function to set an uint32 value in an event field. More...
 
SERVER_EXPORT int uaserver_event_set_datetime (struct uaserver_event *e, int handle, ua_datetime value)
 Convenience function to set a datime value in an event field. More...
 
SERVER_EXPORT int uaserver_event_set_nodeid (struct uaserver_event *e, int handle, const struct ua_nodeid *value)
 Convenience function to set a nodeid value in an event field. More...
 
SERVER_EXPORT int uaserver_event_set_localized_text (struct uaserver_event *e, int handle, const char *locale, const char *text)
 Convenience function to set a localized text value in an event field. More...
 
SERVER_EXPORT int uaserver_event_set_twostatevariable (struct uaserver_event *e, const char *browsename, uint16_t nsidx, const char *locale, const char *text, bool state)
 Convenience function to set the localized text and Id of a TwoStateVariable. More...
 
static const struct ua_variantuaserver_event_get_field_value_qn (struct uaserver_event *event, const char *name, uint16_t nsidx)
 Same as uaserver_event_get_field_value but uses a qualifiedname (browsepath of length 1) to identify the eventfield.
 
static int uaserver_event_overwrite_field_qn (struct uaserver_event *event, const char *name, uint16_t nsidx, const struct ua_variant *value)
 Same as uaserver_event_overwrite_field but uses a qualifiedname (browsepath of length 1) to identify the eventfield.
 
static int uaserver_event_add_field_qn (struct uaserver_event *event, const char *name, uint16_t nsidx, const struct ua_variant *value)
 Same as uaserver_event_add_field but uses a qualifiedname (browsepath of length 1) to identify the eventfield.
 

Detailed Description

Create/Delete an event and access its fields.

Function Documentation

◆ uaserver_event_add_field()

SERVER_EXPORT int uaserver_event_add_field ( struct uaserver_event event,
int  global_handle,
const struct ua_variant value 
)

Add a new eventfield with value to the event.

Only use this functions for fields that do not exist in the event. If you know the field already exists or unsure use uaserver_event_overwrite_field instead.

Parameters
eventEvent to add the field to.
global_handleHandle to identify the new field, see uaserver_eventfield_lookup.
valueNew value to add for the field, a copy of this value will be attached to the event.
Returns
Zero on success or negative errorcode on failure.

◆ uaserver_event_create()

UA_BEGIN_EXTERN_C SERVER_EXPORT struct uaserver_event* uaserver_event_create ( ua_node_t  event_type,
ua_node_t  source_node 
)

Create a new event object.

The following fields from the BaseEventType are initialized:

  • EventId: random guid converted to 16 byte bytestring.
  • EventType: uses the event_type argument.
  • SourceNode: uses the source_node argument.
  • SourceName: display name of the source_node
  • Message: browse name of the source_node
  • Time: current time.
  • ReceiveTime: current time.
  • Severity: rather low serverity of 200.
  • LocalTime: not set, this field is optional

To set a new value for any of these fields or set the LocalTime the respective setter function should be used.

To add/overwrite eventfields from other event types the functions uaserver_event_add_field and uaserver_event_overwrite_field should be used.

To fire the event it must be passed to uaserver_eventnotifier_fire_event. Afterwards it can be deleted with uaserver_event_delete or it may be reused and later fired again as new event, in this case at least the EvendId must be changed.

Parameters
event_typeNode handle for the type of the new event.
source_nodeNode handle for the source of the event, this node must have been registered with uaserver_eventnotifier_register. The node must be either an event source or an event notifier.
Returns
Pointer to new event object or NULL on failure.

◆ uaserver_event_get_field_value()

SERVER_EXPORT const struct ua_variant* uaserver_event_get_field_value ( struct uaserver_event event,
int  global_handle 
)

Get the value of a eventfield.

The value is still attached to the event, so it must not be freed and must not be accessed after the event is deleted.

Parameters
eventEvent to get the value from.
global_handleHandle to identify the field, see uaserver_eventfield_lookup.
Returns
Pointer to the value or NULL if the field does not exist.

◆ uaserver_event_overwrite_field()

SERVER_EXPORT int uaserver_event_overwrite_field ( struct uaserver_event event,
int  global_handle,
const struct ua_variant value 
)

Overwrite the value of an eventfield.

Replace the value of an existing eventfield. If the field is not present in the event it will be added. If you are sure the field does not exist in the event use uaserver_event_add_field for better performance.

Parameters
eventEvent to overwrite the field.
global_handleHandle to identify the field, see uaserver_eventfield_lookup.
valueNew value to write, a copy of this value will be attached to the event.
Returns
Zero on success or negative errorcode on failure.

◆ uaserver_event_set_bool()

SERVER_EXPORT int uaserver_event_set_bool ( struct uaserver_event e,
int  handle,
bool  value 
)

Convenience function to set a boolean value in an event field.

Parameters
eEvent to set value.
handleGlobal handle of the event field.
valueBoolean value to set.
Returns
Zero on success or negative errorcode on failure.

◆ uaserver_event_set_datetime()

SERVER_EXPORT int uaserver_event_set_datetime ( struct uaserver_event e,
int  handle,
ua_datetime  value 
)

Convenience function to set a datime value in an event field.

Parameters
eEvent to set value.
handleGlobal handle of the event field.
valueDatetime value to set.
Returns
Zero on success or negative errorcode on failure.

◆ uaserver_event_set_event_id()

SERVER_EXPORT int uaserver_event_set_event_id ( struct uaserver_event event,
const struct ua_bytestring event_id 
)

Set the field EventId of the event.

Returns
Zero on success or negative errorcode on failure.

◆ uaserver_event_set_local_time()

SERVER_EXPORT int uaserver_event_set_local_time ( struct uaserver_event event,
const struct ua_timezonedatatype tz 
)

Set the field LocalTime of the event.

Returns
Zero on success or negative errorcode on failure.

◆ uaserver_event_set_localized_text()

SERVER_EXPORT int uaserver_event_set_localized_text ( struct uaserver_event e,
int  handle,
const char *  locale,
const char *  text 
)

Convenience function to set a localized text value in an event field.

Parameters
eEvent to set value.
handleGlobal handle of the event field.
localeLocale to set (may be NULL).
textText to set (may be NULL).
Returns
Zero on success or negative errorcode on failure.

◆ uaserver_event_set_message()

SERVER_EXPORT int uaserver_event_set_message ( struct uaserver_event event,
const char *  locale,
const char *  message_text 
)

Set the field Message of the event.

Returns
Zero on success or negative errorcode on failure.

◆ uaserver_event_set_nodeid()

SERVER_EXPORT int uaserver_event_set_nodeid ( struct uaserver_event e,
int  handle,
const struct ua_nodeid value 
)

Convenience function to set a nodeid value in an event field.

Parameters
eEvent to set value.
handleGlobal handle of the event field.
valueNodeid value to set.
Returns
Zero on success or negative errorcode on failure.

◆ uaserver_event_set_receive_time()

SERVER_EXPORT int uaserver_event_set_receive_time ( struct uaserver_event event,
ua_datetime  receive_time 
)

Set the field ReceiveTime of the event.

Returns
Zero on success or negative errorcode on failure.

◆ uaserver_event_set_severity()

SERVER_EXPORT int uaserver_event_set_severity ( struct uaserver_event event,
uint16_t  severity 
)

Set the field Severity of the event.

Returns
Zero on success or negative errorcode on failure.

◆ uaserver_event_set_source_name()

SERVER_EXPORT int uaserver_event_set_source_name ( struct uaserver_event event,
const char *  source_name 
)

Set the field SourceName of the event.

Returns
Zero on success or negative errorcode on failure.

◆ uaserver_event_set_string()

SERVER_EXPORT int uaserver_event_set_string ( struct uaserver_event e,
int  handle,
const char *  value 
)

Convenience function to set a string value in an event field.

Parameters
eEvent to set value.
handleGlobal handle of the event field.
valueString value to set.
Returns
Zero on success or negative errorcode on failure.

◆ uaserver_event_set_time()

SERVER_EXPORT int uaserver_event_set_time ( struct uaserver_event event,
ua_datetime  time 
)

Set the field Time of the event.

Returns
Zero on success or negative errorcode on failure.

◆ uaserver_event_set_twostatevariable()

SERVER_EXPORT int uaserver_event_set_twostatevariable ( struct uaserver_event e,
const char *  browsename,
uint16_t  nsidx,
const char *  locale,
const char *  text,
bool  state 
)

Convenience function to set the localized text and Id of a TwoStateVariable.

The event field is given by its browsename, so only fields with a browsepath of length 1 are supported by this function. Also only the mandatory Id Property of the TwoStateVariable is set, possible further Properties must be set manually.

Parameters
eEvent to set value.
browsenameName part of the browsename to identifiy the event field.
nsidxNamespace index part of the browsename to identifiy the event field.
localeLocale to set (may be NULL).
textText to set (may be NULL).
stateState of the Id Property.
Returns
Zero on success or negative errorcode on failure.

◆ uaserver_event_set_uint16()

SERVER_EXPORT int uaserver_event_set_uint16 ( struct uaserver_event e,
int  handle,
uint16_t  value 
)

Convenience function to set an uint16 value in an event field.

Parameters
eEvent to set value.
handleGlobal handle of the event field.
valueUint16 value to set.
Returns
Zero on success or negative errorcode on failure.

◆ uaserver_event_set_uint32()

SERVER_EXPORT int uaserver_event_set_uint32 ( struct uaserver_event e,
int  handle,
uint32_t  value 
)

Convenience function to set an uint32 value in an event field.

Parameters
eEvent to set value.
handleGlobal handle of the event field.
valueUint32 value to set.
Returns
Zero on success or negative errorcode on failure.

◆ uaserver_event_update_event_id()

SERVER_EXPORT int uaserver_event_update_event_id ( struct uaserver_event e)

Update the EventId with a new randomly generated EventId.

Returns
Zero on success or errorcode on failure.