-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
rusefillc
committed
Jul 26, 2024
1 parent
6a63b31
commit 1070010
Showing
3 changed files
with
56 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
53 changes: 53 additions & 0 deletions
53
reader/src/main/java/com/rusefi/can/analysis/FirstPacket.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
package com.rusefi.can.analysis; | ||
|
||
import com.rusefi.can.CANPacket; | ||
import com.rusefi.can.reader.dbc.DbcFile; | ||
import com.rusefi.can.reader.dbc.DbcPacket; | ||
|
||
import java.io.File; | ||
import java.io.FileWriter; | ||
import java.io.IOException; | ||
import java.io.Writer; | ||
import java.util.List; | ||
import java.util.Map; | ||
import java.util.TreeMap; | ||
|
||
public class FirstPacket { | ||
public static void write(DbcFile dbc, String reportDestinationFolder, List<CANPacket> logFileContent, String simpleFileName) throws IOException { | ||
if (logFileContent.isEmpty()) | ||
return; | ||
CANPacket firstPacket = logFileContent.get(0); | ||
|
||
Map<Integer, CANPacket> firstPacketById = new TreeMap<>(); | ||
Map<Double, CANPacket> sorterByFirstPacket = new TreeMap<>(); | ||
|
||
for (CANPacket packet : logFileContent) { | ||
if (!firstPacketById.containsKey(packet.getId())) { | ||
firstPacketById.put(packet.getId(), packet); | ||
sorterByFirstPacket.put(packet.getTimeStamp() - firstPacket.getTimeStamp(), packet); | ||
} | ||
} | ||
|
||
|
||
Writer w = new FileWriter(reportDestinationFolder + File.separator + "start_" + simpleFileName + ".txt"); | ||
|
||
for (CANPacket packet : firstPacketById.values()) { | ||
writeLine(dbc, packet, w, firstPacket); | ||
} | ||
|
||
w.write("***************************************************\n"); | ||
|
||
for (CANPacket packet : sorterByFirstPacket.values()) { | ||
writeLine(dbc, packet, w, firstPacket); | ||
} | ||
|
||
w.close(); | ||
} | ||
|
||
private static void writeLine(DbcFile dbc, CANPacket packet, Writer w, CANPacket firstPacket) throws IOException { | ||
int sid = packet.getId(); | ||
DbcPacket dbcPacket = dbc == null ? null : dbc.packets.get(sid); | ||
String key = dbcPacket == null ? Integer.toString(sid) : dbcPacket.getName(); | ||
w.write(key + ": " + (packet.getTimeStamp() - firstPacket.getTimeStamp()) + "\n"); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters