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..2316b42 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;
}
@@ -154,7 +155,6 @@ fmi2Status OSMP::DoExitInitializationMode()
{
string address = "tcp://" + FmiIp() + ":" + FmiPort();
- std::cout << address << std::endl;
const char* protocol = address.c_str();
if (FmiSender() != 0)
@@ -167,8 +167,13 @@ 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));
+ }
+ const int linger = 0;
+ zmq_setsockopt(socket_, ZMQ_LINGER, &linger, sizeof(linger));
socket_.bind(protocol);
}
else
@@ -181,8 +186,13 @@ 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));
+ }
+ const int linger = 0;
+ zmq_setsockopt(socket_, ZMQ_LINGER, &linger, sizeof(linger));
socket_.connect(protocol);
}
@@ -256,6 +266,12 @@ fmi2Status OSMP::DoCalc(fmi2Real current_communication_point, fmi2Real communica
fmi2Status OSMP::DoTerm()
{
+ string address = "tcp://" + FmiIp() + ":" + FmiPort();
+ const char* protocol = address.c_str();
+ socket_.unbind(protocol);
+ socket_.close();
+ context_.shutdown();
+ context_.close();
return fmi2OK;
}
diff --git a/src/OSMP.h b/src/OSMP.h
index b90dc39..b623149 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 */
@@ -125,7 +126,7 @@ class OSMP
static fmi2Status DoEnterInitializationMode();
fmi2Status DoExitInitializationMode();
fmi2Status DoCalc(fmi2Real current_communication_point, fmi2Real communication_step_size, fmi2Boolean no_set_fmu_state_prior_to_current_pointfmi_2_component);
- static fmi2Status DoTerm();
+ fmi2Status DoTerm();
void DoFree();
void ProcessMessage(zmq::message_t& message);
@@ -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 @@
+
+
+