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.EcuSwitch;
|
||||
import enginuity.logger.ecu.definition.ExternalData;
|
||||
import enginuity.logger.ecu.definition.ExternalDataImpl;
|
||||
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.ExternalDataSourceLoaderImpl;
|
||||
import enginuity.logger.ecu.profile.UserProfile;
|
||||
|
@ -114,6 +117,7 @@ import java.awt.event.WindowListener;
|
|||
import java.beans.PropertyChangeEvent;
|
||||
import java.beans.PropertyChangeListener;
|
||||
import java.io.File;
|
||||
import java.util.ArrayList;
|
||||
import static java.util.Collections.sort;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
|
@ -171,13 +175,14 @@ public final class EcuLogger extends JFrame implements WindowListener, PropertyC
|
|||
private DashboardUpdateHandler dashboardUpdateHandler;
|
||||
private EcuInit ecuInit;
|
||||
private JToggleButton logToFileButton;
|
||||
private List<ExternalDataSource> externalDataSources;
|
||||
|
||||
public EcuLogger(Settings settings) {
|
||||
super(ENGINUITY_ECU_LOGGER_TITLE);
|
||||
bootstrap(settings);
|
||||
loadEcuDefs();
|
||||
loadLoggerConfig();
|
||||
loadLoggerPlugins();
|
||||
loadLoggerParams();
|
||||
initControllerListeners();
|
||||
initUserInterface();
|
||||
initDataUpdateHandlers();
|
||||
|
@ -206,7 +211,7 @@ public final class EcuLogger extends JFrame implements WindowListener, PropertyC
|
|||
}
|
||||
ecuIdLabel.setText(buildEcuInfoLabelText(ECU_ID_LABEL, 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);
|
||||
}
|
||||
|
||||
private void loadLoggerParams() {
|
||||
loadLoggerConfig();
|
||||
loadFromExternalDataSources();
|
||||
}
|
||||
|
||||
private void initControllerListeners() {
|
||||
controller.addListener(dataTabBroker);
|
||||
controller.addListener(graphTabBroker);
|
||||
|
@ -309,8 +319,17 @@ public final class EcuLogger extends JFrame implements WindowListener, PropertyC
|
|||
private void loadLoggerPlugins() {
|
||||
try {
|
||||
ExternalDataSourceLoader dataSourceLoader = new ExternalDataSourceLoaderImpl();
|
||||
dataSourceLoader.loadFromExternalDataSources();
|
||||
loadExternalDatas(dataSourceLoader.getExternalDatas());
|
||||
dataSourceLoader.loadExternalDataSources();
|
||||
externalDataSources = dataSourceLoader.getExternalDataSources();
|
||||
} catch (Exception e) {
|
||||
reportError(e);
|
||||
}
|
||||
}
|
||||
|
||||
private void loadFromExternalDataSources() {
|
||||
try {
|
||||
List<ExternalData> externalDatas = getExternalData(externalDataSources);
|
||||
loadExternalDatas(externalDatas);
|
||||
} catch (Exception e) {
|
||||
reportError(e);
|
||||
}
|
||||
|
@ -334,6 +353,7 @@ public final class EcuLogger extends JFrame implements WindowListener, PropertyC
|
|||
private void initFileLoggingController(final EcuSwitch fileLoggingControllerSwitch) {
|
||||
controller.setFileLoggerSwitchMonitor(new FileLoggerControllerSwitchMonitorImpl(fileLoggingControllerSwitch, new FileLoggerControllerSwitchHandler() {
|
||||
boolean oldDefogStatus = false;
|
||||
|
||||
public void handleSwitch(double switchValue) {
|
||||
boolean logToFile = (int) switchValue == 1;
|
||||
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) {
|
||||
clearExternalTableModels();
|
||||
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) {
|
||||
if (title != null) {
|
||||
if (!title.startsWith(ENGINUITY_ECU_LOGGER_TITLE)) {
|
||||
|
|
|
@ -15,7 +15,7 @@ public interface ExternalDataSource {
|
|||
// Suggested Methods of interest
|
||||
// *****************************
|
||||
|
||||
public void setCommPortChoice(String commPort);
|
||||
public void setPort(String portName);
|
||||
|
||||
public void connect();
|
||||
|
||||
|
|
|
@ -1,12 +1,10 @@
|
|||
package enginuity.logger.ecu.external;
|
||||
|
||||
import enginuity.logger.ecu.definition.ExternalData;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public interface ExternalDataSourceLoader {
|
||||
|
||||
void loadFromExternalDataSources();
|
||||
void loadExternalDataSources();
|
||||
|
||||
List<ExternalData> getExternalDatas();
|
||||
List<ExternalDataSource> getExternalDataSources();
|
||||
}
|
||||
|
|
|
@ -1,7 +1,5 @@
|
|||
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.exception.ConfigurationException;
|
||||
import static enginuity.util.ParamChecker.isNullOrEmpty;
|
||||
|
@ -13,13 +11,13 @@ import java.util.List;
|
|||
import java.util.Properties;
|
||||
|
||||
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 {
|
||||
File pluginsDir = new File("./plugins");
|
||||
if (pluginsDir.exists() && pluginsDir.isDirectory()) {
|
||||
externalDatas = new ArrayList<ExternalData>();
|
||||
externalDataSources = new ArrayList<ExternalDataSource>();
|
||||
File[] pluginPropertyFiles = pluginsDir.listFiles(new PluginFilenameFilter());
|
||||
for (File pluginPropertyFile : pluginPropertyFiles) {
|
||||
Properties pluginProps = new Properties();
|
||||
|
@ -32,10 +30,7 @@ public final class ExternalDataSourceLoaderImpl implements ExternalDataSourceLoa
|
|||
Class<?> dataSourceClass = getClass().getClassLoader().loadClass(datasourceClassName);
|
||||
if (dataSourceClass != null && ExternalDataSource.class.isAssignableFrom(dataSourceClass)) {
|
||||
ExternalDataSource dataSource = (ExternalDataSource) dataSourceClass.newInstance();
|
||||
List<ExternalDataItem> dataItems = dataSource.getDataItems();
|
||||
for (ExternalDataItem dataItem : dataItems) {
|
||||
externalDatas.add(new ExternalDataImpl(dataItem));
|
||||
}
|
||||
externalDataSources.add(dataSource);
|
||||
System.out.println("Plugin loaded: " + dataSource.getName() + " v" + dataSource.getVersion());
|
||||
}
|
||||
} catch (Throwable t) {
|
||||
|
@ -54,7 +49,7 @@ public final class ExternalDataSourceLoaderImpl implements ExternalDataSourceLoa
|
|||
}
|
||||
}
|
||||
|
||||
public List<ExternalData> getExternalDatas() {
|
||||
return externalDatas;
|
||||
public List<ExternalDataSource> getExternalDataSources() {
|
||||
return externalDataSources;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -44,7 +44,7 @@ public final class TestExternalDataSource implements ExternalDataSource {
|
|||
// 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(Exception e);
|
||||
|
||||
void reportError(String error, Exception e);
|
||||
}
|
||||
|
|
|
@ -8,6 +8,7 @@ import static java.util.Arrays.asList;
|
|||
import java.util.List;
|
||||
|
||||
public final class Lc1DataSource implements ExternalDataSource {
|
||||
private String portName = "COM6";
|
||||
|
||||
public String getName() {
|
||||
return "Innovate LC-1 Datasource";
|
||||
|
@ -18,12 +19,13 @@ public final class Lc1DataSource implements ExternalDataSource {
|
|||
}
|
||||
|
||||
public List<ExternalDataItem> getDataItems() {
|
||||
Lc1Connection connection = new Lc1Connection(new InnovateConnectionProperties(), "COM6");
|
||||
Lc1Connection connection = new Lc1Connection(new InnovateConnectionProperties(), portName);
|
||||
InnovateController controller = new InnovateControllerImpl(connection);
|
||||
return asList(controller.getDataItem());
|
||||
}
|
||||
|
||||
public void setCommPortChoice(String commPort) {
|
||||
public void setPort(String portName) {
|
||||
this.portName = portName;
|
||||
}
|
||||
|
||||
public void connect() {
|
||||
|
|
|
@ -35,7 +35,7 @@ public final class UtecDataSource implements ExternalDataSource {
|
|||
// Suggested Methods of interest
|
||||
// *****************************
|
||||
|
||||
public void setCommPortChoice(String commPort){
|
||||
public void setPort(String commPort){
|
||||
UtecInterface.setPortChoice(commPort);
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue