Index: firmware/App/Modes/SalineBolus.c =================================================================== diff -u -r2f9807457197c347c20a24c64492edcf063f3daa -r8d3dbd25627fb7e993409eb47b2575e0430afddd --- firmware/App/Modes/SalineBolus.c (.../SalineBolus.c) (revision 2f9807457197c347c20a24c64492edcf063f3daa) +++ firmware/App/Modes/SalineBolus.c (.../SalineBolus.c) (revision 8d3dbd25627fb7e993409eb47b2575e0430afddd) @@ -15,7 +15,6 @@ * ***************************************************************************/ - #include "BloodFlow.h" #include "Dialysis.h" #include "ModeTreatment.h" @@ -44,6 +43,7 @@ static U32 salineBolusBroadcastTimerCtr; ///< Saline bolus data broadcast timer counter used to schedule when to transmit data. static BOOL salineBolusStartRequested; ///< Flag indicates a saline bolus start has been requested by user. static BOOL salineBolusAbortRequested; ///< Flag indicates a salien bolus abort has been requested by user. +static BOOL airTrapFillInProgress; ///< Flag indicates an air trap fill is in progress. static F32 totalSalineVolumeDelivered_mL; ///< Volume (mL) in total of saline delivered so far (cumulative for all boluses including current one). static F32 bolusSalineVolumeDelivered_mL; ///< Volume (mL) of current bolus delivered so far (calculated from measured blood flow rate). @@ -63,7 +63,7 @@ * @details Inputs: none * @details Outputs: currentSalineBolusState, salineBolusBroadcastTimerCtr, * totalSalineVolumeDelivered_mL, bolusSalineVolumeDelivered_mL, - * salineBolusStartRequested, salineBolusAbortRequested + * salineBolusStartRequested, salineBolusAbortRequested, airTrapFillInProgress * @return none *************************************************************************/ void initSalineBolus( void ) @@ -74,6 +74,7 @@ bolusSalineVolumeDelivered_mL = 0.0; salineBolusStartRequested = FALSE; salineBolusAbortRequested = FALSE; + airTrapFillInProgress = FALSE; bolusSalineLastVolumeTimeStamp = getMSTimerCount(); } @@ -82,14 +83,15 @@ * The resetSalineBolus function resets the saline bolus variables. * @details Inputs: currentSalineBolusState * @details Outputs: bolusSalineVolumeDelivered_mL, salineBolusStartRequested, - * salineBolusAbortRequested, currentSalineBolusState + * salineBolusAbortRequested, currentSalineBolusState, airTrapFillInProgress * @return none *************************************************************************/ void resetSalineBolus( void ) { bolusSalineVolumeDelivered_mL = 0.0; salineBolusStartRequested = FALSE; salineBolusAbortRequested = FALSE; + airTrapFillInProgress = FALSE; currentSalineBolusState = SALINE_BOLUS_STATE_IDLE; resetUF(); } @@ -98,7 +100,7 @@ * @brief * The execSalineBolus function executes the saline bolus state machine. * @details Inputs: currentSalineBolusState - * @details Outputs: currentSalineBolusState + * @details Outputs: currentSalineBolusState, airTrapFillInProgress * @return Current saline bolus state machine. *************************************************************************/ SALINE_BOLUS_STATE_T execSalineBolus( void ) @@ -125,6 +127,8 @@ break; } + airTrapFillInProgress = isAirTrapFillInProgress(); + if ( priorSubState != currentSalineBolusState ) { setCurrent4thLevelState( (U32)currentSalineBolusState ); @@ -217,7 +221,7 @@ } else if ( ( TRUE == isAnyAlarmActive() ) && ( ( TRUE == isBloodRecircBlocked() ) || ( TRUE == isRinseBackBlocked() ) ) ) { - // Any alarm can be active but blood recirculation and dialysate recirculation cannot be blocked in their properties in order + // Any alarm can be active but blood recirculation and rinseback cannot be blocked in their properties in order // to do saline bolus rejReason = REQUEST_REJECT_REASON_SALINE_BOLUS_NOT_ALLOWED; } @@ -377,8 +381,11 @@ * @brief * The handleSalineBolusInProgressState function handles the in-progress state of the * saline bolus state machine. - * @details Inputs: none - * @details Outputs: + * @details Inputs: bolusSalineLastVolumeTimeStamp, bolusSalineVolumeDelivered_mL, + * totalSalineVolumeDelivered_mL, salineBolusAbortRequested + * @details Outputs: bolusSalineLastVolumeTimeStamp, bolusSalineVolumeDelivered_mL, + * totalSalineVolumeDelivered_mL, airTrapFillInProgress, salineBolusAbortRequested, + * salineBolusBroadcastTimerCtr * @return next saline bolus state *************************************************************************/ static SALINE_BOLUS_STATE_T handleSalineBolusInProgressState( void ) @@ -395,6 +402,23 @@ bolusSalineVolumeDelivered_mL += volSinceLastUpdateMl; totalSalineVolumeDelivered_mL += volSinceLastUpdateMl; + // 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 saline bolus + else if ( ( TRUE == airTrapFillInProgress ) && ( isAirTrapFillInProgress() != TRUE ) ) + { + // Set to patient in case VBV is closed in treatment stop + setValvePosition( VBV, VALVE_POSITION_B_OPEN ); + // Start blood pump at saline bolus rate + setBloodPumpTargetFlowRate( SALINE_BOLUS_FLOW_RATE, MOTOR_DIR_FORWARD, PUMP_CONTROL_MODE_CLOSED_LOOP ); + } + // Check for empty saline bag per arterial line pressure if ( TRUE == isSalineBagEmpty() ) {