Skip to content

Commit

Permalink
avoid spurious external transitions
Browse files Browse the repository at this point in the history
  • Loading branch information
romancardenas committed Jan 9, 2024
1 parent 59e5b6a commit 9ad630f
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 11 deletions.
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "xdevs-no-std"
version = "0.1.0"
version = "0.1.1"
edition = "2021"
license = "GPL-3.0"
description = "no-std implementation of xDEVS for real-time simulation on embedded systems"
Expand Down
3 changes: 0 additions & 3 deletions examples/gpt.rs
Original file line number Diff line number Diff line change
Expand Up @@ -241,10 +241,7 @@ fn main() {
let ef = EF::new(generator, transducer);
let efp = EFP::new(ef, processor);

//let mut simulator = xdevs::simulator::rt_std::Simulator::new(efp, 1., None);

let mut simulator = xdevs::simulator::Simulator::new(efp);
// simulator.simulate_vt(0.0, 100.0);
simulator.simulate_rt(
0.0,
14.0,
Expand Down
11 changes: 4 additions & 7 deletions src/simulator.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use crate::aux::AbstractSimulator;
use crate::aux::{AbstractSimulator, Bag};

#[cfg(feature = "std")]
pub mod std;
Expand Down Expand Up @@ -36,16 +36,13 @@ impl<M: AbstractSimulator> Simulator<M> {
let mut t = t_start;
let mut t_next_internal = self.model.start(t);
while t < t_stop {
let t_until = if t_next_internal > t_stop {
t_stop
} else {
t_next_internal
};

let t_until = f64::min(t_next_internal, t_stop);
t = wait_until(t_until, self.model.get_input_mut());
if t >= t_next_internal {
self.model.lambda(t);
propagate_output(self.model.get_output());
} else if self.model.get_input().is_empty() {
continue; // avoid spurious external transitions
}
t_next_internal = self.model.delta(t);
}
Expand Down

0 comments on commit 9ad630f

Please sign in to comment.