Arbeit an Ankerseite und NMEA0183
This commit is contained in:
		
							parent
							
								
									df04c9ad8e
								
							
						
					
					
						commit
						9e4622aeef
					
				
							
								
								
									
										49
									
								
								nmea0183.py
								
								
								
								
							
							
						
						
									
										49
									
								
								nmea0183.py
								
								
								
								
							|  | @ -6,16 +6,22 @@ NMEA0183 verarbeiten | |||
| def DBS(boatdata, msg): | ||||
|     # Wassertiefe unter der Oberfläche | ||||
|     pass | ||||
|     #boatdata.setValue("DBS", msg.depth) | ||||
| 
 | ||||
| def DBT(boatdata, msg): | ||||
|     # Wassertiefe unter Geber | ||||
|     pass | ||||
|     #boatdata.setValue("DBT", msg.depth) | ||||
| 
 | ||||
| def GLL(boatdata, msg): | ||||
|     print("-> GLL") | ||||
|     boatdata.setValue("LAT", msg.latitude) | ||||
|     boatdata.setValue("LON", msg.longitude) | ||||
| 
 | ||||
| def GSV(boatdata, msg): | ||||
|     # Satellites in view | ||||
|     print("-> GSV") | ||||
| 
 | ||||
| def HDT(boatdata, msg): | ||||
|     # Heading True | ||||
|     print("-> HDT") | ||||
|  | @ -27,6 +33,22 @@ def MWV(boatdata, msg): | |||
|     boatdata.setValue("AWA", msg.wind_angle) | ||||
|     boatdata.setValue("AWS", msg.wind_speed) | ||||
| 
 | ||||
| def MTW(boatdata, msg): | ||||
|     # Wassertemperatur | ||||
|     # boatdata.setValue("WTemp", msg.xxx) | ||||
|     print("-> MTW Wassertemperatur") | ||||
| 
 | ||||
| def RMB(boatdata, msg): | ||||
|     # Recommended Minimum Navigation Information | ||||
|     # Informationen bzgl. Erreichen des nächsten Wegepunkts | ||||
|     # | ||||
|     print("-> RMB") | ||||
| 
 | ||||
| def RMC(boatdata, msg): | ||||
|     print("-> RMC") | ||||
|     #boatdata.setValue("LAT", msg.lat) | ||||
|     #boatdata.setValue("LON", msg.lon) | ||||
| 
 | ||||
| def RSA(boatdata, msg): | ||||
|     # Rudder Sensor Angle | ||||
|     # negative Werte bedeuten Backbord | ||||
|  | @ -39,6 +61,9 @@ def RTE(boatdata, msg): | |||
|     print("-> RTE") | ||||
|     print(msg.fields) | ||||
| 
 | ||||
| def VBW(boatdata, msg): | ||||
|     print("-> VBW") | ||||
| 
 | ||||
| def VHW(boatdata, msg): | ||||
|     boatdata.setValue("STW", float(msg.water_speed_knots)) | ||||
| 
 | ||||
|  | @ -54,16 +79,38 @@ def WPL(boatdata, msg): | |||
|     print("-> WPL") | ||||
|     print(msg.fields) | ||||
| 
 | ||||
| def XTE(boatdata, msg): | ||||
|     # Cross Track error measured | ||||
|     print("-> XTE") | ||||
| 
 | ||||
| def XTR(boatdata, msg): | ||||
|     # Cross Track error gekoppelt | ||||
|     print("-> XTR") | ||||
| 
 | ||||
| def ZDA(boatdata, msg): | ||||
|     # Time and date | ||||
|     print("-> XTE") | ||||
|     #boatdata.gpsd | ||||
|     #boatdata.gpst | ||||
| 
 | ||||
| # Aus Performancegründen eine direkte Sprungtabelle, ggf. können | ||||
| # zukünftig außer der Funktion noch weitere Daten gespeichert werdeb | ||||
| decoder = { | ||||
|     "DBS": DBS, | ||||
|     "DBT": DBT, | ||||
|     "GLL": GLL, | ||||
|     "GSV": GSV, | ||||
|     "MWV": MWV, | ||||
|     "MTW": MTW, | ||||
|     "RMB": RMB, | ||||
|     "RMC": RMC, | ||||
|     "RSA": RSA, | ||||
|     "RTE": RTE, | ||||
|     "VBW": VBW, | ||||
|     "VHW": VHW, | ||||
|     "VTG": VTG, | ||||
|     "WPL": WPL | ||||
|     "WPL": WPL, | ||||
|     "XTE": XTE, | ||||
|     "XTR": XTR, | ||||
|     "ZDA": ZDA | ||||
| } | ||||
|  |  | |||
|  | @ -9,10 +9,20 @@ Daten | |||
|   - aktuelle Position des Schiffs | ||||
|   - aktuelle Wassertiefe an Schiffsposition | ||||
|   - aktuelle Schiffsausrichtung bearing/heading | ||||
|   - aktuelle Windrichtung | ||||
|   - aktuelle Windstärke | ||||
|   - aktuelle Windrichtung (wahr) | ||||
|   - aktuelle Windstärke (wahr) | ||||
|   - Alarm aktiv J/N | ||||
|   - Alarmradius | ||||
|   - GPS Abweichung/ Fehler in der Horizontalen | ||||
| 
 | ||||
| Darstellung: | ||||
|   - Modi:  | ||||
|   - Anker oben / unten | ||||
|   - Nord ist oben  | ||||
| 
 | ||||
