CORDET Framework - C2 Implementation
CrFwBaseCmpTestCases.c
Go to the documentation of this file.
1 
19 #include <stdio.h>
20 #include <stdlib.h>
21 #include "FwSmConstants.h"
22 #include "FwSmConfig.h"
23 #include "FwSmCore.h"
24 #include "FwPrConfig.h"
25 #include "FwPrCore.h"
26 #include "FwPrConstants.h"
27 /* Include Framework Files */
28 #include "BaseCmp/CrFwBaseCmp.h"
29 #include "BaseCmp/CrFwInitProc.h"
30 #include "BaseCmp/CrFwResetProc.h"
32 #include "CrFwBaseCmpTestCases.h"
33 /* Include Configuration Files */
34 #include "CrFwCmpData.h"
35 #include "CrFwUserConstants.h"
36 
38  FwSmDesc_t baseCmp;
39  FwPrDesc_t initProc, resetProc, execProc;
40  CrFwCmpData_t baseCmpData;
41 
42  /* Create base component and its procedures */
43  baseCmp = CrFwBaseCmpMake();
44  if (CrFwCmpIsStarted(baseCmp) == 1)
45  return 0;
46 
47  initProc = CrFwCmpGetInitProc();
48  if (FwPrIsStarted(initProc) == 1)
49  return 0;
50 
51  resetProc = CrFwCmpGetResetProc();
52  if (FwPrIsStarted(resetProc) == 1)
53  return 0;
54 
55  execProc = CrFwBaseCmpGetDummyExecProc();
56  if (FwPrIsStarted(execProc) == 1)
57  return 0;
58 
59  /* Attach procedures to base component */
60  baseCmpData.initProc = initProc;
61  baseCmpData.resetProc = resetProc;
62  baseCmpData.execProc = execProc;
63  FwSmSetData(baseCmp, &baseCmpData);
64  FwPrSetData(initProc, &baseCmpData);
65  FwPrSetData(resetProc, &baseCmpData);
66 
67  /* Check configuration of Base Component and its procedures */
68  if (FwSmCheck(baseCmp) != smSuccess)
69  return 0;
70  if (FwPrCheck(initProc) != prSuccess)
71  return 0;
72  if (FwPrCheck(resetProc) != prSuccess)
73  return 0;
74  if (FwPrCheck(execProc) != prSuccess)
75  return 0;
76 
77  /* Start and command base component into state CONFIGURED */
78  FwSmStart(baseCmp);
79  if (CrFwCmpIsStarted(baseCmp) != 1)
80  return 0;
81  if (!CrFwCmpIsInCreated(baseCmp))
82  return 0;
83 
84  CrFwCmpInit(baseCmp);
85  if (!CrFwCmpIsInInitialized(baseCmp))
86  return 0;
87 
88  CrFwCmpReset(baseCmp);
89  if (!CrFwCmpIsInConfigured(baseCmp))
90  return 0;
91 
92  /* Shutdown base component */
93  CrFwCmpShutdown(baseCmp);
94  if (CrFwCmpIsStarted(baseCmp) == 1)
95  return 0;
96 
97  /* Detach procedures from Base Component instance and bring it back to state STOPPED */
98  FwSmStop(baseCmp);
99  FwSmSetData(baseCmp, NULL);
100 
101  return 1;
102 }
Declaration of the test cases for the Base Component (see CrFwBaseCmp.h).
Type for the Framework Component Data (FCD).
Definition: CrFwCmpData.h:79
void CrFwCmpInit(FwSmDesc_t smDesc)
Initialize a framework component.
Definition: CrFwBaseCmp.c:112
FwPrDesc_t CrFwCmpGetResetProc()
Retrieve the singleton instance of the CRP.
Definition: CrFwResetProc.c:45
Definition of the Framework Component Data (FCD) Type.
CrFwBool_t CrFwCmpIsInConfigured(FwSmDesc_t smDesc)
Return true if the argument component is in state CONFIGURED.
Definition: CrFwBaseCmp.c:177
CrFwBool_t CrFwCmpIsInCreated(FwSmDesc_t smDesc)
Return true if the argument component is in state CREATED.
Definition: CrFwBaseCmp.c:167
int CrFwBool_t
Type used for boolean values (1 represent "true" and 0 represents "false").
Definition: CrFwConstants.h:32
FwPrDesc_t resetProc
The Component Reset Procedure (CRP) (see CrFwResetProc.h).
Definition: CrFwCmpData.h:97
Dummy Component Execution Procedure (CEP) for the Base Component.
CrFwBool_t CrFwCmpIsInInitialized(FwSmDesc_t smDesc)
Return true if the argument component is in state INITIALIZED.
Definition: CrFwBaseCmp.c:172
CrFwBool_t CrFwBaseCmpTestCase1()
Test the transitions in the Base Component state machine and its Initialization and Reset Procedures...
FwPrDesc_t execProc
The Component Execution Procedure (CEP) (see CrFwBaseCmp.h).
Definition: CrFwCmpData.h:99
FwSmDesc_t CrFwBaseCmpMake()
Retrieve the singleton instance of the Base State Machine.
Definition: CrFwBaseCmp.c:77
void CrFwCmpReset(FwSmDesc_t smDesc)
Reset a framework component.
Definition: CrFwBaseCmp.c:117
FwPrDesc_t CrFwBaseCmpGetDummyExecProc()
Retrieve the singleton instance of the Dummy CEP.
Definition of Base Component.
CrFwBool_t CrFwCmpIsStarted(FwSmDesc_t smDesc)
Return true if the state machine of the argument component has been started.
Definition: CrFwBaseCmp.c:162
Header file to define all user-configurable constants and types for the CORDET Framework (the non-con...
Component Initialization Procedure (CIP) for the Base Component.
void CrFwCmpShutdown(FwSmDesc_t smDesc)
Shutdown a framework component.
Definition: CrFwBaseCmp.c:122
FwPrDesc_t CrFwCmpGetInitProc()
Retrieve the singleton instance of the CIP.
Definition: CrFwInitProc.c:48
Component Reset Procedure (CRP) for the Base Component.
FwPrDesc_t initProc
The Component Initialization Procedure (CIP) (see CrFwInitProc.h).
Definition: CrFwCmpData.h:95
P&P Software GmbH, Copyright 2012-2013, All Rights Reserved