[][src]Trait fmi::instance::Common

pub trait Common: Hash {
    fn name(&self) -> &str;
fn import(&self) -> &Rc<Import>;
fn version(&self) -> Result<&str>;
fn set_debug_logging(
        &self,
        logging_on: bool,
        categories: &[&str]
    ) -> Result<()>;
fn setup_experiment(
        &self,
        tolerance: Option<f64>,
        start_time: f64,
        stop_time: Option<f64>
    ) -> Result<()>;
fn enter_initialization_mode(&self) -> Result<()>;
fn exit_initialization_mode(&self) -> Result<()>;
fn terminate(&self) -> Result<()>;
fn reset(&self) -> Result<()>;
fn get_real(&self, sv: &ScalarVariable) -> Result<f64>;
fn get_integer(&mut self, sv: &ScalarVariable) -> Result<i64>;
fn get_boolean(&mut self, sv: &ScalarVariable) -> Result<bool>;
fn get_string(&mut self, sv: &ScalarVariable) -> Result<String>;
fn set_real(&self, vrs: &[u64], values: &[f64]) -> Result<()>;
fn set_integer(&self, sv: &ScalarVariable, value: i64) -> Result<()>;
fn set_boolean(&self, sv: &ScalarVariable, value: bool) -> Result<()>;
fn set_string(&self, sv: &ScalarVariable, value: &str) -> Result<()>; }

Interface common to both ModelExchange and CoSimulation

Required methods

fn name(&self) -> &str

The instance name

fn import(&self) -> &Rc<Import>

fn version(&self) -> Result<&str>

The FMI-standard version string

fn set_debug_logging(&self, logging_on: bool, categories: &[&str]) -> Result<()>

fn setup_experiment(
    &self,
    tolerance: Option<f64>,
    start_time: f64,
    stop_time: Option<f64>
) -> Result<()>

Informs the FMU to setup the experiment. This function can be called after instantiate() and before enter_initialization_mode() is called.

Tolerance control

  • Under ModelExchange: If tolerance = Some(..) then the model is called with a numerical integration scheme where the step size is controlled by using tolerance for error estimation (usually as relative tolerance). In such a case, all numerical algorithms used inside the model (for example to solve non-linear algebraic equations) should also operate with an error estimation of an appropriate smaller relative tolerance.
  • Under CoSimulation: If tolerance = Some(..) then the communication interval of the slave is controlled by error estimation. In case the slave utilizes a numerical integrator with variable step size and error estimation, it is suggested to use tolerance for the error estimation of the internal integrator (usually as relative tolerance). An FMU for Co-Simulation might ignore this argument.

Start and Stop times

The arguments start_time and stop_time can be used to check whether the model is valid within the given boundaries. Argument start_timeis the fixed initial value of the independent variable [if the independent variable is "time",start_timeis the starting time of initializaton]. Ifstop_timeisSome(..), then stop_timeis the defined final value of the independent variable [if the independent variable is "time",stop_timeis the stop time of the simulation] and if the environment tries to compute paststop_timethe FMU has to returnError. If stop_timeisNone()`, then no final value of the independent variable is defined.

fn enter_initialization_mode(&self) -> Result<()>

Informs the FMU to enter Initialization Mode.

Before calling this function, all variables with attribute <ScalarVariable initial = "exact" or "approx"> can be set with the set() function. Setting other variables is not allowed. Furthermore, setup_experiment() must be called at least once before calling enter_initialization_mode(), in order that start_time is defined.

fn exit_initialization_mode(&self) -> Result<()>

Informs the FMU to exit Initialization Mode.

Under ModelExchange this function switches off all initialization equations and the FMU enters implicitely Event Mode, that is all continuous-time and active discrete-time equations are available.

fn terminate(&self) -> Result<()>

Informs the FMU that the simulation run is terminated.

After calling this function, the final values of all variables can be inquired with the fmi2GetXXX(..) functions. It is not allowed to call this function after one of the functions returned with a status flag of fmi2Error or fmi2Fatal.

fn reset(&self) -> Result<()>

Is called by the environment to reset the FMU after a simulation run.

The FMU goes into the same state as if fmi2Instantiate would have been called. All variables have their default values. Before starting a new run, fmi2SetupExperiment and fmi2EnterInitializationMode have to be called.

fn get_real(&self, sv: &ScalarVariable) -> Result<f64>

fn get_integer(&mut self, sv: &ScalarVariable) -> Result<i64>

fn get_boolean(&mut self, sv: &ScalarVariable) -> Result<bool>

fn get_string(&mut self, sv: &ScalarVariable) -> Result<String>

fn set_real(&self, vrs: &[u64], values: &[f64]) -> Result<()>

Set real values

Arguments

  • vrs - a slice of u64 ValueReferences
  • values - a slice of f64 values to set

fn set_integer(&self, sv: &ScalarVariable, value: i64) -> Result<()>

fn set_boolean(&self, sv: &ScalarVariable, value: bool) -> Result<()>

fn set_string(&self, sv: &ScalarVariable, value: &str) -> Result<()>

Loading content...

Implementors

impl<A> Common for Instance<A> where
    A: FmiApi
[src]

Loading content...