1
1
from SimConnect import *
2
2
import logging
3
+ from SimConnect .Enum import *
3
4
from time import sleep
4
5
import asyncio
6
+
5
7
logging .basicConfig (level = logging .DEBUG )
6
8
LOGGER = logging .getLogger (__name__ )
7
9
LOGGER .info ("START" )
10
+
11
+
12
+ # creat simconnection and pass used user classes
8
13
sm = 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
+
10
28
11
- Data = {}
29
+ # THROTTLE1 Request
30
+ Throttle = aq .find ('GENERAL_ENG_THROTTLE_LEVER_POSITION:1' )
12
31
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)
13
37
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 )
17
46
18
47
19
48
async def main ():
49
+ # time holder for inline commands
50
+ ct_g = millis ()
20
51
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 )
24
60
25
- for ed in aq . PositionandSpeedData . list :
26
- await temp [ ed ]
61
+ # Send Event with value
62
+ # THROTTLE1(1500)
27
63
28
- print ( Data )
29
- sleep ( 2 )
30
- sm . exit ()
31
- quit ()
64
+ # Send Event toggle AP_MASTER
65
+ # AP_MASTER( )
66
+
67
+ # PARKING_BRAKES ()
32
68
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 ()
33
76
34
- asyncio .run (main ())
77
+ asyncio .run (main ())
0 commit comments