This commit is contained in:
gac-S_Changer
2018-06-04 16:45:52 +02:00
parent 367822409c
commit 145ac05116
2 changed files with 24 additions and 16 deletions

View File

@@ -25,7 +25,7 @@ class RobotSC(RobotTCP):
RobotTCP.__init__(self, name, server, timeout, retries)
self.set_tasks(["getDewar", "putDewar", "putGonio", "getGonio", "robotRecover", "moveDewar", "movePark"])
self.setPolling(DEFAULT_ROBOT_POLLING)
self.known_points = ["pHome", "pPark", "pDewarHome", "pGonioHome", "pDewarWait"]
self.known_points = ["pHome", "pPark", "pDewarHome", "pGonioHome", "pDewarWait", "pGonioGet", "pScanHome", "pHeaterHome"]
def get_dewar(self, segment, puck, sample):
segment = self.toSegmentNumber(segment)
@@ -145,6 +145,7 @@ class RobotSC(RobotTCP):
if ret[i] == True:
return self.known_points[i]
return None
if simulation:

View File

@@ -484,19 +484,20 @@ class RobotTCP(TcpDevice, Stoppable):
def doUpdate(self):
try:
start = time.time()
sts = self.execute("get_status", self.current_task)
cur_task = self.current_task #Can change in background so cache it
sts = self.execute("get_status", cur_task)
self._update_working_mode(int(sts[0]), int(sts[1]))
self.powered = sts[2] == "1"
self.speed = int(sts[3])
self.empty = sts[4] == "1"
self.settled = sts[5] == "1"
if int(sts[6]) < 0:
if self.current_task is not None:
log("Task "+ str(self.current_task) + " finished with code: " + str(sts[7]), False)
try:
self.current_task, self.current_task_ret = None, int(sts[7])
except:
self.current_task, self.current_task_ret = None, None
self.settled = sts[5] == "1"
if cur_task is not None:
if int(sts[6]) < 0:
log("Task "+ str(cur_task) + " finished with code: " + str(sts[7]), False)
try:
self.current_task, self.current_task_ret = None, int(sts[7])
except:
self.current_task, self.current_task_ret = None, None
for i in range(6):
self.joint_pos[i] = float(sts[8 + i])
for i in range(6):
@@ -514,7 +515,7 @@ class RobotTCP(TcpDevice, Stoppable):
"speed": self.speed,
"empty": self.empty,
"settled": self.settled,
"task": self.current_task,
"task": cur_task,
"mode": self.working_mode,
"status": self.status
}, None)
@@ -651,12 +652,13 @@ class RobotTCP(TcpDevice, Stoppable):
self.task_create(program, *args, **kwargs)
(code, status) = self.get_task_status(program)
if code>=0: break
if i < retries-1:
ret = self.get_task_ret()
if i < self.task_start_retries-1:
ret = self.get_task_ret(False)
if ret == 0: #Did't start
log("Retrying starting : " + str(program) + " - status: " + str(status) + " (" + str(code) + ")", False)
print "Retrying starting : " + str(program) + " - status: " + str(status) + " (" + str(code) + ")"
else :
print "Retrying aborted : " + str(program) + " - ret: " + str(ret) + " - status: " + str(status) + " (" + str(code) + ")"
break
else:
log("Failed starting : " + str(program), False)
@@ -668,6 +670,12 @@ class RobotTCP(TcpDevice, Stoppable):
self.current_task, self.current_task_ret = program, None
self.update()
#self._update_state()
#TODO: remove
if self.current_task is None:
log("Task finished in first polling : " + str(program) , False)
print "Task finished in first polling : " + str(program)
return code
def stop_task(self):
@@ -679,9 +687,8 @@ class RobotTCP(TcpDevice, Stoppable):
self.task_kill(task)
def get_task_ret(self):
#return self.eval_int("tcp_ret")
return self.current_task_ret
def get_task_ret(self, cached = True):
return self.current_task_ret if cached else self.eval_int("tcp_ret")
def clear_task_ret(self):
return self.evaluate("tcp_ret=0")