Index: firmware/App/Modes/Dialysis.c =================================================================== diff -u -r1a36e9bd718b40ceaee21dd12eca2da353828e30 -rf3d625e2593ced120c4a98b9ed7e28b132445642 --- firmware/App/Modes/Dialysis.c (.../Dialysis.c) (revision 1a36e9bd718b40ceaee21dd12eca2da353828e30) +++ firmware/App/Modes/Dialysis.c (.../Dialysis.c) (revision f3d625e2593ced120c4a98b9ed7e28b132445642) @@ -103,6 +103,7 @@ static F32 setUFRate; ///< Currently set ultrafiltration rate (from prescription). static BOOL autoResumeUF; ///< Flag indicates UF should be auto-resumed after saline bolus completes. +static BOOL airTrapFillInProgress; ///< Flag indicates an air trap fill is in progress. static BLOOD_LEAK_ZEROING_T bloodLeakZeroingStatus; ///< Blood leak zeroing status. // ********** private function prototypes ********** @@ -160,6 +161,7 @@ resetDialOutRateOffset(); autoResumeUF = FALSE; + airTrapFillInProgress = FALSE; for ( i = 0; i < NUM_OF_LOAD_CELLS; i++ ) { @@ -217,6 +219,8 @@ lastUFTimeStamp = getMSTimerCount(); // Send dialysate outlet pump latest UF volumes setDialOutUFVolumes( refUFVolume, measUFVolume ); + // initialize air trap fill flag + airTrapFillInProgress = FALSE; resetReservoirsVariables(); @@ -572,6 +576,7 @@ bloodLeakZeroingStatus.zeroingRequestState = BLOOD_LEAK_ZEROING_RQST_REQUESTED; } + // Check for blood leak zeroing request if ( ( BLOOD_LEAK_ZEROING_RQST_REQUESTED == bloodLeakZeroingStatus.zeroingRequestState ) && ( DIALYSIS_UF_STATE == currentDialysisState ) ) { if ( TRUE == checkHasReservoirBeenSwitched() ) @@ -607,6 +612,8 @@ // Calculate UF measured volume and provide to dialysate outlet pump controller (watch UF regardless of dialysis state) updateUFVolumes(); + airTrapFillInProgress = isAirTrapFillInProgress(); + if ( priorSubState != currentDialysisState ) { setCurrentSubState( (U32)currentDialysisState ); @@ -639,6 +646,23 @@ setHeparinCompleted(); } + // if an air trap fill has started, set BP rate and VBV state accordingly + if ( ( airTrapFillInProgress != TRUE ) && ( TRUE == isAirTrapFillInProgress() ) ) + { + // 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 ); + } + // if an air trap fill has completed, restore BP and VBV to blood prime ramp settings + if ( ( TRUE == airTrapFillInProgress ) && ( isAirTrapFillInProgress() != TRUE ) ) + { + // restore BP to set blood flow rate + setBloodPumpTargetFlowRate( setBloodFlowRate, MOTOR_DIR_FORWARD, PUMP_CONTROL_MODE_CLOSED_LOOP ); + // re-open VBV for blood recirculation + setValvePosition( VBV, VALVE_POSITION_B_OPEN ); + } + // Handle current ultrafiltration state switch ( currentUFState ) { @@ -724,7 +748,7 @@ * @brief * The handleUFPausedState function handles the Paused state of the * ultrafiltration state machine. - * @details Inputs: salineBolusStartRequested + * @details Inputs: none * @details Outputs: if ultrafiltration resumption requested, UF time is set to resume. * @param dialysisState next dialysis state * @return next ultrafiltration state.