Esempio n. 1
0
void
PowerHist::setData(RideFileCache *cache)
{
    source = Cache;
    this->cache = cache;
    dt = 1.0f / 60.0f; // rideFileCache is normalised to 1secs

    // we set with this data already?
    if (cache == LASTcache && source == LASTsource) return;

    // Now go set all those tedious arrays from
    // the ride cache
    wattsArray.resize(0);
    wattsZoneArray.resize(10);
    nmArray.resize(0);
    hrArray.resize(0);
    hrZoneArray.resize(10);
    kphArray.resize(0);
    cadArray.resize(0);

    // we do not use the selected array since it is
    // not meaningful to overlay interval selection
    // with long term data
    wattsSelectedArray.resize(0);
    wattsZoneSelectedArray.resize(0);
    nmSelectedArray.resize(0);
    hrSelectedArray.resize(0);
    hrZoneSelectedArray.resize(0);
    kphSelectedArray.resize(0);
    cadSelectedArray.resize(0);

    longFromDouble(wattsArray, cache->distributionArray(RideFile::watts));
    longFromDouble(hrArray, cache->distributionArray(RideFile::hr));
    longFromDouble(nmArray, cache->distributionArray(RideFile::nm));
    longFromDouble(cadArray, cache->distributionArray(RideFile::cad));
    longFromDouble(kphArray, cache->distributionArray(RideFile::kph));

    if (!useMetricUnits) {
        double torque_factor = (useMetricUnits ? 1.0 : 0.73756215);
        double speed_factor  = (useMetricUnits ? 1.0 : 0.62137119);

        for(int i=0; i<nmArray.size(); i++) nmArray[i] = nmArray[i] * torque_factor;
        for(int i=0; i<kphArray.size(); i++) kphArray[i] = kphArray[i] * speed_factor;
    }

    // zone array
    for (int i=0; i<10; i++) {
        wattsZoneArray[i] = cache->wattsZoneArray()[i];
        hrZoneArray[i] = cache->hrZoneArray()[i];
    }
}
Esempio n. 2
0
static void doubleToTwoUInts(double d, UInt *a, UInt *b) {
  longToTwoUInts(longFromDouble(d), a, b);
}