Commit b76935f8 authored by kpetersn's avatar kpetersn
Browse files

Modified python scripts to properly handle changing off EPICS offsets.

git-svn-id: https://subversion.xray.aps.anl.gov/kmp/HexapodSrc/trunk@8 f095f811-4e88-6c84-d33e-e382bdb4531c
parent 37c4adf9
......@@ -28,6 +28,8 @@ class hxp_interface:
motorToolTwValChan = []
motorToolTwForwardChan = []
motorToolTwReverseChan = []
motorOffsetChan = []
motorOffsets = [0.0] * 6
multiMovePos = [0.0] * 6
movingMotor = -1
movingMotorPos = 0.0
......@@ -35,6 +37,8 @@ class hxp_interface:
tweakFlag = 0
tweakedMotor = -1
tweakMultiplier = 1
offsetFlag = 0
offsetMotor = -1
tweakArray = [0.0] * 6
# This doesn't necessarily need to be a global variable
tweakMagnitude = 0.0
......@@ -78,6 +82,19 @@ class hxp_interface:
self.hexapodMultiGoChan.searchw()
self.hexapodMultiGoChan.add_masked_array_event(ca.DBR_SHORT, 1, ca.DBE_VALUE, self.motorMultiGoCallback)
# print "Connecting to the offset PVs"
for i in range(6):
index = i + 1
pv = "%s:hxp:m%i.OFF" % (self.prefix, index)
# Append the chan object to the motorOffsetChan array
self.motorOffsetChan.append( CaChannel.CaChannel(pv) )
# Connect to the PV
self.motorOffsetChan[i].searchw()
# Initialize the offset value
self.motorOffsets[i] = self.motorOffsetChan[i].getw()
# Create the monitor (more efficient than polling every time)
self.motorOffsetChan[i].add_masked_array_event(ca.DBR_DOUBLE, 1, ca.DBE_VALUE, self.motorOffsetCallback, i)
# print "CONNECTING TO WORK TARGET PVs"
for i in range(6):
index = i + 1
......@@ -85,7 +102,7 @@ class hxp_interface:
pv = "%s:hxp:work:t%i" % (self.prefix, index)
self.motorWorkTargChan.append( CaChannel.CaChannel(pv) )
self.motorWorkTargChan[i].searchw()
self.motorWorkTargChan[i].putw( pos[i] )
self.motorWorkTargChan[i].putw( pos[i] + self.motorOffsets[i] )
# print "CONNECTING TO TOOL TWEAK VALUE PVs"
for i in range(6):
......@@ -152,6 +169,14 @@ class hxp_interface:
print "Disconnecting from the XPS"
self.XPS.TCP_CloseSocket(self.socketID)
def motorOffsetCallback(self, epicsArgs, userArgs):
print "motorOffsetCallback"
#print epicsArgs, userArgs
self.offsetMotor = userArgs[0]
self.motorOffsets[self.offsetMotor] = epicsArgs['pv_value']
print "motor offsets:", self.motorOffsets
self.offsetFlag = 1
def tweakCallback(self, epicsArgs, userArgs):
print "tweakCallback"
if epicsArgs['pv_value'] == 1:
......@@ -282,7 +307,7 @@ class hxp_interface:
self.hexapodDoneMovingChan.putw(0)
# Synchronize the work target position
self.motorWorkTargChan[self.movingMotor].putw(self.movingMotorPos)
self.motorWorkTargChan[self.movingMotor].putw(self.movingMotorPos + self.motorOffsets[self.movingMotor])
# move the motor
val = self.singleAxisAbsMove(self.movingMotor, self.movingMotorPos)
......@@ -299,8 +324,10 @@ class hxp_interface:
if self.multiMoveFlag == 1:
# Get the target positions
### NOTE! At the moment these are raw positions. For these to be dial coords, the
### offset needs to be taken into account, since this calls the move command directly
for i in range(6):
self.multiMovePos[i] = self.motorWorkTargChan[i].getw()
self.multiMovePos[i] = self.motorWorkTargChan[i].getw() - self.motorOffsets[i]
print self.multiMovePos
......@@ -320,8 +347,9 @@ class hxp_interface:
self.hexapodMultiGoChan.putw(0)
# Synchronize the soft-motor readbacks by telling them to go to their same targets
print "SYNCHRONIZING soft-motor positions!"
for i in range(6):
self.motorValChan[i].putw(self.multiMovePos[i])
self.motorValChan[i].putw( self.multiMovePos[i] + self.motorOffsets[i] )
if self.tweakFlag == 1:
#
......@@ -356,6 +384,18 @@ class hxp_interface:
# Reset the tweak PV (Should MEDM do this instead?)
if self.offsetFlag == 1:
# Synchronize the work target PV for the offset change
target_array = self.getTargetPositions()
newTarget = target_array[self.offsetMotor] + self.motorOffsets[self.offsetMotor]
print newTarget
self.motorWorkTargChan[self.offsetMotor].putw( newTarget )
self.offsetFlag = 0
## Do the stuff
......
......@@ -80,10 +80,12 @@ class hxp_poller:
# Initialize the status PVs
#print self.last_hxp_status
print "last_hxp_status", self.last_hxp_status
self.groupStatusChan.putw(self.last_hxp_status)
print "hxp_status_str", self.hxp_status_str
self.groupStatusStrChan.putw(self.hxp_status_str)
# Initialize the PVs
# Initialize the Readback PVs
for i in range(6):
self.motorValChan[i].putw( self.last_pos_array[i] )
......@@ -171,8 +173,8 @@ class hxp_poller:
self.hxp_status_str = self.getStatusString(hxp_status)
# update the PVs only when the status actually changes
self.GroupStatusChan.putw(hxp_status)
self.GroupStatusStrChan.putw(self.hxp_status_str)
self.groupStatusChan.putw(hxp_status)
self.groupStatusStrChan.putw(self.hxp_status_str)
### Store status for comparison next iteration
# this could probably be done in the above if statement
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment