Skip to content

Commit

Permalink
Fix nasa#16, Convert LC state macros to enums
Browse files Browse the repository at this point in the history
  • Loading branch information
thnkslprpt committed May 5, 2023
1 parent 40f9480 commit c34dd87
Show file tree
Hide file tree
Showing 15 changed files with 371 additions and 370 deletions.
10 changes: 5 additions & 5 deletions config/default_lc_fcncodes.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
#define LC_FCNCODES_H

/************************************************************************
* Macro Definitions
* Type Definitions
************************************************************************/

/**
Expand Down Expand Up @@ -152,8 +152,8 @@
* - Invalid actionpoint state specified in command message
* - Actionpoint number specified in command message is
* out of range
* - Actionpoint current state is either #LC_APSTATE_NOT_USED
* or #LC_APSTATE_PERMOFF
* - Actionpoint current state is either #LC_ActionPoint_NOT_USED
* or #LC_ActionPointState_PERMOFF
*
* \par Evidence of failure may be found in the following telemetry:
* - #LC_HkTlm_Payload_t.CmdErrCount will increment
Expand All @@ -172,7 +172,7 @@
* \brief Set AP Permanently Off
*
* \par Description
* Set the specified actionpoint's state to #LC_APSTATE_PERMOFF
* Set the specified actionpoint's state to #LC_ActionPointState_PERMOFF
*
* \par Command Structure
* #LC_SetAPPermOffCmd_t
Expand All @@ -189,7 +189,7 @@
* - Command packet length not as expected
* - Actionpoint number specified in command message is
* out of range
* - Actionpoint current state is not #LC_APSTATE_DISABLED
* - Actionpoint current state is not #LC_ActionPointState_DISABLED
*
* \par Evidence of failure may be found in the following telemetry:
* - #LC_HkTlm_Payload_t.CmdErrCount will increment
Expand Down
22 changes: 11 additions & 11 deletions config/default_lc_internal_cfg.h
Original file line number Diff line number Diff line change
Expand Up @@ -78,11 +78,11 @@
*
* \par Limits:
* This parameter must be one of the following:
* #LC_STATE_ACTIVE
* #LC_STATE_PASSIVE
* #LC_STATE_DISABLED
* #LC_AppState_ACTIVE
* #LC_AppState_PASSIVE
* #LC_AppState_DISABLED
*/
#define LC_STATE_POWER_ON_RESET LC_STATE_DISABLED
#define LC_STATE_POWER_ON_RESET LC_AppState_DISABLED

/**
* \brief Save data to CDS compiler switch
Expand Down Expand Up @@ -110,19 +110,19 @@
* is set to true, and provides a way to override any state LC
* may have been operating in prior to the reset occurring.
*
* If this is set to LC_STATE_FROM_CDS and LC_SAVE_TO_CDS is set
* If this is set to LC_AppState_FROM_CDS and LC_SAVE_TO_CDS is set
* to true, then the LC state will be preserved across resets and
* restored. If this is not set to LC_STATE_FROM_CDS, the state
* restored. If this is not set to LC_AppState_FROM_CDS, the state
* saved in the CDS is overwritten by the state assigned here.
*
* \par Limits:
* This parameter must be one of the following:
* #LC_STATE_ACTIVE
* #LC_STATE_PASSIVE
* #LC_STATE_DISABLED
* #LC_STATE_FROM_CDS
* #LC_AppState_ACTIVE
* #LC_AppState_PASSIVE
* #LC_AppState_DISABLED
* #LC_AppState_FROM_CDS
*/
#define LC_STATE_WHEN_CDS_RESTORED LC_STATE_FROM_CDS
#define LC_STATE_WHEN_CDS_RESTORED LC_AppState_FROM_CDS

/**
* \brief Watchpoint Definition Table (WDT) filename
Expand Down
4 changes: 2 additions & 2 deletions config/default_lc_msgstruct.h
Original file line number Diff line number Diff line change
Expand Up @@ -275,8 +275,8 @@ typedef struct
uint8 APResults[LC_HKAR_NUM_BYTES]; /**< \brief Packed actionpoint results data, 4 bits per actionpoint */

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

