API interface of the Finite State Machines (FSM) extension.
More...
|
namespace | qOS::sm |
| Finite State Machine interfaces.
|
|
|
enum | qOS::sm::signalID : signalIDType {
qOS::sm::SIGNAL_START
, qOS::sm::SIGNAL_EXIT
, qOS::sm::SIGNAL_ENTRY
, qOS::sm::SIGNAL_NONE
,
qOS::sm::SIGNAL_TIMEOUT0
, qOS::sm::SIGNAL_TIMEOUT1
, qOS::sm::SIGNAL_TIMEOUT2
} |
| The type for signal ID. More...
|
|
enum | qOS::sm::status : int16_t {
qOS::sm::BEFORE_ANY
, qOS::sm::ABSENT
, qOS::sm::FAILURE
, qOS::sm::SUCCESS
,
qOS::sm::SIGNAL_HANDLED
} |
| This enumeration defines the built-in state-execution status values that can be used as return value in a state callback. More...
|
|
enum | qOS::sm::historyMode : uint8_t { qOS::sm::NO_HISTORY
, qOS::sm::SHALLOW_HISTORY
, qOS::sm::DEEP_HISTORY
} |
| This enumeration defines the possible modes to perform a transition to history. More...
|
|
API interface of the Finite State Machines (FSM) extension.
◆ signalAction_t
Pointer to a function that represents a signal guard/action.
bool retVal = false
if ( ConditionGuard ) {
performSomeAction();
retVal = true;
}
return retVal;
}
The state callback argument to handle the state-machine dynamics and provide execution information....
Definition fsm.hpp:252
- Parameters
-
h | The object that handles the state machine |
- Returns
- A boolean value that allow or rejects the state transition. If the value is
false
the event-signal is rejected, preventing the state transition to be performed.
◆ signalIDType
◆ stateCallback_t
Pointer to a function that represents a state callback.
break;
break;
case USER_SIGNAL:
break;
default:
break;
return retVal;
}
signalID signal(void) const noexcept
Get the Signal ID currently being evaluated for this state.
Definition fsm.hpp:340
status
This enumeration defines the built-in state-execution status values that can be used as return value ...
Definition fsm.hpp:193
@ SUCCESS
To indicate that the status was successful.
Definition fsm.hpp:213
@ SIGNAL_HANDLED
To indicate that the state handled the signal and therefore it is not necessary to continue propagati...
Definition fsm.hpp:219
@ SIGNAL_ENTRY
Built-in signal to indicate if the current state has just entered from another state.
Definition fsm.hpp:53
@ SIGNAL_EXIT
Built-in signal to indicate if the current state has just exit to another state.
Definition fsm.hpp:47
- Parameters
-
h | The object that handles the state machine |
- Returns
- The execution status of the state.
◆ surroundingCallback_t
Pointer to a function that represents a surrounding callback.
break;
break;
break;
default:
break;
}
status lastStatus(void) const noexcept
The last state return status.
Definition fsm.hpp:349
@ FAILURE
To indicate that the state had a failure or abnormal execution. It can be used to handle exceptions.
Definition fsm.hpp:209
@ BEFORE_ANY
(Only available in the surrounding callback) Indicates an execution of the surrounding callback befor...
Definition fsm.hpp:199
- Parameters
-
h | The object that handles the state machine |
- Returns
- none.
◆ timeoutSpecOption_t
A typedef to hold the timeout specification options.
◆ historyMode
This enumeration defines the possible modes to perform a transition to history.
Enumerator |
---|
NO_HISTORY | History is not preserved. Composite states will start according to their default transition.
|
SHALLOW_HISTORY | History will be kept to allow the return to only the top-most sub-state of the most recent state configuration, which is entered using the default entry rule.
|
DEEP_HISTORY | History will be kept to allow full state configuration of the most recent visit to the containing region..
|
◆ signalID
The type for signal ID.
Enumerator |
---|
SIGNAL_START | Built-in signal that can be used to set a nested initial-transition (aka default transition) by using the sm::handler_t::startState() method.
- Note
- Transitions by setting the sm::handler_t::nextState() member are not allowed here
|
SIGNAL_EXIT | Built-in signal to indicate if the current state has just exit to another state.
- Note
- Transitions are not allowed here
|
SIGNAL_ENTRY | Built-in signal to indicate if the current state has just entered from another state.
- Note
- Transitions are not allowed here
|
SIGNAL_NONE | Built-in signal to indicate that there is not signal available.
|
SIGNAL_TIMEOUT0 | Built-in signal to indicate that the timeout at index 0 expired.
|
SIGNAL_TIMEOUT1 | Built-in signal to indicate that the timeout at index 1 expired.
|
SIGNAL_TIMEOUT2 | Built-in signal to indicate that the timeout at index 2 expired.
|
◆ status
This enumeration defines the built-in state-execution status values that can be used as return value in a state callback.
Enumerator |
---|
BEFORE_ANY | (Only available in the surrounding callback) Indicates an execution of the surrounding callback before launching the state callback
|
ABSENT | Not to be used at the application level. This value is reserved for use.
|
FAILURE | To indicate that the state had a failure or abnormal execution. It can be used to handle exceptions.
|
SUCCESS | To indicate that the status was successful.
|
SIGNAL_HANDLED | To indicate that the state handled the signal and therefore it is not necessary to continue propagating the signal through the rest of the hierarchy.
|
◆ add()
Add a task to the scheduling scheme running a dedicated state-machine. The task is scheduled to run every t time units in task::PERIODIC mode. The event info will be available as a generic pointer inside the sm::handler_t::Data field.
- Precondition
- The State-machine object should be previously configured with qOS::stateMachine::setup()
- See also
- qOS::stateMachine::setup()
- Parameters
-
- Returns
- Returns
true
on success, otherwise returns false
.
◆ SIGNAL_TIMEOUT()
Built-in signal to indicate that a timeout expiration event occurs.
- Parameters
-
iTm | The index of the timeout (0, 1, 2... ( Q_FSM_MAX_TIMEOUTS-1 ) ) |
- Returns
- The built-int timeout signal at index iTm.
◆ SIGNAL_USER()
signalID qOS::sm::SIGNAL_USER |
( |
uint32_t | s | ) |
|
|
constexpr |
Function to define a user-defined signal.
- Parameters
-
s | The value for the user-defined signal. |
- Returns
- The user defined signal as a signalID type
◆ TIMEOUT_INDEX()
Timeout-specification option. Should be used only to specify which timeout signal to use.
- See also
- TIMEOUT_USE_SIGNAL()
- Note
- Can be combined with a bitwise OR
◆ TIMEOUT_USE_SIGNAL()
Timeout-specification option. Should be used only to specify which timeout signal to use.
- See also
- TIMEOUT_INDEX()
- Note
- Can be combined with a bitwise OR
◆ TIMEOUT_KEEP_IF_SET
This timeout-specification option its used to specify that the engine should set the timeout only if it is in reset state.
- Note
- Can be combined with a bitwise OR
◆ TIMEOUT_PERIODIC
This timeout-specification option its used setup the timeout in periodic mode.
- Note
- Can be combined with a bitwise OR
◆ TIMEOUT_RST_ENTRY
This timeout-specification option its used to specify that the engine should reset the timeout when the specified state its entering.
- Note
- Can be combined with a bitwise OR
◆ TIMEOUT_RST_EXIT
This timeout-specification option its used to specify that the engine should reset the timeout when the specified state its exiting*.
- Note
- Can be combined with a bitwise OR
◆ TIMEOUT_SET_ENTRY
This timeout-specification option its used to specify that the engine should set the timeout when the specified state its entering.
- Note
- Can be combined with a bitwise OR
◆ TIMEOUT_SET_EXIT
This timeout-specification option its used to specify that the engine should set the timeout when the specified state its exiting*.
- Note
- Can be combined with a bitwise OR