Index: firmware/App/Controllers/Bubble.c =================================================================== diff -u -rba4b62be88b1a12ff5cd9cc68624302fe4f608a4 -rcd5be724d5a3ba7457e761191d82f278654d7f5c --- firmware/App/Controllers/Bubble.c (.../Bubble.c) (revision ba4b62be88b1a12ff5cd9cc68624302fe4f608a4) +++ firmware/App/Controllers/Bubble.c (.../Bubble.c) (revision cd5be724d5a3ba7457e761191d82f278654d7f5c) @@ -1,14 +1,14 @@ /************************************************************************** * -* Copyright (c) 2021-2022 Diality Inc. - All Rights Reserved. +* Copyright (c) 2021-2024 Diality Inc. - All Rights Reserved. * * THIS CODE MAY NOT BE COPIED OR REPRODUCED IN ANY FORM, IN PART OR IN * WHOLE, WITHOUT THE EXPLICIT PERMISSION OF THE COPYRIGHT OWNER. * * @file Bubble.c * -* @author (last) Darren Cox -* @date (last) 10-Mar-2022 +* @author (last) Dara Navaei +* @date (last) 22-Jun-2023 * * @author (original) Peman Montazemi * @date (original) 06-May-2021 @@ -19,6 +19,7 @@ #include "Bubble.h" #include "FPGA.h" #include "OperationModes.h" +#include "Switches.h" #include "SystemCommMessages.h" #include "TaskPriority.h" #include "Timers.h" @@ -50,10 +51,11 @@ static U32 bubblesSelfTestStartTime[ NUM_OF_BUBBLES ]; ///< Air bubble detectors self-test start times. static BOOL bubblesSelfTestRequested[ NUM_OF_BUBBLES ]; ///< Air bubble detectors self-test requested flags. +static BOOL bubbleDetectionEnabled[ NUM_OF_BUBBLES ]; ///< Flag indicates whether air bubble alarm detection is enabled. /// Interval (in ms) at which to publish air bubble detectors data on CAN bus. static OVERRIDE_U32_T bubblesDataPublishInterval = { BUBBLE_PUB_INTERVAL, BUBBLE_PUB_INTERVAL, 0, 0 }; -static U32 bubblesDataPublicationTimerCounter = 0; ///< Timer counter used to schedule air bubble detectors data publication to CAN bus. +static U32 bubblesDataPublicationTimerCounter; ///< Timer counter used to schedule air bubble detectors data publication to CAN bus. // ********** private function prototypes ********** @@ -73,7 +75,7 @@ { BUBBLES_T bubble; - for (bubble = ADV; bubble < NUM_OF_BUBBLES; bubble++) + for ( bubble = ADV; bubble < NUM_OF_BUBBLES; bubble++ ) { bubblesState[ bubble ] = BUBBLE_NORMAL_STATE; bubblesStatus[ bubble ].data = BUBBLE_NOT_DETECTED; @@ -141,6 +143,33 @@ /*********************************************************************//** * @brief + * The setVenousBubbleDetectionEnabled function enabled or disables venous + * bubble detection. + * @details Inputs: none + * @details Outputs: bubbleDetectionEnabled[] + * @param enabled flag indicates whether venous bubble detection is enabled + * @return none + *************************************************************************/ +void setVenousBubbleDetectionEnabled( BOOL enabled ) +{ + bubbleDetectionEnabled[ ADV ] = enabled; +} + +/*********************************************************************//** + * @brief + * The getVenousBubbleDetectionEnabled function returns the state of the + * venous bubble detection enable flag. + * @details Inputs: bubbleDetectionEnabled[] + * @details Outputs: none + * @return bubbleDetectionEnabled[] + *************************************************************************/ +BOOL getVenousBubbleDetectionEnabled( void ) +{ + return bubbleDetectionEnabled[ ADV ]; +} + +/*********************************************************************//** + * @brief * The getBubbleStatus function gets the current reading for a given air bubble * detector. * @details Inputs: bubblesStatus @@ -200,34 +229,13 @@ if ( getSoftwareConfigStatus( SW_CONFIG_DISABLE_BUBBLE_ALARMS ) != SW_CONFIG_ENABLE_VALUE ) #endif { - // Check status reading and act upon - if ( BUBBLE_DETECTED == getBubbleStatus( bubble ) ) + // Check for venous bubble alarm if enabled and pump track closed. + if ( ( BUBBLE_DETECTED == getBubbleStatus( bubble ) ) && + ( STATE_CLOSED == getSwitchStatus( PUMP_TRACK_SWITCH ) ) && + ( bubbleDetectionEnabled[ ADV ] != FALSE ) ) { - if ( getCurrentOperationMode() == MODE_TREA ) - { - switch ( treatmentState ) - { - case TREATMENT_BLOOD_PRIME_STATE: - case TREATMENT_DIALYSIS_STATE: - case TREATMENT_END_STATE: - activateAlarmNoData( ALARM_ID_HD_VENOUS_BUBBLE_DETECTED ); - break; - - case TREATMENT_RINSEBACK_STATE: - activateAlarmNoData( ALARM_ID_HD_VENOUS_BUBBLE_DETECTED_RINSEBACK ); - break; - - default: - // Ignore other treatment states - break; - } - } + activateAlarmNoData( ALARM_ID_HD_VENOUS_BUBBLE_DETECTED ); } - else // Air bubble not detected - { - clearAlarmCondition( ALARM_ID_HD_VENOUS_BUBBLE_DETECTED ); - clearAlarmCondition( ALARM_ID_HD_VENOUS_BUBBLE_DETECTED_RINSEBACK ); - } } if ( TRUE == bubblesSelfTestRequested[ bubble ] ) @@ -390,7 +398,7 @@ { BOOL result = FALSE; - if ( status < NUM_OF_BUBBLE_STATUS ) + if ( ( status < NUM_OF_BUBBLE_STATUS ) && ( bubble < NUM_OF_BUBBLES ) ) { if ( TRUE == isTestingActivated() ) {