Commit 0a5f1f91 authored by Matias Guijarro's avatar Matias Guijarro
Browse files

fix issue #1601: call initialize_axis() after settings are set

Added "test" in mockup controller code
parent 315a8b56
......@@ -866,7 +866,6 @@ class Axis:
return position
@_set_position.setter
@lazy_init
def _set_position(self, new_set_pos):
new_set_pos = float(
new_set_pos
......@@ -937,7 +936,6 @@ class Axis:
return dial_pos
@dial.setter
@lazy_init
def dial(self, new_dial):
if self.is_moving:
raise RuntimeError(
......@@ -987,7 +985,6 @@ class Axis:
return pos
@position.setter
@lazy_init
def position(self, new_pos):
log_debug(self, "axis.py : position(new_pos=%r)" % new_pos)
if self.is_moving:
......@@ -1177,7 +1174,6 @@ class Axis:
return _user_vel
@velocity.setter
@lazy_init
def velocity(self, new_velocity):
# Write -> Converts into motor units to change velocity of axis."
new_velocity = float(
......@@ -1212,7 +1208,6 @@ class Axis:
return _acceleration
@acceleration.setter
@lazy_init
def acceleration(self, new_acc):
if self.is_moving:
raise RuntimeError(
......@@ -1242,7 +1237,6 @@ class Axis:
return self.velocity / self.acceleration
@acctime.setter
@lazy_init
def acctime(self, new_acctime):
# Converts acctime into acceleration.
new_acctime = float(
......@@ -1294,7 +1288,6 @@ class Axis:
return tuple(map(self.dial2user, self.dial_limits))
@limits.setter
@lazy_init
def limits(self, limits):
# Set limits (low, high) in user units.
try:
......@@ -1316,7 +1309,6 @@ class Axis:
return self.dial2user(ll)
@low_limit.setter
@lazy_init
def low_limit(self, limit):
# Sets Low Limit
# <limit> must be given in USER units
......@@ -1334,7 +1326,6 @@ class Axis:
return self.dial2user(hl)
@high_limit.setter
@lazy_init
def high_limit(self, limit):
# Sets High Limit (given in USER units)
# Saved in settings in DIAL units.
......
......@@ -53,7 +53,7 @@ class Controller:
self.__initialized_hw_axis = dict()
self.__initialized_encoder = dict()
self.__initialized_axis = dict()
self.__lock = lock.RLock() # Semaphore()
self.__lock = lock.RLock()
self._axes_config = axes
self._axes = dict()
self._encoders_config = encoders
......@@ -171,35 +171,35 @@ class Controller:
def _initialize_axis(self, axis, *args, **kwargs):
"""
"""
with self.__lock:
# Only if axis is not already initialized.
if self.__initialized_axis[axis]:
return
if self.__initialized_axis[axis]:
return
with self.__lock:
# Initialize controller hardware only once.
if not self.__initialized_hw.value:
self.initialize_hardware()
self.__initialized_hw.value = True
# Call specific axis initialization.
self.initialize_axis(axis)
# Call specific hardware axis initialization.
# Done only once even in case of multi clients.
axis_initialized = self.__initialized_hw_axis[axis]
if not axis_initialized.value:
self.initialize_hardware_axis(axis)
axis_initialized.value = 1
# Consider axis is initialized => prevent re-entering
# _initialize_axis in lazy_init
self.__initialized_axis[axis] = True
# Apply settings but for NoSettingsAxis.
if isinstance(axis, NoSettingsAxis):
return
else:
try:
self._init_settings(axis)
# Call specific axis initialization.
self.initialize_axis(axis)
# Call specific hardware axis initialization.
# Done only once even in case of multi clients.
axis_initialized = self.__initialized_hw_axis[axis]
if not axis_initialized.value:
self.initialize_hardware_axis(axis)
axis_initialized.value = 1
# Apply settings but for NoSettingsAxis.
if not isinstance(axis, NoSettingsAxis):
self._init_settings(axis)
except BaseException:
# Failed to initialize
self.__initialized_axis[axis] = False
raise
......
......@@ -109,6 +109,11 @@ class Mockup(Controller):
axis.settings.set("init_count", axis.settings.get("init_count") + 1)
axis.stop_jog_called = False
# the next lines are there to test issue #1601
old_low_limit = axis.low_limit
axis.low_limit = -999
axis.low_limit = old_low_limit
def initialize_encoder(self, encoder):
enc_config = self.__encoders.setdefault(encoder, {})
enc_config.setdefault("measured_noise", None)
......
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