mirror of
https://github.com/GoldenCheetah/GoldenCheetah.git
synced 2026-02-13 16:18:42 +00:00
New Metric Fatigue Index
Looks at the max and min (non-zero) power values and uses the difference between them to calculate a fatigue index as a percentage. i.e. FI = (maxP - minP) / maxP * 100.00; This is really only useful for targetted intervals as for most riding there will always be a period of time where the rider coasts or takes it easy. We may look to improve it by smoothing or comparing to the average power instead of minimum power.
This commit is contained in:
@@ -71,8 +71,9 @@
|
||||
// 50 29 Oct 2013 Mark Liversedge Added percentage time in heartrate zone
|
||||
// 51 05 Nov 2013 Mark Liversedge Added average aPower
|
||||
// 52 05 Nov 2013 Mark Liversedge Added EOA - Effect of Altitude
|
||||
// 53 18 Dec 2013 Mark Liversedge Added Fatigue Index (for power)
|
||||
|
||||
int DBSchemaVersion = 52;
|
||||
int DBSchemaVersion = 53;
|
||||
|
||||
DBAccess::DBAccess(Context* context) : context(context), db(NULL)
|
||||
{
|
||||
|
||||
@@ -22,6 +22,46 @@
|
||||
#include <math.h>
|
||||
#include <QApplication>
|
||||
|
||||
class FatigueIndex : public RideMetric {
|
||||
Q_DECLARE_TR_FUNCTIONS(FatigueIndex)
|
||||
double maxp;
|
||||
double minp;
|
||||
|
||||
public:
|
||||
|
||||
FatigueIndex() : maxp(0.0), minp(10000)
|
||||
{
|
||||
setType(RideMetric::Average);
|
||||
setSymbol("power_fatigue_index");
|
||||
setInternalName("Fatigue Index");
|
||||
setName(tr("Fatigue Index"));
|
||||
setMetricUnits(tr("%"));
|
||||
setPrecision(1); // e.g. 99.9%
|
||||
setImperialUnits(tr("%"));
|
||||
|
||||
}
|
||||
void compute(const RideFile *ride, const Zones *, int,
|
||||
const HrZones *, int,
|
||||
const QHash<QString,RideMetric*> &,
|
||||
const Context *) {
|
||||
|
||||
if (ride->dataPoints().isEmpty() || !ride->areDataPresent()->watts) {
|
||||
// no data
|
||||
setValue(0.0);
|
||||
|
||||
} else {
|
||||
foreach(const RideFilePoint *point, ride->dataPoints()) {
|
||||
if (point->watts < minp && point->watts != 0) minp = point->watts;
|
||||
if (point->watts > maxp && point->watts != 0) maxp = point->watts;
|
||||
}
|
||||
|
||||
if (minp > maxp) setValue(0.00); // minp wasn't changed, all zeroes?
|
||||
else setValue(100 * ((maxp-minp)/maxp)); // as a percentage
|
||||
}
|
||||
}
|
||||
RideMetric *clone() const { return new FatigueIndex(*this); }
|
||||
};
|
||||
|
||||
class PeakPower : public RideMetric {
|
||||
Q_DECLARE_TR_FUNCTIONS(PeakPower)
|
||||
double watts;
|
||||
@@ -474,6 +514,8 @@ class PeakPowerHr60m : public PeakPowerHr {
|
||||
};
|
||||
|
||||
static bool addAllPeaks() {
|
||||
RideMetricFactory::instance().addMetric(FatigueIndex()); // added here instead of new function
|
||||
|
||||
RideMetricFactory::instance().addMetric(PeakPower1s());
|
||||
RideMetricFactory::instance().addMetric(PeakPower5s());
|
||||
RideMetricFactory::instance().addMetric(PeakPower10s());
|
||||
|
||||
Reference in New Issue
Block a user