Index: firmware/App/Modes/BloodPrime.c =================================================================== diff -u -rd963f2a611b2d5ed18172c390b0f593045abced7 -r8d3dbd25627fb7e993409eb47b2575e0430afddd --- firmware/App/Modes/BloodPrime.c (.../BloodPrime.c) (revision d963f2a611b2d5ed18172c390b0f593045abced7) +++ firmware/App/Modes/BloodPrime.c (.../BloodPrime.c) (revision 8d3dbd25627fb7e993409eb47b2575e0430afddd) @@ -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 }; @@ -126,21 +128,35 @@ setValvePosition( VDI, VALVE_POSITION_C_CLOSE ); setValvePosition( VDO, VALVE_POSITION_C_CLOSE ); setValvePosition( VBA, VALVE_POSITION_B_OPEN ); - setValvePosition( VBV, VALVE_POSITION_B_OPEN ); // Ensure dialysate outlet and Heparin pumps are stopped signalDialOutPumpHardStop(); stopSyringePump(); // start blood and dialysate inlet pumps - setBloodPumpTargetFlowRate( (U32)bloodPrimeRampFlowRate_mL_min, MOTOR_DIR_FORWARD, PUMP_CONTROL_MODE_OPEN_LOOP ); setDialInPumpTargetFlowRate( DIALYSATE_FLOW_RATE_FOR_RECIRC, MOTOR_DIR_FORWARD, PUMP_CONTROL_MODE_CLOSED_LOOP ); cmdStartDGTrimmerHeater(); setCurrentSubState( (U32)bloodPrimeState ); // Start air trap control startAirTrapControl(); + // 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, PUMP_CONTROL_MODE_OPEN_LOOP ); + // close VBV for fill + setValvePosition( VBV, VALVE_POSITION_C_CLOSE ); + } + else + { + // Start blood pump at prescribed flow rate + setBloodPumpTargetFlowRate( (U32)bloodPrimeRampFlowRate_mL_min, MOTOR_DIR_FORWARD, PUMP_CONTROL_MODE_OPEN_LOOP ); + // re-open VBV for blood recirculation + setValvePosition( VBV, VALVE_POSITION_B_OPEN ); + } + // Set user alarm recovery actions allowed in this sub-mode setAlarmUserActionEnabled( ALARM_USER_ACTION_RESUME, TRUE ); setAlarmUserActionEnabled( ALARM_USER_ACTION_RINSEBACK, TRUE ); @@ -151,12 +167,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: airTrapFillInProgress * @return none *************************************************************************/ static void resetBloodPrimeFlags( void ) { - // No flags for now + airTrapFillInProgress = isAirTrapFillInProgress(); } /*********************************************************************//** @@ -210,8 +226,9 @@ * @brief * The handleBloodPrimeRampState function handles the blood prime ramp * state operations. - * @details Inputs: flags - * @details Outputs: flags handled + * @details Inputs: bloodPrimeTargetVolume_mL, airTrapFillInProgress, + * bloodPrimeRampControlTimerCtr + * @details Outputs: cumulativeBloodPrimeVolume_mL, bloodPrimeRampControlTimerCtr * @return next blood prime state *************************************************************************/ static BLOOD_PRIME_STATE_T handleBloodPrimeRampState( void ) @@ -227,6 +244,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_OPEN_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 +269,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 );