diff --git a/CMakeLists.txt b/CMakeLists.txt index 73f603a..381b15f 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -36,6 +36,7 @@ endif() # Dependencies # ============================================================================== +find_package(libcbor REQUIRED) find_package(libcosim REQUIRED) find_package(Boost REQUIRED COMPONENTS log program_options) diff --git a/conanfile.py b/conanfile.py index bbae563..b0bff77 100644 --- a/conanfile.py +++ b/conanfile.py @@ -13,7 +13,7 @@ def requirements(self): self.tool_requires("cmake/[>=3.19]") if self.settings.os == "Linux": self.tool_requires("patchelf/[<0.18]") - self.requires("libcosim/0.10.4@osp/stable") + self.requires("libcosim/0.11.1@osp/stable") self.requires("boost/[>=1.71]") def layout(self): diff --git a/src/run.cpp b/src/run.cpp index ef74339..dc9f7ba 100644 --- a/src/run.cpp +++ b/src/run.cpp @@ -21,6 +21,8 @@ #include #include +#include +#include void run_subcommand::setup_options( @@ -72,6 +74,12 @@ void run_subcommand::setup_options( namespace { +template +struct overloaded : Ts... { using Ts::operator()...; }; + +template +overloaded(Ts...) -> overloaded; + cosim::execution load_system_structure( const cosim::filesystem::path& path, cosim::model_uri_resolver& uriResolver, @@ -82,9 +90,19 @@ cosim::execution load_system_structure( (cosim::filesystem::is_directory(path) && cosim::filesystem::exists(path / "OspSystemStructure.xml"))) { const auto config = cosim::load_osp_config(path, uriResolver); - auto execution = cosim::execution( - startTime, - std::make_shared(config.step_size, workerThreadCount)); + std::shared_ptr algorithm; + + std::visit( + overloaded{ + [&algorithm, &workerThreadCount](const cosim::fixed_step_algorithm_params& params) { + algorithm = std::make_shared(params, workerThreadCount); + }, + [&algorithm, &workerThreadCount](const cosim::ecco_algorithm_params& params) { + algorithm = std::make_shared(params, workerThreadCount); + }}, + config.algorithm_configuration); + + auto execution = cosim::execution(startTime, algorithm); cosim::inject_system_structure( execution, config.system_structure, @@ -154,6 +172,7 @@ class progress_monitor : public cosim::observer : logger_(startTime, duration, percentIncrement, mrProgressResolution) {} + private: void simulator_added(cosim::simulator_index, cosim::observable*, cosim::time_point) override {} void simulator_removed(cosim::simulator_index, cosim::time_point) override {} @@ -184,6 +203,8 @@ class progress_monitor : public cosim::observer override {} + void state_restored(cosim::step_number, cosim::time_point) override {} + progress_logger logger_; }; } // namespace