diff options
Diffstat (limited to 'src/nodes_config.h')
| -rw-r--r-- | src/nodes_config.h | 18 |
1 files changed, 16 insertions, 2 deletions
diff --git a/src/nodes_config.h b/src/nodes_config.h index 0207a55..cb42942 100644 --- a/src/nodes_config.h +++ b/src/nodes_config.h @@ -8,7 +8,8 @@ * Reads a config file containing node.N.field entries, parses them into * an array of node descriptors, and creates corresponding OPC UA variable * nodes in the server address space. Each node gets a string NodeId in - * namespace 1 (ns=1;s=<name>). + * namespace 1 (ns=1;s=<name>). Nodes are created with zero-initialized + * values; call nodes_config_randomize() to assign random values. * * Supported types (scalar and 1D array via "type[]" suffix): * bool, int16, uint16, int32, uint32, int64, uint64, float, double, string @@ -62,7 +63,6 @@ typedef struct char *description; /**< Optional description text (NULL when absent). */ node_type type; /**< OPC UA data type. */ UA_Boolean is_array; /**< true when the type name ended with "[]". */ - char *value_str; /**< Raw value string (comma-separated for arrays). */ node_access_level access; /**< Read or read-write. */ } node_config; @@ -114,6 +114,20 @@ int nodes_config_load (const char *path, nodes_config *out); int nodes_config_add (UA_Server *server, const nodes_config *nc); /** + * @brief Writes random values to all configured variable nodes. + * + * Generates a random value appropriate for each node's type and writes + * it to the server using UA_Server_writeValue. For array nodes, each + * element is randomized independently. Call srand() before the first + * invocation to seed the random number generator. + * + * @param server The UA_Server containing the nodes. + * @param nc The parsed nodes configuration. + * @return 0 when all nodes were updated, -1 if any write failed. + */ +int nodes_config_randomize (UA_Server *server, const nodes_config *nc); + +/** * @brief Frees all memory owned by a nodes_config structure. * * After this call the structure is zeroed and must not be used |
