Instance

Struct Instance 

Source
pub struct Instance<'a, Tag> { /* private fields */ }
Expand description

An imported FMI 3.0 instance

Implementations§

Source§

impl<'a> Instance<'a, CS>

Source

pub fn new( import: &'a Fmi3Import, instance_name: &str, visible: bool, logging_on: bool, event_mode_used: bool, early_return_allowed: bool, required_intermediate_variables: &[fmi3ValueReference], ) -> Result<Self, Error>

Returns a new CoSimulation instance.

An FMU can be instantiated many times (provided capability flag can_be_instantiated_only_once_per_process = false).

Arguments:

  • instance_name: a unique identifier for the FMU instance. It is used to name the instance, for example, in error or information messages generated by one of the fmi3XXX functions. The argument instance_name must be a non empty string (in other words, must have at least one character that is not a white space). If only one FMU is simulated, either the attribute crate::fmi3::schema::Fmi3ModelDescription::model_name or one of

  • visible: Defines that the interaction with the user should be reduced to a minimum (no application window, no plotting, no animation, etc.). In other words, the FMU is executed in batch mode. If visible = true, the FMU is executed in interactive mode, and the FMU might require to explicitly acknowledge start of simulation / instantiation / initialization (acknowledgment is non-blocking).

  • logging_on: If = false, then any logging is disabled and the logMessage callback function must not be called by the FMU. If logging_on = true, then all LogCategories are enabled. The function crate::fmi3::traits::Common::set_debug_logging gives more detailed control about enabling specific LogCategories.

  • event_mode_used: If = true the importer can handle events. The flag may only be true, if has_event_mode = true, otherwise the FMU must raise an error. For FMUs that have clocks, event_mode_used = true is required.

  • early_return_allowed: If = true the importer can handle early return. Only in this case, crate::fmi3::traits::CoSimulation::do_step() may return with early_return = true.

  • required_intermediate_variables: An array of the value references of all input variables that the simulation algorithm intends to set and all output variables it intends to get during intermediate updates. This set may be empty (nRequiredIntermediateVariables = 0) when the simulation algorithm does not intend to use intermediate update. Only the variables in requiredIntermediateVariables may be accessed by the simulation algorithm using fmi3Set{VariableType} and fmi3Get{VariableType} during Intermediate Update Mode. All variables referenced in this set must be marked with the attribute intermediateUpdate = “true” in modelDescription.xml.

See: https://fmi-standard.org/docs/3.0.1/#fmi3InstantiateCoSimulation

Source§

impl<'a> Instance<'a, ME>

Source

pub fn new( import: &'a Fmi3Import, instance_name: &str, visible: bool, logging_on: bool, ) -> Result<Self, Error>

Source§

impl<'a> Instance<'a, SE>

Source

pub fn new( import: &'a Fmi3Import, instance_name: &str, visible: bool, logging_on: bool, ) -> Result<Self, Error>

Source§

impl<'a, Tag> Instance<'a, Tag>
where Self: Common,

Source

pub fn get_variable_dimensions(&mut self, var_refs: &[u32]) -> usize

Get the sum of the product of the dimensions of the variables with the given value references.

Trait Implementations§

Source§

impl CoSimulation for Instance<'_, CS>

Source§

fn enter_step_mode(&mut self) -> Result<Fmi3Res, Fmi3Error>

This function must be called to change from Event Mode into Step Mode in Co-Simulation.
Source§

fn do_step( &mut self, current_communication_point: f64, communication_step_size: f64, no_set_fmustate_prior_to_current_point: bool, event_handling_needed: &mut bool, terminate_simulation: &mut bool, early_return: &mut bool, last_successful_time: &mut f64, ) -> Result<Fmi3Res, Fmi3Error>

The importer requests the computation of the next time step. Read more
Source§

impl<'a, Tag> Common for Instance<'a, Tag>

Source§

fn get_version(&self) -> &str

The FMI-standard version string
Source§

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

The function controls the debug logging that is output by the FMU Read more
Source§

fn enter_configuration_mode(&mut self) -> Result<Fmi3Res, Fmi3Error>

Changes state to Reconfiguration Mode. Read more
Source§

fn exit_configuration_mode(&mut self) -> Result<Fmi3Res, Fmi3Error>

Exits the Configuration Mode and returns to state Instantiated. Read more
Source§

fn enter_initialization_mode( &mut self, tolerance: Option<f64>, start_time: f64, stop_time: Option<f64>, ) -> Result<Fmi3Res, Fmi3Error>

Changes state to Initialization Mode. Read more
Source§

fn exit_initialization_mode(&mut self) -> Result<Fmi3Res, Fmi3Error>

Changes the state, depending on the instance type: Read more
Source§

fn enter_event_mode(&mut self) -> Result<Fmi3Res, Fmi3Error>

This function changes the state to Event Mode. Read more
Source§

fn terminate(&mut self) -> Result<Fmi3Res, Fmi3Error>

Changes state to Terminated. Read more
Source§

fn reset(&mut self) -> Result<Fmi3Res, Fmi3Error>

Is called by the environment to reset the FMU after a simulation run. The FMU goes into the same state as if newly created. All variables have their default values. Before starting a new run Common::enter_initialization_mode() has to be called. Read more
Source§

fn update_discrete_states( &mut self, discrete_states_need_update: &mut bool, terminate_simulation: &mut bool, nominals_of_continuous_states_changed: &mut bool, values_of_continuous_states_changed: &mut bool, next_event_time: &mut Option<f64>, ) -> Result<Fmi3Res, Fmi3Error>

This function is called to signal a converged solution at the current super-dense time instant. update_discrete_states must be called at least once per super-dense time instant. Read more
Source§

impl<'a, Tag> Drop for Instance<'a, Tag>

Source§

fn drop(&mut self)

Executes the destructor for this type. Read more
Source§

impl FmiEventHandler for Instance<'_, CS>

Source§

fn enter_event_mode(&mut self) -> Result<Fmi3Res, Fmi3Error>

Source§

fn update_discrete_states( &mut self, discrete_states_need_update: &mut bool, terminate_simulation: &mut bool, nominals_of_continuous_states_changed: &mut bool, values_of_continuous_states_changed: &mut bool, next_event_time: &mut Option<f64>, ) -> Result<Fmi3Res, Fmi3Error>

Source§

impl FmiEventHandler for Instance<'_, ME>

Source§

fn enter_event_mode(&mut self) -> Result<Fmi3Res, Fmi3Error>

Source§

fn update_discrete_states( &mut self, discrete_states_need_update: &mut bool, terminate_simulation: &mut bool, nominals_of_continuous_states_changed: &mut bool, values_of_continuous_states_changed: &mut bool, next_event_time: &mut Option<f64>, ) -> Result<Fmi3Res, Fmi3Error>

Source§

impl<'a, Tag> FmiInstance for Instance<'a, Tag>

Source§

type ModelDescription = Fmi3ModelDescription

Source§

type ValueRef = <Fmi3Import as FmiImport>::ValueRef

Source§

type Status = Fmi3Status

Source§

fn name(&self) -> &str

Get the instance name
Source§

fn get_version(&self) -> &str

Get the version of the FMU
Source§

fn model_description(&self) -> &Self::ModelDescription

Get the model description of the FMU
Source§

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

The function controls the debug logging that is output by the FMU Read more
Source§

fn get_number_of_continuous_state_values(&mut self) -> usize

Get the number of values required to store the continuous states. Array dimensions are expanded.
Source§

fn get_number_of_event_indicator_values(&mut self) -> usize

Get the number of values required to store the event indicators. Array dimensions are expanded.
Source§

fn enter_initialization_mode( &mut self, tolerance: Option<f64>, start_time: f64, stop_time: Option<f64>, ) -> Result<Fmi3Res, Fmi3Error>

Source§

fn exit_initialization_mode(&mut self) -> Result<Fmi3Res, Fmi3Error>

Source§

fn terminate(&mut self) -> Result<Fmi3Res, Fmi3Error>

Changes state to Terminated. Read more
Source§

fn reset(&mut self) -> Result<Fmi3Res, Fmi3Error>

Is called by the environment to reset the FMU after a simulation run. The FMU goes into the same state as if newly created. All variables have their default values. Before starting a new run FmiInstance::enter_initialization_mode() has to be called. Read more
Source§

impl FmiModelExchange for Instance<'_, ME>

Source§

fn enter_continuous_time_mode(&mut self) -> Result<Fmi3Res, Fmi3Error>

Source§

fn enter_event_mode(&mut self) -> Result<Fmi3Res, Fmi3Error>

Source§

fn update_discrete_states( &mut self, discrete_states_need_update: &mut bool, terminate_simulation: &mut bool, nominals_of_continuous_states_changed: &mut bool, values_of_continuous_states_changed: &mut bool, next_event_time: &mut Option<f64>, ) -> Result<Fmi3Res, Fmi3Error>

This function is called to signal a converged solution at the current super-dense time instant. update_discrete_states must be called at least once per super-dense time instant. Read more
Source§

fn completed_integrator_step( &mut self, no_set_fmu_state_prior: bool, enter_event_mode: &mut bool, terminate_simulation: &mut bool, ) -> Result<Fmi3Res, Fmi3Error>

Source§

fn set_time(&mut self, time: f64) -> Result<Fmi3Res, Fmi3Error>

Source§

fn get_continuous_states( &mut self, continuous_states: &mut [f64], ) -> Result<Fmi3Res, Fmi3Error>

Source§

fn set_continuous_states( &mut self, states: &[f64], ) -> Result<Fmi3Res, Fmi3Error>

Source§

fn get_continuous_state_derivatives( &mut self, derivatives: &mut [f64], ) -> Result<Fmi3Res, Fmi3Error>

Source§

fn get_nominals_of_continuous_states( &mut self, nominals: &mut [f64], ) -> Result<Fmi3Res, Fmi3Error>

Source§

fn get_event_indicators( &mut self, event_indicators: &mut [f64], ) -> Result<bool, <Self::Status as FmiStatus>::Err>

Source§

fn get_number_of_event_indicators(&mut self) -> Result<usize, Fmi3Error>

Source§

impl<'a, Tag> GetSet for Instance<'a, Tag>

Source§

type ValueRef = <Fmi3Import as FmiImport>::ValueRef

Source§

fn get_boolean( &mut self, vrs: &[fmi3ValueReference], values: &mut [bool], ) -> Fmi3Status

Get the values of the specified variable references. Read more
Source§

fn set_boolean( &mut self, vrs: &[fmi3ValueReference], values: &[bool], ) -> Fmi3Status

Set the values of the specified variable references. Read more
Source§

fn get_float32( &mut self, vrs: &[fmi3ValueReference], values: &mut [f32], ) -> Fmi3Status

Get the values of the specified variable references. Read more
Source§

fn set_float32( &mut self, vrs: &[fmi3ValueReference], values: &[f32], ) -> Fmi3Status

Set the values of the specified variable references. Read more
Source§

fn get_float64( &mut self, vrs: &[fmi3ValueReference], values: &mut [f64], ) -> Fmi3Status

Get the values of the specified variable references. Read more
Source§

fn set_float64( &mut self, vrs: &[fmi3ValueReference], values: &[f64], ) -> Fmi3Status

Set the values of the specified variable references. Read more
Source§

fn get_int8( &mut self, vrs: &[fmi3ValueReference], values: &mut [i8], ) -> Fmi3Status

Get the values of the specified variable references. Read more
Source§

fn set_int8(&mut self, vrs: &[fmi3ValueReference], values: &[i8]) -> Fmi3Status

Set the values of the specified variable references. Read more
Source§

fn get_int16( &mut self, vrs: &[fmi3ValueReference], values: &mut [i16], ) -> Fmi3Status

Get the values of the specified variable references. Read more
Source§

fn set_int16( &mut self, vrs: &[fmi3ValueReference], values: &[i16], ) -> Fmi3Status

Set the values of the specified variable references. Read more
Source§

fn get_int32( &mut self, vrs: &[fmi3ValueReference], values: &mut [i32], ) -> Fmi3Status

Get the values of the specified variable references. Read more
Source§

fn set_int32( &mut self, vrs: &[fmi3ValueReference], values: &[i32], ) -> Fmi3Status

Set the values of the specified variable references. Read more
Source§

fn get_int64( &mut self, vrs: &[fmi3ValueReference], values: &mut [i64], ) -> Fmi3Status

Get the values of the specified variable references. Read more
Source§

fn set_int64( &mut self, vrs: &[fmi3ValueReference], values: &[i64], ) -> Fmi3Status

Set the values of the specified variable references. Read more
Source§

fn get_uint8( &mut self, vrs: &[fmi3ValueReference], values: &mut [u8], ) -> Fmi3Status

Get the values of the specified variable references. Read more
Source§

fn set_uint8(&mut self, vrs: &[fmi3ValueReference], values: &[u8]) -> Fmi3Status

Set the values of the specified variable references. Read more
Source§

fn get_uint16( &mut self, vrs: &[fmi3ValueReference], values: &mut [u16], ) -> Fmi3Status

Get the values of the specified variable references. Read more
Source§

fn set_uint16( &mut self, vrs: &[fmi3ValueReference], values: &[u16], ) -> Fmi3Status

Set the values of the specified variable references. Read more
Source§

fn get_uint32( &mut self, vrs: &[fmi3ValueReference], values: &mut [u32], ) -> Fmi3Status

Get the values of the specified variable references. Read more
Source§

fn set_uint32( &mut self, vrs: &[fmi3ValueReference], values: &[u32], ) -> Fmi3Status

Set the values of the specified variable references. Read more
Source§

fn get_uint64( &mut self, vrs: &[fmi3ValueReference], values: &mut [u64], ) -> Fmi3Status

Get the values of the specified variable references. Read more
Source§

fn set_uint64( &mut self, vrs: &[fmi3ValueReference], values: &[u64], ) -> Fmi3Status

Set the values of the specified variable references. Read more
Source§

fn get_string( &mut self, vrs: &[Self::ValueRef], values: &mut [CString], ) -> Result<(), Fmi3Error>

Source§

fn set_string( &mut self, vrs: &[Self::ValueRef], values: &[CString], ) -> Result<(), Fmi3Error>

Source§

fn get_binary( &mut self, value_references: &[fmi3ValueReference], value_buffers: &mut [&mut [u8]], ) -> Result<Vec<usize>, Fmi3Error>

Get binary values from the FMU. Read more
Source§

fn set_binary( &mut self, vrs: &[fmi3ValueReference], values: &[&[u8]], ) -> Result<(), Fmi3Error>

Set binary values in the FMU. Read more
Source§

impl ModelExchange for Instance<'_, ME>

Source§

fn enter_continuous_time_mode(&mut self) -> Result<Fmi3Res, Fmi3Error>

This function must be called to change from Event Mode into Continuous-Time Mode in Model Exchange.

Source§

fn completed_integrator_step( &mut self, no_set_fmu_state_prior: bool, enter_event_mode: &mut bool, terminate_simulation: &mut bool, ) -> Result<Fmi3Res, Fmi3Error>

This function is called after every completed step of the integrator provided the capability flag crate::fmi3::schema::Fmi3ModelExchange::needs_completed_integrator_step = true. Read more
Source§

fn set_time(&mut self, time: f64) -> Result<Fmi3Res, Fmi3Error>

Set a new value for the independent variable (typically a time instant). Read more
Source§

fn get_continuous_states( &mut self, continuous_states: &mut [f64], ) -> Result<Fmi3Res, Fmi3Error>

Return the current continuous state vector. Read more
Source§

fn set_continuous_states( &mut self, states: &[f64], ) -> Result<Fmi3Res, Fmi3Error>

Set new continuous state values. Read more
Source§

fn get_continuous_state_derivatives( &mut self, derivatives: &mut [f64], ) -> Result<Fmi3Res, Fmi3Error>

Fetch the first-order derivatives with respect to the independent variable (usually time) of the continuous states. Read more
Source§

fn get_nominals_of_continuous_states( &mut self, nominals: &mut [f64], ) -> Result<Fmi3Res, Fmi3Error>

Return the nominal values of the continuous states. Read more
Source§

fn get_event_indicators( &mut self, event_indicators: &mut [f64], ) -> Result<bool, Fmi3Error>

Returns the event indicators signaling state events by their sign changes. Read more
Source§

fn get_number_of_event_indicators(&mut self) -> Result<usize, Fmi3Error>

This function returns the number of event indicators. Read more
Source§

impl<'a> ScheduledExecution for Instance<'a, SE>

Source§

fn activate_model_partition( &mut self, clock_reference: Self::ValueRef, activation_time: f64, ) -> Result<Fmi3Res, Fmi3Error>

Each activate_model_partition call relates to one input Clock which triggers the computation of its associated model partition. Read more

Auto Trait Implementations§

§

impl<'a, Tag> Freeze for Instance<'a, Tag>

§

impl<'a, Tag> !RefUnwindSafe for Instance<'a, Tag>

§

impl<'a, Tag> !Send for Instance<'a, Tag>

§

impl<'a, Tag> !Sync for Instance<'a, Tag>

§

impl<'a, Tag> Unpin for Instance<'a, Tag>

§

impl<'a, Tag> !UnwindSafe for Instance<'a, Tag>

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> ErasedDestructor for T
where T: 'static,