diff --git a/README.md b/README.md index fa6b347..8a3585d 100644 --- a/README.md +++ b/README.md @@ -12,13 +12,14 @@ The following FMI parameters can be set. Either `sender` or `receiver` have to be set to _true_. Otherwise, the FMU will return with an error. -| Type | Parameter | Default | Description | -|---------|------------|-------------|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------| -| Boolean | `sender` | _true_ | Set if Proxy shall send data via TCP/IP | -| Boolean | `receiver` | _false_ | Set if Proxy shall receive data via TCP/IP | -| Boolean | `pushpull` | _false_ | If true, use [Push/Pull](https://learning-0mq-with-pyzmq.readthedocs.io/en/latest/pyzmq/patterns/pushpull.html) ZeroMQ configuration, if false, use [Client/Server](https://learning-0mq-with-pyzmq.readthedocs.io/en/latest/pyzmq/patterns/client_server.html) config. | -| String | `ip` | _127.0.0.1_ | IP address of TCP connection | -| String | `port` | _3456_ | Port of TCP connection | +| Type | Parameter | Default | Description | +|---------|------------------|-------------|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| +| Boolean | `sender` | _true_ | Set if Proxy shall send data via TCP/IP | +| Boolean | `receiver` | _false_ | Set if Proxy shall receive data via TCP/IP | +| Boolean | `pushpull` | _false_ | If true, use [Push/Pull](https://learning-0mq-with-pyzmq.readthedocs.io/en/latest/pyzmq/patterns/pushpull.html) ZeroMQ configuration, if false, use [Client/Server](https://learning-0mq-with-pyzmq.readthedocs.io/en/latest/pyzmq/patterns/client_server.html) config. | +| String | `ip` | _127.0.0.1_ | IP address of TCP connection | +| String | `port` | _3456_ | Port of TCP connection | +| Integer | `wait_time_in_s` | _5_ | In Client/Server configuration: wait time to receive message after request. When the network proxy does not receive a message in this wait time, it will throw an error. If this is set to _0_, the network proxy will wait indefinitely. | ## Interface diff --git a/src/OSMP.cpp b/src/OSMP.cpp index 80316c3..483c35f 100644 --- a/src/OSMP.cpp +++ b/src/OSMP.cpp @@ -136,6 +136,7 @@ fmi2Status OSMP::DoInit() SetFmiPushPull(1); SetFmiIp("127.0.0.1"); SetFmiPort("3456"); + SetFmiWaitTime(5); return fmi2OK; } @@ -167,8 +168,11 @@ fmi2Status OSMP::DoExitInitializationMode() { socket_ = zmq::socket_t(context_, ZMQ_REP); } - const int wait_time_ms = 5000; - zmq_setsockopt(socket_, ZMQ_SNDTIMEO, &wait_time_ms, sizeof(wait_time_ms)); + if (FmiWaitTime() > 0) + { + const int wait_time_ms = FmiWaitTime() * 1000; + zmq_setsockopt(socket_, ZMQ_SNDTIMEO, &wait_time_ms, sizeof(wait_time_ms)); + } socket_.bind(protocol); } else @@ -181,8 +185,11 @@ fmi2Status OSMP::DoExitInitializationMode() { socket_ = zmq::socket_t(context_, ZMQ_REQ); } - const int wait_time_ms = 5000; - zmq_setsockopt(socket_, ZMQ_RCVTIMEO, &wait_time_ms, sizeof(wait_time_ms)); + if (FmiWaitTime() > 0) + { + const int wait_time_ms = FmiWaitTime() * 1000; + zmq_setsockopt(socket_, ZMQ_RCVTIMEO, &wait_time_ms, sizeof(wait_time_ms)); + } socket_.connect(protocol); } diff --git a/src/OSMP.h b/src/OSMP.h index b90dc39..dab6c0c 100644 --- a/src/OSMP.h +++ b/src/OSMP.h @@ -54,7 +54,8 @@ #define FMI_INTEGER_OSI_OUT_BASELO_IDX 3 #define FMI_INTEGER_OSI_OUT_BASEHI_IDX 4 #define FMI_INTEGER_OSI_OUT_SIZE_IDX 5 -#define FMI_INTEGER_LAST_IDX FMI_INTEGER_OSI_OUT_SIZE_IDX +#define FMI_INTEGER_WAIT_TIME_IDX 6 +#define FMI_INTEGER_LAST_IDX FMI_INTEGER_WAIT_TIME_IDX #define FMI_INTEGER_VARS (FMI_INTEGER_LAST_IDX + 1) /* Real Variables */ @@ -277,4 +278,12 @@ class OSMP { string_vars_[FMI_STRING_PORT_IDX] = value; } + int FmiWaitTime() + { + return integer_vars_[FMI_INTEGER_WAIT_TIME_IDX]; + } + void SetFmiWaitTime(fmi2Integer value) + { + integer_vars_[FMI_INTEGER_WAIT_TIME_IDX] = value; + } }; diff --git a/src/modelDescription.in.xml b/src/modelDescription.in.xml index 3df024c..a5e5393 100644 --- a/src/modelDescription.in.xml +++ b/src/modelDescription.in.xml @@ -60,6 +60,9 @@ + + +