Ignore:
Timestamp:
04/21/12 14:49:45 (12 years ago)
Author:
István Váradi <ivaradi@…>
Branch:
default
Phase:
public
Message:

The PIREP can be created and sent.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/mlx/gui/flight.py

    r96 r97  
    77from mlx.checks import PayloadChecker
    88import mlx.util as util
     9from mlx.pirep import PIREP
    910
    1011import datetime
     
    777778        self._button.connect("clicked", self._forwardClicked)
    778779
     780    @property
     781    def cargoWeight(self):
     782        """Get the cargo weight entered."""
     783        return self._cargoWeight.get_int()
     784
    779785    def activate(self):
    780786        """Setup the information."""
     
    9961002        self._cruiseLevel.set_numeric(True)
    9971003        self._cruiseLevel.connect("value-changed", self._cruiseLevelChanged)
    998         label.set_mnemonic_widget(self._cruiseLevel)       
     1004        label.set_mnemonic_widget(self._cruiseLevel)
     1005        self._filedCruiseLevel = 240
    9991006
    10001007        levelBox.pack_start(self._cruiseLevel, False, False, 8)
     
    10441051
    10451052    @property
     1053    def filedCruiseLevel(self):
     1054        """Get the filed cruise level."""
     1055        return self._filedCruiseLevel
     1056
     1057    @property
    10461058    def cruiseLevel(self):
    10471059        """Get the cruise level."""
    10481060        return self._cruiseLevel.get_value_as_int()
    10491061
     1062    @property
     1063    def route(self):
     1064        """Get the route."""
     1065        return self._getRoute()
     1066
    10501067    def activate(self):
    10511068        """Setup the route from the booked flight."""
    10521069        self._cruiseLevel.set_value(240)
     1070        self._filedCruiseLevel = 240
    10531071        self._route.get_buffer().set_text(self._wizard._bookedFlight.route)
    10541072        self._updateForwardButton()
     
    10831101        else:
    10841102            bookedFlight = self._wizard._bookedFlight
     1103            self._filedCruiseLevel = self.cruiseLevel
    10851104            self._wizard.gui.beginBusy("Downloading NOTAMs...")
    10861105            self._wizard.gui.webHandler.getNOTAMs(self._notamsCallback,
     
    12041223        self._button.connect("clicked", self._forwardClicked)
    12051224
     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
    12061232    def activate(self):
    12071233        """Activate the page."""
     
    13571383
    13581384    @property
     1385    def runway(self):
     1386        """Get the runway."""
     1387        return self._runway.get_text()
     1388
     1389    @property
     1390    def sid(self):
     1391        """Get the SID."""
     1392        return self._sid.get_text()
     1393
     1394    @property
    13591395    def v1(self):
    13601396        """Get the v1 speed."""
     
    15141550
    15151551    @property
     1552    def star(self):
     1553        """Get the STAR or None if none entered."""
     1554        return self._star.get_text() if self._starButton.get_active() else None
     1555
     1556    @property
     1557    def transition(self):
     1558        """Get the transition or None if none entered."""
     1559        return self._transition.get_text() \
     1560               if self._transitionButton.get_active() else None
     1561
     1562    @property
     1563    def approachType(self):
     1564        """Get the approach type."""
     1565        return self._approachType.get_text()
     1566
     1567    @property
     1568    def runway(self):
     1569        """Get the runway."""
     1570        return self._runway.get_text()
     1571
     1572    @property
    15161573    def vref(self):
    15171574        """Return the landing reference speed."""
     
    16081665class FinishPage(Page):
    16091666    """Flight finish page."""
     1667    _flightTypes = [ ("scheduled", const.FLIGHTTYPE_SCHEDULED),
     1668                     ("old-timer", const.FLIGHTTYPE_OLDTIMER),
     1669                     ("VIP", const.FLIGHTTYPE_VIP),
     1670                     ("charter", const.FLIGHTTYPE_CHARTER) ]
     1671   
    16101672    def __init__(self, wizard):
    16111673        """Construct the finish page."""
     
    16981760
    16991761        flightTypeModel = gtk.ListStore(str, int)
    1700         index = 1
    1701         for type in ["scheduled", "old-timer", "VIP", "charter"]:
    1702             flightTypeModel.append([type, index])
    1703             index += 1
     1762        for (name, type) in FinishPage._flightTypes:
     1763            flightTypeModel.append([name, type])
    17041764
    17051765        self._flightType = gtk.ComboBox(model = flightTypeModel)
     
    17341794        self._sendButton.set_use_underline(True)
    17351795        self._sendButton.set_sensitive(False)
    1736         #self._sendButton.connect("clicked", self._sendClicked)
     1796        self._sendButton.connect("clicked", self._sendClicked)
     1797       
     1798    @property
     1799    def flightType(self):
     1800        """Get the flight type."""
     1801        index = self._flightType.get_active()
     1802        return None if index<0 else self._flightType.get_model()[index][1]
     1803
     1804    @property
     1805    def online(self):
     1806        """Get whether the flight was an online flight or not."""
     1807        return self._onlineFlight.get_active()
    17371808
    17381809    def activate(self):
     
    17701841        index = self._flightType.get_active()
    17711842        flightTypeIsValid = index>=0
    1772         self._saveButton.set_sensitive(flightTypeIsValid)
     1843        #self._saveButton.set_sensitive(flightTypeIsValid)
    17731844        self._sendButton.set_sensitive(flightTypeIsValid)
     1845
     1846    def _sendClicked(self, button):
     1847        """Called when the Send button is clicked."""
     1848        pirep = PIREP(self._wizard.gui)
     1849        gui = self._wizard.gui
     1850        gui.beginBusy("Sending PIREP...")
     1851        gui.webHandler.sendPIREP(self._pirepSentCallback, pirep)
     1852
     1853    def _pirepSentCallback(self, returned, result):
     1854        """Callback for the PIREP sending result."""
     1855        gobject.idle_add(self._handlePIREPSent, returned, result)
     1856
     1857    def _handlePIREPSent(self, returned, result):
     1858        """Callback for the PIREP sending result."""
     1859        self._wizard.gui.endBusy()
     1860        secondaryMarkup = None
     1861        type = MESSAGETYPE_ERROR
     1862        if returned:
     1863            if result.success:
     1864                type = MESSAGETYPE_INFO
     1865                messageFormat = "The PIREP was sent successfully."
     1866                secondaryMarkup = "Await the thorough scrutiny from our PIREP correctors! :)"
     1867            elif result.alreadyFlown:
     1868                messageFormat = "The PIREP for this flight has already been sent!"
     1869                secondaryMarkup = "You may clear the old PIREP on the MAVA website."
     1870            elif result.notAvailable:
     1871                messageFormat = "This flight is not available anymore!"
     1872            else:
     1873                messageFormat = "The MAVA website returned with an unknown error."
     1874                secondaryMarkup = "See the debug log for more information."
     1875        else:
     1876            print "PIREP sending failed", result
     1877            messageFormat = "Could not send the PIREP to the MAVA website."
     1878            secondaryMarkup = "This can be a network problem, in which case\n" \
     1879                              "you may try again later. Or it can be a bug;\n" \
     1880                              "see the debug log for more information."
     1881       
     1882        dialog = gtk.MessageDialog(type = type, buttons = BUTTONSTYPE_OK,
     1883                                   message_format = messageFormat)
     1884        if secondaryMarkup is not None:
     1885            dialog.format_secondary_markup(secondaryMarkup)
     1886
     1887        dialog.run()
     1888        dialog.hide()
    17741889       
    17751890#-----------------------------------------------------------------------------
     
    17951910        self._routePage = RoutePage(self)
    17961911        self._pages.append(self._routePage)
    1797         self._pages.append(BriefingPage(self, True))
    1798         self._pages.append(BriefingPage(self, False))
     1912        self._departureBriefingPage = BriefingPage(self, True)
     1913        self._pages.append(self._departureBriefingPage)
     1914        self._arrivalBriefingPage = BriefingPage(self, False)
     1915        self._pages.append(self._arrivalBriefingPage)
    17991916        self._takeoffPage = TakeoffPage(self)
    18001917        self._pages.append(self._takeoffPage)
    18011918        self._landingPage = LandingPage(self)
    18021919        self._pages.append(self._landingPage)
    1803         self._pages.append(FinishPage(self))
     1920        self._finishPage = FinishPage(self)
     1921        self._pages.append(self._finishPage)
    18041922       
    18051923        maxWidth = 0
     
    18451963
    18461964    @property
     1965    def bookedFlight(self):
     1966        """Get the booked flight selected."""
     1967        return self._bookedFlight
     1968
     1969    @property
     1970    def cargoWeight(self):
     1971        """Get the calculated ZFW value."""
     1972        return self._payloadPage.cargoWeight
     1973
     1974    @property
    18471975    def zfw(self):
    18481976        """Get the calculated ZFW value."""
     
    18511979
    18521980    @property
     1981    def filedCruiseAltitude(self):
     1982        """Get the filed cruise altitude."""
     1983        return self._routePage.filedCruiseLevel * 100
     1984
     1985    @property
    18531986    def cruiseAltitude(self):
    18541987        """Get the cruise altitude."""
     
    18561989
    18571990    @property
     1991    def route(self):
     1992        """Get the route."""
     1993        return self._routePage.route
     1994
     1995    @property
     1996    def departureMETAR(self):
     1997        """Get the METAR of the departure airport."""
     1998        return self._departureBriefingPage.metar
     1999
     2000    @property
     2001    def arrivalMETAR(self):
     2002        """Get the METAR of the arrival airport."""
     2003        return self._arrivalBriefingPage.metar
     2004
     2005    @property
     2006    def departureRunway(self):
     2007        """Get the departure runway."""
     2008        return self._takeoffPage.runway
     2009
     2010    @property
     2011    def sid(self):
     2012        """Get the SID."""
     2013        return self._takeoffPage.sid
     2014
     2015    @property
    18582016    def v1(self):
    18592017        """Get the V1 speed."""
     
    18712029
    18722030    @property
     2031    def arrivalRunway(self):
     2032        """Get the arrival runway."""
     2033        return self._landingPage.runway
     2034
     2035    @property
     2036    def star(self):
     2037        """Get the STAR."""
     2038        return self._landingPage.star
     2039
     2040    @property
     2041    def transition(self):
     2042        """Get the transition."""
     2043        return self._landingPage.transition
     2044
     2045    @property
     2046    def approachType(self):
     2047        """Get the approach type."""
     2048        return self._landingPage.approachType
     2049
     2050    @property
    18732051    def vref(self):
    18742052        """Get the Vref speed."""
    18752053        return self._landingPage.vref
     2054
     2055    @property
     2056    def flightType(self):
     2057        """Get the flight type."""
     2058        return self._finishPage.flightType
     2059
     2060    @property
     2061    def online(self):
     2062        """Get whether the flight was online or not."""
     2063        return self._finishPage.online
    18762064
    18772065    def nextPage(self, finalize = True):
Note: See TracChangeset for help on using the changeset viewer.