Commit 39a4f4d7 authored by Philipp Oleynik's avatar Philipp Oleynik
Browse files

Agilent pump update

parent 6b29ff49
......@@ -41,15 +41,16 @@ class pumpAgilent:
isConnected = False
pump_com = None
status = None
def __init__(self, dev_com):
try:
dev_com = serial.Serial(
port = dev_com,
baudrate = 9600,
parity = serial.PARITY_NONE,
stopbits = serial.STOPBITS_ONE,
bytesize = serial.EIGHTBITS
port=dev_com,
baudrate=9600,
parity=serial.PARITY_NONE,
stopbits=serial.STOPBITS_ONE,
bytesize=serial.EIGHTBITS,
timeout=0.25
)
dev_com.isOpen()
self.pump_com = dev_com
......@@ -60,31 +61,42 @@ class pumpAgilent:
print(sys.exc_info())
self.pump_com = None
self.isConnected = False
def close(self):
self.pump_com.close()
def serWriteAndRecieve(self, data, delay = 0.05):
def serWriteAndRecieve(self, data, delay=0.05):
self.pump_com.write(data)
out = ''
time.sleep(delay)
# serial.SerialTimeoutException
while self.pump_com.inWaiting() > 0:
out += self.pump_com.read(1).decode(encoding = 'ascii', errors = 'ignore')
out += self.pump_com.read(1).decode(encoding='ascii', errors='ignore')
if out != '':
return out
return None
def getPressure(self):
return float(self.serWriteAndRecieve(b"\002\200\062\062\064\060\003\070\067")[4:12])
stat = self.serWriteAndRecieve(b"\002\200\062\062\064\060\003\070\067")
if stat is not None:
stat = stat[4: 12]
return float(stat)
return 1.20E+03
def getRpm(self):
stat = self.serWriteAndRecieve(b"\002\200\062\062\066\060\003\070\065")[4:11]
return int(stat)
stat = self.serWriteAndRecieve(b"\002\200\062\062\066\060\003\070\065")
if stat is not None:
stat = stat[4: 11]
return int(stat)
return 0
def getStatus(self):
stat = self.serWriteAndRecieve(b"\002\200\062\062\066\060\003\070\065")[4:11]
if int(stat) > 100:
self.status = 1
else:
self.status = 0
return self.status
stat = self.serWriteAndRecieve(b"\002\200\062\062\066\060\003\070\065")
if stat is not None:
stat = stat[4: 11]
if int(stat) > 10000:
self.status = 2
else:
self.status = 1
return self.status
return 0
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment