Sound Player delay

The new Sound Player component is great, neatly getting round the problem of having to have the same .wav file available on every View node.

I would like to use this to drive an alarm if there are any unacknowledged alarms on the system. However, doing this with a typical .wav file would rapidly drive operators mad, with the sound playing over and over with no delay. It would be nice to have a user-configurable delay after the file has been played, so you could for example play it every 5 seconds.

Yeah, thats a good idea. So you want the ON_TRIGGER / LOOP_FOREVER mode to have a delay in between plays, right?

In the meantime, this would be pretty easy to rig up yourself with a Timer component.

Yes, a delay in between plays in ON_TRIGGER / LOOP_FOREVER mode would be ideal.

I achieved the same functionality previously (with Bobby’s help) by putting the following code in a Global Event Script:

try: value = fpmi.tag.getTagValue("[]Misc/All alarm_unack") if value == 1: fpmi.system.execute(["sndrec32", "/play", "/close", "/embedding", "C:\\windows\\media\\ringin.wav"]) except: print "Error occurred playing alarm sound."
This works well and is not tied to one window, but requires every machine to have the .wav file in the same place.

Following your suggestion I got the Sound Player / Timer combination working by setting the ‘Delay’ to 100ms, ‘Step by’ 'to 1 and ‘Bound’ to 5, with its ‘Running’ property linked to the point indicating something is in alarm.

I then set the Sound Player to trigger when the Timer’s value was 1, only playing the sound once. This works, playing the sound once every 5 seconds, with the gotcha that it can take up to 4 seconds to first annunciate the alarm, depending on the value of the Timer. This needs reset somewhere when the value of the trigger drops to zero…

A property change script sound like a good candidate for a reset. Also, I think you meant 1000ms?

Yes, it should have been 1000ms. :slight_smile:

I was puzzling over how to use a property change script to respond to a change in value of a point in the database. I eventually added a new Dynamic Property to the Sound Player which was linked to the value of the input used to set off the alarm. The following script in the Sound Player propertyChange event then resets the Timer value:if event.propertyName == 'Alarm_Clear': if event.newValue == 0: event.source.parent.getComponent('Timer').value = 0This works, but seems a bit ‘involved’. Maybe its just the change from previous SCADA packages we’ve used, where things like this were done in discrete chunks of code. The approach of linking things together is more elegant but perhaps more opaque. Is there any tool which would run through a window and produce a list of dependencies for documentation purposes?

Would it be possible to combine the benefits of the Global Event Script approach (no need to put a Sound Player on a window which is always kept open; ability to trigger script at predefined intervals) with the benefit of the Sound Player (sound file held in the system configuration) by storing a sound file in a blob field in the database and loading this when the global script runs?

My next questions of course are how to load the file into a blob field and how to extract it again and use it as a sound file. Is this possible?

No, not currently, but such a feature has been discussed before...

[quote="AlThePal"]Would it be possible to combine the benefits of the Global Event Script approach (no need to put a Sound Player on a window which is always kept open; ability to trigger script at predefined intervals) with the benefit of the Sound Player (sound file held in the system configuration) by storing a sound file in a blob field in the database and loading this when the global script runs?

My next questions of course are how to load the file into a blob field and how to extract it again and use it as a sound file. Is this possible?[/quote]

Yeah, you can do this already. See this post.

Thanks Carl, that works well. Nathan’s post didn’t explain how to load a blob into the database, but it turns out you can do this using the MySQL Query Browser.