Improved time formatting and added new gps fix time

This commit is contained in:
Thomas Hooge 2025-09-11 15:07:06 +02:00
parent dab2d20006
commit 1df714aa37
1 changed files with 12 additions and 3 deletions

View File

@ -43,6 +43,7 @@ RPOS - Rudder Position, Auslenkung Hauptruder
SOG - Speed Over Ground, Geschwindigkeit über Grund SOG - Speed Over Ground, Geschwindigkeit über Grund
STW - Speed Through Water, Geschwindigkeit durch das Wasser STW - Speed Through Water, Geschwindigkeit durch das Wasser
SatInfo - Satellit Info, Anzahl der sichtbaren Satelliten SatInfo - Satellit Info, Anzahl der sichtbaren Satelliten
TSPOS - Timestamp des Position-Fixes (sie z.B. 0183/GLL)
TWD - True Wind Direction, wahre Windrichtung TWD - True Wind Direction, wahre Windrichtung
TWS - True Wind Speed, wahre Windgeschwindigkeit TWS - True Wind Speed, wahre Windgeschwindigkeit
TXT - Textnachricht / Alarm TXT - Textnachricht / Alarm
@ -211,13 +212,19 @@ class BoatValueDate(BoatValue):
return formatted return formatted
class BoatValueTime(BoatValue): class BoatValueTime(BoatValue):
# timefmt = hh:mm | hh:mm:ss # TODO Formatting!
def __init__(self, shortname, timezone='UTC'): def __init__(self, shortname, timezone='UTC'):
super().__init__(shortname) super().__init__(shortname)
self.tz = timezone self.tz = timezone
self.timefmt = 'hh:mm:' # TODO hh:mm:ss | ...? self.timefmt = 'hh:mm' # TODO hh:mm | hh:mm:ss | hh:mm:ss.000 | ... ?
def format(self): def format(self):
formatted = self.value if self.timefmt == 'hh:mm':
formatted = self.value.strftime("%H:%M")
elif self.timefmt == 'hh:mm:ss':
formatted = self.value.strftime("%H:%M:%S")
else:
# unbekanntes Format
formatted = self.value.strftime("%H%M%S")
return formatted return formatted
class BoatValueSpeed(BoatValue): class BoatValueSpeed(BoatValue):
@ -445,6 +452,7 @@ class BoatData():
self.lon = BoatValueGeo("LON", "lon", "deg") self.lon = BoatValueGeo("LON", "lon", "deg")
self.gpsd = BoatValueDate("GPSD", "ISO") self.gpsd = BoatValueDate("GPSD", "ISO")
self.gpst = BoatValueTime("GPST") self.gpst = BoatValueTime("GPST")
self.tspos = BoatValueTime("TSPOS")
self.sog = BoatValueSpeed("SOG", "kn") self.sog = BoatValueSpeed("SOG", "kn")
self.cog = BoatValueAngle("COG", "deg") self.cog = BoatValueAngle("COG", "deg")
self.hdm = BoatValueAngle("HDM", "deg") self.hdm = BoatValueAngle("HDM", "deg")
@ -534,6 +542,7 @@ class BoatData():
'ROT': self.rot, 'ROT': self.rot,
'SOG': self.sog, 'SOG': self.sog,
'STW': self.stw, 'STW': self.stw,
'TSPOS': self.tspos,
'TWD': self.twd, 'TWD': self.twd,
'TWS': self.tws, 'TWS': self.tws,
'TXT': self.txt, 'TXT': self.txt,