bobbycar/logdata_visualization/logdata_visualization.pde

55 lines
1.0 KiB
Plaintext
Raw Normal View History

2021-03-21 15:12:51 +00:00
Visualization visThrottle;
2021-03-21 15:12:51 +00:00
long lastTimeData=0; //last time data received
2021-03-21 15:12:51 +00:00
Table logdata;
int nextID=0; //next row number to be displayed
long nextTime=0; //time of nextID row
//Data from log
int throttle=0;
void setup() {
2021-03-21 15:12:51 +00:00
size(1920, 1080);
frameRate(100);
2021-03-21 15:12:51 +00:00
logdata = loadTable("LOG00008_rumfahren_neu.TXT", "header, csv");
2021-03-21 15:12:51 +00:00
visThrottle = new BarV(20+80,120,10,100,-1000,1000);
visThrottle.setTitle("Throttle");
}
void draw() {
2021-03-21 15:12:51 +00:00
if (millis()>=nextTime){
TableRow row = logdata.getRow(nextID);
lastTimeData=nextTime;
nextTime=(long)(row.getFloat("time")*1000); //get time and convert from seconds to ms
throttle=row.getInt("throttle");
println(nextTime + " throttle:"+throttle);
nextID++;
nextID=nextID%logdata.getRowCount();
}
2021-03-21 15:12:51 +00:00
background(255);
visThrottle.setValue(throttle);
visThrottle.drawVis();
fill(color(0,0,0));
textSize(12);
2021-03-21 15:12:51 +00:00
text("d="+(nextTime-lastTimeData)+"ms", 5,12*2);
2021-03-21 15:12:51 +00:00
text("t="+(millis()/1000.0)+"s", 5,12);
}