uint16 WPsInUse; /**< \brief How many watchpoints are currently in effect */
Expand Down
40 changes: 20 additions & 20 deletions docs/dox_src/cfs_lc.dox
Original file line number Diff line number Diff line change
Expand Up @@ -181,11 +181,11 @@
commands as a response to this condition.

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

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

/**
Expand Down Expand Up @@ -300,9 +300,9 @@
the WDT parameter DataType to #LC_DATA_WATCH_NOT_USED.

The entire ADT is processed anytime a sample request is received that specifies an
actionpoint equal to #LC_ALL_ACTIONPOINTS. For this reason, it is important that unused
entries are properly marked by setting the ADT parameter DefaultState to
#LC_APSTATE_NOT_USED.
actionpoint equal to #LC_ALL_ACTIONPOINTS. For this reason, it is important that unused
entries are properly marked by setting the ADT parameter DefaultState to
#LC_ActionPoint_NOT_USED.

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

1) The actionpoint is unused (the DefaultState in the ADT is set to
#LC_APSTATE_NOT_USED).
#LC_ActionPoint_NOT_USED).

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

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

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

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

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

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

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

Expand All @@ -592,7 +592,7 @@
#LC_HKAR_STATE_NOT_USED, #LC_HKAR_STATE_ACTIVE, #LC_HKAR_STATE_PASSIVE,
#LC_HKAR_STATE_DISABLED

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

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

In the passive state, the AP will continue to be sampled and statistics
updated, but no RTS requests will be initiated.
Expand Down
10 changes: 5 additions & 5 deletions fsw/inc/lc_eventids.h
Original file line number Diff line number Diff line change
Expand Up @@ -448,7 +448,7 @@
*
* This event message is issued when the #LC_SET_AP_STATE_CC command
* has been received and the current actionpoint state is either
* #LC_APSTATE_NOT_USED or #LC_APSTATE_PERMOFF which can only be changed
* #LC_ActionPoint_NOT_USED or #LC_ActionPointState_PERMOFF which can only be changed
* with a table load.
*/
#define LC_APSTATE_CURR_ERR_EID 31
Expand Down Expand Up @@ -498,7 +498,7 @@
*
* This event message is issued when the #LC_SET_AP_PERM_OFF_CC command
* has been received and the current actionpoint state is not
* #LC_APSTATE_DISABLED
* #LC_ActionPointState_DISABLED
*/
#define LC_APOFF_CURR_ERR_EID 35

Expand Down Expand Up @@ -772,7 +772,7 @@
*
* This event message is issued when the #LC_SAMPLE_AP_MID message
* has been received and the current state for the specified
* actionpoint state is either #LC_APSTATE_NOT_USED or #LC_APSTATE_PERMOFF.
* actionpoint state is either #LC_ActionPoint_NOT_USED or #LC_ActionPointState_PERMOFF.
*/
#define LC_APSAMPLE_CURR_ERR_EID 57

Expand All @@ -796,7 +796,7 @@
* \par Cause:
*
* This event message is issued when an actionpoint fails evaluation while
* the LC task operating state is #LC_STATE_PASSIVE
* the LC task operating state is #LC_AppState_PASSIVE
*/
#define LC_PASSIVE_FAIL_DBG_EID 59

Expand All @@ -808,7 +808,7 @@
* \par Cause:
*
* This event message is issued when an actionpoint fails evaluation while
* the actionpoint state is #LC_APSTATE_PASSIVE
* the actionpoint state is #LC_ActionPointState_PASSIVE
*/
#define LC_AP_PASSIVE_FAIL_INF_EID 60

Expand Down
16 changes: 8 additions & 8 deletions fsw/src/lc_action.c
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ void LC_SampleAPs(uint16 StartIndex, uint16 EndIndex)
*/
CurrentAPState = LC_OperData.ARTPtr[StartIndex].CurrentState;