| Es gibt verschiedene Unterseiten | ||||
|   - Normalansicht | ||||
|   - Konfigurationsseite | ||||
| 
 | ||||
| """ | ||||
| 
 | ||||
|  | @ -26,9 +36,13 @@ class Anchor(Page): | |||
|     def __init__(self, pageno, cfg, boatdata): | ||||
|         super().__init__(pageno, cfg, boatdata) | ||||
|         self.sym_anchor = cairo.ImageSurface.create_from_png(os.path.join(cfg['imgpath'], "anchor.png")) | ||||
|         self.buttonlabel[1] = 'DEC' | ||||
|         self.buttonlabel[2] = 'INC' | ||||
|         self.buttonlabel[5] = 'SET' | ||||
|         self.buttonlabel[1] = 'MODE' | ||||
|         self.buttonlabel[2] = 'SET' | ||||
|         self.buttonlabel[5] = 'ALARM' | ||||
| 
 | ||||
|         self.mode = 'N' # (N)ormal, (C)onfiguration | ||||
| 
 | ||||
|         self._bd = boatdata | ||||
| 
 | ||||
|         # Der sinnvolle Abstand ist abhängig von der Länge der gesteckten Kette | ||||
|         # Die initial eingegebene Position des Ankers sollte nactträglich justiert | ||||
|  | @ -36,6 +50,7 @@ class Anchor(Page): | |||
| 
 | ||||
|         self.chain_length = 60 # maximale Länge die ausgesteckt werden kann | ||||
|         self.chain = 35 # aktuell gesteckte Länge | ||||
|         self.anchor_set = False | ||||
|         self.anchor_lat = 0 | ||||
|         self.anchor_lon = 0 | ||||
|         self.anchor_depth = -1 | ||||
|  | @ -44,12 +59,50 @@ class Anchor(Page): | |||
|         self.heading = -1 | ||||
|         self.depth = -1 | ||||
|         self.alarm_range = 20 | ||||
|         self.alarm_armed = False | ||||
|         self.alarm_enabled = False | ||||
|         self.alarm = False # Alarm ist ausgelöst und aktiv | ||||
|         self.wind_angle = -1 | ||||
| 
 | ||||
|     def handle_key(self, buttonid): | ||||
|         if buttonid == 1: | ||||
|             if self.mode == 'N': | ||||
|                 self.mode = 'C' | ||||
|             else: | ||||
|                 self.mode = 'N' | ||||
|             return True | ||||
|         if buttonid == 2: | ||||
|             if not self.anchor_set: | ||||
|                 self.anchor_lat = self._bd.lat | ||||
|                 self.anchor_lon = self._bd.lon | ||||
|                 self.anchor_set = True | ||||
|             else: | ||||
|                 self.anchor_set = False | ||||
|         if self.buttonid == 5: | ||||
|             # Bei aktivem Alarm kann mit dieser Taste der Alarm zurückgesetzt | ||||
|             # werden | ||||
|             if self.alarm: | ||||
|                 self.alarm = False | ||||
|                 self.buttonlabel[5] = 'ALARM' | ||||
|             if self.alarm_enabled: | ||||
|                 self.alarm_enabled = False | ||||
|                 self.buttonlabel[5] = 'ALARM' | ||||
|             else: | ||||
|                 self.buttonlabel[5] = 'OFF' | ||||
|         return False | ||||
| 
 | ||||
|     def draw(self, ctx): | ||||
| 
 | ||||
|         """ | ||||
|         value1 = LAT | ||||
|         value2 = LON | ||||
|         value3 = HDOP | ||||
|         value4 = DBS | ||||
|         value5 = TWD | ||||
|         value6 = TWS | ||||
|         """ | ||||
| 
 | ||||
|         # self.anchor_lat = | ||||
| 
 | ||||
|         # Name | ||||
|         ctx.select_font_face("Ubuntu", cairo.FontSlant.NORMAL, cairo.FontWeight.BOLD) | ||||
|         ctx.set_font_size(20) | ||||
|  | @ -63,10 +116,9 @@ class Anchor(Page): | |||
|         ctx.move_to(2, 70) | ||||
|         ctx.show_text("Alarm: off") | ||||
|         ctx.move_to(320, 70) | ||||
|         ctx.show_text("45 m") | ||||
|         ctx.show_text(f"{self.chain} m") | ||||
|         ctx.stroke() | ||||
| 
 | ||||
| 
 | ||||
|         # Spezialseite | ||||
|         cx = 200 | ||||
|         cy = 150 | ||||
|  | @ -80,3 +132,17 @@ class Anchor(Page): | |||
|         ctx.set_source_surface(self.sym_anchor, cx-8, cy-8) | ||||
|         ctx.paint() | ||||
|         ctx.restore() | ||||
| 
 | ||||
|         # Boot zeichnen | ||||
|         # Heading beachten | ||||
|          | ||||
| 
 | ||||
|         # Windpfeil zeichnen | ||||
|         # TWD / TWS  | ||||
|         # boatdata.value(TWD) | ||||
|         p = ((cx, cy - r + 25), (cx - 12, cy - r - 4), (cx, cy - r + 6), (cx + 12, cy - r - 4), (cx, cy - r + 25)) | ||||
|         wind = self.rotate((cx, cy), p, 62) | ||||
|         ctx.move_to(*wind[0]) | ||||
|         for point in wind[1:]: | ||||
|             ctx.line_to(*point) | ||||
|         ctx.fill() | ||||
|  |  | |||
		Loading…
	
		Reference in New Issue