Changeset 1042:c1308fb39512
- Timestamp:
- 04/03/22 14:17:27 (3 years ago)
- Branch:
- python3
- Phase:
- public
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
src/mlx/xplane.py
r1004 r1042 1714 1714 #------------------------------------------------------------------------------ 1715 1715 1716 class ZiboB737NGModel(B737Model): 1717 """Base model for the Zibo and LevelUp Boeing 737 models.""" 1718 def __init__(self, flapsRatios = [0.0, 0.081633, 0.142857, 0.224490, 1719 0.285714, 0.367347, 0.551020, 0.714286, 1720 1.0]): 1721 super(ZiboB737NGModel, self).__init__() 1722 self._flapsRatios = flapsRatios 1723 1724 def addMonitoringData(self, data, fsType): 1725 """Add the model-specific monitoring data to the given array.""" 1726 super(ZiboB737NGModel, self).addMonitoringData(data, fsType) 1727 1728 self._speedBrakeIndex = len(data) 1729 self._addDatarefWithIndexMember(data, 1730 "sim/flightmodel2/wing/speedbrake1_deg", 1731 (TYPE_FLOAT_ARRAY, 2)) 1732 self._addDatarefWithIndexMember(data, 1733 "sim/flightmodel2/wing/speedbrake2_deg", 1734 (TYPE_FLOAT_ARRAY, 2)) 1735 self._cgIndex = len(data) 1736 self._addDatarefWithIndexMember(data, 1737 "laminar/B738/fms/calc_to_cg", 1738 TYPE_FLOAT) 1739 self._wingHeatIndex = len(data) 1740 self._addDatarefWithIndexMember(data, 1741 "laminar/B738/ice/wing_heat_pos", 1742 TYPE_FLOAT) 1743 self._eng1HeatIndex = len(data) 1744 self._addDatarefWithIndexMember(data, 1745 "laminar/B738/ice/eng1_heat_pos", 1746 TYPE_FLOAT) 1747 self._eng2HeatIndex = len(data) 1748 self._addDatarefWithIndexMember(data, 1749 "laminar/B738/ice/eng2_heat_pos", 1750 TYPE_FLOAT) 1751 self._spoilersArmedIndex = len(data) 1752 self._addDatarefWithIndexMember(data, 1753 "laminar/B738/annunciator/speedbrake_armed", 1754 TYPE_FLOAT) 1755 1756 1757 def getAircraftState(self, aircraft, timestamp, data): 1758 """Get the aircraft state.""" 1759 state = super(ZiboB737NGModel, self).getAircraftState(aircraft, 1760 timestamp, 1761 data) 1762 state.cog = data[self._cgIndex]/100.0 1763 1764 flapsRatios = self._flapsRatios 1765 flapsRatio = data[self._monidx_flapsLeft] 1766 index = len(flapsRatios) 1767 for i in range(1, len(flapsRatios)): 1768 if flapsRatio<flapsRatios[i]: 1769 index = i-1 1770 break 1771 if index<len(flapsRatios): 1772 flapsRatio0 = flapsRatios[index] 1773 flapsNotch0 = self._flapsNotches[index] 1774 state.flaps = flapsNotch0 + \ 1775 (self._flapsNotches[index+1] - flapsNotch0) * \ 1776 (flapsRatio - flapsRatio0) / \ 1777 (flapsRatios[index+1] - flapsRatio0) 1778 else: 1779 state.flaps = self._flapsNotches[-1] 1780 1781 # 0 -> -1 1782 # 15 -> 0.790881 1783 state.elevatorTrim = \ 1784 15.0 * (data[self._monidx_elevatorTrim] + 1) / 1.790881 1785 1786 state.spoilersExtension = \ 1787 sum(data[self._speedBrakeIndex] + data[self._speedBrakeIndex+1])/4 1788 1789 state.antiIceOn = data[self._wingHeatIndex]!=0 or \ 1790 data[self._eng1HeatIndex]!=0 or \ 1791 data[self._eng2HeatIndex]!=0 1792 1793 state.spoilersArmed = data[self._spoilersArmedIndex]!=0 1794 1795 return state 1796 1797 #------------------------------------------------------------------------------ 1798 1799 class ZiboB738Model(ZiboB737NGModel): 1800 """Model for the Zibo Boeing 737-800 model.""" 1801 @staticmethod 1802 def doesHandle(aircraft, data): 1803 """Determine if this model handler handles the aircraft with the given 1804 name.""" 1805 (tailnum, author, description, notes, icao, liveryPath) = data 1806 return author=="Alex Unruh" and \ 1807 description=="Boeing 737-800X" and \ 1808 notes.startswith("ZIBOmod") and \ 1809 icao=="B738" 1810 1811 def __init__(self): 1812 """Construct the model.""" 1813 super(ZiboB738Model, self).__init__( 1814 flapsRatios = [0.0, 0.081633, 0.142857, 0.224490, 0.285714, 0.346939, 1815 0.551020, 0.673469, 1.0]) 1816 1817 @property 1818 def name(self): 1819 """Get the name for this aircraft model.""" 1820 return "Zibo Boeing 737-800" 1821 1822 #------------------------------------------------------------------------------ 1823 1824 class LevelUpB736Model(ZiboB737NGModel): 1825 """Model for the LevelUp Boeing 737-600 model.""" 1826 1827 @staticmethod 1828 def doesHandle(aircraft, data): 1829 """Determine if this model handler handles the aircraft with the given 1830 name.""" 1831 (tailnum, author, description, notes, icao, liveryPath) = data 1832 return author=="Alex Unruh" and \ 1833 description=="Boeing 737-600NG" and \ 1834 icao=="B736" 1835 1836 @property 1837 def name(self): 1838 """Get the name for this aircraft model.""" 1839 return "LevelUp Boeing 737-600" 1840 1841 #------------------------------------------------------------------------------ 1842 1843 class LevelUpB737Model(ZiboB737NGModel): 1844 """Model for the LevelUp Boeing 737-700 model.""" 1845 1846 @staticmethod 1847 def doesHandle(aircraft, data): 1848 """Determine if this model handler handles the aircraft with the given 1849 name.""" 1850 (tailnum, author, description, notes, icao, liveryPath) = data 1851 return author=="Alex Unruh" and \ 1852 description=="Boeing 737-700NG" and \ 1853 icao=="B737" 1854 1855 @property 1856 def name(self): 1857 """Get the name for this aircraft model.""" 1858 return "LevelUp Boeing 737-700" 1859 1860 #------------------------------------------------------------------------------ 1861 1862 class LevelUpB738Model(ZiboB737NGModel): 1863 """Model for the LevelUp Boeing 737-800 model.""" 1864 1865 @staticmethod 1866 def doesHandle(aircraft, data): 1867 """Determine if this model handler handles the aircraft with the given 1868 name.""" 1869 (tailnum, author, description, notes, icao, liveryPath) = data 1870 return author=="Alex Unruh" and \ 1871 description=="Boeing 737-800NG" and \ 1872 icao=="B738" 1873 1874 @property 1875 def name(self): 1876 """Get the name for this aircraft model.""" 1877 return "LevelUp Boeing 737-800" 1878 1879 #------------------------------------------------------------------------------ 1880 1716 1881 class B767Model(GenericAircraftModel): 1717 1882 """Generic model for the Boeing 767 aircraft.""" … … 1974 2139 #------------------------------------------------------------------------------ 1975 2140 2141 AircraftModel.registerSpecial(ZiboB738Model) 2142 AircraftModel.registerSpecial(LevelUpB736Model) 2143 AircraftModel.registerSpecial(LevelUpB737Model) 2144 AircraftModel.registerSpecial(LevelUpB738Model) 1976 2145 AircraftModel.registerSpecial(FJSDH8DModel) 1977 2146 AircraftModel.registerSpecial(FelisT154Model)
Note:
See TracChangeset
for help on using the changeset viewer.