Skip to main content

Automaton

Trait Automaton 

Source
pub trait Automaton:
    Send
    + Sync
    + Debug {
    type State: Clone + Send + Sync + 'static + Debug;
    type Action: Debug + Clone + Send + Sync + Default + 'static;

    // Required methods
    fn step(
        &self,
        time: Time,
        action: &Self::Action,
        state: &Self::State,
    ) -> (Self::State, Option<f64>);
    fn initial_state(&self) -> Self::State;
    fn name(&self) -> &str;
    fn extract_value(&self, state: &Self::State) -> f64;

    // Provided method
    fn reset(&self) -> Self::State { ... }
}
Expand description

Core trait for all automata.

An automaton is a stateful function generator. Each call to step takes the current time, an action, and the current state, and returns a new state together with an optional output value. Automata are Send and run on the control thread (soft RT).

Required Associated Types§

Source

type State: Clone + Send + Sync + 'static + Debug

State type.

Source

type Action: Debug + Clone + Send + Sync + Default + 'static

Action type (a pure function applied to the state).

Required Methods§

Source

fn step( &self, time: Time, action: &Self::Action, state: &Self::State, ) -> (Self::State, Option<f64>)

Advance the automaton by one time step.

§Arguments
  • time — current time
  • action — action to apply
  • state — current state

Returns (new_state, optional_output_value).

Source

fn initial_state(&self) -> Self::State

Return the initial state.

Source

fn name(&self) -> &str

Automaton name.

Source

fn extract_value(&self, state: &Self::State) -> f64

Extract the output value from the state.

Provided Methods§

Source

fn reset(&self) -> Self::State

Reset the automaton to its initial state.

Implementors§