Skip to content

Commit

Permalink
add cmake variable for max interval time
Browse files Browse the repository at this point in the history
  • Loading branch information
cochicde authored and azoitl committed Jan 25, 2025
1 parent 27ca5b1 commit c4c8a01
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 6 deletions.
6 changes: 5 additions & 1 deletion src/com/opc_ua/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,8 @@ if (FORTE_COM_OPC_UA)
SET(FORTE_COM_OPC_UA_PORT 4840 CACHE STRING "Port where the OPC_UA server will listen")
SET(FORTE_COM_OPC_UA_SERVER_PUB_INTERVAL 100.0 CACHE STRING "OPC UA Server publishing interval in ms")
SET(FORTE_COM_OPC_UA_CLIENT_PUB_INTERVAL 100.0 CACHE STRING "OPC UA Client requested publishing interval via OPC UA data subscription in ms")
SET(FORTE_COM_OPC_UA_SERVER_MAX_ITERATION_INTERVAL 10 CACHE STRING "The maximum time in OPC UA server will wait to iterate again")

SET(FORTE_COM_OPC_UA_MULTICAST OFF CACHE BOOL "Enable multicast support for OPC UA and registering with LDS")
SET(FORTE_COM_OPC_UA_INCLUDE_DIR "" CACHE PATH "ABSOLUTE path to open62541.h file in the OPC UA project")
SET(FORTE_COM_OPC_UA_LIB_DIR "" CACHE PATH "ABSOLUTE path to OPC UA folder with object library FORTE_COM_OPC_UA_LIB")
Expand Down Expand Up @@ -77,7 +79,9 @@ if (FORTE_COM_OPC_UA)
message(SEND_ERROR "OPC UA library not found '${FORTE_COM_OPC_UA_LIB}'. Check the value of FORTE_COM_OPC_UA_LIB_DIR and optionally define an absolute path for FORTE_COM_OPC_UA_LIB.")
endif()

forte_add_custom_configuration("#define FORTE_COM_OPC_UA_PORT ${FORTE_COM_OPC_UA_PORT}")
forte_add_custom_configuration("#define FORTE_COM_OPC_UA_PORT ${FORTE_COM_OPC_UA_PORT}")
forte_add_custom_configuration("#define FORTE_COM_OPC_UA_SERVER_MAX_ITERATION_INTERVAL ${FORTE_COM_OPC_UA_SERVER_MAX_ITERATION_INTERVAL}")
forte_add_custom_configuration("extern TForteUInt16 gOpcuaServerMaxIterationInterval\;")
forte_add_custom_configuration("extern TForteUInt16 gOpcuaServerPort\;")
forte_add_custom_configuration("#include <string>")
forte_add_custom_configuration("extern std::string gOpcuaClientConfigFile\;")
Expand Down
6 changes: 4 additions & 2 deletions src/com/opc_ua/opcua_local_handler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ const char *const COPC_UA_Local_Handler::mEnglishLocaleForNodes = "en-US";
const char *const COPC_UA_Local_Handler::mDefaultDescriptionForVariableNodes = "Digital port of Function Block";

TForteUInt16 gOpcuaServerPort = FORTE_COM_OPC_UA_PORT;
TForteUInt16 gOpcuaServerMaxIterationInterval = FORTE_COM_OPC_UA_SERVER_MAX_ITERATION_INTERVAL;

using namespace forte::com_infra;
using namespace std::string_literals;
Expand Down Expand Up @@ -108,8 +109,9 @@ void COPC_UA_Local_Handler::run() {

if(timeToSleepMs < scmMinimumIterationWaitTime) {
timeToSleepMs = scmMinimumIterationWaitTime;
} else if (timeToSleepMs > scmMaximumIterationWaitTime) {
timeToSleepMs = scmMaximumIterationWaitTime;
}
else if(timeToSleepMs > gOpcuaServerMaxIterationInterval) {
timeToSleepMs = gOpcuaServerMaxIterationInterval;
}

mServerNeedsIteration.timedWait(static_cast<TForteUInt64>(timeToSleepMs) * 1000000ULL);
Expand Down
3 changes: 0 additions & 3 deletions src/com/opc_ua/opcua_local_handler.h
Original file line number Diff line number Diff line change
Expand Up @@ -369,9 +369,6 @@ 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

0 comments on commit c4c8a01

Please sign in to comment.