Changeset 383:fcb9932b14ee for src/mlx
- Timestamp:
- 12/21/12 15:44:59 (12 years ago)
- Branch:
- default
- Phase:
- public
- Location:
- src/mlx
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
src/mlx/flight.py
r365 r383 24 24 It is also the hub for the other main objects participating in the handling of 25 25 the flight.""" 26 @staticmethod 27 def canLogCruiseAltitude(stage): 28 """Determine if the cruise altitude can be logged in the given 29 stage.""" 30 return stage in [const.STAGE_CRUISE, const.STAGE_DESCENT, 31 const.STAGE_LANDING] 32 26 33 def __init__(self, logger, gui): 27 34 """Construct the flight.""" … … 414 421 def cruiseLevelChanged(self): 415 422 """Called when the cruise level hass changed.""" 416 if self._stage in [const.STAGE_CRUISE, const.STAGE_DESCENT, 417 const.STAGE_LANDING]: 423 if self.canLogCruiseAltitude(self._stage): 418 424 message = "Cruise altitude modified to %d feet" % \ 419 (self. cruiseAltitude,)425 (self._gui.loggableCruiseAltitude,) 420 426 self.logger.message(self.aircraft.timestamp, message) 427 return True 428 else: 429 return False 421 430 422 431 def _updateFlownDistance(self, currentState): -
src/mlx/gui/flight.py
r349 r383 5 5 import mlx.fs as fs 6 6 import mlx.acft as acft 7 from mlx.flight import Flight 7 8 from mlx.checks import PayloadChecker 8 9 import mlx.util as util … … 1655 1656 self._cruiseLevel.connect("value-changed", self._cruiseLevelChanged) 1656 1657 label.set_mnemonic_widget(self._cruiseLevel) 1657 self._filedCruiseLevel = 2401658 1658 1659 1659 levelBox.pack_start(self._cruiseLevel, False, False, 8) … … 1706 1706 def filedCruiseLevel(self): 1707 1707 """Get the filed cruise level.""" 1708 return self._filedCruiseLevel1709 1710 @property1711 def cruiseLevel(self):1712 """Get the cruise level."""1713 1708 return self._cruiseLevel.get_value_as_int() 1714 1709 … … 1721 1716 """Setup the route from the booked flight.""" 1722 1717 self._cruiseLevel.set_value(240) 1723 self._filedCruiseLevel = 2401724 1718 self._route.get_buffer().set_text(self._wizard._bookedFlight.route) 1725 1719 self._updateForwardButton() … … 1739 1733 """Called when the cruise level has changed.""" 1740 1734 self._updateForwardButton() 1741 self._wizard.cruiseLevelChanged()1742 1735 1743 1736 def _routeChanged(self, textBuffer): … … 1771 1764 else: 1772 1765 bookedFlight = self._wizard._bookedFlight 1773 self._filedCruiseLevel = self.cruiseLevel1774 1766 self._wizard.gui.beginBusy(xstr("route_down_notams")) 1775 1767 self._wizard.gui.webHandler.getNOTAMs(self._notamsCallback, … … 2212 2204 #----------------------------------------------------------------------------- 2213 2205 2206 class CruisePage(Page): 2207 """The page containing the flight level that might change during flight.""" 2208 def __init__(self, wizard): 2209 """Construct the page.""" 2210 super(CruisePage, self).__init__(wizard, xstr("cruise_title"), 2211 xstr("cruise_help")) 2212 2213 self._loggable = False 2214 self._loggedCruiseLevel = 240 2215 self._activated = False 2216 2217 alignment = gtk.Alignment(xalign = 0.5, yalign = 0.0, 2218 xscale = 0.0, yscale = 1.0) 2219 2220 mainBox = gtk.VBox() 2221 alignment.add(mainBox) 2222 self.setMainWidget(alignment) 2223 2224 alignment = gtk.Alignment(xalign = 0.0, yalign = 0.0, 2225 xscale = 0.0, yscale = 0.0) 2226 mainBox.pack_start(alignment, False, False, 16) 2227 2228 levelBox = gtk.HBox() 2229 2230 label = gtk.Label(xstr("route_level")) 2231 label.set_use_underline(True) 2232 levelBox.pack_start(label, True, True, 0) 2233 2234 self._cruiseLevel = gtk.SpinButton() 2235 self._cruiseLevel.set_increments(step = 10, page = 100) 2236 self._cruiseLevel.set_range(min = 50, max = 500) 2237 self._cruiseLevel.set_tooltip_text(xstr("cruise_route_level_tooltip")) 2238 self._cruiseLevel.set_numeric(True) 2239 self._cruiseLevel.connect("value-changed", self._cruiseLevelChanged) 2240 label.set_mnemonic_widget(self._cruiseLevel) 2241 2242 levelBox.pack_start(self._cruiseLevel, False, False, 8) 2243 2244 self._updateButton = gtk.Button(xstr("cruise_route_level_update")); 2245 self._updateButton.set_use_underline(True) 2246 self._updateButton.set_tooltip_text(xstr("cruise_route_level_update_tooltip")) 2247 self._updateButton.connect("clicked", self._updateButtonClicked) 2248 2249 levelBox.pack_start(self._updateButton, False, False, 16) 2250 2251 mainBox.pack_start(levelBox, False, False, 0) 2252 2253 alignment = gtk.Alignment(xalign = 0.0, yalign = 0.0, 2254 xscale = 0.0, yscale = 1.0) 2255 mainBox.pack_start(alignment, True, True, 0) 2256 2257 self.addCancelFlightButton() 2258 2259 self._backButton = self.addPreviousButton(clicked = self._backClicked) 2260 self._button = self.addNextButton(clicked = self._forwardClicked) 2261 2262 @property 2263 def activated(self): 2264 """Determine if the page is already activated or not.""" 2265 return self._activated 2266 2267 @property 2268 def cruiseLevel(self): 2269 """Get the cruise level.""" 2270 return self._loggedCruiseLevel 2271 2272 @property 2273 def loggableCruiseLevel(self): 2274 """Get the cruise level which should be logged.""" 2275 return self._cruiseLevel.get_value_as_int() 2276 2277 def setLoggable(self, loggable): 2278 """Set whether the cruise altitude can be logged.""" 2279 self._loggable = loggable 2280 self._updateButtons() 2281 2282 def activate(self): 2283 """Setup the route from the booked flight.""" 2284 self._loggedCruiseLevel = self._wizard.filedCruiseLevel 2285 self._cruiseLevel.set_value(self._loggedCruiseLevel) 2286 self._activated = True 2287 2288 def reset(self): 2289 """Reset the page.""" 2290 self._loggable = False 2291 self._activated = False 2292 super(CruisePage, self).reset() 2293 2294 def _updateButtons(self): 2295 """Update the sensitivity of the buttons.""" 2296 self._updateButton.set_sensitive(self._loggable and 2297 self.loggableCruiseLevel!= 2298 self._loggedCruiseLevel) 2299 2300 def _cruiseLevelChanged(self, spinButton): 2301 """Called when the cruise level has changed.""" 2302 self._updateButtons() 2303 2304 def _updateButtonClicked(self, button): 2305 """Called when the update button is clicked.""" 2306 if self._wizard.cruiseLevelChanged(): 2307 self._loggedCruiseLevel = self.loggableCruiseLevel 2308 self._updateButtons() 2309 2310 def _backClicked(self, button): 2311 """Called when the Back button is pressed.""" 2312 self.goBack() 2313 2314 def _forwardClicked(self, button): 2315 """Called when the Forward button is clicked.""" 2316 self._wizard.nextPage() 2317 2318 #----------------------------------------------------------------------------- 2319 2214 2320 class LandingPage(Page): 2215 2321 """Page for entering landing data.""" … … 2848 2954 self._takeoffPage = TakeoffPage(self) 2849 2955 self._pages.append(self._takeoffPage) 2956 self._cruisePage = CruisePage(self) 2957 self._pages.append(self._cruisePage) 2850 2958 self._landingPage = LandingPage(self) 2851 2959 self._pages.append(self._landingPage) … … 2947 3055 2948 3056 @property 3057 def filedCruiseLevel(self): 3058 """Get the filed cruise level.""" 3059 return self._routePage.filedCruiseLevel 3060 3061 @property 2949 3062 def filedCruiseAltitude(self): 2950 3063 """Get the filed cruise altitude.""" … … 2954 3067 def cruiseAltitude(self): 2955 3068 """Get the cruise altitude.""" 2956 return self._routePage.cruiseLevel * 100 3069 level = self._cruisePage.cruiseLevel if self._cruisePage.activated \ 3070 else self._routePage.filedCruiseLevel 3071 return level * 100 3072 3073 @property 3074 def loggableCruiseAltitude(self): 3075 """Get the cruise altitude that can be logged.""" 3076 if self._cruisePage.activated: 3077 return self._cruisePage.loggableCruiseLevel * 100 3078 else: 3079 return 0 2957 3080 2958 3081 @property … … 3059 3182 def setStage(self, stage): 3060 3183 """Set the flight stage to the given one.""" 3184 if stage!=const.STAGE_END: 3185 self._cruisePage.setLoggable(Flight.canLogCruiseAltitude(stage)) 3186 3061 3187 if stage==const.STAGE_TAKEOFF: 3062 3188 self._takeoffPage.allowForward() … … 3121 3247 def cruiseLevelChanged(self): 3122 3248 """Called when the cruise level is changed.""" 3123 self.gui.cruiseLevelChanged()3249 return self.gui.cruiseLevelChanged() 3124 3250 3125 3251 def _loginResultCallback(self, returned, result): -
src/mlx/gui/gui.py
r349 r383 263 263 264 264 @property 265 def loggableCruiseAltitude(self): 266 """Get the cruise altitude that can be logged.""" 267 return self._wizard.loggableCruiseAltitude 268 269 @property 265 270 def route(self): 266 271 """Get the flight route.""" … … 890 895 """Called when the cruise level is changed in the flight wizard.""" 891 896 if self._flight is not None: 892 self._flight.cruiseLevelChanged() 897 return self._flight.cruiseLevelChanged() 898 else: 899 return False 893 900 894 901 def _buildMenuBar(self, accelGroup):
Note:
See TracChangeset
for help on using the changeset viewer.