Ignore:
Timestamp:
05/31/12 15:37:24 (12 years ago)
Author:
István Váradi <ivaradi@…>
Branch:
default
hg-Phase:
(<MercurialRepository 1 'hg:/home/ivaradi/mlx/hg' '/'>, 'public')
Message:

Reorganized the lights loggin and checks a bit

File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/mlx/checks.py

    r209 r211  
    547547    def isCondition(self, flight, aircraft, oldState, state):
    548548        """Check if the fault condition holds."""
    549         isTupolev = aircraft.type in [const.AIRCRAFT_T134,
    550                                       const.AIRCRAFT_T154]
    551549        return (flight.stage!=const.STAGE_PARKING or \
    552550                not flight.config.usingFS2Crew) and \
    553551                not state.antiCollisionLightsOn and \
    554                 ((isTupolev and max(state.n1[1:])>5) or \
    555                  (not isTupolev and max(state.n1)>5))
     552                self.isEngineCondition(state)
    556553
    557554    def logFault(self, flight, aircraft, logger, oldState, state):
     
    561558                                                      "Anti-collision lights were off"),
    562559                           1)
     560
     561    def isEngineCondition(self, state):
     562        """Determine if the engines are in such a state that the lights should
     563        be on."""
     564        return max(state.n1)>5
     565
     566#---------------------------------------------------------------------------------------
     567
     568class TupolevAntiCollisionLightsChecker(AntiCollisionLightsChecker):
     569    """Check for the anti-collision light for Tuplev planes."""
     570
     571    def isEngineCondition(self, state):
     572        """Determine if the engines are in such a state that the lights should
     573        be on."""
     574        return max(state.n1[1:])>5
     575   
    563576
    564577#---------------------------------------------------------------------------------------
     
    923936    def isCondition(self, flight, aircraft, oldState, state):
    924937        """Check if the fault condition holds."""
    925         if aircraft.type in [const.AIRCRAFT_T134,
    926                              const.AIRCRAFT_T154,
    927                              const.AIRCRAFT_YK40]:
    928             return False
    929         else:
    930             return (flight.stage==const.STAGE_BOARDING and \
    931                     state.strobeLightsOn and state.onTheGround) or \
    932                    (flight.stage==const.STAGE_TAKEOFF and \
    933                     not state.strobeLightsOn and not state.gearsDown) or \
    934                    (flight.stage in [const.STAGE_CLIMB, const.STAGE_CRUISE,
    935                                      const.STAGE_DESCENT] and \
    936                    not state.strobeLightsOn and not state.onTheGround) or \
    937                    (flight.stage==const.STAGE_PARKING and \
    938                     state.strobeLightsOn and state.onTheGround)
     938        return (flight.stage==const.STAGE_BOARDING and \
     939                state.strobeLightsOn and state.onTheGround) or \
     940                (flight.stage==const.STAGE_TAKEOFF and \
     941                 not state.strobeLightsOn and not state.gearsDown) or \
     942                 (flight.stage in [const.STAGE_CLIMB, const.STAGE_CRUISE,
     943                                   const.STAGE_DESCENT] and \
     944                  not state.strobeLightsOn and not state.onTheGround) or \
     945                  (flight.stage==const.STAGE_PARKING and \
     946                   state.strobeLightsOn and state.onTheGround)
    939947               
    940948    def logFault(self, flight, aircraft, logger, oldState, state):
Note: See TracChangeset for help on using the changeset viewer.