1 from __future__
import division, absolute_import
3 from twistedActor
import CommandError
5 __all__ = [
"getRestart"]
11 for key, val
in _TranslateDict.items():
12 _TranslateDict[
"no" + key] =
"no" + val
13 _AllAxesList = (
"azimuth",
"altitude",
"rotator")
16 """!Get a list of axes from the /Restart qualifier
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"
21 Useful because the parser returns the data as named axes and the names are negatable.
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)
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.
34 AxisExists = (
True,
True, rotExists)
35 if not qual.boolValue:
38 if not qual.valueListDefaulted:
39 raise CommandError(
"No axis specification allowed when using /NoRestart")
40 return (
False,
False,
False)
43 allSpecified = qual.valueListDefaulted
and not qual.boolValueDefaulted
46 for val
in qual.valueList:
48 val = _TranslateDict.get(val, val)
54 elif val.startswith(
"no"):
55 noAxisSet.add(val[2:])
60 conflictSet = axisSet.intersection(noAxisSet)
62 raise CommandError(
"Conflicting values in /Restart: %s" % (qual.valueList,))
65 axisSet = set(_AllAxesList) - noAxisSet
66 elif not axisSet
and noAxisSet:
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.