Index: firmware/App/Drivers/GPIO.c =================================================================== diff -u -r3518e8a088c32e75c0c8960d5e629a7401095feb -re8654d6ebf2c76c6bae8e1b465cc1382d205832a --- firmware/App/Drivers/GPIO.c (.../GPIO.c) (revision 3518e8a088c32e75c0c8960d5e629a7401095feb) +++ firmware/App/Drivers/GPIO.c (.../GPIO.c) (revision e8654d6ebf2c76c6bae8e1b465cc1382d205832a) @@ -79,6 +79,12 @@ #define SET_SAFETY_SHUTDOWN() gioSetBit( gioPORTB, SAFETY_GIO_PORT_PIN, PIN_SIGNAL_HIGH ) #define CLR_SAFETY_SHUTDOWN() gioSetBit( gioPORTB, SAFETY_GIO_PORT_PIN, PIN_SIGNAL_LOW ) +/// Pin SPI3-CS0 - re-purposed as output GPIO for backup alarm audio enable. +#define BACKUP_AUDIO_ENABLE_SPI3_PORT_MASK 0x00000001 +// Backup alarm audio enable/disable macros +#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. + /*********************************************************************//** * @brief * The toggleWatchdogPetSignal function toggles the watchdog pet output @@ -321,4 +327,30 @@ return signal; } +/*********************************************************************//** + * @brief + * The setAlarmBuzzerSignal function sets the alarm buzzer output signal + * on its GPIO pin to HIGH. + * @details \b Inputs: none + * @details \b Outputs: Alarm buzzer output signal set high + * @return none + *************************************************************************/ +void setAlarmBuzzerSignal( void ) +{ + SET_BACKUP_AUDIO_ENABLE() +} + +/*********************************************************************//** + * @brief + * The clrAlarmBuzzerSignal function sets the alarm buzzer output signal + * on its GPIO pin to LOW. + * @details \b Inputs: none + * @details \b Outputs: Alarm buzzer output signal set low + * @return none + *************************************************************************/ +void clrAlarmBuzzerSignal( void ) +{ + CLR_BACKUP_AUDIO_ENABLE() +} + /**@}*/ Index: firmware/App/Drivers/GPIO.h =================================================================== diff -u -r3518e8a088c32e75c0c8960d5e629a7401095feb -re8654d6ebf2c76c6bae8e1b465cc1382d205832a --- firmware/App/Drivers/GPIO.h (.../GPIO.h) (revision 3518e8a088c32e75c0c8960d5e629a7401095feb) +++ firmware/App/Drivers/GPIO.h (.../GPIO.h) (revision e8654d6ebf2c76c6bae8e1b465cc1382d205832a) @@ -54,6 +54,9 @@ PIN_SIGNAL_STATE_T getOffButtonSignal( void ); PIN_SIGNAL_STATE_T getStopButtonSignal( void ); +void setAlarmBuzzerSignal( void ); +void clrAlarmBuzzerSignal( void ); + /**@}*/ #endif Index: firmware/App/Services/AlarmMgmtTD.c =================================================================== diff -u -r3518e8a088c32e75c0c8960d5e629a7401095feb -re8654d6ebf2c76c6bae8e1b465cc1382d205832a --- firmware/App/Services/AlarmMgmtTD.c (.../AlarmMgmtTD.c) (revision 3518e8a088c32e75c0c8960d5e629a7401095feb) +++ firmware/App/Services/AlarmMgmtTD.c (.../AlarmMgmtTD.c) (revision e8654d6ebf2c76c6bae8e1b465cc1382d205832a) @@ -17,11 +17,8 @@ #include "mibspi.h" -#include "AlarmLamp.h" #include "AlarmMgmtTD.h" -//#include "CPLD.h" -//#include "FPGA.h" -//#include "InternalADC.h" +#include "CpldInterface.h" #include "Messaging.h" #include "OperationModes.h" #include "TaskGeneral.h" @@ -55,19 +52,6 @@ /// 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 }; -/// Pin SPI3-CS0 - re-purposed as output GPIO for backup alarm audio enable. -#define BACKUP_AUDIO_ENABLE_SPI3_PORT_MASK 0x00000001 -// Backup alarm audio enable/disable macros -#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. - -#define ALARM_AUDIO_TEST_TONE 4 ///< Alarm audio state for continuous test tone. -#define ALARM_AUDIO_CURRENT_LG_MIN_MA 50.0F ///< Minimum audio current (low gain) during test tone self-test (in mA). -#define ALARM_AUDIO_CURRENT_LG_MAX_MA 20.0F ///< Maximum audio current (low gain) during no tone self-test (in mA). -#define ALARM_AUDIO_MAX_TEST_TIME_MS 1000 ///< Maximum time for audio current to reach threshold in test. -#define MAX_ALARM_AUDIO_VOLUME_INDEX 0 ///< Index for maximum alarm audio volume. -#define MIN_ALARM_AUDIO_VOLUME_INDEX (MAX_ALARM_VOLUME_LEVEL - 1 ) ///< Index for minimum alarm audio volume. - /// Alarm priority ranking record. typedef struct { @@ -76,39 +60,11 @@ S32 timeSinceTriggeredMS; ///< Time (in ms) since this alarm was triggered } ALARM_PRIORITY_RANKS_T; -/// Enumeration of alarm audio self-test states. -typedef enum Alarm_Audio_Self_Test_States -{ - ALARM_AUDIO_SELF_TEST_STATE_START = 0, ///< Start state of alarm audio self-test. - ALARM_AUDIO_SELF_TEST_STATE_PRIMARY, ///< Test tone state of alarm audio self-test. - ALARM_AUDIO_SELF_TEST_STATE_NO_TONE, ///< No tone state of alarm audio self-test. - ALARM_AUDIO_SELF_TEST_STATE_COMPLETE, ///< Completed state of alarm audio self-test. - NUM_OF_ALARM_AUDIO_SELF_TEST_STATES ///< Number of states in alarm audio self-test. -} ALARM_AUDIO_SELF_TEST_STATE_T; - -/// Enumeration of alarm audio volume factors. -typedef enum Alarm_Audio_Volume_Factors -{ - ALARM_AUDIO_VOLUME_GAIN = 0, ///< Gain setting for alarm audio volume. - ALARM_AUDIO_VOLUME_DIVIDER, ///< Divider setting for alarm audio volume. - NUM_OF_ALARM_AUDIO_VOLUME_FACTORS ///< Number of alarm audio volume factors. -} ALARM_AUDIO_VOLUME_FACTOR_T; - -/// Lookup table to determine appropriate divider for a given alarm audio volume level. -const U08 ALARM_AUDIO_DIVIDER_LOOKUP_TABLE[MAX_ALARM_VOLUME_LEVEL][NUM_OF_ALARM_AUDIO_VOLUME_FACTORS] = { - { 1, 0 }, - { 1, 1 }, - { 3, 1 }, - { 3, 2 }, - { 4, 2 } -}; - // ********** private data ********** 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. -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 lastUserAlarmActionReceivedTime = 0; ///< Time of last alarm action by user received from the UI (ms timestamp). @@ -118,25 +74,13 @@ /// 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 }; -/// Alarm audio attenuation level (0..4 where 0 = max volume and 4 = min volume). -static OVERRIDE_U32_T alarmAudioVolumeLevel = { MAX_ALARM_VOLUME_ATTENUATION, MAX_ALARM_VOLUME_ATTENUATION, MAX_ALARM_VOLUME_ATTENUATION, 0 }; - -static OVERRIDE_F32_T alarmPrimaryAudioCurrentHG = { 0.0, 0.0, 0.0, 0 }; ///< Alarm audio current (high gain) measured at ADC. - -static OVERRIDE_F32_T alarmPrimaryAudioCurrentLG = { 0.0, 0.0, 0.0, 0 }; ///< Alarm audio current (low gain) measured at ADC. - -static OVERRIDE_F32_T alarmBackupAudioCurrent = { 0.0, 0.0, 0.0, 0 }; ///< Alarm backup audio current measured at ADC. - 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. static BOOL alarmUserRecoveryActionEnabled[ NUMBER_OF_ALARM_USER_ACTIONS ]; ///< Alarm user recovery actions enabled flags. static BOOL alarmButtonBlockers[ NUM_OF_ALARM_BUTTON_BLOCKERS ]; ///< Flags indicating whether alarm table or state properties are blocking alarm buttons for UI. -static ALARM_AUDIO_SELF_TEST_STATE_T alarmAudioSelfTestState; ///< Current state of the alarm audio self tests. - -static BOOL alarmAudioTestToneRequested; ///< Flag indicates whether alarm audio test tone should be output. static BOOL resumeBlockedByAlarmProperty; ///< Flag indicates whether treatment resumption is currently blocked by alarm property. // ********** private function prototypes ********** @@ -146,7 +90,6 @@ static void monitorAlarms( void ); static void updateAlarmsState( void ); static void setAlarmLamp( void ); -static void setAlarmAudio( void ); static void updateAlarmsSilenceStatus( void ); static void updateAlarmsFlags( void ); @@ -159,20 +102,20 @@ /*********************************************************************//** * @brief - * The initAlarmMgmtTD function initializes the AlarmMgmt unit. - * @details Inputs: none - * @details Outputs: AlarmMgmtTD unit initialized. + * The initAlarmMgmtTD function initializes the TD AlarmMgmt unit. + * @details \b Inputs: none + * @details \b Outputs: TD AlarmMgmt unit initialized. * @return none *************************************************************************/ void initAlarmMgmtTD( void ) { ALARM_PRIORITY_T p; ALARM_ID_T a; ALARM_BUTTON_BLOCKER_T b; - - // Disable backup audio - CLR_BACKUP_AUDIO_ENABLE(); + // Initialize alarm audio + initAlarmAudio(); + // Initialize common alarm mgmt unit initAlarmMgmt(); @@ -218,18 +161,17 @@ alarmsBlockedTimer = 0; lastUserAlarmActionReceivedTime = 0; - alarmAudioTestToneRequested = FALSE; resumeBlockedByAlarmProperty = FALSE; - alarmAudioSelfTestState = ALARM_AUDIO_SELF_TEST_STATE_START; } /*********************************************************************//** * @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: none - * @details Outputs: none + * The execAlarmMgmt function executes the TD alarm management functions to be + * done periodically. The system alarm state is updated, alarm lamp and + * audio patterns are updated, and the state of the alarm system is sent out + * to the rest of the system. + * @details \b Inputs: alarmsBlockedTimer + * @details \b Outputs: alarmsBlockedTimer * @return none *************************************************************************/ void execAlarmMgmt( void ) @@ -250,9 +192,14 @@ /*********************************************************************//** * @brief - * The activateAlarmTD function activates a given TD alarm. - * @details Inputs: none - * @details Outputs: alarmIsActive[], alarmStartedAt[], alarmStatus is updated + * The activateAlarmTD function activates a given alarm. If alarm system + * is silenced, it will no longer be. The "top" alarm is set to given + * alarm if it is highest in priority/rank. If the alarm is a fault, we + * will transition to fault mode. If the alarm is meant to stop activity, + * a stop signal is sent to the current operating mode. + * @details \b Alarm: ALARM_ID_TD_SOFTWARE_FAULT if given alarm ID is invalid. + * @details \b Inputs: none + * @details \b Outputs: alarmIsActive[], alarmStartedAt[], alarmStatus is updated * @param alarm ID of alarm to activate * @return none *************************************************************************/ @@ -308,11 +255,10 @@ /*********************************************************************//** * @brief - * The clearAlarmTD function clears a given TDalarm if it is recoverable. - * Also an alarm message is broadcast to the rest of the system. - * @details Inputs: none - * @details Outputs: AlarmStatusTable[], alarmIsActive[], alarmStartedAt[], - * alarmIsDetected[] + * The clearAlarmTD function clears a given alarm if it is recoverable. + * @details \b Alarm: ALARM_ID_TD_SOFTWARE_FAULT if given alarm ID is invalid. + * @details \b Inputs: none + * @details \b Outputs: alarmStartedAt[], * @param alarm ID of alarm to clear * @return none *************************************************************************/ @@ -342,11 +288,10 @@ /*********************************************************************//** * @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 - * @details Outputs: alarm triggered message sent, alarm activated + * The activateAlarmNoData function activates a given alarm. The alarm + * data that gets logged with this alarm will be blank. + * @details \b Inputs: none + * @details \b Outputs: Alarm is activated * @param alarm ID of alarm to activate * @return none *************************************************************************/ @@ -357,13 +302,12 @@ /*********************************************************************//** * @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 - * @details Outputs: alarm triggered message sent, alarm activated + * The activateAlarm1Data function activates a given alarm. The one given + * alarm data will be logged with this alarm as well as a second blank data. + * @details \b Inputs: none + * @details \b Outputs: Alarm is activated * @param alarm ID of alarm to activate - * @param alarmData supporting data to include in alarm msg + * @param alarmData First supporting data to include in alarm message * @return none *************************************************************************/ void activateAlarm1Data( ALARM_ID_T alarm, ALARM_DATA_T alarmData ) @@ -373,15 +317,16 @@ /*********************************************************************//** * @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: alarmsBlockedTimer, determines blocked alarm conditions - * @details Outputs: alarm triggered message sent, alarm activated + * The activateAlarm2Data function activates a given alarm. The two given + * alarm data will be logged with this alarm. + * @details \b Message \b Sent: MSG_ID_ALARM_TRIGGERED + * @details \b Alarm: ALARM_ID_TD_SOFTWARE_FAULT if given alarm ID is invalid. + * @details \b Inputs: alarmsBlockedTimer, determines blocked alarm conditions + * @details \b Outputs: Alarm is 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 outside flag indicates whether alarm is originating from outside HD f/w + * @param alarmData1 First supporting data to include in alarm message + * @param alarmData2 Second supporting data to include in alarm message + * @param outside flag indicates whether alarm is originating from outside TD f/w * @return none *************************************************************************/ void activateAlarm2Data( ALARM_ID_T alarm, ALARM_DATA_T alarmData1, ALARM_DATA_T alarmData2, BOOL outside ) @@ -396,9 +341,9 @@ { // 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 ) -// || ( ALARM_ID_HD_DG_RESTARTED_FAULT == alarm ) ) +// || ( ALARM_ID_TD_AC_POWER_LOST == alarm ) +// || ( ALARM_ID_TD_AC_POWER_LOST_IN_TREATMENT == alarm ) +// || ( ALARM_ID_TD_DD_RESTARTED_FAULT == alarm ) ) { TD_OP_MODE_T opMode = getCurrentOperationMode(); // TREATMENT_STATE_T ts = getTreatmentState(); @@ -448,12 +393,14 @@ /*********************************************************************//** * @brief * The setAlarmUserActionEnabled function enables/disables specific alarm - * recovery user actions while in specific modes. Ack option is always - * potentially enabled - automatically enabled as appropriate by updateAlarmsFlags(). - * @details Inputs: none - * @details Outputs: + * recovery user actions while in specific modes. + * @note The Ack option is always potentially enabled - automatically enabled + * as appropriate by updateAlarmsFlags(). + * @details \b Alarm: ALARM_ID_TD_SOFTWARE_FAULT if given alarm action is invalid. + * @details \b Inputs: none + * @details \b Outputs: alarmUserRecoveryActionEnabled[] * @param action ID of user alarm recovery action to enable/disable - * @param enabled set to TRUE to enable action, FALSE to disable + * @param enabled Set to TRUE to enable action, FALSE to disable it * @return none *************************************************************************/ void setAlarmUserActionEnabled( ALARM_USER_ACTION_T action, BOOL enabled ) @@ -470,11 +417,11 @@ /*********************************************************************//** * @brief - * The signalAlarmSilence function handles an alarm silence request from + * The signalAlarmSilence function executes an alarm silence request from * the user. - * @details Inputs: none - * @details Outputs: alarm silence status updated - * @param cmd ID of user command (1=silence, 0=cancel silence) + * @details \b Inputs: alarmStatus.alarmsSilenced + * @details \b Outputs: alarmStatus.alarmsSilenced + * @param cmd ID of alarm silence request type (1=silence, 0=cancel silence) * @return none *************************************************************************/ void signalAlarmSilence( ALARM_SILENCE_CMD_T cmd ) @@ -502,12 +449,15 @@ /*********************************************************************//** * @brief * The signalAlarmUserActionInitiated function clears all non-recoverable alarms - * and initiates selected user action. User actions are debounced (must come - * at least 1 second after last). And user actions must be appropriate for current + * (or just the top alarm if it is recoverable and clear-only) and then executes + * the given user action. + * @note User actions are debounced (must come at least 1 second after last + * received user action). And user actions must be appropriate for current * alarm state. - * @details Inputs: ALARM_TABLE[], alarmStatus, lastUserAlarmActionReceivedTime - * @details Outputs: alarmIsActive[], lastUserAlarmActionReceivedTime - * @param action ID of user's selected action to initiate + * @details \b Alarm: ALARM_ID_TD_SOFTWARE_FAULT if given user action is invalid. + * @details \b Inputs: ALARM_TABLE[], alarmStatus, lastUserAlarmActionReceivedTime + * @details \b Outputs: alarmIsActive[], lastUserAlarmActionReceivedTime + * @param action ID of given user action to execute * @return none *************************************************************************/ void signalAlarmUserActionInitiated( ALARM_USER_ACTION_T action ) @@ -620,8 +570,8 @@ * @brief * The isAnyAlarmActive function determines whether any alarm is currently * active. - * @details Inputs: alarmStatus - * @details Outputs: none + * @details \b Inputs: alarmStatus + * @details \b Outputs: none * @return TRUE if any alarm is active, FALSE if not *************************************************************************/ BOOL isAnyAlarmActive( void ) @@ -633,10 +583,23 @@ /*********************************************************************//** * @brief + * The areAlarmsSilenced function determines whether alarms are currently + * silenced. + * @details \b Inputs: alarmStatus + * @details \b Outputs: none + * @return TRUE if alarms are currently silenced, FALSE if not + *************************************************************************/ +BOOL areAlarmsSilenced( void ) +{ + return alarmStatus.alarmsSilenced; +} + +/*********************************************************************//** + * @brief * The isBloodRecircBlocked function determines whether any currently * active alarm is blocking blood re-circulation. - * @details Inputs: alarmStatus - * @details Outputs: none + * @details \b Inputs: alarmStatus + * @details \b Outputs: none * @return TRUE if any active alarm prevents blood re-circulation, FALSE if not *************************************************************************/ BOOL isBloodRecircBlocked( void ) @@ -648,8 +611,8 @@ * @brief * The isDialysateRecircBlocked function determines whether any currently * active alarm is blocking dialysate re-circulation. - * @details Inputs: alarmStatus - * @details Outputs: none + * @details \b Inputs: alarmStatus + * @details \b Outputs: none * @return TRUE if any active alarm prevents dialysate re-circulation, FALSE if not *************************************************************************/ BOOL isDialysateRecircBlocked( void ) @@ -659,12 +622,11 @@ /*********************************************************************//** * @brief - * The doesAlarmStatusIndicateEndTxOnly function determines whether any currently - * active alarm has ( stop && noRes && /noET ) property, that is end treatment is - * the only choice from full stop. - * @details Inputs: alarmStatus - * @details Outputs: none - * @return TRUE if any active alarm has stop property, FALSE if not + * The doesAlarmStatusIndicateEndTxOnly function determines whether the + * alarm system will only allow end treatment option from full stop. + * @details \b Inputs: alarmStatus + * @details \b Outputs: none + * @return TRUE if end treatment will be only option, FALSE if not *************************************************************************/ BOOL doesAlarmStatusIndicateEndTxOnly( void ) { @@ -679,11 +641,11 @@ /*********************************************************************//** * @brief - * The doesAlarmStatusIndicateStop function determines whether any currently - * active alarm has stop property. - * @details Inputs: alarmStatus - * @details Outputs: none - * @return TRUE if any active alarm has stop property, FALSE if not + * The doesAlarmStatusIndicateStop function determines whether alarm system + * is currently indicating we should stop. + * @details \b Inputs: alarmStatus + * @details \b Outputs: none + * @return TRUE if alarm system indicates stop, FALSE if not *************************************************************************/ BOOL doesAlarmStatusIndicateStop( void ) { @@ -692,11 +654,11 @@ /*********************************************************************//** * @brief - * The doesAlarmIndicateNoResume function determines whether any currently - * active alarm has treatment resume blocked property. - * @details Inputs: resumeBlockedByAlarmProperty - * @details Outputs: none - * @return TRUE if any active alarm has no resume property, FALSE if not + * The doesAlarmIndicateNoResume function determines whether the alarm system + * currently indicates resume option is not allowed. + * @details \b Inputs: resumeBlockedByAlarmProperty + * @details \b Outputs: none + * @return TRUE if alarm system indicates resume option is blocked, FALSE if not *************************************************************************/ BOOL doesAlarmIndicateNoResume( void ) { @@ -706,10 +668,10 @@ /*********************************************************************//** * @brief * The getCurrentAlarmStatePriority function determines the current alarm - * state priority (NONE, LOW, MEDIUM, or HIGH). - * @details Inputs: alarmStatus - * @details Outputs: none - * @return current alarm state priority + * state (NONE, LOW, MEDIUM, or HIGH). + * @details \b Inputs: alarmStatus.alarmsState + * @details \b Outputs: none + * @return current alarm state (priority of highest ranking active alarm) *************************************************************************/ ALARM_PRIORITY_T getCurrentAlarmStatePriority( void ) { @@ -718,38 +680,13 @@ /*********************************************************************//** * @brief -* The setAlarmAudioVolume function sets the current alarm audio volume level. -* @details Inputs: none -* @details Outputs: alarmAudioVolumeLevel -* @param volumeLevel level of volume requested (1..5) -* @return none -*************************************************************************/ -void setAlarmAudioVolume( U32 volumeLevel ) -{ - BOOL accepted = FALSE; - U32 rejReason = REQUEST_REJECT_REASON_NONE; - - if ( ( volumeLevel > 0 ) && ( volumeLevel <= MAX_ALARM_VOLUME_LEVEL ) ) - { - // Convert volume level to attenuation level - alarmAudioVolumeLevel.data = MAX_ALARM_VOLUME_LEVEL - volumeLevel; - accepted = TRUE; - } - else - { - rejReason = REQUEST_REJECT_REASON_PARAM_OUT_OF_RANGE; - } - - // Send response to UI -// sendAlarmAudioVolumeSetResponse( accepted, rejReason ); -} - -/*********************************************************************//** - * @brief -* The handleActiveAlarmListRequest function processes the active alarms list +* The handleActiveAlarmListRequest function handles the active alarms list * request from UI. -* @details Inputs: alarmIsActive[] -* @details Outputs: sent active alarms list to UI +* @note Active alarm list is sorted by rank and is limited to maximum 10 alarm +* entries. +* @details \b Message \b Sent: MSG_ID_TD_ACTIVE_ALARMS_LIST_REQUEST_RESPONSE +* @details \b Inputs: alarmStatus, alarmIsActive[], ALARM_RANK_TABLE[] +* @details \b Outputs: sent active alarms list to UI * @return none *************************************************************************/ void handleActiveAlarmListRequest( void ) @@ -787,10 +724,11 @@ /*********************************************************************//** * @brief -* The handleResendActiveAlarmsRequest function processes the request to re-send -* all active alarms. -* @details Inputs: alarmIsActive[] -* @details Outputs: none +* The handleResendActiveAlarmsRequest function executes the request to re-send +* all currently active alarms. +* @details \b Message \b Sent: MSG_ID_ALARM_TRIGGERED for each active alarm. +* @details \b Inputs: alarmIsActive[], ALARM_TABLE[] +* @details \b Outputs: none * @return none *************************************************************************/ void handleResendActiveAlarmsRequest( void ) @@ -823,11 +761,12 @@ /*********************************************************************//** * @brief - * The getAlarmStartTime function gets the active state of a given alarm. - * @details Inputs: alarmStartedAt[] - * @details Outputs: none - * @param alarmID ID of alarm to check - * @return The start time stamp of given alarm ID + * The getAlarmStartTime function gets the start time of a given alarm. + * @details \b Alarm: ALARM_ID_TD_SOFTWARE_FAULT if given alarm ID is invalid. + * @details \b Inputs: alarmStartedAt[] + * @details \b Outputs: none + * @param alarmID ID of alarm to get start time for + * @return The start time stamp (seconds since power up) of given alarm ID *************************************************************************/ static U32 getAlarmStartTime( ALARM_ID_T alarmID ) { @@ -854,19 +793,16 @@ /*********************************************************************//** * @brief - * The monitorAlarms function monitors alarm audio current. - * @details Inputs: none - * @details Outputs: alarmPrimaryAudioCurrentHG + * The monitorAlarms function monitors alarm audio current and also looks + * for and executes a user confirmation of user request to end treatment. + * @details \b Inputs: none + * @details \b Outputs: none * @return none *************************************************************************/ static void monitorAlarms( void ) { - U32 volume = getAlarmAudioVolume(); + execAlarmAudio(); -// alarmPrimaryAudioCurrentHG.data = getIntADCVoltageConverted( INT_ADC_PRIMARY_ALARM_CURRENT_HG ); -// alarmPrimaryAudioCurrentLG.data = getIntADCVoltageConverted( INT_ADC_PRIMARY_ALARM_CURRENT_LG ); -// alarmBackupAudioCurrent.data = getFPGABackupAlarmAudioCurrent(); - // Check for user confirmation of end treatment alarm response if ( CONFIRMATION_REQUEST_STATUS_ACCEPTED == getConfirmationRequestStatus( GENERIC_CONFIRM_ID_TREATMENT_END ) ) { @@ -881,10 +817,11 @@ /*********************************************************************//** * @brief - * The updateAlarmsState function updates the alarms state and alarm to - * display. - * @details Inputs: alarmStatusTable[] - * @details Outputs: alarmPriorityFIFO[], alarmStatus + * The updateAlarmsState function re-evaluates the current alarm system state + * and the "top" alarm to display (highest ranking active alarm). Some of + * the properties of alarm system status are re-evaluated as well. + * @details \b Inputs: alarmStatusTable[] + * @details \b Outputs: alarmStatus, alarmPriorityFIFO[] * @return none *************************************************************************/ static void updateAlarmsState( void ) @@ -964,9 +901,11 @@ /*********************************************************************//** * @brief * The setAlarmLamp function sets the alarm lamp pattern according to the - * current state of alarms. - * @details Inputs: none - * @details Outputs: Alarm lamp patter set according to current alarms status. + * current state of alarms. + * @details \b Alarm: ALARM_ID_TD_SOFTWARE_FAULT if reported alarm state is invalid. + * @details \b Inputs: alarmStatus, ALARM_TABLE[] + * @details \b Outputs: alarmStatus, alarm lamp pattern set according to + * current alarms status. * @return none *************************************************************************/ static void setAlarmLamp( void ) @@ -1024,67 +963,11 @@ } } -/*********************************************************************//** - * @brief - * The setAlarmAudio function sets the alarm audio pattern according to - * the current state of alarms. - * @details Inputs: alarmAudioTestToneRequested - * @details Outputs: alarmAudioTestToneRequested - * @return none - *************************************************************************/ -static void setAlarmAudio( void ) -{ - U32 volume = getAlarmAudioVolume(); - - // If audio test in progress, play test tone. - if ( TRUE == alarmAudioTestToneRequested ) - { // Play test tone at min volume -// setAlarmAudioState( ALARM_AUDIO_TEST_TONE, -// ALARM_AUDIO_DIVIDER_LOOKUP_TABLE[MAX_ALARM_AUDIO_VOLUME_INDEX][ALARM_AUDIO_VOLUME_GAIN], -// ALARM_AUDIO_DIVIDER_LOOKUP_TABLE[MAX_ALARM_AUDIO_VOLUME_INDEX][ALARM_AUDIO_VOLUME_DIVIDER] ); - // If we're in Fault mode, ensure audio test tone request is cancelled. - if ( MODE_FAUL == getCurrentOperationMode() ) - { - alarmAudioTestToneRequested = FALSE; - } - - } - // If alarm silenced, play no alarm audio. - else if ( ( ALARM_PRIORITY_NONE == alarmStatus.alarmsState ) || ( TRUE == alarmStatus.alarmsSilenced ) ) - { -// setAlarmAudioState( ALARM_PRIORITY_NONE, -// ALARM_AUDIO_DIVIDER_LOOKUP_TABLE[volume][ALARM_AUDIO_VOLUME_GAIN], -// ALARM_AUDIO_DIVIDER_LOOKUP_TABLE[volume][ALARM_AUDIO_VOLUME_DIVIDER] ); - } - // Otherwise, play alarm audio as appropriate based on current alarm status - else - { - if ( alarmStatus.alarmsState < NUM_OF_ALARM_PRIORITIES ) - { -#ifndef _RELEASE_ -// if ( getSoftwareConfigStatus( SW_CONFIG_DISABLE_ALARM_AUDIO ) != SW_CONFIG_ENABLE_VALUE ) -#endif - { -// setAlarmAudioState( alarmStatus.alarmsState, -// ALARM_AUDIO_DIVIDER_LOOKUP_TABLE[volume][ALARM_AUDIO_VOLUME_GAIN], -// ALARM_AUDIO_DIVIDER_LOOKUP_TABLE[volume][ALARM_AUDIO_VOLUME_DIVIDER] ); - } - } -// else -// { -// SET_ALARM_WITH_2_U32_DATA( ALARM_ID_TD_SOFTWARE_FAULT, SW_FAULT_ID_ALARM_MGMT_AUDIO_INVALID_ALARM_STATE, alarmStatus.alarmsState ) -// setAlarmAudioState( ALARM_PRIORITY_HIGH, -// ALARM_AUDIO_DIVIDER_LOOKUP_TABLE[volume][ALARM_AUDIO_VOLUME_GAIN], -// ALARM_AUDIO_DIVIDER_LOOKUP_TABLE[volume][ALARM_AUDIO_VOLUME_DIVIDER] ); -// } - } -} - /*********************************************************************//** * @brief * The updateAlarmsSilenceStatus function updates the alarms silence state. - * @details Inputs: alarmStatus - * @details Outputs: alarmStatus + * @details \b Inputs: alarmStatus + * @details \b Outputs: alarmStatus * @return none *************************************************************************/ static void updateAlarmsSilenceStatus( void ) @@ -1117,10 +1000,11 @@ /*********************************************************************//** * @brief - * The updateAlarmsFlags function updates the alarms flags of the alarms - * status record. - * @details Inputs: alarmStatus, alarmIsActive, ALARM_TABLE, alarmButtonBlockers - * @details Outputs: alarmStatus, alarmUserRecoveryActionEnabled, + * The updateAlarmsFlags function updates the alarms status flags of the + * alarms status record. + * @details \b Inputs: alarmStatus, alarmIsActive, ALARM_TABLE[], + * alarmButtonBlockers[]. alarmUserRecoveryActionEnabled[] + * @details \b Outputs: alarmStatus, alarmButtonBlockers[] * @return none *************************************************************************/ static void updateAlarmsFlags( void ) @@ -1222,13 +1106,13 @@ } // If AC power is out, block all user options -// if ( TRUE == getCPLDACPowerLossDetected() ) -// { -// usrAckReq = FALSE; -// noResume = TRUE; -// noRinseback = TRUE; -// noEndTreatment = TRUE; -// } + if ( TRUE == getCPLDACPowerLossDetected() ) + { + usrAckReq = FALSE; + noResume = TRUE; + noRinseback = TRUE; + noEndTreatment = TRUE; + } // If in Treatment-Stop state or Fault/Service/Standby Mode, allow user to minimize the alarm window // if ( ( MODE_FAUL == currentMode ) || ( MODE_SERV == currentMode ) || ( MODE_STAN == currentMode ) || @@ -1253,9 +1137,9 @@ * @brief * The clearAllRecoverableAlarms function clears all currently active * recoverable alarms. - * @details Inputs: ALARM_TABLE[] - * @details Outputs: alarmIsActive[] - * @param action user action that prompted clearing of recoverable alarms + * @details \b Inputs: ALARM_TABLE[], isAlarmActive[], alarmIsDetected[] + * @details \b Outputs: alarmIsActive[], alarmIsDetected[], alarmStartedAt[] + * @param action User action that prompted clearing of recoverable alarms * @return TRUE if all recoverable alarms cleared, FALSE if any left active *************************************************************************/ static BOOL clearAllRecoverableAlarms( ALARM_USER_ACTION_T action ) @@ -1292,10 +1176,11 @@ /*********************************************************************//** * @brief * The resetAlarmPriorityFIFO function resets a FIFO for a given alarm - * priority. - * @details Inputs: none - * @details Outputs: alarmPriorityFIFO[] - * @param priority priority of FIFO to reset + * priority. + * @details \b Alarm: ALARM_ID_TD_SOFTWARE_FAULT if given priority is invalid. + * @details \b Inputs: none + * @details \b Outputs: alarmPriorityFIFO[] + * @param priority Alarm priority associated with FIFO to reset * @return none *************************************************************************/ static void resetAlarmPriorityFIFO( ALARM_PRIORITY_T priority ) @@ -1316,17 +1201,20 @@ /*********************************************************************//** * @brief * The publishAlarmInfo function publishes alarm information and status - * at the set intervals. - * @details Inputs: alarmInfoPublicationTimerCounter, alarmButtonBlockers - * @details Outputs: alarmStatusPublicationTimerCounter + * at the set time intervals. + * @details \b Message \b Sent: MSG_ID_ALARM_STATUS_DATA + * @details \b Message \b Sent: MSG_ID_TD_ALARM_INFORMATION_DATA + * @details \b Inputs: alarmStatusPublicationTimerCounter, alarmInfoPublicationTimerCounter, + * alarmButtonBlockers[] + * @details \b Outputs: alarmStatusPublicationTimerCounter, alarmInfoPublicationTimerCounter * @return none *************************************************************************/ static void publishAlarmInfo( void ) { // Publish alarm status at interval if ( ++alarmStatusPublicationTimerCounter >= getU32OverrideValue( &alarmStatusPublishInterval ) ) { - // Lamp and audio timing sync'd with broadcast so UI can stay in sync with lamp rhythm + // Lamp and audio timing sync'd with alarm status broadcast so UI/lamp/audio can stay in sync setAlarmLamp(); setAlarmAudio(); // broadcastAlarmStatus( alarmStatus ); @@ -1342,269 +1230,85 @@ data.audioCurrHG = getAlarmAudioPrimaryHighGainCurrent(); data.audioCurrLG = getAlarmAudioPrimaryLowGainCurrent(); data.backupAudioCurr = getAlarmAudioBackupCurrent(); -// data.safetyShutdown = isSafetyShutdownActivated(); -// data.acPowerLost = getCPLDACPowerLossDetected(); + data.safetyShutdown = isSafetyShutdownActivated(); + data.acPowerLost = getCPLDACPowerLossDetected(); data.uiAlarmButtonBlocks[ ALARM_BUTTON_TABLE_BLOCK_RESUME ] = (U08)alarmButtonBlockers[ ALARM_BUTTON_TABLE_BLOCK_RESUME ]; data.uiAlarmButtonBlocks[ ALARM_BUTTON_TABLE_BLOCK_RINSEBACK ] = (U08)alarmButtonBlockers[ ALARM_BUTTON_TABLE_BLOCK_RINSEBACK ]; data.uiAlarmButtonBlocks[ ALARM_BUTTON_TABLE_BLOCK_END_TREATMENT ] = (U08)alarmButtonBlockers[ ALARM_BUTTON_TABLE_BLOCK_END_TREATMENT ]; data.uiAlarmButtonBlocks[ ALARM_BUTTON_STATE_BLOCK_RESUME ] = (U08)alarmButtonBlockers[ ALARM_BUTTON_STATE_BLOCK_RESUME ]; data.uiAlarmButtonBlocks[ ALARM_BUTTON_STATE_BLOCK_RINSEBACK ] = (U08)alarmButtonBlockers[ ALARM_BUTTON_STATE_BLOCK_RINSEBACK ]; data.uiAlarmButtonBlocks[ ALARM_BUTTON_STATE_BLOCK_END_TREATMENT ] = (U08)alarmButtonBlockers[ ALARM_BUTTON_STATE_BLOCK_END_TREATMENT ]; -// broadcastData( MSG_ID_HD_ALARM_INFORMATION_DATA, COMM_BUFFER_OUT_CAN_TD_BROADCAST, (U08*)&data, sizeof( ALARM_INFO_PAYLOAD_T ) ); +// broadcastData( MSG_ID_TD_ALARM_INFORMATION_DATA, COMM_BUFFER_OUT_CAN_TD_BROADCAST, (U08*)&data, sizeof( ALARM_INFO_PAYLOAD_T ) ); alarmInfoPublicationTimerCounter = 0; } } -/*********************************************************************//** - * @brief - * The getAlarmAudioVolume function gets the current alarm audio volume level. - * @details Inputs: alarmAudioVolumeLevel - * @details Outputs: none - * @return the current alarm audio volume level. + +/************************************************************************* + * TEST SUPPORT FUNCTIONS + *************************************************************************/ + + +/*********************************************************************//** + * @brief + * The testSetAlarmStartOverride function overrides the start time for a + * given alarm with a given start time. + * @details \b Inputs: msTimerCount + * @details \b Outputs: alarmStartedAt[] + * @param message Override message from Dialin which includes an ID of + * the alarm to override start time for and a number of milliseconds the + * override is seeking to make the elapsed time since the given alarm was + * triggered. + * @return TRUE if override is successful, FALSE if not *************************************************************************/ -U32 getAlarmAudioVolume( void ) +BOOL testSetAlarmStartOverride( MESSAGE_T *message ) { - U32 result = alarmAudioVolumeLevel.data; + BOOL result = FALSE; + TEST_OVERRIDE_ARRAY_PAYLOAD_T override; + OVERRIDE_TYPE_T reset = getOverrideArrayPayloadFromMessage( message, &override ); -#ifndef _RELEASE_ - // Check the software configurations -// if ( SW_CONFIG_ENABLE_VALUE == getSoftwareConfigStatus( SW_CONFIG_ENABLE_ALARM_VOLUME_DEFAULT_LOW ) ) -// { -// result = MIN_ALARM_VOLUME_ATTENUATION; -// } -#endif - - if ( OVERRIDE_KEY == alarmAudioVolumeLevel.override ) + // Verify tester has logged in with TD and override type is valid + if ( ( TRUE == isTestingActivated() ) && ( reset != OVERRIDE_INVALID ) && ( reset < NUM_OF_OVERRIDE_TYPES ) ) { - result = alarmAudioVolumeLevel.ovData; - } + U32 alarmID = override.index; - return result; -} + // Verify alarm index of override + if ( alarmID < NUM_OF_ALARM_IDS ) + { + if ( OVERRIDE_RESET_OVERRIDE == reset ) + { + U32 value = override.state.u32; + U32 tim = getMSTimerCount(); -/*********************************************************************//** - * @brief - * The getAlarmAudioPrimaryHighGainCurrent function gets the current alarm - * audio high gain current. - * @details Inputs: alarmPrimaryAudioCurrentHG - * @details Outputs: none - * @return the current alarm audio high gain current (in mA). - *************************************************************************/ -F32 getAlarmAudioPrimaryHighGainCurrent( void ) -{ - F32 result = alarmPrimaryAudioCurrentHG.data; - - if ( OVERRIDE_KEY == alarmPrimaryAudioCurrentHG.override ) - { - result = alarmPrimaryAudioCurrentHG.ovData; + if ( tim > value ) + { + result = TRUE; + alarmStartedAt[ alarmID ].ovData = ( tim - value ); + alarmStartedAt[ alarmID ].override = OVERRIDE_KEY; + } + } + else + { + result = TRUE; + alarmStartedAt[ alarmID ].override = OVERRIDE_RESET; + alarmStartedAt[ alarmID ].ovData = alarmStartedAt[ alarmID ].ovInitData; + } + } } return result; -} - -/*********************************************************************//** - * @brief - * The getAlarmAudioPrimaryLowGainCurrent function gets the current alarm - * audio low gain current. - * @details Inputs: alarmPrimaryAudioCurrentLG - * @details Outputs: none - * @return the current alarm audio low gain current (in mA). - *************************************************************************/ -F32 getAlarmAudioPrimaryLowGainCurrent( void ) -{ - F32 result = alarmPrimaryAudioCurrentLG.data; - - if ( OVERRIDE_KEY == alarmPrimaryAudioCurrentLG.override ) - { - result = alarmPrimaryAudioCurrentLG.ovData; - } - - return result; -} - -/*********************************************************************//** - * @brief - * The getAlarmAudioBackupCurrent function gets the current backup alarm - * audio current. - * @details Inputs: alarmBackupAudioCurrent - * @details Outputs: none - * @return the current backup alarm audio current (in mA). - *************************************************************************/ -F32 getAlarmAudioBackupCurrent( void ) -{ - F32 result = alarmBackupAudioCurrent.data; - - if ( OVERRIDE_KEY == alarmBackupAudioCurrent.override ) - { - result = alarmBackupAudioCurrent.ovData; - } - - return result; -} - -/*********************************************************************//** - * @brief - * The execAlarmAudioSelfTest function outputs a test audio tone and - * measures the audio current level. - * @details Inputs: alarmAudioSelfTestState, audioTestStartTime - * @details Outputs: audioTestStartTime, alarmAudioTestToneRequested - * @return the current backup alarm audio current (in mA). - *************************************************************************/ -SELF_TEST_STATUS_T execAlarmAudioSelfTest( void ) -{ - SELF_TEST_STATUS_T result = SELF_TEST_STATUS_IN_PROGRESS; -// F32 almLGCurrent = getIntADCVoltageConverted( INT_ADC_PRIMARY_ALARM_CURRENT_LG ); -// -// switch ( alarmAudioSelfTestState ) -// { -// case ALARM_AUDIO_SELF_TEST_STATE_START: -// if ( almLGCurrent < ALARM_AUDIO_CURRENT_LG_MAX_MA ) -// { -// audioTestStartTime = getMSTimerCount(); -// // Start test tone -// alarmAudioTestToneRequested = TRUE; -// setAlarmAudio(); -// alarmAudioSelfTestState = ALARM_AUDIO_SELF_TEST_STATE_PRIMARY; -// } -// else -// { -// result = SELF_TEST_STATUS_FAILED; -// SET_ALARM_WITH_2_F32_DATA( ALARM_ID_HD_ALARM_AUDIO_SELF_TEST_FAILURE, almLGCurrent, ALARM_AUDIO_CURRENT_LG_MAX_MA ); -// alarmAudioSelfTestState = ALARM_AUDIO_SELF_TEST_STATE_COMPLETE; -// } -// break; -// -// case ALARM_AUDIO_SELF_TEST_STATE_PRIMARY: -// // Check if alarm audio current is sufficiently high indicating alarm tone is being output -// if ( almLGCurrent > ALARM_AUDIO_CURRENT_LG_MIN_MA ) -// { -// alarmAudioTestToneRequested = FALSE; -// audioTestStartTime = getMSTimerCount(); -// alarmAudioSelfTestState = ALARM_AUDIO_SELF_TEST_STATE_NO_TONE; -// } -// else if ( TRUE == didTimeout( audioTestStartTime, ALARM_AUDIO_MAX_TEST_TIME_MS ) ) -// { -// alarmAudioTestToneRequested = FALSE; -// result = SELF_TEST_STATUS_FAILED; -// SET_ALARM_WITH_2_F32_DATA( ALARM_ID_HD_ALARM_AUDIO_SELF_TEST_FAILURE, almLGCurrent, ALARM_AUDIO_CURRENT_LG_MIN_MA ); -// alarmAudioSelfTestState = ALARM_AUDIO_SELF_TEST_STATE_COMPLETE; -// } -// break; -// -// case ALARM_AUDIO_SELF_TEST_STATE_NO_TONE: -// if ( almLGCurrent < ALARM_AUDIO_CURRENT_LG_MAX_MA ) -// { -// result = SELF_TEST_STATUS_PASSED; -// alarmAudioSelfTestState = ALARM_AUDIO_SELF_TEST_STATE_COMPLETE; -// } -// else if ( TRUE == didTimeout( audioTestStartTime, ALARM_AUDIO_MAX_TEST_TIME_MS ) ) -// { -// result = SELF_TEST_STATUS_FAILED; -// SET_ALARM_WITH_2_F32_DATA( ALARM_ID_HD_ALARM_AUDIO_SELF_TEST_FAILURE, almLGCurrent, ALARM_AUDIO_CURRENT_LG_MAX_MA ); -// alarmAudioSelfTestState = ALARM_AUDIO_SELF_TEST_STATE_COMPLETE; -// } -// break; -// -// case ALARM_AUDIO_SELF_TEST_STATE_COMPLETE: -// alarmAudioSelfTestState = ALARM_AUDIO_SELF_TEST_STATE_START; // Should only get here if re-starting self-tests. -// break; -// -// default: -// SET_ALARM_WITH_2_U32_DATA( ALARM_ID_TD_SOFTWARE_FAULT, SW_FAULT_ID_HD_INVALID_ALARM_AUDIO_STATE, (U32)alarmAudioSelfTestState ) -// break; -// } - - return result; -} - -/*********************************************************************//** - * @brief - * The resetAlarmAudioPOSTState function resets the alarm audio POST state. - * @details Inputs: none - * @details Outputs: alarmAudioSelfTestState - * @return none - *************************************************************************/ -void resetAlarmAudioPOSTState( void ) -{ - alarmAudioSelfTestState = ALARM_AUDIO_SELF_TEST_STATE_START; -} - - -/************************************************************************* - * TEST SUPPORT FUNCTIONS - *************************************************************************/ - - -/*********************************************************************//** - * @brief - * The testSetAlarmStartOverride function overrides the start time - * for a given alarm with the alarm management with a given start time. - * @details Inputs: none - * @details 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 - * @return TRUE if override successful, FALSE if not - *************************************************************************/ -BOOL testSetAlarmStartOverride( U32 alarmID, U32 value ) -{ - BOOL result = FALSE; - - if ( alarmID < NUM_OF_ALARM_IDS ) - { - // Verify tester has logged in with HD - if ( TRUE == isTestingActivated() ) - { - U32 tim = getMSTimerCount(); - - if ( tim > value ) - { - result = TRUE; - alarmStartedAt[ alarmID ].ovData = ( tim - value ); - alarmStartedAt[ alarmID ].override = OVERRIDE_KEY; - } - } - } - - return result; } - -/*********************************************************************//** - * @brief - * The testResetAlarmStartOverride function resets the override of the - * start time for a given alarm with the alarm management. - * @details Inputs: none - * @details Outputs: alarmStartedAt[] - * @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 ) -{ - BOOL result = FALSE; - - if ( alarmID < NUM_OF_ALARM_IDS ) - { - // Verify tester has logged in with HD - if ( TRUE == isTestingActivated() ) - { - result = TRUE; - alarmStartedAt[ alarmID ].override = OVERRIDE_RESET; - alarmStartedAt[ alarmID ].ovData = alarmStartedAt[ alarmID ].ovInitData; - } - } - - 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 HD. - * @details Inputs: none - * @details Outputs: alarmIsActive[], alarmStartedAt[] - * @param key 32-bit supervisor alarm key required to perform this function - * @return TRUE if override reset successful, FALSE if not + * the correct 32-bit key. A Dialin user must also be logged into TD. + * @details \b Message \b Sent: MSG_ID_ALARM_CLEARED for each active alarm. + * @details \b Inputs: none + * @details \b Outputs: alarmIsActive[], alarmStartedAt[] + * @param key A 32-bit supervisor alarm key required to perform this function + * @return TRUE if command was successful, FALSE if rejected *************************************************************************/ BOOL testClearAllAlarms( U32 key ) { @@ -1650,12 +1354,12 @@ /*********************************************************************//** * @brief - * The testSetAlarmStatusPublishIntervalOverride function sets the override of the - * alarm status publication interval. - * @details Inputs: none - * @details Outputs: alarmStatusPublishInterval - * @param ms milliseconds between alarm status broadcasts - * @return TRUE if override set successful, FALSE if not + * The testSetAlarmStatusPublishIntervalOverride function sets the override + * of the alarm status publication interval. + * @details \b Inputs: none + * @details \b Outputs: alarmStatusPublishInterval + * @param ms Number of milliseconds between alarm status broadcasts + * @return TRUE if override set is successful, FALSE if not *************************************************************************/ BOOL testSetAlarmStatusPublishIntervalOverride( U32 ms ) { @@ -1675,11 +1379,11 @@ /*********************************************************************//** * @brief - * The testResetAlarmStatusPublishIntervalOverride function resets the override of the - * alarm status publication interval. - * @details Inputs: none - * @details Outputs: alarmStatusPublishInterval - * @return TRUE if override reset successful, FALSE if not + * The testResetAlarmStatusPublishIntervalOverride function resets the + * override of the alarm status publication interval. + * @details \b Inputs: none + * @details \b Outputs: alarmStatusPublishInterval + * @return TRUE if override reset is successful, FALSE if not *************************************************************************/ BOOL testResetAlarmStatusPublishIntervalOverride( void ) { @@ -1697,12 +1401,12 @@ /*********************************************************************//** * @brief - * The testSetAlarmInfoPublishIntervalOverride function sets the override of the - * alarm information publication interval. - * @details Inputs: none - * @details Outputs: alarmInfoPublishInterval - * @param ms milliseconds between alarm info broadcasts - * @return TRUE if override set successful, FALSE if not + * The testSetAlarmInfoPublishIntervalOverride function sets the override + * of the alarm information publication interval. + * @details \b Inputs: none + * @details \b Outputs: alarmInfoPublishInterval + * @param ms Number of milliseconds between alarm info broadcasts + * @return TRUE if override set is successful, FALSE if not *************************************************************************/ BOOL testSetAlarmInfoPublishIntervalOverride( U32 ms ) { @@ -1722,11 +1426,11 @@ /*********************************************************************//** * @brief - * The testResetAlarmInfoPublishIntervalOverride function resets the override of the - * alarm information publication interval. - * @details Inputs: none - * @details Outputs: alarmInfoPublishInterval - * @return TRUE if override reset successful, FALSE if not + * The testResetAlarmInfoPublishIntervalOverride function resets the override + * of the alarm information publication interval. + * @details \b Inputs: none + * @details \b Outputs: alarmInfoPublishInterval + * @return TRUE if override reset is successful, FALSE if not *************************************************************************/ BOOL testResetAlarmInfoPublishIntervalOverride( void ) { @@ -1742,184 +1446,4 @@ return result; } -/*********************************************************************//** - * @brief - * The testSetAlarmAudioVolumeLevelOverride function sets the override of the - * alarm audio volume. - * @details Inputs: none - * @details Outputs: alarmAudioVolumeLevel - * @param volume volume level (1..5) of alarm audio - * @return TRUE if override set successful, FALSE if not - *************************************************************************/ -BOOL testSetAlarmAudioVolumeLevelOverride( U32 volume ) -{ - BOOL result = FALSE; - - if ( TRUE == isTestingActivated() ) - { - result = TRUE; - alarmAudioVolumeLevel.ovData = MAX_ALARM_VOLUME_LEVEL - volume; - alarmAudioVolumeLevel.override = OVERRIDE_KEY; - } - - return result; -} - -/*********************************************************************//** - * @brief - * The testResetAlarmAudioVolumeLevelOverride function resets the override of the - * alarm audio volume. - * @details Inputs: none - * @details Outputs: alarmAudioVolumeLevel - * @return TRUE if override reset successful, FALSE if not - *************************************************************************/ -BOOL testResetAlarmAudioVolumeLevelOverride( void ) -{ - BOOL result = FALSE; - - if ( TRUE == isTestingActivated() ) - { - result = TRUE; - alarmAudioVolumeLevel.override = OVERRIDE_RESET; - alarmAudioVolumeLevel.ovData = alarmAudioVolumeLevel.ovInitData; - } - - return result; -} - -/*********************************************************************//** - * @brief - * The testSetPrimaryAlarmAudioCurrentHGOverride function sets the override of the - * alarm audio current (high gain) in mA. - * @details Inputs: none - * @details Outputs: alarmPrimaryAudioCurrentHG - * @param mA milliamps measured from high gain channel of primary alarm audio - * @return TRUE if override set successful, FALSE if not - *************************************************************************/ -BOOL testSetPrimaryAlarmAudioCurrentHGOverride( F32 mA ) -{ - BOOL result = FALSE; - - if ( TRUE == isTestingActivated() ) - { - result = TRUE; - alarmPrimaryAudioCurrentHG.ovData = mA; - alarmPrimaryAudioCurrentHG.override = OVERRIDE_KEY; - } - - return result; -} - -/*********************************************************************//** - * @brief - * The testResetPrimaryAlarmAudioCurrentHGOverride function resets the override of the - * alarm audio current (high gain). - * @details Inputs: none - * @details Outputs: alarmPrimaryAudioCurrentHG - * @return TRUE if override reset successful, FALSE if not - *************************************************************************/ -BOOL testResetPrimaryAlarmAudioCurrentHGOverride( void ) -{ - BOOL result = FALSE; - - if ( TRUE == isTestingActivated() ) - { - result = TRUE; - alarmPrimaryAudioCurrentHG.override = OVERRIDE_RESET; - alarmPrimaryAudioCurrentHG.ovData = alarmPrimaryAudioCurrentHG.ovInitData; - } - - return result; -} - -/*********************************************************************//** - * @brief - * The testSetPrimaryAlarmAudioCurrentLGOverride function sets the override of the - * alarm audio current (low gain) in mA. - * @details Inputs: none - * @details Outputs: alarmPrimaryAudioCurrentLG - * @param mA milliamps measured from low gain channel of primary alarm audio - * @return TRUE if override set successful, FALSE if not - *************************************************************************/ -BOOL testSetPrimaryAlarmAudioCurrentLGOverride( F32 mA ) -{ - BOOL result = FALSE; - - if ( TRUE == isTestingActivated() ) - { - result = TRUE; - alarmPrimaryAudioCurrentLG.ovData = mA; - alarmPrimaryAudioCurrentLG.override = OVERRIDE_KEY; - } - - return result; -} - -/*********************************************************************//** - * @brief - * The testResetPrimaryAlarmAudioCurrentLGOverride function resets the override of the - * alarm audio current (low gain). - * @details Inputs: none - * @details Outputs: alarmPrimaryAudioCurrentLG - * @return TRUE if override reset successful, FALSE if not - *************************************************************************/ -BOOL testResetPrimaryAlarmAudioCurrentLGOverride( void ) -{ - BOOL result = FALSE; - - if ( TRUE == isTestingActivated() ) - { - result = TRUE; - alarmPrimaryAudioCurrentLG.override = OVERRIDE_RESET; - alarmPrimaryAudioCurrentLG.ovData = alarmPrimaryAudioCurrentLG.ovInitData; - } - - return result; -} - -/*********************************************************************//** - * @brief - * The testSetBackupAlarmAudioCurrentOverride function sets the override of the - * alarm audio current (backup) in mA. - * @details Inputs: none - * @details Outputs: alarmBackupAudioCurrent - * @param mA milliamps measured from backup channel of primary alarm audio - * @return TRUE if override set successful, FALSE if not - *************************************************************************/ -BOOL testSetBackupAlarmAudioCurrentOverride( F32 mA ) -{ - BOOL result = FALSE; - - if ( TRUE == isTestingActivated() ) - { - result = TRUE; - alarmBackupAudioCurrent.ovData = mA; - alarmBackupAudioCurrent.override = OVERRIDE_KEY; - } - - return result; -} - -/*********************************************************************//** - * @brief - * The testResetBackupAlarmAudioCurrentOverride function resets the override of the - * alarm audio current (backup). - * @details Inputs: none - * @details Outputs: alarmBackupAudioCurrent - * @return TRUE if override reset successful, FALSE if not - *************************************************************************/ -BOOL testResetBackupAlarmAudioCurrentOverride( void ) -{ - BOOL result = FALSE; - - if ( TRUE == isTestingActivated() ) - { - result = TRUE; - alarmBackupAudioCurrent.override = OVERRIDE_RESET; - alarmBackupAudioCurrent.ovData = alarmBackupAudioCurrent.ovInitData; - } - - return result; -} - /**@}*/ Index: firmware/App/Services/AlarmMgmtTD.h =================================================================== diff -u -r3518e8a088c32e75c0c8960d5e629a7401095feb -re8654d6ebf2c76c6bae8e1b465cc1382d205832a --- firmware/App/Services/AlarmMgmtTD.h (.../AlarmMgmtTD.h) (revision 3518e8a088c32e75c0c8960d5e629a7401095feb) +++ firmware/App/Services/AlarmMgmtTD.h (.../AlarmMgmtTD.h) (revision e8654d6ebf2c76c6bae8e1b465cc1382d205832a) @@ -20,13 +20,16 @@ #include "TDCommon.h" #include "AlarmDefs.h" +#include "AlarmAudio.h" +#include "AlarmLamp.h" #include "AlarmMgmtSWFaults.h" +#include "TestSupport.h" /** * @defgroup AlarmManagementTD AlarmManagementTD - * @brief Alarm Management service unit for TD firmware. Provides general - * alarm managementfunctionality including support functions for triggering - * and clearingspecific alarms. + * @brief Alarm Management service unit for TD firmware. Provides alarm + * management functionality including support functions for triggering + * and clearing specific alarms. * * @addtogroup AlarmManagementTD * @{ @@ -35,9 +38,6 @@ /// Interval (in ms) at which alarm lamp and audio control will be executed. #define ALARM_LAMP_AND_AUDIO_CONTROL_INTERVAL_MS 250 -#define MAX_ALARM_VOLUME_LEVEL 5 ///< Maximum alarm audio level. -#define MAX_ALARM_VOLUME_ATTENUATION 4 ///< Maximum alarm audio attenuation. -#define MIN_ALARM_VOLUME_ATTENUATION 0 ///< Minimum alarm audio attenuation. #define MAX_ALARM_LIST_SIZE 10 ///< Maximum number of active alarms inside alarm list. /// Enumeration of alarm actions. @@ -82,13 +82,13 @@ /// Enumeration of alarm button blockers. typedef enum Alarm_Button_Blockers { - ALARM_BUTTON_TABLE_BLOCK_RESUME = 0, ///< Alarm table properties are blocking alarm resume button - ALARM_BUTTON_TABLE_BLOCK_RINSEBACK, ///< Alarm table properties are blocking alarm rinseback button - ALARM_BUTTON_TABLE_BLOCK_END_TREATMENT, ///< Alarm table properties are blocking alarm end treatment button - ALARM_BUTTON_STATE_BLOCK_RESUME, ///< State properties are blocking alarm resume button - ALARM_BUTTON_STATE_BLOCK_RINSEBACK, ///< State properties are blocking alarm rinseback button - ALARM_BUTTON_STATE_BLOCK_END_TREATMENT, ///< State properties are blocking alarm end treatment button - NUM_OF_ALARM_BUTTON_BLOCKERS ///< Number of alarm actions + ALARM_BUTTON_TABLE_BLOCK_RESUME = 0, ///< Alarm table properties are blocking alarm resume button + ALARM_BUTTON_TABLE_BLOCK_RINSEBACK, ///< Alarm table properties are blocking alarm rinseback button + ALARM_BUTTON_TABLE_BLOCK_END_TREATMENT, ///< Alarm table properties are blocking alarm end treatment button + ALARM_BUTTON_STATE_BLOCK_RESUME, ///< State properties are blocking alarm resume button + ALARM_BUTTON_STATE_BLOCK_RINSEBACK, ///< State properties are blocking alarm rinseback button + ALARM_BUTTON_STATE_BLOCK_END_TREATMENT, ///< State properties are blocking alarm end treatment button + NUM_OF_ALARM_BUTTON_BLOCKERS ///< Number of alarm actions } ALARM_BUTTON_BLOCKER_T; #pragma pack(push, 1) @@ -112,21 +112,21 @@ /// Payload record structure for an alarm status message. typedef struct { - U32 alarmState; ///< Alarm state: 0 = no alarms, 1 = low priority, 2 = medium priority, 3 = high priority - U32 alarmTop; ///< ID of top active alarm - U32 escalatesIn; ///< Top active alarm escalates in this many seconds - U32 silenceExpiresIn; ///< Silencing of alarms expires in this many seconds - U16 alarmsFlags; ///< Bit flags: 1 = true, 0 = false for each bit flag + U32 alarmState; ///< Alarm state: 0 = no alarms, 1 = low priority, 2 = medium priority, 3 = high priority + U32 alarmTop; ///< ID of top active alarm + U32 escalatesIn; ///< Top active alarm escalates in this many seconds + U32 silenceExpiresIn; ///< Silencing of alarms expires in this many seconds + U16 alarmsFlags; ///< Bit flags: 1 = true, 0 = false for each bit flag } ALARM_COMP_STATUS_PAYLOAD_T; #pragma pack(pop) /// Alarm list request response payload record structure. typedef struct { - BOOL accepted; ///< Accepted/Rejected. - U32 rejectionReason; ///< Rejection reason if not accepted. - U32 activeAlarmList[ MAX_ALARM_LIST_SIZE ]; ///< Active Alarm List array. + BOOL accepted; ///< Accepted/Rejected. + U32 rejectionReason; ///< Rejection reason if not accepted. + U32 activeAlarmList[ MAX_ALARM_LIST_SIZE ]; ///< Active Alarm List array. } ACTIVE_ALARM_LIST_RESPONSE_PAYLOAD_T; // ********** public function prototypes ********** @@ -137,44 +137,31 @@ void clearAlarmTD( ALARM_ID_T alarm ); void activateAlarmNoData( ALARM_ID_T alarm ); void activateAlarm1Data( ALARM_ID_T alarm, ALARM_DATA_T alarmData ); -void activateAlarm2Data( ALARM_ID_T alarm, ALARM_DATA_T alarmData1, ALARM_DATA_T alarmData2, BOOL outside ); -void setAlarmUserActionEnabled( ALARM_USER_ACTION_T action, BOOL enabled ); +void activateAlarm2Data( ALARM_ID_T alarm, ALARM_DATA_T alarmData1, ALARM_DATA_T alarmData2, BOOL outside ); + +void setAlarmUserActionEnabled( ALARM_USER_ACTION_T action, BOOL enabled ); + void signalAlarmSilence( ALARM_SILENCE_CMD_T cmd ); void signalAlarmUserActionInitiated( ALARM_USER_ACTION_T action ); + BOOL isAnyAlarmActive( void ); +BOOL areAlarmsSilenced( void ); BOOL isBloodRecircBlocked( void ); BOOL isDialysateRecircBlocked( void ); BOOL doesAlarmStatusIndicateStop( void ); BOOL doesAlarmIndicateNoResume( void ); BOOL doesAlarmStatusIndicateEndTxOnly( void ); -ALARM_PRIORITY_T getCurrentAlarmStatePriority( void ); -void setAlarmAudioVolume( U32 volumeLevel ); +ALARM_PRIORITY_T getCurrentAlarmStatePriority( void ); void handleActiveAlarmListRequest( void ); void handleResendActiveAlarmsRequest( void ); -U32 getAlarmAudioVolume( void ); -F32 getAlarmAudioPrimaryHighGainCurrent( void ); -F32 getAlarmAudioPrimaryLowGainCurrent( void ); -F32 getAlarmAudioBackupCurrent( void ); -SELF_TEST_STATUS_T execAlarmAudioSelfTest( void ); -void resetAlarmAudioPOSTState( void ); - -BOOL testSetAlarmStartOverride( U32 alarmID, U32 value ); -BOOL testResetAlarmStartOverride( U32 alarmID ); +BOOL testSetAlarmStartOverride( MESSAGE_T *message ); BOOL testClearAllAlarms( U32 key ); BOOL testSetAlarmStatusPublishIntervalOverride( U32 ms ); BOOL testResetAlarmStatusPublishIntervalOverride( void ); BOOL testSetAlarmInfoPublishIntervalOverride( U32 ms ); BOOL testResetAlarmInfoPublishIntervalOverride( void ); -BOOL testSetAlarmAudioVolumeLevelOverride( U32 volume ); -BOOL testResetAlarmAudioVolumeLevelOverride( void ); -BOOL testSetPrimaryAlarmAudioCurrentHGOverride( F32 mA ); -BOOL testResetPrimaryAlarmAudioCurrentHGOverride( void ); -BOOL testSetPrimaryAlarmAudioCurrentLGOverride( F32 mA ); -BOOL testResetPrimaryAlarmAudioCurrentLGOverride( void ); -BOOL testSetBackupAlarmAudioCurrentOverride( F32 mA ); -BOOL testResetBackupAlarmAudioCurrentOverride( void ); /**@}*/ Index: firmware/App/Services/CommBuffers.h =================================================================== diff -u -r3518e8a088c32e75c0c8960d5e629a7401095feb -re8654d6ebf2c76c6bae8e1b465cc1382d205832a --- firmware/App/Services/CommBuffers.h (.../CommBuffers.h) (revision 3518e8a088c32e75c0c8960d5e629a7401095feb) +++ firmware/App/Services/CommBuffers.h (.../CommBuffers.h) (revision e8654d6ebf2c76c6bae8e1b465cc1382d205832a) @@ -18,8 +18,6 @@ #ifndef __COMM_BUFFERS_H__ #define __COMM_BUFFERS_H__ -#include "TDCommon.h" - /** * @defgroup CommBuffers CommBuffers * @brief The communication buffers unit provides buffering services for @@ -52,7 +50,16 @@ COMM_BUFFER_OUT_CAN_PC, ///< Buffer for outgoing TD to PC messages NUM_OF_COMM_BUFFERS ///< Number of CAN communication buffers } COMM_BUFFER_T; + +/**@}*/ +#include "TDCommon.h" + +/** + * @addtogroup CommBuffers + * @{ + */ + // ********** public function prototypes ********** void initCommBuffers( void ); Index: firmware/App/Services/MsgQueues.h =================================================================== diff -u -r3518e8a088c32e75c0c8960d5e629a7401095feb -re8654d6ebf2c76c6bae8e1b465cc1382d205832a --- firmware/App/Services/MsgQueues.h (.../MsgQueues.h) (revision 3518e8a088c32e75c0c8960d5e629a7401095feb) +++ firmware/App/Services/MsgQueues.h (.../MsgQueues.h) (revision e8654d6ebf2c76c6bae8e1b465cc1382d205832a) @@ -20,6 +20,7 @@ #include "TDCommon.h" #include "CommBuffers.h" +#include "MessageSupport.h" /** * @defgroup MsgQueues MsgQueues @@ -32,44 +33,13 @@ // ********** public definitions ********** -#define MAX_MSG_PAYLOAD_SIZE 250 ///< Bytes - /// Enumeration of message queues. typedef enum Msg_Queues { MSG_Q_IN = 0, ///< Incoming CAN message queue. NUM_OF_MSG_QUEUES ///< Number of message queues. } MSG_QUEUE_T; -#pragma pack(push,1) - -/// Record structure for message header. -typedef struct -{ - S16 seqNo; ///< Sequence number (and ACK required bit) of message - U16 msgID; ///< ID of message - U08 payloadLen; ///< Length of payload in bytes -} MESSAGE_HEADER_T; - -/// Record structure for a message (header + payload). -typedef struct -{ - COMM_BUFFER_T in_buffer; ///< Message received into this channel buffer - MESSAGE_HEADER_T hdr; ///< Message header - U08 payload[ MAX_MSG_PAYLOAD_SIZE ]; ///< Message payload -} MESSAGE_T; - -/// Record structure for a wrapped message (message + CRC). -typedef struct -{ - MESSAGE_T msg; ///< Message - U08 crc; ///< Message CRC -} MESSAGE_WRAPPER_T; - -#pragma pack(pop) - -#define MESSAGE_OVERHEAD_SIZE (sizeof(MESSAGE_HEADER_T) + sizeof(U08)) ///< Byte size of a message's overhead (fixed at 6 bytes). - // ********** public function prototypes ********** void initMsgQueues( void );