1 /**********************************************************************************************
2 
3     This program is free software: you can redistribute it and/or modify
4     it under the terms of the GNU General Public License as published by
5     the Free Software Foundation, either version 3 of the License, or
6     (at your option) any later version.
7 
8     This program is distributed in the hope that it will be useful,
9     but WITHOUT ANY WARRANTY; without even the implied warranty of
10     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
11     GNU General Public License for more details.
12 
13     You should have received a copy of the GNU General Public License
14     along with this program.  If not, see <http://www.gnu.org/licenses/>.
15 
16 **********************************************************************************************/
17 
18 #ifndef CENERGYCYCLING_H
19 #define CENERGYCYCLING_H
20 
21 class CGisItemTrk;
22 class CTrackData;
23 
24 /** @brief Class to compute the "Energy Use Cycling" value
25 
26    With this functionality your personal energy use (consumption) for a cycling tour can be computed.
27 
28    The computed value of "Energy Use Cycling" can be see as an indicator for the exertion of a cycling tour.
29 
30    The tour length, speed and slope values will be taken into account.
31 
32    To individualize your personal energy use the following input data are more needed:
33     - Driver and bicyle weight
34     - Air density, wind speed and position to the wind to consider the wind drag resistance
35     - Ground situation (tyre and ground) to consider the rolling resistance
36     - Average pedal cadence for the computation of pedal force
37 
38    The individualize data will be defined in its own dialog (see CEnergyCyclingDialog) and more computed values will be shown here.
39 
40    When loading older tracks or switching in history to tracks with a different parameter set compared to the previous saved parameter set, the shown parameter set in this dialog can be replaced by the previous saved parameter set."
41 
42    The energy use in unit "kcal" will be stored in the track and can be remove later on when no longer needed.
43 
44     For more information see tooltips on input and output values in the dialog.
45  */
46 class CEnergyCycling
47 {
48 public:
49 /** @brief The parameter set structure (input and output values) to compute "Energy Use Cycling" value
50  */
51     struct energy_set_t
52     {
53         qreal driverWeight = 75;
54         qreal bikeWeight = 15;
55         qreal airDensity = 1.2;
56         qint32 windSpeedIndex = 5;
57         qreal windSpeed = 0;
58         qint32 windPositionIndex = 2;
59         qreal frontalArea = 0.65;
60         qreal windDragCoeff = 1.0;
61         qint32 groundIndex = 3;
62         qreal rollingCoeff = 0.005;
63         qreal pedalCadence = 75;
64         qreal airResistForce = NOFLOAT;
65         qreal gravitySlopeForce = NOFLOAT;
66         qreal rollResistForce = NOFLOAT;
67         qreal sumForce = NOFLOAT;
68         qreal powerMovingTime = NOFLOAT;
69         qreal power = NOFLOAT;
70         qreal positivePower = NOFLOAT;
71         qreal powerMovingTimeRatio = NOFLOAT;
72         qreal energyKJoule = NOFLOAT;
73         qreal energyKcal = NOFLOAT;
74         qreal positivePedalForce = NOFLOAT;
75     };
76 
77     CEnergyCycling(CGisItemTrk& trk);
78     virtual ~CEnergyCycling() = default;
79 
80     /** @brief Get the track's parameter set
81 
82        @return The track's parameter set
83      */
getEnergyTrkSet()84     const energy_set_t& getEnergyTrkSet() const { return energyTrkSet; }
85 
86     void setEnergyTrkSet(const energy_set_t& energyTrkSet, bool updateHistory);
87 
88     /** @brief Get the "Energy Use Cycling" value from the track's parameter set
89 
90        @return The "Energy Use Cycling" value
91      */
getEnergyUseCycling()92     qreal getEnergyUseCycling() const { return energyTrkSet.energyKcal; }
93 
94     void compute();
95     void compute(energy_set_t& energySet);
96     void remove();
97 
98     bool isValid() const;
99 
100     void loadSettings(energy_set_t& energySet);
101     void saveSettings();
102 
103 private:
104     energy_set_t energyTrkSet;      //!< The track's parameter set
105     CGisItemTrk& trk;               //!< reference to the track, non-const, due to update of parameter set energyTrkSet
106 };
107 
108 #endif // CENERGYCYCLING_H
109