Index: firmware/App/Modes/ModeTreatment.c =================================================================== diff -u -r4b277cb265d877f6632e9d33dc91ae35b55b2d87 -rab30d3ef5af247823a9a954ff71526699139caa7 --- firmware/App/Modes/ModeTreatment.c (.../ModeTreatment.c) (revision 4b277cb265d877f6632e9d33dc91ae35b55b2d87) +++ firmware/App/Modes/ModeTreatment.c (.../ModeTreatment.c) (revision ab30d3ef5af247823a9a954ff71526699139caa7) @@ -58,7 +58,9 @@ #define USER_CONFIRM_CHANGE_TIMEOUT_MS ( 60 * MS_PER_SECOND ) ///< Require user to confirm UF volume change within this time. #define PREVENT_UF_VOL_CHANGE_IF_NEARLY_DONE_SEC ( 10 * SEC_PER_MIN ) ///< Prevent UF volume change if treatment within this much time from end of treatment (in seconds). +#define UF_RATE_CONFIRM_MSG_TIMEOUT_MS ( 30 * MS_PER_SECOND ) ///< UF rate confirm message timeout in milliseconds. + /// Interval (ms/task time) at which the treatment time data is published on the CAN bus. #define TREATMENT_TIME_DATA_PUB_INTERVAL ( MS_PER_SECOND / TASK_GENERAL_INTERVAL ) /// Interval (ms/task time) at which the treatment state data is published on the CAN bus. @@ -82,6 +84,7 @@ U32 requestedTxDurationMins; ///< Requested treatment duration from the user in minutes. F32 newUFRateMLPM; ///< New calculated UF rate in mL/Min. BOOL isUFRateConfInProgress; ///< Boolean flag to indicate whether a new UF rate confirmation has been requested. + U32 rqstStartTimeStamp; ///< Request start time stamp. } TREATMENT_DURATION_RQST_T; // ********** private data ********** @@ -1078,9 +1081,16 @@ F32 newUFDiffML = ( ( presMaxUFVolumeML - getTotalMeasuredUFVolumeInMl() ) < 0.0F ? 0.0F : ( presMaxUFVolumeML - getTotalMeasuredUFVolumeInMl() ) ); // New UF rate is how much UF is left to be done / remaining treatment time - F32 newUFRateMLPM = ( newUFDiffML ) / (F32)( treatmentTime - CALC_ELAPSED_TREAT_TIME_IN_MIN() ); + F32 newTxTimeS = (F32)treatmentTime * (F32)SEC_PER_MIN; + F32 elapsedTxTimeS = (F32)treatmentTimeMS / (F32)MS_PER_SECOND; + F32 timeDiffMin = (newTxTimeS - elapsedTxTimeS) / (F32)SEC_PER_MIN; + F32 newUFRateMLPM = newUFDiffML / timeDiffMin; U32 dialVolume = getTreatmentParameterU32( TREATMENT_PARAM_DIALYSATE_FLOW ) * treatmentTime; // In mL + SEND_EVENT_WITH_2_F32_DATA(HD_EVENT_TEMP_1, presMaxUFVolumeML, getTotalMeasuredUFVolumeInMl()) + SEND_EVENT_WITH_2_F32_DATA(HD_EVENT_TEMP_2, newUFDiffML, newUFRateMLPM) + SEND_EVENT_WITH_2_U32_DATA(HD_EVENT_TEMP_3, elapsedTxTimeS, timeDiffMin) + // The minimum treatment time is either in the range of the institutional record or the 1-minute treatment config has been requested which is an exception BOOL isMinTxTimeValid = ( ( treatmentTime >= getU32TreatmentParamLowerRangeLimit( TREATMENT_PARAM_TREATMENT_DURATION ) ) || ( TRUE == getTestConfigStatus( TEST_CONFIG_ENABLE_ONE_MINUTE_TREATMENT ) ) ? TRUE : FALSE ); @@ -1104,6 +1114,7 @@ txDurationRequest.requestedTxDurationMins = treatmentTime; txDurationRequest.newUFRateMLPM = newUFRateMLPM; txDurationRequest.isUFRateConfInProgress = TRUE; + txDurationRequest.rqstStartTimeStamp = getMSTimerCount(); genericConfRequest.requestID = (U32)GENERIC_CONFIRM_ID_UF_RATE_CHANGE_IN_TX_DURATION_CHANGE; genericConfRequest.requestType = (U32)GENERIC_CONFIRM_CMD_REQUEST_OPEN; @@ -1117,7 +1128,7 @@ } else { - // Update the treatment time since there is not UF rate chnage that needs approval + // Update the treatment time since there is not UF rate change that needs approval presTreatmentTimeSecs = treatmentTime * SEC_PER_MIN; } } @@ -1301,6 +1312,8 @@ presMaxUFVolumeML = pendingUFVolumeChange; result = setTreatmentParameterF32( TREATMENT_PARAM_UF_VOLUME, ( presMaxUFVolumeML / (F32)ML_PER_LITER ) ); + SEND_EVENT_WITH_2_F32_DATA(HD_EVENT_TEMP_4, presMaxUFVolumeML, pendingUFVolumeChange) + // User should only allow UF rate adjustment to achieve UF volume change if ( UF_ADJ_UF_RATE == adjustment ) { @@ -1608,6 +1621,11 @@ txDurationRequest.isUFRateConfInProgress = FALSE; } } + + if ( TRUE == didTimeout( txDurationRequest.rqstStartTimeStamp, UF_RATE_CONFIRM_MSG_TIMEOUT_MS ) ) + { + setConfirmationRequestStatus( GENERIC_CONFIRM_ID_UF_RATE_CHANGE_IN_TX_DURATION_CHANGE, CONFIRMATION_REQUEST_STATUS_TIMEOUT ); + } } /*********************************************************************//**