Tracker NONE implementiert und kleine Verbesserungen

This commit is contained in:
Thomas Hooge 2025-09-20 09:04:48 +02:00
parent 84a99a747e
commit e5646b6f27
4 changed files with 91 additions and 51 deletions

View File

@ -99,7 +99,6 @@ def GGA(boatdata, msg):
def GLL(boatdata, msg):
# Position data: position fix, time of position fix, and status
# UTC of position ignored
if not msg.status == 'A':
return
lat_fac = 1 if msg.lat_dir == 'N' else -1
@ -341,7 +340,15 @@ def VBW(boatdata, msg):
print("-> VBW")
def VHW(boatdata, msg):
#print("-> VHW")
# Heading und Geschwindigkeit durch das Wasser
# Aktuelle Meßdaten von Sensoren
# msg.heading_true # degrees decimal
# msg.heading_magnetic degrees decimal
# print("-> VHW")
if msg.heading_true is not None:
boatdata.setValue("HDT", float(msg.heading_true))
if msg.heading_magnetic is not None:
boatdata.setValue("HDM", float(msg.heading_magnetic))
boatdata.setValue("STW", float(msg.water_speed_knots))
def VPW(boatdata, msg):
@ -350,19 +357,10 @@ def VPW(boatdata, msg):
pass
def VTG(boatdata, msg):
# Track made good and speed over ground
"""
(('True Track made good', 'true_track', <class 'float'>),
('True Track made good symbol', 'true_track_sym'),
('Magnetic Track made good', 'mag_track', <class 'decimal.Decimal'>),
('Magnetic Track symbol', 'mag_track_sym'),
('Speed over ground knots', 'spd_over_grnd_kts', <class 'decimal.Decimal'>),
('Speed over ground symbol', 'spd_over_grnd_kts_sym'),
('Speed over ground kmph', 'spd_over_grnd_kmph', <class 'float'>),
('Speed over ground kmph symbol', 'spd_over_grnd_kmph_sym'),
('FAA mode indicator', 'faa_mode'))
['', 'T', '', 'M', '0.117', 'N', '0.216', 'K', 'A']
$IIVTG,312.000000,T,,M,2.000000,N,3.704000,K,A*28
Track made good and speed over ground
Calculated from previous GPS positions
Only true track is used at the moment. magnetic is ignored
"""
if msg.faa_mode != 'A':
return

View File

@ -29,15 +29,19 @@ class RaceTracker(Page):
def __init__(self, pageno, cfg, appdata, boatdata):
super().__init__(pageno, cfg, appdata, boatdata)
self.ttype = self.app.track.ttype
self.bv_lat = boatdata.getRef("LAT")
self.bv_lon = boatdata.getRef("LON")
self.bv_sog = boatdata.getRef("SOG")
self.races = None
self.raceid = self.app.track.hero_raceid # Ausgewählte Regatta
if self.ttype == 'HERO':
self.raceid = self.app.track.hero_raceid # Ausgewählte Regatta
self.buttonlabel[1] = 'MODE'
self.buttonlabel[2] = 'INFO'
self.buttonlabel[5] = 'ABORT'
else:
self.raceid = None
self.menupos = 0
self.buttonlabel[1] = 'MODE'
self.buttonlabel[2] = 'INFO'
self.buttonlabel[5] = 'ABORT'
self.mode = 'N' # (N)ormal, (C)onfiguration, (M)itteilung
self.query_active = False
self.savebuttons = None
@ -76,6 +80,8 @@ class RaceTracker(Page):
self.sym_flag[f] = cairo.ImageSurface.create_from_png(flagfile)
def handle_key(self, buttonid):
if self.ttype == 'NONE':
return False
if self.query_active:
if buttonid == 2:
self.query_active = False
@ -158,6 +164,38 @@ class RaceTracker(Page):
return True
return False
def draw_none(self, ctx):
"""
TODO Funktion schreiben, die einen längeren Text mit
Absätzen auf dem Bildschirma ausgibt.
"""
x = 8
y = 50
ctx.select_font_face("Ubuntu", cairo.FontSlant.NORMAL, cairo.FontWeight.BOLD)
ctx.set_font_size(24)
ctx.move_to(x, y)
ctx.show_text("Tracker")
y += 25
ctx.set_font_size(16)
ctx.move_to(x, y)
ctx.show_text("Disabled by 'NONE in configuration'.")
y += 40
ctx.move_to(x, y)
ctx.show_text("Currently only tracker type 'HERO' is")
y += 20
ctx.move_to(x, y)
ctx.show_text("implemented. Please visit the Regatta")
y += 20
ctx.move_to(x, y)
ctx.show_text("Hero web page for detailed description.")
y += 40
ctx.move_to(x, y)
ctx.show_text("Additionally you should contact your local")
y += 20
ctx.move_to(x, y)
ctx.show_text("race officer to get configuration data.")
def draw_normal(self, ctx):
ctx.select_font_face("DSEG7 Classic")
@ -241,9 +279,6 @@ class RaceTracker(Page):
ctx.paint()
ctx.restore()
pos += 1
if self.query_active:
self.draw_query(ctx, "A B O R T R A C E", "Are you sure to abort the current race? This cannot be undone. Are you sure?")
def draw_config(self, ctx):
@ -399,8 +434,13 @@ class RaceTracker(Page):
def draw(self, ctx):
if self.mode == 'N':
self.draw_normal(ctx)
if self.ttype == 'NONE':
self.draw_none(ctx)
else:
self.draw_normal(ctx)
elif self.mode == 'C':
self.draw_config(ctx)
else:
self.draw_info(ctx)
if self.query_active:
self.draw_query(ctx, "A B O R T R A C E", "Are you sure to abort the current race? This cannot be undone. Are you sure?")

