CORDET Framework - C2 Implementation
CrPsHkOneShotCmd.c
Go to the documentation of this file.
1 
22 #include "CrPsHkOneShotCmd.h"
23 
24 /* CrFramework includes */
25 #include <Pckt/CrFwPckt.h>
27 #include <OutCmp/CrFwOutCmp.h>
29 #include <CrFwCmpData.h>
30 
31 /* FwProfile includes */
32 #include <FwPrConfig.h>
33 #include <FwSmConfig.h>
34 #include <FwPrCore.h>
35 
36 #include <CrPsUserConstants.h>
37 #include <CrPsUtilitiesServHk.h>
41 #include <DataPool/CrPsDpServHk.h>
42 
43 unsigned short nmbSucc;
44 
45 
46 /* ------------------------------------------------------------------------------------ */
47 void CrPsHkOneShotCmdStartAction(FwSmDesc_t smDesc)
48 {
49  CrFwCmpData_t *cmpData;
50  CrFwInCmdData_t *cmpSpecificData;
51  CrFwPckt_t pckt;
53  CrPsSid_t sid[HK_N_REP_DEF+1];
54  CrFwCounterU4_t nmbN;
55  CrFwCounterU4_t k;
56 
57  /* Run the procedure Start Action of Multi-SID Command of figure 9.3 */
58 
59  /* Get in data */
60  cmpData = (CrFwCmpData_t*)FwSmGetData(smDesc);
61  cmpSpecificData = (CrFwInCmdData_t *) cmpData->cmpSpecificData;
62  pckt = cmpSpecificData->pckt;
63 
64  /* Get number N of OneShot requests */
65  nmbN = getHkOneShotCmdN(pckt);
66 
67  for (k=0; k<nmbN; k++)
68  {
69  sid[k] = getHkOneShotCmdRepStrucIdItem(pckt, k+1);
70  }
71  sid[k] = 0;
72 
73  /* Set prData of procedure */
74  /* initial setting of prData */
75  prData.smDesc = smDesc;
76  prData.sidPtr = sid;
77  FwPrSetData(getPrDescMultiSidCmdStart(), &prData);
78 
79  FwPrRun(getPrDescMultiSidCmdStart());
80 
81  cmpData = (CrFwCmpData_t*) FwSmGetData(smDesc);
82 
83  return;
84 }
85 
86 /* ------------------------------------------------------------------------------------ */
87 void CrPsHkOneShotCmdProgressAction(FwSmDesc_t smDesc)
88 {
89  CrFwCmpData_t *cmpData;
90  CrFwInCmdData_t *cmpSpecificData;
91  CrFwPckt_t pckt;
92  CrPsSid_t sid, rdlSid, rdlSlot;
93  CrFwCounterU4_t N, i;
94 
95  /* For the entries in the RDL corresponding to the SIDs which have been identified as valid
96  by the Start Action: set enabled flag to true, set the cycle counter equal to the period.
97  Set the action outcome to 'completed' */
98 
99  /* Get in data */
100  cmpData = (CrFwCmpData_t*)FwSmGetData(smDesc);
101  cmpSpecificData = (CrFwInCmdData_t *) cmpData->cmpSpecificData;
102  pckt = cmpSpecificData->pckt;
103 
104  /*Get number of SID's*/
105  N = getHkOneShotCmdN(pckt);
106 
107  nmbSucc = 0;
108 
109  for (i=0; i<N; i++)
110  {
111  /*Get SID from packet*/
112  sid = getHkOneShotCmdRepStrucIdItem(pckt, i+1);
113 
114  /* look for the slot */
115  for (rdlSlot = 0; rdlSlot < HK_N_REP_DEF; rdlSlot++)
116  {
117  rdlSid = getDpsidItem(rdlSlot);
118 
119  if (sid == rdlSid)
120  break;
121  }
122 
123  if (rdlSlot < HK_N_REP_DEF)
124  {
125  /*Set enable flag to true and set the cycle counter equal to the period*/
126  setDpisEnabledItem(rdlSlot, 1);
127  setDpcycleCntItem(rdlSlot, getDpperiodItem(rdlSlot));
128  nmbSucc++;
129  }
130  }
131 
132  /* Set the outcome to completed */
133  cmpData->outcome = 1;
134 
135  return;
136 }
137 
138 /* ------------------------------------------------------------------------------------ */
139 void CrPsHkOneShotCmdTerminationAction(FwSmDesc_t smDesc)
140 {
141  CrFwCmpData_t *cmpData;
142  CrFwInCmdData_t *cmpSpecificData;
143  CrFwPckt_t pckt;
144  CrFwCounterU4_t N;
145 
146  /* Set action outcome to ’success’ if all valid SIDs in the command were successfully processed by the progress action;
147  * set it to ’failure’ otherwise */
148 
149  /* Get in data */
150  cmpData = (CrFwCmpData_t*)FwSmGetData(smDesc);
151  cmpSpecificData = (CrFwInCmdData_t *) cmpData->cmpSpecificData;
152  pckt = cmpSpecificData->pckt;
153 
154  /*Get number of SID's*/
155  N = getHkOneShotCmdN(pckt);
156 
157  if (nmbSucc == N)
158  {
159  cmpData->outcome = 1;
160  }
161  else
162  {
163  cmpData->outcome = 0;
164  }
165 
166  return;
167 }
168 
Type for the Framework Component Data (FCD).
static CrPsPeriod_t getDpperiodItem(int i)
Gets the value of the i-th element in the datapool array period.
Definition: CrPsDpServHk.h:259
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.
Interface through which applications can initialize and execute framework PUS extension components...
CrPsSid_t getHkOneShotCmdRepStrucIdItem(void *p, CrFwCounterU4_t N)
Get "RepStrucId" from "HkOneShotCmd" packet.
Command (3,27) to Generate One-Shot Housekeeping Report.
Header file to define all user-configurable constants and types for the IASW Application.
Interface for accessing data pool items.
Definition of the OutFactory component.
CrFwPckt_t pckt
Packet holding the InCommand.
Header file to define all service and packet identifiers.
Interface for creating and accessing a report or command packet.
void CrPsHkOneShotCmdProgressAction(FwSmDesc_t smDesc)
Progress action of the Command (3,27) to Generate One-Shot Housekeeping Report in-coming command pack...
static CrPsSid_t getDpsidItem(int i)
Gets the value of the i-th element in the datapool array sid.
Definition: CrPsDpServHk.h:289
static void setDpcycleCntItem(int i, CrFwCounterU4_t cycleCnt)
Sets the value of the i-th element in the datapool array cycleCnt.
Definition: CrPsDpServHk.h:330
static void setDpisEnabledItem(int i, CrPsFlag_t isEnabled)
Sets the value of the i-th element in the datapool array isEnabled.
Definition: CrPsDpServHk.h:240
auxiliary Interface for accessing fields in packets of service "ServHk".
static CrFwCounterU4_t getHkOneShotCmdN(void *p)
Get "N" from "HkOneShotCmd" packet.
void * cmpSpecificData
Derived data which are specific to each type of framework component.
FwPrDesc_t getPrDescMultiSidCmdStart()
Getter for MultiSidCmdStart procedure descriptor.
#define HK_N_REP_DEF
Number of Report Definitions in the Report Definition List (maximum number of housekeeping/diagnostic...
uint8_t CrPsSid_t
Type used for the Parameter Report Structure ID of a packet.
char * CrFwPckt_t
Type for packets (see CrFwPckt.h).
Definition: CrFwConstants.h:36
void CrPsHkOneShotCmdTerminationAction(FwSmDesc_t smDesc)
Termination Action of the Command (3,27) to Generate One-Shot Housekeeping Report in-coming command p...
Definition of the OutComponent Component of the framework.
Interface for accessing fields in packets of service "ServHk".
Type for the data describing an InCommand.
void CrPsHkOneShotCmdStartAction(FwSmDesc_t smDesc)
Start action of the Command (3,27) to Generate One-Shot Housekeeping Report in-coming command packet...
Definition of the OutLoader component.
P&P Software GmbH, Copyright 2012-2013, All Rights Reserved