Skip to content

Commit

Permalink
Import HR from R-R data for SML files
Browse files Browse the repository at this point in the history
Fixes #1841
  • Loading branch information
amtriathlon committed May 2, 2016
1 parent ef27426 commit 28ec053
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions src/FileIO/SmlParser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -269,6 +269,23 @@ SmlParser::endElement(const QString&, const QString&, const QString& qName)
}
}

else if (qName == "Data" && !rideFile->isDataPresent(rideFile->hr))
{ // R-R data and no HR in samples: backfill using EWMA filtered R-R
double secs = 0.0;
double ewmaRR = -1.0;
const double ewmaTC = 5.0;
foreach (QString strRR, buffer.split(" ")) {
double rr = strRR.toDouble() / 1000.0;
if (ewmaRR < 0.0) ewmaRR = rr;
else ewmaRR += (rr - ewmaRR)/ewmaTC;
if (secs + rr >= trunc(secs) + 1.0) {
rideFile->setPointValue(rideFile->timeIndex(secs), rideFile->hr, round(60.0/ ewmaRR));
}
secs += rr;
}
if (ewmaRR >= 0.0) rideFile->setDataPresent(rideFile->hr, true);
}

return true;
}

Expand Down

0 comments on commit 28ec053

Please sign in to comment.