Changeset 1064:d70786515883


Ignore:
Timestamp:
09/25/22 12:53:06 (2 years ago)
Author:
István Váradi <ivaradi@…>
Branch:
python3
Phase:
public
Tags:
version_0.51
Message:

Support for the FlyJSim Q4XP model

File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/mlx/xplane.py

    r1063 r1064  
    14911491        state.cog = data[self._monidx_cog]
    14921492
    1493         state.xpdrC = data[self._monidx_xpdrC]==2
     1493        state.xpdrC = data[self._monidx_xpdrC]>=2
    14941494        state.autoXPDR = False
    14951495
     
    20032003#------------------------------------------------------------------------------
    20042004
     2005class FJSDH8DXPModel(DH8DModel):
     2006    """Model handler for the FlyJSim Q4XP."""
     2007    @staticmethod
     2008    def doesHandle(aircraft, data):
     2009        """Determine if this model handler handles the aircraft with the given
     2010        name."""
     2011        (tailnum, author, description, notes, icao, liveryPath) = data
     2012        return aircraft.type==const.AIRCRAFT_DH8D and \
     2013          description.find("Dash 8 Q400")!=-1 and \
     2014          author=="FlyJSim" and tailnum=="N62890"
     2015
     2016    @property
     2017    def name(self):
     2018        """Get the name for this aircraft model."""
     2019        return "X-Plane/FlyJSim Q4XP"
     2020
     2021    def addMonitoringData(self, data, fsType):
     2022        """Add the model-specific monitoring data to the given array."""
     2023        super(FJSDH8DXPModel, self).addMonitoringData(data, fsType)
     2024
     2025        self._speedBrakeIndex = len(data)
     2026        self._addDatarefWithIndexMember(data,
     2027                                        "sim/flightmodel2/wing/spoiler1_deg",
     2028                                        (TYPE_FLOAT_ARRAY, 32))
     2029        self._addDatarefWithIndexMember(data,
     2030                                        "sim/flightmodel2/wing/spoiler2_deg",
     2031                                        (TYPE_FLOAT_ARRAY, 32))
     2032
     2033        self._gearIndex = len(data)
     2034        self._addDatarefWithIndexMember(data,
     2035                                        "FJS/Q4XP/Manips/GearDeployHandle_Ctl",
     2036                                        (TYPE_FLOAT_ARRAY, 1))
     2037
     2038        self._apIndex = len(data)
     2039        self._addDatarefWithIndexMember(data,
     2040                                        "FJS/Q4XP/FMA/roll_act",
     2041                                        TYPE_INT)
     2042        self._addDatarefWithIndexMember(data,
     2043                                        "FJS/Q4XP/FMA/pitch_act",
     2044                                        TYPE_INT)
     2045
     2046        self._propPitchIndex = len(data)
     2047        self._addDatarefWithIndexMember(data,
     2048                                        "sim/flightmodel2/engines/prop_pitch_deg",
     2049                                        (TYPE_FLOAT_ARRAY, 2))
     2050
     2051
     2052    def getAircraftState(self, aircraft, timestamp, data):
     2053        """Get the aircraft state.
     2054
     2055        Get it from the parent, and then invert the pitot heat state."""
     2056        state = super(FJSDH8DXPModel, self).getAircraftState(aircraft,
     2057                                                             timestamp,
     2058                                                             data)
     2059        state.antiCollisionLightsOn = \
     2060          state.antiCollisionLightsOn or state.strobeLightsOn
     2061        state.cog = (state.cog * 41.656436697 + 27.586779769)/100.0
     2062
     2063        # It seems that N1 does not always go down to 0 properly
     2064        # (maybe due to winds?)
     2065        state.n1 = [0 if n1<2.0 else n1 for n1 in state.n1]
     2066
     2067        state.spoilersExtension = \
     2068            sum(data[self._speedBrakeIndex] + data[self._speedBrakeIndex+1])/4
     2069        if state.spoilersExtension<40:
     2070            state.spoilersExtension = 0.0
     2071
     2072        state.gearControlDown = data[self._gearIndex][0]>0.5
     2073
     2074        state.apHeadingHold = data[self._apIndex]==4
     2075        state.apAltitudeHold = data[self._apIndex+1] in [4, 5]
     2076
     2077        state.reverser = [p<=-12.0 for p in data[self._propPitchIndex]]
     2078
     2079        return state
     2080
     2081#------------------------------------------------------------------------------
     2082
    20052083class CRJ2Model(GenericAircraftModel):
    20062084    """Generic model for the Bombardier CRJ-200 aircraft."""
     
    21802258AircraftModel.registerSpecial(LevelUpB738Model)
    21812259AircraftModel.registerSpecial(FJSDH8DModel)
     2260AircraftModel.registerSpecial(FJSDH8DXPModel)
    21822261AircraftModel.registerSpecial(FelisT154Model)
    21832262
Note: See TracChangeset for help on using the changeset viewer.