Пример #1
0
/*
 * gets called from the GUI to get updated telemetry.
 * so whilst we are at it we check button status too and
 * act accordingly.
 *
 */
void
FortiusController::getRealtimeData(RealtimeData &rtData)
{
    // Added Distance and Steering here but yet to RealtimeData

    int Buttons, Status, Steering;
    double Power, HeartRate, Cadence, Speed, Distance;

    if(!myFortius->isRunning())
    {
        QMessageBox msgBox;
        msgBox.setText("Cannot Connect to Fortius");
        msgBox.setIcon(QMessageBox::Critical);
        msgBox.exec();
        parent->Stop(1);
        return;
    }
    // get latest telemetry
    myFortius->getTelemetry(Power, HeartRate, Cadence, Speed, Distance, Buttons, Steering, Status);

    //
    // PASS BACK TELEMETRY
    //
    rtData.setWatts(Power);
    rtData.setHr(HeartRate);
    rtData.setCadence(Cadence);
    rtData.setSpeed(Speed);


    // post processing, probably not used
    // since its used to compute power for
    // non-power devices, but we may add other
    // calculations later that might apply
    // means we could calculate power based
    // upon speed even for a Fortius!
    processRealtimeData(rtData);

    //
    // BUTTONS
    //

    // ignore other buttons if calibrating
    if (parent->calibrating) return;

    // ADJUST LOAD
    if ((Buttons&FT_PLUS)) parent->Higher();
    
    if ((Buttons&FT_MINUS)) parent->Lower();

    // LAP/INTERVAL
    if (Buttons&FT_ENTER) parent->newLap();

    // CANCEL
    if (Buttons&FT_CANCEL) parent->Stop(0);

    // Ensure we set the UI load to the actual setpoint from the fortius (as it will clamp)
    rtData.setLoad(myFortius->getLoad());
    rtData.setSlope(myFortius->getGradient());
}
Пример #2
0
void
RealtimeWindow::streamUpdate()
{
    RealtimeData rtData;

    // get current telemetry...
    rtData.setWatts(displayPower);
    rtData.setCadence(displayCadence);
    rtData.setHr(displayHeartRate);
    rtData.setSpeed(displaySpeed);
    rtData.setLoad(displayLoad);
    rtData.setTime(0);

    // send over the wire...
    streamController->pushRealtimeData(rtData);
}
Пример #3
0
void NullController::getRealtimeData(RealtimeData &rtData) {
    rtData.setName((char *)"Null");
    //rtData.setWatts(load + ((rand()%25)-15)); // for testing virtual power
    rtData.setWatts(load); // no randomisation
    rtData.setLoad(load);
    rtData.setSpeed(25 + ((rand()%5)-2));
    rtData.setCadence(85 + ((rand()%10)-5));
    rtData.setHr(145 + ((rand()%3)-2));
    rtData.setHb(35 + ((rand()%30)), 11 + (double(rand()%100) * 0.01f));
    processRealtimeData(rtData); // for testing virtual power etc

    // generate an R-R data signal based upon 60bpm +/- 2bpm
    if (count++%5 == 0) {

        // emit measurementTime 1/1024s plus a little randomness, incremental beat count, bpm of 60 +/- 2
        uint16_t m = (beats * 1024) + (rand()%50);
        uint8_t b = ++beats;
        uint8_t bpm =60+(rand()%2);

        //qDebug()<<"rrdata:"<<m<<b<<bpm;
        emit rrData(m, b, bpm);
    }
}
/*
 * gets called from the GUI to get updated telemetry.
 * so whilst we are at it we check button status too and
 * act accordingly.
 *
 */
