pub trait UserModel: Sized {
type LoggingCategory: ModelLoggingCategory + 'static;
// Provided methods
fn configurate(
&mut self,
_context: &dyn Context<Self>,
) -> Result<(), Fmi3Error> { ... }
fn calculate_values(
&mut self,
_context: &dyn Context<Self>,
) -> Result<Fmi3Res, Fmi3Error> { ... }
fn event_update(
&mut self,
_context: &dyn Context<Self>,
event_flags: &mut EventFlags,
) -> Result<Fmi3Res, Fmi3Error> { ... }
fn get_event_indicators(
&mut self,
_context: &dyn Context<Self>,
indicators: &mut [f64],
) -> Result<bool, Fmi3Error> { ... }
fn do_step(
&mut self,
context: &mut dyn Context<Self>,
current_communication_point: f64,
communication_step_size: f64,
_no_set_fmu_state_prior_to_current_point: bool,
) -> Result<CSDoStepResult, Fmi3Error> { ... }
}Expand description
User-defined model behavior trait
This trait should be hand-implemented by the user to define the specific behavior of their model.
Required Associated Types§
Sourcetype LoggingCategory: ModelLoggingCategory + 'static
type LoggingCategory: ModelLoggingCategory + 'static
The logging category type for this model
This is an enum that implements ModelLoggingCategory
Provided Methods§
Sourcefn configurate(&mut self, _context: &dyn Context<Self>) -> Result<(), Fmi3Error>
fn configurate(&mut self, _context: &dyn Context<Self>) -> Result<(), Fmi3Error>
Configure the model (allocate memory, initialize states, etc.) This method is called upon exiting initialization mode
Sourcefn calculate_values(
&mut self,
_context: &dyn Context<Self>,
) -> Result<Fmi3Res, Fmi3Error>
fn calculate_values( &mut self, _context: &dyn Context<Self>, ) -> Result<Fmi3Res, Fmi3Error>
Calculate values (derivatives, outputs, etc.) This method is called whenever the model needs to update its calculated values
Sourcefn event_update(
&mut self,
_context: &dyn Context<Self>,
event_flags: &mut EventFlags,
) -> Result<Fmi3Res, Fmi3Error>
fn event_update( &mut self, _context: &dyn Context<Self>, event_flags: &mut EventFlags, ) -> Result<Fmi3Res, Fmi3Error>
Called to update discrete states and check for events
This method should:
- Update any discrete state variables
- Check for state events and time events
- Set appropriate flags to indicate what has changed
Returns Ok with the appropriate Fmi3Res status, or Err if an error occurs
Sourcefn get_event_indicators(
&mut self,
_context: &dyn Context<Self>,
indicators: &mut [f64],
) -> Result<bool, Fmi3Error>
fn get_event_indicators( &mut self, _context: &dyn Context<Self>, indicators: &mut [f64], ) -> Result<bool, Fmi3Error>
Get event indicators for zero-crossing detection
§Returns
Ok(true)if event indicators were successfully computedOk(false)if the FMU was not able to compute the event indicators because, for example, a numerical issue such as division by zero occurred (corresponding to the C API returning fmi3Discard)Err(Fmi3Error)for other error conditions
Sourcefn do_step(
&mut self,
context: &mut dyn Context<Self>,
current_communication_point: f64,
communication_step_size: f64,
_no_set_fmu_state_prior_to_current_point: bool,
) -> Result<CSDoStepResult, Fmi3Error>
fn do_step( &mut self, context: &mut dyn Context<Self>, current_communication_point: f64, communication_step_size: f64, _no_set_fmu_state_prior_to_current_point: bool, ) -> Result<CSDoStepResult, Fmi3Error>
Co-Simulation step implementation.
Default behavior advances time and reports a completed step.
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.