Changeset 57:04d8f6a603ee


Ignore:
Timestamp:
04/03/12 18:00:24 (12 years ago)
Author:
István Váradi <ivaradi@…>
Branch:
default
Phase:
public
Message:

TAS is calculated.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/mlx/pyuipc_sim.py

    r56 r57  
    1212import struct
    1313import cPickle
     14import math
    1415
    1516#------------------------------------------------------------------------------
     
    266267            # wind the GS
    267268            return int(self.ias * 65536.0 * 1852.0 / 3600.0)
     269        elif offset==0x02b8:       # TAS
     270            return int(self._getTAS() * 128.0)
    268271        elif offset==0x02bc:       # IAS
    269272            return int(self.ias * 128.0)
     
    617620        self.fuelCapacities[index] = value * self.fuelWeight * const.LBSTOKG
    618621
     622    def _getTAS(self):
     623        """Calculate the true airspeed."""
     624        pressure = 101325 * math.pow(1 - 2.25577e-5 * self.altitude *
     625                                      const.FEETTOMETRES,
     626                                      5.25588)
     627        temperature = 15 - self.altitude * 6.5 * const.FEETTOMETRES / 1000.0
     628        temperature += 273.15  # Celsius -> Kelvin
     629        airDensity = pressure / (temperature * 287.05)
     630        print "pressure:", pressure, "temperature:", temperature, "airDensity:", airDensity
     631        return self.ias * math.sqrt(1.225 / airDensity)
    619632
    620633#------------------------------------------------------------------------------
     
    866879                                     lambda word: int(float(word) * 65536.0 *
    867880                                                      1852.0 / 3600))
     881        self._valueHandlers["tas"] = (0x02b8, "d",
     882                                     lambda value: value / 128.0,
     883                                     lambda word: None)
    868884        self._valueHandlers["vs"] = (0x02c8, "d",
    869885                                     lambda value: value * 60 /                                     
Note: See TracChangeset for help on using the changeset viewer.