Changeset 241:dea155dd3ac0
- Timestamp:
- 06/10/12 12:32:09 (12 years ago)
- Branch:
- default
- Phase:
- public
- Files:
-
- 9 edited
Legend:
- Unmodified
- Added
- Removed
-
src/mlx/acft.py
r215 r241 145 145 """Get the current aircraft state.""" 146 146 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 147 154 148 155 def getFlapsSpeedLimit(self, flaps): … … 200 207 5) 201 208 elif newStage==const.STAGE_TAKEOFF: 202 self.logger.message(aircraftState.timestamp, "Flight time start") 209 self.logger.message(aircraftState.timestamp, 210 "Flight time start") 203 211 self.logger.message(aircraftState.timestamp, 204 212 "Takeoff weight: %.0f kg, MTOW: %.0f kg" % \ … … 281 289 "Touchdown rate was calculated by the %s" % \ 282 290 ("simulator" if tdRateCalculatedByFS else "logger",)) 291 flight = self._flight 283 292 self.logger.message(self._aircraftState.timestamp, 284 "Touchdown speed: %.0f knots" % (ias,)) 293 "Touchdown speed: %.0f %s" % \ 294 (flight.speedFromKnots(ias), 295 flight.getEnglishSpeedUnit())) 285 296 self.logger.message(self._aircraftState.timestamp, 286 297 "Touchdown pitch: %.1f degrees" % (pitch,)) … … 329 340 self._checkers.append(checks.StrobeLightsChecker()) 330 341 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 331 350 def _logV1R2(self): 332 351 """Log the V1, Vr and V2 value either newly, or by updating the 333 352 corresponding line.""" 334 353 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)) 341 357 342 358 if self._v1r2LineIndex is None: … … 356 372 line.""" 357 373 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),) 359 375 if self._vrefLineIndex is None: 360 376 self._vrefLineIndex = \ … … 710 726 30 : 300 } 711 727 728 @property 729 def speedInKnots(self): 730 """Indicate if the speed is in knots.""" 731 return False 732 712 733 def logFuel(self, aircraftState): 713 734 """Log the amount of fuel""" … … 758 779 45 : 162 } 759 780 781 @property 782 def speedInKnots(self): 783 """Indicate if the speed is in knots.""" 784 return False 785 760 786 def logFuel(self, aircraftState): 761 787 """Log the amount of fuel""" … … 804 830 35 : 135 } 805 831 832 @property 833 def speedInKnots(self): 834 """Indicate if the speed is in knots.""" 835 return False 836 806 837 def logFuel(self, aircraftState): 807 838 """Log the amount of fuel""" -
src/mlx/checks.py
r211 r241 135 135 self._onTheGround and not state.onTheGround: 136 136 logger.message(state.timestamp, 137 "Takeoff speed: %.0f knots" % (state.ias,)) 137 "Takeoff speed: %.0f %s" % \ 138 (flight.speedFromKnots(state.ias), 139 flight.getEnglishSpeedUnit())) 138 140 logger.message(state.timestamp, 139 141 "Takeoff heading: %03.0f degrees" % (state.heading,)) … … 160 162 else: 161 163 logger.message(state.timestamp, 162 "Cruise speed: %.0f knots" % (state.ias,)) 164 "Cruise speed: %.0f %s" % 165 (flight.speedFromKnots(state.ias), 166 flight.getEnglishSpeedUnit())) 163 167 self._lastTime = state.timestamp 164 168 … … 225 229 - _changed(self, oldState, state): returns a boolean indicating if the 226 230 value has changed or not 227 - _getMessage(self, state): return a strings containing the message to log228 with the new value231 - _getMessage(self, flight, state): return a strings containing the 232 message to log with the new value 229 233 """ 230 234 self._logInitial = logInitial … … 243 247 244 248 if shouldLog: 245 logger.message(self._getLogTimestamp(state), self._getMessage(state)) 249 logger.message(self._getLogTimestamp(state), 250 self._getMessage(flight, state)) 246 251 247 #------------------------------------------------------------------------------- --------252 #------------------------------------------------------------------------------- 248 253 249 254 class SimpleChangeMixin(object): … … 322 327 self._template = template 323 328 324 def _getMessage(self, state):329 def _getMessage(self, flight, state): 325 330 """Get the message.""" 326 331 return self._template % (self._getValue(state),) … … 355 360 DelayedChangeMixin._getLogTimestamp(self, state) 356 361 357 def _getMessage(self, state):362 def _getMessage(self, flight, state): 358 363 """Get the message to log on a change.""" 359 364 logState = self._lastChangeState if \ … … 398 403 self._template = template 399 404 400 def _getMessage(self, state):405 def _getMessage(self, flight, state): 401 406 """Get the message from the given state.""" 402 407 return self._template % ("ON" if self._getValue(state) else "OFF") … … 443 448 SingleValueMixin.__init__(self, "flapsSet") 444 449 445 def _getMessage(self, state):450 def _getMessage(self, flight, state): 446 451 """Get the message to log on a change.""" 447 452 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()) 449 456 450 457 #--------------------------------------------------------------------------------------- … … 457 464 SingleValueMixin.__init__(self, "gearControlDown") 458 465 459 def _getMessage(self, state):466 def _getMessage(self, flight, state): 460 467 """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" % \ 462 469 ("DOWN" if state.gearControlDown else "UP", 463 state.ias, state.altitude) 470 flight.speedFromKnots(state.ias), 471 flight.getEnglishSpeedUnit(), state.altitude) 464 472 465 473 #--------------------------------------------------------------------------------------- … … 889 897 def logFault(self, flight, aircraft, logger, oldState, state): 890 898 """Log the fault.""" 899 message = "Reverser used below %.0f %s" % \ 900 (flight.speedFromKnots(60), flight.getEnglishSpeedUnit()) 891 901 flight.handleFault(ReverserChecker, state.timestamp, 892 FaultChecker._appendDuring(flight, 893 "Reverser used below 60 knots"), 894 15) 902 FaultChecker._appendDuring(flight, message), 903 15) 895 904 896 905 #--------------------------------------------------------------------------------------- … … 906 915 def logFault(self, flight, aircraft, logger, oldState, state): 907 916 """Log the fault.""" 917 message = "Taxi speed over %.0f %s" % \ 918 (flight.speedFromKnots(50), flight.getEnglishSpeedUnit()) 908 919 flight.handleFault(SpeedChecker, state.timestamp, 909 FaultChecker._appendDuring(flight, 910 "Taxi speed over 50 knots"), 920 FaultChecker._appendDuring(flight, message), 911 921 FaultChecker._getLinearScore(50, 80, 10, 15, 912 922 state.groundSpeed)) -
src/mlx/const.py
r231 r241 4 4 5 5 # The version of the program 6 VERSION="0. 3"6 VERSION="0.4" 7 7 8 8 #------------------------------------------------------------------------------- … … 16 16 # The ratio between feet and metre 17 17 FEETTOMETRES=0.3048 18 19 #------------------------------------------------------------------------------- 20 21 # The ratio between knots and km/h 22 KNOTSTOKMPH=1.852 23 24 # The ratio between km/h and knots 25 KMPHTOKNOTS=1/1.852 18 26 19 27 #------------------------------------------------------------------------------- -
src/mlx/flight.py
r215 r241 116 116 """Get the touchdown rate if known, None otherwise.""" 117 117 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 118 125 119 126 def handleState(self, oldState, currentState): … … 207 214 self._checklistHotkeyPressed = True 208 215 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 209 234 def _updateFlownDistance(self, currentState): 210 235 """Update the flown distance.""" -
src/mlx/gui/common.py
r232 r241 179 179 return self._currentInteger 180 180 181 def reset(self): 182 """Reset the integer.""" 183 self.set_int(None) 184 181 185 def set_int(self, value): 182 186 """Set the integer.""" -
src/mlx/gui/flight.py
r233 r241 1888 1888 self._v1 = IntegerEntry() 1889 1889 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")) 1891 1891 self._v1.connect("integer-changed", self._valueChanged) 1892 1892 table.attach(self._v1, 2, 3, 2, 3) 1893 1893 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) 1896 1897 1897 1898 label = gtk.Label(xstr("takeoff_vr")) … … 1903 1904 self._vr = IntegerEntry() 1904 1905 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")) 1906 1907 self._vr.connect("integer-changed", self._valueChanged) 1907 1908 table.attach(self._vr, 2, 3, 3, 4) 1908 1909 label.set_mnemonic_widget(self._vr) 1909 1910 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) 1911 1913 1912 1914 label = gtk.Label(xstr("takeoff_v2")) … … 1918 1920 self._v2 = IntegerEntry() 1919 1921 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")) 1921 1923 self._v2.connect("integer-changed", self._valueChanged) 1922 1924 table.attach(self._v2, 2, 3, 4, 5) 1923 1925 label.set_mnemonic_widget(self._v2) 1924 1926 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) 1926 1929 1927 1930 self.addCancelFlightButton() … … 1968 1971 self._v2.set_int(None) 1969 1972 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 1970 1984 self._button.set_sensitive(False) 1971 1985 self._forwardAllowed = False … … 1985 1999 self._updateForwardButton() 1986 2000 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 1987 2008 def _updateForwardButton(self): 1988 2009 """Update the sensitivity of the forward button based on some conditions.""" … … 2103 2124 self._vref = IntegerEntry() 2104 2125 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")) 2106 2127 self._vref.connect("integer-changed", self._vrefChanged) 2107 2128 table.attach(self._vref, 3, 4, 5, 6) 2108 2129 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) 2111 2133 2112 2134 self.addCancelFlightButton() … … 2149 2171 """Reset the page if the wizard is reset.""" 2150 2172 super(LandingPage, self).reset() 2173 self._vref.reset() 2151 2174 self._flightEnded = False 2152 2175 2153 2176 def activate(self): 2154 2177 """Called when the page is activated.""" … … 2169 2192 self._vref.set_int(None) 2170 2193 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)) 2171 2201 2172 2202 self._updateForwardButton() -
src/mlx/gui/gui.py
r239 r241 338 338 """Called when we have connected to the simulator.""" 339 339 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)) 341 342 fs.sendMessage(const.MESSAGETYPE_INFORMATION, 342 343 "Welcome to MAVA Logger X " + const.VERSION) -
src/mlx/i18n.py
r237 r241 477 477 self.add("takeoff_sid_tooltip", 478 478 "The name of the Standard Instrument Deparature procedure followed.") 479 self.add("label_knots", "knots") 480 self.add("label_kmph", "km/h") 479 481 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.") 482 484 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.") 484 487 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.") 486 490 487 491 self.add("landing_title", "Landing") … … 505 509 "The type of the approach, e.g. ILS or VISUAL.") 506 510 self.add("landing_vref", "V<sub>_Ref</sub>:") 507 self.add("landing_vref_tooltip ",511 self.add("landing_vref_tooltip_knots", 508 512 "The landing reference speed in knots.") 513 self.add("landing_vref_tooltip_kmph", 514 "The landing reference speed in km/h.") 509 515 510 516 self.add("flighttype_scheduled", "scheduled") … … 1313 1319 "Az alkalmazott szabványos műszeres indulási eljárás neve.") 1314 1320 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.") 1316 1323 self.add("label_knots", "csomó") 1324 self.add("label_kmph", "km/h") 1317 1325 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.") 1319 1328 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.") 1321 1333 1322 1334 self.add("landing_title", "Leszállás") … … 1341 1353 "A megközelítgés típusa, pl. ILS vagy VISUAL.") 1342 1354 self.add("landing_vref", "V<sub>_Ref</sub>:") 1343 self.add("landing_vref_tooltip ",1355 self.add("landing_vref_tooltip_knots", 1344 1356 "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.") 1345 1359 1346 1360 self.add("flighttype_scheduled", "menetrendszerinti") -
test/test1.txt
r183 r241 1 set lights=0 1 2 set zfw=46741 hour=7 min=50 2 3 set latitude=47.44 longitude=19.26 3 4 set parking=no 5 set gs=10 ias=10 4 6 set flapsControl=37.5 7 set gs=60 ias=60 5 8 set lights=21 9 set gs=80 ias=80 10 set gs=90 ias=90 11 set gs=100 ias=100 12 set gs=120 ias=120 6 13 set onTheGround=no 7 14 set altitude=600 … … 11 18 set altitude=10000 12 19 set lights=17 20 set ias=400 13 21 set altitude=22001 14 22 set vs=-200 15 23 set flapsControl=87.5 24 set ias=130 gs=130 16 25 set altitude=557 26 set ias=125 gs=125 17 27 set noseGear=100 18 28 set altitude=547 … … 22 32 set latitude=47.49 longitude=21.62 23 33 set onTheGround=yes 34 set ias=45 gs=45 35 set ias=35 gs=35 36 set ias=20 gs=20 37 set ias=0 gs=0 24 38 set parking=yes
Note:
See TracChangeset
for help on using the changeset viewer.