High Performance OPC UA Server SDK  1.2.0.193
event

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

Functions

struct uaserver_eventuaserver_event_create (ua_node_t event_type, ua_node_t source_node)
 Create a new event object. More...
 
void uaserver_event_delete (struct uaserver_event *event)
 Delete the event and all related data.
 
const struct ua_variantuaserver_event_get_field_value (struct uaserver_event *event, int global_handle)
 Get the value of a eventfield. More...
 
int uaserver_event_overwrite_field (struct uaserver_event *event, int global_handle, const struct ua_variant *value)
 Overwrite the value of an eventfield. More...
 
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...
 
int uaserver_event_set_event_id (struct uaserver_event *event, const struct ua_bytestring *event_id)
 Set the field EventId of the event. More...
 
int uaserver_event_set_time (struct uaserver_event *event, ua_datetime time)
 Set the field Time of the event. More...
 
int uaserver_event_set_local_time (struct uaserver_event *event, const struct ua_timezonedatatype *tz)
 Set the field LocalTime of the event. More...
 
int uaserver_event_set_receive_time (struct uaserver_event *event, ua_datetime receive_time)
 Set the field ReceiveTime of the event. More...
 
int uaserver_event_set_message (struct uaserver_event *event, const char *locale, const char *message_text)
 Set the field Message of the event. More...
 
int uaserver_event_set_severity (struct uaserver_event *event, uint16_t)
 Set the field Severity of the event. More...
 
int uaserver_event_set_source_name (struct uaserver_event *event, const char *source_name)
 Set the field SourceName of the event. More...
 
int uaserver_event_fill_eventfieldlist (struct uaserver_event *event, const struct uaserver_selectclause *sc, struct ua_eventfieldlist *field_list)
 
struct ua_eventfieldlistuaserver_event_create_overfloweventfieldlist (const struct uaserver_selectclause *sc)
 
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

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