SAE Teensy ECU
IIT SAE Microcontroller programming
Loading...
Searching...
No Matches
State.h File Reference

State library. More...

#include <stdint.h>
#include <stdlib.h>
#include <typeinfo>
#include "Log.h"
#include "PPHelp.h"

Go to the source code of this file.

Classes

struct  State::State_t
 The parent state structure to extend from to create more states. More...
 

Namespaces

namespace  State
 A state machine implementation, refer to State.h for more info.
 

Enumerations

enum  State::NotifyValue : int {
  State::E_NOERR , State::E_CONTINUE , State::E_ERROR , State::E_FATAL = 0xFA7A1 ,
  State::E_RESTART = 2357427
}
 Common codes that can be used by states. More...
 

Functions

void State::begin (State_t &entry)
 Begin the state machine with a pointer to a state.
 

Detailed Description

State library.

Author
IR
Version
0.1
Date
2020-11-11

This module is a very basic state machine implementation.

It works by continuously calling State::State_t.run() of each State::State_t child returned.

Starting with the State::State_t passed through State::begin(), when State::State_t.run() returns a valid State::State_t pointer, it will continue to run.

States can notify the next state with an integer by using State::State_t.notify(), where the receiving state calls State::State_t.getNotify(). This number is 0 by default.

When State::State_t.notify() is given NotifyValue::E_FATAL, the state machine will break out of its loop and the state machine will stop.

Definition in file State.h.