Index: firmware/App/Controllers/Bubble.c =================================================================== diff -u -r152e924cfb7f4504d4df7ec44736f27b9257f36c -r24b2fe72608344e67ef37234085d15ad5e4fcc37 --- firmware/App/Controllers/Bubble.c (.../Bubble.c) (revision 152e924cfb7f4504d4df7ec44736f27b9257f36c) +++ firmware/App/Controllers/Bubble.c (.../Bubble.c) (revision 24b2fe72608344e67ef37234085d15ad5e4fcc37) @@ -1,17 +1,17 @@ /************************************************************************** * -* Copyright (c) 2019-2021 Diality Inc. - All Rights Reserved. +* Copyright (c) 2019-2022 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 +* @file Bubble.c * -* @author (last) Peman Montazemi -* @date (last) 30-Apr-2021 +* @author (last) Sean Nash +* @date (last) 12-Nov-2021 * -* @author (original) Peman Montazemi -* @date (original) 30-Apr-2021 +* @author (original) Peman Montazemi +* @date (original) 06-May-2021 * ***************************************************************************/ @@ -60,7 +60,6 @@ static BUBBLE_STATES_T handleBubbleSelfTestState( BUBBLES_T ); static void publishBubblesData( void ); -static U32 getPublishBubblesDataInterval( void ); /*********************************************************************//** * @brief @@ -181,6 +180,7 @@ static BUBBLE_STATES_T handleBubbleNormalState( BUBBLES_T bubble ) { BUBBLE_STATES_T state = BUBBLE_NORMAL_STATE; + TREATMENT_STATE_T treatmentState = getTreatmentState(); if ( ( bubble == ADA ) || ( bubble == ADV) ) { @@ -193,33 +193,43 @@ bubblesStatus[ bubble ].data = BUBBLE_DETECTED; } +#ifndef DISABLE_BUBBLE_ALARMS // Check status reading and act upon if ( BUBBLE_DETECTED == getBubbleStatus( bubble ) ) { - if ( ( getCurrentOperationMode() == MODE_TREA ) && ( getTreatmentState() != TREATMENT_RINSEBACK_STATE ) ) + if ( getCurrentOperationMode() == MODE_TREA ) { - // TODO: Enable if ADA is ever used to detect air bubble on arterial line during treatment - //if ( bubble == ADA ) - //{ - // activateAlarmNoData( ALARM_ID_HD_ARTERIAL_BUBBLE_DETECTED ); - //} - - if ( bubble == ADV ) + switch ( treatmentState ) { - activateAlarmNoData( ALARM_ID_HD_VENOUS_BUBBLE_DETECTED ); - } - } - else if ( ( getCurrentOperationMode() == MODE_TREA ) && ( getTreatmentState() == TREATMENT_RINSEBACK_STATE ) ) - { - // TODO: Enable if ADA is ever used to detect air bubble on arterial line during rinseback - //if ( bubble == ADA ) - //{ - // activateAlarmNoData( ALARM_ID_HD_ARTERIAL_BUBBLE_DETECTED_RINSEBACK ); - //} + case TREATMENT_BLOOD_PRIME_STATE: + case TREATMENT_DIALYSIS_STATE: + case TREATMENT_END_STATE: + // TODO: Enable if ADA is ever used to detect air bubble on arterial line during treatment + //if ( bubble == ADA ) + //{ + // activateAlarmNoData( ALARM_ID_HD_ARTERIAL_BUBBLE_DETECTED ); + //} + if ( bubble == ADV ) + { + activateAlarmNoData( ALARM_ID_HD_VENOUS_BUBBLE_DETECTED ); + } + break; - if ( bubble == ADV ) - { - activateAlarmNoData( ALARM_ID_HD_VENOUS_BUBBLE_DETECTED_RINSEBACK ); + case TREATMENT_RINSEBACK_STATE: + // TODO: Enable if ADA is ever used to detect air bubble on arterial line during rinseback + //if ( bubble == ADA ) + //{ + // activateAlarmNoData( ALARM_ID_HD_ARTERIAL_BUBBLE_DETECTED_RINSEBACK ); + //} + if ( bubble == ADV ) + { + activateAlarmNoData( ALARM_ID_HD_VENOUS_BUBBLE_DETECTED_RINSEBACK ); + } + break; + + default: + // Ignore other treatment states + break; } } } @@ -233,8 +243,10 @@ if ( bubble == ADV ) { clearAlarmCondition( ALARM_ID_HD_VENOUS_BUBBLE_DETECTED ); + clearAlarmCondition( ALARM_ID_HD_VENOUS_BUBBLE_DETECTED_RINSEBACK ); } } +#endif if ( TRUE == bubblesSelfTestRequested[ bubble ] ) { @@ -291,7 +303,7 @@ { activateAlarmNoData( ALARM_ID_HD_ARTERIAL_BUBBLE_SELF_TEST_FAILURE ); } - else if ( bubble == ADV ) + else // ADV { activateAlarmNoData( ALARM_ID_HD_VENOUS_BUBBLE_SELF_TEST_FAILURE ); } @@ -316,26 +328,6 @@ /*********************************************************************//** * @brief - * The getPublishBubblesDataInterval function gets the air bubbles data - * publication interval. - * @details Inputs: bubblesDataPublishInterval - * @details Outputs: none - * @return the current air bubbles data publication interval (in task intervals). - *************************************************************************/ -static U32 getPublishBubblesDataInterval( void ) -{ - U32 result = bubblesDataPublishInterval.data; - - if ( OVERRIDE_KEY == bubblesDataPublishInterval.override ) - { - result = bubblesDataPublishInterval.ovData; - } - - return result; -} - -/*********************************************************************//** - * @brief * The publishBubblesData function publishes air bubble detectors data at * the set interval. * @details Inputs: status, bubblesState @@ -345,12 +337,15 @@ static void publishBubblesData( void ) { // Publish air bubble detectors data on interval - if ( ++bubblesDataPublicationTimerCounter >= getPublishBubblesDataInterval() ) + if ( ++bubblesDataPublicationTimerCounter >= getU32OverrideValue( &bubblesDataPublishInterval ) ) { - BUBBLE_STATUS_T statusADA = getBubbleStatus( ADA ); - BUBBLE_STATUS_T statusADV = getBubbleStatus( ADV ); + BUBBLES_DATA_T bubbleData; - broadcastBubblesData( (U32)statusADA, (U32)bubblesState[ ADA ], (U32)statusADV, (U32)bubblesState[ ADV ] ); + bubbleData.statusADA = (U32)getBubbleStatus( ADA ); + bubbleData.stateADA = (U32)bubblesState[ ADA ]; + bubbleData.statusADV = (U32)getBubbleStatus( ADV ); + bubbleData.stateADV = (U32)bubblesState[ ADV ]; + broadcastData( MSG_ID_HD_BUBBLES_DATA, COMM_BUFFER_OUT_CAN_HD_BROADCAST, (U08*)&bubbleData, sizeof( BUBBLES_DATA_T ) ); bubblesDataPublicationTimerCounter = 0; } }