FW Profile - C1 Implementation
FwPrSCreate.c
Go to the documentation of this file.
1 
19 #include "FwPrPrivate.h"
20 #include <stdlib.h>
21 
22 /* ----------------------------------------------------------------------------------------------------------------- */
23 void FwPrInit(FwPrDesc_t prDesc) {
24 
26  PrBaseDesc_t* prBase = prDesc->prBase;
27 
28  for (i = 0; i < prBase->nOfANodes; i++) {
29  prBase->aNodes[i].iFlow = -1;
30  }
31 
32  for (i = 0; i < prBase->nOfDNodes; i++) {
33  prBase->dNodes[i].outFlowIndex = -1;
34  }
35 
36  for (i = 0; i < prBase->nOfFlows; i++) {
37  prBase->flows[i].iGuard = -1;
38  }
39 
40  for (i = 0; i < prDesc->nOfActions; i++) {
41  prDesc->prActions[i] = NULL;
42  }
43 
44  prDesc->prGuards[0] = &PrDummyGuard;
45  for (i = 1; i < prDesc->nOfGuards; i++) {
46  prDesc->prGuards[i] = NULL;
47  }
48 }
49 
50 /* ----------------------------------------------------------------------------------------------------------------- */
51 void FwPrInitDer(FwPrDesc_t prDesc, FwPrDesc_t prDescBase) {
53  PrBaseDesc_t* prBase = prDescBase->prBase;
54 
55  if (prDesc->nOfActions != prDescBase->nOfActions) {
56  prDesc->errCode = prWrongNOfActions;
57  return;
58  }
59 
60  if (prDesc->nOfGuards != prDescBase->nOfGuards) {
61  prDesc->errCode = prWrongNOfGuards;
62  return;
63  }
64 
65  prDesc->prBase = prBase;
66 
67  /* This cycle will always be executed at least once because
68  * the number of actions (nOfActions) is always greater than
69  * zero (since all procedures have at least one action node)
70  */
71  for (i = 0; i < prDesc->nOfActions; i++) {
72  prDesc->prActions[i] = prDescBase->prActions[i];
73  }
74 
75  /* This cycle will always be executed at least once because
76  * the number of guards (nOfGuards) is always greater than
77  * zero (since all procedures have at least the dummy guard)
78  */
79  for (i = 0; i < prDesc->nOfGuards; i++) {
80  prDesc->prGuards[i] = prDescBase->prGuards[i];
81  }
82 
83  prDesc->errCode = prDescBase->errCode;
84 
85  prDesc->flowCnt = 0;
86  prDesc->curNode = 0;
87  prDesc->nodeExecCnt = 0;
88  prDesc->prExecCnt = 0;
89 
90  return;
91 }
FwPrCounterS1_t nOfGuards
the number of guards in the procedure
Definition: FwPrPrivate.h:264
The number of guards in the base procedure is not the same as in the derived procedure.
Definition: FwPrConstants.h:99
void FwPrInitDer(FwPrDesc_t prDesc, FwPrDesc_t prDescBase)
Initialize a procedure descriptor to extend another procedure (the base procedure).
Definition: FwPrSCreate.c:51
Structure representing the base descriptor of a procedure.
Definition: FwPrPrivate.h:186
FwPrCounterS1_t nOfActions
the number of actions in the procedure
Definition: FwPrPrivate.h:262
The number of actions in the base procedure is not the same as in the derived procedure.
Definition: FwPrConstants.h:94
FwPrCounterS1_t nOfANodes
the number of action nodes in the procedure
Definition: FwPrPrivate.h:194
void FwPrInit(FwPrDesc_t prDesc)
Initialize a procedure descriptor to represent an unconfigured procedure with no control flows...
Definition: FwPrSCreate.c:23
PrFlow_t * flows
array holding the control flows in the procedure
Definition: FwPrPrivate.h:192
FwPrCounterS1_t nOfFlows
the number of control flows in the procedure (excluding control flow from initial node) ...
Definition: FwPrPrivate.h:198
PrBaseDesc_t * prBase
pointer to the base descriptor
Definition: FwPrPrivate.h:256
PrANode_t * aNodes
array holding the action nodes in the procedure
Definition: FwPrPrivate.h:188
FwPrCounterS1_t flowCnt
the counter for the number of control flows added to the procedure
Definition: FwPrPrivate.h:266
PrDNode_t * dNodes
array holding the decision nodes in the procedure
Definition: FwPrPrivate.h:190
FwPrCounterS1_t iGuard
the index of the guard associated to the control flow
Definition: FwPrPrivate.h:156
FwPrBool_t PrDummyGuard(FwPrDesc_t prDesc)
Dummy guard which always returns true.
Definition: FwPrCore.c:23
FwPrCounterU3_t nodeExecCnt
the node execution counter
Definition: FwPrPrivate.h:274
FwPrErrCode_t errCode
either &#39;success&#39; or the code of the last error encountered by the procedure
Definition: FwPrPrivate.h:270
FwPrCounterS1_t outFlowIndex
index of first out-going control flow in control flow array
Definition: FwPrPrivate.h:123
signed char FwPrCounterS1_t
Type used for signed counters with a "short" range.
Definition: FwPrConstants.h:78
Structure representing a procedure descriptor.
Definition: FwPrPrivate.h:254
FwPrAction_t * prActions
the procedure actions
Definition: FwPrPrivate.h:258
Declaration of the internal data structures of the FW Procedure Module.
FwPrCounterS1_t iFlow
index of out-going control flows
Definition: FwPrPrivate.h:100
FwPrCounterU3_t prExecCnt
the procedure execution counter
Definition: FwPrPrivate.h:272
FwPrGuard_t * prGuards
the control flow guards in the procedure
Definition: FwPrPrivate.h:260
FwPrCounterS1_t nOfDNodes
the number of decision nodes in the procedure
Definition: FwPrPrivate.h:196
FwPrCounterS1_t curNode
the current node of the procedure
Definition: FwPrPrivate.h:268
P&P Software GmbH, Copyright 2011, All Rights Reserved