Allow serial exceptions to be raised
This commit is contained in:
parent
b5e6a43caa
commit
6b9a34437e
1 changed files with 8 additions and 9 deletions
|
|
@ -1,5 +1,4 @@
|
||||||
from openflexure_stage import OpenFlexureStage
|
from openflexure_stage import OpenFlexureStage
|
||||||
from serial import SerialException
|
|
||||||
|
|
||||||
from openflexure_microscope.lock import StrictLock
|
from openflexure_microscope.lock import StrictLock
|
||||||
|
|
||||||
|
|
@ -14,16 +13,16 @@ class Stage(OpenFlexureStage):
|
||||||
adding an instance of :py:class:`openflexure_microscope.lock.StrictLock` to regulate access.
|
adding an instance of :py:class:`openflexure_microscope.lock.StrictLock` to regulate access.
|
||||||
"""
|
"""
|
||||||
self.lock = StrictLock(timeout=2) #: :py:class:`openflexure_microscope.lock.StrictLock`: Strict lock controlling thread access to camera hardware
|
self.lock = StrictLock(timeout=2) #: :py:class:`openflexure_microscope.lock.StrictLock`: Strict lock controlling thread access to camera hardware
|
||||||
|
|
||||||
try:
|
OpenFlexureStage.__init__(self, *args, **kwargs)
|
||||||
OpenFlexureStage.__init__(self, *args, **kwargs)
|
|
||||||
except SerialException:
|
|
||||||
logging.error("No stage found. Aborting stage.")
|
|
||||||
logging.warning("Stage lock can be acquired, but any stage methods will fail and raise exceptions.")
|
|
||||||
|
|
||||||
def _move_rel_nobacklash(self, *args, **kwargs):
|
def _move_rel_nobacklash(self, *args, **kwargs):
|
||||||
"""
|
"""
|
||||||
Overrides :py:function:`openflexure_stage.stage.OpenFlexureStage._move_rel_nobacklash` to acquire lock first.
|
Overrides :py:function:`openflexure_stage.stage.OpenFlexureStage._move_rel_nobacklash` to acquire lock first.
|
||||||
"""
|
"""
|
||||||
with self.lock:
|
if self._ser:
|
||||||
OpenFlexureStage._move_rel_nobacklash(self, *args, **kwargs)
|
with self.lock:
|
||||||
|
OpenFlexureStage._move_rel_nobacklash(self, *args, **kwargs)
|
||||||
|
else:
|
||||||
|
logging.warning("Unable to move stage. Serial communication unavailable.")
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue