voice stuff cleaned up, added voice warning to logger dashboard

git-svn-id: http://svn.3splooges.com/romraider-arch/trunk@709 d2e2e1cd-ba16-0410-be16-b7c4453c7c2d
This commit is contained in:
kascade 2007-06-26 12:47:27 +00:00
parent aa166d986c
commit 8d182cef47
9 changed files with 85 additions and 98 deletions

View File

@ -36,8 +36,8 @@ public final class EcuConnectionImpl implements EcuConnection {
this.sendTimeout = connectionProperties.getSendTimeout(); this.sendTimeout = connectionProperties.getSendTimeout();
// Use TestSSMConnectionImpl for testing!! // Use TestSSMConnectionImpl for testing!!
serialConnection = new SerialConnectionImpl(connectionProperties, portName); // serialConnection = new SerialConnectionImpl(connectionProperties, portName);
// serialConnection = new TestSSMConnectionImpl(connectionProperties, portName); serialConnection = new TestSSMConnectionImpl(connectionProperties, portName);
} }
public byte[] send(byte[] bytes) { public byte[] send(byte[] bytes) {

View File

@ -23,7 +23,7 @@ package enginuity.logger.ecu.comms.io.connection;
import enginuity.io.connection.ConnectionProperties; import enginuity.io.connection.ConnectionProperties;
import enginuity.io.connection.SerialConnection; import enginuity.io.connection.SerialConnection;
import enginuity.io.connection.SerialConnectionImpl; import enginuity.io.connection.TestSSMConnectionImpl;
import enginuity.logger.ecu.comms.io.protocol.LoggerProtocol; import enginuity.logger.ecu.comms.io.protocol.LoggerProtocol;
import enginuity.logger.ecu.comms.io.protocol.SSMLoggerProtocol; import enginuity.logger.ecu.comms.io.protocol.SSMLoggerProtocol;
import enginuity.logger.ecu.comms.query.EcuQuery; import enginuity.logger.ecu.comms.query.EcuQuery;
@ -45,8 +45,8 @@ public final class SSMLoggerConnection implements LoggerConnection {
protocol = new SSMLoggerProtocol(); protocol = new SSMLoggerProtocol();
// Use TestSSMConnectionImpl for testing!! // Use TestSSMConnectionImpl for testing!!
serialConnection = new SerialConnectionImpl(connectionProperties, portName); // serialConnection = new SerialConnectionImpl(connectionProperties, portName);
// serialConnection = new TestSSMConnectionImpl(connectionProperties, portName); serialConnection = new TestSSMConnectionImpl(connectionProperties, portName);
} }
public void sendAddressReads(Collection<EcuQuery> queries) { public void sendAddressReads(Collection<EcuQuery> queries) {

View File

@ -22,6 +22,7 @@
package enginuity.logger.ecu.ui.handler.dash; package enginuity.logger.ecu.ui.handler.dash;
import enginuity.logger.ecu.definition.LoggerData; import enginuity.logger.ecu.definition.LoggerData;
import enginuity.tts.Speaker;
import static enginuity.util.ParamChecker.checkNotNull; import static enginuity.util.ParamChecker.checkNotNull;
import static javax.swing.BorderFactory.createLineBorder; import static javax.swing.BorderFactory.createLineBorder;
@ -237,6 +238,7 @@ public final class PlainGauge extends Gauge implements ActionListener {
setBackground(RED); setBackground(RED);
liveValuePanel.setBackground(RED); liveValuePanel.setBackground(RED);
progressBar.setForeground(RED); progressBar.setForeground(RED);
Speaker.say("Warning!");
} else { } else {
setBackground(LIGHT_GREY); setBackground(LIGHT_GREY);
liveValuePanel.setBackground(LIGHT_GREY); liveValuePanel.setBackground(LIGHT_GREY);

View File

@ -13,7 +13,7 @@ import enginuity.logger.utec.gui.mapTabs.MapJPanel;
import enginuity.logger.utec.gui.mapTabs.UtecDataManager; import enginuity.logger.utec.gui.mapTabs.UtecDataManager;
import enginuity.logger.utec.gui.realtimeData.RealTimeData; import enginuity.logger.utec.gui.realtimeData.RealTimeData;
import enginuity.logger.utec.mapData.UtecMapData; import enginuity.logger.utec.mapData.UtecMapData;
import enginuity.tts.SpeakString; import enginuity.logger.utec.tts.UtecSpeaker;
import javax.swing.JFileChooser; import javax.swing.JFileChooser;
import javax.swing.JFrame; import javax.swing.JFrame;
@ -127,7 +127,7 @@ public class JutecGUI extends JFrame implements ActionListener, KeyListener {
// Voice the welcome message // Voice the welcome message
// ************************* // *************************
SpeakString vc = new SpeakString("Welcome to you teck logger! Use at your own risk."); UtecSpeaker.say("Welcome to you teck logger! Use at your own risk.");
System.out.println("UTEC Gui is loading now."); System.out.println("UTEC Gui is loading now.");
// Actions to take when window is closing // Actions to take when window is closing

View File

@ -1,15 +1,20 @@
package enginuity.logger.utec.gui.realtimeData; package enginuity.logger.utec.gui.realtimeData;
import java.awt.*; import enginuity.logger.utec.commEvent.LoggerDataListener;
import java.awt.geom.*; import enginuity.logger.utec.commInterface.UtecInterface;
import javax.swing.*;
import enginuity.logger.utec.gui.bottomControl.*;
import enginuity.logger.utec.gui.mapTabs.UtecDataManager; import enginuity.logger.utec.gui.mapTabs.UtecDataManager;
import enginuity.logger.utec.properties.UtecProperties; import enginuity.logger.utec.properties.UtecProperties;
import enginuity.tts.SpeakString; import enginuity.logger.utec.tts.UtecSpeaker;
import enginuity.logger.utec.commEvent.*;
import enginuity.logger.utec.commInterface.UtecInterface; import java.awt.Color;
import java.awt.Component;
import java.awt.Font;
import java.awt.GradientPaint;
import java.awt.Graphics;
import java.awt.Graphics2D;
import java.awt.RenderingHints;
import java.awt.Toolkit;
import java.awt.geom.RoundRectangle2D;
/** /**
* @author botman * @author botman
@ -74,7 +79,7 @@ public class RealTimeData extends Component implements LoggerDataListener{
double value2 = doubleData[Integer.parseInt(indexes[1])]; double value2 = doubleData[Integer.parseInt(indexes[1])];
double maxAllowed2 = Double.parseDouble(UtecProperties.getProperties("utec.boostLimitWarningMaxAcceptable")[0]); double maxAllowed2 = Double.parseDouble(UtecProperties.getProperties("utec.boostLimitWarningMaxAcceptable")[0]);
if(value2 > maxAllowed2){ if(value2 > maxAllowed2){
SpeakString vc = new SpeakString("Max P S I,"+value2); UtecSpeaker.say("Max P S I,"+value2);
} }
double height2 = ((value2 - min2)/(max2 - min2))*maxHeight; double height2 = ((value2 - min2)/(max2 - min2))*maxHeight;
double yValue2 = 5 + (maxHeight - height2); double yValue2 = 5 + (maxHeight - height2);
@ -93,7 +98,7 @@ public class RealTimeData extends Component implements LoggerDataListener{
double value3 = doubleData[Integer.parseInt(indexes[2])]; double value3 = doubleData[Integer.parseInt(indexes[2])];
double maxAllowed3 = Double.parseDouble(UtecProperties.getProperties("utec.knockCountWarningMaxAcceptable")[0]); double maxAllowed3 = Double.parseDouble(UtecProperties.getProperties("utec.knockCountWarningMaxAcceptable")[0]);
if(value3 > maxAllowed3){ if(value3 > maxAllowed3){
SpeakString vc = new SpeakString("knock, count "+(int)value3); UtecSpeaker.say("knock, count "+(int)value3);
Toolkit.getDefaultToolkit().beep(); Toolkit.getDefaultToolkit().beep();
Toolkit.getDefaultToolkit().beep(); Toolkit.getDefaultToolkit().beep();
@ -131,7 +136,7 @@ public class RealTimeData extends Component implements LoggerDataListener{
double value5 = doubleData[Integer.parseInt(indexes[4])]; double value5 = doubleData[Integer.parseInt(indexes[4])];
double maxAllowed5 = Double.parseDouble(UtecProperties.getProperties("utec.injectorCycleWarningMaxAcceptable")[0]); double maxAllowed5 = Double.parseDouble(UtecProperties.getProperties("utec.injectorCycleWarningMaxAcceptable")[0]);
if(value5 > maxAllowed5){ if(value5 > maxAllowed5){
SpeakString vc = new SpeakString("Max injector duty "+value5); UtecSpeaker.say("Max injector duty "+value5);
} }
double height5 = ((value5 - min5)/(max5 - min5))*maxHeight; double height5 = ((value5 - min5)/(max5 - min5))*maxHeight;
double yValue5 = 5 + (maxHeight - height5); double yValue5 = 5 + (maxHeight - height5);

View File

@ -0,0 +1,24 @@
/*
* Created on May 31, 2005
*
* TODO To change the template for this generated file go to
* Window - Preferences - Java - Code Style - Code Templates
*/
package enginuity.logger.utec.tts;
import enginuity.logger.utec.properties.UtecProperties;
import enginuity.tts.Speaker;
public final class UtecSpeaker {
private UtecSpeaker() {
throw new UnsupportedOperationException();
}
public static void say(String message) {
String[] toSpeak = UtecProperties.getProperties("utec.sound");
boolean parsedBoolean = Boolean.parseBoolean(toSpeak[0]);
if (parsedBoolean) {
Speaker.say(message);
}
}
}

View File

@ -1,42 +0,0 @@
/*
* Created on May 31, 2005
*
* TODO To change the template for this generated file go to
* Window - Preferences - Java - Code Style - Code Templates
*/
package enginuity.tts;
import com.sun.speech.freetts.Voice;
import com.sun.speech.freetts.VoiceManager;
/**
* @author botman
*
* TODO To change the template for this generated type comment go to
* Window - Preferences - Java - Code Style - Code Templates
*/
public class SpeakKnock {
private static VoiceManager voiceManager = VoiceManager.getInstance();
private static Voice theVoice = null;
public static void speakKnock(int count){
if(theVoice == null){
theVoice = voiceManager.getVoice("kevin16");
theVoice.allocate();
}
theVoice.speak("Knock! count "+count+"!");
}
public static void speakString(String message){
if(theVoice == null){
theVoice = voiceManager.getVoice("kevin16");
theVoice.allocate();
}
theVoice.speak(message);
}
public static void end(){
theVoice.deallocate();
}
}

View File

@ -1,38 +0,0 @@
/*
* Created on May 31, 2005
*
* TODO To change the template for this generated file go to
* Window - Preferences - Java - Code Style - Code Templates
*/
package enginuity.tts;
import enginuity.logger.utec.properties.UtecProperties;
/**
* @author botman
*
* TODO To change the template for this generated type comment go to
* Window - Preferences - Java - Code Style - Code Templates
*/
public class SpeakString extends Thread{
private String message = null;
public SpeakString(String message){
this.message = message;
this.speakNow();
}
public void run(){
SpeakKnock.speakString(message);
}
public void speakNow(){
String[] toSpeak = UtecProperties.getProperties("utec.sound");
boolean parsedBoolean = Boolean.parseBoolean(toSpeak[0]);
if(parsedBoolean){
this.start();
}
}
}

36
src/enginuity/tts/Speaker.java Executable file
View File

@ -0,0 +1,36 @@
package enginuity.tts;
import com.sun.speech.freetts.Voice;
import com.sun.speech.freetts.VoiceManager;
import static enginuity.util.ThreadUtil.runAsDaemon;
public class Speaker {
private static final String VOICE_NAME = "kevin16";
private static final VoiceManager VOICE_MANAGER = VoiceManager.getInstance();
private static final Voice VOICE;
static {
VOICE = VOICE_MANAGER.getVoice(VOICE_NAME);
VOICE.allocate();
}
private Speaker() {
throw new UnsupportedOperationException();
}
public static void say(final String message) {
runAsDaemon(new Runnable() {
public void run() {
try {
VOICE.speak(message);
} catch (Exception e) {
// ignore
}
}
});
}
public static void end() {
VOICE.deallocate();
}
}