Commit 041d176e authored by blissadm's avatar blissadm

acceleration in user unit

parent b7f6119d
......@@ -202,21 +202,33 @@ class FlexDC(Controller):
Flexdc works in steps/s2
<new_acc> is in user-unit/s2
"""
_spu = self.steps_per_unit()
_spu = axis.steps_per_unit()
if new_acc is None:
""" Reads acceleration from flexdc in steps/s2"""
_acc_spss = float(self._flexdc_query("%sAC" % axis.channel))
_acc = _acc_spss / _spu
flexdc_debug("bliss read Acceleration : _acc=%g spu=%g _acc_spss=%g " % (_acc, _spu, _acc_spss))
axis.settings.set("acceleration", _acc)
try:
_acc_spss = float(self._flexdc_query("%sAC" % axis.channel))
_acc = _acc_spss / _spu
flexdc_debug("bliss read Acceleration : _acc=%g spu=%g _acc_spss=%g " % (_acc, _spu, _acc_spss))
axis.settings.set("acceleration", _acc)
except:
print "marche pas pas"
sys.excepthook(sys.exc_info()[0],
sys.exc_info()[1],
sys.exc_info()[2])
else:
""" Set acceleration """
_new_acc_spss = new_acc * _spu
self._flexdc_query("%sAC=%d" % (axis.channel, _new_acc_spss))
flexdc_debug( "bliss write Acceleration : new_acc=%g, _spu=%g, _new_acc_spss=%g" % (new_acc, _spu, _new_acc_spss))
# Settings work in user-unit/s2
axis.settings.set("acceleration", new_acc)
try:
_new_acc_spss = new_acc * _spu
self._flexdc_query("%sAC=%d" % (axis.channel, _new_acc_spss))
flexdc_debug( "bliss write Acceleration : new_acc=%g, _spu=%g, _new_acc_spss=%g" % (new_acc, _spu, _new_acc_spss))
# Settings work in user-unit/s2
axis.settings.set("acceleration", new_acc)
except:
print "marche pas"
sys.excepthook(sys.exc_info()[0],
sys.exc_info()[1],
sys.exc_info()[2])
return axis.settings.get("acceleration")
......
......@@ -25,10 +25,12 @@ config_xml = """
<steps_per_unit value="13111"/>
<target_radius value="20"/>
<target_time value="10"/>
<min_dead_zone value="40" />
<max_dead_zone value="100" />
<smoothing value="4"/>
<acceleration value="1111"/>
<deceleration value="1010"/>
<velocity value="1234"/>
<acceleration value="3"/>
<deceleration value="2"/>
<velocity value="1.2"/>
</axis>
</controller>
</config>
......@@ -65,13 +67,13 @@ class TestFlexDCController(unittest.TestCase):
fd = bliss.get_axis("fd")
_read_vel = fd.velocity()
print "FlexDC read velocity :", _read_vel
self.assertEqual(_read_vel, 1234)
self.assertAlmostEqual(_read_vel, 1.2, places=3)
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)
self.assertEqual(_read_acc, 3)
def test_get_info(self):
fd = bliss.get_axis("fd")
......
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