Skip to content
Permalink
Browse files

Avoid duplicate time records in Train Mode

Fixes #3205
  • Loading branch information...
amtriathlon committed Nov 6, 2019
1 parent ab18468 commit cc1ebdd8275f45d13b7453046ae396725d41deab
Showing with 7 additions and 2 deletions.
  1. +6 −2 src/Train/TrainSidebar.cpp
  2. +1 −0 src/Train/TrainSidebar.h
@@ -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;
@@ -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 {
@@ -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";

@@ -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

0 comments on commit cc1ebdd

Please sign in to comment.
You can’t perform that action at this time.