Changeset 13:7cdc145ceef9 for src


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

Fixed some types and small problems

File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/checks.py

    r11 r13  
    122122        """Construct the logger."""
    123123        self._logged = False
    124         self._spoilerExtension = None
     124        self._spoilersExtension = None
    125125   
    126126    def check(self, flight, aircraft, logger, oldState, state):
     
    128128        if flight.stage==const.STAGE_LANDING and not self._logged:
    129129            if state.onTheGround:
    130                 if state.spoilerExtension!=self._spoilerExtension:
     130                if state.spoilersExtension!=self._spoilersExtension:
    131131                    logger.message(state.timestamp, "Spoilers deployed")
    132132                    self._logged = True
    133133            else:
    134                 self._spoilerExtension = state.spoilerExtension
     134                self._spoilersExtension = state.spoilersExtension
    135135
    136136#---------------------------------------------------------------------------------------
     
    456456    def logFault(self, flight, aircraft, logger, oldState, state):
    457457        """Log the fault."""
    458         logger.fault(AntiCollisionLightChecker, state.timestamp,
     458        logger.fault(AntiCollisionLightsChecker, state.timestamp,
    459459                     FaultChecker._appendDuring(flight, "Anti-collision lights were off"),
    460460                     1)
     
    486486class FlapsRetractChecker(SimpleFaultChecker):
    487487    """Check if the flaps are not retracted too early."""
     488    def __init__(self):
     489        """Construct the flaps checker."""
     490        self._timeStart = None
     491   
    488492    def isCondition(self, flight, aircraft, oldState, state):
    489493        """Check if the fault condition holds.
     
    497501            if state.flapsSet==0 and state.timestamp<=(self._timeStart+2.0):
    498502                return True
     503        else:
     504            self._timeStart = None
    499505        return False
    500506
     
    542548    def isCondition(self, flight, aircraft, oldState, state):
    543549        """Check if the fault condition holds."""
    544         return state.gearsDown and state.ias>gearSpeedLimit
     550        return state.gearsDown and state.ias>aircraft.gearSpeedLimit
    545551
    546552    def logFault(self, flight, aircraft, logger, oldState, state):
     
    616622            if flight.options.compensation is not None:
    617623                limit += flight.options.compensation
    618             return state.grossWeight>mlw
     624            return self.getWeight(state)>limit
    619625
    620626        return False
     
    622628    def logFault(self, flight, aircraft, logger, oldState, state):
    623629        """Log the fault."""
     630        mname = "M" + self._name
    624631        logger.noGo(self.__class__, state.timestamp,
    625                     "%s exceeded: %.0f kg" % (self._name, state.grossWeight),
    626                     "%s NO GO" % (self._name,))
     632                    "%s exceeded: %s is %.0f kg" % \
     633                    (mname, self._name, self.getWeight(state)),
     634                    "%s NO GO" % (mname,))
     635
     636    def getWeight(self, state):
     637        """Get the weight that is interesting for us."""
     638        return state.grossWeight
    627639
    628640#---------------------------------------------------------------------------------------
     
    632644    def __init__(self):
    633645        """Construct the checker."""
    634         super(MLWChecker, self).__init__("MLW")
    635 
    636     def getLimit(flight, aircraft, state):
     646        super(MLWChecker, self).__init__("LW")
     647
     648    def getLimit(self, flight, aircraft, state):
    637649        """Get the limit if we are in the right state."""
    638650        return aircraft.mlw if flight.stage==const.STAGE_LANDING and \
     
    645657    def __init__(self):
    646658        """Construct the checker."""
    647         super(MTOWChecker, self).__init__("MTOW")
    648 
    649     def getLimit(flight, aircraft, state):
     659        super(MTOWChecker, self).__init__("TOW")
     660
     661    def getLimit(self, flight, aircraft, state):
    650662        """Get the limit if we are in the right state."""
    651663        return aircraft.mtow if flight.stage==const.STAGE_TAKEOFF else None
     
    657669    def __init__(self):
    658670        """Construct the checker."""
    659         super(MZFWChecker, self).__init__("MZFW")
    660 
    661     def getLimit(flight, aircraft, state):
     671        super(MZFWChecker, self).__init__("ZFW")
     672
     673    def getLimit(self, flight, aircraft, state):
    662674        """Get the limit if we are in the right state."""
    663675        return aircraft.mzfw
     676
     677    def getWeight(self, state):
     678        """Get the weight that is interesting for us."""
     679        return state.zfw
    664680
    665681#---------------------------------------------------------------------------------------
     
    725741    def isCondition(self, flight, aircraft, oldState, state):
    726742        """Check if the fault condition holds."""
    727         return state.groundSpeed>80 and not current.pitotHeatOn
     743        return state.groundSpeed>80 and not state.pitotHeatOn
    728744               
    729745    def logFault(self, flight, aircraft, logger, oldState, state):
     
    765781        """Log the fault."""
    766782        logger.fault(SpeedChecker, state.timestamp,
    767                      FaultChecker._appendDuring(flight, "Reverser used below 60 knots"),
     783                     FaultChecker._appendDuring(flight, "Taxi speed over 50 knots"),
    768784                     FaultChecker._getLinearScore(50, 80, 10, 15, state.groundSpeed))
    769785
     
    821837    def logFault(self, flight, aircraft, logger, oldState, state):
    822838        """Log the fault."""
     839        print state.n1
    823840        logger.fault(LandingLightsChecker, state.timestamp,
    824841                     FaultChecker._appendDuring(flight, "Thrust setting was too high (>97%)"),
     
    841858        return vs < -8000 or vs > 8000 or \
    842859               (altitude<500 and vs < (VSChecker.BELOW500 *
    843                                        VSCHECKER.TOLERANCE)) or \
     860                                       VSChecker.TOLERANCE)) or \
    844861               (altitude<2500 and vs < (VSChecker.BELOW2500 *
    845                                         VSCHECKER.TOLERANCE)) or \
     862                                        VSChecker.TOLERANCE)) or \
    846863               (altitude<5000 and vs < (VSChecker.BELOW5000 *
    847                                         VSCHECKER.TOLERANCE)) or \
     864                                        VSChecker.TOLERANCE)) or \
    848865               (altitude<10000 and vs < (VSChecker.BELOW10000 *
    849                                          VSCHECKER.TOLERANCE))
     866                                         VSChecker.TOLERANCE))
    850867               
    851868    def logFault(self, flight, aircraft, logger, oldState, state):
Note: See TracChangeset for help on using the changeset viewer.