source: src/mlx/gui/monitor.py@ 87:b13b4d827920

Last change on this file since 87:b13b4d827920 was 77:cc8b178b8102, checked in by István Váradi <ivaradi@…>, 13 years ago

The monitoring window is now separate window

File size: 12.4 KB
Line 
1# The monitoring window
2
3from mlx.gui.common import *
4
5import mlx.const as const
6
7import time
8
9#------------------------------------------------------------------------------
10
11class MonitorWindow(gtk.Window):
12 """The window for the data monitor."""
13 def __init__(self, gui, iconDirectory):
14 """Construct the monitor window."""
15 super(MonitorWindow, self).__init__()
16
17 self._gui = gui
18
19 self.set_title("MAVA Logger X " + const.VERSION + " - Data Monitor")
20 self.set_icon_from_file(os.path.join(iconDirectory, "logo.ico"))
21 self.connect("delete-event",
22 lambda a, b: self._gui.hideMonitorWindow())
23
24 alignment = gtk.Alignment(xscale = 1.0, yscale = 1.0)
25
26 alignment.set_padding(padding_top = 4, padding_bottom = 10,
27 padding_left = 16, padding_right = 16)
28
29 table = gtk.Table(rows = 7, columns = 12)
30 table.set_homogeneous(False)
31 table.set_row_spacings(4)
32 table.set_col_spacings(8)
33
34 (label, self._timestamp) = self._createLabeledEntry("Time:")
35 table.attach(label, 0, 1, 0, 1)
36 table.attach(self._timestamp, 1, 2, 0, 1)
37
38 self._paused = gtk.Label("PAUSED")
39 table.attach(self._paused, 2, 4, 0, 1)
40
41 self._trickMode = gtk.Label("TRICKMODE")
42 table.attach(self._trickMode, 4, 6, 0, 1, xoptions = 0)
43
44 self._overspeed = gtk.Label("OVERSPEED")
45 table.attach(self._overspeed, 6, 8, 0, 1)
46
47 self._stalled = gtk.Label("STALLED")
48 table.attach(self._stalled, 8, 10, 0, 1)
49
50 self._onTheGround = gtk.Label("ONTHEGROUND")
51 table.attach(self._onTheGround, 10, 12, 0, 1)
52
53 (label, self._zfw) = self._createLabeledEntry("ZFW:", 6)
54 table.attach(label, 0, 1, 1, 2)
55 table.attach(self._zfw, 1, 2, 1, 2)
56
57 (label, self._grossWeight) = self._createLabeledEntry("Weight:", 6)
58 table.attach(label, 2, 3, 1, 2)
59 table.attach(self._grossWeight, 3, 4, 1, 2)
60
61 (label, self._heading) = self._createLabeledEntry("Heading:", 3)
62 table.attach(label, 4, 5, 1, 2)
63 table.attach(self._heading, 5, 6, 1, 2)
64
65 (label, self._pitch) = self._createLabeledEntry("Pitch:", 3)
66 table.attach(label, 6, 7, 1, 2)
67 table.attach(self._pitch, 7, 8, 1, 2)
68
69 (label, self._bank) = self._createLabeledEntry("Bank:", 3)
70 table.attach(label, 8, 9, 1, 2)
71 table.attach(self._bank, 9, 10, 1, 2)
72
73 (label, self._vs) = self._createLabeledEntry("VS:", 5)
74 table.attach(label, 10, 11, 1, 2)
75 table.attach(self._vs, 11, 12, 1, 2)
76
77 (label, self._ias) = self._createLabeledEntry("IAS:", 4)
78 table.attach(label, 0, 1, 2, 3)
79 table.attach(self._ias, 1, 2, 2, 3)
80
81 (label, self._mach) = self._createLabeledEntry("Mach:", 4)
82 table.attach(label, 2, 3, 2, 3)
83 table.attach(self._mach, 3, 4, 2, 3)
84
85 (label, self._groundSpeed) = self._createLabeledEntry("GS:", 4)
86 table.attach(label, 4, 5, 2, 3)
87 table.attach(self._groundSpeed, 5, 6, 2, 3)
88
89 (label, self._radioAltitude) = self._createLabeledEntry("Radio alt.:", 6)
90 table.attach(label, 6, 7, 2, 3)
91 table.attach(self._radioAltitude, 7, 8, 2, 3)
92
93 (label, self._altitude) = self._createLabeledEntry("Altitude:", 6)
94 table.attach(label, 8, 9, 2, 3)
95 table.attach(self._altitude, 9, 10, 2, 3)
96
97 (label, self._gLoad) = self._createLabeledEntry("G-Load:", 4)
98 table.attach(label, 10, 11, 2, 3)
99 table.attach(self._gLoad, 11, 12, 2, 3)
100
101 (label, self._flapsSet) = self._createLabeledEntry("Flaps set:", 2)
102 table.attach(label, 0, 1, 3, 4)
103 table.attach(self._flapsSet, 1, 2, 3, 4)
104
105 (label, self._flaps) = self._createLabeledEntry("Flaps:", 2)
106 table.attach(label, 2, 3, 3, 4)
107 table.attach(self._flaps, 3, 4, 3, 4)
108
109 (label, self._altimeter) = self._createLabeledEntry("Altimeter:", 4)
110 table.attach(label, 4, 5, 3, 4)
111 table.attach(self._altimeter, 5, 6, 3, 4)
112
113 (label, self._squawk) = self._createLabeledEntry("Squawk:", 4)
114 table.attach(label, 6, 7, 3, 4)
115 table.attach(self._squawk, 7, 8, 3, 4)
116
117 (label, self._nav1) = self._createLabeledEntry("NAV1:", 5)
118 table.attach(label, 8, 9, 3, 4)
119 table.attach(self._nav1, 9, 10, 3, 4)
120
121 (label, self._nav2) = self._createLabeledEntry("NAV2:", 5)
122 table.attach(label, 10, 11, 3, 4)
123 table.attach(self._nav2, 11, 12, 3, 4)
124
125 (label, self._fuel) = self._createLabeledEntry("Fuel:", 40, xalign = 0.0)
126 table.attach(label, 0, 1, 4, 5)
127 table.attach(self._fuel, 1, 4, 4, 5)
128
129 (label, self._n1) = self._createLabeledEntry("N1/RPM:", 20, xalign = 0.0)
130 table.attach(label, 4, 5, 4, 5)
131 table.attach(self._n1, 5, 8, 4, 5)
132
133 (label, self._reverser) = self._createLabeledEntry("Reverser:", 20, xalign = 0.0)
134 table.attach(label, 8, 9, 4, 5)
135 table.attach(self._reverser, 9, 12, 4, 5)
136
137 self._navLightsOn = gtk.Label("NAV")
138 table.attach(self._navLightsOn, 0, 1, 5, 6)
139
140 self._antiCollisionLightsOn = gtk.Label("ANTICOLLISION")
141 table.attach(self._antiCollisionLightsOn, 1, 3, 5, 6)
142
143 self._strobeLightsOn = gtk.Label("STROBE")
144 table.attach(self._strobeLightsOn, 3, 4, 5, 6)
145
146 self._landingLightsOn = gtk.Label("LANDING")
147 table.attach(self._landingLightsOn, 4, 5, 5, 6)
148
149 self._pitotHeatOn = gtk.Label("PITOT HEAT")
150 table.attach(self._pitotHeatOn, 5, 7, 5, 6)
151
152 self._parking = gtk.Label("PARKING")
153 table.attach(self._parking, 7, 8, 5, 6)
154
155 self._gearsDown = gtk.Label("GEARS DOWN")
156 table.attach(self._gearsDown, 8, 10, 5, 6)
157
158 self._spoilersArmed = gtk.Label("SPOILERS ARMED")
159 table.attach(self._spoilersArmed, 10, 12, 5, 6)
160
161 (label, self._spoilersExtension) = self._createLabeledEntry("Spoilers:", 3)
162 table.attach(label, 0, 1, 6, 7)
163 table.attach(self._spoilersExtension, 1, 2, 6, 7)
164
165 (label, self._windSpeed) = self._createLabeledEntry("Wind speed:", 3)
166 table.attach(label, 2, 3, 6, 7)
167 table.attach(self._windSpeed, 3, 4, 6, 7)
168
169 (label, self._windDirection) = self._createLabeledEntry("Wind from:", 3)
170 table.attach(label, 4, 5, 6, 7)
171 table.attach(self._windDirection, 5, 6, 6, 7)
172
173 alignment.add(table)
174
175 self.add(alignment)
176
177 self.setData()
178
179 def _createLabeledEntry(self, label, width = 8, xalign = 1.0):
180 """Create a labeled entry.
181
182 Return a tuple consisting of:
183 - the box
184 - the entry."""
185
186 alignment = gtk.Alignment(xalign = 1.0, yalign = 0.5, xscale = 1.0)
187 alignment.set_padding(padding_top = 0, padding_bottom = 0,
188 padding_left = 0, padding_right = 16)
189 alignment.add(gtk.Label(label))
190
191 entry = gtk.Entry()
192 entry.set_editable(False)
193 entry.set_width_chars(width)
194 entry.set_max_length(width)
195 entry.set_alignment(xalign)
196
197 return (alignment, entry)
198
199 def setData(self, aircraftState = None):
200 """Set the data.
201
202 If aircraftState is None, everything will be set to its default."""
203 if aircraftState is None:
204 self._timestamp.set_text("--:--:--")
205 self._paused.set_sensitive(False)
206 self._trickMode.set_sensitive(False)
207 self._overspeed.set_sensitive(False)
208 self._stalled.set_sensitive(False)
209 self._onTheGround.set_sensitive(False)
210 self._zfw.set_text("-")
211 self._grossWeight.set_text("-")
212 self._heading.set_text("-")
213 self._pitch.set_text("-")
214 self._bank.set_text("-")
215 self._vs.set_text("-")
216 self._ias.set_text("-")
217 self._mach.set_text("-")
218 self._groundSpeed.set_text("-")
219 self._radioAltitude.set_text("-")
220 self._altitude.set_text("-")
221 self._gLoad.set_text("-")
222 self._flapsSet.set_text("-")
223 self._flaps.set_text("-")
224 self._altimeter.set_text("-")
225 self._squawk.set_text("-")
226 self._nav1.set_text("-")
227 self._nav2.set_text("-")
228 self._fuel.set_text("-")
229 self._n1.set_text("-")
230 self._reverser.set_text("-")
231 self._navLightsOn.set_sensitive(False)
232 self._antiCollisionLightsOn.set_sensitive(False)
233 self._strobeLightsOn.set_sensitive(False)
234 self._landingLightsOn.set_sensitive(False)
235 self._pitotHeatOn.set_sensitive(False)
236 self._parking.set_sensitive(False)
237 self._gearsDown.set_sensitive(False)
238 self._spoilersArmed.set_sensitive(False)
239 self._spoilersExtension.set_text("-")
240 self._windSpeed.set_text("-")
241 self._windDirection.set_text("-")
242 else:
243 self._timestamp.set_text(time.strftime("%H:%M:%S",
244 time.gmtime(aircraftState.timestamp)))
245 self._paused.set_sensitive(aircraftState.paused)
246 self._trickMode.set_sensitive(aircraftState.trickMode)
247 self._overspeed.set_sensitive(aircraftState.overspeed)
248 self._stalled.set_sensitive(aircraftState.stalled)
249 self._onTheGround.set_sensitive(aircraftState.onTheGround)
250 self._zfw.set_text("%.0f" % (aircraftState.zfw,))
251 self._grossWeight.set_text("%.0f" % (aircraftState.grossWeight,))
252 self._heading.set_text("%03.0f" % (aircraftState.heading,))
253 self._pitch.set_text("%.0f" % (aircraftState.pitch,))
254 self._bank.set_text("%.0f" % (aircraftState.bank,))
255 self._vs.set_text("%.0f" % (aircraftState.vs,))
256 self._ias.set_text("%.0f" % (aircraftState.ias,))
257 self._mach.set_text("%.2f" % (aircraftState.mach,))
258 self._groundSpeed.set_text("%.0f" % (aircraftState.groundSpeed,))
259 self._radioAltitude.set_text("%.0f" % (aircraftState.radioAltitude,))
260 self._altitude.set_text("%.0f" % (aircraftState.altitude,))
261 self._gLoad.set_text("%.2f" % (aircraftState.gLoad,))
262 self._flapsSet.set_text("%.0f" % (aircraftState.flapsSet,))
263 self._flaps.set_text("%.0f" % (aircraftState.flaps,))
264 self._altimeter.set_text("%.0f" % (aircraftState.altimeter,))
265 self._squawk.set_text(aircraftState.squawk)
266 self._nav1.set_text(aircraftState.nav1)
267 self._nav2.set_text(aircraftState.nav2)
268
269 fuelStr = ""
270 for fuel in aircraftState.fuel:
271 if fuelStr: fuelStr += ", "
272 fuelStr += "%.0f" % (fuel,)
273 self._fuel.set_text(fuelStr)
274
275 if hasattr(aircraftState, "n1"):
276 n1Str = ""
277 for n1 in aircraftState.n1:
278 if n1Str: n1Str += ", "
279 n1Str += "%.0f" % (n1,)
280 elif hasattr(aircraftState, "rpm"):
281 n1Str = ""
282 for rpm in aircraftState.rpm:
283 if n1Str: n1Str += ", "
284 n1Str += "%.0f" % (rpm,)
285 else:
286 n1Str = "-"
287 self._n1.set_text(n1Str)
288
289 reverserStr = ""
290 for reverser in aircraftState.reverser:
291 if reverserStr: reverserStr += ", "
292 reverserStr += "ON" if reverser else "OFF"
293 self._reverser.set_text(reverserStr)
294
295 self._navLightsOn.set_sensitive(aircraftState.navLightsOn)
296 self._antiCollisionLightsOn.set_sensitive(aircraftState.antiCollisionLightsOn)
297 self._strobeLightsOn.set_sensitive(aircraftState.strobeLightsOn)
298 self._landingLightsOn.set_sensitive(aircraftState.landingLightsOn)
299 self._pitotHeatOn.set_sensitive(aircraftState.pitotHeatOn)
300 self._parking.set_sensitive(aircraftState.parking)
301 self._gearsDown.set_sensitive(aircraftState.gearsDown)
302 self._spoilersArmed.set_sensitive(aircraftState.spoilersArmed)
303 self._spoilersExtension.set_text("%.0f" % (aircraftState.spoilersExtension,))
304 self._windSpeed.set_text("%.0f" % (aircraftState.windSpeed,))
305 self._windDirection.set_text("%03.0f" % (aircraftState.windDirection,))
306
307#------------------------------------------------------------------------------
Note: See TracBrowser for help on using the repository browser.