CORDET Framework - C2 Implementation
CrPsHkCreateCmd.c
Go to the documentation of this file.
1 
22 #include "CrPsHkCreateCmd.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 <CrPsUtilitiesServHk.h>
44 #include <CrPsUserConstants.h>
45 #include <DataPool/CrPsDpServHk.h>
46 
47 
48 /* ------------------------------------------------------------------------------------ */
49 void CrPsHkCreateCmdStartAction(FwSmDesc_t smDesc)
50 {
51  /* Run the procedure Start Action of HkCreate Command of figure 9.1 */
52 
53  FwPrSetData(getPrDescHkCmd3s1Start(), smDesc);
54 
55  FwPrRun(getPrDescHkCmd3s1Start());
56 
57  return;
58 }
59 
60 /* ------------------------------------------------------------------------------------ */
61 void CrPsHkCreateCmdProgressAction(FwSmDesc_t smDesc)
62 {
63  CrFwCmpData_t *cmpData;
64  CrFwInCmdData_t *cmpSpecificData;
65  CrFwPckt_t pckt;
66  CrPsSid_t rdlSlot, rdlSid;
67  CrFwCounterU4_t i, j;
68  CrPsSid_t sid;
69  CrPsParamId_t N1ParamId, N2ParamId;
70  CrPsCollectInterval_t period;
71  CrFwBool_t isEnabled;
72  CrFwCounterU4_t N1, NFA, N2;
73  CrPsRepNum_t SCSampleRep;
74 
75  /* Add the definition of the new report to the RDL, set its enabled status to ’disabled’, and set the action outcome to ’completed’ */
76 
77  /* Get inPckt */
78  cmpData = (CrFwCmpData_t*) FwSmGetData(smDesc);
79  cmpSpecificData = (CrFwInCmdData_t *) cmpData->cmpSpecificData;
80  pckt = cmpSpecificData->pckt;
81 
82  /* look for a free slot */
83  for (rdlSlot = 0; rdlSlot < HK_N_REP_DEF; rdlSlot++)
84  {
85  rdlSid = getDpsidItem(rdlSlot);
86 
87  if (rdlSid == 0)
88  break;
89  }
90 
91  /* Get SID and add in RDL */
92  sid = getHkCreateCmdRepStrucId(pckt);
93  setDpsidItem(rdlSlot, (CrPsSid_t)sid);
94 
95  /* Get Collection Interval (= period) and add in RDL */
96  period = getHkCreateCmdCollectionInterval(pckt);
97  setDpperiodItem(rdlSlot, period);
98 
99  /* Set enabled status to 'disabled' */
100  isEnabled = 0;
101  setDpisEnabledItem(rdlSlot, isEnabled);
102 
103  /* Set the single commutated parameter IDs */
104  N1 = getHkCreateCmdN1(pckt);
105  setDpnSimpleItem(rdlSlot, N1);
106  for (i=0; i<N1; i++)
107  {
108  N1ParamId = getHkCreateCmdN1ParamIdItem(pckt, i+1);
109  setDplstIdItem(HK_MAX_N_ITEMS*rdlSlot + i, N1ParamId);
110  }
111 
112  /* Set the super commutated parameter IDs */
113  NFA = getHkCreateCmdNFA(pckt);
114  for (i=0;i<NFA;i++)
115  {
116  SCSampleRep = getHkCreateCmdSCSampleRepNumItem(pckt, i+1);
117  setDplstSampleRepItem(HK_MAX_N_GR*rdlSlot + i, SCSampleRep);
118  N2 = getHkCreateCmdN2(pckt, i+1);
119  setDplstNSampRepItem(HK_MAX_N_GR*rdlSlot + i, N2);
120  for (j=0;j<N2;j++)
121  {
122  N2ParamId = getHkCreateCmdN2ParamIdItem(pckt, i+1, j+1);
123  setDplstIdItem(HK_MAX_N_ITEMS*rdlSlot + N1 + j, N2ParamId);
124  }
125  }
126 
127  cmpData->outcome = 1;
128 
129  return;
130 }
131 
132 /* ------------------------------------------------------------------------------------ */
133 void CrPsHkCreateCmdTerminationAction(FwSmDesc_t smDesc)
134 {
135  CrFwCmpData_t *inData;
136 
137  /* Set action outcome to 'success' */
138 
139  /* Get in data */
140  inData = (CrFwCmpData_t*)FwSmGetData(smDesc);
141 
142  inData->outcome = 1;
143 
144  return;
145 }
146 
Type for the Framework Component Data (FCD).
uint32_t CrPsRepNum_t
Type used for the Repetition Number of a packet.
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...
Header file to define all user-configurable constants and types for the IASW Application.
uint16_t CrPsParamId_t
Type used for the Parameter ID of a packet.
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.
int CrFwBool_t
Type used for boolean values (1 represent "true" and 0 represents "false").
Definition: CrFwConstants.h:30
static void setDplstNSampRepItem(int i, CrPsNumberU2_t lstNSampRep)
Sets the value of the i-th element in the datapool array lstNSampRep.
Definition: CrPsDpServHk.h:420
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 setDpsidItem(int i, CrPsSid_t sid)
Sets the value of the i-th element in the datapool array sid.
Definition: CrPsDpServHk.h:300
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".
uint32_t CrPsCollectInterval_t
Type used for the Collection Interval of a packet.
CrFwCounterU4_t getHkCreateCmdN2(void *p, CrFwCounterU4_t NFA)
Get "N2" from "HkCreateCmd" packet.
static void setDplstSampleRepItem(int i, CrPsRepetition_t lstSampleRep)
Sets the value of the i-th element in the datapool array lstSampleRep.
Definition: CrPsDpServHk.h:450
FwPrDesc_t getPrDescHkCmd3s1Start()
Getter for HkCmd3s1Start procedure descriptor.
void * cmpSpecificData
Derived data which are specific to each type of framework component.
void CrPsHkCreateCmdProgressAction(FwSmDesc_t smDesc)
Progress action of the Command (3,1) to Create a Housekeeping Report Structure in-coming command pack...
static void setDpnSimpleItem(int i, CrPsNumberU2_t nSimple)
Sets the value of the i-th element in the datapool array nSimple.
Definition: CrPsDpServHk.h:480
static CrPsCollectInterval_t getHkCreateCmdCollectionInterval(void *p)
Get "CollectionInterval" from "HkCreateCmd" packet.
static CrPsSid_t getHkCreateCmdRepStrucId(void *p)
Get "RepStrucId" from "HkCreateCmd" packet.
Command (3,1) to Create a Housekeeping Report Structure.
CrPsRepNum_t getHkCreateCmdSCSampleRepNumItem(void *p, CrFwCounterU4_t NFA)
Get "SCSampleRepNum" from "HkCreateCmd" packet.
#define HK_N_REP_DEF
Number of Report Definitions in the Report Definition List (maximum number of housekeeping/diagnostic...
CrPsParamId_t getHkCreateCmdN2ParamIdItem(void *p, CrFwCounterU4_t NFA, CrFwCounterU4_t N2)
Get "N2ParamID" from "HkCreateCmd" packet.
uint8_t CrPsSid_t
Type used for the Parameter Report Structure ID of a packet.
static void setDpperiodItem(int i, CrPsPeriod_t period)
Sets the value of the i-th element in the datapool array period.
Definition: CrPsDpServHk.h:270
char * CrFwPckt_t
Type for packets (see CrFwPckt.h).
Definition: CrFwConstants.h:36
#define HK_MAX_N_GR
Maximum number of super-commutated groups in a house- keeping/diagnostic report.
Definition of the OutComponent Component of the framework.
void CrPsHkCreateCmdTerminationAction(FwSmDesc_t smDesc)
Termination Action of the Command (3,1) to Create a Housekeeping Report Structure in-coming command p...
static void setDplstIdItem(int i, CrPsParamId_t lstId)
Sets the value of the i-th element in the datapool array lstId.
Definition: CrPsDpServHk.h:390
Interface for accessing fields in packets of service "ServHk".
Type for the data describing an InCommand.
CrFwCounterU4_t getHkCreateCmdNFA(void *p)
Get "NFA" from "HkCreateCmd" packet.
CrPsParamId_t getHkCreateCmdN1ParamIdItem(void *p, CrFwCounterU4_t N)
Get "N1ParamId" arrayItem from "HkCreateCmd" packet.
Definition of the OutLoader component.
static CrFwCounterU4_t getHkCreateCmdN1(void *p)
Get "N1" from "HkCreateCmd" packet.
void CrPsHkCreateCmdStartAction(FwSmDesc_t smDesc)
Start action of the Command (3,1) to Create a Housekeeping Report Structure in-coming command packet...
P&P Software GmbH, Copyright 2012-2013, All Rights Reserved