Changeset 431:207f92566e4f for src
- Timestamp:
- 02/17/13 12:41:47 (12 years ago)
- Branch:
- xplane
- Phase:
- public
- Location:
- src/mlx
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
src/mlx/gui/monitor.py
r428 r431 409 409 self._adf1.set_text("-" if aircraftState.adf1 is None else aircraftState.adf1) 410 410 self._adf2.set_text("-" if aircraftState.adf2 is None else aircraftState.adf2) 411 self._cog.set_text("%.2f%%" % (aircraftState.cog ,))411 self._cog.set_text("%.2f%%" % (aircraftState.cog*100.0,)) 412 412 413 413 #------------------------------------------------------------------------------ -
src/mlx/xplane.py
r429 r431 12 12 import math 13 13 14 from xplra import XPlane, MultiGetter, MultiSetter 14 from xplra import XPlane, MultiGetter, MultiSetter, ProtocolException 15 15 from xplra import TYPE_INT, TYPE_FLOAT, TYPE_DOUBLE 16 16 from xplra import TYPE_FLOAT_ARRAY, TYPE_INT_ARRAY, TYPE_BYTE_ARRAY … … 97 97 self._result = True 98 98 return True 99 elif Handler._performRead(self._multiBuffer, 100 self._extra, self._validator): 101 self._result = self._multiBuffer 99 100 try: 101 if Handler._performRead(self._multiBuffer, 102 self._extra, self._validator): 103 self._result = self._multiBuffer 104 return True 105 else: 106 return False 107 except ProtocolException, e: 108 self._result = None 102 109 return True 103 else:104 return False105 110 106 111 class ShowMessageRequest(Request): … … 304 309 attemptsLeft = Handler.NUM_READATTEMPTS 305 310 while attemptsLeft>0: 306 multiGetter.execute() 311 try: 312 multiGetter.execute() 313 except ProtocolException, e: 314 print "xplane.Handler._performRead: " + str(e) 315 raise 316 307 317 if validator is None or \ 308 318 Handler._callSafe(lambda: validator(multiGetter, extra)): … … 718 728 self._fuelCallback = None 719 729 730 self._hasXFMC = None 731 732 @property 733 def hasXFMC(self): 734 """Indicate if the simulator has the X-FMC plugin.""" 735 return self._hasXFMC 736 720 737 def connect(self, aircraft): 721 738 """Initiate a connection to the simulator.""" … … 892 909 simulator of the given type.""" 893 910 self._fsType = fsType 911 912 self._handler.requestRead([("xfmc/Status", TYPE_INT)], 913 self._xfmcStatusRead) 914 894 915 with self._hotkeyLock: 895 916 if self._hotkeyCodes is not None: … … 911 932 def disconnected(self): 912 933 """Called when a connection to the flight simulator has been broken.""" 934 self._hasXFMC = None 913 935 with self._hotkeyLock: 914 936 self._clearHotkeyRequest() … … 929 951 self._normalRequestID = None 930 952 self._monitoring = False 953 954 def _xfmcStatusRead(self, data, extra): 955 """Called when the xfmc/Status dataref is read or not.""" 956 self._hasXFMC = data is not None 957 print "xplane.Simulator: XFMC is %savailable" % \ 958 ("" if self._hasXFMC else "not ") 931 959 932 960 def _handleNormal(self, data, extra): … … 1008 1036 will be replaced by a new one.""" 1009 1037 self._aircraftModel = model 1038 model.simulator = self 1010 1039 1011 1040 if self._monitoring: … … 1302 1331 flapsNotches is a list of degrees of flaps that are available on the aircraft.""" 1303 1332 self._flapsNotches = flapsNotches 1333 self._simulator = None 1304 1334 1305 1335 @property … … 1307 1337 """Get the name for this aircraft model.""" 1308 1338 return "X-Plane/Generic" 1339 1340 @property 1341 def simulator(self): 1342 """Get the simulator this aircraft model works for.""" 1343 return self._simulator 1344 1345 @simulator.setter 1346 def simulator(self, simulator): 1347 """Get the simulator this aircraft model works for.""" 1348 self._simulator = simulator 1309 1349 1310 1350 def doesHandle(self, aircraft, aircraftInfo): … … 1340 1380 self._addDataWithIndexMembers(data, "_monidx_", 1341 1381 AircraftModel.monitoringData) 1382 if self.simulator.hasXFMC: 1383 print "xplane.AircraftModel.addMonitoringData: adding XFMC status dataref""" 1384 self._addDatarefWithIndexMember(data, "xfmc/Status", TYPE_INT, 1385 attrName = "_monidx_xfmcStatus") 1342 1386 1343 1387 def getAircraftState(self, aircraft, timestamp, data): 1344 1388 """Get an aircraft state object for the given monitoring data.""" 1345 1389 state = fs.AircraftState() 1390 1391 xfmcLNAVOn = self.simulator.hasXFMC and \ 1392 (data[self._monidx_xfmcStatus]&0x03==0x03) 1346 1393 1347 1394 state.timestamp = timestamp … … 1412 1459 state.nav2 = self._convertFrequency(data[self._monidx_nav2]) 1413 1460 state.nav2_obs = self._convertOBS(data[self._monidx_nav2_obs]) 1414 state.nav2_manual = True1461 state.nav2_manual = not xfmcLNAVOn 1415 1462 state.adf1 = str(data[self._monidx_adf1]) 1416 1463 state.adf2 = str(data[self._monidx_adf2]) … … 1431 1478 state.apMaster = data[self._monidx_apMaster]==2 1432 1479 apState = data[self._monidx_apState] 1433 state.apHeadingHold = (apState&0x00002)!=0 1434 state.apHeading = data[self._monidx_apHeading] 1480 if xfmcLNAVOn: 1481 state.apHeadingHold = None 1482 state.apHeading = None 1483 else: 1484 state.apHeadingHold = (apState&0x00002)!=0 1485 state.apHeading = data[self._monidx_apHeading] 1486 1435 1487 state.apAltitudeHold = (apState&0x04000)!=0 1436 1488 state.apAltitude = data[self._monidx_apAltitude] … … 1692 1744 name.""" 1693 1745 return aircraft.type==const.AIRCRAFT_DH8D and \ 1694 description.find("Dash 8 Q400")!=-1 and \ 1695 liveryPath.startswith("Aircraft/Heavy Metal/Dash 8 Q400") 1746 description.find("Dash 8 Q400")!=-1 and \ 1747 ((author=="2012" and tailnum=="N62890") or \ 1748 author.find("Jack Skieczius")!=-1) 1696 1749 1697 1750 @property
Note:
See TracChangeset
for help on using the changeset viewer.