extracting DualSid
This commit is contained in:
parent
dbdb57f191
commit
8f7dd55311
|
@ -0,0 +1,11 @@
|
|||
package com.rusefi.can;
|
||||
|
||||
public class DualSid {
|
||||
public static String dualSid(int sid, String separator) {
|
||||
return String.format("%d%s0x%x", sid, separator, sid);
|
||||
}
|
||||
|
||||
public static String dualSid(int sid) {
|
||||
return dualSid(sid, "/");
|
||||
}
|
||||
}
|
|
@ -1,6 +1,7 @@
|
|||
package com.rusefi.can.analysis;
|
||||
|
||||
import com.rusefi.can.CANPacket;
|
||||
import com.rusefi.can.DualSid;
|
||||
|
||||
import java.io.*;
|
||||
import java.util.*;
|
||||
|
@ -45,7 +46,7 @@ public class ByteRateOfChange {
|
|||
|
||||
for (ByteStatistics byteStatistics : allStats) {
|
||||
ByteId key = byteStatistics.key;
|
||||
ps.println(dualSid(key.sid) + " byte " + key.getByteIndex() + " has " + byteStatistics.getUniqueValuesCount() + " unique value(s)");
|
||||
ps.println(DualSid.dualSid(key.sid) + " byte " + key.getByteIndex() + " has " + byteStatistics.getUniqueValuesCount() + " unique value(s)");
|
||||
}
|
||||
|
||||
ps.close();
|
||||
|
@ -69,14 +70,6 @@ public class ByteRateOfChange {
|
|||
return packets.isEmpty() ? 0 : packets.get(packets.size() - 1).getTimeStamp() - packets.get(0).getTimeStamp();
|
||||
}
|
||||
|
||||
public static String dualSid(int sid) {
|
||||
return dualSid(sid, "/");
|
||||
}
|
||||
|
||||
public static String dualSid(int sid, String separator) {
|
||||
return String.format("%d%s0x%x", sid, separator, sid);
|
||||
}
|
||||
|
||||
public static class ByteStatistics {
|
||||
private final HashSet<Integer> uniqueValues = new HashSet<>();
|
||||
int totalTransitions;
|
||||
|
@ -131,7 +124,7 @@ public class ByteRateOfChange {
|
|||
}
|
||||
|
||||
public String getLogKey() {
|
||||
return dualSid(sid) + "_byte_" + byteIndex + "_bit_" + (byteIndex * 8);
|
||||
return DualSid.dualSid(sid) + "_byte_" + byteIndex + "_bit_" + (byteIndex * 8);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
package com.rusefi.can.analysis;
|
||||
|
||||
import com.rusefi.can.CANPacket;
|
||||
import com.rusefi.can.DualSid;
|
||||
import com.rusefi.can.Launcher;
|
||||
import com.rusefi.can.reader.dbc.DbcFile;
|
||||
import com.rusefi.mlv.LoggingContext;
|
||||
|
@ -92,10 +93,10 @@ public class CanToMegaLogViewer {
|
|||
|
||||
|
||||
private static String getTwoBytesKeyM(Integer sid, int i) {
|
||||
return ByteRateOfChange.dualSid(sid) + "__" + i + "_" + (i + 1);
|
||||
return DualSid.dualSid(sid) + "__" + i + "_" + (i + 1);
|
||||
}
|
||||
|
||||
private static String getTwoBytesKeyL(Integer sid, int i) {
|
||||
return ByteRateOfChange.dualSid(sid) + "__" + (i + 1) + "_" + i;
|
||||
return DualSid.dualSid(sid) + "__" + (i + 1) + "_" + i;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
package com.rusefi.can.analysis;
|
||||
|
||||
import com.rusefi.can.CANPacket;
|
||||
import com.rusefi.can.DualSid;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FileWriter;
|
||||
|
@ -26,7 +27,7 @@ public class PacketRatio {
|
|||
|
||||
for (Map.Entry<Integer, AtomicInteger> e : countBySID.entrySet()) {
|
||||
double ratio = 100.0 * e.getValue().get() / logFileContent.size();
|
||||
w.write(ByteRateOfChange.dualSid(e.getKey()) + ": " + ratio + "\n");
|
||||
w.write(DualSid.dualSid(e.getKey()) + ": " + ratio + "\n");
|
||||
}
|
||||
w.close();
|
||||
}
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
package com.rusefi.can.analysis;
|
||||
|
||||
import com.rusefi.can.CANPacket;
|
||||
import com.rusefi.can.DualSid;
|
||||
import com.rusefi.can.writer.SteveWriter;
|
||||
|
||||
import java.io.File;
|
||||
|
@ -11,8 +12,6 @@ import java.util.ArrayList;
|
|||
import java.util.List;
|
||||
import java.util.TreeSet;
|
||||
|
||||
import static com.rusefi.can.analysis.ByteRateOfChange.dualSid;
|
||||
|
||||
/**
|
||||
* Write a separate file for each unique packet ID
|
||||
*/
|
||||
|
@ -29,7 +28,7 @@ public class PerSidDump {
|
|||
// O(n*M) is not so bad
|
||||
for (int sid : sids) {
|
||||
|
||||
String outputFileName = filteredDestinationFolder + File.separator + simpleFileName + "_filtered_" + ByteRateOfChange.dualSid(sid, "_") + ".txt";
|
||||
String outputFileName = filteredDestinationFolder + File.separator + simpleFileName + "_filtered_" + DualSid.dualSid(sid, "_") + ".txt";
|
||||
PrintWriter pw = new PrintWriter(new FileOutputStream(outputFileName));
|
||||
|
||||
List<CANPacket> filteredPackets = new ArrayList<>();
|
||||
|
@ -47,7 +46,7 @@ public class PerSidDump {
|
|||
int middleIndex = filteredPackets.size() / 2;
|
||||
CANPacket middlePacket = filteredPackets.get(middleIndex);
|
||||
|
||||
String middleOutputFileName = filteredDestinationFolder + File.separator + simpleFileName + "_filtered_" + ByteRateOfChange.dualSid(sid, "_") + "_middle.txt";
|
||||
String middleOutputFileName = filteredDestinationFolder + File.separator + simpleFileName + "_filtered_" + DualSid.dualSid(sid, "_") + "_middle.txt";
|
||||
PrintWriter middle = new PrintWriter(new FileOutputStream(middleOutputFileName));
|
||||
|
||||
String decAndHex = middlePacket.getId() + "_" + Integer.toHexString(middlePacket.getId());
|
||||
|
|
Loading…
Reference in New Issue