source: src/fs.py@ 10:103229d7ace5

Last change on this file since 10:103229d7ace5 was 9:3dac12e8914d, checked in by István Váradi <ivaradi@…>, 13 years ago

Flare calculations are handled and added some other printouts

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, aircraft):
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==const.SIM_MSFS9, "Only MS Flight Simulator 2004 is supported"
35 import fsuipc
36 return fsuipc.Simulator(connectionListener, aircraft)
37
38#-------------------------------------------------------------------------------
39
40class AircraftState(object):
41 """Base class for the aircraft state produced by the aircraft model based
42 on readings from the simulator.
43
44 The following data members should be provided at least:
45 - timestamp: the simulator time of the measurement in seconds since the
46 epoch (float)
47 - paused: a boolean indicating if the flight simulator is paused for
48 whatever reason (it could be a pause mode, or a menu, a dialog, or a
49 replay, etc.)
50 - trickMode: a boolean indicating if some "trick" mode (e.g. "SLEW" in
51 MSFS) is activated
52 - overspeed: a boolean indicating if the aircraft is in overspeed
53 - stalled: a boolean indicating if the aircraft is stalled
54 - onTheGround: a boolean indicating if the aircraft is on the ground
55 - zfw: the zero-fuel weight in kilograms (float)
56 - grossWeight: the gross weight in kilograms (float)
57 - heading: the heading of the aircraft in degrees (float)
58 - pitch: the pitch of the aircraft in degrees. Positive means pitch down,
59 negative means pitch up (float)
60 - bank: the bank of the aircraft in degrees. Positive means bank left,
61 negative means bank right (float)
62 - ias: the indicated airspeed in knots (float)
63 - mach: the airspeed in mach (float)
64 - groundSpeed: the ground speed (float)
65 - vs: the vertical speed in feet/minutes (float)
66 - radioAltitude: the radio altitude of the aircraft in feet (float)
67 - altitude: the altitude of the aircraft in feet (float)
68 - gLoad: G-load (float)
69 - flapsSet: the selected degrees of the flaps (float)
70 - flaps: the actual degrees of the flaps (float)
71 - fuelWeight[]: the fuel weights in the different tanks in kgs (array of
72 floats of as many items as the number fuel tanks)
73 - n1[]: the N1 values of the turbine engines (array of floats
74 of as many items as the number of engines, present only for aircraft with
75 turbines)
76 - rpm[]: the RPM values of the piston engines (array of floats
77 of as many items as the number of engines, present only for aircraft with
78 pistons)
79 - reverser[]: an array of booleans indicating if the thrust reversers are
80 activated on any of the engines. The number of items equals to the number
81 of engines.
82 - navLightsOn: a boolean indicating if the navigation lights are on
83 - antiCollisionLightsOn: a boolean indicating if the anti-collision lights are on
84 - strobeLightsOn: a boolean indicating if the strobe lights are on
85 - langingLightsOn: a boolean indicating if the landing lights are on
86 - pitotHeatOn: a boolean indicating if the pitot heat is on
87 - parking: a boolean indicating if the parking brake is set
88 - gearsDown: a boolean indicating if the gears are down
89 - spoilersArmed: a boolean indicating if the spoilers have been armed for
90 automatic deployment
91 - spoilersExtension: the percentage of how much the spoiler is extended
92 (float)
93 - altimeter: the altimeter setting in hPa (float)
94 - nav1: the frequency of the NAV1 radio in MHz (string)
95 - nav2: the frequency of the NAV1 radio in MHz (string)
96 - squawk: the transponder code
97 - windSpeed: the speed of the wind at the aircraft in knots (float)
98 - windDirection: the direction of the wind at the aircraft in degrees (float)
99
100 FIXME: needed when taxiing only:
101 - payload weight
102
103 FIXME: needed rarely:
104 - latitude, longitude
105 - transporter
106 - visibility
107 """
108
Note: See TracBrowser for help on using the repository browser.