bluesky / ophyd

hardware abstraction in Python with an emphasis on EPICS
https://blueskyproject.io/ophyd
BSD 3-Clause "New" or "Revised" License
51 stars 79 forks source link

Ask a device for the limits of its components #831

Open jklynch opened 4 years ago

jklynch commented 4 years ago

This a vague idea. Could there be a mechanism that reports for a device those components with limits - these would be mostly motors.

A feature like this was seen as being helpful in the beamline optimization project at TES.

prjemian commented 4 years ago

More than just motors. Numerical values, in general, often (not always) have a limited range. In EPICS, most such records have HOPR and LOPR fields. The motor record is anomalous (reasons are beyond this scope), using HLM and LLM for ends of the user coordinate system.

But, I like the general interface idea of an object being to describe that it has limits and interfaces with how to get/set them.

prjemian commented 4 years ago

To be complete, there are also DHLM & DLLM for the dial coordinate system of the EPICS motor record but no corresponding values for the raw coordinate system.

klauer commented 4 years ago

Signals have easily accessible limits: https://github.com/bluesky/ophyd/blob/c71bd8de58f2aa4f7e66d3475f51030f151f6931/ophyd/signal.py#L403

Devices do not, currently.

mrakitin commented 4 years ago

@klauer, yes, that's the idea described in this issue to have the Device to report all known limits.

tacaswell commented 4 years ago

A whole bunch of unstructured thoughts:

I'm imagining usage like


def centering_plan(obj):
     limits = obj.query_limits()
     group_key = 'centering'
     for leaf, lim in limits.items():
         yield from bpp.abs_set(leaf, np.mean([lim['high'], lim['low']), group=group_key)
    yield from bpp.wait(group=group_key)

or

limits = obj.query_limits()
args = list(itertools.chain((leaf, (lim['low'], lim['high']))) for leaf, lim in limits.items()))
yield from adaptive_in_volume(dets, *args)