Changes in / [495:9c830f5791a5:496:0dadad5a93b8]
- Location:
- src/mlx
- Files:
-
- 1 added
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
src/mlx/checks.py
r480 r496 957 957 """Check if the fault condition holds.""" 958 958 if flight.stage==const.STAGE_CRUISE: 959 bankLimit = 30 959 isDH8DXplane = flight.aircraftType==const.AIRCRAFT_DH8D and \ 960 (flight.fsType==const.SIM_XPLANE10 or 961 flight.fsType==const.SIM_XPLANE9) 962 bankLimit = 35 if isDH8DXplane else 30 960 963 elif flight.stage in [const.STAGE_TAKEOFF, const.STAGE_CLIMB, 961 964 const.STAGE_DESCENT, const.STAGE_LANDING]: … … 968 971 def logFault(self, flight, aircraft, logger, oldState, state): 969 972 """Log the fault.""" 973 message = "Bank too steep (%.1f)" % (state.bank,) 970 974 flight.handleFault(BankChecker, state.timestamp, 971 FaultChecker._appendDuring(flight, "Bank too steep"),975 FaultChecker._appendDuring(flight, message), 972 976 2) 973 977 -
src/mlx/flight.py
r391 r430 86 86 """Get the flight stage.""" 87 87 return self._stage 88 89 @property 90 def fsType(self): 91 """Get the flight simulator type.""" 92 return self._gui.fsType 88 93 89 94 @property -
src/mlx/fs.py
r408 r420 3 3 from sound import startSound 4 4 5 import fsuipc 5 import os 6 7 if os.name=="nt" or "FORCE_PYUIPC_SIM" in os.environ: 8 import fsuipc as sim 9 else: 10 import xplane as sim 11 6 12 import threading 7 13 import time … … 58 64 assert type in [const.SIM_MSFS9, const.SIM_MSFSX], \ 59 65 "Only MS Flight Simulator 2004 and X are supported" 60 return fsuipc.Simulator(connectionListener, connectAttempts = 3)66 return sim.Simulator(connectionListener, connectAttempts = 3) 61 67 62 68 #------------------------------------------------------------------------------- -
src/mlx/gui/gui.py
r491 r496 69 69 self._flight = None 70 70 self._simulator = None 71 self._fsType = None 71 72 self._monitoring = False 72 73 … … 208 209 209 210 @property 211 def fsType(self): 212 """Get the flight simulator type.""" 213 return self._fsType 214 215 @property 210 216 def entranceExam(self): 211 217 """Get whether an entrance exam is about to be taken.""" … … 428 434 self._wizard.connected(fsType, descriptor) 429 435 self._reconnecting = False 436 self._fsType = fsType 430 437 self._listenHotkeys() 431 438 -
src/mlx/gui/monitor.py
r480 r496 226 226 table.attach(label, 0, 1, 8, 9) 227 227 table.attach(self._qnh, 1, 2, 8, 9) 228 229 (label, self._cog) = self._createLabeledEntry("CoG:", 7) 230 table.attach(label, 2, 3, 8, 9) 231 table.attach(self._cog, 3, 4, 8, 9) 228 232 229 233 alignment.add(table) … … 312 316 self._adf2.set_text("-") 313 317 self._qnh.set_text("-") 318 self._cog.set_text("-") 314 319 else: 315 320 self._timestamp.set_text(time.strftime("%H:%M:%S", … … 386 391 self._gearControlDown.set_sensitive(aircraftState.gearControlDown) 387 392 self._gearsDown.set_sensitive(aircraftState.gearsDown) 388 self._spoilersArmed.set_sensitive(aircraftState.spoilersArmed )393 self._spoilersArmed.set_sensitive(aircraftState.spoilersArmed is True) 389 394 self._spoilersExtension.set_text("%.0f" % (aircraftState.spoilersExtension,)) 390 395 self._windSpeed.set_text("%.0f" % (aircraftState.windSpeed,)) … … 404 409 self._adf1.set_text("-" if aircraftState.adf1 is None else aircraftState.adf1) 405 410 self._adf2.set_text("-" if aircraftState.adf2 is None else aircraftState.adf2) 411 self._cog.set_text("%.2f%%" % (aircraftState.cog*100.0,)) 406 412 407 413 #------------------------------------------------------------------------------ -
src/mlx/sound.py
r401 r422 166 166 def startSound(name, finishCallback = None, extra = None): 167 167 """Start playing back the given sound. 168 168 169 169 name should be the name of a sound file relative to the sound directory 170 170 given in initializeSound.""" 171 171 _thread.requestSound(name, finishCallback = finishCallback, 172 172 extra = extra) 173 173 174 174 #------------------------------------------------------------------------------ 175 175 176 176 else: # os.name!="nt" 177 def initializeSound(soundsDirectory): 178 """Initialize the sound handling with the given directory containing 179 the sound files.""" 180 pass 181 182 def startSound(name, finishCallback = None, extra = None): 183 """Start playing back the given sound. 184 185 FIXME: it does not do anything currently, but it should.""" 186 print "sound.startSound:", name 177 import threading 178 try: 179 import pyglet 180 181 class SoundThread(threading.Thread): 182 """A thread executing the pyglet event loop that directs the 183 playback of the sound files.""" 184 class Player(pyglet.media.ManagedSoundPlayer): 185 """Player which handles the end-of-stream condition 186 properly.""" 187 188 def __init__(self, finishCallback, extra): 189 """Construct the player with the given data.""" 190 super(SoundThread.Player, self).__init__() 191 192 self._finishCallback = finishCallback 193 self._extra = extra 194 195 def _on_eos(self): 196 if self._finishCallback is not None: 197 self._finishCallback(True, self._extra) 198 return super(SoundThread.Player, self)._on_eos() 199 200 class EventLoop(pyglet.app.EventLoop): 201 """Own implementation of the event loop that collects the 202 requested sound files and plays them.""" 203 204 def __init__(self, soundsDirectory): 205 """Construct the event loop.""" 206 super(SoundThread.EventLoop, self).__init__() 207 208 self._soundsDirectory = soundsDirectory 209 210 self._lock = threading.Lock() 211 self._requestedSounds = [] 212 213 def startSound(self, name, finishCallback, extra): 214 """Add the sound with the given name""" 215 with self._lock: 216 path = os.path.join(self._soundsDirectory, name) 217 self._requestedSounds.append( (path, 218 finishCallback, extra) ) 219 220 def idle(self): 221 """The idle callback.""" 222 with self._lock: 223 requestedSounds = self._requestedSounds 224 self._requestedSounds = [] 225 226 for (path, finishCallback, extra) in requestedSounds: 227 try: 228 media = pyglet.media.load(path) 229 player = SoundThread.Player(finishCallback, extra) 230 player.queue(media) 231 player.play() 232 except Exception, e: 233 print "mlx.SoundThread.EventLoop.idle: " + str(e) 234 if finishCallback is not None: 235 finishCallback(False, extra) 236 237 timeout = super(SoundThread.EventLoop, self).idle() 238 return 0.1 if timeout is None else min(timeout, 0.1) 239 240 def __init__(self, soundsDirectory): 241 """Construct the sound playing thread with the given 242 directory.""" 243 super(SoundThread, self).__init__() 244 245 self.daemon = True 246 self.eventLoop = SoundThread.EventLoop(soundsDirectory) 247 248 def run(self): 249 """Run the event loop.""" 250 self.eventLoop.run() 251 252 def startSound(self, name, finishCallback = None, extra = None): 253 """Start the playback of the given sound.""" 254 self.eventLoop.startSound(name, finishCallback, extra) 255 256 _thread = None 257 258 def initializeSound(soundsDirectory): 259 """Initialize the sound handling with the given directory containing 260 the sound files.""" 261 global _thread 262 _thread = SoundThread(soundsDirectory) 263 _thread.start() 264 265 266 def startSound(name, finishCallback = None, extra = None): 267 """Start playing back the given sound.""" 268 _thread.startSound(name, finishCallback = finishCallback, 269 extra = extra) 270 271 except: 272 print "The pyglet library is missing from your system. It is needed for sound playback on Linux" 273 def initializeSound(soundsDirectory): 274 """Initialize the sound handling with the given directory containing 275 the sound files.""" 276 pass 277 278 def startSound(name, finishCallback = None, extra = None): 279 """Start playing back the given sound. 280 281 FIXME: it does not do anything currently, but it should.""" 282 print "sound.startSound:", name 187 283 188 284 #------------------------------------------------------------------------------ … … 192 288 def callback(result, extra): 193 289 print "callback", result, extra 194 290 195 291 initializeSound("e:\\home\\vi\\tmp") 196 292 startSound("malev.mp3", finishCallback = callback, extra="malev.mp3")
Note:
See TracChangeset
for help on using the changeset viewer.