1 from __future__
import division, absolute_import
3 from twistedActor
import CommandError
7 from tcc.parse import getPVTList, getRestart
8 from .checkTargetForSlew
import checkTargetForSlew
9 from .startSlew
import startSlew
10 from .showObject
import showObjectFields
16 OffsetNumAxesAttrDict = dict(
17 arc = (2,
"userArcOff"),
18 boresight = (2,
"objInstXY"),
19 instplane = (2,
"objInstXY"),
20 rotator = (1,
"rotUser"),
21 guidecorrection = (3,
"guideOff"),
22 gcorrection = (3,
"guideOff"),
23 calibration = (3,
"calibOff"),
26 def setObjOffset(obj, parsedCmd, rotExists, tai, writeToUsers=None):
27 """Update user-set attributes of object block based on an offset command
29 @param[in,out] obj object block to update
30 @param[in] parsedCmd parsed offset command
31 @param[in] rotExists True if there is an instrument rotator
32 @param[in] tai TAI date for PVT coordinates
35 - isNewObj: True if new object position requested
36 - isNewRot: True if new rotator position requested
38 @throw twistedActor.CommandError if offset type is rotator and there is no rotator
41 offsetType = parsedCmd.paramDict[
"type"].valueList[0].keyword.lower()
42 if offsetType ==
"rotator" and not rotExists:
43 raise CommandError(
"Cannot command rotator offset, current instrument has no rotator")
44 numAxes, attrName = OffsetNumAxesAttrDict[offsetType]
45 coordSetParam = parsedCmd.paramDict[
"coordset"]
46 pvtList, numValues =
getPVTList(coordSetParam, numAxes, defTAI=tai)
48 pAbs = parsedCmd.qualDict[
"pabsolute"].boolValue
49 vAbs =
not parsedCmd.qualDict[
"vincremental"].boolValue
51 objField = getattr(obj, attrName)
55 numAxesToSet = numAxes
57 if numValues == 0
and not rotExists:
63 rotOmitted = numAxesToSet != numAxes
65 for ind
in range(numAxesToSet):
70 newPVT = pvt.copy(tai)
72 newPVT.pos = offPVT.pos
74 newPVT.pos += offPVT.pos
77 newPVT.vel = offPVT.vel
79 newPVT.vel += offPVT.vel
83 setattr(obj, attrName, newPVT)
85 objField[ind] = newPVT
95 isNewRot =
not rotOmitted
97 return isNewObj, isNewRot
101 """Implement the offset command
103 rotExists = tccActor.inst.hasRotator()
104 parsedCmd = userCmd.parsedCmd
106 currTAI = tcc.base.tai()
107 newObj = tcc.base.Obj(tccActor.obj)
108 isNewObj, isNewRot =
setObjOffset(obj=newObj, parsedCmd=parsedCmd, rotExists=rotExists, tai=currTAI, writeToUsers=tccActor.writeToUsers)
109 if isNewRot
and not rotExists:
112 tccActor.writeToUsers(
"w",
"Text=\"No instrument rotator: rotator component of offset recorded but not applied\"", cmd=userCmd)
114 if isNewObj
and tccActor.obj.userSys.getName().lower() ==
"mount":
115 tccActor.obj = newObj
116 tccActor.writeToUsers(
"w",
"Text=\"Tracking in mount coordinates; offset recorded but not applied\"", cmd=userCmd)
117 userCmd.setState(userCmd.Done)
120 qualDict = parsedCmd.qualDict
122 doRestart =
getRestart(qual=qualDict[
"restart"], rotExists=rotExists)
123 doComputed = qualDict[
"computed"].boolValue
124 doAbsRefCorr = qualDict[
"absrefcorrect"].boolValue
126 if qualDict[
"computed"].boolValueDefaulted:
130 raise CommandError(
"May not specify /NoComputed and /Restart simultaneously")
131 perfect = qualDict[
"perfect"].boolValue
132 if qualDict[
"refcoefficients"].boolValue:
133 tccActor.weath.updateSite(newObj.site)
149 doCollimate = qualDict[
"collimate"].boolValue
157 doAbsRefCorr=doAbsRefCorr,
158 doCollimate=doCollimate,
165 oldObj = tcc.base.Obj(tccActor.obj)
171 earth=tccActor.earth,
173 telMod=tccActor.telMod,
174 axeLim=tccActor.axeLim,
178 offsetPVTList = [newObj.targetMount[axis] - oldObj.targetMount[axis]
for axis
in range(tcc.base.NAxes)]
180 newObj.updateTime = tccActor.obj.updateTime
181 tccActor.obj = newObj
182 tccActor.axisDevSet.plusMovePV(offsetPVTList, userCmd=userCmd)
185 kwString =
"Moved; %s"%
moveItemKW(tccActor.obj)
186 tccActor.writeToUsers(
"i", kwString)
188 tccActor.updateCollimation()
def getRestart
Get a list of axes from the /Restart qualifier.
def computeObj
Compute all computed obj fields from user-specified fields except path generator outputs.
def showObjectFields
Write fields from the object block.
def getPVTList
Obtain a list of PVTs from a PVT list parameter.