Crate gwr_engine

Source
Expand description

GWR - The Great Western Runtime

This library provides the core of the GWR Engine which executes event driven asynchronous simulation components.

§Developer Guide

The Developer Guide provides a document that goes through the GWR engine and related libraries in a more directed approach than the API guide can. See the gwr-developer-guide/ folder.

§Examples

Make sure you look at the examples/ folder which includes worked/documented examples. The current examples are:

§Simple Application

A very simple application would look like:

use gwr_components::sink::Sink;
use gwr_components::source::Source;
use gwr_components::{connect_port, option_box_repeat};
use gwr_engine::engine::Engine;
use gwr_engine::run_simulation;

let mut engine = Engine::default();
let mut source = Source::new_and_register(&engine, engine.top(), "source", option_box_repeat!(0x123 ; 10))
    .expect("should be able to create and register `Source`");
let sink = Sink::new_and_register(&engine, engine.top(), "sink")
    .expect("should be able to create and register `Sink`");
connect_port!(source, tx => sink, rx)
    .expect("should be able to connect `Source` to `Sink`");
run_simulation!(engine);
assert_eq!(sink.num_sunk(), 10);

Simulations can be run as purely event driven (where one event triggers one or more others) or the use of clocks can be introduced to model time. The combination of both is the most common.

The engine manages the clocks. A simple example of a component that uses the clock is the rate limiter which models the amount of time it takes for objects to pass through it.

Modules§

engine
events
Different types of events.
executor
port
Port
test_helpers
time
Modules that model time within the simulations.
traits
A set of common traits used across GWR Engine.
types
Shared types.

Macros§

run_simulation
Spawn all component run() functions and then run the simulation.
sim_error
Build a SimError from a message that supports to_string
spawn_subcomponent
Spawn a sub-component that is stored in an RefCell<Option<>>