Changeset 60:110237fed44b for src
- Timestamp:
- 04/07/12 09:39:40 (13 years ago)
- Branch:
- default
- Phase:
- public
- Location:
- src/mlx
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
src/mlx/checks.py
r30 r60 697 697 698 698 class MZFWChecker(WeightChecker): 699 """Checks if the M TOW is not exceeded on landing."""699 """Checks if the MZFW is not exceeded on landing.""" 700 700 def __init__(self): 701 701 """Construct the checker.""" … … 750 750 """Check if the payload matches the specification.""" 751 751 TOLERANCE=550 752 753 @staticmethod 754 def isZFWFaulty(aircraftZFW, flightZFW): 755 """Check if the given aircraft's ZFW is outside of the limits.""" 756 return aircraftZFW < (flightZFW - PayloadChecker.TOLERANCE) or \ 757 aircraftZFW > (flightZFW + PayloadChecker.TOLERANCE) 752 758 753 759 def isCondition(self, flight, aircraft, oldState, state): 754 760 """Check if the fault condition holds.""" 755 761 return flight.stage==const.STAGE_PUSHANDTAXI and \ 756 (state.zfw < (flight.zfw - PayloadChecker.TOLERANCE) or \ 757 state.zfw > (flight.zfw + PayloadChecker.TOLERANCE)) 762 PayloadChecker.isZFWFaulty(state.zfw, flight.zfw) 758 763 759 764 def logFault(self, flight, aircraft, logger, oldState, state): -
src/mlx/gui/flight.py
r59 r60 5 5 import mlx.const as const 6 6 import mlx.fs as fs 7 from mlx.logger import Logger 8 from mlx.flight import Flight 9 from mlx.acft import Aircraft 7 from mlx.checks import PayloadChecker 10 8 11 9 #----------------------------------------------------------------------------- … … 463 461 labelAlignment = gtk.Alignment(xalign=1.0, xscale=0.0) 464 462 label = gtk.Label("Gate:") 465 label.set_use_underline(True)466 463 labelAlignment.add(label) 467 464 table.attach(labelAlignment, 0, 1, 1, 2) … … 474 471 table.attach(labelAlignment, 1, 2, 1, 2) 475 472 476 477 473 self._button = self.addButton("_Connect", default = True) 478 474 self._button.set_use_underline(True) … … 480 476 481 477 def activate(self): 482 """Setup the dep rature information."""478 """Setup the departure information.""" 483 479 icao = self._wizard._bookedFlight.departureICAO 484 480 self._departureICAO.set_markup("<b>" + icao + "</b>") … … 499 495 """Construct the page.""" 500 496 help = "The briefing contains the weights below.\n" \ 501 "Setup the cargo weight and check if the simulator\n" \ 502 "reports the expected Zero Fuel Weight." 497 "Setup the cargo weight here and the payload weight in the simulator.\n\n" \ 498 "You can also check here what the simulator reports as ZFW." 499 503 500 super(PayloadPage, self).__init__(wizard, "Payload", help) 504 501 505 button = gtk.Button("_Query ZFW") 502 alignment = gtk.Alignment(xalign = 0.5, yalign = 0.5, 503 xscale = 0.0, yscale = 0.0) 504 505 table = gtk.Table(7, 3) 506 table.set_row_spacings(4) 507 table.set_col_spacings(16) 508 table.set_homogeneous(False) 509 alignment.add(table) 510 self.setMainWidget(alignment) 511 512 label = gtk.Label("Crew:") 513 label.set_alignment(0.0, 0.5) 514 table.attach(label, 0, 1, 0, 1) 515 516 self._numCrew = gtk.Label() 517 self._numCrew.set_width_chars(6) 518 self._numCrew.set_alignment(1.0, 0.5) 519 table.attach(self._numCrew, 1, 2, 0, 1) 520 521 label = gtk.Label("Passengers:") 522 label.set_alignment(0.0, 0.5) 523 table.attach(label, 0, 1, 1, 2) 524 525 self._numPassengers = gtk.Label() 526 self._numPassengers.set_width_chars(6) 527 self._numPassengers.set_alignment(1.0, 0.5) 528 table.attach(self._numPassengers, 1, 2, 1, 2) 529 530 label = gtk.Label("Baggage:") 531 label.set_alignment(0.0, 0.5) 532 table.attach(label, 0, 1, 2, 3) 533 534 self._bagWeight = gtk.Label() 535 self._bagWeight.set_width_chars(6) 536 self._bagWeight.set_alignment(1.0, 0.5) 537 table.attach(self._bagWeight, 1, 2, 2, 3) 538 539 table.attach(gtk.Label("kg"), 2, 3, 2, 3) 540 541 label = gtk.Label("_Cargo:") 542 label.set_use_underline(True) 543 label.set_alignment(0.0, 0.5) 544 table.attach(label, 0, 1, 3, 4) 545 546 self._cargoWeight = gtk.Entry() 547 self._cargoWeight.set_width_chars(6) 548 self._cargoWeight.set_alignment(1.0) 549 self._cargoWeight.connect("changed", self._cargoWeightChanged) 550 self._cargoWeight.set_tooltip_text("The weight of the cargo for your flight.") 551 table.attach(self._cargoWeight, 1, 2, 3, 4) 552 self._cargoWeightValue = 0 553 label.set_mnemonic_widget(self._cargoWeight) 554 555 table.attach(gtk.Label("kg"), 2, 3, 3, 4) 556 557 label = gtk.Label("Mail:") 558 label.set_alignment(0.0, 0.5) 559 table.attach(label, 0, 1, 4, 5) 560 561 self._mailWeight = gtk.Label() 562 self._mailWeight.set_width_chars(6) 563 self._mailWeight.set_alignment(1.0, 0.5) 564 table.attach(self._mailWeight, 1, 2, 4, 5) 565 566 table.attach(gtk.Label("kg"), 2, 3, 4, 5) 567 568 label = gtk.Label("<b>Calculated ZFW:</b>") 569 label.set_alignment(0.0, 0.5) 570 label.set_use_markup(True) 571 table.attach(label, 0, 1, 5, 6) 572 573 self._calculatedZFW = gtk.Label() 574 self._calculatedZFW.set_width_chars(6) 575 self._calculatedZFW.set_alignment(1.0, 0.5) 576 table.attach(self._calculatedZFW, 1, 2, 5, 6) 577 578 table.attach(gtk.Label("kg"), 2, 3, 5, 6) 579 580 button = gtk.Button("_ZFW from FS:") 581 button.set_use_underline(True) 506 582 button.connect("clicked", self._zfwRequested) 507 self.setMainWidget(button) 508 583 table.attach(button, 0, 1, 6, 7) 584 585 self._simulatorZFW = gtk.Label("-") 586 self._simulatorZFW.set_width_chars(6) 587 self._simulatorZFW.set_alignment(1.0, 0.5) 588 table.attach(self._simulatorZFW, 1, 2, 6, 7) 589 self._simulatorZFWValue = None 590 591 table.attach(gtk.Label("kg"), 2, 3, 6, 7) 592 593 self._button = self.addButton(gtk.STOCK_GO_FORWARD, default = True) 594 self._button.set_use_stock(True) 595 self._button.connect("clicked", self._forwardClicked) 596 597 def activate(self): 598 """Setup the information.""" 599 bookedFlight = self._wizard._bookedFlight 600 self._numCrew.set_text(str(bookedFlight.numCrew)) 601 self._numPassengers.set_text(str(bookedFlight.numPassengers)) 602 self._bagWeight.set_text(str(bookedFlight.bagWeight)) 603 self._cargoWeightValue = bookedFlight.cargoWeight 604 self._cargoWeight.set_text(str(bookedFlight.cargoWeight)) 605 self._mailWeight.set_text(str(bookedFlight.mailWeight)) 606 self._updateCalculatedZFW() 607 608 def _calculateZFW(self): 609 """Calculate the ZFW value.""" 610 zfw = self._wizard.gui._flight.aircraft.dow 611 bookedFlight = self._wizard._bookedFlight 612 zfw += (bookedFlight.numCrew + bookedFlight.numPassengers) * 82 613 zfw += bookedFlight.bagWeight 614 zfw += self._cargoWeightValue 615 zfw += bookedFlight.mailWeight 616 return zfw 617 618 def _updateCalculatedZFW(self): 619 """Update the calculated ZFW""" 620 zfw = self._calculateZFW() 621 622 markupBegin = "<b>" 623 markupEnd = "</b>" 624 if self._simulatorZFWValue is not None and \ 625 PayloadChecker.isZFWFaulty(self._simulatorZFWValue, zfw): 626 markupBegin += '<span foreground="red">' 627 markupEnd = "</span>" + markupEnd 628 self._calculatedZFW.set_markup(markupBegin + str(zfw) + markupEnd) 629 630 def _cargoWeightChanged(self, entry): 631 """Called when the cargo weight has changed.""" 632 text = self._cargoWeight.get_text() 633 if text=="": 634 self._cargoWeightValue = 0 635 else: 636 try: 637 self._cargoWeightValue = int(text) 638 except: 639 self._cargoWeight.set_text(str(self._cargoWeightValue)) 640 self._updateCalculatedZFW() 641 509 642 def _zfwRequested(self, button): 510 643 """Called when the ZFW is requested from the simulator.""" … … 513 646 def _handleZFW(self, zfw): 514 647 """Called when the ZFW value is retrieved.""" 515 print "ZFW", zfw 516 648 gobject.idle_add(self._processZFW, zfw) 649 650 def _processZFW(self, zfw): 651 """Process the given ZFW value received from the simulator.""" 652 self._simulatorZFWValue = zfw 653 self._simulatorZFW.set_text("%.0f" % (zfw,)) 654 self._updateCalculatedZFW() 655 656 def _forwardClicked(self, button): 657 """Called when the forward button is clicked.""" 658 self._wizard._zfw = self._calculateZFW() 659 self._wizard.nextPage() 660 517 661 #----------------------------------------------------------------------------- 518 662 … … 600 744 self._bookedFlight = None 601 745 self._departureGate = "-" 746 self._zfw = None 602 747 603 748 self.setCurrentPage(0)
Note:
See TracChangeset
for help on using the changeset viewer.