From 2cf28c8044931648d453eb9b6971520ac4aabfe7 Mon Sep 17 00:00:00 2001 From: Avi Date: Tue, 1 Nov 2022 21:02:59 +1000 Subject: [PATCH] Fix #14, Refactor LC_SampleAPs to remove extraneous if statement --- fsw/src/lc_action.c | 37 +++++++++++++------------------------ 1 file changed, 13 insertions(+), 24 deletions(-) diff --git a/fsw/src/lc_action.c b/fsw/src/lc_action.c index 1f03662..eb720ae 100644 --- a/fsw/src/lc_action.c +++ b/fsw/src/lc_action.c @@ -44,39 +44,28 @@ void LC_SampleAPs(uint16 StartIndex, uint16 EndIndex) uint8 CurrentAPState; /* - ** If we're specifying a single actionpoint, make sure it's - ** current state is valid for a sample request + ** Make sure the current state of the starting actionpoint + ** in the sample is valid for a sample request */ - if (StartIndex == EndIndex) - { - CurrentAPState = LC_OperData.ARTPtr[StartIndex].CurrentState; + CurrentAPState = LC_OperData.ARTPtr[StartIndex].CurrentState; - if ((CurrentAPState != LC_APSTATE_NOT_USED) && (CurrentAPState != LC_APSTATE_PERMOFF)) - { - /* - ** Sample the specified actionpoint - */ - LC_SampleSingleAP(StartIndex); - } - else + if ((CurrentAPState != LC_ACTION_NOT_USED) && (CurrentAPState != LC_APSTATE_PERMOFF)) + { + /* + ** Sample selected actionpoints + */ + for (TableIndex = StartIndex; TableIndex <= EndIndex; TableIndex++) { - /* - ** Actionpoint isn't currently operational - */ - CFE_EVS_SendEvent(LC_APSAMPLE_CURR_ERR_EID, CFE_EVS_EventType_ERROR, - "Sample AP error, invalid current AP state: AP = %d, State = %d", StartIndex, - CurrentAPState); + LC_SampleSingleAP(TableIndex); } } else { /* - ** Sample selected actionpoints + ** Actionpoint isn't currently operational */ - for (TableIndex = StartIndex; TableIndex <= EndIndex; TableIndex++) - { - LC_SampleSingleAP(TableIndex); - } + CFE_EVS_SendEvent(LC_APSAMPLE_CURR_ERR_EID, CFE_EVS_EventType_ERROR, + "Sample AP error, invalid current AP state: AP = %d, State = %d", StartIndex, CurrentAPState); } return;