Compare commits

...

4 Commits

Author SHA1 Message Date
rusefillc b08dd8cf72 gradle-8.5 2023-12-15 12:29:35 -05:00
rusefillc 925526673a better error handling 2023-12-15 10:43:39 -05:00
rusefillc f9cd363abf better error handling 2023-12-15 10:38:43 -05:00
rusefillc aa5b1f2fea better class name 2023-12-15 10:38:43 -05:00
9 changed files with 23 additions and 17 deletions

View File

@ -1,6 +1,6 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-8.4-all.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-8.5-all.zip
networkTimeout=10000
validateDistributionUrl=true
zipStoreBase=GRADLE_USER_HOME

View File

@ -11,14 +11,14 @@ public class ByteRateOfChangeReports {
/**
* sweet baby O(n^2)
*/
public static void compareEachReportAgainstAllOthers(String reportDestinationFolder, List<ByteRateOfChange.TraceReport> reports, CanContext context) throws FileNotFoundException {
public static void compareEachReportAgainstAllOthers(String reportDestinationFolder, List<ByteRateOfChange.TraceReport> reports, CanMetaDataContext context) throws FileNotFoundException {
for (int i = 0; i < reports.size(); i++) {
for (int j = i + 1; j < reports.size(); j++)
compareTwoReports(reportDestinationFolder, reports.get(i), reports.get(j), context);
}
}
private static void compareTwoReports(String reportDestinationFolder, ByteRateOfChange.TraceReport traceReport1, ByteRateOfChange.TraceReport traceReport2, CanContext context) throws FileNotFoundException {
private static void compareTwoReports(String reportDestinationFolder, ByteRateOfChange.TraceReport traceReport1, ByteRateOfChange.TraceReport traceReport2, CanMetaDataContext context) throws FileNotFoundException {
Set<ByteRateOfChange.ByteId> allKeys = new TreeSet<>();
allKeys.addAll(traceReport1.getStatistics().keySet());
allKeys.addAll(traceReport2.getStatistics().keySet());
@ -92,7 +92,7 @@ public class ByteRateOfChangeReports {
public static void scanInputFolder(String inputFolderName, String fileNameSuffix) throws IOException {
String reportDestinationFolder = createOutputFolder(inputFolderName);
CanContext context = CanContext.read(inputFolderName);
CanMetaDataContext context = CanMetaDataContext.read(inputFolderName);
List<ByteRateOfChange.TraceReport> reports = new ArrayList<>();

View File

@ -7,13 +7,13 @@ import java.io.FileNotFoundException;
import java.io.FileReader;
import java.util.*;
public class CanContext {
public class CanMetaDataContext {
final Set<Integer> withChecksum = new HashSet<>();
final Map<Integer, Map<Integer, Integer>> countersMap;
Set<ByteRateOfChange.ByteId> counterBytes = new HashSet<>();
private CanContext(List<Integer> withChecksum, Map<Integer, Map<Integer, Integer>> countersMap) {
private CanMetaDataContext(List<Integer> withChecksum, Map<Integer, Map<Integer, Integer>> countersMap) {
this.countersMap = countersMap;
this.withChecksum.addAll(withChecksum);
@ -33,17 +33,17 @@ public class CanContext {
}
}
public static CanContext read(String inputFolderName) throws FileNotFoundException {
public static CanMetaDataContext read(String inputFolderName) throws FileNotFoundException {
Yaml checksum = new Yaml();
String checkSumFileName = inputFolderName + File.separator + ChecksumScanner.CHECKSUM_YAML;
if (!new File(checkSumFileName).exists())
return new CanContext(new ArrayList<>(), new HashMap<>());
return new CanMetaDataContext(new ArrayList<>(), new HashMap<>());
List<Integer> withChecksum = checksum.load(new FileReader(checkSumFileName));
Yaml countersYaml = new Yaml();
Map<Integer, Map<Integer, Integer>> countersMap = countersYaml.load(new FileReader(inputFolderName + File.separator + CounterScanner.COUNTERS_YAML));
return new CanContext(withChecksum, countersMap);
return new CanMetaDataContext(withChecksum, countersMap);
}
}

View File

@ -41,7 +41,11 @@ public interface CANLineReader {
return readLine(line, "no-file-name");
}
CANPacket readLine(String line, String fileName);
default CANPacket readLine(String line, String fileName) {
return readLine(line, fileName, -1);
}
CANPacket readLine(String line, String fileName, int lineIndex);
default List<CANPacket> readFile(String fileName) throws IOException {
return skipHeaderAndRead(fileName, 0);
@ -57,7 +61,7 @@ public interface CANLineReader {
public void accept(String s) {
if (index++ < skipCount)
return;
CANPacket packet = readLine(s, fileName);
CANPacket packet = readLine(s, fileName, index);
if (packet != null)
result.add(packet);
}

View File

@ -10,7 +10,7 @@ public enum CANoeReader implements CANLineReader {
INSTANCE;
@Override
public CANPacket readLine(String line, String fileName) {
public CANPacket readLine(String line, String fileName, int lineIndex) {
if (line.contains("ErrorFrame"))
return null;
String[] tokens = line.trim().split("\\s+");

View File

@ -18,7 +18,7 @@ public enum CanHackerReader implements CANLineReader {
INSTANCE;
@Override
public CANPacket readLine(String line, String fileName) {
public CANPacket readLine(String line, String fileName, int lineIndex) {
line = line.trim();
if (line.startsWith("@"))
return null;

View File

@ -19,8 +19,8 @@ public class PcanAutoReader implements CANLineReader {
}
@Override
public CANPacket readLine(String line, String fileName) {
return delegate.readLine(line, fileName);
public CANPacket readLine(String line, String fileName, int lineIndex) {
return delegate.readLine(line, fileName, lineIndex);
}
@Override

View File

@ -13,13 +13,15 @@ public class PcanTrcReader1_1 implements CANLineReader {
public static final CANLineReader INSTANCE = new PcanTrcReader1_1();
@Override
public CANPacket readLine(String line, String fileName) {
public CANPacket readLine(String line, String fileName, int lineIndex) {
line = line.trim();
if (line.startsWith(FILEVERSION) && !line.startsWith(FILEVERSION + "=1.1"))
throw new IllegalStateException("Unexpected fileversion " + line);
if (line.startsWith(";"))
return null;
String[] tokens = line.split("\\s+");
if (tokens.length < 2)
throw new IllegalStateException("Unexpected token count in " + fileName + "@" + lineIndex + ": [" + line + "]");
double timeStamp = Double.parseDouble(tokens[1]);
int sid = Integer.parseInt(tokens[3], 16);

View File

@ -13,7 +13,7 @@ public enum PcanTrcReader2_0 implements CANLineReader {
public static final String FILEVERSION = ";$FILEVERSION";
@Override
public CANPacket readLine(String line, String fileName) {
public CANPacket readLine(String line, String fileName, int lineIndex) {
line = line.trim();
if (line.startsWith(FILEVERSION) && !line.startsWith(FILEVERSION + "=2.0"))
throw new IllegalStateException("Unexpected fileversion " + line + " in " + fileName);