Lua: 'read from ECU' does not read modified script fix #3906

there is just no reason for that button
This commit is contained in:
rusefillc 2022-02-09 23:45:40 -05:00
parent 3f9a8cef57
commit 179f059671
2 changed files with 10 additions and 26 deletions

View File

@ -6,7 +6,7 @@ import java.net.URL;
import java.util.concurrent.atomic.AtomicReference; import java.util.concurrent.atomic.AtomicReference;
public class rusEFIVersion { public class rusEFIVersion {
public static final int CONSOLE_VERSION = 20220201; public static final int CONSOLE_VERSION = 20220209;
public static AtomicReference<String> firmwareVersion = new AtomicReference<>("N/A"); public static AtomicReference<String> firmwareVersion = new AtomicReference<>("N/A");
public static long classBuildTimeMillis() { public static long classBuildTimeMillis() {

View File

@ -26,9 +26,6 @@ public class LuaScriptPanel {
private final JPanel mainPanel = new JPanel(new BorderLayout()); private final JPanel mainPanel = new JPanel(new BorderLayout());
private final AnyCommand command; private final AnyCommand command;
private final TextEditor scriptText = new TextEditor(); private final TextEditor scriptText = new TextEditor();
private boolean isFirstRender = true;
private boolean alreadyRequestedFromListener;
private boolean renderedBeforeConnected;
public LuaScriptPanel(UIContext context, Node config) { public LuaScriptPanel(UIContext context, Node config) {
this.context = context; this.context = context;
@ -37,14 +34,12 @@ public class LuaScriptPanel {
// Upper panel: command entry, etc // Upper panel: command entry, etc
JPanel upperPanel = new JPanel(new FlowLayout(FlowLayout.LEFT, 5, 0)); JPanel upperPanel = new JPanel(new FlowLayout(FlowLayout.LEFT, 5, 0));
JButton readButton = new JButton("Read from ECU");
JButton writeButton = new JButton("Write to ECU"); JButton writeButton = new JButton("Write to ECU");
JButton resetButton = new JButton("Reset/Reload Lua"); JButton resetButton = new JButton("Reset/Reload Lua");
JButton formatButton = new JButton("Format"); JButton formatButton = new JButton("Format");
MessagesPanel mp = new MessagesPanel(null, config); MessagesPanel mp = new MessagesPanel(null, config);
readButton.addActionListener(e -> readFromECU());
writeButton.addActionListener(e -> { writeButton.addActionListener(e -> {
write(); write();
// resume messages on 'write new script to ECU' // resume messages on 'write new script to ECU'
@ -64,7 +59,6 @@ public class LuaScriptPanel {
} } } }
}); });
upperPanel.add(readButton);
upperPanel.add(formatButton); upperPanel.add(formatButton);
upperPanel.add(writeButton); upperPanel.add(writeButton);
upperPanel.add(resetButton); upperPanel.add(resetButton);
@ -81,28 +75,19 @@ public class LuaScriptPanel {
messagesPanel.add(BorderLayout.CENTER, mp.getMessagesScroll()); messagesPanel.add(BorderLayout.CENTER, mp.getMessagesScroll());
ConnectionStatusLogic.INSTANCE.addListener(isConnected -> { ConnectionStatusLogic.INSTANCE.addListener(isConnected -> {
if (renderedBeforeConnected && !alreadyRequestedFromListener) { SwingUtilities.invokeLater(new Runnable() {
// this whole listener is one huge hack :( @Override
alreadyRequestedFromListener = true; public void run() {
SwingUtilities.invokeLater(new Runnable() { try {
@Override
public void run() {
readFromECU(); readFromECU();
} catch (Throwable e) {
System.out.println(e);
} }
}); }
} });
}); });
JSplitPane centerPanel = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, scriptPanel, messagesPanel) { JSplitPane centerPanel = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, scriptPanel, messagesPanel);
@Override
public void paint(Graphics g) {
super.paint(g);
if (isFirstRender) {
readFromECU();
isFirstRender = false;
}
}
};
mainPanel.add(upperPanel, BorderLayout.NORTH); mainPanel.add(upperPanel, BorderLayout.NORTH);
mainPanel.add(centerPanel, BorderLayout.CENTER); mainPanel.add(centerPanel, BorderLayout.CENTER);
@ -127,7 +112,6 @@ public class LuaScriptPanel {
if (bp == null) { if (bp == null) {
scriptText.setText("No ECU located"); scriptText.setText("No ECU located");
renderedBeforeConnected = true;
return; return;
} }