Julius Pfrommer лет назад: 10
Родитель
Сommit
a627fb8b42
4 измененных файлов с 116 добавлено и 15 удалено
  1. 2 1
      examples/client_proper.c
  2. 38 0
      include/ua_client.h
  3. 56 0
      src/client/ua_client.c
  4. 20 14
      src/server/ua_services.h

+ 2 - 1
examples/client_proper.c

@@ -18,9 +18,10 @@ int main(int argc, char *argv[]) {
     read_req.nodesToRead = UA_ReadValueId_new();
     read_req.nodesToReadSize = 1;
     read_req.nodesToRead[0].nodeId = UA_NODEID_STATIC(1, 73);
-    read_req.nodesToRead[0].attributeId = 13;
+    read_req.nodesToRead[0].attributeId = UA_ATTRIBUTEID_VALUE;
     UA_ReadResponse read_resp = UA_Client_read(client, &read_req);
     printf("answer statuscode: %i\n", read_resp.responseHeader.serviceResult);
     printf("answer value: %i\n", *(UA_Int32*)read_resp.results[0].value.dataPtr);
+    UA_ReadResponse_deleteMembers(&read_resp);
     UA_Client_delete(client);
 }

+ 38 - 0
include/ua_client.h

@@ -36,10 +36,48 @@ UA_StatusCode UA_EXPORT UA_Client_connect(UA_Client *client, UA_ConnectionConfig
 
 UA_StatusCode UA_EXPORT UA_Client_disconnect(UA_Client *client);
 
+typedef enum {
+    UA_ATTRIBUTEID_NODEID                  = 1,
+    UA_ATTRIBUTEID_NODECLASS               = 2,
+    UA_ATTRIBUTEID_BROWSENAME              = 3,
+    UA_ATTRIBUTEID_DISPLAYNAME             = 4,
+    UA_ATTRIBUTEID_DESCRIPTION             = 5,
+    UA_ATTRIBUTEID_WRITEMASK               = 6,
+    UA_ATTRIBUTEID_USERWRITEMASK           = 7,
+    UA_ATTRIBUTEID_ISABSTRACT              = 8,
+    UA_ATTRIBUTEID_SYMMETRIC               = 9,
+    UA_ATTRIBUTEID_INVERSENAME             = 10,
+    UA_ATTRIBUTEID_CONTAINSNOLOOPS         = 11,
+    UA_ATTRIBUTEID_EVENTNOTIFIER           = 12,
+    UA_ATTRIBUTEID_VALUE                   = 13,
+    UA_ATTRIBUTEID_DATATYPE                = 14,
+    UA_ATTRIBUTEID_VALUERANK               = 15,
+    UA_ATTRIBUTEID_ARRAYDIMENSIONS         = 16,
+    UA_ATTRIBUTEID_ACCESSLEVEL             = 17,
+    UA_ATTRIBUTEID_USERACCESSLEVEL         = 18,
+    UA_ATTRIBUTEID_MINIMUMSAMPLINGINTERVAL = 19,
+    UA_ATTRIBUTEID_HISTORIZING             = 20,
+    UA_ATTRIBUTEID_EXECUTABLE              = 21,
+    UA_ATTRIBUTEID_USEREXECUTABLE          = 22
+} UA_AttributeId;
+
+/* Attribute Service Set */
 UA_ReadResponse UA_EXPORT UA_Client_read(UA_Client *client, const UA_ReadRequest *request);
 UA_WriteResponse UA_EXPORT UA_Client_write(UA_Client *client, const UA_WriteRequest *request);
+
+/* View Service Set */    
 UA_BrowseResponse UA_EXPORT UA_Client_browse(UA_Client *client, const UA_BrowseRequest *request);
+UA_TranslateBrowsePathsToNodeIdsResponse UA_EXPORT UA_Client_translateBrowsePathsToNodeIds(UA_Client *client,
+                                                        const UA_TranslateBrowsePathsToNodeIdsRequest *request);
 
+/* NodeManagement Service Set */
+UA_AddNodesResponse UA_EXPORT UA_Client_addNodes(UA_Client *client, const UA_AddNodesRequest *request);
+UA_AddReferencesResponse UA_EXPORT
+    UA_Client_addReferences(UA_Client *client, const UA_AddReferencesRequest *request);
+UA_DeleteNodesResponse UA_EXPORT UA_Client_deleteNodes(UA_Client *client, const UA_DeleteNodesRequest *request);
+UA_DeleteReferencesResponse UA_EXPORT
+    UA_Client_deleteReferences(UA_Client *client, const UA_DeleteReferencesRequest *request);
+    
 #ifdef __cplusplus
 } // extern "C"
 #endif

