From dcfc572c02066f9a8285bfe5b5ec2c8d55d0c76d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rafa=C5=82=20Paluch?= Date: Tue, 20 Oct 2026 16:48:15 +0200 Subject: [PATCH] Wtyczka odczytuje plan lotu z FMS/GPS (countFMSEntries/getFMSEntryInfo) --- PythonPlugins/PI_XSayATC.py | 45 +++++++++++++++++++++++++++++++++++++ 1 file changed, 45 insertions(+) diff --git a/PythonPlugins/PI_XSayATC.py b/PythonPlugins/PI_XSayATC.py index fa2456a..8ab301a 100644 --- a/PythonPlugins/PI_XSayATC.py +++ b/PythonPlugins/PI_XSayATC.py @@ -264,6 +264,13 @@ class XSayATC: else: lines.append("Nearby traffic: none detected") + # Plan lotu z FMS/GPS + fp_lines = self._collect_flight_plan() + ctx["FlightPlan"] = fp_lines + if fp_lines: + lines.append("Flight plan (FMS/GPS):") + lines.extend(fp_lines) + return ctx, "\n".join(lines) def _get_tuned_facility(self, ref): @@ -350,6 +357,44 @@ class XSayATC: return out + def _collect_flight_plan(self): + """Zbiera plan lotu z FMS/GPS (listę punktów). WYWOLYWAC TYLKO na glownym watku.""" + lines = [] + try: + n = xp.countFMSEntries() + except Exception: + n = 0 + if not n or n <= 0: + return lines + + try: + dest_idx = xp.getDestinationFMSEntry() + except Exception: + dest_idx = -1 + + for i in range(n): + try: + info = xp.getFMSEntryInfo(i) + except Exception: + continue + if info is None: + continue + navid = getattr(info, "navAidID", "") or "" + alt = getattr(info, "altitude", 0) or 0 + marker = "" + if i == dest_idx: + marker = " [DEST]" + alt_s = f", alt {int(alt)} ft" if alt else "" + if navid: + lines.append(f" {i}: {navid}{alt_s}{marker}") + else: + lat = getattr(info, "lat", None) + lon = getattr(info, "lon", None) + if lat is not None and lon is not None: + lines.append(f" {i}: lat/lon {lat:.4f}/{lon:.4f}{alt_s}{marker}") + + return lines + # ---------------------------- Komunikacja z LLM ---------------------------- def _resolve_model(self): if self._model_cache: