Index: firmware/App/Modes/Rinseback.c =================================================================== diff -u -r0bb3fe3f34c02bd19c36aff2b98876e46a2ad177 -r48fda88cb7d8607181efb80f98deaaab1b343a92 --- firmware/App/Modes/Rinseback.c (.../Rinseback.c) (revision 0bb3fe3f34c02bd19c36aff2b98876e46a2ad177) +++ firmware/App/Modes/Rinseback.c (.../Rinseback.c) (revision 48fda88cb7d8607181efb80f98deaaab1b343a92) @@ -82,6 +82,7 @@ static BOOL recircRequested; ///< Flag indicates user requesting to begin re-circulation (confirming disconnection and shunt). static BOOL backToTreatmentRequested; ///< Flag indicates user requesting to go back to treatment (confirming still connected). static BOOL endTreatmentRequested; ///< Flag indicates user requesting to end treatment. +static BOOL airTrapFillInProgress; ///< Flag indicates an air trap fill is in progress. // ********** private function prototypes ********** @@ -133,6 +134,7 @@ rinsebackAdditionalTimerCtr = 0; rinsebackPublishTimerCtr = 0; resetRinsebackFlags(); + airTrapFillInProgress = FALSE; // set to false initially - so keep after call to reset function } /*********************************************************************//** @@ -154,6 +156,7 @@ recircRequested = FALSE; backToTreatmentRequested = FALSE; endTreatmentRequested = FALSE; + airTrapFillInProgress = isAirTrapFillInProgress(); } /*********************************************************************//** @@ -453,20 +456,20 @@ setupForRinsebackStopOrPause(); result = RINSEBACK_PAUSED_STATE; } - // 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 ); } // Otherwise, continue rinseback else { - // re-open VBV and restore BP rate after air trap fill - if ( VALVE_POSITION_C_CLOSE == getSetValvePosition( VBV ) ) + if ( ( TRUE == airTrapFillInProgress ) && ( isAirTrapFillInProgress() != TRUE ) ) { + // re-open VBV after fill setValvePosition( VBV, VALVE_POSITION_B_OPEN ); // restore BP to rinseback blood flow rate setBloodPumpTargetFlowRate( rinsebackRate_mL_min, MOTOR_DIR_FORWARD, PUMP_CONTROL_MODE_CLOSED_LOOP ); @@ -645,17 +648,18 @@ setRinsebackIsCompleted( TRUE ); } } - // 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 rinseback blood flow rate setBloodPumpTargetFlowRate( rinsebackRate_mL_min, MOTOR_DIR_FORWARD, PUMP_CONTROL_MODE_CLOSED_LOOP );