CORDET Framework - C2 Implementation
CrFwAppSmTestCases.c
Go to the documentation of this file.
1 
19 #include <stdio.h>
20 #include <stdlib.h>
21 #include "CrFwAppSmTestCases.h"
22 /* Include FW Profile files */
23 #include "FwSmConstants.h"
24 #include "FwSmConfig.h"
25 #include "FwSmSCreate.h"
26 #include "FwSmCore.h"
27 #include "FwPrConfig.h"
28 #include "FwPrCore.h"
29 #include "FwPrConstants.h"
30 /* Include framework files */
32 #include "AppStartUp/CrFwAppSm.h"
36 /* Include configuration files */
37 #include "CrFwAppSmUserPar.h"
38 
39 /* Dummy state machine to be embedded in state START-UP of the Application State Machine */
40 FW_SM_INST_NOCPS(startUpEsmDesc, 1, 1, 0, 0)
41 
42 /* Dummy state machine to be embedded in state NORMAL of the Application State Machine */
43 FW_SM_INST_NOCPS(normalEsmDesc, 1, 1, 0, 0)
44 
45 /* Dummy state machine to be embedded in state RESET of the Application State Machine */
46 FW_SM_INST_NOCPS(resetEsmDesc, 1, 1, 0, 0)
47 
48 /* ---------------------------------------------------------------------------------------------*/
50  FwSmDesc_t appSm;
51 
52  /* Initialize and configure embedded state machines */
53  FwSmInit(&startUpEsmDesc);
54  FwSmAddState(&startUpEsmDesc, 1, 0, NULL, NULL, NULL, NULL); /* 1 state with no out-going transitions */
55  FwSmAddTransIpsToSta(&startUpEsmDesc, 1, NULL);
56 
57  FwSmInit(&normalEsmDesc);
58  FwSmAddState(&normalEsmDesc, 1, 0, NULL, NULL, NULL, NULL); /* 1 state with no out-going transitions */
59  FwSmAddTransIpsToSta(&normalEsmDesc, 1, NULL);
60 
61  FwSmInit(&resetEsmDesc);
62  FwSmAddState(&resetEsmDesc, 1, 0, NULL, NULL, NULL, NULL); /* 1 state with no out-going transitions */
63  FwSmAddTransIpsToSta(&resetEsmDesc, 1, NULL);
64 
65 
66  /* Instantiate the Application State Machine (ASM) */
67  appSm = CrFwAppSmMake();
68 
69  /* Check that ASM has not yet been started */
70  if (CrFwAppSmIsStarted())
71  return 0;
72 
73  /* Check ASM configuration */
74  if (FwSmCheck(appSm) != 1)
75  return 0;
76 
77  /* Attempt to instantiate the ASM a second time */
78  if (appSm != CrFwAppSmMake())
79  return 0;
80 
81  /* Check embedded SMs */
82  if (CrFwAppSmGetEsmStartUp() != &startUpEsmDesc)
83  return 0;
84  if (CrFwAppSmGetEsmNormal() != &normalEsmDesc)
85  return 0;
86  if (CrFwAppSmGetEsmReset() != &resetEsmDesc)
87  return 0;
88  if (CrFwAppSmGetEsmShutdown() != NULL)
89  return 0;
90 
91  /* Start ASM */
93  if (!CrFwAppSmIsInStartUp())
94  return 0;
95  if (!FwPrIsStarted(CrFwAppSmGetAppStartUpProc()))
96  return 0;
97 
98  /* Execute the ASM -- ASM should remain in START_UP */
100  if (!CrFwAppSmIsInStartUp())
101  return 0;
102 
103  /* Execute the Start-Up Procedure twice */
104  FwPrExecute(CrFwAppSmGetAppStartUpProc());
105  FwPrExecute(CrFwAppSmGetAppStartUpProc());
106  if (FwPrIsStarted(CrFwAppSmGetAppStartUpProc()))
107  return 0;
108 
109  /* Execute the ASM -- ASM should be in NORMAL */
111  if (!CrFwAppSmIsInNormal())
112  return 0;
113 
114  /* Reset the ASM -- ASM should enter RESET */
115  CrFwAppSmReset();
116  if (!CrFwAppSmIsInReset())
117  return 0;
118  if (!FwPrIsStarted(CrFwAppSmGetAppResetProc()))
119  return 0;
120 
121  /* Execute the Reset Procedure twice */
122  FwPrExecute(CrFwAppSmGetAppResetProc());
123  FwPrExecute(CrFwAppSmGetAppResetProc());
124  if (FwPrIsStarted(CrFwAppSmGetAppResetProc()))
125  return 0;
126 
127  /* Execute the ASM -- ASM should be in NORMAL */
129  if (!CrFwAppSmIsInNormal())
130  return 0;
131 
132  /* Shutdown the ASM -- ASM should enter SHUTDOWN */
134  if (!CrFwAppSmIsInShutdown())
135  return 0;
136  if (!FwPrIsStarted(CrFwAppSmGetAppShutdownProc()))
137  return 0;
138 
139  /* Execute the Shutdown Procedure twice */
140  FwPrExecute(CrFwAppSmGetAppShutdownProc());
141  FwPrExecute(CrFwAppSmGetAppShutdownProc());
142  if (FwPrIsStarted(CrFwAppSmGetAppShutdownProc()))
143  return 0;
144 
145  /* Execute the ASM -- ASM should be stopped */
147  if (CrFwAppSmIsStarted())
148  return 0;
149 
150  return 1;
151 }
152 
154  return &startUpEsmDesc;
155 }
156 
158  return &normalEsmDesc;
159 }
160 
162  return &resetEsmDesc;
163 }
Interface to the Application Reset Procedure.
FwPrDesc_t CrFwAppSmGetAppResetProc()
Retrieve the singleton instance of the Application Reset Procedure.
Interface to the Application Shutdown Procedure.
FwPrDesc_t CrFwAppSmGetAppShutdownProc()
Retrieve the singleton instance of the Application Shutdown Procedure.
FwSmDesc_t CrFwAppSmGetEsmReset()
Return the state machine embedded in state RESET (or NULL if no state machine is embedded in RESET).
Definition: CrFwAppSm.c:233
CrFwBool_t CrFwAppSmIsInNormal()
Return true if the Application State Machine is in state NORMAL.
Definition: CrFwAppSm.c:169
FwSmDesc_t CrFwAppSmGetEsmShutdown()
Return the state machine embedded in state SHUTDOWN (or NULL if no state machine is embedded in SHUTD...
Definition: CrFwAppSm.c:238
void CrFwAppSmExecute()
Execute the Application State Machine.
Definition: CrFwAppSm.c:144
CrFwBool_t CrFwAppSmIsStarted()
Return true if the Application State Machine has been started.
Definition: CrFwAppSm.c:159
CrFwBool_t CrFwAppSmIsInStartUp()
Return true if the Application State Machine is in state START_UP.
Definition: CrFwAppSm.c:164
void CrFwAppSmReset()
Reset the Application State Machine.
Definition: CrFwAppSm.c:149
CrFwBool_t CrFwAppSmIsInReset()
Return true if the Application State Machine is in state RESET.
Definition: CrFwAppSm.c:174
FwSmDesc_t CrFwAppSmMake()
Retrieve the singleton instance of the Application State Machine.
Definition: CrFwAppSm.c:106
void CrFwAppSmStart()
Start the Application State Machine.
Definition: CrFwAppSm.c:139
void CrFwAppSmShutdown()
Shutdown the Application State Machine.
Definition: CrFwAppSm.c:154
CrFwBool_t CrFwAppSmIsInShutdown()
Return true if the Application State Machine is in state SHUTDOWN.
Definition: CrFwAppSm.c:179
FwSmDesc_t CrFwAppSmGetEsmStartUp()
Return the state machine embedded in state START-UP (or NULL if no state machine is embedded in START...
Definition: CrFwAppSm.c:223
FwSmDesc_t CrFwAppSmGetEsmNormal()
Return the state machine embedded in state NORMAL (or NULL if no state machine is embedded in NORMAL)...
Definition: CrFwAppSm.c:228
Definition of Application State Machine.
FwSmDesc_t CrFwAppSmTestCasesGetNormalEsm()
Return the dummy state machine to be embedded in state NORMAL of the Application State Machine.
FwSmDesc_t CrFwAppSmTestCasesGetResetEsm()
Return the dummy state machine to be embedded in state RESET of the Application State Machine.
CrFwBool_t CrFwAppSmTestCase1()
Check the creation and configuration of the Application State Machine.
FwSmDesc_t CrFwAppSmTestCasesGetStartUpEsm()
Return the dummy state machine to be embedded in state START-UP of the Application State Machine.
Declaration of the test cases for the Application State Machine (see CrFwAppSm.h).
User-modifiable parameters for the Application State Machine (see CrFwAppSm.h).
Interface to the Application Start-Up Procedure.
FwPrDesc_t CrFwAppSmGetAppStartUpProc()
Retrieve the singleton instance of the Application Start-Up Procedure.
int CrFwBool_t
Type used for boolean values (1 represent "true" and 0 represents "false").
Definition: CrFwConstants.h:32
Definition of the utility functions for the CORDET Framework.
P&P Software GmbH, Copyright 2012-2013, All Rights Reserved