Index: firmware/App/Modes/ModeTreatment.c =================================================================== diff -u -r999e1a2f4e499155d934b3aaa93c0ae02161d3c7 -rb55b4aad2941b470c5652aad5538a1bbb28a76ed --- firmware/App/Modes/ModeTreatment.c (.../ModeTreatment.c) (revision 999e1a2f4e499155d934b3aaa93c0ae02161d3c7) +++ firmware/App/Modes/ModeTreatment.c (.../ModeTreatment.c) (revision b55b4aad2941b470c5652aad5538a1bbb28a76ed) @@ -7,8 +7,8 @@ * * @file ModeTreatment.c * -* @author (last) Vijay Pamula -* @date (last) 26-Jun-2026 +* @author (last) Varshini Nagabooshanam +* @date (last) 05-Aug-2026 * * @author (original) Sean Nash * @date (original) 21-Apr-2025 @@ -679,13 +679,32 @@ // Came back from temp break? if ( TRUE == recircAllowed ) { - F32 rinsebackVolume_L = getDeliveredRinsebackVolume() / (F32)ML_PER_LITER; + // Add rinseback volume (ml) to uf volume. + F32 newUFVolumeMl = ( getTreatmentParameterF32( TREATMENT_PARAM_UF_VOLUME ) * + (F32)ML_PER_LITER ) + getDeliveredRinsebackVolume(); + F32 remainingTimeMins = (F32)( getTreatmentTimeRemainingSecs() / SEC_PER_MIN ); + F32 newUFRateMlMin = ( remainingTimeMins > 0.0F ) ? + ( newUFVolumeMl / remainingTimeMins ) : 0.0F; - presUFVolumeMl = ( getTreatmentParameterF32( TREATMENT_PARAM_UF_VOLUME ) + rinsebackVolume_L ) * (F32)ML_PER_LITER; - presUFRateMlMin = presUFVolumeMl / (F32)( getTreatmentTimeRemainingSecs() / SEC_PER_MIN ); - // Add rinseback volume to UF volume (fluid in circuit goes back to the patient when we resume treatment) - setTreatmentParameterF32( TREATMENT_PARAM_UF_VOLUME, presUFVolumeMl ); - setDialysisDDParams( getTreatmentParameterU32( TREATMENT_PARAM_DIALYSATE_FLOW ), presUFVolumeMl, presUFRateMlMin ); + // Clamp to max UF volume + if ( newUFVolumeMl > (F32)MAX_UF_VOLUME_ML ) + { + newUFVolumeMl = (F32)MAX_UF_VOLUME_ML; + } + + // Clamp to max UF rate + if ( newUFRateMlMin > MAX_UF_RATE_ML_MIN ) + { + newUFRateMlMin = MAX_UF_RATE_ML_MIN; + } + + presUFVolumeMl = newUFVolumeMl; + presUFRateMlMin = newUFRateMlMin; + setTreatmentParameterF32( TREATMENT_PARAM_UF_VOLUME, + presUFVolumeMl / (F32)ML_PER_LITER ); + setDialysisDDParams( getTreatmentParameterU32( TREATMENT_PARAM_DIALYSATE_FLOW ), + presUFVolumeMl, + presUFRateMlMin ); recircAllowed = FALSE; }