COSA
An Object-Oriented Platform for Arduino Programming
|
#include <FSM.hh>
Public Types | |
typedef bool(* | StateHandler) (FSM *fsm, uint8_t type) |
Public Member Functions | |
FSM (StateHandler init, Job::Scheduler *scheduler=NULL, uint16_t period=0) | |
void | state (StateHandler fn) |
StateHandler | state () const |
void | period (uint8_t ms) |
void | get (uint16_t ¶m) const |
void | get (void *¶m) const |
void | send (uint8_t type, uint16_t value=0) |
void | send (uint8_t type, void *value) |
bool | begin () |
void | end () |
void | set_timer (uint16_t ms) |
void | cancel_timer () |
Protected Member Functions | |
void | expire_at (uint32_t time) |
uint32_t | expire_at () const |
void | expire_after (uint32_t time) |
int32_t | expire_after () const |
uint32_t | time () const |
bool | is_started () const |
bool | start () |
bool | stop () |
virtual void | on_expired () |
virtual void | run () |
void | detach () |
Linkage * | succ () const |
Linkage * | pred () const |
void | attach (Linkage *pred) |
Protected Attributes | |
uint32_t | m_expires |
Scheduler * | m_scheduler |
Linkage * | m_succ |
Linkage * | m_pred |
Finite State Machine support class. States are represented as an Event handler. Supports timeout events and period timed state machines.
The design of FSM is inspired by UML-2 State Machines, QP by Miro Samek, and ObjecTime by Brian Selic.
typedef bool(* FSM::StateHandler) (FSM *fsm, uint8_t type) |
|
inline |
|
inlineinherited |
Attach given linkage as predecessor. Will check and detach if already attached.
[in] | pred | linkage to attach. |
Definition at line 71 of file Linkage.hh.
|
inline |
Start the state machine with an Event::BEGIN_TYPE.
|
inline |
|
inlineinherited |
Detach this link. Unlink from any list.
Definition at line 125 of file Linkage.hh.
|
inline |
End the state machine with an Event::END_TYPE.
|
inlineinherited |
|
inlineinherited |
|
inlineinherited |
|
inlineinherited |
|
inline |
|
inline |
|
inlineinherited |
|
inlinevirtualinherited |
Job member function that is called Scheduler::dispatch() when the job time has expired. This function is normally called from an interrupt service routine. The default implementation will push a timeout event with the job as target. The default event handler will call the job run() virtual member function. Override this function if the job should be executed during the interrupt service routine.
|
inline |
|
inlineinherited |
Return predecessor in sequence.
Definition at line 60 of file Linkage.hh.
|
inlinevirtualinherited |
|
inline |
|
inline |
|
inline |
|
inlineinherited |
|
inline |
|
inline |
|
inlineinherited |
|
inlineinherited |
|
inlineinherited |
|
protectedinherited |
|
protectedinherited |
Definition at line 94 of file Linkage.hh.
|
protectedinherited |
|
protectedinherited |
Double linked list pointers.
Definition at line 93 of file Linkage.hh.