diff --git a/.github/workflows/fmu_checker.yml b/.github/workflows/fmu_checker.yml
index 9d75c0a..aae10c2 100644
--- a/.github/workflows/fmu_checker.yml
+++ b/.github/workflows/fmu_checker.yml
@@ -17,7 +17,7 @@ jobs:
key: ${{ runner.os }}-model-fmu
- name: Install FMPy
- run: python -m pip install fmpy[complete]
+ run: python -m pip install fmpy==0.3.16
- name: Run FMPy Validate
working-directory: /tmp/model_fmu
diff --git a/.github/workflows/srmd-validator.yml b/.github/workflows/srmd-validator.yml
index 86d86fe..cf2279d 100644
--- a/.github/workflows/srmd-validator.yml
+++ b/.github/workflows/srmd-validator.yml
@@ -8,25 +8,25 @@ jobs:
name: SRMD Validator
runs-on: ubuntu-latest
steps:
- - name: Checkout
- uses: actions/checkout@master
+ - name: Checkout
+ uses: actions/checkout@master
- - name: Get Sensor Model Testing
- run: git clone https://github.com/openMSL/sl-1-5-sensor-model-testing.git
+ - name: Get SRMD Validator
+ run: git clone https://github.com/openMSL/sl-5-1-srmd-validator.git
- - name: Init Submodules
- working-directory: sl-1-5-sensor-model-testing
- run: git submodule update --init --recursive
+ - name: Init Submodules
+ working-directory: sl-5-1-srmd-validator
+ run: git submodule update --init --recursive
- - name: Install Dependencies
- run: pip3 install xmlschema
+ - name: Install Dependencies
+ run: pip3 install xmlschema
- - name: Validate SRMD
- working-directory: sl-1-5-sensor-model-testing/src/srmd-validator
- run: python3 srmd-validator.py
+ - name: Validate SRMD
+ working-directory: sl-5-1-srmd-validator
+ run: python3 srmd-validator.py
- - name: Commit ID
- working-directory: sl-1-5-sensor-model-testing
- run: |
- echo "Commit ID: "
- echo $(git rev-parse --short HEAD)
+ - name: Commit ID
+ working-directory: sl-5-1-srmd-validator
+ run: |
+ echo "Commit ID: "
+ echo $(git rev-parse --short HEAD)
diff --git a/README.md b/README.md
index 6b5f44b..fa6b347 100644
--- a/README.md
+++ b/README.md
@@ -12,12 +12,13 @@ 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 |
-| 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 |
## Interface
diff --git a/src/OSMP.cpp b/src/OSMP.cpp
index 8da5406..80316c3 100644
--- a/src/OSMP.cpp
+++ b/src/OSMP.cpp
@@ -1,6 +1,7 @@
//
// Copyright 2016 -- 2018 PMSF IT Consulting Pierre R. Mai
// Copyright 2023 BMW AG
+// Copyright 2023 Persival GmbH
// SPDX-License-Identifier: MPL-2.0
//
@@ -132,11 +133,10 @@ fmi2Status OSMP::DoInit()
// Set default values
SetFmiSender(1);
SetFmiReceiver(0);
+ SetFmiPushPull(1);
SetFmiIp("127.0.0.1");
SetFmiPort("3456");
- // todo: set default values
-
return fmi2OK;
}
@@ -156,22 +156,36 @@ fmi2Status OSMP::DoExitInitializationMode()
string address = "tcp://" + FmiIp() + ":" + FmiPort();
std::cout << address << std::endl;
const char* protocol = address.c_str();
+
if (FmiSender() != 0)
{
- socket_ = zmq::socket_t(context_, ZMQ_PUSH);
+ if (FmiPushPull() != 0) // Push/Pull configuration
+ {
+ socket_ = zmq::socket_t(context_, ZMQ_PUSH);
+ }
+ else // Server/Client configuration
+ {
+ 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));
socket_.bind(protocol);
- std::cout << "push" << std::endl;
}
else
{
- socket_ = zmq::socket_t(context_, ZMQ_PULL);
+ if (FmiPushPull() != 0) // Push/Pull configuration
+ {
+ socket_ = zmq::socket_t(context_, ZMQ_PULL);
+ }
+ else // Server/Client configuration
+ {
+ 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));
socket_.connect(protocol);
- std::cout << "pull" << std::endl;
}
+
return fmi2OK;
}
@@ -193,6 +207,11 @@ fmi2Status OSMP::DoCalc(fmi2Real current_communication_point, fmi2Real communica
if (FmiSender() != 0)
{
+ if (FmiPushPull() == 0) // Server/Client configuration
+ {
+ zmq::message_t request_message;
+ socket_.recv(request_message, zmq::recv_flags::none);
+ }
zmq::message_t send_message(buffer, buffer_size, nullptr);
auto success = socket_.send(send_message, zmq::send_flags::none);
if (success.has_value())
@@ -207,6 +226,13 @@ fmi2Status OSMP::DoCalc(fmi2Real current_communication_point, fmi2Real communica
}
else if (FmiReceiver() != 0)
{
+ if (FmiPushPull() == 0) // Server/Client configuration
+ {
+ std::stringstream s;
+ s << "ready";
+ zmq::message_t send_message(s.str().data(), s.str().size());
+ socket_.send(send_message, zmq::send_flags::none);
+ }
zmq::message_t rec_message;
auto success = socket_.recv(rec_message, zmq::recv_flags::none);
if (success.has_value())
@@ -224,6 +250,7 @@ fmi2Status OSMP::DoCalc(fmi2Real current_communication_point, fmi2Real communica
NormalLog("OSMP", "Either sender or receiver has to be set to true.");
output_status = fmi2Error;
}
+
return output_status;
}
diff --git a/src/OSMP.h b/src/OSMP.h
index 72044e0..b90dc39 100644
--- a/src/OSMP.h
+++ b/src/OSMP.h
@@ -1,6 +1,7 @@
//
// Copyright 2016 -- 2018 PMSF IT Consulting Pierre R. Mai
// Copyright 2023 BMW AG
+// Copyright 2023 Persival GmbH
// SPDX-License-Identifier: MPL-2.0
//
@@ -42,7 +43,8 @@
#define FMI_BOOLEAN_VALID_IDX 0
#define FMI_BOOLEAN_SENDER_IDX 1
#define FMI_BOOLEAN_RECEIVER_IDX 2
-#define FMI_BOOLEAN_LAST_IDX FMI_BOOLEAN_RECEIVER_IDX
+#define FMI_BOOLEAN_PUSHPULL_IDX 3
+#define FMI_BOOLEAN_LAST_IDX FMI_BOOLEAN_PUSHPULL_IDX
#define FMI_BOOLEAN_VARS (FMI_BOOLEAN_LAST_IDX + 1)
/* Integer Variables */
@@ -177,7 +179,7 @@ class OSMP
}
#endif
#ifdef PUBLIC_LOGGING
- if (logging_on_ && (logging_categories_.count(category) != 0u))
+ if (logging_on_ && (logging_categories_.count(category) != 0U))
{
functions_.logger(functions_.componentEnvironment, instance_name_.c_str(), fmi2OK, category, buffer);
}
@@ -227,14 +229,52 @@ class OSMP
zmq::socket_t socket_;
/* Simple Accessors */
- fmi2Boolean FmiValid() { return boolean_vars_[FMI_BOOLEAN_VALID_IDX]; }
- void SetFmiValid(fmi2Boolean value) { boolean_vars_[FMI_BOOLEAN_VALID_IDX] = value; }
- fmi2Boolean FmiReceiver() { return boolean_vars_[FMI_BOOLEAN_RECEIVER_IDX]; }
- void SetFmiReceiver(fmi2Boolean value) { boolean_vars_[FMI_BOOLEAN_RECEIVER_IDX] = value; }
- fmi2Boolean FmiSender() { return boolean_vars_[FMI_BOOLEAN_SENDER_IDX]; }
- void SetFmiSender(fmi2Boolean value) { boolean_vars_[FMI_BOOLEAN_SENDER_IDX] = value; }
- string FmiIp() { return string_vars_[FMI_STRING_IP_IDX]; }
- void SetFmiIp(fmi2String value) { string_vars_[FMI_STRING_IP_IDX] = value; }
- string FmiPort() { return string_vars_[FMI_STRING_PORT_IDX]; }
- void SetFmiPort(fmi2String value) { string_vars_[FMI_STRING_PORT_IDX] = value; }
+ fmi2Boolean FmiValid()
+ {
+ return boolean_vars_[FMI_BOOLEAN_VALID_IDX];
+ }
+ void SetFmiValid(fmi2Boolean value)
+ {
+ boolean_vars_[FMI_BOOLEAN_VALID_IDX] = value;
+ }
+ fmi2Boolean FmiReceiver()
+ {
+ return boolean_vars_[FMI_BOOLEAN_RECEIVER_IDX];
+ }
+ void SetFmiReceiver(fmi2Boolean value)
+ {
+ boolean_vars_[FMI_BOOLEAN_RECEIVER_IDX] = value;
+ }
+ fmi2Boolean FmiSender()
+ {
+ return boolean_vars_[FMI_BOOLEAN_SENDER_IDX];
+ }
+ void SetFmiSender(fmi2Boolean value)
+ {
+ boolean_vars_[FMI_BOOLEAN_SENDER_IDX] = value;
+ }
+ fmi2Boolean FmiPushPull()
+ {
+ return boolean_vars_[FMI_BOOLEAN_PUSHPULL_IDX];
+ }
+ void SetFmiPushPull(fmi2Boolean value)
+ {
+ boolean_vars_[FMI_BOOLEAN_PUSHPULL_IDX] = value;
+ }
+ string FmiIp()
+ {
+ return string_vars_[FMI_STRING_IP_IDX];
+ }
+ void SetFmiIp(fmi2String value)
+ {
+ string_vars_[FMI_STRING_IP_IDX] = value;
+ }
+ string FmiPort()
+ {
+ return string_vars_[FMI_STRING_PORT_IDX];
+ }
+ void SetFmiPort(fmi2String value)
+ {
+ string_vars_[FMI_STRING_PORT_IDX] = value;
+ }
};
diff --git a/src/modelDescription.in.xml b/src/modelDescription.in.xml
index b5b946a..3df024c 100644
--- a/src/modelDescription.in.xml
+++ b/src/modelDescription.in.xml
@@ -51,6 +51,9 @@
+
+
+