Index: firmware/App/Modes/ModePreTreat.c =================================================================== diff -u -r044d8892373acc5545020aab894cd1943c4d7449 -r71ecc11dd03b57dbabfd9bb3c4d682162c3d06d7 --- firmware/App/Modes/ModePreTreat.c (.../ModePreTreat.c) (revision 044d8892373acc5545020aab894cd1943c4d7449) +++ firmware/App/Modes/ModePreTreat.c (.../ModePreTreat.c) (revision 71ecc11dd03b57dbabfd9bb3c4d682162c3d06d7) @@ -993,6 +993,7 @@ cmdStartDG(); } + // Ensure any pending reservoir switches are completed before sending drain command if ( TRUE == hasDGCompletedReservoirSwitch() ) { if ( ( DG_MODE_GENE == dgOpMode ) && ( DG_GEN_IDLE_MODE_STATE_FLUSH_WATER == dgSubMode ) ) @@ -1019,11 +1020,15 @@ DG_CMD_RESPONSE_T dgCmdResp; DG_OP_MODE_T dgOpMode = getDGOpMode(); + // Check DG response to drain command if ( TRUE == getDGCommandResponse( DG_CMD_START_DRAIN, &dgCmdResp ) ) { if ( DG_CMD_REQUEST_REJECT_REASON_NONE == dgCmdResp.rejectCode ) { - state = PRE_TREATMENT_RESERVOIR_MGMT_START_FILL_STATE; + if ( DG_MODE_DRAI == dgOpMode ) + { + state = PRE_TREATMENT_RESERVOIR_MGMT_START_FILL_STATE; + } } else { @@ -1053,18 +1058,14 @@ if ( ( DG_MODE_GENE == dgOpMode ) && ( DG_GEN_IDLE_MODE_STATE_FLUSH_WATER == dgSubMode ) ) { - // if fills not yet enabled, check to see if we want to move on to drain the other reservoir - if ( reservoirFlags[ DG_RESERVOIR_1 ].startFlushFill != TRUE ) + // Drain both reservoirs and return to active res 2 before initial fills + if ( initialReservoirDrain[ inactiveReservoir ] != TRUE ) { - if ( ( initialReservoirDrain[ inactiveReservoir ] != TRUE ) || - ( inactiveReservoir != DG_RESERVOIR_1 ) ) - { - initialReservoirDrain[ inactiveReservoir ] = TRUE; - state = PRE_TREATMENT_RESERVOIR_MGMT_REQUEST_RESERVOIR_SWITCH_STATE; - } + initialReservoirDrain[ inactiveReservoir ] = TRUE; + state = PRE_TREATMENT_RESERVOIR_MGMT_REQUEST_RESERVOIR_SWITCH_STATE; } - - else + // Once both reservoirs drained and returned to active res 2, wait for pre-tx workflow to get to point where fills allowed before filling + else if ( TRUE == reservoirFlags[ DG_RESERVOIR_1 ].startFlushFill ) { volume = getPreTreatmentFillVolume( inactiveReservoir ); @@ -1160,7 +1161,7 @@ } else { - state = PRE_TREATMENT_RESERVOIR_MGMT_REQUEST_RESERVOIR_SWITCH_STATE; + state = PRE_TREATMENT_RESERVOIR_MGMT_WAIT_FOR_RESERVOIR_SWITCH_STATE; if ( FALSE == reservoirFlushedStatus[ DG_RESERVOIR_1 ] ) { @@ -1242,7 +1243,6 @@ { if ( DG_CMD_REQUEST_REJECT_REASON_INVALID_MODE == dgCmdResp.rejectCode ) { - state = PRE_TREATMENT_RESERVOIR_MGMT_REQUEST_RESERVOIR_SWITCH_STATE; } else if ( dgCmdResp.rejectCode != DG_CMD_REQUEST_REJECT_REASON_NONE )