.logicdata files are a bit broken #1482

This commit is contained in:
rusefi 2020-06-05 17:11:48 -04:00
parent d89f9b5165
commit 9fb76630c4
3 changed files with 28 additions and 22 deletions

View File

@ -81,7 +81,7 @@ public class LogicdataStreamFile extends StreamFile {
// we need to split the combined events into separate channels
for (int ch = 0; ch < numChannels; ch++) {
List<Integer> chDeltas = new ArrayList<Integer>();
List<Integer> chDeltas = new ArrayList<>();
int chPrevState = -1;
int prevTs = 0;
for (CompositeEvent event : events) {
@ -342,6 +342,7 @@ public class LogicdataStreamFile extends StreamFile {
write(numChannels);
}
@Override
protected void writeFooter() throws IOException {
write(BLOCK);
for (int i = 0; i < numChannels; i++) {
@ -386,6 +387,7 @@ public class LogicdataStreamFile extends StreamFile {
writeTimingMarker();
stream.flush();
System.out.println("writeFooter " + fileName);
}
private void writeTimingMarker() throws IOException {
@ -413,9 +415,9 @@ public class LogicdataStreamFile extends StreamFile {
write(value);
}
private void write(int [] values) throws IOException {
for (int i = 0; i < values.length; i++)
write(values[i]);
private void write(int[] values) throws IOException {
for (int value : values)
write(value);
}
private void writeAs(long value, int numBytes) throws IOException {

View File

@ -21,9 +21,13 @@ public abstract class StreamFile {
public abstract void append(List<CompositeEvent> events);
public synchronized void close() {
try {
writeFooter();
} catch (IOException e) {
return;
}
if (writer != null) {
try {
writeFooter(writer);
writer.close();
} catch (IOException e) {
// ignoring this one
@ -44,6 +48,6 @@ public abstract class StreamFile {
writer = new OutputStreamWriter(stream);
}
protected void writeFooter(Writer writer) throws IOException {
protected void writeFooter() throws IOException {
}
}

View File

@ -41,7 +41,7 @@ public class TSHighSpeedLog extends StreamFile {
}
@Override
protected void writeFooter(Writer writer) throws IOException {
protected void writeFooter() throws IOException {
writer.write("MARK 028\n");
}
}