Commit ff6ac074765154ae401b771db9af7e379be8ebcb
1 parent
67c0abcaa5
Exists in
master
Remove some files from master
Showing 3 changed files with 0 additions and 288 deletions Inline Diff
instruments/LS350.py
from abstract_instrument import abstract_instrument | 1 | File was deleted | ||
import socket | 2 | |||
3 | ||||
#============================================================================== | 4 | |||
5 | ||||
ALL_VAL_TYPE = ['TEMP', 'RES'] | 6 | |||
ALL_CHANNELS = ['a', 'b', 'c', 'd'] | 7 | |||
8 | ||||
ADRESS = "192.168.0.12" | 9 | |||
CONF_VAL_TYPE = ['krdg?', 'srdg?'] | 10 | |||
11 | ||||
#============================================================================== | 12 | |||
13 | ||||
class LS350(abstract_instrument): | 14 | |||
def __init__(self, channels, vtypes, adress): | 15 | |||
self.adress = adress | 16 | |||
self.port = 7777 | 17 | |||
self.channels = channels | 18 | |||
self.vtypes = vtypes | 19 | |||
20 | ||||
def model(self): | 21 | |||
#self.send("*IDN?") | 22 | |||
#return self.read() | 23 | |||
return "LS350" | 24 | |||
25 | ||||
def connect(self): | 26 | |||
print('Connecting to device @%s:%s...' %(self.adress, self.port)) | 27 | |||
self.sock = socket.socket(socket.AF_INET, | 28 | |||
socket.SOCK_STREAM, | 29 | |||
socket.IPPROTO_TCP) | 30 | |||
self.sock.settimeout(10.0) # Don't hang around forever | 31 | |||
self.sock.connect((self.adress, self.port)) | 32 | |||
print(' --> Ok') | 33 | |||
print(self.model()) | 34 | |||
self.configure() | 35 | |||
36 | ||||
def configure(self): | 37 | |||
self.strCh = '' | 38 | |||
for ch in self.channels: | 39 | |||
self.strCh = self.strCh + '%s %s;'%(CONF_VAL_TYPE[ALL_VAL_TYPE.index(self.vtypes[self.channels.index(ch)])], ch) | 40 | |||
self.strCh = self.strCh[0:-1] | 41 | |||
print(self.strCh) | 42 | |||
43 | ||||
def getValue(self): | 44 | |||
self.send(self.strCh) | 45 | |||
return self.read() | 46 | |||
47 | ||||
def read(self): | 48 | |||
self.send("++read eoi") | 49 | |||
ans = '' | 50 | |||
nb_data_list = [] | 51 | |||
nb_data = '' | 52 | |||
try: | 53 | |||
while ans != '\n': | 54 | |||
ans = self.sock.recv(1) | 55 | |||
nb_data_list.append(ans) # Return the number of data | 56 | |||
list_size = len(nb_data_list) | 57 | |||
for j in range (0, list_size): | 58 |
instruments/T7Pro.py
from abstract_instrument import abstract_instrument | 1 | File was deleted | ||
from labjack import ljm | 2 | |||
import numpy | 3 | |||
4 | ||||
#============================================================================== | 5 | |||
6 | ||||
ALL_VAL_TYPE = ['TEMP', 'RES'] | 7 | |||
ALL_CHANNELS = ['TEMP', '1', '2', '3', '4'] | 8 | |||
ADRESS = "192.168.0.25" | 9 | |||
10 | ||||
#============================================================================== | 11 | |||
12 | ||||
class T7Pro(abstract_instrument): | 13 | |||
def __init__(self, adress=ADRESS, vtype=[ALL_VAL_TYPE[0]], channels = [ALL_CHANNELS[0]]): | 14 | |||
self.adress = adress | 15 | |||
self.vtype = vtype | 16 | |||
self.tempName = ["TEMPERATURE_AIR_K"] | 17 | |||
self.res1Name = ["AIN0", "AIN10"] | 18 | |||
self.res2Name = ["AIN2", "AIN11"] | 19 | |||
self.res3Name = ["AIN4", "AIN12"] | 20 | |||
self.res4Name = ["AIN6", "AIN13"] | 21 | |||
22 | ||||
def model(self): | 23 | |||
return 'T7Pro' | 24 | |||
25 | ||||
def connect(self): | 26 | |||
try: | 27 | |||
print('Connecting to device @%s...' %(self.adress)) | 28 | |||
self.handle = ljm.openS("T7", "ETHERNET", self.adress) | 29 | |||
self.configureAINs() | 30 | |||
print(' --> Ok') | 31 | |||
32 | ||||
print(self.model()) | 33 | |||
34 | ||||
if self.vtype == "TEMP": | 35 | |||
1 | 36 | |||
elif self.vtype == "RES": | 37 | |||
1 | 38 | |||
else: | 39 | |||
print("Wrong -v argument") | 40 | |||
raise | 41 | |||
42 | ||||
except Exception as er: | 43 | |||
print("Unexpected error during connection: " + str(er)) | 44 | |||
raise | 45 | |||
46 | ||||
def getValue(self): | 47 | |||
mesTemp = self.read(self.tempName) | 48 | |||
mesRes1 = self.read(self.res1Name) | 49 | |||
mesRes2 = self.read(self.res2Name) | 50 | |||
mesRes3 = self.read(self.res3Name) | 51 | |||
mesRes4 = self.read(self.res4Name) | 52 | |||
# mesRes4 = [1, 1] | 53 | |||
# print("~~~~~~~~~~~~~~~~~~~~~~\n" + str(results) + "~~~~~~~~~~~~~~~~~~~~~~\n") | 54 | |||
temp = mesTemp[0] | 55 | |||
res1 = 100.*mesRes1[0]/mesRes1[1] | 56 | |||
res2 = 100.*mesRes2[0]/mesRes2[1] | 57 | |||
res3 = 100.*mesRes3[0]/mesRes3[1] | 58 | |||
res4 = 100.*mesRes4[0]/mesRes4[1] | 59 | |||
60 | ||||
if self.vtype == 'TEMP': | 61 | |||
# Temperature calculation | 62 | |||
temp1 = self.res2tempSensor(628, res1) | 63 | |||
temp2 = self.res2tempSensor(16947, res2) | 64 | |||
temp3 = self.res2tempSensor(625, res3) | 65 | |||
temp4 = self.res2tempSensor(100, res4) | 66 | |||
string = '%f\t%f\t%f\t%f\t%f\n'%(temp, temp1, temp2, temp3, temp4) | 67 | |||
# string = '%f\t%f\n'%(temp, temp1) | 68 | |||
elif self.vtype == 'RES': | 69 | |||
string = '%f\t%f\t%f\t%f\t%f\n'%(temp, res1, res2, res3, res4) | 70 | |||
# string = '%f\t%f\n'%(temp, res1) | 71 | |||
else: | 72 | |||
string = '' | 73 | |||
74 | ||||
return string | 75 | |||
76 | ||||
def read(self, names): | 77 | |||
return ljm.eReadNames(self.handle, len(names), names) | 78 | |||
79 | ||||
def disconnect(self): | 80 | |||
ljm.close(self.handle) | 81 | |||
82 | ||||
def send(self, command): | 83 | |||
pass | 84 | |||
85 | ||||
def configureAINs(self): | 86 | |||
# Setup and call eWriteNames to configure AINs on the LabJack. | 87 | |||
names = ["AIN0_NEGATIVE_CH", "AIN0_RANGE", "AIN0_RESOLUTION_INDEX", | 88 | |||
"AIN1_NEGATIVE_CH", "AIN1_RANGE", "AIN1_RESOLUTION_INDEX", | 89 | |||
"AIN2_NEGATIVE_CH", "AIN2_RANGE", "AIN2_RESOLUTION_INDEX", | 90 | |||
"AIN3_NEGATIVE_CH", "AIN3_RANGE", "AIN3_RESOLUTION_INDEX", | 91 | |||
"AIN4_NEGATIVE_CH", "AIN4_RANGE", "AIN4_RESOLUTION_INDEX", | 92 | |||
"AIN5_NEGATIVE_CH", "AIN5_RANGE", "AIN5_RESOLUTION_INDEX", | 93 | |||
"AIN6_NEGATIVE_CH", "AIN6_RANGE", "AIN6_RESOLUTION_INDEX", | 94 | |||
"AIN7_NEGATIVE_CH", "AIN7_RANGE", "AIN7_RESOLUTION_INDEX", | 95 | |||
"AIN8_NEGATIVE_CH", "AIN8_RANGE", "AIN8_RESOLUTION_INDEX", | 96 | |||
"AIN9_NEGATIVE_CH", "AIN9_RANGE", "AIN9_RESOLUTION_INDEX", | 97 | |||
"AIN10_NEGATIVE_CH", "AIN10_RANGE", "AIN10_RESOLUTION_INDEX", | 98 | |||
"AIN11_NEGATIVE_CH", "AIN11_RANGE", "AIN11_RESOLUTION_INDEX", | 99 | |||
"AIN12_NEGATIVE_CH", "AIN12_RANGE", "AIN12_RESOLUTION_INDEX", | 100 | |||
"AIN13_NEGATIVE_CH", "AIN13_RANGE", "AIN13_RESOLUTION_INDEX" | 101 | |||
] | 102 | |||
l_names = len(names) | 103 | |||
aValues = [1, 0.1, 12,#0 | 104 | |||
199, 0.1, 12,#1 | 105 | |||
3, 0.1, 12,#2 | 106 | |||
199, 0.1, 12,#3 | 107 | |||
5, 0.1, 12,#4 | 108 | |||
199, 0.1, 12,#5 | 109 | |||
7, 0.1, 12,#6 | 110 | |||
199, 0.1, 12,#7 | 111 | |||
199, 0.1, 12,#8 | 112 | |||
199, 0.1, 12,#9 | 113 | |||
199, 0.1, 12,#10 | 114 | |||
199, 0.1, 12,#11 | 115 | |||
199, 0.1, 12,#12 | 116 | |||
199, 0.1, 12#13 | 117 | |||
] | 118 | |||
ljm.eWriteNames(self.handle, l_names, names, aValues) | 119 | |||
120 | ||||
121 | ||||
def res2tempSensor(self, sensor, res): | 122 | |||
if sensor==627: | 123 | |||
K = [0.399341181655472610, | 124 | |||
10.8420092277810909, | 125 | |||
-26.4597939187660813, | 126 | |||
245.9828566655493379, | 127 | |||
-668.069876596331596, | 128 | |||
1001.69882618263364, | 129 | |||
-267.272089680656791] | 130 | |||
if sensor==625: | 131 | |||
K = [0.333548856582638109, | 132 | |||
11.7361551595386118, | 133 | |||
-31.32988932320903987, | 134 | |||
262.878643524833024, | 135 | |||
-704.163538021035492, | 136 | |||
1056.6040485650301, | 137 | |||
-307.057196729816496] | 138 | |||
if sensor==628: | 139 | |||
K = [0.463200932294057566, | 140 | |||
13.5049710820894688, | 141 | |||
-30.5191222755238414, | 142 | |||
231.098593852017075, | 143 | |||
-550.122691885568202, | 144 | |||
806.038547554984689, | 145 | |||
-198.510489917360246] | 146 | |||
if sensor==16945: | 147 | |||
K = [3.2497, 5.1777, 2.499] | 148 | |||
if sensor==16943: | 149 | |||
K = [3.4738, 5.1198, 2.3681] | 150 | |||
if sensor==16944: | 151 | |||
K = [3.3674, 5.2874, 2.5165] | 152 | |||
if sensor==16941: | 153 | |||
K = [2.9486, 4.5862, 2.266] | 154 |
instruments/testDevice.py
from abstract_instrument import abstract_instrument | 1 | File was deleted | ||
import numpy, time | 2 | |||
3 | ||||
#============================================================================== | 4 | |||
5 | ||||
ALL_VAL_TYPE = ['vtype', 'DCV', 'ACV', 'DCI', 'ACI', 'RES2W', 'RES4W', 'FREQ'] | 6 | |||
ALL_CHANNELS = ['0', '1'] | 7 | |||
ADRESS = "123.456.789.123" | 8 | |||
9 | ||||
#============================================================================== | 10 | |||
11 | ||||
class testDevice(abstract_instrument): | 12 | |||
def __init__(self, channels, vtype, adress = ADRESS): | 13 | |||
self.adress = adress | 14 | |||
self.port = 9999 | 15 | |||
self.channels = channels | 16 | |||
print(self.channels) | 17 | |||
self.vtype = vtype | 18 | |||
print(self.vtype) | 19 | |||
20 | ||||
def model(self): | 21 | |||
return 'test_device' | 22 | |||
23 | ||||
def connect(self): | 24 | |||
print('Connecting to device @%s:%s...' %(self.adress, self.port)) | 25 | |||
time.sleep(1) | 26 | |||
print(' --> Ok') | 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 |