Tracker NONE implementiert und kleine Verbesserungen
This commit is contained in:
parent
84a99a747e
commit
e5646b6f27
26
nmea0183.py
26
nmea0183.py
|
@ -99,7 +99,6 @@ def GGA(boatdata, msg):
|
||||||
|
|
||||||
def GLL(boatdata, msg):
|
def GLL(boatdata, msg):
|
||||||
# Position data: position fix, time of position fix, and status
|
# Position data: position fix, time of position fix, and status
|
||||||
# UTC of position ignored
|
|
||||||
if not msg.status == 'A':
|
if not msg.status == 'A':
|
||||||
return
|
return
|
||||||
lat_fac = 1 if msg.lat_dir == 'N' else -1
|
lat_fac = 1 if msg.lat_dir == 'N' else -1
|
||||||
|
@ -341,7 +340,15 @@ def VBW(boatdata, msg):
|
||||||
print("-> VBW")
|
print("-> VBW")
|
||||||
|
|
||||||
def VHW(boatdata, msg):
|
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))
|
boatdata.setValue("STW", float(msg.water_speed_knots))
|
||||||
|
|
||||||
def VPW(boatdata, msg):
|
def VPW(boatdata, msg):
|
||||||
|
@ -350,19 +357,10 @@ def VPW(boatdata, msg):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
def VTG(boatdata, msg):
|
def VTG(boatdata, msg):
|
||||||
# Track made good and speed over ground
|
|
||||||
"""
|
"""
|
||||||
(('True Track made good', 'true_track', <class 'float'>),
|
Track made good and speed over ground
|
||||||
('True Track made good symbol', 'true_track_sym'),
|
Calculated from previous GPS positions
|
||||||
('Magnetic Track made good', 'mag_track', <class 'decimal.Decimal'>),
|
Only true track is used at the moment. magnetic is ignored
|
||||||
('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
|
|
||||||
"""
|
"""
|
||||||
if msg.faa_mode != 'A':
|
if msg.faa_mode != 'A':
|
||||||
return
|
return
|
||||||
|
|
|
@ -29,15 +29,19 @@ class RaceTracker(Page):
|
||||||
|
|
||||||
def __init__(self, pageno, cfg, appdata, boatdata):
|
def __init__(self, pageno, cfg, appdata, boatdata):
|
||||||
super().__init__(pageno, cfg, appdata, boatdata)
|
super().__init__(pageno, cfg, appdata, boatdata)
|
||||||
|
self.ttype = self.app.track.ttype
|
||||||
self.bv_lat = boatdata.getRef("LAT")
|
self.bv_lat = boatdata.getRef("LAT")
|
||||||
self.bv_lon = boatdata.getRef("LON")
|
self.bv_lon = boatdata.getRef("LON")
|
||||||
self.bv_sog = boatdata.getRef("SOG")
|
self.bv_sog = boatdata.getRef("SOG")
|
||||||
self.races = None
|
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.menupos = 0
|
||||||
self.buttonlabel[1] = 'MODE'
|
|
||||||
self.buttonlabel[2] = 'INFO'
|
|
||||||
self.buttonlabel[5] = 'ABORT'
|
|
||||||
self.mode = 'N' # (N)ormal, (C)onfiguration, (M)itteilung
|
self.mode = 'N' # (N)ormal, (C)onfiguration, (M)itteilung
|
||||||
self.query_active = False
|
self.query_active = False
|
||||||
self.savebuttons = None
|
self.savebuttons = None
|
||||||
|
@ -76,6 +80,8 @@ class RaceTracker(Page):
|
||||||
self.sym_flag[f] = cairo.ImageSurface.create_from_png(flagfile)
|
self.sym_flag[f] = cairo.ImageSurface.create_from_png(flagfile)
|
||||||
|
|
||||||
def handle_key(self, buttonid):
|
def handle_key(self, buttonid):
|
||||||
|
if self.ttype == 'NONE':
|
||||||
|
return False
|
||||||
if self.query_active:
|
if self.query_active:
|
||||||
if buttonid == 2:
|
if buttonid == 2:
|
||||||
self.query_active = False
|
self.query_active = False
|
||||||
|
@ -158,6 +164,38 @@ class RaceTracker(Page):
|
||||||
return True
|
return True
|
||||||
return False
|
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):
|
def draw_normal(self, ctx):
|
||||||
|
|
||||||
ctx.select_font_face("DSEG7 Classic")
|
ctx.select_font_face("DSEG7 Classic")
|
||||||
|
@ -241,9 +279,6 @@ class RaceTracker(Page):
|
||||||
ctx.paint()
|
ctx.paint()
|
||||||
ctx.restore()
|
ctx.restore()
|
||||||
pos += 1
|
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):
|
def draw_config(self, ctx):
|
||||||
|
|
||||||
|
@ -399,8 +434,13 @@ class RaceTracker(Page):
|
||||||
|
|
||||||
def draw(self, ctx):
|
def draw(self, ctx):
|
||||||
if self.mode == 'N':
|
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':
|
elif self.mode == 'C':
|
||||||
self.draw_config(ctx)
|
self.draw_config(ctx)
|
||||||
else:
|
else:
|
||||||
self.draw_info(ctx)
|
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?")
|
||||||
|
|
|
@ -13,6 +13,7 @@ Layout
|
||||||
|
|
||||||
import cairo
|
import cairo
|
||||||
from .page import Page
|
from .page import Page
|
||||||
|
import nmea2000.boatdata
|
||||||
|
|
||||||
class TwoValues(Page):
|
class TwoValues(Page):
|
||||||
|
|
||||||
|
@ -44,7 +45,7 @@ class TwoValues(Page):
|
||||||
ctx.show_text(self.ref2.unit)
|
ctx.show_text(self.ref2.unit)
|
||||||
|
|
||||||
# Meßwerte
|
# 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.select_font_face("Ubuntu", cairo.FontSlant.NORMAL, cairo.FontWeight.BOLD)
|
||||||
ctx.set_font_size(40)
|
ctx.set_font_size(40)
|
||||||
ctx.move_to(140, 100)
|
ctx.move_to(140, 100)
|
||||||
|
@ -54,7 +55,7 @@ class TwoValues(Page):
|
||||||
ctx.move_to(180, 130)
|
ctx.move_to(180, 130)
|
||||||
ctx.show_text(self.ref1.format())
|
ctx.show_text(self.ref1.format())
|
||||||
|
|
||||||
if type(self.ref2 == 'BoatValueGeo'):
|
if type(self.ref2) == nmea2000.boatdata.BoatValueGeo:
|
||||||
ctx.select_font_face("Ubuntu")
|
ctx.select_font_face("Ubuntu")
|
||||||
ctx.set_font_size(40)
|
ctx.set_font_size(40)
|
||||||
ctx.move_to(140, 210)
|
ctx.move_to(140, 210)
|
||||||
|
|
55
tracker.py
55
tracker.py
|
@ -65,38 +65,39 @@ class Tracker():
|
||||||
self.club = cfg['boat']['club']
|
self.club = cfg['boat']['club']
|
||||||
self.team = cfg['boat']['team']
|
self.team = cfg['boat']['team']
|
||||||
|
|
||||||
# Regatta Hero
|
if self.ttype == 'HERO':
|
||||||
self.hero_orgid = cfg['tracker']['username'] # Eingestellt in Gerätekonfiguration
|
# Regatta Hero
|
||||||
self.hero_passcode = cfg['tracker']['password']
|
self.hero_orgid = cfg['tracker']['username'] # Eingestellt in Gerätekonfiguration
|
||||||
self.hero_host = cfg['tracker']['host']
|
self.hero_passcode = cfg['tracker']['password']
|
||||||
self.hero_port = cfg['tracker']['port']
|
self.hero_host = cfg['tracker']['host']
|
||||||
self.hero_viewerpass = None # Wird vom Server in "org" gesendet
|
self.hero_port = cfg['tracker']['port']
|
||||||
|
self.hero_viewerpass = None # Wird vom Server in "org" gesendet
|
||||||
|
|
||||||
# Vorlage für Anfragen
|
# Vorlage für Anfragen
|
||||||
self.http_payload_template = {
|
self.http_payload_template = {
|
||||||
"orgid": self.hero_orgid,
|
"orgid": self.hero_orgid,
|
||||||
"passcode": self.hero_passcode,
|
"passcode": self.hero_passcode,
|
||||||
"raceid": "",
|
"raceid": "",
|
||||||
"replay": "live",
|
"replay": "live",
|
||||||
"replaytime": 0,
|
"replaytime": 0,
|
||||||
"updateType": "timerUpdate"
|
"updateType": "timerUpdate"
|
||||||
}
|
}
|
||||||
|
|
||||||
self.hero_raceid = None # Aktuell ausgewählte Regatta
|
self.hero_raceid = None # Aktuell ausgewählte Regatta
|
||||||
self.hero_racephase = 0 # Bei Änderung Event auslösen
|
self.hero_racephase = 0 # Bei Änderung Event auslösen
|
||||||
|
|
||||||
# MQTT
|
# MQTT
|
||||||
self.client = mqtt.Client()
|
self.client = mqtt.Client()
|
||||||
self.client.on_connect = self.mqtt_on_connect
|
self.client.on_connect = self.mqtt_on_connect
|
||||||
self.client.on_message = self.mqtt_on_message
|
self.client.on_message = self.mqtt_on_message
|
||||||
|
|
||||||
self.hero_orgstatus = None
|
self.hero_orgstatus = None
|
||||||
self.hero_racestatus = None
|
self.hero_racestatus = None
|
||||||
self.hero_timedelta = 0 # Zeitdifferenz zum Server in sec
|
self.hero_timedelta = 0 # Zeitdifferenz zum Server in sec
|
||||||
self.hero_givenup = False
|
self.hero_givenup = False
|
||||||
|
|
||||||
# Hole erste Daten vom Server
|
# Hole erste Daten vom Server
|
||||||
self.hero_query_org()
|
self.hero_query_org()
|
||||||
|
|
||||||
def is_server_active(self, hostname, port):
|
def is_server_active(self, hostname, port):
|
||||||
"""
|
"""
|
||||||
|
|
Loading…
Reference in New Issue