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))