mirror of https://github.com/rusefi/RomRaider.git
added plugin ports to settings to be saved
git-svn-id: https://svn2.assembla.com/svn/romraider/trunk@256 38686702-15cf-42e4-a595-3071df8bf5ea
This commit is contained in:
parent
f27d667278
commit
3475448e06
|
@ -13,7 +13,7 @@
|
|||
<!ATTLIST parameter dash ( selected ) #IMPLIED >
|
||||
<!ATTLIST parameter units CDATA #IMPLIED >
|
||||
|
||||
<!ELEMENT parameters ( parameter+ ) >
|
||||
<!ELEMENT parameters ( parameter* ) >
|
||||
|
||||
<!ELEMENT switch EMPTY >
|
||||
<!ATTLIST switch id ID #REQUIRED >
|
||||
|
@ -21,7 +21,7 @@
|
|||
<!ATTLIST switch graph ( selected ) #IMPLIED >
|
||||
<!ATTLIST switch dash ( selected ) #IMPLIED >
|
||||
|
||||
<!ELEMENT switches ( switch+ ) >
|
||||
<!ELEMENT switches ( switch* ) >
|
||||
|
||||
<!ELEMENT external EMPTY >
|
||||
<!ATTLIST external id ID #REQUIRED >
|
||||
|
@ -29,6 +29,6 @@
|
|||
<!ATTLIST external graph ( selected ) #IMPLIED >
|
||||
<!ATTLIST external dash ( selected ) #IMPLIED >
|
||||
|
||||
<!ELEMENT externals ( external+ ) >
|
||||
<!ELEMENT externals ( external* ) >
|
||||
|
||||
<!ELEMENT profile ( serial?, logfilelocation?, parameters*, switches*, externals* ) >
|
||||
<!ELEMENT profile ( serial?, logfilelocation?, parameters?, switches?, externals? ) >
|
||||
|
|
|
@ -81,6 +81,7 @@ public class Settings implements Serializable {
|
|||
private int loggerSelectedTabIndex = 0;
|
||||
private ConnectionProperties loggerConnectionProperties;
|
||||
private Map<String, EcuDefinition> loggerEcuDefinitionMap;
|
||||
private Map<String, String> loggerPluginPorts;
|
||||
|
||||
|
||||
public Settings() {
|
||||
|
@ -420,4 +421,12 @@ public class Settings implements Serializable {
|
|||
public int getLoggerSelectedTabIndex() {
|
||||
return loggerSelectedTabIndex;
|
||||
}
|
||||
|
||||
public Map<String, String> getLoggerPluginPorts() {
|
||||
return loggerPluginPorts;
|
||||
}
|
||||
|
||||
public void setLoggerPluginPorts(Map<String, String> loggerPluginPorts) {
|
||||
this.loggerPluginPorts = loggerPluginPorts;
|
||||
}
|
||||
}
|
|
@ -25,8 +25,8 @@ import com.romraider.logger.ecu.EcuLogger;
|
|||
import com.romraider.logger.ecu.external.ExternalDataItem;
|
||||
import com.romraider.logger.ecu.external.ExternalDataSource;
|
||||
import static com.romraider.util.ThreadUtil.runAsDaemon;
|
||||
import javax.swing.Action;
|
||||
import static java.util.Arrays.asList;
|
||||
import javax.swing.Action;
|
||||
import java.util.List;
|
||||
|
||||
public final class AemDataSource implements ExternalDataSource {
|
||||
|
@ -34,6 +34,10 @@ public final class AemDataSource implements ExternalDataSource {
|
|||
private AemDataItem dataItem = new AemDataItem();
|
||||
private AemRunner runner;
|
||||
|
||||
public String getId() {
|
||||
return getClass().getName();
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return "AEM UEGO";
|
||||
}
|
||||
|
|
|
@ -91,39 +91,6 @@ import com.romraider.util.SettingsManagerImpl;
|
|||
import com.romraider.util.ThreadUtil;
|
||||
import static com.romraider.util.ThreadUtil.runAsDaemon;
|
||||
import static com.romraider.util.ThreadUtil.sleep;
|
||||
import org.apache.log4j.Logger;
|
||||
import javax.swing.AbstractAction;
|
||||
import static javax.swing.BorderFactory.createLoweredBevelBorder;
|
||||
import javax.swing.ImageIcon;
|
||||
import javax.swing.JButton;
|
||||
import javax.swing.JComponent;
|
||||
import static javax.swing.JComponent.WHEN_IN_FOCUSED_WINDOW;
|
||||
import javax.swing.JFrame;
|
||||
import javax.swing.JLabel;
|
||||
import static javax.swing.JLabel.RIGHT;
|
||||
import javax.swing.JMenuBar;
|
||||
import static javax.swing.JOptionPane.DEFAULT_OPTION;
|
||||
import static javax.swing.JOptionPane.INFORMATION_MESSAGE;
|
||||
import static javax.swing.JOptionPane.WARNING_MESSAGE;
|
||||
import static javax.swing.JOptionPane.showMessageDialog;
|
||||
import static javax.swing.JOptionPane.showOptionDialog;
|
||||
import javax.swing.JPanel;
|
||||
import javax.swing.JScrollPane;
|
||||
import static javax.swing.JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED;
|
||||
import static javax.swing.JScrollPane.HORIZONTAL_SCROLLBAR_NEVER;
|
||||
import static javax.swing.JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED;
|
||||
import javax.swing.JSeparator;
|
||||
import static javax.swing.JSeparator.VERTICAL;
|
||||
import javax.swing.JSplitPane;
|
||||
import static javax.swing.JSplitPane.HORIZONTAL_SPLIT;
|
||||
import javax.swing.JTabbedPane;
|
||||
import static javax.swing.JTabbedPane.BOTTOM;
|
||||
import javax.swing.JTable;
|
||||
import javax.swing.JToggleButton;
|
||||
import static javax.swing.KeyStroke.getKeyStroke;
|
||||
import static javax.swing.SwingUtilities.invokeLater;
|
||||
import javax.swing.table.TableColumn;
|
||||
import java.awt.BorderLayout;
|
||||
import static java.awt.BorderLayout.CENTER;
|
||||
import static java.awt.BorderLayout.EAST;
|
||||
import static java.awt.BorderLayout.NORTH;
|
||||
|
@ -131,6 +98,41 @@ import static java.awt.BorderLayout.SOUTH;
|
|||
import static java.awt.BorderLayout.WEST;
|
||||
import static java.awt.Color.BLACK;
|
||||
import static java.awt.Color.RED;
|
||||
import static java.lang.System.currentTimeMillis;
|
||||
import static java.util.Collections.sort;
|
||||
import static javax.swing.BorderFactory.createLoweredBevelBorder;
|
||||
import static javax.swing.JComponent.WHEN_IN_FOCUSED_WINDOW;
|
||||
import static javax.swing.JLabel.RIGHT;
|
||||
import static javax.swing.JOptionPane.DEFAULT_OPTION;
|
||||
import static javax.swing.JOptionPane.INFORMATION_MESSAGE;
|
||||
import static javax.swing.JOptionPane.WARNING_MESSAGE;
|
||||
import static javax.swing.JOptionPane.showMessageDialog;
|
||||
import static javax.swing.JOptionPane.showOptionDialog;
|
||||
import static javax.swing.JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED;
|
||||
import static javax.swing.JScrollPane.HORIZONTAL_SCROLLBAR_NEVER;
|
||||
import static javax.swing.JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED;
|
||||
import static javax.swing.JSeparator.VERTICAL;
|
||||
import static javax.swing.JSplitPane.HORIZONTAL_SPLIT;
|
||||
import static javax.swing.JTabbedPane.BOTTOM;
|
||||
import static javax.swing.KeyStroke.getKeyStroke;
|
||||
import static javax.swing.SwingUtilities.invokeLater;
|
||||
import org.apache.log4j.Logger;
|
||||
import javax.swing.AbstractAction;
|
||||
import javax.swing.ImageIcon;
|
||||
import javax.swing.JButton;
|
||||
import javax.swing.JComponent;
|
||||
import javax.swing.JFrame;
|
||||
import javax.swing.JLabel;
|
||||
import javax.swing.JMenuBar;
|
||||
import javax.swing.JPanel;
|
||||
import javax.swing.JScrollPane;
|
||||
import javax.swing.JSeparator;
|
||||
import javax.swing.JSplitPane;
|
||||
import javax.swing.JTabbedPane;
|
||||
import javax.swing.JTable;
|
||||
import javax.swing.JToggleButton;
|
||||
import javax.swing.table.TableColumn;
|
||||
import java.awt.BorderLayout;
|
||||
import java.awt.Component;
|
||||
import java.awt.Dimension;
|
||||
import java.awt.FlowLayout;
|
||||
|
@ -143,9 +145,7 @@ import java.awt.event.ActionListener;
|
|||
import java.awt.event.WindowEvent;
|
||||
import java.beans.PropertyChangeEvent;
|
||||
import java.io.File;
|
||||
import static java.lang.System.currentTimeMillis;
|
||||
import java.util.ArrayList;
|
||||
import static java.util.Collections.sort;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
@ -422,7 +422,7 @@ public final class EcuLogger extends AbstractFrame implements MessageListener {
|
|||
private void loadLoggerPlugins() {
|
||||
try {
|
||||
ExternalDataSourceLoader dataSourceLoader = new ExternalDataSourceLoaderImpl();
|
||||
dataSourceLoader.loadExternalDataSources();
|
||||
dataSourceLoader.loadExternalDataSources(settings.getLoggerPluginPorts());
|
||||
externalDataSources = dataSourceLoader.getExternalDataSources();
|
||||
} catch (Exception e) {
|
||||
reportError(e);
|
||||
|
@ -622,6 +622,16 @@ public final class EcuLogger extends AbstractFrame implements MessageListener {
|
|||
return new UserProfileImpl(paramProfileItems, switchProfileItems, externalProfileItems);
|
||||
}
|
||||
|
||||
private Map<String, String> getPluginPorts(List<ExternalDataSource> externalDataSources) {
|
||||
Map<String, String> plugins = new HashMap<String, String>();
|
||||
for (ExternalDataSource dataSource : externalDataSources) {
|
||||
String id = dataSource.getId();
|
||||
String port = dataSource.getPort();
|
||||
if (port != null && port.trim().length() > 0) plugins.put(id, port.trim());
|
||||
}
|
||||
return plugins;
|
||||
}
|
||||
|
||||
private Map<String, UserProfileItem> getProfileItems(List<ParameterRow> dataTabRows, List<ParameterRow> graphTabRows, List<ParameterRow> dashTabRows) {
|
||||
Map<String, UserProfileItem> profileItems = new HashMap<String, UserProfileItem>();
|
||||
for (ParameterRow dataTabRow : dataTabRows) {
|
||||
|
@ -1048,6 +1058,7 @@ public final class EcuLogger extends AbstractFrame implements MessageListener {
|
|||
settings.setLoggerWindowSize(getSize());
|
||||
settings.setLoggerWindowLocation(getLocation());
|
||||
settings.setLoggerSelectedTabIndex(tabbedPane.getSelectedIndex());
|
||||
settings.setLoggerPluginPorts(getPluginPorts(externalDataSources));
|
||||
new SettingsManagerImpl().save(settings);
|
||||
}
|
||||
|
||||
|
|
|
@ -24,6 +24,8 @@ import javax.swing.Action;
|
|||
import java.util.List;
|
||||
|
||||
public interface ExternalDataSource {
|
||||
String getId();
|
||||
|
||||
String getName();
|
||||
|
||||
String getVersion();
|
||||
|
|
|
@ -20,10 +20,11 @@
|
|||
package com.romraider.logger.ecu.external;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
public interface ExternalDataSourceLoader {
|
||||
|
||||
void loadExternalDataSources();
|
||||
void loadExternalDataSources(Map<String, String> loggerPluginPorts);
|
||||
|
||||
List<ExternalDataSource> getExternalDataSources();
|
||||
}
|
||||
|
|
|
@ -27,13 +27,14 @@ import java.io.File;
|
|||
import java.io.FileInputStream;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Properties;
|
||||
|
||||
public final class ExternalDataSourceLoaderImpl implements ExternalDataSourceLoader {
|
||||
private static final Logger LOGGER = Logger.getLogger(ExternalDataSourceLoaderImpl.class);
|
||||
private List<ExternalDataSource> externalDataSources = new ArrayList<ExternalDataSource>();
|
||||
|
||||
public void loadExternalDataSources() {
|
||||
public void loadExternalDataSources(Map<String, String> loggerPluginPorts) {
|
||||
try {
|
||||
File pluginsDir = new File("./plugins");
|
||||
if (pluginsDir.exists() && pluginsDir.isDirectory()) {
|
||||
|
@ -49,7 +50,7 @@ public final class ExternalDataSourceLoaderImpl implements ExternalDataSourceLoa
|
|||
try {
|
||||
Class<?> dataSourceClass = getClass().getClassLoader().loadClass(datasourceClassName);
|
||||
if (dataSourceClass != null && ExternalDataSource.class.isAssignableFrom(dataSourceClass)) {
|
||||
ExternalDataSource dataSource = (ExternalDataSource) dataSourceClass.newInstance();
|
||||
ExternalDataSource dataSource = dataSource(dataSourceClass, loggerPluginPorts);
|
||||
ExternalDataSource managedDataSource = new GenericDataSourceManager(dataSource);
|
||||
externalDataSources.add(managedDataSource);
|
||||
LOGGER.info("Plugin loaded: " + dataSource.getName() + " v" + dataSource.getVersion());
|
||||
|
@ -69,6 +70,15 @@ public final class ExternalDataSourceLoaderImpl implements ExternalDataSourceLoa
|
|||
}
|
||||
}
|
||||
|
||||
private ExternalDataSource dataSource(Class<?> dataSourceClass, Map<String, String> loggerPluginPorts) throws Exception {
|
||||
ExternalDataSource dataSource = (ExternalDataSource) dataSourceClass.newInstance();
|
||||
if (loggerPluginPorts != null) {
|
||||
String port = loggerPluginPorts.get(dataSource.getId());
|
||||
if (port != null && port.trim().length() > 0) dataSource.setPort(port);
|
||||
}
|
||||
return dataSource;
|
||||
}
|
||||
|
||||
public List<ExternalDataSource> getExternalDataSources() {
|
||||
return externalDataSources;
|
||||
}
|
||||
|
|
|
@ -41,6 +41,10 @@ public final class GenericDataSourceManager implements ExternalDataSource {
|
|||
this.dataSource = dataSource;
|
||||
}
|
||||
|
||||
public String getId() {
|
||||
return dataSource.getId();
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return dataSource.getName();
|
||||
}
|
||||
|
|
|
@ -33,6 +33,10 @@ public final class InnovateDataSource implements ExternalDataSource {
|
|||
private InnovateRunner runner;
|
||||
private String port;
|
||||
|
||||
public String getId() {
|
||||
return getClass().getName();
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return "Innovate Wideband AFR";
|
||||
}
|
||||
|
|
|
@ -25,11 +25,11 @@ import com.romraider.logger.ecu.external.ExternalDataSource;
|
|||
import com.romraider.logger.innovate.generic.mts.io.MTSRunner;
|
||||
import com.romraider.logger.innovate.generic.mts.io.MTSRunnerImpl;
|
||||
import static com.romraider.util.ThreadUtil.runAsDaemon;
|
||||
import static java.lang.Integer.parseInt;
|
||||
import static java.util.Arrays.asList;
|
||||
import org.apache.log4j.Logger;
|
||||
import static org.apache.log4j.Logger.getLogger;
|
||||
import javax.swing.Action;
|
||||
import static java.lang.Integer.parseInt;
|
||||
import static java.util.Arrays.asList;
|
||||
import java.util.List;
|
||||
|
||||
public final class Lm2MtsDataSource implements ExternalDataSource {
|
||||
|
@ -38,6 +38,10 @@ public final class Lm2MtsDataSource implements ExternalDataSource {
|
|||
private MTSRunner runner;
|
||||
private int mtsPort = 0;
|
||||
|
||||
public String getId() {
|
||||
return getClass().getName();
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return "Innovate LM-2 [mts]";
|
||||
}
|
||||
|
|
|
@ -44,6 +44,10 @@ public final class PlxDataSource implements ExternalDataSource {
|
|||
// dataItems.put(EXHAUST_GAS_TEMPERATURE, new PlxDataItemImpl("EGT", "C", EXHAUST_GAS_TEMPERATURE, EXHAUST_GAS_TEMPERATURE_CELSIUS));
|
||||
}
|
||||
|
||||
public String getId() {
|
||||
return getClass().getName();
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return "PLX SM-AFR";
|
||||
}
|
||||
|
|
|
@ -31,9 +31,9 @@ import static com.romraider.logger.zt2.io.ZT2SensorType.MAP;
|
|||
import static com.romraider.logger.zt2.io.ZT2SensorType.RPM;
|
||||
import static com.romraider.logger.zt2.io.ZT2SensorType.TPS;
|
||||
import static com.romraider.util.ThreadUtil.runAsDaemon;
|
||||
import static java.util.Collections.unmodifiableList;
|
||||
import javax.swing.Action;
|
||||
import java.util.ArrayList;
|
||||
import static java.util.Collections.unmodifiableList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
@ -51,6 +51,10 @@ public final class ZT2DataSource implements ExternalDataSource {
|
|||
dataItems.put(EGT, new ZT2DataItemImpl("EGT", "Celsius", EGT));
|
||||
}
|
||||
|
||||
public String getId() {
|
||||
return getClass().getName();
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return "Zeitronix ZT-2";
|
||||
}
|
||||
|
|
|
@ -27,6 +27,7 @@ import javax.imageio.metadata.IIOMetadataNode;
|
|||
import java.io.File;
|
||||
import java.io.FileOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.util.Map;
|
||||
import java.util.Vector;
|
||||
|
||||
public final class DOMSettingsBuilder {
|
||||
|
@ -276,6 +277,19 @@ public final class DOMSettingsBuilder {
|
|||
filelogging.setAttribute("absolutetimestamp", String.valueOf(settings.isFileLoggingAbsoluteTimestamp()));
|
||||
loggerSettings.appendChild(filelogging);
|
||||
|
||||
// plugin ports
|
||||
Map<String, String> pluginPorts = settings.getLoggerPluginPorts();
|
||||
if (!pluginPorts.isEmpty()) {
|
||||
IIOMetadataNode plugins = new IIOMetadataNode("plugins");
|
||||
for (Map.Entry<String, String> entry : pluginPorts.entrySet()) {
|
||||
IIOMetadataNode plugin = new IIOMetadataNode("plugin");
|
||||
plugin.setAttribute("id", entry.getKey());
|
||||
plugin.setAttribute("port", entry.getValue());
|
||||
plugins.appendChild(plugin);
|
||||
}
|
||||
loggerSettings.appendChild(plugins);
|
||||
}
|
||||
|
||||
return loggerSettings;
|
||||
}
|
||||
}
|
|
@ -21,15 +21,17 @@ package com.romraider.xml;
|
|||
|
||||
import com.romraider.Settings;
|
||||
import static com.romraider.xml.DOMHelper.unmarshallAttribute;
|
||||
import static java.awt.Font.BOLD;
|
||||
import org.w3c.dom.Node;
|
||||
import static org.w3c.dom.Node.ELEMENT_NODE;
|
||||
import org.w3c.dom.NodeList;
|
||||
import java.awt.Color;
|
||||
import java.awt.Dimension;
|
||||
import java.awt.Font;
|
||||
import static java.awt.Font.BOLD;
|
||||
import java.awt.Point;
|
||||
import java.io.File;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
public final class DOMSettingsUnmarshaller {
|
||||
|
||||
|
@ -204,12 +206,11 @@ public final class DOMSettingsUnmarshaller {
|
|||
}
|
||||
|
||||
|
||||
private Settings unmarshallLogger(Node windowNode, Settings settings) {
|
||||
Node n;
|
||||
NodeList nodes = windowNode.getChildNodes();
|
||||
private Settings unmarshallLogger(Node loggerNode, Settings settings) {
|
||||
NodeList nodes = loggerNode.getChildNodes();
|
||||
|
||||
for (int i = 0; i < nodes.getLength(); i++) {
|
||||
n = nodes.item(i);
|
||||
Node n = nodes.item(i);
|
||||
|
||||
if (n.getNodeType() == ELEMENT_NODE && n.getNodeName().equalsIgnoreCase("serial")) {
|
||||
settings.setLoggerPortDefault(unmarshallAttribute(n, "port", ""));
|
||||
|
@ -240,6 +241,20 @@ public final class DOMSettingsUnmarshaller {
|
|||
settings.setFileLoggingControllerSwitchActive(unmarshallAttribute(n, "active", true));
|
||||
settings.setFileLoggingAbsoluteTimestamp(unmarshallAttribute(n, "absolutetimestamp", false));
|
||||
|
||||
} else if (n.getNodeType() == ELEMENT_NODE && n.getNodeName().equalsIgnoreCase("plugins")) {
|
||||
Map<String, String> pluginPorts = new HashMap<String, String>();
|
||||
NodeList pluginNodes = n.getChildNodes();
|
||||
for (int j = 0; j < pluginNodes.getLength(); j++) {
|
||||
Node pluginNode = pluginNodes.item(j);
|
||||
if (pluginNode.getNodeType() == ELEMENT_NODE && pluginNode.getNodeName().equalsIgnoreCase("plugin")) {
|
||||
String id = unmarshallAttribute(pluginNode, "id", null);
|
||||
if (id == null || id.trim().length() == 0) continue;
|
||||
String port = unmarshallAttribute(pluginNode, "port", null);
|
||||
if (port == null || port.trim().length() == 0) continue;
|
||||
pluginPorts.put(id.trim(), port.trim());
|
||||
}
|
||||
}
|
||||
settings.setLoggerPluginPorts(pluginPorts);
|
||||
}
|
||||
}
|
||||
return settings;
|
||||
|
|
|
@ -6,9 +6,9 @@ warning.generated-file=DO NOT EDIT. This file is automatically generated.
|
|||
# basic version name and number properties
|
||||
# name.package should be a single word, since it's used for things like the jar file
|
||||
name.package=RomRaider
|
||||
description.package=RomRaider ROM Editing Suite
|
||||
description.package=RomRaider ROM Editing and Logging Suite
|
||||
name.organization=RomRaider.com
|
||||
name.maintainer=Jared Gould
|
||||
name.maintainer=Paul Brunckhorst
|
||||
email.maintainer=
|
||||
|
||||
supporturl=http://www.romraider.com
|
||||
|
@ -22,7 +22,7 @@ version.minor=5
|
|||
version.patch=3
|
||||
version.buildnumber=${buildnumber}
|
||||
version.extra=Beta
|
||||
version.extra1=RC3
|
||||
version.extra1=RC4
|
||||
|
||||
# the starting class for the application
|
||||
class.start=com.romraider.ECUExec
|
||||
|
|
Loading…
Reference in New Issue