From 28cbf3b9432e2f976d7aa7b6f4ba99a8b8dffb21 Mon Sep 17 00:00:00 2001 From: Ale Martinez Date: Sun, 20 Sep 2020 20:58:07 -0300 Subject: [PATCH] Override existing watts on power estimators manual call Similar to other DPs, it is what the users expect and it is easier to try with different parameters. When called automatically existing watts are preserved to avoid accidental overwrite. --- src/FileIO/FixDerivePower.cpp | 13 ++++++------- src/FileIO/FixRunningPower.cpp | 17 +++++++++-------- 2 files changed, 15 insertions(+), 15 deletions(-) diff --git a/src/FileIO/FixDerivePower.cpp b/src/FileIO/FixDerivePower.cpp index d77dc43ad..21f77d27a 100644 --- a/src/FileIO/FixDerivePower.cpp +++ b/src/FileIO/FixDerivePower.cpp @@ -146,8 +146,8 @@ class FixDerivePowerConfig : public DataProcessorConfig "from -179 to +180 (-90=W, 0=N, 90=E, 180=S)\n" "Note: when the file already contains wind data, " "it will be overridden if wind speed is set\n\n" - "The activity has to be a Ride with Speed, " - "Altitude and without Power data."))); + "The activity has to be a Ride with Speed and " + "Altitude."))); } void readConfig() { @@ -230,8 +230,8 @@ FixDerivePower::postProcess(RideFile *ride, DataProcessorConfig *config=0, QStri // Do nothing for swims and runs if (ride->isSwim() || ride->isRun()) return false; - // if its already there do nothing ! - if (ride->areDataPresent()->watts) return false; + // if called automatically and power already present, do nothing ! + if (!config && ride->areDataPresent()->watts) return false; // no dice if we don't have alt and speed if (!ride->areDataPresent()->alt || !ride->areDataPresent()->kph) return false; @@ -239,7 +239,7 @@ FixDerivePower::postProcess(RideFile *ride, DataProcessorConfig *config=0, QStri // Power Estimation Constants (mostly constants...) double hRider = ride->getHeight(); //Height in m double M = ride->getWeight() + MBik; //Total Mass kg - double T = 15; //Temp degC in not in ride data + double T = 15; // Temp degC if not in ride data double W = 0; // headwind (from records or based on wind parameters entered manually) double bearing = 0.0; //cyclist direction used to compute headwind double cCad=.002; @@ -259,8 +259,7 @@ FixDerivePower::postProcess(RideFile *ride, DataProcessorConfig *config=0, QStri // apply the change ride->command->startLUW("Estimate Power"); - if (ride->areDataPresent()->slope && ride->areDataPresent()->alt - && ride->areDataPresent()->km) { + if (ride->areDataPresent()->slope) { for (int i=0; idataPoints().count(); i++) { RideFilePoint *p = ride->dataPoints()[i]; diff --git a/src/FileIO/FixRunningPower.cpp b/src/FileIO/FixRunningPower.cpp index 14ba68c58..ab4f95851 100644 --- a/src/FileIO/FixRunningPower.cpp +++ b/src/FileIO/FixRunningPower.cpp @@ -120,8 +120,8 @@ class FixRunningPowerConfig : public DataProcessorConfig "from -179 to +180 (-90=W, 0=N, 90=E, 180=S)\n" "Note: when the file already contains wind data, " "it will be overridden if wind speed is set\n\n" - "The activity has to be a Run with Speed, " - "Altitude and without Power data."))); + "The activity has to be a Run with Speed and " + "Altitude."))); } void readConfig() { @@ -170,7 +170,6 @@ static bool FixRunningPowerAdded = DataProcessorFactory::instance().registerProc bool FixRunningPower::postProcess(RideFile *ride, DataProcessorConfig *config=0, QString op="") { - Q_UNUSED(config) Q_UNUSED(op) // get settings @@ -190,8 +189,11 @@ FixRunningPower::postProcess(RideFile *ride, DataProcessorConfig *config=0, QStr windHeading = ((FixRunningPowerConfig*)(config))->windHeading->value() / 180 * MATHCONST_PI; // rad } - // if not a run or its already there do nothing ! - if (!ride->isRun() || ride->areDataPresent()->watts) return false; + // if not a run do nothing ! + if (!ride->isRun()) return false; + + // if called automatically and power already present, do nothing ! + if (!config && ride->areDataPresent()->watts) return false; // no dice if we don't have alt and speed if (!ride->areDataPresent()->alt || !ride->areDataPresent()->kph) return false; @@ -200,7 +202,7 @@ FixRunningPower::postProcess(RideFile *ride, DataProcessorConfig *config=0, QStr double H = ride->getHeight(); //Height in m double M = ride->getWeight(); //Weight kg double Mtotal = M + MEquip; - double T = 15; //Temp degC in not in ride data + double T = 15; // Temp degC if not in ride data double W = 0; // headwind (from records or based on wind parameters entered manually) double bearing = 0.0; //runner direction used to compute headwind double Cx = 0.9; // Axial force coefficient @@ -211,8 +213,7 @@ FixRunningPower::postProcess(RideFile *ride, DataProcessorConfig *config=0, QStr // apply the change ride->command->startLUW("Estimate Running Power"); - if (ride->areDataPresent()->slope && ride->areDataPresent()->alt - && ride->areDataPresent()->km) { + if (ride->areDataPresent()->slope) { for (int i=0; idataPoints().count(); i++) { RideFilePoint *p = ride->dataPoints()[i];