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

Most of the remaining messages are implemented

File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/mlx/checks.py

    r60 r134  
    33#---------------------------------------------------------------------------------------
    44
     5import fs
    56import const
     7import util
    68
    79#---------------------------------------------------------------------------------------
     
    143145#---------------------------------------------------------------------------------------
    144146
     147class VisibilityChecker(StateChecker):
     148    """Inform the pilot of the visibility once when descending below 2000 ft,
     149    then when descending below 1000 ft."""
     150    def __init__(self):
     151        """Construct the visibility checker."""
     152        self._informedBelow2000 = False
     153        self._informedBelow1000 = False
     154
     155    def check(self, flight, aircraft, logger, oldState, state):
     156        """Check if we need to inform the pilot of the visibility."""
     157        if flight.stage==const.STAGE_DESCENT or \
     158           flight.stage==const.STAGE_LANDING:
     159            if (state.radioAltitude<2000 and not self._informedBelow2000) or \
     160               (state.radioAltitude<1000 and not self._informedBelow1000):
     161                visibilityString = util.visibility2String(state.visibility)
     162                fs.sendMessage(const.MESSAGETYPE_VISIBILITY,
     163                               "Current visibility: " + visibilityString,
     164                               5)
     165                logger.message(state.timestamp,
     166                               "Pilot was informed about the visibility: " +
     167                               visibilityString)
     168                self._informedBelow2000 = True
     169                self._informedBelow1000 = state.radioAltitude<1000
     170
     171#---------------------------------------------------------------------------------------
     172
    145173class StateChangeLogger(StateChecker):
    146174    """Base class for classes the instances of which check if a specific change has
Note: See TracChangeset for help on using the changeset viewer.