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

Поисковые слова: п п п п п п п
lsst.tcc: python/tcc/actor/tccCmdParser.py Source File
lsst.tcc  1.2.2-3-g89ecb63
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
tccCmdParser.py
Go to the documentation of this file.
1 from __future__ import division, absolute_import
2 """!TCC command parser
3 """
4 import tcc.parse.parseDefs as parseDefs
5 from tcc.parse.cmdParse import CmdParser
6 import tcc.cmd
7 from tcc.cmd.broadcast import MsgTypeCodeDict
8 
9 __all__ = ["TCCCmdParser"]
10 
11 # list of coordinate system keyword
12 _CoordSysList = (
13  parseDefs.Keyword(
14  name = "icrs",
15  help = "ICRS RA, Dec (deg); date is Julian date (years) of observation and defaults to 2000",
16  numValueRange = [0,1],
17  castVals=float,
18  ),
19  parseDefs.Keyword(
20  name = "fk5",
21  help = "FK5 RA, Dec (deg); date is Julian date (years) of equinox and of observation and defaults to 2000",
22  numValueRange = [0,1],
23  castVals=float,
24  defValueList=[2000.0],
25  ),
26  parseDefs.Keyword(
27  name = "fk4",
28  help = "FK4 RA, Dec (deg); date is Besselian date (years) of equinox and of observation and defaults to 1950",
29  numValueRange = [0,1],
30  castVals=float,
31  defValueList=[1950.0],
32  ),
33  parseDefs.Keyword(
34  name = "galactic",
35  help = "IAU 1958 galactic long, lat (deg); date is Julian date (years) of observation and defaults to the current date",
36  numValueRange = [0,1],
37  castVals=float,
38  ),
39  parseDefs.Keyword(
40  name = "geocentric",
41  help="apparent geocentric RA, Dec (deg); date is Julian date (years) and defaults to the current date",
42  numValueRange = [0,1],
43  castVals=float,
44  ),
45  parseDefs.Keyword(
46  name = "topocentric",
47  help="Apparent topocentric az, alt (deg) without correction for atmospheric refraction; " +
48  "date is TAI (MJD, sec) and defaults to the current date.",
49  numValueRange = [0,1],
50  castVals=float,
51  ),
52  parseDefs.Keyword(
53  name = "observed",
54  help="Refracted apparent topocentric az, alt (deg); date is TAI (MJD, sec) and defaults to the current date.",
55  numValueRange = [0,1],
56  castVals=float,
57  ),
58  parseDefs.Keyword(
59  name = "mount",
60  help="Mount coordinates (az, alt deg); note that azimuth is used as given; it is never wrapped).",
61  numValueRange = [0,0],
62  ),
63  parseDefs.Keyword(
64  name = "none",
65  help="No object; do not track.",
66  numValueRange = [0,0],
67  ),
68  parseDefs.Keyword(
69  name = "instrument",
70  help="Instrument focal plane coordinates (x, y deg, i.e. relative to nominal center of instrument).",
71  numValueRange = [0,0],
72  ),
73  parseDefs.Keyword(
74  name = "gImage",
75  help="Guide image focal plane coordinates (x, y unbinned pixels, " +
76  "where 0.5, 0.5 is the center of the lower left pixel of the CCD); " +
77  "accepts one value: the guide probe number, which defaults to 0",
78  numValueRange = [1,1],
79  defValueList = [1],
80  castVals=int,
81  ),
82  parseDefs.Keyword(
83  name = "gProbe",
84  help="Guide probe focal plane coordinates (x, y deg, i.e. relative to nominal center of guide problem); " +
85  "accepts one value: the guide probe number, which defaults to 0",
86  numValueRange = [1,1],
87  defValueList = [1],
88  castVals=int,
89  ),
90  parseDefs.Keyword(
91  name = "ptCorr",
92  help="Pointing correction (x, y deg): the same as rotator x, y except that x is along the direction of increasing az",
93  numValueRange = [0,0],
94  ),
95  parseDefs.Keyword(
96  name = "rotator",
97  help="Rotator focal plane coordinates (x, y deg). 0,0 is the center of rotation and should be the optical axis. " +
98  "Rotator coordinates have a fixed offset and rotation angle with respect to the instrument; " +
99  "these are specified in the Inst block.",
100  numValueRange = [0,0],
101  ),
102 )
103 
105  """!TCC command parser
106  """
107  def __init__(self):
108  """!Construct a tccCmdParser
109  """
110  ########################### MULTI-USE QUALIFIERS ################################
111  TimeLimit = parseDefs.Qualifier("TimeLimit", numValueRange=[1,1], valType=float,
112  help = "Specify timeout time for communication with controllers.",
113  )
114 
115  class RestartQual(parseDefs.Qualifier):
116  def __init__(self, defValueList, helpIfOmitted):
117  """Construct a Restart qualifier.
118 
119  @param[in] helpIfOmitted describe what happens if you omit /Restart, e.g. "all axes are restarted"
120  """
121  axisList = ["all", "azimuth", "altitude", "rotator", "tel1", "tel2"]
122  fullAxisList = axisList + ["no" + axis for axis in axisList]
123  fullAxisStr = ", ".join(fullAxisList)
124 
125  parseDefs.Qualifier.__init__(self,
126  name = "restart",
127  negatable = True,
128  valType = fullAxisList,
129  numValueRange = [0, None],
130  defValueList = defValueList,
131  defBoolValue = True,
132  help = """Restart one or more axes.
133  * If omitted, %s
134  * Valid values are {%s},
135  where All restarts all axes that are not explicitly negated
136  * /Restart restarts all axes that exist
137  * /NoRestart restarts no axes
138  * If you specify one or more axes (Azimuth, Altitude and/or Rotator), only those are restarted
139  * If you specify one or more negated axes (NoAzimuth, NoAltitude and/or NoRotator)
140  those are left halted, and the other axes are restarted as per the rules above
141  * If there is no instrument rotator, Rotator is silently ignored
142  * Conflicts such as /Restart=(Az, NoAz) are prohibited (but All is acceptable with negated axes)
143  * Examples:
144  /Restart or /Restart=All: restart all axes
145  /Restart=Az: restart only azimuth
146  /Restart=NoRot: restart the default axes, excluding the rotator
147  /NoRestart: restart no axes""" % (helpIfOmitted, fullAxisStr),
148  )
149 
150  Perfect = parseDefs.Qualifier(
151  name = "perfect",
152  help = "Prevents the requested move from happening unless all axes can be moved.",
153  )
154 
155  class AbsRefCorrect(parseDefs.Qualifier):
156  def __init__(self, defBoolValue):
157  parseDefs.Qualifier.__init__(self,
158  name = "absRefCorrect",
159  negatable = True,
160  help = "Specifies whether or not to apply absolute encoder corrections during a move.",
161  defBoolValue = defBoolValue,
162  )
163 
164  class RefCoefficients(parseDefs.Qualifier):
165  def __init__(self, defBoolValue):
166  parseDefs.Qualifier.__init__(self,
167  name = "refCoefficients",
168  negatable = True,
169  help = "Specifies whether to update the refraction coefficients in the obj and/or gs block.",
170  defBoolValue=defBoolValue,
171  )
172 
173  class Collimate(parseDefs.Qualifier):
174  def __init__(self, defBoolValue):
175  parseDefs.Qualifier.__init__(self,
176  name = "collimate",
177  negatable = True,
178  help = "Specifies whether to update the position of the mirrors to maintain " \
179  "collimation as a function of temperature and altitude position.",
180  defBoolValue=defBoolValue,
181  )
182 
183  Stop = parseDefs.Qualifier(
184  name = "stop",
185  help = "The instrument rotator will be gently stopped.",
186  )
187 
188  class WrapPref(parseDefs.Qualifier):
189  def __init__(self, name, axisName, defValue):
190  parseDefs.Qualifier.__init__(self,
191  name = name,
192  valType = ["nearest", "middle", "negative", "positive"],
193  numValueRange = [1, 1],
194  defValueList = (defValue,),
195  help = """Specify the desired wrap for the %s; valid values are:
196 - Nearest: use the angle nearest to the current position. This is the default for /AzWrap and is also used for all offsets (except for offsets in mount coordinates, of course).
197 - Middle: use the angle nearest the center of the range of motion. For example, if the range of motion is -190 to +370, the middle wrap range is -90 to +270. This is the default for /RotWrap (except during offsets), to reduce the odds that an exposure will be halted because the rotator hits a limit.
198 - Negative use the smaller angle. For example, if the range of motion is -190 to +370, the wrap range is -190 to +170. See the notes for details.
199 - Positive: use the larger angle. For example, if the range of motion is -190 to +370, the positive wrap range is 10 to 370. See the notes for details.
200 
201 Notes:
202 - Nearest is the only wrap preference that pays any attention to the current position.
203 - The positive and negative wrap ranges are as follows:
204  - If range of motion < 720 degrees then postive/negative wrap extends from the forward/reverse limit through -/+ 360 degrees.
205  - If range of motion > 720 degrees then positive/negative wrap extends from the center of the range of motion through +/- 360 degrees.
206 """ % (axisName,),
207  )
208 
209  RotWrap = WrapPref(name="rotWrap", axisName="instrument rotator", defValue="middle")
210 
211  AzWrap = WrapPref(name="azWrap", axisName="azimuth axis", defValue="nearest")
212 
213  Input = parseDefs.Qualifier(
214  name = "input",
215  numValueRange = [1,1],
216  valType=str,
217  help = "The specified file is used for input.",
218  )
219 
220  NoRead = parseDefs.Qualifier(
221  name = "noRead",
222  negatable = False,
223  help = "Ignore existing values",
224  )
225 
226  Name = parseDefs.Qualifier(
227  name = "name",
228  valType = str,
229  numValueRange = [1,1],
230  help = "The name of the object.",
231  )
232 
233  Magnitude = parseDefs.Qualifier(
234  name = "magnitude",
235  numValueRange = [1,1],
236  valType = float,
237  defValueList = ('NaN',),
238  help = "Object brightness.",
239  )
240 
241  Distance = parseDefs.Qualifier(
242  name = "distance",
243  numValueRange = [1,1],
244  valType = float,
245  help = "distance to object in au.",
246  )
247 
248  PM = parseDefs.Qualifier(
249  name = "pm",
250  numValueRange = [2,2],
251  valType = float,
252  defValueList = (0,0),
253  help = "Proper motion in arcseconds/century. Equatorial proper motion is dEquatAng/dt, " + \
254  "so it gets large near the pole",
255  )
256 
257  Px = parseDefs.Qualifier(
258  name = "px",
259  numValueRange = [1,1],
260  valType = float,
261  defValueList = (0,),
262  help = "Parallax in arcseconds.",
263  )
264 
265  RV = parseDefs.Qualifier(
266  name = "rv",
267  numValueRange = [1,1],
268  valType = float,
269  defValueList = (0,),
270  help = "Radial velocity in km/s, positive receding.",
271  )
272 
273  Output = parseDefs.Qualifier(
274  name = "output",
275  numValueRange = [1,1],
276  valType = str,
277  help = "The specified file is used for output.",
278  )
279 
280  Full = parseDefs.Qualifier(
281  name = "Full",
282  help = "Certain items return more information if /Full is used."
283  )
284  ######################## Standard Parameters ###########################
285  class CoordSet(parseDefs.ValueParam):
286  def __init__(self, name, defValueList=(), help=""):
287  parseDefs.ValueParam.__init__(self,
288  name=name,
289  castVals=float,
290  numValueRange=(0, None),
291  defValueList=defValueList,
292  help=help,
293  )
294 
295  class CoordPair(CoordSet):
296  def __init__(self, name, extraHelp=""):
297  helpList = ["""equatPos, polarPos [, equatVel, polarVel [, tai]]
298  Specifies equatorial position and, optionally, velocity and time, where:
299  - position is in degrees
300  - velocity is in degrees/sec; default is 0
301  - tai is TAI (MJD, seconds); default is the current TAI"""]
302  if extraHelp:
303  helpList.append(extraHelp)
304  CoordSet.__init__(self,
305  name=name,
306  help="\n".join(helpList),
307  )
308 
309  class CoordSys(parseDefs.KeywordParam):
310  def __init__(self, name, help, omit=()):
311  """Construct a CoordSys keyword parameter
312 
313  @param[in] name name of parameter
314  @param[in] help help string for parameter
315  @paramm[in] omit: list of coordinate systems to omit (case blind)
316  """
317  omitSet = frozenset(str.lower() for str in omit)
318  parseDefs.KeywordParam.__init__(self,
319  name = name,
320  help = help,
321  keywordDefList = [kwd for kwd in _CoordSysList if kwd.name.lower() not in omitSet],
322  )
323 
324  blockName = parseDefs.KeywordParam(
325  name = 'blockName',
326  keywordDefList = [
327  parseDefs.Keyword(name="AxeLim", help="axis limits and status bit flags"),
328  parseDefs.Keyword(name="Earth", help="earth orientation predictions"),
329  parseDefs.Keyword(name="Inst", help="instrument, rotator, guider and collimation parameters"),
330  parseDefs.Keyword(name="Obj", help="object (target) data, including position, " \
331  "offsets, refraction correction wavelength (both for the object and guiding) " \
332  "and computed values through mount position"),
333  parseDefs.Keyword(name="TelMod", help="telescope pointing model; warning: " \
334  "this uses a special format required by TPOINT"),
335  parseDefs.Keyword(name="Tune", help="performance tuning parameters"),
336  parseDefs.Keyword(name="Weath", help="weather data"),
337  ],
338  help = "Name of block (data structure)",
339  )
340 
341 
342  ######################## Command Definitions ###########################
343 
344  tccCmdList = (
345 
346  parseDefs.Command(
347  name = "axis",
348  minParAmt = 1,
349  help = "Command one or more axis controllers.",
350  callFunc = tcc.cmd.axis,
351  paramList = [
352  parseDefs.KeywordParam(
353  name = 'command',
354  keywordDefList = (
355  parseDefs.Keyword(name = "initialize", help = "Reconnect (if disconnected) and initialize the axis controller. " + \
356  "Initializing an axis halts it and puts it into a state in which it can be slewed, if possible."),
357  parseDefs.Keyword(name = "status", help = "Get axis status"),
358  parseDefs.Keyword(name = "stop", help = "Stop the axis"),
359  parseDefs.Keyword(name = "connect", help = "Connect to the axis controller"),
360  parseDefs.Keyword(name = "disconnect", help = "Disconnect from the axis controller"),
361  ),
362  help = "What to do with the axis controller."
363  ),
364  parseDefs.KeywordParam(
365  name = 'axes',
366  keywordDefList = [parseDefs.Keyword(name = item) for item in [
367  "azimuth", "altitude", "rotator", "tel1", "tel2",
368  "noAzimuth", "noAltitude", "noRotator", "noTel1", "noTel2"]
369  ] + [parseDefs.Keyword(name = "all", passMeByDefault=True)],
370  numParamRange = [0, None],
371  help = "Which axes? If omitted then all axes. tel1/tel2 is a synonym for azimuth/altitude.",
372  ),
373  ],
374  qualifierList = [
375  parseDefs.Qualifier(
376  name = "noCheck",
377  help = "Send the command to all specified controllers, without checking to see if they exist.",
378  ),
379  TimeLimit,
380  ],
381 
382  ),
383 
384  parseDefs.Command(
385  name = "broadcast",
386  minParAmt = 1,
387  help = "Broadcast a message to all users.",
388  callFunc = tcc.cmd.broadcast,
389  paramList = [
390  parseDefs.ValueParam(
391  name = "message",
392  castVals = str,
393  numValueRange=(1, 1),
394  help = "Message to broadcast (a quoted string)",
395  ),
396  ],
397  qualifierList = [
398  parseDefs.Qualifier(
399  name = "type",
400  valType = MsgTypeCodeDict.keys(),
401  numValueRange = [1, 1],
402  defValueList = ("information",),
403  defBoolValue = True,
404  help = "Message type (default is Information).",
405  ),
406  ],
407  ),
408 
409  parseDefs.Command(
410  name = "convert",
411  callFunc = tcc.cmd.convert,
412  minParAmt = 2,
413  paramList = [
414  CoordPair(name = 'fromCoords'),
415  CoordSys(
416  name = 'fromSys',
417  help = "Coordinate system from which to convert; Mount and None are not supported; " \
418  + "default date is computed from 'fromCoords' time",
419  omit = ("Mount", "None"),
420  ),
421  CoordSys(
422  name = 'toSys',
423  help = "Coordinate system to which to convert; Mount and None are not supported; " \
424  + "default date is computed from 'fromCoords' time",
425  omit = ("Mount", "None"),
426  ),
427  ],
428  qualifierList = [
429  Distance, PM, Px, RV,
430  parseDefs.Qualifier(
431  name = "zpm",
432  help = "Remove the effects of proper motion, radial velocity, and parallax to the current date " \
433  + " (zpm stands for zero proper motion).",
434  ),
435  parseDefs.Qualifier(
436  name = "useGSWavelength",
437  help = "Use the guide star wavelength instead of the object wavelength for refraction correction.",
438  )
439  ],
440  help = "Convert a position from one coordinate system to another." \
441  ),
442 
443  parseDefs.Command(
444  name = "exit",
445  callFunc = tcc.cmd.exit,
446  help = "Exit from the TCC command interpreter.",
447  ),
448 
449  parseDefs.Command(
450  name = "help",
451  help = "Print help",
452  callFunc = tcc.cmd.help,
453  paramList = [
454  parseDefs.ValueParam(
455  name = 'command',
456  castVals=str,
457  help = "command for which you want detailed help",
458  ),
459  parseDefs.ValueParam(
460  name = 'subcommand',
461  castVals=str,
462  help = "subcommand for which you want detailed help",
463  ),
464  ],
465  qualifierList = [
466  parseDefs.Qualifier(
467  name = "full",
468  help = "print full help about every command",
469  )
470  ],
471  ),
472 
473  parseDefs.Command(
474  name = "mirror",
475  help = "Command one or more mirror controllers.",
476  callFunc = tcc.cmd.mirror,
477  minParAmt = 1,
478  paramList = [
479  parseDefs.KeywordParam(
480  name = 'command',
481  help = "Mirror command",
482  keywordDefList = [
483  parseDefs.Keyword(name = "status", help = "Return controller status"),
484  parseDefs.Keyword(name = "initialize", help = "Reconnect (if disconnected) and initialize the mirror controller. " \
485  "Initializing aborts the current command (if any) and stops motion (if any)."),
486  parseDefs.Keyword(name = "connect", help = "Connect to the mirror controller"),
487  parseDefs.Keyword(name = "disconnect", help = "Disconnect from the mirror controller"),
488  ],
489  ),
490  parseDefs.KeywordParam(
491  name = 'mirrors',
492  help = "Which mirror(s) to command",
493  keywordDefList = [parseDefs.Keyword(name = item)
494  for item in ['primary', 'secondary', 'tertiary']] \
495  + [parseDefs.Keyword(name = 'all', passMeByDefault = True)],
496  numParamRange = [0, None],
497  )
498  ],
499  qualifierList = [TimeLimit],
500  ),
501 
502  parseDefs.Command(
503  name = "offset",
504  minParAmt = 1,
505  help = "Offsets the telescope in various ways in position and velocity.",
506  callFunc = tcc.cmd.offset,
507  paramList = [
508  parseDefs.KeywordParam(
509  name = 'type',
510  keywordDefList = [
511  parseDefs.Keyword(name = "arc", help = "Offset along great circle on sky (coordSys axis 1, 2, e.g. RA, Dec)."),
512  parseDefs.Keyword(name = "boresight", help = "Specify position of object on the " \
513  "instrument (in x-y axes of the instrument) (instrument x,y)."),
514  parseDefs.Keyword(name = "instPlane", help = "Old term for Boresight (instrument x,y)"),
515  parseDefs.Keyword(name = "rotator", help = "Rotator offset (1 axis)"),
516  parseDefs.Keyword(name = "calibration", help = "Local pointing correction (az, alt, rot)."),
517  parseDefs.Keyword(name = "guideCorrection", help = "Changes the guiding correction (az, alt, rot)."),
518  parseDefs.Keyword(name = "gCorrection", help = "Old term for GuideCorrection (az, alt, rot).")
519  ],
520  ),
521  CoordSet(
522  name='coordset',
523  help="""position and optionally velocity and TAI date (optional);
524  the format depends on the offset (because of varying #s of axes):
525  arc and boresight (aka instPlane) offsets have 2 axes:
526  pos1, pos2 [, vel1, vel2, [, TAI]]]
527  rotator offsets have 1 axis:
528  rotPos [, rotVel [, TAI]]
529  calibration and gCorrection offsets have 3 axes, though rotator is optional:
530  azPos, altPos [, rotPos [, azVel, altVel, [rotVel [, TAI]]]]
531  where:
532  - position is in degrees; default is 0
533  - velocity is in degrees/sec; default is 0
534  - TAI is TAI date (MJD, seconds); default is the current date""",
535  ),
536  ],
537  qualifierList = [
538  parseDefs.Qualifier(
539  "pAbsolute", help = "position is absolute",
540  ),
541  parseDefs.Qualifier(
542  "pIncremental", help = "position is incremental (the default)",
543  ),
544  parseDefs.Qualifier(
545  "vIncremental", help = "velocity is incremental",
546  ),
547  parseDefs.Qualifier(
548  "vAbsolute", help = "velocity is absolute (the default)",
549  ),
550  parseDefs.Qualifier(
551  "computed", help = "offset using a computed slew (safer for long offsets)",
552  negatable = True,
553  ),
554  # parseDefs.Qualifier( # discontinued
555  # "TDICorrection", help = "Specifies that the arc offset " \
556  # "velocity should be adjusted for drift scanning.",
557  # ), # need NoComputed?
558  # restart defaults to none
559  RestartQual(defValueList=(), helpIfOmitted="do not restart any axes"),
560  Perfect,
561  AbsRefCorrect(defBoolValue=False),
562  RefCoefficients(defBoolValue=False),
563  Collimate(defBoolValue=False),
564  ],
565  ),
566 
567  parseDefs.Command(
568  name = "ping",
569  callFunc = tcc.cmd.ping,
570  help = "test if actor is alive",
571  ),
572 
573  parseDefs.Command(
574  name = "process",
575  callFunc = tcc.cmd.process,
576  minParAmt = 1,
577  help = "Disable, enable or show the state of various background processes.",
578  paramList = [
579  parseDefs.KeywordParam(
580  name = 'command',
581  keywordDefList = [parseDefs.Keyword(name = item) for item in ['Disable', 'Enable', 'Status']],
582  ),
583  parseDefs.KeywordParam(
584  name = 'procNames',
585  numParamRange = [0, None],
586  keywordDefList = [
587  parseDefs.Keyword(name = "BrdTelPos",
588  help = "Broadcasts telescope position as UDP packets.",
589  ),
590  parseDefs.Keyword(name = "Collimate",
591  help = "Controls the mirrors to adjust focus, collimation and scale.",
592  ),
593  parseDefs.Keyword(name = "Status", help = "Regularly displays status.")
594  ],
595  ),
596  ],
597  ),
598 
599  parseDefs.Command(
600  name = "ptCorr",
601  callFunc = tcc.cmd.ptCorr,
602  minParAmt = 2,
603  paramList = [
604  CoordPair(name = "predCoords"),
605  CoordSys(
606  name = "predCoordSys",
607  help = "coordinate system from which to convert; Mount and None are not accepted",
608  omit = ("Mount", "None"),
609  ),
610  CoordPair(name = "MeasCoords"),
611  CoordSys(
612  name = "measCoordSys",
613  help = "coordinate system to which to convert; Mount and None are not accepted",
614  omit = ("Mount", "None"),
615  ),
616  ],
617  qualifierList = [
618  Distance, PM, Px, RV,
619  parseDefs.Qualifier(
620  name = "useGSWavelength",
621  help = "Use the guide star wavelength instead of the object wavelength for refraction correction.",
622  )
623  ],
624  help = "Compute pointing correction from predicted and measured star position.\n\n" +
625  "Typical usage is to specify the predicted position in ICRS or similar " +
626  "and the measured position in GuideImage, GuideProbe or Instrument coordinates. " +
627  "Allowed coordinate systems include all except Mount and None.\n\n" +
628  "The time at which the conversion is performed is the time of MeasCoords," +
629  "which should be the time at the middle of the exposure",
630  ),
631 
632  parseDefs.Command(
633  name = "queue",
634  callFunc = tcc.cmd.queue,
635  minParAmt = 1,
636  help = "Start or stop a batch job (e.g. snow). Warning: only one batch job may run at a time",
637  paramList = [
638  parseDefs.KeywordParam(
639  name = 'command',
640  keywordDefList = [
641  parseDefs.Keyword(name = "run", numValueRange=[1,1], castVals = str,
642  help = "Start the specified batch job.",
643  ),
644  parseDefs.Keyword(name = "stop", help = "Stop the current batch job."),
645  parseDefs.Keyword(name = "status", help = "Show batch queue status."),
646  parseDefs.Keyword(name = "list", help = "List the batch jobs you can run."),
647  ],
648  ),
649  ],
650  ),
651 
652  parseDefs.Command(
653  name = "quit",
654  callFunc = tcc.cmd.exit,
655  help = "Disconnect from the TCC (a synonym for exit).",
656  ),
657 
658  parseDefs.Command(
659  name = "rotate",
660  callFunc = tcc.cmd.rotate,
661  minParAmt = 0,
662  help = "Make the instrument rotator track the object, horizon, etc.",
663  paramList = [
664  parseDefs.ValueParam(
665  name = 'rotAngle',
666  numValueRange = [0,3],
667  castVals=float,
668  #defValueList = [0,0],
669  defValueList = (),
670  help = "Rotator angle as pos [, vel [, time]], where pos is in degrees, vel in deg/sec and time is TAI (MJD seconds)",
671  ),
672  parseDefs.KeywordParam(
673  name = 'rotType',
674  keywordDefList = [
675  parseDefs.Keyword(name = "None", help = "No rotation.", passMeByDefault=True),
676  parseDefs.Keyword(name = "Object",
677  help = "rotAngle is the orientation of the object with respect to the instrument."),
678  parseDefs.Keyword(name = "Horizon",
679  help = "rotAngle is the angle of the horizon with respect to the instrument."),
680  parseDefs.Keyword(name = "Mount",
681  help = "rotAngle is the angle of the rotator in the coordinate system used by the rotator controller. "\
682  "Wrap preference is ignored (unlike other rotatation types)."),
683  ],
684  ),
685  ],
686  qualifierList = [
687  Stop,
688  AbsRefCorrect(defBoolValue=False),
689  Collimate(defBoolValue=True),
690  Perfect,
691  RefCoefficients(defBoolValue=False),
692  RestartQual(defValueList=('rotator',), helpIfOmitted = "restart the rotator"),
693  RotWrap,
694  ]
695  ),
696 
697  parseDefs.CommandWrapper(
698  name = "set",
699  subCmdList = [
700  parseDefs.SubCommand(
701  parseDefs.Keyword(name="block"),
702  callFunc = tcc.cmd.setBlock,
703  minParAmt = 1,
704  paramList = [blockName],
705  qualifierList = [Input, NoRead],
706  help = """Set data in a block (data structure).
707 
708 You may set the block from a file (using /input) or set individual entries from the command line.
709 All blocks except TelMod use the following standard format:
710  fieldName one-or-more-spaces-separated-values\n" \
711 where fieldName is not case sensitive. Leading whitespace is ignored and lines that begin with # are ignored as comments""",
712  ),
713  parseDefs.SubCommand(
714  parseDefs.Keyword(
715  name="focus",
716  castVals = float,
717  numValueRange = [0,1],
718  ),
719  callFunc = tcc.cmd.setFocus,
720  qualifierList = [
721  parseDefs.Qualifier(
722  name = "incremental",
723  help = "Add the new focus offset to the existing focus offset, rather than replacing it.",
724  ),
725  ],
726  help = "Changes the user-settable focus offset for the " \
727  "secondary mirror (microns), if a new value is specified. " \
728  "Then updates collimation (if tracking or slewing).",
729  ),
730  parseDefs.SubCommand(
731  parseDefs.Keyword(
732  name = "imcenter",
733  castVals = float,
734  numValueRange = [2,2],
735  ),
736  callFunc = tcc.cmd.setImCenter,
737  help="Set a new image center (specified in unbinned pixels) and adjust the pointing " + \
738  "of the telescope accordingly (by shifting the boresight). " + \
739  "The new center will persist until the next Set Instrument command.\n\n" + \
740  "Warning: if the new center is out of bounds (off the instrument) " + \
741  "then the command is rejected.\n\n" + \
742  "This command is intended for spectrographs whose slit positions are not repeatable. " + \
743  "Use Set ImCenter to set the center of the image to the center of the slit. " + \
744  "That way objects will be properly centered on the slit.\n\n" + \
745  "If the slit position is repeatable and you have multiple slits with different centers, " + \
746  "it is may be easier to set up a view data file for each slit and use " + \
747  "Set Instrument/GCView whenever you change slits.",
748  ),
749  parseDefs.SubCommand(
750  parseDefs.Keyword(
751  name = "instrument",
752  castVals = str,
753  numValueRange = [0,1],
754  help = "Name of instrument (the current instrument if omitted)",
755  ),
756  callFunc = tcc.cmd.setInstrument,
757  qualifierList = [
758  parseDefs.Qualifier(
759  name = "gcView",
760  numValueRange = [1,1],
761  valType = str,
762  help = "Specify the guide camera view (none if omitted)."
763  ),
764  parseDefs.Qualifier(
765  name = "keep",
766  valType = ['scaleFac', 'secFocus'],
767  numValueRange = [1,3],
768  help = """Specify which items to retain during the instrument change; omitted items are nulled. Valid values:
769  * SecFocus: focus offset for the secondary mirror
770  * ScaleFac: scale factor""",
771  ),
772  AzWrap,
773  RotWrap,
774  ],
775  help = "Set the instrument: load new instrument data and adjust pointing accordingly. " + \
776  "If this command changes the current instrument then the rotator is halted.",
777  ),
778  parseDefs.SubCommand(
779  parseDefs.Keyword(
780  name="ptErrProbe",
781  castVals = int,
782  numValueRange = [0,1],
783  ),
784  callFunc = tcc.cmd.setPtErrProbe,
785  help = "Specifies the guide probe to use for pointing error correction.",
786  ),
787  parseDefs.SubCommand(
788  parseDefs.Keyword(
789  name="maxUsers",
790  castVals = int,
791  numValueRange = [0,1],
792  ),
793  callFunc = tcc.cmd.setMaxUsers,
794  help = "Set the maximum number of users of the command interpreter." + \
795  " Warning: the limit is only checked when a user connects."
796  ),
797  parseDefs.SubCommand(
798  parseDefs.Keyword(
799  name="scaleFactor",
800  castVals = float,
801  numValueRange = [0,1],
802  ),
803  qualifierList = [
804  parseDefs.Qualifier(
805  "multiplicative",
806  help = "If specified then new scale factor = old scale factor * value.",
807  )
808  ],
809  callFunc = tcc.cmd.setScaleFactor,
810  help = "Set the desired scale factor.",
811  ),
812  parseDefs.SubCommand(
813  parseDefs.Keyword(
814  name="stInterval",
815  castVals = float,
816  numValueRange = [3,3],
817  ),
818  callFunc = tcc.cmd.setStInterval,
819  help = "Set the intervals between status updates "\
820  "during tracking, slewing and when the telescope is doing neither.",
821  ),
822  parseDefs.SubCommand(
823  parseDefs.Keyword(
824  name="time",
825  ),
826  callFunc = tcc.cmd.setTime,
827  help = "Load earth orientation predictions from the current earth orientation prediction file.",
828  ),
829  parseDefs.SubCommand(
830  parseDefs.Keyword(
831  name="wavelength",
832  ),
833  paramList = [
834  parseDefs.KeywordParam(
835  name = 'items',
836  keywordDefList = [
837  parseDefs.Keyword(name = "obj", numValueRange = [1,1], castVals=float),
838  parseDefs.Keyword(name = "gStars", numValueRange = [1,1], castVals=float)
839  ],
840  numParamRange = [0, None],
841  )
842  ],
843  minParAmt = 0,
844  callFunc = tcc.cmd.setWavelength,
845  help = '',
846  ),
847  parseDefs.SubCommand(
848  parseDefs.Keyword(
849  name="weather",
850  ),
851  paramList = [
852  parseDefs.KeywordParam(
853  name = 'items',
854  keywordDefList = [
855  parseDefs.Keyword(name = "airTemp", numValueRange = [1,1], castVals=float,
856  help = "Outside air temperature, in C."),
857  parseDefs.Keyword(name ="secTrussTemp", numValueRange = [1,1], castVals=float,
858  help = "Secondary truss temperature, in C."),
859  parseDefs.Keyword(name ="primF_BFTemp", numValueRange = [2,2], castVals=float, # maxVals=2?
860  help = "Two measures of primary mirror temperature: " \
861  "Front temperature, back - front temperature difference, in C"),
862  parseDefs.Keyword(name ="secF_BFTemp", numValueRange = [2,2], castVals=float,
863  help = "Two measures of secondary mirror temperature: " \
864  "Front temperature, back - front temperature difference, in C"),
865  parseDefs.Keyword(name ="pressure", numValueRange = [1,1], castVals=float,
866  help = "Pressure in Pascals"),
867  parseDefs.Keyword(name ="humidity", numValueRange = [1,1], castVals=float,
868  help = "Fractional humidity (e.g. 0.2 for 20%)"),
869  parseDefs.Keyword(name ="tLapse", numValueRange = [1,1], castVals=float,
870  help = "Temperature lapse rate, in C/km"),
871  parseDefs.Keyword(name ="wSpeed", numValueRange = [1,1], castVals=float,
872  help = "Wind speed in m/s"),
873  parseDefs.Keyword(name ="wDirection", numValueRange = [1,1], castVals=float,
874  help = "Wind direction in degrees: S = 0, E = 90")
875  ],
876  numParamRange = [0, None],
877  ),
878  ],
879  qualifierList = [RefCoefficients(defBoolValue=True), Collimate(defBoolValue=True)],
880  callFunc=tcc.cmd.setWeather
881  ),
882  ],
883  ),
884 
885  parseDefs.CommandWrapper(
886  name = "show",
887  subCmdList = [
888  parseDefs.SubCommand(
889  parseDefs.Keyword(name="focus"),
890  qualifierList = [Full],
891  callFunc = tcc.cmd.showFocus,
892  help = "Show secondary focus offset.",
893  ),
894 
895  parseDefs.SubCommand(
896  parseDefs.Keyword(name="block"),
897  callFunc = tcc.cmd.showBlock,
898  minParAmt = 1,
899  help = "Show the specified block.",
900  paramList = [
901  blockName,
902  ],
903  qualifierList = [Output, NoRead],
904  ),
905 
906  parseDefs.SubCommand(
907  parseDefs.Keyword(name="axisConfig"),
908  callFunc = tcc.cmd.showAxisConfig,
909  help = "Display config info about the axis controllers.",
910  qualifierList = [Full],
911  ),
912 
913  parseDefs.SubCommand(
914  parseDefs.Keyword(name="instrument"),
915  callFunc = tcc.cmd.showInstrument,
916  help = "Display information about the current instrument.",
917  qualifierList = [Full],
918  ),
919 
920  parseDefs.SubCommand(
921  parseDefs.Keyword(name="maxUsers"),
922  callFunc = tcc.cmd.showMaxUsers,
923  help = "Display the maximum number of users.",
924  qualifierList = [Full],
925  ),
926 
927  parseDefs.SubCommand(
928  parseDefs.Keyword(name="mount"),
929  callFunc = tcc.cmd.showMount,
930  help = "Display the mount position of the main axes.",
931  qualifierList = [Full],
932  ),
933 
934  parseDefs.SubCommand(
935  parseDefs.Keyword(name="myNumber"),
936  callFunc = tcc.cmd.showMyNumber,
937  help = "Display your user ID number.",
938  qualifierList = [Full],
939  ),
940 
941  parseDefs.SubCommand(
942  parseDefs.Keyword(name="object"),
943  callFunc = tcc.cmd.showObject,
944  help = "Display user-specified object position and related parameters.",
945  qualifierList = [Full],
946  ),
947 
948  parseDefs.SubCommand(
949  parseDefs.Keyword(name="physical"),
950  callFunc = tcc.cmd.showPhysical,
951  help = "Display the physical position of the main axes.",
952  qualifierList = [Full],
953  ),
954 
955  parseDefs.SubCommand(
956  parseDefs.Keyword(name="ptErrProbe"),
957  callFunc = tcc.cmd.showPtErrProbe,
958  help = "Display the guide probe used for pointing error correction.",
959  qualifierList = [Full],
960  ),
961 
962  parseDefs.SubCommand(
963  parseDefs.Keyword(name="scaleFactor"),
964  callFunc = tcc.cmd.showScaleFactor,
965  help = "Display the current scale factor.",
966  qualifierList = [Full],
967  ),
968 
969  parseDefs.SubCommand(
970  parseDefs.Keyword(name="status"),
971  callFunc = tcc.cmd.showStatus,
972  help = "Display information about the state of the TCC.",
973  qualifierList = [Full],
974  ),
975 
976  parseDefs.SubCommand(
977  parseDefs.Keyword(name="stInterval"),
978  callFunc = tcc.cmd.showStInterval,
979  help = "Display the interval between status updates.",
980  qualifierList = [Full],
981  ),
982 
983  parseDefs.SubCommand(
984  parseDefs.Keyword(name="time"),
985  callFunc = tcc.cmd.showTime,
986  help = "Display the current time in several time systems.",
987  qualifierList = [Full],
988  ),
989 
990  parseDefs.SubCommand(
991  parseDefs.Keyword(name="users"),
992  callFunc = tcc.cmd.showUsers,
993  help = "Display information about connected users.",
994  qualifierList = [Full],
995  ),
996 
997  parseDefs.SubCommand(
998  parseDefs.Keyword(name="version"),
999  callFunc = tcc.cmd.showVersion,
1000  help = "Display the version of the TCC control system software.",
1001  qualifierList = [Full],
1002  ),
1003 
1004  parseDefs.SubCommand(
1005  parseDefs.Keyword(name="wavelength"),
1006  callFunc = tcc.cmd.showWavelength,
1007  help = "Display the central wavelength for refraction correction for the object and the guide star.",
1008  qualifierList = [Full],
1009  ),
1010 
1011  parseDefs.SubCommand(
1012  parseDefs.Keyword(name="weather"),
1013  callFunc = tcc.cmd.showWeather,
1014  help = "Display weather information.",
1015  qualifierList = [Full],
1016  ),
1017  ],
1018  ),
1019 
1020  parseDefs.Command(
1021  name = "talk",
1022  minParAmt = 2,
1023  help = "Send a command directly to an axis or mirror controller.",
1024  callFunc = tcc.cmd.talk,
1025  paramList = [
1026  parseDefs.ValueParam(
1027  name = "device",
1028  castVals = str,
1029  numValueRange=(1, 1),
1030  help = "Device: one of az, alt, rot (axis controllers), prim, sec, tert (mirror controllers).",
1031  ),
1032  parseDefs.ValueParam(
1033  name = "command",
1034  castVals = str,
1035  numValueRange=(1, 1),
1036  help = "The command to send. It must be in double quotes if it includes spaces."
1037  ),
1038  ],
1039  qualifierList = [
1040  TimeLimit,
1041  ],
1042  ),
1043 
1044  parseDefs.Command(
1045  name = "track",
1046  help = "Make the telescope to slew to and track an object.",
1047  callFunc = tcc.cmd.track,
1048  paramList = [
1049  CoordPair(
1050  name = 'coordPair',
1051  extraHelp = "Nonzero velocity specifies dEquatAng/dt, dPolarAng/dt; " \
1052  "to track along a great circle specify /ScanVelocity or, " \
1053  "equivalently, specify an arc offset with nonzero velocity.",
1054  ),
1055  CoordSys(
1056  name = 'coordSys',
1057  help = "Coordinate system and date",
1058  omit = ("Instrument", "GProbe", "GImage", "PtCorr", "Rotator"),
1059  ),
1060  ],
1061  minParAmt = 0,
1062  qualifierList = [
1063  Stop,
1064  Name,
1065  Magnitude,
1066  Distance,
1067  PM,
1068  Px,
1069  RV,
1070  parseDefs.Qualifier(
1071  "rotType",
1072  valType = ["object", "horizon", "physical", "mount", "none"],
1073  numValueRange = [1,1],
1074  help = """Type of rotation; choices are:
1075 * Object: rotate with the object. The rotator angle is the angle of the coordinate system of the object
1076  with respect to instrument x,y. For example if the object is specified in an RA/Dec coordinate system
1077  then at 0 degrees east will be along the x axis of the instrument, and at 90 degrees east will be along y
1078  (because east is the direction of increasing coordinate system axis 1).
1079  Warning: the orientation is specified at the un-arc-offset position (without arc offset taken into account);
1080  this allows drift-scanning to work, but may have surprising (not necessarily bad, just surprising)
1081  effects if you are using arc offsets for other purposes.
1082 * Horizon: rotate with the horizon. The rotator angle is the angle of the horizon with respect to the instrument.
1083  At 0 the horizon (direction of increasing azimuth) lies along the x axis of the instrument;
1084  at 90 the horizon lies along the y axis. Obtaining good results while rotating with the horizon
1085  equires great care: read the note for details. Note: unlike object rotation,
1086  horizon rotation is specified at the net object position, with arc offsets included.
1087 * Mount: the rotator angle is directly sent to the instrument rotator. No wrap is applied.
1088  Use Mount rotation to put the instrument rotator to a known position.
1089 * Physical: similar to mount but wrap may be applied, and there may be difference in scale or offset.
1090  Physical is deprecated.
1091 * None: do not rotate.""",
1092  ),
1093  parseDefs.Qualifier(
1094  "rotAngle", numValueRange = [1,3],
1095  valType = float, help = "Set the angle of rotation: pos [vel [TAI]].",
1096  ),
1097  AzWrap,
1098  RotWrap,
1099  AbsRefCorrect(defBoolValue=True),
1100  Collimate(defBoolValue=True),
1101  Perfect,
1102  RefCoefficients(defBoolValue=True),
1103  RestartQual(defValueList=("all",), helpIfOmitted="restart all axes"),
1104  parseDefs.Qualifier(
1105  name = "keep",
1106  valType = [
1107  'arcOffset', 'boresight', 'gCorrection', 'calibration',
1108  'noArcOffset', 'noBoresight', 'noGCorrection', 'noCalibration',
1109  ],
1110  numValueRange = [1, None],
1111  help = """Retain the specified offsets or zero them?
1112 * /Keep=<OffsetName> keeps the offset (both position and velocity)
1113 * /Keep=No<OffsetName> zeros the offset (both position and velocity)
1114 Valid offset names are:
1115 * ArcOffset: object arc offset
1116 * Boresight: boresight offset (also known as instrument plane offset)
1117 * GCCorrection: net guiding correction
1118 * Calibration: calibration offset
1119 The default behavior for all offsets except calibration is to zero them if a new object is specified, else keep them.
1120 The default behavior for calibration offsets is to keep the position component and zero the velocity component
1121 (which is almost always 0 anyway), regardless of whether a new object is specified.""",
1122  ),
1123  parseDefs.Qualifier(
1124  "ptError",
1125  numValueRange = [0, None],
1126  valType = [
1127  "noFindReference",
1128  "noRefSlew",
1129  "objSlew",
1130  ],
1131  help = """Start or end a pointing error sequence; the default behavior is to
1132 save the current target, find a position reference star near the target, and slew to center the reference star
1133 in the pointing error guide probe (as designated in the inst block). The following options can alter
1134 this behavior:
1135 * NoFindReference: use the target as the position reference star instead of finding one in the position reference catalog
1136 * NoRefSlew: do not slew to the reference star
1137 * ObjSlew: slew back to the target that was saved by the last Track/PtErr command (and the saved target
1138  is cleared). This option may not be specified with NoFindReference or NoRefSlew.
1139 """,
1140  ),
1141  parseDefs.Qualifier(
1142  "magRange",
1143  numValueRange = [2, 2],
1144  valType = float,
1145  help = """magnitude range for reference stars found with Track/Pterr. The order of the two values doesn't matter
1146  (in order to avoid confusion between smaller values and fainter stars).
1147  If omitted, then defaults to target magnitude +/- 2, if known, else (3, 7).
1148  """,
1149  ),
1150  parseDefs.Qualifier(
1151  "scanVelocity",
1152  numValueRange = [2, 3],
1153  valType = float,
1154  help = "Scan along a great circle. Values are equatSkyVel, polarVel [, TAI], " + \
1155  "where equatSkyVel is velocity on the sky (dEquatPos/dt * cos(polarPos)) " + \
1156  "and tai defaults to the current date (or to the date of coordPair, if specified). " + \
1157  "Works by setting arc offset to 0, 0, equatSkyVel, polarVel, tai; " + \
1158  "thus if /scanVelocity is specified, /keep=[no]arcOffset is ignored.",
1159  ),
1160  parseDefs.Qualifier(
1161  "chebyshev", numValueRange = [1,1], valType = str,
1162  help = "Track an object whose position is specified by Chebyshev " +
1163  "polynomials of the first kind, as a function of TAI date.",
1164  ),
1165  ],
1166  ),
1167  )
1168 
1169  CmdParser.__init__(self, tccCmdList)
A class that holds command definitions, and can parse tcc commands.
Definition: cmdParse.py:85
def __init__
Construct a tccCmdParser.