Index: firmware/App/Services/AlarmMgmt.c =================================================================== diff -u -rb61c8330905634762e69ed10fb6614a77552fd54 -r7593a04d1121869dffb536f31c20c57cf571611b --- firmware/App/Services/AlarmMgmt.c (.../AlarmMgmt.c) (revision b61c8330905634762e69ed10fb6614a77552fd54) +++ firmware/App/Services/AlarmMgmt.c (.../AlarmMgmt.c) (revision 7593a04d1121869dffb536f31c20c57cf571611b) @@ -162,6 +162,7 @@ static void publishAlarmInfo( void ); static void checkACPowerLost( void ); +static BOOL isNewAlarmBlocked( ALARM_ID_T alarm ); /*********************************************************************//** * @brief @@ -246,11 +247,8 @@ // Publish alarm status and information at interval publishAlarmInfo(); - // Block new machine alarms during power fail recovery - if ( alarmsBlockedCountdownTimer > 0 ) - { - alarmsBlockedCountdownTimer--; - } + // Block if new alarms are occur during loss of AC power + checkACPowerLost( ); } /*********************************************************************//** @@ -360,16 +358,11 @@ *************************************************************************/ void activateAlarm2Data( ALARM_ID_T alarm, ALARM_DATA_T alarmData1, ALARM_DATA_T alarmData2 ) { - // Block if new alarms are occur during loss of AC power - checkACPowerLost( ); - // Sanity check, verify valid alarm index if ( ( alarm > ALARM_ID_NO_ALARM ) && ( alarm < NUM_OF_ALARM_IDS ) ) { // if the block timer is 0 OR we have an unblockable alarm - if ( ( ALARM_NOT_BLOCKED == alarmsBlockedCountdownTimer ) - || ( ALARM_ID_HD_AC_POWER_LOST == alarm ) - || ( ALARM_ID_HD_AC_POWER_LOST_IN_TREATMENT == alarm ) ) + if ( isNewAlarmBlocked( alarm ) != TRUE ) { // do not re-trigger alarm if blocked by property if ( ( FALSE == alarmNoRetrigger ) || ( ( ALARM_TABLE[ alarm ].alarmNoRetrigOnRB != TRUE ) && ( ALARM_TABLE[ alarm ].alarmNoRetrigOnEndTx != TRUE ) ) ) @@ -679,16 +672,34 @@ /*********************************************************************//** * @brief + * The isNewAlarmBlocked function determines whether A/C power loss has + * blocked new alarms. + * @details Inputs: alarmsBlockedCountdownTimer + * @details Outputs: none + * @return TRUE if A/C power loss condition is in effect, FALSE if not + *************************************************************************/ +static BOOL isNewAlarmBlocked( ALARM_ID_T alarm ) +{ + BOOL result = FALSE; + result = ( ALARM_NOT_BLOCKED == alarmsBlockedCountdownTimer ) || + ( ALARM_ID_HD_AC_POWER_LOST == alarm ) || + ( ALARM_ID_HD_AC_POWER_LOST_IN_TREATMENT == alarm ); + + return result; +} + +/*********************************************************************//** + * @brief * The isACPowerLost function determines whether A/C power loss has been * detected. - * @details Inputs: none + * @details Inputs: alarmsBlockedCountdownTimer * @details Outputs: none * @return TRUE if A/C power loss condition is in effect, FALSE if not *************************************************************************/ BOOL isACPowerLost( void ) { BOOL result = FALSE; - if ( ( getCPLDACPowerLossDetected() != FALSE ) || + if ( ( getCPLDACPowerLossDetected( ) != FALSE ) || ( alarmsBlockedCountdownTimer != ALARM_NOT_BLOCKED ) ) { result = TRUE; @@ -701,16 +712,20 @@ * @brief * The checkACPowerLost function checks whether A/C power loss has been * detected, and sets countdown timer to block new alarms. - * @details Inputs: alarmsBlockedCountdownTimer - * @details Outputs: none + * @details Inputs: none + * @details Outputs: alarmsBlockedCountdownTimer * @return TRUE if A/C power loss condition is in effect, FALSE if not *************************************************************************/ static void checkACPowerLost( void ) { - if ( TRUE == isACPowerLost( ) ) + if ( TRUE == getCPLDACPowerLossDetected( ) ) { alarmsBlockedCountdownTimer = ALARM_BLOCKED_TICK_COUNT_AFTER_AC_RETURN; } + else if ( alarmsBlockedCountdownTimer > 0 ) + { + alarmsBlockedCountdownTimer--; + } } /*********************************************************************//**