1 from __future__
import division, absolute_import
2 """For TCC AXIS command
4 note: currently not checking for a axis command of the type rot, norot
5 in this case rot is ignored
7 from twistedActor
import CommandError
11 def axis(tccActor, userCmd):
12 """Execute the axis command
14 @param[in,out] tccActor tcc actor
15 @param[in,out] userCmd axis command
17 cmdVerb = userCmd.parsedCmd.paramDict[
'command'].valueList[0].keyword.lower()
24 checkExist =
not userCmd.parsedCmd.qualDict[
'nocheck'].boolValue
26 axisCmdNameList = [axis.keyword.lower()
for axis
in userCmd.parsedCmd.paramDict[
'axes'].valueList]
27 yesAxisCmdNameSet = set()
28 noAxisCmdNameSet = set()
30 for axisCmdName
in axisCmdNameList:
31 if axisCmdName.startswith(
"no"):
32 if axisCmdName ==
"noall":
34 noAxisCmdNameSet.add(axisCmdName[2:])
35 elif axisCmdName ==
"all":
41 if tccActor.axisDevSet[matchDict[axisCmdName]]
is None:
42 raise CommandError(
"Axis %s does not exist" % (axisCmdName,))
43 yesAxisCmdNameSet.add(axisCmdName)
46 if yesAxisCmdNameSet & noAxisCmdNameSet:
47 raise CommandError(
"Conflicting axis name in %s" % axisCmdNameList)
50 yesAxisCmdNameSet = set(matchDict.keys())
51 netAxisCmdNameSet = yesAxisCmdNameSet - noAxisCmdNameSet
52 slotList = [matchDict[cmdName]
for cmdName
in netAxisCmdNameSet
if tccActor.axisDevSet[matchDict[cmdName]]]
54 raise CommandError(
"No axes to command")
61 if userCmd.parsedCmd.qualDict[
'timelimit'].boolValue:
62 kwargs[
"timeLim"] = userCmd.parsedCmd.qualDict[
'timelimit'].valueList[0]
63 if cmdVerb ==
"initialize":
64 tccActor.axisDevSet.connectOrInit(**kwargs)
65 elif cmdVerb ==
"reset":
66 tccActor.axisDevSet.stop(**kwargs)
67 elif cmdVerb ==
"status":
68 tccActor.axisDevSet.status(**kwargs)
69 elif cmdVerb ==
"stop":
70 tccActor.axisDevSet.stop(**kwargs)
71 elif cmdVerb ==
"connect":
72 tccActor.axisDevSet.connect(**kwargs)
73 elif cmdVerb ==
"disconnect":
74 tccActor.axisDevSet.disconnect(**kwargs)
76 raise CommandError(
"Bug: unrecognized axis command verb %r in %r" % (cmdVerb, userCmd.cmdStr))