11from SimConnect import *
22import logging
3+ from SimConnect .Enum import *
34from time import sleep
45import asyncio
6+
57logging .basicConfig (level = logging .DEBUG )
68LOGGER = logging .getLogger (__name__ )
79LOGGER .info ("START" )
10+
11+
12+ # creat simconnection and pass used user classes
813sm = SimConnect ()
9- aq = AircraftRequests (sm )
14+ aq = AircraftRequests (sm , _time = 10 , _attemps = 10 )
15+ ae = AircraftEvents (sm )
16+
17+ # PARKING_BRAKES = Event(b'PARKING_BRAKES', sm)
18+ # long path
19+ PARKING_BRAKES = ae .Miscellaneous_Systems .PARKING_BRAKES
20+ # using get
21+ GEAR_TOGGLE = ae .Miscellaneous_Systems .get ("GEAR_TOGGLE" )
22+ # Using find to lookup Event
23+ AP_MASTER = ae .find ("AP_MASTER" )
24+
25+ # THROTTLE1 Event
26+ THROTTLE1 = ae .Engine .THROTTLE1_SET
27+
1028
11- Data = {}
29+ # THROTTLE1 Request
30+ Throttle = aq .find ('GENERAL_ENG_THROTTLE_LEVER_POSITION:1' )
1231
32+ # If useing
33+ # Throttle = aq.find('GENERAL_ENG_THROTTLE_LEVER_POSITION:index')
34+ # Need to set index befor read/write
35+ # Note to set index 2 vs 1 just re-run
36+ # Throttle.setIndex(1)
1337
14- async def pintVal (name ):
15- global Data
16- Data [name ] = await aq .get (name )
38+
39+ # print the built in description
40+ # AP_MASTER Toggles AP on/off
41+ print ("AP_MASTER" , AP_MASTER .description )
42+ # Throttle Percent of max throttle position
43+ print ("Throttle" , Throttle .description )
44+ # THROTTLE1 Set throttle 1 exactly (0 to 16383)
45+ print ("THROTTLE1" , THROTTLE1 .description )
1746
1847
1948async def main ():
49+ # time holder for inline commands
50+ ct_g = millis ()
2051 while not sm .quit :
21- temp = {}
22- for ed in aq .PositionandSpeedData .list :
23- temp [ed ] = asyncio .create_task (pintVal (ed ))
52+ print ("Throttle:" , await Throttle .value )
53+ print ("Alt=%f Lat=%f Lon=%f Kohlsman=%.2f" % (
54+ await aq .PositionandSpeedData .get ('PLANE_ALTITUDE' ),
55+ await aq .PositionandSpeedData .get ('PLANE_LATITUDE' ),
56+ await aq .PositionandSpeedData .get ('PLANE_LONGITUDE' ),
57+ await aq .FlightInstrumentationData .get ('KOHLSMAN_SETTING_HG' )
58+ ))
59+ sleep (2 )
2460
25- for ed in aq . PositionandSpeedData . list :
26- await temp [ ed ]
61+ # Send Event with value
62+ # THROTTLE1(1500)
2763
28- print ( Data )
29- sleep ( 2 )
30- sm . exit ()
31- quit ()
64+ # Send Event toggle AP_MASTER
65+ # AP_MASTER( )
66+
67+ # PARKING_BRAKES ()
3268
69+ # send new data inine @ 5s
70+ if ct_g + 5000 < millis ():
71+ if await Throttle .value < 100 :
72+ Throttle .set (await Throttle .value + 5 )
73+ print ("THROTTLE SET" )
74+ ct_g = millis ()
75+ sm .exit ()
3376
34- asyncio .run (main ())
77+ asyncio .run (main ())
0 commit comments