Skip to content

Commit 8e9be90

Browse files
committed
safe dump of overflow data
1 parent 1273ad8 commit 8e9be90

File tree

2 files changed

+9
-3
lines changed

2 files changed

+9
-3
lines changed

build.gradle

+1-1
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,6 @@ shadowJar {
5454
mainClassName = 'edu.wpi.rbe.rbe2001.fieldsimulator.gui.Main'
5555
baseName = 'FieldControl'
5656
classifier = null
57-
version = '0.2.1'
57+
version = '0.2.2'
5858
mergeServiceFiles()
5959
}

src/main/java/edu/wpi/rbe/rbe2001/fieldsimulator/gui/CSVManager.java

+8-2
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,11 @@
1111
public class CSVManager {
1212
long timestampLast=0;
1313
ArrayList<double[]> hashMap= new ArrayList<double[]>();
14-
14+
private boolean writing=false;
1515
public void addLine(long timestamp, double pos0, double pos1, double pos2, double vel0, double vel1, double vel2,
1616
double hw0, double hw1, double hw2, double velsetpoint0, double velsetpoint1, double velsetpoint2,
1717
double setpoint0, double setpoint1, double setpoint2, double Azimuth) {
18-
if(timestampLast+50>timestamp)
18+
if(timestampLast+50>timestamp || writing)
1919
return;
2020
timestampLast=timestamp;
2121
double[] line = new double[] { timestamp,pos0, pos1, pos2, vel0, vel1, vel2, hw0, hw1, hw2, velsetpoint0, velsetpoint1,
@@ -27,7 +27,10 @@ public void addLine(long timestamp, double pos0, double pos1, double pos2, doubl
2727
}
2828

2929
public void writeToFile() {
30+
if(writing)
31+
return;
3032
new Thread(()->{
33+
writing = true;
3134
File desktop = new File(System.getProperty("user.home")+"/Desktop/");
3235
DateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd_HH-mm-ss");
3336
String timestamp =dateFormat.format(new Date());
@@ -62,6 +65,9 @@ public void writeToFile() {
6265
}
6366

6467
hashMap.clear();
68+
hashMap=null;
69+
hashMap= new ArrayList<double[]>();
70+
writing = false;
6571
}).start();
6672
}
6773

0 commit comments

Comments
 (0)