Index: firmware/App/Modes/TreatmentStop.c =================================================================== diff -u -r736cc5b56cc9c784ab1d8fc8687a73d190c35759 -rfb714597ad515d3774d69b94808f065788504724 --- firmware/App/Modes/TreatmentStop.c (.../TreatmentStop.c) (revision 736cc5b56cc9c784ab1d8fc8687a73d190c35759) +++ firmware/App/Modes/TreatmentStop.c (.../TreatmentStop.c) (revision fb714597ad515d3774d69b94808f065788504724) @@ -118,6 +118,9 @@ // Reset saline bolus state in case alarm interrupted one resetSalineBolus(); + // Reset blood leak zeroing params + resetBloodLeakZeroingVariables(); + // Enable venous bubble detection (in case returning from mid-treatment rinseback) setVenousBubbleDetectionEnabled( TRUE ); @@ -201,6 +204,7 @@ doorClosedRequired( TRUE, TRUE ); cmdStartDGTrimmerHeater(); setDialInPumpTargetFlowRate( DIALYSATE_FLOW_RATE_FOR_BLOOD_DETECT_RECOVERY_MLPM, MOTOR_DIR_FORWARD, PUMP_CONTROL_MODE_CLOSED_LOOP ); + requestBloodLeakZeroing( TRUE ); } /*********************************************************************//** @@ -302,41 +306,48 @@ TREATMENT_STOP_STATE_T result = state; BOOL bloodRecircBlocked = isBloodRecircBlocked(); BOOL dialysateRecircBlocked = isDialysateRecircBlocked(); + BOOL bldAlarmsStatus = ( ( TRUE == isAlarmActive( ALARM_ID_HD_BLOOD_LEAK_RECOVERING_PLEASE_WAIT ) ) && + ( FALSE == isAlarmActive( ALARM_ID_HD_BLOOD_LEAK_DETECTED ) ? TRUE : FALSE ) ); - if ( ( TREATMENT_STOP_RECOVER_BLOOD_DETECT_STATE != state ) && ( dialysateRecircBlocked != TRUE ) && - ( TRUE == isAlarmActive( ALARM_ID_HD_BLOOD_LEAK_RECOVERING_PLEASE_WAIT ) ) && ( FALSE == isAlarmActive( ALARM_ID_HD_BLOOD_LEAK_DETECTED ) ) ) + if ( TRUE == bldAlarmsStatus ) { - setupForRecoverBloodDetectState(); - result = TREATMENT_STOP_RECOVER_BLOOD_DETECT_STATE; + if ( ( TREATMENT_STOP_RECOVER_BLOOD_DETECT_STATE != state ) && ( dialysateRecircBlocked != TRUE ) ) + { + setupForRecoverBloodDetectState(); + result = TREATMENT_STOP_RECOVER_BLOOD_DETECT_STATE; + } } - // Both unblocked and not in recirculate both state - else if ( ( TREATMENT_STOP_RECIRC_STATE != state ) && ( FALSE == dialysateRecircBlocked ) && ( FALSE == bloodRecircBlocked ) ) + else { - setupForBloodRecirculationState(); - setupForDialysateRecirculationState(); - result = TREATMENT_STOP_RECIRC_STATE; + // Both unblocked and not in recirculate both state + if ( ( TREATMENT_STOP_RECIRC_STATE != state ) && ( FALSE == dialysateRecircBlocked ) && ( FALSE == bloodRecircBlocked ) ) + { + setupForBloodRecirculationState(); + setupForDialysateRecirculationState(); + result = TREATMENT_STOP_RECIRC_STATE; + } + // Both blocked and not in stopped state + else if ( ( TREATMENT_STOP_NO_RECIRC_STATE != state ) && ( TRUE == dialysateRecircBlocked ) && ( TRUE == bloodRecircBlocked ) ) + { + setupForBloodRecirculationStopState(); + setupForDialysateRecirculationStopState(); + result = TREATMENT_STOP_NO_RECIRC_STATE; + } + // Dialysate recirculation blocked and not in blood recirc state + else if ( ( TREATMENT_STOP_RECIRC_BLOOD_ONLY_STATE != state ) && ( TRUE == dialysateRecircBlocked ) && + ( FALSE == bloodRecircBlocked ) ) + { + setupForDialysateRecirculationStopState(); + result = TREATMENT_STOP_RECIRC_BLOOD_ONLY_STATE; + } + // Blood recirculation blocked and not in dialysate recirc state + else if ( ( TREATMENT_STOP_RECIRC_DIALYSATE_ONLY_STATE != state ) && ( TRUE == bloodRecircBlocked ) && + ( FALSE == dialysateRecircBlocked ) ) + { + setupForBloodRecirculationStopState(); + result = TREATMENT_STOP_RECIRC_DIALYSATE_ONLY_STATE; + } } - // Both blocked and not in stopped state - else if ( ( TREATMENT_STOP_NO_RECIRC_STATE != state ) && ( TRUE == dialysateRecircBlocked ) && ( TRUE == bloodRecircBlocked ) ) - { - setupForBloodRecirculationStopState(); - setupForDialysateRecirculationStopState(); - result = TREATMENT_STOP_NO_RECIRC_STATE; - } - // Dialysate recirculation blocked and not in blood recirc state - else if ( ( TREATMENT_STOP_RECIRC_BLOOD_ONLY_STATE != state ) && ( TRUE == dialysateRecircBlocked ) && - ( FALSE == bloodRecircBlocked ) ) - { - setupForDialysateRecirculationStopState(); - result = TREATMENT_STOP_RECIRC_BLOOD_ONLY_STATE; - } - // Blood recirculation blocked and not in dialysate recirc state - else if ( ( TREATMENT_STOP_RECIRC_DIALYSATE_ONLY_STATE != state ) && ( TRUE == bloodRecircBlocked ) && - ( FALSE == dialysateRecircBlocked ) ) - { - setupForBloodRecirculationStopState(); - result = TREATMENT_STOP_RECIRC_DIALYSATE_ONLY_STATE; - } return result; } @@ -427,6 +438,8 @@ { TREATMENT_STOP_STATE_T result = TREATMENT_STOP_RECOVER_BLOOD_DETECT_STATE; + execBloodLeakZeroing(); + // Keep reseting the blood sitting timer handleTreatmentStopBloodSittingTimer(); result = handleTreatmentStopAlarmsAndSignals( result );