source: src/fs.py@ 8:85698811c70e

Last change on this file since 8:85698811c70e was 8:85698811c70e, checked in by István Váradi <ivaradi@…>, 12 years ago

The tracking of flight stages and some basic logging functionality works

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 - grossWeight: the gross weight in kilograms (float)
56 - heading: the heading of the aircraft in degrees (float)
57 - pitch: the pitch of the aircraft in degrees. Positive means pitch down,
58 negative means pitch up (float)
59 - bank: the bank of the aircraft in degrees. Positive means bank left,
60 negative means bank right (float)
61 - ias: the indicated airspeed in knots (float)
62 - groundSpeed: the ground speed (float)
63 - vs: the vertical speed in feet/minutes (float)
64 - radioAltitude: the radio altitude of the aircraft in feet (float)
65 - altitude: the altitude of the aircraft in feet (float)
66 - gLoad: G-load (float)
67 - flapsSet: the selected degrees of the flaps (float)
68 - flaps: the actual degrees of the flaps (float)
69 - fuelWeight[]: the fuel weights in the different tanks in kgs (array of
70 floats of as many items as the number fuel tanks)
71 - n1[]: the N1 values of the turbine engines (array of floats
72 of as many items as the number of engines, present only for aircraft with
73 turbines)
74 - rpm[]: the RPM values of the piston engines (array of floats
75 of as many items as the number of engines, present only for aircraft with
76 pistons)
77 - reverser[]: an array of booleans indicating if the thrust reversers are
78 activated on any of the engines. The number of items equals to the number
79 of engines.
80 - navLightsOn: a boolean indicating if the navigation lights are on
81 - antiCollisionLightsOn: a boolean indicating if the anti-collision lights are on
82 - strobeLightsOn: a boolean indicating if the strobe lights are on
83 - langingLightsOn: a boolean indicating if the landing lights are on
84 - pitotHeatOn: a boolean indicating if the pitot heat is on
85 - parking: a boolean indicating if the parking brake is set
86 - gearsDown: a boolean indicating if the gears are down
87 - spoilersArmed: a boolean indicating if the spoilers have been armed for
88 automatic deployment
89 - spoilersExtension: the percentage of how much the spoiler is extended
90 (float)
91 - altimeter: the altimeter setting in hPa (float)
92 - nav1: the frequency of the NAV1 radio in MHz (string)
93 - nav2: the frequency of the NAV1 radio in MHz (string)
94 - squawk: the transponder code
95
96 FIXME: needed when taxiing only:
97 - zfw: the Zero Fuel Weight in klograms (float)
98 - payload weight
99
100 FIXME: needed for touchdown only:
101 - ambientWindDirection: the ambient wind direction around the aircraft (float)
102 - ambientWindSpeed: the ambient wind speed around the aircraft in knowns (float)
103 - tdRate: the touchdown rate calculated by FSUIPC (float)
104
105 FIXME: needed rarely:
106 - latitude, longitude
107 - transporter
108 - visibility
109 """
110
Note: See TracBrowser for help on using the repository browser.