Changeset 317:26cd9b16bf92
- Timestamp:
- 09/30/12 09:00:53 (12 years ago)
- Branch:
- default
- Phase:
- public
- Location:
- src/mlx
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
src/mlx/acft.py
r313 r317 86 86 self._checkers.append(checks.NAV1Logger()) 87 87 self._checkers.append(checks.NAV2Logger()) 88 self._checkers.append(checks.ADF1Logger()) 89 self._checkers.append(checks.ADF2Logger()) 88 90 self._checkers.append(checks.SquawkLogger()) 89 91 -
src/mlx/checks.py
r314 r317 427 427 #--------------------------------------------------------------------------------------- 428 428 429 class ADF1Logger(GenericStateChangeLogger): 430 """Logger for the ADF1 radio setting.""" 431 def __init__(self): 432 """Construct the logger.""" 433 super(ADF1Logger, self).__init__("adf1", "ADF1 frequency: %s kHz") 434 435 #--------------------------------------------------------------------------------------- 436 437 class ADF2Logger(GenericStateChangeLogger): 438 """Logger for the ADF2 radio setting.""" 439 def __init__(self): 440 """Construct the logger.""" 441 super(ADF2Logger, self).__init__("adf2", "ADF2 frequency: %s kHz") 442 443 #--------------------------------------------------------------------------------------- 444 429 445 class SquawkLogger(GenericStateChangeLogger): 430 446 """Logger for the squawk setting.""" -
src/mlx/const.py
r315 r317 11 11 12 12 ## The version of the program 13 VERSION="0. 7"13 VERSION="0.8" 14 14 15 15 #------------------------------------------------------------------------------- -
src/mlx/fs.py
r315 r317 231 231 - nav2: the frequency of the NAV1 radio in MHz (string). Can be None, if 232 232 the frequency is unreliable or meaningless. 233 - adf1: the frequency of the ADF1 radio in kHz (string). Can be None, if 234 the frequency is unreliable or meaningless. 235 - adf2: the frequency of the ADF2 radio in kHz (string). Can be None, if 236 the frequency is unreliable or meaningless. 233 237 - squawk: the transponder code (string) 234 238 - windSpeed: the speed of the wind at the aircraft in knots (float) -
src/mlx/fsuipc.py
r315 r317 1178 1178 ("nav1", 0x0350, "H"), 1179 1179 ("nav2", 0x0352, "H"), 1180 ("adf1_main", 0x034c, "H"), 1181 ("adf1_ext", 0x0356, "H"), 1182 ("adf2_main", 0x02d4, "H"), 1183 ("adf2_ext", 0x02d6, "H"), 1180 1184 ("squawk", 0x0354, "H"), 1181 1185 ("windSpeed", 0x0e90, "H"), … … 1227 1231 return "1" + bcd[0:2] + "." + bcd[2:4] 1228 1232 1233 @staticmethod 1234 def convertADFFrequency(main, ext): 1235 """Convert the given ADF frequency data to a string.""" 1236 mainBCD = AircraftModel.convertBCD(main, 4) 1237 extBCD = AircraftModel.convertBCD(ext, 4) 1238 1239 return (extBCD[1] if extBCD[1]!="0" else "") + \ 1240 mainBCD[1:] + "." + extBCD[3] 1241 1229 1242 def __init__(self, flapsNotches): 1230 1243 """Construct the aircraft model. … … 1350 1363 state.nav1 = AircraftModel.convertFrequency(data[self._monidx_nav1]) 1351 1364 state.nav2 = AircraftModel.convertFrequency(data[self._monidx_nav2]) 1365 state.adf1 = \ 1366 AircraftModel.convertADFFrequency(data[self._monidx_adf1_main], 1367 data[self._monidx_adf1_ext]) 1368 state.adf2 = \ 1369 AircraftModel.convertADFFrequency(data[self._monidx_adf2_main], 1370 data[self._monidx_adf2_ext]) 1352 1371 state.squawk = AircraftModel.convertBCD(data[self._monidx_squawk], 4) 1353 1372 -
src/mlx/pyuipc_sim.py
r314 r317 167 167 168 168 @staticmethod 169 def _readADFFrequency(frequency): 170 """Convert the given frequency into a tuple of ADF BCD frequency 171 components.""" 172 mainFrequency = Values._readBCD(int(math.floor(frequency))%1000) 173 extFrequency = (int(frequency/1000.0)*256) + (int(frequency*10.0)%10) 174 175 return [mainFrequency, extFrequency] 176 177 @staticmethod 169 178 def _readBCD(value): 170 179 """Convert the given value into BCD format.""" … … 184 193 185 194 @staticmethod 195 def _toADFFrequency(main, ext): 196 """Convert the given values into an ADF frequency.""" 197 frequency = Values._writeBCD(main) 198 frequency += 1000.0*int(ext/256) 199 frequency += (int(ext)%16)/10.0 200 return frequency 201 202 @staticmethod 203 def _writeADFFrequency(current, value, isMain): 204 """Convert the given part of an ADF frequency into the 205 whole frequency.""" 206 [mainFrequency, extFrequency] = Values._readADFFrequency(current) 207 if isMain: mainFrequency = value 208 else: extFrequency = value 209 210 return Values._toADFFrequency(mainFrequency, extFrequency) 211 212 @staticmethod 186 213 def _writeBCD(value): 187 214 """Convert the given BCD value into a real value.""" … … 257 284 self.nav1 = 117.3 258 285 self.nav2 = 109.5 286 self.adf1 = 382.7 287 self.adf2 = 1540.6 259 288 self.squawk = 2200 260 289 … … 317 346 elif offset==0x02c8: # VS 318 347 return int(self.vs * const.FEETTOMETRES * 256.0 / 60.0) 348 elif offset==0x02d4: # ADF2 main 349 return Values._readADFFrequency(self.adf2)[0] 350 elif offset==0x02d6: # ADF2 extended 351 return Values._readADFFrequency(self.adf2)[1] 319 352 elif offset==0x030c: # TD rate 320 353 return int(self.tdRate * const.FEETTOMETRES * 256.0 / 60.0) 321 354 elif offset==0x0330: # Altimeter 322 355 return int(self.altimeter * 16.0) 356 elif offset==0x034c: # ADF1 main 357 return Values._readADFFrequency(self.adf1)[0] 323 358 elif offset==0x0350: # NAV1 324 359 return Values._readFrequency(self.nav1) … … 327 362 elif offset==0x0354: # Squawk 328 363 return Values._readBCD(self.squawk) 364 elif offset==0x0356: # ADF1 extended 365 return Values._readADFFrequency(self.adf1)[1] 329 366 elif offset==0x0366: # On the ground 330 367 return 1 if self.onTheGround else 0 … … 546 583 if not self.onTheGround: 547 584 self.tdRate = self.vs 585 elif offset==0x02d4: # ADF2 main 586 self.adf2 = self._writeADFFrequency(self.adf2, value, True) 587 elif offset==0x02d6: # ADF2 main 588 self.adf2 = self._writeADFFrequency(self.adf2, value, False) 548 589 elif offset==0x0330: # Altimeter 549 590 self.altimeter = value / 16.0 591 elif offset==0x034c: # ADF1 main 592 self.adf1 = self._writeADFFrequency(self.adf1, value, True) 550 593 elif offset==0x0350: # NAV1 551 594 self.nav1 = Values._writeFrequency(value) … … 554 597 elif offset==0x0354: # Squawk 555 598 self.squawk = Values._writeBCD(value) 599 elif offset==0x0356: # ADF1 ext 600 self.adf1 = self._writeADFFrequency(self.adf1, value, False) 556 601 elif offset==0x0366: # On the groud 557 602 self.onTheGround = value!=0 … … 1027 1072 """Convert the given PyUIPC value into a throttle value.""" 1028 1073 return value * 100.0 / 16384.0 1029 1074 1030 1075 def __init__(self): 1031 1076 """Construct the CLI.""" … … 1042 1087 1043 1088 self._valueHandlers = {} 1044 self._valueHandlers["year"] = ( 0x0240, "H", lambda value: value,1089 self._valueHandlers["year"] = ([(0x0240, "H")], lambda value: value, 1045 1090 lambda word: int(word)) 1046 self._valueHandlers["yday"] = ( 0x023e, "H", lambda value: value,1091 self._valueHandlers["yday"] = ([(0x023e, "H")], lambda value: value, 1047 1092 lambda word: int(word)) 1048 self._valueHandlers["hour"] = ( 0x023b, "b", lambda value: value,1093 self._valueHandlers["hour"] = ([(0x023b, "b")], lambda value: value, 1049 1094 lambda word: int(word)) 1050 self._valueHandlers["min"] = ( 0x023c, "b", lambda value: value,1095 self._valueHandlers["min"] = ([(0x023c, "b")], lambda value: value, 1051 1096 lambda word: int(word)) 1052 self._valueHandlers["sec"] = ( 0x023a, "b", lambda value: value,1097 self._valueHandlers["sec"] = ([(0x023a, "b")], lambda value: value, 1053 1098 lambda word: int(word)) 1054 self._valueHandlers["acftName"] = ( 0x3d00, -256, lambda value: value,1099 self._valueHandlers["acftName"] = ([(0x3d00, -256)], lambda value: value, 1055 1100 lambda word: word) 1056 self._valueHandlers["airPath"] = ( 0x3c00, -256, lambda value: value,1101 self._valueHandlers["airPath"] = ([(0x3c00, -256)], lambda value: value, 1057 1102 lambda word: word) 1058 self._valueHandlers["latitude"] = ( 0x0560, "l",1103 self._valueHandlers["latitude"] = ([(0x0560, "l")], 1059 1104 lambda value: value * 90.0 / 1060 1105 10001750.0 / 65536.0 / 65536.0, … … 1062 1107 10001750.0 * 1063 1108 65536.0 * 65536.0 / 90.0)) 1064 self._valueHandlers["longitude"] = ( 0x0568, "l",1109 self._valueHandlers["longitude"] = ([(0x0568, "l")], 1065 1110 lambda value: value * 360.0 / 1066 1111 65536.0 / 65536.0 / 65536.0 / 65536.0, … … 1069 1114 65536.0 * 65536.0 / 1070 1115 360.0)) 1071 self._valueHandlers["paused"] = ( 0x0264, "H", CLI.bool2str, CLI.str2bool)1072 self._valueHandlers["frozen"] = ( 0x3364, "H", CLI.bool2str, CLI.str2bool)1073 self._valueHandlers["replay"] = ( 0x0628, "d", CLI.bool2str, CLI.str2bool)1074 self._valueHandlers["slew"] = ( 0x05dc, "H", CLI.bool2str, CLI.str2bool)1075 self._valueHandlers["overspeed"] = ( 0x036d, "b", CLI.bool2str, CLI.str2bool)1076 self._valueHandlers["stalled"] = ( 0x036c, "b", CLI.bool2str, CLI.str2bool)1077 self._valueHandlers["onTheGround"] = ( 0x0366, "H", CLI.bool2str, CLI.str2bool)1078 self._valueHandlers["zfw"] = ( 0x3bfc, "d",1116 self._valueHandlers["paused"] = ([(0x0264, "H")], CLI.bool2str, CLI.str2bool) 1117 self._valueHandlers["frozen"] = ([(0x3364, "H")], CLI.bool2str, CLI.str2bool) 1118 self._valueHandlers["replay"] = ([(0x0628, "d")], CLI.bool2str, CLI.str2bool) 1119 self._valueHandlers["slew"] = ([(0x05dc, "H")], CLI.bool2str, CLI.str2bool) 1120 self._valueHandlers["overspeed"] = ([(0x036d, "b")], CLI.bool2str, CLI.str2bool) 1121 self._valueHandlers["stalled"] = ([(0x036c, "b")], CLI.bool2str, CLI.str2bool) 1122 self._valueHandlers["onTheGround"] = ([(0x0366, "H")], CLI.bool2str, CLI.str2bool) 1123 self._valueHandlers["zfw"] = ([(0x3bfc, "d")], 1079 1124 lambda value: value * const.LBSTOKG / 256.0, 1080 1125 lambda word: int(float(word) * 256.0 * 1081 1126 const.KGSTOLB)) 1082 self._valueHandlers["grossWeight"] = ( 0x30c0, "f",1127 self._valueHandlers["grossWeight"] = ([(0x30c0, "f")], 1083 1128 lambda value: value * const.LBSTOKG, 1084 1129 lambda word: None) 1085 self._valueHandlers["heading"] = ( 0x0580, "d",1130 self._valueHandlers["heading"] = ([(0x0580, "d")], 1086 1131 CLI.pyuipc2degree, CLI.degree2pyuipc) 1087 self._valueHandlers["pitch"] = ( 0x0578, "d",1132 self._valueHandlers["pitch"] = ([(0x0578, "d")], 1088 1133 CLI.pyuipc2degree, CLI.degree2pyuipc) 1089 self._valueHandlers["bank"] = ( 0x057c, "d",1134 self._valueHandlers["bank"] = ([(0x057c, "d")], 1090 1135 CLI.pyuipc2degree, CLI.degree2pyuipc) 1091 self._valueHandlers["ias"] = ( 0x02bc, "d",1136 self._valueHandlers["ias"] = ([(0x02bc, "d")], 1092 1137 lambda value: value / 128.0, 1093 1138 lambda word: int(float(word) * 128.0)) 1094 self._valueHandlers["mach"] = ( 0x11c6, "H",1139 self._valueHandlers["mach"] = ([(0x11c6, "H")], 1095 1140 lambda value: value / 20480.0, 1096 1141 lambda word: int(float(word) * 20480.0)) 1097 self._valueHandlers["gs"] = ( 0x02b4, "d",1142 self._valueHandlers["gs"] = ([(0x02b4, "d")], 1098 1143 lambda value: value * 3600.0 / 65536.0 / 1852.0, 1099 1144 lambda word: int(float(word) * 65536.0 * 1100 1145 1852.0 / 3600)) 1101 self._valueHandlers["tas"] = ( 0x02b8, "d",1146 self._valueHandlers["tas"] = ([(0x02b8, "d")], 1102 1147 lambda value: value / 128.0, 1103 1148 lambda word: None) 1104 self._valueHandlers["vs"] = ( 0x02c8, "d",1149 self._valueHandlers["vs"] = ([(0x02c8, "d")], 1105 1150 lambda value: value * 60 / 1106 1151 const.FEETTOMETRES / 256.0, … … 1108 1153 const.FEETTOMETRES * 1109 1154 256.0 / 60.0)) 1110 self._valueHandlers["tdRate"] = ( 0x030c, "d",1155 self._valueHandlers["tdRate"] = ([(0x030c, "d")], 1111 1156 lambda value: value * 60 / 1112 1157 const.FEETTOMETRES / 256.0, … … 1114 1159 const.FEETTOMETRES * 1115 1160 256.0 / 60.0)) 1116 self._valueHandlers["radioAltitude"] = ( 0x31e4, "d",1161 self._valueHandlers["radioAltitude"] = ([(0x31e4, "d")], 1117 1162 lambda value: value / 1118 1163 const.FEETTOMETRES / … … 1121 1166 const.FEETTOMETRES * 1122 1167 65536.0)) 1123 self._valueHandlers["altitude"] = ( 0x0570, "l",1168 self._valueHandlers["altitude"] = ([(0x0570, "l")], 1124 1169 lambda value: value / 1125 1170 const.FEETTOMETRES / 65536.0 / … … 1128 1173 const.FEETTOMETRES * 1129 1174 65536.0 * 65536.0)) 1130 self._valueHandlers["gLoad"] = ( 0x11ba, "H",1175 self._valueHandlers["gLoad"] = ([(0x11ba, "H")], 1131 1176 lambda value: value / 625.0, 1132 1177 lambda word: int(float(word) * 625.0)) 1133 1178 1134 self._valueHandlers["flapsControl"] = ( 0x0bdc, "d",1179 self._valueHandlers["flapsControl"] = ([(0x0bdc, "d")], 1135 1180 lambda value: value * 100.0 / 16383.0, 1136 1181 lambda word: int(float(word) * 1137 1182 16383.0 / 100.0)) 1138 self._valueHandlers["flaps"] = ( 0x0be0, "d",1183 self._valueHandlers["flaps"] = ([(0x0be0, "d")], 1139 1184 lambda value: value * 100.0 / 16383.0, 1140 1185 lambda word: int(float(word) * 1141 1186 16383.0 / 100.0)) 1142 self._valueHandlers["lights"] = ( 0x0d0c, "H",1187 self._valueHandlers["lights"] = ([(0x0d0c, "H")], 1143 1188 lambda value: value, 1144 1189 lambda word: int(word)) 1145 self._valueHandlers["pitot"] = ( 0x029c, "b", CLI.bool2str, CLI.str2bool)1146 self._valueHandlers["parking"] = ( 0x0bc8, "H", CLI.bool2str, CLI.str2bool)1147 self._valueHandlers["gearControl"] = ( 0x0be8, "d",1190 self._valueHandlers["pitot"] = ([(0x029c, "b")], CLI.bool2str, CLI.str2bool) 1191 self._valueHandlers["parking"] = ([(0x0bc8, "H")], CLI.bool2str, CLI.str2bool) 1192 self._valueHandlers["gearControl"] = ([(0x0be8, "d")], 1148 1193 lambda value: value * 100.0 / 16383.0, 1149 1194 lambda word: int(float(word) * 1150 1195 16383.0 / 100.0)) 1151 self._valueHandlers["noseGear"] = ( 0x0bec, "d",1196 self._valueHandlers["noseGear"] = ([(0x0bec, "d")], 1152 1197 lambda value: value * 100.0 / 16383.0, 1153 1198 lambda word: int(float(word) * 1154 1199 16383.0 / 100.0)) 1155 self._valueHandlers["spoilersArmed"] = ( 0x0bcc, "d",1200 self._valueHandlers["spoilersArmed"] = ([(0x0bcc, "d")], 1156 1201 CLI.bool2str, CLI.str2bool) 1157 self._valueHandlers["spoilers"] = ( 0x0bd0, "d",1202 self._valueHandlers["spoilers"] = ([(0x0bd0, "d")], 1158 1203 lambda value: value, 1159 1204 lambda word: int(word)) 1160 self._valueHandlers["qnh"] = ( 0x0330, "H",1205 self._valueHandlers["qnh"] = ([(0x0330, "H")], 1161 1206 lambda value: value / 16.0, 1162 1207 lambda word: int(float(word)*16.0)) 1163 self._valueHandlers["nav1"] = ( 0x0350, "H",1208 self._valueHandlers["nav1"] = ([(0x0350, "H")], 1164 1209 Values._writeFrequency, 1165 1210 lambda word: Values._readFrequency(float(word))) 1166 self._valueHandlers["nav2"] = ( 0x0352, "H",1211 self._valueHandlers["nav2"] = ([(0x0352, "H")], 1167 1212 Values._writeFrequency, 1168 1213 lambda word: Values._readFrequency(float(word))) 1169 self._valueHandlers["squawk"] = (0x0354, "H", 1214 self._valueHandlers["adf1"] = ([(0x034c, "H"), (0x0356, "H")], 1215 lambda values: 1216 Values._toADFFrequency(values[0], 1217 values[1]), 1218 lambda word: 1219 Values._readADFFrequency(float(word))) 1220 self._valueHandlers["adf2"] = ([(0x02d4, "H"), (0x02d6, "H")], 1221 lambda values: 1222 Values._toADFFrequency(values[0], 1223 values[1]), 1224 lambda word: 1225 Values._readADFFrequency(float(word))) 1226 self._valueHandlers["squawk"] = ([(0x0354, "H")], 1170 1227 Values._writeBCD, 1171 1228 lambda word: Values._readBCD(int(word))) 1172 self._valueHandlers["windSpeed"] = ( 0x0e90, "H",1229 self._valueHandlers["windSpeed"] = ([(0x0e90, "H")], 1173 1230 lambda value: value, 1174 1231 lambda word: int(word)) 1175 self._valueHandlers["windDirection"] = ( 0x0e92, "H",1232 self._valueHandlers["windDirection"] = ([(0x0e92, "H")], 1176 1233 lambda value: value * 360.0 / 65536.0, 1177 1234 lambda word: int(int(word) * 1178 1235 65536.0 / 360.0)) 1179 self._valueHandlers["fuelWeight"] = ( 0x0af4, "H",1236 self._valueHandlers["fuelWeight"] = ([(0x0af4, "H")], 1180 1237 lambda value: value / 256.0, 1181 1238 lambda word: int(float(word)*256.0)) 1182 1239 1183 1240 1184 self._valueHandlers["centreLevel"] = (0x0b74, "d", CLI.pyuipc2fuelLevel, 1241 self._valueHandlers["centreLevel"] = ([(0x0b74, "d")], 1242 CLI.pyuipc2fuelLevel, 1185 1243 CLI.fuelLevel2pyuipc) 1186 self._valueHandlers["centreCapacity"] = ( 0x0b78, "d",1244 self._valueHandlers["centreCapacity"] = ([(0x0b78, "d")], 1187 1245 CLI.pyuipc2fuelCapacity, 1188 1246 CLI.fuelCapacity2pyuipc) 1189 self._valueHandlers["leftMainLevel"] = (0x0b7c, "d", CLI.pyuipc2fuelLevel, 1190 CLI.fuelLevel2pyuipc) 1191 self._valueHandlers["leftMainCapacity"] = (0x0b80, "d", 1247 self._valueHandlers["leftMainLevel"] = ([(0x0b7c, "d")], 1248 CLI.pyuipc2fuelLevel, 1249 CLI.fuelLevel2pyuipc) 1250 self._valueHandlers["leftMainCapacity"] = ([(0x0b80, "d")], 1192 1251 CLI.pyuipc2fuelCapacity, 1193 1252 CLI.fuelCapacity2pyuipc) 1194 self._valueHandlers["leftAuxLevel"] = (0x0b84, "d", CLI.pyuipc2fuelLevel, 1253 self._valueHandlers["leftAuxLevel"] = ([(0x0b84, "d")], 1254 CLI.pyuipc2fuelLevel, 1195 1255 CLI.fuelLevel2pyuipc) 1196 self._valueHandlers["leftAuxCapacity"] = ( 0x0b88, "d",1256 self._valueHandlers["leftAuxCapacity"] = ([(0x0b88, "d")], 1197 1257 CLI.pyuipc2fuelCapacity, 1198 1258 CLI.fuelCapacity2pyuipc) 1199 self._valueHandlers["leftTipLevel"] = (0x0b8c, "d", CLI.pyuipc2fuelLevel, 1200 CLI.fuelLevel2pyuipc) 1201 self._valueHandlers["leftTipCapacity"] = (0x0b90, "d", 1259 self._valueHandlers["leftTipLevel"] = ([(0x0b8c, "d")], 1260 CLI.pyuipc2fuelLevel, 1261 CLI.fuelLevel2pyuipc) 1262 self._valueHandlers["leftTipCapacity"] = ([(0x0b90, "d")], 1202 1263 CLI.pyuipc2fuelCapacity, 1203 1264 CLI.fuelCapacity2pyuipc) 1204 self._valueHandlers["rightMainLevel"] = (0x0b94, "d", CLI.pyuipc2fuelLevel, 1265 self._valueHandlers["rightMainLevel"] = ([(0x0b94, "d")], 1266 CLI.pyuipc2fuelLevel, 1205 1267 CLI.fuelLevel2pyuipc) 1206 self._valueHandlers["rightMainCapacity"] = ( 0x0b98, "d",1268 self._valueHandlers["rightMainCapacity"] = ([(0x0b98, "d")], 1207 1269 CLI.pyuipc2fuelCapacity, 1208 1270 CLI.fuelCapacity2pyuipc) 1209 self._valueHandlers["rightAuxLevel"] = ( 0x0b9c, "d", CLI.pyuipc2fuelLevel,1271 self._valueHandlers["rightAuxLevel"] = ([(0x0b9c, "d")], CLI.pyuipc2fuelLevel, 1210 1272 CLI.fuelLevel2pyuipc) 1211 self._valueHandlers["rightAuxCapacity"] = ( 0x0ba0, "d",1273 self._valueHandlers["rightAuxCapacity"] = ([(0x0ba0, "d")], 1212 1274 CLI.pyuipc2fuelCapacity, 1213 1275 CLI.fuelCapacity2pyuipc) 1214 self._valueHandlers["rightTipLevel"] = (0x0ba4, "d", CLI.pyuipc2fuelLevel, 1276 self._valueHandlers["rightTipLevel"] = ([(0x0ba4, "d")], 1277 CLI.pyuipc2fuelLevel, 1215 1278 CLI.fuelLevel2pyuipc) 1216 self._valueHandlers["rightTipCapacity"] = ( 0x0ba8, "d",1279 self._valueHandlers["rightTipCapacity"] = ([(0x0ba8, "d")], 1217 1280 CLI.pyuipc2fuelCapacity, 1218 1281 CLI.fuelCapacity2pyuipc) 1219 self._valueHandlers["centre2Level"] = (0x1244, "d", CLI.pyuipc2fuelLevel, 1282 self._valueHandlers["centre2Level"] = ([(0x1244, "d")], 1283 CLI.pyuipc2fuelLevel, 1220 1284 CLI.fuelLevel2pyuipc) 1221 self._valueHandlers["centre2Capacity"] = ( 0x1248, "d",1285 self._valueHandlers["centre2Capacity"] = ([(0x1248, "d")], 1222 1286 CLI.pyuipc2fuelCapacity, 1223 1287 CLI.fuelCapacity2pyuipc) 1224 self._valueHandlers["external1Level"] = (0x1254, "d", CLI.pyuipc2fuelLevel, 1288 self._valueHandlers["external1Level"] = ([(0x1254, "d")], 1289 CLI.pyuipc2fuelLevel, 1225 1290 CLI.fuelLevel2pyuipc) 1226 self._valueHandlers["external1Capacity"] = ( 0x1258, "d",1291 self._valueHandlers["external1Capacity"] = ([(0x1258, "d")], 1227 1292 CLI.pyuipc2fuelCapacity, 1228 1293 CLI.fuelCapacity2pyuipc) 1229 self._valueHandlers["external2Level"] = (0x125c, "d", CLI.pyuipc2fuelLevel, 1294 self._valueHandlers["external2Level"] = ([(0x125c, "d")], 1295 CLI.pyuipc2fuelLevel, 1230 1296 CLI.fuelLevel2pyuipc) 1231 self._valueHandlers["external2Capacity"] = ( 0x1260, "d",1297 self._valueHandlers["external2Capacity"] = ([(0x1260, "d")], 1232 1298 CLI.pyuipc2fuelCapacity, 1233 1299 CLI.fuelCapacity2pyuipc) 1234 1300 1235 self._valueHandlers["n1_1"] = ( 0x2000, "f", lambda value: value,1301 self._valueHandlers["n1_1"] = ([(0x2000, "f")], lambda value: value, 1236 1302 lambda word: float(word)) 1237 self._valueHandlers["n1_2"] = ( 0x2100, "f", lambda value: value,1303 self._valueHandlers["n1_2"] = ([(0x2100, "f")], lambda value: value, 1238 1304 lambda word: float(word)) 1239 self._valueHandlers["n1_3"] = ( 0x2200, "f", lambda value: value,1305 self._valueHandlers["n1_3"] = ([(0x2200, "f")], lambda value: value, 1240 1306 lambda word: float(word)) 1241 1307 1242 self._valueHandlers["throttle_1"] = ( 0x088c, "H",1308 self._valueHandlers["throttle_1"] = ([(0x088c, "H")], 1243 1309 CLI.pyuipc2throttle, 1244 1310 CLI.throttle2pyuipc) 1245 self._valueHandlers["throttle_2"] = ( 0x0924, "H",1311 self._valueHandlers["throttle_2"] = ([(0x0924, "H")], 1246 1312 CLI.pyuipc2throttle, 1247 1313 CLI.throttle2pyuipc) 1248 self._valueHandlers["throttle_3"] = ( 0x09bc, "H",1314 self._valueHandlers["throttle_3"] = ([(0x09bc, "H")], 1249 1315 CLI.pyuipc2throttle, 1250 1316 CLI.throttle2pyuipc) 1251 1317 1252 self._valueHandlers["visibility"] = ( 0x0e8a, "H",1318 self._valueHandlers["visibility"] = ([(0x0e8a, "H")], 1253 1319 lambda value: value*1609.344/100.0, 1254 1320 lambda word: int(float(word)* 1255 1321 100.0/1609.344)) 1256 1322 1257 self._valueHandlers["payloadCount"] = ( 0x13fc, "d",1323 self._valueHandlers["payloadCount"] = ([(0x13fc, "d")], 1258 1324 lambda value: value, 1259 1325 lambda word: int(word)) 1260 1326 for i in range(0, 61): 1261 self._valueHandlers["payload%d" % (i,)] = ( 0x1400 + i * 48, "f",1327 self._valueHandlers["payload%d" % (i,)] = ([(0x1400 + i * 48, "f")], 1262 1328 lambda value: 1263 1329 value * const.LBSTOKG, 1264 1330 lambda word: 1265 1331 float(word)*const.KGSTOLB) 1266 self._valueHandlers["textScrolling"] = ( 0x1274, "h",1332 self._valueHandlers["textScrolling"] = ([(0x1274, "h")], 1267 1333 CLI.bool2str, CLI.str2bool) 1268 1334 1269 self._valueHandlers["messageDuration"] = ( 0x32fa, "h",1335 self._valueHandlers["messageDuration"] = ([(0x32fa, "h")], 1270 1336 lambda value: value, 1271 1337 lambda word: int(word)) 1272 self._valueHandlers["message"] = ( 0x3380, -128,1338 self._valueHandlers["message"] = ([(0x3380, -128)], 1273 1339 lambda value: value, 1274 1340 lambda word: word) 1275 1341 1276 1342 for i in range(0, Values.HOTKEY_SIZE): 1277 self._valueHandlers["hotkey%d" % (i,)] = ( 0x3210 + i*4, "u",1343 self._valueHandlers["hotkey%d" % (i,)] = ([(0x3210 + i*4, "u")], 1278 1344 lambda value: "0x%08x" % (value,), 1279 1345 lambda word: long(word, 16)) 1280 1346 1281 self._valueHandlers["cog"] = ( 0x2ef8, "f", lambda value: value,1347 self._valueHandlers["cog"] = ([(0x2ef8, "f")], lambda value: value, 1282 1348 lambda word: float(word)) 1283 1349 1284 self._valueHandlers["pmdg_737ng_switches"] = ( 0x6202, "b",1350 self._valueHandlers["pmdg_737ng_switches"] = ([(0x6202, "b")], 1285 1351 lambda value: value, 1286 1352 lambda word: int(word)) 1287 1353 1288 self._valueHandlers["pmdg_737ngx_lts_positionsw"] = ( 0x6500, "b",1354 self._valueHandlers["pmdg_737ngx_lts_positionsw"] = ([(0x6500, "b")], 1289 1355 lambda value: value, 1290 1356 lambda word: int(word)) … … 1307 1373 return False 1308 1374 valueHandler = self._valueHandlers[name] 1309 data .append((valueHandler[0], valueHandler[1]))1375 data += valueHandler[0] 1310 1376 1311 1377 try: 1312 result = self._client.read(data) 1313 for i in range(0, len(result)): 1378 results = self._client.read(data) 1379 index = 0 1380 i = 0 1381 while index<len(results): 1314 1382 name = names[i] 1315 1383 valueHandler = self._valueHandlers[name] 1316 print name + "=" + str(valueHandler[2](result[i])) 1384 numResults = len(valueHandler[0]) 1385 thisResults = results[index:index+numResults] 1386 value = valueHandler[1](thisResults[0] if numResults==1 1387 else thisResults) 1388 1389 print name + "=" + str(value) 1390 1391 index += numResults 1392 i+=1 1317 1393 except Exception, e: 1318 1394 print >> sys.stderr, "Failed to read data: " + str(e) … … 1364 1440 valueHandler = self._valueHandlers[name] 1365 1441 try: 1366 value = valueHandler[3](value) 1367 data.append((valueHandler[0], valueHandler[1], value)) 1442 values = valueHandler[2](value) 1443 if len(valueHandler[0])==1: 1444 values = [values] 1445 index = 0 1446 for (offset, type) in valueHandler[0]: 1447 data.append((offset, type, values[index])) 1448 index += 1 1368 1449 except Exception, e: 1369 1450 print >> sys.stderr, "Invalid value '%s' for variable %s: %s" % \
Note:
See TracChangeset
for help on using the changeset viewer.