Ignore:
Timestamp:
07/03/12 17:30:04 (12 years ago)
Author:
István Váradi <ivaradi@…>
Branch:
default
Phase:
public
Message:

Added the playback of approach callouts

File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/mlx/checks.py

    r271 r273  
    219219#---------------------------------------------------------------------------------------
    220220
     221class ApproachCalloutsPlayer(StateChecker):
     222    """A state checker that plays a sequence of approach callouts.
     223
     224    It tracks the altitude during the descent and landing phases and
     225    if the altitude crosses one that has a callout associated with and
     226    the vertical speed is negative, that callout will be played."""   
     227    def __init__(self, approachCallouts):
     228        """Construct the approach callouts player."""
     229        self._approachCallouts = approachCallouts
     230        self._altitudes = approachCallouts.getAltitudes(descending = False)
     231
     232    def check(self, flight, aircraft, logger, oldState, state):
     233        """Check if we need to play a callout."""
     234        if (flight.stage==const.STAGE_DESCENT or \
     235            flight.stage==const.STAGE_LANDING) and state.vs<0:
     236            oldRadioAltitude = oldState.radioAltitude
     237            radioAltitude = state.radioAltitude
     238            for altitude in self._altitudes:
     239                if radioAltitude<=altitude and \
     240                   oldRadioAltitude>altitude:
     241                    startSound(self._approachCallouts[altitude])
     242                    break
     243
     244#---------------------------------------------------------------------------------------
     245
    221246class StateChangeLogger(StateChecker):
    222247    """Base class for classes the instances of which check if a specific change has
Note: See TracChangeset for help on using the changeset viewer.