Subversion Repositories public

Rev

Rev 245 | Rev 249 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 245 Rev 248
Line 28... Line 28...
28
disassemble::disassemble()
28
disassemble::disassemble()
29
{
29
{
30
	lap_node = 0;
30
	lap_node = 0;
31
	run_node = 0;
31
	run_node = 0;
32
	point_node = 0;
32
	point_node = 0;
-
 
33
 
-
 
34
	totalDistance = 0.0;
-
 
35
	totalTime = 0;
-
 
36
	avgHR = 0.0;
-
 
37
	avgSpeed = 0.0;
-
 
38
	maxSpeed = 0.0;
-
 
39
	ascend = 0.0;
-
 
40
	descend = 0.0;
33
}
41
}
34
 
42
 
35
disassemble::~disassemble()
43
disassemble::~disassemble()
36
{
44
{
37
	destroy();
45
	destroy();
Line 85... Line 93...
85
	      delete pn;
93
	      delete pn;
86
	   }
94
	   }
87
	}
95
	}
88
 
96
 
89
	point_node = NULL;
97
	point_node = NULL;
-
 
98
 
-
 
99
	totalDistance = 0.0;
-
 
100
	totalTime = 0;
-
 
101
	avgHR = 0.0;
-
 
102
	avgSpeed = 0.0;
-
 
103
	maxSpeed = 0.0;
-
 
104
	ascend = 0.0;
-
 
105
	descend = 0.0;
-
 
106
 
90
}
107
}
91
 
108
 
92
LAP_NODE *disassemble::addLap ()
109
LAP_NODE *disassemble::addLap ()
93
{
110
{
94
LAP_NODE *akt, *n;
111
LAP_NODE *akt, *n;
Line 253... Line 270...
253
*/
270
*/
254
 
271
 
255
void disassemble::garmin_print_dlist (garmin_list *l)
272
void disassemble::garmin_print_dlist (garmin_list *l)
256
{
273
{
257
garmin_list_node *n;
274
garmin_list_node *n;
-
 
275
POINT_NODE *akt;
-
 
276
uint32 time = 0;
-
 
277
int countHR = 0;
-
 
278
int countCD = 0;
-
 
279
bool pause = false;
-
 
280
bool edTime = false;
-
 
281
uint32 stTime, pTime, laTime;
-
 
282
int arrDist[10];
-
 
283
uint32 arrTime[10];
-
 
284
float32 oldAlt, arrAlt[10];
-
 
285
int distPos;
258
 
286
 
259
	for (n = l->head; n != NULL; n = n->next)
287
	for (n = l->head; n != NULL; n = n->next)
260
	{
288
	{
261
	   garmin_print_data(n->data);
289
	   garmin_print_data(n->data);
262
	}
290
	}
-
 
291
 
-
 
292
	// Here all data is into the struct and now we
-
 
293
	// figure out some statistics
-
 
294
	akt = point_node;
-
 
295
	pTime = laTime = 0;
-
 
296
	distPos = 0;
-
 
297
	oldAlt = 0;
-
 
298
	descend = 99999;
-
 
299
 
-
 
300
	while (akt)
-
 
301
	{
-
 
302
	   if (time == 0)
-
 
303
	      time = akt->point->time;
-
 
304
 
-
 
305
	   totalTime = akt->point->time;
-
 
306
 
-
 
307
	   // Find out the pause and detect how much seconds it is.
-
 
308
	   if (!pause && akt->point->distance >= 0x7fffffff)
-
 
309
	   {
-
 
310
	      pause = true;
-
 
311
	      stTime = akt->point->time;
-
 
312
	      akt = akt->next;
-
 
313
	      continue;
-
 
314
	   }
-
 
315
 
-
 
316
	   if (pause && akt->point->distance >= 0x7fffffff)
-
 
317
	   {
-
 
318
	      pause = false;
-
 
319
	      edTime = true;
-
 
320
	      akt = akt->next;
-
 
321
	      continue;
-
 
322
	   }
-
 
323
 
-
 
324
	   if (pause && akt->point->distance < 0x7fffffff)
-
 
325
	   {
-
 
326
	      pause = false;
-
 
327
	      edTime = true;
-
 
328
	   }
-
 
329
 
-
 
330
	   if (edTime)
-
 
331
	   {
-
 
332
	      pTime = akt->point->time - stTime;
-
 
333
	      edTime = false;
-
 
334
	   }
-
 
335
 
-
 
336
	   // If we have a normal point, use it!
-
 
337
	   if (akt->point->distance < 0x7fffffff)
-
 
338
	   {
-
 
339
	      totalDistance += akt->point->distance;
-
 
340
	      arrDist[distPos] = akt->point->distance;
-
 
341
	      arrTime[distPos] = akt->point->time;
-
 
342
	      arrAlt[distPos] = akt->point->alt;
-
 
343
	      distPos++;
-
 
344
 
-
 
345
	      if (distPos > 9)
-
 
346
	      {
-
 
347
	      double speed, alt, sumDist = 0.0;
-
 
348
	      int secs = arrTime[9] - arrTime[0];
-
 
349
 
-
 
350
		 for (int i = 0; i < 9; i++)
-
 
351
		    sumDist += arrDist[i];
-
 
352
 
-
 
353
		 speed = sumDist / secs * 3.6;
-
 
354
 
-
 
355
		 if (speed > maxSpeed)
-
 
356
		    maxSpeed = speed;
-
 
357
 
-
 
358
		 alt = 0.0;
-
 
359
 
-
 
360
		 for (int i = 0; i < 9; i++)
-
 
361
		    alt += arrAlt[i];
-
 
362
 
-
 
363
		 alt /= 10.0;
-
 
364
 
-
 
365
		 if (oldAlt < alt)
-
 
366
		 {
-
 
367
		    ascend += (alt - oldAlt);
-
 
368
		    oldAlt = alt;
-
 
369
		 }
-
 
370
 
-
 
371
		 if (descend > alt)
-
 
372
		    descend = akt->point->alt;
-
 
373
 
-
 
374
		 distPos = 0;
-
 
375
	      }
-
 
376
 
-
 
377
	      if (akt->point->heart_rate > 0x00 && akt->point->heart_rate < 0xff)
-
 
378
	      {
-
 
379
		 avgHR += akt->point->heart_rate;
-
 
380
		 countHR++;
-
 
381
	      }
-
 
382
 
-
 
383
	      if (akt->point->cadence > 0 && akt->point->cadence != 0xff)
-
 
384
	      {
-
 
385
		 avgCadence += akt->point->cadence;
-
 
386
		 countCD++;
-
 
387
	      }
-
 
388
	   }
-
 
389
 
-
 
390
	   laTime = akt->point->time;
-
 
391
	   akt = akt->next;
-
 
392
	}
-
 
393
 
-
 
394
	if (countHR > 0)
-
 
395
	   avgHR /= countHR;
-
 
396
 
-
 
397
	if (countCD > 0)
-
 
398
	   avgCadence /= countCD;
-
 
399
 
-
 
400
	if ((laTime - time - pTime) > 0)
-
 
401
	   avgSpeed = (totalDistance / 100.0) / (laTime - time - pTime) * 3.6;
263
}
402
}
264
 
403
 
265
 
404
 
266
/* Support function to print a time value in ISO 8601 compliant format */
405
/* Support function to print a time value in ISO 8601 compliant format */
267
 
406