Skip to content

Commit 712a7ac

Browse files
committed
Fix #16, Convert LC state macros to enums
1 parent feb5bf5 commit 712a7ac

16 files changed

Lines changed: 382 additions & 370 deletions

config/default_lc_fcncodes.h

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727
#define LC_FCNCODES_H
2828

2929
/************************************************************************
30-
* Macro Definitions
30+
* Type Definitions
3131
************************************************************************/
3232

3333
/**
@@ -152,8 +152,8 @@
152152
* - Invalid actionpoint state specified in command message
153153
* - Actionpoint number specified in command message is
154154
* out of range
155-
* - Actionpoint current state is either #LC_APSTATE_NOT_USED
156-
* or #LC_APSTATE_PERMOFF
155+
* - Actionpoint current state is either #LC_ActionPoint_NOT_USED
156+
* or #LC_ActionPointState_PERMOFF
157157
*
158158
* \par Evidence of failure may be found in the following telemetry:
159159
* - #LC_HkTlm_Payload_t.CmdErrCount will increment
@@ -172,7 +172,7 @@
172172
* \brief Set AP Permanently Off
173173
*
174174
* \par Description
175-
* Set the specified actionpoint's state to #LC_APSTATE_PERMOFF
175+
* Set the specified actionpoint's state to #LC_ActionPointState_PERMOFF
176176
*
177177
* \par Command Structure
178178
* #LC_SetAPPermOffCmd_t
@@ -189,7 +189,7 @@
189189
* - Command packet length not as expected
190190
* - Actionpoint number specified in command message is
191191
* out of range
192-
* - Actionpoint current state is not #LC_APSTATE_DISABLED
192+
* - Actionpoint current state is not #LC_ActionPointState_DISABLED
193193
*
194194
* \par Evidence of failure may be found in the following telemetry:
195195
* - #LC_HkTlm_Payload_t.CmdErrCount will increment

config/default_lc_internal_cfg.h

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -78,11 +78,11 @@
7878
*
7979
* \par Limits:
8080
* This parameter must be one of the following:
81-
* #LC_STATE_ACTIVE
82-
* #LC_STATE_PASSIVE
83-
* #LC_STATE_DISABLED
81+
* #LC_AppState_ACTIVE
82+
* #LC_AppState_PASSIVE
83+
* #LC_AppState_DISABLED
8484
*/
85-
#define LC_STATE_POWER_ON_RESET LC_STATE_DISABLED
85+
#define LC_STATE_POWER_ON_RESET LC_AppState_DISABLED
8686

8787
/**
8888
* \brief Save data to CDS compiler switch
@@ -110,19 +110,19 @@
110110
* is set to true, and provides a way to override any state LC
111111
* may have been operating in prior to the reset occurring.
112112
*
113-
* If this is set to LC_STATE_FROM_CDS and LC_SAVE_TO_CDS is set
113+
* If this is set to LC_AppState_FROM_CDS and LC_SAVE_TO_CDS is set
114114
* to true, then the LC state will be preserved across resets and
115-
* restored. If this is not set to LC_STATE_FROM_CDS, the state
115+
* restored. If this is not set to LC_AppState_FROM_CDS, the state
116116
* saved in the CDS is overwritten by the state assigned here.
117117
*
118118
* \par Limits:
119119
* This parameter must be one of the following:
120-
* #LC_STATE_ACTIVE
121-
* #LC_STATE_PASSIVE
122-
* #LC_STATE_DISABLED
123-
* #LC_STATE_FROM_CDS
120+
* #LC_AppState_ACTIVE
121+
* #LC_AppState_PASSIVE
122+
* #LC_AppState_DISABLED
123+
* #LC_AppState_FROM_CDS
124124
*/
125-
#define LC_STATE_WHEN_CDS_RESTORED LC_STATE_FROM_CDS
125+
#define LC_STATE_WHEN_CDS_RESTORED LC_AppState_FROM_CDS
126126

127127
/**
128128
* \brief Watchpoint Definition Table (WDT) filename

config/default_lc_msgdefs.h

Lines changed: 22 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -40,30 +40,40 @@
4040
#include "lc_fcncodes.h"
4141

4242
/************************************************************************
43-
* Macro Definitions
43+
* Type Definitions
4444
************************************************************************/
4545

