Forráskód Böngészése

Use methods only when the feature is enabled

Julius Pfrommer 6 éve
szülő
commit
3de900fbcd

+ 4 - 0
include/ua_client.h

@@ -421,6 +421,8 @@ UA_Client_AsyncService_write(UA_Client *client, const UA_WriteRequest *request,
                                     userdata, requestId);
 }
 
+#ifdef UA_ENABLE_METHODCALLS
+    
 static UA_INLINE UA_StatusCode
 UA_Client_AsyncService_call(UA_Client *client, const UA_CallRequest *request,
                             UA_ClientAsyncServiceCallback callback,
@@ -431,6 +433,8 @@ UA_Client_AsyncService_call(UA_Client *client, const UA_CallRequest *request,
                                     userdata, requestId);
 }
 
+#endif
+
 static UA_INLINE UA_StatusCode
 UA_Client_AsyncService_browse(UA_Client *client, const UA_BrowseRequest *request,
                               UA_ClientAsyncServiceCallback callback,

+ 8 - 0
include/ua_server.h

@@ -955,6 +955,8 @@ UA_Server_addDataSourceVariableNode(UA_Server *server,
                                     const UA_DataSource dataSource,
                                     void *nodeContext, UA_NodeId *outNewNodeId);
 
+#ifdef UA_ENABLE_METHODCALLS
+
 UA_StatusCode UA_EXPORT
 UA_Server_addMethodNodeEx(UA_Server *server, const UA_NodeId requestedNewNodeId,
                           const UA_NodeId parentNodeId,
@@ -984,6 +986,8 @@ UA_Server_addMethodNode(UA_Server *server, const UA_NodeId requestedNewNodeId,
                                      nodeContext, outNewNodeId);
 }
 
+#endif
+
 
 /**
  * The method pair UA_Server_addNode_begin and _finish splits the AddNodes
@@ -1031,12 +1035,16 @@ UA_Server_addNode_begin(UA_Server *server, const UA_NodeClass nodeClass,
 UA_StatusCode UA_EXPORT
 UA_Server_addNode_finish(UA_Server *server, const UA_NodeId nodeId);
 
+#ifdef UA_ENABLE_METHODCALLS
+
 UA_StatusCode UA_EXPORT
 UA_Server_addMethodNode_finish(UA_Server *server, const UA_NodeId nodeId,
                          UA_MethodCallback method,
                          size_t inputArgumentsSize, const UA_Argument* inputArguments,
                          size_t outputArgumentsSize, const UA_Argument* outputArguments);
 
+#endif
+
 /* Deletes a node and optionally all references leading to the node. */
 UA_StatusCode UA_EXPORT
 UA_Server_deleteNode(UA_Server *server, const UA_NodeId nodeId,

+ 2 - 0
src/server/ua_services.h

@@ -350,9 +350,11 @@ void Service_Write(UA_Server *server, UA_Session *session,
  * Used to call (invoke) a methods. Each method call is invoked within the
  * context of an existing Session. If the Session is terminated, the results of
  * the method's execution cannot be returned to the Client and are discarded. */
+#ifdef UA_ENABLE_METHODCALLS
 void Service_Call(UA_Server *server, UA_Session *session,
                   const UA_CallRequest *request,
                   UA_CallResponse *response);
+#endif
 
 /**
  * MonitoredItem Service Set

+ 9 - 6
tests/client/check_client_subscriptions.c

@@ -464,6 +464,7 @@ START_TEST(Client_subscription_async_sub) {
 }
 END_TEST
 
+#ifdef UA_ENABLE_METHODCALLS
 START_TEST(Client_methodcall) {
     UA_Client *client = UA_Client_new(UA_ClientConfig_default);
     UA_StatusCode retval = UA_Client_connect(client, "opc.tcp://localhost:4840");
@@ -521,30 +522,32 @@ START_TEST(Client_methodcall) {
     UA_Client_delete(client);
 }
 END_TEST
+#endif /* UA_ENABLE_METHODCALLS */
 
 #endif /* UA_ENABLE_SUBSCRIPTIONS */
 
 static Suite* testSuite_Client(void) {
+    Suite *s = suite_create("Client Subscription");
+
+#ifdef UA_ENABLE_SUBSCRIPTIONS
     TCase *tc_client = tcase_create("Client Subscription Basic");
     tcase_add_checked_fixture(tc_client, setup, teardown);
-#ifdef UA_ENABLE_SUBSCRIPTIONS
     tcase_add_test(tc_client, Client_subscription);
     tcase_add_test(tc_client, Client_subscription_connectionClose);
     tcase_add_test(tc_client, Client_subscription_createDataChanges);
     tcase_add_test(tc_client, Client_subscription_keepAlive);
     tcase_add_test(tc_client, Client_subscription_without_notification);
     tcase_add_test(tc_client, Client_subscription_async_sub);
+    suite_add_tcase(s,tc_client);
 #endif /* UA_ENABLE_SUBSCRIPTIONS */
 
+#if defined(UA_ENABLE_SUBSCRIPTIONS) && defined(UA_ENABLE_METHODCALLS)
     TCase *tc_client2 = tcase_create("Client Subscription + Method Call of GetMonitoredItmes");
     tcase_add_checked_fixture(tc_client2, setup, teardown);
-#ifdef UA_ENABLE_SUBSCRIPTIONS
     tcase_add_test(tc_client2, Client_methodcall);
-#endif /* UA_ENABLE_SUBSCRIPTIONS */
-
-    Suite *s = suite_create("Client Subscription");
-    suite_add_tcase(s,tc_client);
     suite_add_tcase(s,tc_client2);
+#endif
+
     return s;
 }