Index: firmware/App/Services/AlarmMgmt.c =================================================================== diff -u -r4bd3bf3483660050d3026f7f9adff43782bfc620 -r8bcb6b1342198d6d87d1350b2ca61a932a4ff006 --- firmware/App/Services/AlarmMgmt.c (.../AlarmMgmt.c) (revision 4bd3bf3483660050d3026f7f9adff43782bfc620) +++ firmware/App/Services/AlarmMgmt.c (.../AlarmMgmt.c) (revision 8bcb6b1342198d6d87d1350b2ca61a932a4ff006) @@ -16,25 +16,25 @@ ***************************************************************************/ #define __ALARM_MGMT_C__ - -#include "AlarmMgmt.h" + +#include "AlarmMgmt.h" #include "CPLD.h" #include "OperationModes.h" #include "PersistentAlarm.h" -#include "Reservoirs.h" +#include "Reservoirs.h" #include "SafetyShutdown.h" #include "SystemComm.h" -#include "SystemCommMessages.h" -#include "TaskGeneral.h" -#include "Timers.h" - -/** - * @addtogroup AlarmManagement - * @{ - */ - -// ********** private definitions ********** +#include "SystemCommMessages.h" +#include "TaskGeneral.h" +#include "Timers.h" +/** + * @addtogroup AlarmManagement + * @{ + */ + +// ********** private definitions ********** + /// Interval (ms/task time) at which the alarm information is published on the CAN bus. #define ALARM_INFO_PUB_INTERVAL ( MS_PER_SECOND / TASK_GENERAL_INTERVAL ) #define DATA_PUBLISH_COUNTER_START_COUNT 12 ///< Data publish counter start count. @@ -48,84 +48,84 @@ U08 alarmRankTableSizeAssertion[ ( ( sizeof( ALARM_RANK_TABLE ) / sizeof( ALARM_RANK_T ) ) == NUM_OF_ALARM_IDS ? 1 : -1 ) ]; U32 alarmLEDTimer; ///< Alarm LED timer - -const ALARM_DATA_T BLANK_ALARM_DATA = { ALARM_DATA_TYPE_NONE, 0 }; ///< A blank alarm data record for alarms that do not include alarm data when triggered. - + +const ALARM_DATA_T BLANK_ALARM_DATA = { ALARM_DATA_TYPE_NONE, 0 }; ///< A blank alarm data record for alarms that do not include alarm data when triggered. + #define SUPERVISOR_ALARM_KEY 0xD2C3B4A5 ///< 32-bit key required for clear all alarms request. -// ********** private data ********** +// ********** private data ********** static BOOL alarmIsActive[ NUM_OF_ALARM_IDS ]; ///< Array of current state of each alarm -static BOOL alarmConditionIsActive[ NUM_OF_ALARM_IDS ]; ///< Array of flag indicates if an alarm condition is active +static BOOL alarmConditionIsActive[ NUM_OF_ALARM_IDS ]; ///< Array of flag indicates if an alarm condition is active static U32 alarmInfoPublicationTimerCounter; ///< Used to schedule alarm information publication to CAN bus. static BOOL isAFaultAlarmActive; ///< Boolean flag to indicate whether a DG fault alarm is active. /// Interval (in task intervals) at which to publish alarm information to CAN bus. static OVERRIDE_U32_T alarmInfoPublishInterval = { ALARM_INFO_PUB_INTERVAL, ALARM_INFO_PUB_INTERVAL, ALARM_INFO_PUB_INTERVAL, 0 }; - -// ********** private function prototypes ********** - -static void activateAlarm( ALARM_ID_T alarm ); + +// ********** private function prototypes ********** + +static void activateAlarm( ALARM_ID_T alarm ); static void publishAlarmInfo( void ); static void alarmUserNotify( void ); static BOOL isTransitionToFaultRequired( void ); - -/*********************************************************************//** - * @brief - * The initAlarmMgmt function initializes the AlarmMgmt module. - * @details Inputs: none + +/*********************************************************************//** + * @brief + * The initAlarmMgmt function initializes the AlarmMgmt module. + * @details Inputs: none * @details Outputs: alarmInfoPublicationTimerCounter, alarmLEDTimer, - * isAFaultAlarmActive, alarmIsActive, alarmConditionIsActive - * @return none - *************************************************************************/ -void initAlarmMgmt( void ) -{ + * isAFaultAlarmActive, alarmIsActive, alarmConditionIsActive + * @return none + *************************************************************************/ +void initAlarmMgmt( void ) +{ ALARM_ID_T alrm; alarmInfoPublicationTimerCounter = DATA_PUBLISH_COUNTER_START_COUNT; alarmLEDTimer = 0; - isAFaultAlarmActive = FALSE; - - // initialize alarm states and start time stamps - for ( alrm = ALARM_ID_NO_ALARM; alrm < NUM_OF_ALARM_IDS; alrm++ ) - { - alarmIsActive[ alrm ] = FALSE; - alarmConditionIsActive[ alrm ] = FALSE; - } -} + isAFaultAlarmActive = FALSE; -/*********************************************************************//** - * @brief - * The execAlarmMgmt function executes the alarm management module. - * @details Inputs: none - * @details Outputs: none - * @return none - *************************************************************************/ -void execAlarmMgmt( void ) -{ + // initialize alarm states and start time stamps + for ( alrm = ALARM_ID_NO_ALARM; alrm < NUM_OF_ALARM_IDS; alrm++ ) + { + alarmIsActive[ alrm ] = FALSE; + alarmConditionIsActive[ alrm ] = FALSE; + } +} + +/*********************************************************************//** + * @brief + * The execAlarmMgmt function executes the alarm management module. + * @details Inputs: none + * @details Outputs: none + * @return none + *************************************************************************/ +void execAlarmMgmt( void ) +{ // Alarm audio and LED/lamp management for DG - alarmUserNotify(); + alarmUserNotify(); // Publish alarm information at interval publishAlarmInfo(); -} +} -/*********************************************************************//** - * @brief - * The activateAlarm function activates a given alarm. - * @details Inputs: none - * @details Outputs: alarmIsActive[], isAFaultAlarmActive - * @param alarm ID of alarm to activate - * @return none - *************************************************************************/ -static void activateAlarm( ALARM_ID_T alarm ) -{ - // verify given alarm - if ( ( alarm > ALARM_ID_NO_ALARM ) && ( alarm < NUM_OF_ALARM_IDS ) ) - { - // no need to do anything if alarm is already active - if ( FALSE == alarmIsActive[ alarm ] ) - { - // activate alarm +/*********************************************************************//** + * @brief + * The activateAlarm function activates a given alarm. + * @details Inputs: none + * @details Outputs: alarmIsActive[], isAFaultAlarmActive + * @param alarm ID of alarm to activate + * @return none + *************************************************************************/ +static void activateAlarm( ALARM_ID_T alarm ) +{ + // verify given alarm + if ( ( alarm > ALARM_ID_NO_ALARM ) && ( alarm < NUM_OF_ALARM_IDS ) ) + { + // no need to do anything if alarm is already active + if ( FALSE == alarmIsActive[ alarm ] ) + { + // activate alarm alarmIsActive[ alarm ] = TRUE; alarmConditionIsActive[ alarm ] = TRUE; @@ -144,59 +144,59 @@ if ( TRUE == ALARM_TABLE[ alarm ].alarmConditionClearImmed ) { clearAlarmCondition( alarm ); - } - } - } - else - { - SET_ALARM_WITH_2_U32_DATA( ALARM_ID_DG_SOFTWARE_FAULT, SW_FAULT_ID_ALARM_MGMT_INVALID_ALARM_TO_ACTIVATE, alarm ) - } -} + } + } + } + else + { + SET_ALARM_WITH_2_U32_DATA( ALARM_ID_DG_SOFTWARE_FAULT, SW_FAULT_ID_ALARM_MGMT_INVALID_ALARM_TO_ACTIVATE, alarm ) + } +} -/*********************************************************************//** - * @brief +/*********************************************************************//** + * @brief * The activateAlarmNoData function activates a given alarm. An alarm message - * is broadcast to the rest of the system. - * @details Inputs: none - * @details Outputs: alarm triggered message sent, alarm activated - * @param alarm ID of alarm to activate - * @return none - *************************************************************************/ -void activateAlarmNoData( ALARM_ID_T alarm ) + * is broadcast to the rest of the system. + * @details Inputs: none + * @details Outputs: alarm triggered message sent, alarm activated + * @param alarm ID of alarm to activate + * @return none + *************************************************************************/ +void activateAlarmNoData( ALARM_ID_T alarm ) { - activateAlarm2Data( alarm, BLANK_ALARM_DATA, BLANK_ALARM_DATA, FALSE ); -} + activateAlarm2Data( alarm, BLANK_ALARM_DATA, BLANK_ALARM_DATA, FALSE ); +} -/*********************************************************************//** - * @brief +/*********************************************************************//** + * @brief * The activateAlarm1Data function activates a given alarm. An alarm message * is broadcast to the rest of the system. This function will include given - * data in the broadcast message for logging. - * @details Inputs: none - * @details Outputs: alarm triggered message sent, alarm activated - * @param alarm ID of alarm to activate - * @param alarmData supporting data to include in alarm message - * @return none - *************************************************************************/ -void activateAlarm1Data( ALARM_ID_T alarm, ALARM_DATA_T alarmData ) + * data in the broadcast message for logging. + * @details Inputs: none + * @details Outputs: alarm triggered message sent, alarm activated + * @param alarm ID of alarm to activate + * @param alarmData supporting data to include in alarm message + * @return none + *************************************************************************/ +void activateAlarm1Data( ALARM_ID_T alarm, ALARM_DATA_T alarmData ) { - activateAlarm2Data( alarm, alarmData, BLANK_ALARM_DATA, FALSE ); -} + activateAlarm2Data( alarm, alarmData, BLANK_ALARM_DATA, FALSE ); +} -/*********************************************************************//** - * @brief +/*********************************************************************//** + * @brief * The activateAlarm2Data function activates a given alarm. An alarm message * is broadcast to the rest of the system. This function will include - * two given data in the broadcast message for logging. - * @details Inputs: none - * @details Outputs: alarm triggered message sent, alarm activated - * @param alarm ID of alarm to activate - * @param alarmData1 supporting data to include in alarm message - * @param alarmData2 supporting data to include in alarm message + * two given data in the broadcast message for logging. + * @details Inputs: none + * @details Outputs: alarm triggered message sent, alarm activated + * @param alarm ID of alarm to activate + * @param alarmData1 supporting data to include in alarm message + * @param alarmData2 supporting data to include in alarm message * @param outside flag indicates whether alarm is originating from outside HD f/w - * @return none - *************************************************************************/ -void activateAlarm2Data( ALARM_ID_T alarm, ALARM_DATA_T alarmData1, ALARM_DATA_T alarmData2, BOOL outside ) + * @return none + *************************************************************************/ +void activateAlarm2Data( ALARM_ID_T alarm, ALARM_DATA_T alarmData1, ALARM_DATA_T alarmData2, BOOL outside ) { HD_MODE_SUB_MODE_T hdModes; @@ -213,38 +213,38 @@ } activateAlarm( alarm ); } -} +} -/*********************************************************************//** - * @brief +/*********************************************************************//** + * @brief * The clearAlarm function clears a given alarm if it is recoverable. - * An alarm message is broadcast to the rest of the system. - * @details Inputs: none - * @details Outputs: AlarmStatusTable[] - * @param alarm ID of alarm to clear - * @return none - *************************************************************************/ -void clearAlarm( ALARM_ID_T alarm ) -{ - // verify given alarm - if ( ( alarm > ALARM_ID_NO_ALARM ) && ( alarm < NUM_OF_ALARM_IDS ) ) - { - // clear alarm and broadcast alarm clear if not already cleared (and not a DG fault which should not be cleared) - if ( ( TRUE == alarmIsActive[ alarm ] ) && ( ALARM_TABLE[ alarm ].alarmIsDGFault != TRUE ) ) + * An alarm message is broadcast to the rest of the system. + * @details Inputs: none + * @details Outputs: AlarmStatusTable[] + * @param alarm ID of alarm to clear + * @return none + *************************************************************************/ +void clearAlarm( ALARM_ID_T alarm ) +{ + // verify given alarm + if ( ( alarm > ALARM_ID_NO_ALARM ) && ( alarm < NUM_OF_ALARM_IDS ) ) + { + // clear alarm and broadcast alarm clear if not already cleared (and not a DG fault which should not be cleared) + if ( ( TRUE == alarmIsActive[ alarm ] ) && ( ALARM_TABLE[ alarm ].alarmIsDGFault != TRUE ) ) { if ( TRUE == isHDCommunicating() ) - { + { broadcastAlarmCleared( alarm ); - } + } alarmIsActive[ alarm ] = FALSE; - clearAlarmCondition( alarm ); - } - } - else - { - SET_ALARM_WITH_2_U32_DATA( ALARM_ID_DG_SOFTWARE_FAULT, SW_FAULT_ID_ALARM_MGMT_INVALID_ALARM_TO_CLEAR, alarm ) - } -} + clearAlarmCondition( alarm ); + } + } + else + { + SET_ALARM_WITH_2_U32_DATA( ALARM_ID_DG_SOFTWARE_FAULT, SW_FAULT_ID_ALARM_MGMT_INVALID_ALARM_TO_CLEAR, alarm ) + } +} /*********************************************************************//** * @brief @@ -276,17 +276,17 @@ } } -/*********************************************************************//** - * @brief - * The isAlarmActive function determines whether a given alarm is currently active. - * @details Inputs: alarmIsActive[] - * @details Outputs: none - * @param alarm ID of alarm to check - * @return TRUE if given alarm is active, FALSE if not +/*********************************************************************//** + * @brief + * The isAlarmActive function determines whether a given alarm is currently active. + * @details Inputs: alarmIsActive[] + * @details Outputs: none + * @param alarm ID of alarm to check + * @return TRUE if given alarm is active, FALSE if not *************************************************************************/ -BOOL isAlarmActive( ALARM_ID_T alarm ) -{ - return alarmIsActive[ alarm ]; +BOOL isAlarmActive( ALARM_ID_T alarm ) +{ + return alarmIsActive[ alarm ]; } /*********************************************************************//** @@ -314,7 +314,7 @@ BOOL isAlarmConditionActive( ALARM_ID_T alarm ) { return alarmConditionIsActive[ alarm ]; -} +} /*********************************************************************//** * @brief @@ -372,6 +372,7 @@ { BOOL status = FALSE; + // Check all the inlet water conditions status |= isAlarmActive( ALARM_ID_DG_CLEANING_MODE_INLET_WATER_TEMP_TOO_HIGH ); status |= isAlarmActive( ALARM_ID_DG_CLEANING_MODE_INLET_WATER_TEMP_TOO_LOW ); status |= isAlarmActive( ALARM_ID_DG_CLEANING_MODE_INLET_WATER_COND_TOO_HIGH ); @@ -458,72 +459,72 @@ return status; } - -/************************************************************************* - * TEST SUPPORT FUNCTIONS - *************************************************************************/ +/************************************************************************* + * TEST SUPPORT FUNCTIONS + *************************************************************************/ -/*********************************************************************//** - * @brief + +/*********************************************************************//** + * @brief * The testSetAlarmStateOverride function overrides the state of the alarm active - * state for a given alarm with the alarm management with a given active state. - * @details Inputs: none - * @details Outputs: alarm activated or cleared - * @param alarmID ID of alarm to activate or clear - * @param value override state for the given alarm ID (1=activate, 0=clear) - * @return TRUE if override successful, FALSE if not - *************************************************************************/ -BOOL testSetAlarmStateOverride( U32 alarmID, U32 state ) -{ - BOOL result = FALSE; - - if ( alarmID < NUM_OF_ALARM_IDS ) - { - if ( TRUE == isTestingActivated() ) - { - if ( TRUE == (BOOL)state ) - { - activateAlarmNoData( (ALARM_ID_T)alarmID ); - } - else - { - clearAlarm( (ALARM_ID_T)alarmID ); - } - result = TRUE; - } - } - - return result; -} + * state for a given alarm with the alarm management with a given active state. + * @details Inputs: none + * @details Outputs: alarm activated or cleared + * @param alarmID ID of alarm to activate or clear + * @param value override state for the given alarm ID (1=activate, 0=clear) + * @return TRUE if override successful, FALSE if not + *************************************************************************/ +BOOL testSetAlarmStateOverride( U32 alarmID, U32 state ) +{ + BOOL result = FALSE; -/*********************************************************************//** - * @brief - * The testResetAlarmStateOverride function resets the override of the - * state of the active state for a given alarm with the alarm management. - * @details Inputs: none - * @details Outputs: alarm cleared - * @param alarmID ID of alarm to clear - * @return TRUE if alarm clear successful, FALSE if not - *************************************************************************/ -BOOL testResetAlarmStateOverride( U32 alarmID ) -{ - BOOL result = FALSE; - - if ( alarmID < NUM_OF_ALARM_IDS ) - { - if ( TRUE == isTestingActivated() ) - { - result = TRUE; - clearAlarm( (ALARM_ID_T)alarmID ); - } - } - - return result; -} + if ( alarmID < NUM_OF_ALARM_IDS ) + { + if ( TRUE == isTestingActivated() ) + { + if ( TRUE == (BOOL)state ) + { + activateAlarmNoData( (ALARM_ID_T)alarmID ); + } + else + { + clearAlarm( (ALARM_ID_T)alarmID ); + } + result = TRUE; + } + } + return result; +} + /*********************************************************************//** * @brief + * The testResetAlarmStateOverride function resets the override of the + * state of the active state for a given alarm with the alarm management. + * @details Inputs: none + * @details Outputs: alarm cleared + * @param alarmID ID of alarm to clear + * @return TRUE if alarm clear successful, FALSE if not + *************************************************************************/ +BOOL testResetAlarmStateOverride( U32 alarmID ) +{ + BOOL result = FALSE; + + if ( alarmID < NUM_OF_ALARM_IDS ) + { + if ( TRUE == isTestingActivated() ) + { + result = TRUE; + clearAlarm( (ALARM_ID_T)alarmID ); + } + } + + return result; +} + +/*********************************************************************//** + * @brief * The testClearAllAlarms function clears all active alarms, even if they * are non-recoverable or faults. The caller of this function must provide * the correct 32-bit key. A Dialin user must also be logged into DG.