Index: firmware/App/Modes/Rinseback.c =================================================================== diff -u -r2637b1aada1cd724952d1b80de139804bb7b675b -r1c628bfd5d6414b74b8cbd083f66839888a8236b --- firmware/App/Modes/Rinseback.c (.../Rinseback.c) (revision 2637b1aada1cd724952d1b80de139804bb7b675b) +++ firmware/App/Modes/Rinseback.c (.../Rinseback.c) (revision 1c628bfd5d6414b74b8cbd083f66839888a8236b) @@ -55,6 +55,8 @@ #define RINSEBACK_DATA_PUBLISH_INTERVAL ( MS_PER_SECOND / TASK_GENERAL_INTERVAL ) /// Maximum time allowed for rinseback operation until full volume is delivered. Timer is reset whenever BP is running. static const U32 MAX_RINSEBACK_TIME = ( 5 * SEC_PER_MIN * ( MS_PER_SECOND / TASK_GENERAL_INTERVAL ) ); +/// Maximum time allowed after rinseback operation completed. Timer is reset whenever BP is running (additional). +static const U32 MAX_RINSEBACK_DONE_TIME = ( 15 * SEC_PER_MIN * ( MS_PER_SECOND / TASK_GENERAL_INTERVAL ) ); /// Maximum time allowed for each additional rinseback volume delivery. static const U32 MAX_RINSEBACK_ADDITIONAL_TIME = ( 20 * MS_PER_SECOND / TASK_GENERAL_INTERVAL ); /// Multiplier to convert flow (mL/min) into volume (mL) for period of general task interval. @@ -513,17 +515,22 @@ { RINSEBACK_STATE_T result = RINSEBACK_STOP_STATE; - // If user confirms ready to start re-circulate sub-mode, go there - if ( TRUE == recircRequested ) + // Have we been in this stopped state for too long w/o having delivered full blood volume back to patient? + if ( ( rinsebackTimerCtr > MAX_RINSEBACK_TIME ) && ( getRinsebackVolume() < TARGET_RINSEBACK_VOLUME_ML ) ) { - signalRinsebackToRecirc(); + signalGoToTreatmentStopped(); + activateAlarmNoData( ALARM_ID_TREATMENT_RINSEBACK_TIMEOUT_ALARM ); } - // Has rinseback operation exceeded max time w/o delivering full volume? - if ( ( rinsebackTimerCtr > MAX_RINSEBACK_TIME ) && ( getRinsebackVolume() < TARGET_RINSEBACK_VOLUME_ML ) ) + // Have we been in this stopped state for too long despite having delivered full blood volume back to patient? + else if ( ( rinsebackTimerCtr > MAX_RINSEBACK_DONE_TIME ) && ( getRinsebackVolume() >= TARGET_RINSEBACK_VOLUME_ML ) ) { signalGoToTreatmentStopped(); activateAlarmNoData( ALARM_ID_TREATMENT_RINSEBACK_TIMEOUT_ALARM ); } + else if ( TRUE == recircRequested ) + { + signalRinsebackToRecirc(); + } else if ( TRUE == additionalRinsebackRequested ) { additionalRinsebackRequested = FALSE; @@ -716,6 +723,7 @@ { result = TRUE; incrRinsebackFlowRateRequested = TRUE; + rinsebackPublishTimerCtr = getPublishRinsebackInterval(); } else { @@ -750,6 +758,7 @@ { result = TRUE; decrRinsebackFlowRateRequested = TRUE; + rinsebackPublishTimerCtr = getPublishRinsebackInterval(); } else {