Commit adaa30fd authored by Sebastien Petitdemange's avatar Sebastien Petitdemange
Browse files

icepap: get/set event positions

parent d2feb0d0
......@@ -10,7 +10,7 @@ import gevent
import functools
from bliss.common.greenlet_utils import protect_from_kill
from bliss.controllers.motor import Controller
from bliss.common.axis import AxisState
from bliss.common.axis import AxisState,Axis
from bliss.common.utils import object_method
from bliss.comm.tcp import Command
import struct
......@@ -250,7 +250,59 @@ class Icepap(Controller):
return int(value)
def set_encoder(self,encoder,steps):
_ackcommand(self._cnx,"ENC %s %d %d" % (encoder.enctype,encoder.address,steps))
_ackcommand(self._cnx,"ENC %s %d %d" %
(encoder.enctype,encoder.address,steps))
def set_event_positions(self,axis_or_encoder,positions):
int_position = numpy.array(positions,dtype=numpy.int32)
#position has to be ordered
int_position.sort()
address = axis_or_encoder.address
if not len(int_position):
_ackcommand(self._cnx,"%d:ECAMDAT CLEAR" % address)
return
if isinstance(axis_or_encoder,Axis):
source = 'AXIS'
else: # encoder
source = 'MEASURE'
#load trigger positions
_ackcommand(self._cnx,"%d:*ECAMDAT %s DWORD" % (address,source),
int_position)
# send the trigger on the multiplexer
_ackcommand(self._cnx,"%d:SYNCAUX eCAM" % address)
def get_event_positions(self,axis_or_encoder):
"""
For this controller this method should be use
for debugging purposed only...
"""
address = axis_or_encoder.address
#Get the number of positions
reply = _command(self._cnx,"%d:?ECAMDAT" % address)
reply_exp = re.compile("(\w+) +([+-]?\d+) +([+-]?\d+) +(\d+)")
m = reply_exp.match(reply)
if m is None:
raise RuntimeError("Reply Didn't expected: %s" % reply)
source = m.group(1)
nb = int(m.group(4))
if isinstance(axis_or_encoder,Axis):
nb = nb if source == 'AXIS' else 0
else: # encoder
nb = nb if source == "MEASURE" else 0
positions = numpy.zeros((nb,),dtype = numpy.int32)
if nb > 0:
reply_exp = re.compile(".+: +([+-]?\d+)")
reply = _command(self._cnx,"%d:?ECAMDAT %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
return positions
@object_method(types_info=("bool","bool"))
def activate_closed_loop(self,axis,active):
......
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