Index: firmware/App/Services/AlarmMgmtTD.c =================================================================== diff -u -r036a75d76ab01912646a480b935d97187a231a19 -r395522dffef1348e176564925656012f529c1910 --- firmware/App/Services/AlarmMgmtTD.c (.../AlarmMgmtTD.c) (revision 036a75d76ab01912646a480b935d97187a231a19) +++ firmware/App/Services/AlarmMgmtTD.c (.../AlarmMgmtTD.c) (revision 395522dffef1348e176564925656012f529c1910) @@ -1,17 +1,17 @@ /************************************************************************** * -* Copyright (c) 2024-2024 Diality Inc. - All Rights Reserved. +* Copyright (c) 2024-2026 Diality Inc. - All Rights Reserved. * * THIS CODE MAY NOT BE COPIED OR REPRODUCED IN ANY FORM, IN PART OR IN * WHOLE, WITHOUT THE EXPLICIT PERMISSION OF THE COPYRIGHT OWNER. * * @file AlarmMgmtTD.c * -* @author (last) Sean -* @date (last) 30-Jul-2024 +* @author (last) Dara Navaei +* @date (last) 01-Aug-2025 * -* @author (original) Sean -* @date (original) 30-Jul-2024 +* @author (original) Sean Nash +* @date (original) 01-Aug-2024 * ***************************************************************************/ @@ -20,6 +20,7 @@ #include "mibspi.h" #include "AlarmMgmtTD.h" +#include "Bubbles.h" #include "CpldInterface.h" #include "Messaging.h" #include "OperationModes.h" @@ -682,46 +683,153 @@ /*********************************************************************//** * @brief + * The handleAlarmTriggered function handles the triggered alarm from the other + * stacks. + * @details \b Inputs: none + * @details \b Outputs: none + * @param message Pointer to the triggered alarm message + * @return TRUE if message handled successfully, FALSE if not + *************************************************************************/ +BOOL handleAlarmTriggered( MESSAGE_T *message ) +{ + BOOL status = FALSE; + + if ( message->hdr.payloadLen == sizeof( ALARM_TRIGGERED_PAYLOAD_T ) ) + { + ALARM_TRIGGERED_PAYLOAD_T payload; + U08 *payloadPtr = message->payload; + + memcpy( &payload, payloadPtr, sizeof( ALARM_TRIGGERED_PAYLOAD_T ) ); + + if ( (ALARM_ID_T)(payload.alarm) < NUM_OF_ALARM_IDS ) + { + ALARM_DATA_T alm1, alm2; + + status = TRUE; + alm1.dataType = (ALARM_DATA_TYPES_T)(payload.almDataType1); + alm1.data.uInt.data = payload.almData1; + alm2.dataType = (ALARM_DATA_TYPES_T)(payload.almDataType2); + alm2.data.uInt.data = payload.almData2; + activateAlarm2Data( (ALARM_ID_T)(payload.alarm), alm1, alm2, TRUE ); + } + } + + return status; +} + +/*********************************************************************//** + * @brief + * The handleAlarmConditionCleared function handles the cleared alarm from + * the other stacks. + * @details \b Inputs: none + * @details \b Outputs: none + * @param message Pointer to the cleared alarm message + * @return TRUE if message handled successfully, FALSE if not + *************************************************************************/ +BOOL handleAlarmConditionCleared( MESSAGE_T *message ) +{ + BOOL status = FALSE; + + if ( message->hdr.payloadLen == sizeof( U32 ) ) + { + U08 *payloadPtr = message->payload; + U32 alarmID; + + memcpy( &alarmID, payloadPtr, sizeof( U32 ) ); + + if ( (ALARM_ID_T)alarmID < NUM_OF_ALARM_IDS ) + { + clearAlarmCondition( (ALARM_ID_T)alarmID ); + status = TRUE; + } + } + + return status; +} + +/*********************************************************************//** + * @brief + * The handleAlarmUserAction function handles the alarm user action that is + * received from the UI. + * @details \b Inputs: none + * @details \b Outputs: none + * @param message Pointer to the user action request message + * @return TRUE if message handled successfully, FALSE if not + *************************************************************************/ +BOOL handleAlarmUserAction( MESSAGE_T *message ) +{ + BOOL status = FALSE; + + if ( message->hdr.payloadLen == sizeof( U32 ) ) + { + U08 *payloadPtr = message->payload; + U32 action; + + memcpy( &action, payloadPtr, sizeof( U32 ) ); + + if ( (ALARM_USER_ACTION_T)action < NUMBER_OF_ALARM_USER_ACTIONS ) + { + signalAlarmUserActionInitiated( (ALARM_USER_ACTION_T)action ); + status = TRUE; + } + } + + return status; +} + +/*********************************************************************//** + * @brief * The handleActiveAlarmListRequest function handles the active alarms list * request from 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 +* @details \b Outputs: none +* @return TRUE if request handled successfully, FALSE if not *************************************************************************/ -void handleActiveAlarmListRequest( void ) +BOOL handleActiveAlarmListRequest( MESSAGE_T *message ) { ACTIVE_ALARM_LIST_RESPONSE_PAYLOAD_T activeAlarmPayload; + BOOL result; U32 index; U32 activeAlarmListIndex = 0; - activeAlarmPayload.accepted = TRUE; - activeAlarmPayload.rejectionReason = (U32)REQUEST_REJECT_REASON_NONE; - // Blank alarm list initially for ( index = 0; index < MAX_ALARM_LIST_SIZE; index++ ) { activeAlarmPayload.activeAlarmList[ index ] = ALARM_ID_NO_ALARM; } - // Fill alarm list from (up to) 10 highest priority active alarms - if ( TRUE == isAnyAlarmActive() ) + if ( 0 == message->hdr.payloadLen ) { - for ( index = 0; index < NUM_OF_ALARM_IDS; index++ ) - { - ALARM_RANK_T ranks = getAlarmRank( index ); + activeAlarmPayload.accepted = TRUE; + activeAlarmPayload.rejectionReason = (U32)REQUEST_REJECT_REASON_NONE; - if ( ( TRUE == isAlarmActive( ranks.alarmID ) ) && ( activeAlarmListIndex < MAX_ALARM_LIST_SIZE ) ) + // Fill alarm list from (up to) 10 highest priority active alarms + if ( TRUE == isAnyAlarmActive() ) + { + for ( index = 0; index < NUM_OF_ALARM_IDS; index++ ) { - activeAlarmPayload.activeAlarmList[ activeAlarmListIndex ] = ranks.alarmID; - activeAlarmListIndex++; + ALARM_RANK_T ranks = getAlarmRank( index ); + + if ( ( TRUE == isAlarmActive( ranks.alarmID ) ) && ( activeAlarmListIndex < MAX_ALARM_LIST_SIZE ) ) + { + activeAlarmPayload.activeAlarmList[ activeAlarmListIndex ] = ranks.alarmID; + activeAlarmListIndex++; + } } } } + else + { + activeAlarmPayload.accepted = FALSE; + activeAlarmPayload.rejectionReason = (U32)REQUEST_REJECT_REASON_INVALID_REQUEST_FORMAT; + } -// TODO sendActiveAlarmsList( activeAlarmPayload ); + result = sendMessage( MSG_ID_TD_ACTIVE_ALARMS_LIST_REQUEST_RESPONSE, COMM_BUFFER_OUT_CAN_TD_2_UI, (U08*)(&activeAlarmPayload), sizeof( ACTIVE_ALARM_LIST_RESPONSE_PAYLOAD_T ) ); + + return result; } /*********************************************************************//** @@ -760,6 +868,27 @@ } } } + +/*********************************************************************//** + * @brief + * The handleAutoResumeAlarm function handles the auto resume status of an alarm. + * @details \b Inputs: alarmStatus + * @details \b Outputs: none + * @param alarmID ID of alarm to be handled. + * @return none + *************************************************************************/ +void handleAutoResumeAlarm( ALARM_ID_T alarm ) +{ + ALARM_T props = getAlarmProperties( alarm ); + + if ( TRUE == props.alarmAutoResume ) + { + if ( ( alarm == alarmStatus.alarmTop ) && ( FALSE == alarmStatus.noResume ) ) + { + signalAlarmUserActionInitiated( ALARM_USER_ACTION_RESUME ); + } + } +} /*********************************************************************//** * @brief @@ -809,7 +938,7 @@ if ( CONFIRMATION_REQUEST_STATUS_ACCEPTED == getConfirmationRequestStatus( GENERIC_CONFIRM_ID_TREATMENT_END ) ) { // To avoid raising repeated alarm before reaching end treatment -// setVenousBubbleDetectionEnabled( FALSE ); + setVenousBubbleDetectionEnabled( H18_BBLD, FALSE ); clearAllRecoverableAlarms( ALARM_USER_ACTION_END_TREATMENT ); initiateAlarmAction( ALARM_ACTION_END_TREATMENT ); }