Index: firmware/App/Services/AlarmMgmt.c =================================================================== diff -u -r848865316d989b1e541b234aefcb99891c92a481 -rd5c5b1d2bc42b166f1ccff1aa4b2441db8f06d4b --- firmware/App/Services/AlarmMgmt.c (.../AlarmMgmt.c) (revision 848865316d989b1e541b234aefcb99891c92a481) +++ firmware/App/Services/AlarmMgmt.c (.../AlarmMgmt.c) (revision d5c5b1d2bc42b166f1ccff1aa4b2441db8f06d4b) @@ -1,20 +1,19 @@ -/**********************************************************************//** - * - * Copyright (c) 2019-2020 Diality Inc. - All Rights Reserved. - * - * THIS CODE MAY NOT BE COPIED OR REPRODUCED IN ANY FORM, IN PART OR IN - * WHOLE, WITHOUT THE EXPLICIT PERMISSION OF THE COPYRIGHT OWNER. - * - * @file Timers.c - * - * @date 07-Nov-2019 - * @author S. Nash - * - * @brief Alarm Management service module. Provides general alarm management \n - * functionality including support functions for triggering and clearing \n - * specific alarms. - * - **************************************************************************/ +/************************************************************************** +* +* Copyright (c) 2019-2020 Diality Inc. - All Rights Reserved. +* +* THIS CODE MAY NOT BE COPIED OR REPRODUCED IN ANY FORM, IN PART OR IN +* WHOLE, WITHOUT THE EXPLICIT PERMISSION OF THE COPYRIGHT OWNER. +* +* @file AlarmMgmt.c +* +* @author (last) Dara Navaei +* @date (last) 06-Oct-2020 +* +* @author (original) Sean Nash +* @date (original) 07-Nov-2019 +* +***************************************************************************/ #include "mibspi.h" @@ -59,10 +58,10 @@ #pragma pack(pop) /// Table of alarms and their static properties. -const ALARM_T alarmTable[ NUM_OF_ALARM_IDS ] = +const ALARM_T alarmTable[] = { // Priority Escalate In Escalate To Fault Stops NoClr NoRes NoRin NoEnd NoNew Bypass { ALARM_PRIORITY_NONE, 0, ALARM_ID_NO_ALARM, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE }, // ALARM_ID_NO_ALARM - { ALARM_PRIORITY_HIGH, 0, ALARM_ID_NO_ALARM, TRUE , TRUE , TRUE , TRUE , TRUE , TRUE , TRUE , FALSE }, // ALARM_ID_SOFTWARE_FAULT + { ALARM_PRIORITY_HIGH, 0, ALARM_ID_NO_ALARM, TRUE , TRUE , TRUE , TRUE , TRUE , TRUE , TRUE , FALSE }, // ALARM_ID_HD_SOFTWARE_FAULT { ALARM_PRIORITY_HIGH, 0, ALARM_ID_NO_ALARM, TRUE , TRUE , TRUE , TRUE , TRUE , TRUE , TRUE , FALSE }, // ALARM_ID_STUCK_BUTTON_TEST_FAILED { ALARM_PRIORITY_HIGH, 0, ALARM_ID_NO_ALARM, TRUE , TRUE , TRUE , TRUE , TRUE , TRUE , TRUE , FALSE }, // ALARM_ID_FPGA_POST_TEST_FAILED { ALARM_PRIORITY_HIGH, 0, ALARM_ID_NO_ALARM, TRUE , TRUE , TRUE , TRUE , TRUE , TRUE , TRUE , FALSE }, // ALARM_ID_WATCHDOG_POST_TEST_FAILED @@ -119,32 +118,63 @@ { ALARM_PRIORITY_HIGH, ALM_ESC_4_MIN, ALARM_ID_BLOOD_SITTING_WARNING, FALSE, TRUE , FALSE, FALSE, FALSE, FALSE, FALSE, FALSE }, // ALARM_ID_BLOOD_PUMP_MOTOR_SPEED_CHECK { ALARM_PRIORITY_HIGH, ALM_ESC_4_MIN, ALARM_ID_BLOOD_SITTING_WARNING, FALSE, TRUE , FALSE, FALSE, FALSE, FALSE, FALSE, FALSE }, // ALARM_ID_DIAL_IN_PUMP_MOTOR_SPEED_CHECK { ALARM_PRIORITY_HIGH, ALM_ESC_4_MIN, ALARM_ID_BLOOD_SITTING_WARNING, FALSE, TRUE , FALSE, FALSE, FALSE, FALSE, FALSE, FALSE }, // ALARM_ID_DIAL_OUT_PUMP_MOTOR_SPEED_CHECK - { ALARM_PRIORITY_HIGH, ALM_ESC_4_MIN, ALARM_ID_BLOOD_SITTING_WARNING, FALSE, TRUE , FALSE, FALSE, FALSE, FALSE, FALSE, FALSE }, // ALARM_ID_BLOOD_PUMP_ROTOR_SPEED_TOO_HIGH -}; + { ALARM_PRIORITY_HIGH, ALM_ESC_4_MIN, ALARM_ID_BLOOD_SITTING_WARNING, FALSE, TRUE , FALSE, FALSE, FALSE, FALSE, FALSE, FALSE }, // ALARM_ID_BLOOD_PUMP_ROTOR_SPEED_TOO_HIGH + { ALARM_PRIORITY_MEDIUM, ALM_ESC_4_MIN, ALARM_ID_BLOOD_SITTING_WARNING, FALSE, TRUE , FALSE, FALSE, FALSE, FALSE, FALSE, FALSE }, // ALARM_ID_INLET_WATER_LOW_CONDUCTIVITY + { ALARM_PRIORITY_MEDIUM, ALM_ESC_4_MIN, ALARM_ID_BLOOD_SITTING_WARNING, FALSE, TRUE , FALSE, FALSE, FALSE, FALSE, FALSE, FALSE }, // ALARM_ID_INLET_WATER_HIGH_CONDUCTIVITY + { ALARM_PRIORITY_HIGH, 0, ALARM_ID_NO_ALARM, TRUE , TRUE , TRUE , TRUE , TRUE , TRUE , TRUE , FALSE }, // ALARM_ID_DG_SOFTWARE_FAULT + { ALARM_PRIORITY_HIGH, 0, ALARM_ID_NO_ALARM, TRUE , TRUE , TRUE , TRUE , TRUE , TRUE , TRUE , FALSE }, // ALARM_ID_CONDUCTIVITY_SENSOR_FAULT + { ALARM_PRIORITY_HIGH, 0, ALARM_ID_NO_ALARM, TRUE , TRUE , TRUE , TRUE , TRUE , TRUE , TRUE , FALSE }, // ALARM_ID_INLET_WATER_LOW_TEMPERATURE + { ALARM_PRIORITY_HIGH, 0, ALARM_ID_NO_ALARM, TRUE , TRUE , TRUE , TRUE , TRUE , TRUE , TRUE , FALSE }, // ALARM_ID_INLET_WATER_HIGH_TEMPERATURE + { ALARM_PRIORITY_HIGH, 0, ALARM_ID_NO_ALARM, TRUE , TRUE , TRUE , TRUE , TRUE , TRUE , TRUE , FALSE }, // ALARM_ID_PRESSURE_SENSOR_FAULT + { ALARM_PRIORITY_HIGH, 0, ALARM_ID_NO_ALARM, TRUE , TRUE , TRUE , TRUE , TRUE , TRUE , TRUE , FALSE }, // ALARM_ID_INLET_WATER_LOW_PRESSURE + { ALARM_PRIORITY_HIGH, 0, ALARM_ID_NO_ALARM, TRUE , TRUE , TRUE , TRUE , TRUE , TRUE , TRUE , FALSE }, // ALARM_ID_CRITICAL_DATA_ERROR + { ALARM_PRIORITY_HIGH, 0, ALARM_ID_NO_ALARM, TRUE , TRUE , TRUE , TRUE , TRUE , TRUE , TRUE , FALSE }, // ALARM_ID_HD_ACCELEROMETER_SELF_TEST_FAILURE + { ALARM_PRIORITY_HIGH, 0, ALARM_ID_NO_ALARM, TRUE , TRUE , TRUE , TRUE , TRUE , TRUE , TRUE , FALSE }, // ALARM_ID_DG_ACCELEROMETER_SELF_TEST_FAILURE + { ALARM_PRIORITY_HIGH, ALM_ESC_4_MIN, ALARM_ID_BLOOD_SITTING_WARNING, FALSE, TRUE , FALSE, FALSE, FALSE, FALSE, FALSE, FALSE }, // ALARM_ID_HD_EXCESSIVE_TILT + { ALARM_PRIORITY_HIGH, ALM_ESC_4_MIN, ALARM_ID_BLOOD_SITTING_WARNING, FALSE, TRUE , FALSE, FALSE, FALSE, FALSE, FALSE, FALSE }, // ALARM_ID_DG_EXCESSIVE_TILT + { ALARM_PRIORITY_HIGH, ALM_ESC_4_MIN, ALARM_ID_BLOOD_SITTING_WARNING, FALSE, TRUE , FALSE, FALSE, FALSE, FALSE, FALSE, FALSE }, // ALARM_ID_HD_SHOCK + { ALARM_PRIORITY_HIGH, ALM_ESC_4_MIN, ALARM_ID_BLOOD_SITTING_WARNING, FALSE, TRUE , FALSE, FALSE, FALSE, FALSE, FALSE, FALSE }, // ALARM_ID_DG_SHOCK + { ALARM_PRIORITY_HIGH, 0, ALARM_ID_NO_ALARM, TRUE , TRUE , TRUE , TRUE , TRUE , TRUE , TRUE , FALSE }, // ALARM_ID_HD_ACCELEROMETER_FAILURE + { ALARM_PRIORITY_HIGH, 0, ALARM_ID_NO_ALARM, TRUE , TRUE , TRUE , TRUE , TRUE , TRUE , TRUE , FALSE }, // ALARM_ID_DG_ACCELEROMETER_FAILURE + { ALARM_PRIORITY_HIGH, 0, ALARM_ID_NO_ALARM, TRUE , TRUE , TRUE , TRUE , TRUE , TRUE , TRUE , FALSE }, // ALARM_ID_DG_CRITICAL_DATA_ERROR + { ALARM_PRIORITY_HIGH, 0, ALARM_ID_NO_ALARM, TRUE , TRUE , TRUE , TRUE , TRUE , TRUE , TRUE , FALSE }, // ALARM_ID_RO_REJECTION_RATIO_OUT_OF_RANGE + { ALARM_PRIORITY_HIGH, 0, ALARM_ID_NO_ALARM, TRUE , TRUE , TRUE , TRUE , TRUE , TRUE , TRUE , FALSE }, // ALARM_ID_INLET_WATER_PRESSURE_FAULT + { ALARM_PRIORITY_HIGH, 0, ALARM_ID_NO_ALARM, TRUE , TRUE , TRUE , TRUE , TRUE , TRUE , TRUE , FALSE }, // ALARM_ID_HD_VALVE_HOMING_FAILED + { ALARM_PRIORITY_HIGH, 0, ALARM_ID_NO_ALARM, TRUE , TRUE , TRUE , TRUE , TRUE , TRUE , TRUE , FALSE }, // ALARM_ID_HD_VALVE_TRANSITION_TIMEOUT + { ALARM_PRIORITY_HIGH, 0, ALARM_ID_NO_ALARM, TRUE , TRUE , TRUE , TRUE , TRUE , TRUE , TRUE , FALSE }, // ALARM_ID_HD_VALVE_NOT_FUNCTIONAL + { ALARM_PRIORITY_HIGH, 0, ALARM_ID_NO_ALARM, TRUE , TRUE , TRUE , TRUE , TRUE , TRUE , TRUE , FALSE }, // ALARM_ID_HD_VALVE_CURRENT_OUT_OF_RANGE + { ALARM_PRIORITY_HIGH, 0, ALARM_ID_NO_ALARM, TRUE , TRUE , TRUE , TRUE , TRUE , TRUE , TRUE , FALSE }, // ALARM_ID_HD_VALVE_POSITION_OUT_OF_RANGE + { ALARM_PRIORITY_HIGH, 0, ALARM_ID_NO_ALARM, TRUE , TRUE , TRUE , TRUE , TRUE , TRUE , TRUE , FALSE }, // ALARM_ID_AIR_TRAP_ILLEGAL_LEVELS + { ALARM_PRIORITY_HIGH, 0, ALARM_ID_NO_ALARM, FALSE, TRUE , FALSE, FALSE, FALSE, FALSE, FALSE, TRUE }, // ALARM_ID_AIR_TRAP_FILL_DURING_PRIME + { ALARM_PRIORITY_HIGH, ALM_ESC_4_MIN, ALARM_ID_BLOOD_SITTING_WARNING, FALSE, TRUE , FALSE, FALSE, FALSE, FALSE, FALSE, TRUE }, // ALARM_ID_AIR_TRAP_FILL_DURING_TREATMENT +}; + +// *** This declaration will cause a compiler error if alarmTable does not have same # of alarms as the Alarm_List enumeration. +U08 alarmTableSizeAssertion[ ( ( sizeof( alarmTable ) / sizeof( ALARM_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 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 ********** @@ -161,13 +191,12 @@ 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 * Outputs : AlarmMgmt module initialized. - * @param none * @return none *************************************************************************/ void initAlarmMgmt( void ) @@ -209,15 +238,14 @@ alarmStatus.bypassDialyzer = FALSE; } -/************************************************************************* - * @brief execAlarmMgmt - * The execAlarmMgmt function executes the alarm management functions to be \n - * done periodically. The composite alarm state is updated, alarm lamp and \n +/*********************************************************************//** + * @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 - * @param none + * Inputs : alarmStatusTable[], alarmTable[] + * Outputs : alarmStatus * @return none *************************************************************************/ void execAlarmMgmt( void ) @@ -235,13 +263,13 @@ } } -/************************************************************************* - * @brief activateAlarm +/*********************************************************************//** + * @brief * The activateAlarm function activates a given alarm. * @details * Inputs : none * Outputs : alarmIsActive[], alarmStartedAt[] - * @param alarm : ID of alarm to activate + * @param alarm ID of alarm to activate * @return none *************************************************************************/ static void activateAlarm( ALARM_ID_T alarm ) @@ -268,20 +296,19 @@ } else { - SET_ALARM_WITH_2_U32_DATA( ALARM_ID_SOFTWARE_FAULT, SW_FAULT_ID_ALARM_MGMT_INVALID_ALARM_TO_ACTIVATE, alarm ) + SET_ALARM_WITH_2_U32_DATA( ALARM_ID_HD_SOFTWARE_FAULT, SW_FAULT_ID_ALARM_MGMT_INVALID_ALARM_TO_ACTIVATE, alarm ) } } -/************************************************************************* - * @brief activateAlarmNoData - * The activateAlarmNoData function activates a given alarm. Also, an alarm \n - * message is broadcast to the rest of the system. This function will \n +/*********************************************************************//** + * @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 + * @param alarm ID of alarm to activate * @return none *************************************************************************/ void activateAlarmNoData( ALARM_ID_T alarm ) @@ -294,26 +321,28 @@ activateAlarm( alarm ); #ifdef DEBUG_ENABLED #ifdef ALARMS_DEBUG - { - // TODO - temporary debug code - remove later - char debugStr[ 256 ]; - sprintf( debugStr, "ALARM triggered:%5d \n", alarm ); - sendDebugData( (U08*)debugStr, strlen(debugStr) ); - } + if ( FALSE == alarmIsActive[ alarm ] ) + { + // TODO - temporary debug code - remove later + char debugStr[ 256 ]; + sprintf( debugStr, "ALARM trig:%5d \n", alarm ); + sendDebugData( (U08*)debugStr, strlen(debugStr) ); + sendDebugDataToUI( (U08*)debugStr ); + } #endif #endif } -/************************************************************************* - * @brief activateAlarm1Data - * The activateAlarm1Data function activates a given alarm. Also, an alarm \n - * message is broadcast to the rest of the system. This function will \n +/*********************************************************************//** + * @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. * @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 + * @param alarm ID of alarm to activate + * @param alarmData supporting data to include in alarm msg * @return none *************************************************************************/ void activateAlarm1Data( ALARM_ID_T alarm, ALARM_DATA_T alarmData ) @@ -326,27 +355,29 @@ activateAlarm( alarm ); #ifdef DEBUG_ENABLED #ifdef ALARMS_DEBUG - { - // TODO - temporary debug code - remove later - char debugStr[ 256 ]; - sprintf( debugStr, "ALARM triggered:%5d %8X \n", alarm, alarmData.data.uInt.data ); - sendDebugData( (U08*)debugStr, strlen(debugStr) ); - } + if ( FALSE == alarmIsActive[ alarm ] ) + { + // TODO - temporary debug code - remove later + char debugStr[ 256 ]; + sprintf( debugStr, "ALARM trig:%5d %8X \n", alarm, alarmData.data.uInt.data ); + sendDebugData( (U08*)debugStr, strlen(debugStr) ); + sendDebugDataToUI( (U08*)debugStr ); + } #endif #endif } -/************************************************************************* - * @brief activateAlarm1Data - * The activateAlarm2Data function activates a given alarm. Also, an alarm \n - * message is broadcast to the rest of the system. This function will \n +/*********************************************************************//** + * @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. * @details * Inputs : none * Outputs : alarm triggered message sent, alarm activated - * @param alarm : ID of alarm to activate - * @param alarmData1 : supporting data to include in alarm msg - * @param alarmData2 : supporting data to include in alarm msg + * @param alarm ID of alarm to activate + * @param alarmData1 supporting data to include in alarm msg + * @param alarmData2 supporting data to include in alarm msg * @return none *************************************************************************/ void activateAlarm2Data( ALARM_ID_T alarm, ALARM_DATA_T alarmData1, ALARM_DATA_T alarmData2 ) @@ -359,24 +390,26 @@ activateAlarm( alarm ); #ifdef DEBUG_ENABLED #ifdef ALARMS_DEBUG - { - // TODO - temporary debug code - remove later - char debugStr[ 256 ]; - sprintf( debugStr, "ALARM triggered:%5d %8X %8X \n", (S32)alarm, alarmData1.data.uInt.data, alarmData2.data.uInt.data ); - sendDebugData( (U08*)debugStr, strlen(debugStr) ); - } + if ( FALSE == alarmIsActive[ alarm ] ) + { + // TODO - temporary debug code - remove later + char debugStr[ 256 ]; + sprintf( debugStr, "ALARM trig:%5d %8X %8X \n", (S32)alarm, alarmData1.data.uInt.data, alarmData2.data.uInt.data ); + sendDebugData( (U08*)debugStr, strlen(debugStr) ); + sendDebugDataToUI( (U08*)debugStr ); + } #endif #endif } -/************************************************************************* - * @brief clearAlarm - * The clearAlarm function clears a given alarm if it is recoverable. Also \n +/*********************************************************************//** + * @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 * Inputs : none * Outputs : AlarmStatusTable[] - * @param alarm : ID of alarm to clear + * @param alarm ID of alarm to clear * @return none *************************************************************************/ void clearAlarm( ALARM_ID_T alarm ) @@ -405,6 +438,7 @@ char debugStr[ 256 ]; sprintf( debugStr, "ALARM cleared:%5d \n", alarm ); sendDebugData( (U08*)debugStr, strlen(debugStr) ); + sendDebugDataToUI( (U08*)debugStr ); } #endif #endif @@ -413,18 +447,18 @@ } else { - SET_ALARM_WITH_2_U32_DATA( ALARM_ID_SOFTWARE_FAULT, SW_FAULT_ID_ALARM_MGMT_INVALID_ALARM_TO_CLEAR, alarm ) + SET_ALARM_WITH_2_U32_DATA( ALARM_ID_HD_SOFTWARE_FAULT, SW_FAULT_ID_ALARM_MGMT_INVALID_ALARM_TO_CLEAR, alarm ) } } -/************************************************************************* - * @brief isAlarmActive - * The isAlarmActive function determines whether a given alarm is currently \n +/*********************************************************************//** + * @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 ) @@ -434,25 +468,45 @@ 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 + * @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 ) + { + 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 - * The updateAlarmsState function updates the alarms state and alarm to \n +/*********************************************************************//** + * @brief + * The updateAlarmsState function updates the alarms state and alarm to * display. * @details * Inputs : alarmStatusTable[] * Outputs : alarmPriorityFIFO[], alarmStatus - * @param none * @return none *************************************************************************/ static void updateAlarmsState( void ) @@ -485,14 +539,13 @@ alarmStatus.systemFault = faultsActive; } -/************************************************************************* - * @brief setAlarmLampAndAudio - * The setAlarmLampAndAudio function sets the alarm lamp and audio patterns \n +/*********************************************************************//** + * @brief + * The setAlarmLampAndAudio function sets the alarm lamp and audio patterns * according to the current state of alarms. * @details * Inputs : none * Outputs : Alarm lamp patter set according to current alarms status. - * @param none * @return none *************************************************************************/ static void setAlarmLampAndAudio( void ) @@ -526,7 +579,7 @@ default: requestAlarmLampPattern( LAMP_PATTERN_FAULT ); - SET_ALARM_WITH_2_U32_DATA( ALARM_ID_SOFTWARE_FAULT, SW_FAULT_ID_ALARM_MGMT_LAMP_INVALID_ALARM_STATE, alarmStatus.alarmsState ) + SET_ALARM_WITH_2_U32_DATA( ALARM_ID_HD_SOFTWARE_FAULT, SW_FAULT_ID_ALARM_MGMT_LAMP_INVALID_ALARM_STATE, alarmStatus.alarmsState ) break; } } @@ -557,19 +610,18 @@ default: // TODO - high priority audio - SET_ALARM_WITH_2_U32_DATA( ALARM_ID_SOFTWARE_FAULT, SW_FAULT_ID_ALARM_MGMT_LAMP_INVALID_ALARM_STATE, alarmStatus.alarmsState ) + SET_ALARM_WITH_2_U32_DATA( ALARM_ID_HD_SOFTWARE_FAULT, SW_FAULT_ID_ALARM_MGMT_LAMP_INVALID_ALARM_STATE, alarmStatus.alarmsState ) break; } } } -/************************************************************************* - * @brief updateAlarmsSilenceStatus +/*********************************************************************//** + * @brief * The updateAlarmsSilenceStatus function updates the alarms silence state. * @details * Inputs : alarmStatus * Outputs : alarmStatus - * @param none * @return none *************************************************************************/ static void updateAlarmsSilenceStatus( void ) @@ -600,13 +652,12 @@ } } -/************************************************************************* - * @brief handleAlarmEscalations +/*********************************************************************//** + * @brief * The handleAlarmEscalations function handles alarm escalation. * @details - * Inputs : none - * Outputs : none - * @param none + * Inputs : alarmIsActive[], alarmTable[] + * Outputs : alarm(s) escalated when appropriate * @return none *************************************************************************/ static void handleAlarmEscalations( void ) @@ -663,14 +714,13 @@ } } -/************************************************************************* - * @brief updateAlarmsFlags - * The updateAlarmsFlags function updates the alarms flags of the alarms \n +/*********************************************************************//** + * @brief + * The updateAlarmsFlags function updates the alarms flags of the alarms * status record. * @details * Inputs : none - * Outputs : none - * @param none + * Outputs : alarmStatus * @return none *************************************************************************/ static void updateAlarmsFlags( void ) @@ -719,14 +769,14 @@ alarmStatus.bypassDialyzer = bypassDialyzer; } -/************************************************************************* - * @brief resetAlarmPriorityFIFO - * The resetAlarmPriorityFIFO function resets a FIFO for a given alarm \n +/*********************************************************************//** + * @brief + * The resetAlarmPriorityFIFO function resets a FIFO for a given alarm * priority. * @details * Inputs : none * Outputs : alarmPriorityFIFO[] - * @param priority : priority of FIFO to reset + * @param priority priority of FIFO to reset * @return none *************************************************************************/ static void resetAlarmPriorityFIFO( ALARM_PRIORITY_T priority ) @@ -738,38 +788,45 @@ } else { - SET_ALARM_WITH_2_U32_DATA( ALARM_ID_SOFTWARE_FAULT, SW_FAULT_ID_ALARM_MGMT_INVALID_FIFO_TO_RESET, priority ) + SET_ALARM_WITH_2_U32_DATA( ALARM_ID_HD_SOFTWARE_FAULT, SW_FAULT_ID_ALARM_MGMT_INVALID_FIFO_TO_RESET, priority ) } } -/************************************************************************* - * @brief getPublishAlarmStatusInterval - * The getPublishAlarmStatusInterval function gets the alarm status \n +/*********************************************************************//** + * @brief + * The getPublishAlarmStatusInterval function gets the alarm status * publication interval. * @details * Inputs : alarmStatusPublishInterval * Outputs : none - * @param 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 - * The testSetAlarmStatusPublishIntervalOverride function overrides the \n +/*********************************************************************//** + * @brief + * The testSetAlarmStatusPublishIntervalOverride function overrides the * alarm status publish interval. * @details * Inputs : none * Outputs : alarmStatusPublishInterval - * @param value : override blood flow data publish interval with (in ms) + * @param value override blood flow data publish interval with (in ms) * @return TRUE if override successful, FALSE if not *************************************************************************/ BOOL testSetAlarmStatusPublishIntervalOverride( U32 value ) @@ -788,9 +845,9 @@ return result; } -/************************************************************************* - * @brief testResetAlarmStatusPublishIntervalOverride - * The testResetAlarmStatusPublishIntervalOverride function resets the override \n +/*********************************************************************//** + * @brief + * The testResetAlarmStatusPublishIntervalOverride function resets the override * of the alarm status publish interval. * @details * Inputs : none @@ -811,16 +868,16 @@ return result; } -/************************************************************************* +/*********************************************************************//** * @brief - * The testSetAlarmStateOverride function overrides the state of the \n - * alarm active state for a given alarm with the alarm management with \n + * 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 * 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) + * @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 ) @@ -846,14 +903,14 @@ return result; } -/************************************************************************* +/*********************************************************************//** * @brief - * The testResetAlarmStateOverride function resets the override of the \n + * The testResetAlarmStateOverride function resets the override of the * state of the active state for a given alarm with the alarm management. * @details * Inputs : none * Outputs : alarm cleared - * @param alarmID : ID of alarm to clear + * @param alarmID ID of alarm to clear * @return TRUE if alarm clear successful, FALSE if not *************************************************************************/ BOOL testResetAlarmStateOverride( U32 alarmID ) @@ -872,15 +929,15 @@ return result; } -/************************************************************************* - * @brief testSetAlarmStartOverride - * The testSetAlarmStartOverride function overrides the start time \n - * for a given alarm with the alarm management with a given start time. \n +/*********************************************************************//** + * @brief + * The testSetAlarmStartOverride function overrides the start time + * for a given alarm with the alarm management with a given start time. * @details * Inputs : none * Outputs : alarmStartedAt[] - * @param alarmID : ID of alarm to override start time for - * @param value : override time since start (in ms) for the given alarm ID + * @param alarmID ID of alarm to override start time for + * @param value override time since start (in ms) for the given alarm ID * @return TRUE if override successful, FALSE if not *************************************************************************/ BOOL testSetAlarmStartOverride( U32 alarmID, U32 value ) @@ -905,14 +962,14 @@ return result; } -/************************************************************************* - * @brief testResetAlarmStartOverride - * The testResetAlarmStartOverride function resets the override of the \n +/*********************************************************************//** + * @brief + * The testResetAlarmStartOverride function resets the override of the * start time for a given alarm with the alarm management. * @details * Inputs : none * Outputs : alarmStartedAt[] - * @param alarmID : ID of alarm to reset override of start time for + * @param alarmID ID of alarm to reset override of start time for * @return TRUE if override reset successful, FALSE if not *************************************************************************/ BOOL testResetAlarmStartOverride( U32 alarmID ) @@ -931,5 +988,5 @@ return result; } - - + +/**@}*/