/* * 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()); }
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); }
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(); } }