Index: firmware/App/Modes/ModeTreatment.c =================================================================== diff -u -r52feec1100700c02663a4d02e2cb16bd48317c3a -r66f8be898cf684567d873e0141c0f47100b34e95 --- firmware/App/Modes/ModeTreatment.c (.../ModeTreatment.c) (revision 52feec1100700c02663a4d02e2cb16bd48317c3a) +++ firmware/App/Modes/ModeTreatment.c (.../ModeTreatment.c) (revision 66f8be898cf684567d873e0141c0f47100b34e95) @@ -1090,7 +1090,7 @@ * @details Inputs: current operating mode, treatment states and parameters * @details Outputs: response message sent * @param uFVolume New ultrafiltration volume requested by the user - * @return TRUE if new UF voluem is valid, FALSE if not. + * @return TRUE if new UF volume is valid, FALSE if not. *************************************************************************/ BOOL verifyUFSettingsChange( F32 uFVolume ) { @@ -1103,7 +1103,6 @@ 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; @@ -1113,11 +1112,12 @@ // 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 ) && ( remUFVol > MIN_UF_RATE_ML_MIN ) && + ( uFVolume <= MAX_UF_VOLUME_ML ) && ( uFVolume > colUFVol ) && ( 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 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,8 +1165,9 @@ { rejectReason = REQUEST_REJECT_REASON_INVALID_TREATMENT_STATE; } + // UF volume cannot be set lower than the UF volume that has already been collected else if ( ( uFVolume > MAX_UF_VOLUME_ML ) || - ( remUFVol <= MIN_UF_RATE_ML_MIN ) ) + ( uFVolume <= colUFVol ) ) { rejectReason = REQUEST_REJECT_REASON_UF_VOLUME_OUT_OF_RANGE; }