Changeset 332:9e73697f6981 for src/mlx
- Timestamp:
- 11/13/12 16:29:19 (12 years ago)
- Branch:
- default
- Phase:
- public
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
src/mlx/checks.py
r329 r332 37 37 This default implementation raises a NotImplementedError.""" 38 38 raise NotImplementedError() 39 39 40 40 #--------------------------------------------------------------------------------------- 41 41 … … 83 83 aircraft.setStage(state, const.STAGE_CRUISE) 84 84 elif stage==const.STAGE_LANDING: 85 if state.onTheGround and state.groundSpeed< 50.0:85 if state.onTheGround and state.groundSpeed<25.0: 86 86 aircraft.setStage(state, const.STAGE_TAXIAFTERLAND) 87 87 elif not state.gearsDown: … … 110 110 ## The interval at which the ACARS are sent 111 111 INTERVAL = 3*60.0 112 112 113 113 def __init__(self, gui): 114 114 """Construct the ACARS sender.""" … … 119 119 """If the time has come to send the ACARS, send it.""" 120 120 now = time.time() 121 121 122 122 if self._lastSent is not None and \ 123 123 (self._lastSent + ACARSSender.INTERVAL)>now: 124 return 124 return 125 125 126 126 acars = ACARS(self._gui, state) … … 135 135 else: 136 136 print "Failed to send the ACARS" 137 137 138 138 #--------------------------------------------------------------------------------------- 139 139 … … 143 143 """Construct the logger.""" 144 144 self._onTheGround = True 145 145 146 146 def check(self, flight, aircraft, logger, oldState, state): 147 147 """Log the cruise speed if necessary.""" … … 156 156 logger.message(state.timestamp, 157 157 "Takeoff pitch: %.1f degrees" % (state.pitch,)) 158 logger.message(state.timestamp, 158 logger.message(state.timestamp, 159 159 "Centre of gravity: %.1f%%" % (state.cog*100.0,)) 160 160 self._onTheGround = False … … 167 167 """Construct the logger.""" 168 168 self._lastTime = None 169 169 170 170 def check(self, flight, aircraft, logger, oldState, state): 171 171 """Log the cruise speed if necessary.""" … … 191 191 self._logged = False 192 192 self._spoilersExtension = None 193 193 194 194 def check(self, flight, aircraft, logger, oldState, state): 195 195 """Log the cruise speed if necessary.""" … … 238 238 It tracks the altitude during the descent and landing phases and 239 239 if the altitude crosses one that has a callout associated with and 240 the vertical speed is negative, that callout will be played.""" 240 the vertical speed is negative, that callout will be played.""" 241 241 def __init__(self, approachCallouts): 242 242 """Construct the approach callouts player.""" … … 273 273 the message to log with the new value 274 274 """ 275 self._logInitial = logInitial 275 self._logInitial = logInitial 276 276 277 277 def _getLogTimestamp(self, state, forced): … … 286 286 else: 287 287 shouldLog = self._changed(oldState, state) 288 288 289 289 if shouldLog: 290 290 self.logState(flight, logger, state) … … 295 295 if message is not None: 296 296 logger.message(self._getLogTimestamp(state, forced), message) 297 297 298 298 #------------------------------------------------------------------------------- 299 299 … … 321 321 """Get the value of the attribute from the state.""" 322 322 return getattr(state, self._attrName) 323 323 324 324 #--------------------------------------------------------------------------------------- 325 325 … … 337 337 self._firstChange = None 338 338 self._lastChangeState = None 339 339 340 340 def _changed(self, oldState, state): 341 341 """Determine if the value has changed.""" 342 342 if self._oldValue is None: 343 343 self._oldValue = self._getValue(oldState) 344 344 345 345 newValue = self._getValue(state) 346 346 if self._isDifferent(self._oldValue, newValue): … … 356 356 self._firstChange = None 357 357 return True 358 358 359 359 return False 360 360 … … 384 384 def _getMessage(self, flight, state, forced): 385 385 """Get the message.""" 386 value = self._getValue(state) 386 value = self._getValue(state) 387 387 return None if value is None else self._template % (value,) 388 388 … … 433 433 self._logState(flight, logger, state, forced) 434 434 self._lastLoggedState = state 435 435 436 436 def _changed(self, oldState, state): 437 437 """Check if the state has changed. … … 476 476 if obs is not None: message += u" (%d\u00b0)" % (obs,) 477 477 return message 478 478 479 479 def __init__(self, attrName, logName): 480 480 """Construct the NAV logger.""" … … 593 593 StateChangeLogger.__init__(self) 594 594 SingleValueMixin.__init__(self, attrName) 595 595 596 596 self._template = template 597 597 … … 599 599 """Get the message from the given state.""" 600 600 return self._template % ("ON" if self._getValue(state) else "OFF") 601 601 602 602 #--------------------------------------------------------------------------------------- 603 603 … … 741 741 else: 742 742 self._faultStarted = None 743 743 744 744 #--------------------------------------------------------------------------------------- 745 745 … … 775 775 """Check for the anti-collision light for Tuplev planes.""" 776 776 def isCondition(self, flight, aircraft, oldState, state): 777 """Check if the fault condition holds.""" 777 """Check if the fault condition holds.""" 778 778 numEnginesRunning = 0 779 779 for n1 in state.n1: 780 780 if n1>5: numEnginesRunning += 1 781 781 782 782 if flight.stage==const.STAGE_PARKING: 783 783 return numEnginesRunning<len(state.n1) \ … … 816 816 """Construct the flaps checker.""" 817 817 self._timeStart = None 818 818 819 819 def isCondition(self, flight, aircraft, oldState, state): 820 820 """Check if the fault condition holds. … … 891 891 return state.gLoad>2.0 and (flight.stage!=const.STAGE_LANDING or \ 892 892 state.radioAltitude>=50) 893 893 894 894 def logFault(self, flight, aircraft, logger, oldState, state): 895 895 """Log the fault.""" … … 923 923 (flight.stage==const.STAGE_PARKING and \ 924 924 state.landingLightsOn and state.onTheGround)) 925 925 926 926 def logFault(self, flight, aircraft, logger, oldState, state): 927 927 """Log the fault.""" … … 930 930 flight.handleFault(LandingLightsChecker, state.timestamp, 931 931 FaultChecker._appendDuring(flight, message), 932 score) 932 score) 933 933 934 934 #--------------------------------------------------------------------------------------- … … 1018 1018 flight.stage!=const.STAGE_PARKING and \ 1019 1019 not state.navLightsOn 1020 1020 1021 1021 def logFault(self, flight, aircraft, logger, oldState, state): 1022 1022 """Log the fault.""" … … 1037 1037 """Check if the fault condition holds.""" 1038 1038 return state.overspeed 1039 1039 1040 1040 def logFault(self, flight, aircraft, logger, oldState, state): 1041 1041 """Log the fault.""" 1042 1042 flight.handleFault(OverspeedChecker, state.timestamp, 1043 1043 FaultChecker._appendDuring(flight, "Overspeed"), 1044 20) 1044 20) 1045 1045 1046 1046 #--------------------------------------------------------------------------------------- … … 1054 1054 """Check if the given aircraft's ZFW is outside of the limits.""" 1055 1055 return aircraftZFW < (flightZFW - PayloadChecker.TOLERANCE) or \ 1056 aircraftZFW > (flightZFW + PayloadChecker.TOLERANCE) 1057 1056 aircraftZFW > (flightZFW + PayloadChecker.TOLERANCE) 1057 1058 1058 def isCondition(self, flight, aircraft, oldState, state): 1059 1059 """Check if the fault condition holds.""" … … 1061 1061 flight.stage==const.STAGE_PUSHANDTAXI and \ 1062 1062 PayloadChecker.isZFWFaulty(state.zfw, flight.zfw) 1063 1063 1064 1064 def logFault(self, flight, aircraft, logger, oldState, state): 1065 1065 """Log the fault.""" … … 1080 1080 """Check if the fault condition holds.""" 1081 1081 return state.groundSpeed>80 and not state.pitotHeatOn 1082 1082 1083 1083 def logFault(self, flight, aircraft, logger, oldState, state): 1084 1084 """Log the fault.""" … … 1088 1088 flight.handleFault(PitotChecker, state.timestamp, 1089 1089 FaultChecker._appendDuring(flight, "Pitot heat was off"), 1090 score) 1090 score) 1091 1091 1092 1092 #--------------------------------------------------------------------------------------- … … 1099 1099 const.STAGE_TAXIAFTERLAND] and \ 1100 1100 state.groundSpeed<60 and max(state.reverser) 1101 1101 1102 1102 def logFault(self, flight, aircraft, logger, oldState, state): 1103 1103 """Log the fault.""" … … 1117 1117 const.STAGE_TAXIAFTERLAND] and \ 1118 1118 state.groundSpeed>50 1119 1119 1120 1120 def logFault(self, flight, aircraft, logger, oldState, state): 1121 1121 """Log the fault.""" … … 1136 1136 const.STAGE_CRUISE, const.STAGE_DESCENT, 1137 1137 const.STAGE_LANDING] and state.stalled 1138 1138 1139 1139 def logFault(self, flight, aircraft, logger, oldState, state): 1140 1140 """Log the fault.""" … … 1143 1143 flight.handleFault(StallChecker, state.timestamp, 1144 1144 FaultChecker._appendDuring(flight, "Stalled"), 1145 score) 1145 score) 1146 1146 1147 1147 #--------------------------------------------------------------------------------------- … … 1160 1160 (flight.stage==const.STAGE_PARKING and \ 1161 1161 state.strobeLightsOn and state.onTheGround) 1162 1162 1163 1163 def logFault(self, flight, aircraft, logger, oldState, state): 1164 1164 """Log the fault.""" … … 1178 1178 return flight.stage==const.STAGE_TAKEOFF and \ 1179 1179 state.n1 is not None and max(state.n1)>97 1180 1180 1181 1181 def logFault(self, flight, aircraft, logger, oldState, state): 1182 1182 """Log the fault.""" … … 1209 1209 (altitude<10000 and vs < (VSChecker.BELOW10000 * 1210 1210 VSChecker.TOLERANCE)) 1211 1211 1212 1212 def logFault(self, flight, aircraft, logger, oldState, state): 1213 1213 """Log the fault."""
Note:
See TracChangeset
for help on using the changeset viewer.