Browse Source

Service_ModifySubscription() has been added to the list of supported services and can now use/recreated timed work jobs. Maximal PublishTimeInterval was raised from 100ms to 10s.

ichrispa 9 years ago
parent
commit
41b1b66ae9

+ 41 - 0
src/server/ua_services_subscription.c

@@ -204,6 +204,47 @@ void Service_Publish(UA_Server *server, UA_Session *session, const UA_PublishReq
     response->diagnosticInfos     = 0;
 }
 
+void Service_ModifySubscription(UA_Server *server, UA_Session *session,
+                                 const UA_ModifySubscriptionRequest *request,
+                                 UA_ModifySubscriptionResponse *response) {
+    UA_Subscription *sub;
+    
+    response->responseHeader.serviceResult = UA_STATUSCODE_GOOD;
+    
+    sub = SubscriptionManager_getSubscriptionByID(&(session->subscriptionManager), request->subscriptionId);
+    if (!sub) {
+        response->responseHeader.serviceResult = UA_STATUSCODE_BADSUBSCRIPTIONIDINVALID;
+        return;
+    }
+    
+    
+    UA_BOUNDEDVALUE_SETWBOUNDS(session->subscriptionManager.GlobalPublishingInterval,
+                               request->requestedPublishingInterval, response->revisedPublishingInterval);
+    sub->PublishingInterval = response->revisedPublishingInterval;
+    
+    UA_BOUNDEDVALUE_SETWBOUNDS(session->subscriptionManager.GlobalLifeTimeCount,
+                               request->requestedLifetimeCount, response->revisedLifetimeCount);
+    sub->LifeTime = (UA_UInt32_BoundedValue)  {
+        .minValue=session->subscriptionManager.GlobalLifeTimeCount.minValue,
+        .maxValue=session->subscriptionManager.GlobalLifeTimeCount.maxValue,
+        .currentValue=response->revisedLifetimeCount};
+        
+    UA_BOUNDEDVALUE_SETWBOUNDS(session->subscriptionManager.GlobalKeepAliveCount,
+                                request->requestedMaxKeepAliveCount, response->revisedMaxKeepAliveCount);
+    sub->KeepAliveCount = (UA_Int32_BoundedValue)  {
+        .minValue=session->subscriptionManager.GlobalKeepAliveCount.minValue,
+        .maxValue=session->subscriptionManager.GlobalKeepAliveCount.maxValue,
+        .currentValue=response->revisedMaxKeepAliveCount};
+        
+    sub->NotificationsPerPublish = request->maxNotificationsPerPublish;
+    sub->Priority                = request->priority;
+    
+    printf("Unregister returned: %u\n", Subscription_unregisterUpdateJob(server, sub));
+    Subscription_registerUpdateJob(server, sub);
+    printf("Modified\n");
+    return;
+}
+
 void Service_DeleteSubscriptions(UA_Server *server, UA_Session *session,
                                  const UA_DeleteSubscriptionsRequest *request,
                                  UA_DeleteSubscriptionsResponse *response) {

+ 1 - 1
src/server/ua_subscription.c

@@ -323,7 +323,7 @@ UA_StatusCode Subscription_unregisterUpdateJob(UA_Server *server, UA_Subscriptio
     
     retval |= UA_Server_removeRepeatedJob(server, sub->timedUpdateJobGuid);
     sub->timedUpdateIsRegistered = UA_FALSE;
-    return UA_FALSE;
+    return retval;
 }
 
 

+ 2 - 2
src/server/ua_subscription_manager.c

@@ -8,11 +8,11 @@ void SubscriptionManager_init(UA_Session *session) {
 
     /* FIXME: These init values are empirical. Maybe they should be part
      *        of the server config? */
-    manager->GlobalPublishingInterval = (UA_Int32_BoundedValue) { .maxValue = 100, .minValue = 0, .currentValue=0 };
+    manager->GlobalPublishingInterval = (UA_Int32_BoundedValue) { .maxValue = 10000, .minValue = 0, .currentValue=0 };
     manager->GlobalLifeTimeCount = (UA_UInt32_BoundedValue) { .maxValue = 15000, .minValue = 0, .currentValue=0 };
     manager->GlobalKeepAliveCount = (UA_UInt32_BoundedValue) { .maxValue = 100, .minValue = 0, .currentValue=0 };
     manager->GlobalNotificationsPerPublish = (UA_Int32_BoundedValue)  { .maxValue = 1000, .minValue = 1, .currentValue=0 };
-    manager->GlobalSamplingInterval = (UA_UInt32_BoundedValue) { .maxValue = 100, .minValue = 0, .currentValue=0 };
+    manager->GlobalSamplingInterval = (UA_UInt32_BoundedValue) { .maxValue = 1000, .minValue = 5, .currentValue=0 };
     manager->GlobalQueueSize = (UA_UInt32_BoundedValue) { .maxValue = 100, .minValue = 0, .currentValue=0 };
     LIST_INIT(&manager->ServerSubscriptions);
     manager->LastSessionID = (UA_UInt32) UA_DateTime_now();