Skyward boardcore
Loading...
Searching...
No Matches
Boardcore::HSM< T > Class Template Reference

#include <HSM.h>

Inheritance diagram for Boardcore::HSM< T >:
Collaboration diagram for Boardcore::HSM< T >:

Public Types

typedef State(T::* StateHandler) (const Event &)
 

Public Member Functions

 HSM (StateHandler initialState, unsigned int stacksize=miosix::STACK_DEFAULT_FOR_PTHREAD, miosix::Priority priority=miosix::MAIN_PRIORITY)
 
virtual ~HSM ()
 
bool start () override
 Start the thread associated with this active object.
 
State transition (StateHandler nextState)
 Performs a transition to the specified state.
 
State tranSuper (StateHandler superState)
 Performs a transaction to the specified super state.
 
bool testState (StateHandler testState)
 Test if the state machine is in the specified state.
 
- Public Member Functions inherited from Boardcore::EventHandler
 EventHandler (unsigned int stacksize=miosix::STACK_DEFAULT_FOR_PTHREAD, miosix::Priority priority=miosix::MAIN_PRIORITY)
 
virtual ~EventHandler ()
 
void postEvent (const Event &ev) override
 
void stop () override
 Signals the runner thread to terminate and joins the thread.
 
- Public Member Functions inherited from Boardcore::EventHandlerBase
 EventHandlerBase ()
 
virtual ~EventHandlerBase ()
 
- Public Member Functions inherited from Boardcore::ActiveObject
 ActiveObject (unsigned int stacksize=miosix::STACK_DEFAULT_FOR_PTHREAD, miosix::Priority priority=miosix::MAIN_PRIORITY)
 
virtual ~ActiveObject ()
 
bool isRunning ()
 

Public Attributes

StateHandler state
 
StateHandler temp
 

Protected Member Functions

void handleEvent (const Event &event) override
 Makes the current state handle the event and changes the state accordingly.
 
State state_top (const Event &)
 
- Protected Member Functions inherited from Boardcore::EventHandler
void run () override
 
- Protected Member Functions inherited from Boardcore::ActiveObject
bool shouldStop ()
 Tells whether or not the ActiveObject should stop its execution.
 

Additional Inherited Members

- Protected Attributes inherited from Boardcore::EventHandler
SynchronizedQueue< EventeventList
 
- Protected Attributes inherited from Boardcore::ActiveObject
miosix::Thread * thread = nullptr
 Gives access to the thread object.
 
std::atomic< bool > stopFlag {false}
 
std::atomic< bool > running {false}
 

Detailed Description

template<class T>
class Boardcore::HSM< T >

Definition at line 50 of file HSM.h.

Member Typedef Documentation

◆ StateHandler

template<class T >
typedef State(T::* Boardcore::HSM< T >::StateHandler) (const Event &)

Definition at line 53 of file HSM.h.

Constructor & Destructor Documentation

◆ HSM()

template<class T >
Boardcore::HSM< T >::HSM ( StateHandler initialState,
unsigned int stacksize = miosix::STACK_DEFAULT_FOR_PTHREAD,
miosix::Priority priority = miosix::MAIN_PRIORITY )
inline

Constructor.

Parameters
initialStateInitial state of the machine.

Definition at line 60 of file HSM.h.

◆ ~HSM()

template<class T >
virtual Boardcore::HSM< T >::~HSM ( )
inlinevirtual

Definition at line 69 of file HSM.h.

Member Function Documentation

◆ handleEvent()

template<class T >
void Boardcore::HSM< T >::handleEvent ( const Event & event)
inlineoverrideprotectedvirtual

Makes the current state handle the event and changes the state accordingly.

Parameters
eventThe event to handle.

Implements Boardcore::EventHandler.

Definition at line 120 of file HSM.h.

◆ start()

template<class T >
bool Boardcore::HSM< T >::start ( )
inlineoverridevirtual

Start the thread associated with this active object.

Warning
The method is not thread safe.

Call stop() to terminate execution of the thread.

Returns
true if the thread has been started.

Reimplemented from Boardcore::ActiveObject.

Definition at line 71 of file HSM.h.

◆ state_top()

template<class T >
State Boardcore::HSM< T >::state_top ( const Event & )
inlineprotected

Definition at line 432 of file HSM.h.

◆ testState()

template<class T >
bool Boardcore::HSM< T >::testState ( StateHandler testState)
inline

Test if the state machine is in the specified state.

Parameters
testStateState to test.
Returns
True if the state machine is in the given state.

Definition at line 106 of file HSM.h.

◆ transition()

template<class T >
State Boardcore::HSM< T >::transition ( StateHandler nextState)
inline

Performs a transition to the specified state.

Parameters
nextStateTarget state.

Definition at line 83 of file HSM.h.

◆ tranSuper()

template<class T >
State Boardcore::HSM< T >::tranSuper ( StateHandler superState)
inline

Performs a transaction to the specified super state.

Parameters
superStateTarget super state.

Definition at line 94 of file HSM.h.

Member Data Documentation

◆ state

template<class T >
StateHandler Boardcore::HSM< T >::state

Definition at line 110 of file HSM.h.

◆ temp

template<class T >
StateHandler Boardcore::HSM< T >::temp

Definition at line 111 of file HSM.h.


The documentation for this class was generated from the following file: