Index: firmware/App/Modes/Dialysis.c =================================================================== diff -u -r736cc5b56cc9c784ab1d8fc8687a73d190c35759 -r14d1cffaeeebd5729f5c05c21b9eb1ac414b4750 --- firmware/App/Modes/Dialysis.c (.../Dialysis.c) (revision 736cc5b56cc9c784ab1d8fc8687a73d190c35759) +++ firmware/App/Modes/Dialysis.c (.../Dialysis.c) (revision 14d1cffaeeebd5729f5c05c21b9eb1ac414b4750) @@ -19,6 +19,7 @@ #include "AirTrap.h" #include "BloodFlow.h" +#include "BloodLeak.h" #include "Buttons.h" #include "Dialysis.h" #include "DialInFlow.h" @@ -95,6 +96,7 @@ static DIALYSIS_STATE_T handleDialysisUltrafiltrationState( void ); static DIALYSIS_STATE_T handleDialysisSalineBolusState( void ); +static DIALYSIS_STATE_T handleDialysisBloodLeakZeroingState( void ); static UF_STATE_T handleUFPausedState( DIALYSIS_STATE_T *dialysisState ); static UF_STATE_T handleUFRunningState( DIALYSIS_STATE_T *dialysisState ); @@ -659,6 +661,12 @@ // Check ultrafiltration control during dialysis (even when ultrafiltration is paused). checkUFControl(); + if ( ( TRUE == isBloodLeakZeroingNeeded() ) && ( DIALYSIS_UF_STATE == currentDialysisState ) ) + { + requestBloodLeakZeroing(); + currentDialysisState = DIALYSIS_BLOOD_LEAK_ZEROING_STATE; + } + // Dialysis state machine switch ( currentDialysisState ) { @@ -670,6 +678,9 @@ currentDialysisState = handleDialysisSalineBolusState(); break; + case DIALYSIS_BLOOD_LEAK_ZEROING_STATE: + currentDialysisState = handleDialysisBloodLeakZeroingState(); + default: SET_ALARM_WITH_2_U32_DATA( ALARM_ID_HD_SOFTWARE_FAULT, SW_FAULT_ID_DIALYSIS_INVALID_STATE, currentDialysisState ) break; @@ -785,6 +796,28 @@ /*********************************************************************//** * @brief + * The handleDialysisBloodLeakZeroingState function handles the blood leak + * zeroing sub state of the state machine. + * @details Inputs: none + * @details Outputs: none + * @return next Dialysis state. + *************************************************************************/ +static DIALYSIS_STATE_T handleDialysisBloodLeakZeroingState( void ) +{ + DIALYSIS_STATE_T result = DIALYSIS_BLOOD_LEAK_ZEROING_STATE; + + execBloodLeakZeroing(); + + if ( TRUE == isBloodLeakZeroingComplete() ) + { + result = DIALYSIS_UF_STATE; + } + + return result; +} + +/*********************************************************************//** + * @brief * The handleUFPausedState function handles the Paused state of the * ultrafiltration state machine. * @details Inputs: salineBolusStartRequested