37 #include "FwSmConstants.h"
38 #include "FwSmDCreate.h"
39 #include "FwSmConfig.h"
41 #include "FwPrConstants.h"
42 #include "FwPrDCreate.h"
43 #include "FwPrConfig.h"
116 static void DoActionA(FwSmDesc_t smDesc);
124 static void DoActionB(FwSmDesc_t smDesc);
129 const FwSmCounterS1_t nOfStates = 2;
130 const FwSmCounterS1_t nOfChoicePseudoStates = 2;
131 const FwSmCounterS1_t nOfTrans = 8;
132 const FwSmCounterS1_t nOfActions = 2;
133 const FwSmCounterS1_t nOfGuards = 2;
134 const FwSmCounterS1_t CPS_1 = 1;
135 const FwSmCounterS1_t CPS_2 = 2;
137 FwPrDesc_t resetPr, execPr, initPr;
149 esm = FwSmCreate(nOfStates, nOfChoicePseudoStates, nOfTrans, nOfActions, nOfGuards);
152 FwSmAddChoicePseudoState(esm, CPS_1, 2);
153 FwSmAddChoicePseudoState(esm, CPS_2, 2);
154 FwSmAddTransIpsToCps(esm, CPS_1, NULL);
256 cmpSpecificData->
pckt = NULL;
258 return cmpSpecificData->
pckt;
304 cmpSpecificData->
pckt = NULL;
320 cmpSpecificData->
pckt = NULL;
368 while (cmpSpecificData->
isPcktAvail(nOfSrcs, srcs)) {
369 pckt = cmpSpecificData->
collectPckt(nOfSrcs, srcs);
400 return cmpSpecificData->
isPcktAvail(nOfSrcs, srcs);
void CrFwBaseCmpDefShutdownAction(FwSmDesc_t smDesc)
Function which performs the Shutdown Action for the Base State Machine.
FwSmDesc_t CrFwBaseCmpMake()
Retrieve the singleton instance of the Base State Machine.
Definition of Base Component.
Definition of the Framework Component Data (FCD) Type.
Header file to define all invariant publicly available constants and types for the CORDET Framework.
#define CR_FW_INSTREAM_TR_GET_PCKT
Identifier for transition command "GetPacket" in the InStream State Machine.
CrFwPckt_t(* CrFwPcktCollect_t)(CrFwDestSrc_t, CrFwDestSrc_t *)
Type for a pointer to a function implementing the Packet Collect Operation of an InStream.
#define CR_FW_INSTREAM_TR_PACKET_AVAILABLE
Identifier for transition command "PacketAvailable" in the InStream State Machine.
#define CR_FW_INSTREAM_STATE_PCKT_AVAIL
State identifier for state PCKT_AVAIL in the InStream State Machine.
unsigned char * CrFwPckt_t
Type for packets (see CrFwPckt.h).
int CrFwBool_t
Type used for boolean values (1 represent "true" and 0 represents "false").
CrFwBool_t(* CrFwPcktAvailCheck_t)(CrFwDestSrc_t, CrFwDestSrc_t *)
Type for a pointer to a function implementing the Packet Available Check Operation of an InStream.
#define CR_FW_BASE_STATE_CONFIGURED
State identifier for state CONFIGURED in the Base State Machine.
#define CR_FW_INSTREAM_TYPE
Type identifier for the InStream components.
#define CR_FW_INSTREAM_STATE_WAITING
State identifier for state WAITING in the InStream State Machine.
FwPrDesc_t CrFwBaseCmpGetDummyExecProc()
Retrieve the singleton instance of the Dummy CEP.
Dummy Component Execution Procedure (CEP) for the Base Component.
void CrFwInStreamDefInitAction(FwPrDesc_t prDesc)
Default initialization action for an InStream.
CrFwBool_t CrFwInStreamIsInWaiting(FwSmDesc_t smDesc)
Return true if the argument InStream is in state WAITING.
static int IsPcktAvail(FwSmDesc_t smDesc)
Function which checks if a packet is available.
CrFwCounterU1_t CrFwInStreamGetNOfSrc(FwSmDesc_t smDesc)
Get the number of packet sources of the argument InStream.
static CrFwPcktCollect_t inStreamPcktCollect[CR_FW_NOF_INSTREAM]
The functions implementing the packet hand-over operations for the InStream components.
static CrFwDestSrc_t inStreamSrcPairs[CR_FW_INSTREAM_NOF_SRCS][2]
The association between sources and inSreams.
CrFwCounterU1_t CrFwInStreamGetPcktQueueSize(FwSmDesc_t smDesc)
Return the size of the packet queue of the InStream.
static FwPrAction_t inStreamConfigCheck[CR_FW_NOF_INSTREAM]
The functions implementing the configuration checks for the InStream components.
CrFwCounterU1_t CrFwInStreamGetNOfPendingPckts(FwSmDesc_t smDesc)
Return the number of packets currently in the packet queue of an InStream.
static FwSmDesc_t baseInStreamSmDesc
Base InStream from which all other InStreams are derived.
static CrFwInStreamData_t inStreamCmpSpecificData[CR_FW_NOF_INSTREAM]
The component-specific data for the InStream State Machines and their Procedures.
static FwSmDesc_t inStreamDesc[CR_FW_NOF_INSTREAM]
The descriptors of the InStream State Machines.
CrFwPckt_t CrFwInStreamGetPckt(FwSmDesc_t smDesc)
Retrieve a packet from the InStream.
static void DoActionA(FwSmDesc_t smDesc)
Function which performs Action A in the InStream State Machine.
static CrFwCounterU1_t inStreamPcktQueueSize[CR_FW_NOF_INSTREAM]
The sizes of the packet queues in the InStream components.
static CrFwPcktAvailCheck_t inStreamPcktAvailCheck[CR_FW_NOF_INSTREAM]
The functions implementing the packet available check operations for the InStream components.
CrFwBool_t CrFwInStreamIsInPcktAvail(FwSmDesc_t smDesc)
Return true if the argument InStream is in state PCKT_AVAIL.
void CrFwInStreamDefConfigAction(FwPrDesc_t prDesc)
Default configuration action for an InStream.
static CrFwSeqCnt_t inStreamSeqCounter[CR_FW_INSTREAM_NOF_GROUPS]
The sequence counters managed by the OutStreams.
void CrFwInStreamSetSeqCnt(CrFwGroup_t group, CrFwSeqCnt_t seqCnt)
Overwrites the sequence counter value of the last packet for a group.
CrFwDestSrc_t CrFwInStreamGetSrc(FwSmDesc_t smDesc, CrFwCounterU1_t i)
Get the i-th packet source of the argument InStream.
static int IsPcktQueueEmpty(FwSmDesc_t smDesc)
Function which checks if the packet queue is empty.
static CrFwDestSrc_t inStreamNofSrc[CR_FW_NOF_INSTREAM]
The number of sources associated to each inStream.
static FwSmAction_t inStreamShutdownAction[CR_FW_NOF_INSTREAM]
The functions implementing the shutdown actions for the InStream components.
FwSmDesc_t CrFwInStreamGet(CrFwDestSrc_t src)
Getter function for the InStream corresponding to the argument source.
static CrFwDestSrc_t * inStreamSrc[CR_FW_NOF_INSTREAM]
The sources associated to each inStream.
CrFwGroup_t CrFwInStreamGetNOfGroups()
Return the number of groups managed by the InStreams.
static FwPrAction_t inStreamInitAction[CR_FW_NOF_INSTREAM]
The functions implementing the initialization actions for the InStream components.
static void DoActionB(FwSmDesc_t smDesc)
Function which performs Action b in the InStream State Machine.
static FwPrAction_t inStreamInitCheck[CR_FW_NOF_INSTREAM]
The functions implementing the initialization checks for the InStream components.
static CrFwCmpData_t inStreamData[CR_FW_NOF_INSTREAM]
The data structures for the InStream State Machines and their Procedures.
void CrFwInStreamDefShutdownAction(FwSmDesc_t smDesc)
Default shutdown action for an InStream.
CrFwSeqCnt_t CrFwInStreamGetSeqCnt(CrFwGroup_t group)
Return the value of the sequence counter of the last packet successfully collected by the InStreams f...
void CrFwInStreamPcktAvail(FwSmDesc_t smDesc)
Query the middleware for available packets and collect them if they are available.
static FwPrAction_t inStreamConfigAction[CR_FW_NOF_INSTREAM]
The functions implementing the configuration actions for the InStream components.
FwSmDesc_t CrFwInStreamMake(CrFwInstanceId_t i)
Factory function to retrieve the i-th InStream State Machine instance.
Definition of the InStream component.
User-modifiable parameters for the InStream components (see CrFwInStream.h).
#define CR_FW_INSTREAM_PCKTAVAILCHECK
The functions implementing the Packet Available Check Operations of the InStream components.
#define CR_FW_INSTREAM_PQSIZE
The sizes of the packet queues in the InStream components.
#define CR_FW_INSTREAM_CONFIGCHECK
The functions implementing the Configuration Check of the InStream components.
#define CR_FW_NOF_INSTREAM
The number of InStream components in the application.
#define CR_FW_INSTREAM_SRC_PAIRS
The association of sources to InStreams.
#define CR_FW_INSTREAM_NOF_SRCS
The number of distinct sources from which the InStream components may receive packets.
#define CR_FW_INSTREAM_CONFIGACTION
The functions implementing the Configuration Action of the InStream components.
#define CR_FW_INSTREAM_SHUTDOWNACTION
The functions implementing the Shutdown Action of the InStream components.
#define CR_FW_INSTREAM_PCKTCOLLECT
The functions implementing the Packet Collect Operations of the InStream components.
#define CR_FW_INSTREAM_NOF_GROUPS
The number of groups managed by the InStream components.
#define CR_FW_INSTREAM_INITCHECK
The functions implementing the Initialization Check of the InStream components.
#define CR_FW_INSTREAM_INITACTION
The functions implementing the Initialization Action of the InStream components.
FwPrDesc_t CrFwCmpGetInitProc()
Retrieve the singleton instance of the CIP.
void CrFwBaseCmpDefInitCheck(FwPrDesc_t prDesc)
Function which performs the default Initialization Check of the CIP.
void CrFwBaseCmpDefInitAction(FwPrDesc_t prDesc)
Function which performs the default Initialization Action of the CIP.
Component Initialization Procedure (CIP) for the Base Component.
static CrFwSeqCnt_t seqCnt[CR_FW_OUTSTREAM_STUB_MEM_LEN]
Sequence counters of most recently received packets.
Interface for creating and accessing a report or command packet.
CrFwSeqCnt_t CrFwPcktGetSeqCnt(CrFwPckt_t pckt)
Return the sequence counter of the command or report encapsulated in a packet.
CrFwDestSrc_t CrFwPcktGetDest(CrFwPckt_t pckt)
Return the destination of the command or report encapsulated in a packet.
void CrFwPcktRelease(CrFwPckt_t pckt)
Release function for command or report packets.
CrFwGroup_t CrFwPcktGetGroup(CrFwPckt_t pckt)
Return the group of the command/report encapsulated in a packet.
CrFwBool_t CrFwPcktQueueIsEmpty(CrFwPcktQueue_t pcktQueue)
Return 1 if the packet queue is empty and 0 otherwise.
CrFwCounterU1_t CrFwPcktQueueGetSize(CrFwPcktQueue_t pcktQueue)
Return the size of the packet queue.
CrFwPckt_t CrFwPcktQueuePop(CrFwPcktQueue_t pcktQueue)
Pop a packet from the packet queue.
void CrFwPcktQueueReset(CrFwPcktQueue_t pcktQueue)
Reset the packet queue.
void CrFwPcktQueueInit(CrFwPcktQueue_t pcktQueue, CrFwCounterU1_t size)
Initializes the packet queue.
CrFwBool_t CrFwPcktQueuePush(CrFwPcktQueue_t pcktQueue, CrFwPckt_t pckt)
Push a packet onto the packet queue.
void CrFwPcktQueueShutdown(CrFwPcktQueue_t pcktQueue)
Shutdown the packet queue.
CrFwCounterU1_t CrFwPcktQueueGetNOfPckts(CrFwPcktQueue_t pcktQueue)
Return the number of packets currently in the packet queue.
Definition and management of packet queues.
Interface for reporting an error detected by a framework component.
void CrFwRepErrGroup(CrFwRepErrCode_t errCode, CrFwTypeId_t typeId, CrFwInstanceId_t instanceId, CrFwGroup_t group)
Report an error which has one single parameter attached to it representing a command or report group.
void CrFwRepErr(CrFwRepErrCode_t errCode, CrFwTypeId_t typeId, CrFwInstanceId_t instanceId)
Report an error which has no parameters attached to it.
void CrFwRepErrSeqCnt(CrFwRepErrCode_t errCode, CrFwTypeId_t typeId, CrFwInstanceId_t instanceId, CrFwSeqCnt_t expSeqCnt, CrFwSeqCnt_t actSeqCnt, CrFwPckt_t pckt)
Report an error which has two parameters attached to it representing expected and actual sequence cou...
FwPrDesc_t CrFwCmpGetResetProc()
Retrieve the singleton instance of the CRP.
void CrFwBaseCmpDefConfigAction(FwPrDesc_t prDesc)
Function which performs the default Configuration Action of the CRP.
void CrFwBaseCmpDefConfigCheck(FwPrDesc_t prDesc)
Function which performs the default Configuration Check of the CRP.
Component Reset Procedure (CRP) for the Base Component.
Interface through which framework components access the current time.
unsigned int CrFwSeqCnt_t
Type used for the sequence counter of commands or reports.
unsigned char CrFwDestSrc_t
Type used for the command or report destination and source.
unsigned char CrFwCounterU1_t
Type used for unsigned integers with a "short" range.
unsigned char CrFwGroup_t
Type used for the destination or source group of a packet.
@ crInStreamSCErr
An InStream has encountered a sequence counter error (see CrFwInStream.h)
@ crInStreamIllGroup
An incoming command or report has an illegal group.
@ crInStreamPQFull
The packet queue of an InStream is full (see CrFwInStream.h)
@ crInStreamUndefDest
A framework function has been called with a source attribute which is not associated to any InStream.
@ crInStreamIllId
A framework function has been called with an illegal InStream identifier.
#define CR_FW_HOST_APP_ID
The identifier of the host application (i.e.
unsigned short CrFwInstanceId_t
Type used for instance identifiers.
void CrFwSetAppErrCode(CrFwAppErrCode_t errCode)
Set the value of the application error code (see CrFwGetAppErrCode).
Definition of the utility functions for the CORDET Framework.
Type for the Framework Component Data (FCD).
FwPrDesc_t initProc
The Component Initialization Procedure (CIP) (see CrFwInitProc.h).
CrFwInstanceId_t instanceId
The instance identifier of the framework component.
CrFwOutcome_t outcome
The outcome of an action or check executed by a state machine or by one of its procedures.
FwPrDesc_t resetProc
The Component Reset Procedure (CRP) (see CrFwResetProc.h).
FwPrDesc_t execProc
The Component Execution Procedure (CEP) (see CrFwBaseCmp.h).
void * cmpSpecificData
Derived data which are specific to each type of framework component.
CrFwTypeId_t typeId
The type identifier of the framework component.
Type for the data describing an InStream.
CrFwPckt_t pckt
The last packet to have been collected from the middleware.
CrFwPcktCollect_t collectPckt
Function which implements the Packet Collect Operation.
CrFwPcktAvailCheck_t isPcktAvail
Function which implements the Packet Available Check Operation.
struct CrFwPcktQueue pcktQueue
Packet queue associated to the InStream.