Navigation Menu

Skip to content

Commit

Permalink
Train : Record load in XData TRAIN
Browse files Browse the repository at this point in the history
  • Loading branch information
grauser committed Dec 8, 2016
1 parent 4673566 commit e32c0ed
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 2 deletions.
29 changes: 29 additions & 0 deletions src/FileIO/CsvRideFile.cpp
Expand Up @@ -126,6 +126,7 @@ RideFile *CsvFileReader::openRideFile(QFile &file, QStringList &errors, QList<Ri
int prevInterval = 0;
double lastKM=0; // when deriving distance from speed
XDataSeries *rowSeries=NULL;
XDataSeries *trainSeries=NULL;

/* Joule 1.0
Version,Date/Time,Km,Minutes,RPE,Tags,"Weight, kg","Work, kJ",FTP,"Sample Rate, s",Device Type,Firmware Version,Last Updated,Category 1,Category 2
Expand Down Expand Up @@ -287,6 +288,7 @@ RideFile *CsvFileReader::openRideFile(QFile &file, QStringList &errors, QList<Ri
rideFile->setFileFormat("GoldenCheetah CSV (csv)");
unitsHeader = 1;
recInterval = 1;

++lineno;
continue;
}
Expand Down Expand Up @@ -540,6 +542,8 @@ RideFile *CsvFileReader::openRideFile(QFile &file, QStringList &errors, QList<Ri
double smo2 = 0.0, thb = 0.0;
double gct = 0.0, vo = 0.0, rcad = 0.0;
//UNUSED double o2hb = 0.0, hhb = 0.0;
double target = 0.0;

int interval=0;
int pause=0;

Expand Down Expand Up @@ -599,6 +603,7 @@ RideFile *CsvFileReader::openRideFile(QFile &file, QStringList &errors, QList<Ri
thb = line.section(',', 20, 20).toInt();
//UNUSED o2hb = line.section(',', 21, 21).toInt();
//UNUSED hhb = line.section(',', 22, 22).toInt();
target = line.section(',', 23, 23).toInt();

} else if (csvType == peripedal) {

Expand Down Expand Up @@ -1009,6 +1014,23 @@ RideFile *CsvFileReader::openRideFile(QFile &file, QStringList &errors, QList<Ri
0.0, 0.0, 0.0, 0.0,
smo2, thb,
vo, rcad, gct, 0.0, interval);

if (target > 0.0) {
if (trainSeries == NULL) {
// add XDATA
trainSeries = new XDataSeries();
trainSeries->name = "TRAIN";
trainSeries->valuename << "TARGET";
trainSeries->unitname << "Watts";
}

XDataPoint *p = new XDataPoint();
p->secs = minutes * 60.0;
p->km = km;
p->number[0] = target;

trainSeries->datapoints.append(p);
}
}
}
++lineno;
Expand Down Expand Up @@ -1102,6 +1124,13 @@ RideFile *CsvFileReader::openRideFile(QFile &file, QStringList &errors, QList<Ri

if (csvType == rowpro) rideFile->setTag("Sport","Row");

if (trainSeries != NULL) {
if (trainSeries->datapoints.count()>0)
rideFile->addXData("TRAIN", trainSeries);
else
delete trainSeries;
}

// did we actually read any samples?
if (rideFile->dataPoints().count() > 0) {
return rideFile;
Expand Down
4 changes: 2 additions & 2 deletions src/Train/TrainSidebar.cpp
Expand Up @@ -1159,7 +1159,7 @@ void TrainSidebar::Start() // when start button is pressed
// CSV File header

QTextStream recordFileStream(recordFile);
recordFileStream << "secs, cad, hr, km, kph, nm, watts, alt, lon, lat, headwind, slope, temp, interval, lrbalance, lte, rte, lps, rps, smo2, thb, o2hb, hhb\n";
recordFileStream << "secs, cad, hr, km, kph, nm, watts, alt, lon, lat, headwind, slope, temp, interval, lrbalance, lte, rte, lps, rps, smo2, thb, o2hb, hhb, target\n";

disk_timer->start(SAMPLERATE); // start screen
}
Expand Down Expand Up @@ -1666,7 +1666,7 @@ void TrainSidebar::diskUpdate()
<< "," << displayTHB
<< "," << displayO2HB
<< "," << displayHHB

<< "," << load
<< "," << "\n";
}

Expand Down

1 comment on commit e32c0ed

@liversedge
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

NICE!

We should update the default ride chart to plot this !

Please sign in to comment.