Changeset 273:066f7271e849


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

Files:
5 edited

Legend:

Unmodified
Added
Removed
  • src/mlx/acft.py

    r271 r273  
    122122       
    123123        self._checkers.append(checks.ReverserChecker())
     124
     125        if flight.aircraftType is not None and config.enableApproachCallouts:
     126            approachCallouts = flight.config.getApproachCallouts(flight.aircraftType)
     127            if approachCallouts:
     128                self._checkers.append(checks.ApproachCalloutsPlayer(approachCallouts))
    124129
    125130        self._smoothedIAS = SmoothedValue()
  • 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
  • src/mlx/config.py

    r270 r273  
    157157            index += 1
    158158
     159    def getAltitudes(self, descending = True):
     160        """Get the altitudes in decreasing order by default."""
     161        altitudes = self._mapping.keys()
     162        altitudes.sort(reverse = descending)
     163        return altitudes
     164
     165    def __nonzero__(self):
     166        """Return if there is anything in the mapping."""
     167        return not not self._mapping
     168
    159169    def __eq__(self, other):
    160170        """Determine if the approach callout mapping is equal to the given
     
    172182
    173183    def __getitem__(self, altitude):
    174         """Get the file that is associated with the highest altitude not higher
    175         than the given one.
     184        """Get the file that is associated with the given altitude.
    176185
    177186        If no such file found, return None."""
    178         candidate = None
    179         for (alt, path) in self._mapping.iteritems():
    180             if alt<=altitude:
    181                 if candidate is None or alt>candidate[0]:
    182                     candidate = (alt, path)
    183 
    184         return candidate
     187        return self._mapping[altitude] if altitude in self._mapping else None
    185188
    186189    def __iter__(self):
    187190        """Iterate over the pairs of altitudes and paths in decreasing order of
    188191        the altitude."""
    189         altitudes = self._mapping.keys()
    190         altitudes.sort(reverse = True)
     192        altitudes = self.getAltitudes()
    191193
    192194        for altitude in altitudes:
  • src/mlx/pyuipc_sim.py

    r243 r273  
    552552        elif offset==0x0570:       # Altitude
    553553            self.altitude = value / const.FEETTOMETRES / 65536.0 / 65536.0
     554            self.radioAltitude = self.altitude - 517
    554555        elif offset==0x0578:       # Pitch
    555556            self.pitch = value * 360.0 / 65536.0 / 65536.0
     
    668669            raise FSUIPCException(ERR_DATA)
    669670        elif offset==0x31e4:       # Radio altitude
     671            self.radioAltitude = value / const.FEETTOMETRES / 65536.0
     672            self.altitude = self.radioAltitude + 517
     673        elif offset==0x31e4:       # Radio altitude
    670674            raise FSUIPCException(ERR_DATA)
    671675        elif offset==0x320c:
  • test/test1.txt

    r241 r273  
    2525set altitude=557
    2626set ias=125 gs=125
     27set radioAltitude=3200
     28set radioAltitude=3100
     29set radioAltitude=3000
     30set radioAltitude=2900
     31set radioAltitude=2800
     32set radioAltitude=2700
     33set radioAltitude=2600
     34set radioAltitude=2521
     35set radioAltitude=2510
     36set radioAltitude=2500
     37set radioAltitude=2500
     38set radioAltitude=2499
     39set radioAltitude=2520
     40set radioAltitude=2400
     41set radioAltitude=2300
     42set radioAltitude=2200
     43set radioAltitude=2100
     44set radioAltitude=2018
     45set radioAltitude=1950
     46set radioAltitude=1800
     47set radioAltitude=1600
     48set radioAltitude=1550
     49set radioAltitude=1450
     50set radioAltitude=1590
     51set radioAltitude=1499
     52set radioAltitude=1400
     53set radioAltitude=1300
     54set radioAltitude=1200
     55set radioAltitude=1200
     56set radioAltitude=1100
     57set radioAltitude=1001
     58set radioAltitude=912
     59set radioAltitude=832
     60set radioAltitude=705
     61set radioAltitude=599
     62set radioAltitude=501
     63set radioAltitude=412
     64set radioAltitude=331
     65set radioAltitude=241
     66set radioAltitude=102
     67set radioAltitude=90
    2768set noseGear=100
    28 set altitude=547
    29 set altitude=537
    30 set altitude=527
     69set radioAltitude=80
     70set radioAltitude=70
     71set radioAltitude=60
     72set radioAltitude=51
     73set radioAltitude=42
     74set radioAltitude=29
     75set radioAltitude=9
    3176set altitude=517
    3277set latitude=47.49 longitude=21.62
Note: See TracChangeset for help on using the changeset viewer.