Files
mxsc/script/local.py
2016-09-19 08:51:51 +02:00

63 lines
1.8 KiB
Python

###################################################################################################
# Deployment specific global definitions - executed after startup.py
###################################################################################################
from ch.psi.pshell.serial import TcpDevice
from ch.psi.pshell.modbus import ModbusTCP
class RobotTCP(TcpDevice):
def __init__(self, name, server):
TcpDevice.__init__(self, name, server)
def execute(self, system, command, *argv):
#print "Done"
cmd = str(system) + "," + str(command)
for arg in argv:
cmd = cmd + "," + str(arg)
cmd = cmd + "\n"
ret = ""
try:
ret = robot.write(cmd)
finally:
self.getLogger().info(cmd + " ret = " + str(ret))
return ret
def mount(self, puck, sample):
return self.execute('1', '1', puck, sample)
add_device(RobotTCP("robot_tcp", "127.0.0.1:3333"), force = True)
def detect_pucks(ip):
aux = grayscale(ip, in_place=False)
threshold(aux,0,50)
binary_fill_holes(aux)
return analyse_particles(aux, 10000,50000,
fill_holes = False, exclude_edges = True,print_table=True,
output_image = "outlines", minCirc = 0.4, maxCirc = 1.0)
def detect_samples(ip):
aux = grayscale(ip, in_place=False)
invert(aux)
subtract_background(aux)
auto_threshold(aux)
binary_open(aux)
return analyse_particles(aux, 250,1000,
fill_holes = False, exclude_edges = True,print_table=True,
output_image = "outlines", minCirc = 0.7, maxCirc = 1.0)
r,g,b = [0]*256,[0]*256,[0]*256
b[0]=0xFF
b[1]=0xFF ; g[1] = 0x80; r[1] = 0x80
outline_lut1 = (r,g,b)
r,g,b = [0]*256,[0]*256,[0]*256
g[0]=0x80;r[0]=0x80;
g[1]=0xFF ; r[1] = 0x80; b[1] = 0x80
outline_lut2 = (r,g,b)