OS
v1.7.5
Documentation
|
A FSM(Finite State Machine) object. More...
#include <fsm.hpp>
Public Member Functions | |
stateMachine ()=default | |
bool | setup (const sm::stateCallback_t &topFcn, sm::state &init, sm::surroundingCallback_t sFcn=nullptr, void *pData=nullptr) noexcept |
Initializes a Finite State Machine (FSM). | |
bool | add (sm::state &s, const sm::stateCallback_t &sFcn, sm::state &init) noexcept |
Add the specified state to the stateMachine "Top" state. | |
bool | add (sm::state &s, const sm::stateCallback_t &sFcn) noexcept |
This function adds the specified state to the stateMachine "Top" state. | |
bool | install (queue &q) noexcept |
Install a signal queue to the provided Finite State Machine (FSM). | |
template<size_t numberOfSignals> | |
bool | install (sm::signalQueue< numberOfSignals > &sq) noexcept |
Install a signal queue to the provided Finite State Machine (FSM). | |
bool | sendSignal (sm::signalID sig, void *sData=nullptr, bool isUrgent=false) noexcept |
Sends a signal to a state machine. | |
bool | sendSignal (sm::signalIDType sig, void *sData=nullptr, bool isUrgent=false) noexcept |
bool | install (sm::timeoutSpec &ts) noexcept |
Install the Timeout-specification object to target FSM and allow timed signals within states. | |
bool | timeoutSet (const index_t xTimeout, const qOS::duration_t t) noexcept |
Set the time for the selected built-in timeout inside the target FSM. | |
bool | timeoutStop (const index_t xTimeout) noexcept |
Stop the time count for the selected built-in timeout. | |
const sm::state & | getTop (void) const noexcept |
Retrieve a reference to the Top state of. | |
sm::state *const & | getCurrent (void) const noexcept |
Retrieve a reference to the state currently being evaluated. | |
queue *const & | getQueue (void) const noexcept |
Get a pointer to the installed queue if available. | |
sm::timeoutSpec *const & | getTimeSpec (void) const noexcept |
Get a pointer to the installed timeout specification if available. | |
void *const & | getData (void) const noexcept |
Retrieve the state machine data or storage-pointer. | |
void | setSurrounding (const sm::surroundingCallback_t &sFcn) noexcept |
Set the state-machine surrounding callback. | |
bool | run (sm::signal_t sig) noexcept |
Execute the Finite State Machine (FSM). | |
A FSM(Finite State Machine) object.
In QuarkTS++, a state-machine must be instantiated with an object of type stateMachine.
Like any other OS object, a Finite State Machine (FSM) must be explicitly initialized before it can be used. The stateMachine::setup() initializes the instance, sets the callback for the top state, sets the initial state and the surrounding callback function.
|
default |
|
inlinenoexcept |
This function adds the specified state to the stateMachine "Top" state.
[in] | s | The state object. |
[in] | sFcn | The handler function associated to the state. |
Prototype:
true
on success, otherwise return false
.
|
inlinenoexcept |
Add the specified state to the stateMachine "Top" state.
[in] | s | The state object. |
[in] | sFcn | The handler function associated to the state. |
Prototype:
[in] | init | The first child-state to be executed if the subscribed state its a parent in an hierarchical pattern. (default transition). You can ignore this argument. |
true
on success, otherwise return false
.
|
noexcept |
Retrieve a reference to the state currently being evaluated.
|
noexcept |
Retrieve the state machine data or storage-pointer.
|
noexcept |
Get a pointer to the installed queue if available.
nullptr
.
|
noexcept |
Get a pointer to the installed timeout specification if available.
nullptr
.
|
noexcept |
Retrieve a reference to the Top state of.
|
noexcept |
Install a signal queue to the provided Finite State Machine (FSM).
[in] | q | The queue to be installed. |
true
on success, otherwise return false
.
|
inlinenoexcept |
Install a signal queue to the provided Finite State Machine (FSM).
[in] | sq | The signal queue to be installed. |
true
on success, otherwise return false
.
|
noexcept |
Install the Timeout-specification object to target FSM and allow timed signals within states.
Q_FSM_MAX_TIMEOUTS
configuration macro inside config.h
[in] | ts | The timeout specification object. |
true
on success, otherwise returns false
.
|
noexcept |
Execute the Finite State Machine (FSM).
[in] | sig | User-defined signal (this value will be ignored if the installed queue has items available) |
true
if the signal was successfully handled, otherwise returns false
.
|
noexcept |
Sends a signal to a state machine.
[in] | sig | The user-defined signal. |
[in] | sData | The data associated to the signal. |
[in] | isUrgent | If true, the signal will be sent to the front of the queue. (only if the there is a signal-queue available) |
true
if the provided signal was successfully delivered to the state machine , otherwise return false
. false
if there is a queue, and the signal cannot be inserted because it is full.
|
inlinenoexcept |
|
noexcept |
Set the state-machine surrounding callback.
[in] | sFcn | The surrounding callback function. |
|
inlinenoexcept |
Initializes a Finite State Machine (FSM).
[in] | topFcn | The callback for the "Top" state. |
[in] | init | The first state to be executed (init-state or default transition). |
[in] | sFcn | The surrounding callback. To ignore pass nullptr . |
[in] | pData | Represents the FSM arguments. User storage pointer. To ignore pass nullptr . |
Returns
true on Success, otherwise returns false
.
|
noexcept |
Set the time for the selected built-in timeout inside the target FSM.
[in] | xTimeout | The index of the requested timeout (0, 1, 2 ... (Q_FSM_MAX_TIMEOUTS-1 ) ) |
[in] | t | The specified time given in milliseconds. |
true
on success, otherwise returns false
.
|
noexcept |
Stop the time count for the selected built-in timeout.
[in] | xTimeout | The index of the timeout (0, 1, 2 ... (Q_FSM_MAX_TIMEOUTS-1 ) ) |
true
on success, otherwise returns false
.