mirror of https://github.com/rusefi/RomRaider.git
Still have memory leak, but not as bad.
git-svn-id: http://svn.3splooges.com/romraider-arch/trunk@553 d2e2e1cd-ba16-0410-be16-b7c4453c7c2d
This commit is contained in:
parent
49386cb788
commit
654083b147
|
@ -11,8 +11,11 @@ public class UtecTimerTask extends TimerTask{
|
|||
private int counter = 0;
|
||||
private StringBuffer stringBuffer = null;
|
||||
|
||||
public UtecTimerTask(String data, UtecTimerTaskListener listener){
|
||||
public UtecTimerTask(UtecTimerTaskListener listener){
|
||||
this.listener = listener;
|
||||
}
|
||||
|
||||
public void setData(String data){
|
||||
this.data = data;
|
||||
this.stringBuffer = new StringBuffer(data);
|
||||
JutecGUI.getInstance().getJProgressBar().setMinimum(0);
|
||||
|
@ -21,7 +24,7 @@ public class UtecTimerTask extends TimerTask{
|
|||
|
||||
public void run(){
|
||||
char theChar = stringBuffer.charAt(counter);
|
||||
// System.out.println("->"+theChar+"<- :"+(int)theChar+"");
|
||||
System.out.println("->"+theChar+"<- :"+(int)theChar+"");
|
||||
|
||||
//Send the data to the Utec
|
||||
UtecSerialConnection.sendCommandToUtec((int)theChar);
|
||||
|
|
|
@ -6,18 +6,16 @@ import enginuity.logger.utec.properties.UtecProperties;
|
|||
|
||||
public class UtecTimerTaskExecute implements UtecTimerTaskListener{
|
||||
private final Timer timer = new Timer();
|
||||
|
||||
private int delay = Integer.parseInt(UtecProperties.getProperties("utec.commandTransmissionPauseMS")[0]);
|
||||
private int period = Integer.parseInt(UtecProperties.getProperties("utec.dataTransmissionPauseMS")[0]);
|
||||
private UtecTimerTask utecTimerTask = new UtecTimerTask( this);
|
||||
|
||||
public UtecTimerTaskExecute(String data){
|
||||
UtecTimerTask utecTimerTask = new UtecTimerTask(data, this);
|
||||
|
||||
utecTimerTask.setData(data);
|
||||
timer.schedule(utecTimerTask, delay, period);
|
||||
}
|
||||
|
||||
public void utecCommTimerCompleted() {
|
||||
|
||||
// Ensure that the manager knows we are done
|
||||
UtecTimerTaskManager.operationComplete();
|
||||
|
||||
|
|
|
@ -23,7 +23,7 @@ public class UtecSerialListener implements SerialPortEventListener{
|
|||
}
|
||||
|
||||
public void serialEvent(SerialPortEvent e) {
|
||||
System.out.println("Got serial event.");
|
||||
//System.out.println("Got serial event.");
|
||||
|
||||
|
||||
// Create a StringBuffer and int to receive input data.
|
||||
|
@ -47,7 +47,7 @@ public class UtecSerialListener implements SerialPortEventListener{
|
|||
}
|
||||
|
||||
inputBuffer.append((char) newData);
|
||||
System.out.print((char)newData);
|
||||
//System.out.print((char)newData);
|
||||
this.totalDat += (char)newData;
|
||||
|
||||
} catch (IOException ex) {
|
||||
|
|
|
@ -10,6 +10,7 @@ import javax.swing.event.TableModelEvent;
|
|||
import javax.swing.table.DefaultTableModel;
|
||||
|
||||
import enginuity.logger.utec.mapData.UtecMapData;
|
||||
import enginuity.logger.utec.properties.UtecProperties;
|
||||
|
||||
public class MapJPanel extends JPanel{
|
||||
|
||||
|
@ -37,22 +38,40 @@ public class MapJPanel extends JPanel{
|
|||
this.tableModel = new UtecTableModel(this.mapType, initialData);
|
||||
|
||||
if(this.mapType == MapJPanel.FUELMAP){
|
||||
init(-8.0, 8.0);
|
||||
Object[] ignored = {new Double(-100.0)};
|
||||
init(Double.parseDouble(UtecProperties.getProperties("utec.fuelMapMin")[0]), Double.parseDouble(UtecProperties.getProperties("utec.fuelMapMax")[0]), ignored, false);
|
||||
}
|
||||
|
||||
if(this.mapType == MapJPanel.TIMINGMAP){
|
||||
init(-1.0, 5.0);
|
||||
Object[] ignored = {new Double(-100.0)};
|
||||
init(Double.parseDouble(UtecProperties.getProperties("utec.timingMapMin")[0]), Double.parseDouble(UtecProperties.getProperties("utec.timingMapMax")[0]), ignored, true);
|
||||
}
|
||||
|
||||
if(this.mapType == MapJPanel.BOOSTMAP){
|
||||
init(0.0, 500.0);
|
||||
Object[] ignored = {new Double(-100.0)};
|
||||
init(Double.parseDouble(UtecProperties.getProperties("utec.boostMapMin")[0]), Double.parseDouble(UtecProperties.getProperties("utec.boostMapMax")[0]), ignored, false);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
public void init(double min, double max){
|
||||
table = new UtecJTable(tableModel, mapType, min, max);
|
||||
public void init(double min, double max, Object[] ignoredValues, boolean isInvertedColoring){
|
||||
|
||||
|
||||
// ************************
|
||||
// Utec Specific code below
|
||||
// ************************
|
||||
if(mapType == MapJPanel.FUELMAP){
|
||||
DataManager.setFuelListener(tableModel);
|
||||
}
|
||||
else if(mapType == MapJPanel.BOOSTMAP){
|
||||
DataManager.setBoostListener(tableModel);
|
||||
}
|
||||
else if(mapType == MapJPanel.TIMINGMAP){
|
||||
DataManager.setTimingListener(tableModel);
|
||||
}
|
||||
|
||||
table = new UtecJTable(tableModel, min, max, ignoredValues, isInvertedColoring);
|
||||
//table.setPreferredScrollableViewportSize(new Dimension(500, 70));
|
||||
|
||||
//Create the scroll pane and add the table to it.
|
||||
|
|
|
@ -5,33 +5,116 @@ import javax.swing.ListSelectionModel;
|
|||
|
||||
public class UtecJTable extends JTable{
|
||||
|
||||
public UtecJTable(UtecTableModel theModel, int modelType, double minValue, double maxValue){
|
||||
private UtecTableModel theModel;
|
||||
|
||||
public UtecJTable(UtecTableModel theModel, double minValue, double maxValue, Object[] ignoredValues, boolean isInvertedColoring){
|
||||
super(theModel);
|
||||
//this.getSelectionModel().setSelectionMode(ListSelectionModel.MULTIPLE_INTERVAL_SELECTION);
|
||||
//this.getColumnModel().getSelectionModel().setSelectionMode(ListSelectionModel.MULTIPLE_INTERVAL_SELECTION);
|
||||
//this.setRowSelectionAllowed(false);
|
||||
|
||||
this.theModel = theModel;
|
||||
|
||||
//this.setSelectionModel(ListSelectionModel.)
|
||||
|
||||
this.setCellSelectionEnabled(true);
|
||||
//this.setColumnSelectionAllowed(false);
|
||||
this.getSelectionModel().addListSelectionListener(new UtecSelectionListener(this));
|
||||
this.setDefaultRenderer(Object.class, new UtecTableCellRenderer(minValue, maxValue, ignoredValues, isInvertedColoring));
|
||||
|
||||
this.setDefaultRenderer(Object.class, new UtecTableCellRenderer(minValue, maxValue));
|
||||
//this.setSelectedQuadrilateral(2,4,4,7);
|
||||
//this.incSelectedCells(22);
|
||||
this.setSelected(0,0);
|
||||
this.setSelected(1,1);
|
||||
this.incSelectedCells(22);
|
||||
//this.setSelected(3,5);
|
||||
}
|
||||
|
||||
|
||||
// ************************
|
||||
// Utec Specific code below
|
||||
// ************************
|
||||
if(modelType == MapJPanel.FUELMAP){
|
||||
DataManager.setFuelListener(theModel);
|
||||
}
|
||||
else if(modelType == MapJPanel.BOOSTMAP){
|
||||
DataManager.setBoostListener(theModel);
|
||||
}
|
||||
else if(modelType == MapJPanel.TIMINGMAP){
|
||||
DataManager.setTimingListener(theModel);
|
||||
/**
|
||||
* Zero based row and columns, inclusive
|
||||
*
|
||||
* @param rowStart
|
||||
* @param rowEnd
|
||||
* @param colStart
|
||||
* @param colEnd
|
||||
*/
|
||||
public void setSelectedQuadrilateral(int rowStart, int rowEnd, int colStart, int colEnd){
|
||||
for(int i = rowStart; i < rowEnd + 1; i++){
|
||||
for(int j = colStart; j < colEnd + 1; j++){
|
||||
this.changeSelection(i, j, false, true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void updateData(double[][] newData){
|
||||
|
||||
/**
|
||||
* Set a cell as being selected.
|
||||
*
|
||||
* @param rowIndex
|
||||
* @param colIndex
|
||||
*/
|
||||
public void setSelected(int rowIndex, int colIndex){
|
||||
this.changeSelection(rowIndex, colIndex, false, true);
|
||||
}
|
||||
|
||||
/**
|
||||
* Increment cell values by passed double amount.
|
||||
* @param amount
|
||||
*/
|
||||
public void incSelectedCells(double amount){
|
||||
|
||||
int rowStart = this.getSelectedRow();
|
||||
int rowEnd = this.getSelectionModel().getMaxSelectionIndex();
|
||||
|
||||
int colStart = this.getSelectedColumn();
|
||||
int colEnd = this.getColumnModel().getSelectionModel().getMaxSelectionIndex();
|
||||
|
||||
for(int i = rowStart; i <= rowEnd; i++){
|
||||
for(int j = colStart; j <= colEnd; j++){
|
||||
if(this.isCellSelected(i,j)){
|
||||
// The cell is selected
|
||||
Object value = theModel.getValueAt(i, j);
|
||||
System.out.println("Selection found at:"+i+" :"+j);
|
||||
|
||||
if(value instanceof Double){
|
||||
Double temp = (Double)value + amount;
|
||||
//theModel.setValueAt(temp, i, j);
|
||||
theModel.setDoubleData(i,j,temp);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Decrement cell values by passed double amount.
|
||||
* @param amount
|
||||
*/
|
||||
public void decSelectedCells(double amount){
|
||||
|
||||
int rowStart = this.getSelectedRow();
|
||||
int rowEnd = this.getSelectionModel().getMaxSelectionIndex();
|
||||
|
||||
int colStart = this.getSelectedColumn();
|
||||
int colEnd = this.getColumnModel().getSelectionModel().getMaxSelectionIndex();
|
||||
|
||||
for(int i = rowStart; i <= rowEnd; i++){
|
||||
for(int j = colStart; j <= colEnd; j++){
|
||||
if(this.isCellSelected(i,j)){
|
||||
// The cell is selected
|
||||
Object value = theModel.getValueAt(i, j);
|
||||
if(value instanceof Double){
|
||||
Double temp = (Double)value - amount;
|
||||
//theModel.setValueAt(temp, i, j);
|
||||
theModel.setDoubleData(i,j,temp);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Replace all table data with passed data.
|
||||
* @param newData
|
||||
*/
|
||||
public void replaceAlltableData(double[][] newData){
|
||||
((UtecTableModel)this.dataModel).replaceData(newData);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -12,12 +12,19 @@ import com.ecm.graphics.tools.ColorTable;
|
|||
public class UtecTableCellRenderer extends DefaultTableCellRenderer{
|
||||
private double min;
|
||||
private double max;
|
||||
private Object[] ignoredValues;
|
||||
private boolean isInvertedColoring;
|
||||
|
||||
public UtecTableCellRenderer(double min, double max){
|
||||
public UtecTableCellRenderer(double min, double max, Object[] ignoredValues, boolean isInvertedColoring){
|
||||
this.min = min;
|
||||
this.max = max;
|
||||
this.ignoredValues = ignoredValues;
|
||||
this.isInvertedColoring = isInvertedColoring;
|
||||
}
|
||||
|
||||
/**
|
||||
* Called when table needs cell rendering information. Cell logic on color values goes here.
|
||||
*/
|
||||
public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int col){
|
||||
Component cell = super.getTableCellRendererComponent(table, value, isSelected, hasFocus, row, col);
|
||||
|
||||
|
@ -25,16 +32,40 @@ public class UtecTableCellRenderer extends DefaultTableCellRenderer{
|
|||
cell.setBackground(Color.BLUE);
|
||||
}else{
|
||||
if(value instanceof Double){
|
||||
//System.out.println("Amount:"+(Double)value);
|
||||
}
|
||||
ColorTable.initColorTable(min, max);
|
||||
Color3f theColor = ColorTable.getColor((Double)value);
|
||||
ColorTable.initColorTable(min, max);
|
||||
if(this.isInvertedColoring){
|
||||
ColorTable.initColorTable(max, min);
|
||||
}
|
||||
Color3f theColor = ColorTable.getColor((Double)value);
|
||||
cell.setBackground(new Color(theColor.x, theColor.y, theColor.z));
|
||||
|
||||
cell.setBackground(new Color(theColor.x, theColor.y, theColor.z));
|
||||
// If out of range color cell red
|
||||
if((Double)value < min || (Double)value > max){
|
||||
cell.setBackground(Color.RED);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// Iterate through the ignored values, paint them gray
|
||||
for(int i = 0; i < ignoredValues.length; i++){
|
||||
|
||||
// Double ignored values
|
||||
if((value instanceof Double) && (ignoredValues[i] instanceof Double)){
|
||||
Double doubleValue = (Double)value;
|
||||
Double ignoredValue = (Double)ignoredValues[i];
|
||||
|
||||
if((doubleValue - ignoredValue) == 0){
|
||||
cell.setBackground(Color.GRAY);
|
||||
}
|
||||
}
|
||||
|
||||
// Maybe add string value detection as needed
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
return cell;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -45,16 +45,21 @@ public class UtecTableModel extends AbstractTableModel {
|
|||
|
||||
|
||||
public void setValueAt(Object value, int row, int col) {
|
||||
System.out.print(" Updated:"+(String)value+": ");
|
||||
//System.out.print(" Updated:"+(String)value+": ");
|
||||
// Set new data in table
|
||||
double temp = data[col][row];
|
||||
|
||||
try{
|
||||
temp = Double.parseDouble((String)value);
|
||||
}catch (NumberFormatException e) {
|
||||
System.out.println("Not a valid number entered.");
|
||||
if(value instanceof String){
|
||||
try{
|
||||
temp = Double.parseDouble((String)value);
|
||||
}catch (NumberFormatException e) {
|
||||
System.out.println("Not a valid number entered.");
|
||||
}
|
||||
data[col][row] = temp;
|
||||
}else if(value instanceof Double){
|
||||
data[col][row] = (Double)value;
|
||||
}
|
||||
data[col][row] = temp;
|
||||
|
||||
|
||||
// Update current map in scope
|
||||
if(this.identifier == MapJPanel.FUELMAP){
|
||||
|
@ -70,6 +75,10 @@ public class UtecTableModel extends AbstractTableModel {
|
|||
this.fireTableDataChanged();
|
||||
}
|
||||
|
||||
public void setDoubleData(int row, int col, double value){
|
||||
this.data[col][row] = value;
|
||||
}
|
||||
|
||||
|
||||
public void replaceData(double[][] newData){
|
||||
System.out.println("Model data being replaced in full.");
|
||||
|
|
|
@ -159,7 +159,7 @@ public class RealTimeData extends JComponent implements LoggerListener{
|
|||
public void getCommEvent(LoggerEvent e){
|
||||
if(e.isLoggerData()){
|
||||
doubleData = e.getDoubleData();
|
||||
System.out.println("Got new data:"+doubleData[0]+"," + doubleData[1]);
|
||||
//System.out.println("Got new data:"+doubleData[0]+"," + doubleData[1]);
|
||||
this.repaint();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
utec.sound=false
|
||||
utec.commandTransmissionPauseMS=500
|
||||
utec.dataTransmissionPauseMS=25
|
||||
utec.dataTransmissionPauseMS=1
|
||||
utec.afrIndex=13
|
||||
utec.startLogging=33
|
||||
utec.startMapDownload=101,*,19,19,*
|
||||
|
@ -9,3 +9,9 @@ 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<>16
|
||||
utec.fuelMapMin=-8.0
|
||||
utec.fuelMapMax=8.0
|
||||
utec.timingMapMin=10.0
|
||||
utec.timingMapMax=40.0
|
||||
utec.boostMapMin=0.0
|
||||
utec.boostMapMax=500.0
|
Loading…
Reference in New Issue