mirror of https://github.com/rusefi/RomRaider.git
working on saving maps back to the utec
git-svn-id: http://svn.3splooges.com/romraider-arch/trunk@541 d2e2e1cd-ba16-0410-be16-b7c4453c7c2d
This commit is contained in:
parent
a1580eb825
commit
a32691e8a8
|
@ -8,6 +8,7 @@ import javax.swing.*;
|
||||||
import enginuity.logger.utec.commEvent.*;
|
import enginuity.logger.utec.commEvent.*;
|
||||||
import enginuity.logger.utec.mapData.GetMapFromUtecListener;
|
import enginuity.logger.utec.mapData.GetMapFromUtecListener;
|
||||||
import enginuity.logger.utec.mapData.UtecMapData;
|
import enginuity.logger.utec.mapData.UtecMapData;
|
||||||
|
import enginuity.logger.utec.properties.UtecProperties;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Class negotiates data to and from UTEC via the serial port
|
* Class negotiates data to and from UTEC via the serial port
|
||||||
|
@ -90,8 +91,17 @@ public class UtecSerialConnection implements SerialPortEventListener {
|
||||||
public void startLoggerDataFlow() {
|
public void startLoggerDataFlow() {
|
||||||
System.out.println("Starting data flow from UTEC");
|
System.out.println("Starting data flow from UTEC");
|
||||||
|
|
||||||
// OutPut a '!' to start basic data flow from UTEC
|
String[] commandList = UtecProperties.getProperties("utec.startLogging");
|
||||||
this.sendDataToUtec(33);
|
if(commandList == null){
|
||||||
|
System.err.println("Command string in properties file for utec.startLogging not found.");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
this.resetUtec();
|
||||||
|
for(int i = 0; i < commandList.length ; i++){
|
||||||
|
// Send parsed command to the utec
|
||||||
|
this.sendCommandToUtec(Integer.parseInt(commandList[i]));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -99,16 +109,18 @@ public class UtecSerialConnection implements SerialPortEventListener {
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public void resetUtec() {
|
public void resetUtec() {
|
||||||
// OutPut 2 ctrl-x to UTEC
|
|
||||||
// this.sendDataToUtec('\u0018');
|
|
||||||
// this.sendDataToUtec('\u0018');
|
|
||||||
System.out.println("Utec reset called.");
|
System.out.println("Utec reset called.");
|
||||||
this.sendDataToUtec(24);
|
|
||||||
this.waitForIt();
|
String[] commandList = UtecProperties.getProperties("utec.resetUtec");
|
||||||
this.sendDataToUtec(24);
|
if(commandList == null){
|
||||||
this.waitForIt();
|
System.err.println("Command string in properties file for utec.resetUtec not found.");
|
||||||
this.sendDataToUtec(24);
|
return;
|
||||||
this.waitForIt();
|
}
|
||||||
|
|
||||||
|
for(int i = 0; i < commandList.length ; i++){
|
||||||
|
// Send parsed command to the utec
|
||||||
|
this.sendCommandToUtec(Integer.parseInt(commandList[i]));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -117,15 +129,22 @@ public class UtecSerialConnection implements SerialPortEventListener {
|
||||||
* @param mapNumber
|
* @param mapNumber
|
||||||
*/
|
*/
|
||||||
public void pullMapData(int mapNumber, GetMapFromUtecListener listener) {
|
public void pullMapData(int mapNumber, GetMapFromUtecListener listener) {
|
||||||
this.resetUtec();
|
|
||||||
System.out.println("UtecControl, getting map:" + mapNumber);
|
|
||||||
|
|
||||||
// Check bounds of map requested
|
// Sanity check
|
||||||
if (mapNumber < 1 || mapNumber > 5) {
|
if (mapNumber < 1 || mapNumber > 5) {
|
||||||
System.err.println("Map selection out of range.");
|
System.err.println("Map selection out of range.");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
String[] commandList = UtecProperties.getProperties("utec.startMapDownload");
|
||||||
|
if(commandList == null){
|
||||||
|
System.err.println("Command string in properties file for utec.startMapDownload not found.");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
this.resetUtec();
|
||||||
|
System.out.println("UtecControl, getting map:" + mapNumber);
|
||||||
|
|
||||||
// Null out any previously loaded map
|
// Null out any previously loaded map
|
||||||
this.currentMap = null;
|
this.currentMap = null;
|
||||||
|
|
||||||
|
@ -136,86 +155,177 @@ public class UtecSerialConnection implements SerialPortEventListener {
|
||||||
this.isMapFromUtecPrep = true;
|
this.isMapFromUtecPrep = true;
|
||||||
this.isMapFromUtec = false;
|
this.isMapFromUtec = false;
|
||||||
|
|
||||||
// Reset the UTEC
|
// Iterate through command string
|
||||||
this.resetUtec();
|
int starCounter = 0;
|
||||||
|
for(int i = 0; i < commandList.length ; i++){
|
||||||
|
if(commandList[i].equalsIgnoreCase("*")){
|
||||||
|
if(starCounter == 0){
|
||||||
|
// Select map
|
||||||
|
|
||||||
// Send an 'e' to enter map menu
|
if (mapNumber == 1) {
|
||||||
// this.sendDataToUtec('\u0065');
|
this.sendCommandToUtec(33);
|
||||||
this.sendDataToUtec(101);
|
System.out.println("Requested Map 1");
|
||||||
System.out.println("Sent an e");
|
}
|
||||||
this.waitForIt();
|
if (mapNumber == 2) {
|
||||||
|
this.sendCommandToUtec(64);
|
||||||
|
System.out.println("Requested Map 2");
|
||||||
|
}
|
||||||
|
if (mapNumber == 3) {
|
||||||
|
this.sendCommandToUtec(35);
|
||||||
|
System.out.println("Requested Map 3");
|
||||||
|
}
|
||||||
|
if (mapNumber == 4) {
|
||||||
|
this.sendCommandToUtec(36);
|
||||||
|
System.out.println("Requested Map 4");
|
||||||
|
}
|
||||||
|
if (mapNumber == 5) {
|
||||||
|
this.sendCommandToUtec(37);
|
||||||
|
System.out.println("Requested Map 5");
|
||||||
|
}
|
||||||
|
}else if(starCounter == 1){
|
||||||
|
|
||||||
// Point UTEC menu to the appropriate map
|
// Make this class receptive to map transfer
|
||||||
if (mapNumber == 1) {
|
this.isMapFromUtec = true;
|
||||||
// this.sendDataToUtec('\u0021');
|
|
||||||
this.sendDataToUtec(33);
|
// No longer map prep
|
||||||
System.out.println("Requested Map 1");
|
this.isMapFromUtecPrep = false;
|
||||||
this.waitForIt();
|
|
||||||
}
|
}else{
|
||||||
if (mapNumber == 2) {
|
System.err.println("No operation supported for properties value '*'");
|
||||||
// this.sendDataToUtec('\u0040');
|
}
|
||||||
this.sendDataToUtec(64);
|
|
||||||
System.out.println("Requested Map 2");
|
starCounter++;
|
||||||
}
|
}else{
|
||||||
if (mapNumber == 3) {
|
// Send parsed command to the utec
|
||||||
// this.sendDataToUtec('\u0023');
|
this.sendCommandToUtec(Integer.parseInt(commandList[i]));
|
||||||
this.sendDataToUtec(35);
|
}
|
||||||
System.out.println("Requested Map 3");
|
|
||||||
}
|
|
||||||
if (mapNumber == 4) {
|
|
||||||
// this.sendDataToUtec('\u0024');
|
|
||||||
this.sendDataToUtec(36);
|
|
||||||
System.out.println("Requested Map 4");
|
|
||||||
}
|
|
||||||
if (mapNumber == 5) {
|
|
||||||
// this.sendDataToUtec('\u0025');
|
|
||||||
this.sendDataToUtec(37);
|
|
||||||
System.out.println("Requested Map 5");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Write first ctrl-s to init save state
|
|
||||||
// this.sendDataToUtec('\u0013');
|
|
||||||
this.sendDataToUtec(19);
|
|
||||||
System.out.println("Sent crtl-s");
|
|
||||||
this.waitForIt();
|
|
||||||
|
|
||||||
// Make this class receptive to map transfer
|
|
||||||
this.isMapFromUtec = true;
|
|
||||||
|
|
||||||
// No longer map prep
|
|
||||||
this.isMapFromUtecPrep = false;
|
|
||||||
|
|
||||||
// Write second ctrl-s to start map data flow
|
|
||||||
// this.sendDataToUtec('\u0013');
|
|
||||||
this.sendDataToUtec(19);
|
|
||||||
System.out.println("Sent crtl-s");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Helper method to write chars to the UTEC
|
* Transmit a map to the utec
|
||||||
|
*
|
||||||
|
* @param mapNumber
|
||||||
|
* @param listener
|
||||||
|
*/
|
||||||
|
public void sendMapData(int mapNumber, StringBuffer mapData) {
|
||||||
|
|
||||||
|
// Sanity check
|
||||||
|
if (mapNumber < 1 || mapNumber > 5) {
|
||||||
|
System.err.println("Map selection out of range.");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
String[] commandList = UtecProperties.getProperties("utec.startMapDownload");
|
||||||
|
if(commandList == null){
|
||||||
|
System.err.println("Command string in properties file for utec.startMapUpload not found.");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
this.resetUtec();
|
||||||
|
System.out.println("UtecControl, sending map:" + mapNumber);
|
||||||
|
|
||||||
|
// Iterate through command string
|
||||||
|
int starCounter = 0;
|
||||||
|
for(int i = 0; i < commandList.length ; i++){
|
||||||
|
if(commandList[i].equalsIgnoreCase("*")){
|
||||||
|
if(starCounter == 0){
|
||||||
|
// Select map
|
||||||
|
|
||||||
|
if (mapNumber == 1) {
|
||||||
|
this.sendCommandToUtec(33);
|
||||||
|
System.out.println("Requested Map 1");
|
||||||
|
}
|
||||||
|
if (mapNumber == 2) {
|
||||||
|
this.sendCommandToUtec(64);
|
||||||
|
System.out.println("Requested Map 2");
|
||||||
|
}
|
||||||
|
if (mapNumber == 3) {
|
||||||
|
this.sendCommandToUtec(35);
|
||||||
|
System.out.println("Requested Map 3");
|
||||||
|
}
|
||||||
|
if (mapNumber == 4) {
|
||||||
|
this.sendCommandToUtec(36);
|
||||||
|
System.out.println("Requested Map 4");
|
||||||
|
}
|
||||||
|
if (mapNumber == 5) {
|
||||||
|
this.sendCommandToUtec(37);
|
||||||
|
System.out.println("Requested Map 5");
|
||||||
|
}
|
||||||
|
}else if(starCounter == 1){
|
||||||
|
this.sendDataToUtec(mapData);
|
||||||
|
|
||||||
|
}else{
|
||||||
|
System.err.println("No operation supported for properties value '*'");
|
||||||
|
}
|
||||||
|
|
||||||
|
starCounter++;
|
||||||
|
}else{
|
||||||
|
// Send parsed command to the utec
|
||||||
|
this.sendCommandToUtec(Integer.parseInt(commandList[i]));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Helper method to write chcommands to the UTEC. There is a pause after each command sent to ensure utec has time to respond.
|
||||||
*
|
*
|
||||||
* @param charValue
|
* @param charValue
|
||||||
*/
|
*/
|
||||||
public void sendDataToUtec(int charValue) {
|
public void sendCommandToUtec(int charValue) {
|
||||||
|
|
||||||
if(this.sPort == null){ System.err.println("No Port Selected, therefore no interraction with Utec happening.");
|
if(this.sPort == null){ System.err.println("No Port Selected, therefore no interraction with Utec happening.");
|
||||||
return; }
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
try {
|
try {
|
||||||
outputToUtecStream.write(charValue);
|
outputToUtecStream.write(charValue);
|
||||||
|
|
||||||
|
System.out.println("Sending command to the ute:"+charValue);
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
System.err.println("Can't send char data to UTEC: " + charValue);
|
System.err.println("Can't send char command to UTEC: " + charValue);
|
||||||
e.getMessage();
|
e.getMessage();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
this.waitForIt();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Method sends string data to the utec
|
||||||
|
* @param mapData
|
||||||
|
*/
|
||||||
|
public void sendDataToUtec(StringBuffer mapData){
|
||||||
|
if(this.sPort == null){ System.err.println("No Port Selected, therefore no interraction with Utec happening.");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
for(int i = 0; i < mapData.length(); i++){
|
||||||
|
try {
|
||||||
|
outputToUtecStream.write(mapData.charAt(i));
|
||||||
|
} catch (IOException e) {
|
||||||
|
System.err.println("Can't send char data to UTEC: " + mapData.charAt(i));
|
||||||
|
e.getMessage();
|
||||||
|
}
|
||||||
|
|
||||||
|
//Wait
|
||||||
|
this.waitForIt();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Helper method to pause application. Used to spread data transmission
|
||||||
|
*
|
||||||
|
*/
|
||||||
private void waitForIt(){
|
private void waitForIt(){
|
||||||
|
String[] pauseString = UtecProperties.getProperties("utec.dataTransmissionPauseMS");
|
||||||
|
|
||||||
|
int pauseCount = Integer.parseInt(pauseString[0]);
|
||||||
try {
|
try {
|
||||||
Thread.currentThread().sleep(1000);
|
Thread.currentThread().sleep(pauseCount);
|
||||||
System.out.println("waiting 1 second.");
|
System.out.println("waiting for this many ms:"+pauseCount);
|
||||||
} catch (InterruptedException e) {
|
} catch (InterruptedException e) {
|
||||||
// TODO Auto-generated catch block
|
// TODO Auto-generated catch block
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
|
|
|
@ -21,7 +21,7 @@ import enginuity.logger.utec.mapData.UtecMapData;
|
||||||
public class CommEvent {
|
public class CommEvent {
|
||||||
private String UtecBuffer = null;
|
private String UtecBuffer = null;
|
||||||
private String[] data = new String[6];
|
private String[] data = new String[6];
|
||||||
private double[] doubleData = new double[6];
|
private double[] doubleData = null; //new double[6];
|
||||||
|
|
||||||
private boolean isLoggerData = false;
|
private boolean isLoggerData = false;
|
||||||
private boolean isMapData = false;
|
private boolean isMapData = false;
|
||||||
|
@ -32,45 +32,11 @@ public class CommEvent {
|
||||||
|
|
||||||
public void setLoggerData(String buffer){
|
public void setLoggerData(String buffer){
|
||||||
UtecBuffer = buffer;
|
UtecBuffer = buffer;
|
||||||
StringTokenizer st = new StringTokenizer(UtecBuffer, ",");
|
|
||||||
int counter = 0;
|
|
||||||
while(st.hasMoreTokens()){
|
|
||||||
String theData = st.nextToken();
|
|
||||||
|
|
||||||
//RPM
|
data = UtecBuffer.split(",");
|
||||||
if(counter == 0){
|
doubleData = new double[data.length];
|
||||||
data[0] = theData;
|
|
||||||
}
|
|
||||||
|
|
||||||
//PSI
|
for(int i = 0; i < data.length; i++){
|
||||||
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];
|
String theData = data[i];
|
||||||
theData = theData.trim();
|
theData = theData.trim();
|
||||||
if(theData.startsWith(">")){
|
if(theData.startsWith(">")){
|
||||||
|
|
|
@ -19,6 +19,7 @@ import javax.swing.*;
|
||||||
|
|
||||||
import enginuity.logger.utec.gui.realtimeData.*;
|
import enginuity.logger.utec.gui.realtimeData.*;
|
||||||
import enginuity.logger.utec.mapData.GetMapFromUtecListener;
|
import enginuity.logger.utec.mapData.GetMapFromUtecListener;
|
||||||
|
import enginuity.logger.utec.mapData.UtecMapData;
|
||||||
import enginuity.logger.utec.comm.*;
|
import enginuity.logger.utec.comm.*;
|
||||||
/**
|
/**
|
||||||
* @author emorgan
|
* @author emorgan
|
||||||
|
@ -52,13 +53,18 @@ public class UtecInterface{
|
||||||
utecControl.pullMapData(mapNumber, listener);
|
utecControl.pullMapData(mapNumber, listener);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static void uploadMap(int mapNumber, UtecMapData mapData){
|
||||||
|
openConnection();
|
||||||
|
utecControl.sendMapData(mapNumber, mapData.getUpdatedMap());
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Pass a command to the UTEC
|
* Pass a command to the UTEC
|
||||||
* @param charValue
|
* @param charValue
|
||||||
*/
|
*/
|
||||||
public static void sendDataToUtec(int charValue){
|
public static void sendCommandToUtec(int charValue){
|
||||||
openConnection();
|
openConnection();
|
||||||
utecControl.sendDataToUtec(charValue);
|
utecControl.sendCommandToUtec(charValue);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -20,7 +20,8 @@ import enginuity.logger.utec.gui.realtimeData.*;
|
||||||
import enginuity.logger.utec.gui.bottomControl.*;
|
import enginuity.logger.utec.gui.bottomControl.*;
|
||||||
import enginuity.logger.utec.mapData.GetMapFromUtecListener;
|
import enginuity.logger.utec.mapData.GetMapFromUtecListener;
|
||||||
import enginuity.logger.utec.mapData.UtecMapData;
|
import enginuity.logger.utec.mapData.UtecMapData;
|
||||||
import enginuity.tts.VoiceThread;
|
import enginuity.logger.utec.properties.UtecProperties;
|
||||||
|
import enginuity.tts.SpeakString;
|
||||||
import enginuity.logger.utec.commInterface.UtecInterface;
|
import enginuity.logger.utec.commInterface.UtecInterface;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -67,6 +68,11 @@ public class JutecGUI extends JFrame implements ActionListener,GetMapFromUtecLis
|
||||||
public JMenuItem loadMapFour = new JMenuItem("Load Map #4");
|
public JMenuItem loadMapFour = new JMenuItem("Load Map #4");
|
||||||
public JMenuItem loadMapFive = new JMenuItem("Load Map #5");
|
public JMenuItem loadMapFive = new JMenuItem("Load Map #5");
|
||||||
|
|
||||||
|
public JMenuItem saveMapOne = new JMenuItem("Save To Map #1");
|
||||||
|
public JMenuItem saveMapTwo = new JMenuItem("Save To Map #2");
|
||||||
|
public JMenuItem saveMapThree = new JMenuItem("Save To Map #3");
|
||||||
|
public JMenuItem saveMapFour = new JMenuItem("Save To Map #4");
|
||||||
|
public JMenuItem saveMapFive = new JMenuItem("Save To Map #5");
|
||||||
|
|
||||||
|
|
||||||
private static JutecGUI instance = null;
|
private static JutecGUI instance = null;
|
||||||
|
@ -91,7 +97,7 @@ public class JutecGUI extends JFrame implements ActionListener,GetMapFromUtecLis
|
||||||
|
|
||||||
// Main frame
|
// Main frame
|
||||||
// Grid layout with a top and bottom, ie two rows
|
// Grid layout with a top and bottom, ie two rows
|
||||||
super("UTEC Loggers");
|
super("UTEC Logger");
|
||||||
this.setSize(800, 640);
|
this.setSize(800, 640);
|
||||||
this.setResizable(false);
|
this.setResizable(false);
|
||||||
this.setDefaultCloseOperation(setDefaultCloseOperation);
|
this.setDefaultCloseOperation(setDefaultCloseOperation);
|
||||||
|
@ -100,8 +106,7 @@ public class JutecGUI extends JFrame implements ActionListener,GetMapFromUtecLis
|
||||||
// Voice the welcome message
|
// Voice the welcome message
|
||||||
// *************************
|
// *************************
|
||||||
|
|
||||||
VoiceThread vc = new VoiceThread("Welcome to you teck logger! Use at your own risk.");
|
SpeakString vc = new SpeakString("Welcome to you teck logger! Use at your own risk.");
|
||||||
vc.start();
|
|
||||||
|
|
||||||
// Actions to take when window is closing
|
// Actions to take when window is closing
|
||||||
addWindowListener(new WindowAdapter() {
|
addWindowListener(new WindowAdapter() {
|
||||||
|
@ -159,6 +164,23 @@ public class JutecGUI extends JFrame implements ActionListener,GetMapFromUtecLis
|
||||||
getMapsMenu.add(loadMapFive);
|
getMapsMenu.add(loadMapFive);
|
||||||
menuBar.add(getMapsMenu);
|
menuBar.add(getMapsMenu);
|
||||||
|
|
||||||
|
|
||||||
|
// ****************************************
|
||||||
|
// Add menu item to save maps to the utec
|
||||||
|
// ****************************************
|
||||||
|
JMenu setMapsMenu = new JMenu("Save Map");
|
||||||
|
saveMapOne.addActionListener(this);
|
||||||
|
saveMapTwo.addActionListener(this);
|
||||||
|
saveMapThree.addActionListener(this);
|
||||||
|
saveMapFour.addActionListener(this);
|
||||||
|
saveMapFive.addActionListener(this);
|
||||||
|
setMapsMenu.add(saveMapOne);
|
||||||
|
setMapsMenu.add(saveMapTwo);
|
||||||
|
setMapsMenu.add(saveMapThree);
|
||||||
|
setMapsMenu.add(saveMapFour);
|
||||||
|
setMapsMenu.add(saveMapFive);
|
||||||
|
menuBar.add(setMapsMenu);
|
||||||
|
|
||||||
// ***************************************
|
// ***************************************
|
||||||
// Add a menu item for comm port selection
|
// Add a menu item for comm port selection
|
||||||
// ***************************************
|
// ***************************************
|
||||||
|
@ -203,7 +225,7 @@ public class JutecGUI extends JFrame implements ActionListener,GetMapFromUtecLis
|
||||||
bottomPanel = new BottomUtecControl();
|
bottomPanel = new BottomUtecControl();
|
||||||
|
|
||||||
|
|
||||||
this.topTabbedPane.add("Graph Data", new RealTimeData());
|
this.topTabbedPane.add("Dashboard", new RealTimeData());
|
||||||
this.topTabbedPane.add("Timing Data", new MapJPanel(MapJPanel.TIMINGMAP));
|
this.topTabbedPane.add("Timing Data", new MapJPanel(MapJPanel.TIMINGMAP));
|
||||||
this.topTabbedPane.add("Fuel Data", new MapJPanel(MapJPanel.FUELMAP));
|
this.topTabbedPane.add("Fuel Data", new MapJPanel(MapJPanel.FUELMAP));
|
||||||
this.topTabbedPane.add("Boost Data", new MapJPanel(MapJPanel.BOOSTMAP));
|
this.topTabbedPane.add("Boost Data", new MapJPanel(MapJPanel.BOOSTMAP));
|
||||||
|
@ -327,6 +349,30 @@ public class JutecGUI extends JFrame implements ActionListener,GetMapFromUtecLis
|
||||||
UtecInterface.getMap(5, this);
|
UtecInterface.getMap(5, this);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
else if (cmd.equals("Save To Map #1")) {
|
||||||
|
System.out.println("Starting to save map #1");
|
||||||
|
UtecInterface.uploadMap(1, DataManager.getCurrentMapData());
|
||||||
|
}
|
||||||
|
|
||||||
|
else if (cmd.equals("Save To Map #2")) {
|
||||||
|
System.out.println("Starting to save map #2");
|
||||||
|
UtecInterface.uploadMap(2, DataManager.getCurrentMapData());
|
||||||
|
}
|
||||||
|
|
||||||
|
else if (cmd.equals("Save To Map #3")) {
|
||||||
|
System.out.println("Starting to save map #3");
|
||||||
|
UtecInterface.uploadMap(3, DataManager.getCurrentMapData());
|
||||||
|
}
|
||||||
|
|
||||||
|
else if (cmd.equals("Save To Map #4")) {
|
||||||
|
System.out.println("Starting to save map #4");
|
||||||
|
UtecInterface.uploadMap(4, DataManager.getCurrentMapData());
|
||||||
|
}
|
||||||
|
|
||||||
|
else if (cmd.equals("Save To Map #5")) {
|
||||||
|
System.out.println("Starting to save map #5");
|
||||||
|
UtecInterface.uploadMap(5, DataManager.getCurrentMapData());
|
||||||
|
}
|
||||||
else if (cmd.equals("Exit")) {
|
else if (cmd.equals("Exit")) {
|
||||||
// Use interface to finally close the connection to the Utec
|
// Use interface to finally close the connection to the Utec
|
||||||
UtecInterface.closeConnection();
|
UtecInterface.closeConnection();
|
||||||
|
@ -407,7 +453,7 @@ public class JutecGUI extends JFrame implements ActionListener,GetMapFromUtecLis
|
||||||
System.out.println("Key Code entered:"+charCodeInt);
|
System.out.println("Key Code entered:"+charCodeInt);
|
||||||
|
|
||||||
//Pass along command to the UTEC
|
//Pass along command to the UTEC
|
||||||
UtecInterface.sendDataToUtec(charCodeInt);
|
UtecInterface.sendCommandToUtec(charCodeInt);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Empty out the text field
|
// Empty out the text field
|
||||||
|
|
|
@ -36,14 +36,25 @@ public class DataManager {
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void setFuelMapValue(int row, int col, double value){
|
public static void setFuelMapValue(int row, int col, double value){
|
||||||
currentMapData.setFuelMapValue(row, col, value);
|
if(currentMapData != null){
|
||||||
|
currentMapData.setFuelMapValue(row, col, value);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void setBoostMapValue(int row, int col, double value){
|
public static void setBoostMapValue(int row, int col, double value){
|
||||||
currentMapData.setBoostMapValue(row, col, value);
|
if(currentMapData != null){
|
||||||
|
currentMapData.setBoostMapValue(row, col, value);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void setTimingMapValue(int row, int col, double value){
|
public static void setTimingMapValue(int row, int col, double value){
|
||||||
currentMapData.setTimingMapValue(row, col, value);
|
if(currentMapData != null){
|
||||||
|
currentMapData.setTimingMapValue(row, col, value);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public static UtecMapData getCurrentMapData() {
|
||||||
|
return currentMapData;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,7 +5,8 @@ import java.awt.geom.*;
|
||||||
import javax.swing.*;
|
import javax.swing.*;
|
||||||
|
|
||||||
import enginuity.logger.utec.gui.bottomControl.*;
|
import enginuity.logger.utec.gui.bottomControl.*;
|
||||||
import enginuity.tts.VoiceThread;
|
import enginuity.logger.utec.properties.UtecProperties;
|
||||||
|
import enginuity.tts.SpeakString;
|
||||||
import enginuity.logger.utec.commEvent.*;
|
import enginuity.logger.utec.commEvent.*;
|
||||||
import enginuity.logger.utec.commInterface.UtecInterface;
|
import enginuity.logger.utec.commInterface.UtecInterface;
|
||||||
|
|
||||||
|
@ -16,18 +17,8 @@ import enginuity.logger.utec.commInterface.UtecInterface;
|
||||||
*/
|
*/
|
||||||
public class RealTimeData extends JComponent implements CommListener{
|
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
|
//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,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0};
|
||||||
public double[] doubleData = {0,0,0,0,0,0};
|
|
||||||
|
|
||||||
//Graph Constants
|
//Graph Constants
|
||||||
private double maxHeight = 370;
|
private double maxHeight = 370;
|
||||||
|
@ -35,6 +26,11 @@ public class RealTimeData extends JComponent implements CommListener{
|
||||||
//Window Constants
|
//Window Constants
|
||||||
private int windowHeight = 400;
|
private int windowHeight = 400;
|
||||||
|
|
||||||
|
// Needed data
|
||||||
|
String[] indexes = UtecProperties.getProperties("utec.loggerIndexes");
|
||||||
|
String[] titles = UtecProperties.getProperties("utec.loggerTitles");
|
||||||
|
String[] dataRanges = UtecProperties.getProperties("utec.loggerDataRanges");
|
||||||
|
|
||||||
//Constructor
|
//Constructor
|
||||||
public RealTimeData() {
|
public RealTimeData() {
|
||||||
UtecInterface.addListener(this);
|
UtecInterface.addListener(this);
|
||||||
|
@ -56,10 +52,10 @@ public class RealTimeData extends JComponent implements CommListener{
|
||||||
Font font = new Font("Serif", Font.PLAIN, 20);
|
Font font = new Font("Serif", Font.PLAIN, 20);
|
||||||
g2.setFont(font);
|
g2.setFont(font);
|
||||||
|
|
||||||
//RPM
|
// 0
|
||||||
double max1 = 7500;
|
double max1 = (minAndMax(dataRanges[0]))[1];
|
||||||
double min1 = 0;
|
double min1 = (minAndMax(dataRanges[0]))[0];
|
||||||
double value1 = doubleData[0];
|
double value1 = doubleData[Integer.parseInt(indexes[0])];
|
||||||
double height1 = ((value1 - min1)/(max1 - min1))*maxHeight;
|
double height1 = ((value1 - min1)/(max1 - min1))*maxHeight;
|
||||||
double yValue1 = 5 + (maxHeight - height1);
|
double yValue1 = 5 + (maxHeight - height1);
|
||||||
double xValueLeft1 = 30;
|
double xValueLeft1 = 30;
|
||||||
|
@ -69,14 +65,14 @@ public class RealTimeData extends JComponent implements CommListener{
|
||||||
g2.fill(rect1);
|
g2.fill(rect1);
|
||||||
g2.setPaint(Color.BLACK);
|
g2.setPaint(Color.BLACK);
|
||||||
g2.draw(rect1);
|
g2.draw(rect1);
|
||||||
g2.drawString("RPM:"+(int)value1, (int)xValueLeft1, windowHeight);
|
g2.drawString(titles[0]+":"+(int)value1, (int)xValueLeft1, windowHeight);
|
||||||
|
|
||||||
//PSI
|
// 1
|
||||||
double max2 = 20;
|
double max2 = (minAndMax(dataRanges[1]))[1];
|
||||||
double min2 = -14.7;
|
double min2 = (minAndMax(dataRanges[1]))[0];
|
||||||
double value2 = doubleData[1];
|
double value2 = doubleData[Integer.parseInt(indexes[1])];
|
||||||
if(value2 > 18.5){
|
if(value2 > 18.5){
|
||||||
VoiceThread vc = new VoiceThread("Max P S I,"+value2);
|
SpeakString vc = new SpeakString("Max P S I,"+value2);
|
||||||
vc.start();
|
vc.start();
|
||||||
}
|
}
|
||||||
double height2 = ((value2 - min2)/(max2 - min2))*maxHeight;
|
double height2 = ((value2 - min2)/(max2 - min2))*maxHeight;
|
||||||
|
@ -88,14 +84,14 @@ public class RealTimeData extends JComponent implements CommListener{
|
||||||
g2.fill(rect2);
|
g2.fill(rect2);
|
||||||
g2.setPaint(Color.BLACK);
|
g2.setPaint(Color.BLACK);
|
||||||
g2.draw(rect2);
|
g2.draw(rect2);
|
||||||
g2.drawString("PSI:"+value2, (int)xValueLeft2, windowHeight);
|
g2.drawString(titles[1]+":"+value2, (int)xValueLeft2, windowHeight);
|
||||||
|
|
||||||
//KNOCK
|
// 2
|
||||||
double max3 = 20;
|
double max3 = (minAndMax(dataRanges[2]))[1];
|
||||||
double min3 = 0;
|
double min3 = (minAndMax(dataRanges[2]))[0];
|
||||||
double value3 = doubleData[2];
|
double value3 = doubleData[Integer.parseInt(indexes[2])];
|
||||||
if(value3 > 0){
|
if(value3 > 0){
|
||||||
VoiceThread vc = new VoiceThread("knock, count "+(int)value3);
|
SpeakString vc = new SpeakString("knock, count "+(int)value3);
|
||||||
vc.start();
|
vc.start();
|
||||||
}
|
}
|
||||||
double height3 = ((value3 - min3)/(max3 - min3))*maxHeight;
|
double height3 = ((value3 - min3)/(max3 - min3))*maxHeight;
|
||||||
|
@ -107,12 +103,12 @@ public class RealTimeData extends JComponent implements CommListener{
|
||||||
g2.fill(rect3);
|
g2.fill(rect3);
|
||||||
g2.setPaint(Color.BLACK);
|
g2.setPaint(Color.BLACK);
|
||||||
g2.draw(rect3);
|
g2.draw(rect3);
|
||||||
g2.drawString("KNOCK:"+(int)value3, (int)xValueLeft3, windowHeight);
|
g2.drawString(titles[2]+":"+(int)value3, (int)xValueLeft3, windowHeight);
|
||||||
|
|
||||||
//IGN
|
// 3
|
||||||
double max4 = 80;
|
double max4 = (minAndMax(dataRanges[3]))[1];
|
||||||
double min4 = 0;
|
double min4 = (minAndMax(dataRanges[3]))[0];
|
||||||
double value4 = doubleData[3];
|
double value4 = doubleData[Integer.parseInt(indexes[3])];
|
||||||
double height4 = ((value4 - min4)/(max4 - min4))*maxHeight;
|
double height4 = ((value4 - min4)/(max4 - min4))*maxHeight;
|
||||||
double yValue4 = 5 + (maxHeight - height4);
|
double yValue4 = 5 + (maxHeight - height4);
|
||||||
double xValueLeft4 = 400;
|
double xValueLeft4 = 400;
|
||||||
|
@ -122,14 +118,14 @@ public class RealTimeData extends JComponent implements CommListener{
|
||||||
g2.fill(rect4);
|
g2.fill(rect4);
|
||||||
g2.setPaint(Color.BLACK);
|
g2.setPaint(Color.BLACK);
|
||||||
g2.draw(rect4);
|
g2.draw(rect4);
|
||||||
g2.drawString("IGN:"+value4, (int)xValueLeft4, windowHeight);
|
g2.drawString(titles[3]+":"+value4, (int)xValueLeft4, windowHeight);
|
||||||
|
|
||||||
//DUTY
|
// 4
|
||||||
double max5 = 105;
|
double max5 = (minAndMax(dataRanges[4]))[1];
|
||||||
double min5 = 0;
|
double min5 = (minAndMax(dataRanges[4]))[0];
|
||||||
double value5 = doubleData[4];
|
double value5 = doubleData[Integer.parseInt(indexes[4])];
|
||||||
if(value5 > 98){
|
if(value5 > 98){
|
||||||
VoiceThread vc = new VoiceThread("Max duty "+value5);
|
SpeakString vc = new SpeakString("Max duty "+value5);
|
||||||
vc.start();
|
vc.start();
|
||||||
}
|
}
|
||||||
double height5 = ((value5 - min5)/(max5 - min5))*maxHeight;
|
double height5 = ((value5 - min5)/(max5 - min5))*maxHeight;
|
||||||
|
@ -141,12 +137,12 @@ public class RealTimeData extends JComponent implements CommListener{
|
||||||
g2.fill(rect5);
|
g2.fill(rect5);
|
||||||
g2.setPaint(Color.BLACK);
|
g2.setPaint(Color.BLACK);
|
||||||
g2.draw(rect5);
|
g2.draw(rect5);
|
||||||
g2.drawString("DUTY:"+value5, (int)xValueLeft5, windowHeight);
|
g2.drawString(titles[4]+":"+value5, (int)xValueLeft5, windowHeight);
|
||||||
|
|
||||||
//AFR
|
// 5
|
||||||
double max6 = 26;
|
double max6 = (minAndMax(dataRanges[5]))[1];
|
||||||
double min6 = 0;
|
double min6 = (minAndMax(dataRanges[5]))[0];
|
||||||
double value6 = doubleData[5];
|
double value6 = doubleData[Integer.parseInt(indexes[5])];
|
||||||
double height6 = ((value6 - min6)/(max6 - min6))*maxHeight;
|
double height6 = ((value6 - min6)/(max6 - min6))*maxHeight;
|
||||||
double yValue6 = 5 + (maxHeight - height6);
|
double yValue6 = 5 + (maxHeight - height6);
|
||||||
double xValueLeft6 = 660;
|
double xValueLeft6 = 660;
|
||||||
|
@ -156,15 +152,24 @@ public class RealTimeData extends JComponent implements CommListener{
|
||||||
g2.fill(rect6);
|
g2.fill(rect6);
|
||||||
g2.setPaint(Color.BLACK);
|
g2.setPaint(Color.BLACK);
|
||||||
g2.draw(rect6);
|
g2.draw(rect6);
|
||||||
g2.drawString("AFR:"+value6, (int)xValueLeft6, windowHeight);
|
g2.drawString(titles[5]+":"+value6, (int)xValueLeft6, windowHeight);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void getCommEvent(CommEvent e){
|
public void getCommEvent(CommEvent e){
|
||||||
if(e.isLoggerData()){
|
if(e.isLoggerData()){
|
||||||
stringData = e.getData();
|
|
||||||
doubleData = e.getDoubleData();
|
doubleData = e.getDoubleData();
|
||||||
this.repaint();
|
this.repaint();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private double[] minAndMax(String value){
|
||||||
|
String[] temp = value.split("<>");
|
||||||
|
|
||||||
|
double[] values = new double[2];
|
||||||
|
values[0] = Double.parseDouble(temp[0]);
|
||||||
|
values[1] = Double.parseDouble(temp[1]);
|
||||||
|
|
||||||
|
return values;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,39 @@
|
||||||
|
package enginuity.logger.utec.properties;
|
||||||
|
|
||||||
|
import java.io.FileInputStream;
|
||||||
|
import java.io.FileNotFoundException;
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.util.Properties;
|
||||||
|
|
||||||
|
public class UtecProperties {
|
||||||
|
private static Properties properties = new Properties();
|
||||||
|
|
||||||
|
private static boolean init = false;
|
||||||
|
|
||||||
|
public static String[] getProperties(String name){
|
||||||
|
if(init == false){
|
||||||
|
init();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
String propertyString = properties.getProperty(name);
|
||||||
|
String[] values = propertyString.split(",");
|
||||||
|
|
||||||
|
|
||||||
|
return values;
|
||||||
|
}
|
||||||
|
|
||||||
|
private static void init(){
|
||||||
|
try {
|
||||||
|
properties.load(new FileInputStream("utec/utec.properties"));
|
||||||
|
} catch (FileNotFoundException e) {
|
||||||
|
// TODO Auto-generated catch block
|
||||||
|
e.printStackTrace();
|
||||||
|
} catch (IOException e) {
|
||||||
|
// TODO Auto-generated catch block
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
|
||||||
|
init = true;
|
||||||
|
}
|
||||||
|
}
|
|
@ -6,22 +6,33 @@
|
||||||
*/
|
*/
|
||||||
package enginuity.tts;
|
package enginuity.tts;
|
||||||
|
|
||||||
|
import enginuity.logger.utec.properties.UtecProperties;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author botman
|
* @author botman
|
||||||
*
|
*
|
||||||
* TODO To change the template for this generated type comment go to
|
* TODO To change the template for this generated type comment go to
|
||||||
* Window - Preferences - Java - Code Style - Code Templates
|
* Window - Preferences - Java - Code Style - Code Templates
|
||||||
*/
|
*/
|
||||||
public class VoiceThread extends Thread{
|
public class SpeakString extends Thread{
|
||||||
|
|
||||||
private String message = null;
|
private String message = null;
|
||||||
|
|
||||||
public VoiceThread(String message){
|
public SpeakString(String message){
|
||||||
this.message = message;
|
this.message = message;
|
||||||
|
this.speakNow();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void run(){
|
public void run(){
|
||||||
SpeakKnock.speakString(message);
|
SpeakKnock.speakString(message);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void speakNow(){
|
||||||
|
String[] toSpeak = UtecProperties.getProperties("utec.sound");
|
||||||
|
boolean parsedBoolean = Boolean.parseBoolean(toSpeak[0]);
|
||||||
|
if(parsedBoolean){
|
||||||
|
this.start();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
|
@ -0,0 +1,10 @@
|
||||||
|
utec.sound=false
|
||||||
|
utec.dataTransmissionPauseMS=100
|
||||||
|
utec.afrIndex=13
|
||||||
|
utec.startLogging=33
|
||||||
|
utec.startMapDownload=101,*,19,19,*
|
||||||
|
utec.startMapUpload=101,*,21,13,*,13
|
||||||
|
utec.resetUtec=24,24,24
|
||||||
|
utec.loggerIndexes=0,1,5,6,7,13
|
||||||
|
utec.loggerTitles=RPM,PSI,KNOCK,IGN,DUTY,AFR
|
||||||
|
utec.loggerDataRanges=0<>7500,-14.7<>26,0<>10,0<>80,0<>110,0<>26
|
Loading…
Reference in New Issue