Skip to content
Start free evaluation

pdcomm_opcua_server_add_variable

Function

Adds a Variable node below the Objects folder.

int32_t pdcomm_opcua_server_add_variable(pdcomm_opcua_handle server, pdcomm_opcua_bytes node_id, pdcomm_opcua_bytes name, pdcomm_opcua_bytes variant, uint32_t flags)

Declared in: #include <pdcomm/opcua/pdcomm_opcua.h>

The node is a BaseDataVariableType instance referenced from Objects (i=85) by Organizes. Its BrowseName (namespace 2) and DisplayName are name. DataType and ValueRank are inferred from the initial value, so the Variant must be typed: a Null Variant is rejected.

NodeId and Variant are complete Part 6 built-in binary encodings without a service prefix. The NodeId must use namespace index 2 (urn:pdcomm:opcua:nodes) and must not exist yet.

Parameters

NameDescription
serverServer handle.
node_idEncoded NodeId, at most 4096 bytes.
nameUTF-8 name, 1 to 4096 bytes.
variantEncoded initial Variant, at most 4 MiB.
flagsBitwise OR of ::pdcomm_opcua_variable_flags values; 0 makes a read-only variable for authenticated users only.

Returns

#PDCOMM_OPCUA_OK; #PDCOMM_OPCUA_INVALID_INPUT for an unknown flag, an invalid encoding, another namespace or a Null Variant; #PDCOMM_OPCUA_LIMIT when Objects already has 8192 references; #PDCOMM_OPCUA_RUNTIME_ERROR when the address space refuses the node (duplicate NodeId, more than 65536 nodes or 64 MiB of values; the text names the StatusCode); #PDCOMM_OPCUA_CLOSED, #PDCOMM_OPCUA_BUSY, #PDCOMM_OPCUA_INVALID_HANDLE or #PDCOMM_OPCUA_POISONED.

Notes

  • A failed call leaves no partial node behind.