4646
/**
4747
* \name LC Application States
4848
* \{
4949
*/
50-
#define LC_STATE_ACTIVE 1 /**< \brief LC Application State Active */
51-
#define LC_STATE_PASSIVE 2 /**< \brief LC Application State Pasive */
52-
#define LC_STATE_DISABLED 3 /**< \brief LC Application State Disabled */
53-
#define LC_STATE_FROM_CDS 4 /**< \brief Used for reset processing, not valid state */
50+
typedef enum LC_AppState_Enum
51+
{
52+
LC_AppState_ACTIVE = 1, /**< \brief LC Application State Active */
53+
LC_AppState_PASSIVE, /**< \brief LC Application State Pasive */
54+
LC_AppState_DISABLED, /**< \brief LC Application State Disabled */
55+
LC_AppState_FROM_CDS /**< \brief Used for reset processing, not valid state */
56+
} LC_AppState_Enum_t;
5457
/**\}*/
5558

5659
/**
5760
* \name Actionpoint States
5861
* \{
5962
*/
60-
#define LC_APSTATE_NOT_USED 0xFF /**< \brief Actionpoint unused, not valid command argument */
61-
#define LC_APSTATE_ACTIVE 1 /**< \brief Actionpoint state active */
62-
#define LC_APSTATE_PASSIVE 2 /**< \brief Actionpoint state passive */
63-
#define LC_APSTATE_DISABLED 3 /**< \brief Actionpoint state disabled */
64-
#define LC_APSTATE_PERMOFF 4 /**< \brief Actionpoint state permanently off, see #LC_SET_AP_PERM_OFF_CC */
63+
typedef enum LC_ActionPointState_Enum
64+
{
65+
LC_ActionPointState_ACTIVE = 1, /**< \brief Actionpoint state active */
66+
LC_ActionPointState_PASSIVE, /**< \brief Actionpoint state passive */
67+
LC_ActionPointState_DISABLED, /**< \brief Actionpoint state disabled */
68+
LC_ActionPointState_PERMOFF, /**< \brief Actionpoint state permanently off, see #LC_SET_AP_PERM_OFF_CC */
69+
LC_ActionPoint_NOT_USED = 255 /**< \brief Actionpoint unused, not valid command argument */
70+
} LC_ActionPointState_Enum_t;
6571
/**\}*/
6672

73+
/************************************************************************
74+
* Macro Definitions
75+
************************************************************************/
76+
6777
/**
6878
* \name Special Values for Commands
6979
* \{
@@ -118,7 +128,8 @@
118128
/**\}*/
119129

120130
#ifndef LC_OMIT_DEPRECATED
121-
#define LC_ACTION_NOT_USED LC_APSTATE_NOT_USED
131+
#define LC_SET_AP_PERMOFF_CC LC_SET_AP_PERM_OFF_CC
132+
#define LC_ACTION_NOT_USED LC_ActionPoint_NOT_USED
122133
#endif
123134

124135
#endif

config/default_lc_msgstruct.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -275,8 +275,8 @@ typedef struct
275275
uint8 APResults[LC_HKAR_NUM_BYTES]; /**< \brief Packed actionpoint results data, 4 bits per actionpoint */
276276

277277
uint16 PassiveRTSExecCount; /**< \brief Total count of RTS sequences not initiated because the LC state is
278-
* set to #LC_STATE_PASSIVE or the state of the actionpoint that failed
279-
* is set to #LC_APSTATE_PASSIVE
278+
* set to #LC_AppState_PASSIVE or the state of the actionpoint that failed
279+
* is set to #LC_ActionPointState_PASSIVE
280280
*/
281281

282282
uint16 WPsInUse; /**< \brief How many watchpoints are currently in effect */

docs/dox_src/cfs_lc.dox

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -181,11 +181,11 @@
181181
commands as a response to this condition.
182182

