Skip to main content

ModelInstance

Struct ModelInstance 

Source
pub struct ModelInstance<M, C>
where M: UserModel, C: Context<M>,
{ /* private fields */ }
Expand description

An exportable FMU instance, generic over model type M and context type C

Implementations§

Source§

impl<M, C> ModelInstance<M, C>
where M: Model + UserModel, C: Context<M>,

Source

pub fn new( name: String, instantiation_token: &str, context: C, instance_type: InterfaceType, ) -> Result<Self, Fmi3Error>

Source

pub fn instance_name(&self) -> &str

Source

pub fn instance_type(&self) -> InterfaceType

Source

pub fn context(&self) -> &C

Source

pub fn assert_instance_type( &self, expected: InterfaceType, ) -> Result<(), Fmi3Error>

Trait Implementations§

Source§

impl<M, C> CoSimulation for ModelInstance<M, C>

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 get_output_derivatives( &mut self, vrs: &[fmi3ValueReference], orders: &[i32], _values: &mut [f64], ) -> Result<Fmi3Res, Fmi3Error>

The returned values correspond to the derivatives at the current time of the FMU. For example, after a successful call to CoSimulation::do_step, the returned values are related to the end of the communication step. Read more
Source§

fn do_step( &mut self, current_communication_point: f64, communication_step_size: f64, no_set_fmu_state_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<M, C> Common for ModelInstance<M, C>
where M: Model + UserModel + ModelGetSet<M>, C: Context<M>,

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_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 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 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_event_mode(&mut self) -> Result<Fmi3Res, Fmi3Error>

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

fn update_discrete_states( &mut self, event_flags: &mut EventFlags, ) -> 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 get_number_of_variable_dependencies( &mut self, _vr: fmi3ValueReference, ) -> Result<usize, Fmi3Error>

This function returns the number of dependencies for a given variable.
Source§

fn get_variable_dependencies( &mut self, _dependent: fmi3ValueReference, ) -> Result<Vec<VariableDependency>, Fmi3Error>

This function returns the dependency information for a single variable. Read more
Source§

impl<M, C> GetSet for ModelInstance<M, C>
where M: Model + UserModel + ModelGetSet<M>, C: Context<M>,

Blanket implementation of the GetSet trait for ModelInstance.

These implementations delegate to the underlying user model’s get/set methods which are generated by the derive macro). Here we have special handling for the ‘time’ variable reference (implicitly always VR=0).

The generated get/set methods do not take into account ‘time’ as VR=0, and expect VRs to be zero-based indices into the model’s variables.

Only the float64 getter has special handling for ‘time’ VR=0, as it is the only type that can represent time.

Source§

fn get_boolean( &mut self, vrs: &[fmi3ValueReference], values: &mut [bool], ) -> Result<Fmi3Res, Fmi3Error>

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

fn set_boolean( &mut self, vrs: &[fmi3ValueReference], values: &[bool], ) -> Result<Fmi3Res, Fmi3Error>

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

fn get_float32( &mut self, vrs: &[fmi3ValueReference], values: &mut [f32], ) -> Result<Fmi3Res, Fmi3Error>

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

fn set_float32( &mut self, vrs: &[fmi3ValueReference], values: &[f32], ) -> Result<Fmi3Res, Fmi3Error>

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

fn get_int8( &mut self, vrs: &[fmi3ValueReference], values: &mut [i8], ) -> Result<Fmi3Res, Fmi3Error>

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

fn set_int8( &mut self, vrs: &[fmi3ValueReference], values: &[i8], ) -> Result<Fmi3Res, Fmi3Error>

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

fn get_int16( &mut self, vrs: &[fmi3ValueReference], values: &mut [i16], ) -> Result<Fmi3Res, Fmi3Error>

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

fn set_int16( &mut self, vrs: &[fmi3ValueReference], values: &[i16], ) -> Result<Fmi3Res, Fmi3Error>

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

fn get_int32( &mut self, vrs: &[fmi3ValueReference], values: &mut [i32], ) -> Result<Fmi3Res, Fmi3Error>

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

fn set_int32( &mut self, vrs: &[fmi3ValueReference], values: &[i32], ) -> Result<Fmi3Res, Fmi3Error>

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

fn get_int64( &mut self, vrs: &[fmi3ValueReference], values: &mut [i64], ) -> Result<Fmi3Res, Fmi3Error>

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

fn set_int64( &mut self, vrs: &[fmi3ValueReference], values: &[i64], ) -> Result<Fmi3Res, Fmi3Error>

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

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

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

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

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

fn get_uint16( &mut self, vrs: &[fmi3ValueReference], values: &mut [u16], ) -> Result<Fmi3Res, Fmi3Error>

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

fn set_uint16( &mut self, vrs: &[fmi3ValueReference], values: &[u16], ) -> Result<Fmi3Res, Fmi3Error>

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

fn get_uint32( &mut self, vrs: &[fmi3ValueReference], values: &mut [u32], ) -> Result<Fmi3Res, Fmi3Error>

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

fn set_uint32( &mut self, vrs: &[fmi3ValueReference], values: &[u32], ) -> Result<Fmi3Res, Fmi3Error>

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

fn get_uint64( &mut self, vrs: &[fmi3ValueReference], values: &mut [u64], ) -> Result<Fmi3Res, Fmi3Error>

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

fn set_uint64( &mut self, vrs: &[fmi3ValueReference], values: &[u64], ) -> Result<Fmi3Res, Fmi3Error>

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

fn get_float64( &mut self, vrs: &[fmi3ValueReference], values: &mut [f64], ) -> Result<Fmi3Res, Fmi3Error>

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

fn set_float64( &mut self, vrs: &[fmi3ValueReference], values: &[f64], ) -> Result<Fmi3Res, Fmi3Error>

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

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

Source§

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

Source§

fn get_binary( &mut self, vrs: &[fmi3ValueReference], values: &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§

fn get_clock( &mut self, vrs: &[fmi3ValueReference], values: &mut [fmi3Clock], ) -> Result<Fmi3Res, Fmi3Error>

Source§

fn set_clock( &mut self, _vrs: &[fmi3ValueReference], _values: &[fmi3Clock], ) -> Result<Fmi3Res, Fmi3Error>

Source§

impl<M, C> ModelExchange for ModelInstance<M, C>

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. 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>

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 set_continuous_states( &mut self, states: &[f64], ) -> Result<Fmi3Res, Fmi3Error>

Set new continuous state values. 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 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_event_indicators( &mut self, indicators: &mut [f64], ) -> Result<bool, Fmi3Error>

Returns the event indicators signaling state events by their sign changes. 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_number_of_event_indicators(&mut self) -> Result<usize, Fmi3Error>

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

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

This function returns the number of continuous states. Read more
Source§

impl<M, C> ScheduledExecution for ModelInstance<M, C>

Source§

fn activate_model_partition( &mut self, _clock_reference: fmi3ValueReference, _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<M, C> Freeze for ModelInstance<M, C>
where C: Freeze, M: Freeze,

§

impl<M, C> RefUnwindSafe for ModelInstance<M, C>

§

impl<M, C> Send for ModelInstance<M, C>
where C: Send, M: Send,

§

impl<M, C> Sync for ModelInstance<M, C>
where C: Sync, M: Sync,

§

impl<M, C> Unpin for ModelInstance<M, C>
where C: Unpin, M: Unpin,

§

impl<M, C> UnwindSafe for ModelInstance<M, C>
where C: UnwindSafe, M: UnwindSafe,

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> InitializeFromStart<T> for T

Source§

fn set_from_start(&mut self, value: T)

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.