Index: firmware/App/Modes/ModeStandby.c =================================================================== diff -u -rb9d63042de23f8a85740eb6ee2689f871c76b5ef -r037f0edb0b880130563058c809ba50308f2a63e9 --- firmware/App/Modes/ModeStandby.c (.../ModeStandby.c) (revision b9d63042de23f8a85740eb6ee2689f871c76b5ef) +++ firmware/App/Modes/ModeStandby.c (.../ModeStandby.c) (revision 037f0edb0b880130563058c809ba50308f2a63e9) @@ -19,8 +19,10 @@ #include "CPLD.h" #include "DrainPump.h" #include "Heaters.h" +#include "ModeFault.h" #include "ModeStandby.h" #include "OperationModes.h" +#include "Pressures.h" #include "Reservoirs.h" #include "ROPump.h" #include "SystemComm.h" @@ -53,13 +55,16 @@ static U32 waterSampleStartTime = 0; ///< Time stamp for start of water sample state. static U32 filterFlushStartTime = 0; ///< Time stamp for start of filter flush state. static U32 filterFlushPublishTimerCounter = 0; ///< Filter flush data publish timer counter. +/// Filter flush time period in ms. +static OVERRIDE_U32_T filterFlushTimePeriod = { FILTER_FLUSH_TIME_MS, FILTER_FLUSH_TIME_MS, 0, 0 }; // ********** private function prototypes ********** static DG_STANDBY_MODE_STATE_T handleStandbyIdleState( void ); static DG_STANDBY_MODE_STATE_T handleStandbyFlushFilterState( void ); static DG_STANDBY_MODE_STATE_T handleStandbyFlushFilterIdleState( void ); static DG_STANDBY_MODE_STATE_T handleStandbySampleWaterState( void ); +static U32 getFilterFlushTimePeriod( void ); /*********************************************************************//** * @brief @@ -94,27 +99,7 @@ // re-initialize standby mode each time we transition to standby mode initStandbyMode(); - // set initial actuator states - setValveState( VRF, VALVE_STATE_R2_C_TO_NO ); - setValveState( VRI, VALVE_STATE_R1_C_TO_NO ); - setValveState( VRD, VALVE_STATE_R2_C_TO_NO ); - setValveState( VRO, VALVE_STATE_R1_C_TO_NO ); - setValveState( VPO, VALVE_STATE_NOFILL_C_TO_NO ); - setValveState( VRC, VALVE_STATE_DRAIN_C_TO_NO ); - setValveState( VDR, VALVE_STATE_DRAIN_C_TO_NO ); - setValveState( VPI, VALVE_STATE_CLOSED ); - setValveState( VSP, VALVE_STATE_CLOSED ); - - signalROPumpHardStop(); - signalDrainPumpHardStop(); - stopPrimaryHeater(); - stopTrimmerHeater(); - requestConcentratePumpsOff( CONCENTRATEPUMPS_CP1_ACID ); - requestConcentratePumpsOff( CONCENTRATEPUMPS_CP2_BICARB ); - - // UV off - turnOffUVReactor( INLET_UV_REACTOR ); - turnOffUVReactor( OUTLET_UV_REACTOR ); + deenergizeActuators(); } /*********************************************************************//** @@ -181,7 +166,11 @@ flushFilterRequest = FALSE; filterFlushStartTime = getMSTimerCount(); setValveState( VPI, VALVE_STATE_OPEN ); - setValveState( VPD, VALVE_STATE_OPEN ); // TODO: VPD drain state is closed for V3 +#ifndef V_2_SYSTEM + setValveState( VPD, VALVE_STATE_OPEN_C_TO_NC ); +#else + setValveState( VPD, VALVE_STATE_OPEN ); // TODO: VPD drain state is closed for V3 +#endif state = DG_STANDBY_MODE_STATE_FLUSH_FILTER; } else if ( TRUE == pendingStartDGRequest ) @@ -204,16 +193,19 @@ static DG_STANDBY_MODE_STATE_T handleStandbyFlushFilterState( void ) { DG_STANDBY_MODE_STATE_T state = DG_STANDBY_MODE_STATE_FLUSH_FILTER; + U32 const filterFlushTimePeriod_ms = getFilterFlushTimePeriod(); - if ( TRUE == didTimeout( filterFlushStartTime, FILTER_FLUSH_TIME_MS ) ) + checkInletPressure(); + + if ( TRUE == didTimeout( filterFlushStartTime, filterFlushTimePeriod_ms ) ) { setValveState( VPI, VALVE_STATE_CLOSED ); state = DG_STANDBY_MODE_STATE_FLUSH_FILTER_IDLE; } if ( FILTER_FLUSH_DATA_PUBLISH_INTERVAL <= filterFlushPublishTimerCounter++ ) { - U32 const timeout = FILTER_FLUSH_TIME_MS / MS_PER_SECOND; + U32 const timeout = filterFlushTimePeriod_ms / MS_PER_SECOND; U32 const countdown = timeout - ( calcTimeSince( filterFlushStartTime ) / MS_PER_SECOND ); filterFlushPublishTimerCounter = 0; @@ -247,7 +239,11 @@ if ( TRUE == endSampleWaterRequest ) { setValveState( VPI, VALVE_STATE_CLOSED ); +#ifndef V_2_SYSTEM + setValveState( VPD, VALVE_STATE_DRAIN_C_TO_NO ); +#else setValveState( VPD, VALVE_STATE_CLOSED ); +#endif state = DG_STANDBY_MODE_STATE_IDLE; } @@ -271,7 +267,12 @@ { stopSampleWaterRequest = FALSE; setValveState( VSP, VALVE_STATE_CLOSED ); + +#ifndef V_2_SYSTEM + setValveState( VPD, VALVE_STATE_DRAIN_C_TO_NO ); +#else setValveState( VPD, VALVE_STATE_OPEN ); // TODO: VPD drain state is closed for V3 +#endif state = DG_STANDBY_MODE_STATE_FLUSH_FILTER_IDLE; } @@ -361,6 +362,29 @@ /*********************************************************************//** * @brief + * The startDGFlush function starts DG flush mode. + * @details Inputs: standbyState + * @details Outputs: none + * @return: TRUE if the switch was successful, otherwise FALSE + *************************************************************************/ +BOOL startDGFlush( void ) +{ + BOOL result = FALSE; + + // If DG is in standby mode or in the solo mode and the standby mode is in Idle state, request DG flush + if ( ( DG_MODE_STAN == getCurrentOperationMode() && DG_STANDBY_MODE_STATE_IDLE == standbyState ) || + DG_MODE_SOLO == getCurrentOperationMode() ) + { + requestNewOperationMode( DG_MODE_FLUS ); + + result = TRUE; + } + + return result; +} + +/*********************************************************************//** + * @brief * The startDGHeatDisinfect function starts heat disinfect mode. * @details Inputs: standbyState * @details Outputs: none @@ -375,7 +399,28 @@ ( DG_MODE_SOLO == getCurrentOperationMode() ) ) { requestNewOperationMode( DG_MODE_HEAT ); + status = TRUE; + } + return status; +} + +/*********************************************************************//** + * @brief + * The startDGChemicalDisinfect function starts chemical disinfect mode. + * @details Inputs: standbyState + * @details Outputs: none + * @return: TRUE if the switch was successful + *************************************************************************/ +BOOL startDGChemicalDisinfect( void ) +{ + BOOL status = FALSE; + + // If DG is in standby mode and the standby mode is in Idle, request chemical disinfect + // Chemical disinfect cannot be run in solo mode because the user has to confirm that the acid is inserted or removed + //if ( ( DG_MODE_STAN == getCurrentOperationMode() ) && ( DG_STANDBY_MODE_STATE_IDLE == standbyState ) ) TODO un-comment this line. This is commented to be able to run chemical without HD for development + { + requestNewOperationMode( DG_MODE_CHEM ); status = TRUE; } @@ -394,4 +439,74 @@ return standbyState; } +/*********************************************************************//** + * @brief + * The getFilterFlushTimePeriod function gets the filter flush time period. + * @details Inputs: filterFlushTimePeriod + * @details Outputs: none + * @return the current filter flush time period (in ms). + *************************************************************************/ +static U32 getFilterFlushTimePeriod( void ) +{ + U32 result = filterFlushTimePeriod.data; + + if ( OVERRIDE_KEY == filterFlushTimePeriod.override ) + { + result = filterFlushTimePeriod.ovData; + } + + return result; +} + + +/************************************************************************* + * TEST SUPPORT FUNCTIONS + *************************************************************************/ + + +/*********************************************************************//** + * @brief + * The testSetFilterFlushTimePeriodOverride function overrides the filter + * flush time period. + * @details Inputs: none + * @details Outputs: filterFlushTimePeriod + * @param value override concentrate pump data publish interval with (in ms) + * @return TRUE if override successful, FALSE if not + *************************************************************************/ +BOOL testSetFilterFlushTimePeriodOverride( U32 value ) +{ + BOOL result = FALSE; + + if ( TRUE == isTestingActivated() ) + { + result = TRUE; + filterFlushTimePeriod.override = OVERRIDE_KEY; + filterFlushTimePeriod.ovData = value; + } + + return result; +} + +/*********************************************************************//** + * @brief + * The testResetFilterFlushTimePeriodOverride function resets the + * override of the filter flush time period. + * @details Inputs: none + * @details Outputs: filterFlushTimePeriod + * @return TRUE if override reset successful, FALSE if not + *************************************************************************/ +BOOL testResetFilterFlushTimePeriodOverride( void ) +{ + BOOL result = FALSE; + + if ( TRUE == isTestingActivated() ) + { + result = TRUE; + filterFlushTimePeriod.override = OVERRIDE_RESET; + filterFlushTimePeriod.ovData = filterFlushTimePeriod.ovInitData; + } + + return result; +} + /**@}*/