public void CalculatCadenceClassificatoion_Under_2_Samples_returns_()
 {
     var samples = new WorkoutSamples(0);
     var vector = new WorkoutSampleVector(1, WorkoutSampleDataType.Cadence);
     vector.AddPoint(1, 2);
     samples.CadenceVector = vector;
     IAthlete athlete = new Athlete();
     var workoutCalculator = new WorkoutSamplesCalculator(samples, athlete);
     var classification = workoutCalculator.ClassifyWorkoutCadenceRanges();
     Assert.IsType<List<ICadenceRange>>(classification);
 }
        public void CalculatCadenceClassificatoion_Under_2_Samples_returns_()
        {
            var samples = new WorkoutSamples(0);
            var vector  = new WorkoutSampleVector(1, WorkoutSampleDataType.Cadence);

            vector.AddPoint(1, 2);
            samples.CadenceVector = vector;
            IAthlete athlete           = new Athlete();
            var      workoutCalculator = new WorkoutSamplesCalculator(samples, athlete);
            var      classification    = workoutCalculator.ClassifyWorkoutCadenceRanges();

            Assert.IsType <List <ICadenceRange> >(classification);
        }
Beispiel #3
0
        private static void Main(string[] args)
        {
            var athlete = new Athlete
            {
                TPData = new TrainingPeaksAthleteData
                {
                    LoginName     = "jscbutler",
                    LoginPassword = "******",
                    AccountType   = TrainingPeaksAthleteAccountTypes.SelfCoachedPremium
                },
                FTBikePower = 260,
                WeightKilos = 86.3
            };

            Console.Out.WriteLine("Starting connection to TrainingPeaks....");

            var conn = new TrainingPeaksClient();

            Console.Out.WriteLine("Initialised SOAP Client - starting to request Person Data");
            conn.GetAthleteData(athlete);
            Console.Out.WriteLine("Received Person Data - " + athlete.TPData.AthleteName + " ID:" +
                                  athlete.TPData.PersonID);
            Console.Out.WriteLine("Accesing last workout for " + athlete.TPData.AthleteName);
            //var workout = conn.GetLastWorkoutIn30Days(athlete);
            //pwx pwxData = conn.GetExtendedWorkoutData(athlete, workout);
            var fromDate = DateTime.ParseExact("20/03/2016", "dd/MM/yyyy", CultureInfo.InvariantCulture);
            var toDate   = DateTime.ParseExact("30/03/2016", "dd/MM/yyyy", CultureInfo.InvariantCulture);
            var workouts = conn.GetAllWorkoutsInDateRange(athlete, fromDate, toDate);

            foreach (var workout in workouts)
            {
                if (workout.SportType == SportType.Bike)
                {
                    var pwxData        = conn.GetExtendedWorkoutData(athlete, workout);
                    var extractor      = new PWXDataExtractor(pwxData);
                    var workoutSamples = extractor.ExtractData();
                    var calculator     = new WorkoutSamplesCalculator(workoutSamples, athlete);
                    Console.Out.WriteLine(workout.SportType + " on " + workout.StartDate + " TSS: " + workoutSamples.SummaryTrainingStressScore + " Duration: " + workout.Duration);
                    var cadenceRanges = calculator.ClassifyWorkoutCadenceRanges();
                    foreach (var cadenceRange in cadenceRanges)
                    {
                        Console.WriteLine(cadenceRange);
                    }
                    Console.WriteLine("==========================================");
                }
            }

            Console.In.ReadLine();
        }
        public void TestCadenceClassification()
        {
            var pwx =
                GetPwxDataFromXml(
                    GetSamplePwxFile(@"c:\dev\autocoach\testxmldata\TestTurboPowerCyclePZoneClassificationPWX.xml"));
            var      dataExtractor     = new PWXDataExtractor(pwx);
            var      workoutSample     = dataExtractor.ExtractData();
            IAthlete athlete           = new Athlete();
            var      workoutCalculator = new WorkoutSamplesCalculator(workoutSample, athlete);
            var      buckets           = workoutCalculator.ClassifyWorkoutCadenceRanges();

            Assert.IsType <List <ICadenceRange> >(buckets);
            Assert.Equal(1, buckets[0].QuanityOfSamples);
            Assert.Equal(14, buckets[0].PercentOfTotal);
            Assert.Equal(3, buckets[1].QuanityOfSamples);
            Assert.Equal(43, buckets[1].PercentOfTotal);
            Assert.Equal(0, buckets[2].QuanityOfSamples);
            Assert.Equal(0, buckets[2].PercentOfTotal);
            Assert.Equal(2, buckets[3].QuanityOfSamples);
            Assert.Equal(29, buckets[3].PercentOfTotal);
            Assert.Equal(1, buckets[4].QuanityOfSamples);
            Assert.Equal(14, buckets[4].PercentOfTotal);
        }
 public void TestCadenceClassification()
 {
     var pwx =
         GetPwxDataFromXml(
             GetSamplePwxFile(@"c:\dev\autocoach\testxmldata\TestTurboPowerCyclePZoneClassificationPWX.xml"));
     var dataExtractor = new PWXDataExtractor(pwx);
     var workoutSample = dataExtractor.ExtractData();
     IAthlete athlete = new Athlete();
     var workoutCalculator = new WorkoutSamplesCalculator(workoutSample,athlete);
     var buckets = workoutCalculator.ClassifyWorkoutCadenceRanges();
     Assert.IsType<List<ICadenceRange>>(buckets);
     Assert.Equal(1, buckets[0].QuanityOfSamples);
     Assert.Equal(14, buckets[0].PercentOfTotal);
     Assert.Equal(3, buckets[1].QuanityOfSamples);
     Assert.Equal(43, buckets[1].PercentOfTotal);
     Assert.Equal(0, buckets[2].QuanityOfSamples);
     Assert.Equal(0, buckets[2].PercentOfTotal);
     Assert.Equal(2, buckets[3].QuanityOfSamples);
     Assert.Equal(29, buckets[3].PercentOfTotal);
     Assert.Equal(1, buckets[4].QuanityOfSamples);
     Assert.Equal(14, buckets[4].PercentOfTotal);
 }