52 lines
1.7 KiB
Python
52 lines
1.7 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)
|
|
subtract_background(aux)
|
|
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.0, 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)
|