Changeset 564:695cde9818ea


Ignore:
Timestamp:
02/22/14 09:50:09 (10 years ago)
Author:
István Váradi <ivaradi@…>
Branch:
default
Phase:
public
Message:

The flight type is also considered when checking the arrival and departure times (re #227)

Files:
4 edited

Legend:

Unmodified
Added
Removed
  • locale/en/mlx.po

    r563 r564  
    939939"Please, provide a comment or a delay code to proceed.</span>"
    940940
     941msgid "finish_help_goodtime"
     942msgstr ""
     943"<span>\n\n\n</span>"
     944
    941945msgid "finish_rating"
    942946msgstr "Flight rating:"
  • locale/hu/mlx.po

    r563 r564  
    940940"Kérlek, írj megjegyzést vagy adj meg késési kódot a PIREP elküldése előtt.</span>"
    941941
     942msgid "finish_help_goodtime"
     943msgstr ""
     944"<span>\n\n\n</span>"
     945
    942946msgid "finish_rating"
    943947msgstr "Pontszám:"
  • src/mlx/flight.py

    r430 r564  
    55import const
    66import util
     7import time
    78
    89import threading
     
    2425    It is also the hub for the other main objects participating in the handling of
    2526    the flight."""
     27
     28    # The difference in minutes from the schedule which is considered a bit big
     29    TIME_WARNING_DIFFERENCE = 5
     30
     31    # The difference in minutes from the schedule which is considered too big
     32    TIME_ERROR_DIFFERENCE = 15
     33
    2634    @staticmethod
    2735    def canLogCruiseAltitude(stage):
     
    3038        return stage in [const.STAGE_CRUISE, const.STAGE_DESCENT,
    3139                         const.STAGE_LANDING]
     40
     41    @staticmethod
     42    def isTimeDifferenceTooMuch(scheduledTime, realTimestamp):
     43        """Determine if the given real time differs to much from the scheduled
     44        time.
     45
     46        Returns a tuple of:
     47        - a boolean indicating if the difference is enough to warrant at least
     48          a warning
     49        - a boolean indicating if the difference is too big, i. e. unacceptable
     50          without explanation."""
     51        realTime = time.gmtime(realTimestamp)
     52
     53        scheduledMinute = scheduledTime.hour * 60 + scheduledTime.minute
     54        realMinute = realTime.tm_hour * 60 + realTime.tm_min
     55
     56        diff1 = scheduledMinute - realMinute
     57        diff2 = -1 * diff1
     58
     59        if diff1 < 0: diff1 += 60*24
     60        else: diff2 += 60*24
     61
     62        diff = min(diff1, diff2)
     63
     64        return (diff>Flight.TIME_WARNING_DIFFERENCE,
     65                diff>Flight.TIME_ERROR_DIFFERENCE)
    3266
    3367    def __init__(self, logger, gui):
     
    283317        """Get the RTO state."""
    284318        return self._rtoState
     319
     320    @property
     321    def blockTimeStartWrong(self):
     322        """Determine if the block time start is wrong compared to the scheduled
     323        departure time.
     324
     325        Returns a tuple of:
     326        - a boolean indicating if the difference warrants a warning
     327        - a boolean indicating if the difference warrants not only a warning,
     328          but an error as well."""
     329        return self.isTimeDifferenceTooMuch(self.bookedFlight.departureTime,
     330                                            self.blockTimeStart)
     331
     332    @property
     333    def blockTimeEndWrong(self):
     334        """Determine if the block time end is wrong compared to the scheduled
     335        arrival time.
     336
     337        Returns a tuple of:
     338        - a boolean indicating if the difference warrants a warning
     339        - a boolean indicating if the difference warrants not only a warning,
     340          but an error as well."""
     341        return self.isTimeDifferenceTooMuch(self.bookedFlight.arrivalTime,
     342                                            self.blockTimeEnd)
    285343
    286344    def handleState(self, oldState, currentState):
  • src/mlx/gui/flight.py

    r563 r564  
    28152815    def __init__(self, wizard):
    28162816        """Construct the finish page."""
    2817         help = xstr("finish_help") + xstr("finish_help_wrongtime")
     2817        help = xstr("finish_help") + xstr("finish_help_goodtime")
    28182818        super(FinishPage, self).__init__(wizard, xstr("finish_title"), help)
    28192819
     
    30493049            self._flightRating.set_markup("<b>%.1f %%</b>" % (rating,))
    30503050
    3051         bookedFlight = self._wizard.bookedFlight
    3052 
    3053         (markup, tooBigDeparture) = \
    3054             self._formatTime(bookedFlight.departureTime, flight.blockTimeStart)
    3055 
    3056         self._depTime.set_markup(markup)
    3057 
    30583051        flightLength = flight.flightTimeEnd - flight.flightTimeStart
    30593052        self._flightTime.set_markup("<b>%s</b>" % \
     
    30633056        self._blockTime.set_markup("<b>%s</b>" % \
    30643057                                   (util.getTimeIntervalString(blockLength),))
    3065 
    3066         (markup, tooBigArrival) = \
    3067             self._formatTime(bookedFlight.arrivalTime, flight.blockTimeEnd)
    3068 
    3069         self._tooBigTimeDifference = tooBigDeparture or tooBigArrival
    3070 
    3071         if self._tooBigTimeDifference:
    3072             self.setHelp(xstr("finish_help") + xstr("finish_help_wrongtime"))
    3073         else:
    3074             self.setHelp(xstr("finish_help"))
    3075 
    3076         self._arrTime.set_markup(markup)
    30773058
    30783059        self._distanceFlown.set_markup("<b>%.2f NM</b>" % \
     
    31013082            self._gate.set_sensitive(False)
    31023083
    3103         self.updateButtons()
     3084        self._updateTimes()
    31043085
    31053086    def updateButtons(self):
     
    31473128    def _flightTypeChanged(self, comboBox):
    31483129        """Called when the flight type has changed."""
    3149         self.updateButtons()
     3130        self._updateTimes()
    31503131
    31513132    def _gateChanged(self, comboBox):
     
    33103291        pass
    33113292
    3312     def _formatTime(self, scheduledTime, realTimestamp):
     3293    def _formatTime(self, scheduledTime, realTimestamp, (warning, error)):
    33133294        """Format the departure or arrival time based on the given data as a
    3314         markup for a label.
    3315 
    3316         If the difference is greater than 15 minutes, the text should be
    3317         red. Otherwise, if the difference is greater that 5 minutes, the text
    3318         should be yellow. Otherwise it should be black.
    3319 
    3320         scheduledTime is the scheduled time as a datetime object
    3321         realTimestamp is the real time as a timestamp (i.e. seconds
    3322         since the epoch)
    3323 
    3324         Returns a tuple consisting of:
    3325         - the markup,
    3326         - a boolean indicating if the difference is greater than 15 minutes."""
     3295        markup for a label."""
    33273296        realTime = time.gmtime(realTimestamp)
    33283297
    3329         scheduledMinute = scheduledTime.hour * 60 + scheduledTime.minute
    3330         realMinute = realTime.tm_hour * 60 + realTime.tm_min
    3331 
    3332         diff1 = scheduledMinute - realMinute
    3333         diff2 = -1 * diff1
    3334 
    3335         if diff1 < 0: diff1 += 60*24
    3336         else: diff2 += 60*24
    3337 
    3338         diff = min(diff1, diff2)
    3339 
    3340         if diff>5:
    3341             colour = "red" if diff>15 else "orange"
     3298        if warning:
     3299            colour = "red" if error else "orange"
    33423300            markupBegin = '<span foreground="%s">' % (colour,)
    33433301            markupEnd = '</span>'
     
    33513309                  markupEnd)
    33523310
    3353         # print "mlx.gui.flight.FinishPage._formatTime: markup='%s', diff=%d" % \
    3354         #       (markup, diff)
    3355 
    3356         return (markup, diff>15)
     3311        return markup
     3312
     3313    def _updateTimes(self):
     3314        """Format the flight times and the help text according to the flight
     3315        type.
     3316
     3317        The buttons are also updated.
     3318        """
     3319        flight = self._wizard.gui._flight
     3320        bookedFlight = flight.bookedFlight
     3321
     3322        (departureWarning, departureError) = flight.blockTimeStartWrong
     3323        (arrivalWarning, arrivalError) = flight.blockTimeEndWrong
     3324
     3325        if self.flightType==const.FLIGHTTYPE_VIP:
     3326            departureError = arrivalError = False
     3327
     3328        self._tooBigTimeDifference = departureError or arrivalError
     3329
     3330        if self._tooBigTimeDifference and self.flightType is not None:
     3331            self.setHelp(xstr("finish_help") + xstr("finish_help_wrongtime"))
     3332        else:
     3333            self.setHelp(xstr("finish_help") + xstr("finish_help_goodtime"))
     3334
     3335        self._depTime.set_markup(self._formatTime(bookedFlight.departureTime,
     3336                                                  flight.blockTimeStart,
     3337                                                  (departureWarning,
     3338                                                   departureError)))
     3339
     3340        self._arrTime.set_markup(self._formatTime(bookedFlight.arrivalTime,
     3341                                                  flight.blockTimeEnd,
     3342                                                  (arrivalWarning,
     3343                                                   arrivalError)))
     3344
     3345        self.updateButtons()
    33573346
    33583347#-----------------------------------------------------------------------------
Note: See TracChangeset for help on using the changeset viewer.