Commit b6bd1b0b authored by bliss administrator's avatar bliss administrator Committed by Matias Guijarro
Browse files

ensure FAULT state exits move loop with exception

parent 5f255007
......@@ -44,6 +44,10 @@ class AxisOnLimitError(RuntimeError):
pass
class AxisFaultError(RuntimeError):
pass
def _prepare_one_controller_motions(controller, motions):
try:
controller.prepare_all(*motions)
......@@ -1911,6 +1915,8 @@ class Axis:
if not state.MOVING:
if limit_error and (state.LIMPOS or state.LIMNEG):
raise AxisOnLimitError(str(state))
elif state.FAULT:
raise AxisFaultError(str(state))
return state
gevent.sleep(polling_time)
......
......@@ -620,6 +620,7 @@ class FaultyMockup(Mockup):
Mockup.__init__(self, *args, **kwargs)
self.bad_state = False
self.fault_state = False
self.bad_start = False
self.bad_state_after_start = False
self.bad_stop = False
......@@ -633,6 +634,9 @@ class FaultyMockup(Mockup):
if self.bad_state:
self.state_msg_index += 1
raise RuntimeError("BAD STATE %d" % self.state_msg_index)
elif self.fault_state:
self._axis_moves[axis]["motion"] = None # stop motion immediately
return AxisState("FAULT")
else:
return Mockup.state(self, axis)
......
......@@ -12,6 +12,7 @@ import math
from bliss.common.standard import Group
from bliss.common.standard import sync
from bliss.common import event
from bliss.common.axis import AxisFaultError
def test_bad_start(bad_motor):
......@@ -153,3 +154,20 @@ def test_issue_1719(bad_motor, capsys):
not "TypeError: '<=' not supported between instances of 'NoneType' and 'int'"
in capsys.readouterr().err
)
def test_fault_state(bad_motor):
bad_motor.move(1000, wait=False)
gevent.sleep(bad_motor.acctime)
bad_motor.controller.fault_state = True
with pytest.raises(AxisFaultError):
bad_motor.wait_move()
bad_motor.controller.fault_state = False
bad_motor.move(0)
assert "READY" in bad_motor.state
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