CORDET Framework - C2 Implementation
CrFwUtilityFunctions.c File Reference

Implementation of utility functions. More...

Go to the source code of this file.

Functions

CrFwAppErrCode_t CrFwGetAppErrCode ()
 Return the value of the application error code. More...
 
void CrFwSetAppErrCode (CrFwAppErrCode_t errCode)
 Set the value of the application error code (see CrFwGetAppErrCode). More...
 
void CrFwSetPrOutcome (FwPrDesc_t prDesc, CrFwOutcome_t outcome)
 Convenience function to set the outcome field of the component data of a procedure. More...
 
FwPrBool_t CrFwIsPrOutcomeOne (FwPrDesc_t prDesc)
 Convenience function to check whether the outcome of the last check or action is equal to 1 ("true" or "success"). More...
 
void CrFwSetSmOutcome (FwSmDesc_t smDesc, CrFwOutcome_t outcome)
 Convenience function to set the outcome of the last check or action of a state machine. More...
 
CrFwOutcome_t CrFwGetSmOutcome (FwSmDesc_t smDesc)
 Convenience function to get the outcome of the last check or action of a state machine. More...
 
FwSmBool_t CrFwIsSmOutcomeZero (FwSmDesc_t smDesc)
 Convenience function to check whether the outcome of the last check or action is equal to 0 ("false"). More...
 
FwSmBool_t CrFwIsSmOutcomeOne (FwSmDesc_t smDesc)
 Convenience function to check whether the outcome of the last check or action is equal to 1 ("true"). More...
 
FwSmBool_t CrFwIsSmOutcomeTwo (FwSmDesc_t smDesc)
 Convenience function to check whether the outcome of the last check or action is equal to 2. More...
 
FwPrBool_t CrFwWaitOnePrCycle (FwPrDesc_t prDesc)
 Convenience function which returns true when a procedure has spent more than one cycle in the current action node. More...
 
CrFwBool_t CrFwPrCheckAlwaysTrue (FwPrDesc_t prDesc)
 Convenience function to be used in a procedure as default implementation for a check which always returns true. More...
 
CrFwBool_t CrFwSmCheckAlwaysTrue (FwSmDesc_t smDesc)
 Convenience function to be used in a state machine as default implementation for a check which always returns true. More...
 
CrFwBool_t CrFwSmCheckAlwaysFalse (FwSmDesc_t smDesc)
 Convenience function to be used in a state machine as default implementation for a check which always returns false. More...
 
void CrFwPrEmptyAction (FwPrDesc_t prDesc)
 Convenience function to be used in a procedure as default implementation for an action which returns without doing anything. More...
 
void CrFwSmEmptyAction (FwSmDesc_t smDesc)
 Convenience function to be used in a state machine as default implementation for an action which returns without doing anything. More...
 
void CrFwSmSuccessAction (FwSmDesc_t smDesc)
 Convenience function to be used in a state machine as default implementation for an action which sets the action outcome to 1 (corresponding to 'success') and then returns. More...
 
CrFwCmdRepKindIndex_t CrFwFindCmdRepKindIndex (CrFwCmdRepKindKey_t *cmdRepKindArray, CrFwCmdRepKindIndex_t length, CrFwCmdRepKindKey_t targetKey)
 Convenience function to retrieve the index of an array where a certain target value is located. More...
 

Variables

static CrFwAppErrCode_t appErrCode = crNoAppErr
 The application error code. More...
 

Detailed Description

Implementation of utility functions.

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 CORDET Framework.

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

Function Documentation

CrFwCmdRepKindIndex_t CrFwFindCmdRepKindIndex ( CrFwCmdRepKindKey_t cmdRepKindArray,
CrFwCmdRepKindIndex_t  length,
CrFwCmdRepKindKey_t  targetKey 
)

Convenience function to retrieve the index of an array where a certain target value is located.

This function is used by the InFactory (see CrFwInFactory.h) and OutFactory (see CrFwOutFactory.h). The InFactory and OutFactory maintain arrays which store sets of command and report kinds in increasing order. A command or report kind is encoded through a key. This function finds the index corresponding to a given target key value.

