fix csv comments

This commit is contained in:
interfisch 2021-05-15 21:51:01 +02:00
parent 467d454547
commit fb961e3da7
1 changed files with 41 additions and 5 deletions

View File

@ -1,9 +1,15 @@
import processing.serial.*; import processing.serial.*;
/*
TODO
- in teensy controller: erst table header screiben, dann anfangen zu loggen (oder erste zeilen comments hier ignorieren)
*/
int vis_textsize=12; //copy from Visualization class int vis_textsize=12; //copy from Visualization class
//String logfile_name="LOG00008_rumfahren_neu.TXT"; //String logfile_name="LOG00008_rumfahren_neu.TXT";
String logfile_name="LOG00181_20210329_trefffahren.TXT"; String logfile_name="LOG00184_20210515b_Video_Treff_FreewheelCurrentFix.TXT";
int columnCount=20;
boolean useSerial=false; //false=read from csv log, true=read from serial port boolean useSerial=false; //false=read from csv log, true=read from serial port
//String serial_port="COM3"; //String serial_port="COM3";
@ -57,7 +63,7 @@ long nextTimeData=0; //time of nextID row
long lastTimeMillis=0; //local time long lastTimeMillis=0; //local time
long nextTimeMillis=0; //local time long nextTimeMillis=0; //local time
boolean newdataforced=false; boolean newdataforced=true;
int dataErrorCount=0; int dataErrorCount=0;
@ -103,6 +109,17 @@ void setup() {
serialString = null; serialString = null;
}else{ }else{
logdata = loadTable(logfile_name, "header, csv"); logdata = loadTable(logfile_name, "header, csv");
for (int i=0; i < logdata.getRowCount();i++) {
if (logdata.getRow(i).getString(0).charAt(0)=='#') { //check if row starts with # (comment)
print("removed row:");
for (int is=0;is< logdata.getRow(i).getColumnCount(); is++)
{
print(logdata.getRow(i).getString(is)+",");
}
println();
logdata.removeRow(i);
}
}
logdata_start_time=logdata.getRow(0).getFloat("time"); logdata_start_time=logdata.getRow(0).getFloat("time");
logdata_end_time = logdata.getRow(logdata.getRowCount()-1).getFloat("time"); logdata_end_time = logdata.getRow(logdata.getRowCount()-1).getFloat("time");
println("loaded "+logdata.getRowCount()+" lines. Times: "+logdata_start_time+"s to "+logdata_end_time+"s"); println("loaded "+logdata.getRowCount()+" lines. Times: "+logdata_start_time+"s to "+logdata_end_time+"s");
@ -272,7 +289,7 @@ void draw() {
}else{ }else{
while (newdataforced || loopmillis>=nextTimeData && nextID+1<logdata.getRowCount()){ //New Data while (newdataforced || loopmillis>=nextTimeData && nextID+1<logdata.getRowCount()){ //New Data
newdataforced=false; //reset flag newdataforced=false; //reset flag
if ((nextID+1 < logdata.getRowCount()) && (nextID-1 > 0)) { //valid row if ((nextID+1 < logdata.getRowCount()) && (nextID >= 0)) { //valid row
TableRow row = logdata.getRow(nextID); TableRow row = logdata.getRow(nextID);
lastTimeData=nextTimeData; lastTimeData=nextTimeData;
@ -387,6 +404,25 @@ void draw() {
} }
void keyPressed() {
if (key == CODED) {
/*if (keyCode == UP) {
fillVal = 255;
} else if (keyCode == DOWN) {
fillVal = 0;
}
*/
} else {
//println("key="+keyCode);
if (keyCode==82) { //82=r
println("restart");
timeoffset=millis(); //rest to time 0
nextID=0;
newdataforced=true;
}
}
}
void mouseClicked() void mouseClicked()
{ {
if (showTimeline) if (showTimeline)
@ -394,7 +430,7 @@ void mouseClicked()
int temp_timeoffset=(int)(tl.checkMouse(mouseX,mouseY)*1000); int temp_timeoffset=(int)(tl.checkMouse(mouseX,mouseY)*1000);
if (temp_timeoffset!=0) { if (temp_timeoffset!=0) {
if (!(nextID+1 < logdata.getRowCount()) && (nextID >= 0)) { //nextID not valid if (!(nextID+1 < logdata.getRowCount()) && (nextID >= 0) || nextID<0) { //nextID not valid
nextID=0; //rest to good value nextID=0; //rest to good value
} }
@ -404,7 +440,7 @@ void mouseClicked()
nextID++; nextID++;
} }
print(" over "+nextID); print(" over "+nextID);
while ((nextID+1 < logdata.getRowCount()) && (nextID >= 0) && (millis()-temp_timeoffset < (long)(logdata.getRow(nextID+1).getFloat("time")*1000))) { //jumped backward while ((nextID+1 < logdata.getRowCount()) && (nextID > 0) && (millis()-temp_timeoffset < (long)(logdata.getRow(nextID+1).getFloat("time")*1000))) { //jumped backward
nextID--; nextID--;
} }
println(" to "+nextID); println(" to "+nextID);