Changeset 349:41c486c8a0b4


Ignore:
Timestamp:
12/10/12 19:28:32 (11 years ago)
Author:
István Váradi <ivaradi@…>
Branch:
default
hg-Phase:
(<MercurialRepository 1 'hg:/home/ivaradi/mlx/hg' '/'>, 'public')
Message:

The basic strobe-less RTO handling logic works (#143)

Files:
9 edited

Legend:

Unmodified
Added
Removed
  • locale/en/mlx.po

    r315 r349  
    766766msgstr "The takeoff safety speed in km/h."
    767767
     768msgid "takeoff_rto"
     769msgstr "R_ejected takeoff"
     770
     771msgid "takeoff_rto_tooltip"
     772msgstr ""
     773"If you fly one of the aircraft the have no strobe lights, "
     774"you can indicate here that you have aborted the takeoff. "
     775"Don't forget to provide an explanation in the comments."
     776
    768777msgid "landing_title"
    769778msgstr "Landing"
  • locale/hu/mlx.po

    r315 r349  
    767767msgstr "A biztonságos emelkedési sebesség km/órában."
    768768
     769msgid "takeoff_rto"
     770msgstr "_Megszakított felszállás"
     771
     772msgid "takeoff_rto_tooltip"
     773msgstr ""
     774"Ha valamelyik strobe fénnyel nem rendelkező repülőgépet "
     775"vezeted, itt jelezheted, ha megszakítottad a felszállást. "
     776"Ne felejts magyarázattal szolgálni a megjegyzések között!"
     777
    769778msgid "landing_title"
    770779msgstr "Leszállás"
  • src/mlx/acft.py

    r345 r349  
    137137        self._checkers.append(checks.PayloadChecker())
    138138
    139         self._checkers.append(checks.SpeedChecker())
    140         #self._checkers.append(checks.NoStrobeSpeedChecker())
     139        #self._checkers.append(checks.SpeedChecker())
     140        self._checkers.append(checks.NoStrobeSpeedChecker())
    141141        self._checkers.append(checks.VSChecker())
    142142
  • src/mlx/checks.py

    r346 r349  
    12851285    """Check if the speed is in the prescribed limits."""
    12861286    @staticmethod
    1287     def logSpeedFault(flight, state):
     1287    def logSpeedFault(flight, state, stage = None, updateID = None):
    12881288        """Log the speed fault."""
    12891289        message = "Taxi speed over %.0f %s" % \
    12901290                  (flight.speedFromKnots(50), flight.getEnglishSpeedUnit())
    1291         flight.handleFault((SpeedChecker, flight.stage), state.timestamp,
    1292                            FaultChecker._appendDuring(flight, message),
    1293                            FaultChecker._getLinearScore(50, 80, 10, 15,
    1294                                                         state.groundSpeed),
    1295                            updatePrevious = True)
     1291        if stage is None:
     1292            stage = flight.stage
     1293        score = FaultChecker._getLinearScore(50, 80, 10, 15, state.groundSpeed)
     1294        return flight.handleFault((SpeedChecker, stage), state.timestamp,
     1295                                  FaultChecker._appendDuring(flight, message),
     1296                                  score, updatePrevious = updateID is None,
     1297                                  updateID = updateID)
    12961298
    12971299    def isCondition(self, flight, aircraft, oldState, state):
     
    13141316    saved as a provisional takeoff state. If the speed then decreases below 50
    13151317    knots, or the plane remains on the ground for more than 20 seconds, a taxi
    1316     speed error is logged with the highest ground speed detected.
     1318    speed error is logged with the highest ground speed detected. This state is
     1319    also stored in the flight object as a possible
    13171320
    13181321    If the plane becomes airborne within 20 seconds, the stage becomes TAKEOFF,
     
    13451348
    13461349                if state.timestamp > (self._takeoffState.timestamp + 20):
    1347                     SpeedChecker.logSpeedFault(flight, self._highestSpeedState)
     1350                    flight.setRTOState(self._highestSpeedState)
    13481351                elif not state.onTheGround:
    13491352                    aircraft.setStage(self._takeoffState, const.STAGE_TAKEOFF)
    13501353                    self._takeoffState = None
    13511354        elif self._takeoffState is not None:
    1352             SpeedChecker.logSpeedFault(flight, self._highestSpeedState)
     1355            flight.setRTOState(self._highestSpeedState)
    13531356            self._takeoffState = None
    13541357
  • src/mlx/flight.py

    r348 r349  
    11
    22from soundsched import SoundScheduler, ChecklistScheduler
     3from checks import SpeedChecker
    34
    45import const
     
    4546        self.blockTimeEnd = None
    4647
     48        self._rtoState = None
     49        self._rtoLogEntryID = None
     50
    4751        self._lastDistanceTime = None
    4852        self._previousLatitude = None
     
    229233        return self.aircraft.speedInKnots if self.aircraft is not None \
    230234               else True
     235
     236    @property
     237    def hasRTO(self):
     238        """Determine if we have an RTO state."""
     239        return self._rtoState is not None
     240
     241    @property
     242    def rtoState(self):
     243        """Get the RTO state."""
     244        return self._rtoState
    231245
    232246    def handleState(self, oldState, currentState):
     
    270284
    271285    def handleFault(self, faultID, timestamp, what, score,
    272                     updatePrevious = False):
     286                    updatePrevious = False, updateID = None):
    273287        """Handle the given fault.
    274288
     
    277291        the score is greater than last time. This ID can be, e.g. the checker
    278292        the report comes from."""
    279         self.logger.fault(faultID, timestamp, what, score,
    280                           updatePrevious = updatePrevious)
     293        id = self.logger.fault(faultID, timestamp, what, score,
     294                               updatePrevious = updatePrevious,
     295                               updateID = updateID)
    281296        self._gui.setRating(self.logger.getRating())
     297        return id
    282298
    283299    def handleNoGo(self, faultID, timestamp, what, shortReason):
     
    285301        self.logger.noGo(faultID, timestamp, what)
    286302        self._gui.setNoGo(shortReason)
     303
     304    def setRTOState(self, state):
     305        """Set the state that might be used as the RTO state.
     306
     307        If there has been no RTO state, the GUI is notified that from now on
     308        the user may select to report an RTO."""
     309        hadNoRTOState = self._rtoState is None
     310
     311        self._rtoState = state
     312        self._rtoLogEntryID = \
     313            SpeedChecker.logSpeedFault(self, state,
     314                                       stage = const.STAGE_PUSHANDTAXI)
     315
     316        if hadNoRTOState:
     317            self._gui.updateRTO()
     318
     319    def rtoToggled(self, indicated):
     320        """Called when the user has toggled the RTO indication."""
     321        if self._rtoState is not None:
     322            if indicated:
     323                self.logger.clearFault(self._rtoLogEntryID,
     324                                       "RTO at %d knots" %
     325                                       (self._rtoState.groundSpeed,))
     326                self._gui.setRating(self.logger.getRating())
     327            else:
     328                SpeedChecker.logSpeedFault(self, self._rtoState,
     329                                           stage = const.STAGE_PUSHANDTAXI,
     330                                           updateID = self._rtoLogEntryID)
    287331
    288332    def flareStarted(self, flareStart, flareStartFS):
  • src/mlx/gui/flight.py

    r347 r349  
    20072007                                  xscale = 0.0, yscale = 0.0)
    20082008
    2009         table = gtk.Table(5, 4)
     2009        table = gtk.Table(6, 4)
    20102010        table.set_row_spacings(4)
    20112011        table.set_col_spacings(16)
     
    20862086        table.attach(self._v2Unit, 3, 4, 4, 5)
    20872087
     2088        self._rto = gtk.CheckButton(xstr("takeoff_rto"))
     2089        self._rto.set_use_underline(True)
     2090        self._rto.set_tooltip_text(xstr("takeoff_rto_tooltip"))
     2091        self._rto.connect("toggled", self._rtoToggled)
     2092        table.attach(self._rto, 2, 4, 5, 6, ypadding = 8)
     2093
    20882094        self.addCancelFlightButton()
    20892095
     
    21162122        """Get the v2 speed."""
    21172123        return self._v2.get_int()
     2124
     2125    @property
     2126    def rtoIndicated(self):
     2127        """Get whether the pilot has indicated if there was an RTO."""
     2128        return self._rto.get_active()
    21182129
    21192130    def activate(self):
     
    21402151        self._v2.set_tooltip_markup(xstr("takeoff_v2_tooltip" + i18nSpeedUnit))
    21412152
     2153        self._rto.set_active(False)
     2154        self._rto.set_sensitive(False)
     2155
    21422156        self._button.set_sensitive(False)
    21432157        self._forwardAllowed = False
     
    21542168        self._vr.reset()
    21552169        self._v2.reset()
     2170
     2171    def setRTOEnabled(self, enabled):
     2172        """Set the RTO checkbox enabled or disabled."""
     2173        if not enabled:
     2174            self._rto.set_active(False)
     2175        self._rto.set_sensitive(enabled)
    21562176
    21572177    def _updateForwardButton(self):
     
    21762196        entry.set_text(entry.get_text().upper())
    21772197        self._valueChanged(entry, arg)
     2198
     2199    def _rtoToggled(self, button):
     2200        """Called when the RTO check button is toggled."""
     2201        self._wizard.rtoToggled(button.get_active())
    21782202
    21792203    def _backClicked(self, button):
     
    29712995        """Get the V2 speed."""
    29722996        return self._takeoffPage.v2
     2997
     2998    @property
     2999    def rtoIndicated(self):
     3000        """Get whether the pilot has indicated that an RTO has occured."""
     3001        return self._takeoffPage.rtoIndicated
    29733002
    29743003    @property
     
    31623191                             callback = callback)
    31633192
     3193    def updateRTO(self):
     3194        """Update the RTO state.
     3195
     3196        The RTO checkbox will be enabled if the flight has an RTO state and the
     3197        comments field contains some text."""
     3198        flight = self.gui.flight
     3199        rtoEnabled = flight is not None and flight.hasRTO and \
     3200                     self.gui.hasComments
     3201        self._takeoffPage.setRTOEnabled(rtoEnabled)
     3202
     3203    def rtoToggled(self, indicated):
     3204        """Called when the RTO indication has changed."""
     3205        self.gui.rtoToggled(indicated)
     3206
    31643207    def _connectSimulator(self):
    31653208        """Connect to the simulator."""
     
    31793222
    31803223#-----------------------------------------------------------------------------
    3181 
  • src/mlx/gui/gui.py

    r345 r349  
    303303
    304304    @property
     305    def rtoIndicated(self):
     306        """Get whether the pilot has indicated than an RTO has occured."""
     307        return self._wizard.rtoIndicated
     308
     309    @property
    305310    def arrivalRunway(self):
    306311        """Get the arrival runway."""
     
    341346        """Get the comments."""
    342347        return self._flightInfo.comments
     348
     349    @property
     350    def hasComments(self):
     351        """Indicate whether there is a comment."""
     352        return self._flightInfo.hasComments
    343353
    344354    @property
     
    728738        else:
    729739            callback(self._fleet)
     740
     741    def updateRTO(self, inLoop = False):
     742        """Indicate that the RTO state should be updated."""
     743        if inLoop:
     744            self._wizard.updateRTO()
     745        else:
     746            gobject.idle_add(self.updateRTO, True)
     747
     748    def rtoToggled(self, indicated):
     749        """Called when the user has toggled the RTO checkbox."""
     750        self._flight.rtoToggled(indicated)
    730751
    731752    def _fleetResultCallback(self, returned, result):
  • src/mlx/gui/info.py

    r300 r349  
    3333                 (const.DELAYCODE_WEATHER, xstr("info_delay_weather")),
    3434                 (const.DELAYCODE_PERSONAL, xstr("info_delay_personal")) ]
    35    
     35
    3636    @staticmethod
    3737    def _createCommentArea(label):
     
    5050        alignment.set_padding(padding_top = 4, padding_bottom = 4,
    5151                              padding_left = 8, padding_right = 8)
    52        
     52
    5353        scroller = gtk.ScrolledWindow()
    5454        # FIXME: these should be constants
     
    8080        (frame, self._comments) = FlightInfo._createCommentArea(xstr("info_comments"))
    8181        commentsBox.pack_start(frame, True, True, 8)
     82        self._comments.get_buffer().connect("changed", self._commentsChanged)
    8283
    8384        (frame, self._flightDefects) = \
     
    130131        return text2unicode(buffer.get_text(buffer.get_start_iter(),
    131132                                            buffer.get_end_iter(), True))
    132    
     133
     134    @property
     135    def hasComments(self):
     136        """Get whether there is any text in comments field."""
     137        return self._comments.get_buffer().get_char_count()>0
     138
    133139    @property
    134140    def flightDefects(self):
     
    147153                codes.append(delayCodes[index][0])
    148154        return codes
    149            
     155
    150156    def enable(self):
    151157        """Enable the flight info tab."""
     
    153159        self._flightDefects.set_sensitive(True)
    154160        self._delayTable.set_sensitive(True)
    155        
     161
    156162    def disable(self):
    157163        """Enable the flight info tab."""
     
    167173        for widget in self._delayCodeWidgets:
    168174            widget.set_active(False)
     175
     176    def _commentsChanged(self, textbuffer):
     177        """Called when the comments have changed."""
     178        self._gui.updateRTO(inLoop = True)
  • src/mlx/logger.py

    r346 r349  
    9797
    9898        def copy(self, timestamp = None, clearTimestamp = False, text = None,
    99                  faultScore = None):
     99                 faultID = None, faultScore = None, clearFault = False):
    100100            """Create a copy of this entry with the given values changed."""
    101             assert faultScore is None or self._faultID is not None
    102 
    103101            return Logger.Entry(None if clearTimestamp
    104102                                else self._timestamp if timestamp is None
     
    109107                                showTimestamp = self._showTimestamp,
    110108
    111                                 faultID = self._faultID,
     109                                faultID =
     110                                None if clearFault
     111                                else self._faultID if faultID is None
     112                                else faultID,
    112113
    113114                                faultScore =
    114                                 self._faultScore if faultScore is None
     115                                None if clearFault
     116                                else self._faultScore if faultScore is None
    115117                                else faultScore,
    116118
     
    248250
    249251    def fault(self, faultID, timestamp, what, score,
    250               updatePrevious = False):
     252              updatePrevious = False, updateID = None):
    251253        """Report a fault.
    252254
     
    262264        and the new score is not greater than the latest one, the ID of the
    263265        latest one is returned.
     266
     267        If updateID is given, the log entry with the given ID will be
     268        'upgraded' to be a fault with the given data.
    264269
    265270        Returns an ID of the fault, or -1 if it was not logged."""
     
    279284                                        faultScore = score)
    280285            self._updateEntry(id, newEntry)
     286        elif updateID is not None:
     287            id = updateID
     288            newEntry = self._entries[id].copy(timestamp = timestamp,
     289                                              text = text, faultID = faultID,
     290                                              faultScore = score)
     291            self._updateEntry(id, newEntry)
    281292        else:
    282293            id = self._addEntry(Logger.Entry(timestamp, text, faultID = faultID,
    283294                                             faultScore = score))
    284295
    285         (messageType, duration) = (const.MESSAGETYPE_NOGO, 10) \
    286                                   if score==Logger.NO_GO_SCORE \
    287                                   else (const.MESSAGETYPE_FAULT, 5)
    288         sendMessage(messageType, text, duration)
     296        if updateID is None:
     297            (messageType, duration) = (const.MESSAGETYPE_NOGO, 10) \
     298                                      if score==Logger.NO_GO_SCORE \
     299                                      else (const.MESSAGETYPE_FAULT, 5)
     300            sendMessage(messageType, text, duration)
    289301
    290302        return id
     
    311323        self._updateEntry(id, self._entries[id].copy(text = line))
    312324
     325    def clearFault(self, id, text):
     326        """Update the line with the given ID to contain the given string,
     327        and clear its fault state."""
     328        newEntry = self._entries[id].copy(text = text, clearFault = True)
     329        self._updateEntry(id, newEntry)
     330
    313331    def _addEntry(self, entry):
    314332        """Add the given entry to the log.
Note: See TracChangeset for help on using the changeset viewer.