From 440e5e1eec206c2ed766a19c905ed0b4dc3d16f0 Mon Sep 17 00:00:00 2001 From: Avi Date: Wed, 2 Nov 2022 18:26:30 +1000 Subject: [PATCH] Fix #16, Convert LC state macros to enums --- fsw/src/lc_msg.h | 4 +-- fsw/src/lc_msgdefs.h | 32 ++++++++++++++--------- fsw/src/lc_tbl.h | 62 ++++++++++++++++++++++---------------------- 3 files changed, 53 insertions(+), 45 deletions(-) diff --git a/fsw/src/lc_msg.h b/fsw/src/lc_msg.h index afc7671..5143a5d 100644 --- a/fsw/src/lc_msg.h +++ b/fsw/src/lc_msg.h @@ -77,8 +77,8 @@ typedef struct { CFE_MSG_CommandHeader_t CmdHeader; /**< \brief Command Header */ - uint16 APNumber; /**< \brief Which actionpoint(s) to change */ - uint16 NewAPState; /**< \brief New actionpoint state */ + uint16 APNumber; /**< \brief Which actionpoint(s) to change */ + LC_APState_t NewAPState; /**< \brief New actionpoint state */ } LC_SetAPState_t; /** diff --git a/fsw/src/lc_msgdefs.h b/fsw/src/lc_msgdefs.h index 80a6db6..6c13a90 100644 --- a/fsw/src/lc_msgdefs.h +++ b/fsw/src/lc_msgdefs.h @@ -35,29 +35,37 @@ #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 +{ + LC_STATE_ACTIVE = 1, /**< \brief LC Application State Active */ + LC_STATE_PASSIVE, /**< \brief LC Application State Pasive */ + LC_STATE_DISABLED, /**< \brief LC Application State Disabled */ + LC_STATE_FROM_CDS /**< \brief Used for reset processing, not valid state */ +} LC_AppState_t; /** * \name Actionpoint States * \{ */ -#define LC_ACTION_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_PERMOFF_CC */ -/**\}*/ +typedef enum LC_APState +{ + LC_APSTATE_ACTIVE = 1, /**< \brief Actionpoint state active */ + LC_APSTATE_PASSIVE, /**< \brief Actionpoint state passive */ + LC_APSTATE_DISABLED, /**< \brief Actionpoint state disabled */ + LC_APSTATE_PERMOFF, /**< \brief Actionpoint state permanently off, see #LC_SET_AP_PERMOFF_CC */ + LC_ACTION_NOT_USED = 255 /**< \brief Actionpoint unused, not valid command argument */ +} LC_APState_t; + +/************************************************************************ + * Macro Definitions + ************************************************************************/ /** * \name Special Values for Commands diff --git a/fsw/src/lc_tbl.h b/fsw/src/lc_tbl.h index 302dfe4..eb649e8 100644 --- a/fsw/src/lc_tbl.h +++ b/fsw/src/lc_tbl.h @@ -90,30 +90,30 @@ typedef struct */ typedef struct { - uint8 DefaultState; /**< \brief Default state for this AP (enumerated) - States are defined in lc_msgdefs.h */ - uint8 MaxPassiveEvents; /**< \brief Max number of events before filter - - RTS not started because AP is passive */ - uint8 MaxPassFailEvents; /**< \brief Max number of events before filter - - AP result transition from pass to fail */ - uint8 MaxFailPassEvents; /**< \brief Max number of events before filter - - AP result transition from fail to pass */ - uint16 RTSId; /**< \brief RTS to request if this AP fails */ - uint16 MaxFailsBeforeRTS; /**< \brief How may consecutive failures before - an RTS request is issued */ - - uint16 RPNEquation[LC_MAX_RPN_EQU_SIZE]; /**< \brief Reverse Polish Equation that - specifies when this actionpoint - should fail */ + LC_APState_t DefaultState; /**< \brief Default state for this AP (enumerated) + States are defined in lc_msgdefs.h */ + uint8 MaxPassiveEvents; /**< \brief Max number of events before filter + - RTS not started because AP is passive */ + uint8 MaxPassFailEvents; /**< \brief Max number of events before filter + - AP result transition from pass to fail */ + uint8 MaxFailPassEvents; /**< \brief Max number of events before filter + - AP result transition from fail to pass */ + uint16 RTSId; /**< \brief RTS to request if this AP fails */ + uint16 MaxFailsBeforeRTS; /**< \brief How may consecutive failures before + an RTS request is issued */ + + uint16 RPNEquation[LC_MAX_RPN_EQU_SIZE]; /**< \brief Reverse Polish Equation + that specifies when this + actionpoint should fail */ uint16 EventType; /**< \brief Event type used for event msg if AP fails: #CFE_EVS_EventType_INFORMATION, #CFE_EVS_EventType_DEBUG, #CFE_EVS_EventType_ERROR, - or #CFE_EVS_EventType_CRITICAL */ + or #CFE_EVS_EventType_CRITICAL */ uint16 EventID; /**< \brief Event ID used for event msg if AP fails - See lc_events.h for those already in use */ + See lc_events.h for those already in use */ char EventText[LC_MAX_ACTION_TEXT]; /**< \brief Text used for the event msg when this AP fails */ @@ -125,12 +125,12 @@ typedef struct 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; /** @@ -139,23 +139,23 @@ 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; /** @@ -163,9 +163,9 @@ typedef struct */ 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 */ + + LC_APState_t CurrentState; /**< \brief Current state of this actionpoint */ uint16 Padding; /**< \brief Structure padding */