38 #include "FwSmConstants.h"
39 #include "FwSmDCreate.h"
40 #include "FwSmConfig.h"
42 #include "FwPrConstants.h"
43 #include "FwPrDCreate.h"
44 #include "FwPrConfig.h"
194 const FwSmCounterS1_t nOfStates = 2;
195 const FwSmCounterS1_t nOfChoicePseudoStates = 1;
196 const FwSmCounterS1_t nOfTrans = 6;
197 const FwSmCounterS1_t nOfActions = 4;
198 const FwSmCounterS1_t nOfGuards = 1;
199 const FwSmCounterS1_t CPS_1 = 1;
201 FwPrDesc_t resetPr, execPr, initPr;
219 esm = FwSmCreate(nOfStates, nOfChoicePseudoStates, nOfTrans, nOfActions, nOfGuards);
222 FwSmAddChoicePseudoState(esm, CPS_1, 2);
324 cmpSpecificData->
pckt = pckt;
369 outStreamBaseData->
outcome = 1;
390 outStreamBaseData->
outcome = 1;
412 outStreamBaseData->
outcome = 1;
425 if (pcktCopy == NULL) {
429 memcpy(pcktCopy,pckt,len);
457 outStreamBaseData->
instanceId, oldestPcktGroup);
537 pcktQueue = &(cmpSpecificData->
pcktQueue);
540 if (pcktCopy == NULL) {
544 memcpy(pcktCopy,pckt,len);
593 (*pNofTypeCounter)++;
598 (*pDestTypeKey) = malloc(
sizeof(
CrFwTypeCnt_t) * (*pNofTypeCounter));
605 assert(j<(*pNofTypeCounter));
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_OUTSTREAM_TYPE
Type identifier for the OutStream components.
#define CR_FW_OUTSTREAM_TR_SEND
Identifier for transition command "Send" in the OutStream State Machine.
void(* CrFwSetDst_t)(CrFwCounterU2_t *nofTypeCounter, CrFwDestTypeKey_t **destTypeKey)
Type for a pointer to a function implement the Set DTS operation of an OutStream.
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(* CrFwPcktHandover_t)(CrFwPckt_t pckt)
Type for a pointer to a function implementing the Packet Hand-Over Operation of an OutStream.
#define CR_FW_BASE_STATE_CONFIGURED
State identifier for state CONFIGURED in the Base State Machine.
#define CR_FW_OUTSTREAM_STATE_READY
State identifier for state READY in the OutStream State Machine.
#define CR_FW_OUTSTREAM_TR_CONNECTION_AVAILABLE
Identifier for transition command "Reset" in the OutStream State Machine.
#define CR_FW_OUTSTREAM_STATE_BUFFERING
State identifier for state INITIALIZED in the OutStream State Machine.
FwPrDesc_t CrFwBaseCmpGetDummyExecProc()
Retrieve the singleton instance of the Dummy CEP.
Dummy Component Execution Procedure (CEP) for the Base Component.
static CrFwServType_t servType
The InCommand type as computed in the Validity Check.
static CrFwDestSrc_t dest
Destination.
static CrFwGroup_t pcktGroup
group
static CrFwServSubType_t servSubType
Service sub-type.
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 CrFwOutCmpKindDesc_t outCmpKindDesc[CR_FW_OUTCMP_NKINDS]
Array of service descriptors.
User-modifiable parameters for the OutFactory component (see CrFwOutFactory.h).
#define CR_FW_OUTCMP_INIT_KIND_DESC
Definition of the OutComponent kinds supported by an application.
#define CR_FW_OUTCMP_NKINDS
The total number of kinds of OutComponents supported by the application.
static FwSmAction_t outStreamShutdownAction[CR_FW_NOF_OUTSTREAM]
The functions implementing the shutdown actions for the InStream components.
FwSmDesc_t CrFwOutStreamGet(CrFwDestSrc_t dest)
Getter function for the OutStream corresponding to the argument destination.
static void SendOrEnqueue(FwSmDesc_t smDesc)
Function which first attempts to hand over a packet to the middleware and, if this fails,...
static CrFwTypeCnt_t * outStreamTypeCounter
The type counters managed by the OutStreams.
void CrFwOutStreamDefSetDTS(CrFwCounterU2_t *pNofTypeCounter, CrFwDestTypeKey_t **pDestTypeKey)
Default implementation of Set DST Function for the OutStreams.
void CrFwOutStreamDefConfigAction(FwPrDesc_t prDesc)
Default configuration action for an OutStream.
static void ResetSeqAndTypeCounters(FwSmDesc_t smDesc)
Function which resets to 1 all sequence and type counters of the OutStreams.
void CrFwOutStreamDefInitAction(FwPrDesc_t prDesc)
Default initialization action for an OutStream.
CrFwCounterU2_t CrFwOutStreamGetNOfTypeCounters()
Return the number of type counters maintained by the OutStreams.
static CrFwDestTypeKey_t * outStreamDestTypeKey
Array of destination-type keys.
CrFwGroup_t CrFwOutStreamGetNOfGroups()
Return the number of groups associated to the OutStreams.
CrFwTypeCnt_t CrFwOutStreamGetTypeCounter(CrFwDestSrc_t dest, CrFwServType_t servType, CrFwServSubType_t servSubType)
Return the current type counter for a (destination, type, sub-type) triplet or zero if the triplet is...
void CrFwOutStreamDefShutdownAction(FwSmDesc_t smDesc)
Default shutdown action for an OutStream.
static CrFwCounterU1_t outStreamPcktQueueSize[CR_FW_NOF_OUTSTREAM]
The sizes of the packet queues in the OutStream components.
static FwPrAction_t outStreamConfigCheck[CR_FW_NOF_OUTSTREAM]
The functions implementing the configuration checks for the InStream components.
CrFwCounterU1_t CrFwOutStreamGetNOfPendingPckts(FwSmDesc_t smDesc)
Return the number of packets currently in the packet queue of an OutStream.
static CrFwCmpData_t outStreamData[CR_FW_NOF_OUTSTREAM]
The base data structures for the OutStream State Machines and their Procedures.
static CrFwDestSrc_t outStreamNofDest[CR_FW_NOF_OUTSTREAM]
The number of destinations associated to each outStream.
static void EnqueuePckt(FwSmDesc_t smDesc)
Function which enqueues a packet on the packet queue.
static CrFwPcktHandover_t outStreamHandoverPckt[CR_FW_NOF_OUTSTREAM]
The functions implementing the packet hand-over operations for the OutStream components.
CrFwSeqCnt_t CrFwOutStreamGetSeqCnt(CrFwGroup_t group)
Return the value of the sequence counter for one of the groups maintained by the OutStreams.
static FwSmDesc_t baseOutStreamSmDesc
Base OutStream from which all other OutStreams are derived.
static FwSmDesc_t outStreamDesc[CR_FW_NOF_OUTSTREAM]
The descriptors of the OutStream State Machines.
static CrFwDestSrc_t outStreamDestPairs[CR_FW_OUTSTREAM_NOF_DEST][2]
The (destination, outStream) pairs.
CrFwBool_t CrFwOutStreamIsInReady(FwSmDesc_t smDesc)
Return true if the argument OutStream is in state READY.
static CrFwSeqCnt_t outStreamSeqCounter[CR_FW_OUTSTREAM_NOF_GROUPS]
The sequence counters managed by the OutStreams.
void CrFwOutStreamSetSeqCnt(CrFwGroup_t group, CrFwSeqCnt_t seqCnt)
Sets the value of the sequence counter for one of the groups maintained by the OutStreams.
static CrFwOutStreamData_t outStreamCmpSpecificData[CR_FW_NOF_OUTSTREAM]
The component-specific data for the OutStream State Machines and their Procedures.
static FwPrAction_t outStreamInitCheck[CR_FW_NOF_OUTSTREAM]
The functions implementing the initialization checks for the InStream components.
static void FlushPcktQueue(FwSmDesc_t smDesc)
Function which flushes the packet queue.
CrFwDestSrc_t CrFwOutStreamGetDest(FwSmDesc_t outStream, CrFwCounterU1_t i)
Return the i-th destination associated to the argument outStream.
CrFwCounterU1_t CrFwOutStreamGetNOfDest(FwSmDesc_t outStream)
Return the number of destinations associated to the argument outStream.
static CrFwTypeCnt_t GetDestTypeKeyPos(CrFwPckt_t pckt)
Compute the destination-type key of the argument packet and returns its position (starting from zero)...
static FwPrAction_t outStreamConfigAction[CR_FW_NOF_OUTSTREAM]
The functions implementing the configuration actions for the InStream components.
static CrFwDestSrc_t * outStreamDest[CR_FW_NOF_OUTSTREAM]
The destinations associated to each outStream.
FwSmDesc_t CrFwOutStreamMake(CrFwInstanceId_t i)
Factory function to retrieve the i-th OutStream State Machine instance.
CrFwCounterU1_t CrFwOutStreamGetPcktQueueSize(FwSmDesc_t smDesc)
Return the size of the packet queue of the OutStream.
void CrFwOutStreamConnectionAvail(FwSmDesc_t smDesc)
Signal that the out-going middleware connection has become available.
static CrFwSetDst_t outStreamSetDts
The function implementing the Set DTS Operation.
CrFwBool_t CrFwOutStreamIsInBuffering(FwSmDesc_t smDesc)
Return true if the argument OutStream is in state BUFFERING.
static int IsPacketQueueEmpty(FwSmDesc_t smDesc)
Function which checks if the packet queue is empty.
static CrFwCounterU2_t outStreamNofTypeCounter
The number of type counters maintained by the OutStreams.
static FwPrAction_t outStreamInitAction[CR_FW_NOF_OUTSTREAM]
The functions implementing the initialization actions for the InStream components.
void CrFwOutStreamSend(FwSmDesc_t smDesc, CrFwPckt_t pckt)
Send a packet to the OutStream.
CrFwBool_t CrFwOutStreamIsInDtsSet(CrFwDestSrc_t dest, CrFwServType_t servType, CrFwServSubType_t servSubType)
Check whether the (destination, type, sub-type) triplet is in DTS_SET.
Definition of the OutStream component.
static CrFwTypeCnt_t typeCnt[CR_FW_OUTSTREAM_STUB_MEM_LEN]
Type counters of most recently received packets.
static CrFwSeqCnt_t seqCnt[CR_FW_OUTSTREAM_STUB_MEM_LEN]
Sequence counters of most recently received packets.
User-modifiable parameters for the OutStream components (see CrFwOutStream.h).
#define CR_FW_NOF_OUTSTREAM
The number of OutStream components in the application.
#define CR_FW_OUTSTREAM_INITACTION
The functions implementing the Initialization Action of the OutStream components.
#define CR_FW_OUTSTREAM_INITCHECK
The functions implementing the Initialization Check of the OutStream components.
#define CR_FW_OUTSTREAM_CONFIGCHECK
The functions implementing the Configuration Check of the OutStream components.
#define CR_FW_OUTSTREAM_SET_DTS
Pointer to Set DTS function which populates the DTS_SET for the OutStreams.
#define CR_FW_OUTSTREAM_CONFIGACTION
The functions implementing the Configuration Action of the OutStream components.
#define CR_FW_OUTSTREAM_SHUTDOWNACTION
The functions implementing the Shutdown Action of the OutStream components.
#define CR_FW_OUTSTREAM_PQSIZE
The sizes of the packet queues in the OutStream component.
#define CR_FW_OUTSTREAM_PCKTHANDOVER
The functions implementing the packet hand-over operations of the OutStream components.
#define CR_FW_OUTSTREAM_NOF_DEST
Number of destinations for out-going packets.
#define CR_FW_OUTSTREAM_DEST_PAIRS
The association of destinations to OutStreams.
#define CR_FW_OUTSTREAM_NOF_GROUPS
The number of groups managed by the OutStream components.
Interface for creating and accessing a report or command packet.
void CrFwPcktSetSeqCnt(CrFwPckt_t pckt, CrFwSeqCnt_t seqCnt)
Set the sequence counter of the command or report encapsulated in a packet.
CrFwCrc_t CrFwPcktComputeCrc(CrFwPckt_t pckt)
Compute the CRC in the command or report encapsulated in a packet.
CrFwDestSrc_t CrFwPcktGetSrc(CrFwPckt_t pckt)
Return the source of the command or report encapsulated in a packet.
CrFwServSubType_t CrFwPcktGetServSubType(CrFwPckt_t pckt)
Return the service sub-type 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 CrFwPcktSetCrc(CrFwPckt_t pckt, CrFwCrc_t crc)
Set the CRC in 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.
CrFwPcktLength_t CrFwPcktGetLength(CrFwPckt_t pckt)
Return the length (in number of bytes) of a packet.
CrFwServType_t CrFwPcktGetServType(CrFwPckt_t pckt)
Return the service type of the command or report encapsulated in a packet.
void CrFwPcktSetTypeCnt(CrFwPckt_t pckt, CrFwTypeCnt_t typeCnt)
Set the type counter of the command or report encapsulated in a packet.
CrFwPckt_t CrFwPcktMake(CrFwPcktLength_t pcktLength)
Make 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.
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.
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.
#define CR_FW_MAX_DEST
Maximum value of the identifiers of destination applications.
#define CR_FW_MAX_SERV_SUBTYPE
Maximum value of the service sub-type attribute of InReports and InCommands.
unsigned int CrFwSeqCnt_t
Type used for the sequence counter of commands or reports.
unsigned char CrFwServType_t
Type used for the service type of a command or report.
unsigned char CrFwDestSrc_t
Type used for the command or report destination and source.
unsigned short CrFwCounterU2_t
Type used for unsigned integers with a "medium" range.
unsigned char CrFwCounterU1_t
Type used for unsigned integers with a "short" range.
unsigned short int CrFwPcktLength_t
Type for the packet length.
unsigned int CrFwTypeCnt_t
Type used for the type counter of commands or reports.
unsigned char CrFwGroup_t
Type used for the destination or source group of a packet.
@ crOutStreamNoMorePckt
An OutStream cannot buffer an out-going packet because no more packets are available (see CrFwOutStre...
@ crOutStreamIllGroup
An OutComponent has an illegal group.
@ crOutStreamPQFull
The packet queue of an OutStream is full (see CrFwOutStream.h)
unsigned short CrFwCrc_t
Type used for the CRC field in a packet.
unsigned int CrFwDestTypeKey_t
Type for the destination type key in CrFwOutStream.c.
@ crOutStreamUndefDest
A framework function has been called with a destination attribute which is not associated to any OutS...
@ crOutStreamIllId
A framework function has been called with an illegal OutStream identifier.
#define CR_FW_HOST_APP_ID
The identifier of the host application (i.e.
unsigned short CrFwInstanceId_t
Type used for instance identifiers.
unsigned char CrFwServSubType_t
Type used for the command or report sub-type.
void CrFwSetAppErrCode(CrFwAppErrCode_t errCode)
Set the value of the application error code (see CrFwGetAppErrCode).
CrFwCounterU2_t CrFwFindKeyIndex(CrFwCounterU3_t *keyValArray, CrFwCounterU2_t length, CrFwCounterU3_t targetKey)
Convenience function to retrieve the index of an array where a certain target value is located.
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.
OutComponent kind descriptor type.
CrFwServType_t servType
The service type.
CrFwServSubType_t servSubType
The service sub-type.
Descriptor for a Packet Queue (PQ) in an OutStream or InStream.
Type for the data describing an OutStream.
CrFwPckt_t pckt
The packet to be sent out.
CrFwPcktHandover_t handoverPckt
Function which hands over a packet from the OutStream to the middleware.
struct CrFwPcktQueue pcktQueue
Packet queue associated to the OutStream.