Ignore:
Location:
src/mlx
Files:
1 deleted
6 edited

Legend:

Unmodified
Added
Removed
  • src/mlx/checks.py

    r496 r480  
    957957        """Check if the fault condition holds."""
    958958        if flight.stage==const.STAGE_CRUISE:
    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
     959            bankLimit = 30
    963960        elif flight.stage in [const.STAGE_TAKEOFF, const.STAGE_CLIMB,
    964961                              const.STAGE_DESCENT, const.STAGE_LANDING]:
     
    971968    def logFault(self, flight, aircraft, logger, oldState, state):
    972969        """Log the fault."""
    973         message = "Bank too steep (%.1f)" % (state.bank,)
    974970        flight.handleFault(BankChecker, state.timestamp,
    975                            FaultChecker._appendDuring(flight, message),
     971                           FaultChecker._appendDuring(flight, "Bank too steep"),
    976972                           2)
    977973
  • src/mlx/flight.py

    r430 r391  
    8686        """Get the flight stage."""
    8787        return self._stage
    88 
    89     @property
    90     def fsType(self):
    91         """Get the flight simulator type."""
    92         return self._gui.fsType
    9388
    9489    @property
  • src/mlx/fs.py

    r420 r408  
    33from sound import startSound
    44
    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 
     5import fsuipc
    126import threading
    137import time
     
    6458    assert type in [const.SIM_MSFS9, const.SIM_MSFSX], \
    6559           "Only MS Flight Simulator 2004 and X are supported"
    66     return sim.Simulator(connectionListener, connectAttempts = 3)
     60    return fsuipc.Simulator(connectionListener, connectAttempts = 3)
    6761
    6862#-------------------------------------------------------------------------------
  • src/mlx/gui/gui.py

    r496 r491  
    6969        self._flight = None
    7070        self._simulator = None
    71         self._fsType = None
    7271        self._monitoring = False
    7372
     
    209208
    210209    @property
    211     def fsType(self):
    212         """Get the flight simulator type."""
    213         return self._fsType
    214 
    215     @property
    216210    def entranceExam(self):
    217211        """Get whether an entrance exam is about to be taken."""
     
    434428            self._wizard.connected(fsType, descriptor)
    435429        self._reconnecting = False
    436         self._fsType = fsType
    437430        self._listenHotkeys()
    438431
  • src/mlx/gui/monitor.py

    r496 r480  
    226226        table.attach(label, 0, 1, 8, 9)
    227227        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)
    232228
    233229        alignment.add(table)
     
    316312            self._adf2.set_text("-")
    317313            self._qnh.set_text("-")
    318             self._cog.set_text("-")
    319314        else:
    320315            self._timestamp.set_text(time.strftime("%H:%M:%S",
     
    391386            self._gearControlDown.set_sensitive(aircraftState.gearControlDown)
    392387            self._gearsDown.set_sensitive(aircraftState.gearsDown)
    393             self._spoilersArmed.set_sensitive(aircraftState.spoilersArmed is True)
     388            self._spoilersArmed.set_sensitive(aircraftState.spoilersArmed)
    394389            self._spoilersExtension.set_text("%.0f" % (aircraftState.spoilersExtension,))
    395390            self._windSpeed.set_text("%.0f" % (aircraftState.windSpeed,))
     
    409404            self._adf1.set_text("-" if aircraftState.adf1 is None else aircraftState.adf1)
    410405            self._adf2.set_text("-" if aircraftState.adf2 is None else aircraftState.adf2)
    411             self._cog.set_text("%.2f%%" % (aircraftState.cog*100.0,))
    412406
    413407#------------------------------------------------------------------------------
  • src/mlx/sound.py

    r422 r401  
    166166    def startSound(name, finishCallback = None, extra = None):
    167167        """Start playing back the given sound.
    168 
     168       
    169169        name should be the name of a sound file relative to the sound directory
    170170        given in initializeSound."""
    171171        _thread.requestSound(name, finishCallback = finishCallback,
    172172                             extra = extra)
    173 
     173       
    174174#------------------------------------------------------------------------------
    175175
    176176else: # 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
    283187
    284188#------------------------------------------------------------------------------
     
    288192    def callback(result, extra):
    289193        print "callback", result, extra
    290 
     194   
    291195    initializeSound("e:\\home\\vi\\tmp")
    292196    startSound("malev.mp3", finishCallback = callback, extra="malev.mp3")
Note: See TracChangeset for help on using the changeset viewer.