Kickr: Load setting fixup

Fixed up the Kickr code to resend the load if the
user is generating more than 50% over the load or
is only generating 50% of the load.

This is in case the last message was not processed
for some reason (connection being established, or
noise).
This commit is contained in:
Mark Liversedge
2013-01-27 15:49:55 +00:00
parent 0e4ccc2e4a
commit 18a7260d36
2 changed files with 9 additions and 21 deletions

View File

@@ -18,9 +18,6 @@
#include "Kickr.h"
/* ----------------------------------------------------------------------
* CONSTRUCTOR/DESRTUCTOR
* ---------------------------------------------------------------------- */
Kickr::Kickr(QObject *parent, DeviceConfiguration *devConf) : QThread(parent)
{
this->parent = parent;
@@ -35,13 +32,8 @@ Kickr::~Kickr()
{
}
/* ----------------------------------------------------------------------
* SET
* ---------------------------------------------------------------------- */
void Kickr::setDevice(QString)
{
// not required
}
// not required
void Kickr::setDevice(QString) { }
void Kickr::setMode(int mode, double load, double gradient)
{
@@ -69,10 +61,6 @@ void Kickr::setGradient(double gradient)
}
/* ----------------------------------------------------------------------
* GET
* ---------------------------------------------------------------------- */
int Kickr::getMode()
{
int tmp;
@@ -135,7 +123,7 @@ int Kickr::quit(int code)
}
/*----------------------------------------------------------------------
* THREADED CODE - READS TELEMETRY AND SENDS COMMANDS TO KEEP CT ALIVE
* MAIN THREAD - READS TELEMETRY AND UPDATES LOAD/GRADIENT ON KICKR
*----------------------------------------------------------------------*/
void Kickr::run()
{
@@ -171,8 +159,11 @@ void Kickr::run()
}
}
// set load
if (mode == RT_MODE_ERGO && currentload != load) {
// set load - reset it if generated watts don't match ..
if (mode == RT_MODE_ERGO &&
((rt.getWatts() > load*1.5) || (rt.getWatts() < load/2)
|| currentload != load)) {
WFApi::getInstance()->setLoad(load);
currentload = load;
}

View File

@@ -1,6 +1,5 @@
/*
* Copyright (c) 2009 Mark Rages
* Copyright (c) 2009 Mark Liversedge (liversedge@gmail.com)
* Copyright (c) 2013 Mark Liversedge (liversedge@gmail.com)
*
* This program is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by the Free
@@ -19,8 +18,6 @@
#include <QProgressDialog>
#include "KickrController.h"
#include "ANT.h"
#include "ANTLogger.h"
#include "RealtimeData.h"
KickrController::KickrController(TrainTool *parent, DeviceConfiguration *dc) : RealtimeController(parent, dc)