Lokaler Tracker funktionsfähig. Bugfixes.

This commit is contained in:
2025-09-22 14:27:05 +02:00
parent f0ebdd0201
commit e7a96390f2
6 changed files with 150 additions and 44 deletions

View File

@@ -48,6 +48,9 @@ class Tracker():
raise TypeError("Invalid tracker type: '{}'. Only supported: {}".format(cfg['tracker']['type'], ','.join(validtypes)))
self.ttype = cfg['tracker']['type']
self.local_lfdno = 0
self.local_dt = cfg['tracker']['interval'] # Eintrag alle <n> Sekunden schreiben
self.trace = cfg['tracker']['trace'] # Debugging
self.trace_fh = None # File Handle der Tracedatei
@@ -127,9 +130,11 @@ class Tracker():
def set_active(self, newval):
self.activated = newval
def local_tracker(self, cfg, boat, appdata, boatdata):
# TODO / WIP
def local_tracker(self, cfg, appdata, boatdata):
self.log.info("Local tracker enabled")
if not os.path.exists(cfg['histpath']):
os.makedirs(cfg['histpath'])
self.log.info(f"History path created: '{cfg['histpath']}'")
# Zugriff auf Boatdata: Referenzen für leichten schnellen Zugriff
bv_lat = boatdata.getRef("LAT")
@@ -137,20 +142,25 @@ class Tracker():
bv_hdop = boatdata.getRef("HDOP")
bv_tspos = boatdata.getRef("TSPOS")
self.local_dt = 15
self.local_lfdno = 0
trackerfile = "/tmp/test.log" # TODO Konfiguration lesen
trackerfile = os.path.join(cfg['histpath'], "localtrack.log")
fh = open(trackerfile, 'a+')
n = 0
while not appdata.shutdown:
time.sleep(self.local_dt)
time.sleep(1)
if not self.activated:
continue
n += 1
if n % self.local_dt != 0:
continue
self.local_lfdno += 1
data = f"{},{},{},{}\n".format(
data = "{},{}Z,{},{},{}\n".format(
self.local_lfdno,
bv_tspos.getValueRaw(),
bv_lat.getValueRaw(),
bv_lon.getValueRaw(),
bv_hdop.getValueRaw())
bv_tspos.getValue(),
bv_lat.getValue(),
bv_lon.getValue(),
bv_hdop.getValue())
fh.write(data)
fh.flush()
fh.close()
def set_hero_raceid(self, newraceid):