This commit is contained in:
@@ -4,6 +4,9 @@ class BarcodeReader(DeviceBase):
|
||||
|
||||
def doInitialize(self):
|
||||
self.disable()
|
||||
self.readout = None
|
||||
self.processing = False
|
||||
self.task_callable=None
|
||||
|
||||
def enable(self):
|
||||
microscan_cmd.write("<H>")
|
||||
@@ -17,6 +20,7 @@ class BarcodeReader(DeviceBase):
|
||||
self.state.assertReady()
|
||||
try:
|
||||
self.setState(State.Busy)
|
||||
microscan.flush()
|
||||
ret = microscan.waitString(int(timeout * 1000))
|
||||
self.setCache(ret, None)
|
||||
return ret
|
||||
@@ -31,17 +35,38 @@ class BarcodeReader(DeviceBase):
|
||||
|
||||
|
||||
def read(self,timeout=1.0):
|
||||
initial = self.state
|
||||
if initial == State.Disabled:
|
||||
self.enable()
|
||||
if self.processing:
|
||||
raise Exception("Ongoing read operation")
|
||||
self.processing = True
|
||||
try:
|
||||
return self.get()
|
||||
finally:
|
||||
initial = self.state
|
||||
if initial == State.Disabled:
|
||||
self.disable()
|
||||
|
||||
|
||||
self.enable()
|
||||
try:
|
||||
return self.get(timeout)
|
||||
finally:
|
||||
if initial == State.Disabled:
|
||||
self.disable()
|
||||
finally:
|
||||
self.processing = False
|
||||
|
||||
def _read_task(self, timeout):
|
||||
global readout
|
||||
self.readout = self.read(timeout)
|
||||
return self.readout
|
||||
|
||||
def start_read(self, timeout=1.0):
|
||||
self.readout = None
|
||||
self.task_callable = fork((self._read_task, (timeout,)))
|
||||
|
||||
def get_readout(self):
|
||||
return self.readout
|
||||
|
||||
def wait_readout(self):
|
||||
if self.task_callable is not None:
|
||||
join(self.task_callable)
|
||||
self.task_callable = None
|
||||
return self.readout
|
||||
|
||||
|
||||
add_device(BarcodeReader("barcode_reader"), force = True)
|
||||
|
||||
@@ -19,12 +19,11 @@ simulation = False
|
||||
|
||||
joint_forces = False
|
||||
|
||||
|
||||
class RobotSC(RobotTCP):
|
||||
def __init__(self, name, server, timeout = 1000, retries = 1):
|
||||
RobotTCP.__init__(self, name, server, timeout, retries)
|
||||
self.set_tasks(["getDewar", "putDewar", "putGonio", "getGonio", "robotRecover", "moveDewar", "movePark", "moveGonio","moveHeater", "moveScanner"])
|
||||
self.set_known_points(["pHome", "pPark", "pDewarHome", "pGonioHome", "pDewarWait", "pGonioGet", "pScanHome", "pHeaterHome", "pHeater", "pHeaterBottom"])
|
||||
self.set_known_points(["pHome", "pPark", "pDewarHome", "pGonioHome", "pDewarWait", "pGonioGet", "pScanHome", "pHeaterHome", "pHeater", "pHeaterBottom", "pScanStop"])
|
||||
self.setPolling(DEFAULT_ROBOT_POLLING)
|
||||
|
||||
def move_dewar(self):
|
||||
@@ -60,6 +59,16 @@ class RobotSC(RobotTCP):
|
||||
self.wait_task_finished(TASK_WAIT_ROBOT_POLLING)
|
||||
self.assert_scanner()
|
||||
|
||||
def move_scanner(self):
|
||||
self.start_task('moveScanner')
|
||||
self.wait_task_finished(TASK_WAIT_ROBOT_POLLING)
|
||||
self.assert_scanner()
|
||||
|
||||
#def do_scan(self):
|
||||
# self.start_task('doScan')
|
||||
# self.wait_task_finished(TASK_WAIT_ROBOT_POLLING)
|
||||
# self.assert_scan_stop()
|
||||
|
||||
def move_gonio(self):
|
||||
self.start_task('moveGonio')
|
||||
self.wait_task_finished(TASK_WAIT_ROBOT_POLLING)
|
||||
@@ -156,6 +165,9 @@ class RobotSC(RobotTCP):
|
||||
def is_scanner(self):
|
||||
return self.is_in_point("pScanHome")
|
||||
|
||||
#def is_scan_stop(self):
|
||||
# return self.is_in_point("pScanStop")
|
||||
|
||||
def is_cleared(self):
|
||||
#return self.is_home() or self.is_park() or self.is_dewar() or self.is_dewar_home()
|
||||
return self.get_current_point() is not None
|
||||
@@ -187,9 +199,15 @@ class RobotSC(RobotTCP):
|
||||
def assert_scanner(self):
|
||||
self.assert_in_point("pScanHome")
|
||||
|
||||
#def assert_scan_stop(self):
|
||||
# self.assert_in_point("pScanStop")
|
||||
|
||||
def assert_cleared(self):
|
||||
if not self.is_cleared():
|
||||
raise Exception("Robot not in cleared position")
|
||||
raise Exception("Robot not in cleared position")
|
||||
|
||||
def wait_ready(self):
|
||||
robot.waitState(State.Ready, 1000) #robot.state.assertReady()
|
||||
|
||||
if simulation:
|
||||
#add_device(RobotSC("robot","129.129.126.92:1000"),force = True)
|
||||
@@ -234,9 +252,4 @@ if joint_forces:
|
||||
add_device(jf4(), force = True)
|
||||
add_device(jf5(), force = True)
|
||||
add_device(jf6(), force = True)
|
||||
add_device(jfc(), force = True)
|
||||
|
||||
|
||||
|
||||
|
||||
"""
|
||||
add_device(jfc(), force = True)
|
||||
@@ -3,6 +3,7 @@ import threading
|
||||
FRAME_DEFAULT = "world"
|
||||
FLANGE = "flange"
|
||||
|
||||
MAX_NUMBER_PARAMETERS = 20
|
||||
|
||||
run("devices/RobotMotors")
|
||||
|
||||
@@ -129,7 +130,7 @@ class RobotTCP(TcpDevice, Stoppable):
|
||||
def execute(self, command, *args, **kwargs):
|
||||
timeout = None if (kwargs is None) or (not kwargs.has_key("timeout")) else kwargs["timeout"]
|
||||
msg = str(command)
|
||||
if len(args)>10:
|
||||
if len(args)>MAX_NUMBER_PARAMETERS:
|
||||
raise Exception("Exceeded maximum number of parameters")
|
||||
for i in range(len(args)):
|
||||
msg += (self.cmd_separator if (i==0) else self.array_separator) + str(args[i])
|
||||
@@ -671,7 +672,7 @@ class RobotTCP(TcpDevice, Stoppable):
|
||||
#for task in tasks:
|
||||
# if self.get_task_status(task)[0]>=0:
|
||||
# raise Exception("Ongoing high-level task: " + task)
|
||||
ts = robot.get_tasks_status(*tasks)
|
||||
ts = self.get_tasks_status(*tasks)
|
||||
for i in range(len(ts)):
|
||||
if ts[i] > 0:
|
||||
raise Exception("Ongoing high-level task: " + tasks[i])
|
||||
|
||||
@@ -10,7 +10,7 @@ class SmartMagnet(DeviceBase):
|
||||
}))
|
||||
|
||||
def doInitialize(self):
|
||||
DeviceBase.doInitialize(self)
|
||||
super(SmartMagnet, self).doInitialize()
|
||||
self.get_current()
|
||||
|
||||
def set_current(self, current):
|
||||
@@ -93,7 +93,7 @@ class SmartMagnet(DeviceBase):
|
||||
def set_remanence_current(self):
|
||||
self.set_current(self.config.getFieldValue("remanenceCurrent"))
|
||||
|
||||
def set_default_current():
|
||||
def set_default_current(self):
|
||||
if self.is_mounted():
|
||||
self.set_holding_current()
|
||||
else:
|
||||
|
||||
Reference in New Issue
Block a user