source: src/mlx/gui/monitor.py@ 804:afbbd0132506

version_0.37
Last change on this file since 804:afbbd0132506 was 765:fc1433d4854f, checked in by István Váradi <ivaradi@…>, 9 years ago

The N1 values of the Majestic Dash-8 Q400 are invalidated (re #292)

File size: 18.4 KB
Line 
1
2from mlx.gui.common import *
3
4import mlx.const as const
5import mlx.util as util
6
7import time
8
9#------------------------------------------------------------------------------
10
11## @package mlx.gui.monitor
12#
13# The monitoring window
14#
15# The \ref MonitorWindow class is a window containing the data received from
16# the simulator by the logger.
17
18#------------------------------------------------------------------------------
19
20class MonitorWindow(gtk.Window):
21 """The window for the data monitor."""
22 def __init__(self, gui, iconDirectory):
23 """Construct the monitor window."""
24 super(MonitorWindow, self).__init__()
25
26 self._gui = gui
27
28 self.set_resizable(False)
29 self.set_title(WINDOW_TITLE_BASE + " - Data Monitor")
30 self.set_icon_from_file(os.path.join(iconDirectory, "logo.ico"))
31 self.connect("delete-event",
32 lambda a, b: self._gui.hideMonitorWindow())
33
34 alignment = gtk.Alignment(xscale = 1.0, yscale = 1.0)
35
36 alignment.set_padding(padding_top = 4, padding_bottom = 10,
37 padding_left = 16, padding_right = 16)
38
39 table = gtk.Table(rows = 9, columns = 14)
40 table.set_homogeneous(False)
41 table.set_row_spacings(4)
42 table.set_col_spacings(8)
43
44 (label, self._timestamp) = self._createLabeledEntry("Time:")
45 table.attach(label, 0, 1, 0, 1)
46 table.attach(self._timestamp, 1, 2, 0, 1)
47
48 self._paused = gtk.Label("PAUSED")
49 table.attach(self._paused, 2, 4, 0, 1)
50
51 self._trickMode = gtk.Label("TRICKMODE")
52 table.attach(self._trickMode, 4, 6, 0, 1, xoptions = 0)
53
54 self._overspeed = gtk.Label("OVERSPEED")
55 table.attach(self._overspeed, 6, 8, 0, 1)
56
57 self._stalled = gtk.Label("STALLED")
58 table.attach(self._stalled, 8, 10, 0, 1)
59
60 self._onTheGround = gtk.Label("ONTHEGROUND")
61 table.attach(self._onTheGround, 10, 11, 0, 1)
62
63 self._antiIceOn = gtk.Label("ANTI-ICE")
64 table.attach(self._antiIceOn, 11, 12, 0, 1)
65
66 (label, self._zfw) = self._createLabeledEntry("ZFW:", 6)
67 table.attach(label, 0, 1, 1, 2)
68 table.attach(self._zfw, 1, 2, 1, 2)
69
70 (label, self._grossWeight) = self._createLabeledEntry("Weight:", 6)
71 table.attach(label, 2, 3, 1, 2)
72 table.attach(self._grossWeight, 3, 4, 1, 2)
73
74 (label, self._heading) = self._createLabeledEntry("Heading:", 3)
75 table.attach(label, 4, 5, 1, 2)
76 table.attach(self._heading, 5, 6, 1, 2)
77
78 (label, self._pitch) = self._createLabeledEntry("Pitch:", 3)
79 table.attach(label, 6, 7, 1, 2)
80 table.attach(self._pitch, 7, 8, 1, 2)
81
82 (label, self._bank) = self._createLabeledEntry("Bank:", 3)
83 table.attach(label, 8, 9, 1, 2)
84 table.attach(self._bank, 9, 10, 1, 2)
85
86 (label, self._vs) = self._createLabeledEntry("VS:", 13)
87 table.attach(label, 10, 11, 1, 2)
88 table.attach(self._vs, 11, 12, 1, 2)
89
90 (label, self._ias) = self._createLabeledEntry("IAS:", 11)
91 table.attach(label, 0, 1, 2, 3)
92 table.attach(self._ias, 1, 2, 2, 3)
93
94 (label, self._mach) = self._createLabeledEntry("Mach:", 4)
95 table.attach(label, 2, 3, 2, 3)
96 table.attach(self._mach, 3, 4, 2, 3)
97
98 (label, self._groundSpeed) = self._createLabeledEntry("GS:", 4)
99 table.attach(label, 4, 5, 2, 3)
100 table.attach(self._groundSpeed, 5, 6, 2, 3)
101
102 (label, self._radioAltitude) = self._createLabeledEntry("Radio alt.:", 6)
103 table.attach(label, 6, 7, 2, 3)
104 table.attach(self._radioAltitude, 7, 8, 2, 3)
105
106 (label, self._altitude) = self._createLabeledEntry("Altitude:", 6)
107 table.attach(label, 8, 9, 2, 3)
108 table.attach(self._altitude, 9, 10, 2, 3)
109
110 (label, self._gLoad) = self._createLabeledEntry("G-Load:", 4)
111 table.attach(label, 10, 11, 2, 3)
112 table.attach(self._gLoad, 11, 12, 2, 3)
113
114 (label, self._flapsSet) = self._createLabeledEntry("Flaps set:", 2)
115 table.attach(label, 0, 1, 3, 4)
116 table.attach(self._flapsSet, 1, 2, 3, 4)
117
118 (label, self._flaps) = self._createLabeledEntry("Flaps:", 2)
119 table.attach(label, 2, 3, 3, 4)
120 table.attach(self._flaps, 3, 4, 3, 4)
121
122 (label, self._altimeter) = self._createLabeledEntry("Altimeter:", 4)
123 table.attach(label, 4, 5, 3, 4)
124 table.attach(self._altimeter, 5, 6, 3, 4)
125
126 (label, self._squawk) = self._createLabeledEntry("Squawk:", 4)
127 table.attach(label, 6, 7, 3, 4)
128 table.attach(self._squawk, 7, 8, 3, 4)
129
130 (label, self._nav1) = self._createLabeledEntry("NAV1:", 5)
131 table.attach(label, 8, 9, 3, 4)
132 table.attach(self._nav1, 9, 10, 3, 4)
133
134 (label, self._nav2) = self._createLabeledEntry("NAV2:", 5)
135 table.attach(label, 10, 11, 3, 4)
136 table.attach(self._nav2, 11, 12, 3, 4)
137
138 (label, self._fuel) = self._createLabeledEntry("Fuel:", 40, xalign = 0.0)
139 table.attach(label, 0, 1, 4, 5)
140 table.attach(self._fuel, 1, 4, 4, 5)
141
142 (label, self._n1) = self._createLabeledEntry("N1/RPM:", 20, xalign = 0.0)
143 table.attach(label, 4, 5, 4, 5)
144 table.attach(self._n1, 5, 8, 4, 5)
145
146 (label, self._reverser) = self._createLabeledEntry("Reverser:", 20, xalign = 0.0)
147 table.attach(label, 8, 9, 4, 5)
148 table.attach(self._reverser, 9, 12, 4, 5)
149
150 self._navLightsOn = gtk.Label("NAV")
151 table.attach(self._navLightsOn, 0, 1, 5, 6)
152
153 self._antiCollisionLightsOn = gtk.Label("ANTICOLLISION")
154 table.attach(self._antiCollisionLightsOn, 1, 2, 5, 6)
155
156 self._strobeLightsOn = gtk.Label("STROBE")
157 table.attach(self._strobeLightsOn, 2, 3, 5, 6)
158
159 self._landingLightsOn = gtk.Label("LANDING")
160 table.attach(self._landingLightsOn, 3, 4, 5, 6)
161
162 self._pitotHeatOn = gtk.Label("PITOT HEAT")
163 table.attach(self._pitotHeatOn, 4, 5, 5, 6)
164
165 self._parking = gtk.Label("PARKING")
166 table.attach(self._parking, 5, 6, 5, 6)
167
168 self._gearControlDown = gtk.Label("GEAR LEVER DOWN")
169 table.attach(self._gearControlDown, 6, 8, 5, 6)
170
171 self._gearsDown = gtk.Label("GEARS DOWN")
172 table.attach(self._gearsDown, 8, 10, 5, 6)
173
174 self._spoilersArmed = gtk.Label("SPOILERS ARMED")
175 table.attach(self._spoilersArmed, 10, 12, 5, 6)
176
177 (label, self._spoilersExtension) = self._createLabeledEntry("Spoilers:", 3)
178 table.attach(label, 0, 1, 6, 7)
179 table.attach(self._spoilersExtension, 1, 2, 6, 7)
180
181 (label, self._windSpeed) = self._createLabeledEntry("Wind speed:", 3)
182 table.attach(label, 2, 3, 6, 7)
183 table.attach(self._windSpeed, 3, 4, 6, 7)
184
185 (label, self._windDirection) = self._createLabeledEntry("Wind from:", 3)
186 table.attach(label, 4, 5, 6, 7)
187 table.attach(self._windDirection, 5, 6, 6, 7)
188
189 (label, self._position) = self._createLabeledEntry("Position:", 25)
190 table.attach(label, 6, 7, 6, 7)
191 table.attach(self._position, 7, 10, 6, 7)
192
193 (label, self._elevatorTrim) = self._createLabeledEntry("Trim:", 5)
194 table.attach(label, 10, 11, 6, 7)
195 table.attach(self._elevatorTrim, 11, 12, 6, 7)
196
197 self._apMaster = gtk.Label("AP MASTER")
198 table.attach(self._apMaster, 0, 1, 7, 8)
199
200 self._apHeadingHold = gtk.Label("AP HDG HOLD")
201 table.attach(self._apHeadingHold, 1, 2, 7, 8)
202
203 (label, self._apHeading) = self._createLabeledEntry("AP HDG:", 5)
204 table.attach(label, 2, 3, 7, 8)
205 table.attach(self._apHeading, 3, 4, 7, 8)
206
207 self._xpdrC = gtk.Label("XPDR C")
208 table.attach(self._xpdrC, 4, 5, 7, 8)
209
210 self._apAltitudeHold = gtk.Label("AP ALT HOLD")
211 table.attach(self._apAltitudeHold, 5, 6, 7, 8)
212
213 (label, self._apAltitude) = self._createLabeledEntry("AP ALT:", 10)
214 table.attach(label, 6, 7, 7, 8)
215 table.attach(self._apAltitude, 7, 8, 7, 8)
216
217 (label, self._adf1) = self._createLabeledEntry("ADF1:", 5)
218 table.attach(label, 8, 9, 7, 8)
219 table.attach(self._adf1, 9, 10, 7, 8)
220
221 (label, self._adf2) = self._createLabeledEntry("ADF2:", 5)
222 table.attach(label, 10, 11, 7, 8)
223 table.attach(self._adf2, 11, 12, 7, 8)
224
225 (label, self._qnh) = self._createLabeledEntry("QNH:", 7)
226 table.attach(label, 0, 1, 8, 9)
227 table.attach(self._qnh, 1, 2, 8, 9)
228
229 (label, self._cog) = self._createLabeledEntry("CoG:", 7)
230 table.attach(label, 2, 3, 8, 9)
231 table.attach(self._cog, 3, 4, 8, 9)
232
233 (label, self._ils) = self._createLabeledEntry("ILS:", 7)
234 table.attach(label, 4, 5, 8, 9)
235 table.attach(self._ils, 5, 6, 8, 9)
236
237 (label, self._crs1) = self._createLabeledEntry("CRS1:", 7)
238 table.attach(label, 6, 7, 8, 9)
239 table.attach(self._crs1, 7, 8, 8, 9)
240
241 (label, self._crs2) = self._createLabeledEntry("CRS2:", 7)
242 table.attach(label, 8, 9, 8, 9)
243 table.attach(self._crs2, 9, 10, 8, 9)
244
245 (label, self._crsi) = self._createLabeledEntry("CRSI:", 7)
246 table.attach(label, 10, 11, 8, 9)
247 table.attach(self._crsi, 11, 12, 8, 9)
248
249 alignment.add(table)
250
251 self.add(alignment)
252
253 self._previousState = None
254
255 self.setData()
256
257 def _createLabeledEntry(self, label, width = 8, xalign = 1.0):
258 """Create a labeled entry.
259
260 Return a tuple consisting of:
261 - the box
262 - the entry."""
263
264 alignment = gtk.Alignment(xalign = 1.0, yalign = 0.5, xscale = 1.0)
265 alignment.set_padding(padding_top = 0, padding_bottom = 0,
266 padding_left = 0, padding_right = 16)
267 alignment.add(gtk.Label(label))
268
269 entry = gtk.Entry()
270 entry.set_editable(False)
271 entry.set_width_chars(width)
272 entry.set_max_length(width)
273 entry.set_alignment(xalign)
274
275 return (alignment, entry)
276
277 def setData(self, aircraftState = None):
278 """Set the data.
279
280 If aircraftState is None, everything will be set to its default."""
281 if aircraftState is None:
282 self._timestamp.set_text("--:--:--")
283 self._paused.set_sensitive(False)
284 self._trickMode.set_sensitive(False)
285 self._overspeed.set_sensitive(False)
286 self._stalled.set_sensitive(False)
287 self._onTheGround.set_sensitive(False)
288 self._antiIceOn.set_sensitive(False)
289 self._zfw.set_text("-")
290 self._grossWeight.set_text("-")
291 self._heading.set_text("-")
292 self._pitch.set_text("-")
293 self._bank.set_text("-")
294 self._vs.set_text("-")
295 self._ias.set_text("-")
296 self._mach.set_text("-")
297 self._groundSpeed.set_text("-")
298 self._radioAltitude.set_text("-")
299 self._altitude.set_text("-")
300 self._gLoad.set_text("-")
301 self._flapsSet.set_text("-")
302 self._flaps.set_text("-")
303 self._altimeter.set_text("-")
304 self._squawk.set_text("-")
305 self._nav1.set_text("-")
306 self._nav2.set_text("-")
307 self._fuel.set_text("-")
308 self._n1.set_text("-")
309 self._reverser.set_text("-")
310 self._navLightsOn.set_sensitive(False)
311 self._antiCollisionLightsOn.set_sensitive(False)
312 self._strobeLightsOn.set_sensitive(False)
313 self._landingLightsOn.set_text("LANDING")
314 self._landingLightsOn.set_sensitive(False)
315 self._pitotHeatOn.set_sensitive(False)
316 self._parking.set_sensitive(False)
317 self._gearControlDown.set_sensitive(False)
318 self._gearsDown.set_sensitive(False)
319 self._spoilersArmed.set_sensitive(False)
320 self._spoilersExtension.set_text("-")
321 self._windSpeed.set_text("-")
322 self._windDirection.set_text("-")
323 self._position.set_text("-")
324 self._elevatorTrim.set_text("-")
325 self._apMaster.set_sensitive(False)
326 self._apHeadingHold.set_sensitive(False)
327 self._apHeading.set_text("-")
328 self._xpdrC.set_sensitive(False)
329 self._apAltitudeHold.set_sensitive(False)
330 self._apAltitude.set_text("-")
331 self._adf1.set_text("-")
332 self._adf2.set_text("-")
333 self._qnh.set_text("-")
334 self._cog.set_text("-")
335 self._ils.set_text("-")
336 self._crs1.set_text("-")
337 self._crs2.set_text("-")
338 self._crsi.set_text("-")
339 else:
340 self._timestamp.set_text(time.strftime("%H:%M:%S",
341 time.gmtime(aircraftState.timestamp)))
342 self._paused.set_sensitive(aircraftState.paused)
343 self._trickMode.set_sensitive(aircraftState.trickMode)
344 self._overspeed.set_sensitive(aircraftState.overspeed)
345 self._stalled.set_sensitive(aircraftState.stalled)
346 self._onTheGround.set_sensitive(aircraftState.onTheGround)
347 self._antiIceOn.set_sensitive(aircraftState.antiIceOn is True)
348 self._zfw.set_text("%.0f" % (aircraftState.zfw,))
349 self._grossWeight.set_text("%.0f" % (aircraftState.grossWeight,))
350 self._heading.set_text("%03.0f" % (aircraftState.heading,))
351 self._pitch.set_text("%.0f" % (aircraftState.pitch,))
352 self._bank.set_text("%.0f" % (aircraftState.bank,))
353 self._vs.set_text("%.0f (%.0f)" % (aircraftState.vs,
354 aircraftState.smoothedVS))
355 self._ias.set_text("%.0f (%.0f)" % (aircraftState.ias,
356 aircraftState.smoothedIAS))
357 self._mach.set_text("%.2f" % (aircraftState.mach,))
358 self._groundSpeed.set_text("%.0f" % (aircraftState.groundSpeed,))
359 self._radioAltitude.set_text("%.0f" % (aircraftState.radioAltitude,))
360 self._altitude.set_text("%.0f" % (aircraftState.altitude,))
361 self._gLoad.set_text("%.2f" % (aircraftState.gLoad,))
362 self._flapsSet.set_text("%.0f" % (aircraftState.flapsSet,))
363 self._flaps.set_text("%.0f" % (aircraftState.flaps,))
364 self._altimeter.set_text("%.0f" % (aircraftState.altimeter,))
365 self._squawk.set_text(aircraftState.squawk)
366 self._nav1.set_text("-" if aircraftState.nav1 is None else aircraftState.nav1)
367 self._nav2.set_text("-" if aircraftState.nav2 is None else aircraftState.nav2)
368 self._qnh.set_text("%.0f" % (aircraftState.qnh,))
369
370 fuelStr = ""
371 for (_tank, fuel) in aircraftState.fuel:
372 if fuelStr: fuelStr += ", "
373 fuelStr += "%.0f" % (fuel,)
374 self._fuel.set_text(fuelStr)
375
376 if aircraftState.n1 is not None:
377 n1Str = ""
378 for n1 in aircraftState.n1:
379 if n1Str: n1Str += ", "
380 if n1 is None:
381 n1Str += "?"
382 else:
383 n1Str += "%.0f" % (n1,)
384 elif aircraftState.rpm is not None:
385 n1Str = ""
386 for rpm in aircraftState.rpm:
387 if n1Str: n1Str += ", "
388 n1Str += "%.0f" % (rpm,)
389 else:
390 n1Str = "-"
391 self._n1.set_text(n1Str)
392
393 reverserStr = ""
394 for reverser in aircraftState.reverser:
395 if reverserStr: reverserStr += ", "
396 reverserStr += "ON" if reverser else "OFF"
397 self._reverser.set_text(reverserStr)
398
399 self._navLightsOn.set_sensitive(aircraftState.navLightsOn is True)
400 self._antiCollisionLightsOn.set_sensitive(aircraftState.antiCollisionLightsOn is True)
401 self._strobeLightsOn.set_sensitive(aircraftState.strobeLightsOn is True)
402
403 if self._previousState is None or \
404 ((self._previousState.landingLightsOn is None)!=
405 (aircraftState.landingLightsOn is None)):
406 if aircraftState.landingLightsOn is None:
407 self._landingLightsOn.set_markup('<span strikethrough="true">LANDING</span>')
408 else:
409 self._landingLightsOn.set_text("LANDING")
410 self._landingLightsOn.set_sensitive(aircraftState.landingLightsOn is True)
411
412 self._pitotHeatOn.set_sensitive(aircraftState.pitotHeatOn is True)
413 self._parking.set_sensitive(aircraftState.parking)
414 self._gearControlDown.set_sensitive(aircraftState.gearControlDown)
415 self._gearsDown.set_sensitive(aircraftState.gearsDown)
416 self._spoilersArmed.set_sensitive(aircraftState.spoilersArmed is True)
417 self._spoilersExtension.set_text("%.0f" % (aircraftState.spoilersExtension,))
418 self._windSpeed.set_text("%.0f" % (aircraftState.windSpeed,))
419 self._windDirection.set_text("%03.0f" % (aircraftState.windDirection,))
420 self._position.set_text(util.getCoordinateString((aircraftState.latitude,
421 aircraftState.longitude)))
422 self._elevatorTrim.set_text("%.2f" % (aircraftState.elevatorTrim,))
423 self._apMaster.set_sensitive(aircraftState.apMaster is True)
424 self._apHeadingHold.set_sensitive(aircraftState.apHeadingHold is True)
425 self._apHeading.set_text("-" if aircraftState.apHeading is None
426 else "%03.0f" % (aircraftState.apHeading,))
427 self._xpdrC.set_sensitive(aircraftState.xpdrC is True)
428 self._apAltitudeHold.set_sensitive(aircraftState.apAltitudeHold is True)
429 self._apAltitude.set_text("-" if aircraftState.apAltitude is None
430 else "%5.0f" % (aircraftState.apAltitude,))
431
432 self._adf1.set_text("-" if aircraftState.adf1 is None else aircraftState.adf1)
433 self._adf2.set_text("-" if aircraftState.adf2 is None else aircraftState.adf2)
434 self._cog.set_text("%.2f%%" % (aircraftState.cog*100.0,))
435
436 self._ils.set_text("-" if aircraftState.ils is None else aircraftState.ils)
437
438 self._crs1.set_text("-" if aircraftState.nav1_obs is None else str(aircraftState.nav1_obs))
439 self._crs2.set_text("-" if aircraftState.nav2_obs is None else str(aircraftState.nav2_obs))
440 self._crsi.set_text("-" if aircraftState.ils_obs is None else str(aircraftState.ils_obs))
441
442#------------------------------------------------------------------------------
Note: See TracBrowser for help on using the repository browser.