Changeset 88:3fdb6ad947ad for src


Ignore:
Timestamp:
04/16/12 17:53:47 (13 years ago)
Author:
István Váradi <ivaradi@…>
Branch:
default
Phase:
public
Message:

The logger disconnects from the simulator if the flight has ended and the Forward button on the landing page can be activated only then.

Location:
src/mlx
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • src/mlx/gui/flight.py

    r86 r88  
    13731373        super(LandingPage, self).__init__(wizard, "Landing", help)
    13741374
     1375        self._flightEnded = False
     1376
    13751377        alignment = gtk.Alignment(xalign = 0.5, yalign = 0.5,
    13761378                                  xscale = 0.0, yscale = 0.0)
     
    14751477    def activate(self):
    14761478        """Called when the page is activated."""
     1479        self._flightEnded = False
     1480       
    14771481        self._starButton.set_sensitive(True)
    14781482        self._starButton.set_active(False)
     
    14921496        self._vref.set_sensitive(True)
    14931497
     1498        self._updateForwardButton()
     1499
     1500    def flightEnded(self):
     1501        """Called when the flight has ended."""
     1502        self._flightEnded = True
    14941503        self._updateForwardButton()
    14951504
     
    15261535    def _updateForwardButton(self, widget = None):
    15271536        """Update the sensitivity of the forward button."""
    1528         sensitive = (self._starButton.get_active() or \
     1537        sensitive = self._flightEnded and \
     1538                    (self._starButton.get_active() or \
    15291539                     self._transitionButton.get_active()) and \
    15301540                    (self._star.get_text()!="" or
     
    16801690        if stage==const.STAGE_TAKEOFF:
    16811691            self._takeoffPage.freezeValues()
     1692        elif stage==const.STAGE_END:
     1693            self._landingPage.flightEnded()
    16821694
    16831695    def _initialize(self):
  • src/mlx/gui/gui.py

    r86 r88  
    150150        gtk.main()
    151151
    152         if self._flight is not None:
    153             simulator = self._flight.simulator
    154             if self._monitoring:
    155                 simulator.stopMonitoring()
    156                 self._monitoring = False
    157             simulator.disconnect()                       
     152        if self._flight is not None and self._connected:
     153            self.stopMonitoring()
     154            self._flight.simulator.disconnect()                       
    158155
    159156    def connected(self, fsType, descriptor):
     
    265262        self._statusIcon.setStage(stage)
    266263        self._wizard.setStage(stage)
     264        if stage==const.STAGE_END:
     265            self.stopMonitoring()
     266            self.simulator.disconnect()
     267            self._connecting = False
     268            self._connected = False
     269            self._statusbar.updateConnection(self._connecting, self._connected)
    267270
    268271    def setRating(self, rating):
     
    412415    def startMonitoring(self):
    413416        """Start monitoring."""
    414         self._simulator.startMonitoring()
    415         self._monitoring = True
     417        if not self._monitoring:
     418            self.simulator.startMonitoring()
     419            self._monitoring = True
    416420
    417421    def stopMonitoring(self):
    418422        """Stop monitoring."""
    419         self._simulator.stoptMonitoring()
    420         self._monitoring = False
     423        if self._monitoring:
     424            self.simulator.stopMonitoring()
     425            self._monitoring = False
    421426
    422427    def _buildLogFrame(self):
  • src/mlx/pyuipc_sim.py

    r85 r88  
    351351            index = 0
    352352            while index<numNotchesM1 and \
    353                   self.flapsControl<self.flapsNotches[index]:
     353                  self.flapsControl>self.flapsNotches[index]:
    354354                index += 1
    355                
     355
    356356            if index==numNotchesM1:
    357357                return 16383
    358358            else:
    359                 return int((self.flapsControl-self.flapsNotches[index]) * \
    360                            flapsIncrement / \
     359                return int(index * flapsIncrement +
     360                           (self.flapsControl-self.flapsNotches[index]) *
     361                           flapsIncrement /
    361362                           (self.flapsNotches[index+1] - self.flapsNotches[index]))
    362363        elif offset==0x0be0 or offset==0x0be4:    # Flaps left and  right
     
    529530            numNotchesM1 = len(self.flapsNotches) - 1
    530531            flapsIncrement = 16383.0 / numNotchesM1
    531             index = value / flapsIncrement
     532            index = int(value / flapsIncrement)
    532533            if index>=numNotchesM1:
    533534                self.flapsControl = self.flapsNotches[-1]
    534535            else:
    535536                self.flapsControl = self.flapsNotches[index]
    536                 self.flapsControl += value * \
     537                self.flapsControl += (value - index * flapsIncrement) * \
    537538                    (self.flapsNotches[index+1] - self.flapsNotches[index]) / \
    538539                    flapsIncrement
     
    583584        elif offset==0x3bfc:       # ZFW
    584585            self.zfw = value * const.LBSTOKG / 256.0
    585             print "ZFW:", self.zfw
    586586        elif offset==0x3c00:       # Path of the current AIR file
    587587            self.airPath = value
     
    640640        temperature += 273.15  # Celsius -> Kelvin
    641641        airDensity = pressure / (temperature * 287.05)
    642         print "pressure:", pressure, "temperature:", temperature, "airDensity:", airDensity
     642        #print "pressure:", pressure, "temperature:", temperature, "airDensity:", airDensity
    643643        return self.ias * math.sqrt(1.225 / airDensity)
    644644
  • src/mlx/web.py

    r74 r88  
    337337        result = Result()
    338338
    339         f = urllib2.urlopen(url)
     339        f = urllib2.urlopen(url, timeout = 10.0)
    340340
    341341        status = readline(f)
     
    375375        url = "http://www.virtualairlines.hu/onlinegates_get.php"
    376376
    377         f = urllib2.urlopen(url)
     377        f = urllib2.urlopen(url, timeout = 10.0)
    378378        result = Result()
    379379        result.fleet = Fleet(f)
     
    407407                                 ("kapu", gateNumber)])
    408408       
    409         f = urllib2.urlopen(url, data)
     409        f = urllib2.urlopen(url, data, timeout = 10.0)
    410410        line = readline(f)
    411411       
     
    434434        url = "http://notams.euroutepro.com/notams.xml"
    435435
    436         f = urllib2.urlopen(url)
     436        f = urllib2.urlopen(url, timeout = 10.0)
    437437        try:
    438438            xmlParser.parse(f)
     
    466466                                  ("mostRecentForEachStation", "constraint")])
    467467        url += data
    468         f = urllib2.urlopen(url)
     468        f = urllib2.urlopen(url, timeout = 10.0)
    469469        try:
    470470            result = Result()
Note: See TracChangeset for help on using the changeset viewer.