From: Philipp Klaus Date: Thu, 10 Aug 2017 10:22:20 +0000 (+0200) Subject: OPUS20: Get all info from device at once X-Git-Url: https://jspc29.x-matter.uni-frankfurt.de/git/?a=commitdiff_plain;h=03ef48eb3a696ba88f1e7446f5a3cd5e82349f85;p=mvd_epics.git OPUS20: Get all info from device at once --- diff --git a/LUFFT_OPUS20/lufft_opus20_driver.py b/LUFFT_OPUS20/lufft_opus20_driver.py index c4d5d9d..546faac 100644 --- a/LUFFT_OPUS20/lufft_opus20_driver.py +++ b/LUFFT_OPUS20/lufft_opus20_driver.py @@ -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))