Index: firmware/App/Services/AlarmMgmt.c =================================================================== diff -u -r395b6a6a9df782ebf1d331c43dc2d26a3fa59a03 -r30f049651877229042e3f8700c8596e5b9a1e0f4 --- firmware/App/Services/AlarmMgmt.c (.../AlarmMgmt.c) (revision 395b6a6a9df782ebf1d331c43dc2d26a3fa59a03) +++ firmware/App/Services/AlarmMgmt.c (.../AlarmMgmt.c) (revision 30f049651877229042e3f8700c8596e5b9a1e0f4) @@ -49,29 +49,29 @@ /// 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 assignment for backup alarm audio enable -#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 +// Pin assignment for backup alarm audio enable +#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;} ///< 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. -/// alarm priority ranking record. +/// Alarm priority ranking record. typedef struct { ALARM_ID_T alarmID; ///< ID of highest priority alarm in this priority category - U32 subRank; ///< sub-rank of this alarm + U32 subRank; ///< Sub-rank of this alarm U32 timeSinceTriggeredMS; ///< Time (in ms) since this alarm was triggered } ALARM_PRIORITY_RANKS_T; // ********** private data ********** static U32 alarmStatusPublicationTimerCounter = 0; ///< Used to schedule alarm status publication to CAN bus. -/// table - current state of each alarm +/// Table - current state of each alarm static BOOL alarmIsActive[ NUM_OF_ALARM_IDS ]; -/// table - current state of each alarm condition (detected or cleared) +/// Table - current state of each alarm condition (detected or cleared) static BOOL alarmIsDetected[ NUM_OF_ALARM_IDS ]; -/// table - when alarm became active for each alarm (if active) or zero (if inactive) +/// Table - when alarm became active for each alarm (if active) or zero (if inactive) static OVERRIDE_U32_T alarmStartedAt[ NUM_OF_ALARM_IDS ]; /// Record for the current composite alarm status. @@ -80,7 +80,7 @@ /// FIFO - first activated or highest sub-rank alarm in each alarm priority category. static ALARM_PRIORITY_RANKS_T alarmPriorityFIFO[ NUM_OF_ALARM_PRIORITIES ]; -/// alarm user recovery actions enabled flags. +/// Alarm user recovery actions enabled flags. static BOOL alarmUserRecoveryActionEnabled[ NUMBER_OF_ALARM_USER_ACTIONS ]; static U32 alarmAudioVolumeLevel = 3; //MIN_ALARM_VOLUME_ATTENUATION; ///< Set alarm audio volume attenuation level (0..4 - lower level = higher gain). @@ -113,10 +113,10 @@ ALARM_PRIORITY_T p; ALARM_ID_T a; - // disable backup audio + // Disable backup audio CLR_BACKUP_AUDIO_ENABLE(); - // initialize alarm states and start time stamps + // Initialize alarm states and start time stamps for ( a = ALARM_ID_NO_ALARM; a < NUM_OF_ALARM_IDS; a++ ) { alarmIsActive[ a ] = FALSE; @@ -126,14 +126,14 @@ alarmStartedAt[ a ].ovInitData = 0; alarmStartedAt[ a ].override = OVERRIDE_RESET; } - // initialize alarm FIFOs + // Initialize alarm FIFOs for ( p = ALARM_PRIORITY_NONE; p < NUM_OF_ALARM_PRIORITIES; p++ ) { alarmPriorityFIFO[ p ].alarmID = ALARM_ID_NO_ALARM; alarmPriorityFIFO[ p ].subRank = LOWEST_ALARM_SUB_RANK; alarmPriorityFIFO[ p ].timeSinceTriggeredMS = 0; } - // initialize composite alarm state + // Initialize composite alarm state alarmStatus.alarmsState = ALARM_PRIORITY_NONE; alarmStatus.alarmsSilenced = FALSE; alarmStatus.alarmsSilenceStart = 0; @@ -167,10 +167,10 @@ updateAlarmsState(); updateAlarmsFlags(); updateAlarmsSilenceStatus(); - // publish alarm status at interval + // Publish alarm status at interval if ( ++alarmStatusPublicationTimerCounter >= ALARM_STATUS_PUBLISH_INTERVAL ) { - // lamp and audio timing sync'd with broadcast so UI can stay in sync with lamp rhythm + // Lamp and audio timing sync'd with broadcast so UI can stay in sync with lamp rhythm setAlarmLamp(); setAlarmAudio(); broadcastAlarmStatus( alarmStatus ); @@ -188,29 +188,29 @@ *************************************************************************/ static void activateAlarm( ALARM_ID_T alarm ) { - // verify given alarm + // Verify given alarm if ( ( alarm > ALARM_ID_NO_ALARM ) && ( alarm < NUM_OF_ALARM_IDS ) ) { - // no need to do anything if alarm is already active + // No need to do anything if alarm is already active if ( FALSE == alarmIsActive[ alarm ] ) { - // if alarms silenced, end silence due to new alarm + // If alarms silenced, end silence due to new alarm alarmStatus.alarmsSilenced = FALSE; - // if alarm is a fault, request transition to fault mode + // If alarm is a fault, request transition to fault mode if ( TRUE == ALARM_TABLE[ alarm ].alarmIsFault ) { requestNewOperationMode( MODE_FAUL ); } - // activate alarm + // Activate alarm alarmIsActive[ alarm ] = TRUE; alarmStartedAt[ alarm ].data = getMSTimerCount(); alarmIsDetected[ alarm ] = TRUE; - // if alarm has clear condition immediately property, clear condition now + // If alarm has clear condition immediately property, clear condition now if ( TRUE == ALARM_TABLE[ alarm ].alarmConditionClearImmed ) { clearAlarmCondition( alarm ); } - // if alarm has stop property, signal stop now + // If alarm has stop property, signal stop now if ( TRUE == ALARM_TABLE[ alarm ].alarmStops ) { initiateAlarmAction( ALARM_ACTION_STOP ); @@ -235,7 +235,7 @@ *************************************************************************/ void activateAlarmNoData( ALARM_ID_T alarm ) { - // broadcast alarm and data if alarm not already active + // Broadcast alarm and data if alarm not already active if ( FALSE == alarmIsActive[ alarm ] ) { broadcastAlarmTriggered( (U16)alarm, BLANK_ALARM_DATA, BLANK_ALARM_DATA ); @@ -268,7 +268,7 @@ *************************************************************************/ void activateAlarm1Data( ALARM_ID_T alarm, ALARM_DATA_T alarmData ) { - // broadcast alarm and data if alarm not already active + // Broadcast alarm and data if alarm not already active if ( FALSE == alarmIsActive[ alarm ] ) { broadcastAlarmTriggered( (U16)alarm, alarmData, BLANK_ALARM_DATA ); @@ -302,7 +302,7 @@ *************************************************************************/ void activateAlarm2Data( ALARM_ID_T alarm, ALARM_DATA_T alarmData1, ALARM_DATA_T alarmData2 ) { - // broadcast alarm and data if alarm not already active + // Broadcast alarm and data if alarm not already active if ( FALSE == alarmIsActive[ alarm ] ) { broadcastAlarmTriggered( (U16)alarm, alarmData1, alarmData2 ); @@ -333,10 +333,10 @@ *************************************************************************/ void clearAlarmCondition( ALARM_ID_T alarm ) { - // verify given alarm + // Verify given alarm if ( ( alarm > ALARM_ID_NO_ALARM ) && ( alarm < NUM_OF_ALARM_IDS ) ) { - // clear alarm condition and broadcast alarm condition clear if not already cleared + // Clear alarm condition and broadcast alarm condition clear if not already cleared if ( TRUE == alarmIsDetected[ alarm ] ) { alarmIsDetected[ alarm ] = FALSE; @@ -357,21 +357,21 @@ *************************************************************************/ void clearAlarm( ALARM_ID_T alarm ) { - // verify given alarm + // Verify given alarm if ( ( alarm > ALARM_ID_NO_ALARM ) && ( alarm < NUM_OF_ALARM_IDS ) ) { - // verify alarm can be cleared + // Verify alarm can be cleared if ( FALSE == ALARM_TABLE[ alarm ].alarmNoClear ) { - // clear alarm and broadcast alarm clear if not already cleared + // Clear alarm and broadcast alarm clear if not already cleared if ( TRUE == alarmIsActive[ alarm ] ) { broadcastAlarmCleared( alarm ); alarmIsActive[ alarm ] = FALSE; alarmIsDetected[ alarm ] = FALSE; alarmStartedAt[ alarm ].data = 0; - // clear FIFO if this alarm was in it + // Clear FIFO if this alarm was in it if ( alarmPriorityFIFO[ ALARM_TABLE[ alarm ].alarmPriority ].alarmID == alarm ) { resetAlarmPriorityFIFO( ALARM_TABLE[ alarm ].alarmPriority ); @@ -461,19 +461,19 @@ *************************************************************************/ void signalAlarmUserActionInitiated( ALARM_USER_ACTION_T action ) { - // validate given action + // Validate given action if ( action < NUMBER_OF_ALARM_USER_ACTIONS ) { ALARM_ID_T a = alarmStatus.alarmTop; if ( ALARM_USER_ACTION_ACK == action ) { - // if user acknowledged top alarm, just clear that alarm + // If user acknowledged top alarm, just clear that alarm if ( TRUE == ALARM_TABLE[ a ].alarmUserAckRequired ) { clearAlarm( a ); } - // otherwise we must be in mode/state where ack was only option - so clear all like other options + // Otherwise we must be in mode/state where ack was only option - so clear all like other options else { clearAllRecoverableAlarms(); @@ -485,7 +485,7 @@ } } - // initiate user selected action + // Initiate user selected action switch ( action ) { case ALARM_USER_ACTION_RESUME: @@ -566,7 +566,7 @@ void setAlarmAudioVolume( U32 volumeLevel ) { if ( ( volumeLevel > 0 ) && ( volumeLevel <= MAX_ALARM_VOLUME_LEVEL ) ) - { // convert volume level to attenuation level + { // Convert volume level to attenuation level alarmAudioVolumeLevel = MAX_ALARM_VOLUME_LEVEL - volumeLevel; } } @@ -616,7 +616,7 @@ ALARM_ID_T a; BOOL faultsActive = FALSE; - // update FIFOs and sub-ranks per active alarms table - for alarm ranking purposes to determine "top" alarm + // Update FIFOs and sub-ranks per active alarms table - for alarm ranking purposes to determine "top" alarm for ( a = ALARM_ID_NO_ALARM; a < NUM_OF_ALARM_IDS; a++ ) { if ( TRUE == alarmIsActive[a] ) @@ -625,10 +625,10 @@ U32 subRank = ALARM_TABLE[ a ].alarmSubRank; U32 msSinceTriggered = calcTimeSince( getAlarmStartTime( a ) ); - // see if this alarm is higher rank than highest active alarm in this priority category so far + // See if this alarm is higher rank than highest active alarm in this priority category so far if ( subRank <= alarmPriorityFIFO[ almPriority ].subRank ) { - // if sub-rank is a tie, see which alarm was triggered first + // If sub-rank is a tie, see which alarm was triggered first if ( subRank == alarmPriorityFIFO[ almPriority ].subRank ) { if ( msSinceTriggered > alarmPriorityFIFO[ almPriority ].timeSinceTriggeredMS ) @@ -638,25 +638,25 @@ alarmPriorityFIFO[ almPriority ].timeSinceTriggeredMS = msSinceTriggered; } } - // otherwise, this alarm simply outranks current candidate and wins outright + // Otherwise, this alarm simply outranks current candidate and wins outright else { alarmPriorityFIFO[ almPriority ].alarmID = a; alarmPriorityFIFO[ almPriority ].subRank = subRank; alarmPriorityFIFO[ almPriority ].timeSinceTriggeredMS = msSinceTriggered; } } - // track highest priority alarm found so far of all priority categories + // Track highest priority alarm found so far of all priority categories highestPriority = MAX( almPriority, highestPriority ); - // track whether any active faults have been found so far + // Track whether any active faults have been found so far if ( TRUE == ALARM_TABLE[ a ].alarmIsFault ) { faultsActive = TRUE; } } } - // update alarm to display per highest priority FIFO + // Update alarm to display per highest priority FIFO alarmStatus.alarmsState = highestPriority; alarmStatus.alarmTop = alarmPriorityFIFO[ highestPriority ].alarmID; alarmStatus.systemFault = faultsActive; @@ -672,7 +672,7 @@ *************************************************************************/ static void setAlarmLamp( void ) { - // set alarm lamp pattern to appropriate pattern for current alarm state + // Set alarm lamp pattern to appropriate pattern for current alarm state if ( getCurrentAlarmLampPattern() != LAMP_PATTERN_MANUAL ) { switch ( alarmStatus.alarmsState ) @@ -707,10 +707,10 @@ } } - // execute alarm lamp controller + // Execute alarm lamp controller execAlarmLamp(); - // set lamp on flag to match current state of alarm lamp + // Set lamp on flag to match current state of alarm lamp if ( getCurrentAlarmLampPattern() != LAMP_PATTERN_MANUAL ) { alarmStatus.lampOn = getAlarmLampOn(); @@ -735,7 +735,7 @@ { setAlarmAudioState( ALARM_PRIORITY_NONE, alarmAudioVolumeLevel ); } - else // alarms not silenced + else // Alarms not silenced { if ( alarmStatus.alarmsState < NUM_OF_ALARM_PRIORITIES ) { @@ -760,7 +760,7 @@ *************************************************************************/ static void updateAlarmsSilenceStatus( void ) { - // if alarms not silenced, reset alarms silence related properties + // If alarms not silenced, reset alarms silence related properties if ( TRUE != alarmStatus.alarmsSilenced ) { alarmStatus.alarmsSilenceExpiresIn = 0; @@ -778,7 +778,7 @@ { alarmStatus.alarmsSilenceExpiresIn = ALARM_SILENCE_EXPIRES_IN_SECS - timeSinceAlarmSilenceStart; } - // if alarms silence expires, end it + // If alarms silence expires, end it if ( 0 == alarmStatus.alarmsSilenceExpiresIn ) { alarmStatus.alarmsSilenced = FALSE; @@ -799,42 +799,42 @@ ALARM_ID_T nextAlarmToEscalate = ALARM_ID_NO_ALARM; ALARM_ID_T a; - // update escalations + // Update escalations for ( a = ALARM_ID_NO_ALARM; a < NUM_OF_ALARM_IDS; a++ ) { if ( TRUE == alarmIsActive[ a ] ) { - // does active alarm escalate? + // Does active alarm escalate? if ( ALARM_ID_NO_ALARM != ALARM_TABLE[ a ].alarmEscalatesTo ) { S32 msRemaining = (S32)ALARM_TABLE[ a ].alarmEscalatesAfter - (S32)calcTimeSince( getAlarmStartTime( a ) ); S32 secsRemaining = ( msRemaining / MS_PER_SECOND ) + 1; - // time to escalate? + // Time to escalate? if ( msRemaining <= 0 ) { activateAlarmNoData( ALARM_TABLE[ a ].alarmEscalatesTo ); clearAlarm( a ); } else - { // no candidates for alarm escalation yet? + { // No candidates for alarm escalation yet? if ( ALARM_ID_NO_ALARM == nextAlarmToEscalate ) { secsToEscalate = secsRemaining; nextAlarmToEscalate = a; } - // sooner candidate for alarm escalation? + // Sooner candidate for alarm escalation? else if ( secsRemaining < secsToEscalate ) { secsToEscalate = secsRemaining; nextAlarmToEscalate = a; } } - } // if alarm escalates - } // if alarm active - } // alarm table loop + } // If alarm escalates + } // If alarm active + } // Alarm table loop - // update alarm escalation properties + // Update alarm escalation properties if ( TRUE == alarmStatus.systemFault || ALARM_ID_NO_ALARM == nextAlarmToEscalate ) { alarmStatus.alarmsToEscalate = FALSE; @@ -867,7 +867,7 @@ BOOL usrAckReq = FALSE; ALARM_ID_T a; - // determine alarm flags + // Determine alarm flags for ( a = ALARM_ID_NO_ALARM; a < NUM_OF_ALARM_IDS; a++ ) { if ( TRUE == alarmIsActive[ a ] ) @@ -876,7 +876,7 @@ stop = ( TRUE == ALARM_TABLE[ a ].alarmStops ? TRUE : stop ); noClear = ( TRUE == ALARM_TABLE[ a ].alarmNoClear ? TRUE : noClear ); noNewTreatment = ( TRUE == ALARM_TABLE[ a ].alarmNoNewTreatment ? TRUE : noNewTreatment ); - // set user alarm recovery actions allowed flags + // Set user alarm recovery actions allowed flags if ( TRUE == alarmUserRecoveryActionEnabled[ ALARM_USER_ACTION_RESUME ] ) { noResume = ( TRUE == ALARM_TABLE[ a ].alarmNoResume ? TRUE : noResume ); @@ -901,17 +901,17 @@ { noEndTreatment = TRUE; } - } // if alarm active - } // alarm table loop + } // If alarm active + } // Alarm table loop - // if top alarm condition not cleared, block resume and rinseback flags + // If top alarm condition not cleared, block resume and rinseback flags if ( TRUE == alarmStatus.topAlarmConditionnDetected ) { noResume = TRUE; noRinseback = TRUE; } - // if top alarm requires user ack or no other user options enabled for recoverable alarm and condition cleared, set user ack flag and block other flags + // If top alarm requires user ack or no other user options enabled for recoverable alarm and condition cleared, set user ack flag and block other flags if ( ( TRUE == ALARM_TABLE[ alarmStatus.alarmTop ].alarmUserAckRequired ) || ( ( FALSE == alarmStatus.noClear ) && ( noResume ) && ( noRinseback ) && ( noEndTreatment ) && ( FALSE == alarmStatus.topAlarmConditionnDetected ) ) ) @@ -922,7 +922,7 @@ noEndTreatment = TRUE; } - // set updated alarm flags + // Set updated alarm flags alarmStatus.systemFault = systemFault; alarmStatus.stop = stop; alarmStatus.noClear = noClear; @@ -947,7 +947,7 @@ for ( a = ALARM_ID_HD_SOFTWARE_FAULT; a < NUM_OF_ALARM_IDS; a++ ) { - // is alarm recoverable? + // Is alarm recoverable? if ( FALSE == ALARM_TABLE[ a ].alarmNoClear ) { clearAlarm( a ); @@ -966,7 +966,7 @@ *************************************************************************/ static void resetAlarmPriorityFIFO( ALARM_PRIORITY_T priority ) { - // verify priority + // Verify priority if ( priority < NUM_OF_ALARM_PRIORITIES ) { alarmPriorityFIFO[ priority ].alarmID = ALARM_ID_NO_ALARM; @@ -1002,7 +1002,7 @@ if ( alarmID < NUM_OF_ALARM_IDS ) { - // verify tester has logged in with HD + // Verify tester has logged in with HD if ( TRUE == isTestingActivated() ) { if ( TRUE == state ) @@ -1035,7 +1035,7 @@ if ( alarmID < NUM_OF_ALARM_IDS ) { - // verify tester has logged in with HD + // Verify tester has logged in with HD if ( TRUE == isTestingActivated() ) { result = TRUE; @@ -1062,7 +1062,7 @@ if ( alarmID < NUM_OF_ALARM_IDS ) { - // verify tester has logged in with HD + // Verify tester has logged in with HD if ( TRUE == isTestingActivated() ) { U32 tim = getMSTimerCount(); @@ -1094,7 +1094,7 @@ if ( alarmID < NUM_OF_ALARM_IDS ) { - // verify tester has logged in with HD + // Verify tester has logged in with HD if ( TRUE == isTestingActivated() ) { result = TRUE; @@ -1120,23 +1120,23 @@ { BOOL result = FALSE; - // verify key + // Verify key if ( SUPERVISOR_ALARM_KEY == key ) { - // verify tester has logged in with HD + // Verify tester has logged in with HD if ( TRUE == isTestingActivated() ) { ALARM_ID_T a; - // clear all active alarms + // Clear all active alarms for ( a = ALARM_ID_NO_ALARM; a < NUM_OF_ALARM_IDS; a++ ) { if ( TRUE == alarmIsActive[ a ] ) { broadcastAlarmCleared( a ); alarmIsActive[ a ] = FALSE; alarmStartedAt[ a ].data = 0; - // clear FIFO if this alarm was in it + // Clear FIFO if this alarm was in it if ( alarmPriorityFIFO[ ALARM_TABLE[ a ].alarmPriority ].alarmID == a ) { resetAlarmPriorityFIFO( ALARM_TABLE[ a ].alarmPriority );