FW Profile - C1 Implementation
|
Implements the configuration functions for the FW State Machine Module. More...
Go to the source code of this file.
Functions | |
void | FwSmSetData (FwSmDesc_t smDesc, void *smData) |
Set the pointer to the state machine data in the state machine descriptor. More... | |
void * | FwSmGetData (FwSmDesc_t smDesc) |
Get the pointer to the state machine data in the state machine descriptor. More... | |
void | FwSmAddState (FwSmDesc_t smDesc, FwSmCounterS1_t stateId, FwSmCounterS1_t nOfOutTrans, FwSmAction_t entryAction, FwSmAction_t exitAction, FwSmAction_t doAction, FwSmDesc_t esmDesc) |
Create a state with the given characteristics and add it to a state machine. More... | |
void | FwSmAddChoicePseudoState (FwSmDesc_t smDesc, FwSmCounterS1_t choiceId, FwSmCounterS1_t nOfOutTrans) |
Create a choice pseudo-state with the given characteristics and add it to a state machine. More... | |
void | FwSmAddTransIpsToSta (FwSmDesc_t smDesc, FwSmCounterS1_t destId, FwSmAction_t trAction) |
Create a transition from the initial pseudo-state to a proper state and add it to a state machine. More... | |
void | FwSmAddTransIpsToCps (FwSmDesc_t smDesc, FwSmCounterS1_t destId, FwSmAction_t trAction) |
Create a transition from the initial pseudo-state to a choice pseudo-state and add it to a state machine. More... | |
void | FwSmAddTransStaToSta (FwSmDesc_t smDesc, FwSmCounterU2_t transId, FwSmCounterS1_t srcId, FwSmCounterS1_t destId, FwSmAction_t trAction, FwSmGuard_t trGuard) |
Create a transition from a proper state to a proper state and add it to a state machine. More... | |
void | FwSmAddTransStaToCps (FwSmDesc_t smDesc, FwSmCounterU2_t transId, FwSmCounterS1_t srcId, FwSmCounterS1_t destId, FwSmAction_t trAction, FwSmGuard_t trGuard) |
Create a transition from a proper state to a choice pseudo-state and add it to a state machine. More... | |
void | FwSmAddTransCpsToSta (FwSmDesc_t smDesc, FwSmCounterS1_t srcId, FwSmCounterS1_t destId, FwSmAction_t trAction, FwSmGuard_t trGuard) |
Create a transition from a choice pseudo-state to a proper state and add it to a state machine. More... | |
void | FwSmAddTransStaToFps (FwSmDesc_t smDesc, FwSmCounterU2_t transId, FwSmCounterS1_t srcId, FwSmAction_t trAction, FwSmGuard_t trGuard) |
Create a transition from a proper state to the final pseudo-state and add it to a state machine. More... | |
void | FwSmAddTransCpsToFps (FwSmDesc_t smDesc, FwSmCounterS1_t srcId, FwSmAction_t trAction, FwSmGuard_t trGuard) |
Create a transition from a choice pseudo-state to the final pseudo-state and add it to a state machine. More... | |
FwSmErrCode_t | FwSmCheck (FwSmDesc_t smDesc) |
Check the correctness and completeness of the configuration of a state machine descriptor. More... | |
FwSmErrCode_t | FwSmCheckRec (FwSmDesc_t smDesc) |
Recursively check the configuration of a state machine and all its embedded state machines. More... | |
void | FwSmOverrideAction (FwSmDesc_t smDesc, FwSmAction_t oldAction, FwSmAction_t newAction) |
Override an action (either a state action or a transition action) in a derived state machine. More... | |
void | FwSmOverrideGuard (FwSmDesc_t smDesc, FwSmGuard_t oldGuard, FwSmGuard_t newGuard) |
Override a guard in a derived state machine. More... | |
void | FwSmEmbed (FwSmDesc_t smDesc, FwSmCounterS1_t stateId, FwSmDesc_t esmDesc) |
Embed a state machine in a state of a derived state machine. More... | |
Implements the configuration functions for the FW State Machine Module.
This file is part of the FW Profile.
This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0. If a copy of the MPL was not distributed with this file, You can obtain one at http://mozilla.org/MPL/2.0/.
For information on alternative licensing, please contact P&P Software GmbH.
Definition in file FwSmConfig.c.
void FwSmAddChoicePseudoState | ( | FwSmDesc_t | smDesc, |
FwSmCounterS1_t | choiceId, | ||
FwSmCounterS1_t | nOfOutTrans | ||
) |
Create a choice pseudo-state with the given characteristics and add it to a state machine.
This function reports the following errors in the error code of the state machine descriptor:
smDesc | the descriptor of the state machine to which the choice pseudo-state is added. |
choiceId | the identifier of the choice pseudo-state to be added (an integer in the range [1,N] where N is the number of choice pseudo-states). |
nOfOutTrans | the number of outgoing transitions from the new state (a positive integer). |
Definition at line 140 of file FwSmConfig.c.
void FwSmAddState | ( | FwSmDesc_t | smDesc, |
FwSmCounterS1_t | stateId, | ||
FwSmCounterS1_t | nOfOutTrans, | ||
FwSmAction_t | entryAction, | ||
FwSmAction_t | exitAction, | ||
FwSmAction_t | doAction, | ||
FwSmDesc_t | esmDesc | ||
) |
Create a state with the given characteristics and add it to a state machine.
This function reports the following errors in the error code of the state machine descriptor:
smDesc | the state machine to which the state is added. |
stateId | the identifier of the state to be added (an integer in the range [1,N] where N is the number of states in the state machine). |
nOfOutTrans | the number of out-going transitions from the new state. This must be a non-negative integer. A negative value is illegal but will not be reported as an error by this function. |
entryAction | the entry action for the new state (a function pointer) or NULL if no entry action is associated to this state. |
doAction | the do action for the new state (a function pointer) or NULL if no do action is associated to this state. |
exitAction | the exit action for the new state (a function pointer) or NULL if no exit action is associated to this state. |
esmDesc | the descriptor of the state machine embedded in the new state or NULL if no state machine is embedded in the new state. |
Definition at line 92 of file FwSmConfig.c.
void FwSmAddTransCpsToFps | ( | FwSmDesc_t | smDesc, |
FwSmCounterS1_t | srcId, | ||
FwSmAction_t | trAction, | ||
FwSmGuard_t | trGuard | ||
) |
Create a transition from a choice pseudo-state to the final pseudo-state and add it to a state machine.
This function should only be performed after the source state of the transition has been added to the state state machine. Transitions from a choice pseudo-state have no trigger. This function reports the following errors in the error code of the state machine descriptor:
smDesc | the descriptor of the state machine to which the transition is added. |
srcId | the identifier of the source state of the transition (an integer in the range [1,N] where N is the number of states). |
trAction | the transition action (a function pointer) or NULL if no action is associated to this transition. |
trGuard | the transition guard (a function pointer) or NULL if no guard is associated to this transition |
Definition at line 215 of file FwSmConfig.c.
void FwSmAddTransCpsToSta | ( | FwSmDesc_t | smDesc, |
FwSmCounterS1_t | srcId, | ||
FwSmCounterS1_t | destId, | ||
FwSmAction_t | trAction, | ||
FwSmGuard_t | trGuard | ||
) |
Create a transition from a choice pseudo-state to a proper state and add it to a state machine.
This function should only be performed after the source of the transition has been added to the state state machine. This function reports the following errors in the error code of the state machine descriptor:
smDesc | the descriptor of the state machine to which the transition is added. |
srcId | the identifier of the source choice pseudo-state of the transition (an integer in the range [1,N] where N is the number of choice pseudo-states). |
destId | the identifier of the destination state of the transition (an integer in the range [1,N] where N is the number of states). |
trAction | the transition action (a function pointer) or NULL if no action is associated to this transition. |
trGuard | the transition guard (a function pointer) or NULL if no guard is associated to this transition. |
Definition at line 203 of file FwSmConfig.c.
void FwSmAddTransIpsToCps | ( | FwSmDesc_t | smDesc, |
FwSmCounterS1_t | destId, | ||
FwSmAction_t | trAction | ||
) |
Create a transition from the initial pseudo-state to a choice pseudo-state and add it to a state machine.
Transitions from the initial pseudo-state have no trigger and no guard. This function reports the following errors in the error code of the state machine descriptor:
smDesc | the descriptor of the state machine to which the transition is added. |
destId | the identifier of the destination choice pseudo-state of the transition (an integer in the range [1,N] where N is the number of choice pseudo-states). |
trAction | the transition action (a function pointer) or NULL if no action is associated to this transition. |
Definition at line 186 of file FwSmConfig.c.
void FwSmAddTransIpsToSta | ( | FwSmDesc_t | smDesc, |
FwSmCounterS1_t | destId, | ||
FwSmAction_t | trAction | ||
) |
Create a transition from the initial pseudo-state to a proper state and add it to a state machine.
Transitions from the initial pseudo-state have no trigger and no guard. This function reports the following errors in the error code of the state machine descriptor:
smDesc | the descriptor of the state machine to which the transition is added. |
destId | the identifier of the destination state of the transition (an integer in the range [1,N] where N is the number of states). |
trAction | the transition action (a function pointer) or NULL if no action is associated to this transition. |
Definition at line 181 of file FwSmConfig.c.
void FwSmAddTransStaToCps | ( | FwSmDesc_t | smDesc, |
FwSmCounterU2_t | transId, | ||
FwSmCounterS1_t | srcId, | ||
FwSmCounterS1_t | destId, | ||
FwSmAction_t | trAction, | ||
FwSmGuard_t | trGuard | ||
) |
Create a transition from a proper state to a choice pseudo-state and add it to a state machine.
This function should only be performed after the source state of the transition has been added to the state state machine. This function reports the following errors in the error code of the state machine descriptor:
smDesc | the descriptor of the state machine to which the transition is added. |
transId | the identifier of the trigger which is associated to the transition. This is a non-negative integer but the value of zero is reserved for the "Execute" transition (see FW_TR_EXECUTE). |
srcId | the identifier of the source state of the transition (an integer in the range [1,N] where N is the number of states) |
destId | the identifier of the destination choice pseudo-state of the transition (an integer in the range [1,M] where M is the number of choice pseudo-states) |
trAction | the transition action (a function pointer) or NULL if no action is associated to this transition. |
trGuard | the transition guard (a function pointer) or NULL if no guard is associated to this transition. |
Definition at line 197 of file FwSmConfig.c.
void FwSmAddTransStaToFps | ( | FwSmDesc_t | smDesc, |
FwSmCounterU2_t | transId, | ||
FwSmCounterS1_t | srcId, | ||
FwSmAction_t | trAction, | ||
FwSmGuard_t | trGuard | ||
) |
Create a transition from a proper state to the final pseudo-state and add it to a state machine.
This function should only be performed after the source state of the transition has been added to the state state machine. This function reports the following errors in the error code of the state machine descriptor:
smDesc | the descriptor of the state machine to which the transition is added. |
transId | the identifier of the trigger which is associated to the transition. This is a non-negative integer but the value of zero is reserved for the "Execute" transition (see FW_TR_EXECUTE). |
srcId | the identifier of the source state of the transition (an integer in the range [1,N] where N is the number of states). |
trAction | the transition action (a function pointer) or NULL if no action is associated to this transition. |
trGuard | the transition guard (a function pointer) or NULL if no guard is associated to this transition. |
Definition at line 209 of file FwSmConfig.c.
void FwSmAddTransStaToSta | ( | FwSmDesc_t | smDesc, |
FwSmCounterU2_t | transId, | ||
FwSmCounterS1_t | srcId, | ||
FwSmCounterS1_t | destId, | ||
FwSmAction_t | trAction, | ||
FwSmGuard_t | trGuard | ||
) |
Create a transition from a proper state to a proper state and add it to a state machine.
This function should only be performed after the source state of the transition has been added to the state state machine. This function reports the following errors in the error code of the state machine descriptor:
smDesc | the descriptor of the state machine to which the transition is added. |
transId | the identifier of the trigger which is associated to the transition. This is an integer which is unique for the state machine and for all its embedded state machines. The zero identifier is reserved for the "Execute" transition. |
srcId | the identifier of the source state of the transition (an integer in the range [1,N] where N is the number of states). |
destId | the identifier of the destination state of the transition. |
trAction | the transition action (a function pointer) or NULL if no action is associated to this transition. |
trGuard | the transition guard (a function pointer) or NULL if no guard is associated to this transition. |
Definition at line 191 of file FwSmConfig.c.
FwSmErrCode_t FwSmCheck | ( | FwSmDesc_t | smDesc | ) |
Check the correctness and completeness of the configuration of a state machine descriptor.
This function may be called on a state machine descriptor after it has been created and configured. This function does not modify the configuration of the state machine. It checks the error conditions which may arise when an application configures a state machine using the configuration functions declared in this header file. More specifically, this function performs the following checks:
smSuccess
).Note that there are configuration errors which are not covered by this function because they cannot occur if the state machine is configured using the functions declared in this header file. Examples of this kind of errors include:
smDesc | the descriptor of the state machine to be checked. |
Definition at line 350 of file FwSmConfig.c.
FwSmErrCode_t FwSmCheckRec | ( | FwSmDesc_t | smDesc | ) |
Recursively check the configuration of a state machine and all its embedded state machines.
This function performs the same checks as FwSmCheck
but the checks are also performed (recursively) on all the embedded state machines. The function returns the first error code it encounters while checking the outer state machine and its embedded state machine. Thus, the error reported by this function may have arisen either in the outer state machine or in one of its embedded state machines.
smDesc | the descriptor of the state machine to be checked. |
FwSmCheck
). Definition at line 438 of file FwSmConfig.c.
void FwSmEmbed | ( | FwSmDesc_t | smDesc, |
FwSmCounterS1_t | stateId, | ||
FwSmDesc_t | esmDesc | ||
) |
Embed a state machine in a state of a derived state machine.
By default a derived state machine has the same embedded state machines as the base state machine from which it was derived. This function allows a state machine to be embedded in one of the states of the derived state machine. A state machine can only be embedded in an "empty" state (i.e. a state which, in the base state machine, had no embedded state).
As an example consider the case of a base state machine B and suppose that state S1 in this state machine has not embedded state machine. If an application creates a derived state machine D from B (for instance, through function FwSmCreateDer
), then, after creation, state S1 in the derived state machine has no embedded state machine. This function allows a state machine to be embedded in S1.
If an attempt is made to embed a state machine in a non-empty state, the function returns with an error but does not modify in any way the state machine descriptor.
The override mechanism is only available for derived state machines. If this function is called on a base state machine, an error is returned and the function returns without doing anything.
This function reports the following errors in the error code of the state machine descriptor:
smDesc | the descriptor of the derived state machine. |
stateId | the identifier of the state where the state machine is to be embedded. |
esmDesc | the descriptor of the state machine to be embedded. |
Definition at line 494 of file FwSmConfig.c.
void* FwSmGetData | ( | FwSmDesc_t | smDesc | ) |
Get the pointer to the state machine data in the state machine descriptor.
This function returns the pointer which was set with the FwSmSetData
function. This function is normally used by the functions implementing a state machine action or guard to access the state machine data. See the description of the FwSmSetData
function for more details.
smDesc | the descriptor of the state machine to which the data structure is attached. |
Definition at line 87 of file FwSmConfig.c.
void FwSmOverrideAction | ( | FwSmDesc_t | smDesc, |
FwSmAction_t | oldAction, | ||
FwSmAction_t | newAction | ||
) |
Override an action (either a state action or a transition action) in a derived state machine.
By default a derived state machine has the same actions as the base state machine from which it was derived. This function overrides one of the actions of the derived state machine.
As an example consider the case of a base state machine B and suppose that action a1 is used as entry action of state S1 and as exit action of state S2. If an application creates a derived state machine D from B (for instance, through function FwSmCreateDer
), then, after creation, the entry action of state S1 and the exit action of state S2 in state machine D is still a1. This function can be used to change a1. Note that a single invocation of this function will change both the entry action of S1 and the exit action of S2.
A call to this function on a state machine D has no effect on the actions of the state machines which are embedded in the states of D.
If an attempt is made to override a non-existent action, an error is declared and the function returns without doing anything.
The override mechanism is only available for derived state machines. If this function is called on a state machine which was not derived by extending some other state machine, an error is declared.
This function reports the following errors in the error code of the state machine descriptor:
smDesc | the descriptor of the derived state machine. |
oldAction | the action to be overridden |
newAction | the new action which overrides the old action |
Definition at line 456 of file FwSmConfig.c.
void FwSmOverrideGuard | ( | FwSmDesc_t | smDesc, |
FwSmGuard_t | oldGuard, | ||
FwSmGuard_t | newGuard | ||
) |
Override a guard in a derived state machine.
By default a derived state machine has the same guards as the base state machine from which it was derived. This function overrides one of the guards of the derived state machine.
As an example consider the case of a base state machine B and suppose that the transitions from state S1 to state S2 and the transition from state S3 to state S4 both have the same guard g1. If an application creates a derived state machine D from B (for instance, through function FwSmCreateDer
), then, after creation, the guard of the transition from S1 to S2 and from S3 to S4 is still g1. This function can be used to change g1. Note that a single invocation of this function will change the guard on both transitions.
A call to this function on a state machine D has no effect on the guards of the state machines which are embedded in the states of D.
If an attempt is made to override a non-existent guard, the function declares an error and returns.
The override mechanism is only available for derived state machines. If this function is called on a state machine which was not derived by extending some other state machine, an error is declared.
This function reports the following errors in the error code of the state machine descriptor:
smDesc | the descriptor of the derived state machine. |
oldGuard | the guard to be overridden |
newGuard | the new guard which overrides the old guard |
Definition at line 475 of file FwSmConfig.c.
void FwSmSetData | ( | FwSmDesc_t | smDesc, |
void * | smData | ||
) |
Set the pointer to the state machine data in the state machine descriptor.
The state machine data are data which are manipulated by the state machine actions and guards. The state machine descriptor holds a pointer to the state machine data. This function allows this pointer to be defined. The exact type of the state machine data is defined by applications for each state machine. It is therefore unknown at the level of the FW State Machine Module. This function accordingly treats the pointer to the state machine data as a pointer to void
. In most cases, the state machine data will take the form of a struct
whose fields represents the inputs and outputs for the state machine actions and guards.
The functions which implement the actions and guards access the state machine data as follows:
FwSmAction_t
and FwSmGuard_t
).FwSmGetData
function to retrieve the pointer to the state machine data.FwSmGetData
is defined as a pointer to void
and will normally have to be cast to its true type. smDesc | the descriptor of the state machine to which the data structure is attached. |
smData | the pointer to the state machine data. A value of NULL is legal (but note that the default value of the pointer to the state machine data when the state machine is created is NULL). |
Definition at line 83 of file FwSmConfig.c.