Changeset 512:46bd71540346


Ignore:
Timestamp:
05/29/13 17:59:20 (11 years ago)
Author:
István Váradi <ivaradi@…>
Branch:
default
Children:
513:0884206a9344, 514:8c53fc09c941
Phase:
public
Message:

Implemented the new derate handling method (re #202)

Files:
4 edited

Legend:

Unmodified
Added
Removed
  • locale/en/mlx.po

    r508 r512  
    786786msgstr "Der_ated thrust:"
    787787
     788msgid "takeoff_derate_boeing_tooltip"
     789msgstr "Enter the percentage of the takeoff power."
     790
     791msgid "takeoff_derate_epr_tooltip"
     792msgstr "Enter the EPR value used for takeoff."
     793
    788794msgid "takeoff_derate_tupolev"
    789 msgstr "N_ominal/takeoff:"
     795msgstr "Thrust setting:"
     796
     797msgid "takeoff_derate_tupolev_nominal"
     798msgstr "_nominal"
     799
     800msgid "takeoff_derate_tupolev_nominal_tooltip"
     801msgstr "Select this if the takeoff thrust setting is nominal."
     802
     803msgid "takeoff_derate_tupolev_takeoff"
     804msgstr "_takeoff"
     805
     806msgid "takeoff_derate_tupolev_takeoff_tooltip"
     807msgstr "Select this if the takeoff thrust setting is takeoff."
    790808
    791809msgid "takeoff_derate_b462"
    792 msgstr "Der_ate (yes/no):"
    793 
    794 msgid "takeoff_derate_tooltip"
    795 msgstr "Enter the takeoff derate parameter."
     810msgstr "Der_ate enabled"
     811
     812msgid "takeoff_derate_b462_tooltip"
     813msgstr "Check this if derate is enabled for takeoff."
    796814
    797815msgid "takeoff_antiice"
  • locale/hu/mlx.po

    r508 r512  
    782782
    783783msgid "takeoff_derate"
    784 msgstr "Teljesítménycsökkentés:"
     784msgstr "Teljesítmény:"
    785785
    786786msgid "takeoff_derate_boeing"
    787 msgstr "Csökkentett teljesítmény:"
     787msgstr "_Teljesítmény:"
     788
     789msgid "takeoff_derate_boeing_tooltip"
     790msgstr "Írd be, hogy hány százalék a felszállási teljesítmény."
     791
     792msgid "takeoff_derate_epr_tooltip"
     793msgstr "Írd be a felszálláskor használt EPR értéket."
    788794
    789795msgid "takeoff_derate_tupolev"
    790 msgstr "Névleges/felszállási:"
     796msgstr "Üzemmód:"
     797
     798msgid "takeoff_derate_tupolev_nominal"
     799msgstr "n_ominális"
     800
     801msgid "takeoff_derate_tupolev_nominal_tooltip"
     802msgstr "Ha a felszálláshoz használt üzemmód beállítása nominális, válaszd ezt."
     803
     804msgid "takeoff_derate_tupolev_takeoff"
     805msgstr "f_elszállási"
     806
     807msgid "takeoff_derate_tupolev_takeoff_tooltip"
     808msgstr "Ha a felszálláshoz használt üzemmód beállítása felszállási, válaszd ezt."
    791809
    792810msgid "takeoff_derate_b462"
    793 msgstr "Teljesítménycsökkentés (yes/no):"
    794 
    795 msgid "takeoff_derate_tooltip"
    796 msgstr "Írd be a felszállási teljesítménycsökkentés értékét."
     811msgstr "_Csökkentett teljesítmény"
     812
     813msgid "takeoff_derate_b462_tooltip"
     814msgstr "Jelöld ezt be, ha a felszállás csökkentett teljesítménnyel történik."
    797815
    798816msgid "takeoff_antiice"
  • src/mlx/acft.py

    r447 r512  
    3232#---------------------------------------------------------------------------------------
    3333
     34# Derate type: no derate possible
     35DERATE_NONE = 0
     36
     37# Derate type: Boeing, i.e. a percentage value.
     38# For logging, the percentage value is expected as a string (i.e. whatever the
     39# pilot enters into the text field).
     40DERATE_BOEING = 1
     41
     42# Derate type: EPR, i.e. an EPR value.
     43# For logging, the EPR value is expected as a string (i.e. whatever the pilot
     44# enters into the text field).
     45DERATE_EPR = 2
     46
     47# Derate type: Tupolev, i.e. nominal or takeoff
     48# For logging, one of the DERATE_TUPOLEV_xxx values are expected.
     49DERATE_TUPOLEV = 3
     50
     51# Tupolev derate value: nominal
     52DERATE_TUPOLEV_NOMINAL = 1
     53
     54# Tupolev derate value: takeoff
     55DERATE_TUPOLEV_TAKEOFF = 2
     56
     57# Derate type: BAe-146, i.e. enabled or not
     58# For logging, a boolean is expected.
     59DERATE_B462 = 4
     60
     61#---------------------------------------------------------------------------------------
     62
    3463class SmoothedValue(object):
    3564    """A smoothed value."""
     
    203232
    204233    @property
    205     def derateLabels(self):
    206         """Get the strings related to the derate entry.
    207 
    208         It returns a tuple of two items:
    209         - the label before the entry field,
    210         - the label after the entry field, which can be None.
    211 
    212         If both labels are None, the derate value will not be logged or
    213         queried. This is the default."""
    214         return (None, None)
    215 
    216     @property
    217     def derateTemplate(self):
    218         """Get the template for logging the derate value.
    219 
    220         If it returns None (which is the default), no derate value will be
    221         logged."""
     234    def derateType(self):
     235        """Get the derate type for this aircraft.
     236
     237        This default implementation returns DERATE_NONE."""
     238        return DERATE_NONE
     239
     240    def getDerateLine(self, value):
     241        """Get the log line for the given derate value.
     242
     243        It uses the the derate type and produces the standard message for
     244        each. This children need not override it, although they can."""
     245        dt = self.derateType
     246
     247        if dt==DERATE_BOEING:
     248            return "Derate calculated by the pilot: %s %%" % \
     249              ("-" if value is None else value,)
     250        elif dt==DERATE_EPR:
     251            return "EPR calculated by the pilot: %s" % \
     252              ("-" if value is None else value,)
     253        elif dt==DERATE_TUPOLEV:
     254            return "Thrust setting calculated by the pilot: %s" % \
     255              ("-" if value is None else
     256               "nominal" if value==DERATE_TUPOLEV_NOMINAL else "takeoff",)
     257        elif dt==DERATE_B462:
     258            return "Derate setting: %s" % \
     259              ("-" if value is None else "enabled" if value else "disabled",)
     260        elif dt!=DERATE_NONE:
     261            print "mlx.acft.getDerateLine: invalid derate type: " + dt
     262
    222263        return None
    223264
     
    472513        """Log the derate values either newly or by updating the corresponding
    473514        line."""
    474         derateTemplate = self.derateTemplate
    475         if derateTemplate is None:
     515        dt = self.derateType
     516        if dt==DERATE_NONE:
    476517            return
    477518
    478         derate = self._flight.derate
    479         message = derateTemplate % ("-" if derate is None else derate)
    480         if self._derateLineID is None:
    481             if state is None:
    482                 state = self._aircraftState
    483             self._derateLineID = \
    484                 self.logger.message(state.timestamp, message)
    485         else:
    486             self.logger.updateLine(self._derateLineID, message)
     519        message = self.getDerateLine(self._flight.derate)
     520        if message is not None:
     521            if self._derateLineID is None:
     522                if state is None:
     523                    state = self._aircraftState
     524                self._derateLineID = \
     525                  self.logger.message(state.timestamp, message)
     526            else:
     527                self.logger.updateLine(self._derateLineID, message)
    487528
    488529    def _logTakeoffAntiIce(self, state = None):
     
    607648
    608649    @property
    609     def derateLabels(self):
    610         """Get the derate strings for this type."""
    611         return (xstr("takeoff_derate_boeing"), "%")
    612 
    613     @property
    614     def derateTemplate(self):
    615         """Get the derate template for this aicraft type."""
    616         return "Derate calculated by the pilot: %s %%"
     650    def derateType(self):
     651        """Get the derate type for this type."""
     652        return DERATE_BOEING
    617653
    618654    # def _appendSpeedChecker(self):
     
    741777
    742778    @property
    743     def derateLabels(self):
    744         """Get the derate strings for this type."""
    745         return (xstr("takeoff_derate_boeing"), "%")
    746 
    747     @property
    748     def derateTemplate(self):
    749         """Get the derate template for this aicraft type."""
    750         return "Derate calculated by the pilot: %s %%"
     779    def derateType(self):
     780        """Get the derate type for this type."""
     781        return DERATE_BOEING
    751782
    752783#---------------------------------------------------------------------------------------
     
    819850
    820851    @property
    821     def derateLabels(self):
    822         """Get the derate strings for this type."""
    823         return ("EPR", None)
    824 
    825     @property
    826     def derateTemplate(self):
    827         """Get the derate template for this aicraft type."""
    828         return "EPR calculated by the pilot: %s"
     852    def derateType(self):
     853        """Get the derate type for this type."""
     854        return DERATE_EPR
    829855
    830856#---------------------------------------------------------------------------------------
     
    881907
    882908    @property
    883     def derateLabels(self):
    884         """Get the derate strings for this type."""
    885         return (xstr("takeoff_derate_tupolev"), None)
    886 
    887     @property
    888     def derateTemplate(self):
    889         """Get the derate template for this aicraft type."""
    890         return "Nominal/takeoff power calculated by the pilot: %s"
     909    def derateType(self):
     910        """Get the derate type for this type."""
     911        return DERATE_TUPOLEV
    891912
    892913    @property
     
    939960
    940961    @property
    941     def derateLabels(self):
    942         """Get the derate strings for this type."""
    943         return (xstr("takeoff_derate_tupolev"), None)
    944 
    945     @property
    946     def derateTemplate(self):
    947         """Get the derate template for this aicraft type."""
    948         return "Nominal/takeoff power calculated by the pilot: %s"
     962    def derateType(self):
     963        """Get the derate type for this type."""
     964        return DERATE_TUPOLEV
    949965
    950966    def _appendLightsLoggers(self):
     
    9901006
    9911007    @property
    992     def derateLabels(self):
    993         """Get the derate strings for this type."""
    994         return (xstr("takeoff_derate_tupolev"), None)
    995 
    996     @property
    997     def derateTemplate(self):
    998         """Get the derate template for this aicraft type."""
    999         return "Nominal/takeoff power calculated by the pilot: %s"
     1008    def derateType(self):
     1009        """Get the derate type for this type."""
     1010        return DERATE_TUPOLEV
    10001011
    10011012    def _appendLightsLoggers(self):
     
    10381049
    10391050    @property
    1040     def derateLabels(self):
    1041         """Get the derate strings for this type."""
    1042         return (xstr("takeoff_derate_b462"), None)
    1043 
    1044     @property
    1045     def derateTemplate(self):
    1046         """Get the derate template for this aicraft type."""
    1047         return "Derate enabled: %s"
     1051    def derateType(self):
     1052        """Get the derate type for this type."""
     1053        return DERATE_B462
    10481054
    10491055#---------------------------------------------------------------------------------------
  • src/mlx/gui/flight.py

    r436 r512  
    20902090        table.attach(self._v2Unit, 3, 4, 4, 5)
    20912091
    2092         self._hasDerate = False
     2092        self._derateType = acft.DERATE_NONE
    20932093
    20942094        self._derateLabel = gtk.Label()
     
    20982098        table.attach(self._derateLabel, 0, 1, 5, 6)
    20992099
    2100         self._derate = gtk.Entry()
    2101         self._derate.set_width_chars(10)
    2102         self._derate.set_tooltip_text(xstr("takeoff_derate_tooltip"))
    2103         self._derate.set_alignment(1.0)
    2104         self._derate.connect("changed", self._derateChanged)
    2105         table.attach(self._derate, 1, 3, 5, 6)
    2106         self._derateLabel.set_mnemonic_widget(self._derate)
    2107 
    2108         self._derateUnit = gtk.Label("")
    2109         self._derateUnit.set_use_markup(True)
    2110         self._derateUnit.set_alignment(0.0, 0.5)
    2111         table.attach(self._derateUnit, 3, 4, 5, 6)
     2100        self._derate = gtk.Alignment()
     2101        table.attach(self._derate, 2, 4, 5, 6)
     2102        self._derateWidget = None
     2103        self._derateEntry = None
     2104        self._derateUnit = None
     2105        self._derateButtons = None
    21122106
    21132107        self._antiIceOn = gtk.CheckButton(xstr("takeoff_antiice"))
     
    21562150    def derate(self):
    21572151        """Get the derate value, if any."""
    2158         if self._hasDerate:
    2159             derate = self._derate.get_text()
     2152        if self._derateWidget is None:
     2153            return None
     2154        if self._derateType==acft.DERATE_BOEING:
     2155            derate = self._derateEntry.get_text()
    21602156            return derate if derate else None
     2157        elif self._derateType==acft.DERATE_EPR:
     2158            derate = self._derateWidget.get_text()
     2159            return derate if derate else None
     2160        elif self._derateType==acft.DERATE_TUPOLEV:
     2161            return acft.DERATE_TUPOLEV_NOMINAL \
     2162                   if self._derateButtons[0].get_active() \
     2163                   else acft.DERATE_TUPOLEV_TAKEOFF
     2164        elif self._derateType==acft.DERATE_B462:
     2165            return self._derateWidget.get_active()
    21612166        else:
    21622167            return None
     
    22002205        self._v2.set_tooltip_markup(xstr("takeoff_v2_tooltip" + i18nSpeedUnit))
    22012206
    2202         (derateLabel, derateUnit) = \
    2203              self._wizard.gui.flight.aircraft.derateLabels
    2204 
    2205         self._hasDerate = derateLabel is not None
    2206 
    2207         if self._hasDerate:
    2208             self._derateLabel.set_markup(derateLabel)
    2209             self._derateLabel.set_use_underline(True)
    2210             self._derateUnit.set_markup("" if derateUnit is None
    2211                                         else derateUnit)
    2212         else:
    2213             self._derateLabel.set_markup(xstr("takeoff_derate"))
    2214             self._derateUnit.set_text("")
    2215 
    2216         self._derate.set_text("")
    2217 
    2218         self._derateLabel.set_sensitive(self._hasDerate)
    2219         self._derate.set_sensitive(self._hasDerate)
    2220         self._derateUnit.set_sensitive(self._hasDerate)
     2207        self._derateType = self._wizard.gui.flight.aircraft.derateType
     2208
     2209        self._setupDerateWidget()
    22212210
    22222211        self._rto.set_active(False)
     
    22562245                    self.v1 <= self.vr and \
    22572246                    self.vr <= self.v2 and \
    2258                     (not self._hasDerate or self._derate.get_text()!="")
     2247                    (self._derateType==acft.DERATE_NONE or
     2248                     self.derate is not None)
    22592249        self._button.set_sensitive(sensitive)
    22602250
     
    22852275        aircraft = self._wizard.gui.flight.aircraft
    22862276        aircraft.updateV1R2()
    2287         if self._hasDerate:
     2277        if self.derate is not None:
    22882278            aircraft.updateDerate()
    22892279        aircraft.updateTakeoffAntiIce()
    22902280        self._wizard.nextPage()
     2281
     2282    def _setupDerateWidget(self):
     2283        """Setup the derate widget."""
     2284        if self._derateWidget is not None:
     2285            self._derate.remove(self._derateWidget)
     2286
     2287        if self._derateType==acft.DERATE_BOEING:
     2288            self._derateLabel.set_text(xstr("takeoff_derate_boeing"))
     2289            self._derateLabel.set_use_underline(True)
     2290            self._derateLabel.set_sensitive(True)
     2291
     2292            self._derateEntry = gtk.Entry()
     2293            self._derateEntry.set_width_chars(7)
     2294            self._derateEntry.set_tooltip_text(xstr("takeoff_derate_boeing_tooltip"))
     2295            self._derateEntry.set_alignment(1.0)
     2296            self._derateEntry.connect("changed", self._derateChanged)
     2297            self._derateLabel.set_mnemonic_widget(self._derateEntry)
     2298
     2299            self._derateUnit = gtk.Label("%")
     2300            self._derateUnit.set_alignment(0.0, 0.5)
     2301
     2302            self._derateWidget = gtk.Table(3, 1)
     2303            self._derateWidget.set_row_spacings(4)
     2304            self._derateWidget.set_col_spacings(16)
     2305            self._derateWidget.set_homogeneous(False)
     2306
     2307            self._derateWidget.attach(self._derateEntry, 0, 2, 0, 1)
     2308            self._derateWidget.attach(self._derateUnit, 2, 3, 0, 1)
     2309
     2310            self._derate.add(self._derateWidget)
     2311        elif self._derateType==acft.DERATE_EPR:
     2312            self._derateLabel.set_text("_EPR:")
     2313            self._derateLabel.set_use_underline(True)
     2314            self._derateLabel.set_sensitive(True)
     2315
     2316            self._derateWidget = gtk.Entry()
     2317            self._derateWidget.set_width_chars(7)
     2318            self._derateWidget.set_tooltip_text(xstr("takeoff_derate_epr_tooltip"))
     2319            self._derateWidget.set_alignment(1.0)
     2320            self._derateWidget.connect("changed", self._derateChanged)
     2321            self._derateLabel.set_mnemonic_widget(self._derateWidget)
     2322
     2323            self._derate.add(self._derateWidget)
     2324        elif self._derateType==acft.DERATE_TUPOLEV:
     2325            self._derateLabel.set_text(xstr("takeoff_derate_tupolev"))
     2326            self._derateLabel.set_use_underline(True)
     2327            self._derateLabel.set_sensitive(True)
     2328
     2329            if pygobject:
     2330                nominal = gtk.RadioButton.\
     2331                  new_with_label_from_widget(None,
     2332                                             xstr("takeoff_derate_tupolev_nominal"))
     2333            else:
     2334                nominal = gtk.RadioButton(None,
     2335                                          xstr("takeoff_derate_tupolev_nominal"))
     2336            nominal.set_use_underline(True)
     2337            nominal.set_tooltip_text(xstr("takeoff_derate_tupolev_nominal_tooltip"))
     2338            nominal.connect("toggled", self._derateChanged)
     2339
     2340            if pygobject:
     2341                takeoff = gtk.RadioButton.\
     2342                  new_with_label_from_widget(nominal,
     2343                                             xstr("takeoff_derate_tupolev_takeoff"))
     2344            else:
     2345                takeoff = gtk.RadioButton(nominal,
     2346                                          xstr("takeoff_derate_tupolev_takeoff"))
     2347
     2348            takeoff.set_use_underline(True)
     2349            takeoff.set_tooltip_text(xstr("takeoff_derate_tupolev_takeoff_tooltip"))
     2350            takeoff.connect("toggled", self._derateChanged)
     2351
     2352            self._derateButtons = [nominal, takeoff]
     2353
     2354            self._derateWidget = gtk.HBox()
     2355            self._derateWidget.pack_start(nominal, False, False, 4)
     2356            self._derateWidget.pack_start(takeoff, False, False, 4)
     2357
     2358            self._derate.add(self._derateWidget)
     2359        elif self._derateType==acft.DERATE_B462:
     2360            self._derateLabel.set_text("")
     2361
     2362            self._derateWidget = gtk.CheckButton(xstr("takeoff_derate_b462"))
     2363            self._derateWidget.set_tooltip_text(xstr("takeoff_derate_b462_tooltip"))
     2364            self._derateWidget.set_use_underline(True)
     2365            self._derate.add(self._derateWidget)
     2366        else:
     2367            self._derateWidget = None
     2368            self._derateLabel.set_text("")
     2369            self._derateLabel.set_sensitive(False)
    22912370
    22922371#-----------------------------------------------------------------------------
Note: See TracChangeset for help on using the changeset viewer.