Skip to content

Commit

Permalink
Merge branch 'master' into CSSTUDIO-2072
Browse files Browse the repository at this point in the history
  • Loading branch information
abrahamwolk committed Apr 24, 2024
2 parents d63fbf8 + 0493d3b commit 2269d1e
Show file tree
Hide file tree
Showing 218 changed files with 10,089 additions and 948 deletions.
6 changes: 3 additions & 3 deletions app/alarm/Readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,9 @@ kafka in `/opt/kafka`.
cd examples

# Use wget, 'curl -O', or web browser to fetch a recent version of kafka
wget https://downloads.apache.org/kafka/3.3.1/kafka_2.13-3.3.1.tgz
tar vzxf kafka_2.13-3.3.1.tgz
ln -s kafka_2.13-3.3.1 kafka
wget https://downloads.apache.org/kafka/3.6.1/kafka_2.13-3.6.1.tgz
tar vzxf kafka_2.13-3.6.1.tgz
ln -s kafka_2.13-3.6.1 kafka

Check `config/zookeeper.properties` and `config/server.properties`.
By default these contain settings for keeping data in `/tmp/`, which works for initial tests,
Expand Down
21 changes: 21 additions & 0 deletions app/alarm/audio-annunciator/.classpath
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>
20 changes: 20 additions & 0 deletions app/alarm/audio-annunciator/build.xml
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>
31 changes: 31 additions & 0 deletions app/alarm/audio-annunciator/pom.xml
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>
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();
});
}
}
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;
}
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
org.phoebus.applications.alarm.audio.annunciator.AudioAnnunciator
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 not shown.
21 changes: 21 additions & 0 deletions app/alarm/freetts-annunciator/.classpath
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>
20 changes: 20 additions & 0 deletions app/alarm/freetts-annunciator/build.xml
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>
32 changes: 32 additions & 0 deletions app/alarm/freetts-annunciator/pom.xml
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>
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();
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
org.phoebus.applications.alarm.freetts.annunciator.FreeTTSAnnunciator
Loading

0 comments on commit 2269d1e

Please sign in to comment.