CORDET Framework - C2 Implementation
|
Implementation of InFactory component. More...
Go to the source code of this file.
Functions | |
static void | InFactoryInitAction (FwPrDesc_t initPr) |
Initialization action for InFactory. More... | |
static void | InFactoryConfigAction (FwPrDesc_t initPr) |
Configuration action for InFactory. More... | |
static void | InFactoryShutdownAction (FwSmDesc_t smDesc) |
Shutdown action for InFactory. More... | |
FwSmDesc_t | CrFwInFactoryMake () |
Factory function for the singleton instance of the InFactory. More... | |
FwSmDesc_t | CrFwInFactoryMakeInCmd (CrFwPckt_t pckt) |
Make function for a component encapsulating an incoming command (InCommand). More... | |
FwSmDesc_t | CrFwInFactoryMakeInRep (CrFwPckt_t pckt) |
Make function for a component encapsulating an incoming report (InReport). More... | |
void | CrFwInFactoryReleaseInCmd (FwSmDesc_t inCmdInstance) |
Release function for an InCommand. More... | |
void | CrFwInFactoryReleaseInRep (FwSmDesc_t inRepInstance) |
Release function for an InReport. More... | |
CrFwInFactoryPoolIndex_t | CrFwInFactoryGetNOfAllocatedInCmd () |
Return the number of InCommands which are currently allocated. More... | |
CrFwInFactoryPoolIndex_t | CrFwInFactoryGetMaxNOfInCmd () |
Return the maximum number of InCommands which may be allocated at any one time. More... | |
CrFwInFactoryPoolIndex_t | CrFwInFactoryGetNOfAllocatedInRep () |
Return the number of InReports which are currently allocated. More... | |
CrFwInFactoryPoolIndex_t | CrFwInFactoryGetMaxNOfInRep () |
Return the maximum number of InReports which may be allocated at any one time. More... | |
Variables | |
static CrFwCmdRepKindKey_t | inCmdKindKey [CR_FW_INCMD_NKINDS] |
Array holding the keys of the InCommand kinds. | |
static CrFwCmdRepKindKey_t | inRepKindKey [CR_FW_INREP_NKINDS] |
Array holding the keys of the InReport kinds. | |
static CrFwInCmdKindDesc_t | inCmdKindDesc [CR_FW_INCMD_NKINDS] = CR_FW_INCMD_INIT_KIND_DESC |
Array of InCommand service descriptors. | |
static CrFwInRepKindDesc_t | inRepKindDesc [CR_FW_INREP_NKINDS] = CR_FW_INREP_INIT_KIND_DESC |
Array of InReport service descriptors. | |
static FwSmDesc_t | inCmd [CR_FW_INFACTORY_MAX_NOF_INCMD] |
The pre-allocated InCommand instances. | |
static FwSmDesc_t | inRep [CR_FW_INFACTORY_MAX_NOF_INREP] |
The pre-allocated InReport instances. | |
static CrFwCmpData_t | inCmdData [CR_FW_INFACTORY_MAX_NOF_INCMD] |
The base data for the pre-allocated InCommand instances. | |
static CrFwInCmdData_t | inCmdCmpSpecificData [CR_FW_INFACTORY_MAX_NOF_INCMD] |
The component-specific data for the pre-allocated InCommand instances. | |
static CrFwCmpData_t | inRepData [CR_FW_INFACTORY_MAX_NOF_INREP] |
The base data for the pre-allocated InReport instances. | |
static CrFwInRepData_t | inRepCmpSpecificData [CR_FW_INFACTORY_MAX_NOF_INREP] |
The component-specific data for the pre-allocated InReport instances. | |
static CrFwBool_t | inRepInUse [CR_FW_INFACTORY_MAX_NOF_INREP] |
The in-use status of each pre-allocated InReport instance. | |
static CrFwBool_t | inCmdInUse [CR_FW_INFACTORY_MAX_NOF_INCMD] |
The in-use status of each pre-allocated InCommand instance. | |
static CrFwInFactoryPoolIndex_t | nOfAllocatedInCmd |
The number of currently allocated InCommands. | |
static CrFwInFactoryPoolIndex_t | nOfAllocatedInRep |
The number of currently allocated InReports. | |
static CrFwInFactoryPoolIndex_t | nextInCmdFreePos |
The index of the next free position in the pool of pre-allocated InCommands instances (a value of CR_FW_INFACTORY_MAX_NOF_INCMD indicates that all InCommand instances have been allocated and there are no free positions left) | |
static CrFwInFactoryPoolIndex_t | nextInRepFreePos |
The index of the next free position in the pool of pre-allocated InReports instances (a value of CR_FW_INFACTORY_MAX_NOF_INREP indicates that all InReport instances have been allocated and there are no free positions left) | |
static CrFwInstanceId_t | nOfAllocatedInCmdSinceReset = 0 |
The total number of InCommands or InCommand allocated since the InFactory was reset. | |
static CrFwInstanceId_t | nOfAllocatedInRepSinceReset = 0 |
The total number of InReports or InCommand allocated since the InFactory was reset. | |
static FwSmDesc_t | inFactory |
The singleton instance of the InFactory. | |
static CrFwCmpData_t | inFactoryData |
The data for the InFactory singleton. More... | |
Implementation of InFactory component.
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 CrFwInFactory.c.
CrFwInFactoryPoolIndex_t CrFwInFactoryGetMaxNOfInCmd | ( | ) |
Return the maximum number of InCommands which may be allocated at any one time.
Definition at line 356 of file CrFwInFactory.c.
CrFwInFactoryPoolIndex_t CrFwInFactoryGetMaxNOfInRep | ( | ) |
Return the maximum number of InReports which may be allocated at any one time.
Definition at line 366 of file CrFwInFactory.c.
CrFwInFactoryPoolIndex_t CrFwInFactoryGetNOfAllocatedInCmd | ( | ) |
Return the number of InCommands which are currently allocated.
This function returns the number of InCommands which have been successfully allocated through calls to CrFwInFactoryMakeInCmd
and have not yet been released through calls to CrFwInFactoryReleaseInCmd
.
Definition at line 351 of file CrFwInFactory.c.
CrFwInFactoryPoolIndex_t CrFwInFactoryGetNOfAllocatedInRep | ( | ) |
Return the number of InReports which are currently allocated.
This function returns the number of InReports which have been successfully allocated through calls to CrFwInFactoryMakeInRep
and have not yet been released through calls to CrFwInFactoryReleaseInRep
.
Definition at line 361 of file CrFwInFactory.c.
FwSmDesc_t CrFwInFactoryMake | ( | ) |
Factory function for the singleton instance of the InFactory.
The first time it is called, this function creates the InFactory singleton instance. Subsequent calls return the same instance. The first time this function is called, it returns the InFactory in state CREATED.
Definition at line 151 of file CrFwInFactory.c.
FwSmDesc_t CrFwInFactoryMakeInCmd | ( | CrFwPckt_t | pckt | ) |
Make function for a component encapsulating an incoming command (InCommand).
This function initializes and resets a component before returning it. Under nominal conditions, the component returned by this function is therefore in state CONFIGURED (but it could be in state INITIALIZED if the InCommand's configuration check fails).
An InCommand encapsulates an incoming packet holding a command. The packet is passed as an argument to this function. The packet holds all the information about the incoming command. In particular, it holds the information about the command kind (as determined by the triplet: [service type, service sub-type, discriminant]). This function checks the command kind and, if it finds that it is illegal, it returns NULL and sets the application error code to: crIllInCmdKind
). If instead the command is legal, this function uses it to configure the InCommand. The configuration information is retrieved from CrFwInFactoryUserPar
.
The Progress Step of the InCommands returned by this function is initialized to 0. Likewise, the completion status of the progress action of the InCommand is initialized to 1 indicating "completed" (this results in an InCommand whose progress action is only executed once). The counter of failed progress steps is initialized to zero.
If the allocation of the memory for the new InCommand fails, the function returns NULL. Allocation memory failure results in the application error code being set to crInCmdAllocationFail
.
When an InCommand created by this function is no longer needed, it should be returned to the factory by calling CrFwInFactoryReleaseInCmd
.
If the InFactory is reset, then all the InCommands which had been created by the factory are released.
pckt | the packet holding the InCommand |
Definition at line 195 of file CrFwInFactory.c.
FwSmDesc_t CrFwInFactoryMakeInRep | ( | CrFwPckt_t | pckt | ) |
Make function for a component encapsulating an incoming report (InReport).
This function initializes and resets a component before returning it. Under nominal conditions, the component returned by this function is therefore in state CONFIGURED (but it could be in state INITIALIZED if the InReport's configuration check fails).
An InReport encapsulates an incoming packet holding a report. The packet is passed as an argument to this function. The packet holds all the information about the incoming report. In particular, it holds the information about the report kind (as determined by the triplet: [service type, service sub-type, discriminant]). This function checks the report kind and, if it finds that it is illegal, it returns NULL and sets the application error code to: crIllInRepKind
). If instead the command is legal, this function uses it to configure the InReport. The configuration information is retrieved from CrFwInFactoryUserPar
.
If the allocation of the memory for the new InReport fails, the function returns NULL. Allocation memory failure results in the application error code being set to crInRepAllocationFail
.
When an InReport created by this function is no longer needed, it should be returned to the factory by calling CrFwInRepReleaseInRep
.
The instance identifier of the InReport created by this function is equal to the number of InReports created by the factory since it was last reset.
If the InFactory is reset, then all the InReports which had been created by the factory are released.
pckt | the packet holding the InReport |
Definition at line 256 of file CrFwInFactory.c.
void CrFwInFactoryReleaseInCmd | ( | FwSmDesc_t | inCmdInstance | ) |
Release function for an InCommand.
The argument of this function must be an InCommand which was created using function CrFwInFactoryMakeInCmd
. This function releases the memory which was allocated to the InCommand. After this function is called, the InCommand cannot be used. The function does not perform any checks on the existence or status of the InCommand. An attempt to use an InCommand which has been released will result in undefined behaviour.
An attempt to release an InCommand which had already been released, or to release a non-existent InCommand will result in undefined behaviour and in the application error code being set to: crInCmdRelErr
.
inCmdInstance | the InCommand to be released |
Definition at line 309 of file CrFwInFactory.c.
void CrFwInFactoryReleaseInRep | ( | FwSmDesc_t | inRepInstance | ) |
Release function for an InReport.
The argument of this function must be an InReport which was created using function CrFwInFactoryMakeInRep
. This function releases the memory which was allocated to the InReport. After this function is called, the InReport cannot be used. The function does not perform any checks on the existence or status of the InReport. An attempt to use an InReport which has been released will result in undefined behaviour.
An attempt to release an InReport which had already been released, or to release a non-existent InReport will result in undefined behaviour and in the application error code being set to: crInRepRelErr
.
inRepInstance | the InReport to be released |
Definition at line 330 of file CrFwInFactory.c.
|
static |
Configuration action for InFactory.
This function releases all the InCommands and InReports which are currently allocated. After this function has been called, any InCommand or InReport which is still in use within the application is no longer valid and should be discarded.
This function also resets the counter used to initialize the instance identifiers of the InCommands and InReports created by the InFactory. After reset, the first InCommand or InReport made by the InFactory will have instance identifier set to 1.
The outcome of the initialization action is always: "success"
initPr | the Initialization Procedure of the InFactory |
Definition at line 461 of file CrFwInFactory.c.
|
static |
Initialization action for InFactory.
This function: (a) allocates the memory for the InFactory data structures; (b) initializes the arrays of descriptors inCmdKindDesc
and inRepKindDesc
; and (c) initializes the component-specific field of the data structures for InCommands and InReports. The outcome of the initialization action is "success" in all cases except when a memory allocation operation fails.
initPr | the Initialization Procedure of the InFactory |
Definition at line 371 of file CrFwInFactory.c.
|
static |
Shutdown action for InFactory.
This function releases the memory which was allocated when the InFactory was initialized and it sets the number of allocated InCommands and InReports to zero. After this function has been called, any InCommand or InReport which is still in use within the application is no longer valid and should be discarded.
smDesc | the InFactory state machine |
Definition at line 491 of file CrFwInFactory.c.
|
static |
The data for the InFactory singleton.
Definition at line 109 of file CrFwInFactory.c.