From 20cd6a9c18a109266aaa5fb9fce583685c1618ae Mon Sep 17 00:00:00 2001 From: Sebastian Goscik Date: Mon, 7 Mar 2016 13:21:40 +0000 Subject: [PATCH] daq: Added check for duplicate channel labels The daq instrument will no longer accept duplicate channel names. This caused issues where files sent from the daq sever were being overwritten. --- wlauto/instrumentation/daq/__init__.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/wlauto/instrumentation/daq/__init__.py b/wlauto/instrumentation/daq/__init__.py index f26c4cba..2d35c2ad 100644 --- a/wlauto/instrumentation/daq/__init__.py +++ b/wlauto/instrumentation/daq/__init__.py @@ -286,6 +286,10 @@ class Daq(Instrument): if self.labels: if len(self.labels) != len(self.resistor_values): raise ConfigError('Number of DAQ port labels does not match the number of resistor values.') + + duplicates = set([x for x in self.labels if self.labels.count(x) > 1]) + if len(duplicates) > 0: + raise ConfigError('Duplicate labels: {}'.format(', '.join(duplicates))) else: self.labels = ['PORT_{}'.format(i) for i, _ in enumerate(self.resistor_values)] self.server_config = ServerConfiguration(host=self.server_host,