Changeset 365:db5767329602 for src


Ignore:
Timestamp:
12/15/12 06:10:23 (12 years ago)
Author:
István Váradi <ivaradi@…>
Branch:
default
Phase:
public
Message:

The durations of certain stages are logged (#146)

File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/mlx/flight.py

    r359 r365  
    4343        self.blockTimeStart = None
    4444        self.flightTimeStart = None
     45        self.climbTimeStart = None
     46        self.cruiseTimeStart = None
     47        self.descentTimeStart = None
    4548        self.flightTimeEnd = None
    4649        self.blockTimeEnd = None
     
    265268        Returns if the stage has really changed."""
    266269        if stage!=self._stage:
     270            self._logStageDuration(timestamp, stage)
    267271            self._stage = stage
    268272            self._gui.setStage(stage)
     
    272276            elif stage==const.STAGE_TAKEOFF:
    273277                self.flightTimeStart = timestamp
     278            elif stage==const.STAGE_CLIMB:
     279                self.climbTimeStart = timestamp
     280            elif stage==const.STAGE_CRUISE:
     281                self.cruiseTimeStart = timestamp
     282            elif stage==const.STAGE_DESCENT:
     283                self.descentTimeStart = timestamp
    274284            elif stage==const.STAGE_TAXIAFTERLAND:
    275285                self.flightTimeEnd = timestamp
     
    439449                                  currentState.latitude, currentState.longitude)[0]
    440450
     451    def _logStageDuration(self, timestamp, stage):
     452        """Log the duration of the stage preceding the given one."""
     453        what = None
     454        startTime = None
     455
     456        if stage==const.STAGE_TAKEOFF:
     457            what = "Pushback and taxi"
     458            startTime = self.blockTimeStart
     459        elif stage==const.STAGE_CRUISE:
     460            what = "Climb"
     461            startTime = self.climbTimeStart
     462        elif stage==const.STAGE_DESCENT:
     463            what = "Cruise"
     464            startTime = self.cruiseTimeStart
     465        elif stage==const.STAGE_LANDING:
     466            what = "Descent"
     467            startTime = self.descentTimeStart
     468        elif stage==const.STAGE_END:
     469            what = "Taxi after landing"
     470            startTime = self.flightTimeEnd
     471
     472        if what is not None and startTime is not None:
     473            duration = timestamp - startTime
     474            self.logger.message(timestamp,
     475                                "%s time: %s" % \
     476                                (what, util.getTimeIntervalString(duration)))
     477
    441478#---------------------------------------------------------------------------------------
Note: See TracChangeset for help on using the changeset viewer.