Commit dc9f7da9 authored by blissadm's avatar blissadm

*get_infos() position()

parent f41a9678
......@@ -32,22 +32,24 @@ class PI_E517(Controller):
# Init of each axis.
def initialize_axis(self, axis):
# ONL ?
# Enables the closed-loop.
# self.sock.write("SVO 1 1\n")
axis.channel = axis.config.get("channel")
axis.chan_letter = axis.config.get("chan_letter")
add_axis_method(axis, self.get_id)
add_axis_method(axis, self.get_infos)
def position(self, axis, new_position=None, measured=False):
if new_position is not None:
pass
if measured:
_ans = self._get_pos()
else:
_ans = self._get_target_pos()
if new_position is None:
if measured:
_ans = self._get_pos(axis)
else:
_ans = self._get_target_pos(axis)
return _ans
......@@ -86,18 +88,22 @@ class PI_E517(Controller):
E517 specific communication
"""
# adds the terminator cheracter.
def send(self, axis, cmd):
_chan = axis.channel
_cmd = cmd + "\n"
print "Send %s to %s"%(cmd, _chan)
print "Sends %s to %s"%(repr(_cmd), _chan)
_ans = self.sock.write_readline(_cmd)
print "Received %s from %s"%(repr(_ans), _chan)
return _ans
# adds the terminator cheracter.
def send_no_ans(self, axis, cmd):
_chan = axis.channel
_cmd = cmd + "\n"
print "Send %s to %s"%(cmd, _chan)
print "Sends (no ans) %s to %s"%(repr(_cmd), _chan)
self.sock.write(_cmd)
......@@ -105,9 +111,7 @@ class PI_E517(Controller):
'''
Returns real position read by capcitive captor.
'''
_ans = self.send("POS? %s"%axis.chan_letter)
print "position POS:", _ans
_ans = self.send(axis, "POS? %s"%axis.chan_letter)
# _ans should looks like ""
# "\n" removed by tcp lib.
......@@ -115,18 +119,20 @@ class PI_E517(Controller):
return _pos
# def _get_target_pos(self):
# '''
# Returns last target position (setpoint value).
# '''
# _ans = self.sock.write_readline("MOV?\n")
#
# # _ans should looks like "1=-8.45709419e+01\n"
# # "\n" removed by tcp lib.
# _pos = float(_ans[2:])
#
# return _pos
#
def _get_target_pos(self, axis):
'''
Returns last target position (setpoint value).
'''
_ans = self.send(axis, "MOV? %s"%axis.chan_letter)
# _ans should looks like 'C=+0001.2345'
# "\n" removed by tcp lib.
# removes 'X=' prefix
_pos = float(_ans[2:])
return _pos
def get_id(self, axis):
return self.send(axis, "IDN?\n")
......@@ -161,46 +167,70 @@ class PI_E517(Controller):
#
# def _set_velocity(self, velocity):
# self.sock.write("VEL 1 %f\n"%velocity)
#
# '''
# Returns a set of usefull information about controller.
# Can be helpful to tune the device.
# '''
# def _get_infos(self):
# _infos = [
# ("Identifier ", "IDN?\n"),
# ("Com level ", "CCL?\n"),
# ("Real Position ", "POS?\n"),
# ("Setpoint Position ", "MOV?\n"),
# ("Position low limit ", "SPA? 1 0x07000000\n"),
# ("Position High limit ", "SPA? 1 0x07000001\n"),
# ("Velocity ", "VEL?\n"),
# ("On target ", "ONT?\n"),
# ("Target tolerance ", "SPA? 1 0X07000900\n"),
# ("Settling time ", "SPA? 1 0X07000901\n"),
# ("Sensor Offset ", "SPA? 1 0x02000200\n"),
# ("Sensor Gain ", "SPA? 1 0x02000300\n"),
# ("Motion status ", "#5\n"),
# ("Closed loop status ", "SVO?\n"),
# ("Auto Zero Calibration ? ", "ATZ?\n"),
# ("Analog input setpoint ", "AOS?\n"),
# ("Low Voltage Limit ", "SPA? 1 0x07000A00\n"),
# ("High Voltage Limit ", "SPA? 1 0x07000A01\n")
# ]
#
# _txt = ""
#
# for i in _infos:
# _txt = _txt + " %s %s\n"%(i[0],
# self.sock.write_readline(i[1]))
#
# _txt = _txt + " %s \n%s\n"%("Communication parameters",
# "\n".join(self.sock.write_readlines("IFC?\n", 5)))
#
'''
Returns a set of usefull information about controller.
Can be helpful to tune the device.
'''
def get_infos(self, axis):
_infos = [
("Identifier ", "*IDN?"),
("Serial Number ", "SSN?"),
("Com level ", "CCL?"),
("GCS Syntax version ", "CSV?"),
("Last error code ", "ERR?"),
("Real Position ", "POS? %s"%axis.chan_letter),
("Position low limit ", "NLM? %s"%axis.chan_letter),
("Position high limit ", "PLM? %s"%axis.chan_letter),
("Closed loop status ", "SVO? %s"%axis.chan_letter),
("Voltage output high limit ", "VMA? %s"%axis.chan_letter),
("Voltage output low limit ", "VMI? %s"%axis.chan_letter),
("Output Voltage ", "VOL? %s"%axis.channel),
("Setpoint Position ", "MOV? %s"%axis.chan_letter),
("Drift compensation Offset ", "DCO? %s"%axis.chan_letter),
("Online ", "ONL? %s"%axis.chan_letter),
("On target ", "ONT? %s"%axis.chan_letter),
("ADC Value of input signal ", "TAD? %s"%axis.chan_letter),
("Velocity control mode ", "VCO? %s"%axis.chan_letter),
("Velocity ", "VEL? %s"%axis.chan_letter),
("Osensor ", "SPA? %s 0x02000200"%axis.channel),
("Ksensor ", "SPA? %s 0x02000300"%axis.channel),
# (" ", "? %s"%axis.chan_letter),
# ("Setpoint Position ", "MOV?"),
# ("Position low limit ", "SPA? 1 0x07000000"),
# ("Position High limit ", "SPA? 1 0x07000001"),
# ("Velocity ", "VEL?"),
# ("On target ", "ONT?"),
# ("Target tolerance ", "SPA? 1 0X07000900"),
# ("Settling time ", "SPA? 1 0X07000901"),
# ("Sensor Offset ", "SPA? 1 0x02000200"),
# ("Sensor Gain ", "SPA? 1 0x02000300"),
# ("Motion status ", "#5"),
# ("Auto Zero Calibration ? ", "ATZ?"),
# ("Analog input setpoint ", "AOS?"),
# ("Low Voltage Limit ", "SPA? 1 0x07000A00"),
# ("High Voltage Limit ", "SPA? 1 0x07000A01")
]
_txt = ""
for i in _infos:
_txt = _txt + " %s %s\n"%(i[0],
self.send(axis, i[1]))
_txt = _txt + " %s \n%s\n"%("Communication parameters",
"\n".join(self.sock.write_readlines("IFC?\n", 6)))
_txt = _txt + " %s \n%s\n"%("Firmware version",
"\n".join(self.sock.write_readlines("VER?\n", 3)))
# _txt = _txt + " %s \n%s\n"%("Analog setpoints",
# "\n".join(self.sock.write_readlines("TSP?\n", 2)))
# _txt = _txt + " %s \n%s\n"%("ADC value of analog input",
# "\n".join(self.sock.write_readlines("TAD?\n", 2)))
#
# return _txt
#
return _txt
......@@ -45,23 +45,18 @@ class TestPI_E517Controller(unittest.TestCase):
pz = bliss.get_axis("pz")
print "E517 IDN :", pz.get_id()
def test_get_position(self):
pz = bliss.get_axis("pz")
print "E517 pz position :", pz.position()
def test_get_axis(self):
pz = bliss.get_axis("pz")
self.assertTrue(pz)
def test_get_infos(self):
pz = bliss.get_axis("pz")
print "E517 INFOS :\n", pz.get_infos()
# def test_get_axis(self):
# pz = bliss.get_axis("pz")
# self.assertTrue(pz)
#
# def test_controller_from_axis(self):
# pz = bliss.get_axis("pz")
# self.assertEqual(pz.controller.name, "testid16")
#
# def test_get_position(self):
# pz = bliss.get_axis("pz")
# print "E517 position :", pz.position()
#
#
# def test_get_infos(self):
# pz = bliss.get_axis("pz")
# print "E517 INFOS :\n", pz.controller._get_infos()
# # called at end of each test
# def tearDown(self):
......
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