Index: firmware/App/Services/AlarmMgmt.c =================================================================== diff -u -r2dd1b02e90c90fcd94bf9b21245282205a963654 -ra171113ad87fdca3c57b49754bd29f70b3c77e64 --- firmware/App/Services/AlarmMgmt.c (.../AlarmMgmt.c) (revision 2dd1b02e90c90fcd94bf9b21245282205a963654) +++ firmware/App/Services/AlarmMgmt.c (.../AlarmMgmt.c) (revision a171113ad87fdca3c57b49754bd29f70b3c77e64) @@ -42,7 +42,7 @@ #define ALARM_INFO_PUB_INTERVAL ( MS_PER_SECOND / TASK_GENERAL_INTERVAL ) /// Interval (ms/task time) Alarms are blocked after the return of AC power. -#define ALARM_BLOCKED_COUNT_AFTER_AC_RETURN ( 10*MS_PER_SECOND / TASK_GENERAL_INTERVAL ) +#define ALARM_BLOCKED_TICK_COUNT_AFTER_AC_RETURN ( 10*MS_PER_SECOND / TASK_GENERAL_INTERVAL ) #define ALARM_SILENCE_EXPIRES_IN_SECS (60) ///< Alarm silence expiration time in seconds. @@ -116,7 +116,7 @@ static U32 alarmStatusPublicationTimerCounter = 0; ///< Used to schedule alarm status publication to CAN bus. static U32 alarmInfoPublicationTimerCounter = 0; ///< Used to schedule alarm information publication to CAN bus. static U32 audioTestStartTime; ///< Start time of audio alarm current self-test. -static U32 alarmsBlockedTimer = 0; ///< Countdown timer used to temporarily block new alarms from being initiated +static U32 alarmsBlockedCountdownTimer = 0; ///< Countdown timer used to temporarily block new alarms from being initiated /// Interval (in task intervals) at which to publish alarm status to CAN bus. static OVERRIDE_U32_T alarmStatusPublishInterval = { ALARM_STATUS_PUBLISH_INTERVAL, ALARM_STATUS_PUBLISH_INTERVAL, ALARM_STATUS_PUBLISH_INTERVAL, 0 }; @@ -161,6 +161,8 @@ static U32 getAlarmStartTime( ALARM_ID_T alarmID ); static void publishAlarmInfo( void ); +static void checkACPowerLost( void ); +static BOOL isNewAlarmBlocked( ALARM_ID_T alarm ); /*********************************************************************//** * @brief @@ -220,7 +222,7 @@ alarmStatus.noDialRecirc = FALSE; alarmStatus.ok = FALSE; - alarmsBlockedTimer = 0; + alarmsBlockedCountdownTimer = 0; alarmAudioTestToneRequested = FALSE; resumeBlockedByAlarmProperty = FALSE; alarmNoRetrigger = FALSE; @@ -245,11 +247,8 @@ // Publish alarm status and information at interval publishAlarmInfo(); - // Block new machine alarms during power fail recovery - if ( alarmsBlockedTimer > 0 ) - { - alarmsBlockedTimer--; - } + // Block if new alarms are occur during loss of AC power + checkACPowerLost(); } /*********************************************************************//** @@ -359,18 +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 - if ( ( TRUE == getCPLDACPowerLossDetected() ) ) - { - alarmsBlockedTimer = ALARM_BLOCKED_COUNT_AFTER_AC_RETURN; - } // 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 == alarmsBlockedTimer ) - || ( 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 ) ) ) @@ -680,6 +672,68 @@ /*********************************************************************//** * @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; + + if( ( ALARM_NOT_BLOCKED != alarmsBlockedCountdownTimer ) && + ( ALARM_ID_HD_AC_POWER_LOST != alarm ) && + ( ALARM_ID_HD_AC_POWER_LOST_IN_TREATMENT != alarm ) ) + { + result = TRUE; + } + + return result; +} + +/*********************************************************************//** + * @brief + * The isACPowerLost function determines whether A/C power loss has been + * detected. + * @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 ) || + ( alarmsBlockedCountdownTimer != ALARM_NOT_BLOCKED ) ) + { + result = TRUE; + } + + return result; +} + +/*********************************************************************//** + * @brief + * The checkACPowerLost function checks whether A/C power loss has been + * detected, and sets countdown timer to block new alarms. + * @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 == getCPLDACPowerLossDetected() ) + { + alarmsBlockedCountdownTimer = ALARM_BLOCKED_TICK_COUNT_AFTER_AC_RETURN; + } + else if ( alarmsBlockedCountdownTimer > 0 ) + { + alarmsBlockedCountdownTimer--; + } +} + +/*********************************************************************//** + * @brief * The isBloodRecircBlocked function determines whether any currently * active alarm is blocking blood re-circulation. * @details Inputs: alarmStatus