Changeset 564:695cde9818ea for src/mlx/flight.py
- Timestamp:
- 02/22/14 09:50:09 (10 years ago)
- Branch:
- default
- Phase:
- public
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
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):
Note:
See TracChangeset
for help on using the changeset viewer.