Closedown
This commit is contained in:
@@ -6,7 +6,7 @@
|
||||
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)
|
||||
@@ -26,9 +26,52 @@ class RobotTCP(TcpDevice):
|
||||
|
||||
def mount(self, puck, sample):
|
||||
return self.execute('1', '1', puck, sample)
|
||||
add_device(RobotTCP("robot_tcp", "127.0.0.1:3333"), force = True)
|
||||
"""
|
||||
|
||||
|
||||
class RobotModbus(DeviceBase):
|
||||
def __init__(self, namer):
|
||||
DeviceBase.__init__(self, name)
|
||||
robot_req.write(0)
|
||||
|
||||
def execute(self, system, command, *argv):
|
||||
#print "Done"
|
||||
if robot_req.read() != 0:
|
||||
raise Exception("Ongoing command")
|
||||
if robot_ack.read() != 0:
|
||||
raise Exception("Robot is not ready")
|
||||
robot_cmd.write(cmd)
|
||||
args = [0,0,0,0,0,0]
|
||||
index = 0
|
||||
for arg in argv:
|
||||
args[index++] = arg
|
||||
robot_args.write(args)
|
||||
robot_req.write(1)
|
||||
try:
|
||||
self.request()
|
||||
ret = robot_ret.read()
|
||||
finally:
|
||||
self.cancel_request()
|
||||
return ret
|
||||
|
||||
def request():
|
||||
robot_req.write(1)
|
||||
while robot_ack.read() == 0:
|
||||
time.sleep(0.01)
|
||||
|
||||
def cancel_request():
|
||||
robot_req.write(0)
|
||||
while robot_ack.read() == 1:
|
||||
time.sleep(0.01)
|
||||
|
||||
def mount(self, puck, sample):
|
||||
return self.execute('1', '1', puck, sample)
|
||||
|
||||
add_device(RobotModbus("robot"), force = True)
|
||||
|
||||
|
||||
add_device(RobotTCP("robot_tcp", "127.0.0.1:3333"), force = True)
|
||||
|
||||
|
||||
|
||||
add_device(img.getContrast(), force = True)
|
||||
|
||||
Reference in New Issue
Block a user