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

Поисковые слова: п п п
lsst.tcc: python/tcc/parse/getRestart.py Source File
lsst.tcc  1.2.2-3-g89ecb63
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
getRestart.py
Go to the documentation of this file.
1 from __future__ import division, absolute_import
2 
3 from twistedActor import CommandError
4 
5 __all__ = ["getRestart"]
6 
7 _TranslateDict = {
8  "tel1": "azimuth",
9  "tel2": "altitude",
10 }
11 for key, val in _TranslateDict.items():
12  _TranslateDict["no" + key] = "no" + val
13 _AllAxesList = ("azimuth", "altitude", "rotator")
14 
15 def getRestart(qual, rotExists):
16  """!Get a list of axes from the /Restart qualifier
17 
18  @todo: tweak this once we figure out how the parser handles /Restart vs /Restart=();
19  for now assume that the values are [] if present with no values and treat this as "all"
20 
21  Useful because the parser returns the data as named axes and the names are negatable.
22 
23  @param[in] qual the parsed /Restart qualifier
24  @param[in] rotExists does the current instrument have a rotator?
25  If False, the returned restartRot is always false (even if the user requested restarting the rotator)
26  @return a tuple of 3 booleans: (restartAz, restartAlt, restartRot).
27  If /Restart is omitted or specified with no values then return the default for the qualifier
28  (but set restartRot false if rotExists false)
29 
30  @throw twistedActor.CommandError if an axis is explicitly specified and negated, e.g. /Restart=(Az, NoAz);
31  the test ignores "all" and "noall" (they are not explicit), so this is permitted: /Restart=(All, NoAz)
32  Also raise a CommandError if a /NoRestart qualifier was used with any axis.
33  """
34  AxisExists = (True, True, rotExists)
35  if not qual.boolValue:
36  # handle /NoRestart
37  # don't allow any axis specification:
38  if not qual.valueListDefaulted:
39  raise CommandError("No axis specification allowed when using /NoRestart")
40  return (False, False, False)
41 
42  # parse axis names; the default is /All if /Restart specified with no values
43  allSpecified = qual.valueListDefaulted and not qual.boolValueDefaulted
44  axisSet = set() # names of axes explicitly requested (e.g. "az" or "rot" but not "all")
45  noAxisSet = set() # names of axes explicitly negated (e.g. "noaz" or "norot", but not "noall")
46  for val in qual.valueList:
47  val = val.lower()
48  val = _TranslateDict.get(val, val)
49  if val == "all":
50  allSpecified = True
51  elif val == "noall":
52  # noall has no useful effect, so ignore it
53  continue
54  elif val.startswith("no"):
55  noAxisSet.add(val[2:])
56  else:
57  axisSet.add(val)
58 
59  # reject explicit name conflicts such as /Restart=(Az, NoAz), but don't worry about All and NoAll
60  conflictSet = axisSet.intersection(noAxisSet)
61  if conflictSet:
62  raise CommandError("Conflicting values in /Restart: %s" % (qual.valueList,))
63  if allSpecified:
64  # "all" axes requested, so restart all axes except those explicitly negated
65  axisSet = set(_AllAxesList) - noAxisSet
66  elif not axisSet and noAxisSet:
67  # only recieved negated axes, all other axes should be restarted
68  axisSet = set(_AllAxesList) - noAxisSet
69  return tuple((axisName in axisSet) and AxisExists[i] for i, axisName in enumerate(_AllAxesList))
def getRestart
Get a list of axes from the /Restart qualifier.
Definition: getRestart.py:15