public override bool Equals(object obj) { if (obj is SprocketCombo) { SprocketCombo combo = obj as SprocketCombo; return(combo.CassetteSize == CassetteSize && combo.ChainringSize == ChainringSize && combo.GearRatio == GearRatio); } return(base.Equals(obj)); }
/// <summary> /// Caculate basic stats for each sprocket. This mostly allows to know the times during which we used a given gear /// </summary> /// <param name="activity"></param> /// <param name="sprocketTrack"></param> /// <returns>Returns an IList<SprocketComboInfo> of the sprocket combo info</returns> public static IList <SprocketComboInfo> Calculate(IActivity activity, ITimeDataSeries <SprocketCombo> sprocketTrack) { List <SprocketCombo> sprockets = GetSprocketCombos(activity); List <SprocketComboInfo> result = new List <SprocketComboInfo>(sprockets.Count + 1); SprocketCombo lastItemSprocket = null; DateTime sectionStartTime = sprocketTrack.StartTime; // Create the results for each zone foreach (SprocketCombo combo in sprockets) { result.Add(new SprocketComboInfo(combo)); } // Go through and find the corresponding sprocket combo for each point foreach (ITimeValueEntry <SprocketCombo> item in sprocketTrack) { // We found a change in gear, add section to times if (lastItemSprocket != item.Value) { DateTime currentItemTime = sprocketTrack.EntryDateTime(item); // First item, ignore it if (lastItemSprocket != null) { int index = sprockets.IndexOf(lastItemSprocket); result[index].Times.Add(new ValueRange <DateTime>(sectionStartTime, currentItemTime)); } sectionStartTime = currentItemTime; lastItemSprocket = item.Value; } } // Add last section if (lastItemSprocket != null && sprocketTrack.Count > 0) { int index = sprockets.IndexOf(lastItemSprocket); DateTime endTime = sprocketTrack.EntryDateTime(sprocketTrack[sprocketTrack.Count - 1]); result[index].Times.Add(new ValueRange <DateTime>(sectionStartTime, endTime)); // There is also a "totals" when Calculate is used in ST, add it although it's a bit useless for now SprocketComboInfo totals = new SprocketComboInfo(null); totals.Times.Add(new ValueRange <DateTime>(sprocketTrack.StartTime, endTime)); result.Add(totals); } return(result); }
public SprocketComboInfo(SprocketCombo combo) { m_Combo = combo; }