SentioProberDev / SentioProberControl

Python bindings for controlling MPI probe stations
https://ast.mpi-corporation.com/
BSD 2-Clause "Simplified" License
5 stars 6 forks source link

Probe position move enhancement in code level #10

Closed BRDMYuhan closed 4 months ago

BRDMYuhan commented 5 months ago

Hi,

I've run into something that might be an ease for users. When moving the probe positioner, I noticed it hesitates for about 2.0 s even when it doesn't need to move. It's not a huge deal, but it adds up over time, especially during extensive testing sessions.

What if we just add a quick check to see if the probe already is where it needs to be? If it doesn’t need to move, we skip the movement. for example:

    def is_probe_home(self, probe: Union[ProbeSentio, str]) -> bool:
        """
        Return True if probe is at home position.
        """
        if isinstance(probe, str):
            probe = getattr(ProbeSentio, probe)
        if (0.0, 0.0) == self.get_probe_xy(probe, ProbeXYReference.Home):
            return True
        else:
            return False

    def move_probe_home(self, probe: Union[ProbeSentio, str]) -> Tuple[float, float]:
        """Move probe to its home position.

        Args:
            probe: The probe to move.

        Returns:
            A tuple containing the x and y position after the move.
        """
        if isinstance(probe, str):
            probe = getattr(ProbeSentio, probe)

        if self.is_probe_home(probe):
            return (0, 0)
        self.__comm.send("move_positioner_home {0}".format(probe.toSentioAbbr()))
        resp = Response.check_resp(self.__comm.read_line())
        tok = resp.message().split(",")
        return float(tok[0]), float(tok[1])
beltoforion commented 4 months ago

Thanks for reporting this. I pretty much agree with the proposed solution in principle. However we will fix this inside SENTIO in this manner. Applying it to the python API would only solve the issue on a python level and leave it for anyone else using remote commands.

BRDMYuhan commented 4 months ago

Thanks! hope to hear from the solution inside SENTIO.