Browse (C)
DarraUa_Session_BrowseNode(h, node_id, filter, &res) — Lists the direct child nodes (first level) of the specified node.
- For pagination of large nodes, please use BrowseWithPaging + BrowseNext.
- For path-based batch parsing, please use TranslateBrowsePaths.
API
OPCUA_API DarraUa_Status OPCUA_CALL DarraUa_Session_Browse(
DarraUa_SessionHandle h,
const DarraUa_NodeId* node_id,
DarraUa_NodeClass filter_node_class,
DarraUa_BrowseResult** out_result);
OPCUA_API DarraUa_Status OPCUA_CALL DarraUa_Session_BrowseNode(
DarraUa_SessionHandle h,
const char* node_id_str,
DarraUa_NodeClass filter_node_class,
DarraUa_BrowseResult** out_result);
OPCUA_API uint32_t OPCUA_CALL
DarraUa_BrowseResult_GetCount(const DarraUa_BrowseResult* r);
OPCUA_API const DarraUa_ReferenceDescription* OPCUA_CALL
DarraUa_BrowseResult_GetReference(const DarraUa_BrowseResult* r, uint32_t index);
OPCUA_API void OPCUA_CALL
DarraUa_BrowseResult_Delete(DarraUa_BrowseResult* r);
out_result Allocated by Stack, released _Delete by. On failure, *out_result = NULL.
The three entry points Browse / BrowseNode / BrowseNodes have only one filter dimension, filter_node_class (mapped to the server's nodeClassMask); there are no reference-type or browse-direction parameters.
ReferenceDescription Field Accessor
OPCUA_API const char* OPCUA_CALL
DarraUa_Ref_GetBrowseName(const DarraUa_ReferenceDescription* rd);
OPCUA_API const char* OPCUA_CALL
DarraUa_Ref_GetDisplayName(const DarraUa_ReferenceDescription* rd);
OPCUA_API int32_t OPCUA_CALL
DarraUa_Ref_GetNodeClass(const DarraUa_ReferenceDescription* rd);
OPCUA_API int32_t OPCUA_CALL
DarraUa_Ref_GetNodeIdString(
const DarraUa_ReferenceDescription* rd,
char* buf, int32_t buf_size);
Get* Returned const char* lifecycle = BrowseResult, do not free.
Usage
DarraUa_BrowseResult* br = NULL;
DarraUa_Status st = DarraUa_Session_BrowseNode(
h, "ns=2;s=Boiler1",
UA_NODE_CLASS_UNSPECIFIED,
&br);
if (!UA_STATUS_IS_GOOD(st) || !br) {
fprintf(stderr, "Browse failed: %s\n", DarraUa_StatusName(st));
return;
}
uint32_t n = DarraUa_BrowseResult_GetCount(br);
char id_buf[128];
for (uint32_t i = 0; i < n; ++i) {
const DarraUa_ReferenceDescription* rd =
DarraUa_BrowseResult_GetReference(br, i);
if (!rd) continue;
int32_t nc = DarraUa_Ref_GetNodeClass(rd);
const char* name = DarraUa_Ref_GetBrowseName(rd);
const char* dname = DarraUa_Ref_GetDisplayName(rd);
DarraUa_Ref_GetNodeIdString(rd, id_buf, (int32_t)sizeof(id_buf));
printf(" [class=%d] %-20s %s -> %s\n",
nc, name ? name : "", dname ? dname : "", id_buf);
}
DarraUa_BrowseResult_Delete(br);
Batch Browsing (BrowseNodes)
If you want to view multiple nodes at the same time (for example, when expanding the tree for the first GUI time), do it in one BrowseNodes go RPC:
OPCUA_API DarraUa_Status OPCUA_CALL DarraUa_Session_BrowseNodes(
DarraUa_SessionHandle h,
const char* const* node_id_strs,
uint32_t count,
DarraUa_NodeClass filter_node_class,
DarraUa_BrowseResult** out_results); /* The caller allocates count slots */
const char* roots[] = { "i=85" /* Objects */, "i=86" /* Types */ };
DarraUa_BrowseResult* results[2] = { NULL };
DarraUa_Session_BrowseNodes(h, roots, 2,
UA_NODE_CLASS_UNSPECIFIED, results);
for (uint32_t r = 0; r < 2; ++r) {
if (!results[r]) {
printf("%s: failed\n", roots[r]);
continue;
}
uint32_t cnt = DarraUa_BrowseResult_GetCount(results[r]);
printf("%s: %u children\n", roots[r], cnt);
DarraUa_BrowseResult_Delete(results[r]);
}
If a node fails to load, the corresponding slot results[i] = NULL, Does not affect others.
NodeClass filter
typedef enum {
UA_NODE_CLASS_UNSPECIFIED = 0,
UA_NODE_CLASS_OBJECT = 1,
UA_NODE_CLASS_VARIABLE = 2,
UA_NODE_CLASS_METHOD = 4,
UA_NODE_CLASS_OBJECT_TYPE = 8,
UA_NODE_CLASS_VARIABLE_TYPE = 16,
UA_NODE_CLASS_REFERENCE_TYPE= 32,
UA_NODE_CLASS_DATA_TYPE = 64,
UA_NODE_CLASS_VIEW = 128
} DarraUa_NodeClass;
Bitwise OR or combinatorial (e.g., OBJECT | VARIABLE).
/* Show only Variable */
DarraUa_Session_BrowseNode(h, "ns=2;s=Boiler1",
UA_NODE_CLASS_VARIABLE, &br);
/* View Only Method */
DarraUa_Session_BrowseNode(h, "ns=2;s=Calculator",
UA_NODE_CLASS_METHOD, &br);
Pagination for Large Nodes (ContinuationPoint)
If the number of references for a node exceeds the limit per page (1000), Browse the server will return only one page at a time. In this case, the returned BrowseNode data contains BrowseResult [...]ContinuationPoint, which can be retrieved using [...], and then _GetContinuationPoint called BrowseNext:
const uint8_t* cp = NULL;
int32_t cp_len = 0;
cp = DarraUa_BrowseResult_GetContinuationPoint(br, &cp_len);
if (cp && cp_len > 0) {
DarraUa_BrowseResult* next = NULL;
DarraUa_Session_BrowseNext(h, /*release*/ 0, cp, cp_len, &next);
/* ... Processing next ... */
DarraUa_BrowseResult_Delete(next);
}
For the complete loop template, see Browse Automatic Pagination.
Error Code
| Status Code | Meaning |
|---|---|
| Good | Success |
| BadNodeIdUnknown | NodeId Does not exist |
| BadNodeIdInvalid | NodeId String parsing failed |
| BadCommunicationError | Network Outage |
Performance
BrowseNodesBatch: Include N nodes in a single request, reducing the number of network round trips from N to 1- Per request, a maximum of 1000 references are returned Browse per node; any excess is stored by the server in [...ContinuationPoint], requiring an additional BrowseNext Continue paging
Limits of Filtration Capacity
C SDK's Browse exposes only the NodeClass filter; there is no entry point for filtering by browse direction (forward / backward / both) or by reference type (e.g. HierarchicalReferences i=33) — of the three Browse entry points, only filter_node_class is a parameter.
The server always returns: forward references (isForward), reference types (References i=31) including all subtypes, and all fields resultMask.
When you need to filter by direction or reference type, filter DarraUa_ReferenceDescription the public fields on the client side using:
typedef struct {
DarraUa_NodeId target_node_id;
DarraUa_NodeId reference_type;
DarraUa_NodeId type_definition;
DarraUa_QualifiedName browse_name;
DarraUa_LocalizedText display_name;
DarraUa_NodeClass node_class;
int32_t is_forward;
} DarraUa_ReferenceDescription;
Example: Keep only the reference to (HasComponent i=47)
DarraUa_BrowseResult* br = NULL;
DarraUa_Session_BrowseNode(h, "ns=2;s=Boiler1",
UA_NODE_CLASS_UNSPECIFIED, &br);
uint32_t n = br ? DarraUa_BrowseResult_GetCount(br) : 0;
char id_buf[128];
for (uint32_t i = 0; i < n; ++i) {
const DarraUa_ReferenceDescription* rd =
DarraUa_BrowseResult_GetReference(br, i);
if (!rd) continue;
if (!rd->is_forward) continue; /* As long as it's positive */
if (rd->reference_type.id.numeric != 47) continue; /* As long as HasComponent */
DarraUa_Ref_GetNodeIdString(rd, id_buf, (int32_t)sizeof(id_buf));
printf("%s\n", id_buf);
}
DarraUa_BrowseResult_Delete(br);
reference_type It is a structure DarraUa_NodeId; first look at (kind (UA_NODE_ID_NUMERIC / _STRING/ _GUID / _BYTESTRING) and then retrieve the corresponding id member.