High Performance OPC UA Server SDK
1.7.1.383
|
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_variant * | ua_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_variant * | values |
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. | |
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.
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
.
store | Context of the memorystore. |
value | New value to attach. |
node | Handle of node associated with the 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.
struct ua_variant * ua_memorystore_clear | ( | struct ua_memorystore * | store | ) |
Clear all values in a memorystore and the store itself.
store | Context of the memorystore to clear. |
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.
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.
store | Context of the memorystore. |
storeidx | Storeindex used for registering the store. Zero means a free value is chosen. |
values | Array with preallocated empty values. |
max_values | Number of elements in values array, which is the maximum possible number of elements in the store. |
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.
store | Context of the memorystore. |
storeidx | Storeindex used for registering the store. Zero means a free value is chosen. |
values | Array with preallocated empty values. |
num_values | Number of used elements in values array, which have been already assigned by xml2c. |
max_values | Number of elements in values array, which is the maximum possible. number of elements in the store. |
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).
store | Context of the memorystore. |
initial_value | New value to attach. |
node | Handle of node associated with the value. |