Changeset 317:26cd9b16bf92


Ignore:
Timestamp:
09/30/12 09:00:53 (12 years ago)
Author:
István Váradi <ivaradi@…>
Branch:
default
hg-Phase:
(<MercurialRepository 1 'hg:/home/ivaradi/mlx/hg' '/'>, 'public')
Message:

Added the logging of the ADF frequencies

Location:
src/mlx
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • src/mlx/acft.py

    r313 r317  
    8686        self._checkers.append(checks.NAV1Logger())
    8787        self._checkers.append(checks.NAV2Logger())
     88        self._checkers.append(checks.ADF1Logger())
     89        self._checkers.append(checks.ADF2Logger())
    8890        self._checkers.append(checks.SquawkLogger())
    8991
  • src/mlx/checks.py

    r314 r317  
    427427#---------------------------------------------------------------------------------------
    428428
     429class 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
     437class 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
    429445class SquawkLogger(GenericStateChangeLogger):
    430446    """Logger for the squawk setting."""
  • src/mlx/const.py

    r315 r317  
    1111
    1212## The version of the program
    13 VERSION="0.7"
     13VERSION="0.8"
    1414
    1515#-------------------------------------------------------------------------------
  • src/mlx/fs.py

    r315 r317  
    231231    - nav2: the frequency of the NAV1 radio in MHz (string). Can be None, if
    232232    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.
    233237    - squawk: the transponder code (string)
    234238    - windSpeed: the speed of the wind at the aircraft in knots (float)
  • src/mlx/fsuipc.py

    r315 r317  
    11781178                      ("nav1", 0x0350, "H"),
    11791179                      ("nav2", 0x0352, "H"),
     1180                      ("adf1_main", 0x034c, "H"),
     1181                      ("adf1_ext", 0x0356, "H"),
     1182                      ("adf2_main", 0x02d4, "H"),
     1183                      ("adf2_ext", 0x02d6, "H"),
    11801184                      ("squawk", 0x0354, "H"),
    11811185                      ("windSpeed", 0x0e90, "H"),
     
    12271231        return "1" + bcd[0:2] + "." + bcd[2:4]
    12281232
     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   
    12291242    def __init__(self, flapsNotches):
    12301243        """Construct the aircraft model.
     
    13501363        state.nav1 = AircraftModel.convertFrequency(data[self._monidx_nav1])
    13511364        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])
    13521371        state.squawk = AircraftModel.convertBCD(data[self._monidx_squawk], 4)
    13531372
  • src/mlx/pyuipc_sim.py

    r314 r317  
    167167
    168168    @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
    169178    def _readBCD(value):
    170179        """Convert the given value into BCD format."""
     
    184193
    185194    @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
    186213    def _writeBCD(value):
    187214        """Convert the given BCD value into a real value."""
     
    257284        self.nav1 = 117.3
    258285        self.nav2 = 109.5
     286        self.adf1 = 382.7
     287        self.adf2 = 1540.6
    259288        self.squawk = 2200
    260289
     
    317346        elif offset==0x02c8:       # VS
    318347            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]
    319352        elif offset==0x030c:       # TD rate
    320353            return int(self.tdRate * const.FEETTOMETRES * 256.0 / 60.0)
    321354        elif offset==0x0330:       # Altimeter
    322355            return int(self.altimeter * 16.0)
     356        elif offset==0x034c:       # ADF1 main
     357            return Values._readADFFrequency(self.adf1)[0]
    323358        elif offset==0x0350:       # NAV1
    324359            return Values._readFrequency(self.nav1)
     
    327362        elif offset==0x0354:       # Squawk
    328363            return Values._readBCD(self.squawk)
     364        elif offset==0x0356:       # ADF1 extended
     365            return Values._readADFFrequency(self.adf1)[1]
    329366        elif offset==0x0366:       # On the ground
    330367            return 1 if self.onTheGround else 0
     
    546583            if not self.onTheGround:
    547584                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)
    548589        elif offset==0x0330:       # Altimeter
    549590            self.altimeter = value / 16.0
     591        elif offset==0x034c:       # ADF1 main
     592            self.adf1 = self._writeADFFrequency(self.adf1, value, True)
    550593        elif offset==0x0350:       # NAV1
    551594            self.nav1 = Values._writeFrequency(value)
     
    554597        elif offset==0x0354:       # Squawk
    555598            self.squawk = Values._writeBCD(value)
     599        elif offset==0x0356:       # ADF1 ext
     600            self.adf1 = self._writeADFFrequency(self.adf1, value, False)
    556601        elif offset==0x0366:       # On the groud
    557602            self.onTheGround = value!=0
     
    10271072        """Convert the given PyUIPC value into a throttle value."""
    10281073        return value * 100.0 / 16384.0
    1029        
     1074
    10301075    def __init__(self):
    10311076        """Construct the CLI."""
     
    10421087
    10431088        self._valueHandlers = {}
    1044         self._valueHandlers["year"] = (0x0240, "H",  lambda value: value,
     1089        self._valueHandlers["year"] = ([(0x0240, "H")],  lambda value: value,
    10451090                                      lambda word: int(word))
    1046         self._valueHandlers["yday"] = (0x023e, "H",  lambda value: value,
     1091        self._valueHandlers["yday"] = ([(0x023e, "H")],  lambda value: value,
    10471092                                       lambda word: int(word))
    1048         self._valueHandlers["hour"] = (0x023b, "b",  lambda value: value,
     1093        self._valueHandlers["hour"] = ([(0x023b, "b")],  lambda value: value,
    10491094                                       lambda word: int(word))
    1050         self._valueHandlers["min"] = (0x023c, "b",  lambda value: value,
     1095        self._valueHandlers["min"] = ([(0x023c, "b")],  lambda value: value,
    10511096                                      lambda word: int(word))
    1052         self._valueHandlers["sec"] = (0x023a, "b",  lambda value: value,
     1097        self._valueHandlers["sec"] = ([(0x023a, "b")],  lambda value: value,
    10531098                                      lambda word: int(word))
    1054         self._valueHandlers["acftName"] = (0x3d00, -256,  lambda value: value,
     1099        self._valueHandlers["acftName"] = ([(0x3d00, -256)],  lambda value: value,
    10551100                                           lambda word: word)
    1056         self._valueHandlers["airPath"] = (0x3c00, -256,  lambda value: value,
     1101        self._valueHandlers["airPath"] = ([(0x3c00, -256)],  lambda value: value,
    10571102                                          lambda word: word)
    1058         self._valueHandlers["latitude"] = (0x0560, "l",
     1103        self._valueHandlers["latitude"] = ([(0x0560, "l")],
    10591104                                           lambda value: value * 90.0 /
    10601105                                           10001750.0 / 65536.0 / 65536.0,
     
    10621107                                                             10001750.0 *
    10631108                                                             65536.0 * 65536.0 / 90.0))
    1064         self._valueHandlers["longitude"] = (0x0568, "l",
     1109        self._valueHandlers["longitude"] = ([(0x0568, "l")],
    10651110                                            lambda value: value * 360.0 /
    10661111                                            65536.0 / 65536.0 / 65536.0 / 65536.0,
     
    10691114                                                              65536.0 * 65536.0 /
    10701115                                                              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")],
    10791124                                      lambda value: value * const.LBSTOKG / 256.0,
    10801125                                      lambda word: int(float(word) * 256.0 *
    10811126                                                       const.KGSTOLB))
    1082         self._valueHandlers["grossWeight"] = (0x30c0, "f",
     1127        self._valueHandlers["grossWeight"] = ([(0x30c0, "f")],
    10831128                                              lambda value: value * const.LBSTOKG,
    10841129                                              lambda word: None)
    1085         self._valueHandlers["heading"] = (0x0580, "d",
     1130        self._valueHandlers["heading"] = ([(0x0580, "d")],
    10861131                                          CLI.pyuipc2degree, CLI.degree2pyuipc)
    1087         self._valueHandlers["pitch"] = (0x0578, "d",
     1132        self._valueHandlers["pitch"] = ([(0x0578, "d")],
    10881133                                        CLI.pyuipc2degree, CLI.degree2pyuipc)
    1089         self._valueHandlers["bank"] = (0x057c, "d",
     1134        self._valueHandlers["bank"] = ([(0x057c, "d")],
    10901135                                       CLI.pyuipc2degree, CLI.degree2pyuipc)
    1091         self._valueHandlers["ias"] = (0x02bc, "d",
     1136        self._valueHandlers["ias"] = ([(0x02bc, "d")],
    10921137                                      lambda value: value / 128.0,
    10931138                                      lambda word: int(float(word) * 128.0))
    1094         self._valueHandlers["mach"] = (0x11c6, "H",
     1139        self._valueHandlers["mach"] = ([(0x11c6, "H")],
    10951140                                       lambda value: value / 20480.0,
    10961141                                       lambda word: int(float(word) * 20480.0))
    1097         self._valueHandlers["gs"] = (0x02b4, "d",
     1142        self._valueHandlers["gs"] = ([(0x02b4, "d")],
    10981143                                     lambda value: value * 3600.0 / 65536.0 / 1852.0,
    10991144                                     lambda word: int(float(word) * 65536.0 *
    11001145                                                      1852.0 / 3600))
    1101         self._valueHandlers["tas"] = (0x02b8, "d",
     1146        self._valueHandlers["tas"] = ([(0x02b8, "d")],
    11021147                                     lambda value: value / 128.0,
    11031148                                     lambda word: None)
    1104         self._valueHandlers["vs"] = (0x02c8, "d",
     1149        self._valueHandlers["vs"] = ([(0x02c8, "d")],
    11051150                                     lambda value: value * 60 /                                     
    11061151                                     const.FEETTOMETRES / 256.0,
     
    11081153                                                      const.FEETTOMETRES *
    11091154                                                      256.0 / 60.0))
    1110         self._valueHandlers["tdRate"] = (0x030c, "d",
     1155        self._valueHandlers["tdRate"] = ([(0x030c, "d")],
    11111156                                         lambda value: value * 60 /                                     
    11121157                                         const.FEETTOMETRES / 256.0,
     
    11141159                                                          const.FEETTOMETRES *
    11151160                                                          256.0 / 60.0))
    1116         self._valueHandlers["radioAltitude"] = (0x31e4, "d",
     1161        self._valueHandlers["radioAltitude"] = ([(0x31e4, "d")],
    11171162                                                lambda value: value /
    11181163                                                const.FEETTOMETRES /
     
    11211166                                                                 const.FEETTOMETRES *
    11221167                                                                 65536.0))
    1123         self._valueHandlers["altitude"] = (0x0570, "l",
     1168        self._valueHandlers["altitude"] = ([(0x0570, "l")],
    11241169                                           lambda value: value /
    11251170                                           const.FEETTOMETRES / 65536.0 /
     
    11281173                                                             const.FEETTOMETRES *
    11291174                                                             65536.0 * 65536.0))
    1130         self._valueHandlers["gLoad"] = (0x11ba, "H",
     1175        self._valueHandlers["gLoad"] = ([(0x11ba, "H")],
    11311176                                        lambda value: value / 625.0,
    11321177                                        lambda word: int(float(word) * 625.0))
    11331178
    1134         self._valueHandlers["flapsControl"] = (0x0bdc, "d",
     1179        self._valueHandlers["flapsControl"] = ([(0x0bdc, "d")],
    11351180                                               lambda value: value * 100.0 / 16383.0,
    11361181                                               lambda word: int(float(word) *
    11371182                                                                16383.0 / 100.0))
    1138         self._valueHandlers["flaps"] = (0x0be0, "d",
     1183        self._valueHandlers["flaps"] = ([(0x0be0, "d")],
    11391184                                        lambda value: value * 100.0 / 16383.0,
    11401185                                        lambda word: int(float(word) *
    11411186                                                         16383.0 / 100.0))
    1142         self._valueHandlers["lights"] = (0x0d0c, "H",
     1187        self._valueHandlers["lights"] = ([(0x0d0c, "H")],
    11431188                                         lambda value: value,
    11441189                                         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")],
    11481193                                              lambda value: value * 100.0 / 16383.0,
    11491194                                              lambda word: int(float(word) *
    11501195                                                               16383.0 / 100.0))
    1151         self._valueHandlers["noseGear"] = (0x0bec, "d",
     1196        self._valueHandlers["noseGear"] = ([(0x0bec, "d")],
    11521197                                           lambda value: value * 100.0 / 16383.0,
    11531198                                           lambda word: int(float(word) *
    11541199                                                            16383.0 / 100.0))
    1155         self._valueHandlers["spoilersArmed"] = (0x0bcc, "d",
     1200        self._valueHandlers["spoilersArmed"] = ([(0x0bcc, "d")],
    11561201                                                CLI.bool2str, CLI.str2bool)
    1157         self._valueHandlers["spoilers"] = (0x0bd0, "d",
     1202        self._valueHandlers["spoilers"] = ([(0x0bd0, "d")],
    11581203                                           lambda value: value,
    11591204                                           lambda word: int(word))
    1160         self._valueHandlers["qnh"] = (0x0330, "H",
     1205        self._valueHandlers["qnh"] = ([(0x0330, "H")],
    11611206                                      lambda value: value / 16.0,
    11621207                                      lambda word: int(float(word)*16.0))
    1163         self._valueHandlers["nav1"] = (0x0350, "H",
     1208        self._valueHandlers["nav1"] = ([(0x0350, "H")],
    11641209                                       Values._writeFrequency,
    11651210                                       lambda word: Values._readFrequency(float(word)))
    1166         self._valueHandlers["nav2"] = (0x0352, "H",
     1211        self._valueHandlers["nav2"] = ([(0x0352, "H")],
    11671212                                       Values._writeFrequency,
    11681213                                       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")],
    11701227                                       Values._writeBCD,
    11711228                                       lambda word: Values._readBCD(int(word)))
    1172         self._valueHandlers["windSpeed"] = (0x0e90, "H",
     1229        self._valueHandlers["windSpeed"] = ([(0x0e90, "H")],
    11731230                                            lambda value: value,
    11741231                                            lambda word: int(word))
    1175         self._valueHandlers["windDirection"] = (0x0e92, "H",
     1232        self._valueHandlers["windDirection"] = ([(0x0e92, "H")],
    11761233                                                lambda value: value * 360.0 / 65536.0,
    11771234                                                lambda word: int(int(word) *
    11781235                                                                 65536.0 / 360.0))
    1179         self._valueHandlers["fuelWeight"] = (0x0af4, "H",
     1236        self._valueHandlers["fuelWeight"] = ([(0x0af4, "H")],
    11801237                                             lambda value: value / 256.0,
    11811238                                             lambda word: int(float(word)*256.0))
    11821239
    11831240
    1184         self._valueHandlers["centreLevel"] = (0x0b74, "d", CLI.pyuipc2fuelLevel,
     1241        self._valueHandlers["centreLevel"] = ([(0x0b74, "d")],
     1242                                              CLI.pyuipc2fuelLevel,
    11851243                                              CLI.fuelLevel2pyuipc)
    1186         self._valueHandlers["centreCapacity"] = (0x0b78, "d",
     1244        self._valueHandlers["centreCapacity"] = ([(0x0b78, "d")],
    11871245                                                 CLI.pyuipc2fuelCapacity,
    11881246                                                 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")],
    11921251                                                   CLI.pyuipc2fuelCapacity,
    11931252                                                   CLI.fuelCapacity2pyuipc)
    1194         self._valueHandlers["leftAuxLevel"] = (0x0b84, "d", CLI.pyuipc2fuelLevel,
     1253        self._valueHandlers["leftAuxLevel"] = ([(0x0b84, "d")],
     1254                                               CLI.pyuipc2fuelLevel,
    11951255                                               CLI.fuelLevel2pyuipc)
    1196         self._valueHandlers["leftAuxCapacity"] = (0x0b88, "d",
     1256        self._valueHandlers["leftAuxCapacity"] = ([(0x0b88, "d")],
    11971257                                                   CLI.pyuipc2fuelCapacity,
    11981258                                                  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")],
    12021263                                                  CLI.pyuipc2fuelCapacity,
    12031264                                                  CLI.fuelCapacity2pyuipc)
    1204         self._valueHandlers["rightMainLevel"] = (0x0b94, "d", CLI.pyuipc2fuelLevel,
     1265        self._valueHandlers["rightMainLevel"] = ([(0x0b94, "d")],
     1266                                                 CLI.pyuipc2fuelLevel,
    12051267                                                 CLI.fuelLevel2pyuipc)
    1206         self._valueHandlers["rightMainCapacity"] = (0x0b98, "d",
     1268        self._valueHandlers["rightMainCapacity"] = ([(0x0b98, "d")],
    12071269                                                    CLI.pyuipc2fuelCapacity,
    12081270                                                    CLI.fuelCapacity2pyuipc)
    1209         self._valueHandlers["rightAuxLevel"] = (0x0b9c, "d", CLI.pyuipc2fuelLevel,
     1271        self._valueHandlers["rightAuxLevel"] = ([(0x0b9c, "d")], CLI.pyuipc2fuelLevel,
    12101272                                                CLI.fuelLevel2pyuipc)
    1211         self._valueHandlers["rightAuxCapacity"] = (0x0ba0, "d",
     1273        self._valueHandlers["rightAuxCapacity"] = ([(0x0ba0, "d")],
    12121274                                                   CLI.pyuipc2fuelCapacity,
    12131275                                                   CLI.fuelCapacity2pyuipc)
    1214         self._valueHandlers["rightTipLevel"] = (0x0ba4, "d", CLI.pyuipc2fuelLevel,
     1276        self._valueHandlers["rightTipLevel"] = ([(0x0ba4, "d")],
     1277                                                CLI.pyuipc2fuelLevel,
    12151278                                                CLI.fuelLevel2pyuipc)
    1216         self._valueHandlers["rightTipCapacity"] = (0x0ba8, "d",
     1279        self._valueHandlers["rightTipCapacity"] = ([(0x0ba8, "d")],
    12171280                                                   CLI.pyuipc2fuelCapacity,
    12181281                                                   CLI.fuelCapacity2pyuipc)
    1219         self._valueHandlers["centre2Level"] = (0x1244, "d", CLI.pyuipc2fuelLevel,
     1282        self._valueHandlers["centre2Level"] = ([(0x1244, "d")],
     1283                                               CLI.pyuipc2fuelLevel,
    12201284                                               CLI.fuelLevel2pyuipc)
    1221         self._valueHandlers["centre2Capacity"] = (0x1248, "d",
     1285        self._valueHandlers["centre2Capacity"] = ([(0x1248, "d")],
    12221286                                                  CLI.pyuipc2fuelCapacity,
    12231287                                                  CLI.fuelCapacity2pyuipc)
    1224         self._valueHandlers["external1Level"] = (0x1254, "d", CLI.pyuipc2fuelLevel,
     1288        self._valueHandlers["external1Level"] = ([(0x1254, "d")],
     1289                                                 CLI.pyuipc2fuelLevel,
    12251290                                                 CLI.fuelLevel2pyuipc)
    1226         self._valueHandlers["external1Capacity"] = (0x1258, "d",
     1291        self._valueHandlers["external1Capacity"] = ([(0x1258, "d")],
    12271292                                                    CLI.pyuipc2fuelCapacity,
    12281293                                                    CLI.fuelCapacity2pyuipc)
    1229         self._valueHandlers["external2Level"] = (0x125c, "d", CLI.pyuipc2fuelLevel,
     1294        self._valueHandlers["external2Level"] = ([(0x125c, "d")],
     1295                                                 CLI.pyuipc2fuelLevel,
    12301296                                                 CLI.fuelLevel2pyuipc)
    1231         self._valueHandlers["external2Capacity"] = (0x1260, "d",
     1297        self._valueHandlers["external2Capacity"] = ([(0x1260, "d")],
    12321298                                                    CLI.pyuipc2fuelCapacity,
    12331299                                                    CLI.fuelCapacity2pyuipc)
    12341300
    1235         self._valueHandlers["n1_1"] = (0x2000, "f", lambda value: value,
     1301        self._valueHandlers["n1_1"] = ([(0x2000, "f")], lambda value: value,
    12361302                                       lambda word: float(word))
    1237         self._valueHandlers["n1_2"] = (0x2100, "f", lambda value: value,
     1303        self._valueHandlers["n1_2"] = ([(0x2100, "f")], lambda value: value,
    12381304                                       lambda word: float(word))
    1239         self._valueHandlers["n1_3"] = (0x2200, "f", lambda value: value,
     1305        self._valueHandlers["n1_3"] = ([(0x2200, "f")], lambda value: value,
    12401306                                       lambda word: float(word))
    12411307
    1242         self._valueHandlers["throttle_1"] = (0x088c, "H",
     1308        self._valueHandlers["throttle_1"] = ([(0x088c, "H")],
    12431309                                             CLI.pyuipc2throttle,
    12441310                                             CLI.throttle2pyuipc)
    1245         self._valueHandlers["throttle_2"] = (0x0924, "H",
     1311        self._valueHandlers["throttle_2"] = ([(0x0924, "H")],
    12461312                                             CLI.pyuipc2throttle,
    12471313                                             CLI.throttle2pyuipc)
    1248         self._valueHandlers["throttle_3"] = (0x09bc, "H",
     1314        self._valueHandlers["throttle_3"] = ([(0x09bc, "H")],
    12491315                                             CLI.pyuipc2throttle,
    12501316                                             CLI.throttle2pyuipc)
    12511317                                                           
    1252         self._valueHandlers["visibility"] = (0x0e8a, "H",
     1318        self._valueHandlers["visibility"] = ([(0x0e8a, "H")],
    12531319                                             lambda value: value*1609.344/100.0,
    12541320                                             lambda word: int(float(word)*
    12551321                                                              100.0/1609.344))
    12561322                                                           
    1257         self._valueHandlers["payloadCount"] = (0x13fc, "d",
     1323        self._valueHandlers["payloadCount"] = ([(0x13fc, "d")],
    12581324                                               lambda value: value,
    12591325                                               lambda word: int(word))
    12601326        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")],
    12621328                                                       lambda value:
    12631329                                                       value * const.LBSTOKG,
    12641330                                                       lambda word:
    12651331                                                       float(word)*const.KGSTOLB)
    1266         self._valueHandlers["textScrolling"] = (0x1274, "h",
     1332        self._valueHandlers["textScrolling"] = ([(0x1274, "h")],
    12671333                                                CLI.bool2str, CLI.str2bool)
    12681334                                                           
    1269         self._valueHandlers["messageDuration"] = (0x32fa, "h",
     1335        self._valueHandlers["messageDuration"] = ([(0x32fa, "h")],
    12701336                                                  lambda value: value,
    12711337                                                  lambda word: int(word))
    1272         self._valueHandlers["message"] = (0x3380, -128,
     1338        self._valueHandlers["message"] = ([(0x3380, -128)],
    12731339                                          lambda value: value,
    12741340                                          lambda word: word)
    12751341
    12761342        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")],
    12781344                                                      lambda value: "0x%08x" % (value,),
    12791345                                                      lambda word: long(word, 16))
    12801346
    1281         self._valueHandlers["cog"] = (0x2ef8, "f", lambda value: value,
     1347        self._valueHandlers["cog"] = ([(0x2ef8, "f")], lambda value: value,
    12821348                                       lambda word: float(word))
    12831349
    1284         self._valueHandlers["pmdg_737ng_switches"] = (0x6202, "b",
     1350        self._valueHandlers["pmdg_737ng_switches"] = ([(0x6202, "b")],
    12851351                                                      lambda value: value,
    12861352                                                      lambda word: int(word))
    12871353
    1288         self._valueHandlers["pmdg_737ngx_lts_positionsw"] = (0x6500, "b",
     1354        self._valueHandlers["pmdg_737ngx_lts_positionsw"] = ([(0x6500, "b")],
    12891355                                                             lambda value: value,
    12901356                                                             lambda word: int(word))
     
    13071373                return False
    13081374            valueHandler = self._valueHandlers[name]
    1309             data.append((valueHandler[0], valueHandler[1]))
     1375            data += valueHandler[0]
    13101376
    13111377        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):
    13141382                name = names[i]
    13151383                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
    13171393        except Exception, e:
    13181394            print >> sys.stderr, "Failed to read data: " + str(e)                       
     
    13641440            valueHandler = self._valueHandlers[name]
    13651441            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
    13681449            except Exception, e:
    13691450                print >> sys.stderr, "Invalid value '%s' for variable %s: %s" % \
Note: See TracChangeset for help on using the changeset viewer.