From d803624996f978965519515dadc1df7193dab4d7 Mon Sep 17 00:00:00 2001 From: mer0m Date: Tue, 7 Mar 2017 00:52:50 +0100 Subject: [PATCH] add test device --- instruments/testDevice.py | 49 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 49 insertions(+) create mode 100644 instruments/testDevice.py diff --git a/instruments/testDevice.py b/instruments/testDevice.py new file mode 100644 index 0000000..f91180d --- /dev/null +++ b/instruments/testDevice.py @@ -0,0 +1,49 @@ +from abstract_instrument import abstract_instrument +import numpy, time + +#============================================================================== + +ALL_VAL_TYPE = ['vtype', 'DCV', 'ACV', 'DCI', 'ACI', 'RES2W', 'RES4W', 'FREQ'] +ALL_CHANNELS = ['0', '1'] +address = "123.456.789.123" + +#============================================================================== + +class testDevice(abstract_instrument): + def __init__(self, channels, vtype, address = address): + self.address = address + self.port = 9999 + self.channels = channels + self.vtype = vtype + + def model(self): + return 'test_device' + + def connect(self): + print('Connecting to device @%s:%s...' %(self.address, self.port)) + time.sleep(1) + print(' --> Ok') + self.configure() + + print(self.model()) + + def getValue(self): + mes = "" + for ch in self.channels: + mes = mes + str(numpy.random.rand()) + '\t' + return mes + '\n' + + def read(self): + print('reading') + return 1 + + def disconnect(self): + print('disconnect') + + def send(self, command): + print('send %s'%command) + + def configure(self): + print(self.channels) + print(self.vtype) + print('configured') -- 2.16.4