Commit 125466f1 authored by Jibril Mammeri's avatar Jibril Mammeri Committed by Matias Guijarro
Browse files

Update message for invalid velocity

parent 4a2be3a0
Pipeline #43008 failed with stages
in 104 minutes and 53 seconds
......@@ -20,7 +20,7 @@ from bliss.common import event
from bliss.common.greenlet_utils import protect_from_one_kill
from bliss.common.utils import with_custom_members, safe_get
from bliss.config.channels import Channel
from bliss.common.logtools import log_debug, user_print
from bliss.common.logtools import log_debug, user_print, log_warning
from bliss.common.utils import rounder
from bliss.common.utils import autocomplete_property
from bliss.comm.exceptions import CommunicationError
......@@ -1273,9 +1273,31 @@ class Axis(Scannable):
) # accepts both float or numpy array of 1 element
self.__controller.set_velocity(self, new_velocity * abs(self.steps_per_unit))
if new_velocity < 0:
raise RuntimeError(
"Invalid velocity, the velocity cannot be a negative value"
self, new_velocity * abs(self.steps_per_unit)
except Exception as err:
raise ValueError(
"Cannot set value {} for {}".format(new_velocity,
) from err
_user_vel = self.__controller.read_velocity(self) / abs(self.steps_per_unit)
if new_velocity != _user_vel:
f"Controller velocity ({_user_vel}) is different from set velocity ({new_velocity})",
self.settings.set("velocity", _user_vel)
return _user_vel
......@@ -126,7 +126,7 @@ def test_1st_time_cfg_wrong_acc_vel(beacon, beacon_directory):
assert m.acceleration == 100
m = beacon.get("invalid_vel")
with pytest.raises(RuntimeError):
with pytest.raises(ValueError):
m.config.set("velocity", 10)
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