Index: firmware/App/Modes/ModeTreatment.c =================================================================== diff -u -r408247fba0f81c8ca77fb3144694ac8d7358d87b -re2cf7feff54dad3fc5be72619fa64b5421fc6f9f --- firmware/App/Modes/ModeTreatment.c (.../ModeTreatment.c) (revision 408247fba0f81c8ca77fb3144694ac8d7358d87b) +++ 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 @@ -89,6 +89,7 @@ static U32 treatmentTimeBroadcastTimerCtr; ///< Treatment time data broadcast timer counter used to schedule when to transmit data. static U32 treatmentStateBroadcastTimerCtr; ///< Treatment state data broadcast timer counter used to schedule when to transmit data. static U32 treatmentParamsRangesBroadcastTimerCtr; ///< Treatment parameter ranges broadcast timer counter used to schedule when to transmit updated ranges. + /// Interval (in task intervals) at which to publish alarm status to CAN bus. static OVERRIDE_U32_T treatmentTimePublishInterval = { TREATMENT_TIME_DATA_PUB_INTERVAL, TREATMENT_TIME_DATA_PUB_INTERVAL, TREATMENT_TIME_DATA_PUB_INTERVAL, 0 }; /// Interval (in task intervals) at which to publish alarm status to CAN bus. @@ -1035,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 { @@ -1090,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 ) { @@ -1102,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; @@ -1111,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 @@ -1165,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; }