1 | # Module for the simulator-independent aircraft classes
|
---|
2 |
|
---|
3 | #---------------------------------------------------------------------------------------
|
---|
4 |
|
---|
5 | import time
|
---|
6 |
|
---|
7 | #---------------------------------------------------------------------------------------
|
---|
8 |
|
---|
9 | class Aircraft(object):
|
---|
10 | """Base class for aircraft."""
|
---|
11 | def __init__(self, type):
|
---|
12 | """Construct the aircraft for the given type."""
|
---|
13 | self._type = type
|
---|
14 | self._aircraftState = None
|
---|
15 |
|
---|
16 | @property
|
---|
17 | def type(self):
|
---|
18 | """Get the type of the aircraft."""
|
---|
19 | return self._type
|
---|
20 |
|
---|
21 | def modelChanged(self, aircraftName, modelName):
|
---|
22 | """Called when the simulator's aircraft changes."""
|
---|
23 | print "Aircraft.modelChanged: aircraftName='%s', modelName='%s'" % \
|
---|
24 | (aircraftName, modelName)
|
---|
25 |
|
---|
26 | def handleState(self, aircraftState):
|
---|
27 | """Called when the state of the aircraft changes."""
|
---|
28 | timeStr = time.ctime(aircraftState.timestamp)
|
---|
29 |
|
---|
30 | if self._aircraftState is None or \
|
---|
31 | self._aircraftState.paused != aircraftState.paused:
|
---|
32 | print "Aircraft.handleState: %s: paused=%d" % \
|
---|
33 | (timeStr, aircraftState.paused)
|
---|
34 |
|
---|
35 | if self._aircraftState is None or \
|
---|
36 | self._aircraftState.trickMode != aircraftState.trickMode:
|
---|
37 | print "Aircraft.handleState: %s: trickMode=%d" % \
|
---|
38 | (timeStr, aircraftState.trickMode)
|
---|
39 |
|
---|
40 | if self._aircraftState is None or \
|
---|
41 | self._aircraftState.overspeed != aircraftState.overspeed:
|
---|
42 | print "Aircraft.handleState: %s: overspeed=%d" % \
|
---|
43 | (timeStr, aircraftState.overspeed)
|
---|
44 |
|
---|
45 | if self._aircraftState is None or \
|
---|
46 | self._aircraftState.stalled != aircraftState.stalled:
|
---|
47 | print "Aircraft.handleState: %s: stalled=%d" % \
|
---|
48 | (timeStr, aircraftState.stalled)
|
---|
49 |
|
---|
50 | if self._aircraftState is None or \
|
---|
51 | self._aircraftState.grossWeight != aircraftState.grossWeight:
|
---|
52 | print "Aircraft.handleState: %s: grossWeight=%f" % \
|
---|
53 | (timeStr, aircraftState.grossWeight)
|
---|
54 |
|
---|
55 | if self._aircraftState is None or \
|
---|
56 | self._aircraftState.heading != aircraftState.heading:
|
---|
57 | print "Aircraft.handleState: %s: heading=%f" % \
|
---|
58 | (timeStr, aircraftState.heading)
|
---|
59 |
|
---|
60 | if self._aircraftState is None or \
|
---|
61 | self._aircraftState.pitch != aircraftState.pitch:
|
---|
62 | print "Aircraft.handleState: %s: pitch=%f" % \
|
---|
63 | (timeStr, aircraftState.pitch)
|
---|
64 |
|
---|
65 | if self._aircraftState is None or \
|
---|
66 | self._aircraftState.bank != aircraftState.bank:
|
---|
67 | print "Aircraft.handleState: %s: bank=%f" % \
|
---|
68 | (timeStr, aircraftState.bank)
|
---|
69 |
|
---|
70 | if self._aircraftState is None or \
|
---|
71 | self._aircraftState.ias != aircraftState.ias:
|
---|
72 | print "Aircraft.handleState: %s: ias=%f" % \
|
---|
73 | (timeStr, aircraftState.ias)
|
---|
74 |
|
---|
75 | if self._aircraftState is None or \
|
---|
76 | self._aircraftState.vs != aircraftState.vs:
|
---|
77 | print "Aircraft.handleState: %s: vs=%f" % \
|
---|
78 | (timeStr, aircraftState.vs)
|
---|
79 |
|
---|
80 | if self._aircraftState is None or \
|
---|
81 | self._aircraftState.altitude != aircraftState.altitude:
|
---|
82 | print "Aircraft.handleState: %s: altitude=%f" % \
|
---|
83 | (timeStr, aircraftState.altitude)
|
---|
84 |
|
---|
85 | if self._aircraftState is None or \
|
---|
86 | self._aircraftState.flapsSet != aircraftState.flapsSet:
|
---|
87 | print "Aircraft.handleState: %s: flapsSet=%f" % \
|
---|
88 | (timeStr, aircraftState.flapsSet)
|
---|
89 |
|
---|
90 | if self._aircraftState is None or \
|
---|
91 | self._aircraftState.flaps != aircraftState.flaps:
|
---|
92 | print "Aircraft.handleState: %s: flaps=%f" % \
|
---|
93 | (timeStr, aircraftState.flaps)
|
---|
94 |
|
---|
95 | if self._aircraftState is None or \
|
---|
96 | self._aircraftState.navLightsOn != aircraftState.navLightsOn:
|
---|
97 | print "Aircraft.handleState: %s: navLightsOn=%d" % \
|
---|
98 | (timeStr, aircraftState.navLightsOn)
|
---|
99 |
|
---|
100 | if self._aircraftState is None or \
|
---|
101 | self._aircraftState.antiCollisionLightsOn != aircraftState.antiCollisionLightsOn:
|
---|
102 | print "Aircraft.handleState: %s: antiCollisionLightsOn=%d" % \
|
---|
103 | (timeStr, aircraftState.antiCollisionLightsOn)
|
---|
104 |
|
---|
105 | if self._aircraftState is None or \
|
---|
106 | self._aircraftState.strobeLightsOn != aircraftState.strobeLightsOn:
|
---|
107 | print "Aircraft.handleState: %s: strobeLightsOn=%d" % \
|
---|
108 | (timeStr, aircraftState.strobeLightsOn)
|
---|
109 |
|
---|
110 | if self._aircraftState is None or \
|
---|
111 | self._aircraftState.landingLightsOn != aircraftState.landingLightsOn:
|
---|
112 | print "Aircraft.handleState: %s: landingLightsOn=%d" % \
|
---|
113 | (timeStr, aircraftState.landingLightsOn)
|
---|
114 |
|
---|
115 | if self._aircraftState is None or \
|
---|
116 | self._aircraftState.pitotHeatOn != aircraftState.pitotHeatOn:
|
---|
117 | print "Aircraft.handleState: %s: pitotHeatOn=%d" % \
|
---|
118 | (timeStr, aircraftState.pitotHeatOn)
|
---|
119 |
|
---|
120 | if self._aircraftState is None or \
|
---|
121 | self._aircraftState.gearsDown != aircraftState.gearsDown:
|
---|
122 | print "Aircraft.handleState: %s: gearsDown=%f" % \
|
---|
123 | (timeStr, aircraftState.gearsDown)
|
---|
124 |
|
---|
125 | if self._aircraftState is None or \
|
---|
126 | self._aircraftState.spoilersArmed != aircraftState.spoilersArmed:
|
---|
127 | print "Aircraft.handleState: %s: spoilersArmed=%f" % \
|
---|
128 | (timeStr, aircraftState.spoilersArmed)
|
---|
129 |
|
---|
130 | if self._aircraftState is None or \
|
---|
131 | self._aircraftState.spoilersExtension != aircraftState.spoilersExtension:
|
---|
132 | print "Aircraft.handleState: %s: spoilersExtension=%f" % \
|
---|
133 | (timeStr, aircraftState.spoilersExtension)
|
---|
134 |
|
---|
135 | self._aircraftState = aircraftState
|
---|
136 |
|
---|
137 | #---------------------------------------------------------------------------------------
|
---|
138 |
|
---|