Commit 6a7849f48af52e199d4507e239653b13dcfa87a9
1 parent
cb568e88d7
Exists in
master
resolve minor bugs
Showing 1 changed file with 1 additions and 1 deletions Inline Diff
instruments/T7Pro.py
from abstract_instrument import abstract_instrument | 1 | 1 | from abstract_instrument import abstract_instrument | |
from labjack import ljm | 2 | 2 | from labjack import ljm | |
import numpy | 3 | 3 | import numpy | |
4 | 4 | |||
#============================================================================== | 5 | 5 | #============================================================================== | |
6 | 6 | |||
ALL_VAL_TYPE = ['RES'] | 7 | 7 | ALL_VAL_TYPE = ['RES'] | |
ALL_CHANNELS = ['1', '2', '3', '4'] | 8 | 8 | ALL_CHANNELS = ['1', '2', '3', '4'] | |
9 | 9 | |||
ADRESS = "192.168.0.25" | 10 | 10 | ADRESS = "192.168.0.25" | |
CONF_CHANNELS = [["AIN0", "AIN10"], ["AIN2", "AIN11"], ["AIN4", "AIN12"], ["AIN6", "AIN13"]] | 11 | 11 | CONF_CHANNELS = [["AIN0", "AIN10"], ["AIN2", "AIN11"], ["AIN4", "AIN12"], ["AIN6", "AIN13"]] | |
12 | 12 | |||
#============================================================================== | 13 | 13 | #============================================================================== | |
14 | 14 | |||
class T7Pro(abstract_instrument): | 15 | 15 | class T7Pro(abstract_instrument): | |
def __init__(self, channels, vtypes, adress): | 16 | 16 | def __init__(self, channels, vtypes, adress): | |
self.adress = adress | 17 | 17 | self.adress = adress | |
self.channels = channels | 18 | 18 | self.channels = channels | |
self.vtypes = vtypes | 19 | 19 | self.vtypes = vtypes | |
20 | 20 | |||
def model(self): | 21 | 21 | def model(self): | |
return 'T7Pro' | 22 | 22 | return 'T7Pro' | |
23 | 23 | |||
def connect(self): | 24 | 24 | def connect(self): | |
print('Connecting to device @%s...' %(self.adress)) | 25 | 25 | print('Connecting to device @%s...' %(self.adress)) | |
self.handle = ljm.openS("T7", "ETHERNET", self.adress) | 26 | 26 | self.handle = ljm.openS("T7", "ETHERNET", self.adress) | |
print(' --> Ok') | 27 | 27 | print(' --> Ok') | |
print(self.model()) | 28 | 28 | print(self.model()) | |
self.configure() | 29 | 29 | self.configure() | |
30 | 30 | |||
def configure(self): | 31 | 31 | def configure(self): | |
names = ["AIN0_NEGATIVE_CH", "AIN0_RANGE", "AIN0_RESOLUTION_INDEX", | 32 | 32 | names = ["AIN0_NEGATIVE_CH", "AIN0_RANGE", "AIN0_RESOLUTION_INDEX", | |
"AIN1_NEGATIVE_CH", "AIN1_RANGE", "AIN1_RESOLUTION_INDEX", | 33 | 33 | "AIN1_NEGATIVE_CH", "AIN1_RANGE", "AIN1_RESOLUTION_INDEX", | |
"AIN2_NEGATIVE_CH", "AIN2_RANGE", "AIN2_RESOLUTION_INDEX", | 34 | 34 | "AIN2_NEGATIVE_CH", "AIN2_RANGE", "AIN2_RESOLUTION_INDEX", | |
"AIN3_NEGATIVE_CH", "AIN3_RANGE", "AIN3_RESOLUTION_INDEX", | 35 | 35 | "AIN3_NEGATIVE_CH", "AIN3_RANGE", "AIN3_RESOLUTION_INDEX", | |
"AIN4_NEGATIVE_CH", "AIN4_RANGE", "AIN4_RESOLUTION_INDEX", | 36 | 36 | "AIN4_NEGATIVE_CH", "AIN4_RANGE", "AIN4_RESOLUTION_INDEX", | |
"AIN5_NEGATIVE_CH", "AIN5_RANGE", "AIN5_RESOLUTION_INDEX", | 37 | 37 | "AIN5_NEGATIVE_CH", "AIN5_RANGE", "AIN5_RESOLUTION_INDEX", | |
"AIN6_NEGATIVE_CH", "AIN6_RANGE", "AIN6_RESOLUTION_INDEX", | 38 | 38 | "AIN6_NEGATIVE_CH", "AIN6_RANGE", "AIN6_RESOLUTION_INDEX", | |
"AIN7_NEGATIVE_CH", "AIN7_RANGE", "AIN7_RESOLUTION_INDEX", | 39 | 39 | "AIN7_NEGATIVE_CH", "AIN7_RANGE", "AIN7_RESOLUTION_INDEX", | |
#"AIN8_NEGATIVE_CH", "AIN8_RANGE", "AIN8_RESOLUTION_INDEX", | 40 | 40 | #"AIN8_NEGATIVE_CH", "AIN8_RANGE", "AIN8_RESOLUTION_INDEX", | |
#"AIN9_NEGATIVE_CH", "AIN9_RANGE", "AIN9_RESOLUTION_INDEX", | 41 | 41 | #"AIN9_NEGATIVE_CH", "AIN9_RANGE", "AIN9_RESOLUTION_INDEX", | |
"AIN10_NEGATIVE_CH", "AIN10_RANGE", "AIN10_RESOLUTION_INDEX", | 42 | 42 | "AIN10_NEGATIVE_CH", "AIN10_RANGE", "AIN10_RESOLUTION_INDEX", | |
"AIN11_NEGATIVE_CH", "AIN11_RANGE", "AIN11_RESOLUTION_INDEX", | 43 | 43 | "AIN11_NEGATIVE_CH", "AIN11_RANGE", "AIN11_RESOLUTION_INDEX", | |
"AIN12_NEGATIVE_CH", "AIN12_RANGE", "AIN12_RESOLUTION_INDEX", | 44 | 44 | "AIN12_NEGATIVE_CH", "AIN12_RANGE", "AIN12_RESOLUTION_INDEX", | |
"AIN13_NEGATIVE_CH", "AIN13_RANGE", "AIN13_RESOLUTION_INDEX" | 45 | 45 | "AIN13_NEGATIVE_CH", "AIN13_RANGE", "AIN13_RESOLUTION_INDEX" | |
] | 46 | 46 | ] | |
l_names = len(names) | 47 | 47 | l_names = len(names) | |
aValues = [1, 1, 12,#0 | 48 | 48 | aValues = [1, 1, 12,#0 | |
199, 1, 12,#1 | 49 | 49 | 199, 1, 12,#1 | |
3, 1, 12,#2 | 50 | 50 | 3, 1, 12,#2 | |
199, 1, 12,#3 | 51 | 51 | 199, 1, 12,#3 | |
5, 1, 12,#4 | 52 | 52 | 5, 1, 12,#4 | |
199, 1, 12,#5 | 53 | 53 | 199, 1, 12,#5 | |
7, 1, 12,#6 | 54 | 54 | 7, 1, 12,#6 | |
199, 1, 12,#7 | 55 | 55 | 199, 1, 12,#7 | |
#199, 1, 12,#8 | 56 | 56 | #199, 1, 12,#8 | |
#199, 1, 12,#9 | 57 | 57 | #199, 1, 12,#9 | |
199, 1, 12,#10 | 58 | 58 | 199, 1, 12,#10 | |
199, 1, 12,#11 | 59 | 59 | 199, 1, 12,#11 | |
199, 1, 12,#12 | 60 | 60 | 199, 1, 12,#12 | |
199, 1, 12#13 | 61 | 61 | 199, 1, 12#13 | |
] | 62 | 62 | ] | |
63 | 63 | |||
ljm.eWriteNames(self.handle, l_names, names, aValues) | 64 | 64 | ljm.eWriteNames(self.handle, l_names, names, aValues) | |
65 | 65 | |||
def getValue(self): | 66 | 66 | def getValue(self): | |
strMes = '' | 67 | 67 | strMes = '' | |
for ch in self.channels: | 68 | 68 | for ch in self.channels: | |
raw = self.read(CONF_CHANNELS[ALL_CHANNELS.index(ch)]) | 69 | 69 | raw = self.read(CONF_CHANNELS[ALL_CHANNELS.index(ch)]) |