Fix distance_base_unit extraction in JPK driver for encoded data.
authorW. Trevor King <wking@drexel.edu>
Wed, 8 Sep 2010 20:13:18 +0000 (16:13 -0400)
committerW. Trevor King <wking@drexel.edu>
Wed, 8 Sep 2010 20:13:18 +0000 (16:13 -0400)
hooke/driver/jpk.py

index afa95704251c9fbb7a8ed214b726a38a2d45b55e..286766cb58c62a16153ef10e7f201db8462bcf5e 100644 (file)
@@ -219,9 +219,14 @@ class JPKDriver (Driver):
         assert distance_base == 'volts', distance_base
         base_conversion = chan_info['channel']['vDeflection']['conversion-set']['conversions']['base']
         assert base_conversion == distance_base, base_conversion
-        distance_base_unit = self._zip_unit(
-            chan_info['channel']['vDeflection']['data'],
-            version)
+        if 'encoder' in chan_info['channel']['vDeflection']['data']:
+            distance_base_unit = self._zip_unit(
+                chan_info['channel']['vDeflection']['data']['encoder']['scaling'],
+                version)
+        else:
+            distance_base_unit = self._zip_unit(
+                chan_info['channel']['vDeflection']['data'],
+                version)
         assert distance_base_unit == 'V', distance_base_unit
         force_mult = float(
             chan_info['channel']['vDeflection']['conversion-set']['conversion']['force']['scaling']['multiplier'])