86 lines
2.2 KiB
Python
86 lines
2.2 KiB
Python
from __future__ import annotations
|
|
|
|
from dataclasses import dataclass, field
|
|
from typing import Any
|
|
|
|
|
|
@dataclass
|
|
class TelemetryData:
|
|
game_id: str = ""
|
|
timestamp: float = 0.0
|
|
|
|
speed_kmh: float = 0.0
|
|
speed_mph: float = 0.0
|
|
|
|
rpm: float = 0.0
|
|
max_rpm: float = 8000.0
|
|
|
|
gear: int = 0
|
|
|
|
throttle: float = 0.0
|
|
brake: float = 0.0
|
|
clutch: float = 0.0
|
|
handbrake: float = 0.0
|
|
|
|
steering: float = 0.0
|
|
|
|
lap_time: float = 0.0
|
|
best_lap: float = 0.0
|
|
last_lap: float = 0.0
|
|
lap_number: int = 0
|
|
|
|
position_x: float = 0.0
|
|
position_y: float = 0.0
|
|
position_z: float = 0.0
|
|
|
|
acceleration_x: float = 0.0
|
|
acceleration_y: float = 0.0
|
|
acceleration_z: float = 0.0
|
|
|
|
engine_temp: float = 0.0
|
|
oil_temp: float = 0.0
|
|
fuel: float = 0.0
|
|
|
|
boost: float = 0.0
|
|
horsepower: float = 0.0
|
|
torque: float = 0.0
|
|
|
|
car_name: str = ""
|
|
car_class: str = ""
|
|
|
|
raw: dict[str, Any] = field(default_factory=dict)
|
|
|
|
def to_dict(self) -> dict[str, Any]:
|
|
return {
|
|
"game_id": self.game_id,
|
|
"timestamp": self.timestamp,
|
|
"speed_kmh": self.speed_kmh,
|
|
"speed_mph": self.speed_mph,
|
|
"rpm": self.rpm,
|
|
"max_rpm": self.max_rpm,
|
|
"gear": self.gear,
|
|
"throttle": self.throttle,
|
|
"brake": self.brake,
|
|
"clutch": self.clutch,
|
|
"handbrake": self.handbrake,
|
|
"steering": self.steering,
|
|
"lap_time": self.lap_time,
|
|
"best_lap": self.best_lap,
|
|
"last_lap": self.last_lap,
|
|
"lap_number": self.lap_number,
|
|
"position_x": self.position_x,
|
|
"position_y": self.position_y,
|
|
"position_z": self.position_z,
|
|
"acceleration_x": self.acceleration_x,
|
|
"acceleration_y": self.acceleration_y,
|
|
"acceleration_z": self.acceleration_z,
|
|
"engine_temp": self.engine_temp,
|
|
"oil_temp": self.oil_temp,
|
|
"fuel": self.fuel,
|
|
"boost": self.boost,
|
|
"horsepower": self.horsepower,
|
|
"torque": self.torque,
|
|
"car_name": self.car_name,
|
|
"car_class": self.car_class,
|
|
}
|