Changeset 117:af3d52b9adc4


Ignore:
Timestamp:
04/28/12 12:25:48 (12 years ago)
Author:
István Váradi <ivaradi@…>
Branch:
default
hg-Phase:
(<MercurialRepository 1 'hg:/home/ivaradi/mlx/hg' '/'>, 'public')
Message:

Implemented the weight help tab

Location:
src/mlx
Files:
1 added
6 edited

Legend:

Unmodified
Added
Removed
  • src/mlx/acft.py

    r101 r117  
    2828        self._v1r2LineIndex = None
    2929        self._vrefLineIndex = None
     30
     31        self.humanWeight = 82.0
    3032
    3133        self._checkers = []
  • src/mlx/fsuipc.py

    r97 r117  
    531531        self._handler.requestRead([(0x3bfc, "d")], self._handleZFW, extra = callback)
    532532
     533    def requestWeights(self, callback):
     534        """Request the following weights: DOW, ZFW, payload.
     535
     536        These values will be passed to the callback function in this order, as
     537        separate arguments."""       
     538        self._handler.requestRead([(0x13fc, "d")], self._handlePayloadCount,
     539                                  extra = callback)
     540
    533541    def requestTime(self, callback):
    534542        """Request the time from the simulator."""
     
    737745        """Callback for a time retrieval request."""
    738746        callback(Simulator._getTimestamp(data))
     747
     748    def _handlePayloadCount(self, data, callback):
     749        """Callback for the payload count retrieval request."""
     750        payloadCount = data[0]
     751        data = [(0x3bfc, "d"), (0x30c0, "f")]
     752        for i in range(0, payloadCount):
     753            data.append((0x1400 + i*48, "f"))
     754       
     755        self._handler.requestRead(data, self._handleWeights,
     756                                  extra = callback)
     757
     758    def _handleWeights(self, data, callback):
     759        """Callback for the weights retrieval request."""
     760        zfw = data[0] * const.LBSTOKG / 256.0
     761        grossWeight = data[1] * const.LBSTOKG
     762        payload = sum(data[2:]) * const.LBSTOKG
     763        dow = zfw - payload
     764        callback(dow, payload, zfw, grossWeight)
    739765                                                 
    740766#------------------------------------------------------------------------------
  • src/mlx/gui/flight.py

    r107 r117  
    799799        """Finalize the payload page."""
    800800        self._cargoWeight.set_sensitive(False)
     801        self._wizard.gui.initializeWeightHelp()
    801802
    802803    def calculateZFW(self):
     
    19081909        self._payloadPage = PayloadPage(self)
    19091910        self._pages.append(self._payloadPage)
     1911        self._payloadIndex = len(self._pages)
    19101912        self._pages.append(TimePage(self))
    19111913        self._routePage = RoutePage(self)
     
    19151917        self._arrivalBriefingPage = BriefingPage(self, False)
    19161918        self._pages.append(self._arrivalBriefingPage)
     1919        self._arrivalBriefingIndex = len(self._pages)
    19171920        self._takeoffPage = TakeoffPage(self)
    19181921        self._pages.append(self._takeoffPage)
  • src/mlx/gui/gui.py

    r110 r117  
    88from mlx.gui.flight import Wizard
    99from mlx.gui.monitor import MonitorWindow
     10from mlx.gui.weighthelp import WeightHelp
    1011
    1112import mlx.const as const
     
    8889        self._flightInfo.disable()
    8990
     91        self._weightHelp = WeightHelp(self)
     92        label = gtk.Label(xstr("tab_weight_help"))
     93        label.set_use_underline(True)
     94        label.set_tooltip_text(xstr("tab_weight_help_tooltip"))
     95        self._notebook.append_page(self._weightHelp, label)
     96       
    9097        (logWidget, self._logView)  = self._buildLogWidget()
    9198        label = gtk.Label(xstr("tab_log"))
     
    112119        window.show_all()
    113120        self._wizard.grabDefault()
     121        self._weightHelp.reset()
     122        self._weightHelp.disable()
    114123
    115124        self._mainWindow = window
     
    353362        self.resetFlightStatus()
    354363
     364        self._weightHelp.reset()
     365        self._weightHelp.disable()
    355366        self._wizard.reset()
    356367        self._notebook.set_current_page(0)
     
    518529        """Begin a period of background processing."""
    519530        self._wizard.set_sensitive(False)
     531        self._weightHelp.set_sensitive(False)
    520532        self._mainWindow.get_window().set_cursor(self._busyCursor)
    521533        self._statusbar.updateBusyState(message)
     
    524536        """End a period of background processing."""
    525537        self._mainWindow.get_window().set_cursor(None)
     538        self._weightHelp.set_sensitive(True)
    526539        self._wizard.set_sensitive(True)
    527540        self._statusbar.updateBusyState(None)
     541
     542    def initializeWeightHelp(self):
     543        """Initialize the weight help tab."""
     544        self._weightHelp.reset()
     545        self._weightHelp.enable()
    528546
    529547    def _writeStdIO(self):
  • src/mlx/i18n.py

    r115 r117  
    139139        self.add("tab_flight_info", "Flight _info")
    140140        self.add("tab_flight_info_tooltip", "Further information regarding the flight")
     141        self.add("tab_weight_help", "_Help")
     142        self.add("tab_weight_help_tooltip", "Help to calculate the weights")
    141143        self.add("tab_log", "_Log")
    142144        self.add("tab_log_tooltip",
    143145                 "The log of your flight that will be sent to the MAVA website")
     146        self.add("tab_gates", "_Gates")       
    144147        self.add("tab_debug_log", "_Debug log")
    145148        self.add("tab_debug_log_tooltip", "Log with debugging information.")
    146         self.add("tab_help", "_Help")
    147         self.add("tab_gates", "_Gates")
    148149
    149150        self.add("conn_failed", "Cannot connect to the simulator.")
     
    475476        self.add("update_nothing", "There was nothing to update")
    476477        self.add("update_failed", "Failed, see the debug log for details.")
     478
     479        self.add("weighthelp_usinghelp", "_Using help")
     480        self.add("weighthelp_usinghelp_tooltip",
     481                 "If you check this, some help will be displayed on how "
     482                 "to calculate the payload weight for your flight. "
     483                 "Note, that the usage of this facility will be logged.")
     484        self.add("weighthelp_header_calculated", "Requested/\ncalculated")
     485        self.add("weighthelp_header_simulator", "Simulator\ndata")
     486        self.add("weighthelp_header_simulator_tooltip",
     487                 "Click this button to retrieve the weight values from the "
     488                 "simulator, which will be displayed below. If a value is "
     489                 "within 10% of the tolerance, it is displayed in "
     490                 '<b><span foreground="darkgreen">green</span></b>, '
     491                 "if it is out of the tolerance, it is displayed in "
     492                 '<b><span foreground="red">red</span></b>, '
     493                 "otherwise in"
     494                 '<b><span foreground="orange">yellow</span></b>.')
     495        self.add("weighthelp_crew", "Crew (%s):")
     496        self.add("weighthelp_pax", "Passengers (%s):")
     497        self.add("weighthelp_baggage", "Baggage:")
     498        self.add("weighthelp_cargo", "Cargo:")
     499        self.add("weighthelp_mail", "Mail:")
     500        self.add("weighthelp_payload", "Payload:")
     501        self.add("weighthelp_dow", "DOW:")
     502        self.add("weighthelp_zfw", "ZFW:")
     503        self.add("weighthelp_gross", "Gross weight:")
     504        self.add("weighthelp_mzfw", "MZFW:")
     505        self.add("weighthelp_mtow", "MTOW:")
     506        self.add("weighthelp_mlw", "MLW:")
     507        self.add("weighthelp_busy", "Querying weight data...")
    477508                 
    478509#------------------------------------------------------------------------------
     
    501532        self.add("tab_flight_info", "Járat _info")
    502533        self.add("tab_flight_info_tooltip", "Egyéb információk a járat teljesítésével kapcsolatban")
     534        self.add("tab_weight_help", "_Segítség")
     535        self.add("tab_weight_help_tooltip", "Segítség a súlyszámításhoz")
    503536        self.add("tab_log", "_Napló")
    504537        self.add("tab_log_tooltip",
     
    507540        self.add("tab_debug_log_tooltip",
    508541                 "Hibakereséshez használható információkat tartalmazó napló.")
    509         self.add("tab_help", "_Segítség")
    510542        self.add("tab_gates", "_Kapuk")       
    511543
     
    842874        self.add("update_failed", "Nem sikerült, a részleteket lásd a debug naplóban.")
    843875
     876        self.add("weighthelp_usinghelp", "_Használom a segítséget")
     877        self.add("weighthelp_usinghelp_tooltip",
     878                 "Ha bejelölöd, az alábbiakban kapsz egy kis segítséget "
     879                 "a járathoz szükséges hasznos teher megállapításához. "
     880                 "Ha igénybe veszed ezt a szolgáltatást, ez a tény "
     881                 "a naplóba bekerül.")
     882        self.add("weighthelp_header_calculated", "Elvárt/\nszámított")
     883        self.add("weighthelp_header_simulator", "Szimulátor\nadatok")
     884        self.add("weighthelp_header_simulator_tooltip",
     885                 "Kattints erre a gombra a súlyadatoknak a szimulátortól "
     886                 "való lekérdezéséhez. Az értékek lent jelennek meg. Ha "
     887                 "egy érték a tűrés 10%-án belül van, akkor az "
     888                 '<b><span foreground="darkgreen">zöld</span></b> '
     889                 "színnel jelenik meg. Ha nem fér bele a tűrésbe, akkor "
     890                 '<b><span foreground="red">piros</span></b>, '
     891                 "egyébként "
     892                 '<b><span foreground="orange">sárga</span></b> '
     893                 "színben olvasható.")
     894        self.add("weighthelp_crew", "Legénység (%s):")
     895        self.add("weighthelp_pax", "Utasok (%s):")
     896        self.add("weighthelp_baggage", "Poggyász:")
     897        self.add("weighthelp_cargo", "Teher:")
     898        self.add("weighthelp_mail", "Posta:")
     899        self.add("weighthelp_payload", "Hasznos teher:")
     900        self.add("weighthelp_dow", "DOW:")
     901        self.add("weighthelp_zfw", "ZFW:")
     902        self.add("weighthelp_gross", "Teljes tömeg:")
     903        self.add("weighthelp_mzfw", "MZFW:")
     904        self.add("weighthelp_mtow", "MTOW:")
     905        self.add("weighthelp_mlw", "MLW:")
     906        self.add("weighthelp_busy", "A tömegadatok lekérdezése...")
     907
    844908#------------------------------------------------------------------------------
    845909
  • src/mlx/pyuipc_sim.py

    r89 r117  
    243243        self.n1 = [0.0, 0.0, 0.0]
    244244        self.throttles = [0.0, 0.0, 0.0]
     245
     246        self.payloadCount = 1
     247        self.payload = []
     248        for i in range(0, 61): self.payload.append(0.0)
    245249
    246250    def read(self, offset):
     
    402406        elif offset==0x1260:       # External 2 tank capacity
    403407            return self._getFuelCapacity(self.FUEL_EXTERNAL_2)
     408        elif offset==0x13fc:       # The number of the payload stations
     409            return self.payloadCount
     410        elif offset>=0x1400 and offset<=0x1f40 and \
     411             ((offset-0x1400)%48)==0: # Payload
     412            return self.payload[ (offset - 0x1400) / 48 ]
    404413        elif offset==0x2000:       # Engine #1 N1
    405414            return self.n1[self.ENGINE_1]
     
    581590        elif offset==0x1260:       # External 2 tank capacity
    582591            self._setFuelCapacity(self.FUEL_EXTERNAL_2, value)
     592        elif offset==0x13fc:       # The number of the payload stations
     593            self.payloadCount = int(value)
     594        elif offset>=0x1400 and offset<=0x1f40 and \
     595             ((offset-0x1400)%48)==0: # Payload
     596            self.payload[ (offset - 0x1400) / 48 ] = value
    583597        elif offset==0x2000:       # Engine #1 N1
    584598            self.n1[self.ENGINE_1] = value
     
    11141128                                                              100.0/1609.344))
    11151129                                                           
     1130        self._valueHandlers["payloadCount"] = (0x13fc, "d",
     1131                                               lambda value: value,
     1132                                               lambda word: int(word))
     1133        for i in range(0, 61):
     1134            self._valueHandlers["payload%d" % (i,)] = (0x1400 + i * 48, "f",
     1135                                                       lambda value:
     1136                                                       value * const.LBSTOKG,
     1137                                                       lambda word:
     1138                                                       float(word)*const.KGSTOLB)
     1139                                                           
    11161140    def default(self, line):
    11171141        """Handle unhandle commands."""
Note: See TracChangeset for help on using the changeset viewer.