Index: firmware/App/Modes/ModeTreatment.c =================================================================== diff -u -r408247fba0f81c8ca77fb3144694ac8d7358d87b -r52feec1100700c02663a4d02e2cb16bd48317c3a --- firmware/App/Modes/ModeTreatment.c (.../ModeTreatment.c) (revision 408247fba0f81c8ca77fb3144694ac8d7358d87b) +++ firmware/App/Modes/ModeTreatment.c (.../ModeTreatment.c) (revision 52feec1100700c02663a4d02e2cb16bd48317c3a) @@ -1102,6 +1102,8 @@ S32 txSecRem = CALC_TREAT_TIME_REMAINING_IN_SECS(); S32 txMinEla = CALC_ELAPSED_TREAT_TIME_IN_SECS() / SEC_PER_MIN; F32 txMinRem = (F32)txSecRem / (F32)SEC_PER_MIN; + F32 colUFVol = getUltrafiltrationReferenceVolume(); // How much UF volume have we taken so far? + F32 remUFVol = uFVolume - colUFVol; // What would remaining UF volume be after subtracting UF volume already taken // Reset pending UF/time settings changes to current values in case request is rejected pendingUFVolumeChange = presMaxUFVolumeML; @@ -1111,13 +1113,11 @@ // Check if we are in an appropriate treatment state for settings adjustment if ( ( MODE_TREA == currMode ) && ( currentTreatmentState > TREATMENT_START_STATE ) && ( currentTreatmentState < TREATMENT_END_STATE ) && - ( uFVolume <= MAX_UF_VOLUME_ML ) && + ( uFVolume <= MAX_UF_VOLUME_ML ) && ( remUFVol > MIN_UF_RATE_ML_MIN ) && ( CALC_TREAT_TIME_REMAINING_IN_SECS() >= PREVENT_UF_VOL_CHANGE_IF_NEARLY_DONE_SEC ) ) { DIALYSIS_STATE_T currDialysisState = getDialysisState(); UF_STATE_T currUFState = getUltrafiltrationState(); - F32 colUFVol = getUltrafiltrationReferenceVolume(); // How much UF volume have we taken so far? - F32 remUFVol = uFVolume - colUFVol; // What would remaining UF volume be after subtracting UF volume already taken F32 remUFVolCap = RANGE( remUFVol, 0.0F, (F32)MAX_UF_VOLUME_ML ); // Enforce valid range on remaining UF volume F32 uFRate = remUFVolCap / txMinRem; // What UF rate would be if user selected to adjust it U32 trtTime = ( fabs( presUFRate ) < NEARLY_ZERO ? txMinEla + 1 : (S32)( remUFVolCap / presUFRate ) + txMinEla + 1 ); // What the treatment duration would be if user selected to adjust it @@ -1165,7 +1165,8 @@ { rejectReason = REQUEST_REJECT_REASON_INVALID_TREATMENT_STATE; } - else if ( uFVolume > MAX_UF_VOLUME_ML ) + else if ( ( uFVolume > MAX_UF_VOLUME_ML ) || + ( remUFVol <= MIN_UF_RATE_ML_MIN ) ) { rejectReason = REQUEST_REJECT_REASON_UF_VOLUME_OUT_OF_RANGE; }