Changeset 541:0369dcfecaae for src
- Timestamp:
- 09/19/13 09:19:19 (11 years ago)
- Branch:
- default
- Phase:
- public
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
src/mlx/xplane.py
r535 r541 733 733 self._fuelCallback = None 734 734 735 self._hasXFMC = None736 737 @property738 def hasXFMC(self):739 """Indicate if the simulator has the X-FMC plugin."""740 return self._hasXFMC741 742 735 def connect(self, aircraft): 743 736 """Initiate a connection to the simulator.""" … … 915 908 self._fsType = fsType 916 909 917 self._handler.requestRead([("xfmc/Status", TYPE_INT)],918 self._xfmcStatusRead)919 920 910 with self._hotkeyLock: 921 911 if self._hotkeyCodes is not None: … … 937 927 def disconnected(self): 938 928 """Called when a connection to the flight simulator has been broken.""" 939 self._hasXFMC = None940 929 with self._hotkeyLock: 941 930 self._clearHotkeyRequest() … … 956 945 self._normalRequestID = None 957 946 self._monitoring = False 958 959 def _xfmcStatusRead(self, data, extra):960 """Called when the xfmc/Status dataref is read or not."""961 self._hasXFMC = data is not None962 print "xplane.Simulator: XFMC is %savailable" % \963 ("" if self._hasXFMC else "not ")964 947 965 948 def _handleNormal(self, data, extra): … … 1291 1274 "sim/cockpit/switches/anti_ice_surf_heat", TYPE_INT), 1292 1275 ("propHeat", 1293 "sim/cockpit/switches/anti_ice_prop_heat", TYPE_INT) ] 1276 "sim/cockpit/switches/anti_ice_prop_heat", TYPE_INT), 1277 ("autopilotOn", 1278 "sim/cockpit2/autopilot/autopilot_on", TYPE_INT), 1279 ("apHeadingMode", 1280 "sim/cockpit2/autopilot/heading_mode", TYPE_INT)] 1281 1294 1282 1295 1283 specialModels = [] … … 1385 1373 self._addDataWithIndexMembers(data, "_monidx_", 1386 1374 AircraftModel.monitoringData) 1387 if self.simulator.hasXFMC:1388 print "xplane.AircraftModel.addMonitoringData: adding XFMC status dataref"""1389 self._addDatarefWithIndexMember(data, "xfmc/Status", TYPE_INT,1390 attrName = "_monidx_xfmcStatus")1391 1375 1392 1376 def getAircraftState(self, aircraft, timestamp, data): … … 1394 1378 state = fs.AircraftState() 1395 1379 1396 xfmcLNAVOn = self.simulator.hasXFMCand \1397 (data[self._monidx_xfmcStatus]&0x03==0x03)1380 lnavOn = data[self._monidx_autopilotOn]!=0 and \ 1381 data[self._monidx_apHeadingMode]==2 1398 1382 1399 1383 state.timestamp = timestamp … … 1464 1448 state.nav2 = self._convertFrequency(data[self._monidx_nav2]) 1465 1449 state.nav2_obs = self._convertOBS(data[self._monidx_nav2_obs]) 1466 state.nav2_manual = not xfmcLNAVOn1450 state.nav2_manual = not lnavOn 1467 1451 state.adf1 = str(data[self._monidx_adf1]) 1468 1452 state.adf2 = str(data[self._monidx_adf2]) … … 1483 1467 state.apMaster = data[self._monidx_apMaster]==2 1484 1468 apState = data[self._monidx_apState] 1485 if xfmcLNAVOn:1469 if lnavOn: 1486 1470 state.apHeadingHold = None 1487 1471 state.apHeading = None
Note:
See TracChangeset
for help on using the changeset viewer.