Changeset 564:695cde9818ea
- Timestamp:
- 02/22/14 09:50:09 (11 years ago)
- Branch:
- default
- Phase:
- public
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
locale/en/mlx.po
r563 r564 939 939 "Please, provide a comment or a delay code to proceed.</span>" 940 940 941 msgid "finish_help_goodtime" 942 msgstr "" 943 "<span>\n\n\n</span>" 944 941 945 msgid "finish_rating" 942 946 msgstr "Flight rating:" -
locale/hu/mlx.po
r563 r564 940 940 "Kérlek, írj megjegyzést vagy adj meg késési kódot a PIREP elküldése előtt.</span>" 941 941 942 msgid "finish_help_goodtime" 943 msgstr "" 944 "<span>\n\n\n</span>" 945 942 946 msgid "finish_rating" 943 947 msgstr "Pontszám:" -
src/mlx/flight.py
r430 r564 5 5 import const 6 6 import util 7 import time 7 8 8 9 import threading … … 24 25 It is also the hub for the other main objects participating in the handling of 25 26 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 26 34 @staticmethod 27 35 def canLogCruiseAltitude(stage): … … 30 38 return stage in [const.STAGE_CRUISE, const.STAGE_DESCENT, 31 39 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) 32 66 33 67 def __init__(self, logger, gui): … … 283 317 """Get the RTO state.""" 284 318 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) 285 343 286 344 def handleState(self, oldState, currentState): -
src/mlx/gui/flight.py
r563 r564 2815 2815 def __init__(self, wizard): 2816 2816 """Construct the finish page.""" 2817 help = xstr("finish_help") + xstr("finish_help_ wrongtime")2817 help = xstr("finish_help") + xstr("finish_help_goodtime") 2818 2818 super(FinishPage, self).__init__(wizard, xstr("finish_title"), help) 2819 2819 … … 3049 3049 self._flightRating.set_markup("<b>%.1f %%</b>" % (rating,)) 3050 3050 3051 bookedFlight = self._wizard.bookedFlight3052 3053 (markup, tooBigDeparture) = \3054 self._formatTime(bookedFlight.departureTime, flight.blockTimeStart)3055 3056 self._depTime.set_markup(markup)3057 3058 3051 flightLength = flight.flightTimeEnd - flight.flightTimeStart 3059 3052 self._flightTime.set_markup("<b>%s</b>" % \ … … 3063 3056 self._blockTime.set_markup("<b>%s</b>" % \ 3064 3057 (util.getTimeIntervalString(blockLength),)) 3065 3066 (markup, tooBigArrival) = \3067 self._formatTime(bookedFlight.arrivalTime, flight.blockTimeEnd)3068 3069 self._tooBigTimeDifference = tooBigDeparture or tooBigArrival3070 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)3077 3058 3078 3059 self._distanceFlown.set_markup("<b>%.2f NM</b>" % \ … … 3101 3082 self._gate.set_sensitive(False) 3102 3083 3103 self. updateButtons()3084 self._updateTimes() 3104 3085 3105 3086 def updateButtons(self): … … 3147 3128 def _flightTypeChanged(self, comboBox): 3148 3129 """Called when the flight type has changed.""" 3149 self. updateButtons()3130 self._updateTimes() 3150 3131 3151 3132 def _gateChanged(self, comboBox): … … 3310 3291 pass 3311 3292 3312 def _formatTime(self, scheduledTime, realTimestamp ):3293 def _formatTime(self, scheduledTime, realTimestamp, (warning, error)): 3313 3294 """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.""" 3327 3296 realTime = time.gmtime(realTimestamp) 3328 3297 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" 3342 3300 markupBegin = '<span foreground="%s">' % (colour,) 3343 3301 markupEnd = '</span>' … … 3351 3309 markupEnd) 3352 3310 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() 3357 3346 3358 3347 #-----------------------------------------------------------------------------
Note:
See TracChangeset
for help on using the changeset viewer.