Changeset 622:21bb632b0961 for src/mlx
- Timestamp:
- 04/04/15 09:26:49 (10 years ago)
- Branch:
- default
- Phase:
- public
- Location:
- src/mlx
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
src/mlx/acft.py
r619 r622 194 194 195 195 timeout = 30.0 + config.realIASSmoothingLength - 1 196 self._checkers.append(checks.OverspeedChecker( timeout = timeout))196 self._checkers.append(checks.OverspeedChecker(faultTimeout = timeout)) 197 197 198 198 self._checkers.append(checks.StallChecker()) -
src/mlx/checks.py
r611 r622 1292 1292 #--------------------------------------------------------------------------------------- 1293 1293 1294 class OverspeedChecker(PatientFaultChecker): 1294 class WindSensitiveFaultChecker(FaultChecker): 1295 """A fault checker which checks for a fault condition that might arise due 1296 to suddenly changing winds. 1297 1298 If the condition is detected, its fact is logged, and the winds are also 1299 logged repeatedly until and for a while after the condition has ceased. A 1300 fault is logged only if the condition holds for a certain period of 1301 time.""" 1302 # The time the winds were logged last. This is global to avoid duplicate 1303 # logging if several wind-sensitive fault conditions gold 1304 _windsLastLogged = None 1305 1306 # The wind logging interval 1307 _windsLogInterval = 5.0 1308 1309 def __init__(self, faultTimeout = 30.0, afterLoggingTime = 20.0): 1310 """Construct the fault checker.""" 1311 self._faultTimeout = faultTimeout 1312 self._afterLoggingTime = afterLoggingTime 1313 1314 self._faultStarted = None 1315 self._faultCeased = None 1316 1317 def check(self, flight, aircraft, logger, oldState, state): 1318 """Check for the condition and do whatever is needed.""" 1319 timestamp = state.timestamp 1320 logWinds = False 1321 1322 if self.isCondition(flight, aircraft, oldState, state): 1323 logWinds = True 1324 if self._faultStarted is None: 1325 self._faultStarted = timestamp 1326 self._faultCeased = None 1327 self.logCondition(flight, aircraft, logger, oldState, state, 1328 False) 1329 1330 WindSensitiveFaultChecker._windsLastLogged = None 1331 1332 elif timestamp >= (self._faultStarted + self._faultTimeout): 1333 self.logCondition(flight, aircraft, logger, oldState, state, 1334 True) 1335 self._faultStarted = timestamp 1336 1337 else: 1338 if self._faultStarted is not None and self._faultCeased is None: 1339 self._faultCeased = timestamp 1340 self._faultStarted = None 1341 1342 if self._faultCeased is not None: 1343 if timestamp < (self._faultCeased + self._afterLoggingTime): 1344 logWinds = True 1345 else: 1346 self._faultCeased = None 1347 1348 if logWinds and \ 1349 (WindSensitiveFaultChecker._windsLastLogged is None or 1350 timestamp >= (WindSensitiveFaultChecker._windsLastLogged + 1351 self._windsLogInterval)): 1352 logger.message(timestamp, "Winds: %.f knots from %.f" % 1353 (state.windSpeed, state.windDirection)) 1354 WindSensitiveFaultChecker._windsLastLogged = timestamp 1355 1356 #--------------------------------------------------------------------------------------- 1357 1358 class OverspeedChecker(WindSensitiveFaultChecker): 1295 1359 """Check if Vne has been exceeded.""" 1296 def __init__(self, timeout = 30.0):1297 """Construct the checker."""1298 super(OverspeedChecker, self).__init__(timeout = timeout)1299 1300 1360 def isCondition(self, flight, aircraft, oldState, state): 1301 1361 """Check if the fault condition holds.""" 1302 1362 return state.overspeed 1303 1363 1304 def logFault(self, flight, aircraft, logger, oldState, state): 1305 """Log the fault.""" 1306 flight.handleFault(OverspeedChecker, state.timestamp, 1307 FaultChecker._appendDuring(flight, "Overspeed"), 1308 20) 1364 def logCondition(self, flight, aircraft, logger, oldState, state, isFault): 1365 """Log the condition fault.""" 1366 if isFault: 1367 flight.handleFault(OverspeedChecker, state.timestamp, 1368 FaultChecker._appendDuring(flight, "Overspeed"), 1369 20) 1370 else: 1371 logger.message(state.timestamp, 1372 FaultChecker._appendDuring(flight, "Overspeed")) 1373 1374 #--------------------------------------------------------------------------------------- 1375 1376 class StallChecker(WindSensitiveFaultChecker): 1377 """Check if stall occured.""" 1378 def isCondition(self, flight, aircraft, oldState, state): 1379 """Check if the fault condition holds.""" 1380 return flight.stage in [const.STAGE_TAKEOFF, const.STAGE_CLIMB, 1381 const.STAGE_CRUISE, const.STAGE_DESCENT, 1382 const.STAGE_LANDING] and state.stalled 1383 1384 def logCondition(self, flight, aircraft, logger, oldState, state, isFault): 1385 """Log the condition.""" 1386 if isFault: 1387 score = 40 if flight.stage in [const.STAGE_TAKEOFF, 1388 const.STAGE_LANDING] else 30 1389 flight.handleFault(StallChecker, state.timestamp, 1390 FaultChecker._appendDuring(flight, "Stalled"), 1391 score) 1392 else: 1393 logger.message(state.timestamp, 1394 FaultChecker._appendDuring(flight, "Stalled")) 1309 1395 1310 1396 #--------------------------------------------------------------------------------------- … … 1478 1564 #--------------------------------------------------------------------------------------- 1479 1565 1480 class StallChecker(PatientFaultChecker):1481 """Check if stall occured."""1482 def isCondition(self, flight, aircraft, oldState, state):1483 """Check if the fault condition holds."""1484 return flight.stage in [const.STAGE_TAKEOFF, const.STAGE_CLIMB,1485 const.STAGE_CRUISE, const.STAGE_DESCENT,1486 const.STAGE_LANDING] and state.stalled1487 1488 def logFault(self, flight, aircraft, logger, oldState, state):1489 """Log the fault."""1490 score = 40 if flight.stage in [const.STAGE_TAKEOFF,1491 const.STAGE_LANDING] else 301492 flight.handleFault(StallChecker, state.timestamp,1493 FaultChecker._appendDuring(flight, "Stalled"),1494 score)1495 1496 #---------------------------------------------------------------------------------------1497 1498 1566 class StrobeLightsChecker(PatientFaultChecker): 1499 1567 """Check if the strobe lights are used properly."""
Note:
See TracChangeset
for help on using the changeset viewer.