auto-sync

This commit is contained in:
rusEfi 2015-10-18 20:01:25 -04:00
parent abb65372d6
commit 1091825172
9 changed files with 89 additions and 45 deletions

View File

@ -1,4 +1,4 @@
// this section was generated by config_definition.jar on Sun Oct 18 13:04:59 EDT 2015 // this section was generated by config_definition.jar on Sun Oct 18 19:32:33 EDT 2015
// begin // begin
#include "rusefi_types.h" #include "rusefi_types.h"
typedef struct { typedef struct {
@ -1044,6 +1044,7 @@ typedef struct {
offset 1496 bit 4 */ offset 1496 bit 4 */
bool_t useConstantDwellDuringCranking : 1; bool_t useConstantDwellDuringCranking : 1;
/** /**
* This options enables data for 'engine sniffer' tab in console, which comes at some CPU price
offset 1496 bit 5 */ offset 1496 bit 5 */
bool_t isEngineChartEnabled : 1; bool_t isEngineChartEnabled : 1;
/** /**
@ -1517,4 +1518,4 @@ typedef struct {
} persistent_config_s; } persistent_config_s;
// end // end
// this section was generated by config_definition.jar on Sun Oct 18 13:04:59 EDT 2015 // this section was generated by config_definition.jar on Sun Oct 18 19:32:33 EDT 2015

View File

@ -808,6 +808,8 @@ static void setSpiMode(int index, bool mode) {
static void enableOrDisable(const char *param, bool isEnabled) { static void enableOrDisable(const char *param, bool isEnabled) {
if (strEqualCaseInsensitive(param, "fastadc")) { if (strEqualCaseInsensitive(param, "fastadc")) {
boardConfiguration->isFastAdcEnabled = isEnabled; boardConfiguration->isFastAdcEnabled = isEnabled;
} else if (strEqualCaseInsensitive(param, "engine_sniffer")) {
engineConfiguration->isEngineChartEnabled = isEnabled;
} else if (strEqualCaseInsensitive(param, "step1limimter")) { } else if (strEqualCaseInsensitive(param, "step1limimter")) {
boardConfiguration->enabledStep1Limiter = isEnabled; boardConfiguration->enabledStep1Limiter = isEnabled;
} else if (strEqualCaseInsensitive(param, "serial")) { } else if (strEqualCaseInsensitive(param, "serial")) {

View File

@ -488,7 +488,7 @@ bit hasMapSensor;@see isMapAveragingEnabled
bit hasBaroSensor bit hasBaroSensor
bit hasAfrSensor bit hasAfrSensor
bit useConstantDwellDuringCranking bit useConstantDwellDuringCranking
bit isEngineChartEnabled bit isEngineChartEnabled;This options enables data for 'engine sniffer' tab in console, which comes at some CPU price
bit isCanEnabled bit isCanEnabled
bit hasCltSensor bit hasCltSensor
bit canReadEnabled bit canReadEnabled

View File

@ -40,7 +40,7 @@ enable2ndByteCanID = false
; see PAGE_0_SIZE in C source code ; see PAGE_0_SIZE in C source code
; CONFIG_DEFINITION_START ; CONFIG_DEFINITION_START
; this section was generated by ConfigDefinition.jar on Sun Oct 18 13:05:04 EDT 2015 ; this section was generated by ConfigDefinition.jar on Sun Oct 18 19:32:39 EDT 2015
pageSize = 15288 pageSize = 15288
page = 1 page = 1

View File

@ -89,7 +89,7 @@ public class SensorSnifferPane {
upperPanel.add(pauseButton); upperPanel.add(pauseButton);
upperPanel.add(new RpmLabel(2).getContent()); upperPanel.add(new RpmLabel(2).getContent());
upperPanel.add(new AnyCommand(config, true, false).getContent()); upperPanel.add(AnyCommand.createField(config, true, false).getContent());
upperPanel.add(new URLLabel(EngineSnifferPanel.HELP_TEXT, HELP_URL)); upperPanel.add(new URLLabel(EngineSnifferPanel.HELP_TEXT, HELP_URL));
pauseButton.addActionListener(new pauseButton.addActionListener(new

View File

@ -190,7 +190,7 @@ public class GaugesPanel {
JPanel leftUpperPanel = new JPanel(new FlowLayout(FlowLayout.LEFT, 5, 0)); JPanel leftUpperPanel = new JPanel(new FlowLayout(FlowLayout.LEFT, 5, 0));
leftUpperPanel.add(createSaveImageButton()); leftUpperPanel.add(createSaveImageButton());
leftUpperPanel.add(new RpmLabel(2).getContent()); leftUpperPanel.add(new RpmLabel(2).getContent());
AnyCommand command = new AnyCommand(config, false, false); AnyCommand command = AnyCommand.createField(config, false, false);
leftUpperPanel.add(command.getContent()); leftUpperPanel.add(command.getContent());
return leftUpperPanel; return leftUpperPanel;
} }

View File

@ -28,7 +28,7 @@ public class MessagesPane {
public MessagesPane(final Node config) { public MessagesPane(final Node config) {
JPanel topPanel = new JPanel(new FlowLayout(FlowLayout.LEFT, 5, 0)); JPanel topPanel = new JPanel(new FlowLayout(FlowLayout.LEFT, 5, 0));
AnyCommand command = new AnyCommand(config, true, false); AnyCommand command = AnyCommand.createArea(config, config.getProperty(AnyCommand.KEY), true, false);
final MessagesPanel upperPanel = new MessagesPanel(command.getContent()); final MessagesPanel upperPanel = new MessagesPanel(command.getContent());
upperPanel.loadFont(config); upperPanel.loadFont(config);

View File

@ -127,7 +127,7 @@ public class EngineSnifferPanel {
upperPanel.add(pauseButton); upperPanel.add(pauseButton);
upperPanel.add(new RpmLabel(2).getContent()); upperPanel.add(new RpmLabel(2).getContent());
JComponent command = new AnyCommand(config, "chartsize " + EFI_DEFAULT_CHART_SIZE, true, true).getContent(); JComponent command = AnyCommand.createField(config, "chartsize " + EFI_DEFAULT_CHART_SIZE, true, true).getContent();
upperPanel.add(command); upperPanel.add(command);
upperPanel.add(zoomControl); upperPanel.add(zoomControl);

View File

@ -13,6 +13,7 @@ import java.awt.event.ActionEvent;
import java.awt.event.ActionListener; import java.awt.event.ActionListener;
import java.awt.event.KeyAdapter; import java.awt.event.KeyAdapter;
import java.awt.event.KeyEvent; import java.awt.event.KeyEvent;
import java.util.concurrent.atomic.AtomicInteger;
/** /**
* Date: 3/20/13 * Date: 3/20/13
@ -20,23 +21,14 @@ import java.awt.event.KeyEvent;
*/ */
public class AnyCommand { public class AnyCommand {
public static final String KEY = "last_value"; public static final String KEY = "last_value";
private final JTextField text = new JTextField() {
@Override
public Dimension getPreferredSize() {
Dimension size = super.getPreferredSize();
return new Dimension(200, size.height);
}
};
private final JTextComponent text;
private JPanel content = new JPanel(new FlowLayout(FlowLayout.LEFT)); private JPanel content = new JPanel(new FlowLayout(FlowLayout.LEFT));
private boolean reentrant; private boolean reentrant;
private int index; private Listener listener;
public AnyCommand(final Node config, boolean listenToCommands, boolean withCommandCaption) { private AnyCommand(final JTextComponent text, final Node config, String defaultCommand, final boolean listenToCommands, boolean withCommandCaption) {
this(config, config.getProperty(KEY), listenToCommands, withCommandCaption); this.text = text;
}
public AnyCommand(final Node config, String defaultCommand, final boolean listenToCommands, boolean withCommandCaption) {
text.setText(defaultCommand); text.setText(defaultCommand);
content.setBorder(BorderFactory.createLineBorder(Color.PINK)); content.setBorder(BorderFactory.createLineBorder(Color.PINK));
if (withCommandCaption) { if (withCommandCaption) {
@ -61,25 +53,6 @@ public class AnyCommand {
} }
}); });
text.addKeyListener(new KeyAdapter() {
@Override
public void keyPressed(KeyEvent e) {
if (e.getKeyCode() == KeyEvent.VK_UP) {
String command = RecentCommands.getRecent(++index);
text.setText(command);
} else if (e.getKeyCode() == KeyEvent.VK_DOWN) {
String command = RecentCommands.getRecent(--index);
text.setText(command);
}
}
});
text.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
send();
}
});
text.getDocument().addDocumentListener(new DocumentListener() { text.getDocument().addDocumentListener(new DocumentListener() {
@Override @Override
public void insertUpdate(DocumentEvent e) { public void insertUpdate(DocumentEvent e) {
@ -93,7 +66,7 @@ public class AnyCommand {
@Override @Override
public void changedUpdate(DocumentEvent e) { public void changedUpdate(DocumentEvent e) {
boolean isOk = isValidInput(text); boolean isOk = isValidInput(text.getText());
text.setBorder(isOk ? null : BorderFactory.createLineBorder(Color.red)); text.setBorder(isOk ? null : BorderFactory.createLineBorder(Color.red));
config.setProperty(KEY, text.getText()); config.setProperty(KEY, text.getText());
} }
@ -111,19 +84,25 @@ public class AnyCommand {
} }
private void send() { private void send() {
index = 0;
String cmd = text.getText(); String cmd = text.getText();
if (!isValidInput(text)) for (String s : cmd.split("\n"))
doSend(s);
}
private void doSend(String cmd) {
if (!isValidInput(cmd))
return; return;
if (listener != null)
listener.onSend();
int timeout = CommandQueue.getTimeout(cmd); int timeout = CommandQueue.getTimeout(cmd);
reentrant = true; reentrant = true;
CommandQueue.getInstance().write(cmd.toLowerCase(), timeout); CommandQueue.getInstance().write(cmd.toLowerCase(), timeout);
reentrant = false; reentrant = false;
} }
private static boolean isValidInput(JTextComponent text) { private static boolean isValidInput(String text) {
boolean isOk = true; boolean isOk = true;
for (char c : text.getText().toCharArray()) { for (char c : text.toCharArray()) {
if (c > 127) { if (c > 127) {
/** /**
* https://sourceforge.net/p/rusefi/tickets/63/ * https://sourceforge.net/p/rusefi/tickets/63/
@ -143,4 +122,66 @@ public class AnyCommand {
public void setContent(JPanel content) { public void setContent(JPanel content) {
this.content = content; this.content = content;
} }
interface Listener {
void onSend();
}
public static AnyCommand createField(Node config, boolean listenToCommands, boolean withCommandCaption) {
return createField(config, config.getProperty(KEY), listenToCommands, withCommandCaption);
}
public static AnyCommand createField(Node config, String defaultCommand, boolean listenToCommands, boolean withCommandCaption) {
final JTextField text = new JTextField() {
@Override
public Dimension getPreferredSize() {
Dimension size = super.getPreferredSize();
return new Dimension(200, size.height);
}
};
final AnyCommand command = new AnyCommand(text, config, defaultCommand, listenToCommands, withCommandCaption);
text.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
command.send();
}
});
final AtomicInteger index = new AtomicInteger();
command.listener = new Listener() {
@Override
public void onSend() {
index.set(0);
}
};
text.addKeyListener(new KeyAdapter() {
@Override
public void keyPressed(KeyEvent e) {
if (e.getKeyCode() == KeyEvent.VK_UP) {
String command = RecentCommands.getRecent(index.incrementAndGet());
text.setText(command);
} else if (e.getKeyCode() == KeyEvent.VK_DOWN) {
String command = RecentCommands.getRecent(index.decrementAndGet());
text.setText(command);
}
}
});
return command;
}
public static AnyCommand createArea(Node config, String defaultCommand, boolean listenToCommands, boolean withCommandCaption) {
final JTextArea text = new JTextArea(3, 20) {
@Override
public Dimension getPreferredSize() {
Dimension size = super.getPreferredSize();
return new Dimension(200, size.height);
}
};
// text.setMax
return new AnyCommand(text, config, defaultCommand, listenToCommands, withCommandCaption);
}
} }