diff --git a/src/com/opc_ua/opcua_local_handler.cpp b/src/com/opc_ua/opcua_local_handler.cpp index 771fecefc..0b04455ec 100644 --- a/src/com/opc_ua/opcua_local_handler.cpp +++ b/src/com/opc_ua/opcua_local_handler.cpp @@ -105,8 +105,11 @@ void COPC_UA_Local_Handler::run() { CCriticalRegion criticalRegion(mServerAccessMutex); timeToSleepMs = UA_Server_run_iterate(mUaServer, false); } + if(timeToSleepMs < scmMinimumIterationWaitTime) { timeToSleepMs = scmMinimumIterationWaitTime; + } else if (timeToSleepMs > scmMaximumIterationWaitTime) { + timeToSleepMs = scmMaximumIterationWaitTime; } mServerNeedsIteration.timedWait(static_cast(timeToSleepMs) * 1000000ULL); diff --git a/src/com/opc_ua/opcua_local_handler.h b/src/com/opc_ua/opcua_local_handler.h index c7da16a41..8656a78c5 100644 --- a/src/com/opc_ua/opcua_local_handler.h +++ b/src/com/opc_ua/opcua_local_handler.h @@ -369,6 +369,9 @@ class COPC_UA_Local_Handler : public COPC_UA_HandlerAbstract, public CThread { */ static const UA_UInt16 scmMinimumIterationWaitTime = 1; + static const UA_UInt16 scmMaximumIterationWaitTime = 10; + + /** * This class is used to store who is the parent of each method. This need comes from the fact when creating objects that have methods, * the method nodeId of every instance is the same as the method nodeID of the Object type. We can then use a CREATE_METHOD action pointing to this instance of the method, diff --git a/src/stdfblib/ita/OPCUA_DEV.h b/src/stdfblib/ita/OPCUA_DEV.h index 4673f32e0..749d31fb0 100644 --- a/src/stdfblib/ita/OPCUA_DEV.h +++ b/src/stdfblib/ita/OPCUA_DEV.h @@ -21,7 +21,7 @@ class OPCUA_DEV : public RMT_DEV { OPCUA_MGR mOPCUAMgr; - OPCUA_DEV(const std::string &paMGRID); + OPCUA_DEV(const std::string &paMGRID = "localhost:61499"); virtual ~OPCUA_DEV(); virtual int startDevice(void);