+ 56 - 0
src/client/ua_client.c

@@ -349,9 +349,65 @@ static UA_StatusCode SessionHandshake(UA_Client *client) {
     return response.responseHeader.serviceResult; // not deleted
 }
 
+/*************************/
+/* User-Facing Functions */
+/*************************/
+
 UA_ReadResponse UA_Client_read(UA_Client *client, const UA_ReadRequest *request) {
     UA_ReadResponse response;
     synchronousRequest(request, &UA_TYPES[UA_TYPES_READREQUEST], &response,
                        &UA_TYPES[UA_TYPES_READRESPONSE], client);
     return response;
 }
+
+UA_WriteResponse UA_Client_write(UA_Client *client, const UA_WriteRequest *request) {
+    UA_WriteResponse response;
+    synchronousRequest(request, &UA_TYPES[UA_TYPES_WRITEREQUEST], &response,
+                       &UA_TYPES[UA_TYPES_WRITERESPONSE], client);
+    return response;
+}
+
+UA_BrowseResponse UA_Client_browse(UA_Client *client, const UA_BrowseRequest *request) {
+    UA_BrowseResponse response;
+    synchronousRequest(request, &UA_TYPES[UA_TYPES_BROWSEREQUEST], &response,
+                       &UA_TYPES[UA_TYPES_BROWSERESPONSE], client);
+    return response;
+}
+
+UA_TranslateBrowsePathsToNodeIdsResponse
+UA_Client_translateBrowsePathsToNodeIds(UA_Client *client,
+                                        const UA_TranslateBrowsePathsToNodeIdsRequest *request) {
+    UA_TranslateBrowsePathsToNodeIdsResponse response;
+    synchronousRequest(request, &UA_TYPES[UA_TYPES_BROWSEREQUEST], &response,
+                       &UA_TYPES[UA_TYPES_BROWSERESPONSE], client);
+    return response;
+}
+
+UA_AddNodesResponse UA_Client_addNodes(UA_Client *client, const UA_AddNodesRequest *request) {
+    UA_AddNodesResponse response;
+    synchronousRequest(request, &UA_TYPES[UA_TYPES_BROWSEREQUEST], &response,
+                       &UA_TYPES[UA_TYPES_BROWSERESPONSE], client);
+    return response;
+}
+
+UA_AddReferencesResponse UA_Client_addReferences(UA_Client *client, const UA_AddReferencesRequest *request) {
+    UA_AddReferencesResponse response;
+    synchronousRequest(request, &UA_TYPES[UA_TYPES_BROWSEREQUEST], &response,
+                       &UA_TYPES[UA_TYPES_BROWSERESPONSE], client);
+    return response;
+}
+
+UA_DeleteNodesResponse UA_Client_deleteNodes(UA_Client *client, const UA_DeleteNodesRequest *request) {
+    UA_DeleteNodesResponse response;
+    synchronousRequest(request, &UA_TYPES[UA_TYPES_BROWSEREQUEST], &response,
+                       &UA_TYPES[UA_TYPES_BROWSERESPONSE], client);
+    return response;
+}
+
+UA_DeleteReferencesResponse UA_Client_deleteReferences(UA_Client *client,
+                                                       const UA_DeleteReferencesRequest *request) {
+    UA_DeleteReferencesResponse response;
+    synchronousRequest(request, &UA_TYPES[UA_TYPES_BROWSEREQUEST], &response,
+                       &UA_TYPES[UA_TYPES_BROWSERESPONSE], client);
+    return response;
+}

+ 20 - 14
src/server/ua_services.h

