Index: firmware/App/Modes/TreatmentStop.c =================================================================== diff -u -r7dc4bb045389ac95e6658602f2659f6071542361 -r3833c8a7a90288a6010a625a884048c775c598d3 --- firmware/App/Modes/TreatmentStop.c (.../TreatmentStop.c) (revision 7dc4bb045389ac95e6658602f2659f6071542361) +++ firmware/App/Modes/TreatmentStop.c (.../TreatmentStop.c) (revision 3833c8a7a90288a6010a625a884048c775c598d3) @@ -8,7 +8,7 @@ * @file TreatmentStop.c * * @author (last) Sean Nash -* @date (last) 02-Feb-2023 +* @date (last) 21-Jun-2023 * * @author (original) Sean * @date (original) 15-Jan-2020 @@ -85,7 +85,8 @@ void transitionToTreatmentStop( void ) { initTreatmentStop(); - + setCurrentSubState( (U32)currentTxStopState ); + setCurrent4thLevelState( NO_SUB_STATE ); // Set user alarm recovery actions allowed in this sub-mode setAlarmUserActionEnabled( ALARM_USER_ACTION_RESUME, TRUE ); @@ -108,9 +109,14 @@ setupForDialysateRecirculationState(); + signalUserRateChange(); // so pressure limits re-stabilize + // Reset saline bolus state in case alarm interrupted one resetSalineBolus(); + // Enable venous bubble detection (in case returning from mid-treatment rinseback) + setVenousBubbleDetectionEnabled( TRUE ); + // Should always have an alarm active in treatment stop sub-mode so that user can take action if ( FALSE == isAnyAlarmActive() ) { @@ -228,7 +234,6 @@ { TREATMENT_STOP_STATE_T priorSubState = currentTxStopState; - // Execute treatment stop sub-mode state machine switch ( currentTxStopState ) { case TREATMENT_STOP_RECIRC_STATE: @@ -254,6 +259,7 @@ if ( priorSubState != currentTxStopState ) { + setCurrentSubState( (U32)currentTxStopState ); SEND_EVENT_WITH_2_U32_DATA( HD_EVENT_SUB_STATE_CHANGE, priorSubState, currentTxStopState ); } // Broadcast treatment stop status @@ -399,15 +405,19 @@ // Ensure we do not sit in stopped state for too long (if blood in line) if ( getRinsebackCompleted() != TRUE ) { - if ( ++bloodSittingTimerCtr > WARN_TIME_BLOOD_SITTING ) + bloodSittingTimerCtr++; + if ( FALSE == doesAlarmStatusIndicateEndTxOnly() ) // Alarms appropriate only if we are not already at an alarm stop, end Tx only { - activateAlarmNoData( ALARM_ID_HD_BLOOD_SITTING_WARNING ); + if ( bloodSittingTimerCtr > WARN_TIME_BLOOD_SITTING ) + { + activateAlarmNoData( ALARM_ID_HD_BLOOD_SITTING_WARNING ); + } + if ( bloodSittingTimerCtr > MAX_TIME_BLOOD_SITTING ) + { + // Activate the alarm + activateAlarmNoData( ALARM_ID_HD_TREATMENT_STOPPED_NO_RINSEBACK ); + } } - if ( bloodSittingTimerCtr > MAX_TIME_BLOOD_SITTING ) - { - // Activate the alarm - activateAlarmNoData( ALARM_ID_HD_TREATMENT_STOPPED_NO_RINSEBACK ); - } } else { @@ -446,7 +456,9 @@ data.timeout = 0; data.countdown = 0; - if ( getRinsebackCompleted() != TRUE ) + if ( ( getRinsebackCompleted() != TRUE ) && + ( isAlarmActive( ALARM_ID_HD_TREATMENT_RINSEBACK_TIMEOUT_ALARM ) != TRUE ) && + ( isAlarmActive( ALARM_ID_HD_TREATMENT_STOPPED_NO_RINSEBACK ) != TRUE ) ) { if ( bloodSittingTimerCtr > 0 ) {