Index: firmware/App/Modes/ModeTreatment.c =================================================================== diff -u -r1507b3d6f58c87107d96a9da744423d06a70057c -r99031535f5bc95d882f982b8f4cc5b74b825cf6a --- firmware/App/Modes/ModeTreatment.c (.../ModeTreatment.c) (revision 1507b3d6f58c87107d96a9da744423d06a70057c) +++ firmware/App/Modes/ModeTreatment.c (.../ModeTreatment.c) (revision 99031535f5bc95d882f982b8f4cc5b74b825cf6a) @@ -46,11 +46,9 @@ // ********** private definitions ********** #define MAX_TREATMENT_TIME_MINUTES ( 8 * MIN_PER_HOUR ) ///< Maximum treatment time (in minutes). -#ifndef ALLOW_1_MIN_TREATMENT_DURATION + #define MIN_TREATMENT_TIME_MINUTES ( 1 * MIN_PER_HOUR ) ///< Minimum treatment time (in minutes). -#else -#define MIN_TREATMENT_TIME_MINUTES ( 1 ) ///< Minimum treatment time (in minutes). -#endif + #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. @@ -135,6 +133,7 @@ static void resetAlarmSignalFlags( void ); static void broadcastTreatmentSettingsRanges( void ); static void broadcastTreatmentPeriodicData(); +static U32 getTreatmentTimeInMinutes( void ); static TREATMENT_STATE_T handleTreatmentStartState( void ); static TREATMENT_STATE_T handleTreatmentBloodPrimeState( void ); static TREATMENT_STATE_T handleTreatmentDialysisState( void ); @@ -972,7 +971,7 @@ // Check if we are in an appropriate treatment state for settings adjustment if ( ( MODE_TREA == currMode ) && ( currentTreatmentState > TREATMENT_START_STATE ) && ( currentTreatmentState < TREATMENT_END_STATE ) && - ( CALC_ELAPSED_TREAT_TIME_IN_MIN() < treatmentTime ) && ( treatmentTime >= MIN_TREATMENT_TIME_MINUTES ) ) + ( CALC_ELAPSED_TREAT_TIME_IN_MIN() < treatmentTime ) && ( treatmentTime >= getTreatmentTimeInMinutes() ) ) { F32 uFVolume; U32 dialVolume = getTreatmentParameterU32( TREATMENT_PARAM_DIALYSATE_FLOW ) * treatmentTime; // In mL @@ -1016,7 +1015,7 @@ { rejectReason = REQUEST_REJECT_REASON_INVALID_TREATMENT_STATE; } - else if ( treatmentTime < MIN_TREATMENT_TIME_MINUTES ) + else if ( treatmentTime < getTreatmentTimeInMinutes() ) { rejectReason = REQUEST_REJECT_REASON_TREATMENT_TIME_LESS_THAN_MINIMUM; } @@ -1094,7 +1093,7 @@ pendingUFRateChange = 0.0; } // Verify treatment duration change would be valid (leave zero if not valid - UI will disable option) - if ( ( trtTime <= MAX_TREATMENT_TIME_MINUTES ) && ( trtTime >= MIN_TREATMENT_TIME_MINUTES ) && + if ( ( trtTime <= MAX_TREATMENT_TIME_MINUTES ) && ( trtTime >= getTreatmentTimeInMinutes() ) && ( dialVolume <= MAX_DIALYSATE_VOLUME_ML ) ) { result = TRUE; @@ -1446,7 +1445,7 @@ // Compute minimum treatment duration U32 presTime = ( presTreatmentTimeSecs / SEC_PER_MIN ); U32 elapseTime = CALC_ELAPSED_TREAT_TIME_IN_MIN(); - U32 minTime = MAX( (elapseTime + 2), MIN_TREATMENT_TIME_MINUTES ); // Treatment duration cannot be < 1 hour. add two minutes to cover rounding and ensure it is valid for next minute + U32 minTime = MAX( (elapseTime + 2), getTreatmentTimeInMinutes() ); // Treatment duration cannot be < 1 hour. add two minutes to cover rounding and ensure it is valid for next minute // Compute maximum treatment duration (from both UF and dialysate volume perspectives) U32 maxTimeRem = ( MAX_UF_VOLUME_ML - (U32)getUltrafiltrationReferenceVolume() ) / ( presUFRate > 0.0 ? (U32)presUFRate : 1 ); U32 maxTime1 = minTime + maxTimeRem; @@ -1526,7 +1525,31 @@ } } +/*********************************************************************//** + * @brief + * The getTreatmentTimeInMinutes function returns the treatment time in minutes. + * @details Inputs: none + * @details Outputs: none + * @return treatment time in minutes + *************************************************************************/ +static U32 getTreatmentTimeInMinutes( void ) +{ + // Assuming a 1 minute treatment + // NOTE: no # define for the 1 minute treatment time since this is only used for testing + U32 treatmentTime = 1; +#ifndef _RELEASE_ + // Check if the 1 minute treatment software configuration has not been enabled + if ( getSoftwareConfigStatus( SW_CONFIG_ENABLE_1_MIN_TREATMENT ) != SW_CONFIG_ENABLE_VALUE ) +#endif + { + treatmentTime = MIN_TREATMENT_TIME_MINUTES; + } + + return treatmentTime; +} + + /************************************************************************* * TEST SUPPORT FUNCTIONS *************************************************************************/