183183
Actionpoints can be individually enabled/disabled with the #LC_SET_AP_STATE_CC ground
184-
command. The state of an actionpoint may be set to #LC_APSTATE_ACTIVE, #LC_APSTATE_PASSIVE,
185-
or #LC_APSTATE_DISABLED. These states operate in the same way as the application operating
186-
modes described above. #LC_APSTATE_PASSIVE will just disable RTS requests, while
187-
#LC_APSTATE_DISABLED will stop evaluation of the actionpoint all together. An additional
188-
state #LC_APSTATE_PERMOFF which functions the same as #LC_APSTATE_DISABLED but can only
184+
command. The state of an actionpoint may be set to #LC_ActionPointState_ACTIVE, #LC_ActionPointState_PASSIVE,
185+
or #LC_ActionPointState_DISABLED. These states operate in the same way as the application operating
186+
modes described above. #LC_ActionPointState_PASSIVE will just disable RTS requests, while
187+
#LC_ActionPointState_DISABLED will stop evaluation of the actionpoint all together. An additional
188+
state #LC_ActionPointState_PERMOFF which functions the same as #LC_ActionPointState_DISABLED but can only
189189
be changed via table load, can be set using the #LC_SET_AP_PERM_OFF_CC ground command
190190
(see \ref cfslcfaqs).
191191

@@ -259,7 +259,7 @@
259259
In the lc_platform_cfg.h file, there are configuration parameters that control use
260260
of the Critical Data Store (CDS) and the LC operation mode on application
261261
initialization. The default case is not to use the CDS and to set the application
262-
state to #LC_STATE_DISABLED.
262+
state to #LC_AppState_DISABLED.
263263
**/
264264

265265
/**
@@ -302,7 +302,7 @@
302302
The entire ADT is processed any time a sample request is received that specifies an
303303
actionpoint equal to #LC_ALL_ACTIONPOINTS. For this reason, it is important that unused
304304
entries are properly marked by setting the ADT parameter DefaultState to
305-
#LC_APSTATE_NOT_USED.
305+
#LC_ActionPoint_NOT_USED.
306306

307307
When either the WDT or ADT are updated, the corresponding results table (WRT or ART) is
308308
reset to initialization values. For each entry in the WRT, WatchResult is set to
@@ -523,7 +523,7 @@
523523
three possible conditions are true:
524524

525525
1) The actionpoint is unused (the DefaultState in the ADT is set to
526-
#LC_APSTATE_NOT_USED).
526+
#LC_ActionPoint_NOT_USED).
527527

528528
2) An actionpoint sample request (#LC_SAMPLE_AP_MID) targeting the AP has not
529529
yet been received by LC so the AP has not yet been evaluated.
@@ -551,27 +551,27 @@
551551
</I>
552552

553553
<B> (Q)
554-
How does the Actionpoint state #LC_APSTATE_PERMOFF differ from
555-
#LC_APSTATE_DISABLED?
554+
How does the Actionpoint state #LC_ActionPointState_PERMOFF differ from
555+
#LC_ActionPointState_DISABLED?
556556
</B> <BR> <BR> <I>
557-
The AP state #LC_APSTATE_PERMOFF is intended to provide a way to disable
557+
The AP state #LC_ActionPointState_PERMOFF is intended to provide a way to disable
558558
an AP so it can not easily be turned back on by mistake. Such actionpoints
559559
may not be needed after a seperation sequence or only apply to certain
560560
mission phases.
561561

562562
While the two states are treated the same way during actionpoint processing
563563
(the AP isn't evaluated), there are a few differences.
564564

565-
An AP can't be set to #LC_APSTATE_PERMOFF with the #LC_SET_AP_STATE_CC command,
565+
An AP can't be set to #LC_ActionPointState_PERMOFF with the #LC_SET_AP_STATE_CC command,
566566
it must be done with the #LC_SET_AP_PERM_OFF_CC command.
567567

568-
To set an AP to #LC_APSTATE_PERMOFF with the #LC_SET_AP_PERM_OFF_CC command, the
569-
current AP state must be #LC_APSTATE_DISABLED.
568+
To set an AP to #LC_ActionPointState_PERMOFF with the #LC_SET_AP_PERM_OFF_CC command, the
569+
current AP state must be #LC_ActionPointState_DISABLED.
570570

571571
The #LC_SET_AP_PERM_OFF_CC command can only be issued for a single actionpoint,
572572
#LC_ALL_ACTIONPOINTS is not valid as an argument for this command.
573573

574-
Once an AP is set to #LC_APSTATE_PERMOFF, it can only be changed with a new ADT
574+
Once an AP is set to #LC_ActionPointState_PERMOFF, it can only be changed with a new ADT
575575
table load.
576576
</I>
577577

@@ -592,7 +592,7 @@
592592
#LC_HKAR_STATE_NOT_USED, #LC_HKAR_STATE_ACTIVE, #LC_HKAR_STATE_PASSIVE,
593593
#LC_HKAR_STATE_DISABLED
594594

595-
An actionpoint whose current state is #LC_APSTATE_PERMOFF will have it's
595+
An actionpoint whose current state is #LC_ActionPointState_PERMOFF will have it's
596596
state reported in the APResults as #LC_HKAR_STATE_NOT_USED.
597597

598598
The numerical 2 bit values for evaluation results are defined using the
@@ -614,9 +614,9 @@
614614
Will an RTS get requested more than once if an AP stays in the #LC_ACTION_FAIL
615615
state?
616616
</B> <BR> <BR> <I>
617-
No. Assuming the current state of an actionpoint is #LC_APSTATE_ACTIVE, then
617+
No. Assuming the current state of an actionpoint is #LC_ActionPointState_ACTIVE, then
618618
when the actionpoint fails enough times to trigger an RTS, the state is set
619-
to #LC_APSTATE_PASSIVE.
619+
to #LC_ActionPointState_PASSIVE.
620620

621621
In the passive state, the AP will continue to be sampled and statistics
622622
updated, but no RTS requests will be initiated.

fsw/inc/lc_eventids.h

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -448,7 +448,7 @@
448448
*
449449
* This event message is issued when the #LC_SET_AP_STATE_CC command
450450
* has been received and the current actionpoint state is either
451-
* #LC_APSTATE_NOT_USED or #LC_APSTATE_PERMOFF which can only be changed
451+
* #LC_ActionPoint_NOT_USED or #LC_ActionPointState_PERMOFF which can only be changed
452452
* with a table load.
453453
*/
454454
#define LC_APSTATE_CURR_ERR_EID 31
@@ -498,7 +498,7 @@
498498
*
499499
* This event message is issued when the #LC_SET_AP_PERM_OFF_CC command
500500
* has been received and the current actionpoint state is not
501-
* #LC_APSTATE_DISABLED
501+
* #LC_ActionPointState_DISABLED
502502
*/
503503
#define LC_APOFF_CURR_ERR_EID 35
504504

