source: src/fs.py@ 7:f8d6fda3c66d

Last change on this file since 7:f8d6fda3c66d was 6:db83d19666dc, checked in by István Váradi <ivaradi@…>, 13 years ago

A bit of work on the constants

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