[8] | 1 |
|
---|
[176] | 2 | from soundsched import SoundScheduler, ChecklistScheduler
|
---|
[349] | 3 | from checks import SpeedChecker
|
---|
[170] | 4 |
|
---|
[8] | 5 | import const
|
---|
[89] | 6 | import util
|
---|
[8] | 7 |
|
---|
| 8 | import threading
|
---|
| 9 |
|
---|
| 10 | #---------------------------------------------------------------------------------------
|
---|
| 11 |
|
---|
[298] | 12 | ## @package mlx.flight
|
---|
| 13 | #
|
---|
| 14 | # The global flight state.
|
---|
| 15 | #
|
---|
| 16 | # This module defines a single class, \ref Flight, which represents the flight
|
---|
| 17 | # in progress.
|
---|
| 18 |
|
---|
| 19 | #---------------------------------------------------------------------------------------
|
---|
| 20 |
|
---|
[8] | 21 | class Flight(object):
|
---|
| 22 | """The object with the global flight state.
|
---|
[348] | 23 |
|
---|
[8] | 24 | It is also the hub for the other main objects participating in the handling of
|
---|
| 25 | the flight."""
|
---|
[383] | 26 | @staticmethod
|
---|
| 27 | def canLogCruiseAltitude(stage):
|
---|
| 28 | """Determine if the cruise altitude can be logged in the given
|
---|
| 29 | stage."""
|
---|
| 30 | return stage in [const.STAGE_CRUISE, const.STAGE_DESCENT,
|
---|
| 31 | const.STAGE_LANDING]
|
---|
| 32 |
|
---|
[29] | 33 | def __init__(self, logger, gui):
|
---|
[8] | 34 | """Construct the flight."""
|
---|
| 35 | self._stage = None
|
---|
| 36 | self.logger = logger
|
---|
[29] | 37 | self._gui = gui
|
---|
[11] | 38 |
|
---|
[31] | 39 | gui.resetFlightStatus()
|
---|
| 40 |
|
---|
[170] | 41 | self._pilotHotkeyPressed = False
|
---|
| 42 | self._checklistHotkeyPressed = False
|
---|
| 43 |
|
---|
[9] | 44 | self.flareTimeFromFS = False
|
---|
[11] | 45 |
|
---|
[8] | 46 | self.aircraftType = None
|
---|
| 47 | self.aircraft = None
|
---|
| 48 | self.simulator = None
|
---|
| 49 |
|
---|
[89] | 50 | self.blockTimeStart = None
|
---|
| 51 | self.flightTimeStart = None
|
---|
[365] | 52 | self.climbTimeStart = None
|
---|
| 53 | self.cruiseTimeStart = None
|
---|
| 54 | self.descentTimeStart = None
|
---|
[89] | 55 | self.flightTimeEnd = None
|
---|
| 56 | self.blockTimeEnd = None
|
---|
| 57 |
|
---|
[349] | 58 | self._rtoState = None
|
---|
| 59 | self._rtoLogEntryID = None
|
---|
| 60 |
|
---|
[89] | 61 | self._lastDistanceTime = None
|
---|
| 62 | self._previousLatitude = None
|
---|
| 63 | self._previousLongitude = None
|
---|
| 64 | self.flownDistance = 0.0
|
---|
| 65 |
|
---|
| 66 | self.startFuel = None
|
---|
| 67 | self.endFuel = None
|
---|
| 68 |
|
---|
[8] | 69 | self._endCondition = threading.Condition()
|
---|
| 70 |
|
---|
[9] | 71 | self._flareStart = None
|
---|
| 72 | self._flareStartFS = None
|
---|
| 73 |
|
---|
[170] | 74 | self._tdRate = None
|
---|
| 75 |
|
---|
[176] | 76 | self._soundScheduler = SoundScheduler(self)
|
---|
| 77 | self._checklistScheduler = ChecklistScheduler(self)
|
---|
| 78 |
|
---|
[8] | 79 | @property
|
---|
[134] | 80 | def config(self):
|
---|
| 81 | """Get the configuration."""
|
---|
| 82 | return self._gui.config
|
---|
| 83 |
|
---|
| 84 | @property
|
---|
[8] | 85 | def stage(self):
|
---|
| 86 | """Get the flight stage."""
|
---|
| 87 | return self._stage
|
---|
| 88 |
|
---|
[84] | 89 | @property
|
---|
[215] | 90 | def loggedIn(self):
|
---|
| 91 | """Indicate if the user has logged in properly."""
|
---|
| 92 | return self._gui.loggedIn
|
---|
| 93 |
|
---|
| 94 | @property
|
---|
[184] | 95 | def entranceExam(self):
|
---|
| 96 | """Get whether an entrance exam is being performed."""
|
---|
| 97 | return self._gui.entranceExam
|
---|
| 98 |
|
---|
| 99 | @property
|
---|
[134] | 100 | def bookedFlight(self):
|
---|
| 101 | """Get the booked flight."""
|
---|
| 102 | return self._gui.bookedFlight
|
---|
| 103 |
|
---|
| 104 | @property
|
---|
[303] | 105 | def numCrew(self):
|
---|
| 106 | """Get the number of crew members on the flight."""
|
---|
| 107 | return self._gui.numCrew
|
---|
| 108 |
|
---|
| 109 | @property
|
---|
| 110 | def numPassengers(self):
|
---|
| 111 | """Get the number of passengers on the flight."""
|
---|
| 112 | return self._gui.numPassengers
|
---|
| 113 |
|
---|
| 114 | @property
|
---|
| 115 | def bagWeight(self):
|
---|
| 116 | """Get the baggage weight for the flight."""
|
---|
| 117 | return self._gui.bagWeight
|
---|
| 118 |
|
---|
| 119 | @property
|
---|
[262] | 120 | def cargoWeight(self):
|
---|
| 121 | """Get the cargo weight for the flight."""
|
---|
| 122 | return self._gui.cargoWeight
|
---|
| 123 |
|
---|
| 124 | @property
|
---|
[303] | 125 | def mailWeight(self):
|
---|
| 126 | """Get the mail weight for the flight."""
|
---|
| 127 | return self._gui.mailWeight
|
---|
| 128 |
|
---|
| 129 | @property
|
---|
[84] | 130 | def zfw(self):
|
---|
| 131 | """Get the Zero-Fuel Weight of the flight."""
|
---|
| 132 | return self._gui.zfw
|
---|
| 133 |
|
---|
| 134 | @property
|
---|
[262] | 135 | def filedCruiseAltitude(self):
|
---|
| 136 | """Get the filed cruise altitude."""
|
---|
| 137 | return self._gui.filedCruiseAltitude
|
---|
| 138 |
|
---|
| 139 | @property
|
---|
[84] | 140 | def cruiseAltitude(self):
|
---|
| 141 | """Get the cruise altitude of the flight."""
|
---|
| 142 | return self._gui.cruiseAltitude
|
---|
| 143 |
|
---|
| 144 | @property
|
---|
[262] | 145 | def route(self):
|
---|
| 146 | """Get the route of the flight."""
|
---|
| 147 | return self._gui.route
|
---|
| 148 |
|
---|
| 149 | @property
|
---|
| 150 | def departureMETAR(self):
|
---|
| 151 | """Get the departure METAR of the flight."""
|
---|
| 152 | return self._gui.departureMETAR
|
---|
| 153 |
|
---|
| 154 | @property
|
---|
| 155 | def arrivalMETAR(self):
|
---|
| 156 | """Get the arrival METAR of the flight."""
|
---|
| 157 | return self._gui.arrivalMETAR
|
---|
| 158 |
|
---|
| 159 | @property
|
---|
| 160 | def departureRunway(self):
|
---|
| 161 | """Get the departure runway."""
|
---|
| 162 | return self._gui.departureRunway
|
---|
| 163 |
|
---|
| 164 | @property
|
---|
| 165 | def sid(self):
|
---|
| 166 | """Get the SID followed."""
|
---|
| 167 | return self._gui.sid
|
---|
| 168 |
|
---|
| 169 | @property
|
---|
[84] | 170 | def v1(self):
|
---|
| 171 | """Get the V1 speed of the flight."""
|
---|
| 172 | return self._gui.v1
|
---|
| 173 |
|
---|
| 174 | @property
|
---|
| 175 | def vr(self):
|
---|
| 176 | """Get the Vr speed of the flight."""
|
---|
| 177 | return self._gui.vr
|
---|
| 178 |
|
---|
| 179 | @property
|
---|
| 180 | def v2(self):
|
---|
| 181 | """Get the V2 speed of the flight."""
|
---|
| 182 | return self._gui.v2
|
---|
| 183 |
|
---|
[86] | 184 | @property
|
---|
[391] | 185 | def takeoffAntiIceOn(self):
|
---|
| 186 | """Get whether the anti-ice system was on during takeoff."""
|
---|
| 187 | return self._gui.takeoffAntiIceOn
|
---|
| 188 |
|
---|
| 189 | @takeoffAntiIceOn.setter
|
---|
| 190 | def takeoffAntiIceOn(self, value):
|
---|
| 191 | """Set whether the anti-ice system was on during takeoff."""
|
---|
| 192 | self._gui.takeoffAntiIceOn = value
|
---|
| 193 |
|
---|
| 194 | @property
|
---|
[384] | 195 | def derate(self):
|
---|
| 196 | """Get the derate value of the flight."""
|
---|
| 197 | return self._gui.derate
|
---|
| 198 |
|
---|
| 199 | @property
|
---|
[262] | 200 | def star(self):
|
---|
| 201 | """Get the STAR planned."""
|
---|
| 202 | return self._gui.star
|
---|
| 203 |
|
---|
| 204 | @property
|
---|
| 205 | def transition(self):
|
---|
| 206 | """Get the transition planned."""
|
---|
| 207 | return self._gui.transition
|
---|
| 208 |
|
---|
| 209 | @property
|
---|
| 210 | def approachType(self):
|
---|
| 211 | """Get the approach type."""
|
---|
| 212 | return self._gui.approachType
|
---|
| 213 |
|
---|
| 214 | @property
|
---|
| 215 | def arrivalRunway(self):
|
---|
| 216 | """Get the arrival runway."""
|
---|
| 217 | return self._gui.arrivalRunway
|
---|
| 218 |
|
---|
| 219 | @property
|
---|
[86] | 220 | def vref(self):
|
---|
| 221 | """Get the VRef speed of the flight."""
|
---|
| 222 | return self._gui.vref
|
---|
| 223 |
|
---|
[170] | 224 | @property
|
---|
[391] | 225 | def landingAntiIceOn(self):
|
---|
| 226 | """Get whether the anti-ice system was on during landing."""
|
---|
| 227 | return self._gui.landingAntiIceOn
|
---|
| 228 |
|
---|
| 229 | @landingAntiIceOn.setter
|
---|
| 230 | def landingAntiIceOn(self, value):
|
---|
| 231 | """Set whether the anti-ice system was on during landing."""
|
---|
| 232 | self._gui.landingAntiIceOn = value
|
---|
| 233 |
|
---|
| 234 | @property
|
---|
[170] | 235 | def tdRate(self):
|
---|
| 236 | """Get the touchdown rate if known, None otherwise."""
|
---|
| 237 | return self._tdRate
|
---|
| 238 |
|
---|
[241] | 239 | @property
|
---|
[262] | 240 | def flightType(self):
|
---|
| 241 | """Get the type of the flight."""
|
---|
| 242 | return self._gui.flightType
|
---|
| 243 |
|
---|
| 244 | @property
|
---|
| 245 | def online(self):
|
---|
| 246 | """Get whether the flight was an online flight."""
|
---|
| 247 | return self._gui.online
|
---|
| 248 |
|
---|
| 249 | @property
|
---|
| 250 | def comments(self):
|
---|
| 251 | """Get the comments made by the pilot."""
|
---|
| 252 | return self._gui.comments
|
---|
| 253 |
|
---|
| 254 | @property
|
---|
| 255 | def flightDefects(self):
|
---|
| 256 | """Get the flight defects reported by the pilot."""
|
---|
| 257 | return self._gui.flightDefects
|
---|
| 258 |
|
---|
| 259 | @property
|
---|
| 260 | def delayCodes(self):
|
---|
| 261 | """Get the delay codes."""
|
---|
| 262 | return self._gui.delayCodes
|
---|
| 263 |
|
---|
| 264 | @property
|
---|
[241] | 265 | def speedInKnots(self):
|
---|
| 266 | """Determine if the speeds for the flight are to be expressed in
|
---|
| 267 | knots."""
|
---|
| 268 | return self.aircraft.speedInKnots if self.aircraft is not None \
|
---|
| 269 | else True
|
---|
| 270 |
|
---|
[349] | 271 | @property
|
---|
| 272 | def hasRTO(self):
|
---|
| 273 | """Determine if we have an RTO state."""
|
---|
| 274 | return self._rtoState is not None
|
---|
| 275 |
|
---|
| 276 | @property
|
---|
| 277 | def rtoState(self):
|
---|
| 278 | """Get the RTO state."""
|
---|
| 279 | return self._rtoState
|
---|
| 280 |
|
---|
[89] | 281 | def handleState(self, oldState, currentState):
|
---|
| 282 | """Handle a new state information."""
|
---|
| 283 | self._updateFlownDistance(currentState)
|
---|
[348] | 284 |
|
---|
[274] | 285 | self.endFuel = currentState.totalFuel
|
---|
[89] | 286 | if self.startFuel is None:
|
---|
| 287 | self.startFuel = self.endFuel
|
---|
[348] | 288 |
|
---|
[170] | 289 | self._soundScheduler.schedule(currentState,
|
---|
| 290 | self._pilotHotkeyPressed)
|
---|
| 291 | self._pilotHotkeyPressed = False
|
---|
[89] | 292 |
|
---|
[176] | 293 | if self._checklistHotkeyPressed:
|
---|
| 294 | self._checklistScheduler.hotkeyPressed()
|
---|
| 295 | self._checklistHotkeyPressed = False
|
---|
| 296 |
|
---|
[8] | 297 | def setStage(self, timestamp, stage):
|
---|
[9] | 298 | """Set the flight stage.
|
---|
| 299 |
|
---|
| 300 | Returns if the stage has really changed."""
|
---|
[8] | 301 | if stage!=self._stage:
|
---|
[365] | 302 | self._logStageDuration(timestamp, stage)
|
---|
[8] | 303 | self._stage = stage
|
---|
[84] | 304 | self._gui.setStage(stage)
|
---|
[8] | 305 | self.logger.stage(timestamp, stage)
|
---|
[89] | 306 | if stage==const.STAGE_PUSHANDTAXI:
|
---|
| 307 | self.blockTimeStart = timestamp
|
---|
| 308 | elif stage==const.STAGE_TAKEOFF:
|
---|
| 309 | self.flightTimeStart = timestamp
|
---|
[365] | 310 | elif stage==const.STAGE_CLIMB:
|
---|
| 311 | self.climbTimeStart = timestamp
|
---|
| 312 | elif stage==const.STAGE_CRUISE:
|
---|
| 313 | self.cruiseTimeStart = timestamp
|
---|
| 314 | elif stage==const.STAGE_DESCENT:
|
---|
| 315 | self.descentTimeStart = timestamp
|
---|
[89] | 316 | elif stage==const.STAGE_TAXIAFTERLAND:
|
---|
| 317 | self.flightTimeEnd = timestamp
|
---|
[359] | 318 | # elif stage==const.STAGE_PARKING:
|
---|
| 319 | # self.blockTimeEnd = timestamp
|
---|
| 320 | elif stage==const.STAGE_END:
|
---|
[89] | 321 | self.blockTimeEnd = timestamp
|
---|
[8] | 322 | with self._endCondition:
|
---|
| 323 | self._endCondition.notify()
|
---|
[9] | 324 | return True
|
---|
| 325 | else:
|
---|
| 326 | return False
|
---|
| 327 |
|
---|
[346] | 328 | def handleFault(self, faultID, timestamp, what, score,
|
---|
[349] | 329 | updatePrevious = False, updateID = None):
|
---|
[30] | 330 | """Handle the given fault.
|
---|
| 331 |
|
---|
| 332 | faultID as a unique ID for the given kind of fault. If another fault of
|
---|
| 333 | this ID has been reported earlier, it will be reported again only if
|
---|
| 334 | the score is greater than last time. This ID can be, e.g. the checker
|
---|
| 335 | the report comes from."""
|
---|
[349] | 336 | id = self.logger.fault(faultID, timestamp, what, score,
|
---|
| 337 | updatePrevious = updatePrevious,
|
---|
| 338 | updateID = updateID)
|
---|
[31] | 339 | self._gui.setRating(self.logger.getRating())
|
---|
[349] | 340 | return id
|
---|
[30] | 341 |
|
---|
| 342 | def handleNoGo(self, faultID, timestamp, what, shortReason):
|
---|
| 343 | """Handle a No-Go fault."""
|
---|
| 344 | self.logger.noGo(faultID, timestamp, what)
|
---|
[31] | 345 | self._gui.setNoGo(shortReason)
|
---|
[30] | 346 |
|
---|
[349] | 347 | def setRTOState(self, state):
|
---|
| 348 | """Set the state that might be used as the RTO state.
|
---|
| 349 |
|
---|
| 350 | If there has been no RTO state, the GUI is notified that from now on
|
---|
| 351 | the user may select to report an RTO."""
|
---|
| 352 | hadNoRTOState = self._rtoState is None
|
---|
| 353 |
|
---|
| 354 | self._rtoState = state
|
---|
| 355 | self._rtoLogEntryID = \
|
---|
| 356 | SpeedChecker.logSpeedFault(self, state,
|
---|
| 357 | stage = const.STAGE_PUSHANDTAXI)
|
---|
| 358 |
|
---|
| 359 | if hadNoRTOState:
|
---|
| 360 | self._gui.updateRTO()
|
---|
| 361 |
|
---|
| 362 | def rtoToggled(self, indicated):
|
---|
| 363 | """Called when the user has toggled the RTO indication."""
|
---|
| 364 | if self._rtoState is not None:
|
---|
| 365 | if indicated:
|
---|
| 366 | self.logger.clearFault(self._rtoLogEntryID,
|
---|
| 367 | "RTO at %d knots" %
|
---|
| 368 | (self._rtoState.groundSpeed,))
|
---|
| 369 | self._gui.setRating(self.logger.getRating())
|
---|
[354] | 370 | if self._stage == const.STAGE_PUSHANDTAXI:
|
---|
| 371 | self.setStage(self.aircraft.state.timestamp,
|
---|
| 372 | const.STAGE_RTO)
|
---|
[349] | 373 | else:
|
---|
| 374 | SpeedChecker.logSpeedFault(self, self._rtoState,
|
---|
| 375 | stage = const.STAGE_PUSHANDTAXI,
|
---|
| 376 | updateID = self._rtoLogEntryID)
|
---|
[354] | 377 | if self._stage == const.STAGE_RTO:
|
---|
| 378 | self.setStage(self.aircraft.state.timestamp,
|
---|
| 379 | const.STAGE_PUSHANDTAXI)
|
---|
[349] | 380 |
|
---|
[9] | 381 | def flareStarted(self, flareStart, flareStartFS):
|
---|
| 382 | """Called when the flare time has started."""
|
---|
| 383 | self._flareStart = flareStart
|
---|
| 384 | self._flareStartFS = flareStartFS
|
---|
| 385 |
|
---|
[170] | 386 | def flareFinished(self, flareEnd, flareEndFS, tdRate):
|
---|
[9] | 387 | """Called when the flare time has ended.
|
---|
[348] | 388 |
|
---|
[9] | 389 | Return a tuple of the following items:
|
---|
| 390 | - a boolean indicating if FS time is used
|
---|
| 391 | - the flare time
|
---|
| 392 | """
|
---|
[170] | 393 | self._tdRate = tdRate
|
---|
[9] | 394 | if self.flareTimeFromFS:
|
---|
| 395 | return (True, flareEndFS - self._flareStartFS)
|
---|
| 396 | else:
|
---|
| 397 | return (False, flareEnd - self._flareStart)
|
---|
[8] | 398 |
|
---|
| 399 | def wait(self):
|
---|
| 400 | """Wait for the flight to end."""
|
---|
| 401 | with self._endCondition:
|
---|
| 402 | while self._stage!=const.STAGE_END:
|
---|
[14] | 403 | self._endCondition.wait(1)
|
---|
[8] | 404 |
|
---|
[134] | 405 | def getFleet(self, callback, force = False):
|
---|
| 406 | """Get the fleet and call the given callback."""
|
---|
| 407 | self._gui.getFleetAsync(callback = callback, force = force)
|
---|
| 408 |
|
---|
[170] | 409 | def pilotHotkeyPressed(self):
|
---|
| 410 | """Called when the pilot hotkey is pressed."""
|
---|
| 411 | self._pilotHotkeyPressed = True
|
---|
| 412 |
|
---|
| 413 | def checklistHotkeyPressed(self):
|
---|
| 414 | """Called when the checklist hotkey is pressed."""
|
---|
| 415 | self._checklistHotkeyPressed = True
|
---|
| 416 |
|
---|
[241] | 417 | def speedFromKnots(self, knots):
|
---|
| 418 | """Convert the given speed value expressed in knots into the flight's
|
---|
| 419 | speed unit."""
|
---|
| 420 | return knots if self.speedInKnots else knots * const.KNOTSTOKMPH
|
---|
| 421 |
|
---|
| 422 | def speedToKnots(self, speed):
|
---|
| 423 | """Convert the given speed expressed in the flight's speed unit into
|
---|
[348] | 424 | knots."""
|
---|
[241] | 425 | return speed if self.speedInKnots else speed * const.KMPHTOKNOTS
|
---|
| 426 |
|
---|
| 427 | def getEnglishSpeedUnit(self):
|
---|
| 428 | """Get the English name of the speed unit used by the flight."""
|
---|
| 429 | return "knots" if self.speedInKnots else "km/h"
|
---|
| 430 |
|
---|
| 431 | def getI18NSpeedUnit(self):
|
---|
| 432 | """Get the speed unit suffix for i18n message identifiers."""
|
---|
| 433 | return "_knots" if self.speedInKnots else "_kmph"
|
---|
| 434 |
|
---|
[274] | 435 | def logFuel(self, aircraftState):
|
---|
| 436 | """Log the amount of fuel"""
|
---|
| 437 | fuelStr = ""
|
---|
| 438 | for (tank, amount) in aircraftState.fuel:
|
---|
| 439 | if fuelStr: fuelStr += " - "
|
---|
| 440 | fuelStr += "%s=%.0f kg" % (const.fuelTank2logString(tank), amount)
|
---|
[348] | 441 |
|
---|
[274] | 442 | self.logger.message(aircraftState.timestamp, "Fuel: " + fuelStr)
|
---|
| 443 | self.logger.message(aircraftState.timestamp,
|
---|
[348] | 444 | "Total fuel: %.0f kg" % (aircraftState.totalFuel,))
|
---|
[274] | 445 |
|
---|
[304] | 446 | def cruiseLevelChanged(self):
|
---|
| 447 | """Called when the cruise level hass changed."""
|
---|
[383] | 448 | if self.canLogCruiseAltitude(self._stage):
|
---|
[304] | 449 | message = "Cruise altitude modified to %d feet" % \
|
---|
[383] | 450 | (self._gui.loggableCruiseAltitude,)
|
---|
[304] | 451 | self.logger.message(self.aircraft.timestamp, message)
|
---|
[383] | 452 | return True
|
---|
| 453 | else:
|
---|
| 454 | return False
|
---|
[304] | 455 |
|
---|
[89] | 456 | def _updateFlownDistance(self, currentState):
|
---|
| 457 | """Update the flown distance."""
|
---|
| 458 | if not currentState.onTheGround:
|
---|
| 459 | updateData = False
|
---|
| 460 | if self._lastDistanceTime is None or \
|
---|
| 461 | self._previousLatitude is None or \
|
---|
| 462 | self._previousLongitude is None:
|
---|
| 463 | updateData = True
|
---|
| 464 | elif currentState.timestamp >= (self._lastDistanceTime + 30.0):
|
---|
| 465 | updateData = True
|
---|
| 466 | self.flownDistance += self._getDistance(currentState)
|
---|
| 467 |
|
---|
| 468 | if updateData:
|
---|
| 469 | self._previousLatitude = currentState.latitude
|
---|
| 470 | self._previousLongitude = currentState.longitude
|
---|
| 471 | self._lastDistanceTime = currentState.timestamp
|
---|
| 472 | else:
|
---|
| 473 | if self._lastDistanceTime is not None and \
|
---|
| 474 | self._previousLatitude is not None and \
|
---|
| 475 | self._previousLongitude is not None:
|
---|
| 476 | self.flownDistance += self._getDistance(currentState)
|
---|
[348] | 477 |
|
---|
[89] | 478 | self._lastDistanceTime = None
|
---|
| 479 |
|
---|
| 480 | def _getDistance(self, currentState):
|
---|
| 481 | """Get the distance between the previous and the current state."""
|
---|
| 482 | return util.getDistCourse(self._previousLatitude, self._previousLongitude,
|
---|
| 483 | currentState.latitude, currentState.longitude)[0]
|
---|
| 484 |
|
---|
[365] | 485 | def _logStageDuration(self, timestamp, stage):
|
---|
| 486 | """Log the duration of the stage preceding the given one."""
|
---|
| 487 | what = None
|
---|
| 488 | startTime = None
|
---|
| 489 |
|
---|
| 490 | if stage==const.STAGE_TAKEOFF:
|
---|
| 491 | what = "Pushback and taxi"
|
---|
| 492 | startTime = self.blockTimeStart
|
---|
| 493 | elif stage==const.STAGE_CRUISE:
|
---|
| 494 | what = "Climb"
|
---|
| 495 | startTime = self.climbTimeStart
|
---|
| 496 | elif stage==const.STAGE_DESCENT:
|
---|
| 497 | what = "Cruise"
|
---|
| 498 | startTime = self.cruiseTimeStart
|
---|
| 499 | elif stage==const.STAGE_LANDING:
|
---|
| 500 | what = "Descent"
|
---|
| 501 | startTime = self.descentTimeStart
|
---|
| 502 | elif stage==const.STAGE_END:
|
---|
| 503 | what = "Taxi after landing"
|
---|
| 504 | startTime = self.flightTimeEnd
|
---|
| 505 |
|
---|
| 506 | if what is not None and startTime is not None:
|
---|
| 507 | duration = timestamp - startTime
|
---|
| 508 | self.logger.message(timestamp,
|
---|
| 509 | "%s time: %s" % \
|
---|
| 510 | (what, util.getTimeIntervalString(duration)))
|
---|
| 511 |
|
---|
[8] | 512 | #---------------------------------------------------------------------------------------
|
---|