open-simulation-platform / libcosim

OSP C++ co-simulation library
https://open-simulation-platform.github.io/libcosim
Mozilla Public License 2.0
61 stars 10 forks source link

Optionally selecting a subset of variables to observe in cosim::last_value_observer(provider) #686

Open davidhjp01 opened 2 years ago

davidhjp01 commented 2 years ago

Currently cosim::last_value_observer caches all port values (variables) of the simulators in every simulation step. However, in many scenarios, this may be not necessary. For example, if a simulator uses the observer to display data for only a single FMU at any given time. To improve simulation performance, it would be better to give a master algorithm an ability to capture only a subset of a model's port values in each step.

In this regard, I suggest to add additional methods in cosim::last_value_provider (A parent of cosim::last_value_observer) and cosim::slave_value_provider to enable this 'optional' feature.

For example:

virtual void cosim::last_value_provider::select_variables(simulator_index sim, gsl::span<const value_reference> variables) = 0;

virtual void cosim::last_value_provider::unselect_variables(simulator_index sim, gsl::span<const value_reference> variables) = 0;

virtual void cosim::last_value_provider::clear_variables() = 0;