Commit 3db99fee authored by Joel Collins's avatar Joel Collins
Browse files

Enable stage coordinate zeroing

parent 2f495988
Loading
Loading
Loading
Loading
+5 −0
Original line number Diff line number Diff line
@@ -37,6 +37,11 @@ _actions = {
        "view_class": stage.MoveStageAPI,
        "conditions": True,
    },
    "zeroStage": {
        "rule": "/stage/zero/",
        "view_class": stage.ZeroStageAPI,
        "conditions": True,
    },
    "shutdown": {
        "rule": "/system/shutdown/",
        "view_class": system.ShutdownAPI,
+19 −0
Original line number Diff line number Diff line
@@ -56,3 +56,22 @@ class MoveStageAPI(MicroscopeView):
            logging.warning("Unable to move. No stage found.")

        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"])
+5 −0
Original line number Diff line number Diff line
@@ -74,6 +74,11 @@ class BaseStage(metaclass=ABCMeta):
        """Make an absolute move to a position"""
        pass

    @abstractmethod
    def zero_position(self):
        """Set the current position to zero"""
        pass

    @abstractmethod
    def close(self):
        """Cleanly close communication with the stage"""
+4 −0
Original line number Diff line number Diff line
@@ -96,5 +96,9 @@ class MockStage(BaseStage):
        self._position = list(final)
        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):
        pass
+5 −0
Original line number Diff line number Diff line
@@ -147,6 +147,11 @@ class SangaStage(BaseStage):
        with self.lock:
            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):
        """Cleanly close communication with the stage"""
        if hasattr(self, "board"):
Loading