Changeset 176:cb593ff93551


Ignore:
Timestamp:
05/13/12 08:17:00 (12 years ago)
Author:
István Váradi <ivaradi@…>
Branch:
default
Phase:
public
Message:

Checklist playback seems to work

Location:
src/mlx
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • src/mlx/flight.py

    r170 r176  
    33#---------------------------------------------------------------------------------------
    44
    5 from soundsched import SoundScheduler
     5from soundsched import SoundScheduler, ChecklistScheduler
    66
    77import const
     
    3434        gui.resetFlightStatus()
    3535
    36         self._soundScheduler = SoundScheduler(self)
    3736        self._pilotHotkeyPressed = False
    3837        self._checklistHotkeyPressed = False
     
    6665
    6766        self._tdRate = None
     67
     68        self._soundScheduler = SoundScheduler(self)
     69        self._checklistScheduler = ChecklistScheduler(self)
    6870
    6971    @property
     
    128130                                      self._pilotHotkeyPressed)
    129131        self._pilotHotkeyPressed = False
     132
     133        if self._checklistHotkeyPressed:
     134            self._checklistScheduler.hotkeyPressed()
     135            self._checklistHotkeyPressed = False
    130136
    131137    def setStage(self, timestamp, stage):
  • src/mlx/sound.py

    r170 r176  
    5959        def requestSound(self, name, finishCallback = None, extra = None):
    6060            """Request the playback of the sound with the given name."""
    61             path = os.path.join(self._soundsDirectory, name)
     61            path = name if os.path.isabs(name) \
     62                   else os.path.join(self._soundsDirectory, name)
    6263            with self._requestCondition:
    6364                self._requests.append((path, (finishCallback, extra)))
     
    167168
    168169        FIXME: it does not do anything currently, but it should."""
    169         pass
     170        print "sound.startSound:", name
    170171
    171172#------------------------------------------------------------------------------
  • src/mlx/soundsched.py

    r170 r176  
    55from sound import startSound
    66import const
     7import fs
    78
    89import threading
     
    211212
    212213#------------------------------------------------------------------------------
     214
     215class ChecklistScheduler(object):
     216    """A scheduler for the checklist sounds"""
     217    def __init__(self, flight):
     218        """Construct the checklist scheduler for the given flight."""
     219        self._flight = flight
     220        self._checklist = None
     221        self._itemIndex = 0
     222
     223    def hotkeyPressed(self):
     224        """Called when the checklist hotkey is pressed."""
     225        flight = self._flight
     226        config = flight.config
     227        if config.enableChecklists and flight.aircraftType is not None:
     228            if self._checklist is None:
     229                self._checklist = config.getChecklist(flight.aircraftType)
     230
     231            index = self._itemIndex
     232            if index>=len(self._checklist):
     233                fs.sendMessage(const.MESSAGETYPE_INFORMATION,
     234                               "End of checklist")
     235            else:
     236                startSound(self._checklist[index])
     237                self._itemIndex += 1
     238
     239#------------------------------------------------------------------------------
Note: See TracChangeset for help on using the changeset viewer.