Skip to content

Commit

Permalink
prepopulate session
Browse files Browse the repository at this point in the history
  • Loading branch information
durandom committed Nov 8, 2024
1 parent c97cad2 commit 2c13044
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 8 deletions.
10 changes: 6 additions & 4 deletions scripts/publish.sh
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,11 @@ fi
# create a random distance round track
DISTANCE_ROUND_TRACK=$(shuf -i 0-10000 -n 1)

TOPIC="/crewchief/durandom/1669233999/iRacing/sebring international/Ferrari 488 GT3 Evo 2021/Race"
TOPIC="crewchief/durandom/1669233999/iRacing/sebring international/Ferrari 488 GT3 Evo 2021/Race"
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}'

TOPIC="crewchief/goern/1689266594/Automobilista 2/Taruma:Taruma_Internacional/Formula Vee/Qualify"
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"}}'
# TOPIC="crewchief/goern/1689266594/Automobilista 2/Taruma:Taruma_Internacional/Formula Vee/Qualify"
# 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"}}'

# TOPIC="replay/crewchief/durandom/1689266594/Richard Burns Rally/Sardian Night/Renault Clio 16S Williams GrpA/Race"
# 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"}}'
Expand All @@ -42,7 +42,9 @@ else
TLS_CERT_OPTS=""
fi

mosquitto_pub -u crewchief -P crewchief \
USERNAME=crewchief
PASSWORD=crewchief
mosquitto_pub -u $USERNAME -P $PASSWORD \
-t "$TOPIC" \
-p $MQTT_PORT -h $MQTT_HOST $TLS_CERT_OPTS \
-i $CLIENT_ID -d \
Expand Down
4 changes: 3 additions & 1 deletion scripts/subscribe.sh
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,9 @@ else
TLS_CERT_OPTS=""
fi

mosquitto_sub -u crewchief -P crewchief \
USERNAME=crewchief
PASSWORD=crewchief
mosquitto_sub -u $USERNAME -P $PASSWORD \
-p $MQTT_PORT -h $MQTT_HOST $TLS_CERT_OPTS \
-i $CLIENT_ID -d \
-t $MQTT_TOPIC
10 changes: 7 additions & 3 deletions telemetry/pitcrew/session_saver.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,17 +40,21 @@ def fetch_sessions(self):
session.driver = Driver.objects.get(name=session.driver)
session.game = Game.objects.get(name=session.game_name)
session.session_type = SessionType.objects.get(type=session.session_type)
session.car = session.game.cars.get(name=session.car)
session.car.car_class = session.game.car_classes.get(name=session.car_class)
session.track = session.game.tracks.get(name=session.track)
session.car, created = session.game.cars.get_or_create(name=session.car)
session.car.car_class, created = session.game.car_classes.get_or_create(name=session.car_class)
session.track, created = session.game.tracks.get_or_create(name=session.track)
session.record = session.driver.sessions.filter(
session_id=session.session_id,
session_type=session.session_type,
game=session.game,
car=session.car,
track=session.track,
).first() or Session(
session_id=session.session_id,
session_type=session.session_type,
game=session.game,
car=session.car,
track=session.track,
start=session.start,
end=session.end,
)
Expand Down

0 comments on commit 2c13044

Please sign in to comment.