Parameters
cmdRepKindArrayarray of key values (the key values must be stored in increasing order)
lengthlength of the array of key values
targetKeythe key value that is searched
Returns
the index in the array where the target key value is located or the length of the array if the target key value is not in the array

Definition at line 136 of file CrFwUtilityFunctions.c.

CrFwAppErrCode_t CrFwGetAppErrCode ( )

Return the value of the application error code.

The application error code is set by a framework function when when either of the following situations arises:

  • a framework function has been called by the application code with an illegal parameter values or in an illegal context and execution of the function with the illegal values would cause an internal framework data structure to be corrupted.
  • a framework function which releases dynamically allocated framework components has been asked to either release a non-allocated component or to release a component which had already been released.

Nominally, the application error code should be equal to: crNoAppErr. If the application error code has a different value, then it is likely that the framework is not configured as the user intended.

Returns
the application error code

Definition at line 40 of file CrFwUtilityFunctions.c.

CrFwOutcome_t CrFwGetSmOutcome ( FwSmDesc_t  smDesc)

Convenience function to get the outcome of the last check or action of a state machine.

This function assumes that the data attached to the state machine descriptor is a pointer to type CrFwCmpData). This type is a data structure which includes an 'outcome' field and this function sets this field to the value of the argument outcome. Each state machine is free to set its own convention for the interpretation of the outcome. For state machines representing commands and reports, a value of 1 means "success", and a value different from 1 means "failure". In the latter case, the value of the outcome is the failure code describing the reason for the failure.

Parameters
smDescthe state machine descriptor
Returns
outcome the value of the state machine outcome

Definition at line 68 of file CrFwUtilityFunctions.c.

FwPrBool_t CrFwIsPrOutcomeOne ( FwPrDesc_t  prDesc)

Convenience function to check whether the outcome of the last check or action is equal to 1 ("true" or "success").

This function returns "true" if and only if the outcome field of the component data (see CrFwCmpData) is equal to 1. This function is intended to be used as a guard in a procedure.

Parameters
prDescthe procedure descriptor
Returns
return 1 if the outcome is 1 and return 0 otherwise

Definition at line 56 of file CrFwUtilityFunctions.c.

FwSmBool_t CrFwIsSmOutcomeOne ( FwSmDesc_t  smDesc)

Convenience function to check whether the outcome of the last check or action is equal to 1 ("true").

This function returns "true" if and only if the outcome field of the component data (see CrFwCmpData) is equal to 1. This function is intended to be used as a guard in a state machine.

Parameters
smDescthe state machine descriptor
Returns
return 1 if the outcome is 1 and return 0 otherwise

Definition at line 80 of file CrFwUtilityFunctions.c.

FwSmBool_t CrFwIsSmOutcomeTwo ( FwSmDesc_t  smDesc)

Convenience function to check whether the outcome of the last check or action is equal to 2.

This function returns "true" if and only if the outcome field of the component data (see CrFwCmpData) is equal to 2. This function is intended to be used as a guard in a state machine.

Parameters
smDescthe state machine descriptor
Returns
return 1 if the outcome is 2 and return 0 otherwise

Definition at line 86 of file CrFwUtilityFunctions.c.

FwSmBool_t CrFwIsSmOutcomeZero ( FwSmDesc_t  smDesc)

Convenience function to check whether the outcome of the last check or action is equal to 0 ("false").

This function returns "true" if and only if the outcome field of the component data (see CrFwCmpData) is equal to 0. This function is intended to be used as a guard in a state machine.

Parameters
smDescthe state machine descriptor
Returns
return 1 if the outcome is 0 and return 0 otherwise

Definition at line 74 of file CrFwUtilityFunctions.c.

CrFwBool_t CrFwPrCheckAlwaysTrue ( FwPrDesc_t  prDesc)

Convenience function to be used in a procedure as default implementation for a check which always returns true.

Parameters
prDescthe procedure descriptor
Returns
always returns true

