Can now pull maps from UTEC.

git-svn-id: http://svn.3splooges.com/romraider-arch/trunk@572 d2e2e1cd-ba16-0410-be16-b7c4453c7c2d
This commit is contained in:
Tgui 2007-03-12 04:04:28 +00:00
parent 977b9b52ae
commit 5f04796c3b
5 changed files with 72 additions and 27 deletions

View File

@ -0,0 +1,5 @@
package enginuity.logger.utec.commEvent;
public interface GeneralDataListener {
public void getCommEvent(double[] doubleData);
}

View File

@ -19,6 +19,7 @@ import gnu.io.*;
import javax.swing.*;
import enginuity.logger.utec.gui.mapTabs.UtecDataManager;
import enginuity.logger.utec.gui.realtimeData.*;
import enginuity.logger.utec.mapData.GetMapFromUtecListener;
import enginuity.logger.utec.mapData.UtecMapData;
@ -61,8 +62,13 @@ public class UtecInterface{
* @param mapNumber
* @param listener
*/
public static void sendMapData(int mapNumber, StringBuffer mapData) {
public static void sendMapData(int mapNumber) {
// Pull current data
if(UtecDataManager.getCurrentMapData() == null){
return;
}
StringBuffer mapData = UtecDataManager.getCurrentMapData().getUpdatedMap();
// Sanity check
if (mapNumber < 1 || mapNumber > 5) {
System.err.println("Map selection out of range.");
@ -169,25 +175,18 @@ public class UtecInterface{
public static void pullMapData(int mapNumber) {
// Sanity check
if (mapNumber < 1 || mapNumber > 5) {
System.err.println("Map selection out of range.");
System.err.println("UI 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.startMapDownload not found.");
System.err.println("UI Command string in properties file for utec.startMapDownload not found.");
return;
}
resetUtec();
System.out.println("UtecControl, getting map:" + mapNumber);
// Null out any previously loaded map
//serialEventListener.currentMap = null;
// Setup map transfer prep state
//serialEventListener.isMapFromUtecPrep = true;
//serialEventListener.isMapFromUtec = false;
System.out.println("UI, getting map:" + mapNumber);
// Iterate through command string
int starCounter = 0;
@ -195,7 +194,7 @@ public class UtecInterface{
if(commandList[i].equalsIgnoreCase("*")){
if(starCounter == 0){
// Select map
UtecDataManager.setExpectingMap(true);
if (mapNumber == 1) {
UtecTimerTaskManager.execute(33);
System.out.println("Requested Map 1");
@ -218,14 +217,11 @@ public class UtecInterface{
}
}else if(starCounter == 1){
// Make this class receptive to map transfer
//serialEventListener.isMapFromUtec = true;
// No longer map prep
//serialEventListener.isMapFromUtecPrep = false;
// Make data class receptive to map transfer
}else{
System.err.println("No operation supported for properties value '*'");
System.err.println(" UI No operation supported for properties value '*'");
}
starCounter++;

View File

@ -370,27 +370,27 @@ public class JutecGUI extends JFrame implements ActionListener, KeyListener {
else if (cmd.equals("Save To Map #1")) {
System.out.println("Starting to save map #1");
UtecInterface.sendMapData(1, UtecDataManager.getCurrentMapData().getUpdatedMap());
UtecInterface.sendMapData(1);
}
else if (cmd.equals("Save To Map #2")) {
System.out.println("Starting to save map #2");
UtecInterface.sendMapData(2, UtecDataManager.getCurrentMapData().getUpdatedMap());
UtecInterface.sendMapData(2);
}
else if (cmd.equals("Save To Map #3")) {
System.out.println("Starting to save map #3");
UtecInterface.sendMapData(3, UtecDataManager.getCurrentMapData().getUpdatedMap());
UtecInterface.sendMapData(3);
}
else if (cmd.equals("Save To Map #4")) {
System.out.println("Starting to save map #4");
UtecInterface.sendMapData(4, UtecDataManager.getCurrentMapData().getUpdatedMap());
UtecInterface.sendMapData(4);
}
else if (cmd.equals("Save To Map #5")) {
System.out.println("Starting to save map #5");
UtecInterface.sendMapData(5, UtecDataManager.getCurrentMapData().getUpdatedMap());
UtecInterface.sendMapData(5);
}
else if (cmd.equals("Exit")) {
// Use interface to finally close the connection to the Utec

View File

@ -15,9 +15,12 @@ public class UtecDataManager {
private static UtecTableModel boostListener = null;
private static UtecAFRListener utecAFRListener = null;
private static Vector<LoggerDataListener> loggerListener = new Vector<LoggerDataListener>();
private static Vector<LoggerDataListener> generalListener = new Vector<LoggerDataListener>();
private static boolean isExpectingMap = false;
private static String rawMapData = "";
// Loggers
private static int afrIndex = Integer.parseInt(UtecProperties.getProperties("utec.afrIndex")[0]);
private static int psiIndex = Integer.parseInt(UtecProperties.getProperties("utec.psiIndex")[0]);
private static int knockIndex = Integer.parseInt(UtecProperties.getProperties("utec.knockIndex")[0]);
@ -27,13 +30,17 @@ public class UtecDataManager {
private static double psiData = 999.0;
private static double knockData = 999.0;
private static int lineCounter = 0;
public static void setCurrentMap(UtecMapData newUtecMap){
currentMapData = newUtecMap;
// Call listeners
System.out.println("Calling map listeners.");
fuelListener.replaceData(currentMapData.getFuelMap());
boostListener.replaceData(currentMapData.getBoostMap());
timingListener.replaceData(currentMapData.getTimingMap());
System.out.println("Done calling map listeners.");
}
/**
@ -43,6 +50,32 @@ public class UtecDataManager {
*/
public static void setSerialData(String serialData){
if(isExpectingMap){
lineCounter++;
System.out.println("Line:"+lineCounter);
//System.out.println("Map:"+serialData+":");
rawMapData += serialData+"\n";
// Detect End of Map
if(lineCounter == 128){
rawMapData += "[END][MAPGROUP][0B05E][EOF]";
lineCounter = 0;
System.out.println("Map EOF");
UtecMapData newMap = new UtecMapData();
newMap.replaceRawData(new StringBuffer(rawMapData));
newMap.populateMapDataStructures();
setCurrentMap(newMap);
rawMapData = "";
setExpectingMap(false);
}
}else{
pullLoggerData(serialData);
}
}
private static void pullLoggerData(String serialData) {
String[] data = serialData.split(",");
// Count the "," to ensure this is a line of logging data
@ -90,7 +123,6 @@ public class UtecDataManager {
// If we make it this far we know we have valid logger data
// ********************************************************
UtecDataManager.notifyLoggerDataListeners(doubleData);
}
/**
@ -195,4 +227,16 @@ public class UtecDataManager {
public static void addLoggerListener(LoggerDataListener loggerListener) {
UtecDataManager.loggerListener.add(loggerListener);
}
public static void addMapDataListener(LoggerDataListener loggerListener) {
UtecDataManager.loggerListener.add(loggerListener);
}
public static boolean isExpectingMap() {
return isExpectingMap;
}
public static void setExpectingMap(boolean isExpectingMap) {
UtecDataManager.isExpectingMap = isExpectingMap;
}
}

View File

@ -5,7 +5,7 @@ utec.afrIndex=13
utec.psiIndex=1
utec.knockIndex=5
utec.startLogging=33
utec.startMapDownload=101,*,19,19,*
utec.startMapDownload=101,*,19,19
utec.startMapUpload=101,*,21,13,*,13
utec.resetUtec=24,24,24
utec.loggerIndexes=0,1,5,6,7,13