-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
6e98400
commit 44aee1d
Showing
4 changed files
with
157 additions
and
26 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
Car Status Packet | ||
|
||
This packet details car statuses for all the cars in the race. | ||
|
||
Frequency: Rate as specified in menus | ||
Size: 1058 bytes | ||
Version: 1 | ||
|
||
struct CarStatusData | ||
{ | ||
uint8 m_tractionControl; // Traction control - 0 = off, 1 = medium, 2 = full | ||
uint8 m_antiLockBrakes; // 0 (off) - 1 (on) | ||
uint8 m_fuelMix; // Fuel mix - 0 = lean, 1 = standard, 2 = rich, 3 = max | ||
uint8 m_frontBrakeBias; // Front brake bias (percentage) | ||
uint8 m_pitLimiterStatus; // Pit limiter status - 0 = off, 1 = on | ||
float m_fuelInTank; // Current fuel mass | ||
float m_fuelCapacity; // Fuel capacity | ||
float m_fuelRemainingLaps; // Fuel remaining in terms of laps (value on MFD) | ||
uint16 m_maxRPM; // Cars max RPM, point of rev limiter | ||
uint16 m_idleRPM; // Cars idle RPM | ||
uint8 m_maxGears; // Maximum number of gears | ||
uint8 m_drsAllowed; // 0 = not allowed, 1 = allowed | ||
uint16 m_drsActivationDistance; // 0 = DRS not available, non-zero - DRS will be available | ||
uint8 m_actualTyreCompound; // F1 Modern - 16 = C5, 17 = C4, 18 = C3, 19 = C2, 20 = C1 | ||
uint8 m_visualTyreCompound; // F1 visual (can be different from actual compound) | ||
uint8 m_tyresAgeLaps; // Age in laps of the current set of tyres | ||
int8 m_vehicleFiaFlags; // -1 = invalid/unknown, 0 = none, 1 = green | ||
float m_ersStoreEnergy; // ERS energy store in Joules | ||
uint8 m_ersDeployMode; // ERS deployment mode, 0 = none, 1 = medium | ||
float m_ersHarvestedThisLapMGUK; // ERS energy harvested this lap by MGU-K | ||
float m_ersHarvestedThisLapMGUH; // ERS energy harvested this lap by MGU-H | ||
float m_ersDeployedThisLap; // ERS energy deployed this lap | ||
uint8 m_networkPaused; // Whether the car is paused in a network game | ||
}; | ||
|
||
struct PacketCarStatusData | ||
{ | ||
PacketHeader m_header; // Header | ||
|
||
CarStatusData m_carStatusData[22]; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
import {F1Parser} from '../../f1.parser'; | ||
|
||
export class CarStatusDataParser extends F1Parser { | ||
constructor() { | ||
super(); | ||
this | ||
/*uint8*/ .uint8('m_tractionControl') | ||
/*uint8*/ .uint8('m_antiLockBrakes') | ||
/*uint8*/ .uint8('m_fuelMix') | ||
/*uint8*/ .uint8('m_frontBrakeBias') | ||
/*uint8*/ .uint8('m_pitLimiterStatus') | ||
/*float*/ .floatle('m_fuelInTank') | ||
/*float*/ .floatle('m_fuelCapacity') | ||
/*float*/ .floatle('m_fuelRemainingLaps') | ||
/*uint16*/ .uint16le('m_maxRPM') | ||
/*uint16*/ .uint16le('m_idleRPM') | ||
/*uint8*/ .uint8('m_maxGears') | ||
/*uint8*/ .uint8('m_drsAllowed') | ||
/*uint16*/ .uint16le('m_drsActivationDistance') | ||
/*uint8*/ .uint8('m_actualTyreCompound') | ||
/*uint8*/ .uint8('m_visualTyreCompound') | ||
/*uint8*/ .uint8('m_tyresAgeLaps') | ||
/*int8*/ .int8('m_vehicleFiaFlags') | ||
/*float*/ .floatle('m_ersStoreEnergy') | ||
/*uint8*/ .uint8('m_ersDeployMode') | ||
/*float*/ .floatle('m_ersHarvestedThisLapMGUK') | ||
/*float*/ .floatle('m_ersHarvestedThisLapMGUH') | ||
/*float*/ .floatle('m_ersDeployedThisLap') | ||
/*uint8*/ .uint8('m_networkPaused'); | ||
} | ||
} | ||
|
||
import {PacketHeaderParser} from '../../PacketHeader/parser'; | ||
import {PacketCarStatusData} from '../types'; | ||
|
||
export class PacketCarStatusDataParser extends F1Parser { | ||
data: PacketCarStatusData; | ||
|
||
constructor(buffer: Buffer, bigintEnabled: boolean) { | ||
super(); | ||
|
||
this.endianess('little') | ||
.nest('m_header', { | ||
type: new PacketHeaderParser(bigintEnabled), | ||
}) | ||
.array('m_carStatusData', { | ||
length: 22, | ||
type: new CarStatusDataParser(), | ||
}); | ||
|
||
this.data = this.fromBuffer(buffer) as PacketCarStatusData; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
import {PacketHeader} from '@Type/PacketHeader'; | ||
|
||
export interface CarStatusData { | ||
/*uint8*/ m_tractionControl: number; | ||
/*uint8*/ m_antiLockBrakes: number; | ||
/*uint8*/ m_fuelMix: number; | ||
/*uint8*/ m_frontBrakeBias: number; | ||
/*uint8*/ m_pitLimiterStatus: number; | ||
/*float*/ m_fuelInTank: number; | ||
/*float*/ m_fuelCapacity: number; | ||
/*float*/ m_fuelRemainingLaps: number; | ||
/*uint16*/ m_maxRPM: number; | ||
/*uint16*/ m_idleRPM: number; | ||
/*uint8*/ m_maxGears: number; | ||
/*uint8*/ m_drsAllowed: number; | ||
/*uint16*/ m_drsActivationDistance: number; | ||
/*uint8*/ m_actualTyreCompound: number; | ||
/*uint8*/ m_visualTyreCompound: number; | ||
/*uint8*/ m_tyresAgeLaps: number; | ||
/*int8*/ m_vehicleFiaFlags: number; | ||
/*float*/ m_ersStoreEnergy: number; | ||
/*uint8*/ m_ersDeployMode: number; | ||
/*float*/ m_ersHarvestedThisLapMGUK: number; | ||
/*float*/ m_ersHarvestedThisLapMGUH: number; | ||
/*float*/ m_ersDeployedThisLap: number; | ||
/*uint8*/ m_networkPaused: number; | ||
} | ||
|
||
export interface PacketCarStatusData { | ||
m_header: PacketHeader; | ||
m_carStatusData: CarStatusData[]; | ||
} |