Changeset 274:b866c39279e8 for src/mlx
- Timestamp:
- 07/05/12 17:51:58 (12 years ago)
- Branch:
- default
- Phase:
- public
- Location:
- src/mlx
- Files:
-
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
src/mlx/acft.py
r273 r274 174 174 This is the function that the simulator calls directly with the new 175 175 state.""" 176 config = self._flight.config 177 178 self._smoothedIAS.add(config.realIASSmoothingLength, aircraftState.ias) 179 aircraftState.smoothedIAS = self._smoothedIAS.get() 180 181 self._smoothedVS.add(config.realVSSmoothingLength, aircraftState.vs) 182 aircraftState.smoothedVS = self._smoothedVS.get() 183 184 for checker in self._checkers: 185 try: 186 checker.check(self._flight, self, self._flight.logger, 187 self._aircraftState, aircraftState) 188 except: 189 print >> sys.stderr, "Checker", checker, "failed" 190 traceback.print_exc() 191 192 self._flight.handleState(self._aircraftState, aircraftState) 193 194 self._maxVS = max(self._maxVS, aircraftState.vs) 195 self._minVS = min(self._minVS, aircraftState.vs) 196 197 self._aircraftState = aircraftState 176 try: 177 config = self._flight.config 178 179 self._smoothedIAS.add(config.realIASSmoothingLength, aircraftState.ias) 180 aircraftState.smoothedIAS = self._smoothedIAS.get() 181 182 self._smoothedVS.add(config.realVSSmoothingLength, aircraftState.vs) 183 aircraftState.smoothedVS = self._smoothedVS.get() 184 185 for checker in self._checkers: 186 try: 187 checker.check(self._flight, self, self._flight.logger, 188 self._aircraftState, aircraftState) 189 except: 190 print >> sys.stderr, "Checker", checker, "failed" 191 traceback.print_exc() 192 193 self._flight.handleState(self._aircraftState, aircraftState) 194 195 self._maxVS = max(self._maxVS, aircraftState.vs) 196 self._minVS = min(self._minVS, aircraftState.vs) 197 except: 198 print >> sys.stderr, "Failed to handle the state" 199 traceback.print_exc() 200 finally: 201 self._aircraftState = aircraftState 198 202 199 203 def setStage(self, aircraftState, newStage): … … 203 207 if newStage==const.STAGE_PUSHANDTAXI: 204 208 self.logger.message(aircraftState.timestamp, "Block time start") 205 self. logFuel(aircraftState)209 self._flight.logFuel(aircraftState) 206 210 self.logger.message(aircraftState.timestamp, 207 211 "Zero-fuel weight: %.0f kg" % (aircraftState.zfw)) … … 234 238 force = True) 235 239 self.logger.message(aircraftState.timestamp, "Flight time end") 236 self. logFuel(aircraftState)240 self._flight.logFuel(aircraftState) 237 241 self.logger.message(aircraftState.timestamp, 238 242 "Landing weight: %.0f kg, MLW: %.0f" % \ … … 409 413 - fuel: left, centre, right 410 414 - n1: left, right 411 - reverser: left, right""" 412 fuelTanks = [const.FUELTANK_LEFT, const.FUELTANK_CENTRE, const.FUELTANK_RIGHT] 413 415 - reverser: left, right""" 414 416 def __init__(self, flight): 415 417 super(Boeing737, self).__init__(flight) … … 426 428 40 : 162 } 427 429 428 def logFuel(self, aircraftState):429 """Log the amount of fuel"""430 self.logger.message(aircraftState.timestamp,431 "Fuel: left=%.0f kg - centre=%.0f kg - right=%.0f kg" % \432 (aircraftState.fuel[0], aircraftState.fuel[1],433 aircraftState.fuel[2]))434 self.logger.message(aircraftState.timestamp,435 "Total fuel: %.0f kg" % (sum(aircraftState.fuel),))436 437 430 #--------------------------------------------------------------------------------------- 438 431 … … 519 512 - n1: left, right 520 513 - reverser: left, right.""" 521 fuelTanks = [const.FUELTANK_LEFT, const.FUELTANK_RIGHT]522 514 523 515 def __init__(self, flight): … … 533 525 35 : 158 } 534 526 535 def logFuel(self, aircraftState):536 """Log the amount of fuel"""537 self.logger.message(aircraftState.timestamp,538 "Fuel: left=%.0f kg - right=%.0f kg" % \539 (aircraftState.fuel[0], aircraftState.fuel[1]))540 self.logger.message(aircraftState.timestamp,541 "Total fuel: %.0f kg" % (sum(aircraftState.fuel),))542 543 527 #--------------------------------------------------------------------------------------- 544 528 … … 551 535 - n1: left, right 552 536 - reverser: left, right""" 553 fuelTanks = [const.FUELTANK_LEFT, const.FUELTANK_CENTRE, const.FUELTANK_RIGHT]554 537 555 538 def __init__(self, flight): … … 564 547 30 : 175 } 565 548 566 def logFuel(self, aircraftState):567 """Log the amount of fuel"""568 self.logger.message(aircraftState.timestamp,569 "Fuel: left=%.0f kg - centre=%.0f kg - right=%.0f kg" % \570 (aircraftState.fuel[0], aircraftState.fuel[1],571 aircraftState.fuel[2]))572 self.logger.message(aircraftState.timestamp,573 "Total fuel: %.0f kg" % (sum(aircraftState.fuel),))574 575 549 #--------------------------------------------------------------------------------------- 576 550 … … 605 579 - n1: left, right 606 580 - reverser: left, right.""" 607 fuelTanks = [const.FUELTANK_LEFT, const.FUELTANK_CENTRE, const.FUELTANK_RIGHT]608 609 581 def __init__(self, flight): 610 582 super(CRJ2, self).__init__(flight) … … 620 592 45 : 175 } 621 593 622 def logFuel(self, aircraftState):623 """Log the amount of fuel"""624 self.logger.message(aircraftState.timestamp,625 "Fuel: left=%.0f kg - centre=%.0f kg - right=%.0f kg" % \626 (aircraftState.fuel[0], aircraftState.fuel[1],627 aircraftState.fuel[2]))628 self.logger.message(aircraftState.timestamp,629 "Total fuel: %.0f kg" % (sum(aircraftState.fuel),))630 631 594 #--------------------------------------------------------------------------------------- 632 595 … … 639 602 - n1: left, right 640 603 - reverser: left, right.""" 641 fuelTanks = [const.FUELTANK_LEFT, const.FUELTANK_CENTRE, const.FUELTANK_RIGHT]642 643 604 def __init__(self, flight): 644 605 super(F70, self).__init__(flight) … … 655 616 42 : 180 } 656 617 657 def logFuel(self, aircraftState):658 """Log the amount of fuel"""659 self.logger.message(aircraftState.timestamp,660 "Fuel: left=%.0f kg - centre=%.0f kg - right=%.0f kg" % \661 (aircraftState.fuel[0], aircraftState.fuel[1],662 aircraftState.fuel[2]))663 self.logger.message(aircraftState.timestamp,664 "Total fuel: %.0f kg" % (sum(aircraftState.fuel),))665 666 618 #--------------------------------------------------------------------------------------- 667 619 … … 674 626 - rpm: left, right 675 627 - reverser: left, right.""" 676 fuelTanks = [const.FUELTANK_LEFT, const.FUELTANK_CENTRE, const.FUELTANK_RIGHT]677 # fuelTanks = [const.FUELTANK_LEFT_AUX, const.FUELTANK_LEFT,678 # const.FUELTANK_RIGHT, const.FUELTANK_RIGHT_AUX]679 680 628 def __init__(self, flight): 681 629 super(DC3, self).__init__(flight) … … 697 645 return True 698 646 699 def logFuel(self, aircraftState):700 """Log the amount of fuel"""701 self.logger.message(aircraftState.timestamp,702 "Fuel: left aux=%.0f kg - left=%.0f kg - right=%.0f kg - right aux=%.0f kg" % \703 (aircraftState.fuel[0], aircraftState.fuel[1],704 aircraftState.fuel[2], aircraftState.fuel[3]))705 self.logger.message(aircraftState.timestamp,706 "Total fuel: %.0f kg" % (sum(aircraftState.fuel),))707 708 647 #--------------------------------------------------------------------------------------- 709 648 … … 717 656 - n1: left, right 718 657 - reverser: left, right.""" 719 fuelTanks = [const.FUELTANK_LEFT_TIP, const.FUELTANK_EXTERNAL1,720 const.FUELTANK_LEFT_AUX,721 const.FUELTANK_CENTRE,722 const.FUELTANK_RIGHT_AUX,723 const.FUELTANK_EXTERNAL2, const.FUELTANK_RIGHT_TIP]724 725 658 def __init__(self, flight): 726 659 super(T134, self).__init__(flight) … … 740 673 return False 741 674 742 def logFuel(self, aircraftState):743 """Log the amount of fuel"""744 self.logger.message(aircraftState.timestamp,745 "Fuel: left tip=%.0f kg - external 1=%.0f kg - left aux=%.0f kg - centre= %.0f kg - right aux=%.0f kg - external 2=%.0f kg - right tip=%.0f kg" % \746 (aircraftState.fuel[0], aircraftState.fuel[1],747 aircraftState.fuel[2],748 aircraftState.fuel[3], aircraftState.fuel[4],749 aircraftState.fuel[5], aircraftState.fuel[6]))750 self.logger.message(aircraftState.timestamp,751 "Total fuel: %.0f kg" % (sum(aircraftState.fuel),))752 753 675 def _appendLightsLoggers(self): 754 676 """Append the loggers needed for the lights.""" … … 773 695 - n1: left, centre, right 774 696 - reverser: left, right""" 775 fuelTanks = [const.FUELTANK_LEFT_AUX, const.FUELTANK_LEFT,776 const.FUELTANK_CENTRE, const.FUELTANK_CENTRE2,777 const.FUELTANK_RIGHT, const.FUELTANK_RIGHT_AUX]778 697 def __init__(self, flight): 779 698 super(T154, self).__init__(flight) … … 793 712 return False 794 713 795 def logFuel(self, aircraftState):796 """Log the amount of fuel"""797 self.logger.message(aircraftState.timestamp,798 "Fuel: left aux=%.0f kg - left=%.0f kg - centre=%.0f kg - centre 2=%.0f kg - right=%.0f kg - right aux=%.0f kg" % \799 (aircraftState.fuel[0], aircraftState.fuel[1],800 aircraftState.fuel[2], aircraftState.fuel[3],801 aircraftState.fuel[4], aircraftState.fuel[5]))802 self.logger.message(aircraftState.timestamp,803 "Total fuel: %.0f kg" % (sum(aircraftState.fuel),))804 805 714 def _appendLightsLoggers(self): 806 715 """Append the loggers needed for the lights.""" … … 826 735 - n1: left, right 827 736 - reverser: left, right""" 828 fuelTanks = [const.FUELTANK_LEFT, const.FUELTANK_RIGHT]829 830 737 def __init__(self, flight): 831 738 super(YK40, self).__init__(flight) … … 844 751 return False 845 752 846 def logFuel(self, aircraftState):847 """Log the amount of fuel"""848 self.logger.message(aircraftState.timestamp,849 "Fuel: left=%.0f kg - right=%.0f kg" % \850 (aircraftState.fuel[0], aircraftState.fuel[1]))851 self.logger.message(aircraftState.timestamp,852 "Total fuel: %.0f kg" % (sum(aircraftState.fuel),))853 854 753 def _appendLightsLoggers(self): 855 754 """Append the loggers needed for the lights.""" … … 866 765 #--------------------------------------------------------------------------------------- 867 766 868 MostFuelTankAircraft = T134 767 mostFuelTanks = [const.FUELTANK_LEFT_TIP, const.FUELTANK_EXTERNAL1, 768 const.FUELTANK_LEFT_AUX, 769 const.FUELTANK_CENTRE, 770 const.FUELTANK_RIGHT_AUX, 771 const.FUELTANK_EXTERNAL2, const.FUELTANK_RIGHT_TIP] 869 772 870 773 #--------------------------------------------------------------------------------------- -
src/mlx/const.py
r252 r274 468 468 #------------------------------------------------------------------------------- 469 469 470 _fuelTankLogStrings = { FUELTANK_CENTRE : "centre", 471 FUELTANK_LEFT : "left", 472 FUELTANK_RIGHT : "right", 473 FUELTANK_LEFT_AUX : "left aux", 474 FUELTANK_RIGHT_AUX : "right aux", 475 FUELTANK_LEFT_TIP : "left tip", 476 FUELTANK_RIGHT_TIP : "right tip", 477 FUELTANK_EXTERNAL1 : "external 1", 478 FUELTANK_EXTERNAL2 : "external 2", 479 FUELTANK_CENTRE2 : "centre 2" } 480 481 def fuelTank2logString(fuelTank): 482 """Get the log string equivalent of the given fuelTank.""" 483 return _fuelTankLogStrings[fuelTank] \ 484 if fuelTank in _fuelTankLogStrings else "unknown" 485 486 #------------------------------------------------------------------------------- 487 470 488 # The available gates at LHBP 471 489 lhbpGateNumbers = [] -
src/mlx/flight.py
r262 r274 208 208 self._updateFlownDistance(currentState) 209 209 210 self.endFuel = sum(currentState.fuel)210 self.endFuel = currentState.totalFuel 211 211 if self.startFuel is None: 212 212 self.startFuel = self.endFuel … … 312 312 return "_knots" if self.speedInKnots else "_kmph" 313 313 314 def logFuel(self, aircraftState): 315 """Log the amount of fuel""" 316 fuelStr = "" 317 for (tank, amount) in aircraftState.fuel: 318 if fuelStr: fuelStr += " - " 319 fuelStr += "%s=%.0f kg" % (const.fuelTank2logString(tank), amount) 320 321 self.logger.message(aircraftState.timestamp, "Fuel: " + fuelStr) 322 self.logger.message(aircraftState.timestamp, 323 "Total fuel: %.0f kg" % (aircraftState.totalFuel,)) 324 314 325 def _updateFlownDistance(self, currentState): 315 326 """Update the flown distance.""" -
src/mlx/fs.py
r263 r274 184 184 - flapsSet: the selected degrees of the flaps (float) 185 185 - flaps: the actual degrees of the flaps (float) 186 - fuelWeight[]: the fuel weights in the different tanks in kgs (array of 187 floats of as many items as the number fuel tanks) 186 - fuel[]: the fuel information. It is a list of tuples with items: 187 the fuel tank identifier and the amount of fuel in that tank in 188 kgs 189 - totalFuel: the total amount of fuel in kg 188 190 - n1[]: the N1 values of the turbine engines (array of floats 189 191 of as many items as the number of engines, present only for aircraft with -
src/mlx/fsuipc.py
r263 r274 658 658 extra = _disconnect) 659 659 660 def getFuel(self, tanks, callback): 661 """Get the fuel from the given tanks. 662 663 The callback will be called with a list of two-tuples, where the tuples 664 have the following items: 660 def getFuel(self, callback): 661 """Get the fuel information for the current model. 662 663 The callback will be called with a list of triplets with the following 664 items: 665 - the fuel tank identifier 665 666 - the current weight of the fuel in the tank (in kgs) 666 667 - the current total capacity of the tank (in kgs).""" 667 data = [(0x0af4, "H")] # Fuel weight 668 for tank in tanks: 669 offset = _tank2offset[tank] 670 data.append( (offset, "u") ) # tank level 671 data.append( (offset+4, "u") ) # tank capacity 672 673 self._handler.requestRead(data, self._handleFuelRetrieved, 674 extra = callback) 668 if self._aircraftModel is None: 669 callback([]) 670 else: 671 self._aircraftModel.getFuel(self._handler, callback) 675 672 676 673 def setFuelLevel(self, levels): … … 682 679 - the requested level of the fuel as a floating-point value between 0.0 683 680 and 1.0.""" 684 data = [] 685 for (tank, level) in levels: 686 offset = _tank2offset[tank] 687 value = long(level * 128.0 * 65536.0) 688 data.append( (offset, "u", value) ) 689 self._handler.requestWrite(data, self._handleFuelWritten) 681 if self._aircraftModel is not None: 682 self._aircraftModel.setFuelLevel(self._handler, levels) 690 683 691 684 def enableTimeSync(self): … … 999 992 if disconnect: 1000 993 self._handler.disconnect() 1001 1002 def _handleFuelRetrieved(self, data, callback):1003 """Callback for a fuel retrieval request."""1004 fuelWeight = data[0] / 256.01005 result = []1006 for i in range(1, len(data), 2):1007 capacity = data[i+1] * fuelWeight * const.LBSTOKG1008 amount = data[i] * capacity / 128.0 / 65536.01009 result.append( (amount, capacity) )1010 1011 callback(result)1012 1013 def _handleFuelWritten(self, success, extra):1014 """Callback for a fuel setting request."""1015 pass1016 994 1017 995 def _handleNumHotkeys(self, data, (id, generation)): … … 1380 1358 super(GenericAircraftModel, self).addMonitoringData(data, fsType) 1381 1359 1382 self._addOffsetWithIndexMember(data, 0x0af4, "H", "_monidx_fuelWeight") 1383 1384 self._fuelStartIndex = len(data) 1385 for tank in self._fuelTanks: 1386 offset = _tank2offset[tank] 1387 self._addOffsetWithIndexMember(data, offset, "u") # tank level 1388 self._addOffsetWithIndexMember(data, offset+4, "u") # tank capacity 1360 self._fuelStartIndex = self._addFuelOffsets(data, "_monidx_fuelWeight") 1389 1361 1390 1362 self._engineStartIndex = len(data) … … 1406 1378 data) 1407 1379 1408 fuelWeight = data[self._monidx_fuelWeight]/256.0 1409 state.fuel = [] 1410 for i in range(self._fuelStartIndex, 1411 self._fuelStartIndex + 2*len(self._fuelTanks), 2): 1412 fuel = data[i+1]*data[i]*fuelWeight*const.LBSTOKG/128.0/65536.0 1413 state.fuel.append(fuel) 1414 1380 (state.fuel, state.totalFuel) = \ 1381 self._convertFuelData(data, index = self._monidx_fuelWeight) 1415 1382 1416 1383 state.n1 = [] if self._isN1 else None … … 1431 1398 return state 1432 1399 1400 def getFuel(self, handler, callback): 1401 """Get the fuel information for this model. 1402 1403 See Simulator.getFuel for more information. This 1404 implementation simply queries the fuel tanks given to the 1405 constructor.""" 1406 data = [] 1407 self._addFuelOffsets(data) 1408 1409 handler.requestRead(data, self._handleFuelRetrieved, 1410 extra = callback) 1411 1412 def setFuelLevel(self, handler, levels): 1413 """Set the fuel level. 1414 1415 See the description of Simulator.setFuelLevel. This 1416 implementation simply sets the fuel tanks as given.""" 1417 data = [] 1418 for (tank, level) in levels: 1419 offset = _tank2offset[tank] 1420 value = long(level * 128.0 * 65536.0) 1421 data.append( (offset, "u", value) ) 1422 1423 handler.requestWrite(data, self._handleFuelWritten) 1424 1425 def _addFuelOffsets(self, data, weightIndexName = None): 1426 """Add the fuel offsets to the given data array. 1427 1428 If weightIndexName is not None, it will be the name of the 1429 fuel weight index. 1430 1431 Returns the index of the first fuel tank's data.""" 1432 self._addOffsetWithIndexMember(data, 0x0af4, "H", weightIndexName) 1433 1434 fuelStartIndex = len(data) 1435 for tank in self._fuelTanks: 1436 offset = _tank2offset[tank] 1437 self._addOffsetWithIndexMember(data, offset, "u") # tank level 1438 self._addOffsetWithIndexMember(data, offset+4, "u") # tank capacity 1439 1440 return fuelStartIndex 1441 1442 def _convertFuelData(self, data, index = 0, addCapacities = False): 1443 """Convert the given data into a fuel info list. 1444 1445 The list consists of two or three-tuples of the following 1446 items: 1447 - the fuel tank ID, 1448 - the amount of the fuel in kg, 1449 - if addCapacities is True, the total capacity of the tank.""" 1450 fuelWeight = data[index] / 256.0 1451 index += 1 1452 1453 result = [] 1454 totalFuel = 0 1455 for fuelTank in self._fuelTanks: 1456 capacity = data[index+1] * fuelWeight * const.LBSTOKG 1457 amount = data[index] * capacity / 128.0 / 65536.0 1458 index += 2 1459 1460 result.append( (fuelTank, amount, capacity) if addCapacities 1461 else (fuelTank, amount)) 1462 totalFuel += amount 1463 1464 return (result, totalFuel) 1465 1466 def _handleFuelRetrieved(self, data, callback): 1467 """Callback for a fuel retrieval request.""" 1468 (fuelData, _totalFuel) = self._convertFuelData(data, 1469 addCapacities = True) 1470 callback(fuelData) 1471 1472 def _handleFuelWritten(self, success, extra): 1473 """Callback for a fuel setting request.""" 1474 pass 1475 1433 1476 #------------------------------------------------------------------------------ 1434 1477 … … 1451 1494 class B737Model(GenericAircraftModel): 1452 1495 """Generic model for the Boeing 737 Classing and NG aircraft.""" 1496 fuelTanks = [const.FUELTANK_LEFT, const.FUELTANK_CENTRE, const.FUELTANK_RIGHT] 1497 1453 1498 def __init__(self): 1454 1499 """Construct the model.""" 1455 1500 super(B737Model, self). \ 1456 1501 __init__(flapsNotches = [0, 1, 2, 5, 10, 15, 25, 30, 40], 1457 fuelTanks = acft.Boeing737.fuelTanks,1502 fuelTanks = B737Model.fuelTanks, 1458 1503 numEngines = 2) 1459 1504 … … 1519 1564 class B767Model(GenericAircraftModel): 1520 1565 """Generic model for the Boeing 767 aircraft.""" 1566 fuelTanks = [const.FUELTANK_LEFT, const.FUELTANK_CENTRE, const.FUELTANK_RIGHT] 1567 1521 1568 def __init__(self): 1522 1569 """Construct the model.""" 1523 1570 super(B767Model, self). \ 1524 1571 __init__(flapsNotches = [0, 1, 5, 15, 20, 25, 30], 1525 fuelTanks = acft.Boeing767.fuelTanks,1572 fuelTanks = Boeing767Model.fuelTanks, 1526 1573 numEngines = 2) 1527 1574 … … 1535 1582 class DH8DModel(GenericAircraftModel): 1536 1583 """Generic model for the Bombardier Dash 8-Q400 aircraft.""" 1584 fuelTanks = [const.FUELTANK_LEFT, const.FUELTANK_RIGHT] 1585 1537 1586 def __init__(self): 1538 1587 """Construct the model.""" 1539 1588 super(DH8DModel, self). \ 1540 1589 __init__(flapsNotches = [0, 5, 10, 15, 35], 1541 fuelTanks = acft.DH8D.fuelTanks,1590 fuelTanks = DH8DModel.fuelTanks, 1542 1591 numEngines = 2) 1543 1592 … … 1580 1629 class CRJ2Model(GenericAircraftModel): 1581 1630 """Generic model for the Bombardier CRJ-200 aircraft.""" 1631 fuelTanks = [const.FUELTANK_LEFT, const.FUELTANK_CENTRE, const.FUELTANK_RIGHT] 1632 1582 1633 def __init__(self): 1583 1634 """Construct the model.""" 1584 1635 super(CRJ2Model, self). \ 1585 1636 __init__(flapsNotches = [0, 8, 20, 30, 45], 1586 fuelTanks = acft.CRJ2.fuelTanks,1637 fuelTanks = CRJ2Model.fuelTanks, 1587 1638 numEngines = 2) 1588 1639 … … 1596 1647 class F70Model(GenericAircraftModel): 1597 1648 """Generic model for the Fokker F70 aircraft.""" 1649 fuelTanks = [const.FUELTANK_LEFT, const.FUELTANK_CENTRE, const.FUELTANK_RIGHT] 1650 1598 1651 def __init__(self): 1599 1652 """Construct the model.""" 1600 1653 super(F70Model, self). \ 1601 1654 __init__(flapsNotches = [0, 8, 15, 25, 42], 1602 fuelTanks = acft.F70.fuelTanks,1655 fuelTanks = F70Model.fuelTanks, 1603 1656 numEngines = 2) 1604 1657 … … 1612 1665 class DC3Model(GenericAircraftModel): 1613 1666 """Generic model for the Lisunov Li-2 (DC-3) aircraft.""" 1667 fuelTanks = [const.FUELTANK_LEFT, const.FUELTANK_CENTRE, const.FUELTANK_RIGHT] 1668 # fuelTanks = [const.FUELTANK_LEFT_AUX, const.FUELTANK_LEFT, 1669 # const.FUELTANK_RIGHT, const.FUELTANK_RIGHT_AUX] 1670 1614 1671 def __init__(self): 1615 1672 """Construct the model.""" 1616 1673 super(DC3Model, self). \ 1617 1674 __init__(flapsNotches = [0, 15, 30, 45], 1618 fuelTanks = acft.DC3.fuelTanks,1675 fuelTanks = DC3Model.fuelTanks, 1619 1676 numEngines = 2, isN1 = False) 1620 1677 … … 1624 1681 return "FSUIPC/Generic Lisunov Li-2 (DC-3)" 1625 1682 1683 def _convertFuelData(self, data, index = 0, addCapacities = False): 1684 """Convert the given data into a fuel info list. 1685 1686 It assumes to receive the 3 fuel tanks as seen above (left, 1687 centre and right) and converts it to left aux, left, right, 1688 and right aux. The amount in the left tank goes into left aux, 1689 the amount of the right tank goes into right aux and the 1690 amount of the centre tank goes into the left and right tanks 1691 evenly distributed.""" 1692 (rawFuelData, totalFuel) = \ 1693 super(DC3Model, self)._convertFuelData(data, index, addCapacities) 1694 1695 centreAmount = rawFuelData[1][1] 1696 if addCapacities: 1697 centreCapacity = rawFuelData[1][2] 1698 fuelData = [(const.FUELTANK_LEFT_AUX, 1699 rawFuelData[0][1], rawFuelData[0][2]), 1700 (const.FUELTANK_LEFT, 1701 centreAmount/2.0, centreCapacity/2.0), 1702 (const.FUELTANK_RIGHT, 1703 centreAmount/2.0, centreCapacity/2.0), 1704 (const.FUELTANK_RIGHT_AUX, 1705 rawFuelData[2][1], rawFuelData[2][2])] 1706 else: 1707 fuelData = [(const.FUELTANK_LEFT_AUX, rawFuelData[0][1]), 1708 (const.FUELTANK_LEFT, centreAmount/2.0), 1709 (const.FUELTANK_RIGHT, centreAmount/2.0), 1710 (const.FUELTANK_RIGHT_AUX, rawFuelData[2][1])] 1711 1712 return (fuelData, totalFuel) 1713 1714 def setFuelLevel(self, handler, levels): 1715 """Set the fuel level. 1716 1717 See the description of Simulator.setFuelLevel. This 1718 implementation assumes to get the four-tank representation, 1719 as returned by getFuel().""" 1720 leftLevel = 0.0 1721 centreLevel = 0.0 1722 rightLevel = 0.0 1723 1724 for (tank, level) in levels: 1725 if tank==const.FUELTANK_LEFT_AUX: leftLevel += level 1726 elif tank==const.FUELTANK_LEFT or tank==const.FUELTANK_RIGHT: 1727 centreLevel += level 1728 elif tank==const.FUELTANK_RIGHT_AUX: rightLevel += level 1729 1730 super(DC3Model, self).setFuelLevel([(const.FUELTANK_LEFT, leftLevel), 1731 (const.FUELTANK_CENTRE, 1732 centreLevel), 1733 (const.FUELTANK_RIGHT, rightLevel)]) 1734 1626 1735 #------------------------------------------------------------------------------ 1627 1736 1628 1737 class T134Model(GenericAircraftModel): 1629 1738 """Generic model for the Tupolev Tu-134 aircraft.""" 1739 fuelTanks = [const.FUELTANK_LEFT_TIP, const.FUELTANK_EXTERNAL1, 1740 const.FUELTANK_LEFT_AUX, 1741 const.FUELTANK_CENTRE, 1742 const.FUELTANK_RIGHT_AUX, 1743 const.FUELTANK_EXTERNAL2, const.FUELTANK_RIGHT_TIP] 1744 1630 1745 def __init__(self): 1631 1746 """Construct the model.""" 1632 1747 super(T134Model, self). \ 1633 1748 __init__(flapsNotches = [0, 10, 20, 30], 1634 fuelTanks = acft.T134.fuelTanks,1749 fuelTanks = T134Model.fuelTanks, 1635 1750 numEngines = 2) 1636 1751 … … 1644 1759 class T154Model(GenericAircraftModel): 1645 1760 """Generic model for the Tupolev Tu-134 aircraft.""" 1761 fuelTanks = [const.FUELTANK_LEFT_AUX, const.FUELTANK_LEFT, 1762 const.FUELTANK_CENTRE, const.FUELTANK_CENTRE2, 1763 const.FUELTANK_RIGHT, const.FUELTANK_RIGHT_AUX] 1764 1646 1765 def __init__(self): 1647 1766 """Construct the model.""" 1648 1767 super(T154Model, self). \ 1649 1768 __init__(flapsNotches = [0, 15, 28, 45], 1650 fuelTanks = acft.T154.fuelTanks,1769 fuelTanks = T154Model.fuelTanks, 1651 1770 numEngines = 3) 1652 1771 … … 1668 1787 class YK40Model(GenericAircraftModel): 1669 1788 """Generic model for the Yakovlev Yak-40 aircraft.""" 1789 fuelTanks = [const.FUELTANK_LEFT, const.FUELTANK_RIGHT] 1790 1670 1791 def __init__(self): 1671 1792 """Construct the model.""" 1672 1793 super(YK40Model, self). \ 1673 1794 __init__(flapsNotches = [0, 20, 35], 1674 fuelTanks = acft.YK40.fuelTanks,1795 fuelTanks = YK40Model.fuelTanks, 1675 1796 numEngines = 2) 1676 1797 -
src/mlx/gui/flight.py
r262 r274 1163 1163 gui.beginBusy(xstr("fuel_get_busy")) 1164 1164 1165 gui.simulator.getFuel(gui.flight.aircraft.fuelTanks, 1166 self._handleFuel) 1165 gui.simulator.getFuel(self._handleFuel) 1167 1166 else: 1168 1167 self._wizard.nextPage() … … 1374 1373 self.setMainWidget(self._fuelAlignment) 1375 1374 1376 tanks = acft.MostFuelTankAircraft.fuelTanks 1377 tankData = ((2500, 3900),) * len(tanks) 1378 self._setupTanks(tanks, tankData) 1375 tankData = [(tank, 2500, 3900) for tank in acft.mostFuelTanks] 1376 self._setupTanks(tankData) 1379 1377 1380 1378 self.addCancelFlightButton() … … 1387 1385 def activate(self): 1388 1386 """Activate the page.""" 1389 gui = self._wizard.gui 1390 1391 self._setupTanks(gui.flight.aircraft.fuelTanks, 1392 self._wizard._fuelData) 1387 self._setupTanks(self._wizard._fuelData) 1393 1388 1394 1389 def finalize(self): … … 1410 1405 self._wizard.nextPage() 1411 1406 1412 def _setupTanks(self, tank s, tankData):1407 def _setupTanks(self, tankData): 1413 1408 """Setup the tanks for the given data.""" 1414 numTanks = len(tank s)1409 numTanks = len(tankData) 1415 1410 if self._fuelTable is not None: 1416 1411 self._fuelAlignment.remove(self._fuelTable) … … 1419 1414 self._fuelTable = gtk.Table(numTanks, 1) 1420 1415 self._fuelTable.set_col_spacings(16) 1421 for i in range(0, numTanks): 1422 tank = tanks[i] 1423 (current, capacity) = tankData[i] 1424 1416 index = 0 1417 for (tank, current, capacity) in tankData: 1425 1418 fuelTank = FuelTank(tank, 1426 1419 xstr("fuel_tank_" + 1427 1420 const.fuelTank2string(tank)), 1428 1421 capacity, current) 1429 self._fuelTable.attach(fuelTank, i , i+1, 0, 1)1422 self._fuelTable.attach(fuelTank, index, index+1, 0, 1) 1430 1423 self._fuelTanks.append(fuelTank) 1424 index += 1 1431 1425 1432 1426 self._fuelAlignment.add(self._fuelTable) -
src/mlx/gui/monitor.py
r263 r274 281 281 282 282 fuelStr = "" 283 for fuelin aircraftState.fuel:283 for (_tank, fuel) in aircraftState.fuel: 284 284 if fuelStr: fuelStr += ", " 285 285 fuelStr += "%.0f" % (fuel,)
Note:
See TracChangeset
for help on using the changeset viewer.