improve csv error check

This commit is contained in:
interfisch 2021-05-24 17:52:58 +02:00
parent d5a60cd499
commit dfc53c494b
1 changed files with 32 additions and 17 deletions

View File

@ -8,7 +8,7 @@ TODO
int vis_textsize=12; //copy from Visualization class
//String logfile_name="LOG00008_rumfahren_neu.TXT";
String logfile_name="LOG00184_20210515b_Video_Treff_FreewheelCurrentFix.TXT";
String logfile_name="20210524_Phaseadvance_enabled.TXT";
int columnCount=20;
boolean useSerial=false; //false=read from csv log, true=read from serial port
@ -109,12 +109,25 @@ void setup() {
serialString = null;
}else{
logdata = loadTable(logfile_name, "header, csv");
float _checkTimeLast=-100;
for (int i=0; i < logdata.getRowCount();i++) {
float _checkTimeCurrent=logdata.getRow(i).getFloat("time")*1000;
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("removed comment:");
for (int is=0;is< logdata.getRow(i).getColumnCount() && logdata.getRow(i).getString(is) != null; is++)
{
print(logdata.getRow(i).getString(is)+",");
print(", "+logdata.getRow(i).getString(is));
}
println();
logdata.removeRow(i);
}else if (Float.isNaN(_checkTimeCurrent) || _checkTimeCurrent <= _checkTimeLast) { //check if time is plausible
print("removed unplausible time:");
for (int is=0;is< logdata.getRow(i).getColumnCount() && logdata.getRow(i).getString(is) != null; is++)
{
print(", "+logdata.getRow(i).getString(is));
}
println();
logdata.removeRow(i);
@ -122,7 +135,7 @@ void setup() {
}
logdata_start_time=logdata.getRow(0).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. Starttime: "+logdata_start_time+"s , Endtime: "+logdata_end_time+"s");
}
PVector pos_vis_cmd = new PVector(100,200);
@ -237,9 +250,11 @@ void setup() {
if (showTimeline) {
println("Preparing Timeline");
tl = new Timeline(30,height-30, width-30*2, 28);
tl.setTimes(logdata_start_time,logdata_end_time);
tl.generatePreview(logdata);
println("Timeline prepared");
}
}
@ -305,18 +320,18 @@ void draw() {
current_FrontL=row.getFloat("current_FrontL");
current_FrontR=row.getFloat("current_FrontR");
current_RearL=row.getFloat("current_RearL");
current_RearR=row.getFloat("current_RearR");
speed_FrontL=row.getInt("speed_FrontL");
speed_FrontR=row.getInt("speed_FrontR");
speed_RearL=row.getInt("speed_RearL");
speed_RearR=row.getInt("speed_RearR");
temp_Front=row.getFloat("temp_Front");
temp_Rear=row.getFloat("temp_Rear");
vbat_Front=row.getFloat("vbat_Front");
vbat_Rear=row.getFloat("vbat_Rear");
currentAll=row.getFloat("currentAll");
throttle=row.getInt("throttle");
brake=row.getInt("brake");
current_RearR=row.getFloat("current_RearR");
speed_FrontL=row.getInt("speed_FrontL");
speed_FrontR=row.getInt("speed_FrontR");
speed_RearL=row.getInt("speed_RearL");
speed_RearR=row.getInt("speed_RearR");
temp_Front=row.getFloat("temp_Front");
temp_Rear=row.getFloat("temp_Rear");
vbat_Front=row.getFloat("vbat_Front");
vbat_Rear=row.getFloat("vbat_Rear");
currentAll=row.getFloat("currentAll");
throttle=row.getInt("throttle");
brake=row.getInt("brake");
if (loopmillis-nextTimeData>1000 && nextTimeData>lastTimeData) {//too much behind
long _timestep=nextTimeData-lastTimeData; //approximated time step