Changeset 335:db900a4a0930 for src/mlx


Ignore:
Timestamp:
11/13/12 18:17:23 (12 years ago)
Author:
István Váradi <ivaradi@…>
Branch:
default
Phase:
public
Message:

#139: added a checker for thev transponder state

Location:
src/mlx
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • src/mlx/acft.py

    r333 r335  
    118118
    119119        self._appendLightsCheckers()
     120
     121        self._checkers.append(checks.TransponderChecker())
    120122
    121123        self._checkers.append(checks.BankChecker())
  • src/mlx/checks.py

    r333 r335  
    927927        """Log the fault."""
    928928        score = 0 if flight.stage==const.STAGE_LANDING else 1
    929         message = "Landing lights were %s" % (("on" if state.landingLightsOn else "off"),)
     929        message = "Landing lights were %s" % \
     930                  (("on" if state.landingLightsOn else "off"),)
    930931        flight.handleFault(LandingLightsChecker, state.timestamp,
     932                           FaultChecker._appendDuring(flight, message),
     933                           score)
     934
     935#---------------------------------------------------------------------------------------
     936
     937class TransponderChecker(PatientFaultChecker):
     938    """Check if the transponder is used properly."""
     939    def isCondition(self, flight, aircraft, oldState, state):
     940        """Check if the fault condition holds."""
     941        return state.xpdrC is not None and \
     942               ((state.xpdrC and flight.stage in
     943                 [const.STAGE_BOARDING, const.STAGE_PARKING]) or \
     944                (not state.xpdrC and flight.stage in
     945                 [const.STAGE_TAKEOFF, const.STAGE_RTO, const.STAGE_CLIMB,
     946                  const.STAGE_CRUISE, const.STAGE_DESCENT,
     947                  const.STAGE_LANDING, const.STAGE_GOAROUND]))
     948
     949    def logFault(self, flight, aircraft, logger, oldState, state):
     950        """Log the fault."""
     951        score = 0
     952        message = "Transponder was %s" % \
     953                  (("mode C" if state.xpdrC else "standby"),)
     954        flight.handleFault(TransponderChecker, state.timestamp,
    931955                           FaultChecker._appendDuring(flight, message),
    932956                           score)
  • src/mlx/const.py

    r329 r335  
    187187    """Convert the given stage to a lower-case string."""
    188188    return _stageStrings[stage] if stage in _stageStrings else None
    189        
     189
    190190#-------------------------------------------------------------------------------
    191191
     
    233233    """Get the string equivalent of the given flight type."""
    234234    return _flightTypeStrings[flightType] \
    235            if flightType in _flightTypeStrings else None   
     235           if flightType in _flightTypeStrings else None
    236236
    237237#-------------------------------------------------------------------------------
     
    325325    """Get the string equivalent of the given message type."""
    326326    return _messageTypeStrings[messageType] \
    327            if messageType in _messageTypeStrings else None   
     327           if messageType in _messageTypeStrings else None
    328328
    329329#-------------------------------------------------------------------------------
     
    358358    """Get the string equivalent of the given message level."""
    359359    return _messageLevelStrings[messageLevel] \
    360            if messageLevel in _messageLevelStrings else None   
     360           if messageLevel in _messageLevelStrings else None
    361361
    362362def string2messageLevel(str):
     
    476476    """Get the string equivalent of the given fuelTank."""
    477477    return _fuelTankStrings[fuelTank] \
    478            if fuelTank in _fuelTankStrings else None   
     478           if fuelTank in _fuelTankStrings else None
    479479
    480480#-------------------------------------------------------------------------------
     
    525525
    526526#-------------------------------------------------------------------------------
    527 
Note: See TracChangeset for help on using the changeset viewer.