Add support to log from External sensors only by unchecking both ECU/TCU

This commit is contained in:
Dale Schultz 2013-03-09 13:57:56 -05:00
parent 197554daaf
commit 58d18c851c
3 changed files with 84 additions and 41 deletions

View File

@ -116,6 +116,7 @@ public class Settings implements Serializable {
private boolean fileLoggingControllerSwitchActive = true;
private boolean fileLoggingAbsoluteTimestamp;
private String logfileNameText;
private boolean logExternalsOnly;
private Dimension loggerWindowSize = new Dimension(1000, 600);
private Point loggerWindowLocation = new Point();
@ -131,7 +132,7 @@ public class Settings implements Serializable {
private double loggerDividerLocation = 400;
private String loggerDebuggingLevel = "info";
private static String j2534Device;
private static String j2534Protocol = "ISO9141";
private static String j2534Protocol = "ISO15765"; // ISO9141 ISO15765
private String tableClipboardFormat = DEFAULT_CLIPBOARD_FORMAT; // Currently 2 options. Default and Airboy. Custom is not hooked up.
private String tableHeader = DEFAULT_TABLE_HEADER;
@ -639,4 +640,12 @@ public class Settings implements Serializable {
public void setTableIconScale(int scale) {
this.tableIconScale = scale;
}
public void setLogExternalsOnly(boolean state) {
this.logExternalsOnly = state;
}
public boolean isLogExternalsOnly() {
return logExternalsOnly;
}
}

View File

@ -197,8 +197,8 @@ public final class EcuLogger extends AbstractFrame implements MessageListener {
private static final String HEADING_EXTERNAL = "External";
private static final String CAL_ID_LABEL = "CAL ID";
private static final String FILE_NAME_EXTENTION = "Right-click to select or type text to add to the saved logfile name.";
private static final String ECU_TEXT = "Engine Control Unit Polling";
private static final String TCU_TEXT = "Transmission Control Unit Polling";
private static final String ECU_TEXT = "Engine Control Unit Polling. Uncheck both ECU & TCU for Externals logging only";
private static final String TCU_TEXT = "Transmission Control Unit Polling. Un-check both ECU & TCU for Externals logging only";
private static final String[] LOG_FILE_TEXT = {"1st PT","2nd PT","3rd PT", // PT = Part Throttle
"4th PT","5th PT","6th PT",
"1st WOT","2nd WOT","3rd WOT",
@ -1177,7 +1177,13 @@ public final class EcuLogger extends AbstractFrame implements MessageListener {
public void actionPerformed(ActionEvent actionEvent) {
stopLogging();
tcuCheckBox.setSelected(false);
setTargetEcu();
if (ecuCheckBox.isSelected()) {
settings.setLogExternalsOnly(false);
setTargetEcu();
}
else {
settings.setLogExternalsOnly(true);
}
startLogging();
}
});
@ -1186,7 +1192,13 @@ public final class EcuLogger extends AbstractFrame implements MessageListener {
public void actionPerformed(ActionEvent actionEvent) {
stopLogging();
ecuCheckBox.setSelected(false);
setTargetTcu();
if (tcuCheckBox.isSelected()) {
settings.setLogExternalsOnly(false);
setTargetTcu();
}
else {
settings.setLogExternalsOnly(true);
}
startLogging();
}
});

View File

@ -67,6 +67,7 @@ public final class QueryManagerImpl implements QueryManager {
private static final PollingState pollState = new PollingStateImpl();
private static final String ECU = "ECU";
private static final String TCU = "TCU";
private static final String EXT = "Externals";
private final Settings settings;
private final EcuInitCallback ecuInitCallback;
private final MessageListener messageListener;
@ -135,9 +136,13 @@ public final class QueryManagerImpl implements QueryManager {
stop = false;
while (!stop) {
notifyConnecting();
if (doEcuInit(settings.getDestinationId())) {
if (!settings.isLogExternalsOnly() &&
doEcuInit(settings.getDestinationId())) {
notifyReading();
runLogger(settings.getDestinationId());
} else if (settings.isLogExternalsOnly()) {
notifyReading();
runLogger((byte) -1);
} else {
sleep(1000L);
}
@ -191,6 +196,9 @@ public final class QueryManagerImpl implements QueryManager {
private void runLogger(byte id) {
String target = null;
if (id == -1){
target = EXT;
}
if (id == 0x10){
target = ECU;
}
@ -198,7 +206,8 @@ public final class QueryManagerImpl implements QueryManager {
target = TCU;
}
TransmissionManager txManager = new TransmissionManagerImpl(settings);
long start = System.currentTimeMillis();
long start = currentTimeMillis();
long end = currentTimeMillis();
int count = 0;
try {
txManager.start();
@ -207,7 +216,8 @@ public final class QueryManagerImpl implements QueryManager {
pollState.setFastPoll(settings.isFastPoll());
updateQueryList();
if (queryMap.isEmpty()) {
if (pollState.isLastQuery() && pollState.getCurrentState() == 0) {
if (pollState.isLastQuery() &&
pollState.getCurrentState() == 0) {
endEcuQueries(txManager);
pollState.setLastState(0);
}
@ -216,44 +226,53 @@ public final class QueryManagerImpl implements QueryManager {
messageListener.reportMessage("Select parameters to be logged...");
sleep(1000L);
} else {
final long end = currentTimeMillis() + 1L; // update once every 1msec
final List<EcuQuery> ecuQueries = filterEcuQueries(queryMap.values());
if (!ecuQueries.isEmpty()) {
sendEcuQueries(txManager);
if (!pollState.isFastPoll() && lastPollState) {
endEcuQueries(txManager);
}
if (pollState.isFastPoll()) {
if (pollState.getCurrentState() == 0 && pollState.isNewQuery()) {
pollState.setCurrentState(1);
pollState.setNewQuery(false);
end = currentTimeMillis() + 1L; // update once every 1msec
final List<EcuQuery> ecuQueries =
filterEcuQueries(queryMap.values());
if (!settings.isLogExternalsOnly()) {
if (!ecuQueries.isEmpty()) {
sendEcuQueries(txManager);
if (!pollState.isFastPoll() && lastPollState) {
endEcuQueries(txManager);
}
if (pollState.getCurrentState() == 0 && !pollState.isNewQuery()) {
pollState.setCurrentState(1);
if (pollState.isFastPoll()) {
if (pollState.getCurrentState() == 0 &&
pollState.isNewQuery()) {
pollState.setCurrentState(1);
pollState.setNewQuery(false);
}
if (pollState.getCurrentState() == 0 &&
!pollState.isNewQuery()) {
pollState.setCurrentState(1);
}
if (pollState.getCurrentState() == 1 &&
pollState.isNewQuery()) {
pollState.setCurrentState(0);
pollState.setLastState(1);
pollState.setNewQuery(false);
}
if (pollState.getCurrentState() == 1 &&
!pollState.isNewQuery()) {
pollState.setLastState(1);
}
pollState.setLastQuery(true);
}
if (pollState.getCurrentState() == 1 && pollState.isNewQuery()) {
else {
pollState.setCurrentState(0);
pollState.setLastState(1);
pollState.setLastState(0);
pollState.setNewQuery(false);
}
if (pollState.getCurrentState() == 1 && !pollState.isNewQuery()) {
pollState.setLastState(1);
}
pollState.setLastQuery(true);
lastPollState = pollState.isFastPoll();
}
else {
pollState.setCurrentState(0);
pollState.setLastState(0);
pollState.setNewQuery(false);
}
lastPollState = pollState.isFastPoll();
}
else {
if (pollState.isLastQuery() && pollState.getLastState() == 1) {
endEcuQueries(txManager);
pollState.setLastState(0);
pollState.setCurrentState(0);
pollState.setNewQuery(true);
if (pollState.isLastQuery() &&
pollState.getLastState() == 1) {
endEcuQueries(txManager);
pollState.setLastState(0);
pollState.setCurrentState(0);
pollState.setNewQuery(true);
}
}
}
sendExternalQueries();
@ -372,9 +391,12 @@ public final class QueryManagerImpl implements QueryManager {
}
private String buildStatsMessage(long start, int count) {
String state = "Slow:";
String state = "Slow-K:";
if (pollState.isFastPoll()) {
state = "Fast:";
state = "Fast-K:";
}
if (settings.isLogExternalsOnly()) {
state = "Externals:";
}
double duration = ((double) (System.currentTimeMillis() - start)) / 1000.0;
String result = String.format(