Skip to content

Commit

Permalink
Correct TCX output for Stages Power meters (#57)
Browse files Browse the repository at this point in the history
Specifically, as the V800 only reports power for the left side when
using Stages power meters, the total output power samples ought to be
doubled.

Note, this implementation has a positive side-effect of causing 0-value
power samples to be included in the generated TCX files, where
previously such samples where being erroneously discarded as "no data".
  • Loading branch information
pcolby committed Nov 23, 2015
1 parent 8fb81dd commit 0db3060
Show file tree
Hide file tree
Showing 5 changed files with 12,293 additions and 11,437 deletions.
22 changes: 15 additions & 7 deletions src/polar/v2/trainingsession.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2235,16 +2235,24 @@ QDomDocument TrainingSession::toTCX(const QString &buildTime) const
}
}

const int currentPowerLeft = (index < powerLeft.length()) ?
first(powerLeft.at(index).toMap().value(QLatin1String("current-power"))).toInt() : 0;
const int currentPowerRight = (index < powerRight.length()) ?
first(powerRight.at(index).toMap().value(QLatin1String("current-power"))).toInt() : 0;
const int currentPower = currentPowerLeft + currentPowerRight;
if (currentPower != 0) {
const QVariant currentPowerLeft = (index < powerLeft.length()) ?
first(powerLeft.at(index).toMap().value(QLatin1String("current-power"))) : QVariant();
const QVariant currentPowerRight = (index < powerRight.length()) ?
first(powerRight.at(index).toMap().value(QLatin1String("current-power"))) : QVariant();

const QVariant currentPower =
(currentPowerLeft.isValid() && currentPowerRight.isValid())
? currentPowerLeft.toInt() + currentPowerRight.toInt()
: currentPowerLeft.isValid() ? currentPowerLeft.toInt() * 2
: currentPowerRight.isValid() ? currentPowerRight.toInt() * 2
: QVariant();

if (currentPower.isValid()) {
tpx.appendChild(doc.createElement(QLatin1String("Watts")))
.appendChild(doc.createTextNode(QString::fromLatin1("%1")
.arg(currentPower)));
.arg(currentPower.toInt())));
}

}

if (trackPoint.hasChildNodes()) {
Expand Down
Loading

0 comments on commit 0db3060

Please sign in to comment.