Kaynağa Gözat

View: Add UA_Server_browseRecursive

Julius Pfrommer 5 yıl önce
ebeveyn
işleme
34b4a01ad9
2 değiştirilmiş dosya ile 21 ekleme ve 0 silme
  1. 9 0
      include/open62541/server.h
  2. 12 0
      src/server/ua_services_view.c

+ 9 - 0
include/open62541/server.h

@@ -453,6 +453,15 @@ UA_BrowseResult UA_EXPORT
 UA_Server_browse(UA_Server *server, UA_UInt32 maxReferences,
                  const UA_BrowseDescription *bd);
 
+/* Nonstandard version of the browse service that recurses into child nodes.
+ * Possible loops (that can occur for non-hierarchical references) are handled
+ * by adding every target node at most once to the result array. The returned
+ * ReferenceDescription refers has the `ReferenceTypeId` and `IsForward` fields
+ * set according to the last reference in the (recursive) chain. */
+UA_BrowseResult UA_EXPORT
+UA_Server_browseRecursive(UA_Server *server, UA_UInt32 maxReferences,
+                          const UA_BrowseDescription *bd);
+
 UA_BrowseResult UA_EXPORT
 UA_Server_browseNext(UA_Server *server, UA_Boolean releaseContinuationPoint,
                      const UA_ByteString *continuationPoint);

+ 12 - 0
src/server/ua_services_view.c

@@ -602,6 +602,18 @@ UA_Server_browse(UA_Server *server, UA_UInt32 maxReferences,
     return result;
 }
 
+UA_BrowseResult
+UA_Server_browseRecursive(UA_Server *server, UA_UInt32 maxReferences,
+                          const UA_BrowseDescription *bd) {
+    UA_BrowseResult result;
+    UA_BrowseResult_init(&result);
+    struct BrowseOpts bo;
+    bo.maxReferences = maxReferences;
+    bo.recursive = true;
+    Operation_Browse(server, &server->adminSession, &bo, bd, &result);
+    return result;
+}
+
 static void
 Operation_BrowseNext(UA_Server *server, UA_Session *session,
                      const UA_Boolean *releaseContinuationPoints,