Ignore:
Timestamp:
05/01/12 09:14:13 (12 years ago)
Author:
István Váradi <ivaradi@…>
Branch:
default
Phase:
public
Message:

Reworked fuel tank handling to be more indirect

File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/mlx/fsuipc.py

    r134 r140  
    66import const
    77import util
     8import acft
    89
    910import threading
     
    1819else:
    1920    import pyuipc_sim as pyuipc
     21
     22#------------------------------------------------------------------------------
     23
     24# The mapping of tank types to FSUIPC offsets
     25_tank2offset = { const.FUELTANK_CENTRE : 0x0b74,
     26                 const.FUELTANK_LEFT : 0x0b7c,
     27                 const.FUELTANK_RIGHT : 0x0b94,
     28                 const.FUELTANK_LEFT_AUX : 0x0b84,
     29                 const.FUELTANK_RIGHT_AUX : 0x0b9c,
     30                 const.FUELTANK_LEFT_TIP : 0x0b8c,
     31                 const.FUELTANK_RIGHT_TIP : 0x0ba4,
     32                 const.FUELTANK_EXTERNAL1 : 0x1254,
     33                 const.FUELTANK_EXTERNAL2 : 0x125c,
     34                 const.FUELTANK_CENTRE2 : 0x1244 }
    2035
    2136#------------------------------------------------------------------------------
     
    10141029    """A generic aircraft model that can handle the fuel levels, the N1 or RPM
    10151030    values and some other common parameters in a generic way."""
    1016     def __init__(self, flapsNotches, fuelInfo, numEngines, isN1 = True):
     1031   
     1032    def __init__(self, flapsNotches, fuelTanks, numEngines, isN1 = True):
    10171033        """Construct the generic aircraft model with the given data.
    10181034
     
    10201036        notches mean.
    10211037
    1022         fuelInfo is an array of FSUIPC offsets for the levels of the fuel
    1023         tanks. It is assumed to be a 4-byte value, followed by another 4-byte
    1024         value, which is the fuel tank capacity.
     1038        fuelTanks is an array of const.FUELTANK_XXX constants about the
     1039        aircraft's fuel tanks. They will be converted to offsets.
    10251040
    10261041        numEngines is the number of engines the aircraft has.
     
    10301045        super(GenericAircraftModel, self).__init__(flapsNotches = flapsNotches)
    10311046
    1032         self._fuelInfo = fuelInfo
     1047        self._fuelTanks = fuelTanks
    10331048        self._fuelStartIndex = None
    10341049        self._numEngines = numEngines
     
    10491064
    10501065        self._fuelStartIndex = len(data)
    1051         for offset in self._fuelInfo:
     1066        for tank in self._fuelTanks:
     1067            offset = _tank2offset[tank]
    10521068            self._addOffsetWithIndexMember(data, offset, "u")    # tank level
    10531069            self._addOffsetWithIndexMember(data, offset+4, "u")  # tank capacity
     
    10711087        state.fuel = []
    10721088        for i in range(self._fuelStartIndex,
    1073                        self._fuelStartIndex + 2*len(self._fuelInfo), 2):
     1089                       self._fuelStartIndex + 2*len(self._fuelTanks), 2):
    10741090            fuel = data[i+1]*data[i]*fuelWeight*const.LBSTOKG/128.0/65536.0
    10751091            state.fuel.append(fuel)
     
    10921108        super(GenericModel, self). \
    10931109            __init__(flapsNotches = [0, 10, 20, 30],
    1094                      fuelInfo = [0x0b74, 0x0b7c, 0xb94],
     1110                     fuelTanks = [const.FUELTANK_LEFT, const.FUELTANK_RIGHT],
    10951111                     numEngines = 2)
    10961112
     
    11081124        super(B737Model, self). \
    11091125            __init__(flapsNotches = [0, 1, 2, 5, 10, 15, 25, 30, 40],
    1110                      fuelInfo = [0x0b74, 0x0b7c, 0xb94],
     1126                     fuelTanks = acft.Boeing737.fuelTanks,
    11111127                     numEngines = 2)
    11121128
     
    11651181        super(B767Model, self). \
    11661182            __init__(flapsNotches = [0, 1, 5, 15, 20, 25, 30],
    1167                      fuelInfo = [0x0b74, 0x0b7c, 0xb94],
     1183                     fuelTanks = acft.Boeing767.fuelTanks,
    11681184                     numEngines = 2)
    11691185
     
    11811197        super(DH8DModel, self). \
    11821198            __init__(flapsNotches = [0, 5, 10, 15, 35],
    1183                      fuelInfo = [0x0b74, 0x0b7c, 0xb94],
     1199                     fuelTanks = acft.DH8D.fuelTanks,
    11841200                     numEngines = 2)
    11851201
     
    12261242        super(CRJ2Model, self). \
    12271243            __init__(flapsNotches = [0, 8, 20, 30, 45],
    1228                      fuelInfo = [0x0b74, 0x0b7c, 0xb94],
     1244                     fuelTanks = acft.CRJ2.fuelTanks,
    12291245                     numEngines = 2)
    12301246
     
    12421258        super(F70Model, self). \
    12431259            __init__(flapsNotches = [0, 8, 15, 25, 42],
    1244                      fuelInfo = [0x0b74, 0x0b7c, 0xb94],
     1260                     fuelTanks = acft.F70.fuelTanks,
    12451261                     numEngines = 2)
    12461262
     
    12581274        super(DC3Model, self). \
    12591275            __init__(flapsNotches = [0, 15, 30, 45],
    1260                      fuelInfo = [0x0b7c, 0x0b84, 0x0b94, 0x0b9c],
     1276                     fuelTanks = acft.DC3.fuelTanks,
    12611277                     numEngines = 2)
    12621278
     
    12741290        super(T134Model, self). \
    12751291            __init__(flapsNotches = [0, 10, 20, 30],
    1276                      fuelInfo = [0x0b74,
    1277                                  0x0b8c, 0x0b84,
    1278                                  0x0ba4, 0x0b9c,
    1279                                  0x1254, 0x125c],
     1292                     fuelTanks = acft.T134.fuelTanks,
    12801293                     numEngines = 2)
    12811294
     
    12931306        super(T154Model, self). \
    12941307            __init__(flapsNotches = [0, 15, 28, 45],
    1295                      fuelInfo = [0x0b74, 0x0b7c, 0x0b94,
    1296                                  0x1244, 0x0b84, 0x0b9c],
     1308                     fuelTanks = acft.T154.fuelTanks,
    12971309                     numEngines = 3)
    12981310
     
    13181330        super(YK40Model, self). \
    13191331            __init__(flapsNotches = [0, 20, 35],
    1320                      fuelInfo = [0x0b7c, 0x0b94],
     1332                     fuelTanks = acft.YK40.fuelTanks,
    13211333                     numEngines = 2)
    13221334
Note: See TracChangeset for help on using the changeset viewer.