if ((CurrentAPState != LC_ACTION_NOT_USED) && (CurrentAPState != LC_APSTATE_PERMOFF))
if ((CurrentAPState != LC_ActionPoint_NOT_USED) && (CurrentAPState != LC_ActionPointState_PERMOFF))
{
/*
** Sample selected actionpoints
Expand Down Expand Up @@ -91,7 +91,7 @@ void LC_SampleSingleAP(uint16 APNumber)
*/
CurrentAPState = LC_OperData.ARTPtr[APNumber].CurrentState;

if ((CurrentAPState == LC_APSTATE_ACTIVE) || (CurrentAPState == LC_APSTATE_PASSIVE))
if ((CurrentAPState == LC_ActionPointState_ACTIVE) || (CurrentAPState == LC_ActionPointState_PASSIVE))
{
/*
** Evaluate the actionpoint and update the results
Expand Down Expand Up @@ -136,14 +136,14 @@ void LC_SampleSingleAP(uint16 APNumber)
/*
** We have failed enough times to request the RTS
*/
if (CurrentAPState == LC_APSTATE_ACTIVE)
if (CurrentAPState == LC_ActionPointState_ACTIVE)
{
/*
** Actions go to passive after they've failed
*/
LC_OperData.ARTPtr[APNumber].CurrentState = LC_APSTATE_PASSIVE;
LC_OperData.ARTPtr[APNumber].CurrentState = LC_ActionPointState_PASSIVE;

if (LC_AppData.CurrentLCState == LC_STATE_ACTIVE)
if (LC_AppData.CurrentLCState == LC_AppState_ACTIVE)
{
/*
** If the LC application state is active, request the
Expand Down Expand Up @@ -501,15 +501,15 @@ int32 LC_ValidateADT(void *TableData)
RPNPtr = TableArray[TableIndex].RPNEquation;
EventType = TableArray[TableIndex].EventType;

if (DefaultState == LC_APSTATE_NOT_USED)
if (DefaultState == LC_ActionPoint_NOT_USED)
{
/*
** Unused table entry
*/
UnusedCount++;
}
else if ((DefaultState != LC_APSTATE_ACTIVE) && (DefaultState != LC_APSTATE_PASSIVE) &&
(DefaultState != LC_APSTATE_DISABLED) && (DefaultState != LC_APSTATE_PERMOFF))
else if ((DefaultState != LC_ActionPointState_ACTIVE) && (DefaultState != LC_ActionPointState_PASSIVE) &&
(DefaultState != LC_ActionPointState_DISABLED) && (DefaultState != LC_ActionPointState_PERMOFF))
{
/*
** Invalid default state
Expand Down
2 changes: 1 addition & 1 deletion fsw/src/lc_app.c
Original file line number Diff line number Diff line change
Expand Up @@ -837,7 +837,7 @@ int32 LC_CreateTaskCDS(void)
** May need to override the restored application state
*/

#if LC_STATE_WHEN_CDS_RESTORED != LC_STATE_FROM_CDS
#if LC_STATE_WHEN_CDS_RESTORED != LC_AppState_FROM_CDS
LC_AppData.CurrentLCState = LC_STATE_WHEN_CDS_RESTORED;
#endif
}
Expand Down
4 changes: 2 additions & 2 deletions fsw/src/lc_app.h
Original file line number Diff line number Diff line change
Expand Up @@ -191,9 +191,9 @@ typedef struct
uint32 RTSExecCount; /**< \brief Total count of RTS sequences initiated */
uint16 PassiveRTSExecCount; /**< \brief Total count of RTS sequences not
initiated because the LC state is
set to #LC_STATE_PASSIVE or the state
set to #LC_AppState_PASSIVE or the state
of the actionpoint that failed is set to
#LC_APSTATE_PASSIVE */
#LC_ActionPointState_PASSIVE */

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

0 comments on commit c34dd87

Please sign in to comment.