filtered uses DBC
This commit is contained in:
parent
e795581f6a
commit
ba11705db0
|
@ -15,13 +15,7 @@ public class ByteRateOfChangeReports {
|
||||||
/**
|
/**
|
||||||
* sweet baby O(n^2)
|
* sweet baby O(n^2)
|
||||||
*/
|
*/
|
||||||
public static void compareEachReportAgainstAllOthers(String reportDestinationFolder, List<ByteRateOfChange.TraceReport> reports, CanMetaDataContext context) throws IOException {
|
public static void compareEachReportAgainstAllOthers(DbcFile dbc, String reportDestinationFolder, List<ByteRateOfChange.TraceReport> reports, CanMetaDataContext context) throws IOException {
|
||||||
|
|
||||||
DbcFile dbc = null;
|
|
||||||
if (Launcher.dbcFileName != null) {
|
|
||||||
dbc = DbcFile.readFromFile(Launcher.dbcFileName);
|
|
||||||
}
|
|
||||||
|
|
||||||
for (int i = 0; i < reports.size(); i++) {
|
for (int i = 0; i < reports.size(); i++) {
|
||||||
for (int j = i + 1; j < reports.size(); j++)
|
for (int j = i + 1; j < reports.size(); j++)
|
||||||
compareTwoReports(dbc, reportDestinationFolder, reports.get(i), reports.get(j), context);
|
compareTwoReports(dbc, reportDestinationFolder, reports.get(i), reports.get(j), context);
|
||||||
|
@ -113,6 +107,8 @@ public class ByteRateOfChangeReports {
|
||||||
public static void scanInputFolder(String inputFolderName, String fileNameSuffix) throws IOException {
|
public static void scanInputFolder(String inputFolderName, String fileNameSuffix) throws IOException {
|
||||||
String reportDestinationFolder = createOutputFolder(inputFolderName);
|
String reportDestinationFolder = createOutputFolder(inputFolderName);
|
||||||
|
|
||||||
|
DbcFile dbc = getDbc();
|
||||||
|
|
||||||
CanMetaDataContext context = CanMetaDataContext.read(inputFolderName);
|
CanMetaDataContext context = CanMetaDataContext.read(inputFolderName);
|
||||||
|
|
||||||
List<ByteRateOfChange.TraceReport> reports = new ArrayList<>();
|
List<ByteRateOfChange.TraceReport> reports = new ArrayList<>();
|
||||||
|
@ -123,7 +119,7 @@ public class ByteRateOfChangeReports {
|
||||||
|
|
||||||
List<CANPacket> logFileContent = CANLineReader.getReader().readFile(fullInputFileName);
|
List<CANPacket> logFileContent = CANLineReader.getReader().readFile(fullInputFileName);
|
||||||
|
|
||||||
PerSidDump.handle(reportDestinationFolder, simpleFileName, logFileContent);
|
PerSidDump.handle(dbc, reportDestinationFolder, simpleFileName, logFileContent);
|
||||||
// at the moment we overwrite counter detection report after we process each file
|
// at the moment we overwrite counter detection report after we process each file
|
||||||
CounterScanner.scanForCounters(reportDestinationFolder, simpleFileName, logFileContent);
|
CounterScanner.scanForCounters(reportDestinationFolder, simpleFileName, logFileContent);
|
||||||
ChecksumScanner.scanForChecksums(reportDestinationFolder, simpleFileName, logFileContent);
|
ChecksumScanner.scanForChecksums(reportDestinationFolder, simpleFileName, logFileContent);
|
||||||
|
@ -140,7 +136,15 @@ public class ByteRateOfChangeReports {
|
||||||
|
|
||||||
|
|
||||||
System.out.println("Processing " + reports.size() + " report(s)");
|
System.out.println("Processing " + reports.size() + " report(s)");
|
||||||
compareEachReportAgainstAllOthers(reportDestinationFolder, reports, context);
|
compareEachReportAgainstAllOthers(dbc, reportDestinationFolder, reports, context);
|
||||||
|
}
|
||||||
|
|
||||||
|
private static DbcFile getDbc() throws IOException {
|
||||||
|
DbcFile dbc = null;
|
||||||
|
if (Launcher.dbcFileName != null) {
|
||||||
|
dbc = DbcFile.readFromFile(Launcher.dbcFileName);
|
||||||
|
}
|
||||||
|
return dbc;
|
||||||
}
|
}
|
||||||
|
|
||||||
static class ByteVariationDifference {
|
static class ByteVariationDifference {
|
||||||
|
|
|
@ -2,6 +2,8 @@ package com.rusefi.can.analysis;
|
||||||
|
|
||||||
import com.rusefi.can.CANPacket;
|
import com.rusefi.can.CANPacket;
|
||||||
import com.rusefi.can.DualSid;
|
import com.rusefi.can.DualSid;
|
||||||
|
import com.rusefi.can.reader.dbc.DbcFile;
|
||||||
|
import com.rusefi.can.reader.dbc.DbcPacket;
|
||||||
import com.rusefi.can.writer.SteveWriter;
|
import com.rusefi.can.writer.SteveWriter;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
|
@ -16,7 +18,7 @@ import java.util.TreeSet;
|
||||||
* Write a separate file for each unique packet ID
|
* Write a separate file for each unique packet ID
|
||||||
*/
|
*/
|
||||||
public class PerSidDump {
|
public class PerSidDump {
|
||||||
public static void handle(String reportDestinationFolder, String simpleFileName, List<CANPacket> packets) throws IOException {
|
public static void handle(DbcFile dbc, String reportDestinationFolder, String simpleFileName, List<CANPacket> packets) throws IOException {
|
||||||
String filteredDestinationFolder = reportDestinationFolder + File.separator + "filtered";
|
String filteredDestinationFolder = reportDestinationFolder + File.separator + "filtered";
|
||||||
new File(filteredDestinationFolder).mkdirs();
|
new File(filteredDestinationFolder).mkdirs();
|
||||||
|
|
||||||
|
@ -50,8 +52,10 @@ public class PerSidDump {
|
||||||
PrintWriter middle = new PrintWriter(new FileOutputStream(middleOutputFileName));
|
PrintWriter middle = new PrintWriter(new FileOutputStream(middleOutputFileName));
|
||||||
|
|
||||||
String decAndHex = middlePacket.getId() + "_" + Integer.toHexString(middlePacket.getId());
|
String decAndHex = middlePacket.getId() + "_" + Integer.toHexString(middlePacket.getId());
|
||||||
String payloadVariableName = "payload" + decAndHex;
|
DbcPacket packet = dbc.packets.get(middlePacket.getId());
|
||||||
String variableName = "CAN_" + decAndHex;
|
String payloadVariableName = "payload" + (packet == null ? decAndHex : packet.getName());
|
||||||
|
String variableName = packet == null ? "CAN_" + decAndHex : packet.getName();
|
||||||
|
String methodName = "on" + (packet == null ? ("Can" + decAndHex) : packet.getName());
|
||||||
|
|
||||||
StringBuilder payloadLine = middlePacket.asLua(payloadVariableName);
|
StringBuilder payloadLine = middlePacket.asLua(payloadVariableName);
|
||||||
|
|
||||||
|
@ -62,7 +66,6 @@ public class PerSidDump {
|
||||||
|
|
||||||
middle.println();
|
middle.println();
|
||||||
middle.println(counterVariable + " = 0");
|
middle.println(counterVariable + " = 0");
|
||||||
String methodName = "onMotor" + decAndHex;
|
|
||||||
middle.println("function " + methodName + "(bus, id, dlc, data)");
|
middle.println("function " + methodName + "(bus, id, dlc, data)");
|
||||||
middle.println("\t" + counterVariable + " = (" + counterVariable + " + 1) % 256");
|
middle.println("\t" + counterVariable + " = (" + counterVariable + " + 1) % 256");
|
||||||
middle.println("\t" + payloadVariableName + "[x] = " + counterVariable);
|
middle.println("\t" + payloadVariableName + "[x] = " + counterVariable);
|
||||||
|
|
Loading…
Reference in New Issue