source: src/mlx/fs.py@ 40:aaf5cd877e21

Last change on this file since 40:aaf5cd877e21 was 27:d95d48685969, checked in by István Váradi <ivaradi@…>, 13 years ago

Created icons, reorganized sources and made the Windows installer work

File size: 4.9 KB
Line 
1# Module for generic flight-simulator interfaces
2
3#-------------------------------------------------------------------------------
4
5import const
6
7#-------------------------------------------------------------------------------
8
9class ConnectionListener(object):
10 """Base class for listeners on connections to the flight simulator."""
11 def connected(self, fsType, descriptor):
12 """Called when a connection has been established to the flight
13 simulator of the given type."""
14 print "fs.ConnectionListener.connected, fsType:", fsType, ", descriptor:", descriptor
15
16 def disconnected(self):
17 """Called when a connection to the flight simulator has been broken."""
18 print "fs.ConnectionListener.disconnected"
19
20#-------------------------------------------------------------------------------
21
22class SimulatorException(Exception):
23 """Exception thrown by the simulator interface for communication failure."""
24
25#-------------------------------------------------------------------------------
26
27def createSimulator(type, connectionListener):
28 """Create a simulator instance for the given simulator type with the given
29 connection listener.
30
31 The returned object should provide the following members:
32 FIXME: add info
33 """
34 assert type in [const.SIM_MSFS9, const.SIM_MSFSX], \
35 "Only MS Flight Simulator 2004 and X are supported"
36 import fsuipc
37 return fsuipc.Simulator(connectionListener)
38
39#-------------------------------------------------------------------------------
40
41class AircraftState(object):
42 """Base class for the aircraft state produced by the aircraft model based
43 on readings from the simulator.
44
45 The following data members should be provided at least:
46 - timestamp: the simulator time of the measurement in seconds since the
47 epoch (float)
48 - paused: a boolean indicating if the flight simulator is paused for
49 whatever reason (it could be a pause mode, or a menu, a dialog, or a
50 replay, etc.)
51 - trickMode: a boolean indicating if some "trick" mode (e.g. "SLEW" in
52 MSFS) is activated
53 - overspeed: a boolean indicating if the aircraft is in overspeed
54 - stalled: a boolean indicating if the aircraft is stalled
55 - onTheGround: a boolean indicating if the aircraft is on the ground
56 - zfw: the zero-fuel weight in kilograms (float)
57 - grossWeight: the gross weight in kilograms (float)
58 - heading: the heading of the aircraft in degrees (float)
59 - pitch: the pitch of the aircraft in degrees. Positive means pitch down,
60 negative means pitch up (float)
61 - bank: the bank of the aircraft in degrees. Positive means bank left,
62 negative means bank right (float)
63 - ias: the indicated airspeed in knots (float)
64 - mach: the airspeed in mach (float)
65 - groundSpeed: the ground speed (float)
66 - vs: the vertical speed in feet/minutes (float)
67 - radioAltitude: the radio altitude of the aircraft in feet (float)
68 - altitude: the altitude of the aircraft in feet (float)
69 - gLoad: G-load (float)
70 - flapsSet: the selected degrees of the flaps (float)
71 - flaps: the actual degrees of the flaps (float)
72 - fuelWeight[]: the fuel weights in the different tanks in kgs (array of
73 floats of as many items as the number fuel tanks)
74 - n1[]: the N1 values of the turbine engines (array of floats
75 of as many items as the number of engines, present only for aircraft with
76 turbines)
77 - rpm[]: the RPM values of the piston engines (array of floats
78 of as many items as the number of engines, present only for aircraft with
79 pistons)
80 - reverser[]: an array of booleans indicating if the thrust reversers are
81 activated on any of the engines. The number of items equals to the number
82 of engines with a reverser.
83 - navLightsOn: a boolean indicating if the navigation lights are on
84 - antiCollisionLightsOn: a boolean indicating if the anti-collision lights are on
85 - strobeLightsOn: a boolean indicating if the strobe lights are on
86 - landingLightsOn: a boolean indicating if the landing lights are on
87 - pitotHeatOn: a boolean indicating if the pitot heat is on
88 - parking: a boolean indicating if the parking brake is set
89 - gearsDown: a boolean indicating if the gears are down
90 - spoilersArmed: a boolean indicating if the spoilers have been armed for
91 automatic deployment
92 - spoilersExtension: the percentage of how much the spoiler is extended
93 (float)
94 - altimeter: the altimeter setting in hPa (float)
95 - nav1: the frequency of the NAV1 radio in MHz (string)
96 - nav2: the frequency of the NAV1 radio in MHz (string)
97 - squawk: the transponder code (string)
98 - windSpeed: the speed of the wind at the aircraft in knots (float)
99 - windDirection: the direction of the wind at the aircraft in degrees (float)
100
101 FIXME: needed when taxiing only:
102 - payload weight
103
104 FIXME: needed rarely:
105 - latitude, longitude
106 - transporter
107 - visibility
108 """
109
Note: See TracBrowser for help on using the repository browser.