Changeset 211:fbd8dad0b6be


Ignore:
Timestamp:
05/31/12 15:37:24 (12 years ago)
Author:
István Váradi <ivaradi@…>
Branch:
default
Phase:
public
Message:

Reorganized the lights loggin and checks a bit

Location:
src/mlx
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • src/mlx/acft.py

    r210 r211  
    7373        self._checkers.append(checks.SquawkLogger())
    7474
    75         self._checkers.append(checks.AnticollisionLightsLogger())
    76         self._checkers.append(checks.LandingLightsLogger())
    77         self._checkers.append(checks.StrobeLightsLogger())
    78         self._checkers.append(checks.NavLightsLogger())
     75        self._appendLightsLoggers()
    7976
    8077        self._checkers.append(checks.FlapsLogger())
     
    9693
    9794        # Fault checkers
    98        
    99         self._checkers.append(checks.AntiCollisionLightsChecker())
    100         self._checkers.append(checks.LandingLightsChecker())
    101         self._checkers.append(checks.NavLightsChecker())
    102         self._checkers.append(checks.StrobeLightsChecker())
     95
     96        self._appendLightsCheckers()
    10397
    10498        self._checkers.append(checks.BankChecker())
     
    314308            self._logV1R2()
    315309
     310    def _appendLightsLoggers(self):
     311        """Append the loggers needed for the lights.
     312
     313        This default implementation adds the loggers for the anti-collision
     314        lights, the landing lights, the strobe lights and the NAV lights."""
     315        self._checkers.append(checks.AnticollisionLightsLogger())
     316        self._checkers.append(checks.LandingLightsLogger())
     317        self._checkers.append(checks.StrobeLightsLogger())
     318        self._checkers.append(checks.NavLightsLogger())
     319
     320    def _appendLightsCheckers(self):
     321        """Append the checkers needed for the lights.
     322
     323        This default implementation adds the checkers for the anti-collision
     324        lights, the landing lights, the strobe lights and the NAV lights."""
     325        self._checkers.append(checks.AntiCollisionLightsChecker())
     326        self._checkers.append(checks.LandingLightsChecker())
     327        self._checkers.append(checks.NavLightsChecker())
     328        self._checkers.append(checks.StrobeLightsChecker())
     329
    316330    def _logV1R2(self):
    317331        """Log the V1, Vr and V2 value either newly, or by updating the
     
    706720                            "Total fuel: %.0f kg" % (sum(aircraftState.fuel),))
    707721                           
     722    def _appendLightsLoggers(self):
     723        """Append the loggers needed for the lights."""
     724        self._checkers.append(checks.AnticollisionLightsLogger())
     725        self._checkers.append(checks.LandingLightsLogger())
     726        self._checkers.append(checks.NavLightsLogger())
     727
     728    def _appendLightsCheckers(self):
     729        """Append the checkers needed for the lights."""
     730        self._checkers.append(checks.TupolevAntiCollisionLightsChecker())
     731        self._checkers.append(checks.LandingLightsChecker())
     732        self._checkers.append(checks.NavLightsChecker())
     733
    708734#---------------------------------------------------------------------------------------
    709735
     
    741767                            "Total fuel: %.0f kg" % (sum(aircraftState.fuel),))
    742768
     769    def _appendLightsLoggers(self):
     770        """Append the loggers needed for the lights."""
     771        self._checkers.append(checks.AnticollisionLightsLogger())
     772        self._checkers.append(checks.LandingLightsLogger())
     773        self._checkers.append(checks.NavLightsLogger())
     774
     775    def _appendLightsCheckers(self):
     776        """Append the checkers needed for the lights."""
     777        self._checkers.append(checks.TupolevAntiCollisionLightsChecker())
     778        self._checkers.append(checks.LandingLightsChecker())
     779        self._checkers.append(checks.NavLightsChecker())
     780
    743781#---------------------------------------------------------------------------------------
    744782
     
    772810        self.logger.message(aircraftState.timestamp,
    773811                            "Total fuel: %.0f kg" % (sum(aircraftState.fuel),))
     812
     813    def _appendLightsLoggers(self):
     814        """Append the loggers needed for the lights."""
     815        self._checkers.append(checks.AnticollisionLightsLogger())
     816        self._checkers.append(checks.LandingLightsLogger())
     817        self._checkers.append(checks.NavLightsLogger())
     818
     819    def _appendLightsCheckers(self):
     820        """Append the checkers needed for the lights."""
     821        self._checkers.append(checks.AntiCollisionLightsChecker())
     822        self._checkers.append(checks.LandingLightsChecker())
     823        self._checkers.append(checks.NavLightsChecker())
    774824
    775825#---------------------------------------------------------------------------------------
  • 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):
  • src/mlx/pyuipc_sim.py

    r209 r211  
    118118
    119119    # Fuel data index: right tip tank
    120     FUEL_RIGHT_AUX = 6
     120    FUEL_RIGHT_TIP = 6
    121121
    122122    # Fuel data index: external 1 tank
     
    186186        self.aircraftName = "Cessna 172SP"
    187187        self.flapsNotches = [0, 1, 2, 5, 10, 15, 25, 30, 40]
    188         self.fuelCapacities = [10000.0, 5000.0, 5000.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0]
     188        self.fuelCapacities = [10000.0, 5000.0, 5000.0, 5000.0, 5000.0,
     189                               5000.0, 5000.0, 5000.0, 5000.0, 5000.0]
    189190
    190191        self.latitude = 47.5
Note: See TracChangeset for help on using the changeset viewer.