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

Поисковые слова: arp 220
lsst.tcc: python/tcc/axis/checkAxesForSlew.py Source File
lsst.tcc  1.2.2-3-g89ecb63
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
checkAxesForSlew.py
Go to the documentation of this file.
1 from __future__ import division, absolute_import
2 
3 import numpy
4 
5 from twistedActor import log
6 
7 import tcc.base
8 
9 __all__ = ["checkAxesForSlew"]
10 
11 def checkAxesForSlew(desObj, perfect, doRestart, isHalted, isNewObj, isNewRot, rotExists, nullSysFlag):
12  """!Apply wrap preference and verify that position is in bounds, preparatory to a slew
13 
14  @param[in] desObj object block; information about the desired object
15  in: userSys, rotType, targetMount, axisErrCode
16  out: axisErrCode
17  @param[in] perfect if True, all existing axes must be able to move, else badAxis and sigBad are set true
18  @param[in] doRestart (3 bools) restart axis, if possible? (ignored for rotator if no rotator)
19  @param[in] isHalted (3 bools) true if axis is presently halted
20  @param[in] isNewObj are you acquiring a new object?
21  @param[in] isNewRot are you setting a new rotator angle; if True and rotExists then the rot axis is "significant"
22  @param[in] rotExists is there a rotator axis?
23  @param[in] nullSysFlag how to set badAxis if coordSys (for az, alt) or rotType (for rot) is none:
24  -1: reject all such cases (badAxis=true); use if you cannot handle this situation
25  0: accept only if halted or halting (isHalted or desObj.targetMount and desObj.axisErrCode are both OK)
26  1: accept for all such cases; useful for a preliminary check, if you are going to handle halting later
27  @return these items:
28  - doAxis[3]: move or halt this axis?
29  - badAxis[3]: error code is nonzero, the axis exists, and a move is wanted**
30  Normally set True if desObj.axisErrCode not OK. These are the exceptions:
31  - The rotator does not exist and move not wanted (desObj.rotType none)
32  - The axis exists, a halt is wanted*, "perfect" is false and:
33  - nullSysFlag > 0 (accept all halts)
34  - nullSysFlag = 0 (accept valid halts) and the halt is valid, i.e.
35  isHalted true (already halted, no need to do anything)
36  or desObj.targetMount is valid and desObj.axisErrCode=tcc.base.AxisErr_HaltRequested (a valid halt)
37  - sigBad: set True if badAxis is true for a "significant" axis. A significant axis is so important
38  that if it cannot be moved as requested then the request should be rejected, specifically:
39  - If isNewObj or perfect then azimuth and altitude are significant.
40  - If rotExists and (isNewRot or perfect) then the rotator is significant.
41 
42  Sets desObj.axisErrCode as follows; the first appropriate condition listed is used:
43  - If not rotExists: sets axisErrCode[3] to tcc.base.AxisErr_NotAvailable
44  - If halt wanted* and nullSysFlag=0 but the halt cannot happen (axisErrCode not tcc.base.AxisErr_HaltRequested,
45  or mount pos. unknown): leaves axisErrCode alone if nonzero, else sets to tcc.base.AxisErr_CannotCompute
46  - If halt wanted* and nullSysFlag != 0: sets axisErrCode to tcc.base.AxisErr_HaltRequested
47  - If move wanted**, doRestart false and isHalted true: sets axisErrCode to tcc.base.AxisErr_NoRestart
48  - If move wanted** but mount position unknown: leaves axisErrCode alone if nonzero,
49  else sets axisErrCode to tcc.base.AxisErr_CannotCompute
50  If none of these conditions apply then axisErrCode is left alone.
51 
52  *halt wanted:
53  - for az and alt: associated coordSys is none (coordConv.NoneCoordSys)
54  - for rot: rot exists and rotType is none (tcc.base.RotType_None)
55  **move wanted:
56  - for az and alt: associated coordSys is not none (coordConv.NoneCoordSys)
57  - for rot: rot exists and rotType is not none (tcc.base.RotType_None)
58  """
59  badAxis = [False]*3
60  axisExists = (True, True, rotExists)
61 
62  # compute doAxis -- all existing axes that are now moving or will be moving
63  doAxis = tuple(axisExists[axis] and ((not isHalted[axis]) or desObj.targetMount[axis].isfinite()) for axis in range(3))
64 
65  # compute wantToMove: all axes we want to move (csys not "none")
66  # as opposed to those we want to halt (csys = "none")
67  wantToMove = (
68  desObj.userSys.getName() != "none",
69  desObj.userSys.getName() != "none",
70  rotExists and desObj.rotType != tcc.base.RotType_None,
71  )
72 
73  # set desObj.axisErrCode and badAxis appropriately
74  for axis in range(3):
75  if axisExists[axis]:
76  if wantToMove[axis]:
77  # the axis exists and motion wanted
78 
79  if isHalted[axis] and not doRestart[axis]:
80  # axis is being left halted
81  desObj.axisErrCode[axis] = tcc.base.AxisErr_NoRestart
82  elif (not desObj.targetMount[axis].isfinite()) and (desObj.axisErrCode[axis] == tcc.base.AxisErr_OK):
83  # axis halted, but no error code to explain why;
84  # this case should never occur
85  desObj.axisErrCode[axis] = tcc.base.AxisErr_CannotCompute
86  badAxis[axis] = (desObj.axisErrCode[axis] != tcc.base.AxisErr_OK)
87  else:
88  # axis exists and halt wanted
89  desObj.axisErrCode[axis] = tcc.base.AxisErr_HaltRequested
90  if not isHalted[axis]:
91  desObj.axisCmdState[axis] = tcc.base.AxisState_Halting
92  if (nullSysFlag < 0) or perfect:
93  # any halt request is bad
94  badAxis[axis] = True
95  elif nullSysFlag == 0:
96  # a halt request is OK only if it can be satisfied:
97  # if halted or halting (isHalted or desObj.targetMount and desObj.axisErrCode are both OK)
98  if not isHalted[axis] and not desObj.targetMount[axis].isfinite():
99  # halt slew computation failed
100  badAxis[axis] = True
101  logMsg = "Cannot compute mount axis %i\ncheckAxesForSlew(desObj, perfect=%s, doRestart=%s isHalted=%s isNewObj=%s isNewRot=%s rotExists=%s nullSysFlag)\nDumping desObj block:\n%s"%(axis, str(isHalted), str(isNewObj), str(isNewRot), str(rotExists), str(nullSysFlag), str(desObj))
102  log.error(logMsg)
103  desObj.axisErrCode[axis] = tcc.base.AxisErr_CannotCompute
104  else:
105  # axis does not exist
106  # mark axis bad only if we want to move it
107  desObj.axisErrCode[axis] = tcc.base.AxisErr_NotAvailable
108  badAxis[axis] = wantToMove[axis]
109 
110  desObj.axisIsSignificant[0] = isNewObj or perfect
111  desObj.axisIsSignificant[1] = isNewObj or perfect
112  # user demanded rotation (even if rotator does not exist, though this should be caught earlier)
113  # or user demanded perfection and a rotator exists
114  desObj.axisIsSignificant[2] = rotExists and (isNewRot or perfect)
115 
116  sigBad = numpy.any(numpy.logical_and(badAxis, desObj.axisIsSignificant))
117 
118  return doAxis, badAxis, sigBad
def checkAxesForSlew
Apply wrap preference and verify that position is in bounds, preparatory to a slew.