Commit 58953c17 authored by Sebastien Petitdemange's avatar Sebastien Petitdemange
Browse files

icepap: added tracking position list.

Icepap controller can load a list of positions and then be externally
triggered to move to the programmed positions
parent adaa30fd
......@@ -324,7 +324,82 @@ class Icepap(Controller):
def temperature(self,axis):
return int(_command(self._cnx,"%d:?MEAS T" % axis.address))
@object_method(types_info=(("float","bool"),"None"))
def set_tracking_positions(self,axis,positions,cyclic = False):
"""
Send position to the controller which will be tracked.
positions -- are expressed in user unit
cyclic -- cyclic position or not default False
@see activate_track method
"""
address = axis.address
if not len(positions):
_ackcommand(self._cnx,"%d:LISTDAT CLEAR" % address)
return
dial_position = axis.user2dial(numpy.array(positions,dtype=numpy.float))
step_positions = numpy.array(dial_position * axis.steps_per_unit,
dtype=numpy.int32)
_ackcommand(self._cnx,"%d:*LISTDAT %s DWORD" %
(address, "CYCLIC" if cyclic else "NOCYCLIC"),
step_positions)
@object_method(types_info=("None",("float","bool")))
def get_tracking_positions(self,axis):
"""
Get the tacking positions.
This method should only be use for debugging
return a tuple with (positions,cyclic flag)
"""
address = axis.address
#Get the number of positions
reply = _command(self._cnx,"%d:?LISTDAT" % address)
reply_exp = re.compile("(\d+) *(\w+)?")
m = reply_exp.match(reply)
if m is None:
raise RuntimeError("Reply didn't expected: %s" % reply)
nb = int(m.group(1))
positions = numpy.zeros((nb,),dtype = numpy.int32)
cyclic = True if m.group(2) == "CYCLIC" else False
if nb > 0:
reply_exp = re.compile(".+: +([+-]?\d+)")
reply = _command(self._cnx,"%d:?LISTDAT %d" % (address,nb))
for i,line in enumerate(reply.split('\n')):
m = reply_exp.match(line)
if m:
pos = int(m.group(1))
positions[i] = pos
dial_position = positions / axis.steps_per_unit
positions = axis.dial2user(dial_position)
return positions,cyclic
@object_method(types_info=(("bool","str"),"None"))
def activate_track(self,axis,activate,mode = None):
"""
Activate/Deactivate the tracking position depending on
activate flag
mode -- default "INPOS" if None.
mode can be :
- SYNC -> Internal SYNC signal
- ENCIN -> ENCIN signal
- INPOS -> INPOS signal
- ABSENC -> ABSENC signal
"""
address = axis.address
if not activate:
_ackcommand(self._cnx,"STOP %d" % address)
axis.sync_hard()
else:
if mode is None: mode = "INPOS"
possibles_modes = ["SYNC","ENCIN","INPOS","ABSENC"]
if mode not in possibles_modes:
raise ValueError("mode %s is not managed, can only choose %s" %
(mode,possibles_modes))
_ackcommand(self._cnx,"%d:LTRACK %s" % (address,mode))
def reset(self):
_command(self._cnx,"RESET")
......
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