@@ -772,7 +772,7 @@
772772
*
773773
* This event message is issued when the #LC_SAMPLE_AP_MID message
774774
* has been received and the current state for the specified
775-
* actionpoint state is either #LC_APSTATE_NOT_USED or #LC_APSTATE_PERMOFF.
775+
* actionpoint state is either #LC_ActionPoint_NOT_USED or #LC_ActionPointState_PERMOFF.
776776
*/
777777
#define LC_APSAMPLE_CURR_ERR_EID 57
778778

@@ -796,7 +796,7 @@
796796
* \par Cause:
797797
*
798798
* This event message is issued when an actionpoint fails evaluation while
799-
* the LC task operating state is #LC_STATE_PASSIVE
799+
* the LC task operating state is #LC_AppState_PASSIVE
800800
*/
801801
#define LC_PASSIVE_FAIL_DBG_EID 59
802802

@@ -808,7 +808,7 @@
808808
* \par Cause:
809809
*
810810
* This event message is issued when an actionpoint fails evaluation while
811-
* the actionpoint state is #LC_APSTATE_PASSIVE
811+
* the actionpoint state is #LC_ActionPointState_PASSIVE
812812
*/
813813
#define LC_AP_PASSIVE_FAIL_INF_EID 60
814814

fsw/src/lc_action.c

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ void LC_SampleAPs(uint16 StartIndex, uint16 EndIndex)
5050
*/
5151
CurrentAPState = LC_OperData.ARTPtr[StartIndex].CurrentState;
5252

