Index: firmware/App/Modes/ModeHeatDisinfect.c =================================================================== diff -u -rc20d71064bad67c2db392c6383bb410e8a7dfa2a -r9ce06772b2f651c57144327e6cbf886e2bc22dee --- firmware/App/Modes/ModeHeatDisinfect.c (.../ModeHeatDisinfect.c) (revision c20d71064bad67c2db392c6383bb410e8a7dfa2a) +++ firmware/App/Modes/ModeHeatDisinfect.c (.../ModeHeatDisinfect.c) (revision 9ce06772b2f651c57144327e6cbf886e2bc22dee) @@ -22,6 +22,7 @@ #include "ModeHeatDisinfect.h" #include "OperationModes.h" #include "Pressures.h" +#include "Reservoirs.h" #include "ROPump.h" #include "SystemCommMessages.h" #include "TaskGeneral.h" @@ -47,9 +48,10 @@ #define MAX_START_STATE_TEMP_SENSORS_DIFF_C 1.0 ///< Max start state TDi and TRo difference tolerance in C. // Drain R1 & R2 states defines -#define DRAIN_PUMP_TARGET_RPM 2700 ///< Drain pump target RPM during drain. +#define DRAIN_PUMP_TARGET_RPM 1800 ///< Drain pump target RPM during drain. #define RSRVRS_INITIAL_DRAIN_TIME_OUT_MS ( 60 * MS_PER_SECOND ) ///< Reservoirs 1 & 2 initial drain time out in milliseconds. #define RSRVRS_EMPTY_VOL_ML 50.0 ///< Reservoirs 1 & 2 empty volume in mL. //TODO Change this value to actual value +#define DRAIN_WEIGH_UNCHANGE_TIMEOUT ( 2 * MS_PER_SECOND ) ///< Time period of unchanged weight during draining before timeout. // Flush drain path state defines #define FLUSH_DRAIN_WAIT_TIME_MS ( 60 * MS_PER_SECOND ) ///< Flush Drain path wait time in milliseconds. @@ -92,7 +94,7 @@ R1 = 0, ///< Reservoir 1 R2, ///< Reservoir 2 NUM_OF_RSRVRS ///< Number of reservoirs -} RSRVRS_T; +} RSRVRS_T; //TODO remove /// TODO remove? typedef enum rsvrs_status @@ -150,7 +152,7 @@ static void resetActuators( void ); static void setModeToFailed( DG_HEAT_DISINFECT_STATE_T state ); static BOOL isRsrvrFull( RSRVRS_T r, F32 targetVol, U32 timeout, DG_HEAT_DISINFECT_STATE_T state ); -static BOOL isRsrvrEmpty( RSRVRS_T r, U32 timeout, DG_HEAT_DISINFECT_STATE_T failedState ); +static BOOL isRsrvrEmpty( DG_RESERVOIR_ID_T r, U32 drainSteadyStateTimeout, U32 timeout, DG_HEAT_DISINFECT_STATE_T failedState ); static BOOL isStateHeatDisinfectComplete( DG_HEAT_DISINFECT_STATE_T state ); static void publishHeatDisinfectData( void ); @@ -384,7 +386,7 @@ { DG_HEAT_DISINFECT_STATE_T state = DG_HEAT_DISINFECT_STATE_DRAIN_R1; - if ( isRsrvrEmpty( R1, RSRVRS_INITIAL_DRAIN_TIME_OUT_MS, state ) ) + if ( isRsrvrEmpty( DG_RESERVOIR_1, DRAIN_WEIGH_UNCHANGE_TIMEOUT, RSRVRS_INITIAL_DRAIN_TIME_OUT_MS, state ) ) { isR1Full = FALSE; @@ -428,7 +430,7 @@ { DG_HEAT_DISINFECT_STATE_T state = DG_HEAT_DISINFECT_STATE_DRAIN_R2; - if ( isRsrvrEmpty( R2, RSRVRS_INITIAL_DRAIN_TIME_OUT_MS, state ) ) + if ( isRsrvrEmpty( DG_RESERVOIR_2, DRAIN_WEIGH_UNCHANGE_TIMEOUT, RSRVRS_INITIAL_DRAIN_TIME_OUT_MS, state ) ) { isR2Full = FALSE; @@ -610,7 +612,7 @@ // If reservoir 1 is empty, turn off the drain pump if ( FALSE == isR1Full ) { - isR1Full = isRsrvrEmpty( R1, RSRVRS_DRAIN_TIMEOUT_MS, state ); + isR1Full = isRsrvrEmpty( DG_RESERVOIR_1, DRAIN_WEIGH_UNCHANGE_TIMEOUT, RSRVRS_INITIAL_DRAIN_TIME_OUT_MS, state ); // Done with draining R1 signalDrainPumpHardStop(); @@ -661,7 +663,7 @@ DG_HEAT_DISINFECT_STATE_T state = DG_HEAT_DISINFECT_STATE_FLUSH_DRAIN_R2; // If reservoir 2 is empty, set the drain valve to drain R1 - if ( isRsrvrEmpty( R2, RSRVRS_DRAIN_TIMEOUT_MS, state ) ) + if (isRsrvrEmpty( DG_RESERVOIR_2, DRAIN_WEIGH_UNCHANGE_TIMEOUT, RSRVRS_INITIAL_DRAIN_TIME_OUT_MS, state ) ) { setValveState( VRD, VALVE_STATE_R1_C_TO_NC ); // Start the timer for drain timeout @@ -685,7 +687,7 @@ DG_HEAT_DISINFECT_STATE_T state = DG_HEAT_DISINFECT_STATE_FLUSH_DRAIN_R1; // If reservoir 1 is empty, set the state to fill water state - if ( isRsrvrEmpty( R1, RSRVRS_DRAIN_TIMEOUT_MS, state ) ) + if ( isRsrvrEmpty( DG_RESERVOIR_1, DRAIN_WEIGH_UNCHANGE_TIMEOUT, RSRVRS_INITIAL_DRAIN_TIME_OUT_MS, state ) ) { setValveState( VPI, VALVE_STATE_OPEN ); setValveState( VPD, VALVE_STATE_OPEN_C_TO_NO ); @@ -885,7 +887,7 @@ { DG_HEAT_DISINFECT_STATE_T state = DG_HEAT_DISINFECT_STATE_MIX_DRAIN_R1; - if ( isRsrvrEmpty( R1, RSRVRS_DRAIN_TIMEOUT_MS, state ) ) + if ( isRsrvrEmpty( DG_RESERVOIR_1, DRAIN_WEIGH_UNCHANGE_TIMEOUT, RSRVRS_INITIAL_DRAIN_TIME_OUT_MS, state ) ) { isR1Full = FALSE; @@ -911,7 +913,7 @@ { DG_HEAT_DISINFECT_STATE_T state = DG_HEAT_DISINFECT_STATE_MIX_DRAIN_R2; - if ( isRsrvrEmpty( R2, RSRVRS_DRAIN_TIMEOUT_MS, state ) ) + if ( isRsrvrEmpty( DG_RESERVOIR_2, DRAIN_WEIGH_UNCHANGE_TIMEOUT, RSRVRS_INITIAL_DRAIN_TIME_OUT_MS, state ) ) { isR2Full = FALSE; @@ -991,7 +993,7 @@ if ( isR1Full ) { // Since reservoir 1 is being filled up at a lower flow rate, the timeout is twice as long as a normal fill up - isR1Full = isRsrvrEmpty( R1, RSRVRS_DRAIN_TIMEOUT_MS, state ); + isR1Full = isRsrvrEmpty( DG_RESERVOIR_1, DRAIN_WEIGH_UNCHANGE_TIMEOUT, RSRVRS_INITIAL_DRAIN_TIME_OUT_MS, state ); // Done with draining R1 signalDrainPumpHardStop(); @@ -1162,32 +1164,23 @@ * @param state is the state that called this function * @return none *************************************************************************/ -static BOOL isRsrvrEmpty( RSRVRS_T r, U32 timeout, DG_HEAT_DISINFECT_STATE_T state ) +static BOOL isRsrvrEmpty( DG_RESERVOIR_ID_T r, U32 drainSteadyStateTimeout, U32 timeout, DG_HEAT_DISINFECT_STATE_T failedState ) { - BOOL rsrvrStatus = FALSE; - F32 volume = 0.0; + BOOL isDrainComplete = FALSE; - if ( r == R1 ) - { - volume = getLoadCellFilteredWeight( LOAD_CELL_RESERVOIR_1_PRIMARY ); - } - else if ( r == R2 ) - { - volume = getLoadCellFilteredWeight( LOAD_CELL_RESERVOIR_2_PRIMARY ); - } + isDrainComplete = hasTargetDrainVolumeBeenReached( r, drainSteadyStateTimeout); - if ( volume < 450 ) //RSRVRS_EMPTY_VOL_ML ) + if ( TRUE == isDrainComplete ) { - rsrvrStatus = TRUE; // Set the state timer in case it needs to be used for another timeout check stateTimer = getMSTimerCount(); } else if ( didTimeout( stateTimer, RSRVRS_DRAIN_TIMEOUT_MS ) ) { - setModeToFailed( state ); + setModeToFailed( failedState ); } - return rsrvrStatus; + return isDrainComplete; } /*********************************************************************//**