Skip to content

Commit

Permalink
Logging: Log every 4 seconds, the camera selected details
Browse files Browse the repository at this point in the history
  • Loading branch information
vipoo committed May 1, 2016
1 parent 2fb1759 commit a197395
Show file tree
Hide file tree
Showing 4 changed files with 73 additions and 2 deletions.
5 changes: 5 additions & 0 deletions Phases/CaptureRace.cs
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,10 @@ internal void _CaptureRaceTest(Action<string> onComplete, IEnumerable<DataSample
var captureCamDriverEveryQuaterSecond = new SampleFilter(TimeSpan.FromSeconds(0.25),
new CaptureCamDriver(overlayData).Process);

var captureCamDriverEvery4Seconds = new SampleFilter(TimeSpan.FromSeconds(4),
new LogCamDriver().Process);


TraceDebug.WriteLine("Cameras:");
TraceDebug.WriteLine(TrackCameras.ToString());

Expand Down Expand Up @@ -105,6 +109,7 @@ internal void _CaptureRaceTest(Action<string> onComplete, IEnumerable<DataSample
recordPitStop.Process(data, relativeTime);
fastestLaps.Process(data, relativeTime);
removalEdits.Process(data, relativeTime);
captureCamDriverEvery4Seconds.Process(data, relativeTime);
}

var files = videoCapture.Deactivate();
Expand Down
5 changes: 3 additions & 2 deletions Phases/Capturing/CaptureCamDriver.cs
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ public void Process(DataSample data, TimeSpan relativeTime)
camDriver.CurrentDriver.UserName,
camDriver.CurrentDriver.CarNumber,
position, indicator);

lastCamDriver = camDriver.CurrentDriver;
}
overlayData.CamDrivers.Add(camDriver);
Expand All @@ -80,7 +80,7 @@ static OverlayData.Driver GetCurrentDriverDetails(DataSample data)
return null;

var car = data.Telemetry.CamCar;

var position = GetPositionFor(data, car.Details);

var driver = new OverlayData.Driver
Expand All @@ -90,6 +90,7 @@ static OverlayData.Driver GetCurrentDriverDetails(DataSample data)
UserName = car.Details.UserName,
Position = position,
PitStopCount = car.PitStopCount

};

return driver;
Expand Down
64 changes: 64 additions & 0 deletions Phases/Capturing/LogCamDriver.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
// This file is part of iRacingReplayOverlay.
//
// Copyright 2014 Dean Netherton
// https://github.com/vipoo/iRacingReplayOverlay.net
//
// iRacingReplayOverlay is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// iRacingReplayOverlay is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License333
// along with iRacingReplayOverlay. If not, see <http://www.gnu.org/licenses/>.

using iRacingSDK;
using iRacingSDK.Support;
using System;
using System.Linq;

namespace iRacingReplayOverlay.Phases.Capturing
{
public class LogCamDriver
{
public LogCamDriver()
{
}

public void Process(DataSample data, TimeSpan relativeTime)
{
try
{
var cameraGroupName = "";
var cameraName = "";

var cameraGroup = data.SessionData.CameraInfo.Groups.FirstOrDefault(g => g.GroupNum == data.Telemetry.CamGroupNumber);
if (cameraGroup != null)
{
cameraGroupName = cameraGroup.GroupName;
var camera = cameraGroup.Cameras.FirstOrDefault(c => c.CameraNum == data.Telemetry.CamCameraNumber);
if (camera != null)
cameraName = camera.CameraName;
}

TraceDebug.WriteLine("{0} Camera: Driver: {1}, GroupNumber: {2}, Number: {3}, State: {4}, GroupName: {5}, Name: {6}",
data.Telemetry.SessionTimeSpan,
data.Telemetry.CamCar.Details.Driver.UserName,
data.Telemetry.CamGroupNumber,
data.Telemetry.CamCameraNumber,
data.Telemetry.CamCameraState,
cameraGroupName,
cameraName);
}
catch(Exception e)
{
TraceError.WriteLine(e.Message);
TraceError.WriteLine(e.StackTrace);
}
}
}
}
1 change: 1 addition & 0 deletions iRacingReplayOverlay.net.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,7 @@
</Compile>
<Compile Include="Aws\AwsKey.cs" />
<Compile Include="Aws\AwsLogListener.cs" />
<Compile Include="Phases\Capturing\LogCamDriver.cs" />
<Compile Include="Phases\TranscodeAndOverlay.cs" />
<Compile Include="PluginSettings.cs">
<SubType>Form</SubType>
Expand Down

0 comments on commit a197395

Please sign in to comment.