Help with audible alerts. Want to continually chime until acknowledged.
-
I've installed the user module that was supplied here: https://forum.infiniteautomation.com/topic/2986/events-table-refreshing/4
It works, but it only will chime once, when the alert is first thrown. This appears to be how it is supposed to work.
I don't know what internals of Mango this script hooks into, but is there a way to change the script such that the audio sample will continually retrigger (every x seconds let's say) until the event is acknowledged?
-
Hi rectifier,
One would do this by modifying the user module to subscribe to the acknowledge event and then using the Angular $interval() function to repeat the event audio, like,
define(['angular', 'require'], function(angular, require) { 'use strict'; var userModule = angular.module('userModule', ['maUiApp']); userModule.component('repeatingEventAudio', { bindings: { audioFile: '@', eventLevel: '@' }, controller: ['maEvents', '$scope', '$interval', function(maEvents, $scope, $interval) { this.activeInterval = null; this.$onInit = () => { maEvents.notificationManager.subscribe((event, mangoEvent) => { if(event.name === 'RAISED' && this.activeInterval === null && mangoEvent.alarmLevel === this.eventLevel) { new Audio(this.audioFile).play(); this.activeInterval = $interval( function(audioFile){ new Audio(audioFile).play(); }, 3000, 0, false, this.audioFile); } if(event.name === 'ACKNOWLEDGED' && this.activeInterval !== null && mangoEvent.alarmLevel === this.eventLevel) { $interval.cancel(this.activeInterval); } }, $scope, ['RAISED', 'ACKNOWLEDGED']); }; }] }); return userModule; }); // define
Note that this
<repeating-event-audio>
directive would start the audio when an event at that level was raised, and stop playing whenever any other event at that level was acknowledged. You may wish to get more specific, but hopefully this helps. -
This almost works. It does cause the audio to repeat until acknowledged. If you acknowledge the event from another tab, it works as expected.
However, if you click the events icon on the page that is playing the audio, it appears that the interval() persists but the rest of the script passes out of scope (I do not know JS at all by the way, I usually do embedded not web development) Now, when the event is acknowledged, that ACKNOWLEDGED is not detected. The audio will continue to repeat until the tab is closed. So, I was wondering if there are some simple alarm flags as well, or is there only this subscription based interface?
It seems a bit odd to me that the Mango new UI has no audible alerts built in. They are present in the old UI, work from every page and will continue to sound until acknowledged or silenced. To me this is the expected behaviour from an audible alert, and is necessary especially if a safety alarm is raised and the operator is not immediately present. Was this a design decision in the new UI?
-
There are audible alerts in the new UI. If your user is not "muted" in their user settings and you are logged in the event audio files configured in the Administration --> UI Settings --> Event audio files menu should play when an event at that level (or default if a level isn't specifically configured) is raised.
As to the consciousness of the omission of it repeating, or whether we'll add a setting to make it repeat, I don't know in this moment, perhaps Monday will bring an answer.
But, if it's in your interest, I suspect you would find adding that into the activeEventsIcon might have some straightforwardness to it.
Edit: This is the component that plays the audio files configured, https://github.com/infiniteautomation/ma-dashboards/blob/main/UI/web/ngMango/components/eventAudio/eventAudio.js
-
Oops, the default setting for both the admin user and newly created users is "Muted". Missed that. Yes, the new UI will sound audible alerts (once) once I un-muted the users.
Looking at activeEventsIcon.js and eventAudio.js it looks like it would make more sense to modify eventAudio.js seeing how it is sitting on the toolbar beside activeEventsIcon. It's already set up with features like isCurrentAudioPlayer() so that it doesn't play in every tab. And if I unmute the users and modify activeEventsIcon then I'm going to end up running two instances of audio.play() on the first run, which will clash with each other for a nasty sound.
Before I start trying to break my copy of eventAudio.js though, I'll wait and see if you guys are planning to add an option for a repeating alert. Makes more sense than me making an internal change that could be broken every time an update comes out. Thanks for your help!
-
@rectifier We can add that feature, we'll probably default it to not repeat and make it configurable from the UI settings page.
-
Thanks! I won't bother messing around with it then. The best way to implement it would probably be so that the administrator can configure it from the "Event audio files" section on a per-level basis, i.e. warning could be set to only be played once, but life safety would repeat indefinitely. This would save the operators from the annoyance of low level alarms repeating.
-
@rectifier I agree, good idea.