Commit f44d6251 authored by Cyril Guilloud's avatar Cyril Guilloud

step_size -> steps_per_unit

parent dba6355d
......@@ -68,8 +68,11 @@ class Axis(object):
def measured_position(self):
return self.__controller.read_position(self, measured=True)
def step_size(self):
return self.config.get("step_size", float, 1)
def steps_per_unit(self):
"""
Returns 'steps_per_unit' config value (float).
"""
return self.config.get("steps_per_unit", float, 1)
def position(self, new_pos=None):
if self.is_moving:
......@@ -88,19 +91,17 @@ class Axis(object):
return pos
def _position(self, new_pos=None, measured=False):
new_pos = new_pos * self.step_size() if new_pos is not None else None
new_pos = new_pos * self.steps_per_unit() if new_pos is not None else None
if new_pos is not None:
try:
return self.__controller.set_position(
self, new_pos) / self.step_size()
return self.__controller.set_position(self, new_pos) / self.steps_per_unit()
except NotImplementedError:
self.__settings.set(
"offset",
(self.__controller.read_position(self) - new_pos) / self.
step_size())
(self.__controller.read_position(self) - new_pos) / self.steps_per_unit())
return self.position()
else:
return (self.__controller.read_position(self, measured) / self.step_size()) - self.offset
return (self.__controller.read_position(self, measured) / self.steps_per_unit()) - self.offset
def state(self):
if self.is_moving:
......@@ -164,9 +165,9 @@ class Axis(object):
user_target_pos += initial_pos
user_backlash = self.config.get("backlash", float, 0)
# all positions are converted to controller units
backlash = user_backlash * self.step_size()
delta = (user_target_pos - initial_pos) * self.step_size()
target_pos = (user_target_pos + self.offset) * self.step_size()
backlash = user_backlash * self.steps_per_unit()
delta = (user_target_pos - initial_pos) * self.steps_per_unit()
target_pos = (user_target_pos + self.offset) * self.steps_per_unit()
if backlash:
if cmp(delta, 0) != cmp(backlash, 0):
......@@ -182,8 +183,8 @@ class Axis(object):
# check software limits
user_high_limit = self.settings.get("high_limit")
user_low_limit = self.settings.get("low_limit")
high_limit = user_high_limit * self.step_size()
low_limit = user_low_limit * self.step_size()
high_limit = user_high_limit * self.steps_per_unit()
low_limit = user_low_limit * self.steps_per_unit()
backlash_str = " (with %f backlash)" % user_backlash if backlash else ""
if user_low_limit is not None:
if target_pos < low_limit:
......
......@@ -202,7 +202,7 @@ class FlexDC(Controller):
def steps_per_unit(self, axis, new_step_per_unit=None):
if new_step_per_unit is None:
return float(axis.config.get("step_size"))
return float(axis.config.get("steps_per_unit"))
else:
print "steps_per_unit writing is not (yet?) implemented."
......
......@@ -189,7 +189,7 @@ class PI_E517(Controller):
- ?
"""
if new_step_per_unit is None:
return float(axis.config.get("step_size"))
return float(axis.config.get("steps_per_unit"))
else:
print "steps_per_unit writing is not (yet?) implemented."
......
......@@ -47,7 +47,6 @@ class PI_E753(Controller):
# Init of each axis.
def initialize_axis(self, axis):
e753_debug("axis initialization")
add_axis_method(axis, self.steps_per_unit)
add_axis_method(axis, self.get_info)
# Enables the closed-loop.
......@@ -95,12 +94,6 @@ class PI_E753(Controller):
E753 specific communication
"""
def steps_per_unit(self, axis, new_step_per_unit=None):
if new_step_per_unit is None:
return float(axis.config.get("step_size"))
else:
e753_info("steps_per_unit writing is not (yet?) implemented.")
def _get_velocity(self, axis):
'''
Returns velocity taken from controller.
......
......@@ -290,25 +290,6 @@ class PMD206(Controller):
"""
self.send(axis, "CS=0")
def steps_per_unit(self, axis, new_step_per_unit=None):
"""
-
Args:
- <axis> : Bliss axis object.
- [<new_step_per_unit>] : float :
Returns:
-
Raises:
- ?
"""
if new_step_per_unit is None:
return float(axis.config.get("step_size"))
else:
print "steps_per_unit writing is not (yet?) implemented."
"""
PMD206 specific communication
......
......@@ -4,6 +4,22 @@ from bliss.controllers.motor import add_axis_method
import math
import time
"""
mockup.py : a mockup controller for bliss.
To be used as skeleton to write bliss plugin controller.
"""
def mockup_err(msg):
log.error("[MOCKUP] " + msg)
def mockup_info(msg):
log.info("[MOCKUP] " + msg)
def mockup_debug(msg):
log.debug("[MOCKUP] " + msg)
class Mockup(Controller):
......@@ -62,7 +78,7 @@ class Mockup(Controller):
axis = motion.axis
t0 = t0 or time.time()
pos = self.read_position(axis)
v = self.read_velocity(axis) * axis.step_size()
v = self.read_velocity(axis) * axis.steps_per_unit()
self._axis_moves[axis] = {
"start_pos": pos,
"delta": motion.delta,
......@@ -86,7 +102,7 @@ class Mockup(Controller):
if self._axis_moves[axis]["end_t"]:
# motor is moving
t = time.time()
v = self.read_velocity(axis) * axis.step_size()
v = self.read_velocity(axis) * axis.steps_per_unit()
d = math.copysign(1, self._axis_moves[axis]["delta"])
dt = t - self._axis_moves[axis]["t0"]
pos = self._axis_moves[axis]["start_pos"] + d * dt * v
......
......@@ -71,7 +71,7 @@ def tango_mot_config(motnum, type, unit, module, channel) '{
}
if(type == "mot") {
local _mot_mne _step_size
local _mot_mne _ds_name
_mot_mne = motor_mne(motnum)
_ds_name = tango_mot_ADDR
......@@ -79,6 +79,7 @@ def tango_mot_config(motnum, type, unit, module, channel) '{
# Registers Tango DS name in parameters of the motor.
tango_mot_dbg(sprintf("Registering DS name : \"%s\" for motor \"%s\"", \
_ds_name, _mot_mne))
# GNARKKK cannot use tango_mot_ADDR here directly...
motor_par(motnum, "dev_name", _ds_name, "add")
......@@ -125,7 +126,7 @@ def tango_mot_par(motnum, key, action, p1, p2) '{
#
def tango_mot_cmd(motnum, cmd, p1, p2) '{
local _mot_mne _dev _attr _step_size _cmd
local _mot_mne _dev _attr _step_size _steps _cmd
_mot_mne = motor_mne(motnum)
......
......@@ -324,7 +324,7 @@ class BlissAxis(PyTango.Device_4Impl):
def read_StepSize(self, attr):
self.debug_stream("In read_StepSize()")
attr.set_value(self.axis.step_size())
attr.set_value(self.attr_StepSize_read)
def read_attr_hardware(self, data):
pass
......@@ -460,7 +460,6 @@ class BlissAxisClass(PyTango.DeviceClass):
'Steps_per_unit':
[[PyTango.DevDouble,
PyTango.SCALAR,
# PyTango.READ_WRITE],
PyTango.READ],
{
'label': "Steps per mm",
......@@ -472,7 +471,6 @@ class BlissAxisClass(PyTango.DeviceClass):
'Steps':
[[PyTango.DevLong,
PyTango.SCALAR,
# PyTango.READ_WRITE],
PyTango.READ],
{
'label': "Steps",
......@@ -610,7 +608,7 @@ class BlissAxisClass(PyTango.DeviceClass):
'StepSize':
[[PyTango.DevDouble,
PyTango.SCALAR,
PyTango.READ],
PyTango.READ_WRITE],
{
'unit': "mm",
'format': "%10.3f",
......
......@@ -2,22 +2,22 @@
<controller class="PI_E517" name="id16pela">
<host value="192.168.167.10"/>
<axis name="p4">
<channel value="1"/>
<chan_letter value="A"/>
<velocity value="10"/>
<step_size value="1"/>
<channel value="1"/>
<chan_letter value="A"/>
<velocity value="10"/>
<steps_per_unit value="1"/>
</axis>
<axis name="p5">
<channel value="2"/>
<chan_letter value="B"/>
<velocity value="10"/>
<step_size value="1"/>
<channel value="2"/>
<chan_letter value="B"/>
<velocity value="10"/>
<steps_per_unit value="1"/>
</axis>
<axis name="p6">
<channel value="3"/>
<chan_letter value="C"/>
<velocity value="10"/>
<step_size value="1"/>
<channel value="3"/>
<chan_letter value="C"/>
<velocity value="10"/>
<steps_per_unit value="1"/>
</axis>
</controller>
</config>
......
......@@ -2,22 +2,22 @@
<controller class="PI_E517" name="id16pelb">
<host value="192.168.168.10"/>
<axis name="p1">
<channel value="1"/>
<chan_letter value="A"/>
<velocity value="10"/>
<step_size value="1"/>
<channel value="1"/>
<chan_letter value="A"/>
<velocity value="10"/>
<steps_per_unit value="1"/>
</axis>
<axis name="p2">
<channel value="2"/>
<chan_letter value="B"/>
<velocity value="10"/>
<step_size value="1"/>
<channel value="2"/>
<chan_letter value="B"/>
<velocity value="10"/>
<steps_per_unit value="1"/>
</axis>
<axis name="p3">
<channel value="3"/>
<chan_letter value="C"/>
<velocity value="10"/>
<step_size value="1"/>
<channel value="3"/>
<chan_letter value="C"/>
<velocity value="10"/>
<steps_per_unit value="1"/>
</axis>
</controller>
</config>
......
......@@ -2,16 +2,16 @@
<controller class="FlexDC" name="id16phn">
<host value="flexdcnina"/>
<axis name="srot">
<channel value="X"/>
<step_size value="13111.11"/>
<target_radius value="100"/>
<target_time value="20"/>
<min_dead_zone value="40"/>
<max_dead_zone value="100"/>
<smoothing value="4"/>
<acceleration value="398400"/>
<deceleration value="398400"/>
<velocity value="13111"/>
<channel value="X"/>
<steps_per_unit value="13111.11"/>
<target_radius value="100"/>
<target_time value="20"/>
<min_dead_zone value="40"/>
<max_dead_zone value="100"/>
<smoothing value="4"/>
<acceleration value="398400"/>
<deceleration value="398400"/>
<velocity value="13111"/>
</axis>
</controller>
</config>
......
......@@ -11,35 +11,35 @@
<controller class="FlexDC" name="id16phn">
<host value="flexdcnina"/>
<axis name="fd">
<channel value="X"/>
<step_size value="13111.11"/>
<target_radius value="10"/>
<target_time value="20"/>
<smoothing value="4"/>
<acceleration value="1111"/>
<deceleration value="1010"/>
<velocity value="1234"/>
<channel value="X"/>
<steps_per_unit value="13111.11"/>
<target_radius value="10"/>
<target_time value="20"/>
<smoothing value="4"/>
<acceleration value="1111"/>
<deceleration value="1010"/>
<velocity value="1234"/>
</axis>
</controller>
<controller class="PI_E517" name="testid16">
<host value="e517pela"/>
<axis name="px">
<channel value="1"/>
<chan_letter value="A"/>
<velocity value="12"/>
<step_size value="1"/>
<channel value="1"/>
<chan_letter value="A"/>
<velocity value="12"/>
<steps_per_unit value="1"/>
</axis>
<axis name="py">
<channel value="2"/>
<chan_letter value="B"/>
<velocity value="12"/>
<step_size value="1"/>
<channel value="2"/>
<chan_letter value="B"/>
<velocity value="12"/>
<steps_per_unit value="1"/>
</axis>
<axis name="pz">
<channel value="3"/>
<chan_letter value="C"/>
<velocity value="12"/>
<step_size value="1"/>
<channel value="3"/>
<chan_letter value="C"/>
<velocity value="12"/>
<steps_per_unit value="1"/>
</axis>
</controller>
</config>
......
......@@ -21,14 +21,14 @@ config_xml = """
<controller class="FlexDC" name="id16phn">
<host value="flexdcnina"/>
<axis name="fd">
<channel value="X"/>
<step_size value="13111"/>
<target_radius value="20"/>
<target_time value="10"/>
<smoothing value="4"/>
<acceleration value="1111"/>
<deceleration value="1010"/>
<velocity value="1234"/>
<channel value="X"/>
<steps_per_unit value="13111"/>
<target_radius value="20"/>
<target_time value="10"/>
<smoothing value="4"/>
<acceleration value="1111"/>
<deceleration value="1010"/>
<velocity value="1234"/>
</axis>
</controller>
</config>
......@@ -102,16 +102,16 @@ load_cfg_fromstring("""<config>
<controller class="FlexDC" name="id16phn">
<host value="flexdcnina"/>
<axis name="srot">
<channel value="X"/>
<step_size value="13111.11"/>
<target_radius value="10"/>
<target_time value="20"/>
<min_dead_zone value="4"/>
<max_dead_zone value="10"/>
<smoothing value="4"/>
<acceleration value="398400"/>
<deceleration value="398400"/>
<velocity value="13111"/>
<channel value="X"/>
<steps_per_unit value="13111.11"/>
<target_radius value="10"/>
<target_time value="20"/>
<min_dead_zone value="4"/>
<max_dead_zone value="10"/>
<smoothing value="4"/>
<acceleration value="398400"/>
<deceleration value="398400"/>
<velocity value="13111"/>
</axis>
</controller>
</config>
......
......@@ -30,7 +30,7 @@ config_xml = """
<port value="5000"/>
<axis name="roby">
<backlash value="2"/>
<step_size value="10"/>
<steps_per_unit value="10"/>
<velocity value="2500"/>
</axis>
</controller>
......
......@@ -39,10 +39,10 @@ config_xml = """
<host value="%s"/>
<libdebug value="1"/>
<axis name="mymot">
<address value="%s"/>
<step_size value="2000"/>
<backlash value="0.01"/>
<velocity value="2500"/>
<address value="%s"/>
<steps_per_unit value="2000"/>
<backlash value="0.01"/>
<velocity value="2500"/>
</axis>
</controller>
<group name="eh1">
......
......@@ -29,7 +29,7 @@ config_xml = """
<port value="5000"/>
<axis name="roby" class="MockupAxis">
<backlash value="2"/>
<step_size value="10"/>
<steps_per_unit value="10"/>
<velocity value="2500"/>
</axis>
</controller>
......@@ -47,7 +47,7 @@ class MockupAxis(Axis):
def _handle_move(self, motion):
self.target_pos = motion.target_pos
self.backlash_move = motion.target_pos / \
self.step_size() if motion.backlash else 0
self.steps_per_unit() if motion.backlash else 0
return Axis._handle_move(self, motion)
......@@ -132,14 +132,14 @@ class TestMockupController(unittest.TestCase):
move_greenlet.join()
self.assertEqual(roby.position(), 180)
def test_axis_stepsize(self):
def test_axis_steps_per_unit(self):
roby = bliss.get_axis("roby")
self.assertEqual(roby.state(), "READY")
move_greenlet = roby.move(180, wait=False)
self.assertEqual(roby.state(), "MOVING")
move_greenlet.join()
self.assertEqual(roby.state(), "READY")
self.assertEqual(roby.target_pos, roby.step_size() * 180)
self.assertEqual(roby.target_pos, roby.steps_per_unit() * 180)
def test_axis_set_pos(self):
roby = bliss.get_axis("roby")
......
......@@ -28,7 +28,7 @@ config_xml = """<config>
<port value="5000"/>
<axis name="roby">
<backlash value="2"/>
<step_size value="10"/>
<steps_per_unit value="10"/>
<velocity value="2500"/>
</axis>
</controller>
......
......@@ -22,19 +22,19 @@ config_xml = """
</axis>
<axis name="s1f">
<velocity value="500"/>
<step_size value="-10"/>
<steps_per_unit value="-10"/>
</axis>
<axis name="s1b">
<velocity value="500"/>
<step_size value="10"/>
<steps_per_unit value="10"/>
</axis>
<axis name="s1u">
<velocity value="500"/>
<step_size value="-10"/>
<steps_per_unit value="-10"/>
</axis>
<axis name="s1d">
<velocity value="500"/>
<step_size value="10"/>
<steps_per_unit value="10"/>
</axis>
</controller>
<controller class="slits" name="test">
......
Markdown is supported
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