Subversion Repositories public

Rev

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

Rev 248 Rev 249
Line 276... Line 276...
276
uint32 time = 0;
276
uint32 time = 0;
277
int countHR = 0;
277
int countHR = 0;
278
int countCD = 0;
278
int countCD = 0;
279
bool pause = false;
279
bool pause = false;
280
bool edTime = false;
280
bool edTime = false;
281
uint32 stTime, pTime, laTime;
281
uint32 stTime, pTime;
282
int arrDist[10];
282
int arrDist[20];
283
uint32 arrTime[10];
283
uint32 arrTime[20];
284
float32 oldAlt, arrAlt[10];
284
float32 oldAlt, arrAlt[20];
285
int distPos;
285
int distPos;
286
 
286
 
287
	for (n = l->head; n != NULL; n = n->next)
287
	for (n = l->head; n != NULL; n = n->next)
288
	{
288
	{
289
	   garmin_print_data(n->data);
289
	   garmin_print_data(n->data);
290
	}
290
	}
291
 
291
 
292
	// Here all data is into the struct and now we
292
	// Here all data is into the struct and now we
293
	// figure out some statistics
293
	// figure out some statistics
294
	akt = point_node;
294
	akt = point_node;
295
	pTime = laTime = 0;
295
	pTime = 0;
296
	distPos = 0;
296
	distPos = 0;
297
	oldAlt = 0;
297
	oldAlt = 0;
298
	descend = 99999;
298
	descend = 99999;
299
 
299
 
-
 
300
	if (akt && akt->point)
-
 
301
	   time = akt->point->time;	// Save the time code of the first point
-
 
302
	else
-
 
303
	   time = 0;
-
 
304
 
300
	while (akt)
305
	while (akt)
301
	{
306
	{
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.
307
	   // Find out the pause and detect how much seconds it is.
308
	   if (!pause && akt->point->distance >= 0x7fffffff)
308
	   if (!pause && akt->point->distance >= 0x7fffffff)
309
	   {
309
	   {
310
	      pause = true;
310
	      pause = true;
311
	      stTime = akt->point->time;
311
	      stTime = akt->point->time;
Line 327... Line 327...
327
	      edTime = true;
327
	      edTime = true;
328
	   }
328
	   }
329
 
329
 
330
	   if (edTime)
330
	   if (edTime)
331
	   {
331
	   {
332
	      pTime = akt->point->time - stTime;
332
	      pTime += (akt->point->time - stTime);
333
	      edTime = false;
333
	      edTime = false;
334
	   }
334
	   }
335
 
335
 
336
	   // If we have a normal point, use it!
336
	   // If we have a normal point, use it!
337
	   if (akt->point->distance < 0x7fffffff)
337
	   if (akt->point->distance < 0x7fffffff)
338
	   {
338
	   {
339
	      totalDistance += akt->point->distance;
339
	      totalDistance = akt->point->distance;
340
	      arrDist[distPos] = akt->point->distance;
340
	      arrDist[distPos] = akt->point->distance;
341
	      arrTime[distPos] = akt->point->time;
341
	      arrTime[distPos] = akt->point->time;
342
	      arrAlt[distPos] = akt->point->alt;
342
	      arrAlt[distPos] = akt->point->alt;
343
	      distPos++;
343
	      distPos++;
344
 
344
 
345
	      if (distPos > 9)
345
	      if (distPos > 19)
346
	      {
346
	      {
347
	      double speed, alt, sumDist = 0.0;
347
	      double speed, alt, sumDist = 0.0;
348
	      int secs = arrTime[9] - arrTime[0];
348
	      int secs = arrTime[19] - arrTime[0];
349
 
349
 
350
		 for (int i = 0; i < 9; i++)
350
		 for (int i = 0; i < 19; i++)
351
		    sumDist += arrDist[i];
351
		    sumDist += arrDist[i];
352
 
352
 
353
		 speed = sumDist / secs * 3.6;
353
		 speed = sumDist / secs * 3.6;
354
 
354
 
355
		 if (speed > maxSpeed)
355
		 if (speed > maxSpeed)
356
		    maxSpeed = speed;
356
		    maxSpeed = speed;
357
 
357
 
358
		 alt = 0.0;
358
		 alt = 0.0;
359
 
359
 
360
		 for (int i = 0; i < 9; i++)
360
		 for (int i = 0; i < 19; i++)
361
		    alt += arrAlt[i];
361
		    alt += arrAlt[i];
362
 
362
 
363
		 alt /= 10.0;
363
		 alt /= 20.0;
364
 
364
 
365
		 if (oldAlt < alt)
365
		 if (oldAlt < alt)
366
		 {
366
		 {
367
		    ascend += (alt - oldAlt);
367
		    ascend += (alt - oldAlt);
368
		    oldAlt = alt;
368
		    oldAlt = alt;
Line 385... Line 385...
385
		 avgCadence += akt->point->cadence;
385
		 avgCadence += akt->point->cadence;
386
		 countCD++;
386
		 countCD++;
387
	      }
387
	      }
388
	   }
388
	   }
389
 
389
 
390
	   laTime = akt->point->time;
390
	   totalTime = akt->point->time;
391
	   akt = akt->next;
391
	   akt = akt->next;
392
	}
392
	}
393
 
393
 
394
	if (countHR > 0)
394
	if (countHR > 0)
395
	   avgHR /= countHR;
395
	   avgHR /= countHR;
396
 
396
 
397
	if (countCD > 0)
397
	if (countCD > 0)
398
	   avgCadence /= countCD;
398
	   avgCadence /= countCD;
399
 
399
 
-
 
400
	if (point_node)
-
 
401
	{
-
 
402
	   totalTime -= time;		// We need the number of seconds
-
 
403
	   totalTime -= pTime;		// Subtract the seconds of pause
-
 
404
	}
-
 
405
	else
-
 
406
	   totalTime = 0;
-
 
407
 
400
	if ((laTime - time - pTime) > 0)
408
	if (totalTime > 0)
401
	   avgSpeed = (totalDistance / 100.0) / (laTime - time - pTime) * 3.6;
409
	   avgSpeed = (totalDistance / 100.0) / totalTime * 3.6;
-
 
410
 
-
 
411
	pauseTime = pTime;
402
}
412
}
403
 
413
 
-
 
414
POINT *disassemble::getLastPoint()
-
 
415
{
-
 
416
POINT_NODE *old, *akt = point_node;
-
 
417
 
-
 
418
	if (!akt)
-
 
419
	   return 0;
-
 
420
 
-
 
421
	old = 0;
-
 
422
 
-
 
423
	while (akt)
-
 
424
	{
-
 
425
	   old = akt;
-
 
426
 
-
 
427
	   if (!akt->next && akt->point)
-
 
428
	   {
-
 
429
	      if (akt->point->distance >= 0x7fffffff && old)
-
 
430
		 return old->point;
-
 
431
 
-
 
432
	      return akt->point;
-
 
433
	   }
-
 
434
 
-
 
435
	   akt = akt->next;
-
 
436
	}
-
 
437
 
-
 
438
	return 0;	// This should never happen!
-
 
439
}
404
 
440
 
405
/* Support function to print a time value in ISO 8601 compliant format */
441
/* Support function to print a time value in ISO 8601 compliant format */
406
 
442
 
407
char *disassemble::garmin_print_dtime (uint32 t)
443
char *disassemble::garmin_print_dtime (uint32 t)
408
{
444
{