Index: firmware/App/Modes/ModeTreatment.c =================================================================== diff -u -rb687ab5673dc5da53537f538056ea12842b3f6ce -re2cf7feff54dad3fc5be72619fa64b5421fc6f9f --- firmware/App/Modes/ModeTreatment.c (.../ModeTreatment.c) (revision b687ab5673dc5da53537f538056ea12842b3f6ce) +++ firmware/App/Modes/ModeTreatment.c (.../ModeTreatment.c) (revision e2cf7feff54dad3fc5be72619fa64b5421fc6f9f) @@ -8,7 +8,7 @@ * @file ModeTreatment.c * * @author (last) Darren Cox -* @date (last) 23-Aug-2023 +* @date (last) 19-Sep-2023 * * @author (original) Dara Navaei * @date (original) 05-Nov-2019 @@ -1036,6 +1036,7 @@ setTreatmentParameterF32( TREATMENT_PARAM_UF_VOLUME, ( presMaxUFVolumeML / (F32)ML_PER_LITER ) ); setTreatmentParameterU32( TREATMENT_PARAM_TREATMENT_DURATION, ( presTreatmentTimeSecs / SEC_PER_MIN ) ); setDialysisParams( getTreatmentParameterU32( TREATMENT_PARAM_BLOOD_FLOW ), getTreatmentParameterU32( TREATMENT_PARAM_DIALYSATE_FLOW ), presMaxUFVolumeML, presUFRate ); + signalInitiatePressureStabilization( USE_NORMAL_STABILIZATION_PERIOD ); } else { @@ -1091,7 +1092,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,6 +1104,7 @@ 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? // Reset pending UF/time settings changes to current values in case request is rejected pendingUFVolumeChange = presMaxUFVolumeML; @@ -1112,12 +1114,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 ) && ( 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 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 @@ -1166,7 +1167,9 @@ { rejectReason = REQUEST_REJECT_REASON_INVALID_TREATMENT_STATE; } - else if ( uFVolume > MAX_UF_VOLUME_ML ) + // UF volume cannot be set lower than the UF volume that has already been collected + else if ( ( uFVolume > MAX_UF_VOLUME_ML ) || + ( uFVolume <= colUFVol ) ) { rejectReason = REQUEST_REJECT_REASON_UF_VOLUME_OUT_OF_RANGE; }