Calculating heat load in RealtimeData via static variables?

29 views
Skip to first unread message

Jonathan Savage

unread,
Jul 7, 2025, 8:41:33 AM7/7/25
to golden-cheetah-developers
I am adding a calculation of heat load, the cumulative impact of heat stress, to GC. I want to display this value in a DialWindow, just like real time data. 

My current implementation uses static variables, accumulating the load based on the passage of time. It's a bit ugly, but I couldn't see a way that's less ugly and more complex. 

(Note the formula for heat load is different to the CORE calculation and only a rough approximation as CORE's heat load is propitiatory.)

define HEATLOAD_OFFSET 0.9596
#define HEATLOAD_MULT 35.92
#define HEATLOAD_EXP 1.324
//heat load persists across sessions
double RealtimeData::heatLoad = 0;
qint64 RealtimeData::heatLoadMSec = 0;

//Skin temp passed but not used elsewhere
void RealtimeData::setCoreTemp(double core, double skin, double heatStrain) {
    this->coreTemp = core;
    this->skinTemp = skin;

    //heatStrain = 3.5;
    this->heatStrain = heatStrain;

    //(HSI-AOC_Off)^AOC_EXP*TIME/AOC_Mult

    QDateTime currentTime = QDateTime::currentDateTimeUtc();
    qint64 msecEpoc = currentTime.toMSecsSinceEpoch();

    if(this->heatLoadMSec != 0)
    {
        qint64 deltaMSec = msecEpoc - this->heatLoadMSec;
        double deltamin = deltaMSec / (1000.0 * 60.0); //msec to minutes

        double newLoad = pow(heatStrain-HEATLOAD_OFFSET, HEATLOAD_EXP) * deltamin / HEATLOAD_MULT;


        if(newLoad > 0)
            this->heatLoad += newLoad;

        if(this->heatLoad >= 10.0)
            this->heatLoad = 10.0;
    }
    this->heatLoadMSec = msecEpoc;
}

(For my personal usage, I can just restart GC each day to reset the heat load, but I'll probably add logic to check the local date and reset each day.) 

Jonathan 

Ale Martinez

unread,
Jul 7, 2025, 2:59:21 PM7/7/25
to golden-cheetah-developers
It seems a bad idea, previous sessions can even belong to a different athlete.

Jonathan Savage

unread,
Jul 8, 2025, 3:06:01 AM7/8/25
to golden-cheetah-developers
Is there a better place to calculate heat load? The simple alternative would be to reset when the timer starts. 

Ale Martinez

unread,
Jul 8, 2025, 9:48:42 AM7/8/25
to golden-cheetah-developers
El martes, 8 de julio de 2025 a la(s) 4:06:01 a.m. UTC-3, Jonathan Savage escribió:
Is there a better place to calculate heat load? The simple alternative would be to reset when the timer starts. 

Derived real time metrics are computed in DialWindow itself in current code, there you can find several examples. 

Jonathan Savage

unread,
Jul 8, 2025, 11:45:39 AM7/8/25
to golden-cheetah-developers
Thanks - that's a much better solution. 
Reply all
Reply to author
Forward
0 new messages