Index: firmware/App/Controllers/BloodLeak.c =================================================================== diff -u -rf14422a7576bf3c44d8fa23d8a14b6cab1922553 -rc7d760a7ff81fa24ea70da20446edd4d90a3c50d --- firmware/App/Controllers/BloodLeak.c (.../BloodLeak.c) (revision f14422a7576bf3c44d8fa23d8a14b6cab1922553) +++ firmware/App/Controllers/BloodLeak.c (.../BloodLeak.c) (revision c7d760a7ff81fa24ea70da20446edd4d90a3c50d) @@ -207,6 +207,7 @@ static U16 getBloodLeakRxBytesAvailable( void ); static void resetEmbModeCmdRqstCount( U08 cmd ); static BLOOD_LEAK_STATUS_T getFPGABloodDetectProcessedStatus( void ); +static BOOL isDialysateLineInBypass( void ); /*********************************************************************//** * @brief @@ -674,40 +675,42 @@ bloodLeakPersistenceCtr = 0; } - // Check status reading and act upon - // Only check the blood detection in treatment mode and service mode for testing in manufacturing - if ( ( BLOOD_LEAK_DETECTED == getBloodLeakStatus() ) && ( ( MODE_TREA == getCurrentOperationMode() ) || ( MODE_SERV == getCurrentOperationMode() ) ) ) + switch ( getCurrentOperationMode() ) { - if ( ++bloodLeakPersistenceCtr > BLOOD_LEAK_PERSISTENCE ) - { - bloodLeakPersistenceCtr = BLOOD_LEAK_PERSISTENCE; -#ifndef _RELEASE_ - if ( getSoftwareConfigStatus( SW_CONFIG_DISABLE_BLOOD_LEAK_ALARM ) != SW_CONFIG_ENABLE_VALUE ) -#endif + case MODE_TREA: + case MODE_SERV: + if ( FALSE == isDialysateLineInBypass() ) { - activateAlarmNoData( ALARM_ID_HD_BLOOD_LEAK_DETECTED ); - activateAlarmNoData( ALARM_ID_HD_BLOOD_LEAK_RECOVERING_PLEASE_WAIT ); - bloodLeakRecoveryStartTimeMS = getMSTimerCount(); - state = BLOOD_LEAK_RECOVER_BLOOD_DETECT_STATE; - } - } - } - else // Blood leak not detected - { - if ( bloodLeakPersistenceCtr > 0 ) - { - bloodLeakPersistenceCtr--; - } - else - { + if ( BLOOD_LEAK_DETECTED == getBloodLeakStatus() ) + { + if ( ++bloodLeakPersistenceCtr > BLOOD_LEAK_PERSISTENCE ) + { + bloodLeakPersistenceCtr = BLOOD_LEAK_PERSISTENCE; #ifndef _RELEASE_ - if ( getSoftwareConfigStatus( SW_CONFIG_DISABLE_BLOOD_LEAK_ALARM ) != SW_CONFIG_ENABLE_VALUE ) + if ( getSoftwareConfigStatus( SW_CONFIG_DISABLE_BLOOD_LEAK_ALARM ) != SW_CONFIG_ENABLE_VALUE ) #endif - { - clearAlarmCondition( ALARM_ID_HD_BLOOD_LEAK_DETECTED ); - clearAlarmCondition( ALARM_ID_HD_BLOOD_LEAK_RECOVERING_PLEASE_WAIT ); + { + activateAlarmNoData( ALARM_ID_HD_BLOOD_LEAK_DETECTED ); + activateAlarmNoData( ALARM_ID_HD_BLOOD_LEAK_RECOVERING_PLEASE_WAIT ); + bloodLeakRecoveryStartTimeMS = getMSTimerCount(); + state = BLOOD_LEAK_RECOVER_BLOOD_DETECT_STATE; + } + } + } + else if ( bloodLeakPersistenceCtr > 0 ) + { + bloodLeakPersistenceCtr--; + } + else + { + clearAlarmCondition( ALARM_ID_HD_BLOOD_LEAK_DETECTED ); + clearAlarmCondition( ALARM_ID_HD_BLOOD_LEAK_RECOVERING_PLEASE_WAIT ); + } } - } + + default: + // Do nothing. Do not check for blood in other modes. + break; } if ( TRUE == bloodLeakExitNormalRequested ) @@ -1590,7 +1593,27 @@ return ( BLOOD_LEAK_STATUS_BIT_LOW == getFPGABloodLeakStatus() ? BLOOD_LEAK_NOT_DETECTED : BLOOD_LEAK_DETECTED ); } +/*********************************************************************//** + * @brief + * The isDialysateLineInBypass function checks and returns whether the + * dialysate line is in bypass mode or not. + * @details Inputs: none + * @details Outputs: none + * @return TRUE if the dialysate line is in bypass otherwise, FALSE + *************************************************************************/ +static BOOL isDialysateLineInBypass( void ) +{ + BOOL status = TRUE; + status &= ( VALVE_POSITION_C_CLOSE == getValvePosition( VDI ) ? TRUE : FALSE ); + status &= ( VALVE_POSITION_C_CLOSE == getValvePosition( VDO ) ? TRUE : FALSE ); + status &= ( getMeasuredDialInPumpSpeed() <= NEARLY_ZERO ? TRUE : FALSE ); + status &= ( getMeasuredDialOutPumpSpeed() <= NEARLY_ZERO ? TRUE : FALSE ); + + return status; +} + + /************************************************************************* * TEST SUPPORT FUNCTIONS *************************************************************************/