

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 |
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.
| alma::acsplugins::alarmsystem::gui::sound::AlarmSound::AlarmSound | ( | AlarmTableModel | model | ) | [inline] |
Constructor
| model | The table model |
References dumpAudioInformation(), tableModel, TIME_INTERVAL, and timer.
| void alma::acsplugins::alarmsystem::gui::sound::AlarmSound::addSoundListener | ( | AlarmSoundListener | listener | ) | [inline] |
Add or remove a listener
| 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
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.
| level | The new level of the sound to play; level must be in the same range of 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
| 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.
| line | ||
| audioIStream |
References EXTERNAL_BUFFER_SIZE.
Referenced by play().
| void alma::acsplugins::alarmsystem::gui::sound::AlarmSound::run | ( | ) | [inline] |
The task to emit the sound.
References alma::acsplugins::alarmsystem::gui::table::AlarmTableModel::hasNotAckAlarms(), INHIBIT_TIME, inhibitCounter, listener, play(), alma::acsplugins::alarmsystem::gui::sound::AlarmSoundListener::played(), alma::acsplugins::alarmsystem::gui::sound::AlarmSoundListener::playing(), soundLevel, and tableModel.
boolean alma::acsplugins::alarmsystem::gui::sound::AlarmSound::closed = false [private] |
true if the object has been close.
Referenced by close().
final int alma::acsplugins::alarmsystem::gui::sound::AlarmSound::EXTERNAL_BUFFER_SIZE = 524288 [private] |
The size of the buffer
Referenced by play(), and playOnLine().
final int alma::acsplugins::alarmsystem::gui::sound::AlarmSound::INHIBIT_TIME = 15 [static, private] |
Inhibit the sound for the given amount of seconds.
The INHIBIT_TIME is a multiple of TIME_INTERVAL.
Referenced by run().
int alma::acsplugins::alarmsystem::gui::sound::AlarmSound::inhibitCounter = 0 [private] |
volatile AlarmSoundListener alma::acsplugins::alarmsystem::gui::sound::AlarmSound::listener = null [private] |
int alma::acsplugins::alarmsystem::gui::sound::AlarmSound::soundLevel = 3 [private] |
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().
final URL [] alma::acsplugins::alarmsystem::gui::sound::AlarmSound::soundURLs [static, private] |
{
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().
final int alma::acsplugins::alarmsystem::gui::sound::AlarmSound::TIME_INTERVAL = 60 [static, private] |
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().
1.6.2