Skip to content

Commit

Permalink
add maximum wait for opcua server iteration
Browse files Browse the repository at this point in the history
  • Loading branch information
cochicde authored and azoitl committed Jan 25, 2025
1 parent c6a7fec commit 27ca5b1
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 1 deletion.
3 changes: 3 additions & 0 deletions src/com/opc_ua/opcua_local_handler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<TForteUInt64>(timeToSleepMs) * 1000000ULL);
Expand Down
3 changes: 3 additions & 0 deletions src/com/opc_ua/opcua_local_handler.h
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
2 changes: 1 addition & 1 deletion src/stdfblib/ita/OPCUA_DEV.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit 27ca5b1

Please sign in to comment.