37 #include "FwSmConstants.h" 38 #include "FwSmDCreate.h" 39 #include "FwSmConfig.h" 41 #include "FwPrConstants.h" 42 #include "FwPrDCreate.h" 43 #include "FwPrConfig.h" 132 const FwSmCounterS1_t nOfStates = 2;
133 const FwSmCounterS1_t nOfChoicePseudoStates = 1;
134 const FwSmCounterS1_t nOfTrans = 6;
135 const FwSmCounterS1_t nOfActions = 4;
136 const FwSmCounterS1_t nOfGuards = 1;
137 const FwSmCounterS1_t CPS_1 = 1;
139 FwPrDesc_t resetPr, execPr, initPr;
151 esm = FwSmCreate(nOfStates, nOfChoicePseudoStates, nOfTrans, nOfActions, nOfGuards);
154 FwSmAddChoicePseudoState(esm, CPS_1, 2);
206 FwPrSetData(outStreamData[i].initProc, &outStreamData[i]);
207 FwPrSetData(outStreamData[i].resetProc, &outStreamData[i]);
229 if (outStreamCmpSpecificData[i].dest == dest)
240 cmpSpecificData->
pckt = pckt;
253 return cmpSpecificData->
dest;
260 return cmpSpecificData->
seqCnt[group];
268 cmpSpecificData->
seqCnt[group] = seqCnt;
299 outStreamBaseData->
outcome = 1;
307 free(cmpSpecificData->
seqCnt);
308 cmpSpecificData->
seqCnt = NULL;
319 outStreamBaseData->
outcome = 1;
332 if (pcktCopy == NULL) {
336 memcpy(pcktCopy,pckt,len);
364 outStreamBaseData->
instanceId, oldestPcktGroup);
370 cmpSpecificData->
seqCnt[oldestPcktGroup]++;
383 cmpSpecificData->
seqCnt[i] = 1;
408 pcktQueue = &(cmpSpecificData->
pcktQueue);
411 if (pcktCopy == NULL) {
415 memcpy(pcktCopy,pckt,len);
void CrFwOutStreamDefConfigAction(FwPrDesc_t prDesc)
Default configuration action for an OutStream.
unsigned char CrFwCounterU1_t
Type used for unsigned integers with a "short" range.
#define CR_FW_OUTSTREAM_DEST
The destinations of the OutStream components.
Type for the Framework Component Data (FCD).
Interface through which framework components access the current time.
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...
static CrFwCounterU1_t outStreamPcktQueueSize[CR_FW_NOF_OUTSTREAM]
The sizes of the packet queues in the OutStream components.
void CrFwOutStreamSend(FwSmDesc_t smDesc, CrFwPckt_t pckt)
Send a packet to the OutStream.
void CrFwPcktQueueReset(CrFwPcktQueue_t pcktQueue)
Reset the packet queue.
unsigned short CrFwInstanceId_t
Type used for instance identifiers.
CrFwOutcome_t outcome
The outcome of an action or check executed by a state machine or by one of its procedures.
CrFwBool_t CrFwPcktQueueIsEmpty(CrFwPcktQueue_t pcktQueue)
Return 1 if the packet queue is empty and 0 otherwise.
Type for the data describing an OutStream.
CrFwPckt_t CrFwPcktQueuePop(CrFwPcktQueue_t pcktQueue)
Pop a packet from the packet queue.
FwPrDesc_t CrFwCmpGetResetProc()
Retrieve the singleton instance of the CRP.
static FwSmDesc_t baseOutStreamSmDesc
Base OutStream from which all other OutStreams are derived.
Definition of the Framework Component Data (FCD) Type.
CrFwCounterU1_t CrFwOutStreamGetNOfPendingPckts(FwSmDesc_t smDesc)
Return the number of packets currently in the packet queue of an OutStream.
CrFwGroup_t CrFwOutStreamGetNOfGroups(FwSmDesc_t smDesc)
Return the number of groups associated to the OutStream.
#define CR_FW_NOF_OUTSTREAM
The number of OutStream components in the application.
void CrFwSetAppErrCode(CrFwAppErrCode_t errCode)
Set the value of the application error code (see CrFwGetAppErrCode).
#define CR_FW_HOST_APP_ID
The identifier of the host application.
CrFwPckt_t pckt
The packet to be sent out.
unsigned char * CrFwPckt_t
Type for packets (see CrFwPckt.h).
static FwPrAction_t outStreamConfigAction[CR_FW_NOF_OUTSTREAM]
The functions implementing the configuration actions for the InStream components. ...
CrFwPckt_t CrFwPcktMake(CrFwPcktLength_t pcktLength)
Make function for command or report packets.
CrFwDestSrc_t CrFwPcktGetSrc(CrFwPckt_t pckt)
Return the source of the command or report encapsulated in a packet.
CrFwBool_t CrFwPcktQueuePush(CrFwPcktQueue_t pcktQueue, CrFwPckt_t pckt)
Push a packet onto the packet queue.
void CrFwBaseCmpDefConfigCheck(FwPrDesc_t prDesc)
Function which performs the default Configuration Check of the CRP.
#define CR_FW_OUTSTREAM_TR_CONNECTION_AVAILABLE
Identifier for transition command "Reset" in the OutStream State Machine.
CrFwSeqCnt_t * seqCnt
Array holding sequence counters for the groups associated to the OutStream.
#define CR_FW_OUTSTREAM_STATE_READY
State identifier for state READY in the OutStream State Machine.
Definition of the OutStream component.
void CrFwPcktQueueInit(CrFwPcktQueue_t pcktQueue, CrFwCounterU1_t size)
Initializes the packet queue.
static CrFwPcktHandover_t outStreamHandoverPckt[CR_FW_NOF_OUTSTREAM]
The functions implementing the packet hand-over operations for the OutStream components.
#define CR_FW_OUTSTREAM_TR_SEND
Identifier for transition command "Send" in the OutStream State Machine.
static FwSmDesc_t outStreamDesc[CR_FW_NOF_OUTSTREAM]
The descriptors of the OutStream State Machines.
Interface for creating and accessing a report or command packet.
void CrFwBaseCmpDefShutdownAction(FwSmDesc_t smDesc)
Function which performs the Shutdown Action for the Base State Machine.
int CrFwBool_t
Type used for boolean values (1 represent "true" and 0 represents "false").
FwPrDesc_t resetProc
The Component Reset Procedure (CRP) (see CrFwResetProc.h).
Dummy Component Execution Procedure (CEP) for the Base Component.
unsigned char CrFwGroup_t
Type used for the destination or source group of a packet.
Descriptor for a Packet Queue (PQ) in an OutStream or InStream.
static void ResetSeqCounter(FwSmDesc_t smDesc)
Function which resets to 1 the sequence counter of an out-going packet.
CrFwCrc_t CrFwPcktComputeCrc(CrFwPckt_t pckt)
Compute the CRC in the command or report encapsulated in a packet.
#define CR_FW_OUTSTREAM_INITCHECK
The functions implementing the Initialization Check of the OutStream components.
static void SendOrEnqueue(FwSmDesc_t smDesc)
Function which first attempts to hand over a packet to the middleware and, if this fails...
Header file to define all invariant publicly available constants and types for the CORDET Framework...
CrFwPcktHandover_t handoverPckt
Function which hands over a packet from the OutStream to the middleware.
void CrFwPcktRelease(CrFwPckt_t pckt)
Release function for command or report packets.
CrFwPckt_t CrFwPcktQueueGetOldest(CrFwPcktQueue_t pcktQueue)
Return the oldest packet from the queue without removing it from the queue.
void CrFwBaseCmpDefInitCheck(FwPrDesc_t prDesc)
Function which performs the default Initialization Check of the CIP.
A framework function has been called with an illegal OutStream identifier.
CrFwCounterU1_t CrFwPcktQueueGetSize(CrFwPcktQueue_t pcktQueue)
Return the size of the packet queue.
unsigned char CrFwDestSrc_t
Type used for the command or report destination and source.
static void EnqueuePckt(FwSmDesc_t smDesc)
Function which enqueues a packet on the packet queue.
CrFwInstanceId_t instanceId
The instance identifier of the framework component.
static FwSmAction_t outStreamShutdownAction[CR_FW_NOF_OUTSTREAM]
The functions implementing the shutdown actions for the InStream components.
An OutComponent has an illegal group.
void CrFwBaseCmpDefInitAction(FwPrDesc_t prDesc)
Function which performs the default Initialization Action of the CIP.
An OutStream cannot buffer an out-going packet because no more packets are available (see CrFwOutStre...
#define CR_FW_OUTSTREAM_CONFIGACTION
The functions implementing the Configuration Action of the OutStream components.
void CrFwOutStreamConnectionAvail(FwSmDesc_t smDesc)
Signal that the out-going middleware connection has become available.
Interface for reporting an error detected by a framework component.
#define CR_FW_OUTSTREAM_PQSIZE
The sizes of the packet queues in the OutStream component.
CrFwBool_t CrFwOutStreamIsInBuffering(FwSmDesc_t smDesc)
Return true if the argument OutStream is in state BUFFERING.
#define CR_FW_OUTSTREAM_PCKTHANDOVER
The functions implementing the packet hand-over operations of the OutStream components.
static int IsPacketQueueEmpty(FwSmDesc_t smDesc)
Function which checks if the packet queue is empty.
CrFwCounterU1_t CrFwOutStreamGetPcktQueueSize(FwSmDesc_t smDesc)
Return the size of the packet queue of the OutStream.
The packet queue of an OutStream is full (see CrFwOutStream.h)
CrFwSeqCnt_t CrFwOutStreamGetSeqCnt(FwSmDesc_t smDesc, CrFwGroup_t group)
Return the value of the sequence counter for one of the groups maintained by an OutStream.
CrFwCounterU1_t CrFwPcktQueueGetNOfPckts(CrFwPcktQueue_t pcktQueue)
Return the number of packets currently in the packet queue.
#define CR_FW_OUTSTREAM_INITACTION
The functions implementing the Initialization Action of the OutStream components. ...
Definition and management of packet queues.
void * cmpSpecificData
Derived data which are specific to each type of framework component.
void CrFwBaseCmpDefConfigAction(FwPrDesc_t prDesc)
Function which performs the default Configuration Action of the CRP.
static FwPrAction_t outStreamInitCheck[CR_FW_NOF_OUTSTREAM]
The functions implementing the initialization checks for the InStream components. ...
Definition of the utility functions for the CORDET Framework.
FwSmDesc_t CrFwOutStreamGet(CrFwDestSrc_t dest)
Getter function for the OutStream corresponding to the argument destination.
void CrFwOutStreamDefShutdownAction(FwSmDesc_t smDesc)
Default shutdown action for an OutStream.
FwPrDesc_t execProc
The Component Execution Procedure (CEP) (see CrFwBaseCmp.h).
FwSmDesc_t CrFwBaseCmpMake()
Retrieve the singleton instance of the Base State Machine.
void CrFwOutStreamDefInitAction(FwPrDesc_t prDesc)
Default initialization action for an OutStream.
A framework function has been called with a destination attribute which is not associated to any OutS...
void CrFwOutStreamSetSeqCnt(FwSmDesc_t smDesc, CrFwGroup_t group, CrFwSeqCnt_t seqCnt)
Sets the value of the sequence counter for one of the groups maintained by an OutStream.
FwPrDesc_t CrFwBaseCmpGetDummyExecProc()
Retrieve the singleton instance of the Dummy CEP.
static FwPrAction_t outStreamConfigCheck[CR_FW_NOF_OUTSTREAM]
The functions implementing the configuration checks for the InStream components.
static CrFwOutStreamData_t outStreamCmpSpecificData[CR_FW_NOF_OUTSTREAM]
The component-specific data for the OutStream State Machines and their Procedures.
#define CR_FW_OUTSTREAM_SHUTDOWNACTION
The functions implementing the Shutdown Action of the OutStream components.
Definition of Base Component.
static CrFwDestSrc_t dest
Destination.
unsigned short CrFwCrc_t
Type used for the CRC field in a packet.
CrFwPcktLength_t CrFwPcktGetLength(CrFwPckt_t pckt)
Return the length (in number of bytes) of a packet.
static CrFwCmpData_t outStreamData[CR_FW_NOF_OUTSTREAM]
The base data structures for the OutStream State Machines and their Procedures.
void CrFwRepErr(CrFwRepErrCode_t errCode, CrFwTypeId_t typeId, CrFwInstanceId_t instanceId)
Report an error which has no parameters attached to it.
void CrFwPcktSetCrc(CrFwPckt_t pckt, CrFwCrc_t crc)
Set the CRC in the command or report encapsulated in a packet.
Component Initialization Procedure (CIP) for the Base Component.
CrFwGroup_t CrFwPcktGetGroup(CrFwPckt_t pckt)
Return the group of the command/report encapsulated in a packet.
unsigned short int CrFwPcktLength_t
Type for the packet length.
CrFwDestSrc_t CrFwOutStreamGetDest(FwSmDesc_t smDesc)
Get the destination for an OutStream.
CrFwDestSrc_t dest
Destination associated to the OutStream.
FwSmDesc_t CrFwOutStreamMake(CrFwInstanceId_t i)
Factory function to retrieve the i-th OutStream State Machine instance.
static CrFwGroup_t outStreamNOfGroups[CR_FW_NOF_OUTSTREAM]
The number of groups associated to the OutStream components.
CrFwTypeId_t typeId
The type identifier of the framework component.
static CrFwGroup_t pcktGroup
group
#define CR_FW_OUTSTREAM_STATE_BUFFERING
State identifier for state INITIALIZED in the OutStream State Machine.
CrFwBool_t CrFwOutStreamIsInReady(FwSmDesc_t smDesc)
Return true if the argument OutStream is in state READY.
CrFwBool_t(* CrFwPcktHandover_t)(CrFwPckt_t pckt)
Type for a pointer to a function implementing the Packet Hand-Over Operation of an OutStream...
void CrFwPcktSetSeqCnt(CrFwPckt_t pckt, CrFwSeqCnt_t seqCnt)
Set the sequence counter of the command or report encapsulated in a packet.
static FwPrAction_t outStreamInitAction[CR_FW_NOF_OUTSTREAM]
The functions implementing the initialization actions for the InStream components.
#define CR_FW_BASE_STATE_CONFIGURED
State identifier for state CONFIGURED in the Base State Machine.
static CrFwDestSrc_t outStreamDest[CR_FW_NOF_OUTSTREAM]
The destinations associated to the OutStream components.
#define CR_FW_OUTSTREAM_TYPE
Type identifier for the OutStream components.
User-modifiable parameters for the OutStream components (see CrFwOutStream.h).
static void FlushPcktQueue(FwSmDesc_t smDesc)
Function which flushes the packet queue.
FwPrDesc_t CrFwCmpGetInitProc()
Retrieve the singleton instance of the CIP.
void CrFwPcktQueueShutdown(CrFwPcktQueue_t pcktQueue)
Shutdown the packet queue.
struct CrFwPcktQueue pcktQueue
Packet queue associated to the OutStream.
#define CR_FW_OUTSTREAM_NOF_GROUPS
The number of groups of the OutStream components.
unsigned int CrFwSeqCnt_t
Type used for the sequence counter of commands or reports.
Component Reset Procedure (CRP) for the Base Component.
FwPrDesc_t initProc
The Component Initialization Procedure (CIP) (see CrFwInitProc.h).
#define CR_FW_OUTSTREAM_CONFIGCHECK
The functions implementing the Configuration Check of the OutStream components.