TSHighSpeedLog
This commit is contained in:
parent
84c877f71a
commit
925c429a93
|
@ -76,7 +76,7 @@ public class BinaryProtocol implements BinaryProtocolCommands {
|
|||
private boolean isCompositeLoggerEnabled;
|
||||
private long lastLowRpmTime = System.currentTimeMillis();
|
||||
|
||||
private VcdStreamFile composite = new VcdStreamFile();
|
||||
private List<StreamFile> compositeLogs = Arrays.asList(new VcdStreamFile(), new TSHighSpeedLog());
|
||||
|
||||
public boolean isClosed;
|
||||
/**
|
||||
|
@ -200,6 +200,7 @@ public class BinaryProtocol implements BinaryProtocolCommands {
|
|||
packet[1] = Fields.TS_COMPOSITE_DISABLE;
|
||||
executeCommand(packet, "disable composite");
|
||||
isCompositeLoggerEnabled = false;
|
||||
for (StreamFile composite : compositeLogs)
|
||||
composite.close();
|
||||
}
|
||||
}
|
||||
|
@ -498,6 +499,7 @@ public class BinaryProtocol implements BinaryProtocolCommands {
|
|||
byte[] response = executeCommand(packet, "composite log", true);
|
||||
if (checkResponseCode(response, RESPONSE_OK)) {
|
||||
List<CompositeEvent> events = CompositeParser.parse(response);
|
||||
for (StreamFile composite : compositeLogs)
|
||||
composite.append(events);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -2,10 +2,36 @@ package com.rusefi.binaryprotocol;
|
|||
|
||||
import com.rusefi.composite.CompositeEvent;
|
||||
|
||||
import java.io.FileWriter;
|
||||
import java.io.IOException;
|
||||
import java.util.List;
|
||||
|
||||
public interface StreamFile {
|
||||
void append(List<CompositeEvent> events);
|
||||
public abstract class StreamFile {
|
||||
protected FileWriter writer;
|
||||
|
||||
void close();
|
||||
public StreamFile() {
|
||||
Runtime.getRuntime().addShutdownHook(new Thread(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
close();
|
||||
}
|
||||
}));
|
||||
}
|
||||
|
||||
abstract void append(List<CompositeEvent> events);
|
||||
|
||||
public synchronized void close() {
|
||||
if (writer != null) {
|
||||
try {
|
||||
writeFooter(writer);
|
||||
writer.close();
|
||||
} catch (IOException e) {
|
||||
// ignoring this one
|
||||
}
|
||||
}
|
||||
writer = null;
|
||||
}
|
||||
|
||||
protected void writeFooter(FileWriter writer) throws IOException {
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,47 @@
|
|||
package com.rusefi.binaryprotocol;
|
||||
|
||||
import com.rusefi.FileLog;
|
||||
import com.rusefi.composite.CompositeEvent;
|
||||
import com.rusefi.rusEFIVersion;
|
||||
import sun.misc.Launcher;
|
||||
|
||||
import java.io.FileWriter;
|
||||
import java.io.IOException;
|
||||
import java.io.Writer;
|
||||
import java.util.List;
|
||||
|
||||
public class TSHighSpeedLog extends StreamFile {
|
||||
private int prevTime = 0;
|
||||
|
||||
private static void writeHeader(Writer writer) throws IOException {
|
||||
writer.write("#Firmware: console" + rusEFIVersion.CONSOLE_VERSION + " firmware " + rusEFIVersion.firmwareVersion.get() + "\n");
|
||||
writer.write("PriLevel,SecLevel,Trigger,Sync,Time,ToothTime\n" +
|
||||
"Flag,Flag,Flag,Flag,ms,ms\n");
|
||||
}
|
||||
|
||||
@Override
|
||||
void append(List<CompositeEvent> events) {
|
||||
try {
|
||||
if (writer == null) {
|
||||
String fileName = FileLog.DIR + "rusEFI_trigger_log_" + FileLog.getDate() + ".csv";
|
||||
writer = new FileWriter(fileName);
|
||||
writeHeader(writer);
|
||||
}
|
||||
for (CompositeEvent event : events) {
|
||||
writer.write(event.isPrimaryTriggerAsInt() + "," + event.isSecondaryTriggerAsInt() + "," + event.isTrgAsInt() + "," + event.isSyncAsInt() + ",");
|
||||
int delta = event.getTimestamp() - prevTime;
|
||||
writer.write(event.getTimestamp() / 1000.0 + "," + delta / 1000.0 + "\n");
|
||||
prevTime = event.getTimestamp();
|
||||
}
|
||||
writer.flush();
|
||||
|
||||
} catch (IOException e) {
|
||||
// ignoring IO exceptions
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void writeFooter(FileWriter writer) throws IOException {
|
||||
writer.write("MARK 028\n");
|
||||
}
|
||||
}
|
|
@ -14,15 +14,13 @@ import java.util.List;
|
|||
*
|
||||
* @see FileLog#WIKI_URL
|
||||
*/
|
||||
public class VcdStreamFile implements StreamFile {
|
||||
public class VcdStreamFile extends StreamFile {
|
||||
private static final String TAG_PRIMARY = "t";
|
||||
private static final String TAG_SECONDARY = "s";
|
||||
private static final String TAG_TRG = "r";
|
||||
private static final String TAG_SYNC = "y";
|
||||
|
||||
private FileWriter writer;
|
||||
|
||||
public static void writeHeader(Writer writer, Date date) throws IOException {
|
||||
private static void writeHeader(Writer writer, Date date) throws IOException {
|
||||
writer.write("$date\n");
|
||||
writer.write("\t" + date + "\n");
|
||||
writer.write("$end\n" +
|
||||
|
@ -54,6 +52,14 @@ public class VcdStreamFile implements StreamFile {
|
|||
writer.flush();
|
||||
}
|
||||
|
||||
public static void writeVCD(List<CompositeEvent> events, Writer writer, Date date) throws IOException {
|
||||
writeHeader(writer, date);
|
||||
appendEvents(events, writer);
|
||||
}
|
||||
|
||||
public static void writeVCD(List<CompositeEvent> events, FileWriter fileWriter) throws IOException {
|
||||
writeVCD(events, fileWriter, new Date());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void append(List<CompositeEvent> events) {
|
||||
|
@ -68,16 +74,4 @@ public class VcdStreamFile implements StreamFile {
|
|||
// ignoring this one
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void close() {
|
||||
if (writer != null) {
|
||||
try {
|
||||
writer.close();
|
||||
} catch (IOException e) {
|
||||
// ignoring this one
|
||||
}
|
||||
}
|
||||
writer = null;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -41,12 +41,4 @@ public class CompositeParser {
|
|||
return events;
|
||||
}
|
||||
|
||||
public static void writeVCD(List<CompositeEvent> events, Writer writer, Date date) throws IOException {
|
||||
VcdStreamFile.writeHeader(writer, date);
|
||||
VcdStreamFile.appendEvents(events, writer);
|
||||
}
|
||||
|
||||
public static void writeVCD(List<CompositeEvent> events, FileWriter fileWriter) throws IOException {
|
||||
writeVCD(events, fileWriter, new Date());
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
package com.rusefi.composite.test;
|
||||
|
||||
import com.rusefi.binaryprotocol.VcdStreamFile;
|
||||
import com.rusefi.composite.CompositeEvent;
|
||||
import com.rusefi.composite.CompositeParser;
|
||||
import org.junit.Test;
|
||||
|
@ -18,6 +19,6 @@ public class CompositeParserTest {
|
|||
|
||||
StringWriter writer = new StringWriter();
|
||||
//FileWriter writer = new FileWriter("rusEFI.vcd");
|
||||
CompositeParser.writeVCD(events, writer, new Date(1590847552574L));
|
||||
VcdStreamFile.writeVCD(events, writer, new Date(1590847552574L));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,8 @@
|
|||
package com.rusefi;
|
||||
|
||||
import java.util.concurrent.atomic.AtomicReference;
|
||||
|
||||
public class rusEFIVersion {
|
||||
public static final int CONSOLE_VERSION = 20200530;
|
||||
public static AtomicReference<String> firmwareVersion = new AtomicReference<>("N/A");
|
||||
}
|
|
@ -41,8 +41,7 @@ import static com.rusefi.ui.storage.PersistentConfiguration.getConfig;
|
|||
* @see StartupFrame
|
||||
* @see EngineSnifferPanel
|
||||
*/
|
||||
public class Launcher {
|
||||
public static final int CONSOLE_VERSION = 20200530;
|
||||
public class Launcher extends rusEFIVersion {
|
||||
public static final String INPUT_FILES_PATH = System.getProperty("input_files_path", "..");
|
||||
public static final String TOOLS_PATH = System.getProperty("tools_path", ".");
|
||||
public static final String TAB_INDEX = "main_tab";
|
||||
|
@ -57,8 +56,6 @@ public class Launcher {
|
|||
|
||||
public TabbedPanel tabbedPane = new TabbedPanel();
|
||||
|
||||
public static AtomicReference<String> firmwareVersion = new AtomicReference<>("N/A");
|
||||
|
||||
private static Frame staticFrame;
|
||||
|
||||
private MainFrame mainFrame = new MainFrame(tabbedPane);
|
||||
|
|
|
@ -8,7 +8,6 @@ import java.io.ByteArrayOutputStream;
|
|||
import java.io.PrintStream;
|
||||
|
||||
import static com.rusefi.Launcher.*;
|
||||
import static javax.swing.JOptionPane.OK_OPTION;
|
||||
|
||||
/**
|
||||
* 6/30/13
|
||||
|
|
Loading…
Reference in New Issue