mirror of
https://github.com/GoldenCheetah/GoldenCheetah.git
synced 2026-02-16 09:29:55 +00:00
Added SRM5 file format read support
SRM5 basically is the same as SRM6, but lacks "blocks". This means, it only has the date of the exercise and no further absolute time info. Furthermore it can't flag periods of time, where no data was collected. Due to lack of absolute time, Exercises start at 0:00, by default. Fixes #208
This commit is contained in:
committed by
Mark Liversedge
parent
bfb85b1fa2
commit
9d05aa0704
@@ -87,7 +87,7 @@ RideFile *SrmFileReader::openRideFile(QFile &file, QStringList &errorStrings) co
|
||||
in.readRawData(magic, sizeof(magic));
|
||||
assert(strncmp(magic, "SRM", 3) == 0);
|
||||
int version = magic[3] - '0';
|
||||
assert(version == 6 || version == 7);
|
||||
assert(version == 5 || version == 6 || version == 7);
|
||||
|
||||
quint16 dayssince1880 = readShort(in);
|
||||
quint16 wheelcirc = readShort(in);
|
||||
@@ -111,8 +111,10 @@ RideFile *SrmFileReader::openRideFile(QFile &file, QStringList &errorStrings) co
|
||||
QVector<marker> markers(markercnt + 1);
|
||||
for (int i = 0; i <= markercnt; ++i) {
|
||||
char mcomment[256];
|
||||
in.readRawData(mcomment, sizeof(mcomment) - 1);
|
||||
mcomment[sizeof(mcomment) - 1] = '\0';
|
||||
size_t mcommentlen = version < 6 ? 3 : 255;
|
||||
assert( mcommentlen < sizeof(mcomment) );
|
||||
in.readRawData(mcomment, mcommentlen );
|
||||
mcomment[mcommentlen] = '\0';
|
||||
|
||||
quint8 active = readByte(in);
|
||||
quint16 start = readShort(in);
|
||||
@@ -146,7 +148,7 @@ RideFile *SrmFileReader::openRideFile(QFile &file, QStringList &errorStrings) co
|
||||
(void) wheelcirc;
|
||||
}
|
||||
|
||||
blockhdr *blockhdrs = new blockhdr[blockcnt];
|
||||
blockhdr *blockhdrs = new blockhdr[blockcnt+1];
|
||||
for (int i = 0; i < blockcnt; ++i) {
|
||||
// In the .srm files generated by Rainer Clasen's srmcmd,
|
||||
// hsecsincemidn is a *signed* 32-bit integer. I haven't seen a
|
||||
@@ -167,7 +169,13 @@ RideFile *SrmFileReader::openRideFile(QFile &file, QStringList &errorStrings) co
|
||||
(void) zero;
|
||||
(void) slope;
|
||||
|
||||
assert(blockcnt > 0);
|
||||
// SRM5 files have no blocks - synthesize one
|
||||
if( blockcnt < 1 ){
|
||||
blockcnt = 0;
|
||||
blockhdrs[0].chunkcnt = datacnt;
|
||||
blockhdrs[0].dt = QDateTime(date);
|
||||
}
|
||||
|
||||
|
||||
int blknum = 0, blkidx = 0, mrknum = 0, interval = 0;
|
||||
double km = 0.0, secs = 0.0;
|
||||
@@ -178,7 +186,7 @@ RideFile *SrmFileReader::openRideFile(QFile &file, QStringList &errorStrings) co
|
||||
for (int i = 0; i < datacnt; ++i) {
|
||||
int cad, hr, watts;
|
||||
double kph, alt;
|
||||
if (version == 6) {
|
||||
if (version < 7) {
|
||||
quint8 ps[3];
|
||||
in.readRawData((char*) ps, sizeof(ps));
|
||||
cad = readByte(in);
|
||||
|
||||
Reference in New Issue
Block a user