mirror of https://github.com/rusefi/RomRaider.git
Add option to auto connect on startup
This commit is contained in:
parent
caea8b8098
commit
f241b59650
|
@ -13,6 +13,7 @@ OUTLOCATION = Log File Output Location ...
|
|||
PROTOOPTIONS = Select Logging Protocol Options ...
|
||||
PROTOOPTIONSTT = Select to switch logging communications protocol
|
||||
DEFOGGERSW = Control File Logging With Defogger Switch
|
||||
AUTOCONNECT= Automatically Connect On Startup
|
||||
COMREFRESH = Enable COM port Auto Refresh
|
||||
COMREFRESHTT = Select to enable automatic COM port refreshing
|
||||
ELM327ENABLED = Enable ELM327 OBD Support
|
||||
|
|
|
@ -217,6 +217,7 @@ public class Settings implements Serializable {
|
|||
private boolean fileLoggingAbsoluteTimestamp;
|
||||
private String logfileNameText;
|
||||
private boolean logExternalsOnly;
|
||||
private boolean autoConnectOnStartup = true;
|
||||
private static String userLocale = SYSTEM_NUMFORMAT;
|
||||
|
||||
private Dimension loggerWindowSize = new Dimension(1000, 600);
|
||||
|
@ -567,6 +568,14 @@ public class Settings implements Serializable {
|
|||
this.loggerPortDefault = loggerPortDefault;
|
||||
}
|
||||
|
||||
public void setAutoConnectOnStartup(boolean value) {
|
||||
autoConnectOnStartup = value;
|
||||
}
|
||||
|
||||
public boolean getAutoConnectOnStartup() {
|
||||
return autoConnectOnStartup;
|
||||
}
|
||||
|
||||
public void setLoggerProtocol(String protocol) {
|
||||
Settings.loggerProtocol = protocol;
|
||||
}
|
||||
|
|
|
@ -2073,6 +2073,10 @@ public final class EcuLogger extends AbstractFrame implements MessageListener {
|
|||
getSettings().setRefreshMode(refreshMode);
|
||||
refresher.setRefreshMode(refreshMode);
|
||||
}
|
||||
|
||||
public void setAutoConnect(boolean connect) {
|
||||
getSettings().setAutoConnectOnStartup(connect);
|
||||
}
|
||||
|
||||
public void setElmEnabled(Boolean value) {
|
||||
getSettings().setElm327Enabled(value);
|
||||
|
@ -2102,13 +2106,12 @@ public final class EcuLogger extends AbstractFrame implements MessageListener {
|
|||
|
||||
//**********************************************************************
|
||||
|
||||
|
||||
public static void startLogger(int defaultCloseOperation, ECUEditor ecuEditor, String[] args) {
|
||||
touchEnabled = setTouchEnabled(args);
|
||||
boolean fullscreen = containsFullScreenArg(args);
|
||||
EcuLogger ecuLogger = getEcuLogger(ecuEditor);
|
||||
createAndShowGui(defaultCloseOperation, ecuLogger, fullscreen);
|
||||
if (!ecuLogger.isLogging()) ecuLogger.startLogging();
|
||||
if (ecuLogger.getSettings().getAutoConnectOnStartup() && !ecuLogger.isLogging()) ecuLogger.startLogging();
|
||||
}
|
||||
|
||||
private static boolean containsFullScreenArg(String... args) {
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
/*
|
||||
* RomRaider Open-Source Tuning, Logging and Reflashing
|
||||
* Copyright (C) 2006-2020 RomRaider.com
|
||||
* Copyright (C) 2006-2022 RomRaider.com
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
|
@ -59,6 +59,7 @@ import javax.swing.JSeparator;
|
|||
|
||||
import com.romraider.Settings;
|
||||
import com.romraider.logger.ecu.EcuLogger;
|
||||
import com.romraider.logger.ecu.ui.swing.menubar.action.AutoConnectAction;
|
||||
import com.romraider.logger.ecu.ui.swing.menubar.action.ComPortAutoRefreshAction;
|
||||
import com.romraider.logger.ecu.ui.swing.menubar.action.DisconnectAction;
|
||||
import com.romraider.logger.ecu.ui.swing.menubar.action.ElmEnabledAction;
|
||||
|
@ -121,6 +122,9 @@ public class EcuLoggerMenuBar extends JMenuBar {
|
|||
fileLoggingControl.setSelected(false);
|
||||
settingsMenu.add(fileLoggingControl);
|
||||
logger.getComponentList().put("fileLoggingControl", fileLoggingControl);
|
||||
RadioButtonMenuItem autoConnect = new RadioButtonMenuItem(rb.getString("AUTOCONNECT"), VK_A, getKeyStroke(VK_A, CTRL_MASK), new AutoConnectAction(logger), logger.getSettings().getAutoConnectOnStartup());
|
||||
autoConnect.setToolTipText(rb.getString("AUTOCONNECT"));
|
||||
settingsMenu.add(autoConnect);
|
||||
RadioButtonMenuItem autoRefresh = new RadioButtonMenuItem(rb.getString("COMREFRESH"), VK_E, getKeyStroke(VK_E, CTRL_MASK), new ComPortAutoRefreshAction(logger), logger.getSettings().getRefreshMode());
|
||||
autoRefresh.setToolTipText(rb.getString("COMREFRESHTT"));
|
||||
settingsMenu.add(autoRefresh);
|
||||
|
|
|
@ -0,0 +1,39 @@
|
|||
/*
|
||||
* RomRaider Open-Source Tuning, Logging and Reflashing
|
||||
* Copyright (C) 2006-2022 RomRaider.com
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License along
|
||||
* with this program; if not, write to the Free Software Foundation, Inc.,
|
||||
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*/
|
||||
|
||||
package com.romraider.logger.ecu.ui.swing.menubar.action;
|
||||
|
||||
import com.romraider.logger.ecu.EcuLogger;
|
||||
import com.romraider.swing.menubar.action.AbstractAction;
|
||||
import java.awt.event.ActionEvent;
|
||||
|
||||
public final class AutoConnectAction extends AbstractAction {
|
||||
|
||||
public AutoConnectAction(EcuLogger logger) {
|
||||
super(logger);
|
||||
}
|
||||
|
||||
public void actionPerformed(ActionEvent actionEvent) {
|
||||
try {
|
||||
logger.getSettings().setAutoConnectOnStartup((Boolean) getValue(SELECTED_KEY));
|
||||
} catch (Exception e) {
|
||||
logger.reportError(e);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -322,6 +322,11 @@ public final class DOMSettingsBuilder {
|
|||
IIOMetadataNode loggerSettings = new IIOMetadataNode("logger");
|
||||
loggerSettings.setAttribute("locale", settings.getLocale());
|
||||
|
||||
// Automatically connect the logger on startup
|
||||
IIOMetadataNode autoConnect = new IIOMetadataNode("autoConnectOnStartup");
|
||||
autoConnect.setAttribute("value", "" + settings.getAutoConnectOnStartup());
|
||||
loggerSettings.appendChild(autoConnect);
|
||||
|
||||
// serial connection
|
||||
IIOMetadataNode serial = new IIOMetadataNode("serial");
|
||||
serial.setAttribute("port", validateAttr(settings.getLoggerPortDefault()));
|
||||
|
|
|
@ -260,7 +260,8 @@ public final class DOMSettingsUnmarshaller {
|
|||
if (n.getNodeType() == ELEMENT_NODE && n.getNodeName().equalsIgnoreCase("serial")) {
|
||||
settings.setLoggerPortDefault(unmarshallAttribute(n, "port", ""));
|
||||
settings.setRefreshMode(unmarshallAttribute(n, "refresh", false));
|
||||
|
||||
} else if (n.getNodeType() == ELEMENT_NODE && n.getNodeName().equalsIgnoreCase("autoConnectOnStartup")) {
|
||||
settings.setAutoConnectOnStartup(unmarshallAttribute(n, "value", true));
|
||||
} else if (n.getNodeType() == ELEMENT_NODE && n.getNodeName().equalsIgnoreCase("protocol")) {
|
||||
settings.setLoggerProtocol(unmarshallAttribute(n, "name", "SSM"));
|
||||
settings.setTransportProtocol(unmarshallAttribute(n, "transport", "ISO9141"));
|
||||
|
|
Loading…
Reference in New Issue