-
Notifications
You must be signed in to change notification settings - Fork 0
/
analysis.go
137 lines (123 loc) · 4.64 KB
/
analysis.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
package model
import "github.com/wI2L/jsondiff"
type DbAnalysis struct {
ID int `json:"id"`
EventID int `json:"eventId"`
Data AnalysisDataGeneric `json:"data"`
}
// used for json marshaling to be compatible with frontend
type AnalysisDataGeneric map[string]interface{}
type AnalysisData struct {
CarInfo []AnalysisCarInfo `json:"carInfo"`
CarLaps []AnalysisCarLaps `json:"carLaps"`
CarPits []AnalysisCarPits `json:"carPits"`
CarStints []AnalysisCarStints `json:"carStints"`
CarComputeState []AnalysisCarComputeState `json:"carComputeState"`
RaceGraph []AnalysisRaceGraph `json:"raceGraph"`
Cars AnalysisMessage `json:"cars"` // latest StateData.Cars
Session AnalysisMessage `json:"session"` // latest StateData.Session
InfoMsgs []AnalysisMessage `json:"infoMsgs"` // all info messages
// carNum ordered by race position
RaceOrder []string `json:"raceOrder"`
}
type AnalysisDataWithPatches struct {
Cars AnalysisMessage `json:"cars"` // latest StateData.Cars
Session AnalysisMessage `json:"session"` // latest StateData.Session
// carNum ordered by race position
RaceOrder []string `json:"raceOrder"`
Patches jsondiff.Patch `json:"patches"`
RaceGraphPatches []AnalysisRaceGraphPatch `json:"raceGraphPatches"`
}
// holds the patch instructions for each car class raceGraph
type AnalysisRaceGraphPatch struct {
CarClass string `json:"carClass"`
Patches jsondiff.Patch `json:"patches"`
}
type AnalysisMessage struct {
Type MessageType `json:"type"`
Data any `json:"data"`
Timestamp float64 `json:"timestamp"`
}
// this is used to send combined analysis data and json-patch to the frontend
type AnalysisCombinedMessage struct {
Type MessageType `json:"type"` // should be MTAnalysisCombinedPatch
Payload AnalysisDataWithPatches `json:"payload"` // contains json-patch data
Timestamp float64 `json:"timestamp"`
}
type AnalysisCarInfo struct {
Name string `json:"name"`
CarNum string `json:"carNum"`
CarClass string `json:"carClass"`
Drivers []AnalysisDriverInfo `json:"drivers"`
}
type AnalysisDriverInfo struct {
DriverName string `json:"driverName"`
SeatTime []AnalysisSeatTime `json:"seatTime"`
}
type AnalysisCarLaps struct {
CarNum string `json:"carNum"`
Laps []AnalysisLapInfo `json:"laps"`
}
type AnalysisLapInfo struct {
LapNo int `json:"lapNo"`
LapTime float64 `json:"lapTime"`
}
type AnalysisSeatTime struct {
EnterCarTime float64 `json:"enterCarTime"` // unit: sessionTime
LeaveCarTime float64 `json:"leaveCarTime"` // unit: sessionTime
}
type AnalysisCarPits struct {
CarNum string `json:"carNum"`
Current AnalysisPitInfo `json:"current"`
History []AnalysisPitInfo `json:"history"`
}
type AnalysisPitInfo struct {
EnterTime float64 `json:"enterTime"` // unit: sessionTime
ExitTime float64 `json:"exitTime"` // unit: sessionTime
CarNum string `json:"carNum"`
LapEnter int `json:"lapEnter"`
LapExit int `json:"lapExit"`
LaneTime float64 `json:"laneTime"`
IsCurrentPitstop bool `json:"isCurrentPitstop"`
}
type AnalysisCarStints struct {
CarNum string `json:"carNum"`
Current AnalysisStintInfo `json:"current"`
History []AnalysisStintInfo `json:"history"`
}
type AnalysisStintInfo struct {
EnterTime float64 `json:"enterTime"` // unit: sessionTime
ExitTime float64 `json:"exitTime"` // unit: sessionTime
CarNum string `json:"carNum"`
LapEnter int `json:"lapEnter"`
LapExit int `json:"lapExit"`
StintTime float64 `json:"stintTime"`
NumLaps int `json:"numLaps"`
IsCurrentStint bool `json:"isCurrentStint"`
}
type AnalysisRaceGraph struct {
LapNo int `json:"lapNo"`
CarClass string `json:"carClass"`
Gaps []AnalysisGapInfo `json:"gaps"`
}
type AnalysisGapInfo struct {
CarNum string `json:"carNum"`
LapNo int `json:"lapNo"`
Gap float64 `json:"gap"`
Pos int `json:"pos"`
Pic int `json:"pic"`
}
type AnalysisCarComputeState struct {
CarNum string `json:"carNum"`
State string `json:"state"`
// sessionTime when state switched from PIT/RUN to OUT
OutEncountered float64 `json:"outEncountered"`
}
type DbTeamInEvent struct {
Name string `json:"name"`
CarNum string `json:"carNum"`
CarClass string `json:"carClass"`
Drivers []struct {
DriverName string `json:"driverName"`
}
}