Initial commit

master
Andrey Prokhorov 6 years ago
parent 50803aef9a
commit bfedc6bdc3

@ -0,0 +1,114 @@
# This Python file uses the following encoding: utf-8
from time import sleep
from math import degrees
import sys
import pyuipc
P3Dv4 = 12
XPL11 = 0
VERSIONS = [P3Dv4, XPL11]
def open_file():
try:
fh = open("bar.html", "w")
except:
print("Cannot open file for writing!")
else:
return fh
def write_data(file, hdg, alt, fpm, gs, gf, aoa):
data = ""
data += "<!doctype html><html lang=\"en\"><head>"
data += "<meta http-equiv=\"refresh\" content=\"3\" />"
data += "<meta charset=\"utf-8\">"
data += "<link rel=\"stylesheet\" href=\"prox-style.css\">"
data += "</head>"
data += "<body><div class=\"flexbox\">"
data += "<div class=\"block heading\">" + str(hdg) + "</div>"
data += "<div class=\"block altitude\">" + str(alt) + "</div>"
data += "<div class=\"block vs\">" + str(fpm) + "</div>"
data += "<div class=\"block speed\">" + str(gs) + "</div>"
data += "<div class=\"block aoa\">" + str(aoa) + "</div>"
data += "<div class=\"block gf\">" + str(gf) + "</div>"
data += "</body></html>"
try:
file.write(data)
file.close()
except:
print("Error writing to file!")
file.close()
while True:
try:
pyuipc.open(XPL11)
while True:
try:
l = list()
t0 = (0x0580, 'u') # heading
t1 = (0x0570, 'l') # alt
t2 = (0x02b4, 'd') # ground speed
t3 = (0x02a0, 'h') # magvar
t4 = (0x1140, 'f') # G-force
t5 = (0x030c, 'd') # vspeed at touchdown
t6 = (0x2ed0, 'f') # AOA
l = [t0, t1, t2, t3, t4, t5, t6]
res = pyuipc.read(l)
hdg = res[0]*360/(65535*65535)
magvar = int(res[3] * 360 / 65536)
mag = hdg - magvar
if mag < 0:
mag = 360 + mag
if mag == 0:
mag = 360
mag = str(mag)
if len(mag) == 1:
mag = "00" + mag
elif len(mag) == 2:
mag = "0" + mag
alt = int(res[1]*3.28084/(65536*65536))
gs = res[2]*3600/65536/1852
gf = str(res[4])
if len(gf) > 3:
if gf[0] == "-":
gf = gf[0:5]
else:
gf = gf[0:4]
tdvspeed = int(res[5]*60*3.28084/256)
aoa = str(degrees(res[6]))
if aoa[0] == "-":
aoa = aoa[0:5]
else:
aoa = aoa[0:4]
print("Hdg: " + str(mag))
print("Alt: " + str(alt) + " ft")
print("Gs: " + str(gs) + " kts")
print("G-force: " + str(gf))
print("T/D VSpeed: " + str(tdvspeed))
print("AOA: " + str(aoa))
print("---")
fh = open_file()
write_data(fh, mag, alt, tdvspeed, gs, gf, aoa)
sleep(2)
except:
print("Error")
print(sys.exc_info()[0])
try:
pyuipc.close()
except:
pass
break
except pyuipc.FSUIPCException as e:
print("Exception")
print(str(e.errorCode) + " " + e.errorString)
sleep(10)
except:
print("Probably incorrect FSUIPC version or simulator is not started. Timeout 10 sec.")
sleep(10)

@ -0,0 +1,72 @@
.flexbox {
display: flex ;
flex-direction: row ;
flex-wrap: wrap ;
justify-content: flex-start ;
align-items: center ;
align-content: center ;
margin: 10px
}
.block {
background: rgba(0, 0, 0, .34);
padding: 10px;
color: #fff;
margin: 3px
}
.block:before {
font-weight: 700;
#color: #00b5ca;
color: #00ffaa;
text-transform: uppercase
}
.block:after {
color: hsla(0, 0%, 100%, .6)
}
.heading:before {
content: 'Hdg: '
}
.heading:after {
content: '°'
}
.altitude:before {
content: 'Alt: '
}
.altitude:after {
content: ' ft'
}
.speed:before {
content: 'G/S: '
}
.speed:after {
content: ' kts'
}
.vs:before {
content: 'V/S: '
}
.vs:after {
content: ' fpm'
}
.gf:before {
content: 'G: '
}
.aoa:before {
text-transform: lowercase;
content: 'α: '
}
.aoa:after {
content: '°'
}

@ -0,0 +1 @@
python setup.py py2exe

@ -0,0 +1,4 @@
from distutils.core import setup
import py2exe
setup(console=['inflight.py'])
Loading…
Cancel
Save