コード例 #1
0
        private ComboUsageInfo GetMostUsedGearValue(RangeInfoCacheWrapper range)
        {
            if (range.ActivityPauselessCadenceTrack.Count > 0)
            {
                ITimeDataSeries <SprocketCombo> rangeSprockets = GetRangeSprocketsTrack(range);
                IList <SprocketComboInfo>       sprocketInfo   = GetSprocketComboInfo(range, rangeSprockets);
                SprocketCombo mostUsedCombo    = null;
                TimeSpan      mostUsedDuration = new TimeSpan(0);

                foreach (SprocketComboInfo comboInfo in sprocketInfo)
                {
                    TimeSpan currentComboDuration = new TimeSpan(0);

                    foreach (IValueRange <DateTime> times in comboInfo.Times)
                    {
                        currentComboDuration += (times.Upper - times.Lower);
                    }

                    if (mostUsedCombo == null || mostUsedDuration < currentComboDuration)
                    {
                        mostUsedCombo    = comboInfo.SprocketCombo;
                        mostUsedDuration = currentComboDuration;
                    }
                }

                return(new ComboUsageInfo(mostUsedCombo, mostUsedDuration));
            }

            return(null);
        }
コード例 #2
0
        public String GetMaxRatio(RangeInfoCacheWrapper range)
        {
            if (range.ActivityPauselessCadenceTrack.Count > 0)
            {
                double        maxRatio = GetMaxRatioValue(range);
                SprocketCombo combo    = FindComboFromRatio(maxRatio, range.Activity);

                // We must refresh our cache, something changed in our activity
                if (combo == null)
                {
                    range.SaveStoredInfo(m_GearTrackStoredInfoId, null);
                    range.SaveStoredInfo(m_SprocketTrackStoredInfoId, null);
                    range.SaveStoredInfo(m_SprocketStoredInfoId, null);

                    maxRatio = GetMaxRatioValue(range);
                    combo    = FindComboFromRatio(maxRatio, range.Activity);
                }

                Debug.Assert(combo != null);

                return(String.Format("{0:0.00} ({1:0}x{2:0})", Math.Round(maxRatio, 2), combo.ChainringSize, combo.CassetteSize));
            }

            return(String.Empty);
        }
コード例 #3
0
        public String GetAvgRatio(RangeInfoCacheWrapper range)
        {
            if (range.ActivityPauselessCadenceTrack.Count > 0)
            {
                return(String.Format("{0:0.00}", Math.Round(GetAvgRatioValue(range), 2)));
            }

            return(String.Empty);
        }
コード例 #4
0
        public String GetMostUsedGear(RangeInfoCacheWrapper range)
        {
            if (range.ActivityPauselessCadenceTrack.Count > 0)
            {
                ComboUsageInfo mostUsedGear = GetMostUsedGearValue(range);

                if (mostUsedGear.m_Combo != null)
                {
                    return(String.Format("{0:0.00} ({1:0}x{2:0}) [{3:00}:{4:00}:{5:00}]",
                                         Math.Round(mostUsedGear.m_Combo.GearRatio, 2), mostUsedGear.m_Combo.ChainringSize,
                                         mostUsedGear.m_Combo.CassetteSize, mostUsedGear.m_UsageDuration.Hours,
                                         mostUsedGear.m_UsageDuration.Minutes, mostUsedGear.m_UsageDuration.Seconds));
                }
            }

            return(String.Empty);
        }
コード例 #5
0
        public IList <SprocketComboInfo> GetSprocketComboInfo(RangeInfoCacheWrapper range, ITimeDataSeries <SprocketCombo> sprocketTrack)
        {
            IList <SprocketComboInfo> result;

            if (range.ContainsStoredInfo(m_SprocketStoredInfoId) &&
                range.RetrieveStoredInfo(m_SprocketStoredInfoId) != null)
            {
                result = range.RetrieveStoredInfo(m_SprocketStoredInfoId) as IList <SprocketComboInfo>;
            }
            else
            {
                result = Common.Data.Calculate(range.Activity, sprocketTrack);

                // Remove totals row
                result.RemoveAt(result.Count - 1);

                range.SaveStoredInfo(m_SprocketStoredInfoId, result);
            }

            return(result);
        }
コード例 #6
0
        public String GetRatioVsAvg(RangeInfoCacheWrapper range)
        {
            if (range.ActivityPauselessCadenceTrack.Count > 0)
            {
                double ratioVsAvg = Math.Round(GetRatioVsAvgValue(range), 2);
                String sign       = "";

                if (ratioVsAvg < 0)
                {
                    sign = "-";
                }
                else if (ratioVsAvg > 0)
                {
                    sign = "+";
                }

                return(String.Format("{1}{0:0.00}", Math.Abs(ratioVsAvg), sign));
            }

            return(String.Empty);
        }
コード例 #7
0
        public ITimeDataSeries <SprocketCombo> GetRangeSprocketsTrack(RangeInfoCacheWrapper range)
        {
            ITimeDataSeries <SprocketCombo> result = null;

            if (range.ContainsStoredInfo(m_SprocketTrackStoredInfoId) &&
                range.RetrieveStoredInfo(m_SprocketTrackStoredInfoId) != null)
            {
                result = range.RetrieveStoredInfo(m_SprocketTrackStoredInfoId) as ITimeDataSeries <SprocketCombo>;
            }
            else
            {
                INumericTimeDataSeries gears = ActivityGearTrackCache.Instance.CalculateGearTrack(range.Activity);

                gears = Utils.Utils.RemovePausedTimesInTrack(gears, range.Activity);

                NumericTimeDataSeries tempResult = new NumericTimeDataSeries();
                Utils.Utils.ExtractRangeFromDataTrack(gears, range.PauselessRange, tempResult);
                result = GearChart.UI.GearUtils.GuessSprockets(tempResult, Common.Data.GetSprocketCombos(range.Activity));

                range.SaveStoredInfo(m_SprocketTrackStoredInfoId, result);
            }

            return(result);
        }
コード例 #8
0
        private double GetPauselessTimePercent(RangeInfoCacheWrapper range)
        {
            double pauselessDuration = (range.PauselessRange.Upper - range.PauselessRange.Lower).TotalSeconds;

            return(pauselessDuration / Utils.Utils.GetActiveActivityTme(range.Activity).TotalSeconds);
        }
コード例 #9
0
        public double GetRatioVsAvgValue(RangeInfoCacheWrapper range)
        {
            INumericTimeDataSeries gears = ActivityGearTrackCache.Instance.CalculateGearTrack(range.Activity);

            return(GetRangeGearsTrack(range).Avg - gears.Avg);
        }
コード例 #10
0
 public double GetMaxRatioValue(RangeInfoCacheWrapper range)
 {
     return(GetRangeGearsTrack(range).Max);
 }