Index: firmware/App/Services/AlarmMgmt.c =================================================================== diff -u -r4459be59bdc2896b44bcf6cd42d2762190e23c16 -r8dad6fab1c33602ad94908fd31b8b15153a9eb6e --- firmware/App/Services/AlarmMgmt.c (.../AlarmMgmt.c) (revision 4459be59bdc2896b44bcf6cd42d2762190e23c16) +++ firmware/App/Services/AlarmMgmt.c (.../AlarmMgmt.c) (revision 8dad6fab1c33602ad94908fd31b8b15153a9eb6e) @@ -144,25 +144,25 @@ const ALARM_DATA_T blankAlarmData = { ALARM_DATA_TYPE_NONE, 0 }; // pin assignment for backup alarm audio enable -#define BACKUP_AUDIO_ENABLE_SPI3_PORT_MASK 0x00000001 // (SPI3-CS0 - re-purposed as output GPIO) +#define BACKUP_AUDIO_ENABLE_SPI3_PORT_MASK 0x00000001 ///< pin SPI3-CS0 - re-purposed as output GPIO for back audio enable. // backup alarm audio enable/disable macros -#define SET_BACKUP_AUDIO_ENABLE() {mibspiREG3->PC3 |= BACKUP_AUDIO_ENABLE_SPI3_PORT_MASK;} -#define CLR_BACKUP_AUDIO_ENABLE() {mibspiREG3->PC3 &= ~BACKUP_AUDIO_ENABLE_SPI3_PORT_MASK;} +#define SET_BACKUP_AUDIO_ENABLE() {mibspiREG3->PC3 |= BACKUP_AUDIO_ENABLE_SPI3_PORT_MASK;} ///< Macro to enable backup alarm audio. +#define CLR_BACKUP_AUDIO_ENABLE() {mibspiREG3->PC3 &= ~BACKUP_AUDIO_ENABLE_SPI3_PORT_MASK;} ///< Macro to disable backup alarm audio. // ********** private data ********** /// interval (in ms) at which to publish alarm status to CAN bus DATA_DECL( U32, AlarmStatusPub, alarmStatusPublishInterval, ALARM_STATUS_PUBLISH_INTERVAL, ALARM_STATUS_PUBLISH_INTERVAL ); -static U32 alarmStatusPublicationTimerCounter = 0; ///< Used to schedule alarm status publication to CAN bus. +static U32 alarmStatusPublicationTimerCounter = 0; ///< Used to schedule alarm status publication to CAN bus. /// table - current state of each alarm static BOOL alarmIsActive[ NUM_OF_ALARM_IDS ]; /// table - when alarm became active for each alarm (if active) or zero (if inactive) DATA_ARRAY_DECL( U32, AlarmStarts, NUM_OF_ALARM_IDS, alarmStartedAt ); -static COMP_ALARM_STATUS_T alarmStatus; ///< Record for the current composite alarm status. +static COMP_ALARM_STATUS_T alarmStatus; ///< Record for the current composite alarm status. -static ALARM_ID_T alarmPriorityFIFO[ NUM_OF_ALARM_PRIORITIES ]; +static ALARM_ID_T alarmPriorityFIFO[ NUM_OF_ALARM_PRIORITIES ]; ///< FIFO - first activated alarm in each alarm priority category. // ********** private function prototypes ********** @@ -179,8 +179,8 @@ static DATA_ARRAY_GET_PROTOTYPE( U32, getAlarmStartTime, alarmID ); static DATA_GET_PROTOTYPE( U32, getPublishAlarmStatusInterval ); -/************************************************************************* - * @brief initAlarmMgmt +/*********************************************************************//** + * @brief * The initAlarmMgmt function initializes the AlarmMgmt module. * @details * Inputs : none @@ -226,14 +226,14 @@ alarmStatus.bypassDialyzer = FALSE; } -/************************************************************************* - * @brief execAlarmMgmt +/*********************************************************************//** + * @brief * The execAlarmMgmt function executes the alarm management functions to be * done periodically. The composite alarm state is updated, alarm lamp and * audio patterns are updated, and status is sent out to the rest of the system. * @details - * Inputs : larmStatusTable[], alarmTable[] - * Outputs : larmStatus + * Inputs : alarmStatusTable[], alarmTable[] + * Outputs : alarmStatus * @return none *************************************************************************/ void execAlarmMgmt( void ) @@ -251,8 +251,8 @@ } } -/************************************************************************* - * @brief activateAlarm +/*********************************************************************//** + * @brief * The activateAlarm function activates a given alarm. * @details * Inputs : none @@ -288,16 +288,15 @@ } } -/************************************************************************* - * @brief activateAlarmNoData +/*********************************************************************//** + * @brief * The activateAlarmNoData function activates a given alarm. Also, 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 * Outputs : alarm triggered message sent, alarm activated * @param alarm ID of alarm to activate - * @param alarmData supporting data to include in alarm msg * @return none *************************************************************************/ void activateAlarmNoData( ALARM_ID_T alarm ) @@ -322,8 +321,8 @@ #endif } -/************************************************************************* - * @brief activateAlarm1Data +/*********************************************************************//** + * @brief * The activateAlarm1Data function activates a given alarm. Also, an alarm * message is broadcast to the rest of the system. This function will * include given data in the broadcast message for logging. @@ -356,8 +355,8 @@ #endif } -/************************************************************************* - * @brief activateAlarm1Data +/*********************************************************************//** + * @brief * The activateAlarm2Data function activates a given alarm. Also, an alarm * message is broadcast to the rest of the system. This function will * include two given data in the broadcast message for logging. @@ -391,8 +390,8 @@ #endif } -/************************************************************************* - * @brief clearAlarm +/*********************************************************************//** + * @brief * The clearAlarm function clears a given alarm if it is recoverable. Also * an alarm message is broadcast to the rest of the system. * @details @@ -440,14 +439,14 @@ } } -/************************************************************************* - * @brief isAlarmActive +/*********************************************************************//** + * @brief * The isAlarmActive function determines whether a given alarm is currently * active. * @details * Inputs : alarmIsActive[] * Outputs : none - * @param alarmID ID of alarm to check + * @param alarm ID of alarm to check * @return TRUE if given alarm is active, FALSE if not *************************************************************************/ BOOL isAlarmActive( ALARM_ID_T alarm ) @@ -457,19 +456,40 @@ return result; } -/************************************************************************* - * @brief getAlarmStartTime +/*********************************************************************//** + * @brief * The getAlarmStartTime function gets the active state of a given alarm. * @details * Inputs : alarmStartedAt[] * Outputs : none * @param alarmID ID of alarm to check * @return The start time stamp of given alarm ID *************************************************************************/ -static DATA_ARRAY_GET( U32, getAlarmStartTime, alarmID, NUM_OF_ALARM_IDS-1, alarmStartedAt, 0 ) +U32 getAlarmStartTime( U32 alarmID ) +{ + U32 result = 0; + + if ( alarmID <= NUM_OF_ALARM_IDS-1 ) + { + if ( OVERRIDE_KEY == alarmStartedAt[ alarmID ].override ) + { + result = alarmStartedAt[ alarmID ].ovData; + } + else + { + result = alarmStartedAt[ alarmID ].data; + } + } + else + { + activateAlarmNoData( ALARM_ID_HD_SOFTWARE_FAULT ); + } + + return result; +} -/************************************************************************* - * @brief updateAlarmsState +/*********************************************************************//** + * @brief * The updateAlarmsState function updates the alarms state and alarm to * display. * @details @@ -507,8 +527,8 @@ alarmStatus.systemFault = faultsActive; } -/************************************************************************* - * @brief setAlarmLampAndAudio +/*********************************************************************//** + * @brief * The setAlarmLampAndAudio function sets the alarm lamp and audio patterns * according to the current state of alarms. * @details @@ -584,8 +604,8 @@ } } -/************************************************************************* - * @brief updateAlarmsSilenceStatus +/*********************************************************************//** + * @brief * The updateAlarmsSilenceStatus function updates the alarms silence state. * @details * Inputs : alarmStatus @@ -620,12 +640,12 @@ } } -/************************************************************************* - * @brief handleAlarmEscalations +/*********************************************************************//** + * @brief * The handleAlarmEscalations function handles alarm escalation. * @details - * Inputs : none - * Outputs : none + * Inputs : alarmIsActive[], alarmTable[] + * Outputs : alarm(s) escalated when appropriate * @return none *************************************************************************/ static void handleAlarmEscalations( void ) @@ -682,13 +702,13 @@ } } -/************************************************************************* - * @brief updateAlarmsFlags +/*********************************************************************//** + * @brief * The updateAlarmsFlags function updates the alarms flags of the alarms * status record. * @details * Inputs : none - * Outputs : none + * Outputs : alarmStatus * @return none *************************************************************************/ static void updateAlarmsFlags( void ) @@ -737,8 +757,8 @@ alarmStatus.bypassDialyzer = bypassDialyzer; } -/************************************************************************* - * @brief resetAlarmPriorityFIFO +/*********************************************************************//** + * @brief * The resetAlarmPriorityFIFO function resets a FIFO for a given alarm * priority. * @details @@ -760,27 +780,35 @@ } } -/************************************************************************* - * @brief getPublishAlarmStatusInterval +/*********************************************************************//** + * @brief * The getPublishAlarmStatusInterval function gets the alarm status * publication interval. * @details * Inputs : alarmStatusPublishInterval * Outputs : none * @return the current alarm status publication interval (in ms). *************************************************************************/ -DATA_GET( U32, getPublishAlarmStatusInterval, alarmStatusPublishInterval ) +U32 getPublishAlarmStatusInterval( void ) +{ + U32 result = alarmStatusPublishInterval.data; + + if ( OVERRIDE_KEY == alarmStatusPublishInterval.override ) + { + result = alarmStatusPublishInterval.ovData; + } + + return result; +} -/**@}*/ - /************************************************************************* * TEST SUPPORT FUNCTIONS *************************************************************************/ -/************************************************************************* - * @brief testSetAlarmStatusPublishIntervalOverride +/*********************************************************************//** + * @brief * The testSetAlarmStatusPublishIntervalOverride function overrides the * alarm status publish interval. * @details @@ -805,8 +833,8 @@ return result; } -/************************************************************************* - * @brief testResetAlarmStatusPublishIntervalOverride +/*********************************************************************//** + * @brief * The testResetAlarmStatusPublishIntervalOverride function resets the override * of the alarm status publish interval. * @details @@ -828,7 +856,7 @@ return result; } -/************************************************************************* +/*********************************************************************//** * @brief * The testSetAlarmStateOverride function overrides the state of the * alarm active state for a given alarm with the alarm management with @@ -863,7 +891,7 @@ return result; } -/************************************************************************* +/*********************************************************************//** * @brief * The testResetAlarmStateOverride function resets the override of the * state of the active state for a given alarm with the alarm management. @@ -889,8 +917,8 @@ return result; } -/************************************************************************* - * @brief testSetAlarmStartOverride +/*********************************************************************//** + * @brief * The testSetAlarmStartOverride function overrides the start time * for a given alarm with the alarm management with a given start time. * @details @@ -922,8 +950,8 @@ return result; } -/************************************************************************* - * @brief testResetAlarmStartOverride +/*********************************************************************//** + * @brief * The testResetAlarmStartOverride function resets the override of the * start time for a given alarm with the alarm management. * @details @@ -948,5 +976,5 @@ return result; } - - + +/**@}*/