coral
A C++ library for distributed co-simulation
Public Member Functions | List of all members
coral::fmi::SlaveInstance1 Class Reference

An FMI 1.0 co-simulation slave instance. More...

#include "coral/fmi/fmu1.hpp"

Inheritance diagram for coral::fmi::SlaveInstance1:
coral::fmi::SlaveInstance coral::slave::Instance

Public Member Functions

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...
 
std::shared_ptr< coral::fmi::FMUFMU () const override
 Returns a reference to the FMU of which this is an instance.
 
std::shared_ptr< coral::fmi::FMU1FMU1 () const
 Returns the same object as FMU(), only statically typed as an FMU1.
 
fmi1_import_t * FmilibHandle () const
 Returns the underlying C API handle (for FMI Library)
 

Detailed Description

An FMI 1.0 co-simulation slave instance.

Member Function Documentation

bool coral::fmi::SlaveInstance1::DoStep ( coral::model::TimePoint  currentT,
coral::model::TimeDuration  deltaT 
)
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.

Returns
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.
Note
Currently, retrying a failed time step is not supported, but this is planned for a future version.

Implements coral::slave::Instance.

bool coral::fmi::SlaveInstance1::GetBooleanVariable ( coral::model::VariableID  variable) const
overridevirtual

Returns the value of a boolean variable.

Exceptions
std::logic_errorif there is no boolean variable with the given ID.

Implements coral::slave::Instance.

int coral::fmi::SlaveInstance1::GetIntegerVariable ( coral::model::VariableID  variable) const
overridevirtual

Returns the value of an integer variable.

Exceptions
std::logic_errorif there is no integer variable with the given ID.

Implements coral::slave::Instance.

double coral::fmi::SlaveInstance1::GetRealVariable ( coral::model::VariableID  variable) const
overridevirtual

Returns the value of a real variable.

Exceptions
std::logic_errorif there is no real variable with the given ID.

Implements coral::slave::Instance.

std::string coral::fmi::SlaveInstance1::GetStringVariable ( coral::model::VariableID  variable) const
overridevirtual

Returns the value of a string variable.

Exceptions
std::logic_errorif there is no string variable with the given ID.

Implements coral::slave::Instance.

bool coral::fmi::SlaveInstance1::SetBooleanVariable ( coral::model::VariableID  variable,
bool  value 
)
overridevirtual

Sets the value of a boolean variable.

Returns
Whether the value was set successfully. This could be false if, for example, the value is out of range.
Exceptions
std::logic_errorIf there is no boolean variable with the given ID.

Implements coral::slave::Instance.

bool coral::fmi::SlaveInstance1::SetIntegerVariable ( coral::model::VariableID  variable,
int  value 
)
overridevirtual

Sets the value of an integer variable.

Returns
Whether the value was set successfully. This could be false if, for example, the value is out of range.
Exceptions
std::logic_errorIf there is no integer variable with the given ID.

Implements coral::slave::Instance.

bool coral::fmi::SlaveInstance1::SetRealVariable ( coral::model::VariableID  variable,
double  value 
)
overridevirtual

Sets the value of a real variable.

Returns
Whether the value was set successfully. This could be false if, for example, the value is out of range.
Exceptions
std::logic_errorIf there is no real variable with the given ID.

Implements coral::slave::Instance.

bool coral::fmi::SlaveInstance1::SetStringVariable ( coral::model::VariableID  variable,
const std::string value 
)
overridevirtual

Sets the value of a string variable.

Returns
Whether the value was set successfully. This could be false if, for example, the value is out of range.
Exceptions
std::logic_errorIf there is no string variable with the given ID.

Implements coral::slave::Instance.

void coral::fmi::SlaveInstance1::Setup ( const std::string slaveName,
const std::string executionName,
coral::model::TimePoint  startTime,
coral::model::TimePoint  stopTime,
bool  adaptiveStepSize,
double  relativeTolerance 
)
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.)

Parameters
[in]slaveNameThe name of the slave in the current execution. May be empty if this feature is not used.
[in]executionNameThe name of the current execution. May be empty if this feature is not used.
[in]startTimeThe earliest possible time point for the simulation.
[in]stopTimeThe latest possible time point for the simulation. May be infinity if there is no defined stop time.
[in]adaptiveStepSizeWhether the step size is being controlled by error estimation.
[in]relativeToleranceOnly 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.


The documentation for this class was generated from the following file: