mirror of https://github.com/rusefi/RomRaider.git
updated logger file logging control
git-svn-id: http://svn.3splooges.com/romraider-arch/trunk@465 d2e2e1cd-ba16-0410-be16-b7c4453c7c2d
This commit is contained in:
parent
0f935a4896
commit
586d0dd1ed
|
@ -113,7 +113,6 @@ public final class EcuLogger extends JFrame implements WindowListener, PropertyC
|
|||
private static final String ENGINUITY_ECU_LOGGER_TITLE = "Enginuity ECU Logger";
|
||||
private static final String HEADING_PARAMETERS = "Parameters";
|
||||
private static final String HEADING_SWITCHES = "Switches";
|
||||
private final String id;
|
||||
private Settings settings;
|
||||
private LoggerController controller;
|
||||
private JLabel messageLabel;
|
||||
|
@ -143,7 +142,6 @@ public final class EcuLogger extends JFrame implements WindowListener, PropertyC
|
|||
|
||||
public EcuLogger(Settings settings) {
|
||||
super(ENGINUITY_ECU_LOGGER_TITLE);
|
||||
id = System.currentTimeMillis() + "_" + hashCode();
|
||||
bootstrap(settings);
|
||||
initControllerListeners();
|
||||
initUserInterface();
|
||||
|
@ -257,7 +255,7 @@ public final class EcuLogger extends JFrame implements WindowListener, PropertyC
|
|||
|
||||
private void initFileLoggingController(final EcuSwitch fileLoggingControllerSwitch) {
|
||||
// add logger and setup callback
|
||||
controller.addLogger(id, fileLoggingControllerSwitch, new LoggerCallback() {
|
||||
controller.setFileLoggerSwitch(fileLoggingControllerSwitch, new LoggerCallback() {
|
||||
public void callback(byte[] bytes) {
|
||||
// update handlers
|
||||
double value = fileLoggingControllerSwitch.getSelectedConvertor().convert(bytes);
|
||||
|
|
|
@ -23,10 +23,13 @@ package enginuity.logger.comms.controller;
|
|||
|
||||
import enginuity.logger.comms.query.LoggerCallback;
|
||||
import enginuity.logger.definition.EcuData;
|
||||
import enginuity.logger.definition.EcuSwitch;
|
||||
import enginuity.logger.ui.StatusChangeListener;
|
||||
|
||||
public interface LoggerController {
|
||||
|
||||
void setFileLoggerSwitch(EcuSwitch ecuSwitch, LoggerCallback callback);
|
||||
|
||||
void addLogger(String callerId, EcuData ecuData, LoggerCallback callback);
|
||||
|
||||
void removeLogger(String callerId, EcuData ecuData);
|
||||
|
|
|
@ -27,6 +27,7 @@ import enginuity.logger.comms.manager.QueryManagerImpl;
|
|||
import enginuity.logger.comms.query.EcuInitCallback;
|
||||
import enginuity.logger.comms.query.LoggerCallback;
|
||||
import enginuity.logger.definition.EcuData;
|
||||
import enginuity.logger.definition.EcuSwitch;
|
||||
import enginuity.logger.ui.MessageListener;
|
||||
import enginuity.logger.ui.StatusChangeListener;
|
||||
import static enginuity.util.ParamChecker.checkNotNull;
|
||||
|
@ -44,6 +45,12 @@ public final class LoggerControllerImpl implements LoggerController {
|
|||
queryManager.addListener(listener);
|
||||
}
|
||||
|
||||
public void setFileLoggerSwitch(EcuSwitch ecuSwitch, LoggerCallback callback) {
|
||||
checkNotNull(ecuSwitch, callback);
|
||||
System.out.println("Setting file logger switch: " + ecuSwitch.getName());
|
||||
queryManager.setFileLoggerQuery(ecuSwitch, callback);
|
||||
}
|
||||
|
||||
public void addLogger(String callerId, EcuData ecuData, LoggerCallback callback) {
|
||||
checkNotNull(ecuData, callback);
|
||||
System.out.println("Adding logger: " + ecuData.getName());
|
||||
|
|
|
@ -23,10 +23,13 @@ package enginuity.logger.comms.manager;
|
|||
|
||||
import enginuity.logger.comms.query.LoggerCallback;
|
||||
import enginuity.logger.definition.EcuData;
|
||||
import enginuity.logger.definition.EcuSwitch;
|
||||
import enginuity.logger.ui.StatusChangeListener;
|
||||
|
||||
public interface QueryManager extends Runnable {
|
||||
|
||||
void setFileLoggerQuery(EcuSwitch ecuSwitch, LoggerCallback callback);
|
||||
|
||||
void addQuery(String callerId, EcuData ecuData, LoggerCallback callback);
|
||||
|
||||
void removeQuery(String callerId, EcuData ecuData);
|
||||
|
@ -36,5 +39,4 @@ public interface QueryManager extends Runnable {
|
|||
void stop();
|
||||
|
||||
void addListener(StatusChangeListener listener);
|
||||
|
||||
}
|
||||
|
|
|
@ -31,6 +31,7 @@ import enginuity.logger.comms.query.LoggerCallback;
|
|||
import enginuity.logger.comms.query.RegisteredQuery;
|
||||
import enginuity.logger.comms.query.RegisteredQueryImpl;
|
||||
import enginuity.logger.definition.EcuData;
|
||||
import enginuity.logger.definition.EcuSwitch;
|
||||
import enginuity.logger.ui.MessageListener;
|
||||
import enginuity.logger.ui.StatusChangeListener;
|
||||
import static enginuity.util.HexUtil.asHex;
|
||||
|
@ -54,6 +55,7 @@ public final class QueryManagerImpl implements QueryManager {
|
|||
private final Settings settings;
|
||||
private final EcuInitCallback ecuInitCallback;
|
||||
private final MessageListener messageListener;
|
||||
private RegisteredQuery fileLoggerQuery;
|
||||
private Thread queryManagerThread;
|
||||
private boolean started;
|
||||
private boolean stop;
|
||||
|
@ -70,6 +72,11 @@ public final class QueryManagerImpl implements QueryManager {
|
|||
listeners.add(listener);
|
||||
}
|
||||
|
||||
public void setFileLoggerQuery(EcuSwitch ecuSwitch, LoggerCallback callback) {
|
||||
checkNotNull(ecuSwitch, callback);
|
||||
fileLoggerQuery = new RegisteredQueryImpl(ecuSwitch, callback);
|
||||
}
|
||||
|
||||
public synchronized void addQuery(String callerId, EcuData ecuData, LoggerCallback callback) {
|
||||
checkNotNull(callerId, ecuData, callback);
|
||||
addList.put(buildQueryId(callerId, ecuData), new RegisteredQueryImpl(ecuData, callback));
|
||||
|
@ -145,7 +152,11 @@ public final class QueryManagerImpl implements QueryManager {
|
|||
messageListener.reportMessage("Select parameters to be logged...");
|
||||
sleep(1000L);
|
||||
} else {
|
||||
txManager.sendQueries(queryMap.values());
|
||||
List<RegisteredQuery> queries = new ArrayList<RegisteredQuery>(queryMap.values());
|
||||
if (fileLoggerQuery != null) {
|
||||
queries.add(fileLoggerQuery);
|
||||
}
|
||||
txManager.sendQueries(queries);
|
||||
count++;
|
||||
messageListener.reportMessage("Querying ECU...");
|
||||
messageListener.reportStats(buildStatsMessage(start, count));
|
||||
|
|
Loading…
Reference in New Issue