CORDET Framework - C2 Implementation
CrFwOutRegistry.c File Reference

Implementation of OutRegistry component. More...

Go to the source code of this file.

Data Structures

struct  CrFwTrackedState_t
 An instance of this type holds the information about an incoming command or report which is being tracked by the InRegistry. More...
 

Functions

static void OutRegistryInitAction (FwPrDesc_t initPr)
 Initialization action for OutRegistry. More...
 
static void OutRegistryConfigAction (FwPrDesc_t resetPr)
 Configuration action for OutRegistry. More...
 
static void OutRegistryShutdownAction (FwSmDesc_t smDesc)
 Shutdown action for OutRegistry. More...
 
FwSmDesc_t CrFwOutRegistryMake ()
 Factory function for the singleton instance of the OutRegistry. More...
 
CrFwServType_t CrFwOutRegistryGetServType (CrFwCmdRepIndex_t cmdRepIndex)
 Get the service type of the argument command or report index. More...
 
CrFwServSubType_t CrFwOutRegistryGetServSubType (CrFwCmdRepIndex_t cmdRepIndex)
 Get the service sub-type of the argument command or report index. More...
 
CrFwDiscriminant_t CrFwOutRegistryGetUpperDiscriminant (CrFwCmdRepIndex_t cmdRepIndex)
 Get the upper bound of the argument command or report index. More...
 
CrFwDiscriminant_t CrFwOutRegistryGetLowerDiscriminant (CrFwCmdRepIndex_t cmdRepIndex)
 Get the lower bound of the argument command or report index. More...
 
CrFwBool_t CrFwOutRegistryIsDiscriminantEnabled (CrFwCmdRepIndex_t cmdRepIndex, CrFwDiscriminant_t disc)
 Get the enable status of a discriminant in the argument command or report index. More...
 
CrFwCmdRepIndex_t CrFwOutRegistryGetCmdRepIndex (CrFwServType_t servType, CrFwServSubType_t servSubType)
 Get the index corresponding to the argument [service type, service sub-type] of an out-going command or report. More...
 
void CrFwOutRegistrySetEnable (CrFwServType_t servType, CrFwServSubType_t servSubType, CrFwDiscriminant_t discriminant, CrFwBool_t isEnabled)
 Set the enable state of a set of out-going commands or reports. More...
 
CrFwBool_t CrFwOutRegistryIsEnabled (FwSmDesc_t outCmp)
 Query the enable status of an out-going command or report. More...
 
void CrFwOutRegistryStartTracking (FwSmDesc_t outCmp)
 Ask the OutRegistry to start tracking an out-going command or report. More...
 
void CrFwOutRegistryUpdateState (FwSmDesc_t outCmp, CrFwOutRegistryCmdRepState_t newState)
 Ask the OutRegistry to update the state of an out-going command or report. More...
 
CrFwOutRegistryCmdRepState_t CrFwOutRegistryGetState (CrFwInstanceId_t cmdRepId)
 Query the OutRegistry for the state of an out-going command or report. More...
 

Variables

static CrFwServDesc_t servDesc [CR_FW_OUTREGISTRY_NSERV] = CR_FW_OUTREGISTRY_INIT_SERV_DESC
 Array of service descriptors (see CrFwServDesc_t).
 
static CrFwTrackedState_t cmdRepState [CR_FW_OUTREGISTRY_N]
 Array to track the state of out-going commands or reports.
 
static CrFwTrackingIndex_t cmdRepStateIndex = 0
 The index of the most recent entry in cmdRepState.
 
static FwSmDesc_t outRegistry = NULL
 The OutRegistry singleton.
 
static CrFwCmpData_t outRegistryData
 The data for the OutRegistry singleton.
 

Detailed Description

Implementation of OutRegistry component.

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

Function Documentation

◆ CrFwOutRegistryGetCmdRepIndex()

CrFwCmdRepIndex_t CrFwOutRegistryGetCmdRepIndex ( CrFwServType_t  servType,
CrFwServSubType_t  servSubType 
)

Get the index corresponding to the argument [service type, service sub-type] of an out-going command or report.

For out-going commands or reports the index uniquely identifies a pair: [service type, service sub-type]. This function returns the index corresponding to a specific [service type, service sub-type] pair. If either of the two arguments has an illegal value (i.e. if it has a value which does not correspond to any [service type, service sub-type] declared in the initializer of the service descriptor CR_FW_OUTREGISTRY_INIT_SERV_DESC.), the function returns CR_FW_OUTREGISTRY_NSERV.

Parameters
servTypethe service type
servSubTypethe service sub-type
Returns
cmdRepIndex the command or report index or CR_FW_OUTREGISTRY_NSERV if the specified [type, sub-type] does not exist

Definition at line 167 of file CrFwOutRegistry.c.

◆ CrFwOutRegistryGetLowerDiscriminant()

CrFwDiscriminant_t CrFwOutRegistryGetLowerDiscriminant ( CrFwCmdRepIndex_t  cmdRepIndex)

Get the lower bound of the argument command or report index.

For out-going commands or reports the index uniquely identifies a pair: [service type, service sub-type]. This function returns the lower discriminant value corresponding to a certain index value. If the index value is out of range (i.e. if it is greater than CR_FW_OUTREGISTRY_NSERV-1), the behaviour of this function is undefined.

Parameters
cmdRepIndexthe command or report index
Returns
the lower discriminant bound corresponding to the command or report index

Definition at line 156 of file CrFwOutRegistry.c.

◆ CrFwOutRegistryGetServSubType()

CrFwServSubType_t CrFwOutRegistryGetServSubType ( CrFwCmdRepIndex_t  cmdRepIndex)

Get the service sub-type of the argument command or report index.

For out-going commands or reports the index uniquely identifies a pair: [service type, service sub-type]. This function returns the service sub-type corresponding to a certain index value. If the index value is out of range (i.e. if it is greater than CR_FW_OUTREGISTRY_NSERV-1), the behaviour of this function is undefined.

Parameters
cmdRepIndexthe command or report index
Returns
the service type corresponding to the command or report index

Definition at line 146 of file CrFwOutRegistry.c.

◆ CrFwOutRegistryGetServType()

CrFwServType_t CrFwOutRegistryGetServType ( CrFwCmdRepIndex_t  cmdRepIndex)

Get the service type of the argument command or report index.

For out-going commands or reports the index uniquely identifies a pair: [service type, service sub-type]. This function returns the service type corresponding to a certain index value. If the index value is out of range (i.e. if it is greater than CR_FW_OUTREGISTRY_NSERV-1), the behaviour of this function is undefined.

Parameters
cmdRepIndexthe command or report index
Returns
the service type corresponding to the command or report index

Definition at line 141 of file CrFwOutRegistry.c.

◆ CrFwOutRegistryGetState()

CrFwOutRegistryCmdRepState_t CrFwOutRegistryGetState ( CrFwInstanceId_t  cmdRepId)

Query the OutRegistry for the state of an out-going command or report.

If the specified index does not correspond to any command or report being tracked by the OutRegistry, a value of crOutRegistryNotTracked is returned. This function searches all locations in the InRegistry in sequence until it finds the out-going command or report.

Parameters
cmdRepIdthe instance identifier of the out-going command or report.
Returns
the state of the out-going command or report (or crOutRegistryNotTracked if the command or report is not tracked)

Definition at line 307 of file CrFwOutRegistry.c.

◆ CrFwOutRegistryGetUpperDiscriminant()

CrFwDiscriminant_t CrFwOutRegistryGetUpperDiscriminant ( CrFwCmdRepIndex_t  cmdRepIndex)

Get the upper bound of the argument command or report index.

For out-going commands or reports the index uniquely identifies a pair: [service type, service sub-type]. This function returns the upper discriminant value corresponding to a certain index value. If the index value is out of range (i.e. if it is greater than CR_FW_OUTREGISTRY_NSERV-1), the behaviour of this function is undefined.

Parameters
cmdRepIndexthe command or report index
Returns
the upper discriminant bound corresponding to the command or report index

Definition at line 151 of file CrFwOutRegistry.c.

◆ CrFwOutRegistryIsDiscriminantEnabled()

CrFwBool_t CrFwOutRegistryIsDiscriminantEnabled ( CrFwCmdRepIndex_t  cmdRepIndex,
CrFwDiscriminant_t  disc 
)

Get the enable status of a discriminant in the argument command or report index.

For out-going commands or reports the index uniquely identifies a pair: [service type, service sub-type]. For each [service type, service sub-type], the OutRegistry stores the range of discriminant values and stores the current enable type of each discriminant value (the boudanries of the range are returned by functions CrFwOutRegistryGetUpperDiscriminant and CrFwOutRegistryGetLowerDiscriminant). This function returns the enable status of a discriminant in that range.

If the index value is out of range (i.e. if it is greater than CR_FW_OUTREGISTRY_NSERV-1) or if the argument discriminant is out of range (i.e. if it is outside the interval [l,u] where l and u are the return values of CrFwOutRegistryGetUpperDiscriminant and CrFwOutRegistryGetLowerDiscriminant), or if there are no discriminants associated to the argument command or report index, the behaviour of this function is undefined.

Parameters
cmdRepIndexthe command or report index
discthe value of the discriminant
Returns
the enable status of the i-th discriminant in the discriminant range of the command or report index

Definition at line 161 of file CrFwOutRegistry.c.

◆ CrFwOutRegistryIsEnabled()

CrFwBool_t CrFwOutRegistryIsEnabled ( FwSmDesc_t  outCmp)

Query the enable status of an out-going command or report.

If the argument does not represent an out-going command or report (i.e. if it is not a component of type OutComponent), the behaviour of the function is undefined. The enable state of an out-going command or report is determined by running the Enable State Determination Procedure shown in the figure.

Parameters
outCmpthe out-going command or report as an OutComponent
Returns
the enable state of the specified command or report (1 means enabled and 0 means disabled)

Definition at line 257 of file CrFwOutRegistry.c.

◆ CrFwOutRegistryMake()

FwSmDesc_t CrFwOutRegistryMake ( )

Factory function for the singleton instance of the OutRegistry.

The first time this function is called, it creates and configures the OutRegistry. Subsequent calls returns the same singleton instance. The first time this function is called, it returns the OutRegistry in state CREATED.

If the creation or the configuration of the OutRegistry fails, the function returns NULL.

Returns
singleton instance of the OutRegistry or NULL if the creation or configuration of the OutRegistry failed.

Definition at line 97 of file CrFwOutRegistry.c.

◆ CrFwOutRegistrySetEnable()

void CrFwOutRegistrySetEnable ( CrFwServType_t  servType,
CrFwServSubType_t  servSubType,
CrFwDiscriminant_t  discriminant,
CrFwBool_t  isEnabled 
)

Set the enable state of a set of out-going commands or reports.

The enable state of out-going command and reports can be controlled at three levels:

  • At the level of the service type (all commands or reports of a certain type are disabled)
  • At the level of the service sub-type (all commands or reports matching a certain [type, sub-type] pair are disabled)
  • At the level of the discriminant (all commands or reports matching a certain [type, sub-type, discriminant] triplet are enabled or disabled)

This function allows all three enable levels to be set according to the logic in the activity diagram shown below. Use of illegal values for the function parameters results in the application error code being set to: crIllServType (if the service type is illegal), or to crIllServSubType (if the service sub-type is illegal), or to crIllDiscriminant (if the discriminant value is illegal). A service type or sub-type or a discriminant value are illegal if they are not covered in the list of [type, sub-types, discriminant] in the CrFwOutRegistryUserPar.h (see CR_FW_OUTREGISTRY_INIT_SERV_DESC).

Parameters
servTypethe service type
servSubTypethe service type
discriminantthe discriminant
isEnabledthe enable state (1 means enabled and 0 means disabled)

Definition at line 193 of file CrFwOutRegistry.c.

◆ CrFwOutRegistryStartTracking()

void CrFwOutRegistryStartTracking ( FwSmDesc_t  outCmp)

Ask the OutRegistry to start tracking an out-going command or report.

The OutRegistry tracks the state of the last N out-going command or reports to have been loaded with this function. Initially, when this function is called, the out-going command or report is placed in state PENDING. This function runs the procedure in the left-hand side of the activity diagram shown in the figure.

Parameters
outCmpthe out-going command or report to be tracked

Definition at line 278 of file CrFwOutRegistry.c.

◆ CrFwOutRegistryUpdateState()

void CrFwOutRegistryUpdateState ( FwSmDesc_t  outCmp,
CrFwOutRegistryCmdRepState_t  newState 
)

Ask the OutRegistry to update the state of an out-going command or report.

If the argument component is not tracked by the OutRegistry (perhaps because too many OutComponents have been added to the list of tracked components), nothing is done. This function runs the procedure in the right-hand side of the activity diagram shown in the figure.

Parameters
outCmpthe out-going command or report to be tracked
newStatethe new state of the out-going command or report

Definition at line 294 of file CrFwOutRegistry.c.

◆ OutRegistryConfigAction()

static void OutRegistryConfigAction ( FwPrDesc_t  resetPr)
static

Configuration action for OutRegistry.

This function sets the enable state of all service types, sub-types and discriminant to "enabled" and resets the queue of tracked commands and reports. The outcome of the configuration action is always: "successful"

Parameters
resetPrthe Configuration Procedure of the OutRegistry

Definition at line 357 of file CrFwOutRegistry.c.

◆ OutRegistryInitAction()

static void OutRegistryInitAction ( FwPrDesc_t  initPr)
static

Initialization action for OutRegistry.

This function allocates the memory for the OutRegistry data structures and initializes all data structures which depend on the set of services supported by the application. The outcome of the initialization action is always "success". The situation where the memory allocation for the OutRegistry data structures fails is not handled and will result in undefined behaviour (probably a run-time exception).

Parameters
initPrthe Initialization Procedure of the OutRegistry

Definition at line 331 of file CrFwOutRegistry.c.

◆ OutRegistryShutdownAction()

static void OutRegistryShutdownAction ( FwSmDesc_t  smDesc)
static

Shutdown action for OutRegistry.

This function sets the enable state of all service types, sub-types and discriminant to "enabled" and resets the queue of tracked commands and reports. This function also releases the memory allocated when the OutRegistry was initialized.

Parameters
smDescthe OutRegistry state machine

Definition at line 382 of file CrFwOutRegistry.c.

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