Skip to content

Commit 2260229

Browse files
authored
Update libcosim to 0.11.1 (#118)
* Update libcosim to 0.11.1
1 parent 61b180b commit 2260229

File tree

3 files changed

+26
-4
lines changed

3 files changed

+26
-4
lines changed

CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ endif()
3636
# Dependencies
3737
# ==============================================================================
3838

39+
find_package(libcbor REQUIRED)
3940
find_package(libcosim REQUIRED)
4041
find_package(Boost REQUIRED COMPONENTS log program_options)
4142

conanfile.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ def requirements(self):
1313
self.tool_requires("cmake/[>=3.19]")
1414
if self.settings.os == "Linux":
1515
self.tool_requires("patchelf/[<0.18]")
16-
self.requires("libcosim/0.10.4@osp/stable")
16+
self.requires("libcosim/0.11.1@osp/stable")
1717
self.requires("boost/[>=1.71]")
1818

1919
def layout(self):

src/run.cpp

Lines changed: 24 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,8 @@
2121

2222
#include <chrono>
2323
#include <memory>
24+
#include <variant>
25+
#include <type_traits>
2426

2527

2628
void run_subcommand::setup_options(
@@ -72,6 +74,12 @@ void run_subcommand::setup_options(
7274
namespace
7375
{
7476

77+
template<class... Ts>
78+
struct overloaded : Ts... { using Ts::operator()...; };
79+
80+
template<class... Ts>
81+
overloaded(Ts...) -> overloaded<Ts...>;
82+
7583
cosim::execution load_system_structure(
7684
const cosim::filesystem::path& path,
7785
cosim::model_uri_resolver& uriResolver,
@@ -82,9 +90,19 @@ cosim::execution load_system_structure(
8290
(cosim::filesystem::is_directory(path) &&
8391
cosim::filesystem::exists(path / "OspSystemStructure.xml"))) {
8492
const auto config = cosim::load_osp_config(path, uriResolver);
85-
auto execution = cosim::execution(
86-
startTime,
87-
std::make_shared<cosim::fixed_step_algorithm>(config.step_size, workerThreadCount));
93+
std::shared_ptr<cosim::algorithm> algorithm;
94+
95+
std::visit(
96+
overloaded{
97+
[&algorithm, &workerThreadCount](const cosim::fixed_step_algorithm_params& params) {
98+
algorithm = std::make_shared<cosim::fixed_step_algorithm>(params, workerThreadCount);
99+
},
100+
[&algorithm, &workerThreadCount](const cosim::ecco_algorithm_params& params) {
101+
algorithm = std::make_shared<cosim::ecco_algorithm>(params, workerThreadCount);
102+
}},
103+
config.algorithm_configuration);
104+
105+
auto execution = cosim::execution(startTime, algorithm);
88106
cosim::inject_system_structure(
89107
execution,
90108
config.system_structure,
@@ -154,6 +172,7 @@ class progress_monitor : public cosim::observer
154172
: logger_(startTime, duration, percentIncrement, mrProgressResolution)
155173
{}
156174

175+
157176
private:
158177
void simulator_added(cosim::simulator_index, cosim::observable*, cosim::time_point) override {}
159178
void simulator_removed(cosim::simulator_index, cosim::time_point) override {}
@@ -184,6 +203,8 @@ class progress_monitor : public cosim::observer
184203
override
185204
{}
186205

206+
void state_restored(cosim::step_number, cosim::time_point) override {}
207+
187208
progress_logger logger_;
188209
};
189210
} // namespace

0 commit comments

Comments
 (0)