Index: firmware/App/Modes/ModeChemicalDisinfectFlush.c =================================================================== diff -u -r9e5ee62245eb2a73b167eabd6c274a71a76a7b0e -r46a1f88d8a17cc847d3825fb40ee76844869b930 --- firmware/App/Modes/ModeChemicalDisinfectFlush.c (.../ModeChemicalDisinfectFlush.c) (revision 9e5ee62245eb2a73b167eabd6c274a71a76a7b0e) +++ firmware/App/Modes/ModeChemicalDisinfectFlush.c (.../ModeChemicalDisinfectFlush.c) (revision 46a1f88d8a17cc847d3825fb40ee76844869b930) @@ -86,6 +86,8 @@ // Sample flush R1 to R2 drain R2 defines #define SAMPLE_FLUSH_WAIT_TIME_MS ( 2.5 * SEC_PER_MIN * MS_PER_SECOND ) ///< Time to wait for sampling flush R1 to R2 drain R2 in milliseconds. #define SAMPLE_FLUSH_WAIT_STATE_TIMEOUT_MS ( 30 * SEC_PER_MIN * MS_PER_SECOND ) ///< Time to wait for sampling flush R1 to R2 drain R2 state waiting for the user to confirm in milliseconds. +#define SAMPLE_FLUSH_RESULT_FAIL 0 ///< Chemical disinfect flush result fail. +#define SAMPLE_FLUSH_RESULT_PASS 1 ///< Chemical disinfect flush result pass. /// Cancellation paths typedef enum Cancellation_modes @@ -102,6 +104,13 @@ BOOL hasDisStatusBeenWrittenToNV; ///< Boolean flag to indicate whether the disinfect status been written to NV or not. } DISINFECT_NV_OPS_T; +/// Chem flush sample results structure +typedef struct +{ + BOOL hasMessageBeenReceived; ///< Boolean flag to indicate whether the message has been received from HD. + U32 chemFlushSampleResult; ///< Chemical disinfect flush sample results back from HD. +} CHEM_FLUSH_SAMPLE_RESULT_T; + // ********** private data ********** static DG_CHEM_DISINFECT_FLUSH_STATE_T chemDisinfectFlushState; ///< Currently active chemical disinfect flush state. @@ -122,6 +131,7 @@ static DISINFECT_NV_OPS_T disinfectNVOps; ///< Disinfect non-volatile memory operations. static BOOL hasAlarmBeenTriggered; ///< Boolean flag to indicate that an alarm has been raised. static BOOL haveDrainParamsBeenInit[ NUM_OF_DG_RESERVOIRS ]; ///< Boolean flag to indicate whether the drain parameters have been reset or not. +static CHEM_FLUSH_SAMPLE_RESULT_T sampleResult; ///< Chemical disinfect flush sample result. // ********** private function prototypes ********** @@ -154,7 +164,8 @@ * stateTrialCounter, rsrvr1Status, rsrvr2Status, haveInletWaterChecksPassed, * overallChemDisinfectFlushTimer, hasAlarmBeenTriggered, haveDrainParamsBeenInit * cancellationMode, rsrvrFillToFullStableTimeCounter, prevChemDisinfectFlushState - * numberOfPostDisinfectRinses, chemDisinfectFlushUIState, disinfectFlushNVOps + * numberOfPostDisinfectRinses, chemDisinfectFlushUIState, disinfectFlushNVOps, + * sampleResult * @return none *************************************************************************/ void initChemicalDisinfectFlushMode( void ) @@ -178,6 +189,8 @@ hasAlarmBeenTriggered = FALSE; haveDrainParamsBeenInit[ DG_RESERVOIR_1 ] = FALSE; haveDrainParamsBeenInit[ DG_RESERVOIR_2 ] = FALSE; + sampleResult.hasMessageBeenReceived = FALSE; + sampleResult.chemFlushSampleResult = SAMPLE_FLUSH_RESULT_FAIL; } /*********************************************************************//** @@ -300,6 +313,20 @@ /*********************************************************************//** * @brief + * The setChemicalDisinfectFlushSampleResult function sets the received chemical + * disinfect sample flush result. + * @details Inputs: none + * @details Outputs: sampleResult + * @return none + *************************************************************************/ +void setChemicalDisinfectFlushSampleResult( U32 result ) +{ + sampleResult.hasMessageBeenReceived = TRUE; + sampleResult.chemFlushSampleResult = result; +} + +/*********************************************************************//** + * @brief * The stopChemicalDisinfectFlush function stops chemical disinfect flush mode. * @details Inputs: none * @details Outputs: none @@ -369,6 +396,15 @@ { DG_CHEM_DISINFECT_FLUSH_STATE_T state = DG_CHEM_DISINFECT_FLUSH_STATE_DRAIN_R1; + if ( ( TRUE == isThisLastDrain ) && ( SAMPLE_FLUSH_RESULT_PASS == sampleResult.chemFlushSampleResult ) ) + { + // Drain R1 state comes after chemical flush sample result. If this is the last drain, and the sample flush result + // has passed write the new chemical flush sample time to the NV memory. This is done in drain R1 so the write to NV + // can be attempted until the write is scheduled in the NV queue. + // If the sample result is failed, do not update the time so the chemical disinfect sample flush is considered failed. + writeDisinfectDataToNV( USAGE_INFO_CHEM_FLUSH ); + } + if ( DG_RESERVOIR_ABOVE_TARGET == rsrvr1Status ) { rsrvr1Status = getRsrvrDrainStatus( DG_RESERVOIR_1, DRAIN_WEIGHT_UNCHANGE_TIMEOUT_MS, RSRVRS_INITIAL_FINAL_DRAIN_TIME_OUT_MS ); @@ -718,26 +754,30 @@ if ( ( TRUE == hasAlarmBeenTriggered ) && ( FALSE == isAlarmActive( ALARM_ID_DG_CHEM_DISINFECT_FLUSH_FLUSH_SAMPLE ) ) ) { - signalROPumpHardStop(); - turnOffUVReactor( INLET_UV_REACTOR ); - turnOffUVReactor( OUTLET_UV_REACTOR ); - requestConcentratePumpOff( CONCENTRATEPUMPS_CP1_ACID, NO_PARK_CONC_PUMPS ); - requestConcentratePumpOff( CONCENTRATEPUMPS_CP2_BICARB, NO_PARK_CONC_PUMPS ); - setValveState( VPI, VALVE_STATE_CLOSED ); - setValveState( VRF, VALVE_STATE_R2_C_TO_NO ); - setValveState( VPD, VALVE_STATE_DRAIN_C_TO_NO ); - setValveState( VRC, VALVE_STATE_DRAIN_C_TO_NO ); - setValveState( VDR, VALVE_STATE_DRAIN_C_TO_NO ); - setValveState( VRI, VALVE_STATE_R1_C_TO_NO ); - setValveState( VPO, VALVE_STATE_FILL_C_TO_NC ); - setValveState( VRD1, VALVE_STATE_OPEN ); - setValveState( VRD2, VALVE_STATE_CLOSED ); + if ( TRUE == sampleResult.hasMessageBeenReceived ) + { + // The sample flush message has been received. + signalROPumpHardStop(); + turnOffUVReactor( INLET_UV_REACTOR ); + turnOffUVReactor( OUTLET_UV_REACTOR ); + requestConcentratePumpOff( CONCENTRATEPUMPS_CP1_ACID, NO_PARK_CONC_PUMPS ); + requestConcentratePumpOff( CONCENTRATEPUMPS_CP2_BICARB, NO_PARK_CONC_PUMPS ); + setValveState( VPI, VALVE_STATE_CLOSED ); + setValveState( VRF, VALVE_STATE_R2_C_TO_NO ); + setValveState( VPD, VALVE_STATE_DRAIN_C_TO_NO ); + setValveState( VRC, VALVE_STATE_DRAIN_C_TO_NO ); + setValveState( VDR, VALVE_STATE_DRAIN_C_TO_NO ); + setValveState( VRI, VALVE_STATE_R1_C_TO_NO ); + setValveState( VPO, VALVE_STATE_FILL_C_TO_NC ); + setValveState( VRD1, VALVE_STATE_OPEN ); + setValveState( VRD2, VALVE_STATE_CLOSED ); - isThisLastDrain = TRUE; - rsrvr1Status = DG_RESERVOIR_ABOVE_TARGET; - hasAlarmBeenTriggered = TRUE; - stateTimer = getMSTimerCount(); - state = DG_CHEM_DISINFECT_FLUSH_STATE_DRAIN_R1; + isThisLastDrain = TRUE; + rsrvr1Status = DG_RESERVOIR_ABOVE_TARGET; + hasAlarmBeenTriggered = TRUE; + stateTimer = getMSTimerCount(); + state = DG_CHEM_DISINFECT_FLUSH_STATE_DRAIN_R1; + } } if ( TRUE == didTimeout( stateTimer, SAMPLE_FLUSH_WAIT_STATE_TIMEOUT_MS ) )