Exemplo n.º 1
0
        /// <summary>
        /// Starts a new lap
        /// </summary>
        public ILapSummary NewLap()
        {
            var lap = new MemoryLap();

            _laps.NewLap(lap);

            return(lap);
        }
Exemplo n.º 2
0
        /// <summary>
        /// Calculates decoupling values
        /// </summary>
        private void CalculateDecoupling()
        {
            if (TimeFrames.Count < 2)
            {
                _powerHeartRateDecoupling = 0;
                _paceHeartRateDecoupling  = 0;
            }
            else
            {
                var firstHalf  = new MemoryLap(); // first half
                var secondHalf = new MemoryLap(); // second half
                foreach (var timeFrame in TimeFrames)
                {
                    if (timeFrame.Timestamp.Subtract(StartTime).TotalSeconds < ElapsedTime * 0.5)
                    {
                        firstHalf.AddTimeFrame(timeFrame);
                    }
                    else
                    {
                        secondHalf.AddTimeFrame(timeFrame);
                    }
                }

                if (firstHalf.AvgHeartRate == 0 || secondHalf.AvgHeartRate == 0 || firstHalf.AvgPower == 0)
                {
                    _powerHeartRateDecoupling = double.NaN;
                }
                else
                {
                    _powerHeartRateDecoupling = ((double)firstHalf.AvgPower / firstHalf.AvgHeartRate - (double)secondHalf.AvgPower / secondHalf.AvgHeartRate) /
                                                ((double)firstHalf.AvgPower / firstHalf.AvgHeartRate);
                }
                const SpeedUnit speedUnit = SpeedUnit.MeterPerSecond;
                if (firstHalf.AvgHeartRate == 0 || secondHalf.AvgHeartRate == 0 || firstHalf.AvgSpeed.GetValueAs(speedUnit) == 0)
                {
                    _paceHeartRateDecoupling = double.NaN;
                }
                else
                {
                    _paceHeartRateDecoupling = (firstHalf.AvgSpeed.GetValueAs(speedUnit) / firstHalf.AvgHeartRate - secondHalf.AvgSpeed.GetValueAs(speedUnit) / secondHalf.AvgHeartRate) /
                                               (firstHalf.AvgSpeed.GetValueAs(speedUnit) / firstHalf.AvgHeartRate);
                }
            }
        }