forked from der-On/X-Plane-Flight-Planner
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathPI_flight_planner.py
More file actions
43 lines (35 loc) · 1.33 KB
/
Copy pathPI_flight_planner.py
File metadata and controls
43 lines (35 loc) · 1.33 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
import urllib
from XPLMPlugin import *
from XPLMProcessing import *
from XPLMDataAccess import *
from XPLMDefs import *
class PythonInterface:
def XPluginStart(self):
self.Name = "Flight Planner"
self.Sig = "OndrejBrinkel.Python.X-Plane-Flight-Planner"
self.Desc = "Provides in game connection to the X-Plane Flight Planner."
return self.Name, self.Sig, self.Desc
def XPluginStop(self):
XPLMUnregisterFlightLoopCallback(self,self.FlightLoopCB,0)
pass
def XPluginEnable(self):
self.FlightLoopCB = self.Update
XPLMRegisterFlightLoopCallback(self,self.FlightLoopCB,1.0,0)
return 1
def XPluginDisable(self):
XPLMUnregisterFlightLoopCallback(self,self.FlightLoopCB,0)
def XPluginReceiveMessage(self, inFromWho, inMessage, inParam):
pass
def Update(self,inFlightLoopCallback, inInterval,inRelativeToNow, inRefcon):
lat_dref = XPLMFindDataRef('sim/flightmodel/position/latitude')
lon_dref = XPLMFindDataRef('sim/flightmodel/position/longitude')
heading_dref = XPLMFindDataRef('sim/flightmodel/position/psi')
lat = XPLMGetDatad(lat_dref)
lon = XPLMGetDatad(lon_dref)
heading = XPLMGetDataf(heading_dref)
try:
sock = urllib.urlopen('http://localhost:3001?lat='+str(lat)+'&lon='+str(lon)+'&heading='+str(heading))
sock.close()
except:
pass
return 0.5