alma::acsplugins::alarmsystem::gui::sound::AlarmSound Class Reference

Inheritance diagram for alma::acsplugins::alarmsystem::gui::sound::AlarmSound:
Inheritance graph
[legend]
Collaboration diagram for alma::acsplugins::alarmsystem::gui::sound::AlarmSound:
Collaboration graph
[legend]

List of all members.

Public Member Functions

 AlarmSound (AlarmTableModel model)
void inhibit (int level)
int getSoundLevel ()
void close ()
void run ()
void addSoundListener (AlarmSoundListener listener)

Private Member Functions

void play (int priority) throws Exception
void playOnLine (SourceDataLine line, AudioInputStream audioIStream)
void dumpAudioInformation ()

Private Attributes

final AlarmTableModel tableModel
final int EXTERNAL_BUFFER_SIZE = 524288
int soundLevel = 3
int inhibitCounter = 0
final Timer timer = new Timer("AlarmSound",true)
boolean closed = false
volatile AlarmSoundListener listener = null

Static Private Attributes

static final int TIME_INTERVAL = 60
static final int INHIBIT_TIME = 15
static final URL[] soundURLs

Detailed Description

A class to play sounds for alarms.

The class emits a sound every TIME_INTERVAL seconds if the table contains alarms not seen by the user. The sound depends on the highest priority of the alarms not seen i.e. every priority has its own specific sound.

It is possible to inhibit the sound for a given period of time, INHIBIT_TIME. After INHIBIT_TIME seconds, the sounds will be re-enabled.

In case of error playing a sound, objects of this class do nothing because we do not want to trigger a failure in the application neither to present a dialog to the operator. Apart of that, if the audio system is in use by another application then it might happen that it is not possible to reserve a new line and play the sound.;

Note: after testing in tf-ohg I have found that the STE sound environment is quite problematic. for example in my account there were 4 mixers but I have tried another one that add only one and in that case it was not possible to find a line to play the sound. With my account, even with 4 mixers available the process was able to play the sound but not in the speakers.
To limit the risk that the sound is played in the wrong device or that the line obtained by default is not available because locked by another application and so n, I decided to play the sound in all available devices with the risk to play it twice.

Author:
acaproni
Since:
ACS 8.1.0

Constructor & Destructor Documentation

alma::acsplugins::alarmsystem::gui::sound::AlarmSound::AlarmSound ( AlarmTableModel  model  )  [inline]

Constructor

Parameters:
model The table model

References dumpAudioInformation(), tableModel, TIME_INTERVAL, and timer.


Member Function Documentation

void alma::acsplugins::alarmsystem::gui::sound::AlarmSound::addSoundListener ( AlarmSoundListener  listener  )  [inline]

Add or remove a listener

Parameters:
listener If not null add the listener; otherwise remove the listener

Referenced by alma::acsplugins::alarmsystem::gui::toolbar::SoundWidget::SoundWidget().

void alma::acsplugins::alarmsystem::gui::sound::AlarmSound::close (  )  [inline]

Close the timer.

References closed, listener, and timer.

Referenced by alma::acsplugins::alarmsystem::gui::CernSysPanel::close().

void alma::acsplugins::alarmsystem::gui::sound::AlarmSound::dumpAudioInformation (  )  [inline, private]

Dump info about supported audio, file types and so on...

This method is useful while updating the audio files.

References soundURLs.

Referenced by AlarmSound().

int alma::acsplugins::alarmsystem::gui::sound::AlarmSound::getSoundLevel (  )  [inline]

Return the inhibit sound level

Returns:
thethe inhibit sound level
See also:
AlarmSound#soundLevel

References soundLevel.

void alma::acsplugins::alarmsystem::gui::sound::AlarmSound::inhibit ( int  level  )  [inline]

Set the level of the alarm to which a sound has to be played.

Parameters:
level The new level of the sound to play; level must be in the same range of AlarmSound#soundLevel.
See also:
AlarmSound#soundLevel

References inhibitCounter, and soundLevel.

Referenced by alma::acsplugins::alarmsystem::gui::toolbar::SoundWidget::toggleSoundButton().

void alma::acsplugins::alarmsystem::gui::sound::AlarmSound::play ( int  priority  )  throws Exception [inline, private]

Play the sound for the given priority

Parameters:
priority The priority of the alarm

References EXTERNAL_BUFFER_SIZE, playOnLine(), and soundURLs.

Referenced by run().

void alma::acsplugins::alarmsystem::gui::sound::AlarmSound::playOnLine ( SourceDataLine  line,
AudioInputStream  audioIStream 
) [inline, private]

Play the sound using the passed line.

Parameters:
line 
audioIStream 

References EXTERNAL_BUFFER_SIZE.

Referenced by play().

void alma::acsplugins::alarmsystem::gui::sound::AlarmSound::run (  )  [inline]

Member Data Documentation

true if the object has been close.

Referenced by close().

The size of the buffer

Referenced by play(), and playOnLine().

Inhibit the sound for the given amount of seconds.

The INHIBIT_TIME is a multiple of TIME_INTERVAL.

Referenced by run().

The counter to re-enable the level

It is reset to 0 when a new level is selected or after INHIBIT_CONTER seconds.

Referenced by inhibit(), and run().

A listener for sound events.

This class supports only one listener; if more then one listener is added then only the last one will be notified.

Referenced by close(), and run().

Objects of this class plays a sound when the priority of an unseen alarm is equal or less then soundLevel appears in the table.

It is not possible to inhibit alarms having priority 0 or 1 therefore this property can only have values in range [1-3]

Referenced by getSoundLevel(), inhibit(), and run().

Initial value:
 {
                AlarmSound.class.getResource("/alma/acsplugins/alarmsystem/gui/sound/resources/level0.wav"),
                AlarmSound.class.getResource("/alma/acsplugins/alarmsystem/gui/sound/resources/level1.wav"),
                AlarmSound.class.getResource("/alma/acsplugins/alarmsystem/gui/sound/resources/level2.wav"),
                AlarmSound.class.getResource("/alma/acsplugins/alarmsystem/gui/sound/resources/level3.wav")
        }

The URLs of the sounds to play.

The index of the array correspond to the level of the alarm i.e. for alarms with level=0 the sound to play is soundURLs[0].

Referenced by dumpAudioInformation(), and play().

The table model

Referenced by AlarmSound(), and run().

A sound is emitted every TIME_INTERVAL seconds

Referenced by AlarmSound().

final Timer alma::acsplugins::alarmsystem::gui::sound::AlarmSound::timer = new Timer("AlarmSound",true) [private]

The timer to emit the sound

Referenced by AlarmSound(), and close().


The documentation for this class was generated from the following file:

Generated by  doxygen 1.6.2