CORDET Framework - C2 Implementation
CrFwInManagerTestCases.c
Go to the documentation of this file.
1 
19 #include <stdio.h>
20 #include <stdlib.h>
21 #include "CrFwInManagerTestCases.h"
22 #include "CrFwInCmdSample1.h"
23 #include "CrFwInRepSample1.h"
24 /* Include FW Profile files */
25 #include "FwSmConstants.h"
26 #include "FwSmConfig.h"
27 #include "FwSmCore.h"
28 #include "FwPrConfig.h"
29 #include "FwPrCore.h"
30 #include "FwPrConstants.h"
31 /* Include framework files */
33 #include "BaseCmp/CrFwBaseCmp.h"
34 #include "Pckt/CrFwPckt.h"
35 #include "InRep/CrFwInRep.h"
36 #include "InCmd/CrFwInCmd.h"
38 #include "CrFwTime.h"
39 #include "CrFwRepErr.h"
41 /* Include configuration files */
42 #include "CrFwInRegistryUserPar.h"
43 #include "CrFwInManagerUserPar.h"
44 #include "CrFwRepErrStub.h"
45 #include "CrFwOutFactoryUserPar.h"
46 #include "CrFwCmpData.h"
47 
48 /* ---------------------------------------------------------------------------------------------*/
50  FwSmDesc_t inManager1, inManagerIll;
51 
52  /* Instantiate the first InManager */
53  inManager1 = CrFwInManagerMake(0);
54 
55  /* Check current state of InManager */
56  if (!CrFwCmpIsInCreated(inManager1))
57  return 0;
58 
59  /* Initialize and Configure InManager and check success */
60  CrFwCmpInit(inManager1);
61  if (!CrFwCmpIsInInitialized(inManager1))
62  return 0;
63  CrFwCmpReset(inManager1);
64  if (!CrFwCmpIsInConfigured(inManager1))
65  return 0;
66 
67  /* Check Instance and Type Identifiers */
68  if (CrFwCmpGetInstanceId(inManager1) != 0)
69  return 0;
70  if (CrFwCmpGetTypeId(inManager1) != CR_FW_INMANAGER_TYPE)
71  return 0;
72 
73  /* Check PCRL */
74  if (CrFwInManagerGetPCRLSize(inManager1) != 3)
75  return 0;
76  if (CrFwInManagerGetNOfPendingInCmp(inManager1) != 0)
77  return 0;
78 
79  /* Check number of loaded InReports/InCommands */
80  if (CrFwInManagerGetNOfLoadedInCmp(inManager1) != 0)
81  return 0;
82 
83  /* Attempt to instantiate an InManager with an illegal identifier */
85  return 0;
86  inManagerIll = CrFwInManagerMake(CR_FW_NOF_INMANAGER);
87  if (inManagerIll != NULL)
88  return 0;
90  return 0;
91  CrFwSetAppErrCode(crNoAppErr); /* reset application error code */
92 
93  /* Check that there are no allocated packets */
94  if (CrFwPcktGetNOfAllocated() != 0)
95  return 0;
96 
97  /* Check application errors */
99  return 0;
100 
101  return 1;
102 }
103 
104 /* ---------------------------------------------------------------------------------------------*/
106  FwSmDesc_t inManager2, inFactory;
107  FwSmDesc_t inRep1, inCmd1;
108  CrFwPckt_t pckt1, pckt2;
109  CrFwCounterU2_t i;
110  CrFwCounterU2_t errRepPosLocal;
111  CrFwBool_t loadOutcome;
112 
113  /* Instantiate the second InManager */
114  inManager2 = CrFwInManagerMake(1);
115 
116  /* Initialize and Configure InManager and check success */
117  CrFwCmpInit(inManager2);
118  CrFwCmpReset(inManager2);
119  if (!CrFwCmpIsInConfigured(inManager2))
120  return 0;
121 
122  /* Check Instance Identifiers */
123  if (CrFwCmpGetInstanceId(inManager2) != 1)
124  return 0;
125 
126  /* Initialize and Configure factories and check success */
131  return 0;
132 
133  /* Create and load an InReport and an InCommand */
134  pckt1 = CrFwPcktMake(100);
135  CrFwPcktSetServType(pckt1,5);
136  CrFwPcktSetServSubType(pckt1,1);
137  CrFwPcktSetDiscriminant(pckt1,1);
138  pckt2 = CrFwPcktMake(100);
139  CrFwPcktSetServType(pckt2,8);
140  CrFwPcktSetServSubType(pckt2,1);
141  CrFwPcktSetDiscriminant(pckt2,1);
142  inRep1 = CrFwInFactoryMakeInRep(pckt1);
143  inCmd1 = CrFwInFactoryMakeInCmd(pckt2);
144 
145  loadOutcome = CrFwInManagerLoad(inManager2, inRep1);
146  if (loadOutcome != 1)
147  return 0;
148  if (CrFwInManagerGetNOfPendingInCmp(inManager2) != 1)
149  return 0;
150  if (CrFwInManagerGetNOfLoadedInCmp(inManager2) != 1)
151  return 0;
152 
153  loadOutcome = CrFwInManagerLoad(inManager2, inCmd1);
154  if (loadOutcome != 1)
155  return 0;
156  if (CrFwInManagerGetNOfPendingInCmp(inManager2) != 2)
157  return 0;
158  if (CrFwInManagerGetNOfLoadedInCmp(inManager2) != 2)
159  return 0;
160 
161  /* Fill up the InManager */
162  for (i=2; i<CrFwInManagerGetPCRLSize(inManager2); i++) {
163  pckt1 = CrFwPcktMake(100);
164  CrFwPcktSetServType(pckt1,5);
165  CrFwPcktSetServSubType(pckt1,1);
166  CrFwPcktSetDiscriminant(pckt1,1);
167  inRep1 = CrFwInFactoryMakeInRep(pckt1);
168  CrFwInManagerLoad(inManager2, inRep1);
169  }
170 
171  /* Check number of loaded InReports/InCommands */
172  if (CrFwInManagerGetNOfLoadedInCmp(inManager2) != CrFwInManagerGetPCRLSize(inManager2))
173  return 0;
174 
175  /* Store the current value of the error report counter */
176  errRepPosLocal = CrFwRepErrStubGetPos();
177 
178  /* Create one more InCommand and overflow the PCRL */
179  pckt1 = CrFwPcktMake(100);
180  CrFwPcktSetServType(pckt1,8);
181  CrFwPcktSetServSubType(pckt1,1);
182  CrFwPcktSetDiscriminant(pckt1,1);
183  inCmd1 = CrFwInFactoryMakeInCmd(pckt1);
184  loadOutcome = CrFwInManagerLoad(inManager2, inCmd1);
185  if (loadOutcome != 0)
186  return 0;
187 
188  /* Check number of loaded InReports/InCommands */
189  if (CrFwInManagerGetNOfLoadedInCmp(inManager2) != CrFwInManagerGetPCRLSize(inManager2))
190  return 0;
191 
192  /* Check that an error report has been generated */
193  if (CrFwRepErrStubGetPos() != errRepPosLocal+1)
194  return 0;
196  return 0;
198  return 0;
200  return 0;
201 
202  /* Reset the InManager (this should clear the PCRL and release all loaded components) */
203  CrFwCmpReset(inManager2);
204  if (!CrFwCmpIsInConfigured(inManager2))
205  return 0;
206  if (CrFwInManagerGetNOfPendingInCmp(inManager2) != 0)
207  return 0;
208  if (CrFwPcktGetNOfAllocated() != 1)
209  return 0;
210  if (CrFwInManagerGetNOfLoadedInCmp(inManager2) != 0)
211  return 0;
212 
213  /* Release the last InCommand */
215 
216  /* Check that there are no allocated packets */
217  if (CrFwPcktGetNOfAllocated() != 0)
218  return 0;
219 
220  /* Check application errors */
221  if (CrFwGetAppErrCode() != crNoAppErr)
222  return 0;
223 
224  return 1;
225 }
226 
227 /* ---------------------------------------------------------------------------------------------*/
229  FwSmDesc_t inManager1, inRegistry, inFactory;
230  FwSmDesc_t sampleInRep;
231  FwSmCounterU3_t execCnt;
232  CrFwPckt_t pckt;
233 
234  /* Instantiate the first InManager */
235  inManager1 = CrFwInManagerMake(0);
236 
237  /* Initialize and Configure InManager and check success */
238  CrFwCmpInit(inManager1);
239  CrFwCmpReset(inManager1);
240  if (!CrFwCmpIsInConfigured(inManager1))
241  return 0;
242 
243  /* Initialize and Configure InRegistry and check success */
248  return 0;
249 
250  /* Execute the empty InManager */
251  CrFwCmpExecute(inManager1);
252  CrFwCmpExecute(inManager1);
253 
254  /* Initialize and Configure InFactory and check success */
259  return 0;
260 
261  /* Allocate a Sample 1 InReport instance */
262  pckt = CrFwPcktMake(100);
263  CrFwPcktSetServType(pckt,40);
264  CrFwPcktSetServSubType(pckt,1);
265  CrFwPcktSetDiscriminant(pckt,0);
266  CrFwInRepSample1SetValidityFlag(1); /* Validity Check will succeed */
267  sampleInRep = CrFwInFactoryMakeInRep(pckt);
268 
269  /* Load Sample InCommand in InManager */
270  CrFwInManagerLoad(inManager1, sampleInRep);
271  if (CrFwInManagerGetNOfPendingInCmp(inManager1) != 1)
272  return 0;
273 
274  /* Store execution counter of Sample InCommand */
275  execCnt = FwSmGetExecCnt(sampleInRep);
276 
277  /* Execute the InManager */
278  CrFwCmpExecute(inManager1); /* this causes the Sample InReport to terminate */
279  CrFwCmpExecute(inManager1);
280 
281  /* Check that execution was propagated to Sample InReport */
282  if (FwSmGetExecCnt(sampleInRep) != execCnt+1)
283  return 0;
284  if (CrFwInManagerGetNOfPendingInCmp(inManager1) != 0)
285  return 0;
287  return 0;
288 
289  /* Check that Sample InReport was released by InManager */
291  return 0;
292 
293  /* Check that there are no allocated packets */
294  if (CrFwPcktGetNOfAllocated() != 0)
295  return 0;
296 
297  /* Check application errors */
298  if (CrFwGetAppErrCode() != crNoAppErr)
299  return 0;
300 
301  return 1;
302 }
303 
304 /* ---------------------------------------------------------------------------------------------*/
306  FwSmDesc_t inManager1, inRegistry, inFactory;
307  FwSmDesc_t sampleInCmd;
308  FwSmCounterU3_t execCnt;
309  CrFwPckt_t pckt;
310 
311  /* Instantiate the first InManager */
312  inManager1 = CrFwInManagerMake(0);
313 
314  /* Initialize and Configure InManager and check success */
315  CrFwCmpInit(inManager1);
316  CrFwCmpReset(inManager1);
317  if (!CrFwCmpIsInConfigured(inManager1))
318  return 0;
319 
320  /* Initialize and Configure InRegistry and check success */
325  return 0;
326 
327  /* Execute the empty InManager */
328  CrFwCmpExecute(inManager1);
329  CrFwCmpExecute(inManager1);
330 
331  /* Initialize and Configure InFactory and check success */
336  return 0;
337 
338  /* Allocate a Sample 1 InCommand instance and configure it to remain pending*/
339  pckt = CrFwPcktMake(100);
340  CrFwPcktSetServType(pckt,50);
341  CrFwPcktSetServSubType(pckt,1);
342  CrFwPcktSetDiscriminant(pckt,0);
343  CrFwPcktSetAckLevel(pckt, 0, 0, 0, 0); /* No acknowledgement of success */
344  CrFwInCmdSample1SetValidityFlag(1); /* Validity Check returns "valid" */
345  CrFwInCmdSample1SetProgressActionCompletionOutcome(0); /* Completion Outcome is "not completed" */
346  CrFwInCmdSample1SetProgressActionOutcome(1); /* Progress action outcome is "success" */
347  CrFwInCmdSample1SetReadyFlag(1); /* Outcome of Ready Check is "ready" */
348  CrFwInCmdSample1SetStartActionOutcome(1); /* Outcome of Start Action is "success" */
349  CrFwInCmdSample1SetTerminationActionOutcome(1); /* Outcome of Termination Action is "success" */
350  sampleInCmd = CrFwInFactoryMakeInCmd(pckt);
351 
352  /* Load Sample InCommand in InManager */
353  CrFwInManagerLoad(inManager1, sampleInCmd);
354  if (CrFwInManagerGetNOfPendingInCmp(inManager1) != 1)
355  return 0;
356 
357  /* Store execution counter of Sample InCommand */
358  execCnt = FwSmGetExecCnt(sampleInCmd);
359 
360  /* Execute the InManager */
361  CrFwCmpExecute(inManager1); /* this causes the Sample InCommand to enter PROGRESS */
362  CrFwCmpExecute(inManager1);
363 
364  /* Check that execution was propagated to Sample InCommand */
365  if (FwSmGetExecCnt(sampleInCmd) != execCnt+2)
366  return 0;
367  if (!CrFwInCmdIsInProgress(sampleInCmd))
368  return 0;
369  if (CrFwInManagerGetNOfPendingInCmp(inManager1) != 1)
370  return 0;
372  return 0;
373 
374  /* Configure InCommand to terminate */
375  CrFwInCmdSample1SetProgressActionCompletionOutcome(1); /* Outcome of Progress Action is "completed" */
376 
377  /* Execute the InManager */
378  CrFwCmpExecute(inManager1); /* this causes the Sample InCommand to enter TERMINATE */
379  CrFwCmpExecute(inManager1);
380 
381  /* Check that execution was propagated to Sample InCommand */
382  if (FwSmGetExecCnt(sampleInCmd) != execCnt+3)
383  return 0;
384  if (!CrFwInCmdIsInTerminated(sampleInCmd))
385  return 0;
386  if (CrFwInManagerGetNOfPendingInCmp(inManager1) != 0)
387  return 0;
389  return 0;
390 
391  /* Check that Sample InCommand was released by InManager */
393  return 0;
394 
395  /* Check that there are no allocated packets */
396  if (CrFwPcktGetNOfAllocated() != 0)
397  return 0;
398 
399  /* Check application errors */
400  if (CrFwGetAppErrCode() != crNoAppErr)
401  return 0;
402 
403  return 1;
404 }
405 
406 /* ---------------------------------------------------------------------------------------------*/
408  FwSmDesc_t inManager1, inRegistry, inFactory;
409  FwSmDesc_t sampleInCmd;
410  FwSmCounterU3_t execCnt;
411  CrFwPckt_t pckt;
412 
413  /* Instantiate the first InManager */
414  inManager1 = CrFwInManagerMake(0);
415 
416  /* Initialize and Configure InManager and check success */
417  CrFwCmpInit(inManager1);
418  CrFwCmpReset(inManager1);
419  if (!CrFwCmpIsInConfigured(inManager1))
420  return 0;
421 
422  /* Initialize and Configure InRegistry and check success */
427  return 0;
428 
429  /* Execute the empty InManager */
430  CrFwCmpExecute(inManager1);
431  CrFwCmpExecute(inManager1);
432 
433  /* Initialize and Configure InFactory and check success */
438  return 0;
439 
440  /* Allocate a Sample 1 InCommand instance and configure it to be aborted */
441  pckt = CrFwPcktMake(100);
442  CrFwPcktSetServType(pckt,50);
443  CrFwPcktSetServSubType(pckt,1);
444  CrFwPcktSetDiscriminant(pckt,0);
445  CrFwPcktSetAckLevel(pckt, 0, 0, 0, 0); /* No acknowledgement of success */
446  CrFwInCmdSample1SetValidityFlag(1); /* Validity Check returns "valid" */
447  CrFwInCmdSample1SetProgressActionCompletionOutcome(0); /* Completion Outcome is "not completed" */
448  CrFwInCmdSample1SetProgressActionOutcome(1); /* Progress action outcome is "success" */
449  CrFwInCmdSample1SetReadyFlag(1); /* Outcome of Ready Check is "ready" */
450  CrFwInCmdSample1SetStartActionOutcome(0); /* Outcome of Start Action is "failed" */
451  CrFwInCmdSample1SetTerminationActionOutcome(1); /* Outcome of Termination Action is "success" */
452  sampleInCmd = CrFwInFactoryMakeInCmd(pckt);
453 
454  /* Load Sample InCommand in InManager */
455  CrFwInManagerLoad(inManager1, sampleInCmd);
456  if (CrFwInManagerGetNOfPendingInCmp(inManager1) != 1)
457  return 0;
458 
459  /* Store execution counter of Sample InCommand */
460  execCnt = FwSmGetExecCnt(sampleInCmd);
461 
462  /* Execute the InManager */
463  CrFwCmpExecute(inManager1); /* this causes the Sample InCommand to enter ABORTED */
464  CrFwCmpExecute(inManager1);
465 
466  /* Check that execution was propagated to Sample InCommand */
467  if (FwSmGetExecCnt(sampleInCmd) != execCnt+1)
468  return 0;
469  if (!CrFwInCmdIsInAborted(sampleInCmd))
470  return 0;
471  if (CrFwInManagerGetNOfPendingInCmp(inManager1) != 0)
472  return 0;
474  return 0;
475 
476  /* Check that Sample InCommand was released by InManager */
478  return 0;
479 
480  /* Check that there are no allocated packets */
481  if (CrFwPcktGetNOfAllocated() != 0)
482  return 0;
483 
484  /* Check application errors */
485  if (CrFwGetAppErrCode() != crNoAppErr)
486  return 0;
487 
488  return 1;
489 }
490 
491 /* ---------------------------------------------------------------------------------------------*/
493  FwSmDesc_t inManager2, inRegistry, inFactory;
494  FwSmDesc_t sampleInCmd1, sampleInCmd2, inRep1, inRep2, inRep3, inRep4;
495  CrFwPckt_t pckt;
496 
497  /* Instantiate an InManager */
498  inManager2 = CrFwInManagerMake(1);
499 
500  /* Initialize and Configure InManager and check success */
501  CrFwCmpInit(inManager2);
502  CrFwCmpReset(inManager2);
503  if (!CrFwCmpIsInConfigured(inManager2))
504  return 0;
505 
506  /* Initialize and Configure InRegistry and check success */
511  return 0;
512 
513  /* Initialize and Configure InFactory and check success */
518  return 0;
519 
520  /* Allocate Sample 1 InCommand instances and configure them to remain pending */
521  pckt = CrFwPcktMake(100);
522  CrFwPcktSetServType(pckt,50);
523  CrFwPcktSetServSubType(pckt,1);
524  CrFwPcktSetDiscriminant(pckt,0);
525  CrFwPcktSetAckLevel(pckt, 0, 0, 0, 0); /* No acknowledgement of success */
526  CrFwInCmdSample1SetValidityFlag(1); /* Validity Check returns "valid" */
527  CrFwInCmdSample1SetProgressActionCompletionOutcome(0); /* Completion Outcome is "not completed" */
528  CrFwInCmdSample1SetProgressActionOutcome(1); /* Progress action outcome is "success" */
529  CrFwInCmdSample1SetReadyFlag(1); /* Outcome of Ready Check is "ready" */
530  CrFwInCmdSample1SetStartActionOutcome(1); /* Outcome of Start Action is "success" */
531  CrFwInCmdSample1SetTerminationActionOutcome(1); /* Outcome of Termination Action is "success" */
532  sampleInCmd1 = CrFwInFactoryMakeInCmd(pckt);
533 
534  pckt = CrFwPcktMake(100);
535  CrFwPcktSetServType(pckt,50);
536  CrFwPcktSetServSubType(pckt,1);
537  CrFwPcktSetDiscriminant(pckt,0);
538  CrFwPcktSetAckLevel(pckt, 0, 0, 0, 0); /* No acknowledgement of success */
539  CrFwInCmdSample1SetValidityFlag(1); /* Validity Check returns "valid" */
540  CrFwInCmdSample1SetProgressActionCompletionOutcome(0); /* Completion Outcome is "not completed" */
541  CrFwInCmdSample1SetProgressActionOutcome(1); /* Progress action outcome is "success" */
542  CrFwInCmdSample1SetReadyFlag(1); /* Outcome of Ready Check is "ready" */
543  CrFwInCmdSample1SetStartActionOutcome(1); /* Outcome of Start Action is "success" */
544  CrFwInCmdSample1SetTerminationActionOutcome(1); /* Outcome of Termination Action is "success" */
545  sampleInCmd2 = CrFwInFactoryMakeInCmd(pckt);
546 
547  /* Allocate InReport instances */
548  pckt = CrFwPcktMake(100);
549  CrFwPcktSetServType(pckt,5);
550  CrFwPcktSetServSubType(pckt,1);
551  CrFwPcktSetDiscriminant(pckt,1);
552  inRep1 = CrFwInFactoryMakeInRep(pckt);
553 
554  pckt = CrFwPcktMake(100);
555  CrFwPcktSetServType(pckt,5);
556  CrFwPcktSetServSubType(pckt,1);
557  CrFwPcktSetDiscriminant(pckt,1);
558  inRep2 = CrFwInFactoryMakeInRep(pckt);
559 
560  /* Load InCommands and InReports in InManager */
561  CrFwInManagerLoad(inManager2, sampleInCmd1);
562  CrFwInManagerLoad(inManager2, inRep1);
563  CrFwInManagerLoad(inManager2, sampleInCmd2);
564  CrFwInManagerLoad(inManager2, inRep2);
565  if (CrFwInManagerGetNOfPendingInCmp(inManager2) != 4)
566  return 0;
567  if (CrFwInManagerGetNOfLoadedInCmp(inManager2) != 4)
568  return 0;
569 
570  /* Execute the InManager */
571  CrFwCmpExecute(inManager2); /* this causes the InReports to be unloaded */
572  CrFwCmpExecute(inManager2);
573 
574  /* Check that InReports were unloaded and released */
575  if (CrFwInManagerGetNOfPendingInCmp(inManager2) != 2)
576  return 0;
578  return 0;
580  return 0;
581  if (CrFwInManagerGetNOfLoadedInCmp(inManager2) != 4)
582  return 0;
583 
584  /* Check tracking by InRegistry */
586  return 0;
588  return 0;
590  return 0;
592  return 0;
593 
594  /* Allocate two more InReport instances */
595  pckt = CrFwPcktMake(100);
596  CrFwPcktSetServType(pckt,5);
597  CrFwPcktSetServSubType(pckt,1);
598  CrFwPcktSetDiscriminant(pckt,1);
599  inRep3 = CrFwInFactoryMakeInRep(pckt);
600 
601  pckt = CrFwPcktMake(100);
602  CrFwPcktSetServType(pckt,5);
603  CrFwPcktSetServSubType(pckt,1);
604  CrFwPcktSetDiscriminant(pckt,1);
605  inRep4 = CrFwInFactoryMakeInRep(pckt);
606 
607  /* Load InReports in InManager */
608  CrFwInManagerLoad(inManager2, inRep3);
609  CrFwInManagerLoad(inManager2, inRep4);
610  if (CrFwInManagerGetNOfPendingInCmp(inManager2) != 4)
611  return 0;
612  if (CrFwInManagerGetNOfLoadedInCmp(inManager2) != 6)
613  return 0;
614 
615  /* Execute the InManager */
616  CrFwCmpExecute(inManager2); /* this causes the InReports to be unloaded */
617 
618  /* Check that InReports were unloaded and released */
619  if (CrFwInManagerGetNOfPendingInCmp(inManager2) != 2)
620  return 0;
622  return 0;
624  return 0;
625  if (CrFwInManagerGetNOfLoadedInCmp(inManager2) != 6)
626  return 0;
627 
628  /* Configure InCommands to be terminated */
629  CrFwInCmdSample1SetProgressActionCompletionOutcome(1); /* Outcome of Progress Action is "completed" */
630 
631  /* Execute the InManager */
632  CrFwCmpExecute(inManager2); /* this causes the InCommands to be unloaded */
633 
634  /* Check that InCommands were unloaded and released */
635  if (CrFwInManagerGetNOfPendingInCmp(inManager2) != 0)
636  return 0;
638  return 0;
639 
640  /* Check tracking by InRegistry */
642  return 0;
644  return 0;
646  return 0;
648  return 0;
649 
650  /* Check that there are no allocated packets */
651  if (CrFwPcktGetNOfAllocated() != 0)
652  return 0;
653 
654  /* Check application errors */
655  if (CrFwGetAppErrCode() != crNoAppErr)
656  return 0;
657 
658  return 1;
659 }
660 
661 /* ---------------------------------------------------------------------------------------------*/
663  FwSmDesc_t inManager3, inRegistry, inFactory;
664  FwSmDesc_t sampleInCmd1, sampleInCmd2, inRep1, inRep2;
665  CrFwPckt_t pckt;
666 
667  /* Instantiate an InManager */
668  inManager3 = CrFwInManagerMake(2);
669 
670  /* Initialize and Configure InManager and check success */
671  CrFwCmpInit(inManager3);
672  CrFwCmpReset(inManager3);
673  if (!CrFwCmpIsInConfigured(inManager3))
674  return 0;
675 
676  /* Initialize and Configure InRegistry and check success */
681  return 0;
682 
683  /* Initialize and Configure InFactory and check success */
688  return 0;
689 
690  /* Allocate Sample 1 InCommand instances and configure them to remain pending */
691  pckt = CrFwPcktMake(100);
692  CrFwPcktSetServType(pckt,50);
693  CrFwPcktSetServSubType(pckt,1);
694  CrFwPcktSetDiscriminant(pckt,0);
695  CrFwPcktSetAckLevel(pckt, 0, 0, 0, 0); /* No acknowledgement of success */
696  CrFwInCmdSample1SetValidityFlag(1); /* Validity Check returns "valid" */
697  CrFwInCmdSample1SetProgressActionCompletionOutcome(0); /* Completion Outcome is "not completed" */
698  CrFwInCmdSample1SetProgressActionOutcome(1); /* Progress action outcome is "success" */
699  CrFwInCmdSample1SetReadyFlag(1); /* Outcome of Ready Check is "ready" */
700  CrFwInCmdSample1SetStartActionOutcome(1); /* Outcome of Start Action is "success" */
701  CrFwInCmdSample1SetTerminationActionOutcome(1); /* Outcome of Termination Action is "success" */
702  sampleInCmd1 = CrFwInFactoryMakeInCmd(pckt);
703 
704  pckt = CrFwPcktMake(100);
705  CrFwPcktSetServType(pckt,50);
706  CrFwPcktSetServSubType(pckt,1);
707  CrFwPcktSetDiscriminant(pckt,0);
708  CrFwPcktSetAckLevel(pckt, 0, 0, 0, 0); /* No acknowledgement of success */
709  CrFwInCmdSample1SetValidityFlag(1); /* Validity Check returns "valid" */
710  CrFwInCmdSample1SetProgressActionCompletionOutcome(0); /* Completion Outcome is "not completed" */
711  CrFwInCmdSample1SetProgressActionOutcome(1); /* Progress action outcome is "success" */
712  CrFwInCmdSample1SetReadyFlag(1); /* Outcome of Ready Check is "ready" */
713  CrFwInCmdSample1SetStartActionOutcome(1); /* Outcome of Start Action is "success" */
714  CrFwInCmdSample1SetTerminationActionOutcome(1); /* Outcome of Termination Action is "success" */
715  sampleInCmd2 = CrFwInFactoryMakeInCmd(pckt);
716 
717  /* Allocate InReport instances */
718  pckt = CrFwPcktMake(100);
719  CrFwPcktSetServType(pckt,5);
720  CrFwPcktSetServSubType(pckt,1);
721  CrFwPcktSetDiscriminant(pckt,1);
722  inRep1 = CrFwInFactoryMakeInRep(pckt);
723 
724  pckt = CrFwPcktMake(100);
725  CrFwPcktSetServType(pckt,5);
726  CrFwPcktSetServSubType(pckt,1);
727  CrFwPcktSetDiscriminant(pckt,1);
728  inRep2 = CrFwInFactoryMakeInRep(pckt);
729 
730  /* Load InCommands and InReports in InManager */
731  CrFwInManagerLoad(inManager3, sampleInCmd1);
732  CrFwInManagerLoad(inManager3, sampleInCmd2);
733  CrFwInManagerLoad(inManager3, inRep1);
734  CrFwInManagerLoad(inManager3, inRep2);
735  if (CrFwInManagerGetNOfPendingInCmp(inManager3) != 4)
736  return 0;
737 
738  /* Reset the InManager */
739  CrFwCmpReset(inManager3);
740 
741  /* Check that InReports and InCommands were unloaded and released */
742  if (CrFwInManagerGetNOfPendingInCmp(inManager3) != 0)
743  return 0;
745  return 0;
747  return 0;
748 
749  /* Check that there are no allocated packets */
750  if (CrFwPcktGetNOfAllocated() != 0)
751  return 0;
752 
753  /* Check application errors */
754  if (CrFwGetAppErrCode() != crNoAppErr)
755  return 0;
756 
757  return 1;
758 }
759 
760 /* ---------------------------------------------------------------------------------------------*/
762  FwSmDesc_t inManager3, inRegistry, inFactory;
763  FwSmDesc_t sampleInCmd1, sampleInCmd2, inRep1, inRep2;
764  CrFwPckt_t pckt;
765 
766  /* Instantiate an InManager */
767  inManager3 = CrFwInManagerMake(2);
768 
769  /* Initialize and Configure InManager and check success */
770  CrFwCmpInit(inManager3);
771  CrFwCmpReset(inManager3);
772  if (!CrFwCmpIsInConfigured(inManager3))
773  return 0;
774 
775  /* Initialize and Configure InRegistry and check success */
780  return 0;
781 
782  /* Initialize and Configure InFactory and check success */
787  return 0;
788 
789  /* Allocate Sample 1 InCommand instances and configure them to remain pending */
790  pckt = CrFwPcktMake(100);
791  CrFwPcktSetServType(pckt,50);
792  CrFwPcktSetServSubType(pckt,1);
793  CrFwPcktSetDiscriminant(pckt,0);
794  CrFwPcktSetAckLevel(pckt, 0, 0, 0, 0); /* No acknowledgement of success */
795  CrFwInCmdSample1SetValidityFlag(1); /* Validity Check returns "valid" */
796  CrFwInCmdSample1SetProgressActionCompletionOutcome(0); /* Completion Outcome is "not completed" */
797  CrFwInCmdSample1SetProgressActionOutcome(1); /* Progress action outcome is "success" */
798  CrFwInCmdSample1SetReadyFlag(1); /* Outcome of Ready Check is "ready" */
799  CrFwInCmdSample1SetStartActionOutcome(1); /* Outcome of Start Action is "success" */
800  CrFwInCmdSample1SetTerminationActionOutcome(1); /* Outcome of Termination Action is "success" */
801  sampleInCmd1 = CrFwInFactoryMakeInCmd(pckt);
802 
803  pckt = CrFwPcktMake(100);
804  CrFwPcktSetServType(pckt,50);
805  CrFwPcktSetServSubType(pckt,1);
806  CrFwPcktSetDiscriminant(pckt,0);
807  CrFwPcktSetAckLevel(pckt, 0, 0, 0, 0); /* No acknowledgement of success */
808  CrFwInCmdSample1SetValidityFlag(1); /* Validity Check returns "valid" */
809  CrFwInCmdSample1SetProgressActionCompletionOutcome(0); /* Completion Outcome is "not completed" */
810  CrFwInCmdSample1SetProgressActionOutcome(1); /* Progress action outcome is "success" */
811  CrFwInCmdSample1SetReadyFlag(1); /* Outcome of Ready Check is "ready" */
812  CrFwInCmdSample1SetStartActionOutcome(1); /* Outcome of Start Action is "success" */
813  CrFwInCmdSample1SetTerminationActionOutcome(1); /* Outcome of Termination Action is "success" */
814  sampleInCmd2 = CrFwInFactoryMakeInCmd(pckt);
815 
816  /* Allocate InReport instances */
817  pckt = CrFwPcktMake(100);
818  CrFwPcktSetServType(pckt,5);
819  CrFwPcktSetServSubType(pckt,1);
820  CrFwPcktSetDiscriminant(pckt,1);
821  inRep1 = CrFwInFactoryMakeInRep(pckt);
822 
823  pckt = CrFwPcktMake(100);
824  CrFwPcktSetServType(pckt,5);
825  CrFwPcktSetServSubType(pckt,1);
826  CrFwPcktSetDiscriminant(pckt,1);
827  inRep2 = CrFwInFactoryMakeInRep(pckt);
828 
829  /* Load InCommands and InReports in InManager */
830  CrFwInManagerLoad(inManager3, sampleInCmd1);
831  CrFwInManagerLoad(inManager3, sampleInCmd2);
832  CrFwInManagerLoad(inManager3, inRep1);
833  CrFwInManagerLoad(inManager3, inRep2);
834  if (CrFwInManagerGetNOfPendingInCmp(inManager3) != 4)
835  return 0;
836 
837  /* Shutdown the InManager */
838  CrFwCmpShutdown(inManager3);
839 
840  /* Check that InReports and InCommands were unloaded and released */
841  if (CrFwInManagerGetNOfPendingInCmp(inManager3) != 0)
842  return 0;
844  return 0;
846  return 0;
847 
848  /* Re-start, initialize and reset the InManager */
849  FwSmStart(inManager3);
850  CrFwCmpInit(inManager3);
851  CrFwCmpReset(inManager3);
852  if (!CrFwCmpIsInConfigured(inManager3))
853  return 0;
854 
855  /* Check that there are no allocated packets */
856  if (CrFwPcktGetNOfAllocated() != 0)
857  return 0;
858 
859  /* Check application errors */
860  if (CrFwGetAppErrCode() != crNoAppErr)
861  return 0;
862 
863  return 1;
864 }
865 
866 
CrFwInstanceId_t CrFwCmpGetInstanceId(FwSmDesc_t smDesc)
Return the instance identifier of the argument component.
Definition: CrFwBaseCmp.c:150
void CrFwCmpInit(FwSmDesc_t smDesc)
Initialize a framework component.
Definition: CrFwBaseCmp.c:112
CrFwBool_t CrFwCmpIsInInitialized(FwSmDesc_t smDesc)
Return true if the argument component is in state INITIALIZED.
Definition: CrFwBaseCmp.c:172
void CrFwCmpShutdown(FwSmDesc_t smDesc)
Shutdown a framework component.
Definition: CrFwBaseCmp.c:122
CrFwBool_t CrFwCmpIsInConfigured(FwSmDesc_t smDesc)
Return true if the argument component is in state CONFIGURED.
Definition: CrFwBaseCmp.c:177
void CrFwCmpReset(FwSmDesc_t smDesc)
Reset a framework component.
Definition: CrFwBaseCmp.c:117
CrFwBool_t CrFwCmpIsInCreated(FwSmDesc_t smDesc)
Return true if the argument component is in state CREATED.
Definition: CrFwBaseCmp.c:167
void CrFwCmpExecute(FwSmDesc_t smDesc)
Execute a framework component.
Definition: CrFwBaseCmp.c:127
CrFwTypeId_t CrFwCmpGetTypeId(FwSmDesc_t smDesc)
Return the type identifier of the argument component.
Definition: CrFwBaseCmp.c:156
Definition of Base Component.
Definition of the Framework Component Data (FCD) Type.
#define CR_FW_INMANAGER_TYPE
Type identifier for the InManager component.
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 CrFwInCmdIsInProgress(FwSmDesc_t smDesc)
Return true if the argument InCommand is in state PROGRESS.
Definition: CrFwInCmd.c:160
CrFwBool_t CrFwInCmdIsInAborted(FwSmDesc_t smDesc)
Return true if the argument InCommand is in state ABORTED.
Definition: CrFwInCmd.c:170
CrFwBool_t CrFwInCmdIsInTerminated(FwSmDesc_t smDesc)
Return true if the argument InCommand is in state TERMINATED.
Definition: CrFwInCmd.c:165
Definition of the InCommand Component of the framework.
void CrFwInCmdSample1SetReadyFlag(CrFwBool_t flag)
Set the value of the Ready Flag (see CrFwInCmdSample1ReadyCheck).
void CrFwInCmdSample1SetProgressActionCompletionOutcome(CrFwOutcome_t outcome)
Set the value of the Progress Action Completion Outcome (see CrFwInCmdSample1ProgressAction).
void CrFwInCmdSample1SetProgressActionOutcome(CrFwOutcome_t outcome)
Set the value of the Progress Action Outcome (see CrFwInCmdSample1ProgressAction).
void CrFwInCmdSample1SetStartActionOutcome(CrFwOutcome_t outcome)
Set the value of the Start Action Outcome Counter (see CrFwInCmdSample1StartAction).
void CrFwInCmdSample1SetTerminationActionOutcome(CrFwOutcome_t outcome)
Set the value of the Termination Action Outcome Counter (see CrFwInCmdSample1TerminationAction).
void CrFwInCmdSample1SetValidityFlag(CrFwBool_t flag)
Set the value of the Validity Flag (see CrFwInCmdSample1ValidityCheck).
Sample InCommand used in the Test Suite.
CrFwInFactoryPoolIndex_t CrFwInFactoryGetNOfAllocatedInCmd()
Return the number of InCommands which are currently allocated.
FwSmDesc_t CrFwInFactoryMakeInCmd(CrFwPckt_t pckt)
Make function for a component encapsulating an incoming command (InCommand).
CrFwInFactoryPoolIndex_t CrFwInFactoryGetNOfAllocatedInRep()
Return the number of InReports which are currently allocated.
void CrFwInFactoryReleaseInCmd(FwSmDesc_t inCmdInstance)
Release function for an InCommand.
FwSmDesc_t CrFwInFactoryMakeInRep(CrFwPckt_t pckt)
Make function for a component encapsulating an incoming report (InReport).
FwSmDesc_t CrFwInFactoryMake()
Factory function for the singleton instance of the InFactory.
static FwSmDesc_t inFactory
The singleton instance of the InFactory.
Definition of the InFactory component.
CrFwBool_t CrFwInManagerLoad(FwSmDesc_t smDesc, FwSmDesc_t inCmp)
Load a new InReport or InCommand into the InManager.
CrFwCounterU2_t CrFwInManagerGetNOfLoadedInCmp(FwSmDesc_t smDesc)
Return the number of InReport or InCommands successfully loaded since the InManager was last reset.
CrFwCounterU1_t CrFwInManagerGetNOfPendingInCmp(FwSmDesc_t smDesc)
Return the number of InReport or InCommands currently in the PCRL of an InManager.
FwSmDesc_t CrFwInManagerMake(CrFwInstanceId_t i)
Factory function to retrieve the i-th InManager State Machine instance.
Definition: CrFwInManager.c:96
CrFwCounterU1_t CrFwInManagerGetPCRLSize(FwSmDesc_t smDesc)
Return the size of the PCRL of an InManager.
CrFwBool_t CrFwInManagerTestCase7()
Check the reset function of an InManager.
CrFwBool_t CrFwInManagerTestCase8()
Check the shutdown function of an InManager.
CrFwBool_t CrFwInManagerTestCase3()
Check the execution function of an InManager with one single InReport loaded.
CrFwBool_t CrFwInManagerTestCase5()
Check the execution function of an InManager with one InCommand loaded.
CrFwBool_t CrFwInManagerTestCase1()
Check the configuration of a newly created InManager.
CrFwBool_t CrFwInManagerTestCase6()
Check the execution function of an InManager with several InReports and InCommands loaded.
CrFwBool_t CrFwInManagerTestCase4()
Check the execution function of an InManager with one InCommand loaded.
CrFwBool_t CrFwInManagerTestCase2()
Check the load function of an InManager.
Declaration of the test cases for the InManager Component (see CrFwInManager.h).
User-modifiable parameters for the InManager components (see CrFwInManager.h).
#define CR_FW_NOF_INMANAGER
The number of InManager components in the application.
FwSmDesc_t CrFwInRegistryMake()
Factory function for the singleton instance of the InRegistry.
static FwSmDesc_t inRegistry
The InRegistry singleton.
CrFwInRegistryCmdRepState_t CrFwInRegistryGetState(CrFwInstanceId_t cmdRepId)
Query the InRegistry for the state of an incoming command or report.
Definition of the InRegistry Component.
@ crInRegistryAborted
Incoming command has been aborted.
@ crInRegistryTerminated
Incoming command or report has completed execution.
@ crInRegistryPending
Incoming command or report is pending (waiting to be sent)
User-modifiable parameters for the InRegistry component (see CrFwInRegistry.h).
Definition of the InReport Component of the framework.
void CrFwInRepSample1SetValidityFlag(CrFwBool_t flag)
Set the value of the Validity Flag (see CrFwInRepSample1ValidityCheck).
Sample InReport used in the Test Suite.
User-modifiable parameters for the OutFactory component (see CrFwOutFactory.h).
Interface for creating and accessing a report or command packet.
void CrFwPcktSetServSubType(CrFwPckt_t pckt, CrFwServSubType_t servSubType)
Set the service sub-type of the command or report encapsulated in a packet.
Definition: CrFwPckt.c:327
void CrFwPcktSetDiscriminant(CrFwPckt_t pckt, CrFwDiscriminant_t discriminant)
Set the discriminant of the command or report encapsulated in a packet.
Definition: CrFwPckt.c:309
void CrFwPcktSetServType(CrFwPckt_t pckt, CrFwServType_t servType)
Set the service type of the command or report encapsulated in a packet.
Definition: CrFwPckt.c:315
CrFwCounterU2_t CrFwPcktGetNOfAllocated()
Return the number of packets which are currently allocated.
Definition: CrFwPckt.c:214
void CrFwPcktSetAckLevel(CrFwPckt_t pckt, CrFwBool_t accept, CrFwBool_t start, CrFwBool_t progress, CrFwBool_t term)
Set the acknowledge level for the command encapsulated in a packet.
Definition: CrFwPckt.c:375
CrFwPckt_t CrFwPcktMake(CrFwPcktLength_t pcktLength)
Make function for command or report packets.
Definition: CrFwPckt.c:147
CrFwInstanceId_t CrFwRepErrStubGetInstanceId(CrFwCounterU2_t errRepPos)
Return the type identifier of the error report at position errRepPos.
Definition: CrFwRepErr.c:277
CrFwCounterU2_t CrFwRepErrStubGetPos()
Return the position in the error report array at which the next error report will be written.
Definition: CrFwRepErr.c:79
CrFwTypeId_t CrFwRepErrStubGetTypeId(CrFwCounterU2_t errRepPos)
Return the type identifier of the error report at position errRepPos.
Definition: CrFwRepErr.c:272
CrFwRepErrCode_t CrFwRepErrStubGetErrCode(CrFwCounterU2_t errRepPos)
Return the error code of the error report at position errRepPos.
Definition: CrFwRepErr.c:267
Interface for reporting an error detected by a framework component.
The CORDET Framework defines an interface for generating error reports (see CrFwRepErr....
Interface through which framework components access the current time.
unsigned short CrFwCounterU2_t
Type used for unsigned integers with a "medium" range.
@ crInManagerPcrlFull
The Pending Command/Report List (PCRL) of an InManager is full (see CrFwInManager....
@ crInManagerIllId
A framework function has been called with an illegal InManager identifier.
@ crNoAppErr
No application errors have been detected.
CrFwAppErrCode_t CrFwGetAppErrCode()
Return the value of the application error code.
void CrFwSetAppErrCode(CrFwAppErrCode_t errCode)
Set the value of the application error code (see CrFwGetAppErrCode).
Definition of the utility functions for the CORDET Framework.
P&P Software GmbH, Copyright 2012-2013, All Rights Reserved