CORDET Framework - C2 Implementation
CrFwOutStream.c
Go to the documentation of this file.
1 
19 #include <stdlib.h>
20 #include<string.h>
21 /* Include configuration files */
22 #include "CrFwOutStreamUserPar.h"
23 #include "CrFwOutFactoryUserPar.h"
24 #include "CrFwCmpData.h"
25 /* Include framework files */
26 #include "CrFwConstants.h"
27 #include "CrFwRepErr.h"
28 #include "CrFwTime.h"
29 #include "BaseCmp/CrFwBaseCmp.h"
30 #include "CrFwOutStream.h"
31 #include "BaseCmp/CrFwInitProc.h"
32 #include "BaseCmp/CrFwResetProc.h"
34 #include "Pckt/CrFwPckt.h"
35 #include "Pckt/CrFwPcktQueue.h"
37 /* Include FW Profile files */
38 #include "FwSmConstants.h"
39 #include "FwSmDCreate.h"
40 #include "FwSmConfig.h"
41 #include "FwSmCore.h"
42 #include "FwPrConstants.h"
43 #include "FwPrDCreate.h"
44 #include "FwPrConfig.h"
45 #include "FwPrCore.h"
46 
47 #include <assert.h>
48 
50 static FwSmDesc_t baseOutStreamSmDesc = NULL;
51 
54 
57 
60 
63 
66 
69 
78 
96 
99 
102 
105 
108 
111 
114 
117 
120 
123 
126 
138 static void EnqueuePckt(FwSmDesc_t smDesc);
139 
146 static void FlushPcktQueue(FwSmDesc_t smDesc);
147 
156 static void ResetSeqAndTypeCounters(FwSmDesc_t smDesc);
157 
164 static void SendOrEnqueue(FwSmDesc_t smDesc);
165 
172 static int IsPacketQueueEmpty(FwSmDesc_t smDesc);
173 
191 
192 /*-----------------------------------------------------------------------------------------*/
194  const FwSmCounterS1_t nOfStates = 2; /* Number of states */
195  const FwSmCounterS1_t nOfChoicePseudoStates = 1; /* Number of choice pseudo-states */
196  const FwSmCounterS1_t nOfTrans = 6; /* Number of transitions */
197  const FwSmCounterS1_t nOfActions = 4; /* Number of actions */
198  const FwSmCounterS1_t nOfGuards = 1; /* Number of guards */
199  const FwSmCounterS1_t CPS_1 = 1; /* Identifier of first choice pseudo-state */
200  FwSmDesc_t esm;
201  FwPrDesc_t resetPr, execPr, initPr;
202 
203  if (i >= CR_FW_NOF_OUTSTREAM) {
205  return NULL;
206  }
207 
208  /* If not yet done, create the DTS_SET and allocate type counter array */
209  if (outStreamNofTypeCounter == 0) {
212  }
213 
214  /* If not yet done, create the base OutStream SM */
215  if (baseOutStreamSmDesc == NULL) {
216  /* Extend the Base Component */
217  baseOutStreamSmDesc = FwSmCreateDer(CrFwBaseCmpMake());
218  /* Create the OutStream SM and then embed it in state CONFIGURED of the Base Component */
219  esm = FwSmCreate(nOfStates, nOfChoicePseudoStates, nOfTrans, nOfActions, nOfGuards);
220  FwSmAddState(esm, CR_FW_OUTSTREAM_STATE_READY, 1, NULL, NULL, NULL, NULL);
221  FwSmAddState(esm, CR_FW_OUTSTREAM_STATE_BUFFERING, 2, NULL, NULL, NULL, NULL);
222  FwSmAddChoicePseudoState(esm, CPS_1, 2);
223  FwSmAddTransIpsToSta(esm, CR_FW_OUTSTREAM_STATE_READY, &ResetSeqAndTypeCounters);
224  FwSmAddTransStaToCps(esm, CR_FW_OUTSTREAM_TR_SEND, CR_FW_OUTSTREAM_STATE_READY, CPS_1,
225  &SendOrEnqueue, NULL);
226  FwSmAddTransCpsToSta(esm, CPS_1, CR_FW_OUTSTREAM_STATE_READY, NULL, &IsPacketQueueEmpty);
227  FwSmAddTransCpsToSta(esm, CPS_1, CR_FW_OUTSTREAM_STATE_BUFFERING, NULL, NULL); /* Else Transition */
229  CPS_1, &FlushPcktQueue, NULL);
230  FwSmAddTransStaToSta(esm, CR_FW_OUTSTREAM_TR_SEND, CR_FW_OUTSTREAM_STATE_BUFFERING,
233  }
234 
235  if (outStreamDesc[i] != NULL) {
236  return outStreamDesc[i]; /* The requested SM has already been created */
237  }
238 
239  /* Create the requested SM as an extension of the base OutStream SM */
240  outStreamDesc[i] = FwSmCreateDer(baseOutStreamSmDesc);
241 
242  /* Create the Reset Procedure for the OutStream Component */
243  resetPr = FwPrCreateDer(CrFwCmpGetResetProc());
244  FwPrOverrideAction(resetPr, &CrFwBaseCmpDefConfigCheck, outStreamConfigCheck[i]);
245  FwPrOverrideAction(resetPr, &CrFwBaseCmpDefConfigAction, outStreamConfigAction[i]);
246 
247  /* Create the Initialization Procedure for the OutStream Component */
248  initPr = FwPrCreateDer(CrFwCmpGetInitProc());
249  FwPrOverrideAction(initPr, &CrFwBaseCmpDefInitCheck, outStreamInitCheck[i]);
250  FwPrOverrideAction(initPr, &CrFwBaseCmpDefInitAction, outStreamInitAction[i]);
251 
252  /* Override the Shutdown Action for the OutStream Component */
254 
255  /* Get the Dummy Execution Procedure for the OutStream Component */
256  execPr = CrFwBaseCmpGetDummyExecProc();
257 
258  /* Initialize the data for the requested SM */
259  outStreamData[i].outcome = 1;
260  outStreamData[i].initProc = initPr;
261  outStreamData[i].resetProc = resetPr;
262  outStreamData[i].execProc = execPr;
263  outStreamData[i].instanceId = i;
267 
268  /* Attach the data to the OutStream state machine and to its procedures.
269  * The data is attached to the outer SM and to the SM embedded in state CONFIGURED
270  * and to the Initialization and Reset Procedures. */
271  FwSmSetData(outStreamDesc[i], &outStreamData[i]);
272  FwSmSetData(FwSmGetEmbSm(outStreamDesc[i], CR_FW_BASE_STATE_CONFIGURED), &outStreamData[i]);
273  FwPrSetData(outStreamData[i].initProc, &outStreamData[i]);
274  FwPrSetData(outStreamData[i].resetProc, &outStreamData[i]);
275 
276  /* Start the OutStream */
277  FwSmStart(outStreamDesc[i]);
278 
279  return outStreamDesc[i];
280 }
281 
282 /*-----------------------------------------------------------------------------------------*/
283 CrFwBool_t CrFwOutStreamIsInReady(FwSmDesc_t smDesc) {
284  return (FwSmGetCurStateEmb(smDesc) == CR_FW_OUTSTREAM_STATE_READY);
285 }
286 
287 /*-----------------------------------------------------------------------------------------*/
289  return (FwSmGetCurStateEmb(smDesc) == CR_FW_OUTSTREAM_STATE_BUFFERING);
290 }
291 
292 /*-----------------------------------------------------------------------------------------*/
294  unsigned int i;
295  for (i=0; i<CR_FW_OUTSTREAM_NOF_DEST; i++)
296  if (outStreamDestPairs[i][0] == dest) {
297  assert(outStreamDestPairs[i][1] < CR_FW_NOF_OUTSTREAM);
298  return outStreamDesc[outStreamDestPairs[i][1]];
299  }
300 
302  return NULL;
303 }
304 
305 /*-----------------------------------------------------------------------------------------*/
307  CrFwCmpData_t* outStreamBaseData = (CrFwCmpData_t*)FwSmGetData(outStream);
308  CrFwInstanceId_t outStreamId = outStreamBaseData->instanceId;
309  assert(i <= outStreamNofDest[outStreamId]);
310  return outStreamDest[outStreamId][i-1];
311 }
312 
313 /*-----------------------------------------------------------------------------------------*/
315  CrFwCmpData_t* outStreamBaseData = (CrFwCmpData_t*)FwSmGetData(outStream);
316  CrFwInstanceId_t outStreamId = outStreamBaseData->instanceId;
317  return outStreamNofDest[outStreamId];
318 }
319 
320 /*-----------------------------------------------------------------------------------------*/
321 void CrFwOutStreamSend(FwSmDesc_t smDesc, CrFwPckt_t pckt) {
322  CrFwCmpData_t* outStreamBaseData = (CrFwCmpData_t*)FwSmGetData(smDesc);
323  CrFwOutStreamData_t* cmpSpecificData = (CrFwOutStreamData_t*)outStreamBaseData->cmpSpecificData;
324  cmpSpecificData->pckt = pckt;
325  FwSmMakeTrans(smDesc, CR_FW_OUTSTREAM_TR_SEND);
326 }
327 
328 /*-----------------------------------------------------------------------------------------*/
329 void CrFwOutStreamConnectionAvail(FwSmDesc_t smDesc) {
330  FwSmMakeTrans(smDesc, CR_FW_OUTSTREAM_TR_CONNECTION_AVAILABLE);
331 }
332 
333 /*-----------------------------------------------------------------------------------------*/
335  return outStreamSeqCounter[group];
336 }
337 
338 /*-----------------------------------------------------------------------------------------*/
340  outStreamSeqCounter[group] = seqCnt;
341 }
342 
343 /*-----------------------------------------------------------------------------------------*/
345  CrFwCmpData_t* outStreamBaseData = (CrFwCmpData_t*)FwSmGetData(smDesc);
346  CrFwOutStreamData_t* cmpSpecificData = (CrFwOutStreamData_t*)outStreamBaseData->cmpSpecificData;
347  return CrFwPcktQueueGetNOfPckts(&(cmpSpecificData->pcktQueue));
348 }
349 
350 /*-----------------------------------------------------------------------------------------*/
353 }
354 
355 /*-----------------------------------------------------------------------------------------*/
357  CrFwCmpData_t* outStreamBaseData = (CrFwCmpData_t*)FwSmGetData(smDesc);
358  CrFwOutStreamData_t* cmpSpecificData = (CrFwOutStreamData_t*)outStreamBaseData->cmpSpecificData;
359  return CrFwPcktQueueGetSize(&(cmpSpecificData->pcktQueue));
360 }
361 
362 /*-----------------------------------------------------------------------------------------*/
363 void CrFwOutStreamDefConfigAction(FwPrDesc_t prDesc) {
364  CrFwCmpData_t* outStreamBaseData = (CrFwCmpData_t*)FwPrGetData(prDesc);
365  CrFwOutStreamData_t* cmpSpecificData = (CrFwOutStreamData_t*)outStreamBaseData->cmpSpecificData;
366 
367  CrFwPcktQueueReset(&(cmpSpecificData->pcktQueue));
368  cmpSpecificData->handoverPckt = outStreamHandoverPckt[outStreamBaseData->instanceId];
369  outStreamBaseData->outcome = 1;
370 }
371 
372 /*-----------------------------------------------------------------------------------------*/
373 void CrFwOutStreamDefShutdownAction(FwSmDesc_t smDesc) {
374  CrFwCmpData_t* outStreamBaseData = (CrFwCmpData_t*)FwSmGetData(smDesc);
375  CrFwInstanceId_t outStreamId = outStreamBaseData->instanceId;
376  CrFwOutStreamData_t* cmpSpecificData = (CrFwOutStreamData_t*)outStreamBaseData->cmpSpecificData;
377  free(outStreamDest[outStreamId]);
378  outStreamDest[outStreamId] = NULL;
379  outStreamNofDest[outStreamId] = 0;
380  CrFwPcktQueueShutdown(&(cmpSpecificData->pcktQueue));
381 }
382 
383 /*-----------------------------------------------------------------------------------------*/
384 void CrFwOutStreamDefInitAction(FwPrDesc_t prDesc) {
385  CrFwCmpData_t* outStreamBaseData = (CrFwCmpData_t*)FwPrGetData(prDesc);
386  CrFwInstanceId_t outStreamId = outStreamBaseData->instanceId;
387  unsigned int i, j;
388 
389  if (outStreamNofDest[outStreamId] != 0) {
390  outStreamBaseData->outcome = 1;
391  return;
392  }
393 
394  outStreamNofDest[outStreamId] = 0;
395  for (i=0; i<CR_FW_OUTSTREAM_NOF_DEST; i++)
396  if (outStreamDestPairs[i][1] == outStreamId) {
397  outStreamNofDest[outStreamId]++;
398  }
399 
400  assert(outStreamNofDest[outStreamId] > 0);
401  outStreamDest[outStreamId] = malloc(sizeof(CrFwDestSrc_t) * outStreamNofDest[outStreamId]);
402 
403  j = 0;
404  for (i=0; i<CR_FW_OUTSTREAM_NOF_DEST; i++)
405  if (outStreamDestPairs[i][1] == outStreamId) {
406  outStreamDest[outStreamId][j] = outStreamDestPairs[i][0];
407  j++;
408  }
409  assert(j == outStreamNofDest[outStreamId]);
410 
411  CrFwPcktQueueInit(&(outStreamCmpSpecificData[outStreamId].pcktQueue),outStreamPcktQueueSize[outStreamId]);
412  outStreamBaseData->outcome = 1;
413 }
414 
415 /*-----------------------------------------------------------------------------------------*/
416 static void EnqueuePckt(FwSmDesc_t smDesc) {
417  CrFwCmpData_t* outStreamBaseData = (CrFwCmpData_t*)FwSmGetData(smDesc);
418  CrFwOutStreamData_t* cmpSpecificData = (CrFwOutStreamData_t*)outStreamBaseData->cmpSpecificData;
419  CrFwPckt_t pckt = cmpSpecificData->pckt;
420  CrFwPckt_t pcktCopy;
421  CrFwPcktQueue_t pcktQueue = &(cmpSpecificData->pcktQueue);
423 
424  pcktCopy = CrFwPcktMake(CrFwPcktGetLength(pckt));
425  if (pcktCopy == NULL) {
426  CrFwRepErr(crOutStreamNoMorePckt, outStreamBaseData->typeId, outStreamBaseData->instanceId);
427  return;
428  }
429  memcpy(pcktCopy,pckt,len);
430  if (!CrFwPcktQueuePush(pcktQueue, pcktCopy)) {
431  CrFwRepErr(crOutStreamPQFull, outStreamBaseData->typeId, outStreamBaseData->instanceId);
432  CrFwPcktRelease(pcktCopy);
433  }
434 
435  return;
436 }
437 
438 /*-----------------------------------------------------------------------------------------*/
439 static void FlushPcktQueue(FwSmDesc_t smDesc) {
440  CrFwCmpData_t* outStreamBaseData = (CrFwCmpData_t*)FwSmGetData(smDesc);
441  CrFwOutStreamData_t* cmpSpecificData = (CrFwOutStreamData_t*)outStreamBaseData->cmpSpecificData;
442  CrFwPckt_t oldestPckt;
443  CrFwPcktQueue_t pcktQueue = &(cmpSpecificData->pcktQueue);
444  CrFwGroup_t oldestPcktGroup = 0;
446  CrFwCounterU2_t destTypeKeyPos;
447  CrFwCrc_t crc;
448 
449  while (CrFwPcktQueueIsEmpty(pcktQueue)==0) {
450  oldestPckt = CrFwPcktQueueGetOldest(pcktQueue);
451  if (CrFwPcktGetSrc(oldestPckt) == CR_FW_HOST_APP_ID) { /* pckt originates from host application */
452  oldestPcktGroup = CrFwPcktGetGroup(oldestPckt);
453  if (oldestPcktGroup < CR_FW_OUTSTREAM_NOF_GROUPS) {
454  CrFwPcktSetSeqCnt(oldestPckt, outStreamSeqCounter[oldestPcktGroup]);
455  } else { /* pckt belongs to a non-existent group */
456  CrFwRepErrGroup(crOutStreamIllGroup, outStreamBaseData->typeId,
457  outStreamBaseData->instanceId, oldestPcktGroup);
458  CrFwPcktSetSeqCnt(oldestPckt, 0);
459  }
460 
461  /* If pckt has no type counter, destTypeKeyPos will be equal to outStreamNofTypeCounter
462  and its type counter will be set to the last element of array outStreamTypeCounter,
463  which is always equal to zero */
464  destTypeKeyPos = GetDestTypeKeyPos(oldestPckt);
465  assert(destTypeKeyPos <= outStreamNofTypeCounter);
466  typeCnt = outStreamTypeCounter[destTypeKeyPos];
467  CrFwPcktSetTypeCnt(oldestPckt, typeCnt);
468 
469  crc = CrFwPcktComputeCrc(oldestPckt);
470  CrFwPcktSetCrc(oldestPckt, crc);
471  }
472  if (cmpSpecificData->handoverPckt(oldestPckt) != 1)
473  return;
474  if (CrFwPcktGetSrc(oldestPckt) == CR_FW_HOST_APP_ID) {
475  if (oldestPcktGroup < CR_FW_OUTSTREAM_NOF_GROUPS)
476  outStreamSeqCounter[oldestPcktGroup]++;
477  if (destTypeKeyPos < outStreamNofTypeCounter)
478  outStreamTypeCounter[destTypeKeyPos]++;
479  }
480  CrFwPcktQueuePop(pcktQueue); /* remove packet from PQ */
481  CrFwPcktRelease(oldestPckt);
482  }
483  return;
484 }
485 
486 /*-----------------------------------------------------------------------------------------*/
487 static void ResetSeqAndTypeCounters(FwSmDesc_t smDesc) {
488  (void)smDesc;
489  CrFwGroup_t i;
490  CrFwTypeCnt_t j;
491  for (i=0; i<CR_FW_OUTSTREAM_NOF_GROUPS; i++)
492  outStreamSeqCounter[i] = 1;
493 
494  assert(outStreamNofTypeCounter>0);
495  for (j=0; j<outStreamNofTypeCounter; j++)
496  outStreamTypeCounter[j] = 1;
498 }
499 
500 /*-----------------------------------------------------------------------------------------*/
501 static void SendOrEnqueue(FwSmDesc_t smDesc) {
502  CrFwCmpData_t* outStreamBaseData = (CrFwCmpData_t*)FwSmGetData(smDesc);
503  CrFwOutStreamData_t* cmpSpecificData = (CrFwOutStreamData_t*)outStreamBaseData->cmpSpecificData;
504  CrFwPckt_t pckt = cmpSpecificData->pckt;
505  CrFwPckt_t pcktCopy;
506  CrFwPcktLength_t len;
507  CrFwDestSrc_t pcktSrc;
508  CrFwPcktQueue_t pcktQueue;
511  CrFwCounterU2_t destTypeKeyPos;
512  CrFwCrc_t crc;
513 
514  pcktSrc = CrFwPcktGetSrc(pckt);
515  if (pcktSrc == CR_FW_HOST_APP_ID) { /* pckt originates from host application */
516  pcktGroup = CrFwPcktGetGroup(pckt);
519  } else { /* pckt belongs to a non-existent group */
520  CrFwRepErrGroup(crOutStreamIllGroup, outStreamBaseData->typeId,
521  outStreamBaseData->instanceId, pcktGroup);
522  CrFwPcktSetSeqCnt(pckt, 0);
523  }
524 
525  /* If pckt has no type counter, destTypeKeyPos will be equal to outStreamNofTypeCounter
526  and its type counter will be set to the last element of array outStreamTypeCounter,
527  which is always equal to zero */
528  destTypeKeyPos = GetDestTypeKeyPos(pckt);
529  assert(destTypeKeyPos <= outStreamNofTypeCounter);
530  typeCnt = outStreamTypeCounter[destTypeKeyPos];
532 
533  crc = CrFwPcktComputeCrc(pckt);
534  CrFwPcktSetCrc(pckt, crc);
535  }
536  if (cmpSpecificData->handoverPckt(pckt) != 1) {
537  pcktQueue = &(cmpSpecificData->pcktQueue);
538  len = CrFwPcktGetLength(pckt);
539  pcktCopy = CrFwPcktMake(len);
540  if (pcktCopy == NULL) {
541  CrFwRepErr(crOutStreamNoMorePckt, outStreamBaseData->typeId, outStreamBaseData->instanceId);
542  return;
543  }
544  memcpy(pcktCopy,pckt,len);
545  CrFwPcktQueuePush(pcktQueue,pcktCopy); /* Enqueue packet, queue is empty at entry in READY */
546  } else {
547  if (pcktSrc == CR_FW_HOST_APP_ID) {
550  if (destTypeKeyPos < outStreamNofTypeCounter)
551  outStreamTypeCounter[destTypeKeyPos]++;
552  }
553  }
554 }
555 
556 /*-----------------------------------------------------------------------------------------*/
558  CrFwDestTypeKey_t key;
560  CrFwServType_t type;
561  CrFwServSubType_t subType;
562 
563  dest = CrFwPcktGetDest(pckt);
564  type = CrFwPcktGetServType(pckt);
565  subType = CrFwPcktGetServSubType(pckt);
566  key = type * CR_FW_MAX_SERV_SUBTYPE * CR_FW_MAX_DEST + subType * CR_FW_MAX_DEST + dest;
567 
569 }
570 
571 /*-----------------------------------------------------------------------------------------*/
572 static int IsPacketQueueEmpty(FwSmDesc_t smDesc) {
573  CrFwCmpData_t* outStreamBaseData = (CrFwCmpData_t*)FwSmGetData(smDesc);
574  CrFwOutStreamData_t* cmpSpecificData = (CrFwOutStreamData_t*)outStreamBaseData->cmpSpecificData;
575  return CrFwPcktQueueIsEmpty(&(cmpSpecificData->pcktQueue));
576 }
577 
578 /*-----------------------------------------------------------------------------------------*/
580  CrFwDestTypeKey_t** pDestTypeKey) {
582  CrFwDestSrc_t dest = 1;
583  CrFwServType_t prevServType = 0;
585  CrFwServSubType_t prevServSubType = 0;
587  unsigned int i, j;
588 
589  for (i=0; i<CR_FW_OUTCMP_NKINDS; i++) {
592  if ((servType != prevServType) || (servSubType != prevServSubType))
593  (*pNofTypeCounter)++;
594  prevServType = servType;
595  prevServSubType = servSubType;
596  }
597 
598  (*pDestTypeKey) = malloc(sizeof(CrFwTypeCnt_t) * (*pNofTypeCounter));
599 
600  j = 0;
601  for (i=0; i<CR_FW_OUTCMP_NKINDS; i++) {
604  if ((servType != prevServType) || (servSubType != prevServSubType)) {
605  assert(j<(*pNofTypeCounter));
606  (*pDestTypeKey)[j] = servType * CR_FW_MAX_SERV_SUBTYPE * CR_FW_MAX_DEST + \
607  servSubType * CR_FW_MAX_DEST + dest;
608  j = j + 1;
609  }
610  prevServType = servType;
611  prevServSubType = servSubType;
612  }
613 
614  return;
615 }
616 
617 /*-----------------------------------------------------------------------------------------*/
620 }
621 
622 /*-----------------------------------------------------------------------------------------*/
626  CrFwDestTypeKey_t key;
627  CrFwCounterU2_t pos;
630  return outStreamTypeCounter[pos];
631 }
632 
633 /*-----------------------------------------------------------------------------------------*/
637 
638  CrFwDestTypeKey_t key;
639  CrFwCounterU2_t pos;
642  if (pos == outStreamNofTypeCounter)
643  return 0;
644  else
645  return 1;
646 }
void CrFwBaseCmpDefShutdownAction(FwSmDesc_t smDesc)
Function which performs the Shutdown Action for the Base State Machine.
Definition: CrFwBaseCmp.c:217
FwSmDesc_t CrFwBaseCmpMake()
Retrieve the singleton instance of the Base State Machine.
Definition: CrFwBaseCmp.c:77
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).
Definition: CrFwConstants.h:38
int CrFwBool_t
Type used for boolean values (1 represent "true" and 0 represents "false").
Definition: CrFwConstants.h:32
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.
Definition: CrFwInitProc.c:48
void CrFwBaseCmpDefInitCheck(FwPrDesc_t prDesc)
Function which performs the default Initialization Check of the CIP.
Definition: CrFwInitProc.c:36
void CrFwBaseCmpDefInitAction(FwPrDesc_t prDesc)
Function which performs the default Initialization Action of the CIP.
Definition: CrFwInitProc.c:42
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.
Definition: CrFwOutStream.c:77
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.
Definition: CrFwOutStream.c:95
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.
Definition: CrFwOutStream.c:53
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.
Definition: CrFwOutStream.c:62
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.
Definition: CrFwOutStream.c:50
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.
Definition: CrFwOutStream.c:56
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.
Definition: CrFwOutStream.c:65
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.
Definition: CrFwOutStream.c:59
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.
Definition: CrFwOutStream.c:98
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.
Definition: CrFwOutStream.c:68
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.
Definition: CrFwPckt.c:247
CrFwCrc_t CrFwPcktComputeCrc(CrFwPckt_t pckt)
Compute the CRC in the command or report encapsulated in a packet.
Definition: CrFwPckt.c:277
CrFwDestSrc_t CrFwPcktGetSrc(CrFwPckt_t pckt)
Return the source of the command or report encapsulated in a packet.
Definition: CrFwPckt.c:357
CrFwServSubType_t CrFwPcktGetServSubType(CrFwPckt_t pckt)
Return the service sub-type of the command or report encapsulated in a packet.
Definition: CrFwPckt.c:333
CrFwDestSrc_t CrFwPcktGetDest(CrFwPckt_t pckt)
Return the destination of the command or report encapsulated in a packet.
Definition: CrFwPckt.c:345
void CrFwPcktSetCrc(CrFwPckt_t pckt, CrFwCrc_t crc)
Set the CRC in the command or report encapsulated in a packet.
Definition: CrFwPckt.c:283
void CrFwPcktRelease(CrFwPckt_t pckt)
Release function for command or report packets.
Definition: CrFwPckt.c:174
CrFwGroup_t CrFwPcktGetGroup(CrFwPckt_t pckt)
Return the group of the command/report encapsulated in a packet.
Definition: CrFwPckt.c:428
CrFwPcktLength_t CrFwPcktGetLength(CrFwPckt_t pckt)
Return the length (in number of bytes) of a packet.
Definition: CrFwPckt.c:224
CrFwServType_t CrFwPcktGetServType(CrFwPckt_t pckt)
Return the service type of the command or report encapsulated in a packet.
Definition: CrFwPckt.c:321
void CrFwPcktSetTypeCnt(CrFwPckt_t pckt, CrFwTypeCnt_t typeCnt)
Set the type counter of the command or report encapsulated in a packet.
Definition: CrFwPckt.c:259
CrFwPckt_t CrFwPcktMake(CrFwPcktLength_t pcktLength)
Make function for command or report packets.
Definition: CrFwPckt.c:147
CrFwPckt_t CrFwPcktQueueGetOldest(CrFwPcktQueue_t pcktQueue)
Return the oldest packet from the queue without removing it from the queue.
Definition: CrFwPcktQueue.c:44
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.
Definition: CrFwPcktQueue.c:25
void CrFwPcktQueueReset(CrFwPcktQueue_t pcktQueue)
Reset the packet queue.
Definition: CrFwPcktQueue.c:73
void CrFwPcktQueueInit(CrFwPcktQueue_t pcktQueue, CrFwCounterU1_t size)
Initializes the packet queue.
Definition: CrFwPcktQueue.c:95
CrFwBool_t CrFwPcktQueuePush(CrFwPcktQueue_t pcktQueue, CrFwPckt_t pckt)
Push a packet onto the packet queue.
Definition: CrFwPcktQueue.c:52
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.
Definition: CrFwRepErr.c:136
void CrFwRepErr(CrFwRepErrCode_t errCode, CrFwTypeId_t typeId, CrFwInstanceId_t instanceId)
Report an error which has no parameters attached to it.
Definition: CrFwRepErr.c:89
FwPrDesc_t CrFwCmpGetResetProc()
Retrieve the singleton instance of the CRP.
Definition: CrFwResetProc.c:45
void CrFwBaseCmpDefConfigAction(FwPrDesc_t prDesc)
Function which performs the default Configuration Action of the CRP.
Definition: CrFwResetProc.c:39
void CrFwBaseCmpDefConfigCheck(FwPrDesc_t prDesc)
Function which performs the default Configuration Check of the CRP.
Definition: CrFwResetProc.c:33
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).
Definition: CrFwCmpData.h:79
FwPrDesc_t initProc
The Component Initialization Procedure (CIP) (see CrFwInitProc.h).
Definition: CrFwCmpData.h:95
CrFwInstanceId_t instanceId
The instance identifier of the framework component.
Definition: CrFwCmpData.h:81
CrFwOutcome_t outcome
The outcome of an action or check executed by a state machine or by one of its procedures.
Definition: CrFwCmpData.h:93
FwPrDesc_t resetProc
The Component Reset Procedure (CRP) (see CrFwResetProc.h).
Definition: CrFwCmpData.h:97
FwPrDesc_t execProc
The Component Execution Procedure (CEP) (see CrFwBaseCmp.h).
Definition: CrFwCmpData.h:99
void * cmpSpecificData
Derived data which are specific to each type of framework component.
Definition: CrFwCmpData.h:101
CrFwTypeId_t typeId
The type identifier of the framework component.
Definition: CrFwCmpData.h:83
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.
P&P Software GmbH, Copyright 2012-2013, All Rights Reserved