Skip to content

Commit

Permalink
docs timestamp
Browse files Browse the repository at this point in the history
  • Loading branch information
rusefillc committed Sep 23, 2024
1 parent 5c89e92 commit 430ec5c
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
6 changes: 3 additions & 3 deletions reader/src/main/java/com/rusefi/mlv/LoggingContext.java
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@

public class LoggingContext {
public Map<String, Double> currentSnapshot = new HashMap<>();
AtomicReference<Long> currentTime = new AtomicReference<>();
private final AtomicReference<Long> currentTimeUs = new AtomicReference<>();

public BinarySensorLog<BinaryLogEntry> getBinaryLogEntryBinarySensorLog(Collection<BinaryLogEntry> entries, String outputFileName) {
return new BinarySensorLog<>(o -> {
Expand All @@ -25,7 +25,7 @@ public BinarySensorLog<BinaryLogEntry> getBinaryLogEntryBinarySensorLog(Collecti

public void writeLogContent(List<CANPacket> packets, BinarySensorLog<BinaryLogEntry> log, LoggingStrategy.PacketLogger logger) {
for (CANPacket packetContent : packets) {
currentTime.set((long) (packetContent.getTimeStamp() * 1000));
currentTimeUs.set((long) (packetContent.getTimeStamp() * 1000));
boolean needLine = logger.takeValues(packetContent);
if (needLine)
log.writeSensorLogLine();
Expand All @@ -34,6 +34,6 @@ public void writeLogContent(List<CANPacket> packets, BinarySensorLog<BinaryLogEn
}

public BinarySensorLog.TimeProvider getTimeProvider() {
return () -> this.currentTime.get();
return () -> this.currentTimeUs.get();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ public BinarySensorLog(Function<T, Double> valueProvider, Collection<T> sensors,
}

public interface TimeProvider {
long currentTimestamp();
long currentTimestampUs();
}

@Override
Expand All @@ -56,7 +56,7 @@ public void writeSensorLogLine() {
try {
stream.write(0);
stream.write(lineCounter++);
stream.writeShort((int) (timeProvider.currentTimestamp() * 100));
stream.writeShort((int) (timeProvider.currentTimestampUs() * 100));

ByteArrayOutputStream baos = new ByteArrayOutputStream();
DataOutputStream dos = new DataOutputStream(baos);
Expand Down

0 comments on commit 430ec5c

Please sign in to comment.