High Performance OPC UA Server SDK  1.7.1.383
ua_memorystore Struct Reference

Implementation of a store using in-memory values. More...

#include <memorystore.h>

Public Member Functions

static void ua_memorystore_get_value (void *memorystore, ua_node_t node, unsigned int idx, bool source_ts, struct ua_indexrange *range, unsigned int num_ranges, struct ua_datavalue *result)
 
static ua_statuscode ua_memorystore_attach_value (void *memorystore, ua_node_t node, unsigned int idx, struct ua_indexrange *range, unsigned int num_ranges, struct ua_datavalue *value)
 
int ua_memorystore_attach_new_value (struct ua_memorystore *store, struct ua_variant *value, ua_node_t node)
 Attach a new value to the memorystore. More...
 
int ua_memorystore_register_static_node (struct ua_memorystore *store, struct ua_variant *initial_value, ua_node_t node)
 Initializes the variant value for the given static variable. More...
 
int ua_memorystore_init (struct ua_memorystore *store, uint8_t storeidx, struct ua_variant *values, unsigned int max_values)
 Initialize a memorystore with a preallocated ua_variant array. More...
 
int ua_memorystore_init_static (struct ua_memorystore *store, uint8_t storeidx, struct ua_variant *values, unsigned int num_values, unsigned int max_values)
 Initialize a memorystore with a preallocated ua_variant array. More...
 
struct ua_variantua_memorystore_clear (struct ua_memorystore *store)
 Clear all values in a memorystore and the store itself. More...
 
uint8_t ua_memorystore_get_storeindex (struct ua_memorystore *store)
 Get the storeindex of a memorystore.
 

Data Fields

struct ua_variantvalues
 Array with values.
 
unsigned int num_values
 Number of currently used values.
 
unsigned int max_values
 Number of elements in the array.
 
uint8_t storeidx
 Index of the store.
 

Detailed Description

Implementation of a store using in-memory values.

A new memorystore must be initialized with a user provided array of empty ua_variant structs using ua_memorystore_init. The number of elements in the array is the capacity of the store. Then values can be added with ua_memorystore_attach_new_value. This function also registers the store with the given storeindex.

For a full example how to use the memorystore see Lesson 2: Custom Provider with Value Stores.

Member Function Documentation

◆ ua_memorystore_attach_new_value()

int ua_memorystore_attach_new_value ( struct ua_memorystore store,
struct ua_variant value,
ua_node_t  node 
)

Attach a new value to the memorystore.

A new value is added to the memorystore by creating a shallow copy. The store index and value index are written to the node.

Parameters
storeContext of the memorystore.
valueNew value to attach.
nodeHandle of node associated with the value.
Returns
Zero on success or errorcode on failure.

◆ ua_memorystore_attach_value()

static ua_statuscode ua_memorystore_attach_value ( void *  memorystore,
ua_node_t  node,
unsigned int  idx,
struct ua_indexrange range,
unsigned int  num_ranges,
struct ua_datavalue value 
)

Implementation of the ua_valuestore_attach function for the memorystore.

◆ ua_memorystore_clear()

struct ua_variant * ua_memorystore_clear ( struct ua_memorystore store)

Clear all values in a memorystore and the store itself.

Parameters
storeContext of the memorystore to clear.
Returns
Pointer to the values array provided in ua_memorystore_init.

◆ ua_memorystore_get_value()

static void ua_memorystore_get_value ( void *  memorystore,
ua_node_t  node,
unsigned int  idx,
bool  source_ts,
struct ua_indexrange range,
unsigned int  num_ranges,
struct ua_datavalue result 
)

Implementation of the ua_valuestore_get function for the memorystore.

◆ ua_memorystore_init()

int ua_memorystore_init ( struct ua_memorystore store,
uint8_t  storeidx,
struct ua_variant values,
unsigned int  max_values 
)

Initialize a memorystore with a preallocated ua_variant array.

Parameters
storeContext of the memorystore.
storeidxStoreindex used for registering the store. Zero means a free value is chosen.
valuesArray with preallocated empty values.
max_valuesNumber of elements in values array, which is the maximum possible number of elements in the store.

◆ ua_memorystore_init_static()

int ua_memorystore_init_static ( struct ua_memorystore store,
uint8_t  storeidx,
struct ua_variant values,
unsigned int  num_values,
unsigned int  max_values 
)

Initialize a memorystore with a preallocated ua_variant array.

This can be used to register static variables that have been generated with xml2c. Use the generated function <prefix>_get_num_dynamic_values() of your namespace model to get the value for the num_values argument.

Parameters
storeContext of the memorystore.
storeidxStoreindex used for registering the store. Zero means a free value is chosen.
valuesArray with preallocated empty values.
num_valuesNumber of used elements in values array, which have been already assigned by xml2c.
max_valuesNumber of elements in values array, which is the maximum possible. number of elements in the store.

◆ ua_memorystore_register_static_node()

int ua_memorystore_register_static_node ( struct ua_memorystore store,
struct ua_variant initial_value,
ua_node_t  node 
)

Initializes the variant value for the given static variable.

Unlike ua_memorystore_register_node this function does not modify the variable, to allow using static variables (C constants). It does however compare if the generated storeidx of the variable matches the used store index.

The initial value is set by creating a shallow copy (attach variant).

Parameters
storeContext of the memorystore.
initial_valueNew value to attach.
nodeHandle of node associated with the value.
Returns
Zero on success or errorcode on failure.

The documentation for this struct was generated from the following files: