Index: firmware/App/Modes/Dialysis.c =================================================================== diff -u -r1a36e9bd718b40ceaee21dd12eca2da353828e30 -r86dc010eacfdaad879327202bf03336e0c77ead3 --- firmware/App/Modes/Dialysis.c (.../Dialysis.c) (revision 1a36e9bd718b40ceaee21dd12eca2da353828e30) +++ firmware/App/Modes/Dialysis.c (.../Dialysis.c) (revision 86dc010eacfdaad879327202bf03336e0c77ead3) @@ -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,17 +219,36 @@ lastUFTimeStamp = getMSTimerCount(); // Send dialysate outlet pump latest UF volumes setDialOutUFVolumes( refUFVolume, measUFVolume ); + // initialize air trap fill flag + airTrapFillInProgress = FALSE; + // Reset saline bolus state machine + resetSalineBolus(); resetReservoirsVariables(); // Reset the blood leak zeroing variables resetBloodLeakZeroingVariables(); + // make sure air trap fill is handled right + if ( 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, mode ); + // close VBV for fill + setValvePosition( VBV, VALVE_POSITION_C_CLOSE ); + } + else + { + // Start blood pump at prescribed flow rate + setBloodPumpTargetFlowRate( setBloodFlowRate, MOTOR_DIR_FORWARD, mode ); + // re-open VBV for blood recirculation + setValvePosition( VBV, VALVE_POSITION_B_OPEN ); + } + // Set valves for dialysis setValvePosition( VDI, VALVE_POSITION_B_OPEN ); setValvePosition( VDO, VALVE_POSITION_B_OPEN ); setValvePosition( VBA, VALVE_POSITION_B_OPEN ); - setValvePosition( VBV, VALVE_POSITION_B_OPEN ); // Restart pumps #ifndef _RELEASE_ @@ -236,7 +257,6 @@ mode = PUMP_CONTROL_MODE_OPEN_LOOP; } #endif - setBloodPumpTargetFlowRate( setBloodFlowRate, MOTOR_DIR_FORWARD, mode ); #ifndef _RELEASE_ if ( SW_CONFIG_ENABLE_VALUE == getSoftwareConfigStatus( SW_CONFIG_ENABLE_DIALYSATE_INLET_PUMP_OPEN_LOOP ) ) { @@ -572,6 +592,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 +628,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 +662,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 +764,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.