xdevs/lib.rs
1#![no_std]
2
3pub use xdevs_no_std_macros::*;
4
5pub mod port;
6pub mod simulator;
7pub mod traits;
8
9/// Interface for DEVS atomic models. All DEVS atomic models must implement this trait.
10pub trait Atomic: traits::PartialAtomic {
11 /// Method for performing any operation before simulating. By default, it does nothing.
12 #[allow(unused_variables)]
13 #[inline]
14 fn start(state: &mut Self::State) {}
15
16 /// Method for performing any operation after simulating. By default, it does nothing.
17 #[allow(unused_variables)]
18 #[inline]
19 fn stop(state: &mut Self::State) {}
20
21 /// Internal transition function. It modifies the state of the model when an internal event happens.
22 fn delta_int(state: &mut Self::State);
23
24 /// External transition function. It modifies the state of the model when an external event happens.
25 /// The time elapsed since the last state transition is `e`.
26 fn delta_ext(state: &mut Self::State, e: f64, x: &Self::Input);
27
28 /// Confluent transition function. It modifies the state of the model when an external and an internal event occur simultaneously.
29 /// By default, it calls [`Atomic::delta_int`] and [`Atomic::delta_ext`] with `e = 0`, in that order.
30 #[inline]
31 fn delta_conf(state: &mut Self::State, x: &Self::Input) {
32 Self::delta_int(state);
33 Self::delta_ext(state, 0., x);
34 }
35
36 /// Output function. It triggers output events when an internal event is about to happen.
37 fn lambda(state: &Self::State, output: &mut Self::Output);
38
39 /// Time advance function. It returns the time until the next internal event happens.
40 fn ta(state: &Self::State) -> f64;
41}