Skip to content

Commit

Permalink
Avoid duplicate time records in Train Mode
Browse files Browse the repository at this point in the history
Fixes #3205
  • Loading branch information
amtriathlon committed Nov 6, 2019
1 parent ab18468 commit cc1ebdd
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
8 changes: 6 additions & 2 deletions src/Train/TrainSidebar.cpp
Expand Up @@ -336,6 +336,7 @@ TrainSidebar::TrainSidebar(Context *context) : GcWindow(context), context(contex
lap_elapsed_msec = 0;

rrFile = recordFile = NULL;
lastRecordSecs = 0;
status = 0;
setStatusFlags(RT_MODE_ERGO); // ergo mode by default
mode = ERG;
Expand Down Expand Up @@ -1247,6 +1248,7 @@ void TrainSidebar::Start() // when start button is pressed

if (recordFile) delete recordFile;
recordFile = new QFile(fulltarget);
lastRecordSecs = 0;
if (!recordFile->open(QFile::WriteOnly | QFile::Truncate)) {
clearStatusFlags(RT_RECORDING);
} else {
Expand Down Expand Up @@ -1909,8 +1911,10 @@ void TrainSidebar::diskUpdate()

// convert from milliseconds to secondes
total_msecs = session_elapsed_msec + session_time.elapsed();
secs = total_msecs;
secs /= 1000.0;
secs = round(total_msecs / 1000.0);

if (secs <= lastRecordSecs) return; // Avoid duplicates
lastRecordSecs = secs;

// GoldenCheetah CVS Format "secs, cad, hr, km, kph, nm, watts, alt, lon, lat, headwind, slope, temp, interval, lrbalance, lte, rte, lps, rps, smo2, thb, o2hb, hhb\n";

Expand Down
1 change: 1 addition & 0 deletions src/Train/TrainSidebar.h
Expand Up @@ -268,6 +268,7 @@ class TrainSidebar : public GcWindow
int displaymode;

QFile *recordFile; // where we record!
int lastRecordSecs; // to avoid duplicates
QFile *rrFile; // r-r records, if any received.
ErgFile *ergFile; // workout file
VideoSyncFile *videosyncFile; // videosync file
Expand Down

0 comments on commit cc1ebdd

Please sign in to comment.