1 from __future__
import division, absolute_import
5 from twistedActor
import log
9 __all__ = [
"checkAxesForSlew"]
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
14 @param[in] desObj object block; information about the desired object
15 in: userSys, rotType, targetMount, 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
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.
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.
53 - for az and alt: associated coordSys is none (coordConv.NoneCoordSys)
54 - for rot: rot exists and rotType is none (tcc.base.RotType_None)
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)
60 axisExists = (
True,
True, rotExists)
63 doAxis = tuple(axisExists[axis]
and ((
not isHalted[axis])
or desObj.targetMount[axis].isfinite())
for axis
in range(3))
68 desObj.userSys.getName() !=
"none",
69 desObj.userSys.getName() !=
"none",
70 rotExists
and desObj.rotType != tcc.base.RotType_None,
79 if isHalted[axis]
and not doRestart[axis]:
81 desObj.axisErrCode[axis] = tcc.base.AxisErr_NoRestart
82 elif (
not desObj.targetMount[axis].isfinite())
and (desObj.axisErrCode[axis] == tcc.base.AxisErr_OK):
85 desObj.axisErrCode[axis] = tcc.base.AxisErr_CannotCompute
86 badAxis[axis] = (desObj.axisErrCode[axis] != tcc.base.AxisErr_OK)
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:
95 elif nullSysFlag == 0:
98 if not isHalted[axis]
and not desObj.targetMount[axis].isfinite():
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))
103 desObj.axisErrCode[axis] = tcc.base.AxisErr_CannotCompute
107 desObj.axisErrCode[axis] = tcc.base.AxisErr_NotAvailable
108 badAxis[axis] = wantToMove[axis]
110 desObj.axisIsSignificant[0] = isNewObj
or perfect
111 desObj.axisIsSignificant[1] = isNewObj
or perfect
114 desObj.axisIsSignificant[2] = rotExists
and (isNewRot
or perfect)
116 sigBad = numpy.any(numpy.logical_and(badAxis, desObj.axisIsSignificant))
118 return doAxis, badAxis, sigBad
def checkAxesForSlew
Apply wrap preference and verify that position is in bounds, preparatory to a slew.