53-
if ((CurrentAPState != LC_ACTION_NOT_USED) && (CurrentAPState != LC_APSTATE_PERMOFF))
53+
if ((CurrentAPState != LC_ActionPoint_NOT_USED) && (CurrentAPState != LC_ActionPointState_PERMOFF))
5454
{
5555
/*
5656
** Sample selected actionpoints
@@ -91,7 +91,7 @@ void LC_SampleSingleAP(uint16 APNumber)
9191
*/
9292
CurrentAPState = LC_OperData.ARTPtr[APNumber].CurrentState;
9393

94-
if ((CurrentAPState == LC_APSTATE_ACTIVE) || (CurrentAPState == LC_APSTATE_PASSIVE))
94+
if ((CurrentAPState == LC_ActionPointState_ACTIVE) || (CurrentAPState == LC_ActionPointState_PASSIVE))
9595
{
9696
/*
9797
** Evaluate the actionpoint and update the results
@@ -136,14 +136,14 @@ void LC_SampleSingleAP(uint16 APNumber)
136136
/*
137137
** We have failed enough times to request the RTS
138138
*/
139-
if (CurrentAPState == LC_APSTATE_ACTIVE)
139+
if (CurrentAPState == LC_ActionPointState_ACTIVE)
140140
{
141141
/*
142142
** Actions go to passive after they've failed
143143
*/
144-
LC_OperData.ARTPtr[APNumber].CurrentState = LC_APSTATE_PASSIVE;
144+
LC_OperData.ARTPtr[APNumber].CurrentState = LC_ActionPointState_PASSIVE;
145145

146-
if (LC_AppData.CurrentLCState == LC_STATE_ACTIVE)
146+
if (LC_AppData.CurrentLCState == LC_AppState_ACTIVE)
147147
{
148148
/*
149149
** If the LC application state is active, request the
@@ -501,15 +501,15 @@ int32 LC_ValidateADT(void *TableData)
501501
RPNPtr = TableArray[TableIndex].RPNEquation;
502502
EventType = TableArray[TableIndex].EventType;
503503

504-
if (DefaultState == LC_APSTATE_NOT_USED)
504+
if (DefaultState == LC_ActionPoint_NOT_USED)
505505
{
506506
/*
507507
** Unused table entry
508508
*/
509509
UnusedCount++;
510510
}
511-
else if ((DefaultState != LC_APSTATE_ACTIVE) && (DefaultState != LC_APSTATE_PASSIVE) &&
512-
(DefaultState != LC_APSTATE_DISABLED) && (DefaultState != LC_APSTATE_PERMOFF))
511+
else if ((DefaultState != LC_ActionPointState_ACTIVE) && (DefaultState != LC_ActionPointState_PASSIVE) &&
512+
(DefaultState != LC_ActionPointState_DISABLED) && (DefaultState != LC_ActionPointState_PERMOFF))
513513
{
514514
/*
515515
** Invalid default state

fsw/src/lc_app.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -837,7 +837,7 @@ CFE_Status_t LC_CreateTaskCDS(void)
837837
** May need to override the restored application state
838838
*/
839839

840-
#if LC_STATE_WHEN_CDS_RESTORED != LC_STATE_FROM_CDS
840+
#if LC_STATE_WHEN_CDS_RESTORED != LC_AppState_FROM_CDS
841841
LC_AppData.CurrentLCState = LC_STATE_WHEN_CDS_RESTORED;
842842
#endif
843843
}

fsw/src/lc_app.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -191,9 +191,9 @@ typedef struct
191191
uint32 RTSExecCount; /**< \brief Total count of RTS sequences initiated */
192192
uint16 PassiveRTSExecCount; /**< \brief Total count of RTS sequences not
193193
initiated because the LC state is
194-
set to #LC_STATE_PASSIVE or the state
194+
set to #LC_AppState_PASSIVE or the state
195195
of the actionpoint that failed is set to
196-
#LC_APSTATE_PASSIVE */
196+
#LC_ActionPointState_PASSIVE */
197197

198198
uint16 CDSSavedOnExit; /**< \brief Variable that tells us if we exited clean or not */
199199
uint8 CurrentLCState; /**< \brief Current LC application operating state */

0 commit comments

Comments
 (0)