void
ComputrainerController::getRealtimeData(RealtimeData &rtData)
{
    int Buttons, Status;
    bool calibration;
    double Power, HeartRate, Cadence, Speed, RRC, Load;
    uint8_t ss[24];

    if(!myComputrainer->isRunning())
    {
        QMessageBox msgBox;
        msgBox.setText("Cannot Connect to Computrainer");
        msgBox.setIcon(QMessageBox::Critical);
        msgBox.exec();
        parent->Stop(1);
        return;
    }
    // get latest telemetry
    myComputrainer->getTelemetry(Power, HeartRate, Cadence, Speed,
                        RRC, calibration, Buttons, ss, Status);

    //
    // PASS BACK TELEMETRY
    //
    rtData.setWatts(Power);
    rtData.setHr(HeartRate);
    rtData.setCadence(Cadence);
    rtData.setSpeed(Speed);

    memcpy(rtData.spinScan, ss, 24);

    // post processing, probably not used
    // since its used to compute power for
    // non-power devices, but we may add other
    // calculations later that might apply
    // means we could calculate power based
    // upon speed even for CT!
    processRealtimeData(rtData);

    //
    // BUTTONS
    //

    // toggle calibration
    if (Buttons&CT_F3) {
        parent->Calibrate();
    }

    // ignore other buttons if calibrating
    if (parent->calibrating) return;

    // ADJUST LOAD
    Load = myComputrainer->getLoad();
    if ((Buttons&CT_PLUS) && !(Buttons&CT_F3)) {
            parent->Higher();
    }
    if ((Buttons&CT_MINUS) && !(Buttons&CT_F3)) {
            parent->Lower();
    }
    rtData.setLoad(Load);

#if 0 // F3 now toggles calibration
    // FFWD/REWIND
    if ((Buttons&CT_PLUS) && (Buttons&CT_F3)) {
           parent->FFwd();
    }
    if ((Buttons&CT_MINUS) && (Buttons&CT_F3)) {
           parent->Rewind();
    }
#endif

    // LAP/INTERVAL
    if (Buttons&CT_F1 && !(Buttons&CT_F3)) {
        parent->newLap();
    }
    if ((Buttons&CT_F1) && (Buttons&CT_F3)) {
           parent->FFwdLap();
    }

    // if Buttons == 0 we just pressed stop!
    if (Buttons&CT_RESET) {
        parent->Stop(0);
    }

    // displaymode
    if (Buttons&CT_F2) {
        parent->nextDisplayMode();
    }
}
Пример #5
0
void
RealtimeController::processRealtimeData(RealtimeData &rtData)
{
    if (!dc) return; // no config

    // setup the algorithm or lookup tables
    // for the device postprocessing type
    switch(dc->postProcess) {
    case 0 : // nothing!
        break;
    case 1 : // Kurt Kinetic - Cyclone
        {
        double mph = rtData.getSpeed() * MILES_PER_KM;
        // using the algorithm from http://www.kurtkinetic.com/powercurve.php
        rtData.setWatts((6.481090) * mph + (0.020106) * (mph*mph*mph));
        }
        break;
    case 2 : // Kurt Kinetic - Road Machine
        {
        double mph = rtData.getSpeed() * MILES_PER_KM;
        // using the algorithm from http://www.kurtkinetic.com/powercurve.php
        rtData.setWatts((5.244820) * mph + (0.019168) * (mph*mph*mph));
        }
        break;
    case 3 : // Cyclops Fluid 2
        {
        double mph = rtData.getSpeed() * MILES_PER_KM;
        // using the algorithm from:
        // http://thebikegeek.blogspot.com/2009/12/while-we-wait-for-better-and-better.html
        rtData.setWatts((0.0115*(mph*mph*mph)) - ((0.0137)*(mph*mph)) + ((8.9788)*(mph)));
        }
        break;
    case 4 : // BT-ATS - BT Advanced Training System
        {
        //        v is expressed in revs/second
        double v = rtData.getWheelRpm()/60.0;
        // using the algorithm from Steven Sansonetti of BT:
        //  This is a 3rd order polynomial, where P = av3 + bv2 + cv + d
        //  where:
                double a =       2.90390167E-01; // ( 0.290390167)
                double b =     - 4.61311774E-02; // ( -0.0461311774)
                double c =       5.92125507E-01; // (0.592125507)
                double d =       0.0;
        rtData.setWatts(a*v*v*v + b*v*v +c*v + d);
        }
        break;

    case 5 : // Lemond Revolution
        {
        double V = rtData.getSpeed() * 0.277777778;
        // Tom Anhalt spent a lot of time working this all out
        // for the data / analysis see: http://wattagetraining.com/forum/viewtopic.php?f=2&t=335
        rtData.setWatts((0.21*pow(V,3))+(4.25*V));
        }
        break;

    case 6 : // 1UP USA
        {
        double V = rtData.getSpeed() * MILES_PER_KM;
        // Power curve provided by extraction from SportsTracks plugin
        rtData.setWatts(25.00 + (2.65f*V) - (0.42f*pow(V,2)) + (0.058f*pow(V,3)));
        }
        break;

    // MINOURA - Has many gears
    case 7 : //MINOURA V100 on H
        {
        double V = rtData.getSpeed();
        // 7 = V100 on H: y = -0.0036x^3 + 0.2815x^2 + 3.4978x - 9.7857 
        rtData.setWatts(pow(-0.0036*V, 3) + pow(0.2815*V,2) + (3.4978*V) - 9.7857);
        }
        break;

    case 8 : //MINOURA V100 on 5
        {
        double V = rtData.getSpeed();
        // 8 = V100 on 5: y = -0.0023x^3 + 0.2067x^2 + 3.8906x - 11.214 
        rtData.setWatts(pow(-0.0023*V, 3) + pow(0.2067*V,2) + (3.8906*V) - 11.214);
        }
        break;

    case 9 : //MINOURA V100 on 4
        {
        double V = rtData.getSpeed();
        // 9 = V100 on 4: y = -0.00173x^3 + 0.1825x^2 + 3.4036x - 10 
        rtData.setWatts(pow(-0.00173*V, 3) + pow(0.1825*V,2) + (3.4036*V) - 10.00);
        }
        break;

    case 10 : //MINOURA V100 on 3
        {
        double V = rtData.getSpeed();
        // 10 = V100 on 3: y = -0.0011x^3 + 0.1433x^2 + 2.8808x - 8.1429 
        rtData.setWatts(pow(-0.0011*V, 3) + pow(0.1433*V,2) + (2.8808*V) - 8.1429);
        }
        break;

    case 11 : //MINOURA V100 on 2
        {
        double V = rtData.getSpeed();
        // 11 = V100 on 2: y = -0.0007x^3 + 0.1348x^2 + 1.581x - 3.3571 
        rtData.setWatts(pow(-0.0007*V, 3) + pow(0.1348*V,2) + (1.581*V) - 3.3571);
        }
        break;

    case 12 : //MINOURA V100 on 1
        {
        double V = rtData.getSpeed();
        // 12 = V100 on 1: y = 0.0004x^3 + 0.057x^2 + 1.7797x - 5.0714 
        rtData.setWatts(pow(0.0004*V, 3) + pow(0.057*V,2) + (1.7797*V) - 5.0714);
        }
        break;

    case 13 : //MINOURA V100 on L
        {
        double V = rtData.getSpeed();
        // 13 = V100 on L: y = 0.0557x^2 + 1.231x - 3.7143 
        rtData.setWatts(pow(0.0557*V, 2) + (1.231*V) - 3.7143);
        }
        break;

    case 14 : //SARIS POWERBEAM PRO
        {
        double V = rtData.getSpeed();
        // 14 = 0.0008x^3 + 0.145x^2 + 2.5299x + 14.641 where x = speed in kph
        rtData.setWatts(pow(0.0008*V, 3) + pow(0.145*V, 2) + (2.5299*V) + 14.641);
        }
        break;

    case 15 : //  TACX SATORI SETTING 2
        {
        double V = rtData.getSpeed();
        double slope = 5.33;
        double intercept = -36.67;
        rtData.setWatts((slope * V) + intercept);
        }
        break;

    case 16 : //  TACX SATORI SETTING 4
        {
        double V = rtData.getSpeed();
        double slope = 8.27;
        double intercept = -47.33;
        rtData.setWatts((slope * V) + intercept);
        }
        break;

    case 17 : //  TACX SATORI SETTING 6
        {
        double V = rtData.getSpeed();
        double slope = 11.400;
        double intercept = -67.00;
        rtData.setWatts((slope * V) + intercept);
        }
        break;

    case 18 : //  TACX SATORI SETTING 8
        {
        double V = rtData.getSpeed();
        double slope = 14.40;
        double intercept = -82.00;
        rtData.setWatts((slope * V) + intercept);
        }
        break;

    case 19 : //  TACX SATORI SETTING 10
        {
        double V = rtData.getSpeed();
        double slope = 17.73;
        double intercept = -114.67;
        rtData.setWatts((slope * V) + intercept);
        }
        break;

    case 20 : //  TACX FLOW SETTING 0
        {
        double V = rtData.getSpeed();
        double slope = 7.75;
        double intercept = -47.27;
        rtData.setWatts((slope * V) + intercept);
        }
        break;

    case 21 : //  TACX FLOW SETTING 2
        {
        double V = rtData.getSpeed();
        double slope = 9.51;
        double intercept = -66.69;
        rtData.setWatts((slope * V) + intercept);
        }
        break;

    case 22 : //  TACX FLOW SETTING 4
        {
        double V = rtData.getSpeed();
        double slope = 11.03;
        double intercept = -71.59;
        rtData.setWatts((slope * V) + intercept);
        }
        break;

    case 23 : //  TACX FLOW SETTING 6
        {
        double V = rtData.getSpeed();
        double slope = 12.81;
        double intercept = -95.05;
        rtData.setWatts((slope * V) + intercept);
        }
        break;

    case 24 : //  TACX FLOW SETTING 8
        {
        double V = rtData.getSpeed();
        double slope = 14.37;
        double intercept = -102.43;
        rtData.setWatts((slope * V) + intercept);
        }
        break;

    default : // unknown - do nothing
        break;
    }
}