CORDET Framework - C2 Implementation
CrFwInRegistryTestCases.c
Go to the documentation of this file.
1 
19 #include <stdio.h>
20 #include <stdlib.h>
21 /* Include FW Profile files */
22 #include "FwSmConstants.h"
23 #include "FwSmConfig.h"
24 #include "FwSmCore.h"
25 #include "FwPrConfig.h"
26 #include "FwPrCore.h"
27 #include "FwPrConstants.h"
28 /* Include framework files */
29 #include "CrFwInRegistryUserPar.h"
31 #include "BaseCmp/CrFwBaseCmp.h"
32 #include "Pckt/CrFwPckt.h"
34 #include "CrFwTime.h"
35 #include "CrFwRepErr.h"
37 /* Include configuration files */
38 #include "CrFwRepErrStub.h"
40 #include "CrFwCmpData.h"
41 
42 /* ---------------------------------------------------------------------------------------------*/
44  FwSmDesc_t inRegistry1, inRegistry2;
46 
47  /* Instantiate the InRegistry */
48  inRegistry1 = CrFwInRegistryMake();
49  if (inRegistry1 == NULL)
50  return 0;
51 
52  /* Instantiate it again and check that same component is returned */
53  inRegistry2 = CrFwInRegistryMake();
54  if (inRegistry1 != inRegistry2)
55  return 0;
56 
57  /* Check configuration of InRegistry */
58  if (FwSmCheckRec(inRegistry1) != smSuccess)
59  return 0;
60 
61  /* Initialize inRegistry and check success */
62  if (!CrFwCmpIsInCreated(inRegistry1))
63  return 0;
64 
65  CrFwCmpInit(inRegistry1);
66  if (!CrFwCmpIsInInitialized(inRegistry1))
67  return 0;
68 
69  /* Reset InRegistry */
70  CrFwCmpReset(inRegistry1);
71  if (!CrFwCmpIsInConfigured(inRegistry1))
72  return 0;
73 
74  /* Check component type */
75  inRegistryData = (CrFwCmpData_t*)FwSmGetData(inRegistry1);
76  if (inRegistryData->instanceId != 0)
77  return 0;
79  return 0;
80 
81  return 1;
82 }
83 
84 /*--------------------------------------------------------------------------------*/
86  FwSmDesc_t inRegistry, inFactory, inRep1, inRep2, inCmd3;
87  CrFwPckt_t pckt1, pckt2, pckt3;
89  CrFwCmpData_t* cmpData;
90 
91  /* Instantiate the InRegistry */
93  if (inRegistry == NULL)
94  return 0;
95 
96  /* Initialize and configure InRegistry */
100  return 0;
101 
102  /* Instantiate the InFactory */
104  if (inFactory == NULL)
105  return 0;
106 
107  /* Initialize and configure factories */
111  return 0;
112 
113  /* Retrieve three components from their factories */
114  pckt1 = CrFwPcktMake(100);
115  CrFwPcktSetServType(pckt1,5);
116  CrFwPcktSetServSubType(pckt1,1);
117  CrFwPcktSetDiscriminant(pckt1,1);
118  pckt2 = CrFwPcktMake(100);
119  CrFwPcktSetServType(pckt2,5);
120  CrFwPcktSetServSubType(pckt2,1);
121  CrFwPcktSetDiscriminant(pckt2,1);
122  pckt3 = CrFwPcktMake(100);
123  CrFwPcktSetServType(pckt3,8);
124  CrFwPcktSetServSubType(pckt3,1);
125  CrFwPcktSetDiscriminant(pckt3,1);
126  inRep1 = CrFwInFactoryMakeInRep(pckt1);
127  inRep2 = CrFwInFactoryMakeInRep(pckt2);
128  inCmd3 = CrFwInFactoryMakeInCmd(pckt3);
129 
133 
134  cmpData = (CrFwCmpData_t*)FwSmGetData(inRep1);
136  return 0;
137  cmpData = (CrFwCmpData_t*)FwSmGetData(inRep2);
139  return 0;
140  cmpData = (CrFwCmpData_t*)FwSmGetData(inCmd3);
142  return 0;
143 
147 
148  cmpData = (CrFwCmpData_t*)FwSmGetData(inRep1);
150  return 0;
151  cmpData = (CrFwCmpData_t*)FwSmGetData(inRep2);
153  return 0;
154  cmpData = (CrFwCmpData_t*)FwSmGetData(inCmd3);
156  return 0;
157 
158  for (i=0; i<CR_FW_INREGISTRY_N; i++) {
160  pckt1 = CrFwPcktMake(100);
161  CrFwPcktSetServType(pckt1,5);
162  CrFwPcktSetServSubType(pckt1,1);
163  CrFwPcktSetDiscriminant(pckt1,1);
164  inRep1 = CrFwInFactoryMakeInRep(pckt1);
166  }
167 
169 
170  cmpData = (CrFwCmpData_t*)FwSmGetData(inRep1);
172  return 0;
173  cmpData = (CrFwCmpData_t*)FwSmGetData(inRep2);
175  return 0;
176  cmpData = (CrFwCmpData_t*)FwSmGetData(inCmd3);
178  return 0;
179 
180  /* Release all reports and commands */
184 
185  /* Check that there are no allocated packets */
186  if (CrFwPcktGetNOfAllocated() != 0)
187  return 0;
188 
189  /* Check application errors */
190  if (CrFwGetAppErrCode() != crNoAppErr)
191  return 0;
192 
193  return 1;
194 }
195 
196 /*--------------------------------------------------------------------------------*/
198  FwSmDesc_t inRegistry, inFactory, inRep1, inRep2, inCmd3;
199  CrFwPckt_t pckt1, pckt2, pckt3;
200  CrFwCmpData_t* cmpData;
201 
202  /* Instantiate the InRegistry */
204  if (inRegistry == NULL)
205  return 0;
206 
207  /* Initialize and configure InRegistry */
211  return 0;
212 
213  /* Instantiate the InFactory */
215  if (inFactory == NULL)
216  return 0;
217 
218  /* Initialize and configure factories */
222  return 0;
223 
224  /* Retrieve three OutComponents from the OutFactory (see CrFwInRegistryUserPar.h and CrFwOutFactoryUserPar.h) */
225  pckt1 = CrFwPcktMake(100);
226  CrFwPcktSetServType(pckt1,5);
227  CrFwPcktSetServSubType(pckt1,1);
228  CrFwPcktSetDiscriminant(pckt1,1);
229  pckt2 = CrFwPcktMake(100);
230  CrFwPcktSetServType(pckt2,5);
231  CrFwPcktSetServSubType(pckt2,1);
232  CrFwPcktSetDiscriminant(pckt2,1);
233  pckt3 = CrFwPcktMake(100);
234  CrFwPcktSetServType(pckt3,8);
235  CrFwPcktSetServSubType(pckt3,1);
236  CrFwPcktSetDiscriminant(pckt3,1);
237  inRep1 = CrFwInFactoryMakeInRep(pckt1);
238  inRep2 = CrFwInFactoryMakeInRep(pckt2);
239  inCmd3 = CrFwInFactoryMakeInCmd(pckt3);
240 
244 
245  cmpData = (CrFwCmpData_t*)FwSmGetData(inRep1);
247  return 0;
248  cmpData = (CrFwCmpData_t*)FwSmGetData(inRep2);
250  return 0;
251  cmpData = (CrFwCmpData_t*)FwSmGetData(inCmd3);
253  return 0;
254 
255  /* Shutdown InRegistry and check success */
257  if (CrFwCmpIsStarted(inRegistry) == 1)
258  return 0;
259  cmpData = (CrFwCmpData_t*)FwSmGetData(inRep1);
261  return 0;
262  cmpData = (CrFwCmpData_t*)FwSmGetData(inRep2);
264  return 0;
265  cmpData = (CrFwCmpData_t*)FwSmGetData(inCmd3);
267  return 0;
268 
269  /* Release all reports and commands */
273 
274  /* Restart the InRegistry */
275  FwSmStart(inRegistry);
276 
277  /* Check that there are no allocated packets */
278  if (CrFwPcktGetNOfAllocated() != 0)
279  return 0;
280 
281  /* Check application errors */
282  if (CrFwGetAppErrCode() != crNoAppErr)
283  return 0;
284 
285  return 1;
286 }
287 
288 /*--------------------------------------------------------------------------------*/
290  FwSmDesc_t inRegistry, inFactory, inRep1, inRep2, inCmd3;
291  CrFwPckt_t pckt1, pckt2, pckt3;
292  CrFwCmpData_t* cmpData;
293 
294  /* Instantiate the InRegistry */
296  if (inRegistry == NULL)
297  return 0;
298 
299  /* Initialize and configure InRegistry */
303  return 0;
304 
305  /* Instantiate the InFactory */
307  if (inFactory == NULL)
308  return 0;
309 
310  /* Initialize and configure factories */
314  return 0;
315 
316  /* Retrieve three OutComponents from the OutFactory (see CrFwInRegistryUserPar.h and CrFwOutFactoryUserPar.h) */
317  pckt1 = CrFwPcktMake(100);
318  CrFwPcktSetServType(pckt1,5);
319  CrFwPcktSetServSubType(pckt1,1);
320  CrFwPcktSetDiscriminant(pckt1,1);
321  pckt2 = CrFwPcktMake(100);
322  CrFwPcktSetServType(pckt2,5);
323  CrFwPcktSetServSubType(pckt2,1);
324  CrFwPcktSetDiscriminant(pckt2,1);
325  pckt3 = CrFwPcktMake(100);
326  CrFwPcktSetServType(pckt3,8);
327  CrFwPcktSetServSubType(pckt3,1);
328  CrFwPcktSetDiscriminant(pckt3,1);
329  inRep1 = CrFwInFactoryMakeInRep(pckt1);
330  inRep2 = CrFwInFactoryMakeInRep(pckt2);
331  inCmd3 = CrFwInFactoryMakeInCmd(pckt3);
332 
336 
337  cmpData = (CrFwCmpData_t*)FwSmGetData(inRep1);
339  return 0;
340  cmpData = (CrFwCmpData_t*)FwSmGetData(inRep2);
342  return 0;
343  cmpData = (CrFwCmpData_t*)FwSmGetData(inCmd3);
345  return 0;
346 
347  /* Reset InRegistry and check success */
349  cmpData = (CrFwCmpData_t*)FwSmGetData(inRep1);
351  return 0;
352  cmpData = (CrFwCmpData_t*)FwSmGetData(inRep2);
354  return 0;
355  cmpData = (CrFwCmpData_t*)FwSmGetData(inCmd3);
357  return 0;
358 
359  /* Release all reports and commands */
363 
364  /* Check that there are no allocated packets */
365  if (CrFwPcktGetNOfAllocated() != 0)
366  return 0;
367 
368  /* Check application errors */
369  if (CrFwGetAppErrCode() != crNoAppErr)
370  return 0;
371 
372  return 1;
373 }
374 
CrFwBool_t CrFwCmpIsStarted(FwSmDesc_t smDesc)
Return true if the state machine of the argument component has been started.
Definition: CrFwBaseCmp.c:162
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
Definition of Base Component.
Definition of the Framework Component Data (FCD) Type.
#define CR_FW_INREGISTRY_TYPE
Type identifier for the OutRegistry 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
FwSmDesc_t CrFwInFactoryMakeInCmd(CrFwPckt_t pckt)
Make function for a component encapsulating an incoming command (InCommand).
void CrFwInFactoryReleaseInCmd(FwSmDesc_t inCmdInstance)
Release function for an InCommand.
void CrFwInFactoryReleaseInRep(FwSmDesc_t inRepInstance)
Release function for an InReport.
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.
static CrFwCmpData_t inRegistryData
The data for the InRegistry singleton.
void CrFwInRegistryUpdateState(FwSmDesc_t inCmp, CrFwInRegistryCmdRepState_t newState)
Ask the InRegistry to update the state of an incoming command or report.
FwSmDesc_t CrFwInRegistryMake()
Factory function for the singleton instance of the InRegistry.
static FwSmDesc_t inRegistry
The InRegistry singleton.
void CrFwInRegistryStartTracking(FwSmDesc_t inCmp)
Ask the InRegistry to start tracking an incoming command or report.
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.
@ crInRegistryNotTracked
Incoming command or report is not tracked.
@ crInRegistryTerminated
Incoming command or report has completed execution.
@ crInRegistryPending
Incoming command or report is pending (waiting to be sent)
CrFwBool_t CrFwInRegistryTestCase1()
Test the creation and configuration of the InRegistry singleton component.
CrFwBool_t CrFwInRegistryTestCase2()
Test the ability of the InRegistry to track the state of an incoming command or report.
CrFwBool_t CrFwInRegistryTestCase4()
Test the reset service of the InRegistry.
CrFwBool_t CrFwInRegistryTestCase3()
Test the shutdown service of the InRegistry.
Declaration of the test cases for the InRegistry Component (see CrFwInRegistry.h).
User-modifiable parameters for the InRegistry component (see CrFwInRegistry.h).
#define CR_FW_INREGISTRY_N
The maximum number of commands or reports which can be tracked by the InRegistry.
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
CrFwPckt_t CrFwPcktMake(CrFwPcktLength_t pcktLength)
Make function for command or report packets.
Definition: CrFwPckt.c:147
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.
@ crNoAppErr
No application errors have been detected.
CrFwAppErrCode_t CrFwGetAppErrCode()
Return the value of the application error code.
Definition of the utility functions for the CORDET Framework.
Type for the Framework Component Data (FCD).
Definition: CrFwCmpData.h:79
CrFwInstanceId_t instanceId
The instance identifier of the framework component.
Definition: CrFwCmpData.h:81
CrFwTypeId_t typeId
The type identifier of the framework component.
Definition: CrFwCmpData.h:83
P&P Software GmbH, Copyright 2012-2013, All Rights Reserved