public CaptureLeaderBoard(OverlayData overlayData, CommentaryMessages commentaryMessages, RemovalEdits removalEdits)
 {
     this.overlayData = overlayData;
     this.captureLeaderBoardFirstLap = new CaptureLeaderBoardFirstLap(this, overlayData);
     this.captureLeaderBoardLastLap = new CaptureLeaderBoardLastLap(this, overlayData, commentaryMessages);
     this.captureLeaderBoardMiddleLaps = new CaptureLeaderBoardMiddleLaps(this, overlayData, removalEdits, commentaryMessages);
 }
        public RuleIncident(CameraControl cameraControl, RemovalEdits removalEdits, Incidents incidents, int limitDownTo)
        {
            this.editMarker = removalEdits.For(InterestState.Incident);
            this.cameraControl = cameraControl;
            this.limitDownTo = limitDownTo;

            nextIncident = incidents.GetEnumerator();
            nextIncident.MoveNext();
            if (nextIncident.Current != null)
                TraceInfo.WriteLine("First incident at {0}", nextIncident.Current.StartSessionTime);
        }
        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];
        }
 public EditMarker(RemovalEdits removalEdits, InterestState interest)
 {
     this.removalEdits = removalEdits;
     this.interest = interest;
 }
 public RuleLastLapPeriod(CameraControl cameraControl, RemovalEdits removalEdits)
 {
     this.editMarker = removalEdits.For(InterestState.LastLap);
     this.cameraControl = cameraControl;
 }
 public EditMarker(RemovalEdits removalEdits, InterestState interest)
 {
     this.removalEdits = removalEdits;
     this.interest     = interest;
 }
예제 #7
0
 public CaptureLeaderBoard(OverlayData overlayData, CommentaryMessages commentaryMessages, RemovalEdits removalEdits)
 {
     this.overlayData = overlayData;
     this.captureLeaderBoardFirstLap   = new CaptureLeaderBoardFirstLap(this, overlayData);
     this.captureLeaderBoardLastLap    = new CaptureLeaderBoardLastLap(this, overlayData, commentaryMessages);
     this.captureLeaderBoardMiddleLaps = new CaptureLeaderBoardMiddleLaps(this, overlayData, removalEdits, commentaryMessages);
 }
        internal void _CaptureRaceTest(Action<string> onComplete, IEnumerable<DataSample> samples)
        {
            var overlayData = new OverlayData();
            var removalEdits = new RemovalEdits(overlayData.RaceEvents);
            var commentaryMessages = new CommentaryMessages(overlayData);
            var videoCapture = new VideoCapture();
            var recordPitStop = new RecordPitStop(commentaryMessages);
            var fastestLaps = new RecordFastestLaps(overlayData);
            var replayControl = new ReplayControl(samples.First().SessionData, incidents, removalEdits, TrackCameras);
            var sessionDataCapture = new SessionDataCapture(overlayData);
            var captureLeaderBoardEveryHalfSecond = new SampleFilter(TimeSpan.FromSeconds(0.5),
                new CaptureLeaderBoard(overlayData, commentaryMessages, removalEdits).Process);
            var captureCamDriverEveryQuaterSecond = new SampleFilter(TimeSpan.FromSeconds(0.25),
                 new CaptureCamDriver(overlayData).Process);

            ApplyFirstLapCameraDirection(samples, replayControl);

            samples = samples
                .VerifyReplayFrames()
                .WithCorrectedPercentages()
                .WithCorrectedDistances()
                .WithFastestLaps()
                .WithFinishingStatus()
                .WithPitStopCounts()
                .TakeUntil(3.Seconds()).After(d => d.Telemetry.RaceCars.All(c => c.HasSeenCheckeredFlag || c.HasRetired || c.TrackSurface != TrackLocation.OnTrack))
                .TakeUntil(3.Seconds()).AfterReplayPaused();
            
            if (shortTestOnly)
            {
                samples = samples.AtSpeed(Settings.Default.TimingFactorForShortTest);
                Settings.AppliedTimingFactor = 1.0 / Settings.Default.TimingFactorForShortTest;
            }

            videoCapture.Activate(workingFolder);
            var startTime = DateTime.Now;

            foreach (var data in samples)
            {
                var relativeTime = DateTime.Now - startTime;

                replayControl.Process(data);
                sessionDataCapture.Process(data);
                captureLeaderBoardEveryHalfSecond.Process(data, relativeTime);
                captureCamDriverEveryQuaterSecond.Process(data, relativeTime);
                recordPitStop.Process(data, relativeTime);
                fastestLaps.Process(data, relativeTime);
                removalEdits.Process(data, relativeTime);
            }

            var files = videoCapture.Deactivate();

            removalEdits.Stop();

            var overlayFile = SaveOverlayData(overlayData, files);

            iRacing.Replay.SetSpeed(0);

            AltTabBackToApp();

            if (files.Count == 0)
                throw new Exception("Unable to find video files in '{0}' - possible wrong working folder".F(workingFolder));
            
            _WithOverlayFile(overlayFile);

            onComplete(overlayFile);
        }