Changes in / [450:d009a75685e8:449:7ee0679c217b]
- Location:
- src/mlx
- Files:
-
- 1 deleted
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
src/mlx/checks.py
r450 r448 954 954 """Check if the fault condition holds.""" 955 955 if flight.stage==const.STAGE_CRUISE: 956 isDH8DXplane = flight.aircraftType==const.AIRCRAFT_DH8D and \ 957 (flight.fsType==const.SIM_XPLANE10 or 958 flight.fsType==const.SIM_XPLANE9) 959 bankLimit = 35 if isDH8DXplane else 30 956 bankLimit = 30 960 957 elif flight.stage in [const.STAGE_TAKEOFF, const.STAGE_CLIMB, 961 958 const.STAGE_DESCENT, const.STAGE_LANDING]: … … 968 965 def logFault(self, flight, aircraft, logger, oldState, state): 969 966 """Log the fault.""" 970 message = "Bank too steep (%.1f)" % (state.bank,)971 967 flight.handleFault(BankChecker, state.timestamp, 972 FaultChecker._appendDuring(flight, message),968 FaultChecker._appendDuring(flight, "Bank too steep"), 973 969 2) 974 970 -
src/mlx/flight.py
r430 r391 86 86 """Get the flight stage.""" 87 87 return self._stage 88 89 @property90 def fsType(self):91 """Get the flight simulator type."""92 return self._gui.fsType93 88 94 89 @property -
src/mlx/fs.py
r420 r408 3 3 from sound import startSound 4 4 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 5 import fsuipc 12 6 import threading 13 7 import time … … 64 58 assert type in [const.SIM_MSFS9, const.SIM_MSFSX], \ 65 59 "Only MS Flight Simulator 2004 and X are supported" 66 return sim.Simulator(connectionListener, connectAttempts = 3)60 return fsuipc.Simulator(connectionListener, connectAttempts = 3) 67 61 68 62 #------------------------------------------------------------------------------- -
src/mlx/gui/gui.py
r450 r436 68 68 self._flight = None 69 69 self._simulator = None 70 self._fsType = None71 70 self._monitoring = False 72 71 … … 206 205 207 206 @property 208 def fsType(self):209 """Get the flight simulator type."""210 return self._fsType211 212 @property213 207 def entranceExam(self): 214 208 """Get whether an entrance exam is about to be taken.""" … … 431 425 self._wizard.connected(fsType, descriptor) 432 426 self._reconnecting = False 433 self._fsType = fsType434 427 self._listenHotkeys() 435 428 -
src/mlx/gui/monitor.py
r431 r408 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)232 228 233 229 alignment.add(table) … … 316 312 self._adf2.set_text("-") 317 313 self._qnh.set_text("-") 318 self._cog.set_text("-")319 314 else: 320 315 self._timestamp.set_text(time.strftime("%H:%M:%S", … … 391 386 self._gearControlDown.set_sensitive(aircraftState.gearControlDown) 392 387 self._gearsDown.set_sensitive(aircraftState.gearsDown) 393 self._spoilersArmed.set_sensitive(aircraftState.spoilersArmed is True)388 self._spoilersArmed.set_sensitive(aircraftState.spoilersArmed) 394 389 self._spoilersExtension.set_text("%.0f" % (aircraftState.spoilersExtension,)) 395 390 self._windSpeed.set_text("%.0f" % (aircraftState.windSpeed,)) … … 409 404 self._adf1.set_text("-" if aircraftState.adf1 is None else aircraftState.adf1) 410 405 self._adf2.set_text("-" if aircraftState.adf2 is None else aircraftState.adf2) 411 self._cog.set_text("%.2f%%" % (aircraftState.cog*100.0,))412 406 413 407 #------------------------------------------------------------------------------ -
src/mlx/sound.py
r422 r401 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 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 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 283 187 284 188 #------------------------------------------------------------------------------ … … 288 192 def callback(result, extra): 289 193 print "callback", result, extra 290 194 291 195 initializeSound("e:\\home\\vi\\tmp") 292 196 startSound("malev.mp3", finishCallback = callback, extra="malev.mp3")
Note:
See TracChangeset
for help on using the changeset viewer.