Alarmdialog programmiert

This commit is contained in:
Thomas Hooge 2025-09-10 16:58:20 +02:00
parent 7d8ce221fd
commit 14108b1165
7 changed files with 69 additions and 10 deletions

15
TODO
View File

@ -1,7 +1,14 @@
Aufgaben- und Planungs- und Ideenliste
Aufgaben, Planungs- und Ideenliste
- Tracker
Regatta Hero
python3-paho-mqtt benötigt
- Satelliten: SatelliteList verwenden und dieses auch in
nmea2000 implementieren
- Satellitenübersicht / SkyView
Kreis mit Sats
Rechtecke mit SNR (Signal/Noise)
- datareader für mehrere I²C-Sensoren. History muß entsprechend
eine Liste sein.
@ -12,10 +19,6 @@ Aufgaben- und Planungs- und Ideenliste
Kreis um Position, Liste letzter Positionen
Tasten: Set/Clear, Radius+, Radius-
- Satellitenübersicht / SkyView
Kreis mit Sats
Rechtecke mit SNR (Signal/Noise)
- Sea wave recorder (siehe Steamrock)
- Datenübertragung über Ethernet
@ -25,3 +28,5 @@ Aufgaben- und Planungs- und Ideenliste
- Yacht Devices ASCII Raw Protokoll
https://www.yachtd.com/downloads/ydnr02.pdf
- Actisense?
- AIS

BIN
images/exclamation.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 203 B

View File

@ -278,16 +278,20 @@ def TXT(boatdata, msg):
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_msg = txt_msg.strip()
boatdata.alarm = True
boatdata.alarm_id = msg.msg_type
boatdata.alarm_src = "NMEA0183"
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_msg = msg.text.strip()
boatdata.alarm = True
boatdata.alarm_id = msg.msg_type
boatdata.alarm_src = "NMEA0183"
def VBW(boatdata, msg):
print("-> VBW")

View File

@ -522,6 +522,11 @@ class Frontend(Gtk.Window):
if selected == 6 and self.button_clicked == 1:
self.keylock = False
return True
# Alarm! Only botton "1" so dismiss
if self.boatdata.alarm:
if selected == 1:
self.boatdata.alarm = False
return True
if selected == 1:
if self.button_clicked == 2:
# Programmende bei Klicken auf 2 und loslassen auf 1

View File

@ -313,4 +313,4 @@ class Anchor(Page):
else:
self.draw_config(ctx)
if self._bd.alarm:
self.draw_alarm(ctx)
self.draw_alarm(ctx, self._bd.alarm_src, self._bd.alarm_id, self._bd.alarm_msg)

View File

@ -28,5 +28,6 @@ class OneValue(Page):
ctx.show_text(self.ref1.format())
else:
#print(dir(self.bd))
ctx.show_text("---") # self.bd.getPlaceholder())
#ctx.show_text("---") # self.bd.getPlaceholder())
ctx.show_text(self.placeholder)
ctx.stroke()

View File

@ -82,6 +82,7 @@ class Page():
self.icon['ILUM'] = cairo.ImageSurface.create_from_png(os.path.join(cfg['imgpath'], "lighton.png"))
self.sym_lock = cairo.ImageSurface.create_from_png(os.path.join(cfg['imgpath'], "lock.png"))
self.sym_swipe = cairo.ImageSurface.create_from_png(os.path.join(cfg['imgpath'], "swipe3.png"))
self.sym_exclamation = cairo.ImageSurface.create_from_png(os.path.join(cfg['imgpath'], "exclamation.png"))
self.buttonlabel = {
1: '',
2: '',
@ -208,8 +209,11 @@ class Page():
ctx.show_text(self.buttonlabel[i+1])
ctx.stroke()
def draw_alarm(self, ctx):
def draw_alarm(self, ctx, source, alarmid, message):
x, y, w, h = (50, 100, 300, 150)
ctx.select_font_face("AtariST8x16SystemFont")
ctx.set_font_size(16)
# Dialogbox mit Rahmen
ctx.set_line_width(1)
ctx.set_source_rgb(*self.fgcolor)
ctx.rectangle(x + 0.5, y + 0.5, w, h)
@ -220,7 +224,28 @@ class Page():
ctx.set_source_rgb(*self.fgcolor)
ctx.set_line_width(2)
ctx.rectangle(x + 3, y + 3, w - 5, h - 5)
ctx.clip_preserve()
ctx.stroke()
# Symbol
ctx.save()
ctx.set_source_surface(self.sym_exclamation, x + 16, y + 16)
ctx.paint()
ctx.restore()
# Titel
ctx.move_to(x + 64, y + 30)
ctx.show_text("A L A R M")
ctx.move_to(x + 64, y + 48)
ctx.show_text(f"#{alarmid} from {source}")
# Alarmmeldung, umgebrochen
n = 0
for l in wordwrap(message, (w - 16 - 8) / 8):
ctx.move_to(x + 16, y + 80 + n)
ctx.show_text(l)
n += 16
if n > 64:
break
# Button-Hinweis
self.draw_text_center(ctx, x + w / 2, y + h - 16, "Press button 1 to dismiss alarm")
def clear(self):
ctx.set_source_rgb(1, 1, 1)
@ -312,3 +337,22 @@ class Page():
ctx.move_to(x + 4, y + h - 5 + 0.5)
ctx.show_text(content)
ctx.stroke()
def wordwrap(text, wrap):
# Wrap long line to multiple lines, monospaced character set
# e.g. used for alarm dialog boxes
llen = 0
l = 0
lines = [""]
for w in text.split():
wordlength = len(w)
if llen + 1 + wordlength <= wrap:
if llen > 0:
lines[l] += ' '
lines[l] += w
llen += wordlength + 1
else:
lines.append(w)
l += 1
llen = wordlength
return lines