-
Notifications
You must be signed in to change notification settings - Fork 14
docs: Add simple devices and plans for use in tutorials #1577
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,11 @@ | ||
| env: | ||
| metadata: | ||
| instrument: tutorial-instrument | ||
| sources: | ||
| - kind: deviceManager | ||
| module: blueapi.tutorial.devices | ||
| - kind: planFunctions | ||
| module: blueapi.tutorial.plans | ||
| stomp: | ||
| enabled: true | ||
| url: tcp://localhost:61613/ |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,11 @@ | ||
| from ophyd_async.sim import SimMotor | ||
|
|
||
| from blueapi.core.protocols import StaticDeviceManager | ||
|
|
||
| devices = StaticDeviceManager() | ||
|
|
||
| x = SimMotor(name="x") | ||
| y = SimMotor(name="y") | ||
|
|
||
| devices.devices["x"] = x | ||
| devices.devices["y"] = y |
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is just a direct copy of the wrapped count in dodal. I don't know if it is worth while paring this down to something more simple, or to add a move plan or something.
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I don't think we should have a direct copy - paring it down to the basic would make it clearer, eg the validation checks are not useful for tutorial purposes. |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,43 @@ | ||
| from collections.abc import Sequence | ||
| from typing import Annotated, Any | ||
|
|
||
| import bluesky.plans as bp | ||
| from bluesky.protocols import Readable | ||
| from bluesky.utils import MsgGenerator | ||
| from ophyd_async.core import AsyncReadable | ||
| from pydantic import Field, NonNegativeFloat, validate_call | ||
|
|
||
|
|
||
| @validate_call(config={"arbitrary_types_allowed": True}) | ||
| def count( | ||
| detectors: Annotated[ | ||
| Sequence[Readable | AsyncReadable], | ||
| Field( | ||
| description="Set of readable devices, will take a reading at each point", | ||
| min_length=1, | ||
| ), | ||
| ], | ||
| num: Annotated[int, Field(description="Number of frames to collect", ge=1)] = 1, | ||
| delay: Annotated[ | ||
| NonNegativeFloat | Sequence[NonNegativeFloat], | ||
| Field( | ||
| description="Delay between readings: if tuple, len(delay) == num - 1 and \ | ||
| the delays are between each point, if value or None is the delay for every \ | ||
| gap", | ||
| json_schema_extra={"units": "s"}, | ||
| ), | ||
| ] = 0.0, | ||
| metadata: dict[str, Any] | None = None, | ||
| ) -> MsgGenerator: | ||
| """Reads from a number of devices. | ||
|
|
||
| Wraps bluesky.plans.count(det, num, delay, md=metadata) exposing only serializable | ||
| parameters and metadata. | ||
| """ | ||
| if isinstance(delay, Sequence): | ||
| assert len(delay) == num - 1, ( | ||
| f"Number of delays given must be {num - 1}: was given {len(delay)}" | ||
| ) | ||
| metadata = metadata or {} | ||
| metadata["shape"] = (num,) | ||
| yield from bp.count(tuple(detectors), num, delay=delay, md=metadata) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is there a better place for this to live?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
utils would make the most sense if there's a way of getting it working without import order issues