Programmierung Alarmfunktion

This commit is contained in:
2025-07-22 15:37:05 +02:00
parent d7136e38bf
commit be20826ab5
3 changed files with 59 additions and 0 deletions

View File

@@ -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,