Index: firmware/App/Controllers/Bubble.c =================================================================== diff -u -r68aefeff8890cdfa956c7bfdf0d4505b4ac25cb7 -rcd5be724d5a3ba7457e761191d82f278654d7f5c --- firmware/App/Controllers/Bubble.c (.../Bubble.c) (revision 68aefeff8890cdfa956c7bfdf0d4505b4ac25cb7) +++ firmware/App/Controllers/Bubble.c (.../Bubble.c) (revision cd5be724d5a3ba7457e761191d82f278654d7f5c) @@ -1,14 +1,14 @@ /************************************************************************** * -* Copyright (c) 2019-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) Sean Nash -* @date (last) 12-Nov-2021 +* @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" @@ -30,8 +31,9 @@ // ********** private definitions ********** -#define BUBBLE_PUB_INTERVAL ( MS_PER_SECOND / TASK_PRIORITY_INTERVAL ) ///< Interval (ms/task time) at which the air bubble detector data is published on the CAN bus. -#define BUBBLE_TIMEOUT_MS 500 ///< Air bubble detector timeout for self-test (15 ms extended edge detection) +#define BUBBLE_PUB_INTERVAL ( MS_PER_SECOND / TASK_PRIORITY_INTERVAL ) ///< Interval (ms/task time) at which the air bubble detector data is published on the CAN bus. +#define BUBBLE_TIMEOUT_MS 500 ///< Air bubble detector timeout for self-test (15 ms extended edge detection) +#define DATA_PUBLISH_COUNTER_START_COUNT 70 ///< Data publish counter start count. /// Defined states for the air bubble detectors state machine. typedef enum BubbleStates @@ -49,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 ********** @@ -72,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; @@ -83,6 +86,8 @@ bubblesSelfTestRequested[ bubble ] = FALSE; bubblesSelfTestStartTime[ bubble ] = 0; } + + bubblesDataPublicationTimerCounter = DATA_PUBLISH_COUNTER_START_COUNT; } /*********************************************************************//** @@ -138,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 @@ -193,45 +225,18 @@ bubblesStatus[ bubble ].data = BUBBLE_DETECTED; } -#ifndef DISABLE_BUBBLE_ALARMS - // Check status reading and act upon - if ( BUBBLE_DETECTED == getBubbleStatus( bubble ) ) +#ifndef _RELEASE_ + if ( getSoftwareConfigStatus( SW_CONFIG_DISABLE_BUBBLE_ALARMS ) != SW_CONFIG_ENABLE_VALUE ) +#endif { - if ( getCurrentOperationMode() == MODE_TREA ) + // 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 ) ) { - switch ( treatmentState ) - { - case TREATMENT_BLOOD_PRIME_STATE: - case TREATMENT_DIALYSIS_STATE: - case TREATMENT_END_STATE: - if ( bubble == ADV ) - { - activateAlarmNoData( ALARM_ID_HD_VENOUS_BUBBLE_DETECTED ); - } - break; - - case TREATMENT_RINSEBACK_STATE: - if ( bubble == ADV ) - { - 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 - { - if ( bubble == ADV ) - { - clearAlarmCondition( ALARM_ID_HD_VENOUS_BUBBLE_DETECTED ); - clearAlarmCondition( ALARM_ID_HD_VENOUS_BUBBLE_DETECTED_RINSEBACK ); - } - } -#endif if ( TRUE == bubblesSelfTestRequested[ bubble ] ) { @@ -393,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() ) {