Index: firmware/App/Modes/Rinseback.c =================================================================== diff -u -rf66a94fdd645d2146e828fd760960849d1ac05c6 -rbd2a2be9a1eb2e69e61739b0e734475426ff4cfe --- firmware/App/Modes/Rinseback.c (.../Rinseback.c) (revision f66a94fdd645d2146e828fd760960849d1ac05c6) +++ firmware/App/Modes/Rinseback.c (.../Rinseback.c) (revision bd2a2be9a1eb2e69e61739b0e734475426ff4cfe) @@ -50,8 +50,8 @@ /// Interval at which rinseback progress is to be published to UI. #define RINSEBACK_DATA_PUBLISH_INTERVAL ( MS_PER_SECOND / TASK_GENERAL_INTERVAL ) -/// Maximum time allowed for rinseback operation (including additional rinseback volumes). -#define MAX_RINSEBACK_TIME ( 7 * SEC_PER_MIN * ( MS_PER_SECOND / TASK_GENERAL_INTERVAL ) ) +/// Maximum time allowed for rinseback operation until full volume is delivered. Timer is reset whenever BP is running. +#define MAX_RINSEBACK_TIME ( 5 * SEC_PER_MIN * ( MS_PER_SECOND / TASK_GENERAL_INTERVAL ) ) /// Maximum time allowed for each additional rinseback volume delivery. #define MAX_RINSEBACK_ADDITIONAL_TIME ( 15 * MS_PER_SECOND / TASK_GENERAL_INTERVAL ) /// Multiplier to convert flow (mL/min) into volume (mL) for period of general task interval. @@ -340,7 +340,10 @@ U32 bldPumpMotorCount = getBloodPumpMotorCount(); U32 bldPumpMotorDelta = u32DiffWithWrap( rinsebackLastMotorCount, bldPumpMotorCount ); - // update rinseback volume delivered so far + // Reset rinseback t/o + rinsebackTimerCtr = 0; + + // Update rinseback volume delivered so far cumulativeRinsebackVolume_mL += ( getMeasuredBloodFlowRate() * RINSEBACK_FLOW_INTEGRATOR ); // update independent calculated safety volume delivered so far rinsebackMotorCount += bldPumpMotorDelta; @@ -360,7 +363,7 @@ setRinsebackIsCompleted( TRUE ); setupForRinsebackStopOrPause(); result = RINSEBACK_STOP_STATE; - // check for under-delivery + // Check for under-delivery if ( rinsebackVolumeDelivered_Safety < MIN_RINSEBACK_SAFETY_VOLUME_ML ) { SET_ALARM_WITH_2_F32_DATA( ALARM_ID_RINSEBACK_VOLUME_CHECK_FAILURE, TARGET_RINSEBACK_VOLUME_ML, rinsebackVolumeDelivered_Safety ); @@ -373,12 +376,6 @@ setupForRinsebackStopOrPause(); result = RINSEBACK_PAUSED_STATE; } - // Has rinseback operation exceeded max time? - else if ( rinsebackTimerCtr > MAX_RINSEBACK_TIME ) - { - signalGoToTreatmentStopped(); - activateAlarmNoData( ALARM_ID_TREATMENT_RINSEBACK_TIMEOUT_ALARM ); - } // Has user or alarm requested rinseback pause? else if ( ( TRUE == pauseRinsebackRequested ) || ( TRUE == rinsebackStopRequested ) ) { @@ -474,6 +471,12 @@ { signalRinsebackToRecirc(); } + // Has rinseback operation exceeded max time w/o delivering full volume? + if ( ( rinsebackTimerCtr > MAX_RINSEBACK_TIME ) && ( cumulativeRinsebackVolume_mL < TARGET_RINSEBACK_VOLUME_ML ) ) + { + signalGoToTreatmentStopped(); + activateAlarmNoData( ALARM_ID_TREATMENT_RINSEBACK_TIMEOUT_ALARM ); + } else if ( TRUE == additionalRinsebackRequested ) { additionalRinsebackRequested = FALSE; @@ -512,6 +515,9 @@ RINSEBACK_STATE_T result = RINSEBACK_RUN_ADDITIONAL_STATE; F32 rinsebackVolumeSinceLast = ( getMeasuredBloodFlowRate() * RINSEBACK_FLOW_INTEGRATOR ); + // Reset rinseback t/o + rinsebackTimerCtr = 0; + // update additional rinseback volume delivered so far additionalRinsebackVolume_mL += rinsebackVolumeSinceLast; cumulativeRinsebackVolume_mL += rinsebackVolumeSinceLast; @@ -938,7 +944,7 @@ U32 countdown = ( rinsebackTimerCtr >= MAX_RINSEBACK_TIME ? 0 : ( MAX_RINSEBACK_TIME - rinsebackTimerCtr ) / TASK_GENERAL_INTERVAL ); rinsebackPublishTimerCtr = 0; - // If we have completed rinseback, timeout is no longer in force + // If we have completed rinseback, timeout is no longer in force - indicate by zeroing timeout if ( ( rinsebackState > RINSEBACK_PAUSED_STATE ) && ( cumulativeRinsebackVolume_mL >= TARGET_RINSEBACK_VOLUME_ML ) ) { timeout = 0;