Changeset 30:b8f08115af4c for src


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

Fault messages are routed through the Flight object

Location:
src/mlx
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • src/mlx/checks.py

    r27 r30  
    486486    def logFault(self, flight, aircraft, logger, oldState, state):
    487487        """Log the fault."""
    488         logger.fault(AntiCollisionLightsChecker, state.timestamp,
    489                      FaultChecker._appendDuring(flight, "Anti-collision lights were off"),
    490                      1)
     488        flight.handleFault(AntiCollisionLightsChecker, state.timestamp,
     489                           FaultChecker._appendDuring(flight,
     490                                                      "Anti-collision lights were off"),
     491                           1)
    491492
    492493#---------------------------------------------------------------------------------------
     
    508509    def logFault(self, flight, aircraft, logger, oldState, state):
    509510        """Log the fault."""
    510         logger.fault(BankChecker, state.timestamp,
    511                      FaultChecker._appendDuring(flight, "Bank too steep"),
    512                      2)
     511        flight.handleFault(BankChecker, state.timestamp,
     512                           FaultChecker._appendDuring(flight, "Bank too steep"),
     513                           2)
    513514
    514515#---------------------------------------------------------------------------------------
     
    537538    def logFault(self, flight, aircraft, logger, oldState, state):
    538539        """Log the fault."""
    539         logger.fault(FlapsRetractChecker, state.timestamp,
    540                      FaultChecker._appendDuring(flight, "Flaps retracted"),
    541                      20)
     540        flight.handleFault(FlapsRetractChecker, state.timestamp,
     541                           FaultChecker._appendDuring(flight, "Flaps retracted"),
     542                           20)
    542543
    543544#---------------------------------------------------------------------------------------
     
    552553    def logFault(self, flight, aircraft, logger, oldState, state):
    553554        """Log the fault."""
    554         logger.fault(FlapsSpeedLimitChecker, state.timestamp,
    555                      FaultChecker._appendDuring(flight, "Flap speed limit fault"),
    556                      5)
     555        flight.handleFault(FlapsSpeedLimitChecker, state.timestamp,
     556                           FaultChecker._appendDuring(flight, "Flap speed limit fault"),
     557                           5)
    557558
    558559#---------------------------------------------------------------------------------------
     
    567568    def logFault(self, flight, aircraft, logger, oldState, state):
    568569        """Log the fault."""
    569         logger.noGo(GearsDownChecker, state.timestamp,
    570                     "Gears not down at %.0f feet radio altitude" % \
    571                     (state.radioAltitude,),
    572                     "GEAR DOWN NO GO")
     570        flight.handleNoGo(GearsDownChecker, state.timestamp,
     571                          "Gears not down at %.0f feet radio altitude" % \
     572                          (state.radioAltitude,),
     573                          "GEAR DOWN NO GO")
    573574
    574575#---------------------------------------------------------------------------------------
     
    582583    def logFault(self, flight, aircraft, logger, oldState, state):
    583584        """Log the fault."""
    584         logger.fault(GearSpeedLimitChecker, state.timestamp,
    585                      FaultChecker._appendDuring(flight, "Gear speed limit fault"),
    586                      5)
     585        flight.handleFault(GearSpeedLimitChecker, state.timestamp,
     586                           FaultChecker._appendDuring(flight, "Gear speed limit fault"),
     587                           5)
    587588
    588589#---------------------------------------------------------------------------------------
     
    597598    def logFault(self, flight, aircraft, logger, oldState, state):
    598599        """Log the fault."""
    599         logger.fault(GLoadChecker, state.timestamp,
    600                      "G-load was %.2f" % (state.gLoad,),
    601                      10)
     600        flight.handleFault(GLoadChecker, state.timestamp,
     601                           "G-load was %.2f" % (state.gLoad,),
     602                           10)
    602603
    603604#---------------------------------------------------------------------------------------
     
    630631        score = 0 if flight.stage==const.STAGE_LANDING else 1
    631632        message = "Landing lights were %s" % (("on" if state.landingLightsOn else "off"),)
    632         logger.fault(LandingLightsChecker, state.timestamp,
    633                      FaultChecker._appendDuring(flight, message),
    634                      score)        
     633        flight.handleFault(LandingLightsChecker, state.timestamp,
     634                           FaultChecker._appendDuring(flight, message),
     635                           score)   
    635636
    636637#---------------------------------------------------------------------------------------
     
    659660        """Log the fault."""
    660661        mname = "M" + self._name
    661         logger.noGo(self.__class__, state.timestamp,
    662                     "%s exceeded: %s is %.0f kg" % \
    663                     (mname, self._name, self.getWeight(state)),
    664                     "%s NO GO" % (mname,))
     662        flight.handleNoGo(self.__class__, state.timestamp,
     663                          "%s exceeded: %s is %.0f kg" % \
     664                                    (mname, self._name, self.getWeight(state)),
     665                          "%s NO GO" % (mname,))
    665666
    666667    def getWeight(self, state):
     
    721722    def logFault(self, flight, aircraft, logger, oldState, state):
    722723        """Log the fault."""
    723         logger.fault(NavLightsChecker, state.timestamp,
    724                      FaultChecker._appendDuring(flight, "Navigation lights were off"),
    725                      1)       
     724        flight.handleFault(NavLightsChecker, state.timestamp,
     725                           FaultChecker._appendDuring(flight,
     726                                                      "Navigation lights were off"),
     727                           1)
    726728
    727729#---------------------------------------------------------------------------------------
     
    739741    def logFault(self, flight, aircraft, logger, oldState, state):
    740742        """Log the fault."""
    741         logger.fault(OverspeedChecker, state.timestamp,
    742                      FaultChecker._appendDuring(flight, "Overspeed"),
    743                      20)       
     743        flight.handleFault(OverspeedChecker, state.timestamp,
     744                           FaultChecker._appendDuring(flight, "Overspeed"),
     745                           20)       
    744746
    745747#---------------------------------------------------------------------------------------
     
    757759    def logFault(self, flight, aircraft, logger, oldState, state):
    758760        """Log the fault."""
    759         logger.noGo(PayloadChecker, state.timestamp,
    760                     "ZFW difference is more than %d kgs" % (PayloadChecker.TOLERANCE,),
    761                     "ZFW NO GO")
     761        flight.handleNoGo(PayloadChecker, state.timestamp,
     762                          "ZFW difference is more than %d kgs" % \
     763                          (PayloadChecker.TOLERANCE,),
     764                          "ZFW NO GO")
    762765
    763766#---------------------------------------------------------------------------------------
     
    778781                                      const.STAGE_CRUISE, const.STAGE_DESCENT,
    779782                                      const.STAGE_LANDING] else 0
    780         logger.fault(PitotChecker, state.timestamp,
    781                      FaultChecker._appendDuring(flight, "Pitot heat was off"),
    782                      score)        
     783        flight.handleFault(PitotChecker, state.timestamp,
     784                           FaultChecker._appendDuring(flight, "Pitot heat was off"),
     785                           score)   
    783786
    784787#---------------------------------------------------------------------------------------
     
    794797    def logFault(self, flight, aircraft, logger, oldState, state):
    795798        """Log the fault."""
    796         logger.fault(ReverserChecker, state.timestamp,
    797                      FaultChecker._appendDuring(flight, "Reverser used below 60 knots"),
    798                      15)       
     799        flight.handleFault(ReverserChecker, state.timestamp,
     800                           FaultChecker._appendDuring(flight,
     801                                                      "Reverser used below 60 knots"),
     802                           15)       
    799803
    800804#---------------------------------------------------------------------------------------
     
    810814    def logFault(self, flight, aircraft, logger, oldState, state):
    811815        """Log the fault."""
    812         logger.fault(SpeedChecker, state.timestamp,
    813                      FaultChecker._appendDuring(flight, "Taxi speed over 50 knots"),
    814                      FaultChecker._getLinearScore(50, 80, 10, 15, state.groundSpeed))
     816        flight.handleFault(SpeedChecker, state.timestamp,
     817                           FaultChecker._appendDuring(flight,
     818                                                      "Taxi speed over 50 knots"),
     819                           FaultChecker._getLinearScore(50, 80, 10, 15,
     820                                                        state.groundSpeed))
    815821
    816822#---------------------------------------------------------------------------------------
     
    828834        score = 40 if flight.stage in [const.STAGE_TAKEOFF,
    829835                                       const.STAGE_LANDING] else 30
    830         logger.fault(StallChecker, state.timestamp,
    831                      FaultChecker._appendDuring(flight, "Stalled"),
    832                      score)        
     836        flight.handleFault(StallChecker, state.timestamp,
     837                           FaultChecker._appendDuring(flight, "Stalled"),
     838                           score)   
    833839
    834840#---------------------------------------------------------------------------------------
     
    856862        """Log the fault."""
    857863        message = "Strobe lights were %s" % (("on" if state.strobeLightsOn else "off"),)
    858         logger.fault(StrobeLightsChecker, state.timestamp,
    859                      FaultChecker._appendDuring(flight, message),
    860                      1)       
     864        flight.handleFault(StrobeLightsChecker, state.timestamp,
     865                           FaultChecker._appendDuring(flight, message),
     866                           1)
    861867
    862868#---------------------------------------------------------------------------------------
     
    873879        """Log the fault."""
    874880        print state.n1
    875         logger.fault(ThrustChecker, state.timestamp,
    876                      FaultChecker._appendDuring(flight, "Thrust setting was too high (>97%)"),
    877                      FaultChecker._getLinearScore(97, 110, 0, 10, max(state.n1)))
     881        flight.handleFault(ThrustChecker, state.timestamp,
     882                           FaultChecker._appendDuring(flight,
     883                                                      "Thrust setting was too high (>97%)"),
     884                           FaultChecker._getLinearScore(97, 110, 0, 10, max(state.n1)))
    878885
    879886#---------------------------------------------------------------------------------------
     
    911918        score = 10 if vs<-8000 or vs>8000 else 0
    912919
    913         logger.fault(VSChecker, state.timestamp,
    914                      FaultChecker._appendDuring(flight, message),
    915                      score)
    916 
    917 #---------------------------------------------------------------------------------------
     920        flight.handleFault(VSChecker, state.timestamp,
     921                           FaultChecker._appendDuring(flight, message),
     922                           score)
     923
     924#---------------------------------------------------------------------------------------
  • src/mlx/flight.py

    r29 r30  
    6464            return False
    6565
     66    def handleFault(self, faultID, timestamp, what, score):
     67        """Handle the given fault.
     68
     69        faultID as a unique ID for the given kind of fault. If another fault of
     70        this ID has been reported earlier, it will be reported again only if
     71        the score is greater than last time. This ID can be, e.g. the checker
     72        the report comes from."""
     73        self.logger.fault(faultID, timestamp, what, score)
     74
     75    def handleNoGo(self, faultID, timestamp, what, shortReason):
     76        """Handle a No-Go fault."""
     77        self.logger.noGo(faultID, timestamp, what)
     78
    6679    def flareStarted(self, flareStart, flareStartFS):
    6780        """Called when the flare time has started."""
  • src/mlx/gui/gui.py

    r29 r30  
    156156        if self._connectButton.get_active():
    157157            self._logger.reset()
    158             self._flight = flight.Flight(self._logger)
     158            self._flight = flight.Flight(self._logger, self)
    159159
    160160            acftListModel = self._acftList.get_model()
  • src/mlx/logger.py

    r27 r30  
    2525                const.STAGE_GOAROUND : "Go-Around",
    2626                const.STAGE_END : "End" }
    27 
    28     _noGoScore = 10000
     27   
     28    NO_GO_SCORE = 10000
    2929
    3030    def __init__(self, output = sys.stdout):
     
    8181                return
    8282        self._faults[faultID] = score
    83         if score==Logger._noGoScore:
     83        if score==Logger.NO_GO_SCORE:
    8484            self.message(timestamp, "%s (NO GO)" % (what))
    8585        else:
    8686            self.message(timestamp, "%s (%.1f)" % (what, score))
    8787
    88     def noGo(self, faultID, timestamp, what, shortReason):
     88    def noGo(self, faultID, timestamp, what):
    8989        """Report a No-Go fault."""
    90         self.fault(faultID, timestamp, what, Logger._noGoScore)
     90        self.fault(faultID, timestamp, what, Logger.NO_GO_SCORE)
    9191
     92    def getScore(self):
     93        """Get the score of the flight so far."""
     94        totalScore = 100
     95        for (id, score) in self._faults.iteritems():
     96            if score==Logger.NO_GO_SCORE:
     97                return -score
     98            else:
     99                totalScore -= score
     100        return totalScore
     101       
    92102#--------------------------------------------------------------------------------------
Note: See TracChangeset for help on using the changeset viewer.