Index: firmware/App/Controllers/Bubble.c =================================================================== diff -u -r796d5732ae78870d15ac5c86feee82229626034c -r3d30c9829d316b8c5e632c0201a59c8d14b3486e --- firmware/App/Controllers/Bubble.c (.../Bubble.c) (revision 796d5732ae78870d15ac5c86feee82229626034c) +++ firmware/App/Controllers/Bubble.c (.../Bubble.c) (revision 3d30c9829d316b8c5e632c0201a59c8d14b3486e) @@ -48,8 +48,8 @@ static OVERRIDE_U32_T bubblesStatus[ NUM_OF_BUBBLES ]; ///< Detected air bubble status for air bubble detectors. static SELF_TEST_STATUS_T bubblesSelfTestStatus[ NUM_OF_BUBBLES ]; ///< Current status of air bubble detectors self-tests. -static U32 bubblesSelfTestStartTime[ 0, 0 ]; ///< Air bubble detectors self-test start times. -static BOOL bubblesSelfTestRequested[ FALSE, FALSE ]; ///< Air bubble detectors self-test requested flags. +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. /// 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 }; @@ -151,18 +151,18 @@ *************************************************************************/ static BUBBLE_STATES_T handleBubbleInitState( BUBBLES_T bubble ) { - BUBBLE_STATES_T state[ bubble ] = BUBBLE_INIT_STATE; + BUBBLE_STATES_T state = BUBBLE_INIT_STATE; if ( TRUE == bubblesSelfTestRequested[ bubble ] ) { - state[ bubble ] = BUBBLE_SELF_TEST_STATE; + state = BUBBLE_SELF_TEST_STATE; bubblesSelfTestRequested[ bubble ] = FALSE; setFPGABubbleSelfTest( bubble ); bubblesSelfTestStartTime[ bubble ] = getMSTimerCount(); } - return state[ bubble ]; + return state; } /*********************************************************************//** @@ -175,7 +175,7 @@ *************************************************************************/ static BUBBLE_STATES_T handleBubbleSelfTestState( BUBBLES_T bubble ) { - BUBBLE_STATES_T state[ bubble ] = BUBBLE_SELF_TEST_STATE; + BUBBLE_STATES_T state = BUBBLE_SELF_TEST_STATE; if ( SELF_TEST_STATUS_IN_PROGRESS == bubblesSelfTestStatus[ bubble ] ) { @@ -206,11 +206,11 @@ // Air bubble self-test finished, wait for self-test faked air bubble detector clear if ( TRUE == noFPGABubbleDetected( bubble ) ) { - state[ bubble ] = BUBBLE_NORMAL_STATE; + state = BUBBLE_NORMAL_STATE; } } - return state[ bubble ]; + return state; } /*********************************************************************//** @@ -223,7 +223,7 @@ *************************************************************************/ static BUBBLE_STATES_T handleBubbleNormalState( BUBBLES_T bubble ) { - BUBBLE_STATES_T state[ bubble ] = BUBBLE_NORMAL_STATE; + BUBBLE_STATES_T state = BUBBLE_NORMAL_STATE; if ( TRUE == noFPGABubbleDetected( bubble ) ) { @@ -252,21 +252,6 @@ // TODO: Should never reach here } } - else if ( getCurrentOperationMode() == MODE_PRET ) // TODO: Any better mode to know we are priming? - { - if ( bubble == ADA ) - { - activateAlarmNoData( ALARM_ID_HD_ARTERIAL_BUBBLE_DETECTOR_FAULT ); - } - else if ( bubble == ADV ) - { - activateAlarmNoData( ALARM_ID_HD_VENOUS_BUBBLE_DETECTOR_TREATMENT_FAULT ); - } - else - { - // TODO: Should never reach here - } - } else if ( getCurrentOperationMode() == TREATMENT_RINSEBACK_STATE ) // TODO: Any better mode to know we are in rinseback? { if ( bubble == ADA ) @@ -295,16 +280,16 @@ } } - if ( TRUE == bubblesSelfTestRequested( bubble ) ) + if ( TRUE == bubblesSelfTestRequested[ bubble ] ) { - state[ bubble] = BUBBLE_SELF_TEST_STATE; + state = BUBBLE_SELF_TEST_STATE; bubblesSelfTestRequested[ bubble ] = FALSE; setFPGABubbleSelfTest( bubble ); bubblesSelfTestStartTime[ bubble ] = getMSTimerCount(); } - return state[ bubble ]; + return state; } /*********************************************************************//** @@ -321,7 +306,7 @@ if ( OVERRIDE_KEY == bubblesStatus[ bubble ].override ) { - result = (BLOOD_LEAK_STATUS_T)bubblesStatus[ bubble ].ovData; + result = (BUBBLE_STATUS_T)bubblesStatus[ bubble ].ovData; } return result; @@ -370,18 +355,14 @@ *************************************************************************/ static void publishBubblesData( void ) { - BUBBLES_T bubble; - // Publish air bubble detectors data on interval if ( ++bubblesDataPublicationTimerCounter >= getPublishBubblesDataInterval() ) { - for ( bubble = ADA; bubble < NUM_OF_BUBBLES; bubble++ ) - { - BUBBLE_STATUS_T status = getBubbleStatus( bubble ); + BUBBLE_STATUS_T statusADA = getBubbleStatus( ADA ); + BUBBLE_STATUS_T statusADV = getBubbleStatus( ADV ); - broadcastBubblesData( status, (U32)bubblesState[ bubble ] ); + broadcastBubblesData( statusADA, (U32)bubblesState[ ADA ], statusADV, (U32)bubblesState[ ADV ] ); bubblesDataPublicationTimerCounter = 0; - } } }