Index: firmware/App/Services/AlarmMgmt.c =================================================================== diff -u -r172b320a1007769c7452fe3f1cc7ac85b016f89a -rafa9d4924d55ac4fc98270a012e92dd1f6ee65d0 --- firmware/App/Services/AlarmMgmt.c (.../AlarmMgmt.c) (revision 172b320a1007769c7452fe3f1cc7ac85b016f89a) +++ firmware/App/Services/AlarmMgmt.c (.../AlarmMgmt.c) (revision afa9d4924d55ac4fc98270a012e92dd1f6ee65d0) @@ -44,11 +44,15 @@ #define SUPERVISOR_ALARM_KEY 0xD2C3B4A5 ///< 32-bit key required for clear all alarms request. -#define LOWEST_ALARM_SUB_RANK 999 ///< Lowest alarm sub-rank that can be set. +#define LOWEST_ALARM_SUB_RANK 999 ///< Lowest alarm sub-rank that can be set. +#define MAX_ALARM_LIST_SIZE 10 ///< Maximum number of active alarms inside alarm list. // *** This declaration will cause a compiler error if ALARM_TABLE does not have same # of alarms as the Alarm_List enumeration. U08 alarmTableSizeAssertion[ ( ( sizeof( ALARM_TABLE ) / sizeof( ALARM_T ) ) == NUM_OF_ALARM_IDS ? 1 : -1 ) ]; +// *** This declaration will cause a compiler error if ALARM_RANK_TABLE does not have same # of alarms as the Alarm_List enumeration. +U08 alarmRankTableSizeAssertion[ ( ( sizeof( ALARM_RANK_TABLE ) / sizeof( ALARM_RANK_T ) ) == NUM_OF_ALARM_IDS ? 1 : -1 ) ]; + /// 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 }; @@ -82,15 +86,12 @@ // ********** private data ********** -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 BOOL alarmIsActive[ NUM_OF_ALARM_IDS ]; ///< Table - current state of each alarm +static BOOL alarmIsDetected[ NUM_OF_ALARM_IDS ]; ///< Table - current state of each alarm condition (detected or cleared) +static OVERRIDE_U32_T alarmStartedAt[ NUM_OF_ALARM_IDS ]; ///< Table - when alarm became active for each alarm (if active) or zero (if inactive) +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. -/// Table - current state of each alarm -static BOOL alarmIsActive[ NUM_OF_ALARM_IDS ]; -/// Table - current state of each alarm condition (detected or cleared) -static BOOL alarmIsDetected[ NUM_OF_ALARM_IDS ]; -/// Table - when alarm became active for each alarm (if active) or zero (if inactive) -static OVERRIDE_U32_T alarmStartedAt[ NUM_OF_ALARM_IDS ]; /// 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 }; #ifndef ALARM_VOLUME_DEFAULT_LOW @@ -106,15 +107,11 @@ /// Alarm backup audio current measured at ADC. static OVERRIDE_F32_T alarmBackupAudioCurrent = { 0.0, 0.0, 0.0, 0 }; -/// Record for the current composite alarm status. -static COMP_ALARM_STATUS_T alarmStatus; +static COMP_ALARM_STATUS_T alarmStatus; ///< Record for the current composite alarm status. +static ALARM_PRIORITY_RANKS_T alarmPriorityFIFO[ NUM_OF_ALARM_PRIORITIES ]; ///< FIFO - first activated or highest sub-rank alarm in each alarm priority category. -/// FIFO - first activated or highest sub-rank alarm in each alarm priority category. -static ALARM_PRIORITY_RANKS_T alarmPriorityFIFO[ NUM_OF_ALARM_PRIORITIES ]; +static BOOL alarmUserRecoveryActionEnabled[ NUMBER_OF_ALARM_USER_ACTIONS ]; ///< Alarm user recovery actions enabled flags. -/// Alarm user recovery actions enabled flags. -static BOOL alarmUserRecoveryActionEnabled[ NUMBER_OF_ALARM_USER_ACTIONS ]; - /// Current state of the alarm audio self tests. static ALARM_AUDIO_SELF_TEST_STATE_T alarmAudioSelfTestState; /// Flag indicates whether alarm audio test tone should be output. @@ -150,7 +147,7 @@ void initAlarmMgmt( void ) { ALARM_PRIORITY_T p; - ALARM_ID_T a; + ALARM_ID_T a; // Disable backup audio CLR_BACKUP_AUDIO_ENABLE(); @@ -287,7 +284,12 @@ // Broadcast alarm and data if alarm not already active if ( FALSE == alarmIsActive[ alarm ] ) { - broadcastAlarmTriggered( (U16)alarm, BLANK_ALARM_DATA, BLANK_ALARM_DATA ); + broadcastAlarmTriggered( (U16)alarm, BLANK_ALARM_DATA, BLANK_ALARM_DATA ); + // Send information for UI to log to treatment log + if ( TRUE == ALARM_TABLE[ alarm ].alarmTreatmentLog ) + { + sendTreatmentLogAlarmEventData( alarm, BLANK_ALARM_DATA, BLANK_ALARM_DATA ); + } } activateAlarm( alarm ); } @@ -308,7 +310,12 @@ // Broadcast alarm and data if alarm not already active if ( FALSE == alarmIsActive[ alarm ] ) { - broadcastAlarmTriggered( (U16)alarm, alarmData, BLANK_ALARM_DATA ); + broadcastAlarmTriggered( (U16)alarm, alarmData, BLANK_ALARM_DATA ); + // Send information for UI to log to treatment log + if ( TRUE == ALARM_TABLE[ alarm ].alarmTreatmentLog ) + { + sendTreatmentLogAlarmEventData( alarm, alarmData, BLANK_ALARM_DATA ); + } } activateAlarm( alarm ); } @@ -330,7 +337,12 @@ // Broadcast alarm and data if alarm not already active if ( FALSE == alarmIsActive[ alarm ] ) { - broadcastAlarmTriggered( (U16)alarm, alarmData1, alarmData2 ); + broadcastAlarmTriggered( (U16)alarm, alarmData1, alarmData2 ); + // Send information for UI to log to treatment log + if ( TRUE == ALARM_TABLE[ alarm ].alarmTreatmentLog ) + { + sendTreatmentLogAlarmEventData( alarm, alarmData1, alarmData2 ); + } } activateAlarm( alarm ); } @@ -507,7 +519,7 @@ break; default: - // TODO - s/w fault? + SET_ALARM_WITH_2_U32_DATA( ALARM_ID_HD_SOFTWARE_FAULT, SW_FAULT_ID_INVALID_ALARM_USER_ACTION, action ); break; } } @@ -624,6 +636,55 @@ // Send response to UI sendAlarmAudioVolumeSetResponse( accepted, rejReason ); } + +/*********************************************************************//** + * @brief +* The getNoNewTreatmentStatus function gets the persistent no new +* treatment alarm status flag. +* @details Inputs: alarmStatus.noNewTreatment +* @details Outputs: none +* @return TRUE if no new treatment allowed, otherwise FALSE +*************************************************************************/ +BOOL getNoNewTreatmentStatus( void ) +{ + return alarmStatus.noNewTreatment; +} + +/*********************************************************************//** + * @brief +* The handleActiveAlarmListRequest function processed the active alarms list +* request from UI. +* @details Inputs: alarmIsActive[] +* @details Outputs: sent active alarms list to UI +* @return none +*************************************************************************/ +void handleActiveAlarmListRequest( void ) +{ + BOOL accepted = TRUE; + REQUEST_REJECT_REASON_CODE_T rejReason = REQUEST_REJECT_REASON_NONE; + U32 activeAlarmList[ MAX_ALARM_LIST_SIZE ]; + U32 index; + U32 activeAlarmListIndex = 0; + + for ( index = 0; index < MAX_ALARM_LIST_SIZE; index++ ) + { + activeAlarmList[ index ] = ALARM_ID_NO_ALARM; + } + + if ( TRUE == isAnyAlarmActive() ) + { + for ( index = 0; index < NUM_OF_ALARM_IDS; index++ ) + { + if ( ( TRUE == isAlarmActive( ALARM_RANK_TABLE[ index ].alarmID ) ) && ( activeAlarmListIndex < MAX_ALARM_LIST_SIZE ) ) + { + activeAlarmList[ activeAlarmListIndex ] = ALARM_RANK_TABLE[ index ].alarmID; + activeAlarmListIndex++; + } + } + } + + sendActiveAlarmsList( accepted, rejReason, activeAlarmList, sizeof( activeAlarmList ) ); +} /*********************************************************************//** * @brief @@ -1034,8 +1095,8 @@ alarmStatus.noResume = noResume; alarmStatus.noRinseback = noRinseback; alarmStatus.noEndTreatment = noEndTreatment; - alarmStatus.noNewTreatment = noNewTreatment; - alarmStatus.usrACKRequired = usrAckReq; + alarmStatus.noNewTreatment |= noNewTreatment; + alarmStatus.usrACKRequired = usrAckReq; alarmStatus.noMinimize = noMinimize; }