Tracker GUI Verbesserungen

This commit is contained in:
2025-09-16 21:05:34 +02:00
parent fc87a5959d
commit d3a984075e
2 changed files with 108 additions and 35 deletions

View File

@@ -47,6 +47,7 @@ class Tracker():
self.hero_orgstatus = None
self.hero_racestatus = None
self.hero_raceid = None # Aktuelle Regatta
self.hero_timedelta = 0 # Zeitdifferenz zum Server in sec
# TODO Wirklich alles im Tracker oder ist einiges generisch?
self.boatid = None
@@ -106,7 +107,6 @@ class Tracker():
if not r['hiderace']:
races.append(r['raceid'])
return races
#return [r for r in self.hero_orgstatus['races']]
def mqtt_on_connect(self, client, userdata, flags, rc):
print(f"MQTT connected with result code {rc}")
@@ -138,6 +138,14 @@ class Tracker():
if msg.topic == "regattahero/orgstatus/thomas":
# kommt alle 10s
self.hero_orgstatus = json.loads(msg.payload)
# Zeitdifferenz Client/Server ermitteln für ggf. spätere Warnung
server_ts = self.appdata.track.hero_orgstatus['timestamp'].split(':')
sec1 = int(server_ts[0]) * 3600 + int(server_ts[1]) * 60 + int(server_ts[2])
ts = time.localtime()
sec2 = ts.tm_hour * 3600 + ts.tm_min * 60 + ts.tm_sec
self.hero_timedelta = abs(sec1 - sec2)
if self.hero_orgstatus['allLogout']:
print("All logout received!")
client.disconnect()
@@ -145,17 +153,13 @@ class Tracker():
return
if self.hero_orgstatus['message']:
# TODO Alarm-Funktion nutzen?
print("Nachricht der Wettfahrtkeitung:")
print(self.hero_orgstatus['message'])
#print(self.hero_orgstatus)
pass
elif msg.topic.startswith("regattahero/racestatus/thomas"):
# kommt alle 1s
# dem Topic angehängt ist noch die raceid
payload = json.loads(msg.payload)
self.hero_racestatus = payload['racestatus']
print(self.hero_racestatus['flags'])
#print(self.hero_racestatus)
"""
time: negativ: Zeit vor dem Start, positiv: Zeit nach dem Start
in Sekunden
@@ -195,10 +199,10 @@ class Tracker():
payload['gps']['lon'] = round(lon, 5)
payload['gps']['speed'] = sog
payload['gps']['timestamp'] = time.strftime("%Y-%m-%dT%H:%M:%S.000Z", time.gmtime())
print(payload)
client.publish(topic, json.dumps(payload))
else:
print("No GPS data available. Nothing published!")
#print("No GPS data available. Nothing published!")
pass
def mqtt_tracker(self, cfg, boat, appdata, boatdata):
print("MQTT tracker enabled")
@@ -251,6 +255,13 @@ class Tracker():
"boatname": boat['name'],
"isTracking": True,
"hasGivenUp": False
},
"device": { # optional
"os" : "linux",
"osVer" : "OBP60v 0.1",
"isIOS" : False,
"isAndroid" : False,
"isTracker" : True
}
}