Startup
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -83,5 +83,8 @@
|
||||
<Value key="0" link="Socket\sSIO" />
|
||||
</Data>
|
||||
<Data name="events" access="private" xsi:type="array" type="string" size="10" />
|
||||
<Data name="n" access="private" xsi:type="array" type="num" size="1" />
|
||||
<Data name="arr" access="private" xsi:type="array" type="num" size="10" />
|
||||
<Data name="b" access="private" xsi:type="array" type="bool" size="1" />
|
||||
</Datas>
|
||||
</Database>
|
||||
@@ -14,11 +14,13 @@
|
||||
<Local name="arg" type="num" xsi:type="array" size="1" />
|
||||
<Local name="ex" type="string" xsi:type="array" size="1" />
|
||||
<Local name="array_separator" type="string" xsi:type="array" size="1" />
|
||||
<Local name="last_id" type="string" xsi:type="array" size="1" />
|
||||
</Locals>
|
||||
<Code><![CDATA[begin
|
||||
rx=""
|
||||
sioCtrl(sSio,"timeout",1)
|
||||
sioCtrl(sSio, "endOfString", 10)
|
||||
rx=""
|
||||
last_id = ""
|
||||
sioCtrl(sSio,"timeout",1)
|
||||
sioCtrl(sSio, "endOfString", 10)
|
||||
array_separator = "|"
|
||||
while true
|
||||
while sioGet(sSio,rec_val) >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
|
||||
|
||||
@@ -12,19 +12,87 @@
|
||||
<Local name="puck" type="num" xsi:type="array" size="1" />
|
||||
<Local name="sample" type="num" xsi:type="array" size="1" />
|
||||
<Local name="bOk" type="bool" xsi:type="array" size="1" />
|
||||
<Local name="aux" type="num" xsi:type="array" size="1" />
|
||||
<Local name="ret" type="num" xsi:type="array" size="1" />
|
||||
<Local name="count" type="num" xsi:type="array" size="1" />
|
||||
</Locals>
|
||||
<Code><![CDATA[begin
|
||||
switch(cmd)
|
||||
case "eval"
|
||||
tx=$exec(cmd)
|
||||
break
|
||||
tx=$exec(args[0])
|
||||
|
||||
// if (find(cmd,"numRet")!=-1)
|
||||
// stringReturn = stringReturn+toString("4.4",numRet)
|
||||
// call notify:setString("NumericalReturn",toString("4.4",numRet))
|
||||
// endIf
|
||||
// if (find(cmd,"Power")!=-1)
|
||||
// call notify:setBool("IsPowered",isPowered())
|
||||
// endIf
|
||||
|
||||
// for i=0 to len(stringReturn)-1 step 1
|
||||
// numericalReturn[i]=asc(stringReturn,i)
|
||||
// endFor
|
||||
|
||||
|
||||
break
|
||||
case "get_var"
|
||||
ret = getData(args[0], aux)
|
||||
switch(ret)
|
||||
case -1
|
||||
ex = "The variable does not exists"
|
||||
break
|
||||
case -2
|
||||
ex = "The variable library does not exists"
|
||||
break
|
||||
case -3
|
||||
ex = "The index is out of range"
|
||||
break
|
||||
case -4
|
||||
ex = "The data's type does not match the variable's type"
|
||||
break
|
||||
default
|
||||
tx = toString(".4", ret)
|
||||
break
|
||||
endSwitch
|
||||
break
|
||||
|
||||
case "get_arr"
|
||||
toNum(args[1], count, bOk)
|
||||
tx = ""
|
||||
for index = 0 to count
|
||||
ret = getData(args[0] + "[" + toString("", index )+ "]", aux)
|
||||
switch(ret)
|
||||
case -1
|
||||
ex = "The variable does not exists"
|
||||
return
|
||||
break
|
||||
case -2
|
||||
ex = "The variable library does not exists"
|
||||
return
|
||||
break
|
||||
case -3
|
||||
ex = "The index is out of range"
|
||||
return
|
||||
break
|
||||
case -4
|
||||
ex = "The data's type does not match the variable's type"
|
||||
return
|
||||
break
|
||||
default
|
||||
tx = tx + toString(".4", ret) + "|"
|
||||
break
|
||||
endSwitch
|
||||
endFor
|
||||
break
|
||||
|
||||
|
||||
case "mount"
|
||||
toNum(args[0], puck, bOk)
|
||||
toNum(args[1], sample, bOk)
|
||||
tx = "Mounting sample " + toString("", puck) + ":" + toString("", sample)
|
||||
break
|
||||
default
|
||||
ex = "Invalid command: " + cmd
|
||||
ex = "Invalid command: " + cmd
|
||||
break
|
||||
endSwitch
|
||||
end]]></Code>
|
||||
|
||||
@@ -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)
|
||||
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user