Index: firmware/App/Modes/ModeHeatDisinfect.c =================================================================== diff -u -r263a8e5e9d7314f92def1b5701db2a92cf537542 -r94b2082ddcec6ccb947e67714dc85ae005a2c7b6 --- firmware/App/Modes/ModeHeatDisinfect.c (.../ModeHeatDisinfect.c) (revision 263a8e5e9d7314f92def1b5701db2a92cf537542) +++ firmware/App/Modes/ModeHeatDisinfect.c (.../ModeHeatDisinfect.c) (revision 94b2082ddcec6ccb947e67714dc85ae005a2c7b6) @@ -48,11 +48,11 @@ // Drain R1 & R2 states defines #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_INITIAL_DRAIN_TIME_OUT_MS ( 2* 60 * MS_PER_SECOND ) ///< Reservoirs 1 & 2 initial drain time out in milliseconds. #define DRAIN_WEIGHT_UNCHANGE_TIMEOUT ( 6 * MS_PER_SECOND ) ///< Time period of unchanged weight during draining before timeout. // Flush drain path state defines -#define FLUSH_DRAIN_WAIT_TIME_MS ( 10 * MS_PER_SECOND ) ///< Flush Drain path wait time in milliseconds. TODo original time was 60 seconds +#define FLUSH_DRAIN_WAIT_TIME_MS ( 60 * MS_PER_SECOND ) ///< Flush Drain path wait time in milliseconds. TODo original time was 60 seconds #define MIN_INLET_TEMPERATURE_C 15.0 ///< Minimum water inlet temperature in C. TODO original temperature was 25 C #define MIN_INLET_CONDUCTIVITY_US_PER_CM 0.0 ///< Minimum water inlet conductivity in uS/cm #define MAX_INLET_CONDUCTIVITY_US_PER_CM 2000.0 ///< Maximum water inlet conductivity in us/cm @@ -80,9 +80,9 @@ #define HEAT_DISINFECT_TARGET_RO_FLOW_LPM 0.9 ///< Heat disinfect target RO flow rate in L/min. TODO original value was 0.8 #define HEAT_DISINFECT_MAX_RO_PRESSURE_PSI 30 ///< Heat disinfect maximum RO pressure in psi. #define HEAT_DISINFECT_TARGET_DRAIN_PRES_PSI 10.0 ///< Heat disinfect target drain outlet pressure in psi. -#define HEAT_DISINFECT_TIME_MS ( 5 * 60 * MS_PER_SECOND ) ///< Heat disinfect time for each section in milliseconds. TODO original time was 10 minutes +#define HEAT_DISINFECT_TIME_MS ( 10 * 60 * MS_PER_SECOND ) ///< Heat disinfect time for each section in milliseconds. TODO original time was 10 minutes #define HEAT_DISINFECT_START_TEMP_TIMOUT_MS ( 4 * 60 * 60 * MS_PER_SECOND ) ///< Heat disinfect reaching to minimum temperature timeout in milliseconds. TODO figure out this timeout -#define RSRVRS_TARGET_VOL_OUT_TIMEOUT_MS ( 0.5 * 60 * MS_PER_SECOND ) ///< Reservoirs 1 & 2 maximum volume out of range timeout during heat disnfect. TODO change this to 5 seconds +#define RSRVRS_TARGET_VOL_OUT_TIMEOUT_MS ( 0.5 * 60 * MS_PER_SECOND ) ///< Reservoirs 1 & 2 maximum volume out of range timeout during heat disinfect. TODO change this to 5 seconds #define RSRVRS_MAX_TARGET_VOL_CHANGE_ML 500.0 ///< Reservoirs 1 & 2 maximum allowed volume change when full during heat disinfect. TODO original value is 100 mL #define POST_HEAT_DISINFECT_WAIT_TIME_MS ( 3 * 60 * MS_PER_SECOND ) ///< Heat disinfect final wait time before flushing the system in milliseconds. @@ -166,9 +166,9 @@ static DG_HEAT_DISINFECT_STATE_T handleHeatDisinfectFillR2WithHotWaterState( void ); static DG_HEAT_DISINFECT_STATE_T handleHeatDisinfectDisinfectR2ToR1State( void ); static DG_HEAT_DISINFECT_STATE_T handleHeatDisinfectCoolDownHeatersState( void ); +static DG_HEAT_DISINFECT_STATE_T handleHeatDisinfectCoolDownROFilterState( void ); static DG_HEAT_DISINFECT_STATE_T handleHeatDisinfectMixDrainR1State( void ); static DG_HEAT_DISINFECT_STATE_T handleHeatDisinfectMixDrainR2State( void ); -static DG_HEAT_DISINFECT_STATE_T handleHeatDisinfectCoolDownROFilterState( void ); static DG_HEAT_DISINFECT_STATE_T handleHeatDisinfectRinseR1ToR2State( void ); static DG_HEAT_DISINFECT_STATE_T handleHeatDisinfectRinseR2ToR1AndDrainR1State( void ); static DG_HEAT_DISINFECT_STATE_T handleHeatDisinfectRinseCirculationState( void ); @@ -224,6 +224,8 @@ *************************************************************************/ void transitionToHeatDisinfectMode( void ) { + resetActuators(); + initHeatDisinfectMode(); } @@ -295,6 +297,10 @@ heatDisinfectState = handleHeatDisinfectCoolDownHeatersState(); break; + case DG_HEAT_DISINFECT_STATE_COOL_DOWN_RO_FILTER: + heatDisinfectState = handleHeatDisinfectCoolDownROFilterState(); + break; + case DG_HEAT_DISINFECT_STATE_MIX_DRAIN_R1: heatDisinfectState = handleHeatDisinfectMixDrainR1State(); break; @@ -303,10 +309,6 @@ heatDisinfectState = handleHeatDisinfectMixDrainR2State(); break; - case DG_HEAT_DISINFECT_STATE_COOL_DOWN_RO_FILTER: - heatDisinfectState = handleHeatDisinfectCoolDownROFilterState(); - break; - case DG_HEAT_DISINFECT_STATE_RINSE_R1_TO_R2: heatDisinfectState = handleHeatDisinfectRinseR1ToR2State(); break; @@ -358,8 +360,8 @@ /*********************************************************************//** * @brief * The stopDGHeatDisinfect function stops heat disinfect mode. - * @details Inputs: heatDisinfectionState - * @details Outputs: heatDisinfectionState + * @details Inputs: none + * @details Outputs: none * @return none *************************************************************************/ void stopDGHeatDisinfect( void ) @@ -371,7 +373,7 @@ requestNewOperationMode( DG_MODE_STAN ); } -// ********** private function prototypes ********** +// ********** private functions ********** /*********************************************************************//** * @brief @@ -450,7 +452,7 @@ } else if ( rsrvr1Status == RESERVOIR_STATUS_EMPTY ) { - if ( isThisLastDrain ) + if ( TRUE == isThisLastDrain ) { // Done with draining signalDrainPumpHardStop(); @@ -475,9 +477,9 @@ { // Assume reservoir 2 is full and drain it rsrvr2Status = RESERVOIR_STATUS_FULL; - // Set the actuators to drain R2. // Request a tare for reservoir 2 tareReservoir(); + // Set the actuators to drain R2. // NOTE: Drain pump is already on and VDr is already on drain state setValveState( VRD, VALVE_STATE_R2_C_TO_NO ); state = DG_HEAT_DISINFECT_STATE_DRAIN_R2; @@ -511,7 +513,7 @@ } else if ( rsrvr2Status == RESERVOIR_STATUS_EMPTY ) { - if ( isThisLastDrain ) + if ( TRUE == isThisLastDrain ) { setValveState( VRD, VALVE_STATE_R1_C_TO_NC ); rsrvr1Status = RESERVOIR_STATUS_FULL; @@ -560,7 +562,7 @@ stateTrialCounter = 0; state = DG_HEAT_DISINFECT_STATE_FLUSH_CIRCULATION; } - // If the failure is still in range, reset the timer and start over + // If the number of failures have not exceeded the limit, try again. else if ( ++stateTrialCounter < MAX_ALLOWED_STATE_TRIALS ) { stateTimer = getMSTimerCount(); @@ -609,7 +611,7 @@ BOOL isTD2Out = fabs( TD2Temp - avgTemp ) > MAX_FLUSH_CIRC_TEMP_SENSOR_DIFF_C; // Check if any of the temperature sensors are out of tolerance - if( isThdOut || isTPoOut || isTD1Out || isTD2Out ) + if( TRUE == isThdOut || TRUE == isTPoOut || TRUE == isTD1Out || TRUE == isTD2Out ) { // Check if we have exceeded the number of trials. If not, try another time if ( ++stateTrialCounter < MAX_ALLOWED_STATE_TRIALS ) @@ -633,7 +635,7 @@ } // Only start the concentrate pumps if the temperature sensors are in range - if ( areTempSensorsInRange ) + if ( TRUE == areTempSensorsInRange ) { // TODO: enable the timeout once the concentrate pumps are available. //if ( didTimeout( stateTimer, FLUSH_CICRCULATION_WAIT_TIME_MS ) ) @@ -1125,8 +1127,7 @@ isDrainPumpInMixDrainOn = TRUE; // Turn on the drain pump to drain the reservoirs in open loop mode - //setDrainPumpTargetRPM( DRAIN_PUMP_RPM_IN_MIX_DRAIN ); TODO if this is not needed remove the #define - setDrainPumpTargetOutletPressure( 5.0 ); //TODO if this is the method, add a #define + setDrainPumpTargetRPM( DRAIN_PUMP_RPM_IN_MIX_DRAIN ); } else if ( isDrainPumpInMixDrainOn == TRUE ) { @@ -1313,9 +1314,6 @@ if ( didTimeout( stateTimer, FLUSH_CICRCULATION_WAIT_TIME_MS ) ) { - // Done with heat disinfect cycle - resetActuators(); - state = DG_HEAT_DISINFECT_STATE_COMPLETE; } @@ -1363,6 +1361,8 @@ if ( cancellationMode == CANCELLATION_MODE_NONE ) { + U32 targetRPM = 0; + // Stop all the actuators first then decide who should run next resetActuators(); @@ -1373,6 +1373,7 @@ // The two sensors must be less than a threshold to decide if mix drain is needed to normal drain if ( TDi < MIX_DRAIN_TEMPERATURE_THRESHOLD_C && TRo < MIX_DRAIN_TEMPERATURE_THRESHOLD_C ) { + targetRPM = DRAIN_PUMP_TARGET_RPM; rsrvr1Status = RESERVOIR_STATUS_FULL; rsrvr2Status = RESERVOIR_STATUS_FULL; cancellationMode = CANCELLATION_MODE_COLD; @@ -1383,14 +1384,15 @@ setValveState( VPI, VALVE_STATE_OPEN ); setValveState( VPD, VALVE_STATE_DRAIN_C_TO_NC ); + targetRPM = DRAIN_PUMP_RPM_IN_MIX_DRAIN; rsrvr1Status = RESERVOIR_STATUS_FULL; rsrvr2Status = RESERVOIR_STATUS_FULL; cancellationMode = CANCELLATION_MODE_HOT; } // The drain is set to start from reservoir 2 since all the actuators have been de-energized // Start the drain pump - setDrainPumpTargetRPM( DRAIN_PUMP_TARGET_RPM ); + setDrainPumpTargetRPM( targetRPM ); // Start the timer for drain timeout stateTimer = getMSTimerCount(); @@ -1479,8 +1481,8 @@ /*********************************************************************//** * @brief - * The setModeToFailed function sets the heat disinfect mode to failed - * by changing the state to complete. + * The setModeToFailed function sets the alarm that failed the heat disinfect + * mode. * @details Inputs: alarm, prevHeatDisinfectState * @details Outputs: none * @return none @@ -1500,8 +1502,6 @@ * @param r is DG_RESERVOIR_1 or DG_RESERVOIR_2 * @param targetVol is the target fill volume * @param timeout is the fill up timeout - * @param cancellationState is the cancellation state to be called in case - * the operation timed out. * @return the status of the reservoirs during filling *************************************************************************/ static RESERVOIRS_STATUS_T getRsrvrFillStatus( DG_RESERVOIR_ID_T r, F32 targetVol, U32 timeout ) @@ -1548,8 +1548,10 @@ * @details Outputs: stateTimer, heatDisinfectState heatDisinfectState, * alarm * @param r is DG_RESERVOIR_1 or DG_RESERVOIR_2 - * @param cancellationState is the cancellation state to be called in case - * the operation timed out. + * @param drainSteadyStateTimeout which is the time the reservoir's level + * does not change and is steady state + * @param timeout which is the timeout that a reservoir must be drained by + * then * @return the status of the reservoirs during draining *************************************************************************/ static RESERVOIRS_STATUS_T getRsrvrDrainStatus( DG_RESERVOIR_ID_T r, U32 drainSteadyStateTimeout, U32 timeout ) @@ -1566,6 +1568,7 @@ } else if ( didTimeout( stateTimer, timeout ) ) { + // TODO fix this part // Failed to drain ontime. Update the previous heat disinfect state and transition to basic cancellation //prevHeatDisinfectState = heatDisinfectState; //alarm = ALARM_ID_DG_RESERVOIR_DRAIN_TIMEOUT;