Skip to content

Commit

Permalink
Add a ton of new event triggers
Browse files Browse the repository at this point in the history
  • Loading branch information
JustJoostNL committed Apr 30, 2024
1 parent d4dad48 commit 1a5d5ea
Show file tree
Hide file tree
Showing 4 changed files with 178 additions and 3 deletions.
2 changes: 2 additions & 0 deletions src/main/lightController/integrations/rgbToColorTemp.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,5 +26,7 @@ export function rgbToColorTemp(
return (minMiReds + maxMiReds) / 2;
case EventType.SessionEnded:
return 0;
default:
return 0;
}
}
121 changes: 121 additions & 0 deletions src/main/multiviewer/api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -210,6 +210,14 @@ function checkForNewEventsInRaceControlMessages(
) {
if (!RaceControlMessages || !RaceControlMessages.Messages) return;

if (
processedRaceControlMessages.Messages.length === 0 &&
RaceControlMessages.Messages.length > 0
) {
processedRaceControlMessages = RaceControlMessages;
return;
}

if (
RaceControlMessages.Messages.length ===
processedRaceControlMessages.Messages.length
Expand Down Expand Up @@ -250,6 +258,119 @@ function checkForNewEventsInRaceControlMessages(
if (lastMessage.SubCategory === RaceControlMessageSubCategory.TimePenalty) {
newEventHandler(EventType.TimePenalty);
}
if (
lastMessage.SubCategory ===
RaceControlMessageSubCategory.SessionStartDelayed
) {
newEventHandler(EventType.SessionStartDelayed);
}
if (
lastMessage.SubCategory ===
RaceControlMessageSubCategory.SessionDurationChanged
) {
newEventHandler(EventType.SessionDurationChanged);
}
if (
lastMessage.SubCategory === RaceControlMessageSubCategory.LapTimeDeleted
) {
newEventHandler(EventType.LapTimeDeleted);
}
if (
lastMessage.SubCategory === RaceControlMessageSubCategory.LapTimeReinstated
) {
newEventHandler(EventType.LapTimeReinstated);
}
if (
lastMessage.SubCategory ===
RaceControlMessageSubCategory.LappedCarsMayOvertake
) {
newEventHandler(EventType.LappedCarsMayOvertake);
}
if (
lastMessage.SubCategory ===
RaceControlMessageSubCategory.LappedCarsMayNotOvertake
) {
newEventHandler(EventType.LappedCarsMayNotOvertake);
}
if (
lastMessage.SubCategory ===
RaceControlMessageSubCategory.NormalGripConditions
) {
newEventHandler(EventType.NormalGripConditions);
}
if (
lastMessage.SubCategory ===
RaceControlMessageSubCategory.OffTrackAndContinued
) {
newEventHandler(EventType.OffTrackAndContinued);
}
if (
lastMessage.SubCategory === RaceControlMessageSubCategory.SpunAndContinued
) {
newEventHandler(EventType.SpunAndContinued);
}
if (lastMessage.SubCategory === RaceControlMessageSubCategory.MissedApex) {
newEventHandler(EventType.MissedApex);
}
if (lastMessage.SubCategory === RaceControlMessageSubCategory.CarStopped) {
newEventHandler(EventType.CarStopped);
}
if (lastMessage.SubCategory === RaceControlMessageSubCategory.MedicalCar) {
newEventHandler(EventType.MedicalCar);
}
if (lastMessage.SubCategory === RaceControlMessageSubCategory.IncidentNoted) {
newEventHandler(EventType.IncidentNoted);
}
if (
lastMessage.SubCategory ===
RaceControlMessageSubCategory.IncidentUnderInvestigation
) {
newEventHandler(EventType.IncidentUnderInvestigation);
}
if (
lastMessage.SubCategory ===
RaceControlMessageSubCategory.IncidentInvestigationAfterSession
) {
newEventHandler(EventType.IncidentInvestigationAfterSession);
}
if (
lastMessage.SubCategory ===
RaceControlMessageSubCategory.IncidentNoFurtherAction
) {
newEventHandler(EventType.IncidentNoFurtherAction);
}
if (
lastMessage.SubCategory ===
RaceControlMessageSubCategory.IncidentNoFurtherInvestigation
) {
newEventHandler(EventType.IncidentNoFurtherInvestigation);
}
if (lastMessage.SubCategory === RaceControlMessageSubCategory.StopGoPenalty) {
newEventHandler(EventType.StopGoPenalty);
}
if (
lastMessage.SubCategory ===
RaceControlMessageSubCategory.TrackSurfaceSlippery
) {
newEventHandler(EventType.TrackSurfaceSlippery);
}
if (
lastMessage.SubCategory === RaceControlMessageSubCategory.LowGripConditions
) {
newEventHandler(EventType.LowGripConditions);
}
if (
lastMessage.SubCategory ===
RaceControlMessageSubCategory.SessionStartAborted
) {
newEventHandler(EventType.SessionStartAborted);
}
if (
lastMessage.SubCategory ===
RaceControlMessageSubCategory.DriveThroughPenalty
) {
newEventHandler(EventType.DriveThroughPenalty);
}

processedRaceControlMessages = RaceControlMessages;
}
Expand Down
48 changes: 46 additions & 2 deletions src/shared/config/config_types.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
export const eventTypeReadableMap = {
export const eventTypeReadableMap: Record<EventType, string> = {
GreenFlag: "Green Flag",
YellowFlag: "Yellow Flag",
RedFlag: "Red Flag",
Expand All @@ -15,6 +15,28 @@ export const eventTypeReadableMap = {
PitExitOpen: "Pit Exit Open",
PitEntryClosed: "Pit Entry Closed",
TimePenalty: "Time Penalty",
SessionStartDelayed: "Session Start Delayed",
SessionDurationChanged: "Session Duration Changed",
LapTimeDeleted: "Lap Time Deleted",
LapTimeReinstated: "Lap Time Reinstated",
LappedCarsMayOvertake: "Lapped Cars May Overtake",
LappedCarsMayNotOvertake: "Lapped Cars May Not Overtake",
NormalGripConditions: "Normal Grip Conditions",
OffTrackAndContinued: "Off Track And Continued",
SpunAndContinued: "Spun And Continued",
MissedApex: "Missed Apex",
CarStopped: "Car Stopped",
MedicalCar: "Medical Car",
IncidentNoted: "Incident Noted",
IncidentUnderInvestigation: "Incident Under Investigation",
IncidentInvestigationAfterSession: "Incident Investigation After Session",
IncidentNoFurtherAction: "Incident No Further Action",
IncidentNoFurtherInvestigation: "Incident No Further Investigation",
StopGoPenalty: "Stop Go Penalty",
TrackSurfaceSlippery: "Track Surface Slippery",
LowGripConditions: "Low Grip Conditions",
SessionStartAborted: "Session Start Aborted",
DriveThroughPenalty: "Drive Through Penalty",
};

export enum EventType {
Expand All @@ -34,9 +56,31 @@ export enum EventType {
PitExitOpen = "PitExitOpen",
PitEntryClosed = "PitEntryClosed",
TimePenalty = "TimePenalty",
SessionStartDelayed = "SessionStartDelayed",
SessionDurationChanged = "SessionDurationChanged",
LapTimeDeleted = "LapTimeDeleted",
LapTimeReinstated = "LapTimeReinstated",
LappedCarsMayOvertake = "LappedCarsMayOvertake",
LappedCarsMayNotOvertake = "LappedCarsMayNotOvertake",
NormalGripConditions = "NormalGripConditions",
OffTrackAndContinued = "OffTrackAndContinued",
SpunAndContinued = "SpunAndContinued",
MissedApex = "MissedApex",
CarStopped = "CarStopped",
MedicalCar = "MedicalCar",
IncidentNoted = "IncidentNoted",
IncidentUnderInvestigation = "IncidentUnderInvestigation",
IncidentInvestigationAfterSession = "IncidentInvestigationAfterSession",
IncidentNoFurtherAction = "IncidentNoFurtherAction",
IncidentNoFurtherInvestigation = "IncidentNoFurtherInvestigation",
StopGoPenalty = "StopGoPenalty",
TrackSurfaceSlippery = "TrackSurfaceSlippery",
LowGripConditions = "LowGripConditions",
SessionStartAborted = "SessionStartAborted",
DriveThroughPenalty = "DriveThroughPenalty",
}

export const actionTypeReadableMap = {
export const actionTypeReadableMap: Record<ActionType, string> = {
On: "On",
Off: "Off",
Delay: "Delay",
Expand Down
10 changes: 9 additions & 1 deletion src/shared/multiviewer/graphql_api_types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ export interface IRealtimeTimingState {
Heartbeat: IHeartbeat;
LapCount: ILapCount | undefined;
LapSeries: ILapSeries | undefined;
LapTimeSeries: any;
LapTimeSeries: ILapTimeSeries | undefined;
PitLaneTimeCollection: IPitLaneTimeCollection | undefined;
Position: IPosition;
RaceControlMessages: IRaceControlMessages;
Expand Down Expand Up @@ -237,6 +237,14 @@ export enum RaceControlMessageSubCategory {
SessionResume = "SessionResume",
Correction = "Correction",
RecoveryVehicle = "RecoveryVehicle",
SessionTemperatures = "SessionTemperatures",
PaddingMaterial = "PaddingMaterial",
AwningsAllowed = "AwningsAllowed",
MandatoryTireCompound = "MandatoryTireCompound",
RestartOrder = "RestartOrder",
NoPracticeStarts = "NoPracticeStarts",
SessionStartAborted = "SessionStartAborted",
DriveThroughPenalty = "DriveThroughPenalty",
}

export interface IRaceControlMessage {
Expand Down

0 comments on commit 1a5d5ea

Please sign in to comment.