Skip to content
Snippets Groups Projects
Commit c217fcff authored by kpetersn's avatar kpetersn
Browse files

Changes for debugging SYNC problems for soft motors.

git-svn-id: https://subversion.xray.aps.anl.gov/kmp/transform/trunk@258 f095f811-4e88-6c84-d33e-e382bdb4531c
parent 2dadfee2
No related branches found
No related tags found
No related merge requests found
......@@ -3,3 +3,5 @@ medm -x -attach -macro "P=kmp3:,M1=m1,M2=m2,M3=m3" motor3x.adl &
sleep 4.0
medm -x -attach -macro "P=kmp3:,M1=m4,M2=m5,M3=m6" motor3x.adl &
medm -x -attach -macro "P=kmp3:,M1=lab:m1,M2=lab:m2,M3=lab:m3" motor3x.adl &
medm -x -attach -macro "P=kmp3:,M=m1" ~/epics/synAppsSVN/support/motor/motorApp/op/adl/motorx_all.adl &
medm -x -attach -macro "P=kmp3:lab:,M=m1" ~/epics/synAppsSVN/support/motor/motorApp/op/adl/motorx_all.adl &
......@@ -51,6 +51,7 @@ class myTransform(transform.transform):
return retval.tolist()[0]
if __name__ == "__main__":
#!prefix = 'kmp2:'
prefix = 'kmp3:'
realMotors = ["%s%s" % (prefix, x) for x in ('m1', 'm2', 'm3') ]
transformMotors = ["%s%s" % (prefix, x) for x in ('m4', 'm5', 'm6') ]
......
......@@ -23,6 +23,7 @@ class transform:
self.reinitFlag = False
self.softMotorInitiatedMove = False
self.abortFlag = False
self.initCompleteFlag = False
### PVs to set
......@@ -56,6 +57,18 @@ class transform:
tempStr = "%s:dmov.VAL" % tm
self.tm_dmov.append( epics.PV(tempStr) )
# soft motor sync PVs (for synchronizing target positions)
self.tm_sync = []
for tm in (tm1, tm2, tm3):
tempStr = "%s.SYNC" % tm
self.tm_sync.append( epics.PV(tempStr) )
# soft motor proc PVs (for synchronizing target positions)
self.tm_proc = []
for tm in (tm1, tm2, tm3):
tempStr = "%s.PROC" % tm
self.tm_proc.append( epics.PV(tempStr) )
### PVs to monitor
# real motor RBV (for calculating transformed position)
......@@ -106,14 +119,16 @@ class transform:
#!print "end manual update"
print "End Initialization"
self.initCompleteFlag = True
### Callback functions (to be called when PV values change--only set flags that are watched in main loop)
def driveCallback(self, **kw):
#!print "driveCallback:\n", " ", kw['pvname'], kw['value']
self.moveSoftMotorFlag = True
self.softMotorInitiatedMove = True
if self.initCompleteFlag == True:
self.moveSoftMotorFlag = True
self.softMotorInitiatedMove = True
def rdbkCallback(self, **kw):
#!print "rdbkCallback:\n", " ", kw['pvname'], kw['value']
......@@ -148,7 +163,7 @@ class transform:
# Do the forward transform
tm_positions = self.fwdTrans(m_positions, t_positions)
#!print "updating readbacks:", tm_positions
print "updating readbacks:", tm_positions
# Write the soft (transformed) readback positions
for i in range(len(tm_positions)):
......@@ -158,22 +173,25 @@ class transform:
# This is only useful if LOCK = YES
def syncSoftTargets(self):
print "softMotorInitiatedMove =", self.softMotorInitiatedMove
# Synchronize soft targets if a real motor initated the move
if self.softMotorInitiatedMove == False:
# The following sleep is required to prevent problems when making small moves
sleep(0.05)
#tm_positions = [x.get() for x in self.tm_rbv]
### MAYBE SHOULD RECALCULATE BASED ON REAL MOTORS INSTEAD
m_positions = [x.get() for x in self.m_val]
t_positions = [x.get() for x in self.t_rbv]
#!#tm_positions = [x.get() for x in self.tm_rbv]
#!### MAYBE SHOULD RECALCULATE BASED ON REAL MOTORS INSTEAD
#!m_positions = [x.get() for x in self.m_val]
#!t_positions = [x.get() for x in self.t_rbv]
# Do the forward transform
tm_positions = self.fwdTrans(m_positions, t_positions)
#!# Do the forward transform
#!tm_positions = self.fwdTrans(m_positions, t_positions)
#!print "syncing these target positions:", tm_positions
#!#!print "syncing these target positions:", tm_positions
for i in range(len(self.tm_rbv)):
self.tm_val[i].put(tm_positions[i])
print i
#!self.tm_sync[i].put(1)
#!self.tm_proc[i].put(1)
# For soft-motor-initiate moves don't do anything
......@@ -290,16 +308,16 @@ class transform:
#!print "idle: stop motors"
self.stopMotors()
if self.moveSoftMotorFlag == True:
#!print "idle: move motors"
print "idle: move motors"
self.moveMotors()
if self.dmovChangeFlag == True:
#!print "idle: update dmov"
print "idle: update dmov"
self.updateDmov()
if self.updateReadbackFlag == True:
#!print "idle: update readback"
print "idle: update readback"
self.updateReadbacks()
if self.syncSoftTargetFlag == True:
#!print "idle: sync soft targets"
print "idle: sync soft targets"
self.syncSoftTargets()
if __name__ == "__main__":
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment