Index: firmware/App/Modes/ModeTreatment.c =================================================================== diff -u -r4b358e1af8512dd9a0e948ef7c534b6af393b611 -r4aa16058db700e071748f89f91e6eb58ed348ea3 --- firmware/App/Modes/ModeTreatment.c (.../ModeTreatment.c) (revision 4b358e1af8512dd9a0e948ef7c534b6af393b611) +++ firmware/App/Modes/ModeTreatment.c (.../ModeTreatment.c) (revision 4aa16058db700e071748f89f91e6eb58ed348ea3) @@ -45,8 +45,6 @@ #define MAX_TREATMENT_TIME_MINUTES ( 8 * MIN_PER_HOUR ) ///< Maximum treatment time (in minutes). #define MIN_TREATMENT_TIME_MINUTES ( 1 * MIN_PER_HOUR ) ///< Minimum treatment time (in minutes). -#define MAX_UF_RATE_ML_MIN ( (F32)2500 / (F32)MIN_PER_HOUR ) ///< Maximum ultrafiltration rate (in mL/min). -#define MAX_UF_VOLUME_ML ( 8 * ML_PER_LITER ) ///< Maximum ultrafiltration volume (in mL). #define MAX_DIALYSATE_VOLUME_ML ( 150 * ML_PER_LITER ) ///< Maximum dialysate volume (in mL). #define USER_CONFIRM_CHANGE_TIMEOUT_MS ( 60 * MS_PER_SECOND ) ///< Require user to confirm UF volume change within this time. Index: firmware/App/Modes/ModeTreatmentParams.c =================================================================== diff -u -r6419179374edcd65da462de84e8aeaefb7e20320 -r4aa16058db700e071748f89f91e6eb58ed348ea3 --- firmware/App/Modes/ModeTreatmentParams.c (.../ModeTreatmentParams.c) (revision 6419179374edcd65da462de84e8aeaefb7e20320) +++ firmware/App/Modes/ModeTreatmentParams.c (.../ModeTreatmentParams.c) (revision 4aa16058db700e071748f89f91e6eb58ed348ea3) @@ -397,13 +397,33 @@ REQUEST_REJECT_REASON_CODE_T rejReason = REQUEST_REJECT_REASON_NONE; F32 uFVolumeL = uFVolumeMl / (F32)ML_PER_LITER; - // Validate given UF volume TODO - check dependencies too + // Validate given UF volume accepted = setTreatmentParameterF32( TREATMENT_PARAM_UF_VOLUME, uFVolumeL ); if ( FALSE == accepted ) { rejReason = REQUEST_REJECT_REASON_UF_VOLUME_OUT_OF_RANGE; } + else + { + U32 treatmentDuration = getTreatmentParameterU32( TREATMENT_PARAM_TREATMENT_DURATION ); + if ( treatmentDuration > 0 ) + { + F32 uFRate = uFVolumeMl / (F32)treatmentDuration; + + if ( uFRate > MAX_UF_RATE_ML_MIN ) + { + accepted = FALSE; + rejReason = REQUEST_REJECT_REASON_UF_RATE_OUT_OF_RANGE; + } + } + else + { + accepted = FALSE; + rejReason = REQUEST_REJECT_REASON_TREATMENT_TIME_LESS_THAN_MINIMUM; + } + } + // Respond to set treatment parameters request message uFVolumeL = getTreatmentParameterF32( TREATMENT_PARAM_UF_VOLUME ); uFVolumeMl = uFVolumeL * (F32)ML_PER_LITER; @@ -445,7 +465,19 @@ // Respond to set treatment parameters request message sendTreatmentParamsResponse( paramsAreInvalid, &rejReasons[0] ); + // Send initial adjustable ranges to UI so UF volume range will be known when UF volume prompted for later + if ( TRUE == validTreatParamsReceived ) + { + U32 setTxDuration = stagedParams[ TREATMENT_PARAM_TREATMENT_DURATION ].uInt; + sendTreatmentParamsRangesToUI( treatmentParameters[ TREATMENT_PARAM_TREATMENT_DURATION ].minimum.uInt, + treatmentParameters[ TREATMENT_PARAM_TREATMENT_DURATION ].maximum.uInt, + 0.0, + MIN( (F32)setTxDuration * MAX_UF_RATE_ML_MIN, (F32)MAX_UF_VOLUME_ML ), + treatmentParameters[ TREATMENT_PARAM_DIALYSATE_FLOW ].minimum.uInt, + treatmentParameters[ TREATMENT_PARAM_DIALYSATE_FLOW ].maximum.uInt ); + } + return !paramsAreInvalid; } Index: firmware/App/Modes/ModeTreatmentParams.h =================================================================== diff -u -r30f049651877229042e3f8700c8596e5b9a1e0f4 -r4aa16058db700e071748f89f91e6eb58ed348ea3 --- firmware/App/Modes/ModeTreatmentParams.h (.../ModeTreatmentParams.h) (revision 30f049651877229042e3f8700c8596e5b9a1e0f4) +++ firmware/App/Modes/ModeTreatmentParams.h (.../ModeTreatmentParams.h) (revision 4aa16058db700e071748f89f91e6eb58ed348ea3) @@ -32,7 +32,9 @@ // ********** public definitions ********** -#define MIN_PRESSURE_ALARM_LIMIT_DELTA_MMHG ( 30 ) ///< Minimum pressure alarm limit delta (in mmHg) +#define MIN_PRESSURE_ALARM_LIMIT_DELTA_MMHG ( 30 ) ///< Minimum pressure alarm limit delta (in mmHg) +#define MAX_UF_RATE_ML_MIN ( 2500.0 / (F32)MIN_PER_HOUR ) ///< Maximum ultrafiltration rate (in mL/min). +#define MAX_UF_VOLUME_ML ( 8 * ML_PER_LITER ) ///< Maximum ultrafiltration volume (in mL). /// Record structure for a treatment parameters payload. typedef struct