Changeset 140:7f24ede5d214 for src/mlx/fsuipc.py
- Timestamp:
- 05/01/12 09:14:13 (12 years ago)
- Branch:
- default
- Phase:
- public
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
src/mlx/fsuipc.py
r134 r140 6 6 import const 7 7 import util 8 import acft 8 9 9 10 import threading … … 18 19 else: 19 20 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 } 20 35 21 36 #------------------------------------------------------------------------------ … … 1014 1029 """A generic aircraft model that can handle the fuel levels, the N1 or RPM 1015 1030 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): 1017 1033 """Construct the generic aircraft model with the given data. 1018 1034 … … 1020 1036 notches mean. 1021 1037 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. 1025 1040 1026 1041 numEngines is the number of engines the aircraft has. … … 1030 1045 super(GenericAircraftModel, self).__init__(flapsNotches = flapsNotches) 1031 1046 1032 self._fuel Info = fuelInfo1047 self._fuelTanks = fuelTanks 1033 1048 self._fuelStartIndex = None 1034 1049 self._numEngines = numEngines … … 1049 1064 1050 1065 self._fuelStartIndex = len(data) 1051 for offset in self._fuelInfo: 1066 for tank in self._fuelTanks: 1067 offset = _tank2offset[tank] 1052 1068 self._addOffsetWithIndexMember(data, offset, "u") # tank level 1053 1069 self._addOffsetWithIndexMember(data, offset+4, "u") # tank capacity … … 1071 1087 state.fuel = [] 1072 1088 for i in range(self._fuelStartIndex, 1073 self._fuelStartIndex + 2*len(self._fuel Info), 2):1089 self._fuelStartIndex + 2*len(self._fuelTanks), 2): 1074 1090 fuel = data[i+1]*data[i]*fuelWeight*const.LBSTOKG/128.0/65536.0 1075 1091 state.fuel.append(fuel) … … 1092 1108 super(GenericModel, self). \ 1093 1109 __init__(flapsNotches = [0, 10, 20, 30], 1094 fuel Info = [0x0b74, 0x0b7c, 0xb94],1110 fuelTanks = [const.FUELTANK_LEFT, const.FUELTANK_RIGHT], 1095 1111 numEngines = 2) 1096 1112 … … 1108 1124 super(B737Model, self). \ 1109 1125 __init__(flapsNotches = [0, 1, 2, 5, 10, 15, 25, 30, 40], 1110 fuel Info = [0x0b74, 0x0b7c, 0xb94],1126 fuelTanks = acft.Boeing737.fuelTanks, 1111 1127 numEngines = 2) 1112 1128 … … 1165 1181 super(B767Model, self). \ 1166 1182 __init__(flapsNotches = [0, 1, 5, 15, 20, 25, 30], 1167 fuel Info = [0x0b74, 0x0b7c, 0xb94],1183 fuelTanks = acft.Boeing767.fuelTanks, 1168 1184 numEngines = 2) 1169 1185 … … 1181 1197 super(DH8DModel, self). \ 1182 1198 __init__(flapsNotches = [0, 5, 10, 15, 35], 1183 fuel Info = [0x0b74, 0x0b7c, 0xb94],1199 fuelTanks = acft.DH8D.fuelTanks, 1184 1200 numEngines = 2) 1185 1201 … … 1226 1242 super(CRJ2Model, self). \ 1227 1243 __init__(flapsNotches = [0, 8, 20, 30, 45], 1228 fuel Info = [0x0b74, 0x0b7c, 0xb94],1244 fuelTanks = acft.CRJ2.fuelTanks, 1229 1245 numEngines = 2) 1230 1246 … … 1242 1258 super(F70Model, self). \ 1243 1259 __init__(flapsNotches = [0, 8, 15, 25, 42], 1244 fuel Info = [0x0b74, 0x0b7c, 0xb94],1260 fuelTanks = acft.F70.fuelTanks, 1245 1261 numEngines = 2) 1246 1262 … … 1258 1274 super(DC3Model, self). \ 1259 1275 __init__(flapsNotches = [0, 15, 30, 45], 1260 fuel Info = [0x0b7c, 0x0b84, 0x0b94, 0x0b9c],1276 fuelTanks = acft.DC3.fuelTanks, 1261 1277 numEngines = 2) 1262 1278 … … 1274 1290 super(T134Model, self). \ 1275 1291 __init__(flapsNotches = [0, 10, 20, 30], 1276 fuelInfo = [0x0b74, 1277 0x0b8c, 0x0b84, 1278 0x0ba4, 0x0b9c, 1279 0x1254, 0x125c], 1292 fuelTanks = acft.T134.fuelTanks, 1280 1293 numEngines = 2) 1281 1294 … … 1293 1306 super(T154Model, self). \ 1294 1307 __init__(flapsNotches = [0, 15, 28, 45], 1295 fuelInfo = [0x0b74, 0x0b7c, 0x0b94, 1296 0x1244, 0x0b84, 0x0b9c], 1308 fuelTanks = acft.T154.fuelTanks, 1297 1309 numEngines = 3) 1298 1310 … … 1318 1330 super(YK40Model, self). \ 1319 1331 __init__(flapsNotches = [0, 20, 35], 1320 fuel Info = [0x0b7c, 0x0b94],1332 fuelTanks = acft.YK40.fuelTanks, 1321 1333 numEngines = 2) 1322 1334
Note:
See TracChangeset
for help on using the changeset viewer.