Changeset 212:fab302d5b7f6


Ignore:
Timestamp:
05/31/12 17:25:32 (12 years ago)
Author:
István Váradi <ivaradi@…>
Branch:
default
Phase:
public
Message:

Added support for the lights switches of the PMDG 737 NGX

Location:
src/mlx
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • src/mlx/fsuipc.py

    r209 r212  
    343343                     pyuipc.fs_version)
    344344                if not autoReconnection:
     345                    fsType = const.SIM_MSFSX \
     346                             if pyuipc.fs_version == pyuipc.SIM_FSX \
     347                             else const.SIM_MSFS9
     348               
    345349                    Handler._callSafe(lambda:     
    346                                       self._connectionListener.connected(const.SIM_MSFS9,
     350                                      self._connectionListener.connected(fsType,
    347351                                                                         description))
    348352                self._connected = True
     
    531535         from the simulator or was calculated by the adapter. The other data
    532536         are self-explanatory and expressed in their 'natural' units."""
     537        self._fsType = None
    533538        self._aircraft = None
    534539
     
    749754        """Called when a connection has been established to the flight
    750755        simulator of the given type."""
     756        self._fsType = fsType
    751757        with self._hotkeyLock:
    752758            if self._hotkeys is not None:
     
    892898        """Start monitoring with the current aircraft model."""
    893899        data = Simulator.normalData[:]
    894         self._aircraftModel.addMonitoringData(data)
     900        self._aircraftModel.addMonitoringData(data, self._fsType)
    895901       
    896902        self._normalRequestID = \
     
    12391245            self._addOffsetWithIndexMember(dest, offset, type, prefix + name)
    12401246           
    1241     def addMonitoringData(self, data):
     1247    def addMonitoringData(self, data, fsType):
    12421248        """Add the model-specific monitoring data to the given array."""
    12431249        self._addDataWithIndexMembers(data, "_monidx_",
     
    13671373        return True
    13681374
    1369     def addMonitoringData(self, data):
     1375    def addMonitoringData(self, data, fsType):
    13701376        """Add the model-specific monitoring data to the given array."""
    1371         super(GenericAircraftModel, self).addMonitoringData(data)
     1377        super(GenericAircraftModel, self).addMonitoringData(data, fsType)
    13721378       
    13731379        self._addOffsetWithIndexMember(data, 0x0af4, "H", "_monidx_fuelWeight")
     
    14641470    def name(self):
    14651471        """Get the name for this aircraft model."""
    1466         return "FSUIPC/PMDG Boeing 737NG"
    1467 
    1468     def addMonitoringData(self, data):
     1472        return "FSUIPC/PMDG Boeing 737NG(X)"
     1473
     1474    def addMonitoringData(self, data, fsType):
    14691475        """Add the model-specific monitoring data to the given array."""
    1470         super(PMDGBoeing737NGModel, self).addMonitoringData(data)
     1476        self._fsType = fsType
     1477       
     1478        super(PMDGBoeing737NGModel, self).addMonitoringData(data, fsType)
    14711479               
    14721480        self._addOffsetWithIndexMember(data, 0x6202, "b", "_pmdgidx_switches")
     1481
     1482        if fsType==const.SIM_MSFSX:
     1483            print "FSX detected, adding position lights switch offset"
     1484            self._addOffsetWithIndexMember(data, 0x6500, "b",
     1485                                           "_pmdgidx_lts_positionsw")
    14731486
    14741487    def getAircraftState(self, aircraft, timestamp, data):
     
    14811494        if data[self._pmdgidx_switches]&0x01==0x01:
    14821495            state.altimeter = 1013.25
     1496
     1497        if self._fsType==const.SIM_MSFSX:
     1498            state.strobeLightsOn = data[self._pmdgidx_lts_positionsw]==0x02
    14831499
    14841500        return state
  • src/mlx/pyuipc_sim.py

    r211 r212  
    2525SIM_FS2K2=6
    2626SIM_FS2K4=7
     27SIM_FSX=8
    2728
    2829#------------------------------------------------------------------------------
     
    260261        for i in range(0, Values.HOTKEY_SIZE):
    261262            self.hotkeyTable.append([0, 0, 0, 0])
     263
     264        self.pmdg_737ng_switches = 0
     265        self.pmdg_737ngx_lts_positionsw = 0
    262266
    263267    def read(self, offset, type):
     
    480484        elif offset==0x3d00:       # Name of the current aircraft
    481485            return self.aircraftName
     486        elif offset==0x6202:       # PMDG 737NG switches
     487            return self.pmdg_737ng_switches
     488        elif offset==0x6500:       # PMDG 737NGX lights position SW
     489            return self.pmdg_737ngx_lts_positionsw
    482490        else:
    483491            print "Unhandled offset: %04x" % (offset,)
     
    688696        elif offset==0x3d00:       # Name of the current aircraft
    689697            self.aircraftName = value
     698        elif offset==0x6202:       # PMDG 737NG switches
     699            self.pmdg_737ng_switches = value
     700        elif offset==0x6500:       # PMDG 737NGX lights position SW
     701            self.pmdg_737ngx_lts_positionsw = value
    690702        else:
    691703            print "Unhandled offset: %04x" % (offset,)
     
    808820CALL_READ=1
    809821CALL_WRITE=2
    810 CALL_CLOSE=3
    811 CALL_FAILOPEN=4
     822CALL_SETVERSION=3
     823CALL_CLOSE=4
     824CALL_FAILOPEN=5
    812825CALL_QUIT = 99
    813826
     
    853866                    elif call==CALL_WRITE:
    854867                        result = write(args[0])
     868                    elif call==CALL_SETVERSION:
     869                        global fs_version
     870                        fs_version = args[0]
     871                        result = None
    855872                    elif call==CALL_CLOSE:
    856873                        global opened
     
    899916        """Write the given data."""
    900917        return self._call(CALL_WRITE, data)
     918
     919    def setVersion(self, version):
     920        """Set the FS version to emulate."""
     921        return self._call(CALL_SETVERSION, int(version))
    901922
    902923    def close(self):
     
    12311252                                                      lambda value: "0x%08x" % (value,),
    12321253                                                      lambda word: long(word, 16))
     1254
     1255        self._valueHandlers["pmdg_737ng_switches"] = (0x6202, "b",
     1256                                                      lambda value: value,
     1257                                                      lambda word: int(word))
     1258
     1259        self._valueHandlers["pmdg_737ngx_lts_positionsw"] = (0x6500, "b",
     1260                                                             lambda value: value,
     1261                                                             lambda word: int(word))
     1262
    12331263    def default(self, line):
    12341264        """Handle unhandle commands."""
     
    13131343            return [key + "=" for key in self._valueHandlers if key.startswith(text)]
    13141344
     1345    def do_setversion(self, args):
     1346        """Set the version number to simulate"""
     1347        try:
     1348            value = int(args)
     1349            self._client.setVersion(value)
     1350            print "Emulating version %d" % (value,)
     1351        except Exception, e:
     1352            print >> sys.stderr, "Failed to set the version: " + str(e)
     1353
     1354    def help_setversion(self, usage = False):
     1355        """Help for the setversion command"""
     1356        if usage: print "Usage:",
     1357        print "setversion <number>"
     1358
    13151359    def do_close(self, args):
    13161360        """Close an existing connection so that FS will fail."""
     
    13191363            print "Connection closed"
    13201364        except Exception, e:
    1321             print >> sys.stderr, "Failed to close the connection: " + str(e)       
     1365            print >> sys.stderr, "Failed to close the connection: " + str(e)
    13221366       
    13231367    def do_failopen(self, args):
     
    13311375
    13321376    def help_failopen(self, usage = False):
    1333         """Help for the failopen close"""
     1377        """Help for the failopen command"""
    13341378        if usage: print "Usage:",
    13351379        print "failopen yes|no"
Note: See TracChangeset for help on using the changeset viewer.