Ignore:
Timestamp:
04/17/12 18:00:09 (13 years ago)
Author:
István Váradi <ivaradi@…>
Branch:
default
Phase:
public
Message:

Added the collection of some further statistics and the finish page

Location:
src/mlx/gui
Files:
2 edited

Legend:

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

    r88 r89  
    66import mlx.fs as fs
    77from mlx.checks import PayloadChecker
     8import mlx.util as util
    89
    910import datetime
     
    14771478    def activate(self):
    14781479        """Called when the page is activated."""
    1479         self._flightEnded = False
    1480        
    14811480        self._starButton.set_sensitive(True)
    14821481        self._starButton.set_active(False)
     
    15161515
    15171516        self._vref.set_sensitive(False)
     1517        # FIXME: Perhaps a separate initialize() call which would set up
     1518        # defaults?
     1519        self._flightEnded = False
    15181520
    15191521    def _starButtonClicked(self, button):
     
    15571559    def _forwardClicked(self, button):
    15581560        """Called when the forward button is clicked."""
    1559         #self._wizard.nextPage()
    1560         self.finalize()
     1561        self._wizard.nextPage()
     1562
     1563#-----------------------------------------------------------------------------
     1564
     1565class FinishPage(Page):
     1566    """Flight finish page."""
     1567    def __init__(self, wizard):
     1568        """Construct the finish page."""
     1569        help = "There are some statistics about your flight below.\n\n" \
     1570               "Review the data, also on earlier pages, and if you are\n" \
     1571               "satisfied, you can save or send your PIREP."
     1572
     1573        super(FinishPage, self).__init__(wizard, "Finish", help)
     1574       
     1575        alignment = gtk.Alignment(xalign = 0.5, yalign = 0.5,
     1576                                  xscale = 0.0, yscale = 0.0)
     1577
     1578        table = gtk.Table(5, 2)
     1579        table.set_row_spacings(4)
     1580        table.set_col_spacings(16)
     1581        table.set_homogeneous(True)
     1582        alignment.add(table)
     1583        self.setMainWidget(alignment)
     1584
     1585        labelAlignment = gtk.Alignment(xalign=1.0, xscale=0.0)
     1586        label = gtk.Label("Flight rating:")
     1587        labelAlignment.add(label)
     1588        table.attach(labelAlignment, 0, 1, 0, 1)
     1589
     1590        labelAlignment = gtk.Alignment(xalign=0.0, xscale=0.0)
     1591        self._flightRating = gtk.Label()
     1592        self._flightRating.set_width_chars(7)
     1593        self._flightRating.set_alignment(0.0, 0.5)
     1594        self._flightRating.set_use_markup(True)
     1595        labelAlignment.add(self._flightRating)
     1596        table.attach(labelAlignment, 1, 2, 0, 1)
     1597
     1598        labelAlignment = gtk.Alignment(xalign=1.0, xscale=0.0)
     1599        label = gtk.Label("Flight time:")
     1600        labelAlignment.add(label)
     1601        table.attach(labelAlignment, 0, 1, 1, 2)
     1602
     1603        labelAlignment = gtk.Alignment(xalign=0.0, xscale=0.0)
     1604        self._flightTime = gtk.Label()
     1605        self._flightTime.set_width_chars(10)
     1606        self._flightTime.set_alignment(0.0, 0.5)
     1607        self._flightTime.set_use_markup(True)
     1608        labelAlignment.add(self._flightTime)
     1609        table.attach(labelAlignment, 1, 2, 1, 2)
     1610
     1611        labelAlignment = gtk.Alignment(xalign=1.0, xscale=0.0)
     1612        label = gtk.Label("Block time:")
     1613        labelAlignment.add(label)
     1614        table.attach(labelAlignment, 0, 1, 2, 3)
     1615
     1616        labelAlignment = gtk.Alignment(xalign=0.0, xscale=0.0)
     1617        self._blockTime = gtk.Label()
     1618        self._blockTime.set_width_chars(10)
     1619        self._blockTime.set_alignment(0.0, 0.5)
     1620        self._blockTime.set_use_markup(True)
     1621        labelAlignment.add(self._blockTime)
     1622        table.attach(labelAlignment, 1, 2, 2, 3)
     1623
     1624        labelAlignment = gtk.Alignment(xalign=1.0, xscale=0.0)
     1625        label = gtk.Label("Distance flown:")
     1626        labelAlignment.add(label)
     1627        table.attach(labelAlignment, 0, 1, 3, 4)
     1628
     1629        labelAlignment = gtk.Alignment(xalign=0.0, xscale=0.0)
     1630        self._distanceFlown = gtk.Label()
     1631        self._distanceFlown.set_width_chars(10)
     1632        self._distanceFlown.set_alignment(0.0, 0.5)
     1633        self._distanceFlown.set_use_markup(True)
     1634        labelAlignment.add(self._distanceFlown)
     1635        table.attach(labelAlignment, 1, 2, 3, 4)
     1636       
     1637        labelAlignment = gtk.Alignment(xalign=1.0, xscale=0.0)
     1638        label = gtk.Label("Fuel used:")
     1639        labelAlignment.add(label)
     1640        table.attach(labelAlignment, 0, 1, 4, 5)
     1641
     1642        labelAlignment = gtk.Alignment(xalign=0.0, xscale=0.0)
     1643        self._fuelUsed = gtk.Label()
     1644        self._fuelUsed.set_width_chars(10)
     1645        self._fuelUsed.set_alignment(0.0, 0.5)
     1646        self._fuelUsed.set_use_markup(True)
     1647        labelAlignment.add(self._fuelUsed)
     1648        table.attach(labelAlignment, 1, 2, 4, 5)
     1649
     1650        self._saveButton = self.addButton("S_ave PIREP...")
     1651        self._saveButton.set_use_underline(True)
     1652        #self._saveButton.connect("clicked", self._saveClicked)
     1653       
     1654        self._sendButton = self.addButton("_Send PIREP...", True)
     1655        self._sendButton.set_use_underline(True)
     1656        #self._sendButton.connect("clicked", self._sendClicked)
     1657
     1658    def activate(self):
     1659        """Activate the page."""
     1660        flight = self._wizard.gui._flight
     1661        rating = flight.logger.getRating()
     1662        if rating<0:
     1663            self._flightRating.set_markup('<b><span foreground="red">NO GO</span></b>')
     1664        else:
     1665            self._flightRating.set_markup("<b>%.1f %%</b>" % (rating,))
     1666
     1667        flightLength = flight.flightTimeEnd - flight.flightTimeStart
     1668        self._flightTime.set_markup("<b>%s</b>" % \
     1669                                    (util.getTimeIntervalString(flightLength),))
     1670       
     1671        blockLength = flight.blockTimeEnd - flight.blockTimeStart
     1672        self._blockTime.set_markup("<b>%s</b>" % \
     1673                                   (util.getTimeIntervalString(blockLength),))
     1674
     1675        self._distanceFlown.set_markup("<b>%.2f NM</b>" % \
     1676                                       (flight.flownDistance,))
     1677       
     1678        self._fuelUsed.set_markup("<b>%.0f kg</b>" % \
     1679                                  (flight.endFuel - flight.startFuel,))
    15611680
    15621681#-----------------------------------------------------------------------------
     
    15881707        self._landingPage = LandingPage(self)
    15891708        self._pages.append(self._landingPage)
     1709        self._pages.append(FinishPage(self))
    15901710       
    15911711        maxWidth = 0
  • src/mlx/gui/monitor.py

    r77 r89  
    44
    55import mlx.const as const
     6import mlx.util as util
    67
    78import time
     
    170171        table.attach(label, 4, 5, 6, 7)
    171172        table.attach(self._windDirection, 5, 6, 6, 7)
     173
     174        (label, self._position) = self._createLabeledEntry("Position:", 25)
     175        table.attach(label, 6, 7, 6, 7)
     176        table.attach(self._position, 7, 10, 6, 7)
    172177
    173178        alignment.add(table)
     
    240245            self._windSpeed.set_text("-")
    241246            self._windDirection.set_text("-")
     247            self._position.set_text("-")
    242248        else:
    243249            self._timestamp.set_text(time.strftime("%H:%M:%S",
     
    304310            self._windSpeed.set_text("%.0f" % (aircraftState.windSpeed,))
    305311            self._windDirection.set_text("%03.0f" % (aircraftState.windDirection,))
     312            self._position.set_text(util.getCoordinateString((aircraftState.latitude,
     313                                                              aircraftState.longitude)))
    306314
    307315#------------------------------------------------------------------------------
Note: See TracChangeset for help on using the changeset viewer.