Permalink
Browse files

Added W' expenditure metric

.. energy spent above CP
  • Loading branch information...
liversedge committed Jan 20, 2014
1 parent 393e4a3 commit 89a5ca26348c270d92e034d330e46a9ee8e97f82
Showing with 38 additions and 4 deletions.
  1. +2 −1 src/DBAccess.cpp
  2. +35 −2 src/WPrime.cpp
  3. +1 −1 src/WPrime.h
View
@@ -75,8 +75,9 @@
// 54 07 Jan 2014 Mark Liversedge Revised Estimated VO2MAX metric formula
// 55 20 Jan 2014 Mark Liversedge Added back Minimum W'bal metric and MaxMatch
// 56 20 Jan 2014 Mark Liversedge Added W' TAU to be able to track it
// 57 20 Jan 2014 Mark Liversedge Added W' Expenditure for total energy spent above CP
int DBSchemaVersion = 55;
int DBSchemaVersion = 57;
DBAccess::DBAccess(Context* context) : context(context), db(NULL)
{
View
@@ -125,6 +125,7 @@ WPrime::setRide(RideFile *input)
double totalBelowCP=0;
double countBelowCP=0;
QVector<int> inputArray(last+1);
EXP = 0;
for (int i=0; i<last; i++) {
int value = smoothed.value(i);
@@ -133,7 +134,7 @@ WPrime::setRide(RideFile *input)
if (value < CP) {
totalBelowCP += value;
countBelowCP++;
}
} else EXP += value; // total expenditure above CP
}
TAU = 546.00f * pow(E,-0.01*(CP - (totalBelowCP/countBelowCP))) + 316.00f;
@@ -316,7 +317,7 @@ class MaxMatch : public RideMetric {
}
void initialize() {
setName(tr("Maximum W'bal Match"));
setType(RideMetric::Low);
setType(RideMetric::Peak);
setMetricUnits(tr("Kj"));
setImperialUnits(tr("Kj"));
setPrecision(1);
@@ -366,11 +367,43 @@ class WPrimeTau : public RideMetric {
RideMetric *clone() const { return new WPrimeTau(*this); }
};
class WPrimeExp : public RideMetric {
Q_DECLARE_TR_FUNCTIONS(WPrimeExp);
public:
WPrimeExp()
{
setSymbol("skiba_wprime_exp");
setInternalName("W' expenditure");
}
void initialize() {
setName(tr("W' expenditure"));
setType(RideMetric::Total);
setMetricUnits(tr("Kj"));
setImperialUnits(tr("Kj"));
setPrecision(1);
}
void compute(const RideFile *r, const Zones *, int,
const HrZones *, int,
const QHash<QString,RideMetric*> &,
const Context *) {
WPrime w;
w.setRide((RideFile*)r);
setValue(w.EXP/1000);
}
bool canAggregate() { return false; }
RideMetric *clone() const { return new WPrimeExp(*this); }
};
// add to catalogue
static bool addMetrics() {
RideMetricFactory::instance().addMetric(MinWPrime());
RideMetricFactory::instance().addMetric(MaxMatch());
RideMetricFactory::instance().addMetric(WPrimeTau());
RideMetricFactory::instance().addMetric(WPrimeExp());
return true;
}
View
@@ -54,7 +54,7 @@ class WPrime {
double maxMatch();
double minY, maxY;
double TAU, CP, WPRIME;
double TAU, CP, WPRIME, EXP;
QList<Match> matches; // matches burned with associated cost

0 comments on commit 89a5ca2

Please sign in to comment.