~ubuntu-branches/ubuntu/saucy/goldencheetah/saucy

« back to all changes in this revision

Viewing changes to src/PolarRideFile.cpp

  • Committer: Package Import Robot
  • Author(s): KURASHIKI Satoru
  • Date: 2013-08-18 07:02:45 UTC
  • mfrom: (4.1.8 sid)
  • Revision ID: package-import@ubuntu.com-20130818070245-zgdvb47e1k3mtgil
Tags: 3.0-3
debian/control: remove needless dependency. (Closes: #719571)

Show diffs side-by-side

added added

removed removed

Lines of Context:
29
29
    RideFileFactory::instance().registerReader(
30
30
        "hrm", "Polar Precision", new PolarFileReader());
31
31
 
32
 
RideFile *PolarFileReader::openRideFile(QFile &file, QStringList &errors) const
 
32
RideFile *PolarFileReader::openRideFile(QFile &file, QStringList &errors, QList<RideFile*>*) const
33
33
{
34
34
/*
35
35
* Polar HRM file format documented at www.polar.fi/files/Polar_HRM_file%20format.pdf
42
42
    QString note("");
43
43
 
44
44
    double version=0;
 
45
    int monitor=0;
45
46
 
46
47
    double seconds=0;
47
48
    double distance=0;
52
53
    bool altitude = false;
53
54
    bool power = false;
54
55
    bool balance = false;
55
 
    bool pedaling_index = false;
56
56
 
57
57
 
58
58
    int recInterval = 1;
107
107
                    QString versionString = QString(line);
108
108
                    versionString.remove(0,8).insert(1, ".");
109
109
                    version = versionString.toFloat();
110
 
                    rideFile->setDeviceType("Polar HRM (v"+versionString+")");
 
110
                    rideFile->setFileFormat("Polar HRM v"+versionString+" (hrm)");
 
111
                } else if (line.contains("Monitor=")) {
 
112
                    QString monitorString = QString(line);
 
113
                    monitorString.remove(0,8);
 
114
                    monitor = monitorString.toInt();
 
115
                    switch (monitor) {
 
116
                        case 1: rideFile->setDeviceType("Polar Sport Tester / Vantage XL"); break;
 
117
                        case 2: rideFile->setDeviceType("Polar Vantage NV (VNV)"); break;
 
118
                        case 3: rideFile->setDeviceType("Polar Accurex Plus"); break;
 
119
                        case 4: rideFile->setDeviceType("Polar XTrainer Plus"); break;
 
120
                        case 6: rideFile->setDeviceType("Polar S520"); break;
 
121
                        case 7: rideFile->setDeviceType("Polar Coach"); break;
 
122
                        case 8: rideFile->setDeviceType("Polar S210"); break;
 
123
                        case 9: rideFile->setDeviceType("Polar S410"); break;
 
124
                        case 10: rideFile->setDeviceType("Polar S510"); break;
 
125
                        case 11: rideFile->setDeviceType("Polar S610 / S610i"); break;
 
126
                        case 12: rideFile->setDeviceType("Polar S710 / S710i"); break;
 
127
                        case 13: rideFile->setDeviceType("Polar S810 / S810i"); break;
 
128
                        case 15: rideFile->setDeviceType("Polar E600"); break;
 
129
                        case 20: rideFile->setDeviceType("Polar AXN500"); break;
 
130
                        case 21: rideFile->setDeviceType("Polar AXN700"); break;
 
131
                        case 22: rideFile->setDeviceType("Polar S625X / S725X"); break;
 
132
                        case 23: rideFile->setDeviceType("Polar S725"); break;
 
133
                        case 33: rideFile->setDeviceType("Polar CS400"); break;
 
134
                        case 34: rideFile->setDeviceType("Polar CS600X"); break;
 
135
                        case 35: rideFile->setDeviceType("Polar CS600"); break;
 
136
                        case 36: rideFile->setDeviceType("Polar RS400"); break;
 
137
                        case 37: rideFile->setDeviceType("Polar RS800"); break;
 
138
                        case 38: rideFile->setDeviceType("Polar RS800X"); break;
111
139
 
 
140
                        default: rideFile->setDeviceType(QString("Unknown Polar Device %1").arg(monitor));
 
141
                   }
112
142
                } else if (line.contains("SMode=")) {
113
143
                    line.remove(0,6);
114
144
                    QString smode = QString(line);
122
152
                        power = true;
123
153
                    if (smode.length()>3 && smode.at(4)=='1')
124
154
                        balance = true;
125
 
                    if (smode.length()>4 && smode.at(5)=='1')
126
 
                        pedaling_index = true;
 
155
                    //if (smode.length()>4 && smode.at(5)=='1') pedaling_index = true;
127
156
 
128
157
/*
129
 
It appears that the Polar CS600 exports its data alays in metric when downloaded from the 
130
 
polar software even when English units are displayed on the unit..  It also never sets 
131
 
this bit low in the .hrm file.  This will have to get changed if other software downloads 
 
158
It appears that the Polar CS600 exports its data alays in metric when downloaded from the
 
159
polar software even when English units are displayed on the unit..  It also never sets
 
160
this bit low in the .hrm file.  This will have to get changed if other software downloads
132
161
this differently
133
162
*/
134
163
 
176
205
            }
177
206
            else if (section == "[HRData]"){
178
207
                double nm=0,kph=0,watts=0,km=0,cad=0,hr=0,alt=0;
 
208
                double lrbalance=0;
179
209
 
180
210
                seconds += recInterval;
181
211
 
197
227
                }
198
228
                if (power) {
199
229
                    watts = line.section('\t', i, i).toDouble();
 
230
                    i++;
 
231
                }
 
232
                if (balance) {
 
233
                    // Power LRB + PI:  The value contains :
 
234
                    //  - Left Right Balance (LRB) and
 
235
                    //  - Pedalling Index (PI)
 
236
                    //
 
237
                    // in the following formula:
 
238
                    // value = PI * 256 + LRB   PI bits 15-8  LRB bits 7-0
 
239
                    // LRB is the value of left foot
 
240
                    // for example if LRB = 45, actual balance is L45 - 55R.
 
241
                    // PI values are percentages from 0 to 100.
 
242
                    // For example value 12857 (= 40 * 256 + 47)
 
243
                    // means: PI = 40 and LRB = 47 => L47 - 53R
 
244
 
 
245
                    lrbalance = line.section('\t', i, i).toInt() & 0xff;
 
246
                    i++;
200
247
                }
201
248
 
202
249
                distance = distance + kph/60/60*recInterval;
216
263
                    alt *= METERS_PER_FOOT;
217
264
                }
218
265
 
219
 
                    rideFile->appendPoint(seconds, cad, hr, km, kph, nm, watts, alt, 0.0, 0.0, 0.0, interval);
 
266
                rideFile->appendPoint(seconds, cad, hr, km, kph, nm, watts, alt, 0.0, 0.0, 0.0, 0.0, RideFile::noTemp, lrbalance, interval);
220
267
                    //fprintf(stderr, " %f, %f, %f, %f, %f, %f, %f, %d\n", seconds, cad, hr, km, kph, nm, watts, alt, interval);
221
268
            }
222
269