Changeset 16:eb7e301a7d8b for src
- Timestamp:
- 02/11/12 19:54:41 (13 years ago)
- Branch:
- default
- Phase:
- public
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
src/fsuipc.py
r9 r16 276 276 while self._connectionRequested: 277 277 try: 278 pyuipc.open(pyuipc.SIM_ FS2K4)278 pyuipc.open(pyuipc.SIM_ANY) 279 279 description = "(FSUIPC version: 0x%04x, library version: 0x%04x, FS version: %d)" % \ 280 280 (pyuipc.fsuipc_version, pyuipc.lib_version, … … 326 326 327 327 Returns what the request's process() function returned or None if 328 reconnection failed.""" 329 328 reconnection failed.""" 330 329 self._requestCondition.release() 331 330 … … 393 392 (0x0580, "d") ] # Heading 394 393 395 def __init__(self, connectionListener , aircraft):394 def __init__(self, connectionListener): 396 395 """Construct the simulator. 397 396 … … 414 413 from the simulator or was calculated by the adapter. The other data 415 414 are self-explanatory and expressed in their 'natural' units.""" 416 self._aircraft = aircraft415 self._aircraft = None 417 416 418 417 self._handler = Handler(connectionListener) … … 432 431 self._flareStartFS = None 433 432 434 def connect(self ):433 def connect(self, aircraft): 435 434 """Initiate a connection to the simulator.""" 435 self._aircraft = aircraft 436 self._aircraftName = None 437 self._aircraftModel = None 436 438 self._handler.connect() 437 439 self._startDefaultNormal() … … 488 490 self._handler.clearPeriodic(self._normalRequestID) 489 491 self._normalRequestID = None 492 self._monitoring = False 490 493 491 494 def _handleNormal(self, data, extra): … … 506 509 507 510 if self._monitoringRequested and not self._monitoring: 508 self._monitoring = True509 511 self._stopNormal() 510 512 self._startMonitoring() 511 513 elif self._monitoring and not self._monitoringRequested: 512 self._monitoring = False513 514 self._stopNormal() 514 515 self._startDefaultNormal() … … 559 560 def _startMonitoring(self): 560 561 """Start monitoring with the current aircraft model.""" 561 assert self._monitoring562 563 562 data = Simulator.normalData[:] 564 563 self._aircraftModel.addMonitoringData(data) … … 567 566 self._handler.requestPeriodicRead(1.0, data, 568 567 self._handleNormal) 568 self._monitoring = True 569 569 570 570 def _addFlareRate(self, data): … … 802 802 803 803 flapsLeft = data[self._monidx_flapsLeft] 804 flapsIndex = flapsLeft / flapsIncrement 805 state.flaps = self._flapsNotches[flapsIndex] 806 if flapsIndex != numNotchesM1: 807 thisNotch = flapsIndex * flapsIncrement 808 nextNotch = thisNotch + flapsIncrement 809 810 state.flaps += (self._flapsNotches[flapsIndex+1] - state.flaps) * \ 811 (flapsLeft - thisNotch) / (nextNotch - thisNotch) 804 state.flaps = self._flapsNotches[-1]*flapsLeft/16383.0 812 805 813 806 lights = data[self._monidx_lights] … … 891 884 self._engineStartIndex = len(data) 892 885 for i in range(0, self._numEngines): 893 self._addOffsetWithIndexMember(data, 0x0898 + i * 0x98, " u") # N1894 self._addOffsetWithIndexMember(data, 0x088c + i * 0x98, " d") # throttle lever886 self._addOffsetWithIndexMember(data, 0x0898 + i * 0x98, "H") # N1 887 self._addOffsetWithIndexMember(data, 0x088c + i * 0x98, "h") # throttle lever 895 888 896 889 def getAircraftState(self, aircraft, timestamp, data): … … 1011 1004 1012 1005 class DH8DModel(GenericAircraftModel): 1013 """Generic model for the Bo eing 737 NGaircraft."""1006 """Generic model for the Bombardier Dash 8-Q400 aircraft.""" 1014 1007 def __init__(self): 1015 1008 """Construct the model.""" … … 1022 1015 def name(self): 1023 1016 """Get the name for this aircraft model.""" 1024 return "FSUIPC/Generic Bombardier Dash-8 Q400" 1025 1017 return "FSUIPC/Generic Bombardier Dash 8-Q400" 1018 1019 #------------------------------------------------------------------------------ 1020 1021 class DreamwingsDH8DModel(DH8DModel): 1022 """Model handler for the Dreamwings Dash 8-Q400.""" 1023 @staticmethod 1024 def doesHandle(aircraft, (name, airPath)): 1025 """Determine if this model handler handles the aircraft with the given 1026 name.""" 1027 return aircraft.type==const.AIRCRAFT_DH8D and \ 1028 (name.find("Dreamwings")!=-1 or airPath.find("Dreamwings")!=-1) and \ 1029 (name.find("Dash")!=-1 or airPath.find("Dash")!=-1) and \ 1030 (name.find("Q400")!=-1 or airPath.find("Q400")!=-1) and \ 1031 airPath.find("Dash8Q400")!=-1 1032 1033 @property 1034 def name(self): 1035 """Get the name for this aircraft model.""" 1036 return "FSUIPC/Dreamwings Bombardier Dash 8-Q400" 1037 1038 def getAircraftState(self, aircraft, timestamp, data): 1039 """Get the aircraft state. 1040 1041 Get it from the parent, and then invert the pitot heat state.""" 1042 state = super(DreamwingsDH8DModel, self).getAircraftState(aircraft, 1043 timestamp, 1044 data) 1045 state.pitotHeatOn = not state.pitotHeatOn 1046 1047 return state 1026 1048 #------------------------------------------------------------------------------ 1027 1049 … … 1153 1175 1154 1176 AircraftModel.registerSpecial(PMDGBoeing737NGModel) 1155 1156 #------------------------------------------------------------------------------ 1157 1177 AircraftModel.registerSpecial(DreamwingsDH8DModel) 1178 1179 #------------------------------------------------------------------------------
Note:
See TracChangeset
for help on using the changeset viewer.