FW Profile - C1 Implementation
FwSmSCreate.c File Reference

Implements the static initialization functions for the FW State Machine Module. More...

Go to the source code of this file.

Functions

void FwSmInit (FwSmDesc_t smDesc)
 Initialize a state machine descriptor to represent an unconfigured state machine with no transitions, no actions, no guards and no embedded state machines. More...
 
void FwSmInitDer (FwSmDesc_t smDesc, FwSmDesc_t smDescBase)
 Initialize a state machine descriptor to extend another state machine (the base state machine). More...
 

Detailed Description

Implements the static initialization functions for the FW State Machine Module.

Author
Vaclav Cechticky vacla.nosp@m.v.ce.nosp@m.chtic.nosp@m.ky@p.nosp@m.np-so.nosp@m.ftwa.nosp@m.re.co.nosp@m.m
Alessandro Pasetti paset.nosp@m.ti@p.nosp@m.np-so.nosp@m.ftwa.nosp@m.re.co.nosp@m.m

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 FwSmSCreate.c.

Function Documentation

void FwSmInit ( FwSmDesc_t  smDesc)

Initialize a state machine descriptor to represent an unconfigured state machine with no transitions, no actions, no guards and no embedded state machines.

After this function has been executed, the argument state machine descriptor has the same content as a state machine descriptor which has been created by calling FwSmCreate.

This function is primarily intended to be used to initialize a state machine descriptor which has been statically instantiated with macro FW_SM_INST or FW_SM_INST_NOCPS.

If the function is called upon a state machine descriptor that had already been initialized, the previous initialization values are lost. In such a case, a memory leak is possible due to the potential loss of the pointers to the arrays where the state machines states, choice pseudo-states, transitions and embedded state machines are stored.

Parameters
smDescthe state machine descriptor to be initialized.

Definition at line 24 of file FwSmSCreate.c.

void FwSmInitDer ( FwSmDesc_t  smDesc,
FwSmDesc_t  smDescBase 
)

Initialize a state machine descriptor to extend another state machine (the base state machine).

This function checks that the descriptor to be initialized satisfies the following constraints:

  • it has the same number of actions as the base state machine, and
  • it has the same number of guards as the base state machine.

If either constraint is not satisfied, the function reports an error by setting the error code of the descriptor to be initialized and then returns. If the first constraint is not satisfied, the function sets the error code to smWrongNOfActions. If the second constraint is not satisfied, the function sets the error code to smWrongNOfGuards.

If both constraints are satisfied, this function initializes a descriptor as follows:

  • It links it to the descriptor of the base state machine.
  • It initializes its actions to be the same as the actions of the base state machine.
  • It initializes its guards to be the same as the guards of the base state machine.
  • It initializes its states to have no embedded state machines.
  • It initializes its error code to be the same as the error code of the base state machine.
  • It initializes its transCnt field to zero.
  • It sets its state to STOPPED.

Thus, if the base state machine has no embedded state machines, then this function initializes a descriptor to represent its derived state machine. In this case, the descriptor initialized by this function represents exactly the same state machine as the descriptor created by calling function FwSmCreateDer. If, instead, the base state machine has one or more embedded state machines, then, in order to achieve the same effect as the FwSmCreateDer function, the descriptor initialized by this function must be further configured as follows:

  • The state machines embedded in the base state machine are extended. The extension is done using, recursively, the FW_SM_INST_DER macro and the FwSmInitDer function. Let ESM(i) be the extension of the state machine embedded in the i-th state of the base state machine.
  • The ESM(i) state machine is embedded within the i-th state of the descriptor initialized by this function using the FwSmEmbed function.

This function is primarily intended to be used to initialize a state machine descriptor which has been statically instantiated with macro FW_SM_INST_DER. If the function is called upon a state machine descriptor that had already been initialized, the previous initialization values are lost. In such a case, a memory leak is possible due to the potential loss of the pointers to the arrays where the state machines states, choice pseudo-states, transitions and embedded state machines are stored.

Parameters
smDescthe state machine descriptor to be initialized.
smDescBasethe state machine descriptor of the base state machine.

Definition at line 54 of file FwSmSCreate.c.

P&P Software GmbH, Copyright 2011, All Rights Reserved