auto-sync
This commit is contained in:
parent
97cecba19a
commit
4f80924c05
|
@ -1,5 +1,5 @@
|
|||
// This file was generated by Version2Header
|
||||
// Sun Mar 22 11:16:21 EDT 2015
|
||||
// Wed Apr 22 21:56:21 EDT 2015
|
||||
#ifndef VCS_VERSION
|
||||
#define VCS_VERSION "7501"
|
||||
#define VCS_VERSION "7887"
|
||||
#endif
|
||||
|
|
|
@ -7,6 +7,7 @@ import com.rusefi.core.Pair;
|
|||
*/
|
||||
|
||||
public class Field {
|
||||
private static final String BIT_VALUE_PREFIX = "bit @";
|
||||
private static final String INT_VALUE_PREFIX = "int @";
|
||||
private static final String FLOAT_VALUE_PREFIX = "float @";
|
||||
|
||||
|
@ -40,6 +41,10 @@ public class Field {
|
|||
return offset;
|
||||
}
|
||||
|
||||
public int getBitOffset() {
|
||||
return bitOffset;
|
||||
}
|
||||
|
||||
public FieldType getType() {
|
||||
return type;
|
||||
}
|
||||
|
@ -48,6 +53,9 @@ public class Field {
|
|||
return message.startsWith(INT_VALUE_PREFIX);
|
||||
}
|
||||
|
||||
public static boolean isBitValueMessage(String message) {
|
||||
return message.startsWith(BIT_VALUE_PREFIX);
|
||||
}
|
||||
|
||||
public static boolean isFloatValueMessage(String message) {
|
||||
return message.startsWith(FLOAT_VALUE_PREFIX);
|
||||
|
|
|
@ -32,7 +32,7 @@ import static com.rusefi.ui.storage.PersistentConfiguration.getConfig;
|
|||
* @see com.rusefi.StartupFrame
|
||||
*/
|
||||
public class Launcher {
|
||||
public static final int CONSOLE_VERSION = 20150421;
|
||||
public static final int CONSOLE_VERSION = 20150422;
|
||||
public static final boolean SHOW_STIMULATOR = false;
|
||||
private static final String TAB_INDEX = "main_tab";
|
||||
protected static final String PORT_KEY = "port";
|
||||
|
|
|
@ -0,0 +1,66 @@
|
|||
package com.rusefi.ui.config;
|
||||
|
||||
import com.rusefi.FileLog;
|
||||
import com.rusefi.config.Field;
|
||||
import com.rusefi.io.CommandQueue;
|
||||
import com.rusefi.io.InvocationConfirmationListener;
|
||||
import com.rusefi.ui.ConnectionStatus;
|
||||
|
||||
import javax.swing.*;
|
||||
import java.awt.*;
|
||||
|
||||
class BaseConfigField {
|
||||
protected final JLabel status = new JLabel("P");
|
||||
protected final JPanel panel = new JPanel(new BorderLayout());
|
||||
|
||||
public BaseConfigField(final Field field) {
|
||||
/**
|
||||
* This would request initial value
|
||||
*/
|
||||
ConnectionStatus.INSTANCE.addListener(new ConnectionStatus.Listener() {
|
||||
@Override
|
||||
public void onConnectionStatus(boolean isConnected) {
|
||||
CommandQueue.getInstance().write(field.getCommand(),
|
||||
CommandQueue.DEFAULT_TIMEOUT,
|
||||
InvocationConfirmationListener.VOID,
|
||||
false);
|
||||
}
|
||||
});
|
||||
|
||||
status.setToolTipText("Pending...");
|
||||
|
||||
}
|
||||
|
||||
protected void onValueArrived() {
|
||||
status.setText("");
|
||||
status.setToolTipText(null);
|
||||
}
|
||||
|
||||
protected void sendValue(Field field, String newValue) {
|
||||
String msg = field.setCommand() + " " + newValue;
|
||||
FileLog.MAIN.logLine("Sending " + msg);
|
||||
CommandQueue.getInstance().write(msg);
|
||||
status.setText("S");
|
||||
status.setToolTipText("Storing...");
|
||||
}
|
||||
|
||||
protected void createUi(String topLabel, Component control) {
|
||||
JPanel center = new JPanel(new FlowLayout());
|
||||
|
||||
/**
|
||||
* I guess a nice status enum is coming soon
|
||||
*/
|
||||
center.add(status);
|
||||
|
||||
center.add(control);
|
||||
|
||||
panel.setBorder(BorderFactory.createCompoundBorder(BorderFactory.createLineBorder(Color.black),
|
||||
BorderFactory.createEmptyBorder(2, 2, 2, 2)));
|
||||
panel.add(new JLabel(topLabel), BorderLayout.NORTH);
|
||||
panel.add(center, BorderLayout.CENTER);
|
||||
}
|
||||
|
||||
public JPanel getContent() {
|
||||
return panel;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,46 @@
|
|||
package com.rusefi.ui.config;
|
||||
|
||||
import com.rusefi.config.Field;
|
||||
import com.rusefi.core.MessagesCentral;
|
||||
|
||||
import javax.swing.*;
|
||||
import java.awt.event.ActionEvent;
|
||||
import java.awt.event.ActionListener;
|
||||
|
||||
public class BitConfigField extends BaseConfigField {
|
||||
private final JCheckBox view = new JCheckBox();
|
||||
private boolean ec;
|
||||
|
||||
public BitConfigField(final Field field, String caption) {
|
||||
super(field);
|
||||
|
||||
createUi(caption, view);
|
||||
|
||||
MessagesCentral.getInstance().addListener(new MessagesCentral.MessageListener() {
|
||||
@Override
|
||||
public void onMessage(Class clazz, String message) {
|
||||
if (Field.isBitValueMessage(message)) {
|
||||
String expectedPrefix = "bit @" + field.getOffset() + "/" + field.getBitOffset() + " is ";
|
||||
if (message.startsWith(expectedPrefix) && message.length() == expectedPrefix.length() + 1) {
|
||||
message = message.substring(expectedPrefix.length());
|
||||
System.out.println("Bit arrived " + message);
|
||||
Boolean value = message.equals("1");
|
||||
ec = true;
|
||||
view.setSelected(value);
|
||||
onValueArrived();
|
||||
ec = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
view.addActionListener(new ActionListener() {
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
if (ec)
|
||||
return;
|
||||
sendValue(field, view.isSelected() ? "1" : "0");
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
|
@ -1,12 +1,8 @@
|
|||
package com.rusefi.ui.config;
|
||||
|
||||
import com.rusefi.FileLog;
|
||||
import com.rusefi.config.Field;
|
||||
import com.rusefi.core.MessagesCentral;
|
||||
import com.rusefi.core.Pair;
|
||||
import com.rusefi.io.CommandQueue;
|
||||
import com.rusefi.io.InvocationConfirmationListener;
|
||||
import com.rusefi.ui.ConnectionStatus;
|
||||
import com.rusefi.ui.util.JTextFieldWithWidth;
|
||||
|
||||
import javax.swing.*;
|
||||
|
@ -14,43 +10,12 @@ import java.awt.*;
|
|||
import java.awt.event.KeyAdapter;
|
||||
import java.awt.event.KeyEvent;
|
||||
|
||||
public class ConfigField {
|
||||
private final Field field;
|
||||
|
||||
private final JPanel panel = new JPanel(new BorderLayout());
|
||||
private final JLabel status = new JLabel("P");
|
||||
public class ConfigField extends BaseConfigField {
|
||||
private final JTextField view = new JTextFieldWithWidth(200);
|
||||
|
||||
public ConfigField(final Field field, String topLabel) {
|
||||
this.field = field;
|
||||
|
||||
/**
|
||||
* This would request initial value
|
||||
*/
|
||||
ConnectionStatus.INSTANCE.addListener(new ConnectionStatus.Listener() {
|
||||
@Override
|
||||
public void onConnectionStatus(boolean isConnected) {
|
||||
CommandQueue.getInstance().write(field.getCommand(),
|
||||
CommandQueue.DEFAULT_TIMEOUT,
|
||||
InvocationConfirmationListener.VOID,
|
||||
false);
|
||||
}
|
||||
});
|
||||
|
||||
JPanel center = new JPanel(new FlowLayout());
|
||||
|
||||
/**
|
||||
* I guess a nice status enum is coming soon
|
||||
*/
|
||||
center.add(status);
|
||||
status.setToolTipText("Pending...");
|
||||
|
||||
center.add(view);
|
||||
|
||||
panel.setBorder(BorderFactory.createCompoundBorder(BorderFactory.createLineBorder(Color.black),
|
||||
BorderFactory.createEmptyBorder(2, 2, 2, 2)));
|
||||
panel.add(new JLabel(topLabel), BorderLayout.NORTH);
|
||||
panel.add(center, BorderLayout.CENTER);
|
||||
super(field);
|
||||
createUi(topLabel, view);
|
||||
|
||||
MessagesCentral.getInstance().addListener(new MessagesCentral.MessageListener() {
|
||||
@Override
|
||||
|
@ -59,8 +24,7 @@ public class ConfigField {
|
|||
Pair<Integer, ?> p = Field.parseResponse(message);
|
||||
if (p != null && p.first == field.getOffset()) {
|
||||
view.setText("" + p.second);
|
||||
status.setText("");
|
||||
status.setToolTipText(null);
|
||||
onValueArrived();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -70,17 +34,10 @@ public class ConfigField {
|
|||
@Override
|
||||
public void keyPressed(KeyEvent e) {
|
||||
if (e.getKeyCode() == KeyEvent.VK_ENTER) {
|
||||
String msg = field.setCommand() + " " + view.getText();
|
||||
FileLog.MAIN.logLine("Sending " + msg);
|
||||
CommandQueue.getInstance().write(msg);
|
||||
status.setText("S");
|
||||
status.setToolTipText("Storing...");
|
||||
sendValue(field, ConfigField.this.view.getText());
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public JPanel getContent() {
|
||||
return panel;
|
||||
}
|
||||
}
|
|
@ -7,6 +7,7 @@ import com.rusefi.core.Sensor;
|
|||
import com.rusefi.core.SensorCentral;
|
||||
import com.rusefi.io.LinkManager;
|
||||
import com.rusefi.ui.*;
|
||||
import com.rusefi.ui.config.BitConfigField;
|
||||
import com.rusefi.ui.config.ConfigField;
|
||||
import com.rusefi.ui.storage.Node;
|
||||
import com.rusefi.ui.util.UiUtils;
|
||||
|
@ -141,6 +142,7 @@ public class EngineSnifferPanel {
|
|||
topButtons.add(new URLLabel(HELP_TEXT, HELP_URL));
|
||||
|
||||
JPanel lowerButtons = new JPanel(new FlowLayout(FlowLayout.RIGHT, 5, 0));
|
||||
lowerButtons.add(new BitConfigField(Fields.isDigitalChartEnabled, "Collect Engine Data").getContent());
|
||||
lowerButtons.add(new ConfigField(Fields.ENGINE_SNIFFER_SIZE, "Engine Sniffer size").getContent());
|
||||
|
||||
JPanel bottomPanel = new JPanel(new BorderLayout());
|
||||
|
|
Loading…
Reference in New Issue