Changeset 30:b8f08115af4c for src/mlx
- Timestamp:
- 02/25/12 13:55:56 (13 years ago)
- Branch:
- default
- Phase:
- public
- Location:
- src/mlx
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
src/mlx/checks.py
r27 r30 486 486 def logFault(self, flight, aircraft, logger, oldState, state): 487 487 """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) 491 492 492 493 #--------------------------------------------------------------------------------------- … … 508 509 def logFault(self, flight, aircraft, logger, oldState, state): 509 510 """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) 513 514 514 515 #--------------------------------------------------------------------------------------- … … 537 538 def logFault(self, flight, aircraft, logger, oldState, state): 538 539 """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) 542 543 543 544 #--------------------------------------------------------------------------------------- … … 552 553 def logFault(self, flight, aircraft, logger, oldState, state): 553 554 """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) 557 558 558 559 #--------------------------------------------------------------------------------------- … … 567 568 def logFault(self, flight, aircraft, logger, oldState, state): 568 569 """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") 573 574 574 575 #--------------------------------------------------------------------------------------- … … 582 583 def logFault(self, flight, aircraft, logger, oldState, state): 583 584 """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) 587 588 588 589 #--------------------------------------------------------------------------------------- … … 597 598 def logFault(self, flight, aircraft, logger, oldState, state): 598 599 """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) 602 603 603 604 #--------------------------------------------------------------------------------------- … … 630 631 score = 0 if flight.stage==const.STAGE_LANDING else 1 631 632 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) 635 636 636 637 #--------------------------------------------------------------------------------------- … … 659 660 """Log the fault.""" 660 661 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,)) 665 666 666 667 def getWeight(self, state): … … 721 722 def logFault(self, flight, aircraft, logger, oldState, state): 722 723 """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) 726 728 727 729 #--------------------------------------------------------------------------------------- … … 739 741 def logFault(self, flight, aircraft, logger, oldState, state): 740 742 """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) 744 746 745 747 #--------------------------------------------------------------------------------------- … … 757 759 def logFault(self, flight, aircraft, logger, oldState, state): 758 760 """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") 762 765 763 766 #--------------------------------------------------------------------------------------- … … 778 781 const.STAGE_CRUISE, const.STAGE_DESCENT, 779 782 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) 783 786 784 787 #--------------------------------------------------------------------------------------- … … 794 797 def logFault(self, flight, aircraft, logger, oldState, state): 795 798 """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) 799 803 800 804 #--------------------------------------------------------------------------------------- … … 810 814 def logFault(self, flight, aircraft, logger, oldState, state): 811 815 """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)) 815 821 816 822 #--------------------------------------------------------------------------------------- … … 828 834 score = 40 if flight.stage in [const.STAGE_TAKEOFF, 829 835 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) 833 839 834 840 #--------------------------------------------------------------------------------------- … … 856 862 """Log the fault.""" 857 863 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) 861 867 862 868 #--------------------------------------------------------------------------------------- … … 873 879 """Log the fault.""" 874 880 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))) 878 885 879 886 #--------------------------------------------------------------------------------------- … … 911 918 score = 10 if vs<-8000 or vs>8000 else 0 912 919 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 64 64 return False 65 65 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 66 79 def flareStarted(self, flareStart, flareStartFS): 67 80 """Called when the flare time has started.""" -
src/mlx/gui/gui.py
r29 r30 156 156 if self._connectButton.get_active(): 157 157 self._logger.reset() 158 self._flight = flight.Flight(self._logger )158 self._flight = flight.Flight(self._logger, self) 159 159 160 160 acftListModel = self._acftList.get_model() -
src/mlx/logger.py
r27 r30 25 25 const.STAGE_GOAROUND : "Go-Around", 26 26 const.STAGE_END : "End" } 27 28 _noGoScore= 1000027 28 NO_GO_SCORE = 10000 29 29 30 30 def __init__(self, output = sys.stdout): … … 81 81 return 82 82 self._faults[faultID] = score 83 if score==Logger. _noGoScore:83 if score==Logger.NO_GO_SCORE: 84 84 self.message(timestamp, "%s (NO GO)" % (what)) 85 85 else: 86 86 self.message(timestamp, "%s (%.1f)" % (what, score)) 87 87 88 def noGo(self, faultID, timestamp, what , shortReason):88 def noGo(self, faultID, timestamp, what): 89 89 """Report a No-Go fault.""" 90 self.fault(faultID, timestamp, what, Logger. _noGoScore)90 self.fault(faultID, timestamp, what, Logger.NO_GO_SCORE) 91 91 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 92 102 #--------------------------------------------------------------------------------------
Note:
See TracChangeset
for help on using the changeset viewer.