Changeset 31:c9ed7a60bf3b for src/mlx
- Timestamp:
- 02/25/12 14:44:45 (13 years ago)
- Branch:
- default
- Phase:
- public
- Location:
- src/mlx
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
src/mlx/flight.py
r30 r31 29 29 self._gui = gui 30 30 31 gui.resetFlightStatus() 32 31 33 self.cruiseAltitude = None 32 34 self.flareTimeFromFS = False … … 57 59 self._stage = stage 58 60 self.logger.stage(timestamp, stage) 61 self._gui.setStage(stage) 59 62 if stage==const.STAGE_END: 60 63 with self._endCondition: … … 72 75 the report comes from.""" 73 76 self.logger.fault(faultID, timestamp, what, score) 77 self._gui.setRating(self.logger.getRating()) 74 78 75 79 def handleNoGo(self, faultID, timestamp, what, shortReason): 76 80 """Handle a No-Go fault.""" 77 81 self.logger.noGo(faultID, timestamp, what) 82 self._gui.setNoGo(shortReason) 78 83 79 84 def flareStarted(self, flareStart, flareStartFS): -
src/mlx/gui/gui.py
r30 r31 99 99 gobject.idle_add(self._setData, state) 100 100 101 def resetFlightStatus(self): 102 """Reset the status of the flight.""" 103 self._statusIcon.resetFlightStatus() 104 105 def setStage(self, stage): 106 """Set the stage of the flight.""" 107 gobject.idle_add(self._setStage, stage) 108 109 def _setStage(self, stage): 110 """Set the stage of the flight.""" 111 self._statusIcon.setStage(stage) 112 113 def setRating(self, rating): 114 """Set the rating of the flight.""" 115 gobject.idle_add(self._setRating, rating) 116 117 def _setRating(self, rating): 118 """Set the rating of the flight.""" 119 self._statusIcon.setRating(rating) 120 121 def setNoGo(self, reason): 122 """Set the rating of the flight to No-Go with the given reason.""" 123 gobject.idle_add(self._setNoGo, reason) 124 125 def _setNoGo(self, reason): 126 """Set the rating of the flight.""" 127 self._statusIcon.setNoGo(reason) 128 101 129 def _handleMainWindowState(self, window, event): 102 130 """Hande a change in the state of the window""" … … 177 205 self._simulator.startMonitoring() 178 206 else: 207 self.resetFlightStatus() 179 208 self._connecting = False 180 209 self._simulator.stopMonitoring() -
src/mlx/gui/statusicon.py
r29 r31 4 4 5 5 from common import * 6 7 import mlx.const as const 6 8 7 9 #------------------------------------------------------------------------------- … … 12 14 """Construct the status icon.""" 13 15 self._gui = gui 16 17 self._stage = None 18 self._rating = 100 19 self._noGoReason = None 14 20 15 21 menu = gtk.Menu() 22 23 if appIndicator: 24 self._stageMenuItem = gtk.MenuItem() 25 self._stageMenuItem.set_label("Stage: -") 26 self._stageMenuItem.show() 27 menu.append(self._stageMenuItem) 28 29 self._ratingMenuItem = gtk.MenuItem() 30 self._ratingMenuItem.set_label("Rating: 100%") 31 self._ratingMenuItem.show() 32 menu.append(self._ratingMenuItem) 33 34 separator = gtk.SeparatorMenuItem() 35 separator.show() 36 menu.append(separator) 16 37 17 38 self._showHideMenuItem = gtk.CheckMenuItem() … … 38 59 indicator.set_menu(menu) 39 60 self._indicator = indicator 40 self._usingIndicator = True41 61 else: 42 62 def popup_menu(status, button, time): … … 46 66 statusIcon = gtk.StatusIcon() 47 67 statusIcon.set_from_file(iconFile) 48 statusIcon.set_tooltip_markup("MAVA Logger X")49 68 statusIcon.set_visible(True) 50 69 statusIcon.connect('popup-menu', popup_menu) … … 52 71 lambda status: self._gui.toggleMainWindow()) 53 72 self._statusIcon = statusIcon 54 self._ usingIndicator = False73 self._setTooltip() 55 74 56 75 def mainWindowHidden(self): … … 61 80 """Called when the main window is shown.""" 62 81 self._showHideMenuItem.set_active(True) 82 83 def resetFlightStatus(self): 84 """Reset the status of the flight.""" 85 if not appIndicator: 86 self._statusIcon.set_blinking(False) 87 self._noGoReason = None 88 self.setStage(None) 89 self.setRating(100) 63 90 91 def setStage(self, stage): 92 """Set the stage of the flight.""" 93 self._stage = stage 94 if appIndicator: 95 label = "Stage: %s" % ("-" if self._stage is None \ 96 else (const.stage2string(stage),)) 97 self._stageMenuItem.set_label(label) 98 else: 99 self._setTooltip() 100 101 def setRating(self, rating): 102 """Set the rating to the given value.""" 103 if rating==self._rating: 104 return 105 self._rating = rating 106 107 if appIndicator: 108 if self._noGoReason is None: 109 self._ratingMenuItem.set_label("Rating: %.0f%%" % (rating,)) 110 else: 111 self._setTooltip() 112 113 def setNoGo(self, reason): 114 """Set a No-Go condition with the given reason.""" 115 if self._noGoReason is not None: 116 return 117 118 self._noGoReason = reason 119 if appIndicator: 120 self._ratingMenuItem.set_label("Rating: %s" % (reason,)) 121 else: 122 self._setTooltip() 123 self._statusIcon.set_blinking(True) 124 64 125 def _showHideToggled(self, menuitem): 65 126 """Called when the show/hide menu item is toggled.""" … … 68 129 else: 69 130 self._gui.hideMainWindow() 131 132 def _setTooltip(self): 133 """Set the tooltip of the status icon.""" 134 if self._noGoReason is None: 135 rating = "%.0f%%" % (self._rating,) 136 else: 137 rating = '<span foreground="red">' + self._noGoReason + '</span>' 138 139 markup = "MAVA Logger X %s\n\nStage: %s\nRating: %s" %\ 140 (const.VERSION, ("-" if self._stage is None else 141 const.stage2string(self._stage)), 142 rating) 143 144 self._statusIcon.set_tooltip_markup(markup) 145 -
src/mlx/logger.py
r30 r31 65 65 self.message(timestamp, "--- %s ---" % (s,)) 66 66 if stage==const.STAGE_END: 67 totalScore = 100 68 for (id, score) in self._faults.iteritems(): 69 totalScore -= score 70 self.untimedMessage("Score: %.0f" % (totalScore,)) 67 self.untimedMessage("Rating: %.0f" % (self.getRating(),)) 71 68 72 69 def fault(self, faultID, timestamp, what, score): … … 90 87 self.fault(faultID, timestamp, what, Logger.NO_GO_SCORE) 91 88 92 def get Score(self):93 """Get the scoreof the flight so far."""89 def getRating(self): 90 """Get the rating of the flight so far.""" 94 91 totalScore = 100 95 92 for (id, score) in self._faults.iteritems():
Note:
See TracChangeset
for help on using the changeset viewer.