[42] | 1 | # The flight handling "wizard"
|
---|
| 2 |
|
---|
| 3 | from mlx.gui.common import *
|
---|
| 4 |
|
---|
[51] | 5 | import mlx.const as const
|
---|
| 6 | import mlx.fs as fs
|
---|
[60] | 7 | from mlx.checks import PayloadChecker
|
---|
[89] | 8 | import mlx.util as util
|
---|
[97] | 9 | from mlx.pirep import PIREP
|
---|
[51] | 10 |
|
---|
[61] | 11 | import datetime
|
---|
| 12 | import time
|
---|
| 13 |
|
---|
[78] | 14 | #------------------------------------------------------------------------------
|
---|
| 15 |
|
---|
| 16 | acftTypeNames = { const.AIRCRAFT_B736: "Boeing 737-600",
|
---|
| 17 | const.AIRCRAFT_B737: "Boeing 737-700",
|
---|
| 18 | const.AIRCRAFT_B738: "Boeing 737-800",
|
---|
| 19 | const.AIRCRAFT_DH8D: "Bombardier Dash 8-Q400",
|
---|
| 20 | const.AIRCRAFT_B733: "Boeing 737-300",
|
---|
| 21 | const.AIRCRAFT_B734: "Boeing 737-400",
|
---|
| 22 | const.AIRCRAFT_B735: "Boeing 737-500",
|
---|
| 23 | const.AIRCRAFT_B762: "Boeing 767-200",
|
---|
| 24 | const.AIRCRAFT_B763: "Boeing 767-300",
|
---|
| 25 | const.AIRCRAFT_CRJ2: "Bombardier CRJ200",
|
---|
| 26 | const.AIRCRAFT_F70: "Fokker 70",
|
---|
| 27 | const.AIRCRAFT_DC3: "Lisunov Li-2",
|
---|
| 28 | const.AIRCRAFT_T134: "Tupolev Tu-134",
|
---|
| 29 | const.AIRCRAFT_T154: "Tupolev Tu-154",
|
---|
| 30 | const.AIRCRAFT_YK40: "Yakovlev Yak-40" }
|
---|
| 31 |
|
---|
[42] | 32 | #-----------------------------------------------------------------------------
|
---|
| 33 |
|
---|
[44] | 34 | class Page(gtk.Alignment):
|
---|
[42] | 35 | """A page in the flight wizard."""
|
---|
[94] | 36 | def __init__(self, wizard, title, help, completedHelp = None):
|
---|
[42] | 37 | """Construct the page."""
|
---|
[44] | 38 | super(Page, self).__init__(xalign = 0.0, yalign = 0.0,
|
---|
| 39 | xscale = 1.0, yscale = 1.0)
|
---|
| 40 | self.set_padding(padding_top = 4, padding_bottom = 4,
|
---|
| 41 | padding_left = 12, padding_right = 12)
|
---|
| 42 |
|
---|
| 43 | frame = gtk.Frame()
|
---|
| 44 | self.add(frame)
|
---|
| 45 |
|
---|
| 46 | style = self.get_style() if pygobject else self.rc_get_style()
|
---|
| 47 |
|
---|
| 48 | self._vbox = gtk.VBox()
|
---|
[48] | 49 | self._vbox.set_homogeneous(False)
|
---|
[44] | 50 | frame.add(self._vbox)
|
---|
| 51 |
|
---|
| 52 | eventBox = gtk.EventBox()
|
---|
| 53 | eventBox.modify_bg(0, style.bg[3])
|
---|
| 54 |
|
---|
| 55 | alignment = gtk.Alignment(xalign = 0.0, xscale = 0.0)
|
---|
| 56 |
|
---|
| 57 | label = gtk.Label(title)
|
---|
| 58 | label.modify_fg(0, style.fg[3])
|
---|
| 59 | label.modify_font(pango.FontDescription("bold 24"))
|
---|
| 60 | alignment.set_padding(padding_top = 4, padding_bottom = 4,
|
---|
| 61 | padding_left = 6, padding_right = 0)
|
---|
| 62 |
|
---|
| 63 | alignment.add(label)
|
---|
| 64 | eventBox.add(alignment)
|
---|
| 65 |
|
---|
| 66 | self._vbox.pack_start(eventBox, False, False, 0)
|
---|
| 67 |
|
---|
[79] | 68 | mainBox = gtk.VBox()
|
---|
[48] | 69 |
|
---|
| 70 | alignment = gtk.Alignment(xalign = 0.0, yalign = 0.0,
|
---|
| 71 | xscale = 1.0, yscale = 1.0)
|
---|
| 72 | alignment.set_padding(padding_top = 16, padding_bottom = 16,
|
---|
| 73 | padding_left = 16, padding_right = 16)
|
---|
[79] | 74 | alignment.add(mainBox)
|
---|
[48] | 75 | self._vbox.pack_start(alignment, True, True, 0)
|
---|
| 76 |
|
---|
| 77 | alignment = gtk.Alignment(xalign = 0.5, yalign = 0.0,
|
---|
[94] | 78 | xscale = 0.0, yscale = 0.0)
|
---|
[50] | 79 | alignment.set_padding(padding_top = 0, padding_bottom = 16,
|
---|
| 80 | padding_left = 0, padding_right = 0)
|
---|
[48] | 81 |
|
---|
[94] | 82 | self._help = help
|
---|
| 83 | self._completedHelp = completedHelp
|
---|
| 84 |
|
---|
| 85 | if self._completedHelp is None or \
|
---|
| 86 | len(help.splitlines())>=len(completedHelp.splitlines()):
|
---|
| 87 | longerHelp = help
|
---|
| 88 | else:
|
---|
| 89 | longerHelp = completedHelp
|
---|
| 90 |
|
---|
| 91 | self._helpLabel = gtk.Label(completedHelp)
|
---|
| 92 | # FIXME: should be a constant in common
|
---|
| 93 | self._helpLabel.set_justify(gtk.Justification.CENTER if pygobject
|
---|
| 94 | else gtk.JUSTIFY_CENTER)
|
---|
| 95 | self._helpLabel.set_use_markup(True)
|
---|
| 96 | alignment.add(self._helpLabel)
|
---|
[79] | 97 | mainBox.pack_start(alignment, False, False, 0)
|
---|
[44] | 98 |
|
---|
| 99 | self._mainAlignment = gtk.Alignment(xalign = 0.5, yalign = 0.5,
|
---|
[48] | 100 | xscale = 1.0, yscale = 1.0)
|
---|
[79] | 101 | mainBox.pack_start(self._mainAlignment, True, True, 0)
|
---|
[48] | 102 |
|
---|
| 103 | buttonAlignment = gtk.Alignment(xalign = 1.0, xscale=0.0, yscale = 0.0)
|
---|
[44] | 104 | buttonAlignment.set_padding(padding_top = 4, padding_bottom = 10,
|
---|
| 105 | padding_left = 16, padding_right = 16)
|
---|
| 106 |
|
---|
[70] | 107 | self._buttonBox = gtk.HBox()
|
---|
| 108 | self._buttonBox.set_homogeneous(False)
|
---|
[46] | 109 | self._defaultButton = None
|
---|
[44] | 110 | buttonAlignment.add(self._buttonBox)
|
---|
| 111 |
|
---|
| 112 | self._vbox.pack_start(buttonAlignment, False, False, 0)
|
---|
| 113 |
|
---|
[42] | 114 | self._wizard = wizard
|
---|
| 115 |
|
---|
[94] | 116 | self._completed = False
|
---|
[70] | 117 | self._fromPage = None
|
---|
| 118 |
|
---|
[44] | 119 | def setMainWidget(self, widget):
|
---|
| 120 | """Set the given widget as the main one."""
|
---|
| 121 | self._mainAlignment.add(widget)
|
---|
| 122 |
|
---|
[46] | 123 | def addButton(self, label, default = False):
|
---|
[44] | 124 | """Add a button with the given label.
|
---|
| 125 |
|
---|
| 126 | Return the button object created."""
|
---|
| 127 | button = gtk.Button(label)
|
---|
[70] | 128 | self._buttonBox.pack_start(button, False, False, 4)
|
---|
[48] | 129 | button.set_use_underline(True)
|
---|
[46] | 130 | if default:
|
---|
| 131 | button.set_can_default(True)
|
---|
| 132 | self._defaultButton = button
|
---|
[44] | 133 | return button
|
---|
| 134 |
|
---|
[94] | 135 | def initialize(self):
|
---|
| 136 | """Initialize the page.
|
---|
| 137 |
|
---|
| 138 | It sets up the primary help, and calls the activate() function."""
|
---|
| 139 | self._helpLabel.set_markup(self._help)
|
---|
| 140 | self._helpLabel.set_sensitive(True)
|
---|
| 141 | self.activate()
|
---|
| 142 |
|
---|
[48] | 143 | def activate(self):
|
---|
| 144 | """Called when this page becomes active.
|
---|
| 145 |
|
---|
| 146 | This default implementation does nothing."""
|
---|
| 147 | pass
|
---|
| 148 |
|
---|
[94] | 149 | def complete(self):
|
---|
| 150 | """Called when the page is completed.
|
---|
| 151 |
|
---|
| 152 | It greys out/changes the help text and then calls finalize()."""
|
---|
| 153 | self.finalize()
|
---|
| 154 | if self._completedHelp is None:
|
---|
| 155 | self._helpLabel.set_sensitive(False)
|
---|
| 156 | else:
|
---|
| 157 | self._helpLabel.set_markup(self._completedHelp)
|
---|
| 158 | self._completed = True
|
---|
| 159 |
|
---|
[70] | 160 | def finalize(self):
|
---|
| 161 | """Called when the page is finalized."""
|
---|
| 162 | pass
|
---|
| 163 |
|
---|
[46] | 164 | def grabDefault(self):
|
---|
| 165 | """If the page has a default button, make it the default one."""
|
---|
| 166 | if self._defaultButton is not None:
|
---|
| 167 | self._defaultButton.grab_default()
|
---|
[67] | 168 |
|
---|
| 169 | def reset(self):
|
---|
| 170 | """Reset the page if the wizard is reset."""
|
---|
[94] | 171 | self._completed = False
|
---|
[70] | 172 | self._fromPage = None
|
---|
| 173 |
|
---|
| 174 | def goBack(self):
|
---|
| 175 | """Go to the page we were invoked from."""
|
---|
| 176 | assert self._fromPage is not None
|
---|
| 177 |
|
---|
| 178 | self._wizard.setCurrentPage(self._fromPage, finalize = False)
|
---|
[46] | 179 |
|
---|
[42] | 180 | #-----------------------------------------------------------------------------
|
---|
| 181 |
|
---|
| 182 | class LoginPage(Page):
|
---|
| 183 | """The login page."""
|
---|
| 184 | def __init__(self, wizard):
|
---|
| 185 | """Construct the login page."""
|
---|
[44] | 186 | help = "Enter your MAVA pilot's ID and password to\n" \
|
---|
| 187 | "log in to the MAVA website and download\n" \
|
---|
| 188 | "your booked flights."
|
---|
| 189 | super(LoginPage, self).__init__(wizard, "Login", help)
|
---|
[42] | 190 |
|
---|
[48] | 191 | alignment = gtk.Alignment(xalign = 0.5, yalign = 0.5,
|
---|
| 192 | xscale = 0.0, yscale = 0.0)
|
---|
| 193 |
|
---|
[45] | 194 | table = gtk.Table(2, 3)
|
---|
[42] | 195 | table.set_row_spacings(4)
|
---|
| 196 | table.set_col_spacings(32)
|
---|
[48] | 197 | alignment.add(table)
|
---|
| 198 | self.setMainWidget(alignment)
|
---|
[42] | 199 |
|
---|
| 200 | labelAlignment = gtk.Alignment(xalign=1.0, xscale=0.0)
|
---|
[45] | 201 | label = gtk.Label("Pilot _ID:")
|
---|
| 202 | label.set_use_underline(True)
|
---|
| 203 | labelAlignment.add(label)
|
---|
[42] | 204 | table.attach(labelAlignment, 0, 1, 0, 1)
|
---|
| 205 |
|
---|
| 206 | self._pilotID = gtk.Entry()
|
---|
| 207 | self._pilotID.connect("changed", self._setLoginButton)
|
---|
[45] | 208 | self._pilotID.set_tooltip_text("Enter your MAVA pilot's ID. This "
|
---|
| 209 | "usually starts with a "
|
---|
| 210 | "'P' followed by 3 digits.")
|
---|
[42] | 211 | table.attach(self._pilotID, 1, 2, 0, 1)
|
---|
[45] | 212 | label.set_mnemonic_widget(self._pilotID)
|
---|
[42] | 213 |
|
---|
| 214 | labelAlignment = gtk.Alignment(xalign=1.0, xscale=0.0)
|
---|
[45] | 215 | label = gtk.Label("_Password:")
|
---|
| 216 | label.set_use_underline(True)
|
---|
| 217 | labelAlignment.add(label)
|
---|
[42] | 218 | table.attach(labelAlignment, 0, 1, 1, 2)
|
---|
| 219 |
|
---|
| 220 | self._password = gtk.Entry()
|
---|
| 221 | self._password.set_visibility(False)
|
---|
| 222 | self._password.connect("changed", self._setLoginButton)
|
---|
[45] | 223 | self._password.set_tooltip_text("Enter the password for your pilot's ID")
|
---|
[42] | 224 | table.attach(self._password, 1, 2, 1, 2)
|
---|
[45] | 225 | label.set_mnemonic_widget(self._password)
|
---|
[42] | 226 |
|
---|
[45] | 227 | self._rememberButton = gtk.CheckButton("_Remember password")
|
---|
| 228 | self._rememberButton.set_use_underline(True)
|
---|
| 229 | self._rememberButton.set_tooltip_text("If checked, your password will "
|
---|
| 230 | "be stored, so that you should "
|
---|
| 231 | "not have to enter it every time. "
|
---|
| 232 | "Note, however, that the password "
|
---|
| 233 | "is stored as text, and anybody "
|
---|
| 234 | "who can access your files will "
|
---|
| 235 | "be able to read it.")
|
---|
| 236 | table.attach(self._rememberButton, 1, 2, 2, 3, ypadding = 8)
|
---|
| 237 |
|
---|
[46] | 238 | self._loginButton = self.addButton("_Login", default = True)
|
---|
[42] | 239 | self._loginButton.set_sensitive(False)
|
---|
| 240 | self._loginButton.connect("clicked", self._loginClicked)
|
---|
[92] | 241 | self._loginButton.set_tooltip_text("Click to log in.")
|
---|
| 242 |
|
---|
| 243 | def activate(self):
|
---|
| 244 | """Activate the page."""
|
---|
[42] | 245 | config = self._wizard.gui.config
|
---|
| 246 | self._pilotID.set_text(config.pilotID)
|
---|
| 247 | self._password.set_text(config.password)
|
---|
[45] | 248 | self._rememberButton.set_active(config.rememberPassword)
|
---|
[42] | 249 |
|
---|
| 250 | def _setLoginButton(self, entry):
|
---|
| 251 | """Set the login button's sensitivity.
|
---|
| 252 |
|
---|
| 253 | The button is sensitive only if both the pilot ID and the password
|
---|
| 254 | fields contain values."""
|
---|
| 255 | self._loginButton.set_sensitive(self._pilotID.get_text()!="" and
|
---|
| 256 | self._password.get_text()!="")
|
---|
| 257 |
|
---|
| 258 | def _loginClicked(self, button):
|
---|
| 259 | """Called when the login button was clicked."""
|
---|
[70] | 260 | self._loginButton.set_sensitive(False)
|
---|
| 261 | gui = self._wizard.gui
|
---|
| 262 | gui.beginBusy("Logging in...")
|
---|
| 263 | gui.webHandler.login(self._loginResultCallback,
|
---|
| 264 | self._pilotID.get_text(),
|
---|
| 265 | self._password.get_text())
|
---|
[42] | 266 |
|
---|
| 267 | def _loginResultCallback(self, returned, result):
|
---|
| 268 | """The login result callback, called in the web handler's thread."""
|
---|
| 269 | gobject.idle_add(self._handleLoginResult, returned, result)
|
---|
| 270 |
|
---|
| 271 | def _handleLoginResult(self, returned, result):
|
---|
| 272 | """Handle the login result."""
|
---|
[49] | 273 | self._wizard.gui.endBusy()
|
---|
[70] | 274 | self._loginButton.set_sensitive(True)
|
---|
[42] | 275 | if returned:
|
---|
| 276 | if result.loggedIn:
|
---|
| 277 | config = self._wizard.gui.config
|
---|
[45] | 278 |
|
---|
[42] | 279 | config.pilotID = self._pilotID.get_text()
|
---|
[45] | 280 |
|
---|
| 281 | rememberPassword = self._rememberButton.get_active()
|
---|
| 282 | config.password = self._password.get_text() if rememberPassword \
|
---|
| 283 | else ""
|
---|
| 284 |
|
---|
| 285 | config.rememberPassword = rememberPassword
|
---|
| 286 |
|
---|
[43] | 287 | config.save()
|
---|
[48] | 288 | self._wizard._loginResult = result
|
---|
[42] | 289 | self._wizard.nextPage()
|
---|
| 290 | else:
|
---|
| 291 | dialog = gtk.MessageDialog(type = MESSAGETYPE_ERROR,
|
---|
| 292 | buttons = BUTTONSTYPE_OK,
|
---|
| 293 | message_format =
|
---|
| 294 | "Invalid pilot's ID or password.")
|
---|
| 295 | dialog.format_secondary_markup("Check the ID and try to reenter"
|
---|
| 296 | " the password.")
|
---|
| 297 | dialog.run()
|
---|
| 298 | dialog.hide()
|
---|
| 299 | else:
|
---|
| 300 | dialog = gtk.MessageDialog(type = MESSAGETYPE_ERROR,
|
---|
| 301 | buttons = BUTTONSTYPE_OK,
|
---|
| 302 | message_format =
|
---|
| 303 | "Failed to connect to the MAVA website.")
|
---|
| 304 | dialog.format_secondary_markup("Try again in a few minutes.")
|
---|
| 305 | dialog.run()
|
---|
| 306 | dialog.hide()
|
---|
| 307 |
|
---|
| 308 | #-----------------------------------------------------------------------------
|
---|
| 309 |
|
---|
| 310 | class FlightSelectionPage(Page):
|
---|
| 311 | """The page to select the flight."""
|
---|
| 312 | def __init__(self, wizard):
|
---|
| 313 | """Construct the flight selection page."""
|
---|
[94] | 314 | help = "Select the flight you want to perform."
|
---|
| 315 | completedHelp = "You have selected the flight highlighted below."
|
---|
[44] | 316 | super(FlightSelectionPage, self).__init__(wizard, "Flight selection",
|
---|
[94] | 317 | help, completedHelp = completedHelp)
|
---|
[48] | 318 |
|
---|
| 319 |
|
---|
| 320 | self._listStore = gtk.ListStore(str, str, str, str)
|
---|
| 321 | self._flightList = gtk.TreeView(self._listStore)
|
---|
| 322 | column = gtk.TreeViewColumn("Flight no.", gtk.CellRendererText(),
|
---|
| 323 | text = 1)
|
---|
| 324 | column.set_expand(True)
|
---|
| 325 | self._flightList.append_column(column)
|
---|
| 326 | column = gtk.TreeViewColumn("Departure time [UTC]", gtk.CellRendererText(),
|
---|
| 327 | text = 0)
|
---|
| 328 | column.set_expand(True)
|
---|
| 329 | self._flightList.append_column(column)
|
---|
| 330 | column = gtk.TreeViewColumn("From", gtk.CellRendererText(),
|
---|
| 331 | text = 2)
|
---|
| 332 | column.set_expand(True)
|
---|
| 333 | self._flightList.append_column(column)
|
---|
| 334 | column = gtk.TreeViewColumn("To", gtk.CellRendererText(),
|
---|
| 335 | text = 3)
|
---|
| 336 | column.set_expand(True)
|
---|
| 337 | self._flightList.append_column(column)
|
---|
| 338 |
|
---|
| 339 | flightSelection = self._flightList.get_selection()
|
---|
| 340 | flightSelection.connect("changed", self._selectionChanged)
|
---|
| 341 |
|
---|
| 342 | scrolledWindow = gtk.ScrolledWindow()
|
---|
| 343 | scrolledWindow.add(self._flightList)
|
---|
| 344 | scrolledWindow.set_size_request(400, -1)
|
---|
| 345 | scrolledWindow.set_policy(gtk.PolicyType.AUTOMATIC if pygobject
|
---|
| 346 | else gtk.POLICY_AUTOMATIC,
|
---|
[69] | 347 | gtk.PolicyType.AUTOMATIC if pygobject
|
---|
| 348 | else gtk.POLICY_AUTOMATIC)
|
---|
[62] | 349 | scrolledWindow.set_shadow_type(gtk.ShadowType.IN if pygobject
|
---|
| 350 | else gtk.SHADOW_IN)
|
---|
[48] | 351 |
|
---|
| 352 | alignment = gtk.Alignment(xalign = 0.5, yalign = 0.0, xscale = 0.0, yscale = 1.0)
|
---|
| 353 | alignment.add(scrolledWindow)
|
---|
| 354 |
|
---|
| 355 | self.setMainWidget(alignment)
|
---|
| 356 |
|
---|
| 357 | self._button = self.addButton(gtk.STOCK_GO_FORWARD, default = True)
|
---|
| 358 | self._button.set_use_stock(True)
|
---|
| 359 | self._button.set_sensitive(False)
|
---|
[51] | 360 | self._button.connect("clicked", self._forwardClicked)
|
---|
[48] | 361 |
|
---|
| 362 | def activate(self):
|
---|
| 363 | """Fill the flight list."""
|
---|
[70] | 364 | self._flightList.set_sensitive(True)
|
---|
| 365 | self._listStore.clear()
|
---|
| 366 | for flight in self._wizard.loginResult.flights:
|
---|
| 367 | self._listStore.append([str(flight.departureTime),
|
---|
| 368 | flight.callsign,
|
---|
| 369 | flight.departureICAO,
|
---|
| 370 | flight.arrivalICAO])
|
---|
| 371 |
|
---|
| 372 | def finalize(self):
|
---|
| 373 | """Finalize the page."""
|
---|
| 374 | self._flightList.set_sensitive(False)
|
---|
[48] | 375 |
|
---|
| 376 | def _selectionChanged(self, selection):
|
---|
| 377 | """Called when the selection is changed."""
|
---|
| 378 | self._button.set_sensitive(selection.count_selected_rows()==1)
|
---|
[42] | 379 |
|
---|
[51] | 380 | def _forwardClicked(self, button):
|
---|
| 381 | """Called when the forward button was clicked."""
|
---|
[94] | 382 | if self._completed:
|
---|
[70] | 383 | self._wizard.jumpPage(self._nextDistance, finalize = False)
|
---|
| 384 | else:
|
---|
| 385 | selection = self._flightList.get_selection()
|
---|
| 386 | (listStore, iter) = selection.get_selected()
|
---|
| 387 | path = listStore.get_path(iter)
|
---|
| 388 | [index] = path.get_indices() if pygobject else path
|
---|
[51] | 389 |
|
---|
[70] | 390 | flight = self._wizard.loginResult.flights[index]
|
---|
| 391 | self._wizard._bookedFlight = flight
|
---|
[93] | 392 | # FIXME: with PyGObject this call causes error messages to
|
---|
| 393 | # appear on the standard output
|
---|
| 394 | self._wizard.gui.enableFlightInfo()
|
---|
[51] | 395 |
|
---|
[70] | 396 | self._updateDepartureGate()
|
---|
[51] | 397 |
|
---|
| 398 | def _updateDepartureGate(self):
|
---|
| 399 | """Update the departure gate for the booked flight."""
|
---|
| 400 | flight = self._wizard._bookedFlight
|
---|
| 401 | if flight.departureICAO=="LHBP":
|
---|
| 402 | self._wizard._getFleet(self._fleetRetrieved)
|
---|
| 403 | else:
|
---|
[70] | 404 | self._nextDistance = 2
|
---|
[51] | 405 | self._wizard.jumpPage(2)
|
---|
| 406 |
|
---|
| 407 | def _fleetRetrieved(self, fleet):
|
---|
| 408 | """Called when the fleet has been retrieved."""
|
---|
| 409 | if fleet is None:
|
---|
[70] | 410 | self._nextDistance = 2
|
---|
[51] | 411 | self._wizard.jumpPage(2)
|
---|
| 412 | else:
|
---|
| 413 | plane = fleet[self._wizard._bookedFlight.tailNumber]
|
---|
| 414 | if plane is None:
|
---|
[70] | 415 | self._nextDistance = 2
|
---|
[51] | 416 | self._wizard.jumpPage(2)
|
---|
[70] | 417 | elif plane.gateNumber is not None and \
|
---|
| 418 | not fleet.isGateConflicting(plane):
|
---|
[51] | 419 | self._wizard._departureGate = plane.gateNumber
|
---|
[70] | 420 | self._nextDistance = 2
|
---|
[51] | 421 | self._wizard.jumpPage(2)
|
---|
| 422 | else:
|
---|
[70] | 423 | self._nextDistance = 1
|
---|
[51] | 424 | self._wizard.nextPage()
|
---|
| 425 |
|
---|
| 426 | #-----------------------------------------------------------------------------
|
---|
| 427 |
|
---|
| 428 | class GateSelectionPage(Page):
|
---|
| 429 | """Page to select a free gate at LHBP.
|
---|
| 430 |
|
---|
| 431 | This page should be displayed only if we have fleet information!."""
|
---|
| 432 | def __init__(self, wizard):
|
---|
| 433 | """Construct the gate selection page."""
|
---|
| 434 | help = "The airplane's gate position is invalid.\n\n" \
|
---|
| 435 | "Select the gate from which you\n" \
|
---|
| 436 | "would like to begin the flight."
|
---|
| 437 | super(GateSelectionPage, self).__init__(wizard,
|
---|
| 438 | "LHBP gate selection",
|
---|
| 439 | help)
|
---|
| 440 |
|
---|
| 441 | self._listStore = gtk.ListStore(str)
|
---|
| 442 | self._gateList = gtk.TreeView(self._listStore)
|
---|
| 443 | column = gtk.TreeViewColumn(None, gtk.CellRendererText(),
|
---|
| 444 | text = 0)
|
---|
| 445 | column.set_expand(True)
|
---|
| 446 | self._gateList.append_column(column)
|
---|
| 447 | self._gateList.set_headers_visible(False)
|
---|
| 448 |
|
---|
| 449 | gateSelection = self._gateList.get_selection()
|
---|
| 450 | gateSelection.connect("changed", self._selectionChanged)
|
---|
| 451 |
|
---|
| 452 | scrolledWindow = gtk.ScrolledWindow()
|
---|
| 453 | scrolledWindow.add(self._gateList)
|
---|
| 454 | scrolledWindow.set_size_request(50, -1)
|
---|
| 455 | scrolledWindow.set_policy(gtk.PolicyType.AUTOMATIC if pygobject
|
---|
| 456 | else gtk.POLICY_AUTOMATIC,
|
---|
[69] | 457 | gtk.PolicyType.AUTOMATIC if pygobject
|
---|
| 458 | else gtk.POLICY_AUTOMATIC)
|
---|
[62] | 459 | scrolledWindow.set_shadow_type(gtk.ShadowType.IN if pygobject
|
---|
| 460 | else gtk.SHADOW_IN)
|
---|
[51] | 461 |
|
---|
| 462 | alignment = gtk.Alignment(xalign = 0.5, yalign = 0.0, xscale = 0.0, yscale = 1.0)
|
---|
| 463 | alignment.add(scrolledWindow)
|
---|
| 464 |
|
---|
| 465 | self.setMainWidget(alignment)
|
---|
| 466 |
|
---|
[73] | 467 | button = self.addButton(gtk.STOCK_GO_BACK)
|
---|
| 468 | button.set_use_stock(True)
|
---|
| 469 | button.connect("clicked", self._backClicked)
|
---|
| 470 |
|
---|
[51] | 471 | self._button = self.addButton(gtk.STOCK_GO_FORWARD, default = True)
|
---|
| 472 | self._button.set_use_stock(True)
|
---|
| 473 | self._button.set_sensitive(False)
|
---|
| 474 | self._button.connect("clicked", self._forwardClicked)
|
---|
| 475 |
|
---|
| 476 | def activate(self):
|
---|
| 477 | """Fill the gate list."""
|
---|
| 478 | self._listStore.clear()
|
---|
[70] | 479 | self._gateList.set_sensitive(True)
|
---|
[51] | 480 | occupiedGateNumbers = self._wizard._fleet.getOccupiedGateNumbers()
|
---|
| 481 | for gateNumber in const.lhbpGateNumbers:
|
---|
| 482 | if gateNumber not in occupiedGateNumbers:
|
---|
| 483 | self._listStore.append([gateNumber])
|
---|
| 484 |
|
---|
[70] | 485 | def finalize(self):
|
---|
| 486 | """Finalize the page."""
|
---|
| 487 | self._gateList.set_sensitive(False)
|
---|
| 488 |
|
---|
[51] | 489 | def _selectionChanged(self, selection):
|
---|
| 490 | """Called when the selection is changed."""
|
---|
| 491 | self._button.set_sensitive(selection.count_selected_rows()==1)
|
---|
| 492 |
|
---|
[73] | 493 | def _backClicked(self, button):
|
---|
| 494 | """Called when the Back button is pressed."""
|
---|
| 495 | self.goBack()
|
---|
| 496 |
|
---|
[51] | 497 | def _forwardClicked(self, button):
|
---|
| 498 | """Called when the forward button is clicked."""
|
---|
[94] | 499 | if not self._completed:
|
---|
[70] | 500 | selection = self._gateList.get_selection()
|
---|
| 501 | (listStore, iter) = selection.get_selected()
|
---|
| 502 | (gateNumber,) = listStore.get(iter, 0)
|
---|
[51] | 503 |
|
---|
[70] | 504 | self._wizard._departureGate = gateNumber
|
---|
[51] | 505 |
|
---|
[70] | 506 | #self._wizard._updatePlane(self._planeUpdated,
|
---|
| 507 | # self._wizard._bookedFlight.tailNumber,
|
---|
| 508 | # const.PLANE_HOME,
|
---|
| 509 | # gateNumber)
|
---|
| 510 |
|
---|
[58] | 511 | self._wizard.nextPage()
|
---|
[51] | 512 |
|
---|
| 513 | def _planeUpdated(self, success):
|
---|
| 514 | """Callback for the plane updating call."""
|
---|
| 515 | if success is None or success:
|
---|
| 516 | self._wizard.nextPage()
|
---|
| 517 | else:
|
---|
| 518 | dialog = gtk.MessageDialog(type = MESSAGETYPE_ERROR,
|
---|
| 519 | buttons = BUTTONSTYPE_OK,
|
---|
| 520 | message_format = "Gate conflict detected again")
|
---|
| 521 | dialog.format_secondary_markup("Try to select a different gate.")
|
---|
| 522 | dialog.run()
|
---|
| 523 | dialog.hide()
|
---|
| 524 |
|
---|
| 525 | self._wizard._getFleet(self._fleetRetrieved)
|
---|
| 526 |
|
---|
| 527 | def _fleetRetrieved(self, fleet):
|
---|
| 528 | """Called when the fleet has been retrieved."""
|
---|
| 529 | if fleet is None:
|
---|
| 530 | self._wizard.nextPage()
|
---|
| 531 | else:
|
---|
| 532 | self.activate()
|
---|
| 533 |
|
---|
| 534 | #-----------------------------------------------------------------------------
|
---|
| 535 |
|
---|
| 536 | class ConnectPage(Page):
|
---|
| 537 | """Page which displays the departure airport and gate (if at LHBP)."""
|
---|
| 538 | def __init__(self, wizard):
|
---|
| 539 | """Construct the connect page."""
|
---|
[78] | 540 | help = "Load the aircraft below into the simulator and park it\n" \
|
---|
| 541 | "at the given airport, at the gate below, if present.\n\n" \
|
---|
[51] | 542 | "Then press the Connect button to connect to the simulator."
|
---|
[94] | 543 | completedHelp = "The basic data of your flight can be read below."
|
---|
[51] | 544 | super(ConnectPage, self).__init__(wizard,
|
---|
| 545 | "Connect to the simulator",
|
---|
[94] | 546 | help, completedHelp = completedHelp)
|
---|
[51] | 547 |
|
---|
| 548 | alignment = gtk.Alignment(xalign = 0.5, yalign = 0.5,
|
---|
| 549 | xscale = 0.0, yscale = 0.0)
|
---|
| 550 |
|
---|
[78] | 551 | table = gtk.Table(5, 2)
|
---|
[51] | 552 | table.set_row_spacings(4)
|
---|
| 553 | table.set_col_spacings(16)
|
---|
| 554 | table.set_homogeneous(True)
|
---|
| 555 | alignment.add(table)
|
---|
| 556 | self.setMainWidget(alignment)
|
---|
| 557 |
|
---|
| 558 | labelAlignment = gtk.Alignment(xalign=1.0, xscale=0.0)
|
---|
[78] | 559 | label = gtk.Label("Flight number:")
|
---|
[51] | 560 | labelAlignment.add(label)
|
---|
| 561 | table.attach(labelAlignment, 0, 1, 0, 1)
|
---|
| 562 |
|
---|
| 563 | labelAlignment = gtk.Alignment(xalign=0.0, xscale=0.0)
|
---|
[78] | 564 | self._flightNumber = gtk.Label()
|
---|
[82] | 565 | self._flightNumber.set_width_chars(7)
|
---|
[78] | 566 | self._flightNumber.set_alignment(0.0, 0.5)
|
---|
| 567 | labelAlignment.add(self._flightNumber)
|
---|
| 568 | table.attach(labelAlignment, 1, 2, 0, 1)
|
---|
| 569 |
|
---|
| 570 | labelAlignment = gtk.Alignment(xalign=1.0, xscale=0.0)
|
---|
| 571 | label = gtk.Label("Aircraft:")
|
---|
| 572 | labelAlignment.add(label)
|
---|
| 573 | table.attach(labelAlignment, 0, 1, 1, 2)
|
---|
| 574 |
|
---|
| 575 | labelAlignment = gtk.Alignment(xalign=0.0, xscale=0.0)
|
---|
| 576 | self._aircraft = gtk.Label()
|
---|
| 577 | self._aircraft.set_width_chars(25)
|
---|
| 578 | self._aircraft.set_alignment(0.0, 0.5)
|
---|
| 579 | labelAlignment.add(self._aircraft)
|
---|
| 580 | table.attach(labelAlignment, 1, 2, 1, 2)
|
---|
| 581 |
|
---|
| 582 | labelAlignment = gtk.Alignment(xalign=1.0, xscale=0.0)
|
---|
| 583 | label = gtk.Label("Tail number:")
|
---|
| 584 | labelAlignment.add(label)
|
---|
| 585 | table.attach(labelAlignment, 0, 1, 2, 3)
|
---|
| 586 |
|
---|
| 587 | labelAlignment = gtk.Alignment(xalign=0.0, xscale=0.0)
|
---|
| 588 | self._tailNumber = gtk.Label()
|
---|
[80] | 589 | self._tailNumber.set_width_chars(10)
|
---|
[78] | 590 | self._tailNumber.set_alignment(0.0, 0.5)
|
---|
| 591 | labelAlignment.add(self._tailNumber)
|
---|
| 592 | table.attach(labelAlignment, 1, 2, 2, 3)
|
---|
| 593 |
|
---|
| 594 | labelAlignment = gtk.Alignment(xalign=1.0, xscale=0.0)
|
---|
| 595 | label = gtk.Label("Airport:")
|
---|
| 596 | labelAlignment.add(label)
|
---|
| 597 | table.attach(labelAlignment, 0, 1, 3, 4)
|
---|
| 598 |
|
---|
| 599 | labelAlignment = gtk.Alignment(xalign=0.0, xscale=0.0)
|
---|
[51] | 600 | self._departureICAO = gtk.Label()
|
---|
[80] | 601 | self._departureICAO.set_width_chars(6)
|
---|
[51] | 602 | self._departureICAO.set_alignment(0.0, 0.5)
|
---|
| 603 | labelAlignment.add(self._departureICAO)
|
---|
[78] | 604 | table.attach(labelAlignment, 1, 2, 3, 4)
|
---|
[51] | 605 |
|
---|
| 606 | labelAlignment = gtk.Alignment(xalign=1.0, xscale=0.0)
|
---|
| 607 | label = gtk.Label("Gate:")
|
---|
| 608 | labelAlignment.add(label)
|
---|
[78] | 609 | table.attach(labelAlignment, 0, 1, 4, 5)
|
---|
[51] | 610 |
|
---|
| 611 | labelAlignment = gtk.Alignment(xalign=0.0, xscale=0.0)
|
---|
| 612 | self._departureGate = gtk.Label()
|
---|
| 613 | self._departureGate.set_width_chars(5)
|
---|
| 614 | self._departureGate.set_alignment(0.0, 0.5)
|
---|
| 615 | labelAlignment.add(self._departureGate)
|
---|
[78] | 616 | table.attach(labelAlignment, 1, 2, 4, 5)
|
---|
[51] | 617 |
|
---|
[70] | 618 | button = self.addButton(gtk.STOCK_GO_BACK)
|
---|
| 619 | button.set_use_stock(True)
|
---|
| 620 | button.connect("clicked", self._backClicked)
|
---|
| 621 |
|
---|
[51] | 622 | self._button = self.addButton("_Connect", default = True)
|
---|
| 623 | self._button.set_use_underline(True)
|
---|
[70] | 624 | self._clickedID = self._button.connect("clicked", self._connectClicked)
|
---|
[51] | 625 |
|
---|
| 626 | def activate(self):
|
---|
[60] | 627 | """Setup the departure information."""
|
---|
[70] | 628 | self._button.set_label("_Connect")
|
---|
| 629 | self._button.set_use_underline(True)
|
---|
| 630 | self._button.disconnect(self._clickedID)
|
---|
| 631 | self._clickedID = self._button.connect("clicked", self._connectClicked)
|
---|
[78] | 632 |
|
---|
| 633 | bookedFlight = self._wizard._bookedFlight
|
---|
| 634 |
|
---|
| 635 | self._flightNumber.set_markup("<b>" + bookedFlight.callsign + "</b>")
|
---|
| 636 |
|
---|
| 637 | aircraftType = acftTypeNames[bookedFlight.aircraftType]
|
---|
| 638 | self._aircraft.set_markup("<b>" + aircraftType + "</b>")
|
---|
[70] | 639 |
|
---|
[78] | 640 | self._tailNumber.set_markup("<b>" + bookedFlight.tailNumber + "</b>")
|
---|
| 641 |
|
---|
| 642 | icao = bookedFlight.departureICAO
|
---|
[51] | 643 | self._departureICAO.set_markup("<b>" + icao + "</b>")
|
---|
| 644 | gate = self._wizard._departureGate
|
---|
| 645 | if gate!="-":
|
---|
| 646 | gate = "<b>" + gate + "</b>"
|
---|
| 647 | self._departureGate.set_markup(gate)
|
---|
| 648 |
|
---|
[70] | 649 | def finalize(self):
|
---|
| 650 | """Finalize the page."""
|
---|
| 651 | self._button.set_label(gtk.STOCK_GO_FORWARD)
|
---|
| 652 | self._button.set_use_stock(True)
|
---|
| 653 | self._button.disconnect(self._clickedID)
|
---|
| 654 | self._clickedID = self._button.connect("clicked", self._forwardClicked)
|
---|
| 655 |
|
---|
| 656 | def _backClicked(self, button):
|
---|
| 657 | """Called when the Back button is pressed."""
|
---|
| 658 | self.goBack()
|
---|
| 659 |
|
---|
[51] | 660 | def _connectClicked(self, button):
|
---|
| 661 | """Called when the Connect button is pressed."""
|
---|
| 662 | self._wizard._connectSimulator()
|
---|
| 663 |
|
---|
[70] | 664 | def _forwardClicked(self, button):
|
---|
| 665 | """Called when the Forward button is pressed."""
|
---|
| 666 | self._wizard.nextPage()
|
---|
| 667 |
|
---|
[42] | 668 | #-----------------------------------------------------------------------------
|
---|
| 669 |
|
---|
[59] | 670 | class PayloadPage(Page):
|
---|
| 671 | """Page to allow setting up the payload."""
|
---|
| 672 | def __init__(self, wizard):
|
---|
| 673 | """Construct the page."""
|
---|
| 674 | help = "The briefing contains the weights below.\n" \
|
---|
[60] | 675 | "Setup the cargo weight here and the payload weight in the simulator.\n\n" \
|
---|
| 676 | "You can also check here what the simulator reports as ZFW."
|
---|
[94] | 677 | completedHelp = "You can see the weights in the briefing\n" \
|
---|
| 678 | "and the cargo weight you have selected below.\n\n" \
|
---|
| 679 | "You can also query the ZFW reported by the simulator."
|
---|
| 680 | super(PayloadPage, self).__init__(wizard, "Payload", help,
|
---|
| 681 | completedHelp = completedHelp)
|
---|
[59] | 682 |
|
---|
[60] | 683 | alignment = gtk.Alignment(xalign = 0.5, yalign = 0.5,
|
---|
| 684 | xscale = 0.0, yscale = 0.0)
|
---|
| 685 |
|
---|
| 686 | table = gtk.Table(7, 3)
|
---|
| 687 | table.set_row_spacings(4)
|
---|
| 688 | table.set_col_spacings(16)
|
---|
| 689 | table.set_homogeneous(False)
|
---|
| 690 | alignment.add(table)
|
---|
| 691 | self.setMainWidget(alignment)
|
---|
| 692 |
|
---|
| 693 | label = gtk.Label("Crew:")
|
---|
| 694 | label.set_alignment(0.0, 0.5)
|
---|
| 695 | table.attach(label, 0, 1, 0, 1)
|
---|
| 696 |
|
---|
| 697 | self._numCrew = gtk.Label()
|
---|
| 698 | self._numCrew.set_width_chars(6)
|
---|
| 699 | self._numCrew.set_alignment(1.0, 0.5)
|
---|
| 700 | table.attach(self._numCrew, 1, 2, 0, 1)
|
---|
| 701 |
|
---|
| 702 | label = gtk.Label("Passengers:")
|
---|
| 703 | label.set_alignment(0.0, 0.5)
|
---|
| 704 | table.attach(label, 0, 1, 1, 2)
|
---|
| 705 |
|
---|
| 706 | self._numPassengers = gtk.Label()
|
---|
| 707 | self._numPassengers.set_width_chars(6)
|
---|
| 708 | self._numPassengers.set_alignment(1.0, 0.5)
|
---|
| 709 | table.attach(self._numPassengers, 1, 2, 1, 2)
|
---|
| 710 |
|
---|
| 711 | label = gtk.Label("Baggage:")
|
---|
| 712 | label.set_alignment(0.0, 0.5)
|
---|
| 713 | table.attach(label, 0, 1, 2, 3)
|
---|
| 714 |
|
---|
| 715 | self._bagWeight = gtk.Label()
|
---|
| 716 | self._bagWeight.set_width_chars(6)
|
---|
| 717 | self._bagWeight.set_alignment(1.0, 0.5)
|
---|
| 718 | table.attach(self._bagWeight, 1, 2, 2, 3)
|
---|
| 719 |
|
---|
| 720 | table.attach(gtk.Label("kg"), 2, 3, 2, 3)
|
---|
| 721 |
|
---|
| 722 | label = gtk.Label("_Cargo:")
|
---|
| 723 | label.set_use_underline(True)
|
---|
| 724 | label.set_alignment(0.0, 0.5)
|
---|
| 725 | table.attach(label, 0, 1, 3, 4)
|
---|
| 726 |
|
---|
[84] | 727 | self._cargoWeight = IntegerEntry(defaultValue = 0)
|
---|
[60] | 728 | self._cargoWeight.set_width_chars(6)
|
---|
[84] | 729 | self._cargoWeight.connect("integer-changed", self._cargoWeightChanged)
|
---|
[60] | 730 | self._cargoWeight.set_tooltip_text("The weight of the cargo for your flight.")
|
---|
| 731 | table.attach(self._cargoWeight, 1, 2, 3, 4)
|
---|
| 732 | label.set_mnemonic_widget(self._cargoWeight)
|
---|
| 733 |
|
---|
| 734 | table.attach(gtk.Label("kg"), 2, 3, 3, 4)
|
---|
| 735 |
|
---|
| 736 | label = gtk.Label("Mail:")
|
---|
| 737 | label.set_alignment(0.0, 0.5)
|
---|
| 738 | table.attach(label, 0, 1, 4, 5)
|
---|
| 739 |
|
---|
| 740 | self._mailWeight = gtk.Label()
|
---|
| 741 | self._mailWeight.set_width_chars(6)
|
---|
| 742 | self._mailWeight.set_alignment(1.0, 0.5)
|
---|
| 743 | table.attach(self._mailWeight, 1, 2, 4, 5)
|
---|
| 744 |
|
---|
| 745 | table.attach(gtk.Label("kg"), 2, 3, 4, 5)
|
---|
| 746 |
|
---|
| 747 | label = gtk.Label("<b>Calculated ZFW:</b>")
|
---|
| 748 | label.set_alignment(0.0, 0.5)
|
---|
| 749 | label.set_use_markup(True)
|
---|
| 750 | table.attach(label, 0, 1, 5, 6)
|
---|
| 751 |
|
---|
| 752 | self._calculatedZFW = gtk.Label()
|
---|
| 753 | self._calculatedZFW.set_width_chars(6)
|
---|
| 754 | self._calculatedZFW.set_alignment(1.0, 0.5)
|
---|
| 755 | table.attach(self._calculatedZFW, 1, 2, 5, 6)
|
---|
| 756 |
|
---|
| 757 | table.attach(gtk.Label("kg"), 2, 3, 5, 6)
|
---|
| 758 |
|
---|
[70] | 759 | self._zfwButton = gtk.Button("_ZFW from FS:")
|
---|
| 760 | self._zfwButton.set_use_underline(True)
|
---|
| 761 | self._zfwButton.connect("clicked", self._zfwRequested)
|
---|
| 762 | table.attach(self._zfwButton, 0, 1, 6, 7)
|
---|
[60] | 763 |
|
---|
| 764 | self._simulatorZFW = gtk.Label("-")
|
---|
| 765 | self._simulatorZFW.set_width_chars(6)
|
---|
| 766 | self._simulatorZFW.set_alignment(1.0, 0.5)
|
---|
| 767 | table.attach(self._simulatorZFW, 1, 2, 6, 7)
|
---|
| 768 | self._simulatorZFWValue = None
|
---|
| 769 |
|
---|
| 770 | table.attach(gtk.Label("kg"), 2, 3, 6, 7)
|
---|
| 771 |
|
---|
[70] | 772 | self._backButton = self.addButton(gtk.STOCK_GO_BACK)
|
---|
| 773 | self._backButton.set_use_stock(True)
|
---|
| 774 | self._backButton.connect("clicked", self._backClicked)
|
---|
| 775 |
|
---|
[60] | 776 | self._button = self.addButton(gtk.STOCK_GO_FORWARD, default = True)
|
---|
| 777 | self._button.set_use_stock(True)
|
---|
| 778 | self._button.connect("clicked", self._forwardClicked)
|
---|
| 779 |
|
---|
[97] | 780 | @property
|
---|
| 781 | def cargoWeight(self):
|
---|
| 782 | """Get the cargo weight entered."""
|
---|
| 783 | return self._cargoWeight.get_int()
|
---|
| 784 |
|
---|
[60] | 785 | def activate(self):
|
---|
| 786 | """Setup the information."""
|
---|
| 787 | bookedFlight = self._wizard._bookedFlight
|
---|
| 788 | self._numCrew.set_text(str(bookedFlight.numCrew))
|
---|
| 789 | self._numPassengers.set_text(str(bookedFlight.numPassengers))
|
---|
| 790 | self._bagWeight.set_text(str(bookedFlight.bagWeight))
|
---|
[84] | 791 | self._cargoWeight.set_int(bookedFlight.cargoWeight)
|
---|
[70] | 792 | self._cargoWeight.set_sensitive(True)
|
---|
[60] | 793 | self._mailWeight.set_text(str(bookedFlight.mailWeight))
|
---|
[92] | 794 | self._simulatorZFW.set_text("-")
|
---|
| 795 | self._simulatorZFWValue = None
|
---|
[70] | 796 | self._zfwButton.set_sensitive(True)
|
---|
[60] | 797 | self._updateCalculatedZFW()
|
---|
[59] | 798 |
|
---|
[70] | 799 | def finalize(self):
|
---|
| 800 | """Finalize the payload page."""
|
---|
| 801 | self._cargoWeight.set_sensitive(False)
|
---|
| 802 |
|
---|
[84] | 803 | def calculateZFW(self):
|
---|
[60] | 804 | """Calculate the ZFW value."""
|
---|
| 805 | zfw = self._wizard.gui._flight.aircraft.dow
|
---|
| 806 | bookedFlight = self._wizard._bookedFlight
|
---|
| 807 | zfw += (bookedFlight.numCrew + bookedFlight.numPassengers) * 82
|
---|
| 808 | zfw += bookedFlight.bagWeight
|
---|
[84] | 809 | zfw += self._cargoWeight.get_int()
|
---|
[60] | 810 | zfw += bookedFlight.mailWeight
|
---|
| 811 | return zfw
|
---|
| 812 |
|
---|
| 813 | def _updateCalculatedZFW(self):
|
---|
| 814 | """Update the calculated ZFW"""
|
---|
[84] | 815 | zfw = self.calculateZFW()
|
---|
[60] | 816 |
|
---|
| 817 | markupBegin = "<b>"
|
---|
| 818 | markupEnd = "</b>"
|
---|
| 819 | if self._simulatorZFWValue is not None and \
|
---|
| 820 | PayloadChecker.isZFWFaulty(self._simulatorZFWValue, zfw):
|
---|
| 821 | markupBegin += '<span foreground="red">'
|
---|
| 822 | markupEnd = "</span>" + markupEnd
|
---|
| 823 | self._calculatedZFW.set_markup(markupBegin + str(zfw) + markupEnd)
|
---|
| 824 |
|
---|
[84] | 825 | def _cargoWeightChanged(self, entry, weight):
|
---|
[60] | 826 | """Called when the cargo weight has changed."""
|
---|
| 827 | self._updateCalculatedZFW()
|
---|
| 828 |
|
---|
[59] | 829 | def _zfwRequested(self, button):
|
---|
| 830 | """Called when the ZFW is requested from the simulator."""
|
---|
[70] | 831 | self._zfwButton.set_sensitive(False)
|
---|
| 832 | self._backButton.set_sensitive(False)
|
---|
| 833 | self._button.set_sensitive(False)
|
---|
| 834 | gui = self._wizard.gui
|
---|
| 835 | gui.beginBusy("Querying ZFW...")
|
---|
| 836 | gui.simulator.requestZFW(self._handleZFW)
|
---|
[59] | 837 |
|
---|
| 838 | def _handleZFW(self, zfw):
|
---|
| 839 | """Called when the ZFW value is retrieved."""
|
---|
[60] | 840 | gobject.idle_add(self._processZFW, zfw)
|
---|
[59] | 841 |
|
---|
[60] | 842 | def _processZFW(self, zfw):
|
---|
| 843 | """Process the given ZFW value received from the simulator."""
|
---|
[61] | 844 | self._wizard.gui.endBusy()
|
---|
[70] | 845 | self._zfwButton.set_sensitive(True)
|
---|
| 846 | self._backButton.set_sensitive(True)
|
---|
| 847 | self._button.set_sensitive(True)
|
---|
[60] | 848 | self._simulatorZFWValue = zfw
|
---|
| 849 | self._simulatorZFW.set_text("%.0f" % (zfw,))
|
---|
| 850 | self._updateCalculatedZFW()
|
---|
| 851 |
|
---|
| 852 | def _forwardClicked(self, button):
|
---|
| 853 | """Called when the forward button is clicked."""
|
---|
| 854 | self._wizard.nextPage()
|
---|
[70] | 855 |
|
---|
| 856 | def _backClicked(self, button):
|
---|
| 857 | """Called when the Back button is pressed."""
|
---|
| 858 | self.goBack()
|
---|
[60] | 859 |
|
---|
[59] | 860 | #-----------------------------------------------------------------------------
|
---|
| 861 |
|
---|
[61] | 862 | class TimePage(Page):
|
---|
| 863 | """Page displaying the departure and arrival times and allows querying the
|
---|
| 864 | current time from the flight simulator."""
|
---|
| 865 | def __init__(self, wizard):
|
---|
| 866 | help = "The departure and arrival times are displayed below in UTC.\n\n" \
|
---|
| 867 | "You can also query the current UTC time from the simulator.\n" \
|
---|
| 868 | "Ensure that you have enough time to properly prepare for the flight."
|
---|
[94] | 869 | completedHelp = "The departure and arrival times are displayed below in UTC.\n\n" \
|
---|
| 870 | "You can also query the current UTC time from the simulator.\n"
|
---|
| 871 | super(TimePage, self).__init__(wizard, "Time", help,
|
---|
| 872 | completedHelp = completedHelp)
|
---|
[61] | 873 |
|
---|
| 874 | alignment = gtk.Alignment(xalign = 0.5, yalign = 0.5,
|
---|
| 875 | xscale = 0.0, yscale = 0.0)
|
---|
| 876 |
|
---|
| 877 | table = gtk.Table(3, 2)
|
---|
| 878 | table.set_row_spacings(4)
|
---|
| 879 | table.set_col_spacings(16)
|
---|
| 880 | table.set_homogeneous(False)
|
---|
| 881 | alignment.add(table)
|
---|
| 882 | self.setMainWidget(alignment)
|
---|
| 883 |
|
---|
| 884 | label = gtk.Label("Departure:")
|
---|
| 885 | label.set_alignment(0.0, 0.5)
|
---|
| 886 | table.attach(label, 0, 1, 0, 1)
|
---|
| 887 |
|
---|
| 888 | self._departure = gtk.Label()
|
---|
| 889 | self._departure.set_alignment(0.0, 0.5)
|
---|
| 890 | table.attach(self._departure, 1, 2, 0, 1)
|
---|
| 891 |
|
---|
| 892 | label = gtk.Label("Arrival:")
|
---|
| 893 | label.set_alignment(0.0, 0.5)
|
---|
| 894 | table.attach(label, 0, 1, 1, 2)
|
---|
| 895 |
|
---|
| 896 | self._arrival = gtk.Label()
|
---|
| 897 | self._arrival.set_alignment(0.0, 0.5)
|
---|
| 898 | table.attach(self._arrival, 1, 2, 1, 2)
|
---|
| 899 |
|
---|
[70] | 900 | self._timeButton = gtk.Button("_Time from FS:")
|
---|
| 901 | self._timeButton.set_use_underline(True)
|
---|
| 902 | self._timeButton.connect("clicked", self._timeRequested)
|
---|
| 903 | table.attach(self._timeButton, 0, 1, 2, 3)
|
---|
[61] | 904 |
|
---|
| 905 | self._simulatorTime = gtk.Label("-")
|
---|
| 906 | self._simulatorTime.set_alignment(0.0, 0.5)
|
---|
| 907 | table.attach(self._simulatorTime, 1, 2, 2, 3)
|
---|
| 908 |
|
---|
[70] | 909 | self._backButton = self.addButton(gtk.STOCK_GO_BACK)
|
---|
| 910 | self._backButton.set_use_stock(True)
|
---|
| 911 | self._backButton.connect("clicked", self._backClicked)
|
---|
| 912 |
|
---|
[61] | 913 | self._button = self.addButton(gtk.STOCK_GO_FORWARD, default = True)
|
---|
| 914 | self._button.set_use_stock(True)
|
---|
| 915 | self._button.connect("clicked", self._forwardClicked)
|
---|
| 916 |
|
---|
| 917 | def activate(self):
|
---|
| 918 | """Activate the page."""
|
---|
[70] | 919 | self._timeButton.set_sensitive(True)
|
---|
[61] | 920 | bookedFlight = self._wizard._bookedFlight
|
---|
| 921 | self._departure.set_text(str(bookedFlight.departureTime.time()))
|
---|
| 922 | self._arrival.set_text(str(bookedFlight.arrivalTime.time()))
|
---|
[92] | 923 | self._simulatorTime.set_text("-")
|
---|
[61] | 924 |
|
---|
| 925 | def _timeRequested(self, button):
|
---|
| 926 | """Request the time from the simulator."""
|
---|
[70] | 927 | self._timeButton.set_sensitive(False)
|
---|
| 928 | self._backButton.set_sensitive(False)
|
---|
| 929 | self._button.set_sensitive(False)
|
---|
[61] | 930 | self._wizard.gui.beginBusy("Querying time...")
|
---|
| 931 | self._wizard.gui.simulator.requestTime(self._handleTime)
|
---|
| 932 |
|
---|
| 933 | def _handleTime(self, timestamp):
|
---|
| 934 | """Handle the result of a time retrieval."""
|
---|
| 935 | gobject.idle_add(self._processTime, timestamp)
|
---|
| 936 |
|
---|
| 937 | def _processTime(self, timestamp):
|
---|
| 938 | """Process the given time."""
|
---|
| 939 | self._wizard.gui.endBusy()
|
---|
[70] | 940 | self._timeButton.set_sensitive(True)
|
---|
| 941 | self._backButton.set_sensitive(True)
|
---|
| 942 | self._button.set_sensitive(True)
|
---|
[61] | 943 | tm = time.gmtime(timestamp)
|
---|
| 944 | t = datetime.time(tm.tm_hour, tm.tm_min, tm.tm_sec)
|
---|
| 945 | self._simulatorTime.set_text(str(t))
|
---|
| 946 |
|
---|
| 947 | ts = tm.tm_hour * 3600 + tm.tm_min * 60 + tm.tm_sec
|
---|
| 948 | dt = self._wizard._bookedFlight.departureTime.time()
|
---|
| 949 | dts = dt.hour * 3600 + dt.minute * 60 + dt.second
|
---|
| 950 | diff = dts-ts
|
---|
| 951 |
|
---|
| 952 | markupBegin = ""
|
---|
| 953 | markupEnd = ""
|
---|
| 954 | if diff < 0:
|
---|
| 955 | markupBegin = '<b><span foreground="red">'
|
---|
| 956 | markupEnd = '</span></b>'
|
---|
| 957 | elif diff < 3*60 or diff > 30*60:
|
---|
| 958 | markupBegin = '<b><span foreground="orange">'
|
---|
| 959 | markupEnd = '</span></b>'
|
---|
| 960 |
|
---|
| 961 | self._departure.set_markup(markupBegin + str(dt) + markupEnd)
|
---|
| 962 |
|
---|
[70] | 963 | def _backClicked(self, button):
|
---|
| 964 | """Called when the Back button is pressed."""
|
---|
| 965 | self.goBack()
|
---|
| 966 |
|
---|
[61] | 967 | def _forwardClicked(self, button):
|
---|
| 968 | """Called when the forward button is clicked."""
|
---|
| 969 | self._wizard.nextPage()
|
---|
| 970 |
|
---|
| 971 | #-----------------------------------------------------------------------------
|
---|
| 972 |
|
---|
[62] | 973 | class RoutePage(Page):
|
---|
| 974 | """The page containing the route and the flight level."""
|
---|
| 975 | def __init__(self, wizard):
|
---|
| 976 | help = "Set your cruise flight level below, and\n" \
|
---|
| 977 | "if necessary, edit the flight plan."
|
---|
[94] | 978 | completedHelp = "If necessary, you can modify the cruise level and\n" \
|
---|
| 979 | "the flight plan below during flight.\n" \
|
---|
| 980 | "If so, please, add a comment on why " \
|
---|
| 981 | "the modification became necessary."
|
---|
| 982 | super(RoutePage, self).__init__(wizard, "Route", help,
|
---|
| 983 | completedHelp = completedHelp)
|
---|
[62] | 984 |
|
---|
| 985 | alignment = gtk.Alignment(xalign = 0.5, yalign = 0.5,
|
---|
| 986 | xscale = 0.0, yscale = 0.0)
|
---|
| 987 |
|
---|
| 988 | mainBox = gtk.VBox()
|
---|
| 989 | alignment.add(mainBox)
|
---|
| 990 | self.setMainWidget(alignment)
|
---|
| 991 |
|
---|
| 992 | levelBox = gtk.HBox()
|
---|
| 993 |
|
---|
| 994 | label = gtk.Label("_Cruise level")
|
---|
| 995 | label.set_use_underline(True)
|
---|
| 996 | levelBox.pack_start(label, True, True, 0)
|
---|
| 997 |
|
---|
| 998 | self._cruiseLevel = gtk.SpinButton()
|
---|
| 999 | self._cruiseLevel.set_increments(step = 10, page = 100)
|
---|
| 1000 | self._cruiseLevel.set_range(min = 50, max = 500)
|
---|
| 1001 | self._cruiseLevel.set_tooltip_text("The cruise flight level.")
|
---|
| 1002 | self._cruiseLevel.set_numeric(True)
|
---|
| 1003 | self._cruiseLevel.connect("value-changed", self._cruiseLevelChanged)
|
---|
[97] | 1004 | label.set_mnemonic_widget(self._cruiseLevel)
|
---|
| 1005 | self._filedCruiseLevel = 240
|
---|
[62] | 1006 |
|
---|
| 1007 | levelBox.pack_start(self._cruiseLevel, False, False, 8)
|
---|
| 1008 |
|
---|
| 1009 | alignment = gtk.Alignment(xalign = 0.0, yalign = 0.5,
|
---|
| 1010 | xscale = 0.0, yscale = 0.0)
|
---|
| 1011 | alignment.add(levelBox)
|
---|
| 1012 |
|
---|
| 1013 | mainBox.pack_start(alignment, False, False, 0)
|
---|
| 1014 |
|
---|
| 1015 |
|
---|
| 1016 | routeBox = gtk.VBox()
|
---|
| 1017 |
|
---|
| 1018 | alignment = gtk.Alignment(xalign = 0.0, yalign = 0.5,
|
---|
| 1019 | xscale = 0.0, yscale = 0.0)
|
---|
| 1020 | label = gtk.Label("_Route")
|
---|
| 1021 | label.set_use_underline(True)
|
---|
| 1022 | alignment.add(label)
|
---|
| 1023 | routeBox.pack_start(alignment, True, True, 0)
|
---|
| 1024 |
|
---|
| 1025 | routeWindow = gtk.ScrolledWindow()
|
---|
| 1026 | routeWindow.set_size_request(400, 80)
|
---|
| 1027 | routeWindow.set_shadow_type(gtk.ShadowType.IN if pygobject
|
---|
| 1028 | else gtk.SHADOW_IN)
|
---|
[69] | 1029 | routeWindow.set_policy(gtk.PolicyType.AUTOMATIC if pygobject
|
---|
| 1030 | else gtk.POLICY_AUTOMATIC,
|
---|
| 1031 | gtk.PolicyType.AUTOMATIC if pygobject
|
---|
| 1032 | else gtk.POLICY_AUTOMATIC)
|
---|
[62] | 1033 |
|
---|
| 1034 | self._route = gtk.TextView()
|
---|
| 1035 | self._route.set_tooltip_text("The planned flight route.")
|
---|
| 1036 | self._route.get_buffer().connect("changed", self._routeChanged)
|
---|
| 1037 | routeWindow.add(self._route)
|
---|
| 1038 |
|
---|
| 1039 | label.set_mnemonic_widget(self._route)
|
---|
| 1040 | routeBox.pack_start(routeWindow, True, True, 0)
|
---|
| 1041 |
|
---|
| 1042 | mainBox.pack_start(routeBox, True, True, 8)
|
---|
| 1043 |
|
---|
[70] | 1044 | self._backButton = self.addButton(gtk.STOCK_GO_BACK)
|
---|
| 1045 | self._backButton.set_use_stock(True)
|
---|
| 1046 | self._backButton.connect("clicked", self._backClicked)
|
---|
| 1047 |
|
---|
[62] | 1048 | self._button = self.addButton(gtk.STOCK_GO_FORWARD, default = True)
|
---|
| 1049 | self._button.set_use_stock(True)
|
---|
| 1050 | self._button.connect("clicked", self._forwardClicked)
|
---|
| 1051 |
|
---|
[84] | 1052 | @property
|
---|
[97] | 1053 | def filedCruiseLevel(self):
|
---|
| 1054 | """Get the filed cruise level."""
|
---|
| 1055 | return self._filedCruiseLevel
|
---|
| 1056 |
|
---|
| 1057 | @property
|
---|
[84] | 1058 | def cruiseLevel(self):
|
---|
| 1059 | """Get the cruise level."""
|
---|
| 1060 | return self._cruiseLevel.get_value_as_int()
|
---|
| 1061 |
|
---|
[97] | 1062 | @property
|
---|
| 1063 | def route(self):
|
---|
| 1064 | """Get the route."""
|
---|
| 1065 | return self._getRoute()
|
---|
| 1066 |
|
---|
[62] | 1067 | def activate(self):
|
---|
| 1068 | """Setup the route from the booked flight."""
|
---|
[92] | 1069 | self._cruiseLevel.set_value(240)
|
---|
[97] | 1070 | self._filedCruiseLevel = 240
|
---|
[62] | 1071 | self._route.get_buffer().set_text(self._wizard._bookedFlight.route)
|
---|
| 1072 | self._updateForwardButton()
|
---|
| 1073 |
|
---|
| 1074 | def _getRoute(self):
|
---|
| 1075 | """Get the text of the route."""
|
---|
| 1076 | buffer = self._route.get_buffer()
|
---|
| 1077 | return buffer.get_text(buffer.get_start_iter(),
|
---|
| 1078 | buffer.get_end_iter(), True)
|
---|
| 1079 |
|
---|
| 1080 | def _updateForwardButton(self):
|
---|
| 1081 | """Update the sensitivity of the forward button."""
|
---|
| 1082 | self._button.set_sensitive(self._cruiseLevel.get_value_as_int()>=50 and \
|
---|
[68] | 1083 | self._getRoute()!="")
|
---|
[62] | 1084 |
|
---|
| 1085 | def _cruiseLevelChanged(self, spinButton):
|
---|
| 1086 | """Called when the cruise level has changed."""
|
---|
| 1087 | self._updateForwardButton()
|
---|
| 1088 |
|
---|
| 1089 | def _routeChanged(self, textBuffer):
|
---|
| 1090 | """Called when the route has changed."""
|
---|
| 1091 | self._updateForwardButton()
|
---|
| 1092 |
|
---|
[70] | 1093 | def _backClicked(self, button):
|
---|
| 1094 | """Called when the Back button is pressed."""
|
---|
| 1095 | self.goBack()
|
---|
| 1096 |
|
---|
[62] | 1097 | def _forwardClicked(self, button):
|
---|
| 1098 | """Called when the Forward button is clicked."""
|
---|
[94] | 1099 | if self._completed:
|
---|
[70] | 1100 | self._wizard.nextPage()
|
---|
| 1101 | else:
|
---|
| 1102 | bookedFlight = self._wizard._bookedFlight
|
---|
[97] | 1103 | self._filedCruiseLevel = self.cruiseLevel
|
---|
[70] | 1104 | self._wizard.gui.beginBusy("Downloading NOTAMs...")
|
---|
| 1105 | self._wizard.gui.webHandler.getNOTAMs(self._notamsCallback,
|
---|
| 1106 | bookedFlight.departureICAO,
|
---|
| 1107 | bookedFlight.arrivalICAO)
|
---|
[64] | 1108 |
|
---|
| 1109 | def _notamsCallback(self, returned, result):
|
---|
| 1110 | """Callback for the NOTAMs."""
|
---|
| 1111 | gobject.idle_add(self._handleNOTAMs, returned, result)
|
---|
| 1112 |
|
---|
| 1113 | def _handleNOTAMs(self, returned, result):
|
---|
| 1114 | """Handle the NOTAMs."""
|
---|
| 1115 | if returned:
|
---|
| 1116 | self._wizard._departureNOTAMs = result.departureNOTAMs
|
---|
| 1117 | self._wizard._arrivalNOTAMs = result.arrivalNOTAMs
|
---|
[67] | 1118 | else:
|
---|
| 1119 | self._wizard._departureNOTAMs = None
|
---|
| 1120 | self._wizard._arrivalNOTAMs = None
|
---|
[64] | 1121 |
|
---|
[67] | 1122 | bookedFlight = self._wizard._bookedFlight
|
---|
| 1123 | self._wizard.gui.beginBusy("Downloading METARs...")
|
---|
| 1124 | self._wizard.gui.webHandler.getMETARs(self._metarsCallback,
|
---|
| 1125 | [bookedFlight.departureICAO,
|
---|
| 1126 | bookedFlight.arrivalICAO])
|
---|
| 1127 |
|
---|
| 1128 | def _metarsCallback(self, returned, result):
|
---|
| 1129 | """Callback for the METARs."""
|
---|
| 1130 | gobject.idle_add(self._handleMETARs, returned, result)
|
---|
| 1131 |
|
---|
| 1132 | def _handleMETARs(self, returned, result):
|
---|
| 1133 | """Handle the METARs."""
|
---|
| 1134 | self._wizard._departureMETAR = None
|
---|
| 1135 | self._wizard._arrivalMETAR = None
|
---|
| 1136 | bookedFlight = self._wizard._bookedFlight
|
---|
| 1137 | if returned:
|
---|
| 1138 | if bookedFlight.departureICAO in result.metars:
|
---|
| 1139 | self._wizard._departureMETAR = result.metars[bookedFlight.departureICAO]
|
---|
| 1140 | if bookedFlight.arrivalICAO in result.metars:
|
---|
| 1141 | self._wizard._arrivalMETAR = result.metars[bookedFlight.arrivalICAO]
|
---|
| 1142 |
|
---|
| 1143 | self._wizard.gui.endBusy()
|
---|
[70] | 1144 | self._backButton.set_sensitive(True)
|
---|
| 1145 | self._button.set_sensitive(True)
|
---|
[62] | 1146 | self._wizard.nextPage()
|
---|
| 1147 |
|
---|
| 1148 | #-----------------------------------------------------------------------------
|
---|
| 1149 |
|
---|
[67] | 1150 | class BriefingPage(Page):
|
---|
| 1151 | """Page for the briefing."""
|
---|
| 1152 | def __init__(self, wizard, departure):
|
---|
| 1153 | """Construct the briefing page."""
|
---|
| 1154 | self._departure = departure
|
---|
| 1155 |
|
---|
[69] | 1156 | title = "Briefing (%d/2): %s" % (1 if departure else 2,
|
---|
| 1157 | "departure" if departure
|
---|
| 1158 | else "arrival")
|
---|
[67] | 1159 |
|
---|
[94] | 1160 | help = "Read carefully the NOTAMs and METAR below.\n\n" \
|
---|
| 1161 | "You can edit the METAR if your simulator or network\n" \
|
---|
| 1162 | "provides different weather."
|
---|
| 1163 | completedHelp = "If your simulator or network provides a different\n" \
|
---|
| 1164 | "weather, you can edit the METAR below."
|
---|
| 1165 | super(BriefingPage, self).__init__(wizard, title, help,
|
---|
| 1166 | completedHelp = completedHelp)
|
---|
[64] | 1167 |
|
---|
| 1168 | alignment = gtk.Alignment(xalign = 0.5, yalign = 0.5,
|
---|
| 1169 | xscale = 1.0, yscale = 1.0)
|
---|
| 1170 |
|
---|
| 1171 | mainBox = gtk.VBox()
|
---|
| 1172 | alignment.add(mainBox)
|
---|
| 1173 | self.setMainWidget(alignment)
|
---|
| 1174 |
|
---|
[67] | 1175 | self._notamsFrame = gtk.Frame()
|
---|
| 1176 | self._notamsFrame.set_label("LHBP NOTAMs")
|
---|
[64] | 1177 | scrolledWindow = gtk.ScrolledWindow()
|
---|
[67] | 1178 | scrolledWindow.set_size_request(-1, 128)
|
---|
[94] | 1179 | # FIXME: these constants should be in common
|
---|
[69] | 1180 | scrolledWindow.set_policy(gtk.PolicyType.AUTOMATIC if pygobject
|
---|
| 1181 | else gtk.POLICY_AUTOMATIC,
|
---|
| 1182 | gtk.PolicyType.AUTOMATIC if pygobject
|
---|
| 1183 | else gtk.POLICY_AUTOMATIC)
|
---|
[67] | 1184 | self._notams = gtk.TextView()
|
---|
| 1185 | self._notams.set_editable(False)
|
---|
| 1186 | self._notams.set_accepts_tab(False)
|
---|
| 1187 | self._notams.set_wrap_mode(gtk.WrapMode.WORD if pygobject else gtk.WRAP_WORD)
|
---|
| 1188 | scrolledWindow.add(self._notams)
|
---|
| 1189 | alignment = gtk.Alignment(xalign = 0.0, yalign = 0.0,
|
---|
| 1190 | xscale = 1.0, yscale = 1.0)
|
---|
| 1191 | alignment.set_padding(padding_top = 4, padding_bottom = 0,
|
---|
| 1192 | padding_left = 0, padding_right = 0)
|
---|
| 1193 | alignment.add(scrolledWindow)
|
---|
| 1194 | self._notamsFrame.add(alignment)
|
---|
| 1195 | mainBox.pack_start(self._notamsFrame, True, True, 4)
|
---|
| 1196 |
|
---|
| 1197 | self._metarFrame = gtk.Frame()
|
---|
| 1198 | self._metarFrame.set_label("LHBP METAR")
|
---|
| 1199 | scrolledWindow = gtk.ScrolledWindow()
|
---|
| 1200 | scrolledWindow.set_size_request(-1, 32)
|
---|
[69] | 1201 | scrolledWindow.set_policy(gtk.PolicyType.AUTOMATIC if pygobject
|
---|
| 1202 | else gtk.POLICY_AUTOMATIC,
|
---|
| 1203 | gtk.PolicyType.AUTOMATIC if pygobject
|
---|
| 1204 | else gtk.POLICY_AUTOMATIC)
|
---|
[67] | 1205 | self._metar = gtk.TextView()
|
---|
| 1206 | self._metar.set_accepts_tab(False)
|
---|
| 1207 | self._metar.set_wrap_mode(gtk.WrapMode.WORD if pygobject else gtk.WRAP_WORD)
|
---|
| 1208 | scrolledWindow.add(self._metar)
|
---|
| 1209 | alignment = gtk.Alignment(xalign = 0.0, yalign = 0.0,
|
---|
| 1210 | xscale = 1.0, yscale = 1.0)
|
---|
| 1211 | alignment.set_padding(padding_top = 4, padding_bottom = 0,
|
---|
| 1212 | padding_left = 0, padding_right = 0)
|
---|
| 1213 | alignment.add(scrolledWindow)
|
---|
| 1214 | self._metarFrame.add(alignment)
|
---|
| 1215 | mainBox.pack_start(self._metarFrame, True, True, 4)
|
---|
[64] | 1216 |
|
---|
[70] | 1217 | button = self.addButton(gtk.STOCK_GO_BACK)
|
---|
| 1218 | button.set_use_stock(True)
|
---|
| 1219 | button.connect("clicked", self._backClicked)
|
---|
| 1220 |
|
---|
[64] | 1221 | self._button = self.addButton(gtk.STOCK_GO_FORWARD, default = True)
|
---|
| 1222 | self._button.set_use_stock(True)
|
---|
| 1223 | self._button.connect("clicked", self._forwardClicked)
|
---|
| 1224 |
|
---|
[97] | 1225 | @property
|
---|
| 1226 | def metar(self):
|
---|
| 1227 | """Get the METAR on the page."""
|
---|
| 1228 | buffer = self._metar.get_buffer()
|
---|
| 1229 | return buffer.get_text(buffer.get_start_iter(),
|
---|
| 1230 | buffer.get_end_iter(), True)
|
---|
| 1231 |
|
---|
[64] | 1232 | def activate(self):
|
---|
| 1233 | """Activate the page."""
|
---|
[70] | 1234 | if not self._departure:
|
---|
| 1235 | self._button.set_label("I have read the briefing and am ready to fly!")
|
---|
| 1236 | self._button.set_use_stock(False)
|
---|
| 1237 |
|
---|
| 1238 | bookedFlight = self._wizard._bookedFlight
|
---|
[67] | 1239 |
|
---|
[70] | 1240 | icao = bookedFlight.departureICAO if self._departure \
|
---|
| 1241 | else bookedFlight.arrivalICAO
|
---|
| 1242 | notams = self._wizard._departureNOTAMs if self._departure \
|
---|
| 1243 | else self._wizard._arrivalNOTAMs
|
---|
| 1244 | metar = self._wizard._departureMETAR if self._departure \
|
---|
| 1245 | else self._wizard._arrivalMETAR
|
---|
[64] | 1246 |
|
---|
[70] | 1247 | self._notamsFrame.set_label(icao + " NOTAMs")
|
---|
| 1248 | buffer = self._notams.get_buffer()
|
---|
| 1249 | if notams is None:
|
---|
| 1250 | buffer.set_text("Could not download NOTAMs")
|
---|
[92] | 1251 | elif not notams:
|
---|
| 1252 | buffer.set_text("Could not download NOTAM for this airport")
|
---|
[70] | 1253 | else:
|
---|
| 1254 | s = ""
|
---|
| 1255 | for notam in notams:
|
---|
| 1256 | s += str(notam.begin)
|
---|
| 1257 | if notam.end is not None:
|
---|
| 1258 | s += " - " + str(notam.end)
|
---|
| 1259 | elif notam.permanent:
|
---|
| 1260 | s += " - PERMANENT"
|
---|
| 1261 | s += "\n"
|
---|
| 1262 | if notam.repeatCycle:
|
---|
| 1263 | s += "Repeat cycle: " + notam.repeatCycle + "\n"
|
---|
| 1264 | s += notam.notice + "\n"
|
---|
| 1265 | s += "-------------------- * --------------------\n"
|
---|
| 1266 | buffer.set_text(s)
|
---|
[67] | 1267 |
|
---|
[70] | 1268 | self._metarFrame.set_label(icao + " METAR")
|
---|
| 1269 | buffer = self._metar.get_buffer()
|
---|
| 1270 | if metar is None:
|
---|
| 1271 | buffer.set_text("Could not download METAR")
|
---|
| 1272 | else:
|
---|
| 1273 | buffer.set_text(metar)
|
---|
[67] | 1274 |
|
---|
[70] | 1275 | def _backClicked(self, button):
|
---|
| 1276 | """Called when the Back button is pressed."""
|
---|
| 1277 | self.goBack()
|
---|
| 1278 |
|
---|
[67] | 1279 | def _forwardClicked(self, button):
|
---|
[64] | 1280 | """Called when the forward button is clicked."""
|
---|
[70] | 1281 | if not self._departure:
|
---|
[94] | 1282 | if not self._completed:
|
---|
[70] | 1283 | self._wizard.gui.startMonitoring()
|
---|
[86] | 1284 | self._button.set_use_stock(True)
|
---|
| 1285 | self._button.set_label(gtk.STOCK_GO_FORWARD)
|
---|
[94] | 1286 | self.complete()
|
---|
[71] | 1287 |
|
---|
| 1288 | self._wizard.nextPage()
|
---|
| 1289 |
|
---|
| 1290 | #-----------------------------------------------------------------------------
|
---|
| 1291 |
|
---|
| 1292 | class TakeoffPage(Page):
|
---|
| 1293 | """Page for entering the takeoff data."""
|
---|
| 1294 | def __init__(self, wizard):
|
---|
| 1295 | """Construct the takeoff page."""
|
---|
| 1296 | help = "Enter the runway and SID used, as well as the speeds."
|
---|
[94] | 1297 | completedHelp = "The runway, SID and takeoff speeds logged can be seen below."
|
---|
[71] | 1298 |
|
---|
[94] | 1299 | super(TakeoffPage, self).__init__(wizard, "Takeoff", help,
|
---|
| 1300 | completedHelp = completedHelp)
|
---|
[71] | 1301 |
|
---|
[101] | 1302 | self._forwardAllowed = False
|
---|
| 1303 |
|
---|
[71] | 1304 | alignment = gtk.Alignment(xalign = 0.5, yalign = 0.5,
|
---|
| 1305 | xscale = 0.0, yscale = 0.0)
|
---|
| 1306 |
|
---|
[84] | 1307 | table = gtk.Table(5, 4)
|
---|
[71] | 1308 | table.set_row_spacings(4)
|
---|
| 1309 | table.set_col_spacings(16)
|
---|
| 1310 | table.set_homogeneous(False)
|
---|
| 1311 | alignment.add(table)
|
---|
| 1312 | self.setMainWidget(alignment)
|
---|
| 1313 |
|
---|
| 1314 | label = gtk.Label("Run_way:")
|
---|
| 1315 | label.set_use_underline(True)
|
---|
| 1316 | label.set_alignment(0.0, 0.5)
|
---|
| 1317 | table.attach(label, 0, 1, 0, 1)
|
---|
| 1318 |
|
---|
| 1319 | self._runway = gtk.Entry()
|
---|
| 1320 | self._runway.set_width_chars(10)
|
---|
| 1321 | self._runway.set_tooltip_text("The runway the takeoff is performed from.")
|
---|
[101] | 1322 | self._runway.connect("changed", self._valueChanged)
|
---|
[84] | 1323 | table.attach(self._runway, 1, 3, 0, 1)
|
---|
[71] | 1324 | label.set_mnemonic_widget(self._runway)
|
---|
| 1325 |
|
---|
| 1326 | label = gtk.Label("_SID:")
|
---|
| 1327 | label.set_use_underline(True)
|
---|
| 1328 | label.set_alignment(0.0, 0.5)
|
---|
| 1329 | table.attach(label, 0, 1, 1, 2)
|
---|
| 1330 |
|
---|
| 1331 | self._sid = gtk.Entry()
|
---|
| 1332 | self._sid.set_width_chars(10)
|
---|
[75] | 1333 | self._sid.set_tooltip_text("The name of the Standard Instrument Deparature procedure followed.")
|
---|
[101] | 1334 | self._sid.connect("changed", self._valueChanged)
|
---|
[84] | 1335 | table.attach(self._sid, 1, 3, 1, 2)
|
---|
[71] | 1336 | label.set_mnemonic_widget(self._sid)
|
---|
| 1337 |
|
---|
| 1338 | label = gtk.Label("V<sub>_1</sub>:")
|
---|
| 1339 | label.set_use_markup(True)
|
---|
| 1340 | label.set_use_underline(True)
|
---|
| 1341 | label.set_alignment(0.0, 0.5)
|
---|
| 1342 | table.attach(label, 0, 1, 2, 3)
|
---|
| 1343 |
|
---|
[84] | 1344 | self._v1 = IntegerEntry()
|
---|
[86] | 1345 | self._v1.set_width_chars(4)
|
---|
[71] | 1346 | self._v1.set_tooltip_markup("The takeoff decision speed in knots.")
|
---|
[101] | 1347 | self._v1.connect("integer-changed", self._valueChanged)
|
---|
[84] | 1348 | table.attach(self._v1, 2, 3, 2, 3)
|
---|
[71] | 1349 | label.set_mnemonic_widget(self._v1)
|
---|
| 1350 |
|
---|
[84] | 1351 | table.attach(gtk.Label("knots"), 3, 4, 2, 3)
|
---|
[71] | 1352 |
|
---|
[86] | 1353 | label = gtk.Label("V<sub>_R</sub>:")
|
---|
[71] | 1354 | label.set_use_markup(True)
|
---|
| 1355 | label.set_use_underline(True)
|
---|
| 1356 | label.set_alignment(0.0, 0.5)
|
---|
| 1357 | table.attach(label, 0, 1, 3, 4)
|
---|
| 1358 |
|
---|
[84] | 1359 | self._vr = IntegerEntry()
|
---|
[86] | 1360 | self._vr.set_width_chars(4)
|
---|
[71] | 1361 | self._vr.set_tooltip_markup("The takeoff rotation speed in knots.")
|
---|
[101] | 1362 | self._vr.connect("integer-changed", self._valueChanged)
|
---|
[84] | 1363 | table.attach(self._vr, 2, 3, 3, 4)
|
---|
[71] | 1364 | label.set_mnemonic_widget(self._vr)
|
---|
| 1365 |
|
---|
[84] | 1366 | table.attach(gtk.Label("knots"), 3, 4, 3, 4)
|
---|
[71] | 1367 |
|
---|
| 1368 | label = gtk.Label("V<sub>_2</sub>:")
|
---|
| 1369 | label.set_use_markup(True)
|
---|
| 1370 | label.set_use_underline(True)
|
---|
| 1371 | label.set_alignment(0.0, 0.5)
|
---|
| 1372 | table.attach(label, 0, 1, 4, 5)
|
---|
| 1373 |
|
---|
[84] | 1374 | self._v2 = IntegerEntry()
|
---|
[86] | 1375 | self._v2.set_width_chars(4)
|
---|
[71] | 1376 | self._v2.set_tooltip_markup("The takeoff safety speed in knots.")
|
---|
[101] | 1377 | self._v2.connect("integer-changed", self._valueChanged)
|
---|
[84] | 1378 | table.attach(self._v2, 2, 3, 4, 5)
|
---|
[71] | 1379 | label.set_mnemonic_widget(self._v2)
|
---|
| 1380 |
|
---|
[84] | 1381 | table.attach(gtk.Label("knots"), 3, 4, 4, 5)
|
---|
[71] | 1382 |
|
---|
| 1383 | button = self.addButton(gtk.STOCK_GO_BACK)
|
---|
| 1384 | button.set_use_stock(True)
|
---|
| 1385 | button.connect("clicked", self._backClicked)
|
---|
| 1386 |
|
---|
| 1387 | self._button = self.addButton(gtk.STOCK_GO_FORWARD, default = True)
|
---|
| 1388 | self._button.set_use_stock(True)
|
---|
| 1389 | self._button.connect("clicked", self._forwardClicked)
|
---|
| 1390 |
|
---|
[84] | 1391 | @property
|
---|
[97] | 1392 | def runway(self):
|
---|
| 1393 | """Get the runway."""
|
---|
| 1394 | return self._runway.get_text()
|
---|
| 1395 |
|
---|
| 1396 | @property
|
---|
| 1397 | def sid(self):
|
---|
| 1398 | """Get the SID."""
|
---|
| 1399 | return self._sid.get_text()
|
---|
| 1400 |
|
---|
| 1401 | @property
|
---|
[84] | 1402 | def v1(self):
|
---|
| 1403 | """Get the v1 speed."""
|
---|
| 1404 | return self._v1.get_int()
|
---|
| 1405 |
|
---|
| 1406 | @property
|
---|
| 1407 | def vr(self):
|
---|
| 1408 | """Get the vr speed."""
|
---|
| 1409 | return self._vr.get_int()
|
---|
| 1410 |
|
---|
| 1411 | @property
|
---|
| 1412 | def v2(self):
|
---|
| 1413 | """Get the v2 speed."""
|
---|
| 1414 | return self._v2.get_int()
|
---|
| 1415 |
|
---|
[71] | 1416 | def activate(self):
|
---|
| 1417 | """Activate the page."""
|
---|
[72] | 1418 | self._runway.set_text("")
|
---|
[71] | 1419 | self._runway.set_sensitive(True)
|
---|
[72] | 1420 | self._sid.set_text("")
|
---|
[71] | 1421 | self._sid.set_sensitive(True)
|
---|
[84] | 1422 | self._v1.set_int(None)
|
---|
[71] | 1423 | self._v1.set_sensitive(True)
|
---|
[86] | 1424 | self._vr.set_int(None)
|
---|
[71] | 1425 | self._vr.set_sensitive(True)
|
---|
[86] | 1426 | self._v2.set_int(None)
|
---|
[71] | 1427 | self._v2.set_sensitive(True)
|
---|
[84] | 1428 | self._button.set_sensitive(False)
|
---|
[71] | 1429 |
|
---|
[101] | 1430 | def finalize(self):
|
---|
| 1431 | """Finalize the page."""
|
---|
[71] | 1432 | self._runway.set_sensitive(False)
|
---|
| 1433 | self._sid.set_sensitive(False)
|
---|
| 1434 | self._v1.set_sensitive(False)
|
---|
| 1435 | self._vr.set_sensitive(False)
|
---|
| 1436 | self._v2.set_sensitive(False)
|
---|
[101] | 1437 | self._wizard.gui.flight.aircraft.updateV1R2()
|
---|
| 1438 |
|
---|
| 1439 | def allowForward(self):
|
---|
| 1440 | """Allow going to the next page."""
|
---|
| 1441 | self._forwardAllowed = True
|
---|
| 1442 | self._updateForwardButton()
|
---|
| 1443 |
|
---|
| 1444 | def _updateForwardButton(self):
|
---|
| 1445 | """Update the sensitivity of the forward button based on some conditions."""
|
---|
| 1446 | sensitive = self._forwardAllowed and \
|
---|
| 1447 | self._runway.get_text()!="" and \
|
---|
| 1448 | self._sid.get_text()!="" and \
|
---|
| 1449 | self.v1 is not None and \
|
---|
| 1450 | self.vr is not None and \
|
---|
| 1451 | self.v2 is not None and \
|
---|
| 1452 | self.v1 <= self.vr and \
|
---|
| 1453 | self.vr <= self.v2
|
---|
| 1454 | self._button.set_sensitive(sensitive)
|
---|
| 1455 |
|
---|
| 1456 | def _valueChanged(self, widget, arg = None):
|
---|
| 1457 | """Called when the value of some widget has changed."""
|
---|
| 1458 | self._updateForwardButton()
|
---|
[84] | 1459 |
|
---|
[71] | 1460 | def _backClicked(self, button):
|
---|
| 1461 | """Called when the Back button is pressed."""
|
---|
| 1462 | self.goBack()
|
---|
| 1463 |
|
---|
| 1464 | def _forwardClicked(self, button):
|
---|
| 1465 | """Called when the forward button is clicked."""
|
---|
[75] | 1466 | self._wizard.nextPage()
|
---|
| 1467 |
|
---|
| 1468 | #-----------------------------------------------------------------------------
|
---|
| 1469 |
|
---|
| 1470 | class LandingPage(Page):
|
---|
| 1471 | """Page for entering landing data."""
|
---|
| 1472 | def __init__(self, wizard):
|
---|
| 1473 | """Construct the landing page."""
|
---|
| 1474 | help = "Enter the STAR and/or transition, runway,\n" \
|
---|
[86] | 1475 | "approach type and V<sub>Ref</sub> used."
|
---|
[94] | 1476 | completedHelp = "The STAR and/or transition, runway, approach\n" \
|
---|
| 1477 | "type and V<sub>Ref</sub> logged can be seen below."
|
---|
[75] | 1478 |
|
---|
[94] | 1479 | super(LandingPage, self).__init__(wizard, "Landing", help,
|
---|
| 1480 | completedHelp = completedHelp)
|
---|
[75] | 1481 |
|
---|
[88] | 1482 | self._flightEnded = False
|
---|
| 1483 |
|
---|
[75] | 1484 | alignment = gtk.Alignment(xalign = 0.5, yalign = 0.5,
|
---|
| 1485 | xscale = 0.0, yscale = 0.0)
|
---|
| 1486 |
|
---|
[86] | 1487 | table = gtk.Table(5, 5)
|
---|
[75] | 1488 | table.set_row_spacings(4)
|
---|
| 1489 | table.set_col_spacings(16)
|
---|
| 1490 | table.set_homogeneous(False)
|
---|
| 1491 | alignment.add(table)
|
---|
| 1492 | self.setMainWidget(alignment)
|
---|
| 1493 |
|
---|
| 1494 | self._starButton = gtk.CheckButton()
|
---|
| 1495 | self._starButton.connect("clicked", self._starButtonClicked)
|
---|
| 1496 | table.attach(self._starButton, 0, 1, 0, 1)
|
---|
| 1497 |
|
---|
| 1498 | label = gtk.Label("_STAR:")
|
---|
| 1499 | label.set_use_underline(True)
|
---|
| 1500 | label.set_alignment(0.0, 0.5)
|
---|
| 1501 | table.attach(label, 1, 2, 0, 1)
|
---|
| 1502 |
|
---|
| 1503 | self._star = gtk.Entry()
|
---|
| 1504 | self._star.set_width_chars(10)
|
---|
| 1505 | self._star.set_tooltip_text("The name of Standard Terminal Arrival Route followed.")
|
---|
| 1506 | self._star.connect("changed", self._updateForwardButton)
|
---|
| 1507 | self._star.set_sensitive(False)
|
---|
[86] | 1508 | table.attach(self._star, 2, 4, 0, 1)
|
---|
[75] | 1509 | label.set_mnemonic_widget(self._starButton)
|
---|
| 1510 |
|
---|
| 1511 | self._transitionButton = gtk.CheckButton()
|
---|
| 1512 | self._transitionButton.connect("clicked", self._transitionButtonClicked)
|
---|
| 1513 | table.attach(self._transitionButton, 0, 1, 1, 2)
|
---|
| 1514 |
|
---|
| 1515 | label = gtk.Label("_Transition:")
|
---|
| 1516 | label.set_use_underline(True)
|
---|
| 1517 | label.set_alignment(0.0, 0.5)
|
---|
| 1518 | table.attach(label, 1, 2, 1, 2)
|
---|
| 1519 |
|
---|
| 1520 | self._transition = gtk.Entry()
|
---|
| 1521 | self._transition.set_width_chars(10)
|
---|
| 1522 | self._transition.set_tooltip_text("The name of transition executed or VECTORS if vectored by ATC.")
|
---|
| 1523 | self._transition.connect("changed", self._updateForwardButton)
|
---|
| 1524 | self._transition.set_sensitive(False)
|
---|
[86] | 1525 | table.attach(self._transition, 2, 4, 1, 2)
|
---|
[75] | 1526 | label.set_mnemonic_widget(self._transitionButton)
|
---|
| 1527 |
|
---|
| 1528 | label = gtk.Label("Run_way:")
|
---|
| 1529 | label.set_use_underline(True)
|
---|
| 1530 | label.set_alignment(0.0, 0.5)
|
---|
| 1531 | table.attach(label, 1, 2, 2, 3)
|
---|
| 1532 |
|
---|
| 1533 | self._runway = gtk.Entry()
|
---|
| 1534 | self._runway.set_width_chars(10)
|
---|
| 1535 | self._runway.set_tooltip_text("The runway the landing is performed on.")
|
---|
| 1536 | self._runway.connect("changed", self._updateForwardButton)
|
---|
[86] | 1537 | table.attach(self._runway, 2, 4, 2, 3)
|
---|
[75] | 1538 | label.set_mnemonic_widget(self._runway)
|
---|
| 1539 |
|
---|
| 1540 | label = gtk.Label("_Approach type:")
|
---|
| 1541 | label.set_use_underline(True)
|
---|
| 1542 | label.set_alignment(0.0, 0.5)
|
---|
| 1543 | table.attach(label, 1, 2, 3, 4)
|
---|
| 1544 |
|
---|
| 1545 | self._approachType = gtk.Entry()
|
---|
| 1546 | self._approachType.set_width_chars(10)
|
---|
| 1547 | self._approachType.set_tooltip_text("The type of the approach, e.g. ILS or VISUAL.")
|
---|
[76] | 1548 | self._approachType.connect("changed", self._updateForwardButton)
|
---|
[86] | 1549 | table.attach(self._approachType, 2, 4, 3, 4)
|
---|
[75] | 1550 | label.set_mnemonic_widget(self._approachType)
|
---|
| 1551 |
|
---|
[86] | 1552 | label = gtk.Label("V<sub>_Ref</sub>:")
|
---|
[75] | 1553 | label.set_use_markup(True)
|
---|
| 1554 | label.set_use_underline(True)
|
---|
| 1555 | label.set_alignment(0.0, 0.5)
|
---|
| 1556 | table.attach(label, 1, 2, 5, 6)
|
---|
| 1557 |
|
---|
[86] | 1558 | self._vref = IntegerEntry()
|
---|
| 1559 | self._vref.set_width_chars(5)
|
---|
[75] | 1560 | self._vref.set_tooltip_markup("The approach reference speed in knots.")
|
---|
[86] | 1561 | self._vref.connect("integer-changed", self._vrefChanged)
|
---|
| 1562 | table.attach(self._vref, 3, 4, 5, 6)
|
---|
[75] | 1563 | label.set_mnemonic_widget(self._vref)
|
---|
| 1564 |
|
---|
[86] | 1565 | table.attach(gtk.Label("knots"), 4, 5, 5, 6)
|
---|
[75] | 1566 |
|
---|
| 1567 | button = self.addButton(gtk.STOCK_GO_BACK)
|
---|
| 1568 | button.set_use_stock(True)
|
---|
| 1569 | button.connect("clicked", self._backClicked)
|
---|
| 1570 |
|
---|
| 1571 | self._button = self.addButton(gtk.STOCK_GO_FORWARD, default = True)
|
---|
| 1572 | self._button.set_use_stock(True)
|
---|
| 1573 | self._button.connect("clicked", self._forwardClicked)
|
---|
| 1574 |
|
---|
[76] | 1575 | # These are needed for correct size calculations
|
---|
| 1576 | self._starButton.set_active(True)
|
---|
| 1577 | self._transitionButton.set_active(True)
|
---|
| 1578 |
|
---|
[86] | 1579 | @property
|
---|
[97] | 1580 | def star(self):
|
---|
| 1581 | """Get the STAR or None if none entered."""
|
---|
| 1582 | return self._star.get_text() if self._starButton.get_active() else None
|
---|
| 1583 |
|
---|
| 1584 | @property
|
---|
| 1585 | def transition(self):
|
---|
| 1586 | """Get the transition or None if none entered."""
|
---|
| 1587 | return self._transition.get_text() \
|
---|
| 1588 | if self._transitionButton.get_active() else None
|
---|
| 1589 |
|
---|
| 1590 | @property
|
---|
| 1591 | def approachType(self):
|
---|
| 1592 | """Get the approach type."""
|
---|
| 1593 | return self._approachType.get_text()
|
---|
| 1594 |
|
---|
| 1595 | @property
|
---|
| 1596 | def runway(self):
|
---|
| 1597 | """Get the runway."""
|
---|
| 1598 | return self._runway.get_text()
|
---|
| 1599 |
|
---|
| 1600 | @property
|
---|
[86] | 1601 | def vref(self):
|
---|
| 1602 | """Return the landing reference speed."""
|
---|
| 1603 | return self._vref.get_int()
|
---|
| 1604 |
|
---|
[75] | 1605 | def activate(self):
|
---|
| 1606 | """Called when the page is activated."""
|
---|
| 1607 | self._starButton.set_sensitive(True)
|
---|
| 1608 | self._starButton.set_active(False)
|
---|
| 1609 | self._star.set_text("")
|
---|
| 1610 |
|
---|
| 1611 | self._transitionButton.set_sensitive(True)
|
---|
| 1612 | self._transitionButton.set_active(False)
|
---|
| 1613 | self._transition.set_text("")
|
---|
| 1614 |
|
---|
| 1615 | self._runway.set_text("")
|
---|
| 1616 | self._runway.set_sensitive(True)
|
---|
| 1617 |
|
---|
| 1618 | self._approachType.set_text("")
|
---|
| 1619 | self._approachType.set_sensitive(True)
|
---|
| 1620 |
|
---|
[86] | 1621 | self._vref.set_int(None)
|
---|
[75] | 1622 | self._vref.set_sensitive(True)
|
---|
| 1623 |
|
---|
| 1624 | self._updateForwardButton()
|
---|
| 1625 |
|
---|
[88] | 1626 | def flightEnded(self):
|
---|
| 1627 | """Called when the flight has ended."""
|
---|
| 1628 | self._flightEnded = True
|
---|
| 1629 | self._updateForwardButton()
|
---|
| 1630 |
|
---|
[75] | 1631 | def finalize(self):
|
---|
| 1632 | """Finalize the page."""
|
---|
| 1633 | self._starButton.set_sensitive(False)
|
---|
| 1634 | self._star.set_sensitive(False)
|
---|
| 1635 |
|
---|
| 1636 | self._transitionButton.set_sensitive(False)
|
---|
| 1637 | self._transition.set_sensitive(False)
|
---|
| 1638 |
|
---|
| 1639 | self._runway.set_sensitive(False)
|
---|
| 1640 |
|
---|
| 1641 | self._approachType.set_sensitive(False)
|
---|
| 1642 |
|
---|
| 1643 | self._vref.set_sensitive(False)
|
---|
[96] | 1644 | self._wizard.gui.flight.aircraft.updateVRef()
|
---|
[89] | 1645 | # FIXME: Perhaps a separate initialize() call which would set up
|
---|
[96] | 1646 | # defaults? -> use reset()
|
---|
[89] | 1647 | self._flightEnded = False
|
---|
[75] | 1648 |
|
---|
| 1649 | def _starButtonClicked(self, button):
|
---|
| 1650 | """Called when the STAR button is clicked."""
|
---|
| 1651 | active = button.get_active()
|
---|
| 1652 | self._star.set_sensitive(active)
|
---|
| 1653 | if active:
|
---|
| 1654 | self._star.grab_focus()
|
---|
| 1655 | self._updateForwardButton()
|
---|
| 1656 |
|
---|
| 1657 | def _transitionButtonClicked(self, button):
|
---|
| 1658 | """Called when the Transition button is clicked."""
|
---|
| 1659 | active = button.get_active()
|
---|
| 1660 | self._transition.set_sensitive(active)
|
---|
| 1661 | if active:
|
---|
| 1662 | self._transition.grab_focus()
|
---|
[86] | 1663 | self._updateForwardButton()
|
---|
[75] | 1664 |
|
---|
| 1665 | def _updateForwardButton(self, widget = None):
|
---|
| 1666 | """Update the sensitivity of the forward button."""
|
---|
[88] | 1667 | sensitive = self._flightEnded and \
|
---|
| 1668 | (self._starButton.get_active() or \
|
---|
[75] | 1669 | self._transitionButton.get_active()) and \
|
---|
| 1670 | (self._star.get_text()!="" or
|
---|
| 1671 | not self._starButton.get_active()) and \
|
---|
| 1672 | (self._transition.get_text()!="" or
|
---|
| 1673 | not self._transitionButton.get_active()) and \
|
---|
| 1674 | self._runway.get_text()!="" and \
|
---|
[86] | 1675 | self._approachType.get_text()!="" and \
|
---|
| 1676 | self.vref is not None
|
---|
[75] | 1677 | self._button.set_sensitive(sensitive)
|
---|
| 1678 |
|
---|
[86] | 1679 | def _vrefChanged(self, widget, value):
|
---|
| 1680 | """Called when the Vref has changed."""
|
---|
| 1681 | self._updateForwardButton()
|
---|
| 1682 |
|
---|
[75] | 1683 | def _backClicked(self, button):
|
---|
| 1684 | """Called when the Back button is pressed."""
|
---|
| 1685 | self.goBack()
|
---|
| 1686 |
|
---|
| 1687 | def _forwardClicked(self, button):
|
---|
| 1688 | """Called when the forward button is clicked."""
|
---|
[89] | 1689 | self._wizard.nextPage()
|
---|
| 1690 |
|
---|
| 1691 | #-----------------------------------------------------------------------------
|
---|
| 1692 |
|
---|
| 1693 | class FinishPage(Page):
|
---|
| 1694 | """Flight finish page."""
|
---|
[97] | 1695 | _flightTypes = [ ("scheduled", const.FLIGHTTYPE_SCHEDULED),
|
---|
| 1696 | ("old-timer", const.FLIGHTTYPE_OLDTIMER),
|
---|
| 1697 | ("VIP", const.FLIGHTTYPE_VIP),
|
---|
| 1698 | ("charter", const.FLIGHTTYPE_CHARTER) ]
|
---|
| 1699 |
|
---|
[89] | 1700 | def __init__(self, wizard):
|
---|
| 1701 | """Construct the finish page."""
|
---|
| 1702 | help = "There are some statistics about your flight below.\n\n" \
|
---|
| 1703 | "Review the data, also on earlier pages, and if you are\n" \
|
---|
| 1704 | "satisfied, you can save or send your PIREP."
|
---|
| 1705 |
|
---|
| 1706 | super(FinishPage, self).__init__(wizard, "Finish", help)
|
---|
| 1707 |
|
---|
| 1708 | alignment = gtk.Alignment(xalign = 0.5, yalign = 0.5,
|
---|
| 1709 | xscale = 0.0, yscale = 0.0)
|
---|
| 1710 |
|
---|
[96] | 1711 | table = gtk.Table(7, 2)
|
---|
[89] | 1712 | table.set_row_spacings(4)
|
---|
| 1713 | table.set_col_spacings(16)
|
---|
[96] | 1714 | table.set_homogeneous(False)
|
---|
[89] | 1715 | alignment.add(table)
|
---|
| 1716 | self.setMainWidget(alignment)
|
---|
| 1717 |
|
---|
| 1718 | labelAlignment = gtk.Alignment(xalign=1.0, xscale=0.0)
|
---|
| 1719 | label = gtk.Label("Flight rating:")
|
---|
| 1720 | labelAlignment.add(label)
|
---|
| 1721 | table.attach(labelAlignment, 0, 1, 0, 1)
|
---|
| 1722 |
|
---|
| 1723 | labelAlignment = gtk.Alignment(xalign=0.0, xscale=0.0)
|
---|
| 1724 | self._flightRating = gtk.Label()
|
---|
| 1725 | self._flightRating.set_width_chars(7)
|
---|
| 1726 | self._flightRating.set_alignment(0.0, 0.5)
|
---|
| 1727 | self._flightRating.set_use_markup(True)
|
---|
| 1728 | labelAlignment.add(self._flightRating)
|
---|
| 1729 | table.attach(labelAlignment, 1, 2, 0, 1)
|
---|
| 1730 |
|
---|
| 1731 | labelAlignment = gtk.Alignment(xalign=1.0, xscale=0.0)
|
---|
| 1732 | label = gtk.Label("Flight time:")
|
---|
| 1733 | labelAlignment.add(label)
|
---|
| 1734 | table.attach(labelAlignment, 0, 1, 1, 2)
|
---|
| 1735 |
|
---|
| 1736 | labelAlignment = gtk.Alignment(xalign=0.0, xscale=0.0)
|
---|
| 1737 | self._flightTime = gtk.Label()
|
---|
| 1738 | self._flightTime.set_width_chars(10)
|
---|
| 1739 | self._flightTime.set_alignment(0.0, 0.5)
|
---|
| 1740 | self._flightTime.set_use_markup(True)
|
---|
| 1741 | labelAlignment.add(self._flightTime)
|
---|
| 1742 | table.attach(labelAlignment, 1, 2, 1, 2)
|
---|
| 1743 |
|
---|
| 1744 | labelAlignment = gtk.Alignment(xalign=1.0, xscale=0.0)
|
---|
| 1745 | label = gtk.Label("Block time:")
|
---|
| 1746 | labelAlignment.add(label)
|
---|
| 1747 | table.attach(labelAlignment, 0, 1, 2, 3)
|
---|
| 1748 |
|
---|
| 1749 | labelAlignment = gtk.Alignment(xalign=0.0, xscale=0.0)
|
---|
| 1750 | self._blockTime = gtk.Label()
|
---|
| 1751 | self._blockTime.set_width_chars(10)
|
---|
| 1752 | self._blockTime.set_alignment(0.0, 0.5)
|
---|
| 1753 | self._blockTime.set_use_markup(True)
|
---|
| 1754 | labelAlignment.add(self._blockTime)
|
---|
| 1755 | table.attach(labelAlignment, 1, 2, 2, 3)
|
---|
| 1756 |
|
---|
| 1757 | labelAlignment = gtk.Alignment(xalign=1.0, xscale=0.0)
|
---|
| 1758 | label = gtk.Label("Distance flown:")
|
---|
| 1759 | labelAlignment.add(label)
|
---|
| 1760 | table.attach(labelAlignment, 0, 1, 3, 4)
|
---|
| 1761 |
|
---|
| 1762 | labelAlignment = gtk.Alignment(xalign=0.0, xscale=0.0)
|
---|
| 1763 | self._distanceFlown = gtk.Label()
|
---|
| 1764 | self._distanceFlown.set_width_chars(10)
|
---|
| 1765 | self._distanceFlown.set_alignment(0.0, 0.5)
|
---|
| 1766 | self._distanceFlown.set_use_markup(True)
|
---|
| 1767 | labelAlignment.add(self._distanceFlown)
|
---|
| 1768 | table.attach(labelAlignment, 1, 2, 3, 4)
|
---|
| 1769 |
|
---|
| 1770 | labelAlignment = gtk.Alignment(xalign=1.0, xscale=0.0)
|
---|
| 1771 | label = gtk.Label("Fuel used:")
|
---|
| 1772 | labelAlignment.add(label)
|
---|
| 1773 | table.attach(labelAlignment, 0, 1, 4, 5)
|
---|
| 1774 |
|
---|
| 1775 | labelAlignment = gtk.Alignment(xalign=0.0, xscale=0.0)
|
---|
| 1776 | self._fuelUsed = gtk.Label()
|
---|
| 1777 | self._fuelUsed.set_width_chars(10)
|
---|
| 1778 | self._fuelUsed.set_alignment(0.0, 0.5)
|
---|
| 1779 | self._fuelUsed.set_use_markup(True)
|
---|
| 1780 | labelAlignment.add(self._fuelUsed)
|
---|
| 1781 | table.attach(labelAlignment, 1, 2, 4, 5)
|
---|
| 1782 |
|
---|
[96] | 1783 | labelAlignment = gtk.Alignment(xalign=1.0, xscale=0.0)
|
---|
| 1784 | label = gtk.Label("_Type:")
|
---|
| 1785 | label.set_use_underline(True)
|
---|
| 1786 | labelAlignment.add(label)
|
---|
| 1787 | table.attach(labelAlignment, 0, 1, 5, 6)
|
---|
| 1788 |
|
---|
| 1789 | flightTypeModel = gtk.ListStore(str, int)
|
---|
[97] | 1790 | for (name, type) in FinishPage._flightTypes:
|
---|
| 1791 | flightTypeModel.append([name, type])
|
---|
[96] | 1792 |
|
---|
| 1793 | self._flightType = gtk.ComboBox(model = flightTypeModel)
|
---|
| 1794 | renderer = gtk.CellRendererText()
|
---|
| 1795 | self._flightType.pack_start(renderer, True)
|
---|
| 1796 | self._flightType.add_attribute(renderer, "text", 0)
|
---|
| 1797 | self._flightType.set_tooltip_text("Select the type of the flight.")
|
---|
| 1798 | self._flightType.set_active(0)
|
---|
| 1799 | self._flightType.connect("changed", self._flightTypeChanged)
|
---|
| 1800 | flightTypeAlignment = gtk.Alignment(xalign=0.0, xscale=0.0)
|
---|
| 1801 | flightTypeAlignment.add(self._flightType)
|
---|
| 1802 | table.attach(flightTypeAlignment, 1, 2, 5, 6)
|
---|
| 1803 | label.set_mnemonic_widget(self._flightType)
|
---|
| 1804 |
|
---|
| 1805 | self._onlineFlight = gtk.CheckButton("_Online flight")
|
---|
| 1806 | self._onlineFlight.set_use_underline(True)
|
---|
| 1807 | self._onlineFlight.set_tooltip_text("Check if your flight was online, uncheck otherwise.")
|
---|
| 1808 | onlineFlightAlignment = gtk.Alignment(xalign=0.0, xscale=0.0)
|
---|
| 1809 | onlineFlightAlignment.add(self._onlineFlight)
|
---|
| 1810 | table.attach(onlineFlightAlignment, 1, 2, 6, 7)
|
---|
| 1811 |
|
---|
[94] | 1812 | button = self.addButton(gtk.STOCK_GO_BACK)
|
---|
| 1813 | button.set_use_stock(True)
|
---|
| 1814 | button.connect("clicked", self._backClicked)
|
---|
| 1815 |
|
---|
[89] | 1816 | self._saveButton = self.addButton("S_ave PIREP...")
|
---|
| 1817 | self._saveButton.set_use_underline(True)
|
---|
[94] | 1818 | self._saveButton.set_sensitive(False)
|
---|
[89] | 1819 | #self._saveButton.connect("clicked", self._saveClicked)
|
---|
| 1820 |
|
---|
| 1821 | self._sendButton = self.addButton("_Send PIREP...", True)
|
---|
| 1822 | self._sendButton.set_use_underline(True)
|
---|
[94] | 1823 | self._sendButton.set_sensitive(False)
|
---|
[97] | 1824 | self._sendButton.connect("clicked", self._sendClicked)
|
---|
| 1825 |
|
---|
| 1826 | @property
|
---|
| 1827 | def flightType(self):
|
---|
| 1828 | """Get the flight type."""
|
---|
| 1829 | index = self._flightType.get_active()
|
---|
| 1830 | return None if index<0 else self._flightType.get_model()[index][1]
|
---|
| 1831 |
|
---|
| 1832 | @property
|
---|
| 1833 | def online(self):
|
---|
| 1834 | """Get whether the flight was an online flight or not."""
|
---|
| 1835 | return self._onlineFlight.get_active()
|
---|
[89] | 1836 |
|
---|
| 1837 | def activate(self):
|
---|
| 1838 | """Activate the page."""
|
---|
| 1839 | flight = self._wizard.gui._flight
|
---|
| 1840 | rating = flight.logger.getRating()
|
---|
| 1841 | if rating<0:
|
---|
| 1842 | self._flightRating.set_markup('<b><span foreground="red">NO GO</span></b>')
|
---|
| 1843 | else:
|
---|
| 1844 | self._flightRating.set_markup("<b>%.1f %%</b>" % (rating,))
|
---|
| 1845 |
|
---|
| 1846 | flightLength = flight.flightTimeEnd - flight.flightTimeStart
|
---|
| 1847 | self._flightTime.set_markup("<b>%s</b>" % \
|
---|
| 1848 | (util.getTimeIntervalString(flightLength),))
|
---|
| 1849 |
|
---|
| 1850 | blockLength = flight.blockTimeEnd - flight.blockTimeStart
|
---|
| 1851 | self._blockTime.set_markup("<b>%s</b>" % \
|
---|
| 1852 | (util.getTimeIntervalString(blockLength),))
|
---|
| 1853 |
|
---|
| 1854 | self._distanceFlown.set_markup("<b>%.2f NM</b>" % \
|
---|
| 1855 | (flight.flownDistance,))
|
---|
| 1856 |
|
---|
| 1857 | self._fuelUsed.set_markup("<b>%.0f kg</b>" % \
|
---|
[102] | 1858 | (flight.startFuel - flight.endFuel,))
|
---|
[64] | 1859 |
|
---|
[96] | 1860 | self._flightType.set_active(-1)
|
---|
| 1861 | self._onlineFlight.set_active(True)
|
---|
| 1862 |
|
---|
[94] | 1863 | def _backClicked(self, button):
|
---|
| 1864 | """Called when the Back button is pressed."""
|
---|
| 1865 | self.goBack()
|
---|
[96] | 1866 |
|
---|
| 1867 | def _flightTypeChanged(self, comboBox):
|
---|
| 1868 | """Called when the flight type has changed."""
|
---|
| 1869 | index = self._flightType.get_active()
|
---|
| 1870 | flightTypeIsValid = index>=0
|
---|
[97] | 1871 | #self._saveButton.set_sensitive(flightTypeIsValid)
|
---|
[96] | 1872 | self._sendButton.set_sensitive(flightTypeIsValid)
|
---|
[97] | 1873 |
|
---|
| 1874 | def _sendClicked(self, button):
|
---|
| 1875 | """Called when the Send button is clicked."""
|
---|
| 1876 | pirep = PIREP(self._wizard.gui)
|
---|
| 1877 | gui = self._wizard.gui
|
---|
| 1878 | gui.beginBusy("Sending PIREP...")
|
---|
| 1879 | gui.webHandler.sendPIREP(self._pirepSentCallback, pirep)
|
---|
| 1880 |
|
---|
| 1881 | def _pirepSentCallback(self, returned, result):
|
---|
| 1882 | """Callback for the PIREP sending result."""
|
---|
| 1883 | gobject.idle_add(self._handlePIREPSent, returned, result)
|
---|
| 1884 |
|
---|
| 1885 | def _handlePIREPSent(self, returned, result):
|
---|
| 1886 | """Callback for the PIREP sending result."""
|
---|
| 1887 | self._wizard.gui.endBusy()
|
---|
| 1888 | secondaryMarkup = None
|
---|
| 1889 | type = MESSAGETYPE_ERROR
|
---|
| 1890 | if returned:
|
---|
| 1891 | if result.success:
|
---|
| 1892 | type = MESSAGETYPE_INFO
|
---|
| 1893 | messageFormat = "The PIREP was sent successfully."
|
---|
| 1894 | secondaryMarkup = "Await the thorough scrutiny from our PIREP correctors! :)"
|
---|
| 1895 | elif result.alreadyFlown:
|
---|
| 1896 | messageFormat = "The PIREP for this flight has already been sent!"
|
---|
| 1897 | secondaryMarkup = "You may clear the old PIREP on the MAVA website."
|
---|
| 1898 | elif result.notAvailable:
|
---|
| 1899 | messageFormat = "This flight is not available anymore!"
|
---|
| 1900 | else:
|
---|
| 1901 | messageFormat = "The MAVA website returned with an unknown error."
|
---|
| 1902 | secondaryMarkup = "See the debug log for more information."
|
---|
| 1903 | else:
|
---|
| 1904 | print "PIREP sending failed", result
|
---|
| 1905 | messageFormat = "Could not send the PIREP to the MAVA website."
|
---|
| 1906 | secondaryMarkup = "This can be a network problem, in which case\n" \
|
---|
| 1907 | "you may try again later. Or it can be a bug;\n" \
|
---|
| 1908 | "see the debug log for more information."
|
---|
| 1909 |
|
---|
| 1910 | dialog = gtk.MessageDialog(type = type, buttons = BUTTONSTYPE_OK,
|
---|
| 1911 | message_format = messageFormat)
|
---|
| 1912 | if secondaryMarkup is not None:
|
---|
| 1913 | dialog.format_secondary_markup(secondaryMarkup)
|
---|
| 1914 |
|
---|
| 1915 | dialog.run()
|
---|
| 1916 | dialog.hide()
|
---|
[94] | 1917 |
|
---|
[64] | 1918 | #-----------------------------------------------------------------------------
|
---|
| 1919 |
|
---|
[42] | 1920 | class Wizard(gtk.VBox):
|
---|
| 1921 | """The flight wizard."""
|
---|
| 1922 | def __init__(self, gui):
|
---|
| 1923 | """Construct the wizard."""
|
---|
| 1924 | super(Wizard, self).__init__()
|
---|
| 1925 |
|
---|
| 1926 | self.gui = gui
|
---|
| 1927 |
|
---|
| 1928 | self._pages = []
|
---|
| 1929 | self._currentPage = None
|
---|
| 1930 |
|
---|
| 1931 | self._pages.append(LoginPage(self))
|
---|
| 1932 | self._pages.append(FlightSelectionPage(self))
|
---|
[51] | 1933 | self._pages.append(GateSelectionPage(self))
|
---|
| 1934 | self._pages.append(ConnectPage(self))
|
---|
[84] | 1935 | self._payloadPage = PayloadPage(self)
|
---|
| 1936 | self._pages.append(self._payloadPage)
|
---|
[61] | 1937 | self._pages.append(TimePage(self))
|
---|
[84] | 1938 | self._routePage = RoutePage(self)
|
---|
| 1939 | self._pages.append(self._routePage)
|
---|
[97] | 1940 | self._departureBriefingPage = BriefingPage(self, True)
|
---|
| 1941 | self._pages.append(self._departureBriefingPage)
|
---|
| 1942 | self._arrivalBriefingPage = BriefingPage(self, False)
|
---|
| 1943 | self._pages.append(self._arrivalBriefingPage)
|
---|
[84] | 1944 | self._takeoffPage = TakeoffPage(self)
|
---|
| 1945 | self._pages.append(self._takeoffPage)
|
---|
[86] | 1946 | self._landingPage = LandingPage(self)
|
---|
| 1947 | self._pages.append(self._landingPage)
|
---|
[97] | 1948 | self._finishPage = FinishPage(self)
|
---|
| 1949 | self._pages.append(self._finishPage)
|
---|
[67] | 1950 |
|
---|
[51] | 1951 | maxWidth = 0
|
---|
| 1952 | maxHeight = 0
|
---|
| 1953 | for page in self._pages:
|
---|
| 1954 | page.show_all()
|
---|
| 1955 | pageSizeRequest = page.size_request()
|
---|
| 1956 | width = pageSizeRequest.width if pygobject else pageSizeRequest[0]
|
---|
| 1957 | height = pageSizeRequest.height if pygobject else pageSizeRequest[1]
|
---|
| 1958 | maxWidth = max(maxWidth, width)
|
---|
| 1959 | maxHeight = max(maxHeight, height)
|
---|
| 1960 | maxWidth += 16
|
---|
| 1961 | maxHeight += 32
|
---|
| 1962 | self.set_size_request(maxWidth, maxHeight)
|
---|
| 1963 |
|
---|
[59] | 1964 | self._initialize()
|
---|
[51] | 1965 |
|
---|
[48] | 1966 | @property
|
---|
| 1967 | def loginResult(self):
|
---|
| 1968 | """Get the login result."""
|
---|
| 1969 | return self._loginResult
|
---|
| 1970 |
|
---|
[70] | 1971 | def setCurrentPage(self, index, finalize = False):
|
---|
[42] | 1972 | """Set the current page to the one with the given index."""
|
---|
| 1973 | assert index < len(self._pages)
|
---|
[70] | 1974 |
|
---|
| 1975 | fromPage = self._currentPage
|
---|
| 1976 | if fromPage is not None:
|
---|
| 1977 | page = self._pages[fromPage]
|
---|
[94] | 1978 | if finalize and not page._completed:
|
---|
| 1979 | page.complete()
|
---|
[70] | 1980 | self.remove(page)
|
---|
[42] | 1981 |
|
---|
| 1982 | self._currentPage = index
|
---|
[70] | 1983 | page = self._pages[index]
|
---|
| 1984 | self.add(page)
|
---|
| 1985 | if page._fromPage is None:
|
---|
| 1986 | page._fromPage = fromPage
|
---|
[94] | 1987 | page.initialize()
|
---|
[42] | 1988 | self.show_all()
|
---|
[72] | 1989 | if fromPage is not None:
|
---|
| 1990 | self.grabDefault()
|
---|
[42] | 1991 |
|
---|
[84] | 1992 | @property
|
---|
[97] | 1993 | def bookedFlight(self):
|
---|
| 1994 | """Get the booked flight selected."""
|
---|
| 1995 | return self._bookedFlight
|
---|
| 1996 |
|
---|
| 1997 | @property
|
---|
| 1998 | def cargoWeight(self):
|
---|
| 1999 | """Get the calculated ZFW value."""
|
---|
| 2000 | return self._payloadPage.cargoWeight
|
---|
| 2001 |
|
---|
| 2002 | @property
|
---|
[84] | 2003 | def zfw(self):
|
---|
| 2004 | """Get the calculated ZFW value."""
|
---|
| 2005 | return 0 if self._bookedFlight is None \
|
---|
| 2006 | else self._payloadPage.calculateZFW()
|
---|
| 2007 |
|
---|
| 2008 | @property
|
---|
[97] | 2009 | def filedCruiseAltitude(self):
|
---|
| 2010 | """Get the filed cruise altitude."""
|
---|
| 2011 | return self._routePage.filedCruiseLevel * 100
|
---|
| 2012 |
|
---|
| 2013 | @property
|
---|
[84] | 2014 | def cruiseAltitude(self):
|
---|
| 2015 | """Get the cruise altitude."""
|
---|
| 2016 | return self._routePage.cruiseLevel * 100
|
---|
| 2017 |
|
---|
| 2018 | @property
|
---|
[97] | 2019 | def route(self):
|
---|
| 2020 | """Get the route."""
|
---|
| 2021 | return self._routePage.route
|
---|
| 2022 |
|
---|
| 2023 | @property
|
---|
| 2024 | def departureMETAR(self):
|
---|
| 2025 | """Get the METAR of the departure airport."""
|
---|
| 2026 | return self._departureBriefingPage.metar
|
---|
| 2027 |
|
---|
| 2028 | @property
|
---|
| 2029 | def arrivalMETAR(self):
|
---|
| 2030 | """Get the METAR of the arrival airport."""
|
---|
| 2031 | return self._arrivalBriefingPage.metar
|
---|
| 2032 |
|
---|
| 2033 | @property
|
---|
| 2034 | def departureRunway(self):
|
---|
| 2035 | """Get the departure runway."""
|
---|
| 2036 | return self._takeoffPage.runway
|
---|
| 2037 |
|
---|
| 2038 | @property
|
---|
| 2039 | def sid(self):
|
---|
| 2040 | """Get the SID."""
|
---|
| 2041 | return self._takeoffPage.sid
|
---|
| 2042 |
|
---|
| 2043 | @property
|
---|
[84] | 2044 | def v1(self):
|
---|
| 2045 | """Get the V1 speed."""
|
---|
[86] | 2046 | return self._takeoffPage.v1
|
---|
[84] | 2047 |
|
---|
| 2048 | @property
|
---|
| 2049 | def vr(self):
|
---|
| 2050 | """Get the Vr speed."""
|
---|
[86] | 2051 | return self._takeoffPage.vr
|
---|
[84] | 2052 |
|
---|
| 2053 | @property
|
---|
| 2054 | def v2(self):
|
---|
| 2055 | """Get the V2 speed."""
|
---|
[86] | 2056 | return self._takeoffPage.v2
|
---|
| 2057 |
|
---|
| 2058 | @property
|
---|
[97] | 2059 | def arrivalRunway(self):
|
---|
| 2060 | """Get the arrival runway."""
|
---|
| 2061 | return self._landingPage.runway
|
---|
| 2062 |
|
---|
| 2063 | @property
|
---|
| 2064 | def star(self):
|
---|
| 2065 | """Get the STAR."""
|
---|
| 2066 | return self._landingPage.star
|
---|
| 2067 |
|
---|
| 2068 | @property
|
---|
| 2069 | def transition(self):
|
---|
| 2070 | """Get the transition."""
|
---|
| 2071 | return self._landingPage.transition
|
---|
| 2072 |
|
---|
| 2073 | @property
|
---|
| 2074 | def approachType(self):
|
---|
| 2075 | """Get the approach type."""
|
---|
| 2076 | return self._landingPage.approachType
|
---|
| 2077 |
|
---|
| 2078 | @property
|
---|
[86] | 2079 | def vref(self):
|
---|
| 2080 | """Get the Vref speed."""
|
---|
| 2081 | return self._landingPage.vref
|
---|
[84] | 2082 |
|
---|
[97] | 2083 | @property
|
---|
| 2084 | def flightType(self):
|
---|
| 2085 | """Get the flight type."""
|
---|
| 2086 | return self._finishPage.flightType
|
---|
| 2087 |
|
---|
| 2088 | @property
|
---|
| 2089 | def online(self):
|
---|
| 2090 | """Get whether the flight was online or not."""
|
---|
| 2091 | return self._finishPage.online
|
---|
| 2092 |
|
---|
[70] | 2093 | def nextPage(self, finalize = True):
|
---|
[42] | 2094 | """Go to the next page."""
|
---|
[70] | 2095 | self.jumpPage(1, finalize)
|
---|
[51] | 2096 |
|
---|
[70] | 2097 | def jumpPage(self, count, finalize = True):
|
---|
[51] | 2098 | """Go to the page which is 'count' pages after the current one."""
|
---|
[70] | 2099 | self.setCurrentPage(self._currentPage + count, finalize = finalize)
|
---|
[46] | 2100 |
|
---|
| 2101 | def grabDefault(self):
|
---|
| 2102 | """Make the default button of the current page the default."""
|
---|
| 2103 | self._pages[self._currentPage].grabDefault()
|
---|
[51] | 2104 |
|
---|
[59] | 2105 | def connected(self, fsType, descriptor):
|
---|
| 2106 | """Called when the connection could be made to the simulator."""
|
---|
| 2107 | self.nextPage()
|
---|
| 2108 |
|
---|
[91] | 2109 | def reset(self):
|
---|
| 2110 | """Resets the wizard to go back to the login page."""
|
---|
[59] | 2111 | self._initialize()
|
---|
| 2112 |
|
---|
[84] | 2113 | def setStage(self, stage):
|
---|
| 2114 | """Set the flight stage to the given one."""
|
---|
| 2115 | if stage==const.STAGE_TAKEOFF:
|
---|
[101] | 2116 | self._takeoffPage.allowForward()
|
---|
[88] | 2117 | elif stage==const.STAGE_END:
|
---|
| 2118 | self._landingPage.flightEnded()
|
---|
[84] | 2119 |
|
---|
[59] | 2120 | def _initialize(self):
|
---|
| 2121 | """Initialize the wizard."""
|
---|
| 2122 | self._fleet = None
|
---|
| 2123 | self._fleetCallback = None
|
---|
| 2124 | self._updatePlaneCallback = None
|
---|
| 2125 |
|
---|
| 2126 | self._loginResult = None
|
---|
| 2127 | self._bookedFlight = None
|
---|
| 2128 | self._departureGate = "-"
|
---|
[64] | 2129 | self._departureNOTAMs = None
|
---|
[67] | 2130 | self._departureMETAR = None
|
---|
[64] | 2131 | self._arrivalNOTAMs = None
|
---|
[67] | 2132 | self._arrivalMETAR = None
|
---|
| 2133 |
|
---|
| 2134 | for page in self._pages:
|
---|
| 2135 | page.reset()
|
---|
[62] | 2136 |
|
---|
[59] | 2137 | self.setCurrentPage(0)
|
---|
| 2138 |
|
---|
[51] | 2139 | def _getFleet(self, callback, force = False):
|
---|
| 2140 | """Get the fleet, if needed.
|
---|
| 2141 |
|
---|
| 2142 | callback is function that will be called, when the feet is retrieved,
|
---|
| 2143 | or the retrieval fails. It should have a single argument that will
|
---|
| 2144 | receive the fleet object on success, None otherwise.
|
---|
| 2145 | """
|
---|
| 2146 | if self._fleet is not None and not force:
|
---|
| 2147 | callback(self._fleet)
|
---|
| 2148 |
|
---|
| 2149 | self.gui.beginBusy("Retrieving fleet...")
|
---|
| 2150 | self._fleetCallback = callback
|
---|
| 2151 | self.gui.webHandler.getFleet(self._fleetResultCallback)
|
---|
| 2152 |
|
---|
| 2153 | def _fleetResultCallback(self, returned, result):
|
---|
| 2154 | """Called when the fleet has been queried."""
|
---|
| 2155 | gobject.idle_add(self._handleFleetResult, returned, result)
|
---|
| 2156 |
|
---|
| 2157 | def _handleFleetResult(self, returned, result):
|
---|
| 2158 | """Handle the fleet result."""
|
---|
| 2159 | self.gui.endBusy()
|
---|
| 2160 | if returned:
|
---|
| 2161 | self._fleet = result.fleet
|
---|
| 2162 | else:
|
---|
| 2163 | self._fleet = None
|
---|
| 2164 |
|
---|
| 2165 | dialog = gtk.MessageDialog(type = MESSAGETYPE_ERROR,
|
---|
| 2166 | buttons = BUTTONSTYPE_OK,
|
---|
| 2167 | message_format =
|
---|
| 2168 | "Failed to retrieve the information on "
|
---|
| 2169 | "the fleet.")
|
---|
| 2170 | dialog.run()
|
---|
| 2171 | dialog.hide()
|
---|
| 2172 |
|
---|
| 2173 | self._fleetCallback(self._fleet)
|
---|
| 2174 |
|
---|
| 2175 | def _updatePlane(self, callback, tailNumber, status, gateNumber = None):
|
---|
| 2176 | """Update the given plane's gate information."""
|
---|
| 2177 | self.gui.beginBusy("Updating plane status...")
|
---|
| 2178 | self._updatePlaneCallback = callback
|
---|
| 2179 | self.gui.webHandler.updatePlane(self._updatePlaneResultCallback,
|
---|
| 2180 | tailNumber, status, gateNumber)
|
---|
| 2181 |
|
---|
| 2182 | def _updatePlaneResultCallback(self, returned, result):
|
---|
| 2183 | """Callback for the plane updating operation."""
|
---|
| 2184 | gobject.idle_add(self._handleUpdatePlaneResult, returned, result)
|
---|
| 2185 |
|
---|
| 2186 | def _handleUpdatePlaneResult(self, returned, result):
|
---|
| 2187 | """Handle the result of a plane update operation."""
|
---|
| 2188 | self.gui.endBusy()
|
---|
| 2189 | if returned:
|
---|
| 2190 | success = result.success
|
---|
| 2191 | else:
|
---|
| 2192 | success = None
|
---|
| 2193 |
|
---|
| 2194 | dialog = gtk.MessageDialog(type = MESSAGETYPE_ERROR,
|
---|
| 2195 | buttons = BUTTONSTYPE_OK,
|
---|
| 2196 | message_format =
|
---|
| 2197 | "Failed to update the statuis of "
|
---|
| 2198 | "the airplane.")
|
---|
| 2199 | dialog.run()
|
---|
| 2200 | dialog.hide()
|
---|
| 2201 |
|
---|
| 2202 | self._updatePlaneCallback(success)
|
---|
| 2203 |
|
---|
| 2204 | def _connectSimulator(self):
|
---|
| 2205 | """Connect to the simulator."""
|
---|
[59] | 2206 | self.gui.connectSimulator(self._bookedFlight.aircraftType)
|
---|
[42] | 2207 |
|
---|
| 2208 | #-----------------------------------------------------------------------------
|
---|
| 2209 |
|
---|