Commit 524ba28c authored by Benoit Formet's avatar Benoit Formet Committed by Matias Guijarro
Browse files

umv: display updated reals position

parent 5e265e54
......@@ -61,6 +61,7 @@ class _Group(object):
self.__name = name
self._group_move = GroupMove(self)
self._axes = dict(axes_dict)
self._axes_with_reals = self._expand_axes_with_reals(self.axes.copy())
def __info__(self):
info = "MOTOR GROUP:"
......@@ -77,6 +78,34 @@ class _Group(object):
def axes(self):
return self._axes
@property
def axes_with_reals(self):
return self._axes_with_reals
def _expand_axes_with_reals(self, axes_with_reals):
""" return axes dict in argument with all reals added to it
"""
from bliss.controllers.motor import CalcController
seen_mot_list = list()
more_calc = True
while more_calc is True:
more_calc = False
mot_list = list(axes_with_reals.values())
for mot in mot_list:
if (
isinstance(mot.controller, CalcController)
and mot not in seen_mot_list
):
for real in mot.controller.reals:
axes_with_reals[real.name] = real
if isinstance(real.controller, CalcController):
more_calc = True
seen_mot_list.append(mot)
return axes_with_reals
@property
def is_moving(self):
return self._group_move.is_moving or any(
......@@ -110,16 +139,30 @@ class _Group(object):
@property
def position(self):
positions_dict = dict()
for axis in self.axes.values():
positions_dict[axis] = axis.position
return positions_dict
return self._dial_or_position("position")
@property
def dial(self):
return self._dial_or_position("dial")
@property
def position_with_reals(self):
return self._dial_or_position("position", with_reals=True)
@property
def dial_with_reals(self):
return self._dial_or_position("dial", with_reals=True)
def _dial_or_position(self, attr, with_reals=False):
positions_dict = dict()
for axis in self.axes.values():
positions_dict[axis] = axis.dial
if with_reals:
axes = self._axes_with_reals
else:
axes = self.axes
for axis in axes.values():
positions_dict[axis] = getattr(axis, attr)
return positions_dict
def _check_ready(self):
......
......@@ -843,9 +843,10 @@ def umvdr(*args):
def __umove(*args, **kwargs):
kwargs["wait"] = False
group, motor_pos = __move(*args, **kwargs)
motors = list(group.axes_with_reals.values())
with error_cleanup(group.stop):
motor_names = list()
for axis in motor_pos:
for axis in motors:
if axis.unit:
motor_names.append(
"{}[{}]".format(global_map.alias_or_name(axis), axis.unit)
......@@ -864,28 +865,28 @@ def __umove(*args, **kwargs):
magic_char = "\033[F"
while group.is_moving:
positions = group.position
dials = group.dial
positions = group.position_with_reals
dials = group.dial_with_reals
row = "".join(
[
"user ",
__row_positions(positions, motor_pos, rfmt, sep=" "),
__row_positions(positions, motors, rfmt, sep=" "),
"\ndial ",
__row_positions(dials, motor_pos, rfmt, sep=" "),
__row_positions(dials, motors, rfmt, sep=" "),
]
)
ret_depth = magic_char * row.count("\n")
print("{}{}".format(ret_depth, row), end="", flush=True)
sleep(0.1)
# print last time for final positions
positions = group.position
dials = group.dial
positions = group.position_with_reals
dials = group.dial_with_reals
row = "".join(
[
"user ",
__row_positions(positions, motor_pos, rfmt, sep=" "),
__row_positions(positions, motors, rfmt, sep=" "),
"\ndial ",
__row_positions(dials, motor_pos, rfmt, sep=" "),
__row_positions(dials, motors, rfmt, sep=" "),
]
)
ret_depth = magic_char * row.count("\n")
......
Supports Markdown
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