FW Profile - C1 Implementation
FwSmMakeTest.c
Go to the documentation of this file.
1 
19 #include "FwSmMakeTest.h"
20 #include "FwSmCore.h"
21 #include "FwSmConfig.h"
22 #include "FwSmDCreate.h"
23 #include "FwSmSCreate.h"
24 #include "FwSmPrivate.h" /* Needed for direct creation and configuration */
25 #include <stdlib.h>
26 
40 
52 struct TestSmData* GetTestSmData(FwSmDesc_t smDesc);
53 
58 static void incrCnt1By1(FwSmDesc_t smDesc) {
59  struct TestSmData* smData = GetTestSmData(smDesc);
60  smData->counter_1++;
61  fwSm_logMarker[fwSm_logIndex] = smData->logBase + 1;
63  fwSm_logIndex++;
64 }
65 
70 static void incrCnt2By1(FwSmDesc_t smDesc) {
71  struct TestSmData* smData = GetTestSmData(smDesc);
72  smData->counter_2++;
73  fwSm_logMarker[fwSm_logIndex] = smData->logBase + 4;
75  fwSm_logIndex++;
76 }
77 
82 static void incrCnt1By2(FwSmDesc_t smDesc) {
83  struct TestSmData* smData = GetTestSmData(smDesc);
84  smData->counter_1 = smData->counter_1+2;
85  fwSm_logMarker[fwSm_logIndex] = smData->logBase + 2;
87  fwSm_logIndex++;
88 }
89 
94 static void incrCnt1By4(FwSmDesc_t smDesc) {
95  struct TestSmData* smData = GetTestSmData(smDesc);
96  smData->counter_1 = smData->counter_1+4;
97  fwSm_logMarker[fwSm_logIndex] = smData->logBase + 3;
99  fwSm_logIndex++;
100 }
101 
108 static void incrCnt1By8(FwSmDesc_t smDesc) {
109  struct TestSmData* smData = GetTestSmData(smDesc);
110  smData->counter_1 = smData->counter_1+8;
111  fwSm_logMarker[fwSm_logIndex] = smData->logBase + 3;
113  fwSm_logIndex++;
114 }
115 
123 static void assignExecCnt(FwSmDesc_t smDesc) {
124  struct TestSmData* smData = GetTestSmData(smDesc);
125  smData->counter_1 = FwSmGetExecCnt(smDesc);
126  smData->counter_2 = FwSmGetStateExecCnt(smDesc);
127  fwSm_logMarker[fwSm_logIndex] = smData->logBase + 20;
129  fwSm_logIndex++;
130 }
131 
137 static FwSmBool_t retFlag1(FwSmDesc_t smDesc) {
138  struct TestSmData* smData = GetTestSmData(smDesc);
139  return (smData->flag_1 == 1);
140 }
141 
147 static FwSmBool_t retFlag2(FwSmDesc_t smDesc) {
148  struct TestSmData* smData = GetTestSmData(smDesc);
149  return (smData->flag_2 == 1);
150 }
151 
157 static FwSmBool_t retFlag3(FwSmDesc_t smDesc) {
158  struct TestSmData* smData = GetTestSmData(smDesc);
159  return (smData->flag_3 == 1);
160 }
161 
168 static FwSmBool_t wait1Cycle(FwSmDesc_t smDesc) {
169  return (FwSmGetStateExecCnt(smDesc) == 1);
170 }
171 
178 static FwSmBool_t wait2Cycle(FwSmDesc_t smDesc) {
179  return (FwSmGetStateExecCnt(smDesc) == 2);
180 }
181 
188 static FwSmBool_t smExecCntEqual4(FwSmDesc_t smDesc) {
189  return (FwSmGetExecCnt(smDesc) == 4);
190 }
191 
198 static FwSmBool_t smExecCntSmallerThan4(FwSmDesc_t smDesc) {
199  return (FwSmGetExecCnt(smDesc) < 4);
200 }
201 
203  return (struct TestSmData*)FwSmGetData(smDesc);
204 }
205 
206 
207 /*-------------------------------------------------------------------------------------------------*/
209  const FwSmCounterS1_t nOfPStates = 1; /* number of proper states */
210  const FwSmCounterS1_t nOfCStates = 0; /* number of choice pseudo-states */
211  const FwSmCounterS1_t nOfTrans = 2; /* number of transitions */
212  const FwSmCounterS1_t nOfActions = 3; /* number of actions */
213  const FwSmCounterS1_t nOfGuards = 1; /* number of guards */
214  FwSmDesc_t p_sm;
215 
216  /* Create the state machine */
217  p_sm = FwSmCreate(nOfPStates, nOfCStates, nOfTrans, nOfActions, nOfGuards);
218 
219  /* Configure the state machine */
220  FwSmSetData(p_sm, smData);
221  FwSmAddState(p_sm, STATE_S1, 1, &incrCnt1By1, NULL, &incrCnt1By2, NULL);
222  FwSmAddTransIpsToSta(p_sm, STATE_S1, &incrCnt2By1);
223  FwSmAddTransStaToFps(p_sm, TR_S1_FPS, STATE_S1, &incrCnt2By1, &retFlag1);
224  return p_sm;
225 }
226 
227 /*-------------------------------------------------------------------------------------------------*/
229 
230  /* Create the state machine */
231  FW_SM_INST_NOCPS(smDesc, 1, 2, 3, 1)
232  FwSmInit(&smDesc);
233 
234  /* Configure the state machine */
235  FwSmSetData(&smDesc, smData);
236  FwSmAddState(&smDesc, STATE_S1, 1, &incrCnt1By1, NULL, &incrCnt1By2, NULL);
237  FwSmAddTransIpsToSta(&smDesc, STATE_S1, &incrCnt2By1);
238  FwSmAddTransStaToFps(&smDesc, TR_S1_FPS, STATE_S1, &incrCnt2By1, &retFlag1);
239  return &smDesc;
240 }
241 
242 /*-------------------------------------------------------------------------------------------------*/
244  const FwSmCounterS1_t nOfPStates = 1; /* number of proper states */
245  const FwSmCounterS1_t nOfCStates = 1; /* number of choice pseudo-states */
246  const FwSmCounterS1_t nOfTrans = 4; /* number of transitions */
247  const FwSmCounterS1_t nOfActions = 4; /* number of actions */
248  const FwSmCounterS1_t nOfGuards = 2; /* number of guards */
249  FwSmDesc_t p_sm;
250 
251  /* Create the state machine */
252  p_sm = FwSmCreate(nOfPStates, nOfCStates, nOfTrans, nOfActions, nOfGuards);
253 
254  /* Configure the state machine */
255  FwSmSetData(p_sm, smData);
256  FwSmAddState(p_sm, STATE_S1, 1, &incrCnt1By1, &incrCnt1By4, &incrCnt1By2, NULL);
257  FwSmAddChoicePseudoState(p_sm, CPS1, 2);
258  FwSmAddTransIpsToCps(p_sm, CPS1, &incrCnt2By1);
259  FwSmAddTransCpsToSta(p_sm, CPS1, STATE_S1, &incrCnt2By1, &retFlag1);
260  FwSmAddTransCpsToFps(p_sm, CPS1, &incrCnt2By1, &retFlag2);
261  FwSmAddTransStaToFps(p_sm, TR_S1_FPS, STATE_S1, &incrCnt2By1, &retFlag2);
262  return p_sm;
263 }
264 
265 /*-------------------------------------------------------------------------------------------------*/
266 FwSmDesc_t FwSmMakeTestSM3(struct TestSmData* smData, struct TestSmData* esmData) {
267  const FwSmCounterS1_t nOfPStates = 1; /* number of proper states */
268  const FwSmCounterS1_t nOfCStates = 0; /* number of choice pseudo-states */
269  const FwSmCounterS1_t nOfTrans = 2; /* number of transitions */
270  const FwSmCounterS1_t nOfActions = 3; /* number of actions */
271  const FwSmCounterS1_t nOfGuards = 1; /* number of guards */
272  FwSmDesc_t p_sm;
273  FwSmDesc_t p_esm;
274 
275  /* Create and configure the embedded state machine (the state machine is initially
276  * configured without any data; its data are added to the state machine separately)
277  */
278  p_esm = FwSmMakeTestSM2(NULL);
279 
280  /* Create the embedding state machine */
281  p_sm = FwSmCreate(nOfPStates, nOfCStates, nOfTrans, nOfActions, nOfGuards);
282 
283  /* Configure the state machine */
284  FwSmSetData(p_sm, smData);
285  FwSmAddState(p_sm, STATE_S1, 1, &incrCnt1By1, NULL, &incrCnt1By2, p_esm);
286  FwSmAddTransIpsToSta(p_sm, STATE_S1, &incrCnt2By1);
287  FwSmAddTransStaToFps(p_sm, TR_S1_FPS, STATE_S1, &incrCnt2By1, &retFlag1);
288 
289  /* Set the data for the embedded state machine */
290  FwSmSetData(p_esm, esmData);
291 
292  return p_sm;
293 }
294 
295 /*-------------------------------------------------------------------------------------------------*/
297  const FwSmCounterS1_t nOfPStates = 2; /* number of proper states */
298  const FwSmCounterS1_t nOfCStates = 0; /* number of choice pseudo-states */
299  const FwSmCounterS1_t nOfTrans = 6; /* number of transitions */
300  const FwSmCounterS1_t nOfActions = 4; /* number of actions */
301  const FwSmCounterS1_t nOfGuards = 1; /* number of guards */
302  FwSmDesc_t p_sm;
303 
304  /* Create the state machine */
305  p_sm = FwSmCreate(nOfPStates, nOfCStates, nOfTrans, nOfActions, nOfGuards);
306 
307  /* Configure the state machine */
308  FwSmSetData(p_sm, smData);
309  FwSmAddState(p_sm, STATE_S1, 1, &incrCnt1By1, &incrCnt1By4, &incrCnt1By2, NULL);
310  FwSmAddState(p_sm, STATE_S2, 4, &incrCnt1By1, &incrCnt1By4, &incrCnt1By2, NULL);
311  FwSmAddTransIpsToSta(p_sm, STATE_S1, &incrCnt2By1);
312  FwSmAddTransStaToSta(p_sm, FW_TR_EXECUTE, STATE_S1, STATE_S2, &incrCnt2By1, &retFlag1);
313  FwSmAddTransStaToSta(p_sm, FW_TR_EXECUTE, STATE_S2, STATE_S1, &incrCnt2By1, &retFlag1);
314  FwSmAddTransStaToSta(p_sm, TR6, STATE_S2, STATE_S1, &incrCnt2By1, &retFlag1);
315  FwSmAddTransStaToFps(p_sm, TR3, STATE_S2, &incrCnt2By1, &retFlag1);
316  FwSmAddTransStaToSta(p_sm, TR4, STATE_S2, STATE_S2, &incrCnt2By1, &retFlag1);
317  return p_sm;
318 }
319 
320 /*-------------------------------------------------------------------------------------------------*/
322  const FwSmCounterS1_t nOfPStates = 2; /* number of proper states */
323  const FwSmCounterS1_t nOfCStates = 1; /* number of choice pseudo-states */
324  const FwSmCounterS1_t nOfTrans = 7; /* number of transitions */
325  const FwSmCounterS1_t nOfActions = 4; /* number of actions */
326  const FwSmCounterS1_t nOfGuards = 2; /* number of guards */
327  FwSmDesc_t smDesc;
328 
329  /* Create the state machine */
330  smDesc = FwSmCreate(nOfPStates, nOfCStates, nOfTrans, nOfActions, nOfGuards);
331 
332  /* Configure the state machine */
333  FwSmSetData(smDesc, smData);
334  FwSmAddState(smDesc, STATE_S1, 1, &incrCnt1By1, &incrCnt1By4, &incrCnt1By2, NULL);
335  FwSmAddState(smDesc, STATE_S2, 3, &incrCnt1By1, &incrCnt1By4, &incrCnt1By2, NULL);
336  FwSmAddChoicePseudoState(smDesc, CPS1, 2);
337  FwSmAddTransIpsToSta(smDesc, STATE_S1, &incrCnt2By1);
338  FwSmAddTransStaToSta(smDesc, TR2, STATE_S1, STATE_S2, &incrCnt2By1, &retFlag1);
339  FwSmAddTransStaToCps(smDesc, TR6, STATE_S2, CPS1, &incrCnt2By1, NULL);
340  FwSmAddTransCpsToSta(smDesc, CPS1, STATE_S1, &incrCnt2By1, &retFlag1);
341  FwSmAddTransCpsToSta(smDesc, CPS1, STATE_S2, &incrCnt2By1, &retFlag2);
342  FwSmAddTransStaToFps(smDesc, TR5, STATE_S2, &incrCnt2By1, &retFlag1);
343  FwSmAddTransStaToSta(smDesc, TR4, STATE_S2, STATE_S2, &incrCnt2By1, &retFlag1);
344  return smDesc;
345 }
346 
347 /*-------------------------------------------------------------------------------------------------*/
349 
350  /* Create the state machine */
351  FW_SM_INST(smDesc, 2, 1, 7, 4, 2)
352  FwSmInit(&smDesc);
353 
354  /* Configure the state machine */
355  FwSmSetData(&smDesc, smData);
356  FwSmAddState(&smDesc, STATE_S1, 1, &incrCnt1By1, &incrCnt1By4, &incrCnt1By2, NULL);
357  FwSmAddState(&smDesc, STATE_S2, 3, &incrCnt1By1, &incrCnt1By4, &incrCnt1By2, NULL);
358  FwSmAddChoicePseudoState(&smDesc, CPS1, 2);
359  FwSmAddTransIpsToSta(&smDesc, STATE_S1, &incrCnt2By1);
360  FwSmAddTransStaToSta(&smDesc, TR2, STATE_S1, STATE_S2, &incrCnt2By1, &retFlag1);
361  FwSmAddTransStaToCps(&smDesc, TR6, STATE_S2, CPS1, &incrCnt2By1, NULL);
362  FwSmAddTransCpsToSta(&smDesc, CPS1, STATE_S1, &incrCnt2By1, &retFlag1);
363  FwSmAddTransCpsToSta(&smDesc, CPS1, STATE_S2, &incrCnt2By1, &retFlag2);
364  FwSmAddTransStaToFps(&smDesc, TR5, STATE_S2, &incrCnt2By1, &retFlag1);
365  FwSmAddTransStaToSta(&smDesc, TR4, STATE_S2, STATE_S2, &incrCnt2By1, &retFlag1);
366  return &smDesc;
367 }
368 
369 /*-------------------------------------------------------------------------------------------------*/
371 
372  static SmTrans_t trans[7];
373  static FwSmAction_t actions[5];
374  static FwSmGuard_t guards[3];
375  static SmPState_t pStates[2];
376  static SmCState_t cStates[1];
377  static FwSmDesc_t esmDesc[2];
378  static struct FwSmDesc smDesc;
379  static SmBaseDesc_t smBase;
380 
381  /* Configure the array of state machine actions */
382  actions[0] = &SmDummyAction;
383  actions[1] = &incrCnt1By1;
384  actions[2] = &incrCnt1By2;
385  actions[3] = &incrCnt1By4;
386  actions[4] = &incrCnt2By1;
387 
388  /* Configure the array of state machine guards */
389  guards[0] = &SmDummyGuard;
390  guards[1] = &retFlag1;
391  guards[2] = &retFlag2;
392 
393  /* Configure the array of embedded state machines */
394  esmDesc[0] = NULL;
395  esmDesc[1] = NULL;
396 
397  /* Configure the array of proper states */
398  pStates[0].outTransIndex = 1;
399  pStates[0].nOfOutTrans = 1;
400  pStates[0].iEntryAction = 1;
401  pStates[0].iDoAction = 2;
402  pStates[0].iExitAction = 3;
403 
404  pStates[1].outTransIndex = 2;
405  pStates[1].nOfOutTrans = 3;
406  pStates[1].iEntryAction = 1;
407  pStates[1].iDoAction = 2;
408  pStates[1].iExitAction = 3;
409 
410  /* Configure the array of choice pseudo-states */
411  cStates[0].outTransIndex = 5;
412  cStates[0].nOfOutTrans = 2;
413 
414  /* Configure the array of transitions */
415  trans[0].dest = STATE_S1;
416  trans[0].id = 0;
417  trans[0].iTrAction = 4;
418  trans[0].iTrGuard = 0;
419 
420  trans[1].dest = STATE_S2;
421  trans[1].id = TR2;
422  trans[1].iTrAction = 4;
423  trans[1].iTrGuard = 1;
424 
425  trans[2].dest = -CPS1;
426  trans[2].id = TR6;
427  trans[2].iTrAction = 4;
428  trans[2].iTrGuard = 0;
429 
430  trans[3].dest = 0;
431  trans[3].id = TR5;
432  trans[3].iTrAction = 4;
433  trans[3].iTrGuard = 1;
434 
435  trans[4].dest = STATE_S2;
436  trans[4].id = TR4;
437  trans[4].iTrAction = 4;
438  trans[4].iTrGuard = 1;
439 
440  trans[5].dest = STATE_S1;
441  trans[5].id = 0;
442  trans[5].iTrAction = 4;
443  trans[5].iTrGuard = 1;
444 
445  trans[6].dest = STATE_S2;
446  trans[6].id = 0;
447  trans[6].iTrAction = 4;
448  trans[6].iTrGuard = 2;
449 
450  /* Configure the SM Descriptor */
451  smBase.pStates = pStates;
452  smBase.cStates = cStates;
453  smBase.trans = trans;
454  smBase.nOfPStates = 2;
455  smBase.nOfCStates = 1;
456  smBase.nOfTrans = 7;
457  smDesc.smBase = &smBase;
458  smDesc.transCnt = 0;
459  smDesc.curState = 0;
460  smDesc.smData = NULL;
461  smDesc.nOfActions = 5;
462  smDesc.nOfGuards = 3;
463  smDesc.smActions = actions;
464  smDesc.smGuards = guards;
465  smDesc.esmDesc = esmDesc;
466  smDesc.smExecCnt = 0;
467  smDesc.stateExecCnt = 0;
468  smDesc.errCode = smSuccess;
469  smDesc.smData = smData;
470 
471  return &smDesc;
472 }
473 
474 /*-------------------------------------------------------------------------------------------------*/
475 FwSmDesc_t FwSmMakeTestSM6(struct TestSmData* smData, struct TestSmData* esmData) {
476  const FwSmCounterS1_t nOfPStates = 2; /* number of proper states */
477  const FwSmCounterS1_t nOfCStates = 0; /* number of choice pseudo-states */
478  const FwSmCounterS1_t nOfTrans = 6; /* number of transitions */
479  const FwSmCounterS1_t nOfActions = 4; /* number of actions */
480  const FwSmCounterS1_t nOfGuards = 1; /* number of guards */
481  FwSmDesc_t p_sm;
482  FwSmDesc_t p_esm;
483 
484  /* Create and configure the embedded state machine */
485  p_esm = FwSmMakeTestSM5(esmData);
486 
487  /* Create the embedding state machine */
488  p_sm = FwSmCreate(nOfPStates, nOfCStates, nOfTrans, nOfActions, nOfGuards);
489 
490  /* Configure the state machine */
491  FwSmSetData(p_sm, smData);
492  FwSmAddState(p_sm, STATE_S1, 1, &incrCnt1By1, &incrCnt1By4, &incrCnt1By2, NULL);
493  FwSmAddState(p_sm, STATE_S2, 4, &incrCnt1By1, &incrCnt1By4, &incrCnt1By2, p_esm);
494  FwSmAddTransIpsToSta(p_sm, STATE_S1, &incrCnt2By1);
495  FwSmAddTransStaToSta(p_sm, FW_TR_EXECUTE, STATE_S1, STATE_S2, &incrCnt2By1, &retFlag1);
496  FwSmAddTransStaToSta(p_sm, FW_TR_EXECUTE, STATE_S2, STATE_S1, &incrCnt2By1, &retFlag1);
497  FwSmAddTransStaToSta(p_sm, TR6, STATE_S2, STATE_S1, &incrCnt2By1, &retFlag1);
498  FwSmAddTransStaToFps(p_sm, TR3, STATE_S2, &incrCnt2By1, &retFlag1);
499  FwSmAddTransStaToSta(p_sm, TR4, STATE_S2, STATE_S2, &incrCnt2By1, &retFlag1);
500  return p_sm;
501 }
502 
503 /*-------------------------------------------------------------------------------------------------*/
505  const FwSmCounterS1_t nOfPStates = 1; /* number of proper states */
506  const FwSmCounterS1_t nOfCStates = 1; /* number of choice pseudo-states */
507  const FwSmCounterS1_t nOfTrans = 4; /* number of transitions */
508  const FwSmCounterS1_t nOfActions = 3; /* number of actions */
509  const FwSmCounterS1_t nOfGuards = 2; /* number of guards */
510  FwSmDesc_t p_sm;
511 
512  /* Create the state machine */
513  p_sm = FwSmCreate(nOfPStates, nOfCStates, nOfTrans, nOfActions, nOfGuards);
514 
515  /* Configure the state machine */
516  FwSmSetData(p_sm, smData);
517  FwSmAddState(p_sm, STATE_S1, 1, NULL, &incrCnt1By4, &incrCnt1By2, NULL);
518  FwSmAddChoicePseudoState(p_sm, CPS1, 2);
519  FwSmAddTransIpsToSta(p_sm, STATE_S1, &incrCnt2By1);
520  FwSmAddTransStaToCps(p_sm, TR1, STATE_S1, CPS1, &incrCnt2By1, NULL);
521  FwSmAddTransCpsToSta(p_sm, CPS1, STATE_S1, &incrCnt2By1, &retFlag1);
522  FwSmAddTransCpsToFps(p_sm, CPS1, &incrCnt2By1, &retFlag2);
523  return p_sm;
524 }
525 
526 /*-------------------------------------------------------------------------------------------------*/
528  const FwSmCounterS1_t nOfPStates = 0; /* number of proper states */
529  const FwSmCounterS1_t nOfCStates = 1; /* number of choice pseudo-states */
530  const FwSmCounterS1_t nOfTrans = 3; /* number of transitions */
531  const FwSmCounterS1_t nOfActions = 1; /* number of actions */
532  const FwSmCounterS1_t nOfGuards = 2; /* number of guards */
533  FwSmDesc_t p_sm;
534 
535  /* Create the state machine */
536  p_sm = FwSmCreate(nOfPStates, nOfCStates, nOfTrans, nOfActions, nOfGuards);
537 
538  /* Configure the state machine */
539  FwSmSetData(p_sm, smData);
540  FwSmAddChoicePseudoState(p_sm, CPS1, 2);
541  FwSmAddTransIpsToCps(p_sm, CPS1, &incrCnt2By1);
542  FwSmAddTransCpsToFps(p_sm, CPS1, &incrCnt2By1, &retFlag1);
543  FwSmAddTransCpsToFps(p_sm, CPS1, &incrCnt2By1, &retFlag2);
544  return p_sm;
545 }
546 
547 /*-------------------------------------------------------------------------------------------------*/
549  const FwSmCounterS1_t nOfPStates = 1; /* number of proper states */
550  const FwSmCounterS1_t nOfCStates = 0; /* number of choice pseudo-states */
551  const FwSmCounterS1_t nOfTrans = 1; /* number of transitions */
552  const FwSmCounterS1_t nOfActions = 4; /* number of actions */
553  const FwSmCounterS1_t nOfGuards = 0; /* number of guards */
554  FwSmDesc_t p_sm;
555 
556  /* Create the state machine */
557  p_sm = FwSmCreate(nOfPStates, nOfCStates, nOfTrans, nOfActions, nOfGuards);
558 
559  /* Configure the state machine */
560  FwSmSetData(p_sm, smData);
561  FwSmAddState(p_sm, STATE_S1, 0, &incrCnt1By1, &incrCnt1By4, &incrCnt1By2, NULL);
562  FwSmAddTransIpsToSta(p_sm, STATE_S1, &incrCnt2By1);
563  return p_sm;
564 }
565 
566 /*-------------------------------------------------------------------------------------------------*/
568 
569  /* Create the state machine */
570  FW_SM_INST_NOCPS(smDesc, 1, 1, 4, 0)
571  FwSmInit(&smDesc);
572 
573  /* Configure the state machine */
574  FwSmSetData(&smDesc, smData);
575  FwSmAddState(&smDesc, STATE_S1, 0, &incrCnt1By1, &incrCnt1By4, &incrCnt1By2, NULL);
576  FwSmAddTransIpsToSta(&smDesc, STATE_S1, &incrCnt2By1);
577  return &smDesc;
578 }
579 
580 /*-------------------------------------------------------------------------------------------------*/
581 FwSmDesc_t FwSmMakeTestSM10(struct TestSmData* smData, struct TestSmData* esmData) {
582  const FwSmCounterS1_t nOfPStates = 2; /* number of proper states */
583  const FwSmCounterS1_t nOfCStates = 1; /* number of choice pseudo-states */
584  const FwSmCounterS1_t nOfTrans = 4; /* number of transitions */
585  const FwSmCounterS1_t nOfActions = 3; /* number of actions */
586  const FwSmCounterS1_t nOfGuards = 2; /* number of guards */
587  FwSmDesc_t p_sm;
588  FwSmDesc_t p_esm;
589 
590  /* Create SM to be embedded in state S1 */
591  p_esm = FwSmMakeTestSM1(esmData);
592  if (p_esm==NULL)
593  return NULL;
594 
595  /* Create the state machine */
596  p_sm = FwSmCreate(nOfPStates, nOfCStates, nOfTrans, nOfActions, nOfGuards);
597 
598  /* Configure the state machine */
599  FwSmSetData(p_sm, smData);
600  FwSmAddState(p_sm, STATE_S1, 1, &incrCnt1By1, &incrCnt1By4, NULL, NULL);
601  FwSmAddState(p_sm, STATE_S2, 0, &incrCnt1By1, &incrCnt1By4, NULL, p_esm);
602  FwSmAddChoicePseudoState(p_sm, CPS1, 2);
603  FwSmAddTransIpsToSta(p_sm, STATE_S1, &incrCnt2By1);
604  FwSmAddTransStaToCps(p_sm, TR1, STATE_S1, CPS1, &incrCnt2By1, NULL);
605  FwSmAddTransCpsToSta(p_sm, CPS1, STATE_S2, &incrCnt2By1, &retFlag1);
606  FwSmAddTransCpsToFps(p_sm, CPS1, &incrCnt2By1, &retFlag2);
607  return p_sm;
608 }
609 
610 /*-------------------------------------------------------------------------------------------------*/
612 
613  static SmTrans_t trans[1];
614  static FwSmAction_t actions[2];
615  static FwSmGuard_t guards[1];
616 
617  actions[0] = &SmDummyAction;
618  actions[1] = &incrCnt2By1;
619 
620  guards[0] = &SmDummyGuard;
621 
622  trans[0].dest = 0;
623  trans[0].id = 0;
624  trans[0].iTrAction = 1;
625  trans[0].iTrGuard = 0;
626 
627  static struct FwSmDesc smDesc;
628  static SmBaseDesc_t smBase;
629 
630  smBase.pStates = NULL;
631  smBase.cStates = NULL;
632  smBase.trans = trans;
633  smBase.nOfPStates = 0;
634  smBase.nOfCStates = 0;
635  smBase.nOfTrans = 1;
636  smDesc.transCnt = 0;
637  smDesc.smBase = &smBase;
638  smDesc.curState = 0;
639  smDesc.smData = NULL;
640  smDesc.nOfActions = 2;
641  smDesc.nOfGuards = 1;
642  smDesc.smActions = actions;
643  smDesc.smGuards = guards;
644  smDesc.esmDesc = NULL;
645  smDesc.errCode = smSuccess;
646  smDesc.smData = smData;
647 
648  return &smDesc;
649 }
650 
651 /*-------------------------------------------------------------------------------------------------*/
653  const FwSmCounterS1_t nOfPStates = 1; /* number of proper states */
654  const FwSmCounterS1_t nOfCStates = 1; /* number of choice pseudo-states */
655  const FwSmCounterS1_t nOfTrans = 4; /* number of transitions */
656  const FwSmCounterS1_t nOfActions = 4; /* number of actions */
657  const FwSmCounterS1_t nOfGuards = 2; /* number of guards */
658  FwSmDesc_t p_sm;
659 
660  /* Create the state machine */
661  p_sm = FwSmCreate(nOfPStates, nOfCStates, nOfTrans, nOfActions, nOfGuards);
662 
663  /* Configure the state machine */
664  FwSmSetData(p_sm, smData);
665  FwSmAddState(p_sm, STATE_S1, 1, &incrCnt1By1, &incrCnt1By4, &incrCnt1By2, NULL);
666  FwSmAddChoicePseudoState(p_sm, CPS1, 2);
667  FwSmAddTransIpsToCps(p_sm, CPS1, &incrCnt2By1);
668  FwSmAddTransCpsToSta(p_sm, CPS1, STATE_S1, &incrCnt2By1, &retFlag1);
669  FwSmAddTransCpsToFps(p_sm, CPS1, &incrCnt2By1, &retFlag2);
670  FwSmAddTransStaToFps(p_sm, TR_S1_FPS, STATE_S1, &incrCnt2By1, &retFlag2);
671 
672  /* Modify first transition out of CPS1 to terminate in CPS1 */
673  p_sm->smBase->trans[2].dest = -CPS1;
674 
675  return p_sm;
676 }
677 
678 /*-------------------------------------------------------------------------------------------------*/
680  const FwSmCounterS1_t nOfPStates = 1; /* number of proper states */
681  const FwSmCounterS1_t nOfCStates = 1; /* number of choice pseudo-states */
682  const FwSmCounterS1_t nOfTrans = 5; /* number of transitions */
683  const FwSmCounterS1_t nOfActions = 3; /* number of actions */
684  const FwSmCounterS1_t nOfGuards = 2; /* number of guards */
685  FwSmDesc_t p_sm;
686 
687  /* Create the state machine */
688  p_sm = FwSmCreate(nOfPStates, nOfCStates, nOfTrans, nOfActions, nOfGuards);
689 
690  /* Configure the state machine */
691  FwSmSetData(p_sm, smData);
692  FwSmAddState(p_sm, STATE_S1, 2, &incrCnt1By1, &incrCnt1By4, &incrCnt1By2, NULL);
693  FwSmAddChoicePseudoState(p_sm, CPS1, 2);
694  FwSmAddTransIpsToSta(p_sm, STATE_S1, NULL);
695  FwSmAddTransStaToCps(p_sm, FW_TR_EXECUTE, STATE_S1, CPS1, NULL, &retFlag1);
696  FwSmAddTransCpsToSta(p_sm, CPS1, STATE_S1, NULL, &retFlag1);
697  FwSmAddTransCpsToFps(p_sm, CPS1, NULL, &retFlag2);
698  FwSmAddTransStaToFps(p_sm, FW_TR_EXECUTE, STATE_S1, NULL, &retFlag2);
699 
700  return p_sm;
701 }
702 
703 /*-------------------------------------------------------------------------------------------------*/
705  const FwSmCounterS1_t nOfPStates = 2; /* number of proper states */
706  const FwSmCounterS1_t nOfCStates = 2; /* number of choice pseudo-states */
707  const FwSmCounterS1_t nOfTrans = 6; /* number of transitions */
708  const FwSmCounterS1_t nOfActions = 1; /* number of actions */
709  const FwSmCounterS1_t nOfGuards = 2; /* number of guards */
710  FwSmDesc_t p_sm;
711 
712  /* Create the state machine */
713  p_sm = FwSmCreate(nOfPStates, nOfCStates, nOfTrans, nOfActions, nOfGuards);
714 
715  /* Configure the state machine */
716  FwSmSetData(p_sm, smData);
717  FwSmAddState(p_sm, STATE_S1, 1, NULL, NULL, NULL, NULL);
718  FwSmAddState(p_sm, STATE_S2, 1, NULL, NULL, NULL, NULL);
719  FwSmAddChoicePseudoState(p_sm, CPS1, 2);
720  FwSmAddChoicePseudoState(p_sm, CPS2, 1);
721  FwSmAddTransIpsToCps(p_sm, CPS1, &incrCnt2By1);
722  FwSmAddTransCpsToSta(p_sm, CPS1, STATE_S1, &incrCnt2By1, &retFlag1);
723  FwSmAddTransCpsToSta(p_sm, CPS1, STATE_S2, &incrCnt2By1, &retFlag2);
724  FwSmAddTransStaToCps(p_sm, TR1, STATE_S1, CPS2, &incrCnt2By1, NULL);
725  FwSmAddTransStaToCps(p_sm, TR2, STATE_S2, CPS2, &incrCnt2By1, NULL);
726  FwSmAddTransCpsToFps(p_sm, CPS2, &incrCnt2By1, NULL);
727 
728  return p_sm;
729 }
730 
731 /*-------------------------------------------------------------------------------------------------*/
733  const FwSmCounterS1_t nOfPStates = 2; /* number of proper states */
734  const FwSmCounterS1_t nOfCStates = 1; /* number of choice pseudo-states */
735  const FwSmCounterS1_t nOfTrans = 5; /* number of transitions */
736  const FwSmCounterS1_t nOfActions = 1; /* number of actions */
737  const FwSmCounterS1_t nOfGuards = 4; /* number of guards */
738  FwSmDesc_t p_sm;
739 
740  /* Create the state machine */
741  p_sm = FwSmCreate(nOfPStates, nOfCStates, nOfTrans, nOfActions, nOfGuards);
742 
743  /* Configure the state machine */
744  FwSmSetData(p_sm, smData);
745  FwSmAddState(p_sm, STATE_S1, 1, &assignExecCnt, NULL, NULL, NULL);
746  FwSmAddState(p_sm, STATE_S2, 1, &assignExecCnt, NULL, NULL, NULL);
747  FwSmAddChoicePseudoState(p_sm, CPS1, 2);
748  FwSmAddTransIpsToSta(p_sm, STATE_S1, NULL);
749  FwSmAddTransStaToCps(p_sm, FW_TR_EXECUTE, STATE_S1, CPS1, NULL, &wait1Cycle);
750  FwSmAddTransCpsToSta(p_sm, CPS1, STATE_S2, NULL, &smExecCntSmallerThan4);
751  FwSmAddTransCpsToFps(p_sm, CPS1, NULL, &smExecCntEqual4);
752  FwSmAddTransStaToSta(p_sm, TR1, STATE_S2, STATE_S1, NULL, &wait2Cycle);
753 
754  return p_sm;
755 }
756 
757 /*-------------------------------------------------------------------------------------------------*/
758 FwSmDesc_t FwSmMakeTestSMDer1(FwSmDesc_t smDescBase, struct TestSmData* smData) {
759  FwSmDesc_t p_sm;
760 
761  /* Create and configure the derived state machine */
762  p_sm = FwSmCreateDer(smDescBase);
763  FwSmOverrideAction(p_sm, &incrCnt1By1, &incrCnt1By8);
764  FwSmOverrideGuard(p_sm, &retFlag1, &retFlag2);
765  FwSmSetData(p_sm, smData);
766 
767  return p_sm;
768 }
769 
770 /*-------------------------------------------------------------------------------------------------*/
772 
773  /* Instantiate the derived state machine. The number of states, of actions and of guards
774  * of the derived state machine must be the same as number of states, of actions, and of
775  * guards of the base state machine.
776  */
777  FW_SM_INST_DER(smDescDer, 1, 3, 1)
778  FwSmDesc_t p_sm = &smDescDer;
779 
780  /* Initialize the derived state machine */
781  FwSmInitDer(p_sm, smDescBase);
782 
783  /* Configure the derived state machine */
784  FwSmOverrideAction(p_sm, &incrCnt1By1, &incrCnt1By8);
785  FwSmOverrideGuard(p_sm, &retFlag1, &retFlag2);
786  FwSmSetData(p_sm, smData);
787 
788  return p_sm;
789 }
790 
791 /*-------------------------------------------------------------------------------------------------*/
793  const FwSmCounterS1_t nOfPStates = 4; /* number of proper states */
794  const FwSmCounterS1_t nOfCStates = 1; /* number of choice pseudo-states */
795  const FwSmCounterS1_t nOfTrans = 8; /* number of transitions */
796  const FwSmCounterS1_t nOfActions = 0; /* number of actions */
797  const FwSmCounterS1_t nOfGuards = 3; /* number of guards */
798  FwSmDesc_t p_sm;
799 
800  /* Create the state machine */
801  p_sm = FwSmCreate(nOfPStates, nOfCStates, nOfTrans, nOfActions, nOfGuards);
802 
803  /* Configure the state machine */
804  FwSmSetData(p_sm, smData);
805  FwSmAddState(p_sm, STATE_S1, 4, NULL, NULL, NULL, NULL);
806  FwSmAddState(p_sm, STATE_S2, 0, NULL, NULL, NULL, NULL);
807  FwSmAddState(p_sm, STATE_S3, 0, NULL, NULL, NULL, NULL);
808  FwSmAddState(p_sm, STATE_S4, 0, NULL, NULL, NULL, NULL);
809  FwSmAddChoicePseudoState(p_sm, CPS1, 3);
810  FwSmAddTransIpsToSta(p_sm, STATE_S1, NULL);
811  FwSmAddTransStaToSta(p_sm, TR1, STATE_S1, STATE_S2, NULL, &retFlag1);
812  FwSmAddTransStaToSta(p_sm, TR1, STATE_S1, STATE_S3, NULL, &retFlag2);
813  FwSmAddTransStaToSta(p_sm, TR1, STATE_S1, STATE_S4, NULL, &retFlag3);
814  FwSmAddTransStaToCps(p_sm, TR2, STATE_S1, CPS1, NULL, NULL);
815  FwSmAddTransCpsToSta(p_sm, CPS1, STATE_S2, NULL, &retFlag1);
816  FwSmAddTransCpsToSta(p_sm, CPS1, STATE_S3, NULL, &retFlag2);
817  FwSmAddTransCpsToSta(p_sm, CPS1, STATE_S4, NULL, &retFlag3);
818 
819  return p_sm;
820 }
821 
822 /*-------------------------------------------------------------------------------------------------*/
824  const FwSmCounterS1_t nOfPStates = 4; /* number of proper states */
825  const FwSmCounterS1_t nOfCStates = 1; /* number of choice pseudo-states */
826  const FwSmCounterS1_t nOfTrans = 8; /* number of transitions */
827  const FwSmCounterS1_t nOfActions = 0; /* number of actions */
828  const FwSmCounterS1_t nOfGuards = 3; /* number of guards */
829  FwSmDesc_t p_sm;
830 
831  /* Create the state machine */
832  p_sm = FwSmCreate(nOfPStates, nOfCStates, nOfTrans, nOfActions, nOfGuards);
833 
834  /* Configure the state machine */
835  FwSmSetData(p_sm, smData);
836  FwSmAddState(p_sm, STATE_S1, 4, NULL, NULL, NULL, NULL);
837  FwSmAddState(p_sm, STATE_S2, 0, NULL, NULL, NULL, NULL);
838  FwSmAddState(p_sm, STATE_S3, 0, NULL, NULL, NULL, NULL);
839  FwSmAddState(p_sm, STATE_S4, 0, NULL, NULL, NULL, NULL);
840  FwSmAddChoicePseudoState(p_sm, CPS1, 3);
841  FwSmAddTransIpsToSta(p_sm, STATE_S1, NULL);
842  FwSmAddTransStaToSta(p_sm, TR1, STATE_S1, STATE_S4, NULL, &retFlag3);
843  FwSmAddTransStaToSta(p_sm, TR1, STATE_S1, STATE_S3, NULL, &retFlag2);
844  FwSmAddTransStaToSta(p_sm, TR1, STATE_S1, STATE_S2, NULL, &retFlag1);
845  FwSmAddTransStaToCps(p_sm, TR2, STATE_S1, CPS1, NULL, NULL);
846  FwSmAddTransCpsToSta(p_sm, CPS1, STATE_S4, NULL, &retFlag3);
847  FwSmAddTransCpsToSta(p_sm, CPS1, STATE_S3, NULL, &retFlag2);
848  FwSmAddTransCpsToSta(p_sm, CPS1, STATE_S2, NULL, &retFlag1);
849 
850  return p_sm;
851 }
852 
853 /*-------------------------------------------------------------------------------------------------*/
855  const FwSmCounterS1_t nOfPStates = 4; /* number of proper states */
856  const FwSmCounterS1_t nOfCStates = 1; /* number of choice pseudo-states */
857  const FwSmCounterS1_t nOfTrans = 8; /* number of transitions */
858  const FwSmCounterS1_t nOfActions = 0; /* number of actions */
859  const FwSmCounterS1_t nOfGuards = 3; /* number of guards */
860  FwSmDesc_t p_sm;
861 
862  /* Create the state machine */
863  p_sm = FwSmCreate(nOfPStates, nOfCStates, nOfTrans, nOfActions, nOfGuards);
864 
865  /* Configure the state machine */
866  FwSmSetData(p_sm, smData);
867  FwSmAddState(p_sm, STATE_S1, 4, NULL, NULL, NULL, NULL);
868  FwSmAddState(p_sm, STATE_S2, 0, NULL, NULL, NULL, NULL);
869  FwSmAddState(p_sm, STATE_S3, 0, NULL, NULL, NULL, NULL);
870  FwSmAddState(p_sm, STATE_S4, 0, NULL, NULL, NULL, NULL);
871  FwSmAddChoicePseudoState(p_sm, CPS1, 3);
872  FwSmAddTransIpsToSta(p_sm, STATE_S1, NULL);
873  FwSmAddTransStaToSta(p_sm, TR1, STATE_S1, STATE_S3, NULL, &retFlag2);
874  FwSmAddTransStaToSta(p_sm, TR1, STATE_S1, STATE_S4, NULL, &retFlag3);
875  FwSmAddTransStaToSta(p_sm, TR1, STATE_S1, STATE_S2, NULL, &retFlag1);
876  FwSmAddTransStaToCps(p_sm, TR2, STATE_S1, CPS1, NULL, NULL);
877  FwSmAddTransCpsToSta(p_sm, CPS1, STATE_S3, NULL, &retFlag2);
878  FwSmAddTransCpsToSta(p_sm, CPS1, STATE_S4, NULL, &retFlag3);
879  FwSmAddTransCpsToSta(p_sm, CPS1, STATE_S2, NULL, &retFlag1);
880 
881  return p_sm;
882 }
FwSmBool_t SmDummyGuard(FwSmDesc_t smDesc)
Dummy guard which always returns true.
Definition: FwSmCore.c:46
FwSmCounterS1_t curState
the current state of the state machine
Definition: FwSmPrivate.h:319
FwSmCounterS1_t outTransIndex
index of first out-going transition in transition array of SmBaseDesc_t
Definition: FwSmPrivate.h:151
void FwSmAddTransStaToSta(FwSmDesc_t smDesc, FwSmCounterU2_t transId, FwSmCounterS1_t srcId, FwSmCounterS1_t destId, FwSmAction_t trAction, FwSmGuard_t trGuard)
Create a transition from a proper state to a proper state and add it to a state machine.
Definition: FwSmConfig.c:191
FwSmDesc_t FwSmMakeTestSM16_1(struct TestSmData *smData)
Operation to create and configure a state machine to verify the order of evaluation of guards...
Definition: FwSmMakeTest.c:792
#define FW_TR_EXECUTE
Identifier of "Execute" transition in a state machine.
void * FwSmGetData(FwSmDesc_t smDesc)
Get the pointer to the state machine data in the state machine descriptor.
Definition: FwSmConfig.c:87
FwSmCounterS1_t dest
the index of the destination of the transition
Definition: FwSmPrivate.h:197
FwSmCounterS1_t nOfOutTrans
number of outgoing transitions from the choice pseudo-state
Definition: FwSmPrivate.h:153
FwSmCounterS1_t iTrGuard
the index of the guard associated to the transition
Definition: FwSmPrivate.h:203
#define LOG_ARRAY_SIZE
Size of the log arrays.
Definition: FwPrMakeTest.h:46
FwSmDesc_t FwSmMakeTestSM5(struct TestSmData *smData)
Operation to create and configure the state machine SM5.
Definition: FwSmMakeTest.c:321
#define TR1
A transition identifier.
Definition: FwSmMakeTest.h:56
Declaration of the dynamical creation interface for a FW State Machine.
void FwSmInit(FwSmDesc_t smDesc)
Initialize a state machine descriptor to represent an unconfigured state machine with no transitions...
Definition: FwSmSCreate.c:24
Declaration of the execution interface for a FW State Machine.
FwSmCounterS1_t nOfActions
the number of actions (state actions + transition actions) in the state machine
Definition: FwSmPrivate.h:313
#define CPS2
A choice pseudo-state identifier.
Definition: FwSmMakeTest.h:46
int flag_1
Flag checked by the transition guards.
Definition: FwSmMakeTest.h:107
FwSmDesc_t FwSmMakeTestSMDer1Static(FwSmDesc_t smDescBase, struct TestSmData *smData)
Create a derived state machine and override one of its actions and one of its guards.
Definition: FwSmMakeTest.c:771
Type for the state machine data for the test state machines.
Definition: FwSmMakeTest.h:101
FwSmAction_t * smActions
the state machine actions (state and transition actions)
Definition: FwSmPrivate.h:307
FwSmCounterS1_t iDoAction
the do action for the state
Definition: FwSmPrivate.h:129
FwSmDesc_t FwSmMakeTestSM12(struct TestSmData *smData)
Operation to create and configure a state machine where a transition has a choice pseudo-state as bot...
Definition: FwSmMakeTest.c:652
#define FW_SM_INST(SM_DESC, NS, NCPS, NTRANS, NA, NG)
Instantiate a state machine descriptor and its internal data structure.
Definition: FwSmSCreate.h:113
FwSmCounterU3_t FwSmGetExecCnt(FwSmDesc_t smDesc)
Return the State Machine Execution Counter.
Definition: FwSmCore.c:253
#define FW_SM_INST_DER(SM_DESC, NS, NA, NG)
Instantiate a descriptor for a derived state machine.
Definition: FwSmSCreate.h:231
struct TestSmData * GetTestSmData(FwSmDesc_t smDesc)
Get the pointer to the state machine data of a test state machine.
Definition: FwSmMakeTest.c:202
FwSmCounterU3_t FwSmGetStateExecCnt(FwSmDesc_t smDesc)
Return the State Execution Counter.
Definition: FwSmCore.c:258
int logBase
Offset for markers written to log array.
Definition: FwSmMakeTest.h:113
#define TR2
A transition identifier.
Definition: FwSmMakeTest.h:58
Declaration of the configuration interface for a FW State Machine.
int flag_2
Flag checked by the transition guards.
Definition: FwSmMakeTest.h:109
FwSmDesc_t FwSmCreate(FwSmCounterS1_t nOfStates, FwSmCounterS1_t nOfChoicePseudoStates, FwSmCounterS1_t nOfTrans, FwSmCounterS1_t nOfActions, FwSmCounterS1_t nOfGuards)
Create a new state machine descriptor.
Definition: FwSmDCreate.c:23
void FwSmAddTransStaToCps(FwSmDesc_t smDesc, FwSmCounterU2_t transId, FwSmCounterS1_t srcId, FwSmCounterS1_t destId, FwSmAction_t trAction, FwSmGuard_t trGuard)
Create a transition from a proper state to a choice pseudo-state and add it to a state machine...
Definition: FwSmConfig.c:197
Declaration of functions to create and configure test state machines.
FwSmDesc_t FwSmMakeTestSM7(struct TestSmData *smData)
Operation to create and configure the state machine SM7.
Definition: FwSmMakeTest.c:504
#define STATE_S4
A state identifier.
Definition: FwSmMakeTest.h:42
int fwSm_logMarker[LOG_ARRAY_SIZE]
Log array where the actions of the test state machines write their markers.
Definition: FwSmMakeTest.c:30
int flag_3
Flag checked by the transition guards.
Definition: FwSmMakeTest.h:111
FwSmCounterU2_t id
the identifier (the "name") of the transition
Definition: FwSmPrivate.h:199
void FwSmOverrideGuard(FwSmDesc_t smDesc, FwSmGuard_t oldGuard, FwSmGuard_t newGuard)
Override a guard in a derived state machine.
Definition: FwSmConfig.c:475
FwSmErrCode_t errCode
either &#39;success&#39; or the code of the last error encountered by the state machine
Definition: FwSmPrivate.h:325
#define FW_SM_INST_NOCPS(SM_DESC, NS, NTRANS, NA, NG)
Instantiate a state machine descriptor and its internal data structure.
Definition: FwSmSCreate.h:176
FwSmDesc_t FwSmMakeTestSM6(struct TestSmData *smData, struct TestSmData *esmData)
Operation to create and configure the state machine SM6.
Definition: FwSmMakeTest.c:475
void FwSmInitDer(FwSmDesc_t smDesc, FwSmDesc_t smDescBase)
Initialize a state machine descriptor to extend another state machine (the base state machine)...
Definition: FwSmSCreate.c:54
#define TR4
A transition identifier.
Definition: FwSmMakeTest.h:62
FwSmCounterS1_t outTransIndex
index of first out-going transition in the transition array of SmBaseDesc_t
Definition: FwSmPrivate.h:123
void FwSmAddChoicePseudoState(FwSmDesc_t smDesc, FwSmCounterS1_t choiceId, FwSmCounterS1_t nOfOutTrans)
Create a choice pseudo-state with the given characteristics and add it to a state machine...
Definition: FwSmConfig.c:140
void FwSmOverrideAction(FwSmDesc_t smDesc, FwSmAction_t oldAction, FwSmAction_t newAction)
Override an action (either a state action or a transition action) in a derived state machine...
Definition: FwSmConfig.c:456
FwSmCounterS1_t transCnt
the counter for the number of transitions added to the state machine
Definition: FwSmPrivate.h:317
struct FwSmDesc ** esmDesc
the state machines embedded in the state machine
Definition: FwSmPrivate.h:311
FwSmDesc_t FwSmMakeTestSM1(struct TestSmData *smData)
Operation to create and configure the state machine SM1.
Definition: FwSmMakeTest.c:208
FwSmBool_t(* FwSmGuard_t)(FwSmDesc_t)
Type for a pointer to a state machine guard.
Definition: FwSmConstants.h:64
int FwSmBool_t
Type used for booleans (0 is "false" and 1 is "true").
Definition: FwSmConstants.h:49
FwSmDesc_t FwSmCreateDer(FwSmDesc_t smDesc)
Create the descriptor of a derived state machine.
Definition: FwSmDCreate.c:137
FwSmCounterU3_t smExecCnt
the state machine execution counter
Definition: FwSmPrivate.h:321
FwSmCounterS1_t nOfOutTrans
number of outgoing transitions
Definition: FwSmPrivate.h:125
int fwSm_logIndex
Location in the log array where the next entry is written.
Definition: FwSmMakeTest.c:39
FwSmDesc_t FwSmMakeTestSM11(struct TestSmData *smData)
Operation to create and configure a degenerate state machine with neither states nor choice pseudo-st...
Definition: FwSmMakeTest.c:611
FwSmDesc_t FwSmMakeTestSM5Dir(struct TestSmData *smData)
Operation to create and configure the state machine SM5 (see FwSmMakeTestSM5 and figure below) by dir...
Definition: FwSmMakeTest.c:370
FwSmDesc_t FwSmMakeTestSMDer1(FwSmDesc_t smDescBase, struct TestSmData *smData)
Create a derived state machine and override one of its actions and one of its guards.
Definition: FwSmMakeTest.c:758
FwSmDesc_t FwSmMakeTestSM15(struct TestSmData *smData)
Operation to create and configure a state machine which uses the execution counters.
Definition: FwSmMakeTest.c:732
FwSmDesc_t FwSmMakeTestSM1Static(struct TestSmData *smData)
Operation to create and configure the state machine SM1 (see FwSmMakeTestSM1 and figure below) static...
Definition: FwSmMakeTest.c:228
void * smData
the pointer to the data manipulated by the state machine actions and guards
Definition: FwSmPrivate.h:327
#define CPS1
A choice pseudo-state identifier.
Definition: FwSmMakeTest.h:44
void(* FwSmAction_t)(FwSmDesc_t)
Type for a pointer to a state machine action.
Definition: FwSmConstants.h:46
int fwSm_logState[LOG_ARRAY_SIZE]
Log array where the actions of the test state machines write the state of their state machine...
Definition: FwSmMakeTest.c:35
#define STATE_S2
A state identifier.
Definition: FwSmMakeTest.h:38
#define STATE_S1
A state identifier.
Definition: FwSmMakeTest.h:36
Structure representing a transition.
Definition: FwSmPrivate.h:195
FwSmDesc_t FwSmMakeTestSM5Static(struct TestSmData *smData)
Operation to create and configure the state machine SM5 (see FwSmMakeTestSM5 and figure below) static...
Definition: FwSmMakeTest.c:348
Structure representing a state machine descriptor.
Definition: FwSmPrivate.h:303
FwSmDesc_t FwSmMakeTestSM8(struct TestSmData *smData)
Operation to create and configure a degenerate state machine with no states.
Definition: FwSmMakeTest.c:527
FwSmDesc_t FwSmMakeTestSM10(struct TestSmData *smData, struct TestSmData *esmData)
Operation to create and configure the state machine SM10.
Definition: FwSmMakeTest.c:581
FwSmDesc_t FwSmMakeTestSM3(struct TestSmData *smData, struct TestSmData *esmData)
Operation to create and configure the state machine SM3.
Definition: FwSmMakeTest.c:266
void FwSmAddTransIpsToCps(FwSmDesc_t smDesc, FwSmCounterS1_t destId, FwSmAction_t trAction)
Create a transition from the initial pseudo-state to a choice pseudo-state and add it to a state mach...
Definition: FwSmConfig.c:186
void FwSmAddTransCpsToFps(FwSmDesc_t smDesc, FwSmCounterS1_t srcId, FwSmAction_t trAction, FwSmGuard_t trGuard)
Create a transition from a choice pseudo-state to the final pseudo-state and add it to a state machin...
Definition: FwSmConfig.c:215
FwSmCounterS1_t FwSmGetCurState(FwSmDesc_t smDesc)
Return the identifier of the current state in a state machine (or zero if the state machine is stoppe...
Definition: FwSmCore.c:222
FwSmCounterU3_t stateExecCnt
the state execution counter
Definition: FwSmPrivate.h:323
FwSmDesc_t FwSmMakeTestSM4(struct TestSmData *smData)
Operation to create and configure the state machine SM4.
Definition: FwSmMakeTest.c:296
FwSmDesc_t FwSmMakeTestSM14(struct TestSmData *smData)
Operation to create and configure a state machine where the choice pseudo-state is used both to split...
Definition: FwSmMakeTest.c:704
FwSmDesc_t FwSmMakeTestSM16_2(struct TestSmData *smData)
Operation to create and configure a state machine to verify the order of evaluation of guards...
Definition: FwSmMakeTest.c:823
void FwSmSetData(FwSmDesc_t smDesc, void *smData)
Set the pointer to the state machine data in the state machine descriptor.
Definition: FwSmConfig.c:83
void FwSmAddTransStaToFps(FwSmDesc_t smDesc, FwSmCounterU2_t transId, FwSmCounterS1_t srcId, FwSmAction_t trAction, FwSmGuard_t trGuard)
Create a transition from a proper state to the final pseudo-state and add it to a state machine...
Definition: FwSmConfig.c:209
#define TR_S1_FPS
A transition identifier.
Definition: FwSmMakeTest.h:48
FwSmDesc_t FwSmMakeTestSM16_3(struct TestSmData *smData)
Operation to create and configure a state machine to verify the order of evaluation of guards...
Definition: FwSmMakeTest.c:854
FwSmCounterS1_t iExitAction
the exit action for the state
Definition: FwSmPrivate.h:131
FwSmCounterS1_t iTrAction
the index of the action associated to the transition
Definition: FwSmPrivate.h:201
#define TR6
A transition identifier.
Definition: FwSmMakeTest.h:66
Structure representing the base descriptor of a state machine.
Definition: FwSmPrivate.h:235
#define TR5
A transition identifier.
Definition: FwSmMakeTest.h:64
int counter_2
Counter incremented by the transition actions.
Definition: FwSmMakeTest.h:105
FwSmCounterS1_t nOfGuards
the number of guards in the state machine
Definition: FwSmPrivate.h:315
#define STATE_S3
A state identifier.
Definition: FwSmMakeTest.h:40
FwSmDesc_t FwSmMakeTestSM9Static(struct TestSmData *smData)
Operation to create and configure the state machine SM5 (see FwSmMakeTestSM9 and figure below) static...
Definition: FwSmMakeTest.c:567
FwSmGuard_t * smGuards
the transition guards in the state machine
Definition: FwSmPrivate.h:309
void SmDummyAction(FwSmDesc_t smDesc)
Dummy action which returns without doing anything.
Definition: FwSmCore.c:40
SmPState_t * pStates
array holding the proper states in the state machine
Definition: FwSmPrivate.h:237
#define TR3
A transition identifier.
Definition: FwSmMakeTest.h:60
SmBaseDesc_t * smBase
pointer to the base descriptor
Definition: FwSmPrivate.h:305
FwSmDesc_t FwSmMakeTestSM9(struct TestSmData *smData)
Operation to create and configure a degenerate state machine with no transitions other than the initi...
Definition: FwSmMakeTest.c:548
Structure representing a choice pseudo state in a state machine.
Definition: FwSmPrivate.h:149
int counter_1
Counter incremented by the state actions.
Definition: FwSmMakeTest.h:103
void FwSmAddState(FwSmDesc_t smDesc, FwSmCounterS1_t stateId, FwSmCounterS1_t nOfOutTrans, FwSmAction_t entryAction, FwSmAction_t exitAction, FwSmAction_t doAction, FwSmDesc_t esmDesc)
Create a state with the given characteristics and add it to a state machine.
Definition: FwSmConfig.c:92
Declaration of the static creation interface for a FW State Machine.
Structure representing a proper state in state machine.
Definition: FwSmPrivate.h:121
void FwSmAddTransIpsToSta(FwSmDesc_t smDesc, FwSmCounterS1_t destId, FwSmAction_t trAction)
Create a transition from the initial pseudo-state to a proper state and add it to a state machine...
Definition: FwSmConfig.c:181
void FwSmAddTransCpsToSta(FwSmDesc_t smDesc, FwSmCounterS1_t srcId, FwSmCounterS1_t destId, FwSmAction_t trAction, FwSmGuard_t trGuard)
Create a transition from a choice pseudo-state to a proper state and add it to a state machine...
Definition: FwSmConfig.c:203
Return codes of a function which has completed execution without errors.
Definition: FwSmConstants.h:86
signed char FwSmCounterS1_t
Type used for signed counters with a "short" range.
Definition: FwSmConstants.h:79
FwSmDesc_t FwSmMakeTestSM13(struct TestSmData *smData)
Operation to create and configure a state machine where the &#39;execute&#39; transition has a choice pseudo-...
Definition: FwSmMakeTest.c:679
FwSmCounterS1_t iEntryAction
the entry action for the state
Definition: FwSmPrivate.h:127
Declaration of the internal data structures of the FW State Machine Module.
FwSmDesc_t FwSmMakeTestSM2(struct TestSmData *smData)
Operation to create and configure the state machine SM2.
Definition: FwSmMakeTest.c:243
SmTrans_t * trans
array holding the transitions in the state machine
Definition: FwSmPrivate.h:241
P&P Software GmbH, Copyright 2011, All Rights Reserved