auto-sync

This commit is contained in:
rusEfi 2015-04-22 00:04:25 -04:00
parent 4bbb95adf9
commit b397a15bdd
7 changed files with 46 additions and 18 deletions

View File

@ -2,8 +2,6 @@ package com.rusefi.config;
import com.rusefi.core.Pair; import com.rusefi.core.Pair;
import java.util.Objects;
/** /**
* @see com.rusefi.config.Fields * @see com.rusefi.config.Fields
*/ */
@ -14,10 +12,28 @@ public class Field {
private final int offset; private final int offset;
private final FieldType type; private final FieldType type;
private final int bitOffset;
public Field(int offset, FieldType type) { public Field(int offset, FieldType type) {
this(offset, type, -1);
}
public Field(int offset, FieldType type, int bitOffset) {
this.offset = offset; this.offset = offset;
this.type = type; this.type = type;
this.bitOffset = bitOffset;
}
public String setCommand() {
if (type == FieldType.BIT)
return "set_bit " + getOffset() + " " + bitOffset;
return getType().getStoreCommand() + " " + getOffset();
}
public String getCommand() {
if (type == FieldType.BIT)
return "get_bit " + getOffset() + " " + bitOffset;
return type.getLoadCommand() + " " + getOffset();
} }
public int getOffset() { public int getOffset() {

View File

@ -1,7 +1,10 @@
package com.rusefi.config; package com.rusefi.config;
public enum FieldType { public enum FieldType {
INT, FLOAT, ANALOG_CHART_E; INT,
BIT,
FLOAT,
ANALOG_CHART_E;
private String getTypeForCommand() { private String getTypeForCommand() {

View File

@ -9,4 +9,5 @@ public class Fields {
public static final Field SENSOR_SNIFFER_MODE = new Field(1400, FieldType.ANALOG_CHART_E); public static final Field SENSOR_SNIFFER_MODE = new Field(1400, FieldType.ANALOG_CHART_E);
public static final Field GLOBAL_FUEL_CORRECTION = new Field(552, FieldType.FLOAT); public static final Field GLOBAL_FUEL_CORRECTION = new Field(552, FieldType.FLOAT);
public static final Field ENGINE_SNIFFER_SIZE = new Field(1504, FieldType.INT); public static final Field ENGINE_SNIFFER_SIZE = new Field(1504, FieldType.INT);
public static final Field isDigitalChartEnabled = new Field(1488, FieldType.BIT, 5);
} }

View File

@ -109,7 +109,6 @@ public class AnalogChartPanel {
lowerPanel.add(new ConfigField(Fields.SENSOR_SNIFFER_MODE, "Sensor chart mode").getContent()); lowerPanel.add(new ConfigField(Fields.SENSOR_SNIFFER_MODE, "Sensor chart mode").getContent());
lowerPanel.add(new ConfigField(Fields.SENSOR_SNIFFER_FREQUENCY, "Every XXX engine cycles").getContent()); lowerPanel.add(new ConfigField(Fields.SENSOR_SNIFFER_FREQUENCY, "Every XXX engine cycles").getContent());
lowerPanel.add(new ConfigField(Fields.GLOBAL_FUEL_CORRECTION, "Global Fuel Correction").getContent()); lowerPanel.add(new ConfigField(Fields.GLOBAL_FUEL_CORRECTION, "Global Fuel Correction").getContent());
lowerPanel.add(new ConfigField(Fields.ENGINE_SNIFFER_SIZE, "Engine Sniffer size").getContent());
} }
private void clear() { private void clear() {

View File

@ -32,7 +32,7 @@ import static com.rusefi.ui.storage.PersistentConfiguration.getConfig;
* @see com.rusefi.StartupFrame * @see com.rusefi.StartupFrame
*/ */
public class Launcher { public class Launcher {
public static final int CONSOLE_VERSION = 20150419; public static final int CONSOLE_VERSION = 20150421;
public static final boolean SHOW_STIMULATOR = false; public static final boolean SHOW_STIMULATOR = false;
private static final String TAB_INDEX = "main_tab"; private static final String TAB_INDEX = "main_tab";
protected static final String PORT_KEY = "port"; protected static final String PORT_KEY = "port";

View File

@ -30,7 +30,7 @@ public class ConfigField {
ConnectionStatus.INSTANCE.addListener(new ConnectionStatus.Listener() { ConnectionStatus.INSTANCE.addListener(new ConnectionStatus.Listener() {
@Override @Override
public void onConnectionStatus(boolean isConnected) { public void onConnectionStatus(boolean isConnected) {
CommandQueue.getInstance().write(field.getType().getLoadCommand() + " " + field.getOffset(), CommandQueue.getInstance().write(field.getCommand(),
CommandQueue.DEFAULT_TIMEOUT, CommandQueue.DEFAULT_TIMEOUT,
InvocationConfirmationListener.VOID, InvocationConfirmationListener.VOID,
false); false);
@ -70,7 +70,7 @@ public class ConfigField {
@Override @Override
public void keyPressed(KeyEvent e) { public void keyPressed(KeyEvent e) {
if (e.getKeyCode() == KeyEvent.VK_ENTER) { if (e.getKeyCode() == KeyEvent.VK_ENTER) {
String msg = field.getType().getStoreCommand() + " " + field.getOffset() + " " + view.getText(); String msg = field.setCommand() + " " + view.getText();
FileLog.MAIN.logLine("Sending " + msg); FileLog.MAIN.logLine("Sending " + msg);
CommandQueue.getInstance().write(msg); CommandQueue.getInstance().write(msg);
status.setText("S"); status.setText("S");

View File

@ -1,11 +1,13 @@
package com.rusefi.ui.engine; package com.rusefi.ui.engine;
import com.rusefi.FileLog; import com.rusefi.FileLog;
import com.rusefi.config.Fields;
import com.rusefi.core.EngineState; import com.rusefi.core.EngineState;
import com.rusefi.core.Sensor; import com.rusefi.core.Sensor;
import com.rusefi.core.SensorCentral; import com.rusefi.core.SensorCentral;
import com.rusefi.io.LinkManager; import com.rusefi.io.LinkManager;
import com.rusefi.ui.*; import com.rusefi.ui.*;
import com.rusefi.ui.config.ConfigField;
import com.rusefi.ui.storage.Node; import com.rusefi.ui.storage.Node;
import com.rusefi.ui.util.UiUtils; import com.rusefi.ui.util.UiUtils;
import com.rusefi.ui.widgets.AnyCommand; import com.rusefi.ui.widgets.AnyCommand;
@ -117,16 +119,16 @@ public class EngineSnifferPanel {
} }
}); });
JPanel buttonPanel = new JPanel(new FlowLayout(FlowLayout.LEFT, 5, 0)); JPanel topButtons = new JPanel(new FlowLayout(FlowLayout.LEFT, 5, 0));
buttonPanel.add(clearButton); topButtons.add(clearButton);
buttonPanel.add(saveImageButton); topButtons.add(saveImageButton);
buttonPanel.add(pauseButton); topButtons.add(pauseButton);
buttonPanel.add(new RpmLabel().setSize(2).getContent()); topButtons.add(new RpmLabel().setSize(2).getContent());
JComponent command = new AnyCommand(config, "chartsize " + EFI_DEFAULT_CHART_SIZE, true).getContent(); JComponent command = new AnyCommand(config, "chartsize " + EFI_DEFAULT_CHART_SIZE, true).getContent();
buttonPanel.add(command); topButtons.add(command);
buttonPanel.add(zoomControl); topButtons.add(zoomControl);
scrollControl = ChartRepository.getInstance().createControls(new ChartRepository.ChartRepositoryListener() { scrollControl = ChartRepository.getInstance().createControls(new ChartRepository.ChartRepositoryListener() {
@Override @Override
@ -134,13 +136,20 @@ public class EngineSnifferPanel {
displayChart(chart); displayChart(chart);
} }
}); });
buttonPanel.add(scrollControl.getContent()); topButtons.add(scrollControl.getContent());
buttonPanel.add(new URLLabel(HELP_TEXT, HELP_URL)); topButtons.add(new URLLabel(HELP_TEXT, HELP_URL));
chartPanel.add(buttonPanel, BorderLayout.NORTH); JPanel lowerButtons = new JPanel(new FlowLayout(FlowLayout.RIGHT, 5, 0));
lowerButtons.add(new ConfigField(Fields.ENGINE_SNIFFER_SIZE, "Engine Sniffer size").getContent());
JPanel bottomPanel = new JPanel(new BorderLayout());
bottomPanel.add(lowerButtons, BorderLayout.NORTH);
bottomPanel.add(statusPanel.infoPanel, BorderLayout.SOUTH);
chartPanel.add(topButtons, BorderLayout.NORTH);
chartPanel.add(pane, BorderLayout.CENTER); chartPanel.add(pane, BorderLayout.CENTER);
chartPanel.add(statusPanel.infoPanel, BorderLayout.SOUTH); chartPanel.add(bottomPanel, BorderLayout.SOUTH);
zoomControl.listener = new ZoomControl.ZoomControlListener() { zoomControl.listener = new ZoomControl.ZoomControlListener() {
@Override @Override