Skip to content

Commit

Permalink
Fix missing speed trap data during race sessions
Browse files Browse the repository at this point in the history
  • Loading branch information
JustAman62 committed Nov 3, 2024
1 parent 10c4de3 commit 4fd820c
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 11 deletions.
23 changes: 15 additions & 8 deletions OpenF1.Console/Display/SessionStatsDisplay.cs
Original file line number Diff line number Diff line change
Expand Up @@ -119,23 +119,30 @@ private IRenderable GetTeamsChampionshipTable()

private IRenderable GetSpeedTrapTable()
{
var traps = new string[] {"FL", "I1", "I2", "ST"};
var traps = new string[] { "FL", "I1", "I2", "ST" };
var tables = new List<Table>();

var stats = timingStatsProcessor.Latest.Lines.Values;
var stats = timingStatsProcessor.Latest.Lines;

foreach (var trapKey in traps)
{
var table = new Table() { Title = new TableTitle(trapKey) };
table.AddColumns("Driver", "Kph");
var lines = stats.OrderBy(x => x.BestSpeeds.GetValueOrDefault(trapKey)?.Position);
foreach (var line in lines)
var lines = stats.OrderBy(x => x.Value.BestSpeeds.GetValueOrDefault(trapKey)?.Position);
foreach (var (driverNumber, line) in lines)
{
var driver = driverList.Latest.GetValueOrDefault(line.RacingNumber ?? "", new() { RacingNumber = line.RacingNumber });
table.AddRow(
new Markup(DisplayUtils.MarkedUpDriverNumber(driver)),
new Text(line.BestSpeeds.GetValueOrDefault(trapKey)?.Value ?? "UNK")
var driver = driverList.Latest.GetValueOrDefault(
driverNumber ?? "",
new() { RacingNumber = driverNumber }
);
var speed = line.BestSpeeds.GetValueOrDefault(trapKey)?.Value ?? "";
if (!string.IsNullOrWhiteSpace(speed))
{
table.AddRow(
new Markup(DisplayUtils.MarkedUpDriverNumber(driver)),
new Text(speed)
);
}
}

table.SimpleBorder();
Expand Down
3 changes: 0 additions & 3 deletions OpenF1.Data/Models/TimingDataPoints/TimingStatsDataPoint.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,6 @@ public sealed record TimingStatsDataPoint: ILiveTimingDataPoint

public sealed record Driver
{
public int? Line { get; set; }
public string? RacingNumber { get; set; }

public Dictionary<string, Stat> BestSpeeds { get; set; } = [];

public record Stat
Expand Down

0 comments on commit 4fd820c

Please sign in to comment.