Index: firmware/App/Modes/TreatmentEnd.c =================================================================== diff -u -r0bb3fe3f34c02bd19c36aff2b98876e46a2ad177 -r48fda88cb7d8607181efb80f98deaaab1b343a92 --- firmware/App/Modes/TreatmentEnd.c (.../TreatmentEnd.c) (revision 0bb3fe3f34c02bd19c36aff2b98876e46a2ad177) +++ firmware/App/Modes/TreatmentEnd.c (.../TreatmentEnd.c) (revision 48fda88cb7d8607181efb80f98deaaab1b343a92) @@ -54,6 +54,7 @@ static BOOL txEndRinsebackRequested; ///< Flag indicates user requesting final rinseback. static BOOL txEndDrainCmdSent; ///< Flag indicates DG Drain command has been sent. static U32 treatmentEndPublishTimerCtr; ///< Timer counter for determining interval for treatment end status to be published. +static BOOL airTrapFillInProgress; ///< Flag indicates an air trap fill is in progress. // ********** private function prototypes ********** @@ -84,6 +85,7 @@ treatmentEndPublishTimerCtr = 0; txEndDrainCmdSent = FALSE; resetTreatmentEndFlags(); + airTrapFillInProgress = FALSE; // set to false initially - so keep after call to reset function } /*********************************************************************//** @@ -98,6 +100,7 @@ txEndAlarmRinsebackRequested = FALSE; txEndAlarmEndTreatmentRequested = FALSE; txEndRinsebackRequested = FALSE; + airTrapFillInProgress = isAirTrapFillInProgress(); } /*********************************************************************//** @@ -271,18 +274,20 @@ { signalGoToRinseback(); } - // set BP to air trap fill rate if air trap fill has been initiated - else if ( TRUE == isAirTrapFillInProgress() ) + // if an air trap fill has started, set BP rate and VBV state accordingly + else if ( ( airTrapFillInProgress != TRUE ) && ( TRUE == isAirTrapFillInProgress() ) ) { - if ( 0 == getTargetBloodFlowRate() ) - { - setBloodPumpTargetFlowRate( AIR_TRAP_FILL_BLOOD_FLOW_RATE, MOTOR_DIR_FORWARD, PUMP_CONTROL_MODE_CLOSED_LOOP ); - } + // set BP to air trap fill rate if air trap fill has been initiated + setBloodPumpTargetFlowRate( AIR_TRAP_FILL_BLOOD_FLOW_RATE, MOTOR_DIR_FORWARD, PUMP_CONTROL_MODE_CLOSED_LOOP ); + // close VBV for fill + setValvePosition( VBV, VALVE_POSITION_C_CLOSE ); } // re-open VBV and restore BP rate after air trap fill - else if ( VALVE_POSITION_C_CLOSE == getSetValvePosition( VBV ) ) + else if ( ( TRUE == airTrapFillInProgress ) && ( isAirTrapFillInProgress() != TRUE ) ) { + // re-open VBV after fill setValvePosition( VBV, VALVE_POSITION_B_OPEN ); + // restore BP to Tx End blood flow rate setBloodPumpTargetFlowRate( TX_END_BP_FLOW_RATE_ML_MIN, MOTOR_DIR_FORWARD, PUMP_CONTROL_MODE_CLOSED_LOOP ); }