smarter auto-format
This commit is contained in:
parent
b08dd8cf72
commit
3213707c71
|
@ -3,7 +3,6 @@ package com.rusefi.can.reader;
|
|||
import com.rusefi.can.CANPacket;
|
||||
import com.rusefi.can.reader.impl.CANoeReader;
|
||||
import com.rusefi.can.reader.impl.CanHackerReader;
|
||||
import com.rusefi.can.reader.impl.PcanTrcReader1_1;
|
||||
import com.rusefi.can.reader.impl.*;
|
||||
|
||||
import java.io.IOException;
|
||||
|
@ -33,7 +32,7 @@ public interface CANLineReader {
|
|||
return CanHackerReader.INSTANCE;
|
||||
case PCAN:
|
||||
default:
|
||||
return PcanAutoReader.INSTANCE;
|
||||
return AutoFormatReader.INSTANCE;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -8,8 +8,8 @@ import java.nio.file.Files;
|
|||
import java.nio.file.Paths;
|
||||
import java.util.List;
|
||||
|
||||
public class PcanAutoReader implements CANLineReader {
|
||||
public static final CANLineReader INSTANCE = new PcanAutoReader();
|
||||
public class AutoFormatReader implements CANLineReader {
|
||||
public static final CANLineReader INSTANCE = new AutoFormatReader();
|
||||
|
||||
private CANLineReader delegate;
|
||||
|
||||
|
@ -26,9 +26,11 @@ public class PcanAutoReader implements CANLineReader {
|
|||
@Override
|
||||
public List<CANPacket> readFile(String fileName) throws IOException {
|
||||
String firstLine = Files.lines(Paths.get(fileName)).findFirst().get();
|
||||
if (!firstLine.contains(PcanTrcReader2_0.FILEVERSION))
|
||||
if (!firstLine.contains(PcanTrcReader2_0.FILEVERSION) && !firstLine.contains(CanHackerReader.HEADER))
|
||||
throw new IllegalStateException(PcanTrcReader2_0.FILEVERSION + " expected in first line");
|
||||
if (firstLine.contains("1.1")) {
|
||||
if (firstLine.contains(CanHackerReader.HEADER)) {
|
||||
delegate = CanHackerReader.INSTANCE;
|
||||
} else if (firstLine.contains("1.1")) {
|
||||
delegate = PcanTrcReader1_1.INSTANCE;
|
||||
} else if (firstLine.contains("2.0")) {
|
||||
delegate = PcanTrcReader2_0.INSTANCE;
|
|
@ -17,11 +17,15 @@ import com.rusefi.can.reader.CANLineReader;
|
|||
public enum CanHackerReader implements CANLineReader {
|
||||
INSTANCE;
|
||||
|
||||
public static final String HEADER = "@ TEXT";
|
||||
|
||||
@Override
|
||||
public CANPacket readLine(String line, String fileName, int lineIndex) {
|
||||
line = line.trim();
|
||||
if (line.startsWith("@"))
|
||||
return null;
|
||||
if (line.startsWith("# "))
|
||||
return null;
|
||||
|
||||
String[] tokens = line.split("\\s+");
|
||||
double timeStamp = Double.parseDouble(CANLineReader.attemptToFixLocalization(tokens[0]));
|
||||
|
|
Loading…
Reference in New Issue