Skip to content
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

Reduce boilerplate when creating Devices #240

Merged
merged 13 commits into from
Apr 25, 2024

Conversation

AlexanderWells-diamond
Copy link
Contributor

@AlexanderWells-diamond AlexanderWells-diamond commented Apr 18, 2024

This reduces the amount of duplication and repetition when adding signals to a StandardReadable.

As part of this, classes defining the types of signal have been created, which control the behaviour of the Signal being registered. See ConfigSignal and HintedSignal.

Signals should now be registered either using the "add_children_as_readables" contextmanager, or the "add_readables" function.

Fixes #223

NOTE: This deprecates the set_readable_signals() method in StandardReadable

src/ophyd_async/core/standard_readable.py Outdated Show resolved Hide resolved
src/ophyd_async/core/standard_readable.py Show resolved Hide resolved
src/ophyd_async/core/standard_readable.py Outdated Show resolved Hide resolved
src/ophyd_async/core/standard_readable.py Outdated Show resolved Hide resolved
src/ophyd_async/core/standard_readable.py Outdated Show resolved Hide resolved
src/ophyd_async/core/standard_readable.py Outdated Show resolved Hide resolved
src/ophyd_async/core/standard_readable.py Outdated Show resolved Hide resolved
src/ophyd_async/core/standard_readable.py Outdated Show resolved Hide resolved
src/ophyd_async/epics/areadetector/single_trigger_det.py Outdated Show resolved Hide resolved
src/ophyd_async/core/standard_readable.py Outdated Show resolved Hide resolved
src/ophyd_async/epics/demo/__init__.py Outdated Show resolved Hide resolved
src/ophyd_async/epics/demo/__init__.py Outdated Show resolved Hide resolved
src/ophyd_async/epics/motion/motor.py Outdated Show resolved Hide resolved
src/ophyd_async/sim/demo/sim_motor.py Show resolved Hide resolved
tests/core/test_standard_readable.py Outdated Show resolved Hide resolved
@AlexanderWells-diamond AlexanderWells-diamond changed the title Reduce boilerplace Reduce boilerplate Apr 19, 2024
@AlexanderWells-diamond AlexanderWells-diamond changed the title Reduce boilerplate Reduce boilerplate when creating Devices Apr 22, 2024
@AlexanderWells-diamond
Copy link
Contributor Author

I've restored the set_readable_signals function, for backwards compatibility. Also added docs to the newly added functions - do I need to add some for the ConfigSignal and HintedSignal class? I'm not sure I'm best placed for it as I'm really not sure about the nomenclature (as may already be obvious by the new docs I wrote!)

This reduces the amount of duplication and repetition when adding
signals to a StandardReadable.

As part of this, classes defining the types of signal have been created,
which control the behaviour of the Signal being registered

Signals must be registered either using the "add_children_as_readables"
contextmanager, or the "add_readables" function.
Review done by Tom Cobb

Includes:
- Much refactoring of types
- Allowing wrappers to be optional
- Generate hints when requested, rather than in advance
Instead of assuming everything added inside the cm is a SignalR, we will
instead filter the created attributes for only those we care for.
This allows us to broaden how the context manager can be used;
see sim_motor for an example.
May as well test a little more code here
It will issue a DeprecationWarning when used
Copy link
Collaborator

@coretl coretl left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, looks good!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Reduce boilerplate in StandardReadable
2 participants