I want to create a simple python window that displays and refreshes the information for the DME relative to NAV1 and NAV2 frequency. I can’t seem to find the correct variables following is the snippet of test code i wrote, but it does not return any values. Question: Are the following variables i used correct?
NAV DME:1
NAV DMESPEED:1
NAV DMEDISTANCETIME:1
NAV DME:2
NAV DMESPEED:2
NAV DMEDISTANCETIME:2
Are there any other variables i should use?
Thank you.
Code:
from SimConnect import SimConnect, AircraftRequests, AircraftEvents
import time
def is_msfs_running():
“”“Check if MSFS is running by looking for the ‘FlightSimulator.exe’ process.”“”
for process in psutil.process_iter([‘name’]):
if process.info[‘name’] == ‘FlightSimulator.exe’:
return True
return False
Wait for MSFS to start if it’s not already running
while not is_msfs_running():
input(“Microsoft Flight Simulator is not running. Please start it and press Enter to continue…”)
Connect to MSFS 2020
conn = SimConnect() # Establish connection to MSFS
requests = AircraftRequests(conn) # Create AircraftRequests instance for MSFS data retrieval
events = AircraftEvents(conn)
Fetching NAV1 and NAV2 DME data
dme_distance_nav1 = requests.get(“NAV DME:1”) # Distance to station in NM
dme_speed_nav1 = requests.get(“NAV DMESPEED:1”) # Ground speed in KT
dme_time_nav1 = requests.get(“NAV DMEDISTANCETIME:1”) # Time to station in MIN
dme_distance_nav2 = requests.get(“NAV DME:2”)
dme_speed_nav2 = requests.get(“NAV DMESPEED:2”)
dme_time_nav2 = requests.get(“NAV DMEDISTANCETIME:2”)
Print values for debugging
print(f"NAV1 DME Distance: {dme_distance_nav1}, Speed: {dme_speed_nav1}, Time: {dme_time_nav1}“)
print(f"NAV2 DME Distance: {dme_distance_nav2}, Speed: {dme_speed_nav2}, Time: {dme_time_nav2}”)