Index: firmware/App/Modes/BloodPrime.c =================================================================== diff -u -r1a36e9bd718b40ceaee21dd12eca2da353828e30 -rf3d625e2593ced120c4a98b9ed7e28b132445642 --- firmware/App/Modes/BloodPrime.c (.../BloodPrime.c) (revision 1a36e9bd718b40ceaee21dd12eca2da353828e30) +++ firmware/App/Modes/BloodPrime.c (.../BloodPrime.c) (revision f3d625e2593ced120c4a98b9ed7e28b132445642) @@ -61,6 +61,8 @@ static U32 bloodPrimeRampControlTimerCtr; ///< Timer counter for determining interval for controlling BP ramp. static U32 bloodPrimePublishTimerCtr; ///< Timer counter for determining interval for blood prime status to be published. +static BOOL airTrapFillInProgress; ///< Flag indicates an air trap fill is in progress. + /// Interval (in task intervals) at which to publish blood prime data to CAN bus. static OVERRIDE_U32_T bloodPrimePublishInterval = { BLOOD_PRIME_DATA_PUBLISH_INTERVAL, BLOOD_PRIME_DATA_PUBLISH_INTERVAL, BLOOD_PRIME_DATA_PUBLISH_INTERVAL, 0 }; @@ -151,12 +153,12 @@ * @brief * The resetBloodPrimeFlags function resets the blood prime request flags. * @details Inputs: none - * @details Outputs: Blood prime request flags reset to FALSE. + * @details Outputs: Blood prime request flags reset. * @return none *************************************************************************/ static void resetBloodPrimeFlags( void ) { - // No flags for now + airTrapFillInProgress = isAirTrapFillInProgress(); } /*********************************************************************//** @@ -227,6 +229,22 @@ cumulativeBloodPrimeVolume_mL.data = bloodPrimeTargetVolume_mL; } + // 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 + else if ( ( TRUE == airTrapFillInProgress ) && ( isAirTrapFillInProgress() != TRUE ) ) + { + // re-open VBV after fill + setValvePosition( VBV, VALVE_POSITION_B_OPEN ); + // Blood pump rate will be set to ramp rate below + } + // Has blood prime completed? if ( getBloodPrimeVolume() >= bloodPrimeTargetVolume_mL ) { @@ -236,13 +254,11 @@ signalBloodPrimeToDialysis(); // Signal treatment mode that it's time to start dialysis cmdStopDGTrimmerHeater(); // Stop trimmer heater - dialysis sub-mode will restart as appropriate } - else + else if ( isAirTrapFillInProgress() != TRUE ) { // ramp blood pump on ramp interval if ( ++bloodPrimeRampControlTimerCtr >= BLOOD_PRIME_RAMPING_INTERVAL ) { - U32 setBPRate = getTreatmentParameterU32( TREATMENT_PARAM_BLOOD_FLOW ); - bloodPrimeRampControlTimerCtr = 0; bloodPrimeRampFlowRate_mL_min += bloodPrimeRampStep_mL; setBloodPumpTargetFlowRate( (U32)bloodPrimeRampFlowRate_mL_min, MOTOR_DIR_FORWARD, PUMP_CONTROL_MODE_OPEN_LOOP );