Index: firmware/App/Modes/ModeTreatment.c =================================================================== diff -u -r4977b2f2cee48b1dbc1bc6a70fb818404922c917 -r2f4f66fcceb986cc592693b08f1b57767cb1c515 --- firmware/App/Modes/ModeTreatment.c (.../ModeTreatment.c) (revision 4977b2f2cee48b1dbc1bc6a70fb818404922c917) +++ firmware/App/Modes/ModeTreatment.c (.../ModeTreatment.c) (revision 2f4f66fcceb986cc592693b08f1b57767cb1c515) @@ -7,8 +7,8 @@ * * @file ModeTreatment.c * -* @author (last) Dara Navaei -* @date (last) 11-Nov-2022 +* @author (last) Sean Nash +* @date (last) 05-Feb-2023 * * @author (original) Dara Navaei * @date (original) 05-Nov-2019 @@ -133,7 +133,7 @@ static void broadcastTreatmentSettingsRanges( void ); static void broadcastTreatmentPeriodicData(); -static U32 getTreatmentTimeInMinutes( void ); +static U32 getMinTreatmentTimeInMinutes( void ); static TREATMENT_STATE_T handleTreatmentStartState( void ); static TREATMENT_STATE_T handleTreatmentBloodPrimeState( void ); static TREATMENT_STATE_T handleTreatmentDialysisState( void ); @@ -589,16 +589,19 @@ { BOOL stop = isStopButtonPressed(); + // Trigger user stop alarm at any time in treatment mode when user presses stop button if ( TRUE == stop ) { activateAlarmNoData( ALARM_ID_TREATMENT_STOPPED_BY_USER ); } + // Check dialysate temperature during treatment mode (except end state where treatment is over, dialyzer is bypassed and temp is no longer an issue) if ( currentTreatmentState != TREATMENT_END_STATE ) { checkDialysateTemperature(); } + // Record treatment start time if not done yet if ( FALSE == hasTreatmentStartTimeBeenWrittenToNV ) { // Started the treatment set the start time in epoch @@ -962,7 +965,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 >= getTreatmentTimeInMinutes() ) ) + ( CALC_ELAPSED_TREAT_TIME_IN_MIN() < treatmentTime ) && ( treatmentTime >= getMinTreatmentTimeInMinutes() ) ) { F32 uFVolume; U32 dialVolume = getTreatmentParameterU32( TREATMENT_PARAM_DIALYSATE_FLOW ) * treatmentTime; // In mL @@ -1008,7 +1011,7 @@ { rejectReason = REQUEST_REJECT_REASON_INVALID_TREATMENT_STATE; } - else if ( treatmentTime < getTreatmentTimeInMinutes() ) + else if ( treatmentTime < getMinTreatmentTimeInMinutes() ) { rejectReason = REQUEST_REJECT_REASON_TREATMENT_TIME_LESS_THAN_MINIMUM; } @@ -1086,7 +1089,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 >= getTreatmentTimeInMinutes() ) && + if ( ( trtTime <= MAX_TREATMENT_TIME_MINUTES ) && ( trtTime >= getMinTreatmentTimeInMinutes() ) && ( dialVolume <= MAX_DIALYSATE_VOLUME_ML ) ) { result = TRUE; @@ -1443,7 +1446,7 @@ // Compute minimum treatment duration U32 presTime = ( presTreatmentTimeSecs / SEC_PER_MIN ); U32 elapseTime = CALC_ELAPSED_TREAT_TIME_IN_MIN(); - 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 + U32 minTime = MAX( (elapseTime + 2), getMinTreatmentTimeInMinutes() ); // 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; @@ -1525,24 +1528,23 @@ /*********************************************************************//** * @brief - * The getTreatmentTimeInMinutes function returns the treatment time in minutes. - * @details Inputs: none + * The getMinTreatmentTimeInMinutes function returns the minimum treatment + * time (in minutes) that the user could set treatment duration to. + * @details Inputs: MIN_TREATMENT_TIME_MINUTES * @details Outputs: none - * @return treatment time in minutes + * @return minimum treatment time in minutes *************************************************************************/ -static U32 getTreatmentTimeInMinutes( void ) +static U32 getMinTreatmentTimeInMinutes( 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; + U32 treatmentTime = MIN_TREATMENT_TIME_MINUTES; #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 + if ( SW_CONFIG_ENABLE_VALUE == getSoftwareConfigStatus( SW_CONFIG_ENABLE_1_MIN_TREATMENT ) ) { - treatmentTime = MIN_TREATMENT_TIME_MINUTES; + treatmentTime = 1; } +#endif return treatmentTime; }