-
Notifications
You must be signed in to change notification settings - Fork 90
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'master' into CSSTUDIO-2072
- Loading branch information
Showing
218 changed files
with
10,089 additions
and
948 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<classpath> | ||
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"> | ||
<attributes> | ||
<attribute name="module" value="true"/> | ||
</attributes> | ||
</classpathentry> | ||
<classpathentry kind="src" output="target/classes" path="src/main/java"/> | ||
<classpathentry kind="src" output="target/classes" path="src/main/resources"/> | ||
<classpathentry kind="src" output="target/classes" path="src/test/java"/> | ||
<classpathentry kind="con" path="org.eclipse.jdt.junit.JUNIT_CONTAINER/4"/> | ||
<classpathentry combineaccessrules="false" kind="src" path="/phoebus-target"/> | ||
<classpathentry combineaccessrules="false" kind="src" path="/core-framework"/> | ||
<classpathentry combineaccessrules="false" kind="src" path="/core-types"/> | ||
<classpathentry combineaccessrules="false" kind="src" path="/core-util"/> | ||
<classpathentry combineaccessrules="false" kind="src" path="/core-security"/> | ||
<classpathentry combineaccessrules="false" kind="src" path="/core-ui"/> | ||
<classpathentry combineaccessrules="false" kind="src" path="/app-alarm-model"/> | ||
<classpathentry combineaccessrules="false" kind="src" path="/app-alarm-ui"/> | ||
<classpathentry kind="output" path="target/classes"/> | ||
</classpath> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
<project default="app-alarm-ui"> | ||
<import file="../../../dependencies/ant_settings.xml"/> | ||
|
||
<target name="app-alarm-audio-annunciator"> | ||
<mkdir dir="${classes}"/> | ||
<javac destdir="${classes}" debug="${debug}"> | ||
<src path="${src}"/> | ||
<classpath> | ||
<path refid="app-classpath"/> | ||
<pathelement path="../model/${build}/app-alarm-ui-${version}.jar"/> | ||
</classpath> | ||
</javac> | ||
|
||
<jar destfile="${build}/app-alarm-audio-annunciator-${version}.jar"> | ||
<fileset dir="${classes}"/> | ||
<fileset dir="${resources}"/> | ||
</jar> | ||
</target> | ||
|
||
</project> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<project xmlns="http://maven.apache.org/POM/4.0.0" | ||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> | ||
<modelVersion>4.0.0</modelVersion> | ||
<parent> | ||
<groupId>org.phoebus</groupId> | ||
<artifactId>app-alarm</artifactId> | ||
<version>4.7.4-SNAPSHOT</version> | ||
</parent> | ||
<artifactId>app-alarm-audio-annunciator</artifactId> | ||
|
||
<properties> | ||
<maven.compiler.source>17</maven.compiler.source> | ||
<maven.compiler.target>17</maven.compiler.target> | ||
</properties> | ||
|
||
<dependencies> | ||
<dependency> | ||
<groupId>org.phoebus</groupId> | ||
<artifactId>app-alarm-ui</artifactId> | ||
<version>4.7.4-SNAPSHOT</version> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.openjfx</groupId> | ||
<artifactId>javafx-media</artifactId> | ||
<version>${openjfx.version}</version> | ||
</dependency> | ||
</dependencies> | ||
|
||
</project> |
84 changes: 84 additions & 0 deletions
84
...ator/src/main/java/org/phoebus/applications/alarm/audio/annunciator/AudioAnnunciator.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,84 @@ | ||
/******************************************************************************* | ||
* Copyright (c) 2018 Oak Ridge National Laboratory. | ||
* All rights reserved. This program and the accompanying materials | ||
* are made available under the terms of the Eclipse Public License v1.0 | ||
* which accompanies this distribution, and is available at | ||
* http://www.eclipse.org/legal/epl-v10.html | ||
*******************************************************************************/ | ||
package org.phoebus.applications.alarm.audio.annunciator; | ||
|
||
import javafx.scene.media.AudioClip; | ||
import javafx.scene.media.Media; | ||
import javafx.scene.media.MediaPlayer; | ||
import javafx.util.Duration; | ||
import org.phoebus.applications.alarm.ui.annunciator.Annunciator; | ||
import org.phoebus.applications.alarm.ui.annunciator.AnnunciatorMessage; | ||
|
||
import java.util.List; | ||
|
||
/** | ||
* Annunciator class. Uses Audio files to annunciate passed messages. | ||
* | ||
* @author Kunal Shroff | ||
*/ | ||
@SuppressWarnings("nls") | ||
public class AudioAnnunciator implements Annunciator { | ||
private final MediaPlayer alarmSound; | ||
private final MediaPlayer minorAlarmSound; | ||
private final MediaPlayer majorAlarmSound; | ||
private final MediaPlayer invalidAlarmSound; | ||
private final MediaPlayer undefinedAlarmSound; | ||
|
||
/** | ||
* Constructor | ||
*/ | ||
public AudioAnnunciator() { | ||
alarmSound = new MediaPlayer(new Media(Preferences.alarm_sound_url)); | ||
minorAlarmSound = new MediaPlayer(new Media(Preferences.minor_alarm_sound_url)); | ||
majorAlarmSound = new MediaPlayer(new Media(Preferences.major_alarm_sound_url)); | ||
invalidAlarmSound = new MediaPlayer(new Media(Preferences.invalid_alarm_sound_url)); | ||
undefinedAlarmSound = new MediaPlayer(new Media(Preferences.undefined_alarm_sound_url)); | ||
// configure the media players for the different alarm sounds | ||
List.of(alarmSound, minorAlarmSound, majorAlarmSound, invalidAlarmSound, undefinedAlarmSound) | ||
.forEach(sound -> { | ||
sound.setStopTime(Duration.seconds(Preferences.max_alarm_duration)); | ||
sound.setVolume(Preferences.volume); | ||
}); | ||
} | ||
|
||
/** | ||
* Annunciate the message. | ||
* | ||
* @param message Message text | ||
*/ | ||
@Override | ||
public void speak(final AnnunciatorMessage message) { | ||
switch (message.severity) { | ||
case MINOR -> speakAlone(minorAlarmSound); | ||
case MAJOR -> speakAlone(majorAlarmSound); | ||
case INVALID -> speakAlone(invalidAlarmSound); | ||
case UNDEFINED -> speakAlone(undefinedAlarmSound); | ||
default -> speakAlone(alarmSound); | ||
} | ||
} | ||
|
||
synchronized private void speakAlone(MediaPlayer alarm) { | ||
List.of(alarmSound, minorAlarmSound, majorAlarmSound, invalidAlarmSound, undefinedAlarmSound) | ||
.forEach(sound -> { | ||
sound.stop(); | ||
}); | ||
alarm.play(); | ||
} | ||
|
||
/** | ||
* Deallocates the voice. | ||
*/ | ||
@Override | ||
public void shutdown() { | ||
List.of(alarmSound, minorAlarmSound, majorAlarmSound, invalidAlarmSound, undefinedAlarmSound) | ||
.forEach(sound -> { | ||
sound.stop(); | ||
sound.dispose(); | ||
}); | ||
} | ||
} |
63 changes: 63 additions & 0 deletions
63
...nunciator/src/main/java/org/phoebus/applications/alarm/audio/annunciator/Preferences.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
/******************************************************************************* | ||
* Copyright (c) 2010-2022 Oak Ridge National Laboratory. | ||
* All rights reserved. This program and the accompanying materials | ||
* are made available under the terms of the Eclipse Public License v1.0 | ||
* which accompanies this distribution, and is available at | ||
* http://www.eclipse.org/legal/epl-v10.html | ||
******************************************************************************/ | ||
package org.phoebus.applications.alarm.audio.annunciator; | ||
|
||
|
||
import org.phoebus.framework.preferences.AnnotatedPreferences; | ||
import org.phoebus.framework.preferences.Preference; | ||
import org.phoebus.framework.preferences.PreferencesReader; | ||
|
||
/** | ||
* Helper for reading preference settings | ||
* | ||
* @author Kunal Shroff | ||
*/ | ||
@SuppressWarnings("nls") | ||
public class Preferences { | ||
|
||
/** | ||
* Setting | ||
*/ | ||
@Preference | ||
public static String alarm_sound_url; | ||
@Preference | ||
public static String minor_alarm_sound_url; | ||
@Preference | ||
public static String major_alarm_sound_url; | ||
@Preference | ||
public static String invalid_alarm_sound_url; | ||
@Preference | ||
public static String undefined_alarm_sound_url; | ||
@Preference | ||
public static int volume; | ||
@Preference | ||
public static int max_alarm_duration; | ||
|
||
static { | ||
final PreferencesReader prefs = AnnotatedPreferences.initialize(AudioAnnunciator.class, Preferences.class, "/audio_annunciator_preferences.properties"); | ||
alarm_sound_url = useLocalResourceIfUnspecified(alarm_sound_url); | ||
minor_alarm_sound_url = useLocalResourceIfUnspecified(minor_alarm_sound_url); | ||
major_alarm_sound_url = useLocalResourceIfUnspecified(major_alarm_sound_url); | ||
invalid_alarm_sound_url = useLocalResourceIfUnspecified(invalid_alarm_sound_url); | ||
undefined_alarm_sound_url = useLocalResourceIfUnspecified(undefined_alarm_sound_url); | ||
} | ||
|
||
private static String useLocalResourceIfUnspecified(String alarmResource) { | ||
if (alarmResource == null || alarmResource.isEmpty()) { | ||
// If only the alarm sound url is set, in a case where we want to use the same alarm sound for all severties | ||
if (!alarm_sound_url.isEmpty()) { | ||
return alarm_sound_url; | ||
} else { | ||
return Preferences.class.getResource("/sounds/mixkit-classic-alarm-995.wav").toString(); | ||
} | ||
} else { | ||
return alarmResource; | ||
} | ||
} | ||
|
||
} |
1 change: 1 addition & 0 deletions
1
...ain/resources/META-INF/services/org.phoebus.applications.alarm.ui.annunciator.Annunciator
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
org.phoebus.applications.alarm.audio.annunciator.AudioAnnunciator |
23 changes: 23 additions & 0 deletions
23
app/alarm/audio-annunciator/src/main/resources/audio_annunciator_preferences.properties
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
# ---------------------------------------- | ||
# Package org.phoebus.applications.alarm.audio.annunciator | ||
# ---------------------------------------- | ||
|
||
# The audio annunciator will play the audio files specified for the associated alarm severity levels. | ||
# Currently supported formats are AIFF and WAV files. | ||
# examples of audio file URL's, they can be local or remote files. | ||
# file:/C:/tmp/audio/AudioFileWithWavFormat.wav | ||
# https://wavlist.com/wav/brass1.wav | ||
|
||
# default alarm sound, if we don't want severity specific sounds only setting this one preference is enough | ||
alarm_sound_url= | ||
|
||
minor_alarm_sound_url= | ||
major_alarm_sound_url= | ||
invalid_alarm_sound_url= | ||
undefined_alarm_sound_url= | ||
|
||
# audio clip volume (0-100) | ||
volume=100 | ||
|
||
# max alarm Duration in seconds. | ||
max_alarm_duration=10 |
Binary file added
BIN
+866 KB
app/alarm/audio-annunciator/src/main/resources/sounds/mixkit-classic-alarm-995.wav
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<classpath> | ||
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"> | ||
<attributes> | ||
<attribute name="module" value="true"/> | ||
</attributes> | ||
</classpathentry> | ||
<classpathentry kind="src" output="target/classes" path="src/main/java"/> | ||
<classpathentry kind="src" output="target/classes" path="src/main/resources"/> | ||
<classpathentry kind="src" output="target/classes" path="src/test/java"/> | ||
<classpathentry kind="con" path="org.eclipse.jdt.junit.JUNIT_CONTAINER/4"/> | ||
<classpathentry combineaccessrules="false" kind="src" path="/phoebus-target"/> | ||
<classpathentry combineaccessrules="false" kind="src" path="/core-framework"/> | ||
<classpathentry combineaccessrules="false" kind="src" path="/core-types"/> | ||
<classpathentry combineaccessrules="false" kind="src" path="/core-util"/> | ||
<classpathentry combineaccessrules="false" kind="src" path="/core-security"/> | ||
<classpathentry combineaccessrules="false" kind="src" path="/core-ui"/> | ||
<classpathentry combineaccessrules="false" kind="src" path="/app-alarm-model"/> | ||
<classpathentry combineaccessrules="false" kind="src" path="/app-alarm-ui"/> | ||
<classpathentry kind="output" path="target/classes"/> | ||
</classpath> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
<project default="app-alarm-ui"> | ||
<import file="../../../dependencies/ant_settings.xml"/> | ||
|
||
<target name="app-alarm-freetts-annunciator"> | ||
<mkdir dir="${classes}"/> | ||
<javac destdir="${classes}" debug="${debug}"> | ||
<src path="${src}"/> | ||
<classpath> | ||
<path refid="app-classpath"/> | ||
<pathelement path="../model/${build}/app-alarm-ui-${version}.jar"/> | ||
</classpath> | ||
</javac> | ||
|
||
<jar destfile="${build}/app-alarm-freetts-annunciator-${version}.jar"> | ||
<fileset dir="${classes}"/> | ||
<fileset dir="${resources}"/> | ||
</jar> | ||
</target> | ||
|
||
</project> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<project xmlns="http://maven.apache.org/POM/4.0.0" | ||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> | ||
<modelVersion>4.0.0</modelVersion> | ||
<parent> | ||
<groupId>org.phoebus</groupId> | ||
<artifactId>app-alarm</artifactId> | ||
<version>4.7.4-SNAPSHOT</version> | ||
</parent> | ||
<artifactId>app-alarm-freetts-annunciator</artifactId> | ||
|
||
<properties> | ||
<maven.compiler.source>17</maven.compiler.source> | ||
<maven.compiler.target>17</maven.compiler.target> | ||
</properties> | ||
|
||
<dependencies> | ||
<dependency> | ||
<groupId>net.sf.sociaal</groupId> | ||
<artifactId>freetts</artifactId> | ||
<version>1.2.2</version> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.phoebus</groupId> | ||
<artifactId>app-alarm-ui</artifactId> | ||
<version>4.7.4-SNAPSHOT</version> | ||
<scope>compile</scope> | ||
</dependency> | ||
</dependencies> | ||
|
||
</project> |
55 changes: 55 additions & 0 deletions
55
.../src/main/java/org/phoebus/applications/alarm/freetts/annunciator/FreeTTSAnnunciator.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
/******************************************************************************* | ||
* Copyright (c) 2018 Oak Ridge National Laboratory. | ||
* All rights reserved. This program and the accompanying materials | ||
* are made available under the terms of the Eclipse Public License v1.0 | ||
* which accompanies this distribution, and is available at | ||
* http://www.eclipse.org/legal/epl-v10.html | ||
*******************************************************************************/ | ||
package org.phoebus.applications.alarm.freetts.annunciator; | ||
|
||
import com.sun.speech.freetts.Voice; | ||
import com.sun.speech.freetts.VoiceManager; | ||
import org.phoebus.applications.alarm.ui.annunciator.Annunciator; | ||
import org.phoebus.applications.alarm.ui.annunciator.AnnunciatorMessage; | ||
|
||
/** | ||
* Annunciator class. Uses freeTTS to annunciate passed messages. | ||
* @author Evan Smith, Kunal Shroff | ||
*/ | ||
@SuppressWarnings("nls") | ||
public class FreeTTSAnnunciator implements Annunciator | ||
{ | ||
private final VoiceManager voiceManager; | ||
private final Voice voice; | ||
private static final String voice_name = "kevin16"; | ||
|
||
/** Constructor */ | ||
public FreeTTSAnnunciator() | ||
{ | ||
// Define the voices directory. | ||
System.setProperty("freetts.voices", "com.sun.speech.freetts.en.us.cmu_us_kal.KevinVoiceDirectory"); | ||
voiceManager = VoiceManager.getInstance(); | ||
voice = voiceManager.getVoice(voice_name); | ||
voice.allocate(); | ||
} | ||
|
||
/** | ||
* Annunciate the message. Only returns once speaking finishes. | ||
* @param message Message text | ||
*/ | ||
@Override | ||
public void speak(final AnnunciatorMessage message) | ||
{ | ||
if (null != message) | ||
voice.speak(message.message); | ||
} | ||
|
||
/** | ||
* Deallocates the voice. | ||
*/ | ||
@Override | ||
public void shutdown() | ||
{ | ||
voice.deallocate(); | ||
} | ||
} |
1 change: 1 addition & 0 deletions
1
...ain/resources/META-INF/services/org.phoebus.applications.alarm.ui.annunciator.Annunciator
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
org.phoebus.applications.alarm.freetts.annunciator.FreeTTSAnnunciator |
Oops, something went wrong.