Simulator

Struct Simulator 

Source
pub struct Simulator<M: AbstractSimulator> { /* private fields */ }
Expand description

A DEVS simulator.

Implementations§

Source§

impl<M: AbstractSimulator> Simulator<M>

Source

pub const fn new(model: M) -> Self

Creates a new Simulator with the given DEVS model.

Source

pub fn simulate_rt( &mut self, config: &Config, wait_until: impl FnMut(f64, f64, &mut M::Input) -> f64, propagate_output: impl FnMut(&M::Output), )

It executes the simulation of the inner DEVS model from t_start to t_stop. It provides support for real time execution via the following arguments:

  • wait_until: a closure that is called between state transitions. It receives the current time, the time of the next state transition and a mutable reference to the input ports. It returns the actual time “waited”. If the returned time is equal to the input time, an internal/confluent state transition is performed. Otherwise, it assumes that an external event happened and executes the external transition function.

  • propagate_output: a closure that is called after output functions. It receives a mutable reference to the output ports so the closure can access to output events.

Source

pub fn simulate_vt(&mut self, config: &Config)

It executes the simulation of the inner DEVS model from t_start to t_stop. It uses a virtual clock (i.e., no real time is used).

Source

pub async fn simulate_rt_async( &mut self, config: &Config, input_handler: impl AsyncInput<Input = M::Input>, propagate_output: impl FnMut(&M::Output), )

Asynchronous version of the simulate_rt method.

The main difference is that the wait_until function has been replaced with an AsyncInput trait, which allows for asynchronous handling of input events.

Auto Trait Implementations§

§

impl<M> Freeze for Simulator<M>
where M: Freeze,

§

impl<M> RefUnwindSafe for Simulator<M>
where M: RefUnwindSafe,

§

impl<M> Send for Simulator<M>
where M: Send,

§

impl<M> Sync for Simulator<M>
where M: Sync,

§

impl<M> Unpin for Simulator<M>
where M: Unpin,

§

impl<M> UnwindSafe for Simulator<M>
where 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, 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, 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.