forked from odwdinc/Python-SimConnect
-
Notifications
You must be signed in to change notification settings - Fork 0
/
local_example.py
94 lines (73 loc) · 2.05 KB
/
local_example.py
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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
from SimConnect import *
import logging
from SimConnect.Enum import *
from time import sleep
logging.basicConfig(level=logging.DEBUG)
LOGGER = logging.getLogger(__name__)
LOGGER.info("START")
# time holder for inline commands
ct_g = millis()
# creat simconnection and pass used user classes
sm = SimConnect()
aq = AircraftRequests(sm)
ae = AircraftEvents(sm)
mc = aq.find("MAGNETIC_COMPASS")
mv = aq.find("MAGVAR")
print(mc.get() + mv.get())
sm.exit()
quit()
# Set pos arund space nedle in WA.
sm.set_pos(
_Altitude=1000.0,
_Latitude=47.614699,
_Longitude=-122.358473,
_Airspeed=130,
_Heading=70.0,
# _Pitch=0.0,
# _Bank=0.0,
# _OnGround=0
)
# PARKING_BRAKES = Event(b'PARKING_BRAKES', sm)
# long path
PARKING_BRAKES = ae.Miscellaneous_Systems.PARKING_BRAKES
# using get
GEAR_TOGGLE = ae.Miscellaneous_Systems.get("GEAR_TOGGLE")
# Using find to lookup Event
AP_MASTER = ae.find("AP_MASTER")
# THROTTLE1 Event
THROTTLE1 = ae.Engine.THROTTLE1_SET
# THROTTLE1 Request
Throttle = aq.find('GENERAL_ENG_THROTTLE_LEVER_POSITION:1')
# If useing
# Throttle = aq.find('GENERAL_ENG_THROTTLE_LEVER_POSITION:index')
# Need to set index befor read/write
# Note to set index 2 vs 1 just re-run
# Throttle.setIndex(1)
# print the built in description
# AP_MASTER Toggles AP on/off
print("AP_MASTER", AP_MASTER.description)
# Throttle Percent of max throttle position
print("Throttle", Throttle.description)
# THROTTLE1 Set throttle 1 exactly (0 to 16383)
print("THROTTLE1", THROTTLE1.description)
while not sm.quit:
print("Throttle:", Throttle.value)
print("Alt=%f Lat=%f Lon=%f Kohlsman=%.2f" % (
aq.PositionandSpeedData.get('PLANE_ALTITUDE'),
aq.PositionandSpeedData.get('PLANE_LATITUDE'),
aq.PositionandSpeedData.get('PLANE_LONGITUDE'),
aq.FlightInstrumentationData.get('KOHLSMAN_SETTING_HG')
))
sleep(2)
# Send Event with value
# THROTTLE1(1500)
# Send Event toggle AP_MASTER
# AP_MASTER()
# PARKING_BRAKES()
# send new data inine @ 5s
if ct_g + 5000 < millis():
if Throttle.value < 100:
Throttle.value += 5
print("THROTTLE SET")
ct_g = millis()
sm.exit()