counter report as yaml
This commit is contained in:
parent
1a23e50ed0
commit
2059134948
|
@ -45,7 +45,7 @@ public class ByteRateOfChange {
|
||||||
|
|
||||||
for (ByteStatistics byteStatistics : allStats) {
|
for (ByteStatistics byteStatistics : allStats) {
|
||||||
ByteId key = byteStatistics.key;
|
ByteId key = byteStatistics.key;
|
||||||
ps.println(dualSid(key.sid) + " byte " + key.index + " has " + byteStatistics.getUniqueValuesCount() + " unique value(s)");
|
ps.println(dualSid(key.sid) + " byte " + key.bitIndex + " has " + byteStatistics.getUniqueValuesCount() + " unique value(s)");
|
||||||
}
|
}
|
||||||
|
|
||||||
ps.close();
|
ps.close();
|
||||||
|
@ -105,15 +105,15 @@ public class ByteRateOfChange {
|
||||||
|
|
||||||
public static class ByteId implements Comparable<ByteId> {
|
public static class ByteId implements Comparable<ByteId> {
|
||||||
final int sid;
|
final int sid;
|
||||||
final int index;
|
final int bitIndex;
|
||||||
|
|
||||||
public ByteId(int sid, int index) {
|
public ByteId(int sid, int bitIndex) {
|
||||||
this.sid = sid;
|
this.sid = sid;
|
||||||
this.index = index;
|
this.bitIndex = bitIndex;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getLogKey() {
|
public String getLogKey() {
|
||||||
return dualSid(sid) + "_byte_" + index + "_bit_" + (index * 8);
|
return dualSid(sid) + "_byte_" + bitIndex + "_bit_" + (bitIndex * 8);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -121,20 +121,20 @@ public class ByteRateOfChange {
|
||||||
if (this == o) return true;
|
if (this == o) return true;
|
||||||
if (o == null || getClass() != o.getClass()) return false;
|
if (o == null || getClass() != o.getClass()) return false;
|
||||||
ByteId byteId = (ByteId) o;
|
ByteId byteId = (ByteId) o;
|
||||||
return sid == byteId.sid && index == byteId.index;
|
return sid == byteId.sid && bitIndex == byteId.bitIndex;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int hashCode() {
|
public int hashCode() {
|
||||||
return Objects.hash(sid, index);
|
return Objects.hash(sid, bitIndex);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int compareTo(ByteId o) {
|
public int compareTo(ByteId o) {
|
||||||
ByteId other = (ByteId) o;
|
ByteId other = o;
|
||||||
if (other.sid != sid)
|
if (other.sid != sid)
|
||||||
return sid - other.sid;
|
return sid - other.sid;
|
||||||
return index - other.index;
|
return bitIndex - other.bitIndex;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -64,6 +64,14 @@ public class CounterAggregator {
|
||||||
this.totalNumberOfBits = totalNumberOfBits;
|
this.totalNumberOfBits = totalNumberOfBits;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public CounterScanner.BitStateKey getStart() {
|
||||||
|
return start;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getTotalNumberOfBits() {
|
||||||
|
return totalNumberOfBits;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
return "Counter{" +
|
return "Counter{" +
|
||||||
|
|
|
@ -1,12 +1,13 @@
|
||||||
package com.rusefi.can.analysis;
|
package com.rusefi.can.analysis;
|
||||||
|
|
||||||
import com.rusefi.can.CANPacket;
|
import com.rusefi.can.CANPacket;
|
||||||
|
import org.yaml.snakeyaml.Yaml;
|
||||||
|
|
||||||
import java.io.*;
|
import java.io.*;
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
|
|
||||||
public class CounterScanner {
|
public class CounterScanner {
|
||||||
public static void scanForCounters(String reportDestinationFolder, List<CANPacket> packets) throws FileNotFoundException {
|
public static void scanForCounters(String reportDestinationFolder, List<CANPacket> packets) throws IOException {
|
||||||
|
|
||||||
String outputFileName = reportDestinationFolder + File.separator + "counter_report.txt";
|
String outputFileName = reportDestinationFolder + File.separator + "counter_report.txt";
|
||||||
PrintWriter pw = new PrintWriter(new FileOutputStream(outputFileName));
|
PrintWriter pw = new PrintWriter(new FileOutputStream(outputFileName));
|
||||||
|
@ -47,10 +48,20 @@ public class CounterScanner {
|
||||||
pw.println("Scanning...");
|
pw.println("Scanning...");
|
||||||
List<CounterAggregator.CounterWithWidth> countersWithWidth = CounterAggregator.scan(counters);
|
List<CounterAggregator.CounterWithWidth> countersWithWidth = CounterAggregator.scan(counters);
|
||||||
|
|
||||||
|
Yaml yaml = new Yaml();
|
||||||
|
Map<Integer, Map<Integer, Integer>> map = new HashMap<>();
|
||||||
|
|
||||||
pw.println("Here are the founding:");
|
pw.println("Here are the founding:");
|
||||||
for (CounterAggregator.CounterWithWidth counterWithWidth : countersWithWidth) {
|
for (CounterAggregator.CounterWithWidth counterWithWidth : countersWithWidth) {
|
||||||
pw.println("Found " + counterWithWidth);
|
pw.println("Found " + counterWithWidth);
|
||||||
|
|
||||||
|
Map<Integer, Integer> lengthByStartIndex = map.computeIfAbsent(counterWithWidth.getStart().getSid(), integer -> new HashMap<>());
|
||||||
|
|
||||||
|
lengthByStartIndex.put(counterWithWidth.getStart().getTotalBitIndex(), counterWithWidth.getTotalNumberOfBits());
|
||||||
}
|
}
|
||||||
|
String yamlCountersReportFileName = reportDestinationFolder + File.separator + "counters.yaml";
|
||||||
|
System.out.println("Writing report to " + yamlCountersReportFileName);
|
||||||
|
yaml.dump(map, new FileWriter(yamlCountersReportFileName));
|
||||||
pw.close();
|
pw.close();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -63,12 +74,16 @@ public class CounterScanner {
|
||||||
this.bitIndex = bitIndex;
|
this.bitIndex = bitIndex;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public int getTotalBitIndex() {
|
||||||
|
return byteId.bitIndex * 8 + bitIndex;
|
||||||
|
}
|
||||||
|
|
||||||
public int getSid() {
|
public int getSid() {
|
||||||
return byteId.sid;
|
return byteId.sid;
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getByteIndex() {
|
public int getByteIndex() {
|
||||||
return byteId.index;
|
return byteId.bitIndex;
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getBitIndex() {
|
public int getBitIndex() {
|
||||||
|
|
Loading…
Reference in New Issue