Skip to main content

Model

Trait Model 

Source
pub trait Model: Default {
    const MODEL_NAME: &'static str;
    const INSTANTIATION_TOKEN: &'static str;
    const MAX_EVENT_INDICATORS: usize;
    const SUPPORTS_MODEL_EXCHANGE: bool;
    const SUPPORTS_CO_SIMULATION: bool;
    const SUPPORTS_SCHEDULED_EXECUTION: bool;

    // Required methods
    fn build_metadata(
        variables: &mut ModelVariables,
        model_structure: &mut ModelStructure,
        vr_offset: u32,
        prefix: Option<&str>,
    ) -> u32;
    fn set_start_values(&mut self);

    // Provided methods
    fn build_toplevel_metadata() -> (ModelVariables, ModelStructure) { ... }
    fn validate_variable_setting(
        vr: fmi3ValueReference,
        state: &ModelState,
    ) -> Result<(), &'static str> { ... }
}
Expand description

Model trait. This trait should be implementing by deriving FmuModel on the user model struct.

It provides the necessary back-end functionality for the FMI 3.0 API, delegating user-specific behavior to the UserModel trait.

Required Associated Constants§

Source

const MODEL_NAME: &'static str

Source

const INSTANTIATION_TOKEN: &'static str

Source

const MAX_EVENT_INDICATORS: usize

Number of event indicators

Source

const SUPPORTS_MODEL_EXCHANGE: bool

Whether this model supports Model Exchange interface

Source

const SUPPORTS_CO_SIMULATION: bool

Whether this model supports Co-Simulation interface

Source

const SUPPORTS_SCHEDULED_EXECUTION: bool

Whether this model supports Scheduled Execution interface

Required Methods§

Source

fn build_metadata( variables: &mut ModelVariables, model_structure: &mut ModelStructure, vr_offset: u32, prefix: Option<&str>, ) -> u32

Recursively build the model variables and structure by appending to the provided ModelVariables and ModelStructure instances.

Returns the number of variables that were added.

Source

fn set_start_values(&mut self)

Set start values

Provided Methods§

Source

fn build_toplevel_metadata() -> (ModelVariables, ModelStructure)

Build the top-level model variables and structure, including the ‘time’ variable.

Source

fn validate_variable_setting( vr: fmi3ValueReference, state: &ModelState, ) -> Result<(), &'static str>

Validate that a variable can be set in the current model state This method should be implemented by the generated code to check causality and variability restrictions for each variable

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementors§