mirror of https://github.com/rusefi/RomRaider.git
Settings Update:
Reset Defaults now propagates the following settings: - ECU Definition Files - Last Image Dir - User Level - Logger Definition Path - Logger Profile Path - Logger Output Path. Moved settings into the SettingsManager. Note: I am not totally sold on the SettingsManager changes. This needs to be inspected using VisualVM or similar tools.
This commit is contained in:
parent
a308b7bcee
commit
0e2152f6d5
|
@ -45,7 +45,6 @@ import org.apache.log4j.Logger;
|
|||
import com.romraider.editor.ecu.ECUEditor;
|
||||
import com.romraider.util.JREChecker;
|
||||
import com.romraider.util.SettingsManager;
|
||||
import com.romraider.util.SettingsManagerImpl;
|
||||
|
||||
public class ECUExec {
|
||||
private static final Logger LOGGER = getLogger(ECUExec.class);
|
||||
|
@ -116,9 +115,7 @@ public class ECUExec {
|
|||
}
|
||||
|
||||
private static void openLogger(String[] args) {
|
||||
SettingsManager manager = new SettingsManagerImpl();
|
||||
Settings settings = manager.load();
|
||||
startLogger(EXIT_ON_CLOSE, settings, args);
|
||||
startLogger(EXIT_ON_CLOSE, SettingsManager.getSettings(), args);
|
||||
}
|
||||
|
||||
private static void openRom(final ECUEditor editor, final String rom) {
|
||||
|
|
|
@ -481,15 +481,15 @@ public class Settings implements Serializable {
|
|||
this.loggerPortDefault = loggerPortDefault;
|
||||
}
|
||||
|
||||
public static void setLoggerProtocol(String protocol) {
|
||||
public void setLoggerProtocol(String protocol) {
|
||||
Settings.loggerProtocol = protocol;
|
||||
}
|
||||
|
||||
public static String getLoggerProtocol() {
|
||||
public String getLoggerProtocol() {
|
||||
return loggerProtocol;
|
||||
}
|
||||
|
||||
public static String getLoggerDefinitionFilePath() {
|
||||
public String getLoggerDefinitionFilePath() {
|
||||
return loggerDefinitionFilePath;
|
||||
}
|
||||
|
||||
|
@ -497,7 +497,7 @@ public class Settings implements Serializable {
|
|||
Settings.loggerDefinitionFilePath = loggerDefinitionFilePath;
|
||||
}
|
||||
|
||||
public static String getLoggerOutputDirPath() {
|
||||
public String getLoggerOutputDirPath() {
|
||||
return loggerOutputDirPath;
|
||||
}
|
||||
|
||||
|
@ -533,7 +533,7 @@ public class Settings implements Serializable {
|
|||
this.loggerDividerLocation = dividerLocation;
|
||||
}
|
||||
|
||||
public static String getLoggerProfileFilePath() {
|
||||
public String getLoggerProfileFilePath() {
|
||||
return loggerProfileFilePath;
|
||||
}
|
||||
|
||||
|
@ -618,11 +618,11 @@ public class Settings implements Serializable {
|
|||
return loggerRefreshMode;
|
||||
}
|
||||
|
||||
public static void setDestinationId(byte id) {
|
||||
public void setDestinationId(byte id) {
|
||||
loggerDestinationId = id;
|
||||
}
|
||||
|
||||
public static byte getDestinationId() {
|
||||
public byte getDestinationId() {
|
||||
return loggerDestinationId;
|
||||
}
|
||||
|
||||
|
@ -650,19 +650,19 @@ public class Settings implements Serializable {
|
|||
return loggerDebuggingLevel;
|
||||
}
|
||||
|
||||
public static void setJ2534Device(String j2534Device) {
|
||||
public void setJ2534Device(String j2534Device) {
|
||||
Settings.j2534Device = j2534Device;
|
||||
}
|
||||
|
||||
public static String getJ2534Device() {
|
||||
public String getJ2534Device() {
|
||||
return j2534Device;
|
||||
}
|
||||
|
||||
public static void setTransportProtocol(String transport) {
|
||||
public void setTransportProtocol(String transport) {
|
||||
Settings.transportProtocol = transport;
|
||||
}
|
||||
|
||||
public static String getTransportProtocol() {
|
||||
public String getTransportProtocol() {
|
||||
return transportProtocol;
|
||||
}
|
||||
|
||||
|
@ -746,7 +746,7 @@ public class Settings implements Serializable {
|
|||
return logExternalsOnly;
|
||||
}
|
||||
|
||||
public static boolean isCanBus() {
|
||||
public boolean isCanBus() {
|
||||
if (transportProtocol.equals(ISO15765)) {
|
||||
return true;
|
||||
}
|
||||
|
|
|
@ -85,7 +85,6 @@ import com.romraider.swing.TableFrame;
|
|||
import com.romraider.swing.TableToolBar;
|
||||
import com.romraider.swing.TableTreeNode;
|
||||
import com.romraider.util.SettingsManager;
|
||||
import com.romraider.util.SettingsManagerImpl;
|
||||
import com.romraider.xml.DOMRomUnmarshaller;
|
||||
import com.romraider.xml.RomNotFoundException;
|
||||
import com.sun.org.apache.xerces.internal.parsers.DOMParser;
|
||||
|
@ -95,7 +94,6 @@ public class ECUEditor extends AbstractFrame {
|
|||
|
||||
private final String titleText = PRODUCT_NAME + " v" + VERSION + " | ECU Editor";
|
||||
|
||||
private final SettingsManager settingsManager = new SettingsManagerImpl();
|
||||
private final RomTreeRootNode imageRoot = new RomTreeRootNode("Open Images");
|
||||
private final RomTree imageList = new RomTree(imageRoot);
|
||||
public MDIDesktopPane rightPanel = new MDIDesktopPane();
|
||||
|
@ -115,7 +113,7 @@ public class ECUEditor extends AbstractFrame {
|
|||
|
||||
public ECUEditor() {
|
||||
// get settings from xml
|
||||
settings = settingsManager.load();
|
||||
settings = SettingsManager.getSettings();
|
||||
|
||||
if (!settings.getRecentVersion().equalsIgnoreCase(VERSION)) {
|
||||
showReleaseNotes();
|
||||
|
@ -238,7 +236,7 @@ public class ECUEditor extends AbstractFrame {
|
|||
getSettings().setWindowLocation(getLocation());
|
||||
|
||||
// Save when exit to save file settings.
|
||||
settingsManager.save(getSettings(), statusPanel);
|
||||
SettingsManager.save(getSettings(), statusPanel);
|
||||
statusPanel.update("Ready...", 0);
|
||||
repaint();
|
||||
}
|
||||
|
@ -526,10 +524,6 @@ public class ECUEditor extends AbstractFrame {
|
|||
launchLoggerWorker.execute();
|
||||
}
|
||||
|
||||
public SettingsManager getSettingsManager() {
|
||||
return this.settingsManager;
|
||||
}
|
||||
|
||||
public RomTreeRootNode getImageRoot() {
|
||||
return imageRoot;
|
||||
}
|
||||
|
|
|
@ -33,6 +33,7 @@ import com.romraider.io.j2534.api.J2534DllLocator;
|
|||
import com.romraider.io.j2534.api.J2534Library;
|
||||
import com.romraider.io.j2534.api.J2534TransportFactory;
|
||||
import com.romraider.io.serial.connection.SerialConnectionManager;
|
||||
import com.romraider.util.SettingsManager;
|
||||
import com.romraider.util.proxy.TimerWrapper;
|
||||
|
||||
public final class ConnectionManagerFactory {
|
||||
|
@ -45,7 +46,7 @@ public final class ConnectionManagerFactory {
|
|||
public static ConnectionManager getManager(
|
||||
String portName,
|
||||
ConnectionProperties connectionProperties) {
|
||||
|
||||
|
||||
ConnectionManager manager = manager(portName, connectionProperties);
|
||||
if (ENABLE_TIMER) return proxy(manager, TimerWrapper.class);
|
||||
return manager;
|
||||
|
@ -54,69 +55,72 @@ public final class ConnectionManagerFactory {
|
|||
private static ConnectionManager manager(
|
||||
String portName,
|
||||
ConnectionProperties connectionProperties) {
|
||||
|
||||
|
||||
Settings settings = SettingsManager.getSettings();
|
||||
|
||||
try {
|
||||
|
||||
if (!isPlatform(WINDOWS))
|
||||
throw new RuntimeException("J2534 is not support on this platform");
|
||||
Set<J2534Library> libraries =
|
||||
J2534DllLocator.listLibraries(
|
||||
Settings.getTransportProtocol().toUpperCase());
|
||||
|
||||
settings.getTransportProtocol().toUpperCase());
|
||||
|
||||
if (libraries.isEmpty())
|
||||
throw new RuntimeException(
|
||||
"No J2534 libraries found that support protocol " +
|
||||
Settings.getTransportProtocol());;
|
||||
settings.getTransportProtocol());;
|
||||
|
||||
// if the J2534 device has not been previously defined, search for it
|
||||
// else use the defined device
|
||||
if (Settings.getJ2534Device() == null) {
|
||||
for (J2534Library dll : libraries) {
|
||||
LOGGER.info(String.format("Trying new J2534/%s connection: %s",
|
||||
Settings.getTransportProtocol(),
|
||||
dll.getVendor()));
|
||||
try {
|
||||
Settings.setJ2534Device(dll.getLibrary());
|
||||
return J2534TransportFactory.getManager(
|
||||
Settings.getTransportProtocol().toUpperCase(),
|
||||
connectionProperties,
|
||||
dll.getLibrary());
|
||||
// if the J2534 device has not been previously defined, search for it
|
||||
// else use the defined device
|
||||
if (settings.getJ2534Device() == null) {
|
||||
for (J2534Library dll : libraries) {
|
||||
LOGGER.info(String.format("Trying new J2534/%s connection: %s",
|
||||
settings.getTransportProtocol(),
|
||||
dll.getVendor()));
|
||||
try {
|
||||
settings.setJ2534Device(dll.getLibrary());
|
||||
return J2534TransportFactory.getManager(
|
||||
settings.getTransportProtocol().toUpperCase(),
|
||||
connectionProperties,
|
||||
dll.getLibrary());
|
||||
|
||||
}
|
||||
catch (Throwable t) {
|
||||
Settings.setJ2534Device(null);
|
||||
LOGGER.info(String.format("%s is not available: %s",
|
||||
dll.getVendor(), t.getMessage()));
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
for (J2534Library dll : libraries) {
|
||||
if (dll.getLibrary().toLowerCase().contains(
|
||||
Settings.getJ2534Device().toLowerCase())) {
|
||||
}
|
||||
catch (Throwable t) {
|
||||
settings.setJ2534Device(null);
|
||||
LOGGER.info(String.format("%s is not available: %s",
|
||||
dll.getVendor(), t.getMessage()));
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
for (J2534Library dll : libraries) {
|
||||
if (dll.getLibrary().toLowerCase().contains(
|
||||
settings.getJ2534Device().toLowerCase())) {
|
||||
|
||||
LOGGER.info(String.format(
|
||||
"Re-trying previous J2534/%s connection: %s",
|
||||
Settings.getTransportProtocol(),
|
||||
dll.getVendor()));
|
||||
try {
|
||||
Settings.setJ2534Device(dll.getLibrary());
|
||||
return J2534TransportFactory.getManager(
|
||||
Settings.getTransportProtocol().toUpperCase(),
|
||||
connectionProperties,
|
||||
dll.getLibrary());
|
||||
}
|
||||
catch (Throwable t) {
|
||||
Settings.setJ2534Device(null);
|
||||
LOGGER.info(String.format("%s is not available: %s",
|
||||
dll.getVendor(), t.getMessage()));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
throw new RuntimeException("J2534 connection not available");
|
||||
LOGGER.info(String.format(
|
||||
"Re-trying previous J2534/%s connection: %s",
|
||||
settings.getTransportProtocol(),
|
||||
dll.getVendor()));
|
||||
try {
|
||||
settings.setJ2534Device(dll.getLibrary());
|
||||
return J2534TransportFactory.getManager(
|
||||
settings.getTransportProtocol().toUpperCase(),
|
||||
connectionProperties,
|
||||
dll.getLibrary());
|
||||
}
|
||||
catch (Throwable t) {
|
||||
settings.setJ2534Device(null);
|
||||
LOGGER.info(String.format("%s is not available: %s",
|
||||
dll.getVendor(), t.getMessage()));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
throw new RuntimeException("J2534 connection not available");
|
||||
}
|
||||
catch (Throwable t) {
|
||||
Settings.setJ2534Device(null);
|
||||
settings.setJ2534Device(null);
|
||||
LOGGER.info(String.format("%s, trying serial connection...",
|
||||
t.getMessage()));
|
||||
return new SerialConnectionManager(portName, connectionProperties);
|
||||
|
|
|
@ -24,13 +24,13 @@ import static org.apache.log4j.Logger.getLogger;
|
|||
|
||||
import org.apache.log4j.Logger;
|
||||
|
||||
import com.romraider.Settings;
|
||||
import com.romraider.io.connection.ConnectionManager;
|
||||
import com.romraider.io.connection.ConnectionProperties;
|
||||
import com.romraider.io.j2534.api.J2534Impl.Config;
|
||||
import com.romraider.io.j2534.api.J2534Impl.Protocol;
|
||||
import com.romraider.io.j2534.api.J2534Impl.TxFlags;
|
||||
import com.romraider.logger.ecu.comms.manager.PollingState;
|
||||
import com.romraider.util.SettingsManager;
|
||||
|
||||
public final class J2534ConnectionISO15765 implements ConnectionManager {
|
||||
private static final Logger LOGGER = getLogger(J2534ConnectionISO15765.class);
|
||||
|
@ -38,19 +38,20 @@ public final class J2534ConnectionISO15765 implements ConnectionManager {
|
|||
private int channelId;
|
||||
private int deviceId;
|
||||
private int msgId;
|
||||
private long timeout;
|
||||
private final long timeout;
|
||||
|
||||
public J2534ConnectionISO15765(
|
||||
ConnectionProperties connectionProperties,
|
||||
String library) {
|
||||
|
||||
api = null;
|
||||
timeout = (long) 2000;
|
||||
timeout = 2000;
|
||||
initJ2534(500000, library);
|
||||
LOGGER.info("J2534/ISO15765 connection initialized");
|
||||
}
|
||||
|
||||
// Send request and wait for response with known length
|
||||
@Override
|
||||
public void send(byte[] request, byte[] response, PollingState pollState) {
|
||||
checkNotNull(request, "request");
|
||||
checkNotNull(response, "response");
|
||||
|
@ -63,17 +64,20 @@ public final class J2534ConnectionISO15765 implements ConnectionManager {
|
|||
}
|
||||
|
||||
// Send request and wait specified time for one response with unknown length
|
||||
@Override
|
||||
public byte[] send(byte[] request) {
|
||||
checkNotNull(request, "request");
|
||||
api.writeMsg(channelId, request, timeout, TxFlags.ISO15765_FRAME_PAD);
|
||||
return api.readMsg(channelId, 1, timeout);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void clearLine() {
|
||||
// LOGGER.debug("J2534/ISO15765 clearing buffers");
|
||||
// api.clearBuffers(channelId);
|
||||
// LOGGER.debug("J2534/ISO15765 clearing buffers");
|
||||
// api.clearBuffers(channelId);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void close() {
|
||||
stopFcFilter();
|
||||
disconnectChannel();
|
||||
|
@ -91,10 +95,10 @@ public final class J2534ConnectionISO15765 implements ConnectionManager {
|
|||
final byte[] mask = {
|
||||
(byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff};
|
||||
byte[] pattern = {
|
||||
(byte) 0x00, (byte) 0x00, (byte) 0x07, (byte) 0xe8};
|
||||
(byte) 0x00, (byte) 0x00, (byte) 0x07, (byte) 0xe8};
|
||||
byte[] flowCntrl = {
|
||||
(byte) 0x00, (byte) 0x00, (byte) 0x07, (byte) 0xe0};
|
||||
if (Settings.getDestinationId() == 0x18) {
|
||||
(byte) 0x00, (byte) 0x00, (byte) 0x07, (byte) 0xe0};
|
||||
if (SettingsManager.getSettings().getDestinationId() == 0x18) {
|
||||
pattern = new byte[] {
|
||||
(byte) 0x00, (byte) 0x00, (byte) 0x07, (byte) 0xe9};
|
||||
flowCntrl = new byte[] {
|
||||
|
@ -102,7 +106,7 @@ public final class J2534ConnectionISO15765 implements ConnectionManager {
|
|||
}
|
||||
|
||||
msgId = api.startFlowCntrlFilter(
|
||||
channelId, mask, pattern,
|
||||
channelId, mask, pattern,
|
||||
flowCntrl, TxFlags.ISO15765_FRAME_PAD);
|
||||
|
||||
LOGGER.debug(String.format(
|
||||
|
@ -114,7 +118,7 @@ public final class J2534ConnectionISO15765 implements ConnectionManager {
|
|||
"J2534/ISO15765 exception: deviceId:%d, channelId:%d, msgId:%d",
|
||||
deviceId, channelId, msgId));
|
||||
close();
|
||||
throw new J2534Exception("J2534/ISO15765 Error opening device: " +
|
||||
throw new J2534Exception("J2534/ISO15765 Error opening device: " +
|
||||
e.getMessage(), e);
|
||||
}
|
||||
}
|
||||
|
@ -122,7 +126,7 @@ public final class J2534ConnectionISO15765 implements ConnectionManager {
|
|||
private void version(int deviceId) {
|
||||
if (!LOGGER.isDebugEnabled()) return;
|
||||
final Version version = api.readVersion(deviceId);
|
||||
LOGGER.info("J2534 Version => firmware: " + version.firmware +
|
||||
LOGGER.info("J2534 Version => firmware: " + version.firmware +
|
||||
", dll: " + version.dll + ", api: " + version.api);
|
||||
}
|
||||
|
||||
|
@ -141,7 +145,7 @@ public final class J2534ConnectionISO15765 implements ConnectionManager {
|
|||
api.stopMsgFilter(channelId, msgId);
|
||||
LOGGER.debug("J2534/ISO15765 stopped message filter:" + msgId);
|
||||
} catch (Exception e) {
|
||||
LOGGER.warn("J2534/ISO15765 Error stopping msg filter: " +
|
||||
LOGGER.warn("J2534/ISO15765 Error stopping msg filter: " +
|
||||
e.getMessage());
|
||||
}
|
||||
}
|
||||
|
@ -151,7 +155,7 @@ public final class J2534ConnectionISO15765 implements ConnectionManager {
|
|||
api.disconnect(channelId);
|
||||
LOGGER.debug("J2534/ISO15765 disconnected channel:" + channelId);
|
||||
} catch (Exception e) {
|
||||
LOGGER.warn("J2534/ISO15765 Error disconnecting channel: " +
|
||||
LOGGER.warn("J2534/ISO15765 Error disconnecting channel: " +
|
||||
e.getMessage());
|
||||
}
|
||||
}
|
||||
|
|
|
@ -21,9 +21,9 @@ package com.romraider.logger.ecu;
|
|||
|
||||
import static com.centerkey.utils.BareBonesBrowserLaunch.openURL;
|
||||
import static com.romraider.Version.LOGGER_DEFS_URL;
|
||||
import static com.romraider.Version.MIN_LOG_DEF_VERSION;
|
||||
import static com.romraider.Version.PRODUCT_NAME;
|
||||
import static com.romraider.Version.VERSION;
|
||||
import static com.romraider.Version.MIN_LOG_DEF_VERSION;
|
||||
import static com.romraider.logger.ecu.profile.UserProfileLoader.BACKUP_PROFILE;
|
||||
import static com.romraider.logger.ecu.ui.swing.menubar.util.FileHelper.saveProfileToFile;
|
||||
import static com.romraider.logger.ecu.ui.swing.vertical.VerticalTextIcon.ROTATE_LEFT;
|
||||
|
@ -181,10 +181,10 @@ import com.romraider.logger.external.core.ExternalDataSource;
|
|||
import com.romraider.logger.external.core.ExternalDataSourceLoader;
|
||||
import com.romraider.logger.external.core.ExternalDataSourceLoaderImpl;
|
||||
import com.romraider.swing.AbstractFrame;
|
||||
import com.romraider.util.FormatFilename;
|
||||
import com.romraider.swing.SetFont;
|
||||
import com.romraider.util.JREChecker;
|
||||
import com.romraider.util.SettingsManagerImpl;
|
||||
import com.romraider.util.FormatFilename;
|
||||
import com.romraider.util.SettingsManager;
|
||||
import com.romraider.util.ThreadUtil;
|
||||
|
||||
/*
|
||||
|
@ -300,12 +300,12 @@ public final class EcuLogger extends AbstractFrame implements MessageListener {
|
|||
// fail until we actually try to use them since the logger requires
|
||||
// these libraries, this is a hard error here
|
||||
if (!JREChecker.is32bit()) {
|
||||
showMessageDialog(null,
|
||||
"Incompatible JRE detected.\n" +
|
||||
PRODUCT_NAME +
|
||||
" ECU Logger requires a 32-bit JRE.\nLogger will now exit.",
|
||||
"JRE Incompatibility Error",
|
||||
ERROR_MESSAGE);
|
||||
showMessageDialog(null,
|
||||
"Incompatible JRE detected.\n" +
|
||||
PRODUCT_NAME +
|
||||
" ECU Logger requires a 32-bit JRE.\nLogger will now exit.",
|
||||
"JRE Incompatibility Error",
|
||||
ERROR_MESSAGE);
|
||||
// this will generate a NullPointerException because we never got
|
||||
// things started
|
||||
WindowEvent e = new WindowEvent(this, WindowEvent.WINDOW_CLOSED);
|
||||
|
@ -378,7 +378,7 @@ public final class EcuLogger extends AbstractFrame implements MessageListener {
|
|||
ecuIdLabel.setText(buildEcuInfoLabelText(target + " ID", ecuId));
|
||||
loadResult = String.format("Loading logger config for new %s ID: %s, ", target, ecuId);
|
||||
loadLoggerParams();
|
||||
loadUserProfile(Settings.getLoggerProfileFilePath());
|
||||
loadUserProfile(settings.getLoggerProfileFilePath());
|
||||
}
|
||||
|
||||
private String getCalId(String ecuId) {
|
||||
|
@ -512,23 +512,23 @@ public final class EcuLogger extends AbstractFrame implements MessageListener {
|
|||
}
|
||||
settings.setLoggerEcuDefinitionMap(ecuDefinitionMap);
|
||||
LOGGER.info(
|
||||
String.format(
|
||||
"%d ECU definitions loaded from %d files",
|
||||
ecuDefinitionMap.size(), ecuDefFiles.size()
|
||||
)
|
||||
);
|
||||
String.format(
|
||||
"%d ECU definitions loaded from %d files",
|
||||
ecuDefinitionMap.size(), ecuDefFiles.size()
|
||||
)
|
||||
);
|
||||
} catch (Exception e) {
|
||||
reportError(e);
|
||||
}
|
||||
}
|
||||
|
||||
private void loadLoggerConfig() {
|
||||
String loggerConfigFilePath = Settings.getLoggerDefinitionFilePath();
|
||||
String loggerConfigFilePath = settings.getLoggerDefinitionFilePath();
|
||||
if (isNullOrEmpty(loggerConfigFilePath)) showMissingConfigDialog();
|
||||
else {
|
||||
try {
|
||||
EcuDataLoader dataLoader = new EcuDataLoaderImpl();
|
||||
dataLoader.loadConfigFromXml(loggerConfigFilePath, Settings.getLoggerProtocol(),
|
||||
dataLoader.loadConfigFromXml(loggerConfigFilePath, settings.getLoggerProtocol(),
|
||||
settings.getFileLoggingControllerSwitchId(), ecuInit);
|
||||
List<EcuParameter> ecuParams = dataLoader.getEcuParameters();
|
||||
addConvertorUpdateListeners(ecuParams);
|
||||
|
@ -544,16 +544,16 @@ public final class EcuLogger extends AbstractFrame implements MessageListener {
|
|||
defVersion = dataLoader.getDefVersion();
|
||||
}
|
||||
|
||||
if ( defVersion.equals("na") ||
|
||||
if ( defVersion.equals("na") ||
|
||||
Integer.parseInt(defVersion) < MIN_LOG_DEF_VERSION ) {
|
||||
final String wrongDefVersion = "This version of RomRaider " +
|
||||
"Logger requires a logger definfition XML\nfile of " +
|
||||
"version " + MIN_LOG_DEF_VERSION + " or higher due " +
|
||||
"to a definition file format change.\n\nIncorrect " +
|
||||
"results may occur if the definition file " +
|
||||
"is not updated.\nUse the Help menu 'Update Logger " +
|
||||
"Definition' item to go online\nand donwload the " +
|
||||
"latest logger definition.\n";
|
||||
"Logger requires a logger definfition XML\nfile of " +
|
||||
"version " + MIN_LOG_DEF_VERSION + " or higher due " +
|
||||
"to a definition file format change.\n\nIncorrect " +
|
||||
"results may occur if the definition file " +
|
||||
"is not updated.\nUse the Help menu 'Update Logger " +
|
||||
"Definition' item to go online\nand donwload the " +
|
||||
"latest logger definition.\n";
|
||||
showMessageDialog(this,
|
||||
wrongDefVersion,
|
||||
"Configuration", INFORMATION_MESSAGE);
|
||||
|
@ -563,7 +563,7 @@ public final class EcuLogger extends AbstractFrame implements MessageListener {
|
|||
loadResult = String.format(
|
||||
"%sloaded %s: %d parameters, %d switches from def version %s.",
|
||||
loadResult,
|
||||
Settings.getLoggerProtocol(),
|
||||
settings.getLoggerProtocol(),
|
||||
ecuParams.size(),
|
||||
dataLoader.getEcuSwitches().size(),
|
||||
defVersion);
|
||||
|
@ -622,7 +622,7 @@ public final class EcuLogger extends AbstractFrame implements MessageListener {
|
|||
final File profileFile = new File(path);
|
||||
if (profileFile.exists()) {
|
||||
reportMessageInTitleBar(
|
||||
"Profile: " + FormatFilename.getShortName(profileFile));
|
||||
"Profile: " + FormatFilename.getShortName(profileFile));
|
||||
}
|
||||
}
|
||||
catch (Exception e) {
|
||||
|
@ -1216,31 +1216,31 @@ public final class EcuLogger extends AbstractFrame implements MessageListener {
|
|||
|
||||
private final Component buildLogToFileButton() {
|
||||
logToFileButton = new JToggleButton(
|
||||
LOG_TO_FILE_START,
|
||||
LOG_TO_FILE_START,
|
||||
new ImageIcon(getClass().getResource(LOG_TO_FILE_ICON)));
|
||||
SetFont.plain(logToFileButton);
|
||||
logToFileButton.setToolTipText(LOG_TO_FILE_TT_TEXT);
|
||||
logToFileButton.setBackground(GREEN);
|
||||
logToFileButton.setOpaque(true);
|
||||
logToFileButton.addActionListener(
|
||||
new ActionListener() {
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent actionEvent) {
|
||||
if (logToFileButton.isSelected() && controller.isStarted()) {
|
||||
fileUpdateHandler.start();
|
||||
logToFileButton.setBackground(RED);
|
||||
logToFileButton.setText(LOG_TO_FILE_STOP);
|
||||
}
|
||||
else {
|
||||
fileUpdateHandler.stop();
|
||||
if (!controller.isStarted()) statusIndicator.stopped();
|
||||
logToFileButton.setBackground(GREEN);
|
||||
logToFileButton.setSelected(false);
|
||||
logToFileButton.setText(LOG_TO_FILE_START);
|
||||
new ActionListener() {
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent actionEvent) {
|
||||
if (logToFileButton.isSelected() && controller.isStarted()) {
|
||||
fileUpdateHandler.start();
|
||||
logToFileButton.setBackground(RED);
|
||||
logToFileButton.setText(LOG_TO_FILE_STOP);
|
||||
}
|
||||
else {
|
||||
fileUpdateHandler.stop();
|
||||
if (!controller.isStarted()) statusIndicator.stopped();
|
||||
logToFileButton.setBackground(GREEN);
|
||||
logToFileButton.setSelected(false);
|
||||
logToFileButton.setText(LOG_TO_FILE_START);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
);
|
||||
);
|
||||
logToFileButton.getInputMap(
|
||||
WHEN_IN_FOCUSED_WINDOW).put(
|
||||
getKeyStroke(LOG_TO_FILE_FK), "toggleFileLogging");
|
||||
|
@ -1298,7 +1298,7 @@ public final class EcuLogger extends AbstractFrame implements MessageListener {
|
|||
startLogging();
|
||||
}
|
||||
});
|
||||
if (Settings.getDestinationId() == 0x10) {
|
||||
if (settings.getDestinationId() == 0x10) {
|
||||
ecuCheckBox.setSelected(true);
|
||||
tcuCheckBox.setSelected(false);
|
||||
setTargetEcu();
|
||||
|
@ -1348,12 +1348,12 @@ public final class EcuLogger extends AbstractFrame implements MessageListener {
|
|||
}
|
||||
|
||||
private void setTargetEcu() {
|
||||
Settings.setDestinationId(ECU_ID);
|
||||
settings.setDestinationId(ECU_ID);
|
||||
target = "ECU";
|
||||
}
|
||||
|
||||
private void setTargetTcu() {
|
||||
Settings.setDestinationId(TCU_ID);
|
||||
settings.setDestinationId(TCU_ID);
|
||||
target = "TCU";
|
||||
}
|
||||
|
||||
|
@ -1491,7 +1491,7 @@ public final class EcuLogger extends AbstractFrame implements MessageListener {
|
|||
}
|
||||
|
||||
public final boolean getDtcodesEmpty() {
|
||||
LOGGER.info("DT codes defined: " + !dtcodes.isEmpty() +
|
||||
LOGGER.info("DT codes defined: " + !dtcodes.isEmpty() +
|
||||
", definition version: " + defVersion);
|
||||
return dtcodes.isEmpty();
|
||||
}
|
||||
|
@ -1505,16 +1505,16 @@ public final class EcuLogger extends AbstractFrame implements MessageListener {
|
|||
}
|
||||
|
||||
public final int readEcuCodes() {
|
||||
final ReadCodesManager readCodesManager =
|
||||
final ReadCodesManager readCodesManager =
|
||||
new ReadCodesManagerImpl(
|
||||
this,
|
||||
dtcodes,
|
||||
this,
|
||||
dtcodes,
|
||||
ecuInit.getEcuInitBytes().length);
|
||||
return readCodesManager.readCodes();
|
||||
}
|
||||
|
||||
public final int ecuGlobalAdjustment() {
|
||||
final GlobalAdjustManager globalAdjustManager =
|
||||
final GlobalAdjustManager globalAdjustManager =
|
||||
new GlobalAdjustManagerImpl(
|
||||
this,
|
||||
dataTabParamListTableModel);
|
||||
|
@ -1565,15 +1565,15 @@ public final class EcuLogger extends AbstractFrame implements MessageListener {
|
|||
if (settings.getLoggerParameterListState()) {
|
||||
final Component c = tabbedPane.getSelectedComponent();
|
||||
if (c instanceof JSplitPane) {
|
||||
// Only save the divider location if there is one
|
||||
final JSplitPane sp = (JSplitPane) c.getComponentAt(100, 100);
|
||||
settings.setLoggerDividerLocation(sp.getDividerLocation());
|
||||
// Only save the divider location if there is one
|
||||
final JSplitPane sp = (JSplitPane) c.getComponentAt(100, 100);
|
||||
settings.setLoggerDividerLocation(sp.getDividerLocation());
|
||||
}
|
||||
}
|
||||
settings.setLoggerSelectedTabIndex(tabbedPane.getSelectedIndex());
|
||||
settings.setLoggerPluginPorts(getPluginPorts(externalDataSources));
|
||||
try {
|
||||
new SettingsManagerImpl().save(settings);
|
||||
SettingsManager.save(settings);
|
||||
LOGGER.debug("Logger settings saved");
|
||||
} catch (Exception e) {
|
||||
LOGGER.warn("Error saving logger settings:", e);
|
||||
|
|
|
@ -19,12 +19,12 @@
|
|||
|
||||
package com.romraider.logger.ecu;
|
||||
|
||||
import static javax.swing.WindowConstants.EXIT_ON_CLOSE;
|
||||
|
||||
import com.romraider.Settings;
|
||||
import com.romraider.swing.LookAndFeelManager;
|
||||
import com.romraider.util.LogManager;
|
||||
import com.romraider.util.SettingsManager;
|
||||
import com.romraider.util.SettingsManagerImpl;
|
||||
import static javax.swing.WindowConstants.EXIT_ON_CLOSE;
|
||||
|
||||
public final class EcuLoggerExec {
|
||||
|
||||
|
@ -37,14 +37,13 @@ public final class EcuLoggerExec {
|
|||
LogManager.initDebugLogging();
|
||||
|
||||
// check for dodgy threading - dev only
|
||||
// RepaintManager.setCurrentManager(new ThreadCheckingRepaintManager(true));
|
||||
// RepaintManager.setCurrentManager(new ThreadCheckingRepaintManager(true));
|
||||
|
||||
// set look and feel
|
||||
LookAndFeelManager.initLookAndFeel();
|
||||
|
||||
// load settings
|
||||
SettingsManager manager = new SettingsManagerImpl();
|
||||
Settings settings = manager.load();
|
||||
Settings settings = SettingsManager.getSettings();
|
||||
|
||||
// start logger
|
||||
EcuLogger.startLogger(EXIT_ON_CLOSE, settings, args);
|
||||
|
|
|
@ -56,18 +56,19 @@ public final class GlobalAdjustManagerImpl implements GlobalAdjustManager {
|
|||
public GlobalAdjustManagerImpl(
|
||||
EcuLogger logger,
|
||||
ParameterListTableModel dataTabParamListTableModel) {
|
||||
|
||||
|
||||
checkNotNull(logger);
|
||||
this.logger = logger;
|
||||
this.settings = logger.getSettings();
|
||||
this.messageListener = (MessageListener) logger;
|
||||
this.messageListener = logger;
|
||||
this.parmeterList = dataTabParamListTableModel;
|
||||
}
|
||||
|
||||
@Override
|
||||
public final int ecuGlobalAdjustments() {
|
||||
try {
|
||||
LoggerConnection connection = getConnection(
|
||||
Settings.getLoggerProtocol(), settings.getLoggerPort(),
|
||||
settings.getLoggerProtocol(), settings.getLoggerPort(),
|
||||
settings.getLoggerConnectionProperties());
|
||||
try {
|
||||
messageListener.reportMessage("Retrieving current ECU global values...");
|
||||
|
@ -110,7 +111,7 @@ public final class GlobalAdjustManagerImpl implements GlobalAdjustManager {
|
|||
} catch (Exception e) {
|
||||
messageListener.reportMessage(
|
||||
"Unable to retrieve current ECU timing value - check correct " +
|
||||
"serial port \nhas been selected, cable is connected and ignition " +
|
||||
"serial port \nhas been selected, cable is connected and ignition " +
|
||||
"is on.");
|
||||
LOGGER.error("Error retrieving current ECU global timing value", e);
|
||||
return 0;
|
||||
|
@ -124,9 +125,9 @@ public final class GlobalAdjustManagerImpl implements GlobalAdjustManager {
|
|||
for (ParameterRow parameterRow : parameterRows) {
|
||||
final String id = parameterRow.getLoggerData().getId();
|
||||
if (id.equals(ID_P239) ||
|
||||
id.equals(ID_P240) ||
|
||||
id.equals(ID_P241)) {
|
||||
|
||||
id.equals(ID_P240) ||
|
||||
id.equals(ID_P241)) {
|
||||
|
||||
query.add(buildEcuQuery(parameterRow));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -19,6 +19,17 @@
|
|||
|
||||
package com.romraider.logger.ecu.comms.io.connection;
|
||||
|
||||
import static com.romraider.util.HexUtil.asHex;
|
||||
import static com.romraider.util.ParamChecker.checkNotNull;
|
||||
import static org.apache.log4j.Logger.getLogger;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import org.apache.log4j.Logger;
|
||||
|
||||
import com.romraider.Settings;
|
||||
import com.romraider.io.connection.ConnectionManager;
|
||||
import com.romraider.io.protocol.ProtocolFactory;
|
||||
|
@ -27,15 +38,7 @@ import com.romraider.logger.ecu.comms.manager.PollingState;
|
|||
import com.romraider.logger.ecu.comms.manager.PollingStateImpl;
|
||||
import com.romraider.logger.ecu.comms.query.EcuInitCallback;
|
||||
import com.romraider.logger.ecu.comms.query.EcuQuery;
|
||||
import static com.romraider.util.HexUtil.asHex;
|
||||
import static com.romraider.util.ParamChecker.checkNotNull;
|
||||
import org.apache.log4j.Logger;
|
||||
import static org.apache.log4j.Logger.getLogger;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import com.romraider.util.SettingsManager;
|
||||
|
||||
public final class SSMLoggerConnection implements LoggerConnection {
|
||||
private static final Logger LOGGER = getLogger(SSMLoggerConnection.class);
|
||||
|
@ -43,15 +46,18 @@ public final class SSMLoggerConnection implements LoggerConnection {
|
|||
private final ConnectionManager manager;
|
||||
private List<EcuQuery> tcuQueries = new ArrayList<EcuQuery>();
|
||||
private final Collection<EcuQuery> tcuSubQuery = new ArrayList<EcuQuery>();
|
||||
Settings settings = SettingsManager.getSettings();
|
||||
|
||||
public SSMLoggerConnection(ConnectionManager manager) {
|
||||
checkNotNull(manager, "manager");
|
||||
this.manager = manager;
|
||||
|
||||
this.protocol = ProtocolFactory.getProtocol(
|
||||
Settings.getLoggerProtocol(),
|
||||
Settings.getTransportProtocol());
|
||||
settings.getLoggerProtocol(),
|
||||
settings.getTransportProtocol());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void ecuReset(byte id) {
|
||||
byte[] request = protocol.constructEcuResetRequest(id);
|
||||
LOGGER.debug("Ecu Reset Request ---> " + asHex(request));
|
||||
|
@ -61,6 +67,7 @@ public final class SSMLoggerConnection implements LoggerConnection {
|
|||
protocol.processEcuResetResponse(processedResponse);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void ecuInit(EcuInitCallback callback, byte id) {
|
||||
byte[] request = protocol.constructEcuInitRequest(id);
|
||||
LOGGER.debug("Ecu Init Request ---> " + asHex(request));
|
||||
|
@ -70,15 +77,16 @@ public final class SSMLoggerConnection implements LoggerConnection {
|
|||
protocol.processEcuInitResponse(callback, processedResponse);
|
||||
}
|
||||
|
||||
@Override
|
||||
public final void sendAddressReads(
|
||||
Collection<EcuQuery> queries,
|
||||
byte id,
|
||||
byte id,
|
||||
PollingState pollState) {
|
||||
|
||||
// Determine if ISO15765 is selected and then if TCU is selected. If
|
||||
// both are true then proceed to split queries so max CAN data packet
|
||||
// contains 8 or less bytes, otherwise don't split up the queries.
|
||||
if (Settings.isCanBus() && id == 0x18) {
|
||||
if (settings.isCanBus() && id == 0x18) {
|
||||
tcuQueries = (ArrayList<EcuQuery>) queries;
|
||||
final int tcuQueryListLength = tcuQueries.size();
|
||||
for (int i = 0; i < tcuQueryListLength; i++) {
|
||||
|
@ -110,7 +118,7 @@ public final class SSMLoggerConnection implements LoggerConnection {
|
|||
final byte[] request = protocol.constructReadAddressRequest(
|
||||
id, queries);
|
||||
if (pollState.getCurrentState() == 0) {
|
||||
LOGGER.debug("Mode:" + pollState.getCurrentState() +
|
||||
LOGGER.debug("Mode:" + pollState.getCurrentState() +
|
||||
" ECU Request ---> " + asHex(request));
|
||||
}
|
||||
final byte[] response = protocol.constructReadAddressResponse(
|
||||
|
@ -118,21 +126,24 @@ public final class SSMLoggerConnection implements LoggerConnection {
|
|||
manager.send(request, response, pollState);
|
||||
final byte[] processedResponse = protocol.preprocessResponse(
|
||||
request, response, pollState);
|
||||
LOGGER.debug("Mode:" + pollState.getCurrentState() +
|
||||
LOGGER.debug("Mode:" + pollState.getCurrentState() +
|
||||
" ECU Response <--- " + asHex(processedResponse));
|
||||
protocol.processReadAddressResponses(
|
||||
queries, processedResponse, pollState);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void clearLine() {
|
||||
manager.clearLine();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void close() {
|
||||
manager.close();
|
||||
}
|
||||
|
||||
@Override
|
||||
public final void sendAddressWrites(
|
||||
Map<EcuQuery, byte[]> writeQueries, byte id) {
|
||||
|
||||
|
@ -143,17 +154,17 @@ public final class SSMLoggerConnection implements LoggerConnection {
|
|||
id,
|
||||
writeKey.getBytes(),
|
||||
writeQueries.get(writeKey)[0]);
|
||||
|
||||
LOGGER.debug("ECU Write Request ---> " + asHex(request));
|
||||
final byte[] response = manager.send(request);
|
||||
byte[] processedResponse =
|
||||
protocol.preprocessResponse(
|
||||
request,
|
||||
response,
|
||||
new PollingStateImpl());
|
||||
LOGGER.debug("ECU Write Response <--- " + asHex(processedResponse));
|
||||
protocol.processWriteResponse(
|
||||
writeQueries.get(writeKey), processedResponse);
|
||||
|
||||
LOGGER.debug("ECU Write Request ---> " + asHex(request));
|
||||
final byte[] response = manager.send(request);
|
||||
byte[] processedResponse =
|
||||
protocol.preprocessResponse(
|
||||
request,
|
||||
response,
|
||||
new PollingStateImpl());
|
||||
LOGGER.debug("ECU Write Response <--- " + asHex(processedResponse));
|
||||
protocol.processWriteResponse(
|
||||
writeQueries.get(writeKey), processedResponse);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -79,13 +79,13 @@ public final class QueryManagerImpl implements QueryManager {
|
|||
private static boolean stop;
|
||||
|
||||
public QueryManagerImpl(Settings settings,
|
||||
EcuInitCallback ecuInitCallback,
|
||||
MessageListener messageListener,
|
||||
DataUpdateHandler... dataUpdateHandlers) {
|
||||
EcuInitCallback ecuInitCallback,
|
||||
MessageListener messageListener,
|
||||
DataUpdateHandler... dataUpdateHandlers) {
|
||||
checkNotNull(settings,
|
||||
ecuInitCallback,
|
||||
messageListener,
|
||||
dataUpdateHandlers);
|
||||
ecuInitCallback,
|
||||
messageListener,
|
||||
dataUpdateHandlers);
|
||||
this.settings = settings;
|
||||
this.ecuInitCallback = ecuInitCallback;
|
||||
this.messageListener = messageListener;
|
||||
|
@ -93,17 +93,20 @@ public final class QueryManagerImpl implements QueryManager {
|
|||
stop = true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public synchronized void addListener(StatusChangeListener listener) {
|
||||
checkNotNull(listener, "listener");
|
||||
listeners.add(listener);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setFileLoggerSwitchMonitor(FileLoggerControllerSwitchMonitor monitor) {
|
||||
checkNotNull(monitor);
|
||||
this.monitor = monitor;
|
||||
fileLoggerQuery = new EcuQueryImpl(monitor.getEcuSwitch());
|
||||
}
|
||||
|
||||
@Override
|
||||
public synchronized void addQuery(String callerId, LoggerData loggerData) {
|
||||
checkNotNull(callerId, loggerData);
|
||||
//FIXME: This is a hack!!
|
||||
|
@ -117,6 +120,7 @@ public final class QueryManagerImpl implements QueryManager {
|
|||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public synchronized void removeQuery(String callerId, LoggerData loggerData) {
|
||||
checkNotNull(callerId, loggerData);
|
||||
removeList.add(buildQueryId(callerId, loggerData));
|
||||
|
@ -125,14 +129,17 @@ public final class QueryManagerImpl implements QueryManager {
|
|||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Thread getThread() {
|
||||
return queryManagerThread;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isRunning() {
|
||||
return started && !stop;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
started = true;
|
||||
queryManagerThread = Thread.currentThread();
|
||||
|
@ -142,10 +149,10 @@ public final class QueryManagerImpl implements QueryManager {
|
|||
while (!stop) {
|
||||
notifyConnecting();
|
||||
if (!settings.isLogExternalsOnly() &&
|
||||
doEcuInit(Settings.getDestinationId())) {
|
||||
doEcuInit(settings.getDestinationId())) {
|
||||
|
||||
notifyReading();
|
||||
runLogger(Settings.getDestinationId());
|
||||
runLogger(settings.getDestinationId());
|
||||
} else if (settings.isLogExternalsOnly()) {
|
||||
notifyReading();
|
||||
runLogger((byte) -1);
|
||||
|
@ -170,12 +177,12 @@ public final class QueryManagerImpl implements QueryManager {
|
|||
if (id == 0x18){
|
||||
target = TCU;
|
||||
}
|
||||
|
||||
|
||||
try {
|
||||
LoggerConnection connection =
|
||||
getConnection(Settings.getLoggerProtocol(),
|
||||
settings.getLoggerPort(),
|
||||
settings.getLoggerConnectionProperties());
|
||||
getConnection(settings.getLoggerProtocol(),
|
||||
settings.getLoggerPort(),
|
||||
settings.getLoggerConnectionProperties());
|
||||
try {
|
||||
messageListener.reportMessage("Sending " + target + " Init...");
|
||||
connection.ecuInit(ecuInitCallback, id);
|
||||
|
@ -306,7 +313,7 @@ public final class QueryManagerImpl implements QueryManager {
|
|||
if (fileLoggerQuery != null
|
||||
&& settings.isFileLoggingControllerSwitchActive())
|
||||
ecuQueries.add(fileLoggerQuery);
|
||||
txManager.sendQueries(ecuQueries, pollState);
|
||||
txManager.sendQueries(ecuQueries, pollState);
|
||||
}
|
||||
|
||||
private void sendExternalQueries() {
|
||||
|
@ -315,7 +322,7 @@ public final class QueryManagerImpl implements QueryManager {
|
|||
for (ExternalQuery externalQuery : externalQueries) {
|
||||
//FIXME: This is a hack!!
|
||||
externalQuery.setResponse(
|
||||
externalQuery.getLoggerData().getSelectedConvertor().convert(null));
|
||||
externalQuery.getLoggerData().getSelectedConvertor().convert(null));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -329,6 +336,7 @@ public final class QueryManagerImpl implements QueryManager {
|
|||
final Response response = buildResponse(queryMap.values());
|
||||
for (final DataUpdateHandler dataUpdateHandler : dataUpdateHandlers) {
|
||||
runAsDaemon(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
dataUpdateHandler.handleDataUpdate(response);
|
||||
}
|
||||
|
@ -366,6 +374,7 @@ public final class QueryManagerImpl implements QueryManager {
|
|||
return filtered;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void stop() {
|
||||
stop = true;
|
||||
}
|
||||
|
@ -398,24 +407,25 @@ public final class QueryManagerImpl implements QueryManager {
|
|||
if (pollState.isFastPoll()) {
|
||||
state = "Fast-K:";
|
||||
}
|
||||
if (Settings.getTransportProtocol().equals("ISO15765")) {
|
||||
if (settings.getTransportProtocol().equals("ISO15765")) {
|
||||
state = "CAN bus:";
|
||||
}
|
||||
if (settings.isLogExternalsOnly()) {
|
||||
state = "Externals:";
|
||||
}
|
||||
double duration = ((double) (System.currentTimeMillis() - start)) / 1000.0;
|
||||
double duration = (System.currentTimeMillis() - start) / 1000.0;
|
||||
String result = String.format(
|
||||
"%s[ %.2f queries/sec, %.2f sec/query ]",
|
||||
state,
|
||||
((double) count) / duration,
|
||||
duration / ((double) count)
|
||||
);
|
||||
"%s[ %.2f queries/sec, %.2f sec/query ]",
|
||||
state,
|
||||
(count) / duration,
|
||||
duration / (count)
|
||||
);
|
||||
return result;
|
||||
}
|
||||
|
||||
private void notifyConnecting() {
|
||||
SwingUtilities.invokeLater(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
for (StatusChangeListener listener : listeners) {
|
||||
listener.connecting();
|
||||
|
@ -426,6 +436,7 @@ public final class QueryManagerImpl implements QueryManager {
|
|||
|
||||
private void notifyReading() {
|
||||
SwingUtilities.invokeLater(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
for (StatusChangeListener listener : listeners) {
|
||||
listener.readingData();
|
||||
|
@ -436,6 +447,7 @@ public final class QueryManagerImpl implements QueryManager {
|
|||
|
||||
private void notifyStopped() {
|
||||
SwingUtilities.invokeLater(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
for (StatusChangeListener listener : listeners) {
|
||||
listener.stopped();
|
||||
|
|
|
@ -19,15 +19,18 @@
|
|||
|
||||
package com.romraider.logger.ecu.comms.manager;
|
||||
|
||||
import static com.romraider.logger.ecu.comms.io.connection.LoggerConnectionFactory.getConnection;
|
||||
import static com.romraider.util.ParamChecker.checkNotNull;
|
||||
import static org.apache.log4j.Logger.getLogger;
|
||||
|
||||
import java.util.Collection;
|
||||
|
||||
import org.apache.log4j.Logger;
|
||||
|
||||
import com.romraider.Settings;
|
||||
import com.romraider.logger.ecu.comms.io.connection.LoggerConnection;
|
||||
import static com.romraider.logger.ecu.comms.io.connection.LoggerConnectionFactory.getConnection;
|
||||
import com.romraider.logger.ecu.comms.query.EcuQuery;
|
||||
import com.romraider.logger.ecu.exception.NotConnectedException;
|
||||
import static com.romraider.util.ParamChecker.checkNotNull;
|
||||
import org.apache.log4j.Logger;
|
||||
import static org.apache.log4j.Logger.getLogger;
|
||||
import java.util.Collection;
|
||||
|
||||
public final class TransmissionManagerImpl implements TransmissionManager {
|
||||
private static final Logger LOGGER = getLogger(TransmissionManagerImpl.class);
|
||||
|
@ -39,27 +42,31 @@ public final class TransmissionManagerImpl implements TransmissionManager {
|
|||
this.settings = settings;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void start() {
|
||||
try {
|
||||
connection = getConnection(Settings.getLoggerProtocol(), settings.getLoggerPort(), settings.getLoggerConnectionProperties());
|
||||
connection = getConnection(settings.getLoggerProtocol(), settings.getLoggerPort(), settings.getLoggerConnectionProperties());
|
||||
LOGGER.info("TX Manager Started.");
|
||||
} catch (Throwable e) {
|
||||
stop();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void sendQueries(Collection<EcuQuery> queries, PollingState pollState) {
|
||||
checkNotNull(queries, "queries");
|
||||
checkNotNull(pollState, "pollState");
|
||||
if (connection == null) throw new NotConnectedException("TransmissionManager must be started before queries can be sent!");
|
||||
connection.sendAddressReads(queries, Settings.getDestinationId(), pollState);
|
||||
connection.sendAddressReads(queries, settings.getDestinationId(), pollState);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void endQueries() {
|
||||
if (connection == null) throw new NotConnectedException("TransmissionManager must be started before ending queries!");
|
||||
connection.clearLine();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void stop() {
|
||||
if (connection != null) {
|
||||
endQueries();
|
||||
|
|
|
@ -34,29 +34,30 @@ import com.romraider.logger.ecu.comms.io.connection.LoggerConnection;
|
|||
import com.romraider.logger.ecu.comms.manager.PollingStateImpl;
|
||||
import com.romraider.logger.ecu.comms.query.EcuQuery;
|
||||
import com.romraider.logger.ecu.comms.query.EcuQueryImpl;
|
||||
import com.romraider.logger.ecu.definition.EcuData;
|
||||
import com.romraider.logger.ecu.definition.EcuSwitch;
|
||||
import com.romraider.logger.ecu.ui.MessageListener;
|
||||
import com.romraider.logger.ecu.ui.swing.tools.ReadCodesResultsPanel;
|
||||
import com.romraider.util.SettingsManager;
|
||||
|
||||
public final class ReadCodesManagerImpl implements ReadCodesManager {
|
||||
private static final Logger LOGGER =
|
||||
Logger.getLogger(ReadCodesManagerImpl.class);
|
||||
private static final Logger LOGGER =
|
||||
Logger.getLogger(ReadCodesManagerImpl.class);
|
||||
private final MessageListener messageListener;
|
||||
private final EcuLogger logger;
|
||||
private final List<EcuSwitch> dtcodes;
|
||||
private final int ecuInitLength;
|
||||
|
||||
public ReadCodesManagerImpl(EcuLogger logger,
|
||||
List<EcuSwitch> dtcodes,
|
||||
int ecuInitLength) {
|
||||
public ReadCodesManagerImpl(EcuLogger logger,
|
||||
List<EcuSwitch> dtcodes,
|
||||
int ecuInitLength) {
|
||||
checkNotNull(logger, dtcodes);
|
||||
this.logger = logger;
|
||||
this.messageListener = (MessageListener) logger;
|
||||
this.messageListener = logger;
|
||||
this.dtcodes = dtcodes;
|
||||
this.ecuInitLength = ecuInitLength;
|
||||
}
|
||||
|
||||
@Override
|
||||
public final int readCodes() {
|
||||
final ArrayList<EcuQuery> queries = new ArrayList<EcuQuery>();
|
||||
String lastCode = dtcodes.get(dtcodes.size() - 1).getId();
|
||||
|
@ -67,22 +68,23 @@ public final class ReadCodesManagerImpl implements ReadCodesManager {
|
|||
lastCode = "D256";
|
||||
}
|
||||
LOGGER.debug(
|
||||
"DT codes ECU init length: " + ecuInitLength +
|
||||
"DT codes ECU init length: " + ecuInitLength +
|
||||
", Last code: " + lastCode);
|
||||
|
||||
for (int i = 0; !dtcodes.get(i).getId().equals(lastCode); i++) {
|
||||
queries.add(new EcuQueryImpl((EcuData) dtcodes.get(i)));
|
||||
queries.add(new EcuQueryImpl(dtcodes.get(i)));
|
||||
LOGGER.debug("Adding query for DTC: " + dtcodes.get(i).getName());
|
||||
}
|
||||
|
||||
String target = "ECU";
|
||||
try {
|
||||
Settings settings = SettingsManager.getSettings();
|
||||
final LoggerConnection connection = getConnection(
|
||||
Settings.getLoggerProtocol(),
|
||||
settings.getLoggerProtocol(),
|
||||
logger.getSettings().getLoggerPort(),
|
||||
logger.getSettings().getLoggerConnectionProperties());
|
||||
try {
|
||||
if (Settings.getDestinationId() == 0x18) target = "TCU";
|
||||
if (settings.getDestinationId() == 0x18) target = "TCU";
|
||||
messageListener.reportMessage(
|
||||
"Reading " + target + " DTC codes...");
|
||||
final Collection<EcuQuery> querySet = new ArrayList<EcuQuery>();
|
||||
|
@ -91,8 +93,8 @@ public final class ReadCodesManagerImpl implements ReadCodesManager {
|
|||
querySet.add(queries.get(j));
|
||||
}
|
||||
connection.sendAddressReads(
|
||||
querySet,
|
||||
Settings.getDestinationId(),
|
||||
querySet,
|
||||
settings.getDestinationId(),
|
||||
new PollingStateImpl());
|
||||
querySet.clear();
|
||||
}
|
||||
|
@ -109,13 +111,13 @@ public final class ReadCodesManagerImpl implements ReadCodesManager {
|
|||
if (result == 1 || result == 3) tmp = 1;
|
||||
if (result == 2 || result == 3) mem = 1;
|
||||
LOGGER.debug("DTC: " +
|
||||
query.getLoggerData().getName() +
|
||||
" tmp:" + tmp + " mem:" + mem);
|
||||
query.getLoggerData().getName() +
|
||||
" tmp:" + tmp + " mem:" + mem);
|
||||
dtcSet.add(query);
|
||||
}
|
||||
}
|
||||
if (dtcSet.isEmpty()) {
|
||||
LOGGER.info("Success reading " + target +
|
||||
LOGGER.info("Success reading " + target +
|
||||
" DTC codes, none set");
|
||||
return -1;
|
||||
}
|
||||
|
@ -131,7 +133,7 @@ public final class ReadCodesManagerImpl implements ReadCodesManager {
|
|||
catch (Exception e) {
|
||||
messageListener.reportMessage(
|
||||
"Unable to read " + target + " DTC " +
|
||||
" codes - check correct serial port has been selected," +
|
||||
" codes - check correct serial port has been selected," +
|
||||
" cable is connected and ignition is on.");
|
||||
LOGGER.error("Error reading " + target + " DTC codes", e);
|
||||
|
||||
|
|
|
@ -19,12 +19,14 @@
|
|||
|
||||
package com.romraider.logger.ecu.comms.reset;
|
||||
|
||||
import static com.romraider.logger.ecu.comms.io.connection.LoggerConnectionFactory.getConnection;
|
||||
import static com.romraider.util.ParamChecker.checkNotNull;
|
||||
|
||||
import org.apache.log4j.Logger;
|
||||
|
||||
import com.romraider.Settings;
|
||||
import com.romraider.logger.ecu.comms.io.connection.LoggerConnection;
|
||||
import static com.romraider.logger.ecu.comms.io.connection.LoggerConnectionFactory.getConnection;
|
||||
import com.romraider.logger.ecu.ui.MessageListener;
|
||||
import static com.romraider.util.ParamChecker.checkNotNull;
|
||||
import org.apache.log4j.Logger;
|
||||
|
||||
public final class ResetManagerImpl implements ResetManager {
|
||||
private static final Logger LOGGER = Logger.getLogger(ResetManagerImpl.class);
|
||||
|
@ -37,15 +39,16 @@ public final class ResetManagerImpl implements ResetManager {
|
|||
this.messageListener = messageListener;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean resetEcu() {
|
||||
String target = "ECU";
|
||||
try {
|
||||
LoggerConnection connection = getConnection(Settings.getLoggerProtocol(), settings.getLoggerPort(),
|
||||
LoggerConnection connection = getConnection(settings.getLoggerProtocol(), settings.getLoggerPort(),
|
||||
settings.getLoggerConnectionProperties());
|
||||
try {
|
||||
if (Settings.getDestinationId() == 0x18) target = "TCU";
|
||||
if (settings.getDestinationId() == 0x18) target = "TCU";
|
||||
messageListener.reportMessage("Sending " + target + " Reset...");
|
||||
connection.ecuReset(Settings.getDestinationId());
|
||||
connection.ecuReset(settings.getDestinationId());
|
||||
messageListener.reportMessage("Sending " + target + " Reset...done.");
|
||||
return true;
|
||||
} finally {
|
||||
|
|
|
@ -19,12 +19,8 @@
|
|||
|
||||
package com.romraider.logger.ecu.ui.handler.file;
|
||||
|
||||
import com.romraider.Settings;
|
||||
import com.romraider.logger.ecu.exception.FileLoggerException;
|
||||
import com.romraider.logger.ecu.ui.MessageListener;
|
||||
import com.romraider.util.FormatFilename;
|
||||
|
||||
import static com.romraider.util.ParamChecker.checkNotNull;
|
||||
|
||||
import java.io.BufferedOutputStream;
|
||||
import java.io.File;
|
||||
import java.io.FileOutputStream;
|
||||
|
@ -32,6 +28,12 @@ import java.io.OutputStream;
|
|||
import java.text.SimpleDateFormat;
|
||||
import java.util.Date;
|
||||
|
||||
import com.romraider.Settings;
|
||||
import com.romraider.logger.ecu.exception.FileLoggerException;
|
||||
import com.romraider.logger.ecu.ui.MessageListener;
|
||||
import com.romraider.util.FormatFilename;
|
||||
import com.romraider.util.SettingsManager;
|
||||
|
||||
public final class FileLoggerImpl implements FileLogger {
|
||||
private static final String NEW_LINE = System.getProperty("line.separator");
|
||||
private final SimpleDateFormat dateFormat = new SimpleDateFormat("yyyyMMdd_HHmmss");
|
||||
|
@ -49,6 +51,7 @@ public final class FileLoggerImpl implements FileLogger {
|
|||
this.messageListener = messageListener;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void start() {
|
||||
if (!started) {
|
||||
stop();
|
||||
|
@ -56,8 +59,8 @@ public final class FileLoggerImpl implements FileLogger {
|
|||
String filePath = buildFilePath();
|
||||
os = new BufferedOutputStream(new FileOutputStream(filePath));
|
||||
messageListener.reportMessageInTitleBar(
|
||||
"Started logging to file: " +
|
||||
FormatFilename.getShortName(filePath));
|
||||
"Started logging to file: " +
|
||||
FormatFilename.getShortName(filePath));
|
||||
zero = true;
|
||||
} catch (Exception e) {
|
||||
stop();
|
||||
|
@ -67,6 +70,7 @@ public final class FileLoggerImpl implements FileLogger {
|
|||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void stop() {
|
||||
if (os != null) {
|
||||
try {
|
||||
|
@ -79,10 +83,12 @@ public final class FileLoggerImpl implements FileLogger {
|
|||
started = false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isStarted() {
|
||||
return started;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeHeaders(String headers) {
|
||||
String timeHeader = "Time";
|
||||
if (!settings.isFileLoggingAbsoluteTimestamp()) {
|
||||
|
@ -91,6 +97,7 @@ public final class FileLoggerImpl implements FileLogger {
|
|||
writeText(timeHeader + headers);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeLine(String line, long timestamp) {
|
||||
writeText(prependTimestamp(line, timestamp));
|
||||
}
|
||||
|
@ -124,14 +131,14 @@ public final class FileLoggerImpl implements FileLogger {
|
|||
}
|
||||
|
||||
private String buildFilePath() {
|
||||
String logDir = Settings.getLoggerOutputDirPath();
|
||||
String logDir = SettingsManager.getSettings().getLoggerOutputDirPath();
|
||||
if (!logDir.endsWith(File.separator)) {
|
||||
logDir += File.separator;
|
||||
}
|
||||
logDir += "romraiderlog_";
|
||||
if (settings.getLogfileNameText() != null
|
||||
&& !settings.getLogfileNameText().isEmpty()) {
|
||||
logDir += settings.getLogfileNameText() + "_";
|
||||
logDir += settings.getLogfileNameText() + "_";
|
||||
}
|
||||
logDir += dateFormat.format(new Date()) + ".csv";
|
||||
return logDir;
|
||||
|
|
|
@ -87,10 +87,12 @@ import com.romraider.swing.menubar.Menu;
|
|||
import com.romraider.swing.menubar.MenuItem;
|
||||
import com.romraider.swing.menubar.RadioButtonMenuItem;
|
||||
import com.romraider.swing.menubar.action.AboutAction;
|
||||
import com.romraider.util.SettingsManager;
|
||||
|
||||
public class EcuLoggerMenuBar extends JMenuBar {
|
||||
|
||||
private static final long serialVersionUID = 7081586516953740186L;
|
||||
Settings settings = SettingsManager.getSettings();
|
||||
|
||||
public EcuLoggerMenuBar(EcuLogger logger, List<ExternalDataSource> externalDataSources) {
|
||||
|
||||
|
@ -116,14 +118,14 @@ public class EcuLoggerMenuBar extends JMenuBar {
|
|||
RadioButtonMenuItem fastPoll = new RadioButtonMenuItem("Enable Fast Polling Mode", VK_M, getKeyStroke(VK_M, CTRL_MASK), new FastPollModeAction(logger), logger.getSettings().isFastPoll());
|
||||
fastPoll.setToolTipText("Select to enable faster K-line polling of the ECU");
|
||||
settingsMenu.add(fastPoll);
|
||||
RadioButtonMenuItem canBus = new RadioButtonMenuItem("CAN bus Logging (2007+)", VK_N, getKeyStroke(VK_N, CTRL_MASK), new CanBusModeAction(logger), Settings.isCanBus());
|
||||
RadioButtonMenuItem canBus = new RadioButtonMenuItem("CAN bus Logging (2007+)", VK_N, getKeyStroke(VK_N, CTRL_MASK), new CanBusModeAction(logger), settings.isCanBus());
|
||||
canBus.setToolTipText("Select to enable logging via CAN bus using a J2534 compatible cable");
|
||||
if (isPlatform(WINDOWS)) {
|
||||
settingsMenu.add(canBus);
|
||||
}
|
||||
settingsMenu.add(new JSeparator());
|
||||
settingsMenu.add(new RadioButtonMenuItem("Use Absolute Timestamp In Log File", VK_T, getKeyStroke(VK_T, CTRL_MASK), new LogFileAbsoluteTimestampAction(logger), logger.getSettings().isFileLoggingAbsoluteTimestamp()));
|
||||
final RadioButtonMenuItem numFormat = new RadioButtonMenuItem("Use US English number format in Log File", VK_B, getKeyStroke(VK_B, CTRL_MASK), new LogFileNumberFormatAction(logger), logger.getSettings().isUsNumberFormat());
|
||||
final RadioButtonMenuItem numFormat = new RadioButtonMenuItem("Use US English number format in Log File", VK_B, getKeyStroke(VK_B, CTRL_MASK), new LogFileNumberFormatAction(logger), logger.getSettings().isUsNumberFormat());
|
||||
numFormat.setToolTipText("Select to force log files to be written with . decimal point and , field separator");
|
||||
settingsMenu.add(numFormat);
|
||||
add(settingsMenu);
|
||||
|
|
|
@ -24,6 +24,7 @@ import java.awt.event.ActionEvent;
|
|||
import com.romraider.Settings;
|
||||
import com.romraider.logger.ecu.EcuLogger;
|
||||
import com.romraider.swing.menubar.action.AbstractAction;
|
||||
import com.romraider.util.SettingsManager;
|
||||
|
||||
public final class CanBusModeAction extends AbstractAction {
|
||||
|
||||
|
@ -31,13 +32,16 @@ public final class CanBusModeAction extends AbstractAction {
|
|||
super(logger);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent actionEvent) {
|
||||
try {
|
||||
Settings settings = SettingsManager.getSettings();
|
||||
if ((Boolean) getValue(SELECTED_KEY)) {
|
||||
Settings.setTransportProtocol("ISO15765");
|
||||
|
||||
settings.setTransportProtocol("ISO15765");
|
||||
}
|
||||
else {
|
||||
Settings.setTransportProtocol("ISO9141");
|
||||
settings.setTransportProtocol("ISO9141");
|
||||
}
|
||||
logger.stopLogging();
|
||||
logger.startLogging();
|
||||
|
|
|
@ -32,22 +32,26 @@ import java.awt.event.ActionEvent;
|
|||
import com.romraider.Settings;
|
||||
import com.romraider.logger.ecu.EcuLogger;
|
||||
import com.romraider.swing.menubar.action.AbstractAction;
|
||||
import com.romraider.util.SettingsManager;
|
||||
|
||||
public final class GlobalAdjustmentAction extends AbstractAction {
|
||||
Settings settings = SettingsManager.getSettings();
|
||||
|
||||
public GlobalAdjustmentAction(EcuLogger logger) {
|
||||
super(logger);
|
||||
}
|
||||
|
||||
@Override
|
||||
public final void actionPerformed(ActionEvent actionEvent) {
|
||||
if (showConfirmation() == OK_OPTION) {
|
||||
final String transport = Settings.getTransportProtocol();
|
||||
if (Settings.isCanBus()) {
|
||||
Settings.setTransportProtocol("ISO9141");
|
||||
final String transport = settings.getTransportProtocol();
|
||||
if (settings.isCanBus()) {
|
||||
settings.setTransportProtocol("ISO9141");
|
||||
}
|
||||
final boolean logging = logger.isLogging();
|
||||
if (logging) logger.stopLogging();
|
||||
adjustEcu();
|
||||
Settings.setTransportProtocol(transport);
|
||||
settings.setTransportProtocol(transport);
|
||||
if (logging) logger.startLogging();
|
||||
}
|
||||
}
|
||||
|
@ -71,14 +75,14 @@ public final class GlobalAdjustmentAction extends AbstractAction {
|
|||
else if (result == 0) {
|
||||
showMessageDialog(logger,
|
||||
"Error performing ECU Global Timing or Idle RPM adjustment.\n" +
|
||||
"Check the following:\n" +
|
||||
"* Logger has successfully conencted to the ECU\n" +
|
||||
"* Correct COM port is selected (if not Openport 2)\n" +
|
||||
"* CAN bus logging mode is disabled\n" +
|
||||
"* Cable is connected properly\n* Ignition is ON\n" +
|
||||
"* Logger is stopped\n",
|
||||
"Adjust ECU Global Parameters",
|
||||
ERROR_MESSAGE);
|
||||
"Check the following:\n" +
|
||||
"* Logger has successfully conencted to the ECU\n" +
|
||||
"* Correct COM port is selected (if not Openport 2)\n" +
|
||||
"* CAN bus logging mode is disabled\n" +
|
||||
"* Cable is connected properly\n* Ignition is ON\n" +
|
||||
"* Logger is stopped\n",
|
||||
"Adjust ECU Global Parameters",
|
||||
ERROR_MESSAGE);
|
||||
}
|
||||
if (result == -1) {
|
||||
showMessageDialog(logger,
|
||||
|
|
|
@ -19,24 +19,26 @@
|
|||
|
||||
package com.romraider.logger.ecu.ui.swing.menubar.action;
|
||||
|
||||
import com.romraider.Settings;
|
||||
import com.romraider.logger.ecu.EcuLogger;
|
||||
|
||||
import static com.romraider.logger.ecu.ui.swing.menubar.util.FileHelper.getFile;
|
||||
import static com.romraider.logger.ecu.ui.swing.menubar.util.FileHelper.getProfileFileChooser;
|
||||
import com.romraider.swing.menubar.action.AbstractAction;
|
||||
import com.romraider.util.FormatFilename;
|
||||
|
||||
import javax.swing.JFileChooser;
|
||||
import java.awt.event.ActionEvent;
|
||||
import java.io.File;
|
||||
|
||||
import javax.swing.JFileChooser;
|
||||
|
||||
import com.romraider.logger.ecu.EcuLogger;
|
||||
import com.romraider.swing.menubar.action.AbstractAction;
|
||||
import com.romraider.util.FormatFilename;
|
||||
import com.romraider.util.SettingsManager;
|
||||
|
||||
public final class LoadProfileAction extends AbstractAction {
|
||||
|
||||
public LoadProfileAction(EcuLogger logger) {
|
||||
super(logger);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent actionEvent) {
|
||||
try {
|
||||
loadProfileDialog();
|
||||
|
@ -47,14 +49,14 @@ public final class LoadProfileAction extends AbstractAction {
|
|||
|
||||
private void loadProfileDialog() throws Exception {
|
||||
logger.getSettings();
|
||||
final File lastProfileFile = getFile(Settings.getLoggerProfileFilePath());
|
||||
final File lastProfileFile = getFile(SettingsManager.getSettings().getLoggerProfileFilePath());
|
||||
JFileChooser fc = getProfileFileChooser(lastProfileFile);
|
||||
if (fc.showOpenDialog(logger) == JFileChooser.APPROVE_OPTION) {
|
||||
final String profileFilePath = fc.getSelectedFile().getAbsolutePath();
|
||||
logger.loadUserProfile(profileFilePath);
|
||||
logger.getSettings().setLoggerProfileFilePath(profileFilePath);
|
||||
logger.reportMessageInTitleBar("" +
|
||||
"Profile: " + FormatFilename.getShortName(profileFilePath));
|
||||
"Profile: " + FormatFilename.getShortName(profileFilePath));
|
||||
logger.restartLogging();
|
||||
logger.reportMessage("Profile succesfully loaded: " + profileFilePath);
|
||||
}
|
||||
|
|
|
@ -19,22 +19,26 @@
|
|||
|
||||
package com.romraider.logger.ecu.ui.swing.menubar.action;
|
||||
|
||||
import com.romraider.Settings;
|
||||
import com.romraider.logger.ecu.EcuLogger;
|
||||
import static com.romraider.logger.ecu.ui.swing.menubar.util.FileHelper.getFile;
|
||||
import static com.romraider.logger.ecu.ui.swing.menubar.util.FileHelper.getLoggerOutputDirFileChooser;
|
||||
import com.romraider.swing.menubar.action.AbstractAction;
|
||||
import static javax.swing.JFileChooser.APPROVE_OPTION;
|
||||
import javax.swing.JFileChooser;
|
||||
|
||||
import java.awt.event.ActionEvent;
|
||||
import java.io.File;
|
||||
|
||||
import javax.swing.JFileChooser;
|
||||
|
||||
import com.romraider.logger.ecu.EcuLogger;
|
||||
import com.romraider.swing.menubar.action.AbstractAction;
|
||||
import com.romraider.util.SettingsManager;
|
||||
|
||||
public final class LogFileLocationAction extends AbstractAction {
|
||||
|
||||
public LogFileLocationAction(EcuLogger logger) {
|
||||
super(logger);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent actionEvent) {
|
||||
try {
|
||||
setLogFileLocationDialog();
|
||||
|
@ -44,7 +48,7 @@ public final class LogFileLocationAction extends AbstractAction {
|
|||
}
|
||||
|
||||
private void setLogFileLocationDialog() throws Exception {
|
||||
File lastLoggerOutputDir = getFile(Settings.getLoggerOutputDirPath());
|
||||
File lastLoggerOutputDir = getFile(SettingsManager.getSettings().getLoggerOutputDirPath());
|
||||
JFileChooser fc = getLoggerOutputDirFileChooser(lastLoggerOutputDir);
|
||||
if (fc.showOpenDialog(logger) == APPROVE_OPTION) {
|
||||
String loggerOutputDirPath = fc.getSelectedFile().getAbsolutePath();
|
||||
|
|
|
@ -19,22 +19,26 @@
|
|||
|
||||
package com.romraider.logger.ecu.ui.swing.menubar.action;
|
||||
|
||||
import com.romraider.Settings;
|
||||
import com.romraider.logger.ecu.EcuLogger;
|
||||
import static com.romraider.logger.ecu.ui.swing.menubar.util.FileHelper.getDefinitionFileChooser;
|
||||
import static com.romraider.logger.ecu.ui.swing.menubar.util.FileHelper.getFile;
|
||||
import com.romraider.swing.menubar.action.AbstractAction;
|
||||
import static javax.swing.JFileChooser.APPROVE_OPTION;
|
||||
import javax.swing.JFileChooser;
|
||||
|
||||
import java.awt.event.ActionEvent;
|
||||
import java.io.File;
|
||||
|
||||
import javax.swing.JFileChooser;
|
||||
|
||||
import com.romraider.logger.ecu.EcuLogger;
|
||||
import com.romraider.swing.menubar.action.AbstractAction;
|
||||
import com.romraider.util.SettingsManager;
|
||||
|
||||
public final class LoggerDefinitionLocationAction extends AbstractAction {
|
||||
|
||||
public LoggerDefinitionLocationAction(EcuLogger logger) {
|
||||
super(logger);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent actionEvent) {
|
||||
try {
|
||||
setDefinitionLocationDialog();
|
||||
|
@ -46,7 +50,7 @@ public final class LoggerDefinitionLocationAction extends AbstractAction {
|
|||
|
||||
private void setDefinitionLocationDialog() throws Exception {
|
||||
logger.getSettings();
|
||||
File lastConfigPath = getFile(Settings.getLoggerDefinitionFilePath());
|
||||
File lastConfigPath = getFile(SettingsManager.getSettings().getLoggerDefinitionFilePath());
|
||||
JFileChooser fc = getDefinitionFileChooser(lastConfigPath);
|
||||
if (fc.showOpenDialog(logger) == APPROVE_OPTION) {
|
||||
String path = fc.getSelectedFile().getAbsolutePath();
|
||||
|
|
|
@ -19,10 +19,11 @@
|
|||
|
||||
package com.romraider.logger.ecu.ui.swing.menubar.action;
|
||||
|
||||
import com.romraider.Settings;
|
||||
import java.awt.event.ActionEvent;
|
||||
|
||||
import com.romraider.logger.ecu.EcuLogger;
|
||||
import com.romraider.swing.menubar.action.AbstractAction;
|
||||
import java.awt.event.ActionEvent;
|
||||
import com.romraider.util.SettingsManager;
|
||||
|
||||
public final class ReloadProfileAction extends AbstractAction {
|
||||
|
||||
|
@ -30,10 +31,11 @@ public final class ReloadProfileAction extends AbstractAction {
|
|||
super(logger);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent actionEvent) {
|
||||
try {
|
||||
logger.getSettings();
|
||||
logger.loadUserProfile(Settings.getLoggerProfileFilePath());
|
||||
logger.loadUserProfile(SettingsManager.getSettings().getLoggerProfileFilePath());
|
||||
} catch (Exception e) {
|
||||
logger.reportError(e);
|
||||
}
|
||||
|
|
|
@ -19,19 +19,22 @@
|
|||
|
||||
package com.romraider.logger.ecu.ui.swing.menubar.action;
|
||||
|
||||
import com.romraider.Settings;
|
||||
import com.romraider.logger.ecu.EcuLogger;
|
||||
import static com.romraider.logger.ecu.ui.swing.menubar.util.FileHelper.saveProfileToFile;
|
||||
import com.romraider.swing.menubar.action.AbstractAction;
|
||||
|
||||
import java.awt.event.ActionEvent;
|
||||
import java.io.File;
|
||||
|
||||
import com.romraider.logger.ecu.EcuLogger;
|
||||
import com.romraider.swing.menubar.action.AbstractAction;
|
||||
import com.romraider.util.SettingsManager;
|
||||
|
||||
public final class SaveProfileAction extends AbstractAction {
|
||||
|
||||
public SaveProfileAction(EcuLogger logger) {
|
||||
super(logger);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent actionEvent) {
|
||||
try {
|
||||
saveProfile();
|
||||
|
@ -42,7 +45,7 @@ public final class SaveProfileAction extends AbstractAction {
|
|||
|
||||
private void saveProfile() throws Exception {
|
||||
logger.getSettings();
|
||||
File lastProfileFile = new File(Settings.getLoggerProfileFilePath());
|
||||
File lastProfileFile = new File(SettingsManager.getSettings().getLoggerProfileFilePath());
|
||||
String profileFilePath = saveProfileToFile(logger.getCurrentProfile(), lastProfileFile);
|
||||
logger.getSettings().setLoggerProfileFilePath(profileFilePath);
|
||||
logger.reportMessageInTitleBar("Profile: " + profileFilePath);
|
||||
|
|
|
@ -19,25 +19,29 @@
|
|||
|
||||
package com.romraider.logger.ecu.ui.swing.menubar.action;
|
||||
|
||||
import com.romraider.Settings;
|
||||
import com.romraider.logger.ecu.EcuLogger;
|
||||
import static com.romraider.logger.ecu.ui.swing.menubar.util.FileHelper.getFile;
|
||||
import static com.romraider.logger.ecu.ui.swing.menubar.util.FileHelper.getProfileFileChooser;
|
||||
import static com.romraider.logger.ecu.ui.swing.menubar.util.FileHelper.saveProfileToFile;
|
||||
import com.romraider.swing.menubar.action.AbstractAction;
|
||||
import static javax.swing.JFileChooser.APPROVE_OPTION;
|
||||
import static javax.swing.JOptionPane.OK_OPTION;
|
||||
import static javax.swing.JOptionPane.showConfirmDialog;
|
||||
import javax.swing.JFileChooser;
|
||||
|
||||
import java.awt.event.ActionEvent;
|
||||
import java.io.File;
|
||||
|
||||
import javax.swing.JFileChooser;
|
||||
|
||||
import com.romraider.logger.ecu.EcuLogger;
|
||||
import com.romraider.swing.menubar.action.AbstractAction;
|
||||
import com.romraider.util.SettingsManager;
|
||||
|
||||
public final class SaveProfileAsAction extends AbstractAction {
|
||||
|
||||
public SaveProfileAsAction(EcuLogger logger) {
|
||||
super(logger);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent actionEvent) {
|
||||
try {
|
||||
saveProfileAs();
|
||||
|
@ -48,7 +52,7 @@ public final class SaveProfileAsAction extends AbstractAction {
|
|||
|
||||
private void saveProfileAs() throws Exception {
|
||||
logger.getSettings();
|
||||
File lastProfileFile = getFile(Settings.getLoggerProfileFilePath());
|
||||
File lastProfileFile = getFile(SettingsManager.getSettings().getLoggerProfileFilePath());
|
||||
JFileChooser fc = getProfileFileChooser(lastProfileFile);
|
||||
if (fc.showSaveDialog(logger) == APPROVE_OPTION) {
|
||||
File selectedFile = fc.getSelectedFile();
|
||||
|
|
|
@ -47,9 +47,9 @@ import javax.swing.JTable;
|
|||
import javax.swing.table.JTableHeader;
|
||||
import javax.swing.table.TableColumn;
|
||||
|
||||
import com.romraider.Settings;
|
||||
import com.romraider.logger.ecu.EcuLogger;
|
||||
import com.romraider.logger.ecu.comms.query.EcuQuery;
|
||||
import com.romraider.util.SettingsManager;
|
||||
import com.romraider.logger.ecu.ui.swing.tools.tablemodels.ReadCodesTableModel;
|
||||
|
||||
public final class ReadCodesResultsPanel extends JPanel {
|
||||
|
@ -59,7 +59,7 @@ public final class ReadCodesResultsPanel extends JPanel {
|
|||
|
||||
private ReadCodesResultsPanel(ArrayList<EcuQuery> dtcSet) {
|
||||
super(new GridLayout(1,0));
|
||||
|
||||
|
||||
final ReadCodesTableModel dtcModel = new ReadCodesTableModel();
|
||||
dtcModel.setDtcList(dtcSet);
|
||||
final JTable table = new JTable(dtcModel);
|
||||
|
@ -83,9 +83,9 @@ public final class ReadCodesResultsPanel extends JPanel {
|
|||
final JTableHeader th = table.getTableHeader();
|
||||
final Font thFont = th.getFont();
|
||||
final Font thBoldFont = new Font(
|
||||
thFont.getFamily(),
|
||||
Font.BOLD,
|
||||
thFont.getSize());
|
||||
thFont.getFamily(),
|
||||
Font.BOLD,
|
||||
thFont.getSize());
|
||||
th.setFont(thBoldFont);
|
||||
resultsPanel.add(th, BorderLayout.PAGE_START);
|
||||
resultsPanel.add(table, BorderLayout.CENTER);
|
||||
|
@ -93,14 +93,14 @@ public final class ReadCodesResultsPanel extends JPanel {
|
|||
}
|
||||
|
||||
public final static void displayResultsPane(
|
||||
EcuLogger logger,
|
||||
ArrayList<EcuQuery> dtcSet) {
|
||||
EcuLogger logger,
|
||||
ArrayList<EcuQuery> dtcSet) {
|
||||
final JDialog frame = new JDialog(logger, "Diagnostic Code Read Results");
|
||||
frame.setDefaultCloseOperation(JDialog.DISPOSE_ON_CLOSE);
|
||||
final JPanel mainPanel = new JPanel();
|
||||
mainPanel.setLayout(new BoxLayout(mainPanel, BoxLayout.PAGE_AXIS));
|
||||
mainPanel.setOpaque(true);
|
||||
final ReadCodesResultsPanel resultsPane =
|
||||
final ReadCodesResultsPanel resultsPane =
|
||||
new ReadCodesResultsPanel(dtcSet);
|
||||
mainPanel.add(resultsPane);
|
||||
mainPanel.add(createSaveReultsPanel(dtcSet));
|
||||
|
@ -118,13 +118,13 @@ public final class ReadCodesResultsPanel extends JPanel {
|
|||
|
||||
private final static JPanel createSaveReultsPanel(
|
||||
final ArrayList<EcuQuery> dtcSet) {
|
||||
|
||||
|
||||
final JPanel basePanel = new JPanel(new BorderLayout());
|
||||
basePanel.setBorder(BorderFactory.createTitledBorder("Save Results"));
|
||||
|
||||
|
||||
final JLabel comment = new JLabel();
|
||||
comment.setText("Click table, press Ctrl-A then Ctrl-C to copy " +
|
||||
"table to clipboard, or...");
|
||||
"table to clipboard, or...");
|
||||
|
||||
final JPanel controlPanel = new JPanel();
|
||||
final JButton toFile = new JButton("Save to File");
|
||||
|
@ -155,7 +155,7 @@ public final class ReadCodesResultsPanel extends JPanel {
|
|||
private static final void saveTableText(ArrayList<EcuQuery> dtcSet) {
|
||||
final String nowStr = String.format(DT_FORMAT, System.currentTimeMillis());
|
||||
final String fileName = String.format("%s%sromraiderDTC_%s.csv",
|
||||
Settings.getLoggerOutputDirPath(),
|
||||
SettingsManager.getSettings().getLoggerOutputDirPath(),
|
||||
File.separator,
|
||||
nowStr);
|
||||
try {
|
||||
|
@ -172,19 +172,19 @@ public final class ReadCodesResultsPanel extends JPanel {
|
|||
if (result == 1 || result == 3) tmp = "true";
|
||||
if (result == 2 || result == 3) mem = "true";
|
||||
bw.append(query.getLoggerData().getName() + "," +
|
||||
tmp + "," +
|
||||
mem + eol);
|
||||
tmp + "," +
|
||||
mem + eol);
|
||||
}
|
||||
bw.close();
|
||||
showMessageDialog(
|
||||
null,
|
||||
null,
|
||||
"Table text saved to: " + fileName,
|
||||
"Save Success",
|
||||
INFORMATION_MESSAGE);
|
||||
}
|
||||
catch (Exception e) {
|
||||
showMessageDialog(
|
||||
null,
|
||||
null,
|
||||
"Failed to save table, check path:\n" + fileName,
|
||||
"Save Failed",
|
||||
ERROR_MESSAGE);
|
||||
|
@ -193,13 +193,13 @@ public final class ReadCodesResultsPanel extends JPanel {
|
|||
|
||||
private static final void saveTableImage() {
|
||||
final BufferedImage resultsImage = new BufferedImage(
|
||||
resultsPanel.getWidth(),
|
||||
resultsPanel.getHeight(),
|
||||
resultsPanel.getWidth(),
|
||||
resultsPanel.getHeight(),
|
||||
BufferedImage.TYPE_INT_ARGB);
|
||||
resultsPanel.paint(resultsImage.createGraphics());
|
||||
final String nowStr = String.format(DT_FORMAT, System.currentTimeMillis());
|
||||
final String fileName = String.format("%s%sromraiderDTC_%s.png",
|
||||
Settings.getLoggerOutputDirPath(),
|
||||
SettingsManager.getSettings().getLoggerOutputDirPath(),
|
||||
File.separator,
|
||||
nowStr);
|
||||
try {
|
||||
|
@ -209,14 +209,14 @@ public final class ReadCodesResultsPanel extends JPanel {
|
|||
"png",
|
||||
imageFile);
|
||||
showMessageDialog(
|
||||
null,
|
||||
null,
|
||||
"Table image saved to: " + fileName,
|
||||
"Save Success",
|
||||
INFORMATION_MESSAGE);
|
||||
}
|
||||
catch (Exception e) {
|
||||
showMessageDialog(
|
||||
null,
|
||||
null,
|
||||
"Failed to save image, check path:\n" + fileName,
|
||||
"Save Failed",
|
||||
ERROR_MESSAGE);
|
||||
|
|
|
@ -21,15 +21,6 @@ package com.romraider.logger.ecu.ui.tab.dyno;
|
|||
|
||||
import static com.centerkey.utils.BareBonesBrowserLaunch.openURL;
|
||||
import static com.romraider.Version.CARS_DEFS_URL;
|
||||
|
||||
import com.romraider.Settings;
|
||||
import com.romraider.editor.ecu.ECUEditor;
|
||||
import com.romraider.logger.ecu.definition.EcuDataConvertor;
|
||||
import com.romraider.logger.ecu.definition.EcuParameter;
|
||||
import com.romraider.logger.ecu.definition.EcuSwitch;
|
||||
import com.romraider.logger.ecu.definition.ExternalData;
|
||||
import com.romraider.logger.ecu.definition.LoggerData;
|
||||
import com.romraider.logger.ecu.ui.DataRegistrationBroker;
|
||||
import static com.romraider.logger.car.util.SpeedCalculator.calculateMph;
|
||||
import static com.romraider.logger.car.util.SpeedCalculator.calculateRpm;
|
||||
import static com.romraider.logger.car.util.TorqueCalculator.calculateTorque;
|
||||
|
@ -42,29 +33,7 @@ import static javax.swing.JOptionPane.ERROR_MESSAGE;
|
|||
import static javax.swing.JOptionPane.WARNING_MESSAGE;
|
||||
import static javax.swing.JOptionPane.showMessageDialog;
|
||||
import static javax.swing.JOptionPane.showOptionDialog;
|
||||
import org.apache.log4j.Logger;
|
||||
import org.w3c.dom.Document;
|
||||
import org.w3c.dom.Element;
|
||||
import org.w3c.dom.Node;
|
||||
import org.w3c.dom.NodeList;
|
||||
import org.xml.sax.SAXException;
|
||||
import org.xml.sax.SAXParseException;
|
||||
import javax.swing.ButtonGroup;
|
||||
import javax.swing.DefaultComboBoxModel;
|
||||
import javax.swing.JButton;
|
||||
import javax.swing.JCheckBox;
|
||||
import javax.swing.JComboBox;
|
||||
import javax.swing.JComponent;
|
||||
import javax.swing.JFileChooser;
|
||||
import javax.swing.JLabel;
|
||||
import javax.swing.JPanel;
|
||||
import javax.swing.JRadioButton;
|
||||
import javax.swing.JTextField;
|
||||
import javax.swing.JToggleButton;
|
||||
import javax.swing.border.TitledBorder;
|
||||
import javax.swing.text.JTextComponent;
|
||||
import javax.xml.parsers.DocumentBuilder;
|
||||
import javax.xml.parsers.DocumentBuilderFactory;
|
||||
|
||||
import java.awt.Component;
|
||||
import java.awt.GridBagConstraints;
|
||||
import java.awt.GridBagLayout;
|
||||
|
@ -83,6 +52,41 @@ import java.util.ArrayList;
|
|||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
import javax.swing.ButtonGroup;
|
||||
import javax.swing.DefaultComboBoxModel;
|
||||
import javax.swing.JButton;
|
||||
import javax.swing.JCheckBox;
|
||||
import javax.swing.JComboBox;
|
||||
import javax.swing.JComponent;
|
||||
import javax.swing.JFileChooser;
|
||||
import javax.swing.JLabel;
|
||||
import javax.swing.JPanel;
|
||||
import javax.swing.JRadioButton;
|
||||
import javax.swing.JTextField;
|
||||
import javax.swing.JToggleButton;
|
||||
import javax.swing.border.TitledBorder;
|
||||
import javax.swing.text.JTextComponent;
|
||||
import javax.xml.parsers.DocumentBuilder;
|
||||
import javax.xml.parsers.DocumentBuilderFactory;
|
||||
|
||||
import org.apache.log4j.Logger;
|
||||
import org.w3c.dom.Document;
|
||||
import org.w3c.dom.Element;
|
||||
import org.w3c.dom.Node;
|
||||
import org.w3c.dom.NodeList;
|
||||
import org.xml.sax.SAXException;
|
||||
import org.xml.sax.SAXParseException;
|
||||
|
||||
import com.romraider.Settings;
|
||||
import com.romraider.editor.ecu.ECUEditor;
|
||||
import com.romraider.logger.ecu.definition.EcuDataConvertor;
|
||||
import com.romraider.logger.ecu.definition.EcuParameter;
|
||||
import com.romraider.logger.ecu.definition.EcuSwitch;
|
||||
import com.romraider.logger.ecu.definition.ExternalData;
|
||||
import com.romraider.logger.ecu.definition.LoggerData;
|
||||
import com.romraider.logger.ecu.ui.DataRegistrationBroker;
|
||||
import com.romraider.util.SettingsManager;
|
||||
|
||||
public final class DynoControlPanel extends JPanel {
|
||||
private static final long serialVersionUID = 3787020251963102201L;
|
||||
private static final Logger LOGGER = Logger.getLogger(DynoControlPanel.class);
|
||||
|
@ -217,7 +221,7 @@ public final class DynoControlPanel extends JPanel {
|
|||
// private String tqUnits = "lbf-ft";
|
||||
private double distance;
|
||||
private long lastET;
|
||||
private double[] etResults = new double[12];
|
||||
private final double[] etResults = new double[12];
|
||||
|
||||
private final JPanel filterPanel = new JPanel();
|
||||
private final JPanel unitsPanel = new JPanel();
|
||||
|
@ -257,16 +261,16 @@ public final class DynoControlPanel extends JPanel {
|
|||
mass = (parseDouble(carMass) + parseDouble(deltaMass)); //kg
|
||||
pressure = atm * 1000; // [Pa] = [kPa] * 1000
|
||||
}
|
||||
// if (units.equals(SI)) {
|
||||
// altitude = parseDouble(elevation); // meters
|
||||
// airTemp = parseDouble(ambTemp); //[K]
|
||||
// mass = (parseDouble(carMass) + parseDouble(deltaMass)); //kg
|
||||
// }
|
||||
// if (units.equals(SI)) {
|
||||
// altitude = parseDouble(elevation); // meters
|
||||
// airTemp = parseDouble(ambTemp); //[K]
|
||||
// mass = (parseDouble(carMass) + parseDouble(deltaMass)); //kg
|
||||
// }
|
||||
tSize = parseDouble(tireSize) + parseDouble(tireWidth) / 25.4 * parseDouble(tireAspect) / 100 * 2;
|
||||
rpm2mph = parseDouble(gearRatio) * parseDouble(finalRatio) / (tSize * 0.002975);
|
||||
humidity = parseDouble(relHumid) / 100;
|
||||
// carInfo = (String) carSelectBox.getSelectedItem() + "(" + gearSelectBox.getSelectedItem() + "), Pres: " + pressText +
|
||||
// pressUnits + ", Hum: " + relHumid.getText().trim() + "%, Temp: " + ambTemp.getText().trim() + tempUnits;
|
||||
// carInfo = (String) carSelectBox.getSelectedItem() + "(" + gearSelectBox.getSelectedItem() + "), Pres: " + pressText +
|
||||
// pressUnits + ", Hum: " + relHumid.getText().trim() + "%, Temp: " + ambTemp.getText().trim() + tempUnits;
|
||||
// Use elevation if ATM was not read from ECU
|
||||
if (atm == 0) {
|
||||
pressure = 101325 * Math.pow((1 - 22.5577 * Math.pow(10, -6) * altitude), 5.25578); //Pressure at altitude [Pa]
|
||||
|
@ -347,7 +351,7 @@ public final class DynoControlPanel extends JPanel {
|
|||
elevation.setText(String.format("%1.0f", altitude));
|
||||
}
|
||||
// disable user input if ECU parameters recorded
|
||||
// ambTemp.setEnabled(false);
|
||||
// ambTemp.setEnabled(false);
|
||||
elevation.setEnabled(false);
|
||||
calculateEnv();
|
||||
updateChart();
|
||||
|
@ -508,7 +512,7 @@ public final class DynoControlPanel extends JPanel {
|
|||
|
||||
public boolean isValidET(long now, double vs) {
|
||||
try {
|
||||
// LOGGER.trace("lastET: " + lastET + " now: " + now + " VS: " + vs);
|
||||
// LOGGER.trace("lastET: " + lastET + " now: " + now + " VS: " + vs);
|
||||
if (vs > 0) {
|
||||
if (vsLogUnits.equals(LOG_VS_M)) vs = (vs / KPH_2_MPH);
|
||||
distance = distance + (vs * 5280 / 3600 * (now - lastET) / 1000);
|
||||
|
@ -574,7 +578,7 @@ public final class DynoControlPanel extends JPanel {
|
|||
add(panel, gridBagLayout, buildRadioPanel(), 0, 2, 1, HORIZONTAL);
|
||||
add(panel, gridBagLayout, buildInterpolatePanel(), 0, 3, 1, HORIZONTAL);
|
||||
add(panel, gridBagLayout, buildReferencePanel(), 0, 4, 1, HORIZONTAL);
|
||||
// add(panel, gridBagLayout, buildEtPanel(), 0, 5, 1, HORIZONTAL);
|
||||
// add(panel, gridBagLayout, buildEtPanel(), 0, 5, 1, HORIZONTAL);
|
||||
add(panel);
|
||||
}
|
||||
|
||||
|
@ -586,7 +590,7 @@ public final class DynoControlPanel extends JPanel {
|
|||
}
|
||||
|
||||
private JPanel buildRadioPanel() {
|
||||
// JPanel panel = new JPanel();
|
||||
// JPanel panel = new JPanel();
|
||||
unitsPanel.setBorder(new TitledBorder("Measurement Units"));
|
||||
|
||||
GridBagLayout gridBagLayout = new GridBagLayout();
|
||||
|
@ -680,9 +684,9 @@ public final class DynoControlPanel extends JPanel {
|
|||
addComponent(filterPanel, gridBagLayout, recordButton, 31);
|
||||
addComponent(filterPanel, gridBagLayout, buildLoadFileCB(), 32);
|
||||
addComponent(filterPanel, gridBagLayout, buildResetButton(), 33);
|
||||
// addLabeledComponent(panel, gridBagLayout, "Drag Coeff", dragCoeff, 33);
|
||||
// addLabeledComponent(panel, gridBagLayout, "Frontal Area", frontalArea, 36);
|
||||
// addLabeledComponent(panel, gridBagLayout, "Rolling Resist Coeff", rollCoeff, 39);
|
||||
// addLabeledComponent(panel, gridBagLayout, "Drag Coeff", dragCoeff, 33);
|
||||
// addLabeledComponent(panel, gridBagLayout, "Frontal Area", frontalArea, 36);
|
||||
// addLabeledComponent(panel, gridBagLayout, "Rolling Resist Coeff", rollCoeff, 39);
|
||||
setSelectAllFieldText(tireWidth);
|
||||
setSelectAllFieldText(tireAspect);
|
||||
setSelectAllFieldText(tireSize);
|
||||
|
@ -713,6 +717,7 @@ public final class DynoControlPanel extends JPanel {
|
|||
private JButton buildResetButton() {
|
||||
JButton resetButton = new JButton("Clear Data");
|
||||
resetButton.addActionListener(new ActionListener() {
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent actionEvent) {
|
||||
chartPanel.clear();
|
||||
parent.repaint();
|
||||
|
@ -725,6 +730,7 @@ public final class DynoControlPanel extends JPanel {
|
|||
private JToggleButton buildRecordDataButton() {
|
||||
if (!carTypeArr[0].trim().equals(MISSING_CAR_DEF)) {
|
||||
recordDataButton.addActionListener(new ActionListener() {
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent actionEvent) {
|
||||
elevation.setEnabled(true);
|
||||
if (dButton.isSelected()) {
|
||||
|
@ -777,6 +783,7 @@ public final class DynoControlPanel extends JPanel {
|
|||
|
||||
private JCheckBox buildLoadFileCB() {
|
||||
loadFileCB.addActionListener(new ActionListener() {
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent actionEvent) {
|
||||
if (loadFileCB.isSelected()) {
|
||||
recordDataButton.setText("Read From File");
|
||||
|
@ -799,6 +806,7 @@ public final class DynoControlPanel extends JPanel {
|
|||
|
||||
private void buildModeButtons(JPanel panel) {
|
||||
dButton.addActionListener(new ActionListener() {
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent actionEvent) {
|
||||
chartPanel.setDyno();
|
||||
if (loadFileCB.isSelected()) {
|
||||
|
@ -806,25 +814,26 @@ public final class DynoControlPanel extends JPanel {
|
|||
} else {
|
||||
recordDataButton.setText("Record Data");
|
||||
}
|
||||
// etPanel.setVisible(false);
|
||||
// filterPanel.setVisible(true);
|
||||
// etPanel.setVisible(false);
|
||||
// filterPanel.setVisible(true);
|
||||
unitsPanel.setVisible(true);
|
||||
iPanel.setVisible(true);
|
||||
// refPanel.setVisible(true);
|
||||
// refPanel.setVisible(true);
|
||||
parent.repaint();
|
||||
}
|
||||
});
|
||||
dButton.setSelected(true);
|
||||
|
||||
eButton.addActionListener(new ActionListener() {
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent actionEvent) {
|
||||
chartPanel.setET();
|
||||
recordDataButton.setText("Record ET");
|
||||
// filterPanel.setVisible(false);
|
||||
// filterPanel.setVisible(false);
|
||||
unitsPanel.setVisible(false);
|
||||
iPanel.setVisible(false);
|
||||
// refPanel.setVisible(false);
|
||||
// etPanel.setVisible(true);
|
||||
// refPanel.setVisible(false);
|
||||
// etPanel.setVisible(true);
|
||||
parent.repaint();
|
||||
}
|
||||
});
|
||||
|
@ -838,37 +847,39 @@ public final class DynoControlPanel extends JPanel {
|
|||
|
||||
private void buildRadioButtons(JPanel panel) {
|
||||
iButton.addActionListener(new ActionListener() {
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent actionEvent) {
|
||||
buttonAction(iButton);
|
||||
}
|
||||
});
|
||||
// iButton.setActionCommand(IMPERIAL);
|
||||
// iButton.setActionCommand(IMPERIAL);
|
||||
iButton.setSelected(true);
|
||||
|
||||
mButton.addActionListener(new ActionListener() {
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent actionEvent) {
|
||||
buttonAction(mButton);
|
||||
}
|
||||
});
|
||||
// mButton.setActionCommand(METRIC);
|
||||
// mButton.setActionCommand(METRIC);
|
||||
|
||||
// final JRadioButton sButton = new JRadioButton(SI);
|
||||
// sButton.addActionListener(new ActionListener() {
|
||||
// public void actionPerformed(ActionEvent actionEvent) {
|
||||
// buttonAction(sButton);
|
||||
// }
|
||||
// });
|
||||
// sButton.setActionCommand(SI);
|
||||
// final JRadioButton sButton = new JRadioButton(SI);
|
||||
// sButton.addActionListener(new ActionListener() {
|
||||
// public void actionPerformed(ActionEvent actionEvent) {
|
||||
// buttonAction(sButton);
|
||||
// }
|
||||
// });
|
||||
// sButton.setActionCommand(SI);
|
||||
|
||||
//Group the radio buttons.
|
||||
ButtonGroup group = new ButtonGroup();
|
||||
group.add(iButton);
|
||||
group.add(mButton);
|
||||
// group.add(sButton);
|
||||
// group.add(sButton);
|
||||
|
||||
panel.add(iButton);
|
||||
panel.add(mButton);
|
||||
// panel.add(sButton);
|
||||
// panel.add(sButton);
|
||||
|
||||
}
|
||||
|
||||
|
@ -887,16 +898,16 @@ public final class DynoControlPanel extends JPanel {
|
|||
elevation.setText(String.format("%1.0f", result));
|
||||
atm = atm / 6.89475728;
|
||||
}
|
||||
// if (preUnits.equals(SI)){
|
||||
// result = parseDouble(ambTemp)* 9/5 - 459.67;
|
||||
// ambTemp.setText(String.format("%1.0f", result));
|
||||
// result = parseDouble(carMass) / 0.4536;
|
||||
// carMass.setText(String.format("%1.0f", result));
|
||||
// result = parseDouble(deltaMass) / 0.4536;
|
||||
// deltaMass.setText(String.format("%1.0f", result));
|
||||
// result = parseDouble(elevation) / 0.3048;
|
||||
// elevation.setText(String.format("%1.0f", result));
|
||||
// }
|
||||
// if (preUnits.equals(SI)){
|
||||
// result = parseDouble(ambTemp)* 9/5 - 459.67;
|
||||
// ambTemp.setText(String.format("%1.0f", result));
|
||||
// result = parseDouble(carMass) / 0.4536;
|
||||
// carMass.setText(String.format("%1.0f", result));
|
||||
// result = parseDouble(deltaMass) / 0.4536;
|
||||
// deltaMass.setText(String.format("%1.0f", result));
|
||||
// result = parseDouble(elevation) / 0.3048;
|
||||
// elevation.setText(String.format("%1.0f", result));
|
||||
// }
|
||||
preUnits = IMPERIAL;
|
||||
elevUnits = "ft";
|
||||
tempUnits = "\u00b0F";
|
||||
|
@ -919,10 +930,10 @@ public final class DynoControlPanel extends JPanel {
|
|||
elevation.setText(String.format("%1.0f", result));
|
||||
atm = atm * 6.89475728;
|
||||
}
|
||||
// if (preUnits.equals(SI)){
|
||||
// result = parseDouble(ambTemp) - 273.15;
|
||||
// ambTemp.setText(String.format("%1.1f", result));
|
||||
// }
|
||||
// if (preUnits.equals(SI)){
|
||||
// result = parseDouble(ambTemp) - 273.15;
|
||||
// ambTemp.setText(String.format("%1.1f", result));
|
||||
// }
|
||||
preUnits = METRIC;
|
||||
elevUnits = "m";
|
||||
tempUnits = "\u00b0C";
|
||||
|
@ -933,30 +944,30 @@ public final class DynoControlPanel extends JPanel {
|
|||
pressText = String.format("%1.2f", atm);
|
||||
pressUnits = "kPa";
|
||||
}
|
||||
// if (units.equals(SI)) {
|
||||
// if (preUnits.equals(IMPERIAL)){
|
||||
// result = (parseDouble(ambTemp) + 459.67) * 5/9;
|
||||
// ambTemp.setText(String.format("%1.1f", result));
|
||||
// result = parseDouble(carMass) * 0.4536;
|
||||
// carMass.setText(String.format("%1.0f", result));
|
||||
// LOGGER.trace("units selcted: " + units + " result: " + result);
|
||||
// result = parseDouble(deltaMass) * 0.4536;
|
||||
// deltaMass.setText(String.format("%1.0f", result));
|
||||
// result = parseDouble(elevation) * 0.3048;
|
||||
// elevation.setText(String.format("%1.0f", result));
|
||||
// }
|
||||
// if (preUnits.equals(METRIC)){
|
||||
// result = parseDouble(ambTemp) + 273.15;
|
||||
// ambTemp.setText(String.format("%1.1f", result));
|
||||
// }
|
||||
// preUnits = SI;
|
||||
// elevUnits = "m";
|
||||
// tempUnits = "K";
|
||||
// elevLabel.setText("Elevation (m)");
|
||||
// tempLabel.setText("Air Temperature (K)");
|
||||
// deltaMassLabel.setText("Delta Weight (kg)");
|
||||
// carMassLabel.setText("Base Weight (kg)");
|
||||
// }
|
||||
// if (units.equals(SI)) {
|
||||
// if (preUnits.equals(IMPERIAL)){
|
||||
// result = (parseDouble(ambTemp) + 459.67) * 5/9;
|
||||
// ambTemp.setText(String.format("%1.1f", result));
|
||||
// result = parseDouble(carMass) * 0.4536;
|
||||
// carMass.setText(String.format("%1.0f", result));
|
||||
// LOGGER.trace("units selcted: " + units + " result: " + result);
|
||||
// result = parseDouble(deltaMass) * 0.4536;
|
||||
// deltaMass.setText(String.format("%1.0f", result));
|
||||
// result = parseDouble(elevation) * 0.3048;
|
||||
// elevation.setText(String.format("%1.0f", result));
|
||||
// }
|
||||
// if (preUnits.equals(METRIC)){
|
||||
// result = parseDouble(ambTemp) + 273.15;
|
||||
// ambTemp.setText(String.format("%1.1f", result));
|
||||
// }
|
||||
// preUnits = SI;
|
||||
// elevUnits = "m";
|
||||
// tempUnits = "K";
|
||||
// elevLabel.setText("Elevation (m)");
|
||||
// tempLabel.setText("Air Temperature (K)");
|
||||
// deltaMassLabel.setText("Delta Weight (kg)");
|
||||
// carMassLabel.setText("Base Weight (kg)");
|
||||
// }
|
||||
if (resultStrings[0] != null) interpolateButton.doClick();
|
||||
LOGGER.info("DYNO Measurement units selected: " + units);
|
||||
}
|
||||
|
@ -1022,9 +1033,9 @@ public final class DynoControlPanel extends JPanel {
|
|||
if (headers[x].contains(LOG_VS_I)) vsLogUnits = LOG_VS_I;
|
||||
if (headers[x].contains(LOG_VS_M)) vsLogUnits = LOG_VS_M;
|
||||
}
|
||||
LOGGER.trace("DYNO log file conversions: Time Column: " + timeCol + "; Time X: " + timeMult +
|
||||
"; RPM Column: " + rpmCol + "; TA Column: " + taCol + "; VS Column: " + vsCol +
|
||||
"; VS units: " + vsLogUnits);
|
||||
LOGGER.trace("DYNO log file conversions: Time Column: " + timeCol + "; Time X: " + timeMult +
|
||||
"; RPM Column: " + rpmCol + "; TA Column: " + taCol + "; VS Column: " + vsCol +
|
||||
"; VS units: " + vsLogUnits);
|
||||
while ((line = inputStream.readLine()) != null) {
|
||||
String[] values = line.split(delimiter);
|
||||
if (Double.parseDouble(values[taCol]) > 98) {
|
||||
|
@ -1083,6 +1094,7 @@ public final class DynoControlPanel extends JPanel {
|
|||
final JButton openButton = new JButton("Open");
|
||||
|
||||
openButton.addActionListener(new ActionListener() {
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent actionEvent) {
|
||||
int returnVal = openFile.showOpenDialog(openButton);
|
||||
|
||||
|
@ -1143,6 +1155,7 @@ public final class DynoControlPanel extends JPanel {
|
|||
final JButton saveButton = new JButton("Save");
|
||||
|
||||
saveButton.addActionListener(new ActionListener() {
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent actionEvent) {
|
||||
int returnVal = openFile.showSaveDialog(saveButton);
|
||||
|
||||
|
@ -1156,11 +1169,11 @@ public final class DynoControlPanel extends JPanel {
|
|||
outputStream = new BufferedWriter(new FileWriter(traceFile));
|
||||
LOGGER.info("DYNO Saving trace to file: " + traceFile.getName());
|
||||
String line = units + TAB + orderComboBox.getSelectedItem() +
|
||||
TAB + resultStrings[1] +
|
||||
TAB + fToE +
|
||||
TAB + sToE +
|
||||
TAB + tToS +
|
||||
TAB + auc;
|
||||
TAB + resultStrings[1] +
|
||||
TAB + fToE +
|
||||
TAB + sToE +
|
||||
TAB + tToS +
|
||||
TAB + auc;
|
||||
outputStream.write(line, 0, line.length());
|
||||
outputStream.newLine();
|
||||
|
||||
|
@ -1212,6 +1225,7 @@ public final class DynoControlPanel extends JPanel {
|
|||
private JButton buildClearReferenceButton() {
|
||||
final JButton clearButton = new JButton("Clear");
|
||||
clearButton.addActionListener(new ActionListener() {
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent actionEvent) {
|
||||
reFfToE = 0;
|
||||
reFsToE = 0;
|
||||
|
@ -1287,6 +1301,7 @@ public final class DynoControlPanel extends JPanel {
|
|||
|
||||
private JButton buildInterpolateButton(final JComboBox orderComboBox) {
|
||||
interpolateButton.addActionListener(new ActionListener() {
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent actionEvent) {
|
||||
if (dButton.isSelected()) {
|
||||
interpolateButton.setEnabled(true);
|
||||
|
@ -1364,18 +1379,20 @@ public final class DynoControlPanel extends JPanel {
|
|||
loadCars();
|
||||
final JComboBox selectComboBox = new JComboBox(carTypeArr);
|
||||
selectComboBox.addActionListener(new ActionListener() {
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent actionEvent) {
|
||||
changeCars(selectComboBox.getSelectedIndex());
|
||||
}
|
||||
});
|
||||
// carSelectBox.setSelectedItem("05 USDM OBXT WGN LTD 5MT");
|
||||
// carSelectBox.setSelectedItem("05 USDM OBXT WGN LTD 5MT");
|
||||
return selectComboBox;
|
||||
}
|
||||
|
||||
private JComboBox buildGearComboBox() {
|
||||
// makeGearList();
|
||||
// makeGearList();
|
||||
final JComboBox gearSelectBox = new JComboBox();
|
||||
gearSelectBox.addActionListener(new ActionListener() {
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent actionEvent) {
|
||||
gearRatio.setText(gearsRatioArr[carSelectBox.getSelectedIndex()][gearSelectBox.getSelectedIndex() + 1]);
|
||||
LOGGER.info("DYNO Car: " + carSelectBox.getSelectedItem() + ", Changed gear to: " + gearSelectBox.getSelectedItem() + " (" + gearRatio.getText() + ")");
|
||||
|
@ -1423,9 +1440,10 @@ public final class DynoControlPanel extends JPanel {
|
|||
|
||||
private void loadCars() {
|
||||
try {
|
||||
Settings settings = SettingsManager.getSettings();
|
||||
File carDef = null;
|
||||
final String SEPARATOR = System.getProperty("file.separator");
|
||||
final String loggerFilePath = Settings.getLoggerDefinitionFilePath();
|
||||
final String loggerFilePath = settings.getLoggerDefinitionFilePath();
|
||||
if (loggerFilePath != null) {
|
||||
final int index = loggerFilePath.lastIndexOf(SEPARATOR);
|
||||
if (index > 0) {
|
||||
|
@ -1434,7 +1452,7 @@ public final class DynoControlPanel extends JPanel {
|
|||
}
|
||||
}
|
||||
if (!carDef.exists()) {
|
||||
final String profileFilePath = Settings.getLoggerProfileFilePath();
|
||||
final String profileFilePath = settings.getLoggerProfileFilePath();
|
||||
if (profileFilePath != null) {
|
||||
final int index = profileFilePath.lastIndexOf(SEPARATOR);
|
||||
if (index > 0) {
|
||||
|
@ -1485,52 +1503,52 @@ public final class DynoControlPanel extends JPanel {
|
|||
Element element = (Element) list.item(0);
|
||||
if (element != null) {
|
||||
NodeList value = element.getChildNodes();
|
||||
String data = ((Node) value.item(0)).getNodeValue().trim();
|
||||
String data = value.item(0).getNodeValue().trim();
|
||||
switch (i) {
|
||||
case 0:
|
||||
carTypeArr[s] = data;
|
||||
// gearRatioArr[s] = data;
|
||||
for (int g = 1; g <= 6; g++) {
|
||||
String gearNo = "gearratio" + g;
|
||||
NodeList grsList = carElement.getElementsByTagName(gearNo);
|
||||
Element carGrsElement = (Element) grsList.item(0);
|
||||
if (carGrsElement != null) {
|
||||
NodeList grsValueList = carGrsElement.getChildNodes();
|
||||
if (((Node) grsValueList.item(0)).getNodeValue().trim() != null) {
|
||||
gearsRatioArr[s][0] = Integer.toString(g);
|
||||
gearsRatioArr[s][g] = (String) ((Node) grsValueList.item(0)).getNodeValue().trim();
|
||||
}
|
||||
case 0:
|
||||
carTypeArr[s] = data;
|
||||
// gearRatioArr[s] = data;
|
||||
for (int g = 1; g <= 6; g++) {
|
||||
String gearNo = "gearratio" + g;
|
||||
NodeList grsList = carElement.getElementsByTagName(gearNo);
|
||||
Element carGrsElement = (Element) grsList.item(0);
|
||||
if (carGrsElement != null) {
|
||||
NodeList grsValueList = carGrsElement.getChildNodes();
|
||||
if (grsValueList.item(0).getNodeValue().trim() != null) {
|
||||
gearsRatioArr[s][0] = Integer.toString(g);
|
||||
gearsRatioArr[s][g] = grsValueList.item(0).getNodeValue().trim();
|
||||
}
|
||||
// LOGGER.trace("Car: " + s + " Gear: " + g + " Ratio: " + gearsRatioArr[s][g]);
|
||||
}
|
||||
break;
|
||||
case 1:
|
||||
carMassArr[s] = data;
|
||||
break;
|
||||
case 2:
|
||||
dragCoeffArr[s] = data;
|
||||
break;
|
||||
case 3:
|
||||
rollCoeffArr[s] = data;
|
||||
break;
|
||||
case 4:
|
||||
frontalAreaArr[s] = data;
|
||||
break;
|
||||
case 5:
|
||||
finalRatioArr[s] = data;
|
||||
break;
|
||||
case 6:
|
||||
transArr[s] = data;
|
||||
break;
|
||||
case 7:
|
||||
widthArr[s] = data;
|
||||
break;
|
||||
case 8:
|
||||
aspectArr[s] = data;
|
||||
break;
|
||||
case 9:
|
||||
sizeArr[s] = data;
|
||||
break;
|
||||
// LOGGER.trace("Car: " + s + " Gear: " + g + " Ratio: " + gearsRatioArr[s][g]);
|
||||
}
|
||||
break;
|
||||
case 1:
|
||||
carMassArr[s] = data;
|
||||
break;
|
||||
case 2:
|
||||
dragCoeffArr[s] = data;
|
||||
break;
|
||||
case 3:
|
||||
rollCoeffArr[s] = data;
|
||||
break;
|
||||
case 4:
|
||||
frontalAreaArr[s] = data;
|
||||
break;
|
||||
case 5:
|
||||
finalRatioArr[s] = data;
|
||||
break;
|
||||
case 6:
|
||||
transArr[s] = data;
|
||||
break;
|
||||
case 7:
|
||||
widthArr[s] = data;
|
||||
break;
|
||||
case 8:
|
||||
aspectArr[s] = data;
|
||||
break;
|
||||
case 9:
|
||||
sizeArr[s] = data;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1567,6 +1585,7 @@ public final class DynoControlPanel extends JPanel {
|
|||
// selected whenever the cursor is in that field (gains focus):
|
||||
if (allTextSelector == null) {
|
||||
allTextSelector = new java.awt.event.FocusAdapter() {
|
||||
@Override
|
||||
public void focusGained(FocusEvent ev) {
|
||||
JTextComponent textComp = (JTextComponent) ev.getSource();
|
||||
textComp.selectAll();
|
||||
|
|
|
@ -19,6 +19,52 @@
|
|||
|
||||
package com.romraider.ramtune.test;
|
||||
|
||||
import static com.romraider.util.HexUtil.asBytes;
|
||||
import static com.romraider.util.HexUtil.asHex;
|
||||
import static com.romraider.util.ThreadUtil.runAsDaemon;
|
||||
import static com.romraider.util.ThreadUtil.sleep;
|
||||
import static java.awt.FlowLayout.LEFT;
|
||||
import static java.awt.Font.PLAIN;
|
||||
import static java.awt.GridBagConstraints.BOTH;
|
||||
import static javax.swing.JOptionPane.ERROR_MESSAGE;
|
||||
import static javax.swing.JOptionPane.WARNING_MESSAGE;
|
||||
import static javax.swing.JOptionPane.YES_NO_OPTION;
|
||||
import static javax.swing.JOptionPane.YES_OPTION;
|
||||
import static javax.swing.JOptionPane.showConfirmDialog;
|
||||
import static javax.swing.JOptionPane.showMessageDialog;
|
||||
import static javax.swing.ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER;
|
||||
import static javax.swing.ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED;
|
||||
import static javax.swing.border.BevelBorder.LOWERED;
|
||||
|
||||
import java.awt.BorderLayout;
|
||||
import java.awt.Component;
|
||||
import java.awt.FlowLayout;
|
||||
import java.awt.Font;
|
||||
import java.awt.GridBagConstraints;
|
||||
import java.awt.GridBagLayout;
|
||||
import java.awt.Insets;
|
||||
import java.awt.event.ActionEvent;
|
||||
import java.awt.event.ActionListener;
|
||||
import java.awt.event.WindowEvent;
|
||||
import java.io.PrintWriter;
|
||||
import java.io.StringWriter;
|
||||
import java.io.Writer;
|
||||
import java.util.List;
|
||||
|
||||
import javax.swing.ImageIcon;
|
||||
import javax.swing.JButton;
|
||||
import javax.swing.JCheckBox;
|
||||
import javax.swing.JComboBox;
|
||||
import javax.swing.JLabel;
|
||||
import javax.swing.JPanel;
|
||||
import javax.swing.JScrollPane;
|
||||
import javax.swing.JTextArea;
|
||||
import javax.swing.JTextField;
|
||||
import javax.swing.SwingUtilities;
|
||||
import javax.swing.border.BevelBorder;
|
||||
import javax.swing.border.EtchedBorder;
|
||||
import javax.swing.border.TitledBorder;
|
||||
|
||||
import com.romraider.Settings;
|
||||
import com.romraider.io.connection.ConnectionProperties;
|
||||
import com.romraider.io.protocol.Protocol;
|
||||
|
@ -37,53 +83,8 @@ import com.romraider.ramtune.test.command.generator.WriteCommandGenerator;
|
|||
import com.romraider.ramtune.test.io.RamTuneTestAppConnectionProperties;
|
||||
import com.romraider.swing.AbstractFrame;
|
||||
import com.romraider.swing.LookAndFeelManager;
|
||||
import static com.romraider.util.HexUtil.asBytes;
|
||||
import static com.romraider.util.HexUtil.asHex;
|
||||
import com.romraider.util.LogManager;
|
||||
import com.romraider.util.SettingsManager;
|
||||
import com.romraider.util.SettingsManagerImpl;
|
||||
|
||||
import static com.romraider.util.ThreadUtil.runAsDaemon;
|
||||
import static com.romraider.util.ThreadUtil.sleep;
|
||||
import static java.awt.FlowLayout.LEFT;
|
||||
import static java.awt.Font.PLAIN;
|
||||
import static java.awt.GridBagConstraints.BOTH;
|
||||
import static javax.swing.JOptionPane.ERROR_MESSAGE;
|
||||
import static javax.swing.JOptionPane.WARNING_MESSAGE;
|
||||
import static javax.swing.JOptionPane.YES_NO_OPTION;
|
||||
import static javax.swing.JOptionPane.YES_OPTION;
|
||||
import static javax.swing.JOptionPane.showConfirmDialog;
|
||||
import static javax.swing.JOptionPane.showMessageDialog;
|
||||
import static javax.swing.JScrollPane.HORIZONTAL_SCROLLBAR_NEVER;
|
||||
import static javax.swing.JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED;
|
||||
import static javax.swing.border.BevelBorder.LOWERED;
|
||||
import javax.swing.ImageIcon;
|
||||
import javax.swing.JButton;
|
||||
import javax.swing.JCheckBox;
|
||||
import javax.swing.JComboBox;
|
||||
import javax.swing.JLabel;
|
||||
import javax.swing.JPanel;
|
||||
import javax.swing.JScrollPane;
|
||||
import javax.swing.JTextArea;
|
||||
import javax.swing.JTextField;
|
||||
import javax.swing.SwingUtilities;
|
||||
import javax.swing.border.BevelBorder;
|
||||
import javax.swing.border.EtchedBorder;
|
||||
import javax.swing.border.TitledBorder;
|
||||
import java.awt.BorderLayout;
|
||||
import java.awt.Component;
|
||||
import java.awt.FlowLayout;
|
||||
import java.awt.Font;
|
||||
import java.awt.GridBagConstraints;
|
||||
import java.awt.GridBagLayout;
|
||||
import java.awt.Insets;
|
||||
import java.awt.event.ActionEvent;
|
||||
import java.awt.event.ActionListener;
|
||||
import java.awt.event.WindowEvent;
|
||||
import java.io.PrintWriter;
|
||||
import java.io.StringWriter;
|
||||
import java.io.Writer;
|
||||
import java.util.List;
|
||||
|
||||
/*
|
||||
* This is a test app! Use at your own risk!!
|
||||
|
@ -113,12 +114,11 @@ public final class RamTuneTestApp extends AbstractFrame {
|
|||
|
||||
public RamTuneTestApp(String title) {
|
||||
super(title);
|
||||
final SettingsManager manager = new SettingsManagerImpl();
|
||||
settings = manager.load();
|
||||
settings = SettingsManager.getSettings();
|
||||
portsComboBox = new SerialPortComboBox(settings);
|
||||
userTp = Settings.getTransportProtocol();
|
||||
userLibrary = Settings.getJ2534Device();
|
||||
Settings.setTransportProtocol(ISO9141);
|
||||
userTp = settings.getTransportProtocol();
|
||||
userLibrary = settings.getJ2534Device();
|
||||
settings.setTransportProtocol(ISO9141);
|
||||
// Read Address blocks only seems to work with ISO9141, it
|
||||
// may not be implemented in the ECU for ISO15765
|
||||
final LoggerProtocol lp = ProtocolFactory.getProtocol(
|
||||
|
@ -262,8 +262,10 @@ public final class RamTuneTestApp extends AbstractFrame {
|
|||
private JButton buildSendButton() {
|
||||
final JButton button = new JButton("Send Command");
|
||||
button.addActionListener(new ActionListener() {
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
runAsDaemon(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
button.setEnabled(false);
|
||||
try {
|
||||
|
@ -296,6 +298,7 @@ public final class RamTuneTestApp extends AbstractFrame {
|
|||
|
||||
private void appendResponseLater(final String text) {
|
||||
SwingUtilities.invokeLater(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
responseField.append(text);
|
||||
}
|
||||
|
@ -393,12 +396,14 @@ public final class RamTuneTestApp extends AbstractFrame {
|
|||
final JCheckBox ecuCheckBox = new JCheckBox("ECU");
|
||||
final JCheckBox tcuCheckBox = new JCheckBox("TCU");
|
||||
ecuCheckBox.addActionListener(new ActionListener() {
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent actionEvent) {
|
||||
tcuCheckBox.setSelected(false);
|
||||
ecuId = 0x10;
|
||||
}
|
||||
}
|
||||
});
|
||||
tcuCheckBox.addActionListener(new ActionListener() {
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent actionEvent) {
|
||||
ecuCheckBox.setSelected(false);
|
||||
ecuId = 0x18;
|
||||
|
@ -453,6 +458,7 @@ public final class RamTuneTestApp extends AbstractFrame {
|
|||
|
||||
public static void startTestApp(final int defaultCloseOperation) {
|
||||
SwingUtilities.invokeLater(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
RamTuneTestApp ramTuneTestApp = new RamTuneTestApp("SSM Read/Write");
|
||||
ramTuneTestApp.setIconImage(new ImageIcon( getClass().getResource("/graphics/romraider-ico.gif")).getImage());
|
||||
|
@ -467,7 +473,7 @@ public final class RamTuneTestApp extends AbstractFrame {
|
|||
|
||||
@Override
|
||||
public void windowClosing(WindowEvent e) {
|
||||
Settings.setTransportProtocol(userTp);
|
||||
Settings.setJ2534Device(userLibrary);
|
||||
settings.setTransportProtocol(userTp);
|
||||
settings.setJ2534Device(userLibrary);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -53,6 +53,7 @@ import com.romraider.editor.ecu.ECUEditorManager;
|
|||
import com.romraider.maps.Rom;
|
||||
import com.romraider.maps.Table;
|
||||
import com.romraider.util.FileAssociator;
|
||||
import com.romraider.util.SettingsManager;
|
||||
|
||||
public class SettingsForm extends JFrame implements MouseListener {
|
||||
|
||||
|
@ -876,7 +877,20 @@ public class SettingsForm extends JFrame implements MouseListener {
|
|||
btnChooseFont.setText(fc.getFont().getFontName());
|
||||
}
|
||||
} else if (e.getSource() == reset) {
|
||||
getEditor().setSettings(new Settings());
|
||||
Settings newSettings = new Settings();
|
||||
Settings curSettings = getSettings();
|
||||
|
||||
newSettings.setEcuDefinitionFiles(curSettings.getEcuDefinitionFiles());
|
||||
newSettings.setLastImageDir(curSettings.getLastImageDir());
|
||||
newSettings.setLastRepositoryDir(curSettings.getLastRepositoryDir());
|
||||
newSettings.setUserLevel(curSettings.getUserLevel());
|
||||
newSettings.setLoggerDefinitionFilePath(curSettings.getLoggerDefinitionFilePath());
|
||||
newSettings.setLoggerDebuggingLevel(curSettings.getLoggerDebuggingLevel());
|
||||
newSettings.setLoggerProfileFilePath(curSettings.getLoggerProfileFilePath());
|
||||
newSettings.setLoggerOutputDirPath(curSettings.getLoggerOutputDirPath());
|
||||
|
||||
getEditor().setSettings(newSettings);
|
||||
|
||||
initSettings();
|
||||
} else if (e.getSource() == btnAddAssocs) {
|
||||
// add file associations for selected file types
|
||||
|
@ -1014,7 +1028,7 @@ public class SettingsForm extends JFrame implements MouseListener {
|
|||
|
||||
public void saveSettings()
|
||||
{
|
||||
getEditor().getSettingsManager().save(getSettings());
|
||||
SettingsManager.save(getSettings());
|
||||
|
||||
// TODO: check if table setting changed before refreshing all tables.
|
||||
// Refresh all tables.
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
/*
|
||||
* RomRaider Open-Source Tuning, Logging and Reflashing
|
||||
* Copyright (C) 2006-2012 RomRaider.com
|
||||
* Copyright (C) 2006-2013 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
|
||||
|
@ -19,13 +19,77 @@
|
|||
|
||||
package com.romraider.util;
|
||||
|
||||
import static com.romraider.Version.VERSION;
|
||||
import static javax.swing.JOptionPane.INFORMATION_MESSAGE;
|
||||
import static javax.swing.JOptionPane.showMessageDialog;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FileInputStream;
|
||||
import java.io.FileNotFoundException;
|
||||
|
||||
import org.w3c.dom.Document;
|
||||
import org.xml.sax.InputSource;
|
||||
|
||||
import com.romraider.Settings;
|
||||
import com.romraider.swing.JProgressPane;
|
||||
import com.romraider.xml.DOMSettingsBuilder;
|
||||
import com.romraider.xml.DOMSettingsUnmarshaller;
|
||||
import com.sun.org.apache.xerces.internal.parsers.DOMParser;
|
||||
|
||||
public interface SettingsManager {
|
||||
Settings load();
|
||||
public class SettingsManager {
|
||||
private static final String SETTINGS_FILE = "/settings.xml";
|
||||
private static final String USER_HOME =
|
||||
System.getProperty("user.home") + "/.RomRaider";
|
||||
private static final String START_DIR = System.getProperty("user.dir");
|
||||
private static String settingsDir = USER_HOME;
|
||||
|
||||
void save(Settings settings);
|
||||
private static Settings settings = null;
|
||||
|
||||
void save(Settings settings, JProgressPane progress);
|
||||
public static Settings getSettings() {
|
||||
if(null == settings) {
|
||||
try {
|
||||
FileInputStream settingsFileIn = null;
|
||||
try {
|
||||
final File sf = new File(USER_HOME + SETTINGS_FILE);
|
||||
settingsFileIn = new FileInputStream(sf);
|
||||
}
|
||||
catch (Exception e) {
|
||||
final File sf = new File(START_DIR + SETTINGS_FILE);
|
||||
settingsFileIn = new FileInputStream(sf);
|
||||
settingsDir = START_DIR;
|
||||
}
|
||||
final InputSource src = new InputSource(settingsFileIn);
|
||||
final DOMSettingsUnmarshaller domUms = new DOMSettingsUnmarshaller();
|
||||
final DOMParser parser = new DOMParser();
|
||||
parser.parse(src);
|
||||
final Document doc = parser.getDocument();
|
||||
settings = domUms.unmarshallSettings(doc.getDocumentElement());
|
||||
} catch (FileNotFoundException e) {
|
||||
showMessageDialog(null,
|
||||
"Settings file not found.\nUsing default settings.",
|
||||
"Error Loading Settings", INFORMATION_MESSAGE);
|
||||
settings = new Settings();
|
||||
} catch (Exception e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
return settings;
|
||||
}
|
||||
|
||||
public static void save(Settings newSettings) {
|
||||
save(settings, new JProgressPane());
|
||||
}
|
||||
|
||||
public static void save(Settings newSettings, JProgressPane progress) {
|
||||
final DOMSettingsBuilder builder = new DOMSettingsBuilder();
|
||||
try {
|
||||
final File newDir = new File(settingsDir);
|
||||
newDir.mkdir(); // Creates directory if it does not exist
|
||||
final File sf = new File(settingsDir + SETTINGS_FILE);
|
||||
builder.buildSettings(settings, sf, progress, VERSION);
|
||||
} catch (Exception e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
settings = newSettings;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,92 +0,0 @@
|
|||
/*
|
||||
* RomRaider Open-Source Tuning, Logging and Reflashing
|
||||
* Copyright (C) 2006-2013 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.util;
|
||||
|
||||
import static com.romraider.Version.VERSION;
|
||||
import static javax.swing.JOptionPane.INFORMATION_MESSAGE;
|
||||
import static javax.swing.JOptionPane.showMessageDialog;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FileInputStream;
|
||||
import java.io.FileNotFoundException;
|
||||
|
||||
import org.w3c.dom.Document;
|
||||
import org.xml.sax.InputSource;
|
||||
|
||||
import com.romraider.Settings;
|
||||
import com.romraider.swing.JProgressPane;
|
||||
import com.romraider.xml.DOMSettingsBuilder;
|
||||
import com.romraider.xml.DOMSettingsUnmarshaller;
|
||||
import com.sun.org.apache.xerces.internal.parsers.DOMParser;
|
||||
|
||||
public final class SettingsManagerImpl implements SettingsManager {
|
||||
private static final String SETTINGS_FILE = "/settings.xml";
|
||||
private static final String USER_HOME =
|
||||
System.getProperty("user.home") + "/.RomRaider";
|
||||
private static final String START_DIR = System.getProperty("user.dir");
|
||||
private static String settingsDir = USER_HOME;
|
||||
|
||||
@Override
|
||||
public final Settings load() {
|
||||
try {
|
||||
FileInputStream settingsFileIn = null;
|
||||
try {
|
||||
final File sf = new File(USER_HOME + SETTINGS_FILE);
|
||||
settingsFileIn = new FileInputStream(sf);
|
||||
}
|
||||
catch (Exception e) {
|
||||
final File sf = new File(START_DIR + SETTINGS_FILE);
|
||||
settingsFileIn = new FileInputStream(sf);
|
||||
settingsDir = START_DIR;
|
||||
}
|
||||
final InputSource src = new InputSource(settingsFileIn);
|
||||
final DOMSettingsUnmarshaller domUms = new DOMSettingsUnmarshaller();
|
||||
final DOMParser parser = new DOMParser();
|
||||
parser.parse(src);
|
||||
final Document doc = parser.getDocument();
|
||||
return domUms.unmarshallSettings(doc.getDocumentElement());
|
||||
} catch (FileNotFoundException e) {
|
||||
showMessageDialog(null,
|
||||
"Settings file not found.\nUsing default settings.",
|
||||
"Error Loading Settings", INFORMATION_MESSAGE);
|
||||
return new Settings();
|
||||
} catch (Exception e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public final void save(Settings settings) {
|
||||
save(settings, new JProgressPane());
|
||||
}
|
||||
|
||||
@Override
|
||||
public final void save(Settings settings, JProgressPane progress) {
|
||||
final DOMSettingsBuilder builder = new DOMSettingsBuilder();
|
||||
try {
|
||||
final File newDir = new File(settingsDir);
|
||||
newDir.mkdir(); // Creates directory if it does not exist
|
||||
final File sf = new File(settingsDir + SETTINGS_FILE);
|
||||
builder.buildSettings(settings, sf, progress, VERSION);
|
||||
} catch (Exception e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -286,15 +286,15 @@ public final class DOMSettingsBuilder {
|
|||
IIOMetadataNode serial = new IIOMetadataNode("serial");
|
||||
serial.setAttribute("port", settings.getLoggerPortDefault());
|
||||
serial.setAttribute("refresh", String.valueOf(settings.getRefreshMode()));
|
||||
serial.setAttribute("ecuid", String.valueOf(Settings.getDestinationId()));
|
||||
serial.setAttribute("ecuid", String.valueOf(settings.getDestinationId()));
|
||||
serial.setAttribute("fastpoll", String.valueOf(settings.isFastPoll()));
|
||||
loggerSettings.appendChild(serial);
|
||||
|
||||
// Protocol connection
|
||||
IIOMetadataNode protocol = new IIOMetadataNode("protocol");
|
||||
protocol.setAttribute("name", Settings.getLoggerProtocol());
|
||||
protocol.setAttribute("transport", Settings.getTransportProtocol());
|
||||
protocol.setAttribute("library", Settings.getJ2534Device());
|
||||
protocol.setAttribute("name", settings.getLoggerProtocol());
|
||||
protocol.setAttribute("transport", settings.getTransportProtocol());
|
||||
protocol.setAttribute("library", settings.getJ2534Device());
|
||||
loggerSettings.appendChild(protocol);
|
||||
|
||||
// window maximized
|
||||
|
@ -323,17 +323,17 @@ public final class DOMSettingsBuilder {
|
|||
|
||||
// definition path
|
||||
IIOMetadataNode definition = new IIOMetadataNode("definition");
|
||||
definition.setAttribute("path", Settings.getLoggerDefinitionFilePath());
|
||||
definition.setAttribute("path", settings.getLoggerDefinitionFilePath());
|
||||
loggerSettings.appendChild(definition);
|
||||
|
||||
// profile path
|
||||
IIOMetadataNode profile = new IIOMetadataNode("profile");
|
||||
profile.setAttribute("path", Settings.getLoggerProfileFilePath());
|
||||
profile.setAttribute("path", settings.getLoggerProfileFilePath());
|
||||
loggerSettings.appendChild(profile);
|
||||
|
||||
// file logging
|
||||
IIOMetadataNode filelogging = new IIOMetadataNode("filelogging");
|
||||
filelogging.setAttribute("path", Settings.getLoggerOutputDirPath());
|
||||
filelogging.setAttribute("path", settings.getLoggerOutputDirPath());
|
||||
filelogging.setAttribute("switchid", settings.getFileLoggingControllerSwitchId());
|
||||
filelogging.setAttribute("active", String.valueOf(settings.isFileLoggingControllerSwitchActive()));
|
||||
filelogging.setAttribute("absolutetimestamp", String.valueOf(settings.isFileLoggingAbsoluteTimestamp()));
|
||||
|
|
|
@ -250,13 +250,13 @@ public final class DOMSettingsUnmarshaller {
|
|||
if (n.getNodeType() == ELEMENT_NODE && n.getNodeName().equalsIgnoreCase("serial")) {
|
||||
settings.setLoggerPortDefault(unmarshallAttribute(n, "port", ""));
|
||||
settings.setRefreshMode(unmarshallAttribute(n, "refresh", false));
|
||||
Settings.setDestinationId((byte) unmarshallAttribute(n, "ecuid", (byte) 0x10));
|
||||
settings.setDestinationId((byte) unmarshallAttribute(n, "ecuid", (byte) 0x10));
|
||||
settings.setFastPoll(unmarshallAttribute(n, "fastpoll", true));
|
||||
|
||||
} else if (n.getNodeType() == ELEMENT_NODE && n.getNodeName().equalsIgnoreCase("protocol")) {
|
||||
Settings.setLoggerProtocol(unmarshallAttribute(n, "name", "SSM"));
|
||||
Settings.setTransportProtocol(unmarshallAttribute(n, "transport", "ISO9141"));
|
||||
Settings.setJ2534Device(unmarshallAttribute(n, "library", null));
|
||||
settings.setLoggerProtocol(unmarshallAttribute(n, "name", "SSM"));
|
||||
settings.setTransportProtocol(unmarshallAttribute(n, "transport", "ISO9141"));
|
||||
settings.setJ2534Device(unmarshallAttribute(n, "library", null));
|
||||
|
||||
} else if (n.getNodeType() == ELEMENT_NODE && n.getNodeName().equalsIgnoreCase("maximized")) {
|
||||
settings.setLoggerWindowMaximized(unmarshallAttribute(n, "value", false));
|
||||
|
@ -275,7 +275,7 @@ public final class DOMSettingsUnmarshaller {
|
|||
settings.setLoggerParameterListState(unmarshallAttribute(n, "showlist", true));
|
||||
|
||||
} else if (n.getNodeType() == ELEMENT_NODE && n.getNodeName().equalsIgnoreCase("definition")) {
|
||||
settings.setLoggerDefinitionFilePath(unmarshallAttribute(n, "path", Settings.getLoggerDefinitionFilePath()));
|
||||
settings.setLoggerDefinitionFilePath(unmarshallAttribute(n, "path", settings.getLoggerDefinitionFilePath()));
|
||||
|
||||
} else if (n.getNodeType() == ELEMENT_NODE && n.getNodeName().equalsIgnoreCase("profile")) {
|
||||
settings.setLoggerProfileFilePath(unmarshallAttribute(n, "path", ""));
|
||||
|
|
Loading…
Reference in New Issue