Commit 090a8429 authored by blissadm's avatar blissadm

controllers development

parent ad777ae9
......@@ -28,16 +28,16 @@ class FlexDC(Controller):
# Init of controller.
def initialize(self):
print "FLEXDC CONTROLLER initialize"
# print "FLEXDC CONTROLLER initialize"
self.sock = tcp.Socket(self.host, 4000)
def finalize(self):
print "FLEXDC CONTROLLER finalize"
# print "FLEXDC CONTROLLER finalize"
self.sock.close()
# Init of each axis.
def initialize_axis(self, axis):
print "FLEXDC initialize_axis"
# print "FLEXDC initialize_axis"
axis.channel = axis.config.get("channel")
axis.target_radius = axis.config.get("target_radius", int)
......@@ -46,7 +46,9 @@ class FlexDC(Controller):
axis.acceleration = axis.config.get("acceleration", int)
axis.deceleration = axis.config.get("deceleration", int)
axis.settings.set('velocity', axis.config.get("velocity", float))
# should be automatic ?
# axis.settings.set('velocity', axis.config.get("velocity", float))
add_axis_method(axis, self.get_id)
add_axis_method(axis, self.get_info)
......@@ -88,10 +90,10 @@ class FlexDC(Controller):
self._flexdc_query("%sAC=%d"%(axis.channel, axis.acceleration))
# Deceleration
self._flexdc_query("%sAD=%d"%(axis.channel, axis.deceleration))
self._flexdc_query("%sDC=%d"%(axis.channel, axis.deceleration))
print "FLEXDC end of initialize_axis"
# Velocity
self._flexdc_query("%sSP=%s"%(axis.channel, axis.velocity()))
def position(self, axis, new_position=None, measured=False):
if new_position is None:
......@@ -115,8 +117,10 @@ class FlexDC(Controller):
def velocity(self, axis, new_velocity=None):
if new_velocity is None:
_velocity = self._flexdc_query("%sSP"%axis.channel)
print "FLEXDC read velocity"
_velocity = float(self._flexdc_query("%sSP"%axis.channel))
else:
print "FLEXDC write velocity (%g)"%new_velocity
self._flexdc_query("%sSP=%d"%(axis.channel, new_velocity))
_velocity = new_velocity
......@@ -142,20 +146,20 @@ class FlexDC(Controller):
else:
_ret = READY
print "FLEXDC state :", _ret
#print "FLEXDC state :", _ret
return _ret
def prepare_move(self, axis, target_pos, delta):
print "FLEXDC prepare_move, target_pos=", target_pos
#print "FLEXDC prepare_move, target_pos=", target_pos
self._flexdc_query("%sAP=%d"%(axis.channel, int(target_pos)))
def start_move(self, axis, target_pos, delta):
print "FLEXDC start_move, target_pos=", target_pos
#print "FLEXDC start_move, target_pos=", target_pos
self._flexdc_query("%sBG"%axis.channel)
def stop(self, axis):
print "FLEXDC stop"
#print "FLEXDC stop"
_ans = self._flexdc_query("%sST"%axis.channel)
......
......@@ -79,6 +79,22 @@ class PI_E517(Controller):
E517 specific communication
"""
def _send(self, axis, cmd):
_chan = axis.channel
_cmd = cmd + "\n"
print "Send %s to %s"%(cmd, _chan)
_ans = self.sock.write_readline()
return _ans
def _send_no_ans(self, axis, cmd):
_chan = axis.channel
_cmd = cmd + "\n"
print "Send %s to %s"%(cmd, _chan)
self.sock.write(_cmd)
def _get_pos(self):
'''
Returns real position read by capcitive captor.
......
......@@ -7,9 +7,9 @@
<target_radius value="20"/>
<target_time value="10"/>
<smoothing value="4"/>
<acceleration value="1000"/>
<deceleration value="1000"/>
<velocity value="1000"/>
<acceleration value="1111"/>
<deceleration value="1010"/>
<velocity value="1234"/>
</axis>
</controller>
</config>
......
......@@ -21,9 +21,9 @@ config_xml = """
<target_radius value="20"/>
<target_time value="10"/>
<smoothing value="4"/>
<acceleration value="1000"/>
<deceleration value="1000"/>
<velocity value="1000"/>
<acceleration value="1111"/>
<deceleration value="1010"/>
<velocity value="1234"/>
</axis>
</controller>
</config>
......@@ -57,7 +57,9 @@ class TestFlexDCController(unittest.TestCase):
def test_velocity(self):
fd = bliss.get_axis("fd")
print "FlexDC velocity :", fd.velocity()
_read_vel = fd.velocity()
print "FlexDC read velocity :", _read_vel
self.assertEqual(_read_vel, 1234)
def test_get_info(self):
fd = bliss.get_axis("fd")
......@@ -94,9 +96,9 @@ load_cfg_fromstring("""<config>
<target_radius value="20"/>
<target_time value="10"/>
<smoothing value="4"/>
<acceleration value="1000"/>
<deceleration value="1000"/>
<velocity value="1000"/>
<acceleration value="1111"/>
<deceleration value="1010"/>
<velocity value="1234"/>
</axis>
</controller>
</config>
......
......@@ -9,8 +9,27 @@ import bliss
config_xml = """
<config>
<controller class="PI_E517" name="testid16">
<host value="e517id16ni-mlm"/>
<host value="e517pela"/>
<axis name="px">
<channel value="1"/>
<chan_letter value="A"/>
<acceleration value="123"/>
<deceleration value="321"/>
<velocity value="432"/>
</axis>
<axis name="py">
<channel value="2"/>
<chan_letter value="B"/>
<acceleration value="123"/>
<deceleration value="321"/>
<velocity value="432"/>
</axis>
<axis name="pz">
<channel value="3"/>
<chan_letter value="C"/>
<acceleration value="123"/>
<deceleration value="321"/>
<velocity value="432"/>
</axis>
</controller>
</config>
......@@ -61,41 +80,37 @@ if __name__ == '__main__':
'''
NI Interactive test :
load_cfg_fromstring("""<config>
load_cfg_fromstring("""
<config>
<controller class="PI_E517" name="testid16">
<host value="e517id16ni-mlm"/>
<axis name="pz">
<host value="e517pela"/>
<axis name="px">
<channel value="1"/>
<acceleration value="123"/>
<deceleration value="321"/>
<velocity value="432"/>
</axis>
<axis name="py">
<channel value="2"/>
<acceleration value="123"/>
<deceleration value="321"/>
<velocity value="432"/>
</axis>
</controller>
</config>
""")
a=get_axis("pz")
print a.controller.sock.write_readline("IDN?\n")
print a.controller._get_infos()
'''
'''
NA Interactive test :
load_cfg_fromstring("""<config>
<controller class="PI_E517" name="testid16">
<host value="e517id16na-dmir"/>
<axis name="pz">
<channel value="3"/>
<acceleration value="123"/>
<deceleration value="321"/>
<velocity value="432"/>
</axis>
</controller>
</config>
""")
a=get_axis("pz")
print a.controller.sock.write_readline("IDN?\n")
print a.controller._get_infos()
a=get_axis("px")
b=get_axis("py")
c=get_axis("pz")
'''
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