-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathFitListener.cpp
438 lines (422 loc) · 24.5 KB
/
FitListener.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
#include "FitListener.h"
#include "math.h"
//#define LOGOUT
FitListener::FitListener() : TourData()
{
}
void FitListener::PrintValues(const fit::FieldBase& field)
{
for (FIT_UINT8 j=0; j< (FIT_UINT8)field.GetNumValues(); j++)
{
std::wcout << L" Val" << j << L": ";
switch (field.GetType())
{
// Get float 64 values for numeric types to receive values that have
// their scale and offset properly applied.
case FIT_BASE_TYPE_ENUM:
case FIT_BASE_TYPE_BYTE:
case FIT_BASE_TYPE_SINT8:
case FIT_BASE_TYPE_UINT8:
case FIT_BASE_TYPE_SINT16:
case FIT_BASE_TYPE_UINT16:
case FIT_BASE_TYPE_SINT32:
case FIT_BASE_TYPE_UINT32:
case FIT_BASE_TYPE_SINT64:
case FIT_BASE_TYPE_UINT64:
case FIT_BASE_TYPE_UINT8Z:
case FIT_BASE_TYPE_UINT16Z:
case FIT_BASE_TYPE_UINT32Z:
case FIT_BASE_TYPE_UINT64Z:
case FIT_BASE_TYPE_FLOAT32:
case FIT_BASE_TYPE_FLOAT64:
std::wcout << field.GetFLOAT64Value(j);
break;
case FIT_BASE_TYPE_STRING:
std::wcout << field.GetSTRINGValue(j);
break;
default:
break;
}
std::wcout << L" " << field.GetUnits().c_str() << L"\n";;
}
}
void FitListener::OnMesg(fit::Mesg& mesg)
{
if( QString( mesg.GetName().c_str() ) != QString( "device_info" )
&& QString( mesg.GetName().c_str() ) != QString( "file_id" )
&& QString( mesg.GetName().c_str() ) != QString( "record" )
&& QString( mesg.GetName().c_str() ) != QString( "session" )
&& QString( mesg.GetName().c_str() ) != QString( "lap" )
&& QString( mesg.GetName().c_str() ) != QString( "event" )
&& QString( mesg.GetName().c_str() ) != QString( "hr_zone" )
&& QString( mesg.GetName().c_str() ) != QString( "power_zone" ) ) return;
#ifdef LOGOUT
printf("On Mesg:\n");
std::wcout << L" New Mesg: " << mesg.GetName().c_str() << L". It has " << mesg.GetNumFields() << L" field(s) and " << mesg.GetNumDevFields() << " developer field(s).\n";
#endif
double tourTimeStamp = 0;
double tourAltitude = 0;
double tourGpsAccuracy = 0;
double tourDistance = 0;
static double tourBatterySoc = 0;
double tourCadence = 0;
double tourSpeed = 0;
double tourPosLat = 0;
double tourPosLong = 0;
static double tourTemperature = 0;
double tourGrade = 0;
double tourHeartRate = 0;
double tourCalories = 0;
double tourPower = 0;
double tourLRBalance = 50;
deviceInfo_t deviceInfo;
deviceInfo.name = "";
deviceInfo.battery = "";
deviceInfo.deviceId = -1;
fitSection_t lap;
static double lapPosGrade = 0;
static double lapNegGrade = 0;
static double lapMinTemp = 9999;
static double lastDistance = 0;
static double lastLapStartDistance = 0;
double gearTimeStamp = 0;
double gearNumFront = 0;
double gearToothFront = 0;
double gearNumRear = 0;
double gearToothRear = 0;
bool gearRead = false;
quint8 hrIndex = 255;
quint16 hrHighValue = 0;
quint8 pwrIndex = 255;
quint16 pwrHighValue = 0;
for (FIT_UINT16 i = 0; i < (FIT_UINT16)mesg.GetNumFields(); i++)
{
fit::Field* field = mesg.GetFieldByIndex(i);
#ifdef LOGOUT
std::wcout << L" Field" << i << " (" << field->GetName().c_str() << ") has " << field->GetNumValues() << L" value(s)\n";
PrintValues(*field);
#endif
if( QString( mesg.GetName().c_str() ) == QString( "session" ) )
{
if( QString( field->GetName().c_str() ) == QString( "total_elapsed_time" ) ) m_session.totalElapsedTime = field->GetFLOAT64Value(0);
else if( QString( field->GetName().c_str() ) == QString( "total_timer_time" ) ) m_session.totalTimerTime = field->GetFLOAT64Value(0);
else if( QString( field->GetName().c_str() ) == QString( "avg_speed" ) ) m_session.avgSpeed = field->GetFLOAT64Value(0);
else if( QString( field->GetName().c_str() ) == QString( "max_speed" ) ) m_session.maxSpeed = field->GetFLOAT64Value(0);
else if( QString( field->GetName().c_str() ) == QString( "total_distance" ) ) m_session.totalDistance = field->GetFLOAT64Value(0);
else if( QString( field->GetName().c_str() ) == QString( "avg_cadence" ) ) m_session.avgCadence = field->GetFLOAT64Value(0);
else if( QString( field->GetName().c_str() ) == QString( "max_cadence" ) ) m_session.maxCadence = field->GetFLOAT64Value(0);
else if( QString( field->GetName().c_str() ) == QString( "total_ascent" ) ) m_session.ascent = field->GetFLOAT64Value(0);
else if( QString( field->GetName().c_str() ) == QString( "total_descent" ) ) m_session.descent = field->GetFLOAT64Value(0);
else if( QString( field->GetName().c_str() ) == QString( "max_altitude" ) ) m_session.altitudeMax = field->GetFLOAT64Value(0);
else if( QString( field->GetName().c_str() ) == QString( "min_altitude" ) ) m_session.altitudeMin = field->GetFLOAT64Value(0);
else if( QString( field->GetName().c_str() ) == QString( "avg_temperature" ) ) m_session.avgTemperature = field->GetFLOAT64Value(0);
else if( QString( field->GetName().c_str() ) == QString( "max_temperature" ) ) m_session.maxTemperature = field->GetFLOAT64Value(0);
else if( QString( field->GetName().c_str() ) == QString( "start_time" ) ) m_session.startTime = field->GetUINT32Value(0);
else if( QString( field->GetName().c_str() ) == QString( "min_heart_rate" ) ) m_session.minHeartRate = field->GetFLOAT64Value(0);
else if( QString( field->GetName().c_str() ) == QString( "avg_heart_rate" ) ) m_session.avgHeartRate = field->GetFLOAT64Value(0);
else if( QString( field->GetName().c_str() ) == QString( "max_heart_rate" ) ) m_session.maxHeartRate = field->GetFLOAT64Value(0);
else if( QString( field->GetName().c_str() ) == QString( "time_in_hr_zone" ) ) for(int i = 0; i < 5; i++) m_session.hrTimeInZone[i] = field->GetFLOAT64Value(i);
else if( QString( field->GetName().c_str() ) == QString( "time_in_power_zone" ) ) for(int i = 0; i < 8; i++) m_session.pwrTimeInZone[i] = field->GetFLOAT64Value(i);
else if( QString( field->GetName().c_str() ) == QString( "avg_power" ) ) m_session.avgPower = field->GetFLOAT64Value(0);
else if( QString( field->GetName().c_str() ) == QString( "max_power" ) ) m_session.maxPower = field->GetFLOAT64Value(0);
else if( QString( field->GetName().c_str() ) == QString( "left_right_balance" ) ) m_session.leftRightBalance = field->GetFLOAT64Value(0);
else if( QString( field->GetName().c_str() ) == QString( "total_work" ) ) m_session.totalWork = field->GetFLOAT64Value(0);
else if( QString( field->GetName().c_str() ) == QString( "total_calories" ) ) m_session.totalCalories = field->GetFLOAT64Value(0);
else if( QString( field->GetName().c_str() ) == QString( "normalized_power" ) ) m_session.normalizedPower = field->GetFLOAT64Value(0);
else if( QString( field->GetName().c_str() ) == QString( "threshold_power" ) ) m_session.thresholdPower = field->GetFLOAT64Value(0);
else if( QString( field->GetName().c_str() ) == QString( "training_stress_score" ) ) m_session.trainingStressScore = field->GetFLOAT64Value(0);
else if( QString( field->GetName().c_str() ) == QString( "intensity_factor" ) ) m_session.itensityFactor = field->GetFLOAT64Value(0);
//else if( QString( field->GetName().c_str() ) == QString( "max_neg_grade" ) ) m_session.minGrade = field->GetFLOAT64Value(0);
//else if( QString( field->GetName().c_str() ) == QString( "max_pos_grade" ) ) m_session.maxGrade = field->GetFLOAT64Value(0);
}
else if( QString( mesg.GetName().c_str() ) == QString( "lap" ) )
{
if( QString( field->GetName().c_str() ) == QString( "total_elapsed_time" ) ) lap.totalElapsedTime = field->GetFLOAT64Value(0);
else if( QString( field->GetName().c_str() ) == QString( "total_timer_time" ) ) lap.totalTimerTime = field->GetFLOAT64Value(0);
else if( QString( field->GetName().c_str() ) == QString( "avg_speed" ) ) lap.avgSpeed = field->GetFLOAT64Value(0);
else if( QString( field->GetName().c_str() ) == QString( "max_speed" ) ) lap.maxSpeed = field->GetFLOAT64Value(0);
else if( QString( field->GetName().c_str() ) == QString( "total_distance" ) ) lap.totalDistance = field->GetFLOAT64Value(0);
else if( QString( field->GetName().c_str() ) == QString( "avg_cadence" ) ) lap.avgCadence = field->GetFLOAT64Value(0);
else if( QString( field->GetName().c_str() ) == QString( "max_cadence" ) ) lap.maxCadence = field->GetFLOAT64Value(0);
else if( QString( field->GetName().c_str() ) == QString( "total_ascent" ) ) lap.ascent = field->GetFLOAT64Value(0);
else if( QString( field->GetName().c_str() ) == QString( "total_descent" ) ) lap.descent = field->GetFLOAT64Value(0);
else if( QString( field->GetName().c_str() ) == QString( "max_altitude" ) ) lap.altitudeMax = field->GetFLOAT64Value(0);
else if( QString( field->GetName().c_str() ) == QString( "min_altitude" ) ) lap.altitudeMin = field->GetFLOAT64Value(0);
else if( QString( field->GetName().c_str() ) == QString( "avg_temperature" ) ) lap.avgTemperature = field->GetFLOAT64Value(0);
else if( QString( field->GetName().c_str() ) == QString( "max_temperature" ) ) lap.maxTemperature = field->GetFLOAT64Value(0);
else if( QString( field->GetName().c_str() ) == QString( "start_time" ) ) lap.startTime = field->GetUINT32Value(0);
else if( QString( field->GetName().c_str() ) == QString( "min_heart_rate" ) ) lap.minHeartRate = field->GetFLOAT64Value(0);
else if( QString( field->GetName().c_str() ) == QString( "avg_heart_rate" ) ) lap.avgHeartRate = field->GetFLOAT64Value(0);
else if( QString( field->GetName().c_str() ) == QString( "max_heart_rate" ) ) lap.maxHeartRate = field->GetFLOAT64Value(0);
else if( QString( field->GetName().c_str() ) == QString( "time_in_hr_zone" ) ) for(int i = 0; i < 5; i++) lap.hrTimeInZone[i] = field->GetFLOAT64Value(i);
else if( QString( field->GetName().c_str() ) == QString( "time_in_power_zone" ) ) for(int i = 0; i < 8; i++) lap.pwrTimeInZone[i] = field->GetFLOAT64Value(i);
else if( QString( field->GetName().c_str() ) == QString( "avg_power" ) ) lap.avgPower = field->GetFLOAT64Value(0);
else if( QString( field->GetName().c_str() ) == QString( "max_power" ) ) lap.maxPower = field->GetFLOAT64Value(0);
else if( QString( field->GetName().c_str() ) == QString( "left_right_balance" ) ) lap.leftRightBalance = field->GetFLOAT64Value(0);
else if( QString( field->GetName().c_str() ) == QString( "total_work" ) ) lap.totalWork = field->GetFLOAT64Value(0);
else if( QString( field->GetName().c_str() ) == QString( "total_calories" ) ) lap.totalCalories = field->GetFLOAT64Value(0);
else if( QString( field->GetName().c_str() ) == QString( "normalized_power" ) ) lap.normalizedPower = field->GetFLOAT64Value(0);
//else if( QString( field->GetName().c_str() ) == QString( "max_neg_grade" ) ) lap.minGrade = field->GetFLOAT64Value(0);
//else if( QString( field->GetName().c_str() ) == QString( "max_pos_grade" ) ) lap.maxGrade = field->GetFLOAT64Value(0);
}
else if( QString( mesg.GetName().c_str() ) == QString( "record" ) && mesg.GetNumFields() > 5 )
{
if( QString( field->GetName().c_str() ) == QString( "timestamp" ) ) tourTimeStamp = field->GetFLOAT64Value(0);
else if( QString( field->GetName().c_str() ) == QString( "altitude" ) ) tourAltitude = field->GetFLOAT64Value(0);
else if( QString( field->GetName().c_str() ) == QString( "gps_accuracy" ) ) tourGpsAccuracy = field->GetFLOAT64Value(0);
else if( QString( field->GetName().c_str() ) == QString( "distance" ) )
{
tourDistance = field->GetFLOAT64Value(0) / 1000.0;
lastDistance = tourDistance;
}
else if( QString( field->GetName().c_str() ) == QString( "battery_soc" ) ) tourBatterySoc = field->GetFLOAT64Value(0);
else if( QString( field->GetName().c_str() ) == QString( "cadence" ) ) tourCadence = field->GetFLOAT64Value(0);
else if( QString( field->GetName().c_str() ) == QString( "speed" ) ) tourSpeed = field->GetFLOAT64Value(0) * 3.6;
else if( QString( field->GetName().c_str() ) == QString( "position_lat" ) )
{
tourPosLat = field->GetFLOAT64Value(0);
m_posRead = true;
}
else if( QString( field->GetName().c_str() ) == QString( "position_long" ) ) tourPosLong = field->GetFLOAT64Value(0);
else if( QString( field->GetName().c_str() ) == QString( "grade" ) )
{
tourGrade = field->GetFLOAT64Value(0);
if( tourGrade > m_session.maxGrade ) m_session.maxGrade = tourGrade;
if( tourGrade < m_session.minGrade ) m_session.minGrade = tourGrade;
if( tourGrade > lapPosGrade ) lapPosGrade = tourGrade;
if( tourGrade < lapNegGrade ) lapNegGrade = tourGrade;
}
else if( QString( field->GetName().c_str() ) == QString( "temperature" ) )
{
tourTemperature = field->GetFLOAT64Value(0);
if( tourTemperature < m_session.minTemperature ) m_session.minTemperature = tourTemperature;
if( tourTemperature < lapMinTemp ) lapMinTemp = tourTemperature;
if( !m_tempCorrectionDone )
{
m_tempCorrectionDone = true;
for( int i = 0; i < m_tourTemperature.count(); i++ )
m_tourTemperature[i] = tourTemperature;
}
}
else if( QString( field->GetName().c_str() ) == QString( "heart_rate" ) ) tourHeartRate = field->GetFLOAT64Value(0);
else if( QString( field->GetName().c_str() ) == QString( "calories" ) ) tourCalories = field->GetFLOAT64Value(0);
else if( QString( field->GetName().c_str() ) == QString( "power" ) ) tourPower = field->GetFLOAT64Value(0);
else if( QString( field->GetName().c_str() ) == QString( "left_right_balance" ) ) tourLRBalance = field->GetFLOAT64Value(0);
}
else if( QString( mesg.GetName().c_str() ) == QString( "device_info" ) )
{
if( QString( field->GetName().c_str() ) == QString( "product_name" ) ) deviceInfo.name = QString::fromStdWString( field->GetSTRINGValue(0) );
else if( QString( field->GetName().c_str() ) == QString( "device_index" ) ) deviceInfo.deviceId = (int)field->GetFLOAT64Value(0);
else if( QString( field->GetName().c_str() ) == QString( "charge" ) ) deviceInfo.battery = "Battery " + QString::fromStdWString( field->GetSTRINGValue(0) ) + "%";
else if( QString( field->GetName().c_str() ) == QString( "software_version" ) ) deviceInfo.software = "Firmware v" + QString::fromStdWString( field->GetSTRINGValue(0) );
else if( QString( field->GetName().c_str() ) == QString( "battery_status" ) )
{
int val = (int)field->GetFLOAT64Value(0);
//batteryStatus: new=1,good=2,ok=3,low=4,critical=5
switch( val )
{
case 1: deviceInfo.battery = "Battery new";
break;
case 2: deviceInfo.battery = "Battery good";
break;
case 3: deviceInfo.battery = "Battery ok";
break;
case 4: deviceInfo.battery = "Battery low";
break;
case 5: deviceInfo.battery = "Battery critical";
break;
default:
break;
}
}
}
else if( QString( mesg.GetName().c_str() ) == QString( "file_id" ) )
{
if( QString( field->GetName().c_str() ) == QString( "product_name" ) )
{
deviceInfo.name = QString::fromStdWString( field->GetSTRINGValue(0) );
if( !deviceIdIsIncluded( deviceInfo ) )
{
m_deviceInfo.append( deviceInfo );
}
}
}
else if( QString( mesg.GetName().c_str() ) == QString( "event" ) )
{
if( QString( field->GetName().c_str() ) == QString( "timestamp" ) ) gearTimeStamp = field->GetFLOAT64Value(0);
else if( QString( field->GetName().c_str() ) == QString( "rear_gear_num" ) ) gearNumRear = field->GetFLOAT64Value(0);
else if( QString( field->GetName().c_str() ) == QString( "rear_gear" ) ) gearToothRear = field->GetFLOAT64Value(0);
else if( QString( field->GetName().c_str() ) == QString( "front_gear_num" ) ) gearNumFront = field->GetFLOAT64Value(0);
else if( QString( field->GetName().c_str() ) == QString( "front_gear" ) ) gearToothFront = field->GetFLOAT64Value(0);
if( QString( field->GetName().c_str() ).startsWith( QString( "rear_gear" ) ) )
{
m_gearInfoRear = true;
gearRead = true;
}
else if( QString( field->GetName().c_str() ).startsWith( QString( "front_gear" ) ) )
{
m_gearInfoFront = true;
gearRead = true;
}
}
else if( QString( mesg.GetName().c_str() ) == QString( "hr_zone" ) )
{
if( QString( field->GetName().c_str() ) == QString( "message_index" ) ) hrIndex = field->GetFLOAT64Value(0);
else if( QString( field->GetName().c_str() ) == QString( "high_bpm" ) ) hrHighValue = field->GetFLOAT64Value(0);
}
else if( QString( mesg.GetName().c_str() ) == QString( "power_zone" ) )
{
if( QString( field->GetName().c_str() ) == QString( "message_index" ) ) pwrIndex = field->GetFLOAT64Value(0);
else if( QString( field->GetName().c_str() ) == QString( "high_value" ) ) pwrHighValue = field->GetFLOAT64Value(0);
}
}
for (auto devField : mesg.GetDeveloperFields())
{
#ifdef LOGOUT
std::wcout << L" Developer Field(" << devField.GetName().c_str() << ") has " << devField.GetNumValues() << L" value(s)\n";
PrintValues(devField);
#endif
if( QString( mesg.GetName().c_str() ) == QString( "device_info" ) )
{
if( QString( devField.GetName().c_str() ) == QString( "charge" )
&& QString::fromStdWString( devField.GetSTRINGValue(0) ) != QString( "nan" ) ) deviceInfo.battery = "Battery " + QString::fromStdWString( devField.GetSTRINGValue(0) ) + "%";
}
}
if( QString( mesg.GetName().c_str() ) == QString( "record" ) && mesg.GetNumFields() > 5 )
{
if( !m_tourAltitude.empty() && fabs( m_tourAltitude.last() - tourAltitude ) > 20 && !m_altCorrectionDone )
{
m_altCorrectionDone = true;
for( int i = 0; i < m_tourAltitude.count(); i++ )
m_tourAltitude[i] = tourAltitude;
}
else if( !m_tourAltitude.empty() && tourAltitude != 0 && m_tourAltitude.last() != 0 ) m_altCorrectionDone = true;
if( !m_tourBatterySoc.empty() && fabs( m_tourBatterySoc.last() - tourBatterySoc ) > 3 && !m_battCorrectionDone )
{
m_battCorrectionDone = true;
for( int i = 0; i < m_tourBatterySoc.count(); i++ )
m_tourBatterySoc[i] = tourBatterySoc;
}
if( !m_tourPosLat.empty() && m_posRead && !m_firstPosRead ) //GPS not found yet
{
m_firstPosRead = true;
for( int i = 0; i < m_tourPosLat.count(); i++ )
{
m_tourPosLat[i] = tourPosLat;
m_tourPosLong[i] = tourPosLong;
}
}
else if( tourPosLat == 0.0 || tourPosLong == 0.0 ) //No GPS while on track
{
m_tourPosLat.append( m_tourPosLat.last() );
m_tourPosLong.append( m_tourPosLong.last() );
}
else //All fine
{
m_tourPosLat.append( tourPosLat );
m_tourPosLong.append( tourPosLong );
}
m_tourTimeStamp.append( tourTimeStamp );
m_tourDistance.append( tourDistance );
m_tourBatterySoc.append( tourBatterySoc );
m_tourSpeed.append( tourSpeed );
m_tourCadence.append( tourCadence );
m_tourAltitude.append( tourAltitude );
m_tourGpsAccuracy.append( tourGpsAccuracy );
m_tourTemperature.append( tourTemperature );
m_tourGrade.append( tourGrade );
m_tourHeartRate.append( tourHeartRate );
m_tourCalories.append( tourCalories );
m_tourPower.append( tourPower );
m_tourLRBalance.append( tourLRBalance );
}
else if( QString( mesg.GetName().c_str() ) == QString( "lap" ) && mesg.GetNumFields() > 5 )
{
lap.maxGrade = lapPosGrade;
lap.minGrade = lapNegGrade;
lap.minTemperature = lapMinTemp;
lap.startDistance = lastLapStartDistance;
m_sections.append( lap );
lastLapStartDistance = lastDistance;
lapPosGrade = 0;
lapNegGrade = 0;
lapMinTemp = 9999;
}
else if( QString( mesg.GetName().c_str() ) == QString( "device_info" )
&& deviceInfo.deviceId != -1 )
{
if( !deviceIdIsIncluded( deviceInfo ) )
{
m_deviceInfo.append( deviceInfo );
std::sort(m_deviceInfo.begin(), m_deviceInfo.end(), [](const deviceInfo_t& a, const deviceInfo_t& b) { return a.deviceId < b.deviceId; });
}
else
{
m_deviceInfo.replace( deviceIdInVectorAt( deviceInfo ), deviceInfo );
}
}
else if( QString( mesg.GetName().c_str() ) == QString( "event" ) && gearRead )
{
if( gearNumFront < 30 && gearNumRear < 30 )
{
m_gearTimeStamp.append( gearTimeStamp );
m_gearNumFront.append( gearNumFront );
m_gearToothFront.append( gearToothFront );
m_gearNumRear.append( gearNumRear );
m_gearToothRear.append( gearToothRear );
//Calc ratio only, if tooth info existing
if( (int)gearToothFront > 1 && (int)gearToothRear > 1 ) m_gearRatio.append( gearToothFront / gearToothRear );
else m_gearRatio.append( 0.0 );
//Steel the distance
if( m_tourDistance.count() > 0 ) m_gearDistance.append( m_tourDistance.last() );
else m_gearDistance.append( 0.0 );
if( gearNumFront > m_gearCountFront ) m_gearCountFront = gearNumFront;
if( gearNumRear > m_gearCountRear ) m_gearCountRear = gearNumRear;
}
}
else if( QString( mesg.GetName().c_str() ) == QString( "hr_zone" ) )
{
if( hrIndex < 5 ) m_hrZoneHigh[hrIndex] = hrHighValue;
else
{
if( !m_hrZoneHigh[0] ) m_hrZoneHigh[0] = hrHighValue;
else if( !m_hrZoneHigh[1] ) m_hrZoneHigh[1] = hrHighValue;
else if( !m_hrZoneHigh[2] ) m_hrZoneHigh[2] = hrHighValue;
else if( !m_hrZoneHigh[3] ) m_hrZoneHigh[3] = hrHighValue;
else if( !m_hrZoneHigh[4] ) m_hrZoneHigh[4] = hrHighValue;
}
}
else if( QString( mesg.GetName().c_str() ) == QString( "power_zone" ) )
{
if( pwrIndex < 8 ) m_pwrZoneHigh[pwrIndex] = pwrHighValue;
else
{
if( !m_pwrZoneHigh[0] ) m_pwrZoneHigh[0] = pwrHighValue;
else if( !m_pwrZoneHigh[1] ) m_pwrZoneHigh[1] = pwrHighValue;
else if( !m_pwrZoneHigh[2] ) m_pwrZoneHigh[2] = pwrHighValue;
else if( !m_pwrZoneHigh[3] ) m_pwrZoneHigh[3] = pwrHighValue;
else if( !m_pwrZoneHigh[4] ) m_pwrZoneHigh[4] = pwrHighValue;
else if( !m_pwrZoneHigh[5] ) m_pwrZoneHigh[5] = pwrHighValue;
else if( !m_pwrZoneHigh[6] ) m_pwrZoneHigh[6] = pwrHighValue;
else if( !m_pwrZoneHigh[7] ) m_pwrZoneHigh[7] = pwrHighValue;
}
}
}
void FitListener::OnMesg(fit::FileIdMesg& mesg)
{
#ifdef LOGOUT
printf("File ID:\n");
if (mesg.IsTypeValid())
printf(" Type: %d\n", mesg.GetType());
if (mesg.IsManufacturerValid())
printf(" Manufacturer: %d\n", mesg.GetManufacturer());
if (mesg.IsProductValid())
printf(" Product: %d\n", mesg.GetProduct());
if (mesg.IsSerialNumberValid())
printf(" Serial Number: %u\n", mesg.GetSerialNumber());
if (mesg.IsNumberValid())
printf(" Number: %d\n", mesg.GetNumber());
#else
Q_UNUSED( mesg );
#endif
}