Programmierung Alarmfunktion
This commit is contained in:
parent
d7136e38bf
commit
be20826ab5
43
nmea0183.py
43
nmea0183.py
|
@ -1,6 +1,9 @@
|
|||
"""
|
||||
NMEA0183 verarbeiten
|
||||
|
||||
TODO Multi-Sentence verarbeiten
|
||||
TXT
|
||||
AIS-Sentences mit Binärdaten
|
||||
"""
|
||||
|
||||
def DBS(boatdata, msg):
|
||||
|
@ -202,6 +205,45 @@ def RTE(boatdata, msg):
|
|||
print("-> RTE")
|
||||
print(msg.fields)
|
||||
|
||||
txt_msg = ''
|
||||
txt_type = None
|
||||
txt_curr = 0
|
||||
txt_max = 0
|
||||
|
||||
def TXT(boatdata, msg):
|
||||
# Text Transmission (e.G. Alarms)
|
||||
global txt_msg, txt_type, txt_curr, txt_max
|
||||
#print("-> TXT")
|
||||
nmax = int(msg.num_msg)
|
||||
n = int(msg.msg_num)
|
||||
if nmax > 1:
|
||||
if txt_curr == 0 and n == 1:
|
||||
# neue Nachricht
|
||||
txt_msg = msg.text.rstrip('\r\n')
|
||||
txt_type = msg.msg_type
|
||||
txt_curr = 1
|
||||
txt_max = nmax
|
||||
else:
|
||||
# Fortsetzung
|
||||
if txt_curr == n - 1 and txt_type == msg.msg_type:
|
||||
txt_msg += msg.text.rstrip('\r\n')
|
||||
txt_curr = n
|
||||
if n == nmax:
|
||||
# Vollständig!
|
||||
print(f"TXT: {msg.msg_type} - {txt_msg}")
|
||||
if not boatdata.alarm:
|
||||
# Momentan wird kein bereits anstehender Alarm überschrieben
|
||||
boatdata.setValue("TXT", txt_msg)
|
||||
boatdata.alarm = True
|
||||
txt_curr = 0
|
||||
txt_max = 0
|
||||
else:
|
||||
print(f"TXT: {msg.msg_type} - {msg.text}", end='')
|
||||
if not boatdata.alarm:
|
||||
# Momentan wird kein bereits anstehender Alarm überschrieben
|
||||
boatdata.setValue("TXT", msg.text)
|
||||
boatdata.alarm = True
|
||||
|
||||
def VBW(boatdata, msg):
|
||||
print("-> VBW")
|
||||
|
||||
|
@ -323,6 +365,7 @@ decoder = {
|
|||
"RMC": RMC,
|
||||
"RSA": RSA,
|
||||
"RTE": RTE,
|
||||
"TXT": TXT,
|
||||
"VBW": VBW,
|
||||
"VHW": VHW,
|
||||
"VPW": VPW,
|
||||
|
|
|
@ -312,3 +312,5 @@ class Anchor(Page):
|
|||
self.draw_normal(ctx)
|
||||
else:
|
||||
self.draw_config(ctx)
|
||||
if self._bd.alarm:
|
||||
self.draw_alarm(ctx)
|
||||
|
|
|
@ -208,6 +208,20 @@ class Page():
|
|||
ctx.show_text(self.buttonlabel[i+1])
|
||||
ctx.stroke()
|
||||
|
||||
def draw_alarm(self, ctx):
|
||||
x, y, w, h = (50, 100, 300, 150)
|
||||
ctx.set_line_width(1)
|
||||
ctx.set_source_rgb(*self.fgcolor)
|
||||
ctx.rectangle(x + 0.5, y + 0.5, w, h)
|
||||
ctx.stroke()
|
||||
ctx.set_source_rgb(*self.bgcolor)
|
||||
ctx.rectangle(x + 1, y + 1, w - 1, h - 1)
|
||||
ctx.fill()
|
||||
ctx.set_source_rgb(*self.fgcolor)
|
||||
ctx.set_line_width(2)
|
||||
ctx.rectangle(x + 3, y + 3, w - 5, h - 5)
|
||||
ctx.stroke()
|
||||
|
||||
def clear(self):
|
||||
ctx.set_source_rgb(1, 1, 1)
|
||||
ctx.rectangle(0, 0, 399, 299)
|
||||
|
|
Loading…
Reference in New Issue