Index: firmware/App/Services/AlarmMgmt.c =================================================================== diff -u -r90f6438e80dbe0a32472a076a0d1bc54db65d15a -r3417fd56afc9b21fb4c2d86c75dd33ac31fbd9f1 --- firmware/App/Services/AlarmMgmt.c (.../AlarmMgmt.c) (revision 90f6438e80dbe0a32472a076a0d1bc54db65d15a) +++ firmware/App/Services/AlarmMgmt.c (.../AlarmMgmt.c) (revision 3417fd56afc9b21fb4c2d86c75dd33ac31fbd9f1) @@ -20,31 +20,16 @@ #include "AlarmLamp.h" #include "OperationModes.h" #include "SystemCommMessages.h" +#include "TaskGeneral.h" #include "Timers.h" // ********** private definitions ********** +#define ALARM_STATUS_PUBLISH_INTERVAL (500/TASK_GENERAL_INTERVAL) // 500ms / task interval + #pragma pack(push,1) typedef struct { - ALARM_PRIORITY_T alarmsState; // current alarm priority level - BOOL alarmsSilenced; // alarms are currently silenced? - U32 alarmsSilenceStart; // time stamp for when alarms were silenced (ms) - U32 alarmsSilenceExpiresIn; // time until alarm silence expires (seconds) - U32 alarmsEscalatesIn; // time until alarm will escalate (seconds) - ALARM_ID_T alarmTop; // ID of current top alarm that will drive lamp/audio and UI should be displaying right now - BOOL systemFault; // a system fault is active? - BOOL stop; // we should be in controlled stop right now - BOOL noClear; // no recovery will be possible - BOOL noResume; // treatment may not be resumed at this time - BOOL noRinseback; // rinseback may not be initiated at this time - BOOL noEndTreatment; // ending the treatment is not an option at this time - BOOL noNewTreatment; // no new treatments may be started even if current treatment is ended - BOOL bypassDialyzer; // the dialyzer should be bypassed at this time -} COMP_ALARM_STATUS_T; - -typedef struct -{ ALARM_PRIORITY_T alarmPriority; // priority of alarm U32 alarmEscalatesAfter; // time (s) after start when alarm will escalate if not cleared (zero indicates no escalation) ALARM_ID_T alarmEscalatesTo; // ID of alarm that this alarm will escalate to (ALARM_ID_NO_ALARM indicates no esclation) @@ -69,6 +54,10 @@ // ********** private data ********** +static U32 alarmStatusPublicationTimerCounter = 0; // used to schedule alarm status publication to CAN bus +// interval (in ms) at which to publish alarm status to CAN bus +DATA_DECL( U32, AlarmStatusPub, alarmStatusPublishInterval, ALARM_STATUS_PUBLISH_INTERVAL, ALARM_STATUS_PUBLISH_INTERVAL ); + DATA_ARRAY_DECL( BOOL, AlarmStates, NUM_OF_ALARM_IDS, alarmIsActive ); DATA_ARRAY_DECL( U32, AlarmStarts, NUM_OF_ALARM_IDS, alarmStartedAt ); @@ -90,6 +79,7 @@ static DATA_ARRAY_GET_PROTOTYPE( BOOL, getAlarmActive, alarmID ); static DATA_ARRAY_GET_PROTOTYPE( U32, getAlarmStartTime, alarmID ); +static DATA_GET_PROTOTYPE( U32, getPublishAlarmStatusInterval ); /************************************************************************* * @brief initAlarmMgmt @@ -157,7 +147,12 @@ updateAlarmsFlags(); updateAlarmsSilenceStatus(); setAlarmLampAndAudio(); - // TODO - publish alarms status record to rest of system + // publish alarm status at interval + if ( ++alarmStatusPublicationTimerCounter > getPublishAlarmStatusInterval() ) + { + broadcastAlarmStatus( alarmStatus ); + alarmStatusPublicationTimerCounter = 0; + } } /************************************************************************* @@ -177,7 +172,7 @@ // if alarm is a fault and not already triggered, request transition to fault mode if ( ( FALSE == getAlarmActive(alarm) ) && ( TRUE == alarmTable[alarm].alarmIsFault ) ) { -// requestNewOperationMode( MODE_FAUL ); + requestNewOperationMode( MODE_FAUL ); } // activate alarm alarmIsActive[alarm].data = TRUE; @@ -475,13 +470,74 @@ } } +/************************************************************************* + * @brief getPublishAlarmStatusInterval + * The getPublishAlarmStatusInterval function gets the alarm status \n + * publication interval. + * @details + * Inputs : alarmStatusPublishInterval + * Outputs : none + * @param none + * @return the current alarm status publication interval (in ms). + *************************************************************************/ +DATA_GET( U32, getPublishAlarmStatusInterval, alarmStatusPublishInterval ) + /************************************************************************* * TEST SUPPORT FUNCTIONS *************************************************************************/ /************************************************************************* + * @brief testSetAlarmStatusPublishIntervalOverride + * The testSetAlarmStatusPublishIntervalOverride function overrides the \n + * alarm status publish interval. + * @details + * Inputs : none + * Outputs : alarmStatusPublishInterval + * @param value : override blood flow data publish interval with (in ms) + * @return TRUE if override successful, FALSE if not + *************************************************************************/ +BOOL testSetAlarmStatusPublishIntervalOverride( U32 value ) +{ + BOOL result = FALSE; + + if ( TRUE == isTestingActivated() ) + { + U32 intvl = value / TASK_GENERAL_INTERVAL; + + result = TRUE; + alarmStatusPublishInterval.ovData = intvl; + alarmStatusPublishInterval.override = OVERRIDE_KEY; + } + + return result; +} + +/************************************************************************* + * @brief testResetAlarmStatusPublishIntervalOverride + * The testResetAlarmStatusPublishIntervalOverride function resets the override \n + * of the alarm status publish interval. + * @details + * Inputs : none + * Outputs : alarmStatusPublishInterval + * @return TRUE if override reset successful, FALSE if not + *************************************************************************/ +BOOL testResetAlarmStatusPublishIntervalOverride( void ) +{ + BOOL result = FALSE; + + if ( TRUE == isTestingActivated() ) + { + result = TRUE; + alarmStatusPublishInterval.override = OVERRIDE_RESET; + alarmStatusPublishInterval.ovData = alarmStatusPublishInterval.ovInitData; + } + + return result; +} + +/************************************************************************* * @brief testSetAlarmStateOverride and testResetAlarmStateOverride * The testSetAlarmStateOverride function overrides the state of the \n * alarm active state for a given alarm with the alarm management with \n