Commit b0545a98 authored by Matias Guijarro's avatar Matias Guijarro Committed by Cyril Guilloud
Browse files

Resolve "user message"

parent 028e3d7f
...@@ -1268,7 +1268,7 @@ class Axis(Scannable): ...@@ -1268,7 +1268,7 @@ class Axis(Scannable):
@velocity.setter @velocity.setter
@lazy_init @lazy_init
def velocity(self, new_velocity): def velocity(self, new_velocity):
# Write -> Converts into motor units to change velocity of axis." # Write -> Converts into motor units to change velocity of axis.
new_velocity = float( new_velocity = float(
new_velocity new_velocity
) # accepts both float or numpy array of 1 element ) # accepts both float or numpy array of 1 element
...@@ -1296,6 +1296,9 @@ class Axis(Scannable): ...@@ -1296,6 +1296,9 @@ class Axis(Scannable):
f"Controller velocity ({_user_vel}) is different from set velocity ({new_velocity})", f"Controller velocity ({_user_vel}) is different from set velocity ({new_velocity})",
) )
curr_vel = self.settings.get("velocity")
if curr_vel != _user_vel:
user_print(f"'{self.name}` velocity changed from {curr_vel} to {_user_vel}")
self.settings.set("velocity", _user_vel) self.settings.set("velocity", _user_vel)
return _user_vel return _user_vel
...@@ -1494,6 +1497,11 @@ class Axis(Scannable): ...@@ -1494,6 +1497,11 @@ class Axis(Scannable):
self.__controller.set_acceleration(self, new_acc * abs(self.steps_per_unit)) self.__controller.set_acceleration(self, new_acc * abs(self.steps_per_unit))
_ctrl_acc = self.__controller.read_acceleration(self) _ctrl_acc = self.__controller.read_acceleration(self)
_acceleration = _ctrl_acc / abs(self.steps_per_unit) _acceleration = _ctrl_acc / abs(self.steps_per_unit)
curr_acc = self.settings.get("acceleration")
if curr_acc != _acceleration:
user_print(
f"'{self.name}` acceleration changed from {curr_acc} to {_acceleration}"
)
self.settings.set("acceleration", _acceleration) self.settings.set("acceleration", _acceleration)
return _acceleration return _acceleration
......
...@@ -66,6 +66,7 @@ DEMO [11]: mot1.velocity ⏎ # to READ the velocity ...@@ -66,6 +66,7 @@ DEMO [11]: mot1.velocity ⏎ # to READ the velocity
Out [11]: 1.25 Out [11]: 1.25
DEMO [12]: mot1.velocity = 3.0 # to SET a new velocity DEMO [12]: mot1.velocity = 3.0 # to SET a new velocity
'mot1` velocity changed from 1.25 to 3.0
DEMO [13]: DEMO [13]:
DEMO [14]: mot1.velocity ⏎ DEMO [14]: mot1.velocity ⏎
...@@ -128,7 +129,8 @@ position in user units. The dial position is accessible through the ...@@ -128,7 +129,8 @@ position in user units. The dial position is accessible through the
The **user position** derives from the dial, following the formula The **user position** derives from the dial, following the formula
defined below: defined below:
`velocity_low_limit` and `velocity_high_limit` are optional velocity limit defined in the configuration. `velocity_low_limit` and `velocity_high_limit` are optional velocity limit
defined in the configuration.
```user_position = (sign * dial_position) + offset``` ```user_position = (sign * dial_position) + offset```
...@@ -179,7 +181,6 @@ Thus: ...@@ -179,7 +181,6 @@ Thus:
* when acceleration is changed, acctime is updated * when acceleration is changed, acctime is updated
* when acctime is changed, acceleration is updated. * when acctime is changed, acceleration is updated.
```python ```python
DEMO [17]: mot1.acceleration ⏎ DEMO [17]: mot1.acceleration ⏎
Out [17]: 10.0 Out [17]: 10.0
...@@ -188,16 +189,18 @@ DEMO [18]: mot1.acctime ⏎ ...@@ -188,16 +189,18 @@ DEMO [18]: mot1.acctime ⏎
Out [18]: 0.4 Out [18]: 0.4
DEMO [19]: mot1.acceleration=20 ⏎ DEMO [19]: mot1.acceleration=20 ⏎
'mot1` acceleration changed from 10.0 to 20.0
DEMO [20]: mot1.acctime ⏎ DEMO [20]: mot1.acctime ⏎
Out [20]: 0.2 Out [20]: 0.2
DEMO [21]: mot1.acctime=1 ⏎ DEMO [21]: mot1.acctime=1 ⏎
'mot1` acceleration changed from 20.0 to 4.0
DEMO [22]: mot1.acceleration ⏎ DEMO [22]: mot1.acceleration ⏎
Out [22]: 4.0 Out [22]: 4.0
``` ```
### limits ### limits
Read-Write - float - from config and persistant in memory Read-Write - float - from config and persistant in memory
......
...@@ -35,6 +35,22 @@ def test_axis_stdout(roby, capsys, log_shell_mode): ...@@ -35,6 +35,22 @@ def test_axis_stdout(roby, capsys, log_shell_mode):
== "'roby` position reset from 0.0 to 2.0 (sign: 1, offset: 1.0)\n'roby` dial position reset from 1.0 to 2.0\n" == "'roby` position reset from 0.0 to 2.0 (sign: 1, offset: 1.0)\n'roby` dial position reset from 1.0 to 2.0\n"
) )
vel = roby.velocity
roby.velocity = vel + 1
assert (
capsys.readouterr().out
== f"'roby` velocity changed from {vel} to {roby.velocity}\n"
)
acc = roby.acceleration
roby.acceleration = acc + 1
assert (
capsys.readouterr().out
== f"'roby` acceleration changed from {acc} to {roby.acceleration}\n"
)
def test_axis_stdout2(roby, bad_motor, capsys, log_shell_mode): def test_axis_stdout2(roby, bad_motor, capsys, log_shell_mode):
"""Ensure "Moving..." and "...stopped at..." messages are present. """Ensure "Moving..." and "...stopped at..." messages are present.
......
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