diff --git a/.classpath b/.classpath
index e6eeb4f4..a18dc7c8 100644
--- a/.classpath
+++ b/.classpath
@@ -1,19 +1,26 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/lib/tts/cmu_time_awb.jar b/lib/tts/cmu_time_awb.jar
new file mode 100644
index 00000000..31f9a1ae
Binary files /dev/null and b/lib/tts/cmu_time_awb.jar differ
diff --git a/lib/tts/cmu_us_kal.jar b/lib/tts/cmu_us_kal.jar
new file mode 100644
index 00000000..6e0a9208
Binary files /dev/null and b/lib/tts/cmu_us_kal.jar differ
diff --git a/lib/tts/cmudict04.jar b/lib/tts/cmudict04.jar
new file mode 100755
index 00000000..d953ce2f
Binary files /dev/null and b/lib/tts/cmudict04.jar differ
diff --git a/lib/tts/cmulex.jar b/lib/tts/cmulex.jar
new file mode 100644
index 00000000..88b3ccd0
Binary files /dev/null and b/lib/tts/cmulex.jar differ
diff --git a/lib/tts/cmutimelex.jar b/lib/tts/cmutimelex.jar
new file mode 100755
index 00000000..9a2fbf56
Binary files /dev/null and b/lib/tts/cmutimelex.jar differ
diff --git a/lib/tts/en_us.jar b/lib/tts/en_us.jar
new file mode 100644
index 00000000..470a51f7
Binary files /dev/null and b/lib/tts/en_us.jar differ
diff --git a/lib/tts/freetts.jar b/lib/tts/freetts.jar
new file mode 100644
index 00000000..5a4660ee
Binary files /dev/null and b/lib/tts/freetts.jar differ
diff --git a/src/enginuity/logger/utec/comm/PortRequestedDialog.java b/src/enginuity/logger/utec/comm/PortRequestedDialog.java
new file mode 100755
index 00000000..9e9d26c2
--- /dev/null
+++ b/src/enginuity/logger/utec/comm/PortRequestedDialog.java
@@ -0,0 +1,74 @@
+package enginuity.logger.utec.comm;
+
+
+import java.awt.*;
+import java.awt.event.*;
+import enginuity.logger.utec.gui.*;
+
+/**
+Informs the user that an other application has requested the port they
+are using, and then asks if they are willing to give it up. If the user
+answers "Yes" the port is closed and the dialog is closed, if the user
+answers "No" the dialog closes and no other action is taken.
+*/
+public class PortRequestedDialog extends Dialog implements ActionListener {
+
+ private JutecGUI parent;
+
+ /**
+ Creates the a dialog with two buttons and a message asking the user if
+ they are willing to give up the port they are using.
+
+ @param parent The main SerialDemo object.
+ */
+ public PortRequestedDialog(JutecGUI parent) {
+ super(parent, "Port Requested!", true);
+ this.parent = parent;
+
+ String lineOne = "Your port has been requested";
+ String lineTwo = "by an other application.";
+ String lineThree = "Do you want to give up your port?";
+ Panel labelPanel = new Panel();
+ labelPanel.setLayout(new GridLayout(3, 1));
+ labelPanel.add(new Label(lineOne, Label.CENTER));
+ labelPanel.add(new Label(lineTwo, Label.CENTER));
+ labelPanel.add(new Label(lineThree, Label.CENTER));
+ add(labelPanel, "Center");
+
+ Panel buttonPanel = new Panel();
+ Button yesButton = new Button("Yes");
+ yesButton.addActionListener(this);
+ buttonPanel.add(yesButton);
+ Button noButton = new Button("No");
+ noButton.addActionListener(this);
+ buttonPanel.add(noButton);
+ add(buttonPanel, "South");
+
+ FontMetrics fm = getFontMetrics(getFont());
+ int width = Math.max(fm.stringWidth(lineOne),
+ Math.max(fm.stringWidth(lineTwo), fm.stringWidth(lineThree)));
+
+ setSize(width + 40, 150);
+ setLocation(parent.getLocationOnScreen().x + 30,
+ parent.getLocationOnScreen().y + 30);
+ setVisible(true);
+ }
+
+ /**
+ Handles events generated by the buttons. If the yes button in pushed the
+ port closing routine is called and the dialog is disposed of. If the "No"
+ button is pushed the dialog is disposed of.
+ */
+ public void actionPerformed(ActionEvent e) {
+ String cmd = e.getActionCommand();
+
+ if (cmd.equals("Yes")) {
+ ///parent.portClosed();
+ System.out.println("Port has been closed");
+ System.out.println("Eventually handle this notification through the GUI");
+ }
+
+ setVisible(false);
+ dispose();
+ }
+}
diff --git a/src/enginuity/logger/utec/comm/SerialConnection.java b/src/enginuity/logger/utec/comm/SerialConnection.java
new file mode 100755
index 00000000..adab4f18
--- /dev/null
+++ b/src/enginuity/logger/utec/comm/SerialConnection.java
@@ -0,0 +1,398 @@
+package enginuity.logger.utec.comm;
+
+//import javax.comm.*;
+import java.io.*;
+import java.awt.event.*;
+import java.util.*;
+import javax.swing.*;
+import enginuity.logger.utec.commEvent.*;
+
+
+/**
+ * Class negotiates data to and from UTEC via the serial port
+ *
+ * Please note that at this time ownership issues are not handled.
+ * See commented out code pertaining to the parent entity
+ *
+ * @author botman
+ *
+ */
+//public class SerialConnection implements SerialPortEventListener,
+// CommPortOwnershipListener {
+
+import gnu.io.*;
+
+public class SerialConnection implements SerialPortEventListener{
+
+ // Parent object organizing connections to and from UTEC
+ //private JPanel parent;
+
+ //Data to UTEC
+ //private JTextArea messageAreaOut;
+
+ //Data from UTEC
+ //private JTextArea messageAreaIn;
+
+ // Parameters used to define serial connection
+ public SerialParameters parameters = new SerialParameters();
+
+ //Data from UTEC
+ private OutputStream outputToUtecStream;
+
+ //Data to UTEC
+ private InputStream inputFromUtecStream;
+
+ // Handler for keyboard input
+ private KeyHandler keyHandler;
+
+ // Defines named comport
+ private CommPortIdentifier portId;
+
+ // Serial port being accessed
+ private SerialPort sPort;
+
+ // Defin state of defined comport, open or closed.
+ private boolean open;
+
+ //Listeners
+ private Vector portListeners = new Vector();
+ /**
+ * Public constructor
+ *
+ * @param parent
+ * @param parameters
+ * @param messageAreaOut
+ * @param messageAreaIn
+ */
+ //public SerialConnection(JPanel parent, SerialParameters parameters,
+ // TextArea messageAreaOut, TextArea messageAreaIn) {
+ public SerialConnection(SerialParameters parameters) {
+ //this.parent = parent;
+ //this.messageAreaOut = messageAreaOut;
+ //this.messageAreaIn = messageAreaIn;
+ open = false;
+ }
+
+ /**
+ * Get UTEC to send data
+ *
+ */
+ public void startDataFlow(){
+ System.out.println("Starting data flow from UTEC");
+
+ //OutPut a '1' to start basic data flow from UTEC
+ try{
+ outputToUtecStream.write((int) '!');
+ }
+ catch(IOException e){
+ System.err.println("Can't start flow of data from UTEC");
+ e.getMessage();
+ }
+ }
+
+ /**
+ * Reset UTEC to main screen
+ *
+ */
+ public void resetUtec(){
+ //OutPut and 'escape' to UTEC
+ try{
+ outputToUtecStream.write((int) '\u001B');
+ }
+ catch(IOException e){
+ System.err.println("Can't start flow of data from UTEC");
+ e.getMessage();
+ }
+ }
+
+ /**
+ * Opens a connection to the defined serial port If attempt fails,
+ * SerialConnectionException is thrown
+ *
+ * @throws SerialConnectionException
+ */
+ public void openConnection() throws SerialConnectionException {
+
+ // Obtain a CommPortIdentifier object for the port you want to open.
+ try {
+ //System.out.println("PORT: "+parameters.getPortName());
+ portId = CommPortIdentifier.getPortIdentifier(parameters
+ .getPortName());
+ } catch (NoSuchPortException e) {
+ System.err.println("Can't get commport identifier");
+ throw new SerialConnectionException(e.getMessage());
+ }
+
+ // Open the port represented by the CommPortIdentifier object. Give
+ // the open call a relatively long timeout of 30 seconds to allow
+ // a different application to reliquish the port if the user
+ // wants to.
+ try {
+ sPort = (SerialPort) portId.open("SerialDemo", 30000);
+ } catch (PortInUseException e) {
+ System.err.println("Can't open serial port");
+ throw new SerialConnectionException(e.getMessage());
+ }
+
+ // Set the parameters of the connection. If they won't set, close the
+ // port before throwing an exception.
+ try {
+ setConnectionParameters();
+ } catch (SerialConnectionException e) {
+ System.err.println("Can't set connection parameters");
+ sPort.close();
+ throw e;
+ }
+
+ // Open the input and output streams for the connection. If they won't
+ // open, close the port before throwing an exception.
+ try {
+ outputToUtecStream = sPort.getOutputStream();
+ inputFromUtecStream = sPort.getInputStream();
+ } catch (IOException e) {
+ System.err.println("Error opening IO streams");
+ sPort.close();
+ throw new SerialConnectionException("Error opening i/o streams");
+ }
+
+ // Create a new KeyHandler to respond to key strokes in the
+ // messageAreaOut. Add the KeyHandler as a keyListener to the
+ // messageAreaOut.
+ //keyHandler = new KeyHandler(outputToUtecStream);
+ //messageAreaOut.addKeyListener(keyHandler);
+
+ // Add this object as an event listener for the serial port.
+ try {
+ sPort.addEventListener(this);
+ } catch (TooManyListenersException e) {
+ System.err.println("Too Many listeners");
+ sPort.close();
+ throw new SerialConnectionException("too many listeners added");
+ }
+
+ // Set notifyOnDataAvailable to true to allow event driven input.
+ sPort.notifyOnDataAvailable(true);
+
+ // Set notifyOnBreakInterrup to allow event driven break handling.
+ sPort.notifyOnBreakInterrupt(true);
+
+ // Set receive timeout to allow breaking out of polling loop during
+ // input handling.
+ try {
+ sPort.enableReceiveTimeout(30);
+ } catch (UnsupportedCommOperationException e) {
+ System.err.println("Time Out");
+ }
+
+ // Add ownership listener to allow ownership event handling.
+ //portId.addPortOwnershipListener(this);
+
+ open = true;
+ }
+
+ /**
+ * Sets the connection parameters to the setting in the parameters object.
+ * If set fails return the parameters object to origional settings and throw
+ * exception.
+ */
+ public void setConnectionParameters() throws SerialConnectionException {
+
+ // Save state of parameters before trying a set.
+ int oldBaudRate = sPort.getBaudRate();
+ int oldDatabits = sPort.getDataBits();
+ int oldStopbits = sPort.getStopBits();
+ int oldParity = sPort.getParity();
+ int oldFlowControl = sPort.getFlowControlMode();
+
+ // Set connection parameters, if set fails return parameters object
+ // to original state.
+ try {
+ sPort.setSerialPortParams(parameters.getBaudRate(), parameters
+ .getDatabits(), parameters.getStopbits(), parameters
+ .getParity());
+ } catch (UnsupportedCommOperationException e) {
+ parameters.setBaudRate(oldBaudRate);
+ parameters.setDatabits(oldDatabits);
+ parameters.setStopbits(oldStopbits);
+ parameters.setParity(oldParity);
+ throw new SerialConnectionException("Unsupported parameter");
+ }
+
+ // Set flow control.
+ try {
+ sPort.setFlowControlMode(parameters.getFlowControlIn()
+ | parameters.getFlowControlOut());
+ } catch (UnsupportedCommOperationException e) {
+ throw new SerialConnectionException("Unsupported flow control");
+ }
+ }
+
+ /**
+ * Close the port and clean up associated elements.
+ */
+ public void closeConnection() {
+ // If port is alread closed just return.
+ if (!open) {
+ return;
+ }
+ System.out.println("Closing connection to the currently targeted port");
+
+ //Reset the UTEC first
+ resetUtec();
+
+ // Remove the key listener.
+ //messageAreaOut.removeKeyListener(keyHandler);
+
+ // Check to make sure sPort has reference to avoid a NPE.
+ if (sPort != null) {
+ try {
+ // close the i/o streams.
+ outputToUtecStream.close();
+ inputFromUtecStream.close();
+ } catch (IOException e) {
+ System.err.println(e);
+ }
+
+ // Close the port.
+ sPort.close();
+
+ // Remove the ownership listener.
+ //portId.removePortOwnershipListener(this);
+ }
+
+ open = false;
+ }
+
+ /**
+ * Send a one second break signal.
+ */
+ public void sendBreak() {
+ sPort.sendBreak(1000);
+ }
+
+ /**
+ * Reports the open status of the port.
+ *
+ * @return true if port is open, false if port is closed.
+ */
+ public boolean isOpen() {
+ return open;
+ }
+
+
+ /**
+ * Method adds a class as a listener
+ * @param o
+ */
+ public void addListener(Object o){
+ portListeners.add(o);
+ }
+
+ /**
+ * Handles SerialPortEvents. The two types of SerialPortEvents that this
+ * program is registered to listen for are DATA_AVAILABLE and BI. During
+ * DATA_AVAILABLE the port buffer is read until it is drained, when no more
+ * data is availble and 30ms has passed the method returns. When a BI event
+ * occurs the words BREAK RECEIVED are written to the messageAreaIn.
+ */
+
+ public void serialEvent(SerialPortEvent e) {
+ // Create a StringBuffer and int to receive input data.
+ StringBuffer inputBuffer = new StringBuffer();
+ int newData = 0;
+
+ // Determine type of event.
+ switch (e.getEventType()) {
+
+ // Read data until -1 is returned. If \r is received substitute
+ // \n for correct newline handling.
+ case SerialPortEvent.DATA_AVAILABLE:
+ while (newData != -1) {
+ try {
+ newData = inputFromUtecStream.read();
+ if (newData == -1) {
+ break;
+ }
+ if ('\r' == (char) newData) {
+ inputBuffer.append('\n');
+ } else {
+ inputBuffer.append((char) newData);
+ }
+ } catch (IOException ex) {
+ System.err.println(ex);
+ return;
+ }
+ }
+
+ //Build new event with buffer data
+ CommEvent commEvent = new CommEvent(new String(inputBuffer));
+
+ //Send received data to listeners
+ Iterator portIterator = portListeners.iterator();
+ while(portIterator.hasNext()){
+ CommListener theListener = (CommListener)portIterator.next();
+ theListener.getCommEvent(commEvent);
+ }
+ break;
+
+ // If break event append BREAK RECEIVED message.
+ /*
+ case SerialPortEvent.BI:
+ messageAreaIn.append("\n--- BREAK RECEIVED ---\n");
+ */
+ }
+
+ }
+
+ /**
+ * Handles ownership events. If a PORT_OWNERSHIP_REQUESTED event is received
+ * a dialog box is created asking the user if they are willing to give up
+ * the port. No action is taken on other types of ownership events.
+ */
+ /*
+ public void ownershipChange(int type) {
+ if (type == CommPortOwnershipListener.PORT_OWNERSHIP_REQUESTED) {
+ PortRequestedDialog prd = new PortRequestedDialog(parent);
+ }
+ }
+ */
+
+ /**
+ * A class to handle KeyEvent
s generated by the
+ * messageAreaOut. When a KeyEvent
occurs the
+ * char
that is generated by the event is read, converted to
+ * an int
and writen to the OutputStream
for
+ * the port.
+ */
+
+ class KeyHandler extends KeyAdapter {
+ OutputStream toUtec;
+
+ /**
+ * Creates the KeyHandler.
+ *
+ * @param toUtec
+ * The OutputStream for the port.
+ */
+ public KeyHandler(OutputStream toUtec) {
+ super();
+ this.toUtec = toUtec;
+ }
+
+ /**
+ * Handles the KeyEvent. Gets the
+ * char generated by the KeyEvent
,
+ converts it to an int
, writes it to the
+ OutputStream
for the port.
+ */
+ public void keyTyped(KeyEvent evt) {
+ char newCharacter = evt.getKeyChar();
+ try {
+ toUtec.write((int) newCharacter);
+ } catch (IOException e) {
+ System.err.println("OutputStream write error: " + e);
+ }
+ }
+ }
+
+}
diff --git a/src/enginuity/logger/utec/comm/SerialConnectionException.java b/src/enginuity/logger/utec/comm/SerialConnectionException.java
new file mode 100755
index 00000000..8a351a49
--- /dev/null
+++ b/src/enginuity/logger/utec/comm/SerialConnectionException.java
@@ -0,0 +1,27 @@
+/*
+ * Class defines an exception to be thrown in the event
+ * of serial connection troubles
+ */
+
+package enginuity.logger.utec.comm;
+
+public class SerialConnectionException extends Exception {
+
+ /**
+ * Constructs a SerialConnectionException
+ * with the specified detail message.
+ *
+ * @param s the detail message.
+ */
+ public SerialConnectionException(String str) {
+ super(str);
+ }
+
+ /**
+ * Constructs a SerialConnectionException
+ * with no detail message.
+ */
+ public SerialConnectionException() {
+ super();
+ }
+}
diff --git a/src/enginuity/logger/utec/comm/SerialParameters.java b/src/enginuity/logger/utec/comm/SerialParameters.java
new file mode 100755
index 00000000..d05e9187
--- /dev/null
+++ b/src/enginuity/logger/utec/comm/SerialParameters.java
@@ -0,0 +1,349 @@
+/*
+ * Class holds serial port specific data
+ */
+
+package enginuity.logger.utec.comm;
+
+//import javax.comm.*;
+import gnu.io.*;
+
+/**
+ * A class that stores parameters for serial ports.
+ */
+public class SerialParameters {
+ private String portName;
+ private int baudRate;
+ private int flowControlIn;
+ private int flowControlOut;
+ private int databits;
+ private int stopbits;
+ private int parity;
+
+
+ /**
+ * Constructor. Settings tuned to connect to the UTEC
+ *
+ */
+ public SerialParameters() {
+ this.portName = "";
+ this.baudRate = 19200;
+ this.flowControlIn = SerialPort.FLOWCONTROL_NONE;
+ this.flowControlOut = SerialPort.FLOWCONTROL_NONE;
+ this.databits = SerialPort.DATABITS_8;
+ this.stopbits = SerialPort.STOPBITS_1;
+ this.parity = SerialPort.PARITY_NONE;
+ }
+
+ /**
+ Sets port name.
+ @param portName New port name.
+ */
+ public void setPortName(String portName) {
+ //System.out.println("Set portName requested");
+ this.portName = portName;
+ }
+
+ /**
+ Gets port name.
+ @return Current port name.
+ */
+ public String getPortName() {
+ return portName;
+ }
+
+ /**
+ Sets baud rate.
+ @param baudRate New baud rate.
+ */
+ public void setBaudRate(int baudRate) {
+ this.baudRate = baudRate;
+ }
+
+ /**
+ Sets baud rate.
+ @param baudRate New baud rate.
+ */
+ public void setBaudRate(String baudRate) {
+ this.baudRate = Integer.parseInt(baudRate);
+ }
+
+ /**
+ Gets baud rate as an int
.
+ @return Current baud rate.
+ */
+ public int getBaudRate() {
+ return baudRate;
+ }
+
+ /**
+ Gets baud rate as a String
.
+ @return Current baud rate.
+ */
+ public String getBaudRateString() {
+ return Integer.toString(baudRate);
+ }
+
+ /**
+ Sets flow control for reading.
+ @param flowControlIn New flow control for reading type.
+ */
+ public void setFlowControlIn(int flowControlIn) {
+ this.flowControlIn = flowControlIn;
+ }
+
+ /**
+ Sets flow control for reading.
+ @param flowControlIn New flow control for reading type.
+ */
+ public void setFlowControlIn(String flowControlIn) {
+ this.flowControlIn = stringToFlow(flowControlIn);
+ }
+
+ /**
+ Gets flow control for reading as an int
.
+ @return Current flow control type.
+ */
+ public int getFlowControlIn() {
+ return flowControlIn;
+ }
+
+ /**
+ Gets flow control for reading as a String
.
+ @return Current flow control type.
+ */
+ public String getFlowControlInString() {
+ return flowToString(flowControlIn);
+ }
+
+ /**
+ Sets flow control for writing.
+ @param flowControlIn New flow control for writing type.
+ */
+ public void setFlowControlOut(int flowControlOut) {
+ this.flowControlOut = flowControlOut;
+ }
+
+ /**
+ Sets flow control for writing.
+ @param flowControlIn New flow control for writing type.
+ */
+ public void setFlowControlOut(String flowControlOut) {
+ this.flowControlOut = stringToFlow(flowControlOut);
+ }
+
+ /**
+ Gets flow control for writing as an int
.
+ @return Current flow control type.
+ */
+ public int getFlowControlOut() {
+ return flowControlOut;
+ }
+
+ /**
+ Gets flow control for writing as a String
.
+ @return Current flow control type.
+ */
+ public String getFlowControlOutString() {
+ return flowToString(flowControlOut);
+ }
+
+ /**
+ Sets data bits.
+ @param databits New data bits setting.
+ */
+ public void setDatabits(int databits) {
+ this.databits = databits;
+ }
+
+ /**
+ Sets data bits.
+ @param databits New data bits setting.
+ */
+ public void setDatabits(String databits) {
+ if (databits.equals("5")) {
+ this.databits = SerialPort.DATABITS_5;
+ }
+ if (databits.equals("6")) {
+ this.databits = SerialPort.DATABITS_6;
+ }
+ if (databits.equals("7")) {
+ this.databits = SerialPort.DATABITS_7;
+ }
+ if (databits.equals("8")) {
+ this.databits = SerialPort.DATABITS_8;
+ }
+ }
+
+ /**
+ Gets data bits as an int
.
+ @return Current data bits setting.
+ */
+ public int getDatabits() {
+ return databits;
+ }
+
+ /**
+ Gets data bits as a String
.
+ @return Current data bits setting.
+ */
+ public String getDatabitsString() {
+ switch(databits) {
+ case SerialPort.DATABITS_5:
+ return "5";
+ case SerialPort.DATABITS_6:
+ return "6";
+ case SerialPort.DATABITS_7:
+ return "7";
+ case SerialPort.DATABITS_8:
+ return "8";
+ default:
+ return "8";
+ }
+ }
+
+ /**
+ Sets stop bits.
+ @param stopbits New stop bits setting.
+ */
+ public void setStopbits(int stopbits) {
+ this.stopbits = stopbits;
+ }
+
+ /**
+ Sets stop bits.
+ @param stopbits New stop bits setting.
+ */
+ public void setStopbits(String stopbits) {
+ if (stopbits.equals("1")) {
+ this.stopbits = SerialPort.STOPBITS_1;
+ }
+ if (stopbits.equals("1.5")) {
+ this.stopbits = SerialPort.STOPBITS_1_5;
+ }
+ if (stopbits.equals("2")) {
+ this.stopbits = SerialPort.STOPBITS_2;
+ }
+ }
+
+ /**
+ Gets stop bits setting as an int
.
+ @return Current stop bits setting.
+ */
+ public int getStopbits() {
+ return stopbits;
+ }
+
+ /**
+ Gets stop bits setting as a String
.
+ @return Current stop bits setting.
+ */
+ public String getStopbitsString() {
+ switch(stopbits) {
+ case SerialPort.STOPBITS_1:
+ return "1";
+ case SerialPort.STOPBITS_1_5:
+ return "1.5";
+ case SerialPort.STOPBITS_2:
+ return "2";
+ default:
+ return "1";
+ }
+ }
+
+ /**
+ Sets parity setting.
+ @param parity New parity setting.
+ */
+ public void setParity(int parity) {
+ this.parity = parity;
+ }
+
+ /**
+ Sets parity setting.
+ @param parity New parity setting.
+ */
+ public void setParity(String parity) {
+ if (parity.equals("None")) {
+ this.parity = SerialPort.PARITY_NONE;
+ }
+ if (parity.equals("Even")) {
+ this.parity = SerialPort.PARITY_EVEN;
+ }
+ if (parity.equals("Odd")) {
+ this.parity = SerialPort.PARITY_ODD;
+ }
+ }
+
+ /**
+ Gets parity setting as an int
.
+ @return Current parity setting.
+ */
+ public int getParity() {
+ return parity;
+ }
+
+ /**
+ Gets parity setting as a String
.
+ @return Current parity setting.
+ */
+ public String getParityString() {
+ switch(parity) {
+ case SerialPort.PARITY_NONE:
+ return "None";
+ case SerialPort.PARITY_EVEN:
+ return "Even";
+ case SerialPort.PARITY_ODD:
+ return "Odd";
+ default:
+ return "None";
+ }
+ }
+
+ /**
+ Converts a String
describing a flow control type to an
+ int
type defined in SerialPort
.
+ @param flowControl A string
describing a flow control type.
+ @return An int
describing a flow control type.
+ */
+ private int stringToFlow(String flowControl) {
+ if (flowControl.equals("None")) {
+ return SerialPort.FLOWCONTROL_NONE;
+ }
+ if (flowControl.equals("Xon/Xoff Out")) {
+ return SerialPort.FLOWCONTROL_XONXOFF_OUT;
+ }
+ if (flowControl.equals("Xon/Xoff In")) {
+ return SerialPort.FLOWCONTROL_XONXOFF_IN;
+ }
+ if (flowControl.equals("RTS/CTS In")) {
+ return SerialPort.FLOWCONTROL_RTSCTS_IN;
+ }
+ if (flowControl.equals("RTS/CTS Out")) {
+ return SerialPort.FLOWCONTROL_RTSCTS_OUT;
+ }
+ return SerialPort.FLOWCONTROL_NONE;
+ }
+
+ /**
+ Converts an int
describing a flow control type to a
+ String
describing a flow control type.
+ @param flowControl An int
describing a flow control type.
+ @return A String
describing a flow control type.
+ */
+ String flowToString(int flowControl) {
+ switch(flowControl) {
+ case SerialPort.FLOWCONTROL_NONE:
+ return "None";
+ case SerialPort.FLOWCONTROL_XONXOFF_OUT:
+ return "Xon/Xoff Out";
+ case SerialPort.FLOWCONTROL_XONXOFF_IN:
+ return "Xon/Xoff In";
+ case SerialPort.FLOWCONTROL_RTSCTS_IN:
+ return "RTS/CTS In";
+ case SerialPort.FLOWCONTROL_RTSCTS_OUT:
+ return "RTS/CTS Out";
+ default:
+ return "None";
+ }
+ }
+}
diff --git a/src/enginuity/logger/utec/commEvent/CommEvent.java b/src/enginuity/logger/utec/commEvent/CommEvent.java
new file mode 100755
index 00000000..cb9ae426
--- /dev/null
+++ b/src/enginuity/logger/utec/commEvent/CommEvent.java
@@ -0,0 +1,76 @@
+/*
+ * Created on May 28, 2005
+ *
+ * To change the template for this generated file go to
+ * Window - Preferences - Java - Code Generation - Code and Comments
+ */
+package enginuity.logger.utec.commEvent;
+
+
+
+import java.util.*;
+/**
+ * @author emorgan
+ *
+ * To change the template for this generated type comment go to
+ * Window - Preferences - Java - Code Generation - Code and Comments
+ */
+public class CommEvent {
+ public String UtecBuffer = null;
+ public String[] data = new String[6];
+ public double[] doubleData = new double[6];
+
+ public CommEvent(String buffer){
+ UtecBuffer = buffer;
+ StringTokenizer st = new StringTokenizer(UtecBuffer, ",");
+ int counter = 0;
+ while(st.hasMoreTokens()){
+ String theData = st.nextToken();
+
+ //RPM
+ if(counter == 0){
+ data[0] = theData;
+ }
+
+ //PSI
+ if(counter == 1){
+ data[1] = theData;
+ }
+
+ //KNOCK
+ if(counter == 5){
+ data[2] = theData;
+ }
+
+ //IGN
+ if(counter == 6){
+ data[3] = theData;
+ }
+
+ //DUTY
+ if(counter == 7){
+ data[4] = theData;
+ }
+
+ //AFR
+ if(counter == 13){
+ data[5] = theData;
+ }
+
+ counter++;
+ }
+
+ for(int i = 0; i < 6; i++){
+ String theData = data[i];
+ theData = theData.trim();
+ if(theData.startsWith(">")){
+ theData = "25.5";
+ }
+ if(theData.startsWith("--")){
+ theData = "0.0";
+ }
+ doubleData[i] = Double.parseDouble(theData);
+ }
+
+ }
+}
diff --git a/src/enginuity/logger/utec/commEvent/CommListener.java b/src/enginuity/logger/utec/commEvent/CommListener.java
new file mode 100755
index 00000000..41ed025b
--- /dev/null
+++ b/src/enginuity/logger/utec/commEvent/CommListener.java
@@ -0,0 +1,17 @@
+/*
+ * Created on May 28, 2005
+ *
+ * To change the template for this generated file go to
+ * Window - Preferences - Java - Code Generation - Code and Comments
+ */
+package enginuity.logger.utec.commEvent;
+
+/**
+ * @author emorgan
+ *
+ * To change the template for this generated type comment go to
+ * Window - Preferences - Java - Code Generation - Code and Comments
+ */
+public interface CommListener {
+ public void getCommEvent(CommEvent e);
+}
diff --git a/src/enginuity/logger/utec/commInterface/CommInterface.java b/src/enginuity/logger/utec/commInterface/CommInterface.java
new file mode 100755
index 00000000..df1a9e55
--- /dev/null
+++ b/src/enginuity/logger/utec/commInterface/CommInterface.java
@@ -0,0 +1,145 @@
+/*
+ * Created on May 30, 2005
+ *
+ * TODO To change the template for this generated file go to
+ * Window - Preferences - Java - Code Style - Code Templates
+ */
+package enginuity.logger.utec.commInterface;
+
+
+import java.awt.*;
+import java.awt.event.*;
+
+import javax.swing.*;
+import java.awt.event.*;
+import java.util.Enumeration;
+import java.util.*;
+//import javax.comm.CommPortIdentifier
+import gnu.io.*;
+import javax.swing.*;
+
+import enginuity.logger.utec.gui.realtimeData.*;
+import enginuity.logger.utec.comm.*;
+/**
+ * @author emorgan
+ *
+ * To change the template for this generated type comment go to
+ * Window - Preferences - Java - Code Generation - Code and Comments
+ */
+public class CommInterface{
+ //Store string vector of known system comm ports
+ private static Vector portChoices = listPortChoices();
+
+ //Basic connection settings, already tuned for a UTEC connection, baud, parity, etc
+ private static SerialParameters parameters = new SerialParameters();
+
+ //Actual connection entity
+ private static SerialConnection connection = new SerialConnection(parameters);
+
+
+ public static boolean ISOPEN = connection.isOpen();
+
+ public static Vector getPortsVector(){
+ return portChoices;
+ }
+
+ public static String getPortChoiceUsed(){
+ return connection.parameters.getPortName();
+ }
+
+ /**
+ * Open a port as per names defined in get port names method
+ *
+ * @param portName
+ */
+ public static void openConnection(){
+ //No port yet chosen
+ if(connection.parameters.getPortName().equalsIgnoreCase("")){
+ System.err.println("No Port Yet Chosen, nothing to open");
+ return;
+ }
+
+ //Port is already opened, any port is open
+ /*
+ if(ISOPEN){
+ System.err.println("Port already opened");
+ return;
+ }
+ */
+
+ //Attempt to make connection
+ try{
+ connection.openConnection();
+ }catch(SerialConnectionException e){
+ System.err.println("Error opening serial port connection");
+ e.printStackTrace();
+ return;
+ }
+
+ //Successful opening of port
+ //ISOPEN=true;
+ }
+
+ public static void closeConnection(){
+ connection.closeConnection();
+ }
+
+ public static void setPortChoice(String port){
+ connection.parameters.setPortName(port);
+ }
+
+ /**
+ * Resets UTEC to main screen
+ *
+ */
+ public static void resetUtec(){
+ connection.resetUtec();
+ }
+
+ /**
+ * Starts the #1 logger (SHIFT-1), ie !, ie CSV logger.
+ *
+ */
+ public static void startDataLogFromUtec(){
+ connection.startDataFlow();
+ }
+
+
+ /**
+ * Adds a listener for comm port events
+ * @param o
+ */
+ public static void addListener(Object o){
+ if(connection == null){
+ System.err.println("No Serial Connection defined yet.. DIZZoGG!");
+ return;
+ }
+
+ connection.addListener(o);
+ }
+
+ /**
+ * Method returns a vector of all available serial ports found
+ *
+ * @return
+ */
+ private static Vector listPortChoices() {
+ Vector theChoices = new Vector();
+ CommPortIdentifier portId;
+
+ Enumeration en = CommPortIdentifier.getPortIdentifiers();
+ if (!en.hasMoreElements()) {
+ System.err.println("No Valid ports found, check Java installation");
+ }
+
+ //Iterate through the ports
+ while (en.hasMoreElements()) {
+ portId = (CommPortIdentifier) en.nextElement();
+ if (portId.getPortType() == CommPortIdentifier.PORT_SERIAL) {
+ System.out.println("Port found on system: "+portId.getName());
+ theChoices.addElement(portId.getName());
+ }
+ }
+ return theChoices;
+ }
+}
\ No newline at end of file
diff --git a/src/enginuity/logger/utec/gui/JutecGUI.java b/src/enginuity/logger/utec/gui/JutecGUI.java
new file mode 100755
index 00000000..fc254daa
--- /dev/null
+++ b/src/enginuity/logger/utec/gui/JutecGUI.java
@@ -0,0 +1,247 @@
+/*
+ * Created on Jan 8, 2005
+ *
+ * TODO To change the template for this generated file go to
+ * Window - Preferences - Java - Code Style - Code Templates
+ */
+package enginuity.logger.utec.gui;
+
+import java.awt.event.*;
+import java.util.*;
+import java.io.*;
+import javax.swing.*;
+
+import java.awt.*;
+
+import enginuity.Settings;
+import enginuity.logger.utec.gui.realtimeData.*;
+import enginuity.logger.utec.gui.bottomControl.*;
+import enginuity.tts.VoiceThread;
+import enginuity.logger.utec.commInterface.CommInterface;
+
+/**
+ * @author botman
+ */
+public class JutecGUI extends JFrame implements ActionListener{
+ //Top level desktop pane
+ public JLayeredPane desktop = null;
+
+ //Top menu bar
+ private JMenuBar menuBar;
+
+ //A known existing port
+ private String defaultPort = null;
+
+ //Currently selected port
+ private String currentPort = null;
+
+ private BottomUtecControl bottomPanel = null;
+
+ private JFileChooser fileChooser = null;
+ private int fileChosen;
+ private File selectedFile = null;
+
+
+ //FileMenu Items
+ public JMenuItem saveItem = new JMenuItem("Save");
+ public JMenuItem exitItem = new JMenuItem("Exit");
+
+ private static JutecGUI instance = null;
+
+ public static JutecGUI getInstance(){
+ return instance;
+ }
+
+ private JutecGUI(int setDefaultCloseOperation) {
+
+ // Main frame
+ // Grid layout with a top and bottom, ie two rows
+ super("-==- USE AT OWN RISK,NO WARRANTY");
+ this.setSize(800, 600);
+ this.setResizable(false);
+ this.setDefaultCloseOperation(setDefaultCloseOperation);
+
+ //*************************
+ //Voice the welcome message
+ //*************************
+
+ VoiceThread vc = new VoiceThread("Welcome to you teck logger! Use at your own risk.");
+ vc.start();
+
+
+ //Actions to take when window is closing
+ addWindowListener(new WindowAdapter() {
+ public void windowClosing(WindowEvent e) {
+ System.out.println("JUTEC Exiting");
+
+ //Use interface to close the connecetion to the Utec
+ CommInterface.closeConnection();
+
+ }
+ });
+
+ //-----------------------
+ //Start Menu bar addtions
+ //-----------------------
+ menuBar = new JMenuBar();
+
+
+ //*********************************************
+ //Add a menu item for basic application actions
+ //*********************************************
+ // Define the menu system
+ JMenu fileMenu = new JMenu("File");
+ saveItem.addActionListener(this);
+ exitItem.addActionListener(this);
+ fileMenu.add(saveItem);
+ fileMenu.add(exitItem);
+ menuBar.add(fileMenu);
+
+
+ //----------------------------------
+ //Add a menu item for comm port selection
+ //----------------------------------
+ JMenu portsMenu =new JMenu("Ports");
+
+ //Gather list of ports from interface
+ Vector portsVector =CommInterface.getPortsVector();
+
+ Iterator portsIterator = portsVector.iterator();
+ int counter = 0;
+ while(portsIterator.hasNext()){
+ counter++;
+ Object o = portsIterator.next();
+ String theName = (String)o;
+ JMenuItem item = new JMenuItem(theName);
+ item.setName(theName);
+ item.addActionListener(this);
+ portsMenu.add(item);
+ if(counter == 1){
+ defaultPort = theName;
+ CommInterface.setPortChoice(defaultPort);
+ }
+ }
+ menuBar.add(portsMenu);
+
+ // Add menu item to the JFrame
+ this.setJMenuBar(menuBar);
+
+
+ //*********************************************
+ //Start Adding GUI Elements to the Window
+ //*********************************************
+
+ bottomPanel = new BottomUtecControl();
+
+ JTabbedPane topTabbedPane = new JTabbedPane();
+ topTabbedPane.add("Graph Data",new RealTimeData());
+
+ JSplitPane splitPane = new JSplitPane(JSplitPane.VERTICAL_SPLIT);
+ splitPane.setDividerLocation(435);
+
+ splitPane.setTopComponent(topTabbedPane);
+ splitPane.setBottomComponent(bottomPanel);
+ splitPane.setPreferredSize(new Dimension(800,600));
+
+ this.getContentPane().add(splitPane);
+
+
+ //***********************
+ //Define the file chooser
+ //***********************
+ fileChooser = new JFileChooser();
+
+
+ //Save singleton
+ instance = this;
+ }
+
+ /**
+ * Implements actionPerformed
+ *
+ * Action listeners for buttons/menus that throw them
+ *
+ */
+ public void actionPerformed(ActionEvent e) {
+ String cmd = e.getActionCommand();
+
+ //Open Port
+ if (cmd.equals("New")) {
+ System.out.println("New action occuring");
+ }
+
+ //Close Port
+ else if (cmd.equals("Open")) {
+ System.out.println("Open action occuring");
+ }
+
+ //Start Capture
+ else if (cmd.equals("Save")) {
+ String saveFileName = null;
+ System.out.println("Save action occuring");
+ fileChosen = fileChooser.showSaveDialog(this);
+ if(fileChosen == JFileChooser.APPROVE_OPTION)
+ {
+ saveFileName = fileChooser.getSelectedFile().getPath();
+ //selectedFile = fileChooser.getSelectedFile();
+ try {
+ File file = new File(saveFileName);
+ FileWriter out = new FileWriter(file);
+ out.write(bottomPanel.totalLog);
+ out.close();
+ bottomPanel.totalLog = "";
+ }
+ catch (IOException e2) {
+ System.out.println("Couldn't save file " + saveFileName);
+ e2.printStackTrace();
+ }
+ }
+
+ }
+
+ //Stop Capture
+ else if (cmd.equals("Exit")) {
+ //Use interface to finally close the connection to the Utec
+ CommInterface.closeConnection();
+ System.out.println("Exit action occuring");
+
+ //Close out the application
+ System.exit(0);
+ }
+
+ //Only non explicitly defined actions are those generated by ports.
+ //Since an arbitrary machine could have any number of serial ports
+ //its impossible to hard code choices based on menu items generated on the fly.
+ //Must pull the calling object and interrogate
+ else{
+ JMenuItem theItem = (JMenuItem)e.getSource();
+ String portChoice = theItem.getName();
+ System.out.println("Port chosen: "+portChoice);
+ currentPort = portChoice;
+ CommInterface.setPortChoice(currentPort);
+ bottomPanel.setEnabled(true);
+ //Notify the infoPane of the current port choice
+ //infoPane.setPort(currentPort);
+ }
+ }
+
+
+ public static void startLogger(final int defaultCloseOperation, final Settings settings) {
+ SwingUtilities.invokeLater(new Runnable() {
+ public void run() {
+ JutecGUI application = new JutecGUI(defaultCloseOperation);
+ application.setVisible(true);
+ }
+ });
+ }
+
+ /**
+ * Main method
+ * @param args
+ */
+ public static void main(String[] args) {
+ JutecGUI application = new JutecGUI(0);
+ application.setVisible(true);
+
+ }
+}
diff --git a/src/enginuity/logger/utec/gui/barGraph/BarGraph.java b/src/enginuity/logger/utec/gui/barGraph/BarGraph.java
new file mode 100755
index 00000000..d73d1e4e
--- /dev/null
+++ b/src/enginuity/logger/utec/gui/barGraph/BarGraph.java
@@ -0,0 +1,47 @@
+/*
+ * Created on May 26, 2005
+ *
+ * To change the template for this generated file go to
+ * Window - Preferences - Java - Code Generation - Code and Comments
+ */
+package enginuity.logger.utec.gui.barGraph;
+
+import java.awt.*;
+import java.awt.geom.*;
+
+import javax.swing.*;
+
+/**
+ * @author emorgan
+ *
+ * To change the template for this generated type comment go to
+ * Window - Preferences - Java - Code Generation - Code and Comments
+ */
+public class BarGraph extends JComponent{
+
+ public BarGraph(){
+
+ }
+
+ private void Init(){
+
+ }
+
+ public void paint(Graphics g) {
+
+ //Dimensions of bounding entity
+ Dimension theSize = this.getSize();
+ int width = theSize.width;
+ int height = theSize.height;
+
+
+ Graphics2D g2 = (Graphics2D) g;
+ GradientPaint gp = new GradientPaint((float)0, (float)0, Color.RED, (float)0, (float)height-10, Color.GREEN);
+
+ RoundRectangle2D rect1 = new RoundRectangle2D.Double(30, 5, 90, 390, 10, 10);
+ g2.setPaint(gp);
+ g2.fill(rect1);
+ g2.setPaint(Color.BLACK);
+ g2.draw(rect1);
+ }
+}
diff --git a/src/enginuity/logger/utec/gui/bottomControl/BottomUtecControl.java b/src/enginuity/logger/utec/gui/bottomControl/BottomUtecControl.java
new file mode 100755
index 00000000..4bb87cdf
--- /dev/null
+++ b/src/enginuity/logger/utec/gui/bottomControl/BottomUtecControl.java
@@ -0,0 +1,195 @@
+/*
+ * Created on May 29, 2005
+ *
+ * To change the template for this generated file go to
+ * Window - Preferences - Java - Code Generation - Code and Comments
+ */
+package enginuity.logger.utec.gui.bottomControl;
+import javax.swing.*;
+import java.awt.*;
+import java.awt.event.*;
+import enginuity.logger.utec.commInterface.CommInterface;
+import enginuity.logger.utec.gui.JutecGUI;
+import enginuity.logger.utec.commEvent.*;
+
+/**
+ * @author emorgan
+ *
+ * To change the template for this generated type comment go to
+ * Window - Preferences - Java - Code Generation - Code and Comments
+ */
+public class BottomUtecControl extends JPanel implements ActionListener, CommListener{
+ //Buttons to be used
+ private JButton openButton;
+ private JButton closeButton;
+ private JButton startButton;
+ private JButton stopButton;
+
+ //Text areas to be used
+ private JTextArea textFromUtec;
+
+ public String totalLog = "";
+
+ public void setOpenPortEnabled(boolean choice){
+ openButton.setEnabled(choice);
+ }
+
+ public BottomUtecControl() {
+
+ //Define UTEC output text Area
+ textFromUtec = new JTextArea();
+ textFromUtec.setCaretPosition(textFromUtec.getDocument().getLength());
+ textFromUtec.setText(
+ "--==< Live data feed from UTEC will start here. >==--\n");
+ JScrollPane utecOutTextScroll = new JScrollPane(textFromUtec);
+
+ //-------------------------
+ //Define buttons to be used
+ //-------------------------
+ //JButton button;
+ GridBagLayout gridbag = new GridBagLayout();
+ GridBagConstraints c = new GridBagConstraints();
+ this.setLayout(gridbag);
+ c.fill = GridBagConstraints.BOTH;
+ c.gridwidth = 1;
+
+ //Button to open defined COM Port
+ openButton = new JButton("OPEN PORT");
+ openButton.addActionListener(this);
+ c.weightx = 0.5;
+ c.gridx = 0;
+ c.gridy = 0;
+ gridbag.setConstraints(openButton, c);
+ //openButton.setEnabled(false);
+ this.add(openButton);
+
+ //Button to close defined COM port
+ closeButton = new JButton("CLOSE PORT");
+ closeButton.addActionListener(this);
+ closeButton.setEnabled(false);
+ c.gridx = 0;
+ c.gridy = 1;
+ gridbag.setConstraints(closeButton, c);
+ this.add(closeButton);
+
+ //Button to start data capture from UTEC
+ startButton = new JButton("START CAPTURE");
+ startButton.addActionListener(this);
+ startButton.setEnabled(false);
+ c.gridx = 0;
+ c.gridy = 2;
+ gridbag.setConstraints(startButton, c);
+ this.add(startButton);
+
+ //Button to stop data capture from UTEC
+ stopButton = new JButton("STOP CAPTURE");
+ stopButton.addActionListener(this);
+ stopButton.setEnabled(false);
+ c.gridx = 0;
+ c.gridy = 3;
+ gridbag.setConstraints(stopButton, c);
+ this.add(stopButton);
+
+ //Text box that returns live text data from the UTEC
+ c.ipadx = 600;
+ c.gridheight = 5;
+ c.gridx = 1;
+ c.gridy = 0;
+ gridbag.setConstraints(utecOutTextScroll, c);
+ this.add(utecOutTextScroll);
+
+ //Make this panel listen for comm events
+ CommInterface.addListener(this);
+ }
+
+ /**
+ * Implements actionPerformed
+ *
+ */
+ public void actionPerformed(ActionEvent e) {
+ String cmd = e.getActionCommand();
+
+ //Open Port
+ if (cmd.equals("OPEN PORT")) {
+ System.out.println("Opening connection to defined port: "+CommInterface.getPortChoiceUsed());
+
+ //Don't allow use after first press, and until after close port has been pressed
+ openButton.setEnabled(false);
+ closeButton.setEnabled(true);
+ startButton.setEnabled(true);
+ stopButton.setEnabled(false);
+
+ //Use interface to open connection
+ CommInterface.openConnection();
+
+ //VoiceThread vc = new VoiceThread("open port");
+ //vc.start();
+ }
+
+ //Close Port
+ if (cmd.equals("CLOSE PORT")) {
+ System.out.println("Closing connection to defined port");
+
+ //Use interface to close the connection to the Utec
+ CommInterface.closeConnection();
+
+ //Set button states
+ openButton.setEnabled(true);
+ closeButton.setEnabled(false);
+ startButton.setEnabled(false);
+ stopButton.setEnabled(false);
+
+ //VoiceThread vc = new VoiceThread("close port.");
+ //vc.start();
+ }
+
+ //Start Capture
+ if (cmd.equals("START CAPTURE")) {
+ System.out.println("Starting data capture from the UTEC");
+
+ //Use interface to pull logging data from the Utec
+ CommInterface.startDataLogFromUtec();
+
+ //Set button states
+ startButton.setEnabled(false);
+ stopButton.setEnabled(true);
+ openButton.setEnabled(false);
+ closeButton.setEnabled(false);
+
+ //Disable log save option
+ JutecGUI.getInstance().saveItem.setEnabled(false);
+
+ //VoiceThread vc = new VoiceThread("start capture");
+ //vc.start();
+ }
+
+ //Stop Capture
+ if (cmd.equals("STOP CAPTURE")) {
+ System.out.println("Stopping data capture from the UTEC");
+
+ //Use interface to reset the state of the Utec
+ CommInterface.resetUtec();
+
+ //Set button states
+ startButton.setEnabled(true);
+ stopButton.setEnabled(false);
+ closeButton.setEnabled(true);
+ openButton.setEnabled(false);
+
+ //Enable log save option
+ JutecGUI.getInstance().saveItem.setEnabled(true);
+
+ //VoiceThread vc = new VoiceThread("stop capture");
+ //vc.start();
+ }
+ }
+
+ public void getCommEvent(CommEvent e){
+ String utecData = e.UtecBuffer;
+ totalLog+=utecData;
+ textFromUtec.append(utecData);
+ textFromUtec.setCaretPosition(textFromUtec.getDocument().getLength());
+
+ //System.out.println("Adding data to the text AREA");
+ }
+}
diff --git a/src/enginuity/logger/utec/gui/realtimeData/RealTimeData.java b/src/enginuity/logger/utec/gui/realtimeData/RealTimeData.java
new file mode 100755
index 00000000..843351f3
--- /dev/null
+++ b/src/enginuity/logger/utec/gui/realtimeData/RealTimeData.java
@@ -0,0 +1,168 @@
+package enginuity.logger.utec.gui.realtimeData;
+
+import java.awt.*;
+import java.awt.geom.*;
+import javax.swing.*;
+
+import enginuity.logger.utec.gui.bottomControl.*;
+import enginuity.tts.VoiceThread;
+import enginuity.logger.utec.commEvent.*;
+import enginuity.logger.utec.commInterface.CommInterface;
+
+/**
+ * @author botman
+ *
+ * Class displays live data from the UTEC
+ */
+public class RealTimeData extends JComponent implements CommListener{
+
+ //Buttons to be used
+ private JButton openButton;
+ private JButton closeButton;
+ private JButton startButton;
+ private JButton stopButton;
+
+ //Text areas to be used
+ private JTextArea textFromUtec;
+
+ //Recieved utec data, start values are zero
+ public String[] stringData = {"0","0","0","0","0","0"};
+ public double[] doubleData = {0,0,0,0,0,0};
+
+ //Graph Constants
+ private double maxHeight = 370;
+
+ //Window Constants
+ private int windowHeight = 400;
+
+ //Constructor
+ public RealTimeData() {
+ CommInterface.addListener(this);
+ }
+
+ /**
+ * Sets the used ports
+ * @param portChoice
+ */
+ public void setPort(String portChoice) {
+ CommInterface.setPortChoice(portChoice);
+ }
+
+ public void paint(Graphics g) {
+
+ Graphics2D g2 = (Graphics2D) g;
+ GradientPaint gp = new GradientPaint((float)30, (float)-10, Color.RED, (float)30, (float)maxHeight, Color.GREEN);
+ g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
+ Font font = new Font("Serif", Font.PLAIN, 20);
+ g2.setFont(font);
+
+ //RPM
+ double max1 = 7500;
+ double min1 = 0;
+ double value1 = doubleData[0];
+ double height1 = ((value1 - min1)/(max1 - min1))*maxHeight;
+ double yValue1 = 5 + (maxHeight - height1);
+ double xValueLeft1 = 30;
+ double width1 = 90;
+ RoundRectangle2D rect1 = new RoundRectangle2D.Double(xValueLeft1, yValue1, width1, height1, 10, 10);
+ g2.setPaint(gp);
+ g2.fill(rect1);
+ g2.setPaint(Color.BLACK);
+ g2.draw(rect1);
+ g2.drawString("RPM:"+(int)value1, (int)xValueLeft1, windowHeight);
+
+ //PSI
+ double max2 = 20;
+ double min2 = -14.7;
+ double value2 = doubleData[1];
+ if(value2 > 18.5){
+ VoiceThread vc = new VoiceThread("Max P S I,"+value2);
+ vc.start();
+ }
+ double height2 = ((value2 - min2)/(max2 - min2))*maxHeight;
+ double yValue2 = 5 + (maxHeight - height2);
+ double xValueLeft2 = 150;
+ double width2 = 90;
+ RoundRectangle2D rect2 = new RoundRectangle2D.Double(xValueLeft2, yValue2, width2, height2, 10, 10);
+ g2.setPaint(gp);
+ g2.fill(rect2);
+ g2.setPaint(Color.BLACK);
+ g2.draw(rect2);
+ g2.drawString("PSI:"+value2, (int)xValueLeft2, windowHeight);
+
+ //KNOCK
+ double max3 = 20;
+ double min3 = 0;
+ double value3 = doubleData[2];
+ if(value3 > 0){
+ VoiceThread vc = new VoiceThread("knock, count "+(int)value3);
+ vc.start();
+ }
+ double height3 = ((value3 - min3)/(max3 - min3))*maxHeight;
+ double yValue3 = 5 + (maxHeight - height3);
+ double xValueLeft3 = 280;
+ double width3 = 90;
+ RoundRectangle2D rect3 = new RoundRectangle2D.Double(xValueLeft3, yValue3, width3, height3, 10, 10);
+ g2.setPaint(gp);
+ g2.fill(rect3);
+ g2.setPaint(Color.BLACK);
+ g2.draw(rect3);
+ g2.drawString("KNOCK:"+(int)value3, (int)xValueLeft3, windowHeight);
+
+ //IGN
+ double max4 = 80;
+ double min4 = 0;
+ double value4 = doubleData[3];
+ double height4 = ((value4 - min4)/(max4 - min4))*maxHeight;
+ double yValue4 = 5 + (maxHeight - height4);
+ double xValueLeft4 = 400;
+ double width4 = 90;
+ RoundRectangle2D rect4 = new RoundRectangle2D.Double(xValueLeft4, yValue4, width4, height4, 10, 10);
+ g2.setPaint(gp);
+ g2.fill(rect4);
+ g2.setPaint(Color.BLACK);
+ g2.draw(rect4);
+ g2.drawString("IGN:"+value4, (int)xValueLeft4, windowHeight);
+
+ //DUTY
+ double max5 = 105;
+ double min5 = 0;
+ double value5 = doubleData[4];
+ if(value5 > 98){
+ VoiceThread vc = new VoiceThread("Max duty "+value5);
+ vc.start();
+ }
+ double height5 = ((value5 - min5)/(max5 - min5))*maxHeight;
+ double yValue5 = 5 + (maxHeight - height5);
+ double xValueLeft5 = 530;
+ double width5 = 90;
+ RoundRectangle2D rect5 = new RoundRectangle2D.Double(xValueLeft5, yValue5, width5, height5, 10, 10);
+ g2.setPaint(gp);
+ g2.fill(rect5);
+ g2.setPaint(Color.BLACK);
+ g2.draw(rect5);
+ g2.drawString("DUTY:"+value5, (int)xValueLeft5, windowHeight);
+
+ //AFR
+ double max6 = 26;
+ double min6 = 0;
+ double value6 = doubleData[5];
+ double height6 = ((value6 - min6)/(max6 - min6))*maxHeight;
+ double yValue6 = 5 + (maxHeight - height6);
+ double xValueLeft6 = 660;
+ double width6 = 90;
+ RoundRectangle2D rect6 = new RoundRectangle2D.Double(xValueLeft6, yValue6, width6, height6, 10, 10);
+ g2.setPaint(gp);
+ g2.fill(rect6);
+ g2.setPaint(Color.BLACK);
+ g2.draw(rect6);
+ g2.drawString("AFR:"+value6, (int)xValueLeft6, windowHeight);
+
+ }
+
+ public void getCommEvent(CommEvent e){
+ stringData = e.data;
+ doubleData = e.doubleData;
+ this.repaint();
+ }
+}
diff --git a/src/enginuity/swing/ECUEditorMenuBar.java b/src/enginuity/swing/ECUEditorMenuBar.java
index c7fc9a56..6516a0d3 100644
--- a/src/enginuity/swing/ECUEditorMenuBar.java
+++ b/src/enginuity/swing/ECUEditorMenuBar.java
@@ -32,6 +32,7 @@ import com.centerkey.utils.BareBonesBrowserLaunch;
import enginuity.ECUEditor;
import enginuity.logger.EcuLogger;
import enginuity.maps.Rom;
+import enginuity.logger.utec.gui.JutecGUI;
public class ECUEditorMenuBar extends JMenuBar implements ActionListener {
@@ -63,7 +64,9 @@ public class ECUEditorMenuBar extends JMenuBar implements ActionListener {
private JMenu loggerMenu = new JMenu("Logger");
private JMenuItem openLogger = new JMenuItem("Launch ECU Logger...");
-
+ private JMenuItem utecLogger = new JMenuItem("Launch UTEC Logger...");
+
+
private JMenu helpMenu = new JMenu("Help");
private JMenuItem about = new JMenuItem("About Enginuity");
@@ -162,8 +165,10 @@ public class ECUEditorMenuBar extends JMenuBar implements ActionListener {
loggerMenu.setMnemonic('L');
openLogger.setMnemonic('O');
loggerMenu.add(openLogger);
+ loggerMenu.add(utecLogger);
openLogger.addActionListener(this);
-
+ utecLogger.addActionListener(this);
+
// help menu stuff
add(helpMenu);
helpMenu.setMnemonic('H');
@@ -265,6 +270,9 @@ public class ECUEditorMenuBar extends JMenuBar implements ActionListener {
} else if (e.getSource() == openLogger) {
EcuLogger.startLogger(DISPOSE_ON_CLOSE, parent.getSettings());
+ } else if (e.getSource() == utecLogger) {
+ JutecGUI.startLogger(DISPOSE_ON_CLOSE, parent.getSettings());
+
} else if (e.getSource() == updateDefinition) {
BareBonesBrowserLaunch.openURL(parent.getSettings().getEcuDefsURL());
diff --git a/src/enginuity/tts/SpeakKnock.java b/src/enginuity/tts/SpeakKnock.java
new file mode 100755
index 00000000..846a035f
--- /dev/null
+++ b/src/enginuity/tts/SpeakKnock.java
@@ -0,0 +1,42 @@
+/*
+ * 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();
+ }
+}
diff --git a/src/enginuity/tts/VoiceThread.java b/src/enginuity/tts/VoiceThread.java
new file mode 100755
index 00000000..1c9d57ca
--- /dev/null
+++ b/src/enginuity/tts/VoiceThread.java
@@ -0,0 +1,27 @@
+/*
+ * 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;
+
+/**
+ * @author botman
+ *
+ * TODO To change the template for this generated type comment go to
+ * Window - Preferences - Java - Code Style - Code Templates
+ */
+public class VoiceThread extends Thread{
+
+ private String message = null;
+
+ public VoiceThread(String message){
+ this.message = message;
+
+ }
+
+ public void run(){
+ SpeakKnock.speakString(message);
+ }
+}