Commit d803624996f978965519515dadc1df7193dab4d7
1 parent
501ae8f660
Exists in
master
add test device
Showing 1 changed file with 49 additions and 0 deletions Side-by-side Diff
instruments/testDevice.py
1 | +from abstract_instrument import abstract_instrument | |
2 | +import numpy, time | |
3 | + | |
4 | +#============================================================================== | |
5 | + | |
6 | +ALL_VAL_TYPE = ['vtype', 'DCV', 'ACV', 'DCI', 'ACI', 'RES2W', 'RES4W', 'FREQ'] | |
7 | +ALL_CHANNELS = ['0', '1'] | |
8 | +address = "123.456.789.123" | |
9 | + | |
10 | +#============================================================================== | |
11 | + | |
12 | +class testDevice(abstract_instrument): | |
13 | + def __init__(self, channels, vtype, address = address): | |
14 | + self.address = address | |
15 | + self.port = 9999 | |
16 | + self.channels = channels | |
17 | + self.vtype = vtype | |
18 | + | |
19 | + def model(self): | |
20 | + return 'test_device' | |
21 | + | |
22 | + def connect(self): | |
23 | + print('Connecting to device @%s:%s...' %(self.address, self.port)) | |
24 | + time.sleep(1) | |
25 | + print(' --> Ok') | |
26 | + self.configure() | |
27 | + | |
28 | + print(self.model()) | |
29 | + | |
30 | + def getValue(self): | |
31 | + mes = "" | |
32 | + for ch in self.channels: | |
33 | + mes = mes + str(numpy.random.rand()) + '\t' | |
34 | + return mes + '\n' | |
35 | + | |
36 | + def read(self): | |
37 | + print('reading') | |
38 | + return 1 | |
39 | + | |
40 | + def disconnect(self): | |
41 | + print('disconnect') | |
42 | + | |
43 | + def send(self, command): | |
44 | + print('send %s'%command) | |
45 | + | |
46 | + def configure(self): | |
47 | + print(self.channels) | |
48 | + print(self.vtype) | |
49 | + print('configured') |