SVappsLAB.iRacingTelemetrySDK
0.4.8
Prefix Reserved
See the version list below for details.
dotnet add package SVappsLAB.iRacingTelemetrySDK --version 0.4.8
NuGet\Install-Package SVappsLAB.iRacingTelemetrySDK -Version 0.4.8
<PackageReference Include="SVappsLAB.iRacingTelemetrySDK" Version="0.4.8" />
paket add SVappsLAB.iRacingTelemetrySDK --version 0.4.8
#r "nuget: SVappsLAB.iRacingTelemetrySDK, 0.4.8"
// Install SVappsLAB.iRacingTelemetrySDK as a Cake Addin #addin nuget:?package=SVappsLAB.iRacingTelemetrySDK&version=0.4.8 // Install SVappsLAB.iRacingTelemetrySDK as a Cake Tool #tool nuget:?package=SVappsLAB.iRacingTelemetrySDK&version=0.4.8
iRacingTelemetrySDK
iRacingTelemetrySDK is a .Net SDK tailored for C# developers aiming to incorporate telemetry data from the iRacing simulator into their software projects.
Features
Live Telemetry Data: facilitates easy retrieval of telemetry information generated during iRacing sessions, including vehicle speed, engine RPM, tire temperatures, and more.
Playback of saved IBT Telemetry Data: In addition to live data access, the SDK can read previously saved iRacing IBT files and play them back as if it were live data, using the same API. This allows you to analyze and process historical telemetry data, the same way you would with live data.
Optimized Performance: The SDK uses techniques such as asynchronous Task's, ref struct's and ReadOnlySpan's to minimize memory allocations and maximize performance. When processing IBT files for example, the SDK is able to process 1 hour of saved telemetry data in under 1/2 second. A rate of over 300,000 telemetry records/sec.
Strongly Typed Telemetry Data: Source Generation is used to create a strongly typed
TelemetryData
struct, with the iRacing variables you choose.
Getting Started
To incorporate iRacingTelemetrySDK into your projects, follow these steps:
Install the Package: Add the iRacingTelemetrySDK NuGet package to your project using your preferred package manager.
dotnet add package SVappsLAB.iRacingTelemetrySDK
Add the RequiredTelemetryVars attribute to the main class of your project
The attribute takes an array of strings. The string values, are the name of the iRacing variables you want to use in your program.
// these are the telemetry variables we want to track [RequiredTelemetryVars(["gear", "isOnTrackCar", "rpm", "speed"])] internal class Program { ... }
A source generator will be leveraged to create a new .Net
TelemetryData
type you can use in your code. For the attribute above, the created type will look likepublic record struct TelemetryData(Int32 Gear,Boolean IsOnTrackCar,Single RPM,Single Speed);
Create an instance of the TelemetryClient
The logger is required, but the IBT file is optional.
ILogger logger; string ibtFile; using var tc = TelemetryClient<TelemetryData>.Create(logger, ibtFile);
If the IBT file is provided, telemetry data will be read from the file.<br/> If no IBT file is provided, the SDK will connect to the running instance of IRacing.
Add an event handler
The event handler will be called with the latest telemetry data.
// event handler void OnTelemetryUpdate(object? _sender, TelemetryData e) { // do something with the telemetry data logger.LogInformation("gear: {gear}, rpm: {rpm}, speed: {speed}", e.Gear, e.RPM, e.Speed); }
Monitor for telemetry data changes
Once monitoring is initiated, the events will fire and your event handlers will be called.<br> Monitoring is stopped, when the
CancellationToken
is cancelled, or the when the end-of-file is reached when processing a IBT file.CancellationTokenSource cts = new new CancellationTokenSource(); // start monitoring the telemetry await tc.Monitor(cts.Token);
Samples
See ./Samples/README.md for a list of example projects using the SDK
Event Sequence Diagram
The following shows how the events are
sequenceDiagram
participant C as Client
create participant S as SDK
C--)S: created
C->>S: startup()
create participant R as monitoring telemetry
S--)R:
note over R: events start to fire
activate R
R-->>C: EVENT: "connected"
loop sessionInfo
note right of S: when sessionInfo changes
R-->>C: EVENT: "sessionInfo"
end
loop telemetry
note right of S: when telemetry updates
R-->>C: EVENT: "telemetry"
end
R-->C: EVENT: "disconnected"
C->>S: shutdown()
deactivate R
note over R: events stop
destroy R
R--)S:
destroy S
C--)S: destroyed
License
This project is licensed under the Apache License. Refer to the LICENSE file for details.
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net8.0 is compatible. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. |
-
net8.0
- Microsoft.Extensions.Logging.Abstractions (>= 8.0.1)
- YamlDotNet (>= 15.3.0)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.
Version | Downloads | Last updated | |
---|---|---|---|
0.6.7 | 80 | 10/13/2024 | |
0.6.5 | 79 | 9/28/2024 | |
0.6.3 | 100 | 9/17/2024 | |
0.6.2 | 109 | 9/14/2024 | |
0.6.1 | 104 | 9/9/2024 | |
0.6.0 | 110 | 8/27/2024 | |
0.5.0 | 128 | 8/17/2024 | |
0.4.8 | 100 | 7/20/2024 | |
0.1.7-beta | 109 | 7/20/2024 | |
0.1.6-beta | 103 | 7/20/2024 |