Parcourir la source

reverted the client part according to #362

Julius Pfrommer il y a 9 ans
Parent
commit
60ed7b2723
3 fichiers modifiés avec 85 ajouts et 1000 suppressions
  1. 34 62
      examples/client.c
  2. 15 74
      include/ua_client.h
  3. 36 864
      src/client/ua_client.c

+ 34 - 62
examples/client.c

@@ -5,12 +5,12 @@
 # include "networklayer_tcp.h"
 # include "logger_stdout.h"
 # include "ua_types_encoding_binary.h"
-#include "server/ua_nodes.h"
 #else
 # include "open62541.h"
 # include <string.h>
 # include <stdlib.h>
 #endif
+
 #include <stdio.h>
 
 void handler_TheAnswerChanged(UA_UInt32 handle, UA_DataValue *value);
@@ -19,17 +19,6 @@ void handler_TheAnswerChanged(UA_UInt32 handle, UA_DataValue *value) {
     return;
 }
 
-UA_StatusCode nodeIter(UA_NodeId childId, UA_Boolean isInverse, UA_NodeId referenceTypeId, void *handle);
-UA_StatusCode nodeIter(UA_NodeId childId, UA_Boolean isInverse, UA_NodeId referenceTypeId, void *handle) {  
-  printf("References ns=%d;i=%d using i=%d ", childId.namespaceIndex, childId.identifier.numeric, referenceTypeId.identifier.numeric);
-  if (isInverse == UA_TRUE) {
-    printf(" (inverse)");
-  }
-  printf("\n");
-  
-  return UA_STATUSCODE_GOOD;
-}
-
 int main(int argc, char *argv[]) {
     UA_Client *client = UA_Client_new(UA_ClientConfig_standard, Logger_Stdout_new());
     UA_StatusCode retval = UA_Client_connect(client, ClientNetworkLayerTCP_connect,
@@ -156,7 +145,7 @@ int main(int argc, char *argv[]) {
     UA_Int32 outputSize;
     UA_Variant *output;
     
-    retval = UA_Client_callServerMethod(client, UA_NODEID_NUMERIC(0, UA_NS0ID_OBJECTSFOLDER),
+    retval = UA_Client_CallServerMethod(client, UA_NODEID_NUMERIC(0, UA_NS0ID_OBJECTSFOLDER),
                                         UA_NODEID_NUMERIC(1, 62541), 1, &input, &outputSize, &output);
     if(retval == UA_STATUSCODE_GOOD) {
         printf("Method call was successfull, and %i returned values available.\n", outputSize);
@@ -171,10 +160,8 @@ int main(int argc, char *argv[]) {
 #ifdef ENABLE_ADDNODES 
     /* Create a new object type node */
     // New ReferenceType
-    UA_StatusCode addRes;
-    UA_NodeId retNodeId;
-    addRes = UA_Client_addReferenceTypeNode(client,
-        UA_NODEID_NUMERIC(1, 12133), // Assign this NodeId (will fail if client is called multiple times)
+    UA_AddNodesResponse *adResp = UA_Client_createReferenceTypeNode(client,
+        UA_EXPANDEDNODEID_NUMERIC(1, 12133), // Assign this NodeId (will fail if client is called multiple times)
         UA_QUALIFIEDNAME(0, "NewReference"),
         UA_LOCALIZEDTEXT("en_US", "TheNewReference"),
         UA_LOCALIZEDTEXT("en_US", "References something that might or might not exist."),
@@ -182,43 +169,44 @@ int main(int argc, char *argv[]) {
         UA_NODEID_NUMERIC(0, UA_NS0ID_ORGANIZES),
         (UA_UInt32) 0, (UA_UInt32) 0, 
         UA_EXPANDEDNODEID_NUMERIC(0, UA_NS0ID_OBJECTSFOLDER),
-        UA_LOCALIZEDTEXT("en_US", "IsNewlyReferencedBy"),
-        &retNodeId);
-    if (addRes == UA_STATUSCODE_GOOD ) {
-      printf("Created 'NewReference' with numeric NodeID %u\n", retNodeId.identifier.numeric );
+        UA_LOCALIZEDTEXT("en_US", "IsNewlyReferencedBy"));
+    if (adResp->resultsSize > 0 && adResp->results[0].statusCode == UA_STATUSCODE_GOOD ) {
+        printf("Created 'NewReference' with numeric NodeID %u\n", adResp->results[0].addedNodeId.identifier.numeric );
     }
+    UA_AddNodesResponse_deleteMembers(adResp);
+    free(adResp);
     
     // New ObjectType
-    addRes = UA_Client_addObjectTypeNode(client,    
-        UA_NODEID_NUMERIC(1, 12134), // Assign this NodeId (will fail if client is called multiple times)
+    adResp = UA_Client_createObjectTypeNode(client,    
+        UA_EXPANDEDNODEID_NUMERIC(1, 12134), // Assign this NodeId (will fail if client is called multiple times)
         UA_QUALIFIEDNAME(0, "NewObjectType"),
         UA_LOCALIZEDTEXT("en_US", "TheNewObjectType"),
         UA_LOCALIZEDTEXT("en_US", "Put innovative description here."),
         UA_EXPANDEDNODEID_NUMERIC(0, UA_NS0ID_OBJECTSFOLDER),
         UA_NODEID_NUMERIC(0, UA_NS0ID_ORGANIZES),
         (UA_UInt32) 0, (UA_UInt32) 0, 
-        UA_EXPANDEDNODEID_NUMERIC(0, UA_NS0ID_OBJECTSFOLDER), 
-        UA_FALSE,
-        &retNodeId);
-    if (addRes == UA_STATUSCODE_GOOD ) {
-      printf("Created 'NewObjectType' with numeric NodeID %u\n", retNodeId.identifier.numeric );
+        UA_EXPANDEDNODEID_NUMERIC(0, UA_NS0ID_OBJECTSFOLDER));
+        if (adResp->resultsSize > 0 && adResp->results[0].statusCode == UA_STATUSCODE_GOOD ) {
+        printf("Created 'NewObjectType' with numeric NodeID %u\n", adResp->results[0].addedNodeId.identifier.numeric );
     }
     
     // New Object
-    addRes = UA_Client_addObjectNode(client,    
-        UA_NODEID_NUMERIC(1, 0), // Assign new/random NodeID  
+    adResp = UA_Client_createObjectNode(client,    
+        UA_EXPANDEDNODEID_NUMERIC(1, 0), // Assign new/random NodeID  
         UA_QUALIFIEDNAME(0, "TheNewGreatNodeBrowseName"),
         UA_LOCALIZEDTEXT("en_US", "TheNewGreatNode"),
         UA_LOCALIZEDTEXT("de_DE", "Hier koennte Ihre Webung stehen!"),
         UA_EXPANDEDNODEID_NUMERIC(0, UA_NS0ID_OBJECTSFOLDER),
         UA_NODEID_NUMERIC(0, UA_NS0ID_ORGANIZES),
         (UA_UInt32) 0, (UA_UInt32) 0, 
-        UA_EXPANDEDNODEID_NUMERIC(0, UA_NS0ID_OBJECTSFOLDER), 
-        &retNodeId);
-    if (addRes == UA_STATUSCODE_GOOD ) {
-      printf("Created 'NewObject' with numeric NodeID %u\n", retNodeId.identifier.numeric );
+        UA_EXPANDEDNODEID_NUMERIC(0, UA_NS0ID_OBJECTSFOLDER));
+    if (adResp->resultsSize > 0 && adResp->results[0].statusCode == UA_STATUSCODE_GOOD ) {
+        printf("Created 'NewObject' with numeric NodeID %u\n", adResp->results[0].addedNodeId.identifier.numeric );
     }
     
+    UA_AddNodesResponse_deleteMembers(adResp);
+    free(adResp);
+    
     // New Integer Variable
     UA_Variant *theValue = UA_Variant_new();
     UA_Int32 *theValueDate = UA_Int32_new();
@@ -226,43 +214,27 @@ int main(int argc, char *argv[]) {
     theValue->type = &UA_TYPES[UA_TYPES_INT32];
     theValue->data = theValueDate;
     
-    addRes = UA_Client_addVariableNode(client,
-        UA_NODEID_NUMERIC(1, 0), // Assign new/random NodeID  
+    adResp = UA_Client_createVariableNode(client,
+        UA_EXPANDEDNODEID_NUMERIC(1, 0), // Assign new/random NodeID  
         UA_QUALIFIEDNAME(0, "VariableNode"),
         UA_LOCALIZEDTEXT("en_US", "TheNewVariableNode"),
         UA_LOCALIZEDTEXT("en_US", "This integer is just amazing - it has digits and everything."),
         UA_EXPANDEDNODEID_NUMERIC(0, UA_NS0ID_OBJECTSFOLDER),
         UA_NODEID_NUMERIC(0, UA_NS0ID_ORGANIZES),
         (UA_UInt32) 0, (UA_UInt32) 0, 
-        theValue, 
-        &retNodeId);
-    if (addRes == UA_STATUSCODE_GOOD ) {
-      printf("Created 'NewVariable' with numeric NodeID %u\n", retNodeId.identifier.numeric );
+        UA_EXPANDEDNODEID_NUMERIC(0, UA_NS0ID_OBJECTSFOLDER),
+        UA_NODEID_NUMERIC(0, UA_NS0ID_INT32),
+        theValue);
+    if (adResp->resultsSize > 0 && adResp->results[0].statusCode == UA_STATUSCODE_GOOD ) {
+        printf("Created 'NewVariable' with numeric NodeID %u\n", adResp->results[0].addedNodeId.identifier.numeric );
     }
-
+    UA_AddNodesResponse_deleteMembers(adResp);
+    free(adResp);
     free(theValue);
     /* Done creating a new node*/
-#else
-  // retNodeId is needed for the next test
-  UA_NodeId retNodeId = UA_NODEID_STRING(1, "the.answer");
 #endif
-  // Iterate over all nodes in 'Objects'
-  UA_Client_forEachChildNodeCall(client, UA_NODEID_NUMERIC(0, UA_NS0ID_OBJECTSFOLDER), nodeIter, NULL);
-    
-  // Get a copy of the node 'TheNewVariableNode' and delete it
-  void *theCopy;
-  UA_Client_getNodeCopy(client, retNodeId, (void*) &theCopy);
-  UA_Client_deleteNodeCopy(client, &theCopy);
-  
-  // Delete a serverside node
-  UA_Client_deleteMethodNode(client, UA_NODEID_NUMERIC(1,62541));
-  
-  // Set a localized string version of "Objects"
-  UA_LocalizedText objectsLocale = UA_LOCALIZEDTEXT("de_DE", "Die Objekte");
-  UA_Client_setAttributeValue(client, UA_NODEID_NUMERIC(0, UA_NS0ID_OBJECTSFOLDER), UA_ATTRIBUTEID_WRITEMASK, (void *) &objectsLocale);
-  
-  UA_Client_disconnect(client);
-  UA_Client_delete(client);
-  return UA_STATUSCODE_GOOD;
+    UA_Client_disconnect(client);
+    UA_Client_delete(client);
+    return UA_STATUSCODE_GOOD;
 }
 

+ 15 - 74
include/ua_client.h

@@ -63,51 +63,30 @@ UA_DeleteReferencesResponse UA_EXPORT
 
 
 /* Client-Side Macro/Procy functions */
-
-UA_StatusCode UA_EXPORT
-UA_Client_deleteNode(UA_Client *client, UA_NodeId nodeId);
-
-#define UA_CLIENT_DELETENODETYPEALIAS_DECL(TYPE) \
-UA_StatusCode UA_EXPORT UA_Client_delete##TYPE##Node(UA_Client *client, UA_NodeId nodeId);
-
-UA_CLIENT_DELETENODETYPEALIAS_DECL(Object)
-
-UA_CLIENT_DELETENODETYPEALIAS_DECL(Variable)
-
-UA_CLIENT_DELETENODETYPEALIAS_DECL(ObjectType)
-
-UA_CLIENT_DELETENODETYPEALIAS_DECL(VariableType)
-
-UA_CLIENT_DELETENODETYPEALIAS_DECL(DataType)
-
-UA_CLIENT_DELETENODETYPEALIAS_DECL(Method)
-
-UA_CLIENT_DELETENODETYPEALIAS_DECL(View)
-
 #ifdef ENABLE_METHODCALLS
 UA_CallResponse UA_EXPORT UA_Client_call(UA_Client *client, UA_CallRequest *request);
-UA_StatusCode UA_EXPORT UA_Client_callServerMethod(UA_Client *client, UA_NodeId objectNodeId, UA_NodeId methodNodeId,
+UA_StatusCode UA_EXPORT UA_Client_CallServerMethod(UA_Client *client, UA_NodeId objectNodeId, UA_NodeId methodNodeId,
                                                    UA_Int32 inputSize, const UA_Variant *input,
                                                    UA_Int32 *outputSize, UA_Variant **output);
 #endif
     
-UA_StatusCode UA_EXPORT UA_Client_addObjectNode( UA_Client *client, UA_NodeId reqId, UA_QualifiedName browseName, UA_LocalizedText displayName, 
-                                                 UA_LocalizedText description, UA_ExpandedNodeId parentNodeId, UA_NodeId referenceTypeId,
-                                                 UA_UInt32 userWriteMask, UA_UInt32 writeMask, UA_ExpandedNodeId typeDefinition, UA_NodeId *createdNodeId);
+UA_AddNodesResponse UA_EXPORT *UA_Client_createObjectNode(  UA_Client *client, UA_ExpandedNodeId reqId, UA_QualifiedName browseName, UA_LocalizedText displayName, 
+                                                            UA_LocalizedText description, UA_ExpandedNodeId parentNodeId, UA_NodeId referenceTypeId,
+                                                            UA_UInt32 userWriteMask, UA_UInt32 writeMask, UA_ExpandedNodeId typeDefinition);
 
-UA_StatusCode UA_EXPORT UA_Client_addVariableNode( UA_Client *client, UA_NodeId reqId, UA_QualifiedName browseName, UA_LocalizedText displayName, 
-                                                   UA_LocalizedText description, UA_ExpandedNodeId parentNodeId, UA_NodeId referenceTypeId,
-                                                   UA_UInt32 userWriteMask, UA_UInt32 writeMask, UA_Variant *value, UA_NodeId *createdNodeId);
+UA_AddNodesResponse UA_EXPORT *UA_Client_createVariableNode(UA_Client *client, UA_ExpandedNodeId reqId, UA_QualifiedName browseName, UA_LocalizedText displayName, 
+                                                            UA_LocalizedText description, UA_ExpandedNodeId parentNodeId, UA_NodeId referenceTypeId,
+                                                            UA_UInt32 userWriteMask, UA_UInt32 writeMask, UA_ExpandedNodeId typeDefinition, 
+                                                            UA_NodeId dataType, UA_Variant *value );
 
-UA_StatusCode UA_EXPORT UA_Client_addReferenceTypeNode( UA_Client *client, UA_NodeId reqId, UA_QualifiedName browseName, UA_LocalizedText displayName, 
-                                                        UA_LocalizedText description, UA_ExpandedNodeId parentNodeId, UA_NodeId referenceTypeId,
-                                                        UA_UInt32 userWriteMask, UA_UInt32 writeMask, UA_ExpandedNodeId typeDefinition,
-                                                        UA_LocalizedText inverseName, UA_NodeId *createdNodeId );
+UA_AddNodesResponse UA_EXPORT *UA_Client_createReferenceTypeNode(UA_Client *client, UA_ExpandedNodeId reqId, UA_QualifiedName browseName, UA_LocalizedText displayName, 
+                                                            UA_LocalizedText description, UA_ExpandedNodeId parentNodeId, UA_NodeId referenceTypeId,
+                                                            UA_UInt32 userWriteMask, UA_UInt32 writeMask, UA_ExpandedNodeId typeDefinition,
+                                                            UA_LocalizedText inverseName );
 
-UA_StatusCode UA_EXPORT UA_Client_addObjectTypeNode( UA_Client *client, UA_NodeId reqId, UA_QualifiedName browseName, UA_LocalizedText displayName, 
-                                                     UA_LocalizedText description, UA_ExpandedNodeId parentNodeId, UA_NodeId referenceTypeId,
-                                                     UA_UInt32 userWriteMask, UA_UInt32 writeMask, UA_ExpandedNodeId typeDefinition, UA_Boolean isAbstract, 
-                                                     UA_NodeId *createdNodeId);
+UA_AddNodesResponse UA_EXPORT *UA_Client_createObjectTypeNode(UA_Client *client, UA_ExpandedNodeId reqId, UA_QualifiedName browseName, UA_LocalizedText displayName, 
+                                                            UA_LocalizedText description, UA_ExpandedNodeId parentNodeId, UA_NodeId referenceTypeId,
+                                                            UA_UInt32 userWriteMask, UA_UInt32 writeMask, UA_ExpandedNodeId typeDefinition);
 
 
 #ifdef ENABLE_SUBSCRIPTIONS
@@ -123,44 +102,6 @@ UA_StatusCode UA_EXPORT UA_Client_unMonitorItemChanges(UA_Client *client, UA_UIn
                                                        UA_UInt32 monitoredItemId );
 #endif
 
-#ifndef _HAVE_UA_NODEITERATORCALLBACK_D
-#define _HAVE_UA_NODEITERATORCALLBACK_D
-typedef UA_StatusCode (*UA_NodeIteratorCallback)(UA_NodeId childId, UA_Boolean isInverse, UA_NodeId referenceTypeId, void *handle);
-#endif
-
-UA_StatusCode UA_EXPORT
-UA_Client_forEachChildNodeCall(UA_Client *client, UA_NodeId parentNodeId, UA_NodeIteratorCallback callback, void *handle);
-
-UA_StatusCode 
-UA_Client_copyBaseAttributes(UA_Client *client, UA_ReadResponse *readResponseSrc, void *dst);
-
-UA_StatusCode 
-UA_Client_appendObjectNodeAttributes(UA_Client *client, void *dst);
-UA_StatusCode 
-UA_Client_appendObjectTypeNodeAttributes(UA_Client *client, void *dst);
-UA_StatusCode 
-UA_Client_appendVariableNodeAttributes(UA_Client *client, void *dst);
-UA_StatusCode 
-UA_Client_appendVariableTypeNodeAttributes(UA_Client *client, void *dst);
-UA_StatusCode 
-UA_Client_appendReferenceTypeNodeAttributes(UA_Client *client, void *dst);
-UA_StatusCode 
-UA_Client_appendViewNodeAttributes(UA_Client *client, void *dst);
-UA_StatusCode 
-UA_Client_appendDataTypeNodeAttributes(UA_Client *client, void *dst);
-UA_StatusCode 
-UA_Client_appendMethodNodeAttributes(UA_Client *client, void *dst);
-
-UA_StatusCode UA_EXPORT 
-UA_Client_getNodeCopy(UA_Client *client, UA_NodeId nodeId, void **copyInto);
-UA_StatusCode UA_EXPORT 
-UA_Client_deleteNodeCopy(UA_Client *client, void **node);
-
-UA_StatusCode UA_EXPORT 
-UA_Client_setAttributeValue(UA_Client *client, UA_NodeId nodeId, UA_AttributeId attributeId, void *value);
-UA_StatusCode UA_EXPORT 
-UA_Client_getAttributeValue(UA_Client *client, UA_NodeId nodeId, UA_AttributeId attributeId, void **value);
-
 #ifdef __cplusplus
 } // extern "C"
 #endif

Fichier diff supprimé car celui-ci est trop grand
+ 36 - 864
src/client/ua_client.c