Wtyczka odczytuje plan lotu z FMS/GPS (countFMSEntries/getFMSEntryInfo)

This commit is contained in:
pali112 committed 2026-10-20 16:48:15 +02:00
1 parent 6e5cc6b414
commit dcfc572c02
1 file changed
+45
+45
View File
@@ -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: