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

motors: added method to get/set event on position.

Some motors controller can generate event when an axis or an encoder
pass through a position. Most of the time events are electrical pulses.
Those new methods are there to manage the load/read the position into the
controller.
parent 2142dd37
......@@ -40,6 +40,7 @@ import gevent
import re
import types
import functools
import numpy
#: Default polling time
DEFAULT_POLLING_TIME = 0.02
......@@ -1030,6 +1031,18 @@ class Axis(object):
self.limits(*self.limits(from_config=True))
@lazy_init
def set_event_positions(self, positions):
dial_positions = self.user2dial(numpy.array(positions,dtype=numpy.float))
step_positions = dial_positions * self.steps_per_unit
return self.__controller.set_event_positions(self,step_positions)
@lazy_init
def get_event_positions(self):
step_positions = numpy.array(self.__controller.get_event_positions(self),
dtype=numpy.float)
dial_positions = self.dial2user(step_positions)
return dial_positions / self.steps_per_unit
class AxisRef(object):
"""Object representing a named reference to an :class:`Axis`."""
......
......@@ -62,3 +62,11 @@ class Encoder(object):
self.controller.set_encoder(self, new_value*self.steps_per_unit)
return self.read()
@lazy_init
def set_event_positions(self, positions):
return self.__controller.set_event_positions(self,positions)
@lazy_init
def get_event_positions(self, positions):
return self.__controller.get_event_positions(self)
......@@ -313,6 +313,21 @@ class Controller(object):
def set_acceleration(self, axis, new_acc):
raise NotImplementedError
def set_event_positions(self, axis_or_encoder, positions):
"""
This method is use to load into the controller
a list of positions for event/trigger.
The controller should generate an event
(mainly electrical pulses) when the axis or
the encoder pass through one of this position.
"""
raise NotImplementedError
def get_event_positions(self, axis_or_encoder):
"""
@see set_event_position
"""
raise NotImplementedError
class CalcController(Controller):
......
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