source: xplra/test/multisettest.py@ 58:f0fa93354e15

Last change on this file since 58:f0fa93354e15 was 35:9451e75788ea, checked in by István Váradi <ivaradi@…>, 12 years ago

Implemented support for multi-dataref setting

File size: 1.6 KB
Line 
1# Multi-dataref query test program for the Python client library
2
3#------------------------------------------------------------------------------
4
5if __name__ == "__main__":
6 import sys
7 import time
8 from xplra import XPlane, ProtocolException
9
10 xplane = XPlane()
11
12 dontregister = "dontregister" in sys.argv
13
14 try:
15 print "Connecting to X-Plane..."
16 xplane.connect()
17 print "Connected to X-Plane."
18 print
19
20 setter = xplane.createMultiSetter()
21
22 simSpeedID = setter.addInt("sim/time/sim_speed")
23 zuluSecID = setter.addFloat("sim/time/zulu_time_sec")
24 localXID = setter.addDouble("sim/flightmodel/position/local_x")
25 tailNumID = setter.addByteArray("sim/aircraft/view/acf_tailnum", 40)
26 generatorOnID = setter.addIntArray("sim/cockpit/electrical/generator_on", 8)
27 propPitchID = setter.addFloatArray("sim/cockpit2/engine/actuators/prop_pitch_deg", 2)
28
29 if dontregister:
30 setter.finalize()
31 else:
32 print "Registering setter..."
33 setter.register();
34 print "Registered setter"
35 print
36
37 print "Setting values..."
38
39 setter[simSpeedID] = 0
40 setter[zuluSecID] = 7265.0
41 setter[localXID] = 12.0
42 setter[tailNumID] = "Kukutyin"
43 setter[generatorOnID] =[ 1, 0, 1, 0, 1, 0, 1 , 0 ]
44 setter[propPitchID] = [ 32.4, 78.2 ]
45
46 print "Executing..."
47
48 setter.execute()
49
50 print "Done."
51
52 except Exception as e:
53 print ">>>>>>>>>>>>>>>>>>>>>> Exception caught:", str(e)
54 finally:
55 xplane.disconnect()
Note: See TracBrowser for help on using the repository browser.