Index: firmware/App/Modes/FPModes/ModePreGenPermeate.c =================================================================== diff -u -r8d27c30384b9bce99420fc0751d359c4b3871ea4 -r3e1af7cc2576e347ab8bdf2f400196b2301def07 --- firmware/App/Modes/FPModes/ModePreGenPermeate.c (.../ModePreGenPermeate.c) (revision 8d27c30384b9bce99420fc0751d359c4b3871ea4) +++ firmware/App/Modes/FPModes/ModePreGenPermeate.c (.../ModePreGenPermeate.c) (revision 3e1af7cc2576e347ab8bdf2f400196b2301def07) @@ -7,8 +7,8 @@ * * @file ModePreGenPermeate.c * -* @author (last) “rkallala” -* @date (last) 29-Jan-2026 +* @author (last) Raghu Kallala +* @date (last) 31-Mar-2026 * * @author (original) Michael Garthwaite * @date (original) 08-Sep-2025 @@ -18,6 +18,7 @@ #include "BoostPump.h" #include "FPModeStandby.h" #include "FPOperationModes.h" +#include "Level.h" #include "MessageSupport.h" #include "Messaging.h" #include "ModeGenPermeate.h" @@ -550,4 +551,89 @@ return result; } +/*********************************************************************//** + * @brief + * The testValidatePreGenPChangeReq function validate whether requested + * sub mode change is legal or not. + * @details \b Inputs: none + * @details \b Outputs: none + * @param newSubMode the enumerated sub state of the mode. + * @return TRUE if request is legal, FALSE if not. + *************************************************************************/ +BOOL testValidatePreGenPChangeReq( U32 newSubMode ) +{ + BOOL result = FALSE; + LEVEL_STATE_T level = getLevelStatus( P25_LEVL ); + + if ( newSubMode < NUM_OF_FP_PRE_GENW_MODE_STATES ) + { + switch ( newSubMode ) + { + case FP_PRE_GENP_CONCENTRATE_FLUSH: + result = (( LEVEL_STATE_HIGH == level ) ? TRUE : FALSE); + break; + + case FP_PRE_GENP_INLET_PRESSURE_CHECK: + case FP_PRE_GENP_FILTER_FLUSH: + case FP_PRE_GENP_PERMEATE_FLUSH: + case FP_PRE_GENP_VERIFY_WATER: + result = TRUE; + break; + + // TODO change once pause state is implemented + case FP_PRE_GENP_PAUSED: + default: + break; + } + } + + return result; +} + +/*********************************************************************//** + * @brief + * The testSignalNewPreGenPSubMode function requests transition to a new + * PreGen Permeate sub mode. + * @details \b Inputs: none + * @details \b Outputs: preGenPState + * @param newSubMode the enumerated sub state of the mode. + * @return none + *************************************************************************/ +void testSignalNewPreGenPSubMode( U32 newSubMode ) +{ + if ( newSubMode < NUM_OF_FP_PRE_GENW_MODE_STATES ) + { + preGenPState = (FP_PRE_GENP_MODE_STATE_T)newSubMode; + // handle the prerequisite if any + switch ( newSubMode ) + { + case FP_PRE_GENP_INLET_PRESSURE_CHECK: + resetInletPressureCheckSignals(); + break; + + case FP_PRE_GENP_FILTER_FLUSH: + resetFilterFlushSignals(); + signalStartFilterFlush(); + break; + + case FP_PRE_GENP_PERMEATE_FLUSH: + resetPermeateFlushSignals(); + signalStartPermeateFlush(); + break; + + case FP_PRE_GENP_CONCENTRATE_FLUSH: + resetConcentrateFlushSignals(); + signalStartConcentrateFlush(); + break; + + // Require no special handling for now (update if required in future) + case FP_PRE_GENP_VERIFY_WATER: + case FP_PRE_GENP_PAUSED: + default: + break; + } + setModePreGenPTransition( preGenPState ); + } +} + /**@}*/