Enable stage coordinate zeroing
This commit is contained in:
parent
2f4959885c
commit
3db99fee2f
6 changed files with 43 additions and 1 deletions
|
|
@ -37,6 +37,11 @@ _actions = {
|
||||||
"view_class": stage.MoveStageAPI,
|
"view_class": stage.MoveStageAPI,
|
||||||
"conditions": True,
|
"conditions": True,
|
||||||
},
|
},
|
||||||
|
"zeroStage": {
|
||||||
|
"rule": "/stage/zero/",
|
||||||
|
"view_class": stage.ZeroStageAPI,
|
||||||
|
"conditions": True,
|
||||||
|
},
|
||||||
"shutdown": {
|
"shutdown": {
|
||||||
"rule": "/system/shutdown/",
|
"rule": "/system/shutdown/",
|
||||||
"view_class": system.ShutdownAPI,
|
"view_class": system.ShutdownAPI,
|
||||||
|
|
|
||||||
|
|
@ -56,3 +56,22 @@ class MoveStageAPI(MicroscopeView):
|
||||||
logging.warning("Unable to move. No stage found.")
|
logging.warning("Unable to move. No stage found.")
|
||||||
|
|
||||||
return jsonify(self.microscope.status["stage"]["position"])
|
return jsonify(self.microscope.status["stage"]["position"])
|
||||||
|
|
||||||
|
|
||||||
|
class ZeroStageAPI(MicroscopeView):
|
||||||
|
"""
|
||||||
|
Zero stage coordinates
|
||||||
|
"""
|
||||||
|
|
||||||
|
def post(self):
|
||||||
|
"""
|
||||||
|
Set the current position to zero
|
||||||
|
|
||||||
|
.. :quickref: Actions; Zero stage
|
||||||
|
|
||||||
|
:reqheader Accept: application/json
|
||||||
|
|
||||||
|
"""
|
||||||
|
self.microscope.stage.zero_position()
|
||||||
|
|
||||||
|
return jsonify(self.microscope.status["stage"])
|
||||||
|
|
|
||||||
|
|
@ -74,6 +74,11 @@ class BaseStage(metaclass=ABCMeta):
|
||||||
"""Make an absolute move to a position"""
|
"""Make an absolute move to a position"""
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
@abstractmethod
|
||||||
|
def zero_position(self):
|
||||||
|
"""Set the current position to zero"""
|
||||||
|
pass
|
||||||
|
|
||||||
@abstractmethod
|
@abstractmethod
|
||||||
def close(self):
|
def close(self):
|
||||||
"""Cleanly close communication with the stage"""
|
"""Cleanly close communication with the stage"""
|
||||||
|
|
|
||||||
|
|
@ -96,5 +96,9 @@ class MockStage(BaseStage):
|
||||||
self._position = list(final)
|
self._position = list(final)
|
||||||
logging.debug(f"New position: {self._position}")
|
logging.debug(f"New position: {self._position}")
|
||||||
|
|
||||||
|
def zero_position(self):
|
||||||
|
"""Set the current position to zero"""
|
||||||
|
self._position = [0, 0, 0]
|
||||||
|
|
||||||
def close(self):
|
def close(self):
|
||||||
pass
|
pass
|
||||||
|
|
|
||||||
|
|
@ -147,6 +147,11 @@ class SangaStage(BaseStage):
|
||||||
with self.lock:
|
with self.lock:
|
||||||
self.board.move_abs(final, **kwargs)
|
self.board.move_abs(final, **kwargs)
|
||||||
|
|
||||||
|
def zero_position(self):
|
||||||
|
"""Set the current position to zero"""
|
||||||
|
with self.lock:
|
||||||
|
self.board.zero_position()
|
||||||
|
|
||||||
def close(self):
|
def close(self):
|
||||||
"""Cleanly close communication with the stage"""
|
"""Cleanly close communication with the stage"""
|
||||||
if hasattr(self, "board"):
|
if hasattr(self, "board"):
|
||||||
|
|
|
||||||
|
|
@ -52,7 +52,7 @@ class Sangaboard(ExtensibleSerialInstrument):
|
||||||
|
|
||||||
# These are the settings for the sangaboards serial port, and can usually be left as default.
|
# These are the settings for the sangaboards serial port, and can usually be left as default.
|
||||||
port_settings = {
|
port_settings = {
|
||||||
"baudrate": 115200,
|
"baudrate": 115_200,
|
||||||
"bytesize": EIGHTBITS,
|
"bytesize": EIGHTBITS,
|
||||||
"parity": PARITY_NONE,
|
"parity": PARITY_NONE,
|
||||||
"stopbits": STOPBITS_ONE,
|
"stopbits": STOPBITS_ONE,
|
||||||
|
|
@ -215,6 +215,10 @@ class Sangaboard(ExtensibleSerialInstrument):
|
||||||
"""De-energise the stepper motor coils"""
|
"""De-energise the stepper motor coils"""
|
||||||
self.query("release")
|
self.query("release")
|
||||||
|
|
||||||
|
def zero_position(self):
|
||||||
|
"""Set the current position to zero"""
|
||||||
|
self.query("zero")
|
||||||
|
|
||||||
def move_abs(self, final, **kwargs):
|
def move_abs(self, final, **kwargs):
|
||||||
"""Make an absolute move to a position
|
"""Make an absolute move to a position
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue