Index: firmware/App/Modes/TreatmentStop.c =================================================================== diff -u -r07a39ac5f935a84b2dbb93e3f3d3b3eaa8f37cc4 -r90d598a098a5454769a7eabb8ba2b4595afe47a6 --- firmware/App/Modes/TreatmentStop.c (.../TreatmentStop.c) (revision 07a39ac5f935a84b2dbb93e3f3d3b3eaa8f37cc4) +++ firmware/App/Modes/TreatmentStop.c (.../TreatmentStop.c) (revision 90d598a098a5454769a7eabb8ba2b4595afe47a6) @@ -56,7 +56,7 @@ static TREATMENT_STOP_STATE_T handleTreatmentStopAlarmsAndSignals( TREATMENT_STOP_STATE_T state ); static TREATMENT_STOP_STATE_T handleTreatmentStopDialysateRecircState( void ); static TREATMENT_STOP_STATE_T handleTreatmentStopBloodRecircState( void ); -static TREATMENT_STOP_STATE_T handleTreatmentRecoverBloodDetectState( void ); +static TREATMENT_STOP_STATE_T handleTreatmentStopRecoverBloodDetectState( void ); static void setupForRecoverBloodDetectState( void ); static void handleTreatmentStopBloodSittingTimer( void ); @@ -256,7 +256,7 @@ break; case TREATMENT_STOP_RECOVER_BLOOD_DETECT_STATE: - currentTxStopState = handleTreatmentRecoverBloodDetectState(); + currentTxStopState = handleTreatmentStopRecoverBloodDetectState(); break; default: @@ -287,49 +287,42 @@ TREATMENT_STOP_STATE_T result = state; BOOL bloodRecircBlocked = isBloodRecircBlocked(); BOOL dialysateRecircBlocked = isDialysateRecircBlocked(); - BOOL isBloodDetectAlarmActive = 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 ) ) ) + { + setupForRecoverBloodDetectState(); + result = TREATMENT_STOP_RECOVER_BLOOD_DETECT_STATE; + } // Both unblocked and not in recirculate both state - if ( ( TREATMENT_STOP_RECIRC_STATE != state ) && ( FALSE == dialysateRecircBlocked ) && ( FALSE == bloodRecircBlocked ) ) + else if ( ( TREATMENT_STOP_RECIRC_STATE != state ) && ( FALSE == dialysateRecircBlocked ) && ( FALSE == bloodRecircBlocked ) ) { setupForBloodRecirculationState(); setupForDialysateRecirculationState(); result = TREATMENT_STOP_RECIRC_STATE; } - // Both blocked and not in stopped state - if ( ( TREATMENT_STOP_NO_RECIRC_STATE != state ) && ( TRUE == dialysateRecircBlocked ) && ( TRUE == bloodRecircBlocked ) ) + 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 - if ( ( TREATMENT_STOP_RECIRC_BLOOD_ONLY_STATE != state ) && - ( TRUE == dialysateRecircBlocked ) && - ( FALSE == bloodRecircBlocked ) ) + 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 - if ( ( TREATMENT_STOP_RECIRC_DIALYSATE_ONLY_STATE != state ) && - ( TRUE == bloodRecircBlocked ) && - ( FALSE == dialysateRecircBlocked ) ) + else if ( ( TREATMENT_STOP_RECIRC_DIALYSATE_ONLY_STATE != state ) && ( TRUE == bloodRecircBlocked ) && + ( FALSE == dialysateRecircBlocked ) ) { setupForBloodRecirculationStopState(); result = TREATMENT_STOP_RECIRC_DIALYSATE_ONLY_STATE; } - if ( ( TREATMENT_STOP_RECOVER_BLOOD_DETECT_STATE != state ) && ( dialysateRecircBlocked != TRUE ) && - ( TRUE == isAlarmActive( ALARM_ID_HD_BLOOD_LEAK_RECOVERING_PLEASE_WAIT ) ) ) - { - setupForRecoverBloodDetectState(); - result = TREATMENT_STOP_RECOVER_BLOOD_DETECT_STATE; - } - return result; } @@ -407,7 +400,15 @@ return result; } -static TREATMENT_STOP_STATE_T handleTreatmentRecoverBloodDetectState( void ) +/*********************************************************************//** + * @brief + * The handleTreatmentStopRecoverBloodDetectState function handles the recovering + * for blood detect state in treatment stop. + * @details Inputs: none + * @details Outputs: none + * @return next treatment stop state + *************************************************************************/ +static TREATMENT_STOP_STATE_T handleTreatmentStopRecoverBloodDetectState( void ) { TREATMENT_STOP_STATE_T result = TREATMENT_STOP_RECOVER_BLOOD_DETECT_STATE; @@ -416,11 +417,17 @@ return result; } +/*********************************************************************//** + * @brief + * The setupForRecoverBloodDetectState function handles the setup for + * recovering blood detection state. + * @details Inputs: none + * @details Outputs: none + * @return none + *************************************************************************/ static void setupForRecoverBloodDetectState( void ) { doorClosedRequired( TRUE, TRUE ); - // Close dialyzer inlet and go to bypass mode - setValvePosition( VDI, VALVE_POSITION_B_OPEN ); setDialInPumpTargetFlowRate( DIALYSATE_FLOW_RATE_FOR_BLOOD_DETECT_RECOVERY_MLPM, MOTOR_DIR_FORWARD, PUMP_CONTROL_MODE_CLOSED_LOOP ); }