View File

@ -13,6 +13,7 @@ Layout
import cairo
from .page import Page
import nmea2000.boatdata
class TwoValues(Page):
@ -44,7 +45,7 @@ class TwoValues(Page):
ctx.show_text(self.ref2.unit)
# Meßwerte
if type(self.ref1 == 'BoatValueGeo'):
if type(self.ref1) == nmea2000.boatdata.BoatValueGeo:
ctx.select_font_face("Ubuntu", cairo.FontSlant.NORMAL, cairo.FontWeight.BOLD)
ctx.set_font_size(40)
ctx.move_to(140, 100)
@ -54,7 +55,7 @@ class TwoValues(Page):
ctx.move_to(180, 130)
ctx.show_text(self.ref1.format())
if type(self.ref2 == 'BoatValueGeo'):
if type(self.ref2) == nmea2000.boatdata.BoatValueGeo:
ctx.select_font_face("Ubuntu")
ctx.set_font_size(40)
ctx.move_to(140, 210)

View File

@ -65,38 +65,39 @@ class Tracker():
self.club = cfg['boat']['club']
self.team = cfg['boat']['team']
# Regatta Hero
self.hero_orgid = cfg['tracker']['username'] # Eingestellt in Gerätekonfiguration
self.hero_passcode = cfg['tracker']['password']
self.hero_host = cfg['tracker']['host']
self.hero_port = cfg['tracker']['port']
self.hero_viewerpass = None # Wird vom Server in "org" gesendet
if self.ttype == 'HERO':
# Regatta Hero
self.hero_orgid = cfg['tracker']['username'] # Eingestellt in Gerätekonfiguration
self.hero_passcode = cfg['tracker']['password']
self.hero_host = cfg['tracker']['host']
self.hero_port = cfg['tracker']['port']
self.hero_viewerpass = None # Wird vom Server in "org" gesendet
# Vorlage für Anfragen
self.http_payload_template = {
"orgid": self.hero_orgid,
"passcode": self.hero_passcode,
"raceid": "",
"replay": "live",
"replaytime": 0,
"updateType": "timerUpdate"
}
# Vorlage für Anfragen
self.http_payload_template = {
"orgid": self.hero_orgid,
"passcode": self.hero_passcode,
"raceid": "",
"replay": "live",
"replaytime": 0,
"updateType": "timerUpdate"
}
self.hero_raceid = None # Aktuell ausgewählte Regatta
self.hero_racephase = 0 # Bei Änderung Event auslösen
self.hero_raceid = None # Aktuell ausgewählte Regatta
self.hero_racephase = 0 # Bei Änderung Event auslösen
# MQTT
self.client = mqtt.Client()
self.client.on_connect = self.mqtt_on_connect
self.client.on_message = self.mqtt_on_message
# MQTT
self.client = mqtt.Client()
self.client.on_connect = self.mqtt_on_connect
self.client.on_message = self.mqtt_on_message
self.hero_orgstatus = None
self.hero_racestatus = None
self.hero_timedelta = 0 # Zeitdifferenz zum Server in sec
self.hero_givenup = False
self.hero_orgstatus = None
self.hero_racestatus = None
self.hero_timedelta = 0 # Zeitdifferenz zum Server in sec
self.hero_givenup = False
# Hole erste Daten vom Server
self.hero_query_org()
# Hole erste Daten vom Server
self.hero_query_org()
def is_server_active(self, hostname, port):
"""