Train: Add lap handling to qwkcode

This commit is contained in:
Erik Botö
2016-08-08 17:34:18 +02:00
parent ca2c46f383
commit ed99a1f202
2 changed files with 90 additions and 3 deletions

View File

@@ -685,6 +685,9 @@ ErgFile::save(QStringList &errors)
out << "[COURSE DATA]\n";
bool first=true;
long lastLap = 0;
double lastPointX = 0;
foreach(ErgFilePoint p, Points) {
// output
@@ -694,6 +697,22 @@ ErgFile::save(QStringList &errors)
// we scale back if needed
if (Ftp && CP) watts = (double(p.y)/CP) * Ftp;
// check if a lap marker should be inserted
foreach(ErgFileLap l, Laps) {
bool addLap = false;
if (l.x == p.x && lastLap != l.x) {
// this is the case where a lap marker matches a load marker
addLap = true;
} else if (l.x > lastPointX && l.x < p.x) {
// this is the case when a lap marker exist between two load markers
addLap = true;
}
if (addLap) {
out <<QString("%1 LAP\n").arg(minutes, 0, 'f', 2);
lastLap = l.x;
}
}
if (first) {
first=false;
@@ -705,6 +724,8 @@ ErgFile::save(QStringList &errors)
// output in minutes and watts
out <<QString("%1 %2\n").arg(minutes, 0, 'f', 2).arg(watts);
lastPointX = p.x;
}
out << "[END COURSE DATA]\n";