static List <OverlayData.RaceEvent> ExtractEditedEvents( double totalTime, double percentage, List <OverlayData.RaceEvent> raceEvents, InterestState interest, bool byPosition = false) { TraceInfo.WriteLine("Extracting {0} from a total set of {1}", interest, raceEvents.Count); if (raceEvents.Count <= 2) { return(raceEvents); } var duration = 0d; var targetDuration = totalTime * percentage; var orderedRaceEvents = raceEvents.OrderBy(r => r.StartTime).ToList(); var firstEvent = orderedRaceEvents.First(); var lastEvent = orderedRaceEvents.Last(); var searchRaceEvents = new List <_RaceEvent>(); searchRaceEvents.Add(new _RaceEvent { RaceEvent = firstEvent, Level = 0 }); searchRaceEvents.Add(new _RaceEvent { RaceEvent = lastEvent, Level = 0 }); var result = new List <OverlayData.RaceEvent>(); if (byPosition) { foreach (var p in raceEvents.OrderBy(r => r.Position).Select(r => r.Position).Distinct()) { TraceInfo.WriteLine("Scanning for {0}s for position {1}", interest, p); duration = ExtractUptoTargetDuration(raceEvents.Where(r => r.Position == p).ToList(), duration, targetDuration, firstEvent, lastEvent, searchRaceEvents, result); } } else { TraceInfo.WriteLine("Scanning for {0}s", interest); duration = ExtractUptoTargetDuration(raceEvents, duration, targetDuration, firstEvent, lastEvent, searchRaceEvents, result); } foreach (var r in result.OrderBy(x => x.StartTime)) { TraceInfo.WriteLine("Highlight edit {0} @ position {4}: {1} - {2}, duration: {3}", r.Interest, r.StartTime.Seconds(), r.EndTime.Seconds(), r.Duration.Seconds(), r.Position); } TraceInfo.WriteLine("Highlight Edits: {0}. Target Duration: {1}, Percentage: {2:00}%, Resolved Duration: {3}", interest.ToString(), targetDuration.Seconds(), (int)(percentage * 100), duration.Seconds()); return(result); }
public void InterestingThingStopped(InterestState interest) { nextAction = (d, t) => { InterestState le = events.Count > 0 ? events.Pop() : InterestState.Unknown; if (le != interest) throw new Exception("RaceEvent mismatched. Attempted to close {0}, when expecting {1}".F(interest.ToString(), le.ToString())); AddEvent(interest, d, t); }; }
void AddEvent(InterestState interest, DataSample d, TimeSpan t) { raceEvents.Add(new OverlayData.RaceEvent { Interest = interest, StartTime = lastStartTime.TotalSeconds, EndTime = t.TotalSeconds, WithOvertake = withOvertake, Position = position }); lastStartTime = t; TraceInfo.WriteLine("{0} Stopping {1}{2}", d.Telemetry.SessionTimeSpan, interest.ToString(), withOvertake ? " - with Overtake" : ""); withOvertake = false; }
public void InterestingThingStarted(InterestState interest) { var oldAction = nextAction; nextAction = (d, t) => { oldAction(d, t); if (events.Count > 0) { var le = events.Peek(); AddEvent(le, d, t); } events.Push(interest); lastStartTime = t; TraceInfo.WriteLine("{0} Starting {1}", d.Telemetry.SessionTimeSpan, interest.ToString()); }; }
public void InterestingThingStarted(InterestState interest, int pos) { var oldAction = nextAction; position = pos; nextAction = (d, t) => { oldAction(d, t); if (events.Count > 0) { var le = events.Peek(); AddEvent(le, d, t); } events.Push(interest); lastStartTime = t; TraceInfo.WriteLine("{0} Starting {1}", d.Telemetry.SessionTimeSpan, interest.ToString()); }; }
public override string ToString() { return("StartTime: {0}, EndTime: {1}, Interest: {2}, Position: {3}".F(StartTime, EndTime, Interest.ToString(), Position)); }
static List<OverlayData.RaceEvent> GetAllRaceEvents(IEnumerable<OverlayData.RaceEvent> raceEvents, InterestState interest, double factor, double minDuration, out double ratio) { var result = raceEvents .Where(re => re.Interest == interest) .Where(re => re.Duration > minDuration) .ToList(); var duration = result.Sum(re => re.Duration); ratio = duration * factor; TraceInfo.WriteLine("Highlight Edits: {0}. Duration: {1}, Factor: {2}, Ratio: {3}", interest.ToString(), duration.Seconds(), factor, ratio); return result; }
static List<OverlayData.RaceEvent> ExtractEditedEvents(double totalTime, double percentage, List<OverlayData.RaceEvent> raceEvents, InterestState interest) { var duration = 0d; var orderRaceEvents = new List<_RaceEvent>(); var targetDuration = totalTime * percentage; raceEvents = raceEvents.ToArray().ToList(); if( raceEvents.Count <= 2 ) return raceEvents; var firstEvent = raceEvents.OrderBy(r => r.StartTime).First(); var lastEvent = raceEvents.OrderBy(r => r.StartTime).Last(); orderRaceEvents.Add(new _RaceEvent { RaceEvent = firstEvent, Level = 0 }); orderRaceEvents.Add(new _RaceEvent { RaceEvent = lastEvent, Level = 0 }); var result = new List<OverlayData.RaceEvent>(); SliceEvent(orderRaceEvents, raceEvents.Where( rc => rc.WithOvertake).ToList(), firstEvent, lastEvent, 1); duration = SelectOrderByLevel(orderRaceEvents, targetDuration, result, duration); orderRaceEvents.Clear(); SliceEvent(orderRaceEvents, raceEvents.Where(rc => !rc.WithOvertake).ToList(), firstEvent, lastEvent, 1); duration = SelectOrderByLevel(orderRaceEvents, targetDuration, result, duration); foreach( var r in result.OrderBy( x => x.StartTime)) TraceDebug.WriteLine("Highlight edit {0}: {1} - {2}, duration: {3}", r.Interest, r.StartTime.Seconds(), r.EndTime.Seconds(), r.Duration.Seconds()); TraceInfo.WriteLine("Highlight Edits: {0}. Target Duration: {1}, Percentage: {2:00}%, Resolved Duration: {3}", interest.ToString(), targetDuration.Seconds(), (int)(percentage*100), duration.Seconds()); return result; }
public void InterestingThingStopped(InterestState interest) { nextAction = (d, t) => { InterestState le = events.Count > 0 ? events.Pop() : InterestState.Unknown; if (le != interest) { throw new Exception("RaceEvent mismatched. Attempted to close {0}, when expecting {1}".F(interest.ToString(), le.ToString())); } AddEvent(interest, d, t); }; }
static List <OverlayData.RaceEvent> GetAllRaceEvents(IEnumerable <OverlayData.RaceEvent> raceEvents, InterestState interest, double factor, double minDuration, out double ratio) { var result = raceEvents .Where(re => re.Interest == interest) .Where(re => re.Duration > minDuration) .ToList(); var duration = result.Sum(re => re.Duration); ratio = duration * factor; TraceInfo.WriteLine("Highlight Edits: {0}. Duration: {1}, Factor: {2}, Ratio: {3}", interest.ToString(), duration.Seconds(), factor, ratio); return(result); }
static List<OverlayData.RaceEvent> ExtractEditedEvents( double totalTime, double percentage, List<OverlayData.RaceEvent> raceEvents, InterestState interest, bool byPosition = false) { TraceInfo.WriteLine("Extracting {0} from a total set of {1}", interest, raceEvents.Count); if (raceEvents.Count <= 2) return raceEvents; var duration = 0d; var targetDuration = totalTime * percentage; var orderedRaceEvents = raceEvents.OrderBy(r => r.StartTime).ToList(); var firstEvent = orderedRaceEvents.First(); var lastEvent = orderedRaceEvents.Last(); var searchRaceEvents = new List<_RaceEvent>(); searchRaceEvents.Add(new _RaceEvent { RaceEvent = firstEvent, Level = 0 }); searchRaceEvents.Add(new _RaceEvent { RaceEvent = lastEvent, Level = 0 }); var result = new List<OverlayData.RaceEvent>(); if (byPosition) { foreach (var p in raceEvents.OrderBy(r => r.Position).Select(r => r.Position).Distinct()) { TraceInfo.WriteLine("Scanning for {0}s for position {1}", interest, p); duration = ExtractUptoTargetDuration(raceEvents.Where(r => r.Position == p).ToList(), duration, targetDuration, firstEvent, lastEvent, searchRaceEvents, result); } } else { TraceInfo.WriteLine("Scanning for {0}s", interest); duration = ExtractUptoTargetDuration(raceEvents, duration, targetDuration, firstEvent, lastEvent, searchRaceEvents, result); } foreach (var r in result.OrderBy(x => x.StartTime)) TraceInfo.WriteLine("Highlight edit {0} @ position {4}: {1} - {2}, duration: {3}", r.Interest, r.StartTime.Seconds(), r.EndTime.Seconds(), r.Duration.Seconds(), r.Position); TraceInfo.WriteLine("Highlight Edits: {0}. Target Duration: {1}, Percentage: {2:00}%, Resolved Duration: {3}", interest.ToString(), targetDuration.Seconds(), (int)(percentage * 100), duration.Seconds()); return result; }