Index: AlarmMgmt.c =================================================================== diff -u -r3402723ffaf9fb1256d51fd23f4273ad7c087836 -r8e3c1aa26d6668749668255dbc337910b30423ae --- AlarmMgmt.c (.../AlarmMgmt.c) (revision 3402723ffaf9fb1256d51fd23f4273ad7c087836) +++ AlarmMgmt.c (.../AlarmMgmt.c) (revision 8e3c1aa26d6668749668255dbc337910b30423ae) @@ -31,24 +31,24 @@ // ********** private definitions ********** -// ********** private data ********** - // *** This declaration will cause a compiler error if ALARM_TABLE does not have same # of alarms as the Alarm_List enumeration. U08 alarmTableSizeAssertion[ ( ( sizeof( ALARM_TABLE ) / sizeof( ALARM_T ) ) == NUM_OF_ALARM_IDS ? 1 : -1 ) ]; // *** This declaration will cause a compiler error if ALARM_RANK_TABLE does not have same # of alarms as the Alarm_List enumeration. U08 alarmRankTableSizeAssertion[ ( ( sizeof( ALARM_RANK_TABLE ) / sizeof( ALARM_RANK_T ) ) == NUM_OF_ALARM_IDS ? 1 : -1 ) ]; +// ********** private data ********** + static BOOL alarmIsActive[ NUM_OF_ALARM_IDS ]; ///< Table - current state of each alarm static BOOL alarmIsDetected[ NUM_OF_ALARM_IDS ]; ///< Table - current state of each alarm condition (detected or cleared) // ********** private function prototypes ********** /*********************************************************************//** * @brief - * The initAlarmMgmt function initializes the AlarmMgmt module. - * @details Inputs: none - * @details Outputs: AlarmMgmt module initialized. + * The initAlarmMgmt function initializes the AlarmMgmt unit. + * @details \b Inputs: none + * @details \b Outputs: alarmIsActive[], alarmIsDetected[] * @return none *************************************************************************/ void initAlarmMgmt( void ) @@ -66,9 +66,10 @@ /*********************************************************************//** * @brief * The getAlarmProperties function gets the alarm properties for a given alarm. - * @details Inputs: none - * @details Outputs: ALARM_TABLE[] - * @param alarm ID of alarm to get properties record for + * @details \b Alarm: ALARM_ID_XX_SOFTWARE_FAULT if given alarm invalid. + * @details \b Inputs: ALARM_TABLE[] + * @details \b Outputs: none + * @param alarm ID of alarm to get the properties record for * @return properties record for given alarm *************************************************************************/ ALARM_T getAlarmProperties( ALARM_ID_T alarm ) @@ -81,7 +82,15 @@ } else { - // TODO - s/w fault +#ifdef _TD_ + SET_ALARM_WITH_2_U32_DATA( ALARM_ID_TD_SOFTWARE_FAULT, SW_FAULT_ID_ALARM_MGMT_INVALID_ALARM_TO_GET_PROPS, (U32)alarm ); +#endif +#ifdef _DD_ + SET_ALARM_WITH_2_U32_DATA( ALARM_ID_DD_SOFTWARE_FAULT, SW_FAULT_ID_ALARM_MGMT_INVALID_ALARM_TO_GET_PROPS, (U32)alarm ); +#endif +#ifdef _RO_ + SET_ALARM_WITH_2_U32_DATA( ALARM_ID_RO_SOFTWARE_FAULT, SW_FAULT_ID_ALARM_MGMT_INVALID_ALARM_TO_GET_PROPS, (U32)alarm ); +#endif } return result; @@ -90,10 +99,11 @@ /*********************************************************************//** * @brief * The getAlarmRank function gets the alarm rank for a given alarm index. - * @details Inputs: none - * @details Outputs: ALARM_RANK_TABLE[] - * @param index index to alarm table - * @return Alarm rank record for given index + * @details \b Alarm: ALARM_ID_XX_SOFTWARE_FAULT if given alarm index is invalid. + * @details \b Inputs: ALARM_RANK_TABLE[] + * @details \b Outputs: none + * @param index index to alarm range table (lower index = lower rank number = higher rank) + * @return Alarm rank record for given alarm index *************************************************************************/ ALARM_RANK_T getAlarmRank( U32 index ) { @@ -105,7 +115,15 @@ } else { - // TODO - s/w fault +#ifdef _TD_ + SET_ALARM_WITH_2_U32_DATA( ALARM_ID_TD_SOFTWARE_FAULT, SW_FAULT_ID_ALARM_MGMT_INVALID_ALARM_TO_GET_RANK, index ); +#endif +#ifdef _DD_ + SET_ALARM_WITH_2_U32_DATA( ALARM_ID_DD_SOFTWARE_FAULT, SW_FAULT_ID_ALARM_MGMT_INVALID_ALARM_TO_GET_RANK, index ); +#endif +#ifdef _RO_ + SET_ALARM_WITH_2_U32_DATA( ALARM_ID_RO_SOFTWARE_FAULT, SW_FAULT_ID_ALARM_MGMT_INVALID_ALARM_TO_GET_RANK, index ); +#endif } return result; @@ -114,8 +132,10 @@ /*********************************************************************//** * @brief * The activateAlarm function activates a given alarm. - * @details Inputs: none - * @details Outputs: alarmIsActive[], alarmStartedAt[], alarmStatus is updated + * @details \b Alarm: Given alarm is activated if not already. + * @details \b Alarm: ALARM_ID_XX_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 *************************************************************************/ @@ -141,16 +161,26 @@ } else { - SET_ALARM_WITH_2_U32_DATA( ALARM_ID_TD_SOFTWARE_FAULT, SW_FAULT_ID_ALARM_MGMT_INVALID_ALARM_TO_ACTIVATE3, alarm ) +#ifdef _TD_ + SET_ALARM_WITH_2_U32_DATA( ALARM_ID_TD_SOFTWARE_FAULT, SW_FAULT_ID_ALARM_MGMT_INVALID_ALARM_TO_ACTIVATE3, (U32)alarm ) +#endif +#ifdef _DD_ + SET_ALARM_WITH_2_U32_DATA( ALARM_ID_DD_SOFTWARE_FAULT, SW_FAULT_ID_ALARM_MGMT_INVALID_ALARM_TO_ACTIVATE3, (U32)alarm ) +#endif +#ifdef _RO_ + SET_ALARM_WITH_2_U32_DATA( ALARM_ID_RO_SOFTWARE_FAULT, SW_FAULT_ID_ALARM_MGMT_INVALID_ALARM_TO_ACTIVATE3, (U32)alarm ) +#endif } } /*********************************************************************//** * @brief * The clearAlarmCondition function clears a given alarm's condition detected * flag. Also an alarm message is broadcast to the rest of the system. - * @details Inputs: none - * @details Outputs: alarmIsDetected[] + * @details \b Message \b Sent: MSG_ID_ALARM_CONDITION_CLEARED if alarm condition cleared. + * @details \b Alarm: ALARM_ID_XX_SOFTWARE_FAULT if given alarm ID invalid. + * @details \b Inputs: alarmIsDetected[] + * @details \b Outputs: alarmIsDetected[] * @param alarm ID of alarm to clear condition for * @return none *************************************************************************/ @@ -178,15 +208,28 @@ #endif } } + else + { +#ifdef _TD_ + SET_ALARM_WITH_2_U32_DATA( ALARM_ID_TD_SOFTWARE_FAULT, SW_FAULT_ID_ALARM_MGMT_INVALID_ALARM_TO_CLEAR_COND, (U32)alarm ) +#endif +#ifdef _DD_ + SET_ALARM_WITH_2_U32_DATA( ALARM_ID_DD_SOFTWARE_FAULT, SW_FAULT_ID_ALARM_MGMT_INVALID_ALARM_TO_CLEAR_COND, (U32)alarm ) +#endif +#ifdef _RO_ + SET_ALARM_WITH_2_U32_DATA( ALARM_ID_RO_SOFTWARE_FAULT, SW_FAULT_ID_ALARM_MGMT_INVALID_ALARM_TO_CLEAR_COND, (U32)alarm ) +#endif + } } /*********************************************************************//** * @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 - * @details Outputs: AlarmStatusTable[], alarmIsActive[], alarmStartedAt[], - * alarmIsDetected[] + * @details \b Message \b Sent: MSG_ID_ALARM_CLEARED if alarm cleared. + * @details \b Alarm: ALARM_ID_XX_SOFTWARE_FAULT if given alarm ID invalid. + * @details \b Inputs: ALARM_TABLE[], alarmIsActive[] + * @details \b Outputs: alarmIsActive[] * @param alarm ID of alarm to clear * @return none *************************************************************************/ @@ -205,6 +248,8 @@ data.alarmID = (U32) alarm; + alarmIsActive[ alarm ] = FALSE; + clearAlarmCondition( alarm ); #ifdef _TD_ broadcastData( MSG_ID_ALARM_CLEARED, COMM_BUFFER_OUT_CAN_TD_ALARM, (U08*)&data, sizeof( ALARM_ID_DATA_PUBLISH_T ) ); #endif @@ -214,24 +259,30 @@ #ifdef _RO_ broadcastData( MSG_ID_ALARM_CLEARED, COMM_BUFFER_OUT_CAN_RO_ALARM, (U08*)&data, sizeof( ALARM_ID_DATA_PUBLISH_T ) ); #endif - alarmIsActive[ alarm ] = FALSE; - clearAlarmCondition( alarm ); } } } else { - SET_ALARM_WITH_2_U32_DATA( ALARM_ID_TD_SOFTWARE_FAULT, SW_FAULT_ID_ALARM_MGMT_INVALID_ALARM_TO_CLEAR2, alarm ) +#ifdef _TD_ + SET_ALARM_WITH_2_U32_DATA( ALARM_ID_TD_SOFTWARE_FAULT, SW_FAULT_ID_ALARM_MGMT_INVALID_ALARM_TO_CLEAR2, (U32)alarm ) +#endif +#ifdef _DD_ + SET_ALARM_WITH_2_U32_DATA( ALARM_ID_DD_SOFTWARE_FAULT, SW_FAULT_ID_ALARM_MGMT_INVALID_ALARM_TO_CLEAR2, (U32)alarm ) +#endif +#ifdef _RO_ + SET_ALARM_WITH_2_U32_DATA( ALARM_ID_RO_SOFTWARE_FAULT, SW_FAULT_ID_ALARM_MGMT_INVALID_ALARM_TO_CLEAR2, (U32)alarm ) +#endif } } /*********************************************************************//** * @brief * The setAlarmActive function sets the active flag for a given alarm. - * @details Inputs: none - * @details Outputs: alarmIsActive[] + * @details \b Inputs: none + * @details \b Outputs: alarmIsActive[] * @param alarm ID of alarm to set active flag for - * @param active TRUE if setting alarm as active, FALSE if not + * @param active TRUE if setting alarm as active, FALSE if setting alarm as inactive * @return none *************************************************************************/ void setAlarmActive( ALARM_ID_T alarm, BOOL active ) @@ -243,10 +294,11 @@ * @brief * The setAlarmConditionDetected function sets the condition detected flag * for a given alarm. - * @details Inputs: none - * @details Outputs: alarmIsDetected[] + * @details \b Inputs: none + * @details \b Outputs: alarmIsDetected[] * @param alarm ID of alarm to set condition detected flag for - * @param detected TRUE if setting alarm condition as detected, FALSE if not + * @param detected TRUE if setting alarm condition as detected, FALSE if + * setting alarm condition as not detected * @return none *************************************************************************/ void setAlarmConditionDetected( ALARM_ID_T alarm, BOOL detected ) @@ -257,10 +309,11 @@ /*********************************************************************//** * @brief * The isAlarmActive function determines whether a given alarm is currently - * active. - * @details Inputs: alarmIsActive[] - * @details Outputs: none - * @param alarm ID of alarm to check + * active. + * @details \b Alarm: ALARM_ID_TD_SOFTWARE_FAULT if given alarm ID is invalid. + * @details \b Inputs: alarmIsActive[] + * @details \b Outputs: none + * @param alarm ID of alarm to check active status for * @return TRUE if given alarm is active, FALSE if not *************************************************************************/ BOOL isAlarmActive( ALARM_ID_T alarm ) @@ -273,7 +326,15 @@ } else { +#ifdef _TD_ SET_ALARM_WITH_2_U32_DATA( ALARM_ID_TD_SOFTWARE_FAULT, SW_FAULT_ID_INVALID_ALARM_ID_REFERENCED1, (U32)alarm ); +#endif +#ifdef _DD_ + SET_ALARM_WITH_2_U32_DATA( ALARM_ID_DD_SOFTWARE_FAULT, SW_FAULT_ID_INVALID_ALARM_ID_REFERENCED1, (U32)alarm ) +#endif +#ifdef _RO_ + SET_ALARM_WITH_2_U32_DATA( ALARM_ID_RO_SOFTWARE_FAULT, SW_FAULT_ID_INVALID_ALARM_ID_REFERENCED1, (U32)alarm ) +#endif } return result; @@ -283,10 +344,11 @@ * @brief * The isAlarmConditionDetected function determines whether a given alarm * condition is currently detected. - * @details Inputs: alarmIsDetected[] - * @details Outputs: none - * @param alarm ID of alarm to check - * @return TRUE if given alarm is active, FALSE if not + * @details \b Alarm: ALARM_ID_TD_SOFTWARE_FAULT if given alarm ID is invalid. + * @details \b Inputs: alarmIsDetected[] + * @details \b Outputs: none + * @param alarm ID of alarm to check alarm condition detected status for + * @return TRUE if alarm condition for given alarm is detected, FALSE if not *************************************************************************/ BOOL isAlarmConditionDetected( ALARM_ID_T alarm ) { @@ -301,7 +363,15 @@ } else { +#ifdef _TD_ SET_ALARM_WITH_2_U32_DATA( ALARM_ID_TD_SOFTWARE_FAULT, SW_FAULT_ID_INVALID_ALARM_ID_REFERENCED2, (U32)alarm ); +#endif +#ifdef _DD_ + SET_ALARM_WITH_2_U32_DATA( ALARM_ID_DD_SOFTWARE_FAULT, SW_FAULT_ID_INVALID_ALARM_ID_REFERENCED2, (U32)alarm ) +#endif +#ifdef _RO_ + SET_ALARM_WITH_2_U32_DATA( ALARM_ID_RO_SOFTWARE_FAULT, SW_FAULT_ID_INVALID_ALARM_ID_REFERENCED2, (U32)alarm ) +#endif } return result; @@ -311,15 +381,33 @@ * @brief * The isAlarmRecoverable function determines whether a given alarm is * recoverable. -* @details Inputs: ALARM_TABLE[] -* @details Outputs: none -* @param alarm ID of alarm to check +* @details \b Alarm: ALARM_ID_XX_SOFTWARE_FAULT if given alarm ID invalid. +* @details \b Inputs: ALARM_TABLE[] +* @details \b Outputs: none +* @param alarm ID of alarm to determine recoverable status for * @return TRUE if given alarm is recoverable, FALSE if not *************************************************************************/ BOOL isAlarmRecoverable( ALARM_ID_T alarm ) { - BOOL result = ( TRUE == ALARM_TABLE[ alarm ].alarmNoClear ? FALSE : TRUE ); + BOOL result = FALSE; + if ( alarm < NUM_OF_ALARM_IDS ) + { + result = ( TRUE == ALARM_TABLE[ alarm ].alarmNoClear ? FALSE : TRUE ); + } + else + { +#ifdef _TD_ + SET_ALARM_WITH_2_U32_DATA( ALARM_ID_TD_SOFTWARE_FAULT, SW_FAULT_ID_INVALID_ALARM_ID_REFERENCED3, (U32)alarm ); +#endif +#ifdef _DD_ + SET_ALARM_WITH_2_U32_DATA( ALARM_ID_DD_SOFTWARE_FAULT, SW_FAULT_ID_INVALID_ALARM_ID_REFERENCED3, (U32)alarm ) +#endif +#ifdef _RO_ + SET_ALARM_WITH_2_U32_DATA( ALARM_ID_RO_SOFTWARE_FAULT, SW_FAULT_ID_INVALID_ALARM_ID_REFERENCED3, (U32)alarm ) +#endif + } + return result; } @@ -334,8 +422,8 @@ * 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 - * @details Outputs: alarm activated or cleared + * @details \b Inputs: none + * @details \b 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) * @return TRUE if override successful, FALSE if not @@ -376,8 +464,8 @@ * @brief * The testResetAlarmStateOverride function resets the override of the * state of the active state for a given alarm with the alarm management. - * @details Inputs: none - * @details Outputs: alarm cleared + * @details \b Inputs: none + * @details \b Outputs: alarm cleared * @param alarmID ID of alarm to clear * @return TRUE if alarm clear successful, FALSE if not *************************************************************************/