Документ взят из кэша поисковой машины. Адрес оригинального документа : http://www.apo.nmsu.edu/Telescopes/TCC/html/cmd_2axis_8py_source.html
Дата изменения: Tue Sep 15 02:25:37 2015
Дата индексирования: Sun Apr 10 01:33:51 2016
Кодировка:

Поисковые слова: дисперсия скоростей
lsst.tcc: python/tcc/cmd/axis.py Source File
lsst.tcc  1.2.2-3-g89ecb63
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
axis.py
Go to the documentation of this file.
1 from __future__ import division, absolute_import
2 """For TCC AXIS command
3 
4 note: currently not checking for a axis command of the type rot, norot
5 in this case rot is ignored
6 """
7 from twistedActor import CommandError
8 
9 __all = ["axis"]
10 
11 def axis(tccActor, userCmd):
12  """Execute the axis command
13 
14  @param[in,out] tccActor tcc actor
15  @param[in,out] userCmd axis command
16  """
17  cmdVerb = userCmd.parsedCmd.paramDict['command'].valueList[0].keyword.lower()
18  # dict of commanded axis name: axis name in tccActor.axisDevSet
19  matchDict = dict(
20  azimuth = "az",
21  altitude = "alt",
22  rotator = "rot",
23  )
24  checkExist = not userCmd.parsedCmd.qualDict['nocheck'].boolValue
25 
26  axisCmdNameList = [axis.keyword.lower() for axis in userCmd.parsedCmd.paramDict['axes'].valueList]
27  yesAxisCmdNameSet = set()
28  noAxisCmdNameSet = set()
29  allSpecified = False
30  for axisCmdName in axisCmdNameList:
31  if axisCmdName.startswith("no"):
32  if axisCmdName == "noall":
33  continue # NoAll is a no-op
34  noAxisCmdNameSet.add(axisCmdName[2:]) # skip the No prefix
35  elif axisCmdName == "all":
36  allSpecified = True
37  # don't update yesAxisCmdNameSet until after checking for conflicts
38  else:
39  # handle explicit requests for invalid axes now, before handling all; later just skip nonexistent axes
40  if checkExist:
41  if tccActor.axisDevSet[matchDict[axisCmdName]] is None:
42  raise CommandError("Axis %s does not exist" % (axisCmdName,))
43  yesAxisCmdNameSet.add(axisCmdName)
44 
45  # report conflicts (before applying All, since All means "all available axes that are not explicitly negated")
46  if yesAxisCmdNameSet & noAxisCmdNameSet:
47  raise CommandError("Conflicting axis name in %s" % axisCmdNameList)
48 
49  if allSpecified:
50  yesAxisCmdNameSet = set(matchDict.keys())
51  netAxisCmdNameSet = yesAxisCmdNameSet - noAxisCmdNameSet
52  slotList = [matchDict[cmdName] for cmdName in netAxisCmdNameSet if tccActor.axisDevSet[matchDict[cmdName]]]
53  if not slotList:
54  raise CommandError("No axes to command")
55 
56  # sort out qualifiers
57  kwargs = dict(
58  slotList=slotList,
59  userCmd=userCmd,
60  )
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)
75  else:
76  raise CommandError("Bug: unrecognized axis command verb %r in %r" % (cmdVerb, userCmd.cmdStr))
77  return True
def axis
Definition: axis.py:11