public WorkoutSamples ExtractData() { if (numSamples <= 0) { return new WorkoutSamples(0); } var woSamples = new WorkoutSamples(numSamples); foreach (var sample in _file.workout[0].sample) { if (sample.pwrSpecified) woSamples.AddPoint(sample.timeoffset, sample.pwr, WorkoutSampleDataType.Power); else woSamples.AddPoint(sample.timeoffset, -1, WorkoutSampleDataType.Power); if (sample.cadSpecified) woSamples.AddPoint(sample.timeoffset, sample.cad, WorkoutSampleDataType.Cadence); else woSamples.AddPoint(sample.timeoffset, -1, WorkoutSampleDataType.Cadence); if(sample.hrSpecified) woSamples.AddPoint(sample.timeoffset, sample.hr, WorkoutSampleDataType.HeartRate); else woSamples.AddPoint(sample.timeoffset, -1, WorkoutSampleDataType.HeartRate); if(sample.spdSpecified) woSamples.AddPoint(sample.timeoffset, sample.hr, WorkoutSampleDataType.Speed); else woSamples.AddPoint(sample.timeoffset, -1, WorkoutSampleDataType.Speed); } woSamples.SummaryTrainingStressScore = ExtractSummaryTSS(); woSamples.SummaryDuration = ExtractSummaryDuration(); woSamples.SummaryWork = ExtractSummaryWork(); return woSamples; }
public void CalculateNormalizedPower_With_No_Samples_Returns_Zero() { var samples = new WorkoutSamples(0); IAthlete athlete = new Athlete(); var workoutCalculator = new WorkoutSamplesCalculator(samples,athlete); var average = workoutCalculator.GetNormalizedPower(); Assert.Equal(0, average); }
public void CalculateNonZero_Average_With_No_Data_Returns_Zero() { var samples = new WorkoutSamples(0); var vector = new WorkoutSampleVector(3, WorkoutSampleDataType.Power); IAthlete athlete = new Athlete(); var workoutCalculator = new WorkoutSamplesCalculator(samples, athlete); var average = workoutCalculator.CalculateNonZeroVectorAverage(vector); Assert.Equal(0, average); }
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 CalculateNormalizedPower_With_Under_30_Samples_Returns_Average() { //Initialise(); var samples = new WorkoutSamples(0); var vector = new WorkoutSampleVector(2, WorkoutSampleDataType.Power); vector.AddPoint(1, 2); vector.AddPoint(2, 4); IAthlete athlete = new Athlete(); var workoutCalculator = new WorkoutSamplesCalculator(samples, athlete); var average = workoutCalculator.CalculateVectorNormalizedAverage(vector); Assert.Equal(3, average); }
public void CalculateNonZero_Average_Returns_Average() { var samples = new WorkoutSamples(0); var vector = new WorkoutSampleVector(3, WorkoutSampleDataType.Power); vector.AddPoint(1, 2); vector.AddPoint(2, 4); vector.AddPoint(3, 0); IAthlete athlete = new Athlete(); var workoutCalculator = new WorkoutSamplesCalculator(samples,athlete); var average = workoutCalculator.CalculateNonZeroVectorAverage(vector); Assert.Equal(3, average); }
public void CalculateVectorAverage_With_No_Samples_Returns_Zero() { var samples = new WorkoutSamples(0); IAthlete athlete = new Athlete(); var workoutCalculator = new WorkoutSamplesCalculator(samples, athlete); var average = workoutCalculator.GetAverageCadence(); Assert.Equal(0, average); }
public WorkoutSamplesCalculator(WorkoutSamples woSamples, IAthlete athlete) { _workoutSamples = woSamples; _athlete = athlete; }