Changeset 134:9ce031d5d4a9 for src
- Timestamp:
- 04/30/12 14:42:59 (13 years ago)
- Branch:
- default
- Phase:
- public
- Location:
- src/mlx
- Files:
-
- 10 edited
Legend:
- Unmodified
- Added
- Removed
-
src/mlx/acft.py
r117 r134 5 5 import const 6 6 import checks 7 import fs 7 8 import util 8 9 … … 54 55 self._checkers.append(checks.CruiseSpeedLogger()) 55 56 self._checkers.append(checks.SpoilerLogger()) 57 58 if flight.config.isMessageTypeFS(const.MESSAGETYPE_VISIBILITY): 59 self._checkers.append(checks.VisibilityChecker()) 56 60 57 61 # Fault checkers … … 134 138 self.logger.message(aircraftState.timestamp, 135 139 "Zero-fuel weight: %.0f kg" % (aircraftState.zfw)) 140 flight = self._flight 141 if flight.v1 is None or flight.vr is None or flight.v2 is None: 142 fs.sendMessage(const.MESSAGETYPE_HELP, 143 "Don't forget to set the takeoff V-speeds!", 144 5) 136 145 elif newStage==const.STAGE_TAKEOFF: 137 146 self.logger.message(aircraftState.timestamp, "Flight time start") … … 145 154 self._logV1R2() 146 155 elif newStage==const.STAGE_TAXIAFTERLAND: 156 bookedFlight = self._flight.bookedFlight 157 if bookedFlight.arrivalICAO=="LHBP" and \ 158 self._flight.config.isMessageTypeFS(const.MESSAGETYPE_GATE_SYSTEM): 159 self._flight.getFleet(callback = self._fleetRetrieved, 160 force = True) 147 161 self.logger.message(aircraftState.timestamp, "Flight time end") 148 162 self.logFuel(aircraftState) … … 167 181 "Block time: " + 168 182 util.getTimeIntervalString(blockLength)) 183 bookedFlight = self._flight.bookedFlight 184 # FIXME: translate the ICAO into an airport name 185 fs.sendMessage(const.MESSAGETYPE_ENVIRONMENT, 186 "Flight plan closed. Welcome to %s" % \ 187 (bookedFlight.arrivalICAO,), 188 5) 169 189 170 190 def prepareFlare(self): … … 189 209 self._logVRef() 190 210 self.flight.flareStarted(flareStart, flareStartFS) 211 fs.sendMessage(const.MESSAGETYPE_INFORMATION, "Flare-time", 3) 191 212 192 213 def flareFinished(self, flareEnd, flareEndFS, tdRate, tdRateCalculatedByFS, … … 265 286 else: 266 287 self.logger.updateLine(self._vrefLineIndex, message) 288 289 def _fleetRetrieved(self, fleet): 290 """Callback for the fleet retrieval result.""" 291 if fleet is not None: 292 gateList = "" 293 occupiedGateNumbers = fleet.getOccupiedGateNumbers() 294 for gateNumber in const.lhbpGateNumbers: 295 if gateNumber not in occupiedGateNumbers: 296 if gateList: gateList += ", " 297 gateList += gateNumber 298 fs.sendMessage(const.MESSAGETYPE_GATE_SYSTEM, 299 "Free gates: " + gateList, 20) 300 267 301 268 302 #--------------------------------------------------------------------------------------- -
src/mlx/checks.py
r60 r134 3 3 #--------------------------------------------------------------------------------------- 4 4 5 import fs 5 6 import const 7 import util 6 8 7 9 #--------------------------------------------------------------------------------------- … … 143 145 #--------------------------------------------------------------------------------------- 144 146 147 class VisibilityChecker(StateChecker): 148 """Inform the pilot of the visibility once when descending below 2000 ft, 149 then when descending below 1000 ft.""" 150 def __init__(self): 151 """Construct the visibility checker.""" 152 self._informedBelow2000 = False 153 self._informedBelow1000 = False 154 155 def check(self, flight, aircraft, logger, oldState, state): 156 """Check if we need to inform the pilot of the visibility.""" 157 if flight.stage==const.STAGE_DESCENT or \ 158 flight.stage==const.STAGE_LANDING: 159 if (state.radioAltitude<2000 and not self._informedBelow2000) or \ 160 (state.radioAltitude<1000 and not self._informedBelow1000): 161 visibilityString = util.visibility2String(state.visibility) 162 fs.sendMessage(const.MESSAGETYPE_VISIBILITY, 163 "Current visibility: " + visibilityString, 164 5) 165 logger.message(state.timestamp, 166 "Pilot was informed about the visibility: " + 167 visibilityString) 168 self._informedBelow2000 = True 169 self._informedBelow1000 = state.radioAltitude<1000 170 171 #--------------------------------------------------------------------------------------- 172 145 173 class StateChangeLogger(StateChecker): 146 174 """Base class for classes the instances of which check if a specific change has -
src/mlx/config.py
r133 r134 114 114 else const.MESSAGELEVEL_NONE 115 115 116 def isMessageTypeFS(self, messageType): 117 """Determine if the given message type is displayed in the 118 simulator.""" 119 level = self.getMessageTypeLevel(messageType) 120 return level==const.MESSAGELEVEL_FS or \ 121 level==const.MESSAGELEVEL_BOTH 122 116 123 def setMessageTypeLevel(self, messageType, level): 117 124 """Set the level of the given message type.""" -
src/mlx/const.py
r133 r134 202 202 203 203 # Message type: information 204 # FIXME: flare time begin (3 sec)205 204 MESSAGETYPE_INFORMATION = 2 206 205 … … 212 211 213 212 # Message type: gate system messages 214 # FIXME: the available gates when arriving to LHBP (10 sec)215 213 MESSAGETYPE_GATE_SYSTEM = 5 216 214 … … 220 218 221 219 # Message type: help messages 222 # FIXME: don't forget V speeds when stage is PUSHANDTAXI (5 sec)223 220 MESSAGETYPE_HELP = 7 224 221 225 222 # Message type: visibility messages 226 # FIXME: the visibility, once when below 2000 RA, then when below 1000 RA (5 sec)227 223 MESSAGETYPE_VISIBILITY = 8 228 224 -
src/mlx/flight.py
r89 r134 60 60 61 61 @property 62 def config(self): 63 """Get the configuration.""" 64 return self._gui.config 65 66 @property 62 67 def stage(self): 63 68 """Get the flight stage.""" 64 69 return self._stage 70 71 @property 72 def bookedFlight(self): 73 """Get the booked flight.""" 74 return self._gui.bookedFlight 65 75 66 76 @property … … 163 173 self._endCondition.wait(1) 164 174 175 def getFleet(self, callback, force = False): 176 """Get the fleet and call the given callback.""" 177 self._gui.getFleetAsync(callback = callback, force = force) 178 165 179 def _updateFlownDistance(self, currentState): 166 180 """Update the flown distance.""" -
src/mlx/fs.py
r133 r134 199 199 - windSpeed: the speed of the wind at the aircraft in knots (float) 200 200 - windDirection: the direction of the wind at the aircraft in degrees (float) 201 - visibility: the visibility in metres (float) 201 202 202 203 FIXME: needed when taxiing only: -
src/mlx/fsuipc.py
r133 r134 830 830 ("squawk", 0x0354, "H"), 831 831 ("windSpeed", 0x0e90, "H"), 832 ("windDirection", 0x0e92, "H")] 832 ("windDirection", 0x0e92, "H"), 833 ("visibility", 0x0e8a, "H")] 833 834 834 835 … … 1003 1004 state.windDirection = data[self._monidx_windDirection]*360.0/65536.0 1004 1005 if state.windDirection<0.0: state.windDirection += 360.0 1006 1007 state.visibility = data[self._monidx_visibility]*1609.344/100.0 1005 1008 1006 1009 return state -
src/mlx/gui/gui.py
r133 r134 400 400 self._statusbar.updateConnection(False, False) 401 401 self._weightHelp.disable() 402 403 return True 402 404 403 405 def addFlightLogLine(self, timeStr, line): … … 442 444 self._wizard.setStage(stage) 443 445 if stage==const.STAGE_END: 444 self._disconnect() 446 # FIXME: perhaps a more elegant method, e.g. 447 # the simulator should provide a function disconnect 448 # with a final message 449 gobject.timeout_add(1.0, self._disconnect) 445 450 446 451 def setRating(self, rating): … … 564 569 self._weightHelp.reset() 565 570 self._weightHelp.enable() 571 572 def getFleetAsync(self, callback = None, force = None): 573 """Get the fleet asynchronously.""" 574 gobject.idle_add(self.getFleet, callback, force) 566 575 567 576 def getFleet(self, callback = None, force = False): -
src/mlx/logger.py
r133 r134 75 75 if stage==const.STAGE_END: 76 76 self.untimedMessage("Rating: %.0f" % (self.getRating(),)) 77 sendMessage(const.MESSAGETYPE_INFORMATION, "Flight stage: " + s, 3) 77 else: 78 sendMessage(const.MESSAGETYPE_INFORMATION, "Flight stage: " + s, 3) 78 79 79 80 def fault(self, faultID, timestamp, what, score): -
src/mlx/util.py
r97 r134 149 149 return (radians2nm(d), math.degrees(tc)) 150 150 151 #------------------------------------------------------------------------------ 152 153 def visibility2String(visibility): 154 """Convert the given visibility expressed in metres into a string.""" 155 return "%.0f metres" % (visibility,) if visibility<10000 \ 156 else "%.1f kilometres" % (visibility/1000.0,)
Note:
See TracChangeset
for help on using the changeset viewer.