Index: firmware/App/Controllers/ConductivitySensors.c =================================================================== diff -u -r56ba1b163b0cbf6953638065b2108f745b17ec8f -r184ee0c5527af35d34c29bd4f80cf8b1959ffd35 --- firmware/App/Controllers/ConductivitySensors.c (.../ConductivitySensors.c) (revision 56ba1b163b0cbf6953638065b2108f745b17ec8f) +++ firmware/App/Controllers/ConductivitySensors.c (.../ConductivitySensors.c) (revision 184ee0c5527af35d34c29bd4f80cf8b1959ffd35) @@ -328,6 +328,7 @@ case DG_MODE_STAN: case DG_MODE_FLUS: case DG_MODE_HEAT: + case DG_MODE_HCOL: case DG_MODE_CHEM: case DG_MODE_CHFL: if ( VALVE_STATE_OPEN == getValveStateName( VPI ) ) Index: firmware/App/Controllers/Pressures.c =================================================================== diff -u -r56ba1b163b0cbf6953638065b2108f745b17ec8f -r184ee0c5527af35d34c29bd4f80cf8b1959ffd35 --- firmware/App/Controllers/Pressures.c (.../Pressures.c) (revision 56ba1b163b0cbf6953638065b2108f745b17ec8f) +++ firmware/App/Controllers/Pressures.c (.../Pressures.c) (revision 184ee0c5527af35d34c29bd4f80cf8b1959ffd35) @@ -204,6 +204,7 @@ case DG_MODE_STAN: case DG_MODE_FLUS: case DG_MODE_HEAT: + case DG_MODE_HCOL: case DG_MODE_CHEM: case DG_MODE_CHFL: if ( VALVE_STATE_OPEN == getValveStateName( VPI ) ) Index: firmware/App/Controllers/ROPump.c =================================================================== diff -u -rb8f298547eb578000b3ff3cf55732fda7a689ce0 -r184ee0c5527af35d34c29bd4f80cf8b1959ffd35 --- firmware/App/Controllers/ROPump.c (.../ROPump.c) (revision b8f298547eb578000b3ff3cf55732fda7a689ce0) +++ firmware/App/Controllers/ROPump.c (.../ROPump.c) (revision 184ee0c5527af35d34c29bd4f80cf8b1959ffd35) @@ -404,7 +404,11 @@ // To monitor the flow, the control mode must be in closed loop mode and the pump should be control to flow state // If the pump is controlled to the maximum pressure, the flow might be different from the target flow for more than 10% // but the pump is not able to achieve the flow. - if ( ( PUMP_CONTROL_MODE_CLOSED_LOOP == roPumpControlMode ) && ( RO_PUMP_CONTROL_TO_TARGET_FLOW_STATE == roPumpState ) ) + // Do not check the flow target in heat disinfect active cool since the flow during cooling might be very different from the target flow + // since the RO pump membrane is hot and the target flow is low so the RO pump's duty cycle is mostly 0% but the flow is still high and + // above the target + if ( ( PUMP_CONTROL_MODE_CLOSED_LOOP == roPumpControlMode ) && ( RO_PUMP_CONTROL_TO_TARGET_FLOW_STATE == roPumpState ) && + ( getCurrentOperationMode() != DG_MODE_HCOL ) ) { F32 currentFlow = getMeasuredFlowRateLPM( RO_FLOW_SENSOR ); F32 targetFlow = getTargetROPumpFlowRateLPM(); Index: firmware/App/Controllers/TemperatureSensors.c =================================================================== diff -u -rb4f8e2229eb0a08cdce5fdd2e0a14ca25d792946 -r184ee0c5527af35d34c29bd4f80cf8b1959ffd35 --- firmware/App/Controllers/TemperatureSensors.c (.../TemperatureSensors.c) (revision b4f8e2229eb0a08cdce5fdd2e0a14ca25d792946) +++ firmware/App/Controllers/TemperatureSensors.c (.../TemperatureSensors.c) (revision 184ee0c5527af35d34c29bd4f80cf8b1959ffd35) @@ -454,6 +454,7 @@ case DG_MODE_FLUS: case DG_MODE_HEAT: + case DG_MODE_HCOL: case DG_MODE_CHEM: case DG_MODE_INIT: case DG_MODE_STAN: Index: firmware/App/Modes/ModeHeatDisinfect.c =================================================================== diff -u -r2b47dd2e7974618d8899527cdbff80fa93ebc9fa -r184ee0c5527af35d34c29bd4f80cf8b1959ffd35 --- firmware/App/Modes/ModeHeatDisinfect.c (.../ModeHeatDisinfect.c) (revision 2b47dd2e7974618d8899527cdbff80fa93ebc9fa) +++ firmware/App/Modes/ModeHeatDisinfect.c (.../ModeHeatDisinfect.c) (revision 184ee0c5527af35d34c29bd4f80cf8b1959ffd35) @@ -67,7 +67,7 @@ #define MAX_FLUSH_CIRC_TEMP_SENSOR_DIFF_C 3.0F ///< Maximum flush circulation temperature difference tolerance in C. #define NUM_OF_TEMP_SENSORS_TO_AVG 3.0F ///< Number of temperature sensors to average to check the difference. #define ACID_PUMP_SPEED_ML_PER_MIN 30.6F ///< Acid concentrate pump speed in mL/min. -// The acid pump is 2% faster than the acid pump to create a flow from acid to bicarb line during heat disinfect +// The acid pump is 2% faster than the bicarb pump to create a flow from acid to bicarb line during heat disinfect #define BICARB_PUMP_SPEED_ML_PER_MIN -30.0F ///< Bicarb concentrate pump speed in mL/min. // Flush and drain R1 and R2 Index: firmware/App/Modes/ModeHeatDisinfectActiveCool.c =================================================================== diff -u -rd731f3fda9d25e0d63100f648510e9c8cdd21f89 -r184ee0c5527af35d34c29bd4f80cf8b1959ffd35 --- firmware/App/Modes/ModeHeatDisinfectActiveCool.c (.../ModeHeatDisinfectActiveCool.c) (revision d731f3fda9d25e0d63100f648510e9c8cdd21f89) +++ firmware/App/Modes/ModeHeatDisinfectActiveCool.c (.../ModeHeatDisinfectActiveCool.c) (revision 184ee0c5527af35d34c29bd4f80cf8b1959ffd35) @@ -16,6 +16,7 @@ ***************************************************************************/ #include "ConcentratePumps.h" +#include "ConductivitySensors.h" #include "CPLD.h" #include "DrainPump.h" #include "Heaters.h" @@ -24,6 +25,7 @@ #include "ModeFault.h" #include "ModeHeatDisinfectActiveCool.h" #include "OperationModes.h" +#include "Pressures.h" #include "Reservoirs.h" #include "ROPump.h" #include "RTC.h" @@ -45,35 +47,31 @@ #define ACID_PUMP_SPEED_ML_PER_MIN 30.6F ///< Acid concentrate pump speed in mL/min. // The acid pump is 2% faster than the acid pump to create a flow from acid to bicarb line during heat disinfect #define BICARB_PUMP_SPEED_ML_PER_MIN -30.0F ///< Bicarb concentrate pump speed in mL/min. -#define RSRVR_FILL_TIMEOUT_MS ( 5 * SEC_PER_MIN * MS_PER_SECOND ) -#define RSRVR_DRAIN_TIMEOUT_MS ( 2 * SEC_PER_MIN * MS_PER_SECOND ) -#define RSRVR_DRAIN_STEADY_TIMEOUT_MS ( 6 * MS_PER_SECOND ) -#define RSRVR_DRAIN_TARGET_RPM 2400 +#define RSRVR_FILL_TIMEOUT_MS ( 5 * SEC_PER_MIN * MS_PER_SECOND ) ///< Reservoir fill timeout in milliseconds. +#define RSRVR_DRAIN_TIMEOUT_MS ( 2 * SEC_PER_MIN * MS_PER_SECOND ) ///< Reservoir drain timeout in milliseconds. +#define RSRVR_DRAIN_STEADY_TIMEOUT_MS ( 6 * MS_PER_SECOND ) ///< Reservoir drain steady timeout in milliseconds. +#define RSRVR_DRAIN_TARGET_RPM 2400 ///< Reservoir drain target RPM. #define RSRVR_MIX_DRAIN_TIMEOUT_MS ( 5 * SEC_PER_MIN * MS_PER_SECOND ) ///< Reservoirs 1 & 2 mix drain timeout in ms. #define RSRVR_MIX_DRAIN_TEMPERATURE_THRESHOLD_C 60.0F ///< Temperature threshold for performing mix drain or normal drain. -#define TARGET_THD_SENSOR_FOR_RINSING_C 44.0F // TODO remove ///< Target THd temperature sensor value before rinsing in C. -#define ROF_COOL_DOWN_CIRCULATION_TIME_MS ( 2 * SEC_PER_MIN * MS_PER_SECOND ) // TODO remove ///< RO filter cool down circulation timer in milliseconds. -#define ROF_COOL_DOWN_MAX_TIME_MS ( 300 * SEC_PER_MIN * MS_PER_SECOND ) // todo remove ///< RO filter cool down maximum state time in milliseconds. - // RO filter cool down defines #define ROF_ACTIVE_COOL_TARGET_FLOW_LPM 0.3F ///< RO active cool down target flow in L/min. #define ROF_ACTIVE_COOL_MAX_ALLOWED_PRESSURE_PSI 30 ///< RO active cool down maximum pressure in psi. -#define ROF_ACTIVE_COOL_TARGET_RSRVR_FILL_ML 750.0F -#define ROF_ACTIVE_COOL_TARGET_TEMP_C 45.0F -#define ROF_ACTIVE_COOL_BELOW_TEMP_TIMEOUT_MS ( 30 * MS_PER_SECOND ) -#define ROF_ACTIVE_COOL_TARGET_DARIN_RPM 600 -#define ROF_ACTIVE_COOL_MIX_DRAIN_VALVE_ON_TIMEOUT_MS ( 5 * MS_PER_SECOND ) -#define ROF_ACTIVE_COOL_RSRVR_MIX_DRAIN_TIMEOUT_MS ( 4 * SEC_PER_MIN * MS_PER_SECOND ) -#define ROF_ACTIVE_COOL_MIX_DRAIN_STEADY_TIMEOUT_MS ( 15 * MS_PER_SECOND ) +#define ROF_ACTIVE_COOL_TARGET_RSRVR_FILL_ML 600.0F ///< RO active cool target reservoir fill in mL. +#define ROF_ACTIVE_COOL_TARGET_TEMP_C 40.0F ///< RO active cool target temperature in C. +#define ROF_ACTIVE_COOL_BELOW_TEMP_TIMEOUT_MS ( 30 * MS_PER_SECOND ) ///< RO active cool temperature below target for cooling timeout in milliseconds. +#define ROF_ACTIVE_COOL_TARGET_DARIN_RPM 300 ///< RO active cool target drain RPM. +#define ROF_ACTIVE_COOL_MIX_DRAIN_VALVE_ON_TIMEOUT_MS ( 4 * MS_PER_SECOND ) ///< RO active cool mix drain VPd turn on timeout in milliseconds. +#define ROF_ACTIVE_COOL_RSRVR_MIX_DRAIN_TIMEOUT_MS ( 8 * SEC_PER_MIN * MS_PER_SECOND ) ///< RO active cool reservoir mix drain timeout in milliseconds. +#define ROF_ACTIVE_COOL_MIX_DRAIN_STEADY_TIMEOUT_MS ( 15 * MS_PER_SECOND ) ///< RO active cool mix drain steady timeout in milliseconds. // Reservoir cool down defines -#define RSRVR_ACTIVE_COOL_TARGET_FLOW_LPM 0.8F -#define RSRVR_ACTIVE_COOL_MAX_ALLOWED_PRESSURE_PSI 130 -#define RSRVR_ACTIVE_COOL_FILL_TARGET_FILL_ML 1850.0F -#define RSRVR_ACTIVE_COOL_TARGET_TEMP_C 40.0F -#define RSRVR_ACTIVE_COOL_BELOW_TARGET_TEMP_TIMEOUT_MS ( 15 * MS_PER_SECOND ) -#define RSRVR_ACTIVE_COOL_TARGET_TEMP_TIMEOUT_MS ( 10 * SEC_PER_MIN * MS_PER_SECOND ) +#define RSRVR_ACTIVE_COOL_TARGET_FLOW_LPM 0.8F ///< Reservoir active cool target flow in L/min. +#define RSRVR_ACTIVE_COOL_MAX_ALLOWED_PRESSURE_PSI 130 ///< Reservoir active cool max allowed pressure in psi. +#define RSRVR_ACTIVE_COOL_FILL_TARGET_FILL_ML 1850.0F ///< Reservoir active cool over fill target in mL. +#define RSRVR_ACTIVE_COOL_TARGET_TEMP_C 40.0F ///< Reservoir active cool target temperature in C. +#define RSRVR_ACTIVE_COOL_BELOW_TARGET_TEMP_TIMEOUT_MS ( 15 * MS_PER_SECOND ) ///< Reservoir active cool temperature below target timeout in milliseconds. +#define RSRVR_ACTIVE_COOL_TARGET_TEMP_TIMEOUT_MS ( 10 * SEC_PER_MIN * MS_PER_SECOND ) ///< Reservoir active cool target temperature met in milliseconds. /// Non-volatile write structure typedef struct @@ -186,7 +184,17 @@ *************************************************************************/ U32 execHeatDisinfectActiveCoolMode( void ) { - // TODO the inlet water check? + // The inlet pressure shall be checked all the time as long as VPi is open + checkInletWaterPressure(); + + if ( heatDisinfectActiveCoolState > DG_HEAT_DISINFECT_ACTIVE_COOL_FILL_R1_STATE ) + { + // Do not check on the inlet water temperature and conductivity until there has been some inlet water flow + // The initial states are drain reservoirs but in those states VPi is closed so these alarms are not checked + checkInletWaterTemperature(); + checkInletWaterConductivity(); + } + monitorModeHeatDisinfectActiveCool(); switch( heatDisinfectActiveCoolState ) @@ -303,7 +311,7 @@ * @param fillTimeoutMS the timeout in milliseconds that the reservoir should * be filled by then * @param stateTimerMS the time of the state that the reservoir fill is being - * requested + * requested in milliseconds * @return status of the reservoir fill *************************************************************************/ DG_RESERVOIR_STATUS_T getDisinfectRsrvrFillStatus( DG_RESERVOIR_ID_T rsrvrID, DIS_RSRVR_STATUS_T *rsrvrStatus, F32 targetVolML, U32 fillTimeoutMS, U32 stateTimerMS ) @@ -322,6 +330,7 @@ if ( volumeML >= targetVolML ) { + // If the fill volume is greater than the target volume and the stable time has elapsed, call it reached to target if ( ++rsrvrStatus->rsrvrFillStableTime >= rsrvrStatus->rsrvrFillStableTimeoutMS ) { rsrvrStatus->rsrvrFillStableTime = 0; @@ -336,11 +345,33 @@ return status; } -DG_RESERVOIR_STATUS_T getDisinfectRsrvrDrainStatus( DG_RESERVOIR_ID_T rsrvrID, DIS_RSRVR_STATUS_T *rsrvrStatus, U32 drainSteadyTimeoutMS, U32 drainStateTimeoutMS, U32 stateTimerMS ) +/*********************************************************************//** + * @brief + * The getDisinfectRsrvrDrainStatus function gets the disinfect reservoir + * drain status. + * @details Inputs: none + * @details Outputs: none + * @param rsrvrID the reservoir to check + * @param *rsrvrStatus pointer to the reservoir status structure + * @param drainSteayTimeoutMS the time in milliseconds that the reservoir's level + * should not change and stay steady + * @param drainStateTimeoutMS the timeout in milliseconds that the reservoir should + * be drained by then + * @param stateTimerMS the time of the state that the reservoir fill is being + * requested in milliseconds + * @return status of the reservoir drain + *************************************************************************/ +DG_RESERVOIR_STATUS_T getDisinfectRsrvrDrainStatus( DG_RESERVOIR_ID_T rsrvrID, DIS_RSRVR_STATUS_T *rsrvrStatus, U32 drainSteadyTimeoutMS, + U32 drainStateTimeoutMS, U32 stateTimerMS ) { DG_RESERVOIR_STATUS_T status = DG_RESERVOIR_ABOVE_TARGET; BOOL isDrainComplete = FALSE; + if ( rsrvrID >= NUM_OF_DG_RESERVOIRS ) + { + SET_ALARM_WITH_2_U32_DATA( ALARM_ID_DG_SOFTWARE_FAULT, SW_FAULT_ID_INVALID_DG_RESERVOIR_SELECTED, rsrvrID ) + } + if ( FALSE == rsrvrStatus->rsrvr[ rsrvrID ].drainInit ) { initDrainParameters( rsrvrID ); @@ -385,6 +416,14 @@ return state; } +/*********************************************************************//** + * @brief + * The handleHeatDisinfectActiveCoolMixDrainR1State function handles the heat + * disinfect active cool mix drain R1 state. + * @details Inputs: none + * @details Outputs: none + * @return next state of the heat disinfect active cool state machine + *************************************************************************/ static DG_HEAT_DISINFECT_ACTIVE_COOL_STATE_T handleHeatDisinfectActiveCoolMixDrainR1State( void ) { DG_HEAT_DISINFECT_ACTIVE_COOL_STATE_T state = DG_HEAT_DISINFECT_ACITVE_COOL_MIX_DRAIN_R1_STATE; @@ -394,6 +433,14 @@ return state; } +/*********************************************************************//** + * @brief + * The handleHeatDisinfectActiveCoolMixDrainR2State function handles the heat + * disinfect active cool mix drain R2 state. + * @details Inputs: none + * @details Outputs: tempBelowTargetStartTimeMS + * @return next state of the heat disinfect active cool state machine + *************************************************************************/ static DG_HEAT_DISINFECT_ACTIVE_COOL_STATE_T handleHeatDisinfectActiveCoolMixDrainR2State( void ) { DG_HEAT_DISINFECT_ACTIVE_COOL_STATE_T state = DG_HEAT_DISINFECT_ACTIVE_COOL_MIX_DRAIN_R2_STATE; @@ -404,7 +451,14 @@ return state; } -// TODO add doxygen +/*********************************************************************//** + * @brief + * The handleHeatDisinfectActiveCoolFillR1State function handles the heat + * disinfect active cool fill R1 state. + * @details Inputs: none + * @details Outputs: none + * @return next state of the heat disinfect active cool state machine + *************************************************************************/ static DG_HEAT_DISINFECT_ACTIVE_COOL_STATE_T handleHeatDisinfectActiveCoolFillR1State( void ) { DG_HEAT_DISINFECT_ACTIVE_COOL_STATE_T state = DG_HEAT_DISINFECT_ACTIVE_COOL_FILL_R1_STATE; @@ -414,6 +468,14 @@ return state; } +/*********************************************************************//** + * @brief + * The handleHeatDisinfectActiveCoolFillR2State function handles the heat + * disinfect active cool fill R2 state. + * @details Inputs: none + * @details Outputs: none + * @return next state of the heat disinfect active cool state machine + *************************************************************************/ static DG_HEAT_DISINFECT_ACTIVE_COOL_STATE_T handleHeatDisinfectActiveCoolFillR2State( void ) { DG_HEAT_DISINFECT_ACTIVE_COOL_STATE_T state = DG_HEAT_DISINFECT_ACTIVE_COOL_FILL_R2_STATE; @@ -423,7 +485,14 @@ return state; } - +/*********************************************************************//** + * @brief + * The handleHeatDisinfectActiveCoolDrainR2FillR1ToR2State function handles + * the heat disinfect active cool drain R2 and fill R1 to R2 state. + * @details Inputs: none + * @details Outputs: none + * @return next state of the heat disinfect active cool state machine + *************************************************************************/ static DG_HEAT_DISINFECT_ACTIVE_COOL_STATE_T handleHeatDisinfectActiveCoolDrainR2FillR1ToR2State( void ) { DG_HEAT_DISINFECT_ACTIVE_COOL_STATE_T state = DG_HEAT_DISINFECT_ACTIVE_COOL_DRAIN_R2_FILL_R1_TO_R2_STATE; @@ -433,6 +502,14 @@ return state; } +/*********************************************************************//** + * @brief + * The handleHeatDisinfectActiveCoolDrainR1FillR2ToR1State function handles + * the heat disinfect active cool drain R1 and fill R2 to R1 state. + * @details Inputs: none + * @details Outputs: none + * @return next state of the heat disinfect active cool state machine + *************************************************************************/ static DG_HEAT_DISINFECT_ACTIVE_COOL_STATE_T handleHeatDisinfectActiveCoolDrainR1FillR2ToR1State( void ) { DG_HEAT_DISINFECT_ACTIVE_COOL_STATE_T state = DG_HEAT_DISINFECT_ACTIVE_COOL_DRAIN_R1_FILL_R2_TO_R1_STATE; @@ -442,6 +519,14 @@ return state; } +/*********************************************************************//** + * @brief + * The handleHeatDisinfectActiveCoolDrainR1State function handles the heat + * disinfect active cool drain R1 state. + * @details Inputs: none + * @details Outputs: none + * @return next state of the heat disinfect active cool state machine + *************************************************************************/ static DG_HEAT_DISINFECT_ACTIVE_COOL_STATE_T handleHeatDisinfectActiveCoolDrainR1State( void ) { DG_HEAT_DISINFECT_ACTIVE_COOL_STATE_T state = DG_HEAT_DISINFECT_ACTIVE_COOL_DRAIN_R1_STATE; @@ -451,6 +536,14 @@ return state; } +/*********************************************************************//** + * @brief + * The handleHeatDisinfectActiveCoolDrainR1State function handles the heat + * disinfect active cool drain R2 state. + * @details Inputs: none + * @details Outputs: none + * @return next state of the heat disinfect active cool state machine + *************************************************************************/ static DG_HEAT_DISINFECT_ACTIVE_COOL_STATE_T handleHeatDisinfectActiveCoolDrainR2State( void ) { DG_HEAT_DISINFECT_ACTIVE_COOL_STATE_T state = DG_HEAT_DISINFECT_ACTIVE_COOL_DRAIN_R2_STATE; @@ -482,6 +575,14 @@ return state; } +/*********************************************************************//** + * @brief + * The handleHeatDisinfectActiveCoolCancelWaterPathState function handles + * the heat disinfect active cool cancel water path state. + * @details Inputs: cancellationMode, rsrvrsStatus, stateStartTimeMS + * @details Outputs: cancellationMode, rsrvrsStatus, stateStartTimeMS + * @return next state of the heat disinfect active cool state machine + *************************************************************************/ static DG_HEAT_DISINFECT_ACTIVE_COOL_STATE_T handleHeatDisinfectActiveCoolCancelWaterPathState( void ) { DG_HEAT_DISINFECT_ACTIVE_COOL_STATE_T state = DG_HEAT_DISINFECT_ACTIVE_COOL_CANCEL_WATER_PATH_STATE; @@ -658,6 +759,13 @@ alarmDetectedPendingTrigger = ALARM_ID_DG_DIALYSATE_OR_CONC_CAP_NOT_IN_PROPER_POSITION; } } + + if ( ( TRUE == isDGFaultAlarmActive() ) && ( heatDisinfectActiveCoolState != DG_HEAT_DISINFECT_ACTIVE_COOL_CANCEL_WATER_PATH_STATE ) ) + { + // If there is any fault alarm and we are not already in the cancel water path state, set it to cancel water path state + heatDisinfectActiceCoolPrevState = heatDisinfectActiveCoolState; + heatDisinfectActiveCoolState = DG_HEAT_DISINFECT_ACTIVE_COOL_CANCEL_WATER_PATH_STATE; + } } /*********************************************************************//** @@ -666,6 +774,7 @@ * of the provided state. * @details Inputs: none * @details Outputs: none + * @param state the state of the heat disinfect active cool mode * @return: none *************************************************************************/ static void setHeatDisinfectActiveCoolActuators( DG_HEAT_DISINFECT_ACTIVE_COOL_STATE_T state ) @@ -915,6 +1024,16 @@ } } +/*********************************************************************//** + * @brief + * The checkRsrvrMgmtTimeoutStatus function checks and manages the status + * of reservoir management timeout status + * @details Inputs: rsrvrsStatus + * @details Outputs: heatDisinfectActiceCoolPrevState + * @param rsrvrID the reservoir ID to check the status of the timeout + * @param state the state of the heat disinfect active cool mode + * @return: state of the heat disinfect active cool mode + *************************************************************************/ static DG_HEAT_DISINFECT_ACTIVE_COOL_STATE_T checkRsrvrMgmtTimeoutStatus( DG_RESERVOIR_ID_T rsrvrID, DG_HEAT_DISINFECT_ACTIVE_COOL_STATE_T state ) { if ( DG_RESERVOIR_NOT_REACHED_TARGET == rsrvrsStatus.rsrvr[ rsrvrID ].rStatus ) @@ -927,6 +1046,16 @@ return state; } +/*********************************************************************//** + * @brief + * The checkRsrvrPartialFillStatus function checks and manages the status + * of the partial fill of a reservoir + * @details Inputs: tempBelowTargetStartTimeMS, rsrvrsStatus, stateStartTimeMS + * @details Outputs: tempBelowTargetStartTimeMS, rsrvrsStatus, stateStartTimeMS + * @param rsrvrID the reservoir ID to check the status of the timeout + * @param state the state of the heat disinfect active cool mode + * @return: state of the heat disinfect active cool mode + *************************************************************************/ static DG_HEAT_DISINFECT_ACTIVE_COOL_STATE_T checkRsrvrPartialFillStatus( DG_RESERVOIR_ID_T rsrvrID, DG_HEAT_DISINFECT_ACTIVE_COOL_STATE_T state ) { F32 THdTemperatureC = getTemperatureValue( TEMPSENSORS_HEAT_DISINFECT ); @@ -947,6 +1076,7 @@ { stateStartTimeMS = getMSTimerCount(); + // If THd temperature has been below the target temperature, transition to cooling the connection paths in between the two reservoirs if ( DG_HEAT_DISINFECT_ACTIVE_COOL_FILL_R1_STATE == state ) { rsrvrsStatus.rsrvr[ DG_RESERVOIR_1 ].rStatus = DG_RESERVOIR_BELOW_TARGET; @@ -967,6 +1097,8 @@ rsrvrsStatus.rsrvr[ rsrvrID ].rStatus = DG_RESERVOIR_ABOVE_TARGET; stateStartTimeMS = getMSTimerCount(); + // If the temperature after fill is not below the target temperature, transition to mix drain since the fluid is considered + // as hot if ( DG_HEAT_DISINFECT_ACTIVE_COOL_FILL_R1_STATE == state ) { state = DG_HEAT_DISINFECT_ACITVE_COOL_MIX_DRAIN_R1_STATE; @@ -983,6 +1115,16 @@ return state; } +/*********************************************************************//** + * @brief + * The checkRsrvrMixDrainStatus function checks and manages the status + * of the mix drain of a reservoir + * @details Inputs: rsrvrsStatus, stateStartTimeMS + * @details Outputs: rsrvrsStatus, stateStartTimeMS + * @param rsrvrID the reservoir ID to check the status of the timeout + * @param state the state of the heat disinfect active cool mode + * @return: state of the heat disinfect active cool mode + *************************************************************************/ static DG_HEAT_DISINFECT_ACTIVE_COOL_STATE_T checkRsrvrMixDrainStatus( DG_RESERVOIR_ID_T rsrvrID, DG_HEAT_DISINFECT_ACTIVE_COOL_STATE_T state ) { if ( ( TRUE == didTimeout( stateStartTimeMS, ROF_ACTIVE_COOL_MIX_DRAIN_VALVE_ON_TIMEOUT_MS ) ) && ( FALSE == isDrainPumpOn() ) ) @@ -1000,6 +1142,7 @@ if ( TRUE == rsrvrsStatus.isThisInitialDrain ) { + // If this is the initial drain of the mode, tare the reservoirs and get ready for the mix drain if ( DG_HEAT_DISINFECT_ACITVE_COOL_MIX_DRAIN_R1_STATE == state ) { tareLoadCell( LOAD_CELL_RESERVOIR_1_PRIMARY ); @@ -1022,6 +1165,8 @@ { rsrvrsStatus.rsrvr[ switchRsrvrID ].rStatus = DG_RESERVOIR_BELOW_TARGET; + // If state are either of the mix drain reservoir states, transition the the fill state. + // If the mix drain is R1 transition to fill R2 and vice versa if ( DG_HEAT_DISINFECT_ACITVE_COOL_MIX_DRAIN_R1_STATE == state ) { state = DG_HEAT_DISINFECT_ACTIVE_COOL_FILL_R2_STATE; @@ -1041,12 +1186,23 @@ return state; } +/*********************************************************************//** + * @brief + * The checkRsrvrFillStatus function checks and manages the status + * of the a reservoir's fill + * @details Inputs: rsrvrsStatus, stateStartTimeMS, tempBelowTargetStartTimeMS + * @details Outputs: rsrvrsStatus, stateStartTimeMS, tempBelowTargetStartTimeMS + * @param rsrvrID the reservoir ID to check the status of the timeout + * @param state the state of the heat disinfect active cool mode + * @return: state of the heat disinfect active cool mode + *************************************************************************/ static DG_HEAT_DISINFECT_ACTIVE_COOL_STATE_T checkRsrvrFillStatus( DG_RESERVOIR_ID_T rsrvrID, DG_HEAT_DISINFECT_ACTIVE_COOL_STATE_T state ) { F32 TDiTemperatureC = getTemperatureValue( TEMPSENSORS_INLET_DIALYSATE ); if ( TDiTemperatureC > RSRVR_ACTIVE_COOL_TARGET_TEMP_C ) { + // Keep setting the time until the temperature is below the target tempBelowTargetStartTimeMS = getMSTimerCount(); } @@ -1057,36 +1213,47 @@ } else if ( DG_RESERVOIR_REACHED_TARGET == rsrvrsStatus.rsrvr[ rsrvrID ].rStatus ) { - stateStartTimeMS = getMSTimerCount(); - - if ( DG_HEAT_DISINFECT_ACTIVE_COOL_DRAIN_R2_FILL_R1_TO_R2_STATE == state ) + // Keep waiting until the TDi temperature is below the target temperature for the specified time + if ( TRUE == didTimeout( tempBelowTargetStartTimeMS, RSRVR_ACTIVE_COOL_BELOW_TARGET_TEMP_TIMEOUT_MS ) ) { - rsrvrsStatus.rsrvr[ DG_RESERVOIR_1 ].rStatus = DG_RESERVOIR_REACHED_TARGET; - rsrvrsStatus.rsrvr[ DG_RESERVOIR_2 ].rStatus = DG_RESERVOIR_BELOW_TARGET; - state = DG_HEAT_DISINFECT_ACTIVE_COOL_DRAIN_R1_FILL_R2_TO_R1_STATE; - } - else if ( DG_HEAT_DISINFECT_ACTIVE_COOL_DRAIN_R1_FILL_R2_TO_R1_STATE == state ) - { - if ( TRUE == didTimeout( tempBelowTargetStartTimeMS, RSRVR_ACTIVE_COOL_BELOW_TARGET_TEMP_TIMEOUT_MS ) ) + stateStartTimeMS = getMSTimerCount(); + + // Once the TDi has been below the specified temperature for the specified time, transition to the next state per the current state + if ( DG_HEAT_DISINFECT_ACTIVE_COOL_DRAIN_R2_FILL_R1_TO_R2_STATE == state ) { - rsrvrsStatus.rsrvr[ DG_RESERVOIR_1 ].rStatus = DG_RESERVOIR_ABOVE_TARGET; - state = DG_HEAT_DISINFECT_ACTIVE_COOL_DRAIN_R1_STATE; - } - else - { rsrvrsStatus.rsrvr[ DG_RESERVOIR_1 ].rStatus = DG_RESERVOIR_REACHED_TARGET; rsrvrsStatus.rsrvr[ DG_RESERVOIR_2 ].rStatus = DG_RESERVOIR_BELOW_TARGET; - state = DG_HEAT_DISINFECT_ACTIVE_COOL_DRAIN_R2_FILL_R1_TO_R2_STATE; + state = DG_HEAT_DISINFECT_ACTIVE_COOL_DRAIN_R1_FILL_R2_TO_R1_STATE; } + else if ( DG_HEAT_DISINFECT_ACTIVE_COOL_DRAIN_R1_FILL_R2_TO_R1_STATE == state ) + { + rsrvrsStatus.rsrvr[ DG_RESERVOIR_1 ].rStatus = DG_RESERVOIR_ABOVE_TARGET; + state = DG_HEAT_DISINFECT_ACTIVE_COOL_DRAIN_R1_STATE; + } } setHeatDisinfectActiveCoolActuators( state ); } - state = checkRsrvrMgmtTimeoutStatus( rsrvrID, state ); + if ( DG_RESERVOIR_BELOW_TARGET == rsrvrsStatus.rsrvr[ rsrvrID ].rStatus ) + { + // Check for the fill timeout only until the reservoir is being filled. After that the fluid is run until TDi is below + // the target temperature and it can take a while and varies. + state = checkRsrvrMgmtTimeoutStatus( rsrvrID, state ); + } return state; } +/*********************************************************************//** + * @brief + * The checkRsrvrDrainStatus function checks and manages the status + * of the a reservoir's drain + * @details Inputs: rsrvrsStatus, stateStartTimeMS + * @details Outputs: rsrvrsStatus, stateStartTimeMS + * @param rsrvrID the reservoir ID to check the status of the timeout + * @param state the state of the heat disinfect active cool mode + * @return: state of the heat disinfect active cool mode + *************************************************************************/ static DG_HEAT_DISINFECT_ACTIVE_COOL_STATE_T checkRsrvrDrainStatus( DG_RESERVOIR_ID_T rsrvrID, DG_HEAT_DISINFECT_ACTIVE_COOL_STATE_T state ) { if ( DG_RESERVOIR_ABOVE_TARGET == rsrvrsStatus.rsrvr[ rsrvrID ].rStatus ) Index: firmware/App/Modes/ModeStandby.c =================================================================== diff -u -rd731f3fda9d25e0d63100f648510e9c8cdd21f89 -r184ee0c5527af35d34c29bd4f80cf8b1959ffd35 --- firmware/App/Modes/ModeStandby.c (.../ModeStandby.c) (revision d731f3fda9d25e0d63100f648510e9c8cdd21f89) +++ firmware/App/Modes/ModeStandby.c (.../ModeStandby.c) (revision 184ee0c5527af35d34c29bd4f80cf8b1959ffd35) @@ -200,12 +200,10 @@ // if HD requests water sample, go to water sample state else if ( TRUE == flushFilterRequest ) { + setValveState( VPI, VALVE_STATE_OPEN ); flushFilterRequest = FALSE; filterFlushStartTime = getMSTimerCount(); - - setValveState( VPI, VALVE_STATE_OPEN ); - - state = DG_STANDBY_MODE_STATE_FLUSH_FILTER; + state = DG_STANDBY_MODE_STATE_FLUSH_FILTER; } else if ( TRUE == pendingStartDGRequest ) { Index: firmware/App/Modes/OperationModes.c =================================================================== diff -u -r3603cf10bb798c6ccd50899383b1c42965a93cc9 -r184ee0c5527af35d34c29bd4f80cf8b1959ffd35 --- firmware/App/Modes/OperationModes.c (.../OperationModes.c) (revision 3603cf10bb798c6ccd50899383b1c42965a93cc9) +++ firmware/App/Modes/OperationModes.c (.../OperationModes.c) (revision 184ee0c5527af35d34c29bd4f80cf8b1959ffd35) @@ -66,7 +66,7 @@ /* SERV */{ DG_MODE_FAUL, DG_MODE_SERV, DG_MODE_NLEG, DG_MODE_NLEG, DG_MODE_NLEG, DG_MODE_NLEG, DG_MODE_NLEG, DG_MODE_NLEG, DG_MODE_NLEG, DG_MODE_NLEG, DG_MODE_NLEG, DG_MODE_NLEG, DG_MODE_NLEG }, /* INIT */{ DG_MODE_FAUL, DG_MODE_NLEG, DG_MODE_INIT, DG_MODE_STAN, DG_MODE_SOLO, DG_MODE_NLEG, DG_MODE_NLEG, DG_MODE_NLEG, DG_MODE_NLEG, DG_MODE_NLEG, DG_MODE_NLEG, DG_MODE_NLEG, DG_MODE_NLEG }, /* STAN */{ DG_MODE_FAUL, DG_MODE_SERV, DG_MODE_INIT, DG_MODE_STAN, DG_MODE_SOLO, DG_MODE_GENE, DG_MODE_NLEG, DG_MODE_NLEG, DG_MODE_FLUS, DG_MODE_HEAT, DG_MODE_CHEM, DG_MODE_CHFL, DG_MODE_HCOL }, - /* SOLO */{ DG_MODE_FAUL, DG_MODE_SERV, DG_MODE_INIT, DG_MODE_STAN, DG_MODE_SOLO, DG_MODE_NLEG, DG_MODE_NLEG, DG_MODE_NLEG, DG_MODE_FLUS, DG_MODE_HEAT, DG_MODE_NLEG, DG_MODE_NLEG, DG_MODE_NLEG }, + /* SOLO */{ DG_MODE_FAUL, DG_MODE_SERV, DG_MODE_INIT, DG_MODE_STAN, DG_MODE_SOLO, DG_MODE_NLEG, DG_MODE_NLEG, DG_MODE_NLEG, DG_MODE_FLUS, DG_MODE_HEAT, DG_MODE_NLEG, DG_MODE_NLEG, DG_MODE_HCOL }, /* GENE */{ DG_MODE_FAUL, DG_MODE_NLEG, DG_MODE_NLEG, DG_MODE_STAN, DG_MODE_NLEG, DG_MODE_GENE, DG_MODE_FILL, DG_MODE_DRAI, DG_MODE_NLEG, DG_MODE_NLEG, DG_MODE_NLEG, DG_MODE_NLEG, DG_MODE_NLEG }, /* FILL */{ DG_MODE_FAUL, DG_MODE_NLEG, DG_MODE_NLEG, DG_MODE_STAN, DG_MODE_NLEG, DG_MODE_GENE, DG_MODE_FILL, DG_MODE_NLEG, DG_MODE_NLEG, DG_MODE_NLEG, DG_MODE_NLEG, DG_MODE_NLEG, DG_MODE_NLEG }, /* DRAI */{ DG_MODE_FAUL, DG_MODE_NLEG, DG_MODE_NLEG, DG_MODE_STAN, DG_MODE_NLEG, DG_MODE_GENE, DG_MODE_NLEG, DG_MODE_DRAI, DG_MODE_NLEG, DG_MODE_NLEG, DG_MODE_NLEG, DG_MODE_NLEG, DG_MODE_NLEG },