coral
A C++ library for distributed co-simulation
|
A slave instance wrapper that logs variable values to a file. More...
#include "coral/slave/logging.hpp"
Public Member Functions | |
LoggingInstance (std::shared_ptr< Instance > instance, const std::string &outputFilePrefix=std::string{}) | |
Constructs a LoggingInstance that wraps the given slave instance and adds logging to it. More... | |
coral::model::SlaveTypeDescription | TypeDescription () const override |
Returns an object that describes the slave type. | |
void | Setup (const std::string &slaveName, const std::string &executionName, coral::model::TimePoint startTime, coral::model::TimePoint stopTime, bool adaptiveStepSize, double relativeTolerance) override |
Instructs the slave to perform pre-simulation setup and enter initialisation mode. More... | |
void | StartSimulation () override |
Informs the slave that the initialisation stage ends and the simulation begins. | |
void | EndSimulation () override |
Informs the slave that the simulation run has ended. | |
bool | DoStep (coral::model::TimePoint currentT, coral::model::TimeDuration deltaT) override |
Performs model calculations for the time step which starts at the time point currentT and has a duration of deltaT . More... | |
double | GetRealVariable (coral::model::VariableID variable) const override |
Returns the value of a real variable. More... | |
int | GetIntegerVariable (coral::model::VariableID variable) const override |
Returns the value of an integer variable. More... | |
bool | GetBooleanVariable (coral::model::VariableID variable) const override |
Returns the value of a boolean variable. More... | |
std::string | GetStringVariable (coral::model::VariableID variable) const override |
Returns the value of a string variable. More... | |
bool | SetRealVariable (coral::model::VariableID variable, double value) override |
Sets the value of a real variable. More... | |
bool | SetIntegerVariable (coral::model::VariableID variable, int value) override |
Sets the value of an integer variable. More... | |
bool | SetBooleanVariable (coral::model::VariableID variable, bool value) override |
Sets the value of a boolean variable. More... | |
bool | SetStringVariable (coral::model::VariableID variable, const std::string &value) override |
Sets the value of a string variable. More... | |
A slave instance wrapper that logs variable values to a file.
|
explicit |
Constructs a LoggingInstance that wraps the given slave instance and adds logging to it.
[in] | instance | The slave instance to be wrapped by this one. |
[in] | outputFilePrefix | A directory and prefix for a CSV output file. An execution- and slave-specific name as well as a ".csv" extension will be appended to this name. If no prefix is required, and the string only contains a directory name, it should end with a directory separator (a slash). |
|
overridevirtual |
Performs model calculations for the time step which starts at the time point currentT
and has a duration of deltaT
.
If this is not the first time step, it can be assumed that the previous time step ended at currentT
. It can also be assumed that currentT
is greater than or equal to the start time, and currentT+deltaT
is less than or equal to the stop time, specified in the Setup() call.
true
if the model calculations for the given time step were successfully carried out, or false
if they were not because the time step was too long.Implements coral::slave::Instance.
|
overridevirtual |
Returns the value of a boolean variable.
std::logic_error | if there is no boolean variable with the given ID. |
Implements coral::slave::Instance.
|
overridevirtual |
Returns the value of an integer variable.
std::logic_error | if there is no integer variable with the given ID. |
Implements coral::slave::Instance.
|
overridevirtual |
Returns the value of a real variable.
std::logic_error | if there is no real variable with the given ID. |
Implements coral::slave::Instance.
|
overridevirtual |
Returns the value of a string variable.
std::logic_error | if there is no string variable with the given ID. |
Implements coral::slave::Instance.
|
overridevirtual |
Sets the value of a boolean variable.
false
if, for example, the value is out of range. std::logic_error | If there is no boolean variable with the given ID. |
Implements coral::slave::Instance.
|
overridevirtual |
Sets the value of an integer variable.
false
if, for example, the value is out of range. std::logic_error | If there is no integer variable with the given ID. |
Implements coral::slave::Instance.
|
overridevirtual |
Sets the value of a real variable.
false
if, for example, the value is out of range. std::logic_error | If there is no real variable with the given ID. |
Implements coral::slave::Instance.
|
overridevirtual |
Sets the value of a string variable.
false
if, for example, the value is out of range. std::logic_error | If there is no string variable with the given ID. |
Implements coral::slave::Instance.
|
overridevirtual |
Instructs the slave to perform pre-simulation setup and enter initialisation mode.
This function is called when the slave has been added to an execution. The arguments startTime
and stopTime
represent the time interval inside which the slave's model equations are required to be valid. (In other words, it is guaranteed that DoStep() will never be called with a time point outside this interval.)
[in] | slaveName | The name of the slave in the current execution. May be empty if this feature is not used. |
[in] | executionName | The name of the current execution. May be empty if this feature is not used. |
[in] | startTime | The earliest possible time point for the simulation. |
[in] | stopTime | The latest possible time point for the simulation. May be infinity if there is no defined stop time. |
[in] | adaptiveStepSize | Whether the step size is being controlled by error estimation. |
[in] | relativeTolerance | Only used if adaptiveStepSize == true , and then contains the relative tolerance of the step size controller. The slave may then use this for error estimation in its internal integrator. |
Implements coral::slave::Instance.