Changeset 241:dea155dd3ac0


Ignore:
Timestamp:
06/10/12 12:32:09 (12 years ago)
Author:
István Váradi <ivaradi@…>
Branch:
default
Phase:
public
Message:

Added support for calculating speeds in km/h for Soviet aircraft

Files:
9 edited

Legend:

Unmodified
Added
Removed
  • src/mlx/acft.py

    r215 r241  
    145145        """Get the current aircraft state."""
    146146        return self._aircraftState
     147
     148    @property
     149    def speedInKnots(self):
     150        """Indicate if the speed is in knots.
     151
     152        This default implementation returns True."""
     153        return True
    147154   
    148155    def getFlapsSpeedLimit(self, flaps):
     
    200207                                   5)
    201208            elif newStage==const.STAGE_TAKEOFF:
    202                 self.logger.message(aircraftState.timestamp, "Flight time start")
     209                self.logger.message(aircraftState.timestamp,
     210                                    "Flight time start")
    203211                self.logger.message(aircraftState.timestamp,
    204212                                    "Takeoff weight: %.0f kg, MTOW: %.0f kg" % \
     
    281289                            "Touchdown rate was calculated by the %s" % \
    282290                            ("simulator" if tdRateCalculatedByFS else "logger",))
     291        flight = self._flight
    283292        self.logger.message(self._aircraftState.timestamp,
    284                             "Touchdown speed: %.0f knots" % (ias,))
     293                            "Touchdown speed: %.0f %s" % \
     294                            (flight.speedFromKnots(ias),
     295                             flight.getEnglishSpeedUnit()))
    285296        self.logger.message(self._aircraftState.timestamp,
    286297                            "Touchdown pitch: %.1f degrees" % (pitch,))
     
    329340        self._checkers.append(checks.StrobeLightsChecker())
    330341
     342    def _speedToLog(self, speed):
     343        """Convert the given speed (being either None or expressed in the
     344        flight's speed unit into a string."""
     345        if speed is None:
     346            return "-"
     347        else:
     348            return str(speed) + " " + self._flight.getEnglishSpeedUnit()
     349
    331350    def _logV1R2(self):
    332351        """Log the V1, Vr and V2 value either newly, or by updating the
    333352        corresponding line."""
    334353        message = "Speeds calculated by the pilot: V1: %s, VR: %s, V2: %s" % \
    335                   ("-" if self._flight.v1 is None
    336                    else str(self._flight.v1),
    337                    "-" if self._flight.vr is None
    338                    else str(self._flight.vr),
    339                    "-" if self._flight.v2 is None
    340                    else str(self._flight.v2))
     354                  (self._speedToLog(self._flight.v1),
     355                   self._speedToLog(self._flight.vr),
     356                   self._speedToLog(self._flight.v2))
    341357
    342358        if self._v1r2LineIndex is None:
     
    356372        line."""
    357373        message = "VRef speed calculated by the pilot: %s" % \
    358                   ("-" if self._flight.vref is None else str(self._flight.vref))
     374                  (self._speedToLog(self._flight.vref),)
    359375        if self._vrefLineIndex is None:
    360376            self._vrefLineIndex = \
     
    710726                                 30 : 300 }
    711727
     728    @property
     729    def speedInKnots(self):
     730        """Indicate if the speed is in knots."""
     731        return False
     732   
    712733    def logFuel(self, aircraftState):
    713734        """Log the amount of fuel"""
     
    758779                                 45 : 162 }
    759780
     781    @property
     782    def speedInKnots(self):
     783        """Indicate if the speed is in knots."""
     784        return False
     785   
    760786    def logFuel(self, aircraftState):
    761787        """Log the amount of fuel"""
     
    804830                                 35 : 135 }
    805831
     832    @property
     833    def speedInKnots(self):
     834        """Indicate if the speed is in knots."""
     835        return False
     836   
    806837    def logFuel(self, aircraftState):
    807838        """Log the amount of fuel"""
  • src/mlx/checks.py

    r211 r241  
    135135           self._onTheGround and not state.onTheGround:
    136136            logger.message(state.timestamp,
    137                            "Takeoff speed: %.0f knots" % (state.ias,))
     137                           "Takeoff speed: %.0f %s" % \
     138                           (flight.speedFromKnots(state.ias),
     139                            flight.getEnglishSpeedUnit()))
    138140            logger.message(state.timestamp,
    139141                           "Takeoff heading: %03.0f degrees" % (state.heading,))
     
    160162                else:
    161163                    logger.message(state.timestamp,
    162                                    "Cruise speed: %.0f knots" % (state.ias,))
     164                                   "Cruise speed: %.0f %s" %
     165                                   (flight.speedFromKnots(state.ias),
     166                                    flight.getEnglishSpeedUnit()))
    163167                self._lastTime = state.timestamp
    164168
     
    225229        - _changed(self, oldState, state): returns a boolean indicating if the
    226230        value has changed or not
    227         - _getMessage(self, state): return a strings containing the message to log
    228         with the new value
     231        - _getMessage(self, flight, state): return a strings containing the
     232        message to log with the new value
    229233        """
    230234        self._logInitial = logInitial   
     
    243247       
    244248        if shouldLog:
    245             logger.message(self._getLogTimestamp(state), self._getMessage(state))
     249            logger.message(self._getLogTimestamp(state),
     250                           self._getMessage(flight, state))
    246251       
    247 #---------------------------------------------------------------------------------------
     252#-------------------------------------------------------------------------------
    248253
    249254class SimpleChangeMixin(object):
     
    322327        self._template = template
    323328
    324     def _getMessage(self, state):
     329    def _getMessage(self, flight, state):
    325330        """Get the message."""
    326331        return self._template % (self._getValue(state),)
     
    355360                                DelayedChangeMixin._getLogTimestamp(self, state)
    356361
    357     def _getMessage(self, state):
     362    def _getMessage(self, flight, state):
    358363        """Get the message to log on a change."""
    359364        logState = self._lastChangeState if \
     
    398403        self._template = template
    399404
    400     def _getMessage(self, state):
     405    def _getMessage(self, flight, state):
    401406        """Get the message from the given state."""
    402407        return self._template % ("ON" if self._getValue(state) else "OFF")
     
    443448        SingleValueMixin.__init__(self, "flapsSet")
    444449
    445     def _getMessage(self, state):
     450    def _getMessage(self, flight, state):
    446451        """Get the message to log on a change."""
    447452        speed = state.groundSpeed if state.groundSpeed<80.0 else state.ias
    448         return "Flaps set to %.0f at %.0f knots" % (state.flapsSet, speed)
     453        return "Flaps set to %.0f at %.0f %s" % \
     454               (state.flapsSet, flight.speedFromKnots(speed),
     455                flight.getEnglishSpeedUnit())
    449456
    450457#---------------------------------------------------------------------------------------
     
    457464        SingleValueMixin.__init__(self, "gearControlDown")
    458465
    459     def _getMessage(self, state):
     466    def _getMessage(self, flight, state):
    460467        """Get the message to log on a change."""
    461         return "Gears SET to %s at %.0f knots, %.0f feet" % \
     468        return "Gears SET to %s at %.0f %s, %.0f feet" % \
    462469            ("DOWN" if state.gearControlDown else "UP",
    463              state.ias, state.altitude)
     470             flight.speedFromKnots(state.ias),
     471             flight.getEnglishSpeedUnit(), state.altitude)
    464472
    465473#---------------------------------------------------------------------------------------
     
    889897    def logFault(self, flight, aircraft, logger, oldState, state):
    890898        """Log the fault."""
     899        message = "Reverser used below %.0f %s" % \
     900                  (flight.speedFromKnots(60), flight.getEnglishSpeedUnit())
    891901        flight.handleFault(ReverserChecker, state.timestamp,
    892                            FaultChecker._appendDuring(flight,
    893                                                       "Reverser used below 60 knots"),
    894                            15)       
     902                           FaultChecker._appendDuring(flight, message),
     903                           15)
    895904
    896905#---------------------------------------------------------------------------------------
     
    906915    def logFault(self, flight, aircraft, logger, oldState, state):
    907916        """Log the fault."""
     917        message = "Taxi speed over %.0f %s" % \
     918                  (flight.speedFromKnots(50), flight.getEnglishSpeedUnit())
    908919        flight.handleFault(SpeedChecker, state.timestamp,
    909                            FaultChecker._appendDuring(flight,
    910                                                       "Taxi speed over 50 knots"),
     920                           FaultChecker._appendDuring(flight, message),
    911921                           FaultChecker._getLinearScore(50, 80, 10, 15,
    912922                                                        state.groundSpeed))
  • src/mlx/const.py

    r231 r241  
    44
    55# The version of the program
    6 VERSION="0.3"
     6VERSION="0.4"
    77
    88#-------------------------------------------------------------------------------
     
    1616# The ratio between feet and metre
    1717FEETTOMETRES=0.3048
     18
     19#-------------------------------------------------------------------------------
     20
     21# The ratio between knots and km/h
     22KNOTSTOKMPH=1.852
     23
     24# The ratio between km/h and knots
     25KMPHTOKNOTS=1/1.852
    1826
    1927#-------------------------------------------------------------------------------
  • src/mlx/flight.py

    r215 r241  
    116116        """Get the touchdown rate if known, None otherwise."""
    117117        return self._tdRate
     118
     119    @property
     120    def speedInKnots(self):
     121        """Determine if the speeds for the flight are to be expressed in
     122        knots."""
     123        return self.aircraft.speedInKnots if self.aircraft is not None \
     124               else True
    118125
    119126    def handleState(self, oldState, currentState):
     
    207214        self._checklistHotkeyPressed = True
    208215
     216    def speedFromKnots(self, knots):
     217        """Convert the given speed value expressed in knots into the flight's
     218        speed unit."""
     219        return knots if self.speedInKnots else knots * const.KNOTSTOKMPH
     220
     221    def speedToKnots(self, speed):
     222        """Convert the given speed expressed in the flight's speed unit into
     223        knots."""       
     224        return speed if self.speedInKnots else speed * const.KMPHTOKNOTS
     225
     226    def getEnglishSpeedUnit(self):
     227        """Get the English name of the speed unit used by the flight."""
     228        return "knots" if self.speedInKnots else "km/h"
     229
     230    def getI18NSpeedUnit(self):
     231        """Get the speed unit suffix for i18n message identifiers."""
     232        return "_knots" if self.speedInKnots else "_kmph"
     233
    209234    def _updateFlownDistance(self, currentState):
    210235        """Update the flown distance."""
  • src/mlx/gui/common.py

    r232 r241  
    179179        return self._currentInteger
    180180
     181    def reset(self):
     182        """Reset the integer."""
     183        self.set_int(None)
     184
    181185    def set_int(self, value):
    182186        """Set the integer."""
  • src/mlx/gui/flight.py

    r233 r241  
    18881888        self._v1 = IntegerEntry()
    18891889        self._v1.set_width_chars(4)
    1890         self._v1.set_tooltip_markup(xstr("takeoff_v1_tooltip"))
     1890        self._v1.set_tooltip_markup(xstr("takeoff_v1_tooltip_knots"))
    18911891        self._v1.connect("integer-changed", self._valueChanged)
    18921892        table.attach(self._v1, 2, 3, 2, 3)
    18931893        label.set_mnemonic_widget(self._v1)
    1894        
    1895         table.attach(gtk.Label(xstr("label_knots")), 3, 4, 2, 3)
     1894
     1895        self._v1Unit = gtk.Label(xstr("label_knots"))
     1896        table.attach(self._v1Unit, 3, 4, 2, 3)
    18961897       
    18971898        label = gtk.Label(xstr("takeoff_vr"))
     
    19031904        self._vr = IntegerEntry()
    19041905        self._vr.set_width_chars(4)
    1905         self._vr.set_tooltip_markup(xstr("takeoff_vr_tooltip"))
     1906        self._vr.set_tooltip_markup(xstr("takeoff_vr_tooltip_knots"))
    19061907        self._vr.connect("integer-changed", self._valueChanged)
    19071908        table.attach(self._vr, 2, 3, 3, 4)
    19081909        label.set_mnemonic_widget(self._vr)
    19091910       
    1910         table.attach(gtk.Label(xstr("label_knots")), 3, 4, 3, 4)
     1911        self._vrUnit = gtk.Label(xstr("label_knots"))
     1912        table.attach(self._vrUnit, 3, 4, 3, 4)
    19111913       
    19121914        label = gtk.Label(xstr("takeoff_v2"))
     
    19181920        self._v2 = IntegerEntry()
    19191921        self._v2.set_width_chars(4)
    1920         self._v2.set_tooltip_markup(xstr("takeoff_v2_tooltip"))
     1922        self._v2.set_tooltip_markup(xstr("takeoff_v2_tooltip_knots"))
    19211923        self._v2.connect("integer-changed", self._valueChanged)
    19221924        table.attach(self._v2, 2, 3, 4, 5)
    19231925        label.set_mnemonic_widget(self._v2)
    19241926       
    1925         table.attach(gtk.Label(xstr("label_knots")), 3, 4, 4, 5)
     1927        self._v2Unit = gtk.Label(xstr("label_knots"))
     1928        table.attach(self._v2Unit, 3, 4, 4, 5)
    19261929
    19271930        self.addCancelFlightButton()
     
    19681971        self._v2.set_int(None)
    19691972        self._v2.set_sensitive(True)
     1973
     1974        i18nSpeedUnit = self._wizard.gui.flight.getI18NSpeedUnit()
     1975        speedUnit = xstr("label" + i18nSpeedUnit)
     1976        self._v1Unit.set_text(speedUnit)
     1977        self._vrUnit.set_text(speedUnit)
     1978        self._v2Unit.set_text(speedUnit)
     1979
     1980        self._v1.set_tooltip_markup(xstr("takeoff_v1_tooltip" + i18nSpeedUnit))
     1981        self._vr.set_tooltip_markup(xstr("takeoff_vr_tooltip" + i18nSpeedUnit))
     1982        self._v2.set_tooltip_markup(xstr("takeoff_v2_tooltip" + i18nSpeedUnit))
     1983
    19701984        self._button.set_sensitive(False)
    19711985        self._forwardAllowed = False
     
    19851999        self._updateForwardButton()
    19862000
     2001    def reset(self):
     2002        """Reset the page if the wizard is reset."""
     2003        super(TakeoffPage, self).reset()
     2004        self._v1.reset()
     2005        self._vr.reset()
     2006        self._v2.reset()
     2007       
    19872008    def _updateForwardButton(self):
    19882009        """Update the sensitivity of the forward button based on some conditions."""
     
    21032124        self._vref = IntegerEntry()
    21042125        self._vref.set_width_chars(5)
    2105         self._vref.set_tooltip_markup(xstr("landing_vref_tooltip"))
     2126        self._vref.set_tooltip_markup(xstr("landing_vref_tooltip_knots"))
    21062127        self._vref.connect("integer-changed", self._vrefChanged)
    21072128        table.attach(self._vref, 3, 4, 5, 6)
    21082129        label.set_mnemonic_widget(self._vref)
    2109        
    2110         table.attach(gtk.Label(xstr("label_knots")), 4, 5, 5, 6)
     2130
     2131        self._vrefUnit = gtk.Label(xstr("label_knots"))
     2132        table.attach(self._vrefUnit, 4, 5, 5, 6)
    21112133
    21122134        self.addCancelFlightButton()
     
    21492171        """Reset the page if the wizard is reset."""
    21502172        super(LandingPage, self).reset()
     2173        self._vref.reset()
    21512174        self._flightEnded = False
    2152 
     2175       
    21532176    def activate(self):
    21542177        """Called when the page is activated."""
     
    21692192        self._vref.set_int(None)
    21702193        self._vref.set_sensitive(True)
     2194
     2195        i18nSpeedUnit = self._wizard.gui.flight.getI18NSpeedUnit()
     2196        speedUnit = xstr("label" + i18nSpeedUnit)
     2197        self._vrefUnit.set_text(speedUnit)
     2198
     2199        self._vref.set_tooltip_markup(xstr("landing_vref_tooltip" +
     2200                                           i18nSpeedUnit))
    21712201
    21722202        self._updateForwardButton()
  • src/mlx/gui/gui.py

    r239 r241  
    338338        """Called when we have connected to the simulator."""
    339339        self._connected = True
    340         self._logger.untimedMessage("Connected to the simulator %s" % (descriptor,))
     340        self._logger.untimedMessage("MLX %s connected to the simulator %s" % \
     341                                    (const.VERSION, descriptor))
    341342        fs.sendMessage(const.MESSAGETYPE_INFORMATION,
    342343                       "Welcome to MAVA Logger X " + const.VERSION)
  • src/mlx/i18n.py

    r237 r241  
    477477        self.add("takeoff_sid_tooltip",
    478478                 "The name of the Standard Instrument Deparature procedure followed.")
     479        self.add("label_knots", "knots")
     480        self.add("label_kmph", "km/h")
    479481        self.add("takeoff_v1", "V<sub>_1</sub>:")
    480         self.add("takeoff_v1_tooltip", "The takeoff decision speed in knots.")
    481         self.add("label_knots", "knots")
     482        self.add("takeoff_v1_tooltip_knots", "The takeoff decision speed in knots.")
     483        self.add("takeoff_v1_tooltip_kmph", "The takeoff decision speed in km/h.")
    482484        self.add("takeoff_vr", "V<sub>_R</sub>:")
    483         self.add("takeoff_vr_tooltip", "The takeoff rotation speed in knots.")
     485        self.add("takeoff_vr_tooltip_knots", "The takeoff rotation speed in knots.")
     486        self.add("takeoff_vr_tooltip_kmph", "The takeoff rotation speed in km/h.")
    484487        self.add("takeoff_v2", "V<sub>_2</sub>:")
    485         self.add("takeoff_v2_tooltip", "The takeoff safety speed in knots.")
     488        self.add("takeoff_v2_tooltip_knots", "The takeoff safety speed in knots.")
     489        self.add("takeoff_v2_tooltip_kmph", "The takeoff safety speed in km/h.")
    486490
    487491        self.add("landing_title", "Landing")
     
    505509                 "The type of the approach, e.g. ILS or VISUAL.")
    506510        self.add("landing_vref", "V<sub>_Ref</sub>:")
    507         self.add("landing_vref_tooltip",
     511        self.add("landing_vref_tooltip_knots",
    508512                 "The landing reference speed in knots.")
     513        self.add("landing_vref_tooltip_kmph",
     514                 "The landing reference speed in km/h.")
    509515
    510516        self.add("flighttype_scheduled", "scheduled")
     
    13131319                 "Az alkalmazott szabványos műszeres indulási eljárás neve.")
    13141320        self.add("takeoff_v1", "V<sub>_1</sub>:")
    1315         self.add("takeoff_v1_tooltip", "Az elhatározási sebesség csomóban.")
     1321        self.add("takeoff_v1_tooltip_knots", "Az elhatározási sebesség csomóban.")
     1322        self.add("takeoff_v1_tooltip_kmph", "Az elhatározási sebesség km/órában.")
    13161323        self.add("label_knots", "csomó")
     1324        self.add("label_kmph", "km/h")
    13171325        self.add("takeoff_vr", "V<sub>_R</sub>:")
    1318         self.add("takeoff_vr_tooltip", "Az elemelkedési sebesség csomóban.")
     1326        self.add("takeoff_vr_tooltip_knots", "Az elemelkedési sebesség csomóban.")
     1327        self.add("takeoff_vr_tooltip_kmph", "Az elemelkedési sebesség km/órában.")
    13191328        self.add("takeoff_v2", "V<sub>_2</sub>:")
    1320         self.add("takeoff_v2_tooltip", "A biztonságos emelkedési sebesség csomóban.")
     1329        self.add("takeoff_v2_tooltip_knots",
     1330                 "A biztonságos emelkedési sebesség csomóban.")
     1331        self.add("takeoff_v2_tooltip_kmph",
     1332                 "A biztonságos emelkedési sebesség km/órában.")
    13211333       
    13221334        self.add("landing_title", "Leszállás")
     
    13411353                 "A megközelítgés típusa, pl. ILS vagy VISUAL.")
    13421354        self.add("landing_vref", "V<sub>_Ref</sub>:")
    1343         self.add("landing_vref_tooltip",
     1355        self.add("landing_vref_tooltip_knots",
    13441356                 "A leszállási sebesség csomóban.")
     1357        self.add("landing_vref_tooltip_km/h",
     1358                 "A leszállási sebesség km/órában.")
    13451359       
    13461360        self.add("flighttype_scheduled", "menetrendszerinti")
  • test/test1.txt

    r183 r241  
     1set lights=0
    12set zfw=46741 hour=7 min=50
    23set latitude=47.44 longitude=19.26
    34set parking=no
     5set gs=10 ias=10
    46set flapsControl=37.5
     7set gs=60 ias=60
    58set lights=21
     9set gs=80 ias=80
     10set gs=90 ias=90
     11set gs=100 ias=100
     12set gs=120 ias=120
    613set onTheGround=no
    714set altitude=600
     
    1118set altitude=10000
    1219set lights=17
     20set ias=400
    1321set altitude=22001
    1422set vs=-200
    1523set flapsControl=87.5
     24set ias=130 gs=130
    1625set altitude=557
     26set ias=125 gs=125
    1727set noseGear=100
    1828set altitude=547
     
    2232set latitude=47.49 longitude=21.62
    2333set onTheGround=yes
     34set ias=45 gs=45
     35set ias=35 gs=35
     36set ias=20 gs=20
     37set ias=0 gs=0
    2438set parking=yes
Note: See TracChangeset for help on using the changeset viewer.