Commit b453c094 authored by blissadm's avatar blissadm

acceleration in felxdc and DS

parent 090a8429
......@@ -24,8 +24,12 @@ class FlexDC(Controller):
def __init__(self, name, config, axes):
Controller.__init__(self, name, config, axes)
# Gets host from xml config.
self.host = self.config.get("host")
# Adds acceleration as a setting.
self.axis_settings.add('acceleration', float)
# Init of controller.
def initialize(self):
# print "FLEXDC CONTROLLER initialize"
......@@ -43,16 +47,14 @@ class FlexDC(Controller):
axis.target_radius = axis.config.get("target_radius", int)
axis.target_time = axis.config.get("target_time", int)
axis.smoothing = axis.config.get("smoothing", int)
axis.acceleration = axis.config.get("acceleration", int)
#axis.acceleration = axis.config.get("acceleration", int)
axis.deceleration = axis.config.get("deceleration", int)
# should be automatic ?
# axis.settings.set('velocity', axis.config.get("velocity", float))
axis.settings.set('acceleration', axis.config.get("acceleration", float))
add_axis_method(axis, self.get_id)
add_axis_method(axis, self.get_info)
add_axis_method(axis, self.acceleration)
# Enabling servo mode.
self._flexdc_query("%sMO=1"%axis.channel)
......@@ -86,13 +88,15 @@ class FlexDC(Controller):
if _ans == "0":
print "Missing closed loop param TR (Target Radius)!!"
# Acceleration
self._flexdc_query("%sAC=%d"%(axis.channel, axis.acceleration))
# Set config acceleration to the controller.
self._flexdc_query("%sAC=%d"%(axis.channel, axis.settings.get("acceleration")))
# Deceleration
# Set config deceleration to the controller.
self._flexdc_query("%sDC=%d"%(axis.channel, axis.deceleration))
print "FLEXDC end of initialize_axis"
# Config velocity is automatically set.
# print "FLEXDC end of initialize_axis"
def position(self, axis, new_position=None, measured=False):
......@@ -167,10 +171,26 @@ class FlexDC(Controller):
FlexDC specific.
'''
def acceleration(self, axis, new_acc=None):
if new_acc is None:
# read from controller or cache ???
# ...controller
print "bliss read Acceleration"
_acc = self._flexdc_query("%sAC"%axis.channel)
axis.settings.set("acceleration", _acc)
else:
print "bliss write Acceleration", new_acc
self._flexdc_query("%sAC=%d"%(axis.channel, new_acc))
axis.settings.set("acceleration", new_acc)
return axis.settings.get("acceleration")
#
def _flexdc_query(self, cmd):
# Adds "\r" at end of command.
# TODO : test if already present ?
print "SENDING : ",cmd
_cmd = cmd + "\r"
# Adds ACK character:
......
......@@ -106,6 +106,9 @@ class BlissAxis(PyTango.Device_4Impl):
attr = self.get_device_attr().get_attr_by_name("Velocity")
attr.set_write_value(float(self.axis.velocity()))
attr = self.get_device_attr().get_attr_by_name("Acceleration")
attr.set_write_value(float(self.axis.acceleration()))
self.once = True
except:
print "ERROR : Cannot set one of attributs write value."
......@@ -181,14 +184,22 @@ class BlissAxis(PyTango.Device_4Impl):
def read_Acceleration(self, attr):
self.debug_stream("In read_Acceleration()")
attr.set_value(self.attr_Acceleration_read)
try:
_acc = self.axis.acceleration()
self.debug_stream("In read_Acceleration(%f)"%float(_acc))
attr.set_value(_acc)
except:
traceback.print_exc()
raise
def write_Acceleration(self, attr):
data=attr.get_write_value()
self.debug_stream("In write_Acceleration(%f)"%float(data))
try:
data=float(attr.get_write_value())
self.debug_stream("In write_Acceleration(%f)"%data)
self.axis.acceleration(data)
except:
traceback.print_exc()
raise
def read_AccTime(self, attr):
......@@ -427,7 +438,7 @@ class BlissAxisClass(PyTango.DeviceClass):
{
'label': "Acceleration",
'unit': "units/s^2",
'format': "%6.3f",
'format': "%10.3f",
'description': "The acceleration of the motor.",
'Display level': PyTango.DispLevel.EXPERT,
'Memorized':"true"
......@@ -501,7 +512,7 @@ class BlissAxisClass(PyTango.DeviceClass):
{
'label': "Preset Position",
'unit': "mm",
'format': "%6.3f",
'format': "%10.3f",
'description': "preset the position in the step counter",
'Display level': PyTango.DispLevel.EXPERT,
} ],
......@@ -512,7 +523,7 @@ class BlissAxisClass(PyTango.DeviceClass):
{
'label': "first step velocity",
'unit': "units/s",
'format': "%6.3f",
'format': "%10.3f",
'description': "number of unit/s for the first step and for the move reference",
'Display level': PyTango.DispLevel.EXPERT,
'Memorized':"true"
......@@ -530,7 +541,7 @@ class BlissAxisClass(PyTango.DeviceClass):
PyTango.READ_WRITE],
{
'unit': "mm",
'format': "%6.3f",
'format': "%10.3f",
'description': "Size of the relative step performed by the StepUp and StepDown commands.\nThe StepSize is expressed in physical unit.",
'Display level': PyTango.DispLevel.EXPERT,
'Memorized':"true"
......
......@@ -61,6 +61,12 @@ class TestFlexDCController(unittest.TestCase):
print "FlexDC read velocity :", _read_vel
self.assertEqual(_read_vel, 1234)
def test_acceleration(self):
fd = bliss.get_axis("fd")
_read_acc = fd.settings.get("acceleration")
print "FlexDC read acceleration :", _read_acc
self.assertEqual(_read_acc, 1111)
def test_get_info(self):
fd = bliss.get_axis("fd")
print "FlexDC INFOS :\n", fd.get_info()
......
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