-
Notifications
You must be signed in to change notification settings - Fork 26
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
Add create_soft_signal_r and creates_soft_signal_rw methods #217
Conversation
46f8898
to
c80d227
Compare
src/ophyd_async/core/signal.py
Outdated
@@ -253,6 +253,18 @@ def set_sim_callback(signal: Signal[T], callback: ReadingValueCallback[T]) -> No | |||
return _sim_backends[signal].set_callback(callback) | |||
|
|||
|
|||
def create_soft_signal_rw( |
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.
Slight preference for:
def create_soft_signal_rw( | |
def soft_signal_rw( |
tests/core/test_signal.py
Outdated
@@ -119,3 +122,18 @@ async def test_set_and_wait_for_value(): | |||
assert not st.done | |||
set_sim_put_proceeds(sim_signal, True) | |||
assert await time_taken_by(st) < 0.1 | |||
|
|||
|
|||
async def test_create_soft_signal(): |
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.
Could: I would suggest splitting these into separate tests by either:
- Using
pytest.mark.parametrize
- Have a helper function that is the test and call it with each case
8db8da2
to
4551237
Compare
@gilesknap @coretl Add in option to pass an initial value to SimSignalBackend in the init method, and also supporting this in the soft_signal_* methods. self._initial_value gets set to the initial_value argument in SimSignalBackend's init, but the converter only converts it when connect is called, though I think this is fine if users are only accessing it through the public methods. soft_signal_r_and_backend still returns the backend, though this may not be required now. |
0066ab2
to
7ddac6c
Compare
Thanks James, I have rebased and used the new feature successfully. |
bc4e98b
to
ed969fb
Compare
Following discussion with @coretl, SimSignalBackends no longer take a source/name at init, and all backends now provide source as a method, where the Signal classes pass a name to the backend. source is available from signals as a property. |
ed969fb
to
5f551aa
Compare
signals can pass a value to the backend, signal sources are now properties Can no longer pass source to SimSignalBackend at init
e3d4b63
to
f78780d
Compare
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.
Looks good!
src/ophyd_async/core/signal.py
Outdated
signal = SignalRW( | ||
SimSignalBackend(datatype, initial_value) | ||
) | ||
signal.set_name(name) |
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.
Please can we make name=None
be passed to these helpers, and if it isn't already there then add it as an optional arg to Signal.__init__
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.
And also add this to epics_signal_*
helpers
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.
Ah! Missed this comment somehow, might have to be a new PR.
339ea64
to
fd480a7
Compare
test numpy dtype with SimSignalBackend
fd480a7
to
0de1c56
Compare
Moved from dodal, have placed in core.signals as seemed logical to prevent circular imports, could be moved to sim_signal_backends.py