static DataSample[] CreatesSamples(params TrackLocation[] values) { var s = new SessionData { DriverInfo = new SessionData._DriverInfo { Drivers = new[] { new SessionData._DriverInfo._Drivers { UserName = "******", CarNumberRaw = 1 } } } }; var i = 1; var samples = values.Select(ss => new DataSample { IsConnected = true, SessionData = s, Telemetry = new Telemetry { { "ReplayFrameNum", i++ }, { "CarIdxTrackSurface", new[] { ss } }, { "SessionTime", 0d }, } }).ToList(); DataSample lastSs = null; foreach( var ss in samples) { ss.Telemetry.SessionData = s; ss.LastSample = lastSs; lastSs = ss; } return samples.ToArray(); }
void AnnounceIfDriverHasFinished(DataSample data, TimeSpan relativeTime, SessionData._SessionInfo._Sessions session, int i, ref OverlayData.LeaderBoard leaderBoard) { if (!data.LastSample.Telemetry.Cars[i].HasSeenCheckeredFlag || haveNotedCheckerdFlag[i]) return; haveNotedCheckerdFlag[i] = true; var driver = data.SessionData.DriverInfo.CompetingDrivers[i]; var position = (int)session.ResultsPositions.First(r => r.CarIdx == i).Position; var pitStopCount = data.Telemetry.Cars[i].PitStopCount; var drivers = leaderBoard.Drivers.Where(d => d.CarIdx != i) .Select(d => d.Clone()) .ToList(); drivers.Insert((int)position - 1, new OverlayData.Driver { CarNumber = driver.CarNumber, UserName = driver.UserName, Position = position, CarIdx = i, PitStopCount = pitStopCount }); var p = 1; foreach (var d in drivers) d.Position = p++; leaderBoard = captureLeaderBoard.CreateLeaderBoard(data, relativeTime, drivers.ToArray()); var msg = string.Format("{0} finished in {1}{2}", driver.UserName, position, position.Ordinal()); TraceInfo.WriteLine("{0} {1}", data.Telemetry.SessionTimeSpan, msg); commentaryMessages.Add(msg, relativeTime.TotalSeconds); }
static DataSample[] CreatesSamples(params float[] values) { var s = new SessionData { DriverInfo = new SessionData._DriverInfo { Drivers = new [] { new SessionData._DriverInfo._Drivers { UserName = "******", CarNumberRaw = 1 } } } }; var sample1 = new DataSample { IsConnected = true, SessionData = s, Telemetry = new Telemetry { { "CarIdxLap", new[] { 1 } }, { "CarIdxLapDistPct", new[] { values[0] } } } }; var sample2 = new DataSample { IsConnected = true, SessionData = s, Telemetry = new Telemetry { { "CarIdxLap", new[] { 1 } }, { "CarIdxLapDistPct", new[] { values[1] } } } }; return new[] { sample1, sample2 }; }
void MarkResultFlashCardStart(DataSample data, TimeSpan relativeTime, SessionData._SessionInfo._Sessions session, int i) { if (!data.LastSample.Telemetry.Cars[i].HasSeenCheckeredFlag || overlayData.TimeForOutroOverlay != null) return; var position = (int)session.ResultsPositions.First(r => r.CarIdx == i).Position; if (position == Settings.Default.ResultsFlashCardPosition) { overlayData.TimeForOutroOverlay = relativeTime.TotalSeconds; TraceInfo.WriteLine("{0} Mark show results flash card.", data.Telemetry.SessionTimeSpan); } }
public void setup() { Settings.Default.FollowLeaderBeforeRaceEndPeriod = 10.Seconds(); session = BuildSession(resultsLapsCompleted: 12, resultsAverageLapTime: 30d); var cameras = new[] { new TrackCamera { CameraName = "Default", IsRaceStart = true }, new TrackCamera { CameraName = "TVX", IsLastLap = true }, new TrackCamera { CameraName = "TV2", IsLastLap = false } }; ruleLastLapPeriod = new RuleLastLapPeriod(new CameraControl(cameras), new Moq.Mock<RemovalEdits>(null).Object); }
static DataSample BuildDataSample(int raceLaps, SessionData session, double sessionTime = 0) { var data = new DataSample { SessionData = session, IsConnected = true, Telemetry = new Telemetry { { "SessionTime", sessionTime }, { "SessionNum", 0 }, { "RaceLaps", raceLaps }, } }; data.Telemetry.SessionData = session; return data; }
public RuleRandomDriver(CameraControl cameraControl, SessionData sessionData, TimeSpan stickyTime) { this.cameraControl = cameraControl; this.sessionData = sessionData; this.stickyTime = stickyTime; allCarIndexes = sessionData.DriverInfo.CompetingDrivers.Where(x => !x.IsPaceCar).Select(x => x.CarIdx).ToArray(); if (Settings.Default.PreferredDriverNames != null && Settings.Default.PreferredDriverNames.Length > 0) { preferredCarIndexes = sessionData.DriverInfo.CompetingDrivers .Where(x => Settings.Default.PreferredDrivers.Contains(x.UserName.ToLower())) .Select(x => x.CarIdx) .ToArray(); } else preferredCarIndexes = allCarIndexes; randomDriverNumber = new Random(); }
public ReplayControl(SessionData sessionData, Incidents incidents, RemovalEdits removalEdits, TrackCameras trackCameras) { var cameras = trackCameras.Where(tc => tc.TrackName == sessionData.WeekendInfo.TrackDisplayName).ToArray(); TraceInfo.WriteLineIf(cameras.Count() <= 0, "Track Cameras not defined for {0}", sessionData.WeekendInfo.TrackDisplayName); Debug.Assert(cameras.Count() > 0, "Track Cameras not defined for {0}".F(sessionData.WeekendInfo.TrackDisplayName)); foreach (var tc in cameras) tc.CameraNumber = (short)sessionData.CameraInfo.Groups.First(g => g.GroupName.ToLower() == tc.CameraName.ToLower()).GroupNum; var camera = cameras.First(tc => tc.IsRaceStart); var cameraControl = new CameraControl(cameras); cameraControl.CameraOnPositon(1, camera.CameraNumber); var battleMarker = removalEdits.For(InterestState.Battle); var restartMarker = removalEdits.For(InterestState.Restart); var ruleLastSectors = new RuleLastLapPeriod(cameraControl, removalEdits); var ruleUnlimitedIncident = new RuleIncident(cameraControl, removalEdits, incidents, 999); var ruleLimitedIncident = new RuleIncident(cameraControl, removalEdits, incidents, Settings.Default.IgnoreIncidentsBelowPosition); var ruleFirstSectors = new RuleFirstLapPeriod(cameraControl, removalEdits); var rulePaceLaps = new RulePaceLaps(cameraControl, restartMarker, battleMarker); var ruleBattle = new RuleBattle(cameraControl, battleMarker, Settings.Default.CameraStickyPeriod, Settings.Default.BattleStickyPeriod, Settings.Default.BattleGap, Settings.Default.BattleFactor2); ruleRandom = new RuleRandomDriver(cameraControl, sessionData, Settings.Default.CameraStickyPeriod); var ruleForFirstSectors = Settings.Default.IgnoreIncidentsDuringRaceStart ? ruleFirstSectors : ruleFirstSectors.WithVeto(ruleUnlimitedIncident); directionRules = new IDirectionRule[] { ruleLastSectors, ruleForFirstSectors, rulePaceLaps.WithVeto(ruleUnlimitedIncident.WithVeto(ruleLastSectors)), ruleBattle.WithVeto(ruleLimitedIncident.WithVeto(ruleLastSectors)), ruleUnlimitedIncident.WithVeto(ruleLastSectors), ruleRandom.WithVeto(ruleLastSectors) }; currentRule = directionRules[0]; }
static DataSample CreateSample(double time, SessionData sessionData) { var data = new DataSample { SessionData = sessionData, IsConnected = true, Telemetry = new Telemetry { { "SessionTime", time }, } }; data.Telemetry.SessionData = sessionData; return data; }
static void OverrideRacePositionDetails(DataSample data, SessionData._SessionInfo._Sessions session, ref string raceLapsPosition, ref string raceLapCounter) { if (data.Telemetry.RaceLaps <= 0) { raceLapCounter = null; raceLapsPosition = ""; return; } if (data.Telemetry.RaceLaps < session.ResultsLapsComplete) return; if (data.Telemetry.RaceLaps == session.ResultsLapsComplete) { raceLapsPosition = raceLapCounter = "Final Lap"; return; } raceLapsPosition = raceLapCounter = "Results"; }
DataSample DisconnectedSample() { lastSessionInfo = null; sessionLastInfoUpdate = -2; return(DataSample.YetToConnected); }
public void SetQualifyingResults(SessionData._SessionInfo._Sessions._ResultsPositions[] qualifyingResults) { ((dynamic)plugin).QualifyingResults = qualifyingResults; }
void iracingEvents_NewSessionData(DataSample data) { lastSession = data.SessionData; StateUpdated(); }
public EventData(SessionData sessionData) { this.sessionData = sessionData; }
public void SetCompetingDrivers(SessionData._DriverInfo._Drivers[] competingDrivers) { ((dynamic)plugin).CompetingDrivers = competingDrivers; }
static DataSample CreateIncidentSample(int carIdx, double time, SessionData sessionData) { var data = new DataSample { SessionData = sessionData, IsConnected = true, Telemetry = new Telemetry { { "SessionTime", time }, { "RaceLaps", 3 }, { "CarIdxTrackSurface", new [] { TrackLocation.OnTrack, TrackLocation.OnTrack, TrackLocation.OnTrack, TrackLocation.OnTrack } }, { "CamCarIdx", carIdx } } }; data.Telemetry.SessionData = sessionData; return data; }
private static SessionData BuildSession(int resultsLapsCompleted, double resultsAverageLapTime = 0) { var session = new SessionData { SessionInfo = new SessionData._SessionInfo { Sessions = new[] { new SessionData._SessionInfo._Sessions { ResultsAverageLapTime = resultsAverageLapTime, ResultsLapsComplete = resultsLapsCompleted } } } }; return session; }
public void SetWeekendInfo(SessionData._WeekendInfo weekendInfo) { ((dynamic)plugin).WeekendInfo = weekendInfo; }