Ignore:
Timestamp:
12/21/12 16:50:01 (11 years ago)
Author:
István Váradi <ivaradi@…>
Branch:
default
Phase:
public
Message:

Implemented support for entering derate values (#158)

File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/mlx/acft.py

    r369 r384  
    33import checks
    44import fs
     5from i18n import xstr
    56import util
    67
     
    7475
    7576        self._v1r2LineIndex = None
     77        self._derateLineID = None
    7678        self._vrefLineIndex = None
    7779
     
    197199        return None if self._aircraftState is None \
    198200               else self._aircraftState.timestamp
     201
     202    @property
     203    def derateLabels(self):
     204        """Get the strings related to the derate entry.
     205
     206        It returns a tuple of two items:
     207        - the label before the entry field,
     208        - the label after the entry field, which can be None.
     209
     210        If both labels are None, the derate value will not be logged or
     211        queried. This is the default."""
     212        return (None, None)
     213
     214    @property
     215    def derateTemplate(self):
     216        """Get the template for logging the derate value.
     217
     218        If it returns None (which is the default), no derate value will be
     219        logged."""
     220        return None
    199221
    200222    def getFlapsSpeedLimit(self, flaps):
     
    271293                self._logRadios(aircraftState)
    272294                self._logV1R2(aircraftState)
     295                self._logDerate(aircraftState)
    273296            elif newStage==const.STAGE_DESCENT or newStage==const.STAGE_LANDING:
    274297                self._logRadios(aircraftState)
     
    380403            self._logV1R2()
    381404
     405    def updateDerate(self):
     406        """Update the derate value from the flight, if the these values
     407        have already been logged."""
     408        if self._derateLineID is not None:
     409            self._logDerate()
     410
    382411    def _appendLightsLoggers(self):
    383412        """Append the loggers needed for the lights.
     
    429458        else:
    430459            self.logger.updateLine(self._v1r2LineIndex, message)
     460
     461    def _logDerate(self, state = None):
     462        """Log the derate values either newly or by updating the corresponding
     463        line."""
     464        derateTemplate = self.derateTemplate
     465        if derateTemplate is None:
     466            return
     467
     468        derate = self._flight.derate
     469        message = derateTemplate % ("-" if derate is None else derate)
     470        if self._derateLineID is None:
     471            if state is None:
     472                state = self._aircraftState
     473            self._derateLineID = \
     474                self.logger.message(state.timestamp, message)
     475        else:
     476            self.logger.updateLine(self._derateLineID, message)
    431477
    432478    def updateVRef(self):
     
    502548                                 40 : 162 }
    503549
     550    @property
     551    def derateLabels(self):
     552        """Get the derate strings for this type."""
     553        return (xstr("takeoff_derate_boeing"), "%")
     554
     555    @property
     556    def derateTemplate(self):
     557        """Get the derate template for this aicraft type."""
     558        return "Derate calculated by the pilot: %s %%"
     559
    504560    # def _appendSpeedChecker(self):
    505561    #     """Append the NoStrobeSpeedChecker to the checkers.
     
    626682                                 25 : 185,
    627683                                 30 : 175 }
     684
     685    @property
     686    def derateLabels(self):
     687        """Get the derate strings for this type."""
     688        return (xstr("takeoff_derate_boeing"), "%")
     689
     690    @property
     691    def derateTemplate(self):
     692        """Get the derate template for this aicraft type."""
     693        return "Derate calculated by the pilot: %s %%"
    628694
    629695#---------------------------------------------------------------------------------------
     
    697763        self.reverseMinSpeed = 50
    698764
     765    @property
     766    def derateLabels(self):
     767        """Get the derate strings for this type."""
     768        return ("EPR", None)
     769
     770    @property
     771    def derateTemplate(self):
     772        """Get the derate template for this aicraft type."""
     773        return "EPR calculated by the pilot: %s"
     774
    699775#---------------------------------------------------------------------------------------
    700776
     
    751827
    752828    @property
     829    def derateLabels(self):
     830        """Get the derate strings for this type."""
     831        return (xstr("takeoff_derate_tupolev"), None)
     832
     833    @property
     834    def derateTemplate(self):
     835        """Get the derate template for this aicraft type."""
     836        return "Nominal/takeoff power calculated by the pilot: %s"
     837
     838    @property
    753839    def speedInKnots(self):
    754840        """Indicate if the speed is in knots."""
     
    798884        return False
    799885
     886    @property
     887    def derateLabels(self):
     888        """Get the derate strings for this type."""
     889        return (xstr("takeoff_derate_tupolev"), None)
     890
     891    @property
     892    def derateTemplate(self):
     893        """Get the derate template for this aicraft type."""
     894        return "Nominal/takeoff power calculated by the pilot: %s"
     895
    800896    def _appendLightsLoggers(self):
    801897        """Append the loggers needed for the lights."""
     
    811907
    812908#---------------------------------------------------------------------------------------
    813 
    814909
    815910class YK40(Aircraft):
     
    836931        """Indicate if the speed is in knots."""
    837932        return False
     933
     934    @property
     935    def derateLabels(self):
     936        """Get the derate strings for this type."""
     937        return (xstr("takeoff_derate_tupolev"), None)
     938
     939    @property
     940    def derateTemplate(self):
     941        """Get the derate template for this aicraft type."""
     942        return "Nominal/takeoff power calculated by the pilot: %s"
    838943
    839944    def _appendLightsLoggers(self):
Note: See TracChangeset for help on using the changeset viewer.