Skip to content

Commit 2c13044

Browse files
committed
prepopulate session
1 parent c97cad2 commit 2c13044

File tree

3 files changed

+16
-8
lines changed

3 files changed

+16
-8
lines changed

scripts/publish.sh

+6-4
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,11 @@ fi
1111
# create a random distance round track
1212
DISTANCE_ROUND_TRACK=$(shuf -i 0-10000 -n 1)
1313

14-
TOPIC="/crewchief/durandom/1669233999/iRacing/sebring international/Ferrari 488 GT3 Evo 2021/Race"
14+
TOPIC="crewchief/durandom/1669233999/iRacing/sebring international/Ferrari 488 GT3 Evo 2021/Race"
1515
T='{"CarModel": "Ferrari 488 GT3 Evo 2020", "GameName": "iRacing", "SessionId": "1669233672", "SessionTypeName": "Race", "TrackCode": "sebring international", "Brake": 0.0, "Clutch": 1.0, "CurrentLap": 1.0, "CurrentLapTime": 0.0, "DistanceRoundTrack": 5564.84961, "Gear": 3.0, "Handbrake": 0.0, "Rpms": 0.0, "SpeedMs": 46.2075653, "SteeringAngle": -0.232568219, "Throttle": 0.995530248}'
1616

17-
TOPIC="crewchief/goern/1689266594/Automobilista 2/Taruma:Taruma_Internacional/Formula Vee/Qualify"
18-
T='{"time": '$TIMESTAMP', "telemetry": {"Clutch":0.0,"Brake":1.0,"Throttle":0.0,"Handbrake":0.0,"SteeringAngle":-0.0103,"Rpms":0.0,"Gear":0,"SpeedMs":0.0,"DistanceRoundTrack":'$DISTANCE_ROUND_TRACK',"WorldPosition_x":37.7886124,"WorldPosition_y":1.904185,"WorldPosition_z":-204.916718,"CurrentLap":1,"CurrentLapTime":-3.0,"LapTimePrevious":-1.0,"CurrentLapIsValid":false,"PreviousLapWasValid":true,"CarClass":"F_VEE"}}'
17+
# TOPIC="crewchief/goern/1689266594/Automobilista 2/Taruma:Taruma_Internacional/Formula Vee/Qualify"
18+
# T='{"time": '$TIMESTAMP', "telemetry": {"Clutch":0.0,"Brake":1.0,"Throttle":0.0,"Handbrake":0.0,"SteeringAngle":-0.0103,"Rpms":0.0,"Gear":0,"SpeedMs":0.0,"DistanceRoundTrack":'$DISTANCE_ROUND_TRACK',"WorldPosition_x":37.7886124,"WorldPosition_y":1.904185,"WorldPosition_z":-204.916718,"CurrentLap":1,"CurrentLapTime":-3.0,"LapTimePrevious":-1.0,"CurrentLapIsValid":false,"PreviousLapWasValid":true,"CarClass":"F_VEE"}}'
1919

2020
# TOPIC="replay/crewchief/durandom/1689266594/Richard Burns Rally/Sardian Night/Renault Clio 16S Williams GrpA/Race"
2121
# T='{"time": '$TIMESTAMP', "telemetry": {"Clutch":0.0,"Brake":1.0,"Throttle":0.0,"Handbrake":0.0,"SteeringAngle":-0.0103,"Rpms":0.0,"Gear":0,"SpeedMs":0.0,"DistanceRoundTrack":'$DISTANCE_ROUND_TRACK',"WorldPosition_x":37.7886124,"WorldPosition_y":1.904185,"WorldPosition_z":-204.916718,"CurrentLap":1,"CurrentLapTime":-3.0,"LapTimePrevious":-1.0,"CurrentLapIsValid":false,"PreviousLapWasValid":true,"CarClass":"F_VEE"}}'
@@ -42,7 +42,9 @@ else
4242
TLS_CERT_OPTS=""
4343
fi
4444

45-
mosquitto_pub -u crewchief -P crewchief \
45+
USERNAME=crewchief
46+
PASSWORD=crewchief
47+
mosquitto_pub -u $USERNAME -P $PASSWORD \
4648
-t "$TOPIC" \
4749
-p $MQTT_PORT -h $MQTT_HOST $TLS_CERT_OPTS \
4850
-i $CLIENT_ID -d \

scripts/subscribe.sh

+3-1
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,9 @@ else
2525
TLS_CERT_OPTS=""
2626
fi
2727

28-
mosquitto_sub -u crewchief -P crewchief \
28+
USERNAME=crewchief
29+
PASSWORD=crewchief
30+
mosquitto_sub -u $USERNAME -P $PASSWORD \
2931
-p $MQTT_PORT -h $MQTT_HOST $TLS_CERT_OPTS \
3032
-i $CLIENT_ID -d \
3133
-t $MQTT_TOPIC

telemetry/pitcrew/session_saver.py

+7-3
Original file line numberDiff line numberDiff line change
@@ -40,17 +40,21 @@ def fetch_sessions(self):
4040
session.driver = Driver.objects.get(name=session.driver)
4141
session.game = Game.objects.get(name=session.game_name)
4242
session.session_type = SessionType.objects.get(type=session.session_type)
43-
session.car = session.game.cars.get(name=session.car)
44-
session.car.car_class = session.game.car_classes.get(name=session.car_class)
45-
session.track = session.game.tracks.get(name=session.track)
43+
session.car, created = session.game.cars.get_or_create(name=session.car)
44+
session.car.car_class, created = session.game.car_classes.get_or_create(name=session.car_class)
45+
session.track, created = session.game.tracks.get_or_create(name=session.track)
4646
session.record = session.driver.sessions.filter(
4747
session_id=session.session_id,
4848
session_type=session.session_type,
4949
game=session.game,
50+
car=session.car,
51+
track=session.track,
5052
).first() or Session(
5153
session_id=session.session_id,
5254
session_type=session.session_type,
5355
game=session.game,
56+
car=session.car,
57+
track=session.track,
5458
start=session.start,
5559
end=session.end,
5660
)

0 commit comments

Comments
 (0)