mirror of
https://github.com/GoldenCheetah/GoldenCheetah.git
synced 2026-02-14 08:38:45 +00:00
* Options > Data Fields > Processors & Automation (renamed from
"Processing")
* Modernized the UI
* Added UI to set Automation (None, On Import, On Save) for all
processors
* Added UI to set Automated execution only for all processors
* Showing the processors description
* Showing the processors setting (if available) in a more userfriendly
way
* Added option to add / delete / edit custom Python processors
* Enabled editing of Python processors via double click
* Added option to hide code processors
* Removed the submenu to manage Python Fixes from the Edit-menu
* Renamed the Edit-menu to "Process"
* Hiding "automated only"-processors from Process-menu and
Batchprocessing-dialog
* DataProcessors
* Turned configuration of all core processors into forms
* Changed the technical name of all core processors to match their
classname
* Added legacy technical name to all core processors to support existing
scripts
* Moved description from config-class to DataProcessor
* Implemented a migration path for existing persisted processor
configurations
* GSettings
* Added method to remove settings by key
162 lines
5.2 KiB
C++
162 lines
5.2 KiB
C++
/*
|
|
* Copyright (c) 2010 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
|
|
* Software Foundation; either version 2 of the License, or (at your option)
|
|
* any later version.
|
|
*
|
|
* This program is distributed in the hope that it will be useful, but WITHOUT
|
|
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
|
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
|
|
* more details.
|
|
*
|
|
* You should have received a copy of the GNU General Public License along
|
|
* with this program; if not, write to the Free Software Foundation, Inc., 51
|
|
* Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
|
*/
|
|
|
|
#include "DataProcessor.h"
|
|
#include "LTMOutliers.h"
|
|
#include "Settings.h"
|
|
#include "Units.h"
|
|
#include "Colors.h"
|
|
#include "HelpWhatsThis.h"
|
|
#include <algorithm>
|
|
#include <QVector>
|
|
|
|
// Config widget used by the Preferences/Options config panes
|
|
class FixTorque;
|
|
class FixTorqueConfig : public DataProcessorConfig
|
|
{
|
|
Q_DECLARE_TR_FUNCTIONS(FixTorqueConfig)
|
|
|
|
friend class ::FixTorque;
|
|
protected:
|
|
QLineEdit *ta;
|
|
|
|
public:
|
|
FixTorqueConfig(QWidget *parent) : DataProcessorConfig(parent) {
|
|
|
|
HelpWhatsThis *help = new HelpWhatsThis(parent);
|
|
parent->setWhatsThis(help->getWhatsThisText(HelpWhatsThis::MenuBar_Edit_AdjustTorqueValues));
|
|
|
|
QFormLayout *layout = newQFormLayout(this);
|
|
layout->setContentsMargins(0,0,0,0);
|
|
setContentsMargins(0,0,0,0);
|
|
|
|
ta = new QLineEdit();
|
|
layout->addRow(tr("Torque Adjust"), ta);
|
|
}
|
|
|
|
//~FixTorqueConfig() {} // deliberately not declared since Qt will delete
|
|
// the widget and its children when the config pane is deleted
|
|
|
|
void readConfig() {
|
|
ta->setText(appsettings->value(NULL, GC_DPTA, "0 nm").toString());
|
|
}
|
|
|
|
void saveConfig() {
|
|
appsettings->setValue(GC_DPTA, ta->text());
|
|
}
|
|
};
|
|
|
|
|
|
// RideFile Dataprocessor -- used to handle gaps in recording
|
|
// by inserting interpolated/zero samples
|
|
// to ensure dataPoints are contiguous in time
|
|
//
|
|
class FixTorque : public DataProcessor {
|
|
Q_DECLARE_TR_FUNCTIONS(FixTorque)
|
|
|
|
public:
|
|
FixTorque() {}
|
|
~FixTorque() {}
|
|
|
|
// the processor
|
|
bool postProcess(RideFile *, DataProcessorConfig* config, QString op) override;
|
|
|
|
// the config widget
|
|
DataProcessorConfig* processorConfig(QWidget *parent, const RideFile * ride = NULL) const override {
|
|
Q_UNUSED(ride);
|
|
return new FixTorqueConfig(parent);
|
|
}
|
|
|
|
// Localized Name
|
|
QString name() const override {
|
|
return tr("Adjust Torque Values");
|
|
}
|
|
|
|
QString id() const override {
|
|
return "::FixTorque";
|
|
}
|
|
|
|
QString legacyId() const override {
|
|
return "Adjust Torque Values";
|
|
}
|
|
|
|
QString explain() const override {
|
|
return tr("Adjusting torque values allows you to "
|
|
"uplift or degrade the torque values when the calibration "
|
|
"of your power meter was incorrect. It "
|
|
"takes a single parameter:\n\n"
|
|
"Torque Adjust - this defines an absolute value "
|
|
"in poinds per square inch or newton meters to "
|
|
"modify values by. Negative values are supported. (e.g. enter \"1.2 nm\" or "
|
|
"\"-0.5 pi\").");
|
|
}
|
|
};
|
|
|
|
static bool fixTorqueAdded = DataProcessorFactory::instance().registerProcessor(new FixTorque());
|
|
|
|
bool
|
|
FixTorque::postProcess(RideFile *ride, DataProcessorConfig *config=0, QString op="")
|
|
{
|
|
Q_UNUSED(op)
|
|
|
|
// does this ride have torque?
|
|
if (ride->areDataPresent()->nm == false) return false;
|
|
|
|
// Lets do it then!
|
|
QString ta;
|
|
double nmAdjust;
|
|
|
|
if (config == NULL) { // being called automatically
|
|
ta = appsettings->value(NULL, GC_DPTA, "0 nm").toString();
|
|
} else { // being called manually
|
|
ta = ((FixTorqueConfig*)(config))->ta->text();
|
|
}
|
|
|
|
// patrick's torque adjustment code
|
|
bool pi = ta.endsWith("pi", Qt::CaseInsensitive);
|
|
if (pi || ta.endsWith("nm", Qt::CaseInsensitive)) {
|
|
nmAdjust = ta.left(ta.length() - 2).toDouble();
|
|
if (pi) {
|
|
nmAdjust *= 0.11298482933;
|
|
}
|
|
} else {
|
|
nmAdjust = ta.toDouble();
|
|
}
|
|
|
|
// no adjustment required
|
|
if (nmAdjust == 0) return false;
|
|
|
|
// apply the change
|
|
ride->command->startLUW("Adjust Torque");
|
|
for (int i=0; i<ride->dataPoints().count(); i++) {
|
|
RideFilePoint *point = ride->dataPoints()[i];
|
|
|
|
if (point->nm != 0) {
|
|
double newnm = point->nm + nmAdjust;
|
|
ride->command->setPointValue(i, RideFile::watts, point->watts * (newnm / point->nm));
|
|
ride->command->setPointValue(i, RideFile::nm, newnm);
|
|
}
|
|
}
|
|
ride->command->endLUW();
|
|
|
|
double currentta = ride->getTag("Torque Adjust", "0.0").toDouble();
|
|
ride->setTag("Torque Adjust", QString("%1 nm").arg(currentta + nmAdjust));
|
|
|
|
return true;
|
|
}
|