diff --git a/config/config.properties b/config/config.properties index 55413bb..35b08b2 100644 --- a/config/config.properties +++ b/config/config.properties @@ -1,4 +1,4 @@ -#Wed Feb 22 10:47:40 CET 2017 +#Wed Feb 22 14:10:46 CET 2017 autoSaveScanData=true createSessionFiles=false dataLayout=default @@ -24,5 +24,5 @@ userAuthenticator= userManagement=false versionTrackingEnabled=true versionTrackingLogin={context}/svcusr-hlapp_robot -versionTrackingManual=true +versionTrackingManual=false versionTrackingRemote=git@git.psi.ch\:pshell_config/mxsc.git diff --git a/robot/MXLAB/Controller1/usr/usrapp/ForceDetection/ForceDetection.dtx b/robot/MXLAB/Controller1/usr/usrapp/ForceDetection/ForceDetection.dtx index b59ee63..d4e1748 100644 --- a/robot/MXLAB/Controller1/usr/usrapp/ForceDetection/ForceDetection.dtx +++ b/robot/MXLAB/Controller1/usr/usrapp/ForceDetection/ForceDetection.dtx @@ -83,5 +83,8 @@ + + + \ No newline at end of file diff --git a/robot/MXLAB/Controller1/usr/usrapp/ForceDetection/comTcp.pgx b/robot/MXLAB/Controller1/usr/usrapp/ForceDetection/comTcp.pgx index 8aab98e..4dce337 100644 --- a/robot/MXLAB/Controller1/usr/usrapp/ForceDetection/comTcp.pgx +++ b/robot/MXLAB/Controller1/usr/usrapp/ForceDetection/comTcp.pgx @@ -14,11 +14,13 @@ + 0 @@ -43,31 +45,35 @@ else msg = right(rx, len(rx)-4) rx="" - for index=0 to 9 - args[index]="" - endFor - index = find(msg, " ") - if index < 0 - cmd = msg - else - cmd = left(msg, index) - msg = right(msg, len(msg) - index -1) - arg=0 - while (len(msg) > 0 and (arg < 10)) - index = find(msg, array_separator) - if index<0 - args[arg] = msg - msg ="" - else - args[arg] = left(msg, index) - msg = right(msg, len(msg) - index -1) - endIf - arg = arg+1 - endWhile - endIf - tx = "" - ex = "" - call onCommandTcp(cmd,args, tx, ex) + //If same id, repeat last answer + if msg_id != last_id + for index=0 to 9 + args[index]="" + endFor + index = find(msg, " ") + if index < 0 + cmd = msg + else + cmd = left(msg, index) + msg = right(msg, len(msg) - index -1) + arg=0 + while (len(msg) > 0 and (arg < 10)) + index = find(msg, array_separator) + if index<0 + args[arg] = msg + msg ="" + else + args[arg] = left(msg, index) + msg = right(msg, len(msg) - index -1) + endIf + arg = arg+1 + endWhile + endIf + tx = "" + ex = "" + call onCommandTcp(cmd,args, tx, ex) + last_id = msg_id + endIf if len(ex) == 0 sSio = msg_id + tx else diff --git a/robot/MXLAB/Controller1/usr/usrapp/ForceDetection/onCommandTcp.pgx b/robot/MXLAB/Controller1/usr/usrapp/ForceDetection/onCommandTcp.pgx index 0af5c5a..3848c8b 100644 --- a/robot/MXLAB/Controller1/usr/usrapp/ForceDetection/onCommandTcp.pgx +++ b/robot/MXLAB/Controller1/usr/usrapp/ForceDetection/onCommandTcp.pgx @@ -12,19 +12,87 @@ + + + diff --git a/script/local.py b/script/local.py index 2ca406b..22687aa 100644 --- a/script/local.py +++ b/script/local.py @@ -16,8 +16,7 @@ class RobotTCP(TcpDevice): self.trailer = "\n" self.array_separator = '|' self.cmd_separator = ' ' - self.msg_id = 0 - self.setPolling(1000) + self.msg_id = 0 def _sendReceive(self, msg_id, msg = ""): tx = self.header if (self.header != None) else "" @@ -59,19 +58,42 @@ class RobotTCP(TcpDevice): if ev.strip() == "": return None return ev - def eval(self, cmd): + def evaluate(self, cmd): return self.execute('eval', cmd) + def get_var(self, name): + return self.execute('get_var', name) + + def get_arr(self, name, size): + return self.execute('get_arr', name, size) + + def get_int(self): + return int(self.get_var("n")) + + def eval_int(self, cmd): + ret = self.execute('eval', "n=" + cmd) + if ret.strip() != "": + raise Exception(ret) + return self.get_int() + + def get_move_id(): + self.eval_int("getMoveId()") + def mount(self, puck, sample): return self.execute('mount', puck, sample) def doUpdate(self): - ev = self.read_event() + ev = None + try: + ev = self.read_event() + self.setState(State.Ready) + except: + self.setState(State.Offline) if ev is not None: self.getLogger().info(ev) add_device(RobotTCP("robot_tcp", "129.129.126.100:1000"), force = True) - +robot_tcp.setPolling(500)