Definition at line 100 of file CrFwUtilityFunctions.c.

void CrFwPrEmptyAction ( FwPrDesc_t  prDesc)

Convenience function to be used in a procedure as default implementation for an action which returns without doing anything.

Parameters
prDescthe procedure descriptor

Definition at line 118 of file CrFwUtilityFunctions.c.

void CrFwSetAppErrCode ( CrFwAppErrCode_t  errCode)

Set the value of the application error code (see CrFwGetAppErrCode).

Parameters
errCodethe application error code

Definition at line 45 of file CrFwUtilityFunctions.c.

void CrFwSetPrOutcome ( FwPrDesc_t  prDesc,
CrFwOutcome_t  outcome 
)

Convenience function to set the outcome field of the component data of a procedure.

This function assumes that the data attached to the procedure descriptor is a pointer to type CrFwCmpData). This type is a data structure which includes an 'outcome' field and this function sets this field to the value of the argument outcome. Each procedure is free to set its own convention for the interpretation of the outcome but, for procedures defined at CORDET Framework level, a value of 0 means "failure" and a value of 1 means "success".

Parameters
prDescthe procedure descriptor
outcomethe value of the procedure outcome

Definition at line 50 of file CrFwUtilityFunctions.c.

void CrFwSetSmOutcome ( FwSmDesc_t  smDesc,
CrFwOutcome_t  outcome 
)

Convenience function to set the outcome of the last check or action of a state machine.

This function assumes that the data attached to the state machine descriptor is a pointer to type CrFwCmpData). This type is a data structure which includes an 'outcome' field and this function sets this field to the value of the argument outcome. Each state machine is free to set its own convention for the interpretation of the outcome. For state machines representing commands and reports, a value of 1 means "success", and a value different from 1 means "failure". In the latter case, the value of the outcome is the failure code describing the reason for the failure.

Parameters
smDescthe state machine descriptor
outcomethe value of the state machine outcome

Definition at line 62 of file CrFwUtilityFunctions.c.

CrFwBool_t CrFwSmCheckAlwaysFalse ( FwSmDesc_t  smDesc)

Convenience function to be used in a state machine as default implementation for a check which always returns false.

Parameters
smDescthe state machine descriptor
Returns
always returns false

Definition at line 112 of file CrFwUtilityFunctions.c.

CrFwBool_t CrFwSmCheckAlwaysTrue ( FwSmDesc_t  smDesc)

Convenience function to be used in a state machine as default implementation for a check which always returns true.

Parameters
smDescthe state machine descriptor
Returns
always returns true

Definition at line 106 of file CrFwUtilityFunctions.c.

void CrFwSmEmptyAction ( FwSmDesc_t  smDesc)

Convenience function to be used in a state machine as default implementation for an action which returns without doing anything.

Parameters
smDescthe state machine descriptor

Definition at line 124 of file CrFwUtilityFunctions.c.

void CrFwSmSuccessAction ( FwSmDesc_t  smDesc)

Convenience function to be used in a state machine as default implementation for an action which sets the action outcome to 1 (corresponding to 'success') and then returns.

Parameters
smDescthe state machine descriptor

Definition at line 130 of file CrFwUtilityFunctions.c.

FwPrBool_t CrFwWaitOnePrCycle ( FwPrDesc_t  prDesc)

Convenience function which returns true when a procedure has spent more than one cycle in the current action node.

This function can be used as a guard in a procedure where there is a need to express the fact that the procedure should remain only one cycle in a node: the guard is false after the action node has been executed the first time and becomes true after it has been executed the second time.

Parameters
prDescthe procedure descriptor
Returns
return 1 if the action of the current node has been executed two or more times; return 0 otherwise.

Definition at line 92 of file CrFwUtilityFunctions.c.

Variable Documentation

CrFwAppErrCode_t appErrCode = crNoAppErr
static

The application error code.

Definition at line 37 of file CrFwUtilityFunctions.c.

P&P Software GmbH, Copyright 2012-2013, All Rights Reserved