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 Mar 12, 2023
1 parent 2f177ae commit fe4d7f2
Show file tree
Hide file tree
Showing 16 changed files with 417 additions and 405 deletions.
63 changes: 32 additions & 31 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,10 +300,10 @@
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
#LC_WATCH_STALE and all other values are zeroed. For each entry in the ART,
Expand Down Expand Up @@ -520,12 +520,12 @@
</B> <BR> <BR> <I>
#LC_ACTION_STALE is an initialization value for the Actionpoint
Results Table. If an actionpoint has this ActionResult then one of
three possible conditions are true:

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

2) An actionpoint sample request (#LC_SAMPLE_AP_MID) targeting the AP has not
three possible conditions are true:
1) The actionpoint is unused (the DefaultState in the ADT is set to
#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.

3) One or more of the watchpoints that this AP depends on (as defined by
Expand All @@ -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,10 +614,11 @@
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.

>>>>>>> ad7c0e7 (Fix #16, Convert LC state macros to enums)
In the passive state, the AP will continue to be sampled and statistics
updated, but no RTS requests will be initiated.
</I>
Expand Down
10 changes: 5 additions & 5 deletions fsw/inc/lc_events.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
4 changes: 2 additions & 2 deletions fsw/inc/lc_msg.h
Original file line number Diff line number Diff line change
Expand Up @@ -183,8 +183,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: 25 additions & 15 deletions fsw/inc/lc_msgdefs.h
Original file line number Diff line number Diff line change
Expand Up @@ -39,30 +39,40 @@
#include <lc_platform_cfg.h>

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

/**
* \name LC Application States
* \{
*/
#define LC_STATE_ACTIVE 1 /**< \brief LC Application State Active */
#define LC_STATE_PASSIVE 2 /**< \brief LC Application State Pasive */
#define LC_STATE_DISABLED 3 /**< \brief LC Application State Disabled */
#define LC_STATE_FROM_CDS 4 /**< \brief Used for reset processing, not valid state */
typedef enum LC_AppState_Enum
{
LC_AppState_ACTIVE = 1, /**< \brief LC Application State Active */
LC_AppState_PASSIVE, /**< \brief LC Application State Pasive */
LC_AppState_DISABLED, /**< \brief LC Application State Disabled */
LC_AppState_FROM_CDS /**< \brief Used for reset processing, not valid state */
} LC_AppState_Enum_t;
/**\}*/

/**
* \name Actionpoint States
* \{
*/
#define LC_APSTATE_NOT_USED 0xFF /**< \brief Actionpoint unused, not valid command argument */
#define LC_APSTATE_ACTIVE 1 /**< \brief Actionpoint state active */
#define LC_APSTATE_PASSIVE 2 /**< \brief Actionpoint state passive */
#define LC_APSTATE_DISABLED 3 /**< \brief Actionpoint state disabled */
#define LC_APSTATE_PERMOFF 4 /**< \brief Actionpoint state permanently off, see #LC_SET_AP_PERM_OFF_CC */
typedef enum LC_ActionPointState_Enum
{
LC_ActionPointState_ACTIVE = 1, /**< \brief Actionpoint state active */
LC_ActionPointState_PASSIVE, /**< \brief Actionpoint state passive */
LC_ActionPointState_DISABLED, /**< \brief Actionpoint state disabled */
LC_ActionPointState_PERMOFF, /**< \brief Actionpoint state permanently off, see #LC_SET_AP_PERMOFF_CC */
LC_ActionPoint_NOT_USED = 255 /**< \brief Actionpoint unused, not valid command argument */
} LC_ActionPointState_Enum_t;
/**\}*/

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

/**
* \name Special Values for Commands
* \{
Expand Down Expand Up @@ -238,8 +248,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_HkPacket_t.CmdErrCount will increment
Expand All @@ -258,7 +268,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_SetAPPermOff_t
Expand All @@ -275,7 +285,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_HkPacket_t.CmdErrCount will increment
Expand Down Expand Up @@ -361,7 +371,7 @@

#ifndef LC_OMIT_DEPRECATED
#define LC_SET_AP_PERMOFF_CC LC_SET_AP_PERM_OFF_CC
#define LC_ACTION_NOT_USED LC_APSTATE_NOT_USED
#define LC_ACTION_NOT_USED LC_ActionPoint_NOT_USED
#endif

#endif
22 changes: 11 additions & 11 deletions fsw/inc/lc_platform_cfg.h
Original file line number Diff line number Diff line change
Expand Up @@ -120,11 +120,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 @@ -152,19 +152,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
28 changes: 14 additions & 14 deletions fsw/inc/lc_tbl.h
Original file line number Diff line number Diff line change
Expand Up @@ -47,12 +47,12 @@
typedef struct
{
uint32 Value; /**< \brief Watchpoint value at comparison that caused
the transition */
uint8 DataType; /**< \brief Same as Watchpoint Data Type (enumerated) */
the transition */
uint8 DataType; /**< \brief Same as Watchpoint Data Type (enumerated) */

uint8 Padding[3]; /**< \brief Structure padding */

CFE_TIME_SysTime_t Timestamp; /**< \brief Timstamp when the transition was detected */
CFE_TIME_SysTime_t Timestamp; /**< \brief Timstamp when the transition was detected */
} LC_WRTTransition_t;

/**
Expand All @@ -61,33 +61,33 @@ typedef struct
typedef struct
{
uint8 WatchResult; /**< \brief Result for the last evaluation of this
watchpoint (enumerated) */
watchpoint (enumerated) */

uint8 Padding[3]; /**< \brief Structure padding */

uint32 CountdownToStale; /**< \brief Number of LC Sample Actionpoint
commands still to be processed
before WatchResult becomes stale */
before WatchResult becomes stale */
uint32 EvaluationCount; /**< \brief How many times this watchpoint has
been evaluated */
been evaluated */
uint32 FalseToTrueCount; /**< \brief How many times this watchpoint has
transitioned from FALSE to TRUE */
transitioned from FALSE to TRUE */
uint32 ConsecutiveTrueCount; /**< \brief Number of consecutive times this
watchpoint has evaluated to TRUE */
watchpoint has evaluated to TRUE */
uint32 CumulativeTrueCount; /**< \brief Total number of times this watchpoint
has evaluated to TRUE */
LC_WRTTransition_t LastFalseToTrue; /**< \brief Last transition from FALSE to TRUE */
LC_WRTTransition_t LastTrueToFalse; /**< \brief Last transition from TRUE to FALSE */
has evaluated to TRUE */
LC_WRTTransition_t LastFalseToTrue; /**< \brief Last transition from FALSE to TRUE */
LC_WRTTransition_t LastTrueToFalse; /**< \brief Last transition from TRUE to FALSE */
} LC_WRTEntry_t;

/**
* \brief Actionpoint Results Table (ART) Entry
*/
typedef struct
{
uint8 ActionResult; /**< \brief Result for the last sample of this
actionpoint */
uint8 CurrentState; /**< \brief Current state of this actionpoint */
uint8 ActionResult; /**< \brief Result for the last sample of this actionpoint */

uint8 CurrentState; /**< \brief Current state of this actionpoint */

uint16 Padding; /**< \brief Structure padding */

Expand Down
Loading

0 comments on commit fe4d7f2

Please sign in to comment.