]> jspc29.x-matter.uni-frankfurt.de Git - mvd_epics.git/commitdiff
OPUS20: Get all info from device at once
authorPhilipp Klaus <klaus@physik.uni-frankfurt.de>
Thu, 10 Aug 2017 10:22:20 +0000 (12:22 +0200)
committerPhilipp Klaus <klaus@physik.uni-frankfurt.de>
Thu, 10 Aug 2017 10:22:20 +0000 (12:22 +0200)
LUFFT_OPUS20/lufft_opus20_driver.py

index c4d5d9d3e8b0168d466d6fc9177683beb969a24f..546faacaa0d1764ff575fc40e450214fea5c7018 100644 (file)
@@ -30,20 +30,25 @@ class Opus20Driver(Driver):
         while True:
             start = time.time()
 
-            mapping = {
-                'Temperature':       0x0064,
-                'RelativeHumidity':  0x00c8,
-                'AbsoluteHumidity':  0x00cd,
-                'Dewpoint':          0x006e,
-                'BatteryVoltage':    0x2724,
-            }
-            for reason in mapping.keys():
-                try:
-                    value = self.o20.channel_value(mapping[reason])
+            mapping = [
+                ('Temperature',       0x0064),
+                ('RelativeHumidity',  0x00c8),
+                ('AbsoluteHumidity',  0x00cd),
+                ('Dewpoint',          0x006e),
+                ('BatteryVoltage',    0x2724),
+            ]
+            pv_names = [tup[0] for tup in mapping]
+            o20_ids  = [tup[1] for tup in mapping]
+            try:
+                values = self.o20.multi_channel_value(o20_ids)
+            except:
+                values = [None] * len(o20_ids)
+            for i, reason in enumerate(pv_names):
+                if values[i] is not None:
+                    value = values[i]
                     self.setParamStatus(reason, Alarm.NO_ALARM, Severity.NO_ALARM)
                     self.setParam(reason, value)
-                except:
+                else:
                     self.setParamStatus(reason, Alarm.COMM_ALARM, Severity.MINOR_ALARM)
-                    value = self.getParam(reason)
 
             time.sleep(self.scan_period - (time.time() - start))