Index: firmware/App/Modes/ModeTreatment.c =================================================================== diff -u -r7665e7b142961a50c5e77c44877247366a374526 -rd6c75118f4e5792b40b744a0b29e44c78368a469 --- firmware/App/Modes/ModeTreatment.c (.../ModeTreatment.c) (revision 7665e7b142961a50c5e77c44877247366a374526) +++ firmware/App/Modes/ModeTreatment.c (.../ModeTreatment.c) (revision d6c75118f4e5792b40b744a0b29e44c78368a469) @@ -226,6 +226,21 @@ /*********************************************************************//** * @brief + * The getTreatmentTimeRemainingSecs function determines the number of seconds + * remaining in the treatment. + * @details Inputs: presTreatmentTimeSecs, treatmentTimeMS + * @details Outputs: none + * @return The number of seconds remaining in the treatment. + *************************************************************************/ +U32 getTreatmentTimeRemainingSecs( void ) +{ + U32 result = CALC_TREAT_TIME_REMAINING_IN_SECS(); + + return result; +} + +/*********************************************************************//** + * @brief * The getRinsebackCompleted function determines whether a rinseback has been * completed (indicating blood-side circuit should be primarily saline). * @details Inputs: rinsebackDone @@ -743,7 +758,7 @@ U32 dialVolume = presDialysateFlowRate * treatmentTime; // In mL // Always adjust UF volume to accommodate treatment time change (not UF rate) - uFVolume = ( (F32)( treatmentTime - CALC_ELAPSED_TREAT_TIME_IN_MIN() ) * presUFRate ) + getUltrafiltrationVolumeCollected(); + uFVolume = ( (F32)( treatmentTime - CALC_ELAPSED_TREAT_TIME_IN_MIN() ) * presUFRate ) + getUltrafiltrationReferenceVolume(); if ( ( treatmentTime <= MAX_TREATMENT_TIME_MINUTES ) && ( dialVolume <= MAX_DIALYSATE_VOLUME_ML ) && ( uFVolume <= MAX_UF_VOLUME_ML ) ) @@ -1156,7 +1171,7 @@ payload.rinsebackState = getCurrentRinsebackState(); payload.txStopState = getCurrentTreatmentRecircState(); payload.txEndState = getCurrentTreatmentEndState(); - payload.heparinState = HEPARIN_STATE_OFF; // TODO - get Heparin state when implemented + payload.heparinState = getHeparinState(); broadcastTreatmentState( payload ); treatmentStateBroadcastTimerCtr = 0; @@ -1182,12 +1197,12 @@ 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 // Compute maximum treatment duration (from both UF and dialysate volume perspectives) - U32 maxTimeRem = ( MAX_UF_VOLUME_ML - (U32)getUltrafiltrationVolumeCollected() ) / ( presUFRate > 0.0 ? (U32)presUFRate : 1 ); + U32 maxTimeRem = ( MAX_UF_VOLUME_ML - (U32)getUltrafiltrationReferenceVolume() ) / ( presUFRate > 0.0 ? (U32)presUFRate : 1 ); U32 maxTime1 = minTime + maxTimeRem; U32 maxTime2 = MAX_DIALYSATE_VOLUME_ML / presDialysateFlowRate; U32 maxTime = MAX( maxTime1, maxTime2 ); // Compute minimum UF volume - F32 minUFVol = getUltrafiltrationVolumeCollected() + presUFRate; + F32 minUFVol = getUltrafiltrationReferenceVolume() + presUFRate; // Compute maximum UF volume (considering from adjustment of UF rate and time perspectives) F32 maxUFVol1 = minUFVol + ( (F32)( presTime - elapseTime ) * MAX_UF_RATE_ML_MIN ); F32 maxUFVol2 = ( presUFRate > 0.0 ? minUFVol + ( (F32)( MAX_TREATMENT_TIME_MINUTES - elapseTime - 1 ) * presUFRate ) : minUFVol );