mirror of https://github.com/rusefi/RomRaider.git
updated lc-1 support (unfinished)
git-svn-id: http://svn.3splooges.com/romraider-arch/trunk@694 d2e2e1cd-ba16-0410-be16-b7c4453c7c2d
This commit is contained in:
parent
d6d5a241ff
commit
a202ef447a
|
@ -33,7 +33,10 @@ import enginuity.logger.ecu.definition.EcuDefinition;
|
||||||
import enginuity.logger.ecu.definition.EcuParameter;
|
import enginuity.logger.ecu.definition.EcuParameter;
|
||||||
import enginuity.logger.ecu.definition.EcuSwitch;
|
import enginuity.logger.ecu.definition.EcuSwitch;
|
||||||
import enginuity.logger.ecu.definition.ExternalData;
|
import enginuity.logger.ecu.definition.ExternalData;
|
||||||
|
import enginuity.logger.ecu.definition.ExternalDataImpl;
|
||||||
import enginuity.logger.ecu.definition.LoggerData;
|
import enginuity.logger.ecu.definition.LoggerData;
|
||||||
|
import enginuity.logger.ecu.external.ExternalDataItem;
|
||||||
|
import enginuity.logger.ecu.external.ExternalDataSource;
|
||||||
import enginuity.logger.ecu.external.ExternalDataSourceLoader;
|
import enginuity.logger.ecu.external.ExternalDataSourceLoader;
|
||||||
import enginuity.logger.ecu.external.ExternalDataSourceLoaderImpl;
|
import enginuity.logger.ecu.external.ExternalDataSourceLoaderImpl;
|
||||||
import enginuity.logger.ecu.profile.UserProfile;
|
import enginuity.logger.ecu.profile.UserProfile;
|
||||||
|
@ -114,6 +117,7 @@ import java.awt.event.WindowListener;
|
||||||
import java.beans.PropertyChangeEvent;
|
import java.beans.PropertyChangeEvent;
|
||||||
import java.beans.PropertyChangeListener;
|
import java.beans.PropertyChangeListener;
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
|
import java.util.ArrayList;
|
||||||
import static java.util.Collections.sort;
|
import static java.util.Collections.sort;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
@ -171,13 +175,14 @@ public final class EcuLogger extends JFrame implements WindowListener, PropertyC
|
||||||
private DashboardUpdateHandler dashboardUpdateHandler;
|
private DashboardUpdateHandler dashboardUpdateHandler;
|
||||||
private EcuInit ecuInit;
|
private EcuInit ecuInit;
|
||||||
private JToggleButton logToFileButton;
|
private JToggleButton logToFileButton;
|
||||||
|
private List<ExternalDataSource> externalDataSources;
|
||||||
|
|
||||||
public EcuLogger(Settings settings) {
|
public EcuLogger(Settings settings) {
|
||||||
super(ENGINUITY_ECU_LOGGER_TITLE);
|
super(ENGINUITY_ECU_LOGGER_TITLE);
|
||||||
bootstrap(settings);
|
bootstrap(settings);
|
||||||
loadEcuDefs();
|
loadEcuDefs();
|
||||||
loadLoggerConfig();
|
|
||||||
loadLoggerPlugins();
|
loadLoggerPlugins();
|
||||||
|
loadLoggerParams();
|
||||||
initControllerListeners();
|
initControllerListeners();
|
||||||
initUserInterface();
|
initUserInterface();
|
||||||
initDataUpdateHandlers();
|
initDataUpdateHandlers();
|
||||||
|
@ -206,7 +211,7 @@ public final class EcuLogger extends JFrame implements WindowListener, PropertyC
|
||||||
}
|
}
|
||||||
ecuIdLabel.setText(buildEcuInfoLabelText(ECU_ID_LABEL, ecuId));
|
ecuIdLabel.setText(buildEcuInfoLabelText(ECU_ID_LABEL, ecuId));
|
||||||
System.out.println("Loading logger config for new ECU (ecuid: " + ecuId + ")...");
|
System.out.println("Loading logger config for new ECU (ecuid: " + ecuId + ")...");
|
||||||
loadLoggerConfig();
|
loadLoggerParams();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -244,6 +249,11 @@ public final class EcuLogger extends JFrame implements WindowListener, PropertyC
|
||||||
dashboardTabExternalListTableModel = new ParameterListTableModel(dashboardTabBroker, HEADING_EXTERNAL);
|
dashboardTabExternalListTableModel = new ParameterListTableModel(dashboardTabBroker, HEADING_EXTERNAL);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void loadLoggerParams() {
|
||||||
|
loadLoggerConfig();
|
||||||
|
loadFromExternalDataSources();
|
||||||
|
}
|
||||||
|
|
||||||
private void initControllerListeners() {
|
private void initControllerListeners() {
|
||||||
controller.addListener(dataTabBroker);
|
controller.addListener(dataTabBroker);
|
||||||
controller.addListener(graphTabBroker);
|
controller.addListener(graphTabBroker);
|
||||||
|
@ -309,8 +319,17 @@ public final class EcuLogger extends JFrame implements WindowListener, PropertyC
|
||||||
private void loadLoggerPlugins() {
|
private void loadLoggerPlugins() {
|
||||||
try {
|
try {
|
||||||
ExternalDataSourceLoader dataSourceLoader = new ExternalDataSourceLoaderImpl();
|
ExternalDataSourceLoader dataSourceLoader = new ExternalDataSourceLoaderImpl();
|
||||||
dataSourceLoader.loadFromExternalDataSources();
|
dataSourceLoader.loadExternalDataSources();
|
||||||
loadExternalDatas(dataSourceLoader.getExternalDatas());
|
externalDataSources = dataSourceLoader.getExternalDataSources();
|
||||||
|
} catch (Exception e) {
|
||||||
|
reportError(e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void loadFromExternalDataSources() {
|
||||||
|
try {
|
||||||
|
List<ExternalData> externalDatas = getExternalData(externalDataSources);
|
||||||
|
loadExternalDatas(externalDatas);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
reportError(e);
|
reportError(e);
|
||||||
}
|
}
|
||||||
|
@ -334,6 +353,7 @@ public final class EcuLogger extends JFrame implements WindowListener, PropertyC
|
||||||
private void initFileLoggingController(final EcuSwitch fileLoggingControllerSwitch) {
|
private void initFileLoggingController(final EcuSwitch fileLoggingControllerSwitch) {
|
||||||
controller.setFileLoggerSwitchMonitor(new FileLoggerControllerSwitchMonitorImpl(fileLoggingControllerSwitch, new FileLoggerControllerSwitchHandler() {
|
controller.setFileLoggerSwitchMonitor(new FileLoggerControllerSwitchMonitorImpl(fileLoggingControllerSwitch, new FileLoggerControllerSwitchHandler() {
|
||||||
boolean oldDefogStatus = false;
|
boolean oldDefogStatus = false;
|
||||||
|
|
||||||
public void handleSwitch(double switchValue) {
|
public void handleSwitch(double switchValue) {
|
||||||
boolean logToFile = (int) switchValue == 1;
|
boolean logToFile = (int) switchValue == 1;
|
||||||
if (settings.isFileLoggingControllerSwitchActive() && logToFile != oldDefogStatus) {
|
if (settings.isFileLoggingControllerSwitchActive() && logToFile != oldDefogStatus) {
|
||||||
|
@ -444,6 +464,21 @@ public final class EcuLogger extends JFrame implements WindowListener, PropertyC
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private List<ExternalData> getExternalData(List<ExternalDataSource> externalDataSources) {
|
||||||
|
List<ExternalData> externalDatas = new ArrayList<ExternalData>();
|
||||||
|
for (ExternalDataSource dataSource : externalDataSources) {
|
||||||
|
try {
|
||||||
|
List<ExternalDataItem> dataItems = dataSource.getDataItems();
|
||||||
|
for (ExternalDataItem item : dataItems) {
|
||||||
|
externalDatas.add(new ExternalDataImpl(item));
|
||||||
|
}
|
||||||
|
} catch (Exception e) {
|
||||||
|
reportError("Error loading plugin: " + dataSource.getName() + " v" + dataSource.getVersion(), e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return externalDatas;
|
||||||
|
}
|
||||||
|
|
||||||
private void loadExternalDatas(List<ExternalData> externalDatas) {
|
private void loadExternalDatas(List<ExternalData> externalDatas) {
|
||||||
clearExternalTableModels();
|
clearExternalTableModels();
|
||||||
sort(externalDatas, new EcuDataComparator());
|
sort(externalDatas, new EcuDataComparator());
|
||||||
|
@ -865,6 +900,13 @@ public final class EcuLogger extends JFrame implements WindowListener, PropertyC
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void reportError(String error, Exception e) {
|
||||||
|
if (e != null) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
reportError(error);
|
||||||
|
}
|
||||||
|
|
||||||
public void setTitle(String title) {
|
public void setTitle(String title) {
|
||||||
if (title != null) {
|
if (title != null) {
|
||||||
if (!title.startsWith(ENGINUITY_ECU_LOGGER_TITLE)) {
|
if (!title.startsWith(ENGINUITY_ECU_LOGGER_TITLE)) {
|
||||||
|
|
|
@ -15,7 +15,7 @@ public interface ExternalDataSource {
|
||||||
// Suggested Methods of interest
|
// Suggested Methods of interest
|
||||||
// *****************************
|
// *****************************
|
||||||
|
|
||||||
public void setCommPortChoice(String commPort);
|
public void setPort(String portName);
|
||||||
|
|
||||||
public void connect();
|
public void connect();
|
||||||
|
|
||||||
|
|
|
@ -1,12 +1,10 @@
|
||||||
package enginuity.logger.ecu.external;
|
package enginuity.logger.ecu.external;
|
||||||
|
|
||||||
import enginuity.logger.ecu.definition.ExternalData;
|
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
public interface ExternalDataSourceLoader {
|
public interface ExternalDataSourceLoader {
|
||||||
|
|
||||||
void loadFromExternalDataSources();
|
void loadExternalDataSources();
|
||||||
|
|
||||||
List<ExternalData> getExternalDatas();
|
List<ExternalDataSource> getExternalDataSources();
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,7 +1,5 @@
|
||||||
package enginuity.logger.ecu.external;
|
package enginuity.logger.ecu.external;
|
||||||
|
|
||||||
import enginuity.logger.ecu.definition.ExternalData;
|
|
||||||
import enginuity.logger.ecu.definition.ExternalDataImpl;
|
|
||||||
import enginuity.logger.ecu.definition.plugin.PluginFilenameFilter;
|
import enginuity.logger.ecu.definition.plugin.PluginFilenameFilter;
|
||||||
import enginuity.logger.ecu.exception.ConfigurationException;
|
import enginuity.logger.ecu.exception.ConfigurationException;
|
||||||
import static enginuity.util.ParamChecker.isNullOrEmpty;
|
import static enginuity.util.ParamChecker.isNullOrEmpty;
|
||||||
|
@ -13,13 +11,13 @@ import java.util.List;
|
||||||
import java.util.Properties;
|
import java.util.Properties;
|
||||||
|
|
||||||
public final class ExternalDataSourceLoaderImpl implements ExternalDataSourceLoader {
|
public final class ExternalDataSourceLoaderImpl implements ExternalDataSourceLoader {
|
||||||
private List<ExternalData> externalDatas = new ArrayList<ExternalData>();
|
private List<ExternalDataSource> externalDataSources = new ArrayList<ExternalDataSource>();
|
||||||
|
|
||||||
public void loadFromExternalDataSources() {
|
public void loadExternalDataSources() {
|
||||||
try {
|
try {
|
||||||
File pluginsDir = new File("./plugins");
|
File pluginsDir = new File("./plugins");
|
||||||
if (pluginsDir.exists() && pluginsDir.isDirectory()) {
|
if (pluginsDir.exists() && pluginsDir.isDirectory()) {
|
||||||
externalDatas = new ArrayList<ExternalData>();
|
externalDataSources = new ArrayList<ExternalDataSource>();
|
||||||
File[] pluginPropertyFiles = pluginsDir.listFiles(new PluginFilenameFilter());
|
File[] pluginPropertyFiles = pluginsDir.listFiles(new PluginFilenameFilter());
|
||||||
for (File pluginPropertyFile : pluginPropertyFiles) {
|
for (File pluginPropertyFile : pluginPropertyFiles) {
|
||||||
Properties pluginProps = new Properties();
|
Properties pluginProps = new Properties();
|
||||||
|
@ -32,10 +30,7 @@ public final class ExternalDataSourceLoaderImpl implements ExternalDataSourceLoa
|
||||||
Class<?> dataSourceClass = getClass().getClassLoader().loadClass(datasourceClassName);
|
Class<?> dataSourceClass = getClass().getClassLoader().loadClass(datasourceClassName);
|
||||||
if (dataSourceClass != null && ExternalDataSource.class.isAssignableFrom(dataSourceClass)) {
|
if (dataSourceClass != null && ExternalDataSource.class.isAssignableFrom(dataSourceClass)) {
|
||||||
ExternalDataSource dataSource = (ExternalDataSource) dataSourceClass.newInstance();
|
ExternalDataSource dataSource = (ExternalDataSource) dataSourceClass.newInstance();
|
||||||
List<ExternalDataItem> dataItems = dataSource.getDataItems();
|
externalDataSources.add(dataSource);
|
||||||
for (ExternalDataItem dataItem : dataItems) {
|
|
||||||
externalDatas.add(new ExternalDataImpl(dataItem));
|
|
||||||
}
|
|
||||||
System.out.println("Plugin loaded: " + dataSource.getName() + " v" + dataSource.getVersion());
|
System.out.println("Plugin loaded: " + dataSource.getName() + " v" + dataSource.getVersion());
|
||||||
}
|
}
|
||||||
} catch (Throwable t) {
|
} catch (Throwable t) {
|
||||||
|
@ -54,7 +49,7 @@ public final class ExternalDataSourceLoaderImpl implements ExternalDataSourceLoa
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<ExternalData> getExternalDatas() {
|
public List<ExternalDataSource> getExternalDataSources() {
|
||||||
return externalDatas;
|
return externalDataSources;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -44,7 +44,7 @@ public final class TestExternalDataSource implements ExternalDataSource {
|
||||||
// Suggested Methods of interest
|
// Suggested Methods of interest
|
||||||
// *****************************
|
// *****************************
|
||||||
|
|
||||||
public void setCommPortChoice(String commPort){
|
public void setPort(String commPort){
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -32,4 +32,6 @@ public interface MessageListener {
|
||||||
void reportError(String error);
|
void reportError(String error);
|
||||||
|
|
||||||
void reportError(Exception e);
|
void reportError(Exception e);
|
||||||
|
|
||||||
|
void reportError(String error, Exception e);
|
||||||
}
|
}
|
||||||
|
|
|
@ -8,6 +8,7 @@ import static java.util.Arrays.asList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
public final class Lc1DataSource implements ExternalDataSource {
|
public final class Lc1DataSource implements ExternalDataSource {
|
||||||
|
private String portName = "COM6";
|
||||||
|
|
||||||
public String getName() {
|
public String getName() {
|
||||||
return "Innovate LC-1 Datasource";
|
return "Innovate LC-1 Datasource";
|
||||||
|
@ -18,12 +19,13 @@ public final class Lc1DataSource implements ExternalDataSource {
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<ExternalDataItem> getDataItems() {
|
public List<ExternalDataItem> getDataItems() {
|
||||||
Lc1Connection connection = new Lc1Connection(new InnovateConnectionProperties(), "COM6");
|
Lc1Connection connection = new Lc1Connection(new InnovateConnectionProperties(), portName);
|
||||||
InnovateController controller = new InnovateControllerImpl(connection);
|
InnovateController controller = new InnovateControllerImpl(connection);
|
||||||
return asList(controller.getDataItem());
|
return asList(controller.getDataItem());
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setCommPortChoice(String commPort) {
|
public void setPort(String portName) {
|
||||||
|
this.portName = portName;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void connect() {
|
public void connect() {
|
||||||
|
|
|
@ -35,7 +35,7 @@ public final class UtecDataSource implements ExternalDataSource {
|
||||||
// Suggested Methods of interest
|
// Suggested Methods of interest
|
||||||
// *****************************
|
// *****************************
|
||||||
|
|
||||||
public void setCommPortChoice(String commPort){
|
public void setPort(String commPort){
|
||||||
UtecInterface.setPortChoice(commPort);
|
UtecInterface.setPortChoice(commPort);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue