Changeset 56:1b8b546fd929


Ignore:
Timestamp:
04/03/12 17:34:19 (12 years ago)
Author:
István Váradi <ivaradi@…>
Branch:
default
hg-Phase:
(<MercurialRepository 1 'hg:/home/ivaradi/mlx/hg' '/'>, 'public')
Message:

Added the fuel, N1 and throttle values to the CLI as well.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/mlx/pyuipc_sim.py

    r55 r56  
    195195       
    196196        self.fuelWeights = [0.0, 3000.0, 3000.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0]
    197         # FIXME: check for realistic values
    198         self.fuelWeight = 3.5
     197        # Wikipedia: "Jet fuel", Jet A-1 density at 15*C .804kg/l -> 6.7 pounds/gallon
     198        self.fuelWeight = 6.70970518
    199199
    200200        self.heading = 220.0
     
    778778        """Convert the given PyUIPC value into a degree."""
    779779        return valie * 360.0 / 65536.0 / 65536.0
     780
     781    @staticmethod
     782    def fuelLevel2pyuipc(level):
     783        """Convert the given percentage value (as a string) into a PyUIPC value."""
     784        return int(float(level) * 128.0 * 65536.0 / 100.0)
     785       
     786    @staticmethod
     787    def pyuipc2fuelLevel(value):
     788        """Convert the PyUIPC value into a percentage value."""
     789        return value * 100.0 / 128.0 / 65536.0
     790       
     791    @staticmethod
     792    def fuelCapacity2pyuipc(capacity):
     793        """Convert the given capacity value (as a string) into a PyUIPC value."""
     794        return int(capacity)
     795       
     796    @staticmethod
     797    def pyuipc2fuelCapacity(value):
     798        """Convert the given capacity value into a PyUIPC value."""
     799        return value
     800       
     801    @staticmethod
     802    def throttle2pyuipc(throttle):
     803        """Convert the given throttle value (as a string) into a PyUIPC value."""
     804        return int(float(throttle) * 16384.0 / 100.0)
     805       
     806    @staticmethod
     807    def pyuipc2throttle(value):
     808        """Convert the given PyUIPC value into a throttle value."""
     809        return value * 100.0 / 16384.0
    780810       
    781811    def __init__(self):
     
    901931                                                lambda word: int(int(word) *
    902932                                                                 65536.0 / 360.0))
     933        self._valueHandlers["fuelWeight"] = (0x0af4, "H",
     934                                             lambda value: value / 256.0,
     935                                             lambda word: int(float(word)*256.0))
     936
     937
     938        self._valueHandlers["centreLevel"] = (0x0b74, "d", CLI.pyuipc2fuelLevel,
     939                                              CLI.fuelLevel2pyuipc)
     940        self._valueHandlers["centreCapacity"] = (0x0b78, "d",
     941                                                 CLI.pyuipc2fuelCapacity,
     942                                                 CLI.fuelCapacity2pyuipc)
     943        self._valueHandlers["leftMainLevel"] = (0x0b7c, "d", CLI.pyuipc2fuelLevel,
     944                                              CLI.fuelLevel2pyuipc)
     945        self._valueHandlers["leftMainCapacity"] = (0x0b80, "d",
     946                                                   CLI.pyuipc2fuelCapacity,
     947                                                   CLI.fuelCapacity2pyuipc)
     948        self._valueHandlers["leftAuxLevel"] = (0x0b84, "d", CLI.pyuipc2fuelLevel,
     949                                               CLI.fuelLevel2pyuipc)
     950        self._valueHandlers["leftAuxCapacity"] = (0x0b88, "d",
     951                                                   CLI.pyuipc2fuelCapacity,
     952                                                  CLI.fuelCapacity2pyuipc)
     953        self._valueHandlers["leftTipLevel"] = (0x0b8c, "d", CLI.pyuipc2fuelLevel,
     954                                              CLI.fuelLevel2pyuipc)
     955        self._valueHandlers["leftTipCapacity"] = (0x0b90, "d",
     956                                                  CLI.pyuipc2fuelCapacity,
     957                                                  CLI.fuelCapacity2pyuipc)
     958        self._valueHandlers["rightMainLevel"] = (0x0b94, "d", CLI.pyuipc2fuelLevel,
     959                                                 CLI.fuelLevel2pyuipc)
     960        self._valueHandlers["rightMainCapacity"] = (0x0b98, "d",
     961                                                    CLI.pyuipc2fuelCapacity,
     962                                                    CLI.fuelCapacity2pyuipc)
     963        self._valueHandlers["rightAuxLevel"] = (0x0b9c, "d", CLI.pyuipc2fuelLevel,
     964                                                CLI.fuelLevel2pyuipc)
     965        self._valueHandlers["rightAuxCapacity"] = (0x0ba0, "d",
     966                                                   CLI.pyuipc2fuelCapacity,
     967                                                   CLI.fuelCapacity2pyuipc)
     968        self._valueHandlers["rightTipLevel"] = (0x0ba4, "d", CLI.pyuipc2fuelLevel,
     969                                                CLI.fuelLevel2pyuipc)
     970        self._valueHandlers["rightTipCapacity"] = (0x0ba8, "d",
     971                                                   CLI.pyuipc2fuelCapacity,
     972                                                   CLI.fuelCapacity2pyuipc)
     973        self._valueHandlers["centre2Level"] = (0x1244, "d", CLI.pyuipc2fuelLevel,
     974                                               CLI.fuelLevel2pyuipc)
     975        self._valueHandlers["centre2Capacity"] = (0x1248, "d",
     976                                                  CLI.pyuipc2fuelCapacity,
     977                                                  CLI.fuelCapacity2pyuipc)
     978        self._valueHandlers["external1Level"] = (0x1254, "d", CLI.pyuipc2fuelLevel,
     979                                                 CLI.fuelLevel2pyuipc)
     980        self._valueHandlers["external1Capacity"] = (0x1258, "d",
     981                                                    CLI.pyuipc2fuelCapacity,
     982                                                    CLI.fuelCapacity2pyuipc)
     983        self._valueHandlers["external2Level"] = (0x125c, "d", CLI.pyuipc2fuelLevel,
     984                                                 CLI.fuelLevel2pyuipc)
     985        self._valueHandlers["external2Capacity"] = (0x1260, "d",
     986                                                    CLI.pyuipc2fuelCapacity,
     987                                                    CLI.fuelCapacity2pyuipc)
     988
     989        self._valueHandlers["n1_1"] = (0x2000, "f", lambda value: value,
     990                                       lambda word: float(word))
     991        self._valueHandlers["n1_2"] = (0x2100, "f", lambda value: value,
     992                                       lambda word: float(word))
     993        self._valueHandlers["n1_3"] = (0x2200, "f", lambda value: value,
     994                                       lambda word: float(word))
     995
     996        self._valueHandlers["throttle_1"] = (0x088c, "H",
     997                                             CLI.pyuipc2throttle,
     998                                             CLI.throttle2pyuipc)
     999        self._valueHandlers["throttle_2"] = (0x0924, "H",
     1000                                             CLI.pyuipc2throttle,
     1001                                             CLI.throttle2pyuipc)
     1002        self._valueHandlers["throttle_3"] = (0x09bc, "H",
     1003                                             CLI.pyuipc2throttle,
     1004                                             CLI.throttle2pyuipc)
    9031005                                                           
    9041006    def default(self, line):
Note: See TracChangeset for help on using the changeset viewer.