Ejemplo n.º 1
0
    /**
     * http://home.trainingpeaks.com/blog/article/estimating-training-stress-score-tss
     */
    private static IList <HeartRateZone> BuildZones(IList <int> Zones)
    {
        IList <HeartRateZone> HeartRateZones = new List <HeartRateZone>();
        HeartRateZone         Zone1          = new HeartRateZone(0, Zones[0] - 40);

        HeartRateZones.Add(Zone1);
        HeartRateZone Zone2 = new HeartRateZone(Zone1.End + 1, Zones[0] - 10);

        HeartRateZones.Add(Zone2);
        HeartRateZone Zone3 = new HeartRateZone(Zone2.End + 1, Zones[0]);

        HeartRateZones.Add(Zone3);
        HeartRateZone Zone4 = new HeartRateZone(Zone3.End + 1, Zones[1] - ((Zones[1] - Zones[0]) / 2));

        HeartRateZones.Add(Zone4);
        HeartRateZone Zone5 = new HeartRateZone(Zone4.End + 1, Zones[1]);

        HeartRateZones.Add(Zone5);
        HeartRateZone Zone6 = new HeartRateZone(Zone5.End + 1, Zones[2]);

        HeartRateZones.Add(Zone6);
        HeartRateZone Zone7 = new HeartRateZone(Zone6.End + 1, Zones[3]);

        HeartRateZones.Add(Zone7);
        HeartRateZone Zone8 = new HeartRateZone(Zone7.End + 1, Zones[3] + (Zones[4] - Zones[3]) / 3);

        HeartRateZones.Add(Zone8);
        HeartRateZone Zone9 = new HeartRateZone(Zone8.End + 1, Zones[3] + 2 * (Zones[4] - Zones[3]) / 3);

        HeartRateZones.Add(Zone9);
        HeartRateZone Zone10 = new HeartRateZone(Zone9.End + 1, Zones[4]);

        HeartRateZones.Add(Zone10);
        return(HeartRateZones);
    }
Ejemplo n.º 2
0
    /**
     * http://home.trainingpeaks.com/blog/article/estimating-training-stress-score-tss
     */
    private static IList <HeartRateZone> BuildZones(IList <int> Zones)
    {
        IList <HeartRateZone> HeartRateZones = new List <HeartRateZone>();
        HeartRateZone         Zone1          = new HeartRateZone(0, Zones[0] - 40, 0, 20);

        HeartRateZones.Add(Zone1);
        HeartRateZone Zone2 = new HeartRateZone(Zone1.HREnd + 1, Zones[0] - 10, 20, 30);

        HeartRateZones.Add(Zone2);
        HeartRateZone Zone3 = new HeartRateZone(Zone2.HREnd + 1, Zones[0], 30, 40);

        HeartRateZones.Add(Zone3);
        HeartRateZone Zone4 = new HeartRateZone(Zone3.HREnd + 1, Zones[1] - ((Zones[1] - Zones[0]) / 2), 40, 50);

        HeartRateZones.Add(Zone4);
        HeartRateZone Zone5 = new HeartRateZone(Zone4.HREnd + 1, Zones[1], 50, 60);

        HeartRateZones.Add(Zone5);
        HeartRateZone Zone6 = new HeartRateZone(Zone5.HREnd + 1, Zones[2], 60, 70);

        HeartRateZones.Add(Zone6);
        HeartRateZone Zone7 = new HeartRateZone(Zone6.HREnd + 1, Zones[3], 70, 80);

        HeartRateZones.Add(Zone7);
        HeartRateZone Zone8 = new HeartRateZone(Zone7.HREnd + 1, Zones[3] + (Zones[4] - Zones[3]) / 3, 80, 100);

        HeartRateZones.Add(Zone8);
        HeartRateZone Zone9 = new HeartRateZone(Zone8.HREnd + 1, Zones[3] + 2 * (Zones[4] - Zones[3]) / 3, 100, 120);

        HeartRateZones.Add(Zone9);
        HeartRateZone Zone10 = new HeartRateZone(Zone9.HREnd + 1, Zones[4], 120, 140);

        HeartRateZones.Add(Zone10);
        return(HeartRateZones);
    }
Ejemplo n.º 3
0
    private static double CalculateTSS(int HeartRate, IList <HeartRateZone> HeartRateZones)
    {
        double tss = 0;

        for (int i = 0; i < HeartRateZones.Count; i++)
        {
            if (HeartRateZones[i].Contains(HeartRate))
            {
                HeartRateZone HRZ = HeartRateZones[i];
                tss = HRZ.TSSStart + (HeartRate - HRZ.HRStart) * ((HRZ.TSSEnd - HRZ.TSSStart) / (HRZ.HREnd - HRZ.HRStart));
            }
        }
        return(tss);
    }
Ejemplo n.º 4
0
        private void ValidateActivity(List <Activities> stats)
        {
            Activities stat = stats.First();

            stat.ActiveDuration.Should().Be(2764000);
            stat.ActivityLevel.First().Minutes.Should().Be(0);
            stat.ActivityLevel.First().Name.Should().Be("sedentary");
            stat.ActivityName.Should().Be("Walk");
            stat.ActivityTypeId.Should().Be(90013);
            stat.AverageHeartRate.Should().Be(108);
            stat.Calories.Should().Be(375);
            stat.Duration.Should().Be(2764000);
            stat.ElevationGain.Should().Be(3.048);

            HeartRateZone zone1 = stat.HeartRateZones[0];

            zone1.CaloriesOut.Should().Be(default(double));
            zone1.Max.Should().Be(95);
            zone1.Min.Should().Be(30);
            zone1.Minutes.Should().Be(3);
            zone1.Name.Should().Be("Out of Range");

            HeartRateZone zone4 = stat.HeartRateZones[3];

            zone4.CaloriesOut.Should().Be(default(double));
            zone4.Max.Should().Be(220);
            zone4.Min.Should().Be(162);
            zone4.Minutes.Should().Be(0);
            zone4.Name.Should().Be("Peak");

            stat.LastModified.Should().Be(new DateTime(2017, 01, 01, 5, 3, 50));
            stat.LogId.Should().Be(5390522508);
            stat.LogType.Should().Be("auto_detected");

            stat.ManualValuesSpecified.Calories.Should().Be(false);
            stat.ManualValuesSpecified.Distance.Should().Be(false);
            stat.ManualValuesSpecified.Steps.Should().Be(false);

            stat.OriginalDuration.Should().Be(2764000);
            stat.OriginalStartTime.Should().Be(new DateTime(2017, 1, 1, 4, 14, 06));
            stat.StartTime.Should().Be(new DateTime(2017, 1, 1, 4, 14, 06));
            stat.Steps.Should().Be(5138);
            stat.TcxLink.Should().Be("https://api.fitbit.com/1/user/-/activities/5390522508.tcx");
        }