CORDET Framework - C2 Implementation
CrPsCmd5EidStartFunc.c
Go to the documentation of this file.
1 
25 #include "CrPsCmd5EidStartCreate.h"
26 
28 #include "CrFwConstants.h"
29 #include "Pckt/CrFwPckt.h"
31 #include "OutCmp/CrFwOutCmp.h"
33 #include "CrFwCmpData.h"
34 
36 #include "FwSmConstants.h"
37 #include "FwSmConfig.h"
38 #include "FwSmCore.h"
39 #include "FwPrDCreate.h"
40 #include "FwPrConfig.h"
41 #include "FwPrCore.h"
42 #include "FwPrConstants.h"
43 
49 #include <CrPsUserConstants.h>
50 
51 #include <stdlib.h>
52 #include <time.h>
53 
54 CrFwCounterU4_t i, iEidFail;
55 CrPsNumberU4_t iMax;
56 CrPsEid_t currentEid;
57 CrFwCounterU2_t currentEvtSlot;
58 
59 
60 /* ----------------------------------------------------------------------------------------------------------------- */
61 
63 void CrPsCmd5EidStartN1(FwPrDesc_t prDesc)
64 {
65  CrFwCmpData_t *cmpData;
66  CrFwInCmdData_t *cmpSpecificData;
67  CrFwPckt_t pckt;
68  FwSmDesc_t smDesc;
69  prDescCmdEidStart_t *prDataPtr;
71  CrFwCounterU2_t evtSlot;
72  CrPsEid_t evtEid;
73  CrPsEid_t evtEidArray[EVT_N_EID] = EVT_EID;
74  CrPsFlag_t* evtFlagPtr;
75  uint32_t j;
76 
77  /* Set i equal to 1 */
78 
79  i = 1;
80  iEidFail = 0;
81 
82  /* Get prData */
83  prDataPtr = FwPrGetData(prDesc);
84 
85  /* Initialize flag array */
86  evtFlagPtr = (CrPsFlag_t*)prDataPtr->evtFlagPtr;
87  for (j=0; j<EVT_N_EID; j++)
88  {
89  *(evtFlagPtr + j) = 0;
90  }
91 
92  /* Get smDesc from prData */
93  smDesc = prDataPtr->smDesc;
94 
95  /* Get in data */
96  cmpData = (CrFwCmpData_t*)FwSmGetData(smDesc);
97  cmpSpecificData = (CrFwInCmdData_t *) cmpData->cmpSpecificData;
98  pckt = cmpSpecificData->pckt;
99 
100  servSubType = CrFwPcktGetServSubType(pckt);
101 
102  /* Get first EID and iMax */
103  switch(servSubType)
104  {
105  case CRPS_EVT_ENABLE_CMD:
106  currentEid = getEvtEnableCmdEventIdItem(pckt, i);
107  iMax = getEvtEnableCmdN(pckt);
108  break;
109 
111  currentEid = getEvtDisableCmdEventIdItem(pckt, i);
112  iMax = getEvtDisableCmdN(pckt);
113  break;
114 
115  default:
116  currentEid = 0;
117  iMax = 1;
118  break;
119  }
120 
121  /* look for the slot */
122  for (evtSlot = 0; evtSlot < EVT_N_EID; evtSlot++)
123  {
124  evtEid = evtEidArray[evtSlot];
125 
126  if (currentEid == evtEid)
127  break;
128  }
129 
130 currentEvtSlot = evtSlot;
131 
132  if (evtSlot < EVT_N_EID)
133  {
134  /* Set selected first EID in flag array */
135  *(evtFlagPtr + currentEvtSlot) = 1;
136  }
137 
138  return;
139 }
140 
142 void CrPsCmd5EidStartN2(FwPrDesc_t prDesc)
143 {
144  CRFW_UNUSED(prDesc);
145 
146  /* Load invalid EID in
147  data pool item verFailData */
148 
149  iEidFail++;
150  setDpverFailData((CrPsFailData_t)currentEid);
151 
152  return;
153 }
154 
156 void CrPsCmd5EidStartN3(FwPrDesc_t prDesc)
157 {
158  prDescCmdEidStart_t *prDataPtr;
159  FwSmDesc_t smDesc;
160 
161  /* Run Command Verification
162  Failure Procedure to generate (1,4)
163  report with failure code VER_ILL_EID */
164 
165  /* Get smDesc from prData */
166  prDataPtr = FwPrGetData(prDesc);
167  smDesc = prDataPtr->smDesc;
168 
170 
171  return;
172 }
173 
175 void CrPsCmd5EidStartN4(FwPrDesc_t prDesc)
176 {
177  CrFwCmpData_t *cmpData;
178  CrFwInCmdData_t *cmpSpecificData;
179  CrFwPckt_t pckt;
180  FwSmDesc_t smDesc;
181  prDescCmdEidStart_t *prDataPtr;
183  CrFwCounterU2_t evtSlot;
184  CrPsEid_t evtEid;
185  CrPsEid_t evtEidArray[EVT_N_EID] = EVT_EID;
186  CrPsFlag_t* evtFlagPtr;
187 
188  /* Increment i */
189 
190  i++;
191 
192  /* Get smDesc from prData */
193  prDataPtr = FwPrGetData(prDesc);
194  evtFlagPtr = prDataPtr->evtFlagPtr;
195  smDesc = prDataPtr->smDesc;
196 
197  /* Get in data */
198  cmpData = (CrFwCmpData_t*)FwSmGetData(smDesc);
199  cmpSpecificData = (CrFwInCmdData_t *) cmpData->cmpSpecificData;
200  pckt = cmpSpecificData->pckt;
201 
202  servSubType = CrFwPcktGetServSubType(pckt);
203 
204  /* Get next EID */
205  switch(servSubType)
206  {
207  case CRPS_EVT_ENABLE_CMD:
208  currentEid = getEvtEnableCmdEventIdItem(pckt, i);
209  iMax = getEvtEnableCmdN(pckt);
210  break;
211 
213  currentEid = getEvtDisableCmdEventIdItem(pckt, i);
214  iMax = getEvtDisableCmdN(pckt);
215  break;
216 
217  default: /*TODO (01.02.2018)can never be reached, because of N1 */
218  currentEid = 0;
219  iMax = 1;
220  break;
221  }
222 
223  /* look for the slot */
224  for (evtSlot = 0; evtSlot < EVT_N_EID; evtSlot++)
225  {
226  evtEid = evtEidArray[evtSlot];
227 
228  if (currentEid == evtEid)
229  break;
230  }
231 
232  currentEvtSlot = evtSlot;
233 
234  if (evtSlot < EVT_N_EID)
235  {
236  /* Set selected first EID in flag array */
237  *(evtFlagPtr + currentEvtSlot) = 1;
238  }
239 
240  return;
241 }
242 
244 void CrPsCmd5EidStartN7(FwPrDesc_t prDesc)
245 {
246  prDescCmdEidStart_t *prDataPtr;
247  CrFwCmpData_t *cmpData;
248  FwSmDesc_t smDesc;
249 
250  /* Set action outcome to 'success' */
251 
252  /* Get smDesc from OutCmp */
253  prDataPtr = FwPrGetData(prDesc);
254  smDesc = prDataPtr->smDesc;
255 
256  /* Set outcome in InCmd prData to 'success' */
257  cmpData = (CrFwCmpData_t*) FwSmGetData(smDesc);
258  cmpData->outcome = 1;
259  FwSmSetData(smDesc, cmpData);
260 
261  return;
262 }
263 
265 void CrPsCmd5EidStartN8(FwPrDesc_t prDesc)
266 {
267  prDescCmdEidStart_t *prDataPtr;
268  CrFwCmpData_t *cmpData;
269  FwSmDesc_t smDesc;
270 
271  /* Set action outcome to 'failure'
272  with failure code VER_EID_START_FD */
273 
274  /* Get smDesc from OutCmp */
275  prDataPtr = FwPrGetData(prDesc);
276  smDesc = prDataPtr->smDesc;
277 
278  /* Set outcome in InCmd prData to 'failure' */
279  cmpData = (CrFwCmpData_t*) FwSmGetData(smDesc);
280  cmpData->outcome = VER_EID_START_FD;
281  FwSmSetData(smDesc, cmpData);
282 
283  return;
284 }
285 
286 /**************/
287 /*** GUARDS ***/
288 /**************/
289 
291 FwPrBool_t CrPsCmd5EidStartG1(FwPrDesc_t prDesc)
292 {
293  CRFW_UNUSED(prDesc);
294 
295  /* The i-th EID is not in EVT_EID */
296 
297  /* EID not found in list */
298 
299  /*TODO ist nie erfüllt !!!*/
300  if (currentEvtSlot == EVT_N_EID)
301  {
302  return 1;
303  }
304  else
305  {
306  return 0;
307  }
308 }
309 
311 FwPrBool_t CrPsCmd5EidStartG2(FwPrDesc_t prDesc)
312 {
313  CRFW_UNUSED(prDesc);
314 
315  /* The i-th EID was the last EID in the command */
316 
317  if (i == iMax)
318  {
319  return 1;
320  }
321  else
322  {
323  return 0;
324  }
325 }
326 
328 FwPrBool_t CrPsCmd5EidStartG3(FwPrDesc_t prDesc)
329 {
330  CRFW_UNUSED(prDesc);
331 
332  /* All EIDs in the command are invalid */
333 
334  if (iEidFail == iMax)
335  {
336  return 1;
337  }
338  else
339  {
340  return 0;
341  }
342 }
343 
344 /* ----------------------------------------------------------------------------------------------------------------- */
345 
Type for the Framework Component Data (FCD).
CrFwOutcome_t outcome
The outcome of an action or check executed by a state machine or by one of its procedures.
CrFwCounterU4_t i
CrPsCmd5EidStart function definitions.
#define EVT_N_EID
Number of event identifiers supported by the application.
static CrPsNumberU4_t getEvtEnableCmdN(void *p)
Get "N" from "EvtEnableCmd" packet.
static CrFwServSubType_t servSubType
Service sub-type.
Create one instance of the CrPsCmd5EidStart procedure.
#define CRFW_UNUSED(x)
A macro that can be used to specify that a function parameter is not used.
Definition: CrFwConstants.h:27
unsigned char CrFwServSubType_t
Type used for the command or report sub-type.
Header file to define all user-configurable constants and types for the IASW Application.
void CrPsCmd5EidStartN1(FwPrDesc_t prDesc)
Action for node N1.
Definition of the OutFactory component.
CrFwPckt_t pckt
Packet holding the InCommand.
#define CRPS_EVT_ENABLE_CMD
Subtype identifier of the Event Report Enable in-coming command packet.
Header file to define all service and packet identifiers.
Interface for creating and accessing a report or command packet.
CrPsEid_t getEvtDisableCmdEventIdItem(void *p, CrPsNumberU4_t N)
Get "EventId" arrayItem from "EvtDisableCmd" packet.
void CrPsCmd5EidStartN4(FwPrDesc_t prDesc)
Action for node N4.
static void setDpverFailData(CrPsFailData_t verFailData)
Sets the value of the datapool item verFailData.
Header file to define all invariant publicly available constants and types for the CORDET Framework...
uint16_t CrPsEid_t
Type used for Event Id of a Packet.
#define VER_EID_START_FD
Outcome Failure Codes for Service 5 (Event Report)
void CrPsCmd5EidStartN8(FwPrDesc_t prDesc)
Action for node N8.
void CrPsCmd5EidStartN2(FwPrDesc_t prDesc)
Action for node N2.
CrPsEid_t getEvtEnableCmdEventIdItem(void *p, CrPsNumberU4_t N)
Get "EventId" arrayItem from "EvtEnableCmd" packet.
Interface for accessing data pool items.
uint32_t CrPsFailData_t
Type used for the Failure Data of a packet.
void * cmpSpecificData
Derived data which are specific to each type of framework component.
#define CRPS_REQVERIF_START_FAIL
Subtype identifier of the Request Verification Start Failed out-going report packet.
void CrPsCmd5EidStartN7(FwPrDesc_t prDesc)
Action for node N7.
FwPrBool_t CrPsCmd5EidStartG2(FwPrDesc_t prDesc)
Guard on the Control Flow from DECISION3 to DECISION4.
CrFwServSubType_t CrFwPcktGetServSubType(CrFwPckt_t pckt)
Return the service sub-type of the command or report encapsulated in a packet.
Interface for accessing fields in packets of service "ServEvt".
char * CrFwPckt_t
Type for packets (see CrFwPckt.h).
Definition: CrFwConstants.h:36
Definition of the OutComponent Component of the framework.
#define EVT_EID
Array of EVT_N_EID elements holding the event identifiers in ascending order.
#define VER_ILL_EID
Failure Codes of Service 5 (Event Report) for Service 1 (Request Verification)
Interface through which applications can initialize and execute framework PUS extension components...
Type for the data describing an InCommand.
auxiliary Interface for accessing fields in packets of service "ServEvt".
#define CRPS_EVT_DISABLE_CMD
Subtype identifier of the Event Report Disable in-coming command packet.
Definition of the OutLoader component.
unsigned short CrFwCounterU2_t
Type used for unsigned integers with a "medium" range.
FwPrBool_t CrPsCmd5EidStartG1(FwPrDesc_t prDesc)
Guard on the Control Flow from DECISION1 to N2.
FwPrBool_t CrPsCmd5EidStartG3(FwPrDesc_t prDesc)
Guard on the Control Flow from DECISION4 to N8.
static CrPsNumberU4_t getEvtDisableCmdN(void *p)
Get "N" from "EvtDisableCmd" packet.
void SendReqVerifCmdFailRep(FwSmDesc_t smDesc, uint16_t reqVerifCmdFailType, CrPsFailCode_t FailureCode)
Generate a Request Verification Start/Termination Failed out-going report.
void CrPsCmd5EidStartN3(FwPrDesc_t prDesc)
Action for node N3.
P&P Software GmbH, Copyright 2012-2013, All Rights Reserved