@@ -31,7 +31,8 @@ void Service_FindServers(UA_Server                    *server,
  * Returns the Endpoints supported by a Server and all of the configuration
  * information required to establish a SecureChannel and a Session.
  */
-void Service_GetEndpoints(UA_Server *server, const UA_GetEndpointsRequest *request, UA_GetEndpointsResponse *response);
+void Service_GetEndpoints(UA_Server *server, const UA_GetEndpointsRequest *request,
+                          UA_GetEndpointsResponse *response);
 // Service_RegisterServer
 /** @} */
 
@@ -88,7 +89,8 @@ void Service_ActivateSession(UA_Server *server, UA_SecureChannel *channel,
                              const UA_ActivateSessionRequest *request, UA_ActivateSessionResponse *response);
 
 /** Used to terminate a Session. */
-void Service_CloseSession(UA_Server *server, const UA_CloseSessionRequest *request, UA_CloseSessionResponse *response);
+void Service_CloseSession(UA_Server *server, const UA_CloseSessionRequest *request,
+                          UA_CloseSessionResponse *response);
 // Service_Cancel
 /** @} */
 
@@ -103,16 +105,20 @@ void Service_CloseSession(UA_Server *server, const UA_CloseSessionRequest *reque
  */
 
 /** Used to add one or more Nodes into the AddressSpace hierarchy. */
-void Service_AddNodes(UA_Server *server, UA_Session *session, const UA_AddNodesRequest *request, UA_AddNodesResponse *response);
+void Service_AddNodes(UA_Server *server, UA_Session *session, const UA_AddNodesRequest *request,
+                      UA_AddNodesResponse *response);
 
 /** Used to add one or more References to one or more Nodes. */
-void Service_AddReferences(UA_Server *server, UA_Session *session, const UA_AddReferencesRequest *request, UA_AddReferencesResponse *response);
+void Service_AddReferences(UA_Server *server, UA_Session *session, const UA_AddReferencesRequest *request,
+                           UA_AddReferencesResponse *response);
 
 /** Used to delete one or more Nodes from the AddressSpace. */
-void Service_DeleteNodes(UA_Server *server, UA_Session *session, const UA_DeleteNodesRequest *request, UA_DeleteNodesResponse *response);
+void Service_DeleteNodes(UA_Server *server, UA_Session *session, const UA_DeleteNodesRequest *request,
+                         UA_DeleteNodesResponse *response);
 
 /** Used to delete one or more References of a Node. */
-void Service_DeleteReferences(UA_Server *server, UA_Session *session, const UA_DeleteReferencesRequest *request, UA_DeleteReferencesResponse *response);
+void Service_DeleteReferences(UA_Server *server, UA_Session *session, const UA_DeleteReferencesRequest *request,
+                              UA_DeleteReferencesResponse *response);
 
 /** @} */
 
@@ -140,13 +146,11 @@ void Service_TranslateBrowsePathsToNodeIds(UA_Server *server, UA_Session *sessio
 // Service_BrowseNext
 
 // Service_RegisterNodes
-void Service_RegisterNodes(UA_Server *server, UA_Session *session,
-                                           const UA_RegisterNodesRequest *request,
-                                           UA_RegisterNodesResponse *response);
+void Service_RegisterNodes(UA_Server *server, UA_Session *session, const UA_RegisterNodesRequest *request,
+                           UA_RegisterNodesResponse *response);
 // Service_UnregisterNodes
-void Service_UnregisterNodes(UA_Server *server, UA_Session *session,
-                                           const UA_UnregisterNodesRequest *request,
-                                           UA_UnregisterNodesResponse *response);
+void Service_UnregisterNodes(UA_Server *server, UA_Session *session, const UA_UnregisterNodesRequest *request,
+                             UA_UnregisterNodesResponse *response);
 /** @} */
 
 /**
@@ -181,7 +185,8 @@ void Service_UnregisterNodes(UA_Server *server, UA_Session *session,
  * allows Clients to read the entire set of indexed values as a composite, to
  * read individual elements or to read ranges of elements of the composite.
  */
-void Service_Read(UA_Server *server, UA_Session *session, const UA_ReadRequest *request, UA_ReadResponse *response);
+void Service_Read(UA_Server *server, UA_Session *session, const UA_ReadRequest *request,
+                  UA_ReadResponse *response);
 // Service_HistoryRead
 
 /**
@@ -190,7 +195,8 @@ void Service_Read(UA_Server *server, UA_Session *session, const UA_ReadRequest *
  * allows Clients to write the entire set of indexed values as a composite, to
  * write individual elements or to write ranges of elements of the composite.
  */
-void Service_Write(UA_Server *server, UA_Session *session, const UA_WriteRequest *request, UA_WriteResponse *response);
+void Service_Write(UA_Server *server, UA_Session *session, const UA_WriteRequest *request,
+                   UA_WriteResponse *response);
 // Service_HistoryUpdate
 /** @} */