CORDET Framework - C2 Implementation
CrPsHkEnableCmd.c
Go to the documentation of this file.
1 
22 #include "CrPsHkEnableCmd.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 "FwSmConstants.h"
33 #include "FwSmConfig.h"
34 #include "FwSmCore.h"
35 #include "FwPrDCreate.h"
36 #include "FwPrConfig.h"
37 #include "FwPrCore.h"
38 #include "FwPrConstants.h"
39 
40 #include <CrPsUserConstants.h>
41 #include <CrPsUtilitiesServHk.h>
42 #include <DataPool/CrPsDpServHk.h>
46 
47 
48 /* ------------------------------------------------------------------------------------ */
49 void CrPsHkEnableCmdStartAction(FwSmDesc_t smDesc)
50 {
51  CrFwCmpData_t *cmpData;
52  CrFwInCmdData_t *cmpSpecificData;
53  CrFwPckt_t pckt;
55  CrPsSid_t sid[HK_N_REP_DEF+1];
56  CrFwCounterU4_t nmbN;
57  CrFwCounterU4_t k;
58 
59  /* Run the procedure Start Action of Multi-SID Command of figure 9.3 */
60 
61  /* Get in data */
62  cmpData = (CrFwCmpData_t*)FwSmGetData(smDesc);
63  cmpSpecificData = (CrFwInCmdData_t *) cmpData->cmpSpecificData;
64  pckt = cmpSpecificData->pckt;
65 
66  /* Get number N of OneShot requests */
67  nmbN = getHkEnableCmdN(pckt);
68 
69  for (k=0; k<nmbN; k++)
70  {
71  sid[k] = getHkEnableCmdRepStrucIdItem(pckt, k+1);
72  }
73  sid[k] = 0;
74 
75  /* Set prData of procedure */
76  /* initial setting of prData */
77  prData.smDesc = smDesc;
78  prData.sidPtr = sid;
79  FwPrSetData(getPrDescMultiSidCmdStart(), &prData);
80 
81  FwPrRun(getPrDescMultiSidCmdStart());
82 
83  cmpData = (CrFwCmpData_t*) FwSmGetData(smDesc);
84 
85  return;
86 }
87 
88 /* ------------------------------------------------------------------------------------ */
89 void CrPsHkEnableCmdProgressAction(FwSmDesc_t smDesc)
90 {
91  CrPsSid_t sid[HK_N_REP_DEF+1];
92  CrPsSid_t rdlSid, rdlSlot;
93  CrFwBool_t isEnabled;
94  CrFwCounterU4_t nmbN;
95  CrFwCounterU4_t cycleCnt;
96  CrFwCounterU4_t k;
97  CrFwCmpData_t *cmpData;
98  CrFwInCmdData_t *cmpSpecificData;
99  CrFwPckt_t pckt;
100 
101  /* For the entries in the RDL corresponding to the SIDs which have been identified as valid by the Start Action:
102  * set enabled flag to true and set the cycle counter to 0.
103  * Set the action outcome to ’completed’ */
104 
105  /* Get in data */
106  cmpData = (CrFwCmpData_t*)FwSmGetData(smDesc);
107  cmpSpecificData = (CrFwInCmdData_t *) cmpData->cmpSpecificData;
108  pckt = cmpSpecificData->pckt;
109 
110  /* Get number N of OneShot requests */
111  nmbN = getHkEnableCmdN(pckt);
112 
113  for (k=0; k<nmbN; k++)
114  {
115  sid[k] = getHkEnableCmdRepStrucIdItem(pckt, k+1);
116 
117  /* look for the slot */
118  for (rdlSlot = 0; rdlSlot < HK_N_REP_DEF; rdlSlot++)
119  {
120 
121  rdlSid = getDpsidItem(rdlSlot);
122 
123  if (sid[k] == rdlSid)
124  break;
125  }
126 
127  isEnabled = 1;
128  setDpisEnabledItem(rdlSlot, isEnabled);
129 
130  cycleCnt = 0;
131  setDpcycleCntItem(rdlSlot, cycleCnt);
132 
133  /* reread and check */
134  isEnabled = 0;
135  isEnabled = getDpisEnabledItem(rdlSlot);
136 
137  cycleCnt = 1;
138  cycleCnt = getDpcycleCntItem(rdlSlot);
139  }
140 
141  cmpData->outcome = 1;
142 
143  return;
144 }
145 
146 /* ------------------------------------------------------------------------------------ */
147 void CrPsHkEnableCmdTerminationAction(FwSmDesc_t smDesc)
148 {
149  CrFwCmpData_t* inData;
150 
151  /* Set action outcome to 'success' */
152 
153  /* Get in data */
154  inData = (CrFwCmpData_t*)FwSmGetData(smDesc);
155 
156  inData->outcome = 1;
157 
158  return;
159 }
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.
Interface through which applications can initialize and execute framework PUS extension components...
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.
static CrFwCounterU4_t getHkEnableCmdN(void *p)
Get "N" from "HkEnableCmd" packet.
static CrPsFlag_t getDpisEnabledItem(int i)
Gets the value of the i-th element in the datapool array isEnabled.
Definition: CrPsDpServHk.h:229
Header file to define all service and packet identifiers.
Interface for creating and accessing a report or command packet.
int CrFwBool_t
Type used for boolean values (1 represent "true" and 0 represents "false").
Definition: CrFwConstants.h:30
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
void CrPsHkEnableCmdStartAction(FwSmDesc_t smDesc)
Start action of the Command (3,5) to Enable Periodic Generation of a Housekeeping Report Structure in...
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".
CrPsSid_t getHkEnableCmdRepStrucIdItem(void *p, CrFwCounterU4_t N)
Get "RepStrucId" from "HkEnableCmd" packet.
void * cmpSpecificData
Derived data which are specific to each type of framework component.
FwPrDesc_t getPrDescMultiSidCmdStart()
Getter for MultiSidCmdStart procedure descriptor.
void CrPsHkEnableCmdProgressAction(FwSmDesc_t smDesc)
Progress action of the Command (3,5) to Enable Periodic Generation of a Housekeeping Report Structure...
#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
static CrFwCounterU4_t getDpcycleCntItem(int i)
Gets the value of the i-th element in the datapool array cycleCnt.
Definition: CrPsDpServHk.h:319
Definition of the OutComponent Component of the framework.
void CrPsHkEnableCmdTerminationAction(FwSmDesc_t smDesc)
Termination Action of the Command (3,5) to Enable Periodic Generation of a Housekeeping Report Struct...
Command (3,5) to Enable Periodic Generation of a Housekeeping Report Structure.
Interface for accessing fields in packets of service "ServHk".
Type for the data describing an InCommand.
Definition of the OutLoader component.
P&P Software GmbH, Copyright 2012-2013, All Rights Reserved