Git Product home page Git Product logo

Comments (2)

DominicOram avatar DominicOram commented on July 25, 2024

My current work around is:

class XYZLimitsChecker(Device):
    """Checks that a position is within the XYZ limits of the motor.
    To use set the x, y, z vector to the device and read check `within_limits`
    """

    def __init__(self, prefix: str) -> None:
        self.within_limits = False

        axes = ["X", "Y", "Z"]
        self.limit_signals = {
            axis: (
                epics_signal_r(float, f"{prefix}{axis}.LLM"),
                epics_signal_r(float, f"{prefix}{axis}.HLM"),
            )
            for axis in axes
        }

    def children(self) -> Iterator[Tuple[str, Device]]:
        for attr, signals in self.limit_signals.items():
            yield attr + "low_lim", signals[0]
            yield attr + "high_lim", signals[1]
        return super().children()

    async def _check_limits(self, position: np.ndarray):
        check_within_limits = True
        for i, axis_limits in enumerate(self.limit_signals.values()):
            check_within_limits &= (
                (await axis_limits[0].get_value())
                < position[i]
                < (await axis_limits[1].get_value())
            )
        self.within_limits = check_within_limits

    def set(self, position: np.ndarray) -> AsyncStatus:
        return AsyncStatus(wait_for(self._check_limits(position), None))

def my_plan():
    yield from bps.set(limit_checker, [1, 2, 3])
    if limit_checker.within_limits:
        ...

from ophyd-async.

coretl avatar coretl commented on July 25, 2024

Discussed offline and decided plan logic that gets limits from specific signals on the motor, then put the plan stub in ophyd-async next to the Motor class

from ophyd-async.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.