-
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
Open
abbiemery
wants to merge
4
commits into
main
Choose a base branch
from
toy-devices
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+85
−19
Open
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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/ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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 |
|
abbiemery marked this conversation as resolved.
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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
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 but not include it in the
__all__?