Skip to content
GitLab
Menu
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Bliss
bliss
Commits
13c2d364
Commit
13c2d364
authored
Jun 29, 2020
by
Matias Guijarro
Browse files
test for issue 1788, adapt mockup controller and tests to previous
changes
parent
be50f041
Changes
4
Hide whitespace changes
Inline
Side-by-side
bliss/controllers/motors/mockup.py
View file @
13c2d364
...
...
@@ -623,6 +623,20 @@ class FaultyMockup(Mockup):
else
:
return
Mockup
.
state
(
self
,
axis
)
def
_check_hw_limits
(
self
,
axis
):
ll
,
hl
=
self
.
_Mockup__hw_limit
pos
=
super
().
read_position
(
axis
)
if
pos
<=
ll
:
return
AxisState
(
"READY"
,
"LIMNEG"
)
elif
pos
>=
hl
:
return
AxisState
(
"READY"
,
"LIMPOS"
)
if
self
.
_hw_state
.
OFF
:
return
AxisState
(
"OFF"
)
else
:
s
=
AxisState
(
self
.
_hw_state
)
s
.
set
(
"READY"
)
return
s
def
start_one
(
self
,
motion
,
**
kw
):
self
.
state_msg_index
=
0
if
self
.
bad_start
:
...
...
tests/motors/test_axis.py
View file @
13c2d364
...
...
@@ -314,18 +314,17 @@ def test_hardware_limits(roby):
with
pytest
.
raises
(
RuntimeError
):
roby
.
move
(
3
)
assert
roby
.
position
==
2
assert
pytest
.
approx
(
roby
.
position
)
==
2
# move hit limit because of backlash
with
pytest
.
raises
(
RuntimeError
):
roby
.
move
(
0
)
assert
pytest
.
approx
(
roby
.
position
)
==
0
roby
.
move
(
1
)
assert
roby
.
position
==
1
with
pytest
.
raises
(
RuntimeError
):
roby
.
move
(
-
3
)
assert
roby
.
position
==
0
finally
:
roby
.
controller
.
set_hw_limits
(
roby
,
None
,
None
)
...
...
@@ -456,11 +455,27 @@ def test_backlash(roby):
roby
.
move
(
-
10
)
def
test_interrupted_backlash
(
roby
):
roby
.
move
(
-
1
,
wait
=
False
)
roby
.
_group_move
.
_backlash_started_event
.
wait
()
# have to kill twice because backlash move is protected
roby
.
_group_move
.
_move_task
.
kill
(
KeyboardInterrupt
,
block
=
False
)
roby
.
_group_move
.
_move_task
.
kill
(
KeyboardInterrupt
,
block
=
False
)
with
pytest
.
raises
(
KeyboardInterrupt
):
roby
.
wait_move
()
# backlash move is interrupted before it finishes
assert
roby
.
position
<
-
1
assert
"READY"
in
roby
.
state
def
test_backlash2
(
roby
):
roby
.
move
(
1
0
,
wait
=
False
)
roby
.
move
(
1
,
wait
=
False
)
assert
roby
.
backlash_move
==
0
roby
.
wait_move
()
assert
roby
.
position
==
1
0
assert
roby
.
position
==
1
def
test_backlash3
(
roby
):
...
...
@@ -491,12 +506,17 @@ def test_backlash4(roby):
def
test_backlash_stop
(
roby
):
roby
.
move
(
-
10
,
wait
=
False
)
assert
roby
.
backlash_move
==
-
12
pos
=
roby
.
_hw_position
roby
.
stop
()
t
=
time
.
time
()
roby
.
acctime
=
0.1
roby
.
move
(
-
1000
,
wait
=
False
)
assert
roby
.
backlash_move
==
-
1002
time
.
sleep
(
0.2
)
# calculate stop position
roby
.
stop
(
wait
=
False
)
stop_pos
=
roby
.
_hw_position
-
roby
.
acceleration
*
0.5
*
roby
.
acctime
**
2
roby
.
wait_move
()
assert
pytest
.
approx
(
roby
.
dial
,
1e-1
)
==
pos
+
roby
.
backlash
assert
pytest
.
approx
(
roby
.
dial
,
1e-1
)
==
stop_
pos
+
roby
.
backlash
assert
roby
.
_set_position
==
roby
.
dial
assert
roby
.
state
.
READY
...
...
tests/motors/test_bad_controller.py
View file @
13c2d364
...
...
@@ -46,8 +46,8 @@ def test_state_failure(bad_motor, monkeypatch):
state_index
=
bad_motor
.
controller
.
state_msg_index
assert
str
(
exc
.
value
)
==
"BAD STATE 1"
assert
len
(
infos
)
==
3
assert
str
(
infos
[
0
][
1
])
==
"BAD STATE %d"
%
(
state_index
-
2
)
assert
len
(
infos
)
==
1
assert
str
(
infos
[
0
][
1
])
==
"BAD STATE %d"
%
state_index
assert
"FAULT"
in
bad_motor
.
state
with
pytest
.
raises
(
RuntimeError
):
...
...
tests/shell/test_standard.py
View file @
13c2d364
...
...
@@ -130,7 +130,7 @@ def test_wm_exception(default_session, capsys):
def
test_sta_normal
(
default_session
,
capsys
):
bad
=
default_session
.
config
.
get
(
"bad"
)
bad
.
controller
.
bad_
position
=
False
bad
.
controller
.
bad_
state
=
False
sta
()
captured
=
capsys
.
readouterr
()
...
...
@@ -153,7 +153,7 @@ def test_sta_slits(s1hg, capsys):
def
test_sta_exception
(
default_session
,
capsys
):
bad
=
default_session
.
config
.
get
(
"bad"
)
bad
.
controller
.
bad_
position
=
True
bad
.
controller
.
bad_
state
=
True
sta
()
captured
=
capsys
.
readouterr
()
...
...
@@ -166,13 +166,13 @@ def test_sta_exception(default_session, capsys):
errmsg
=
"Traceback (most recent call last):
\n
"
assert
errmsg
in
captured
.
err
errmsg
=
"RuntimeError: Error on motor 'bad': BAD
POSITION
\n
"
errmsg
=
"RuntimeError: Error on motor 'bad': BAD
STATE
"
assert
errmsg
in
captured
.
err
def
test_stm_normal
(
default_session
,
capsys
):
bad
=
default_session
.
config
.
get
(
"bad"
)
bad
.
controller
.
bad_
position
=
False
bad
.
controller
.
bad_
state
=
False
stm
(
"bad"
)
captured
=
capsys
.
readouterr
()
...
...
@@ -185,7 +185,7 @@ def test_stm_normal(default_session, capsys):
def
test_stm_exception
(
default_session
,
capsys
):
bad
=
default_session
.
config
.
get
(
"bad"
)
bad
.
controller
.
bad_
position
=
True
bad
.
controller
.
bad_
state
=
True
stm
(
"bad"
)
captured
=
capsys
.
readouterr
()
...
...
@@ -198,7 +198,7 @@ def test_stm_exception(default_session, capsys):
errmsg
=
"Traceback (most recent call last):
\n
"
assert
errmsg
in
captured
.
err
errmsg
=
"RuntimeError: Error on motor 'bad': BAD
POSITION
\n
"
errmsg
=
"RuntimeError: Error on motor 'bad': BAD
STATE
"
assert
errmsg
in
captured
.
err
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment