Skip to content

230 bimorph optimisation plan #1027

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
wants to merge 251 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
251 commits
Select commit Hold shift + click to select a range
ec85bd8
Create bimorph_mirror.py with basic class structure
dan-fernandes Nov 27, 2024
62f5488
Add VOUT_RBV channel creation to __init__
dan-fernandes Nov 27, 2024
6bd8b07
Move bimorph_mirror.py out of bimorph_mirrors directory
dan-fernandes Nov 28, 2024
70a75f5
Create BimorphMirrorChannel with vout_rbv SignalR
dan-fernandes Nov 28, 2024
4a129a2
Change BimorphMirrorChannel child creation to procedural
dan-fernandes Nov 28, 2024
82ec406
Replace BimorphMirror child decleration to use BimorphMirrorChannel
dan-fernandes Nov 28, 2024
9bb6e50
Remove unused imports
dan-fernandes Nov 28, 2024
c6ab0dd
Remove unused import
dan-fernandes Nov 28, 2024
b615c94
Remove uneccesary Format in add_children_as_readables
dan-fernandes Nov 28, 2024
3f265bf
Add super().__init__ call
dan-fernandes Nov 28, 2024
24cf9d9
Add VTRGT_RBV, STATUS to BimorphMirrorChannel
dan-fernandes Nov 28, 2024
5b10523
Add BimorphMirror.set method
dan-fernandes Nov 28, 2024
fcec361
Add bimorph test file
dan-fernandes Nov 28, 2024
e7e8021
Fix STATUS type
dan-fernandes Nov 28, 2024
3944b78
Make BimorphMirror.set await values in VOUT_RBV
dan-fernandes Nov 28, 2024
3139761
Add assertion that channel exists to BimorphMirror.set
dan-fernandes Nov 29, 2024
503aa0a
Replace .get with square brackets in BimorphMirror.set to avoid typin…
dan-fernandes Nov 29, 2024
a4fd4d3
Add BimorphMirrorChannel.shift
dan-fernandes Nov 29, 2024
bebf974
Add BimorphMirror.all_shift, .add_volt
dan-fernandes Nov 29, 2024
81870c6
Add BimorphMirror.channels, .status, .temps
dan-fernandes Nov 29, 2024
5bdaf89
Rename previous BimorphMirror.channels to BimorphMirror.channel_list …
dan-fernandes Nov 29, 2024
8c17c91
Add BimorphMirror.reset_err_proc, .err
dan-fernandes Nov 29, 2024
b6df119
Add BimorphOnOff Strict Enum
dan-fernandes Nov 29, 2024
1823217
Add BimorphMirror.on_off
dan-fernandes Nov 29, 2024
a216906
Add BimorphMirrorMode StrictEnum
dan-fernandes Nov 29, 2024
e9916c2
Add BimorphMirror.op_mode
dan-fernandes Nov 29, 2024
5867146
Change BimorphMirror.on_off datatype to BimorphMirrorOnOff rather th…
dan-fernandes Nov 29, 2024
916d909
Add docstrings
dan-fernandes Nov 29, 2024
ea19f02
Remove uneccesary signals from BimorphMirror
dan-fernandes Nov 29, 2024
0794a9b
Add missing attribute to docstring
dan-fernandes Nov 29, 2024
c2cbf88
Remove duplicate signal decleration
dan-fernandes Nov 29, 2024
90a842c
Remove uneccesary BimorphMirror signal
dan-fernandes Nov 29, 2024
bd405eb
Change BimorphMirrorChannel.status to datatype BimorphMirrorOnOff
dan-fernandes Nov 29, 2024
20e9768
Add BimorphMirrorStatus, set as BimorphMirror.status datatype
dan-fernandes Nov 29, 2024
0f9a081
Change BimorphMirror.channels datatype to str
dan-fernandes Nov 29, 2024
3ff0a06
Change BimorphMirrorChannel to declare all signals declaratively
dan-fernandes Nov 29, 2024
5b7325b
Remove uneccesary argument
dan-fernandes Nov 29, 2024
664d636
Move all PV delimiters from suffix into prefix
dan-fernandes Nov 29, 2024
a2327a5
Fix incorrect use of PVSuffix
dan-fernandes Nov 29, 2024
521963f
Make BimorphMirrorChannel inherit from EpicsDevice
dan-fernandes Nov 29, 2024
7199a8c
Remove :CHANNELS signal from BimorphMirror
dan-fernandes Nov 29, 2024
051f23e
Rename BimorphMirror.channel_list to .channels
dan-fernandes Nov 29, 2024
2dc2bab
Remove unused import
dan-fernandes Nov 29, 2024
f827c05
Replace BimorphMirror.set wait on rbv with wait=True
dan-fernandes Nov 29, 2024
3af9f88
Add bimorph test_set_channels
dan-fernandes Nov 29, 2024
bd86838
Organise imports
dan-fernandes Nov 29, 2024
5a7cfa8
Make wait_for_value in BimorphMirror.set use DEFAULT_TIMEOUT instead …
dan-fernandes Nov 29, 2024
d0156c0
Rename test_set_channels, fix said test, and add test_set_channels_tr…
dan-fernandes Nov 29, 2024
dcb0b7e
Remove whitespace
dan-fernandes Nov 29, 2024
507139c
Remove unused import
dan-fernandes Nov 29, 2024
aff1a58
Add comments
dan-fernandes Nov 29, 2024
6b83f14
Parametrize test_set_channels_wait_for_readback
dan-fernandes Dec 2, 2024
6774344
Abstract setting vout mock values into fixture
dan-fernandes Dec 2, 2024
0b13698
Parametrize test_set_channels_wait_for_readback
dan-fernandes Dec 2, 2024
550f406
Add whitespace
dan-fernandes Dec 2, 2024
27f72fb
Renam set_vout_mock_values to set_vout_mock_and_return_value
dan-fernandes Dec 2, 2024
81e0ddb
Add test_set_channels_waits_for_vout_readback unimplemented
dan-fernandes Dec 2, 2024
5ffad56
Add test_read, and BIMORPH_NAME global variable
dan-fernandes Dec 2, 2024
31c6bec
Make mirror fixture take number_of_channels argument
dan-fernandes Dec 4, 2024
b7cf4bd
Correct BimorphMirrorChannel Format signal types
dan-fernandes Dec 4, 2024
6f83b30
Add valid_bimorph_values fixture
dan-fernandes Dec 4, 2024
0de2413
Change test parametrization from bimorph input to number of channels
dan-fernandes Dec 4, 2024
35f253b
Add format changes generated by tox pre-commit
dan-fernandes Dec 5, 2024
5dae56f
Change explcit channel number parameter to reference to global list o…
dan-fernandes Dec 4, 2024
e3e5a31
Implement test_set_channels_waits_for_vout_readback
dan-fernandes Dec 4, 2024
e9c578e
Add test_set_invalid_chanel_throws_error
dan-fernandes Dec 4, 2024
ffce233
Add Raises section to BimorphMirror.set docstring
dan-fernandes Dec 4, 2024
61a39af
Make BiorphMirror.__init__ number_of_channels have no default value
dan-fernandes Dec 9, 2024
6ea4522
Replace all asserts inside for loops, to comprehension and comparison
dan-fernandes Dec 9, 2024
b8d81ee
Remove BIMORPH_NAME global variable
dan-fernandes Dec 9, 2024
e015ba5
Remove prng from test input generation
dan-fernandes Dec 9, 2024
09185f0
Add BimorphMirror.__init__ number_of_channels validation
dan-fernandes Dec 9, 2024
cfe357d
Add test_init_mirror_with_invalid_channels_throws_error
dan-fernandes Dec 9, 2024
bdd93d5
Add BimorphMirror.__init__ docstring
dan-fernandes Dec 9, 2024
aba2bc1
Replace assertion in BimorphMirror.set arg validation with raise Valu…
dan-fernandes Dec 9, 2024
db20860
Make test_set_invalid_channel_throws_error expect correct error type
dan-fernandes Dec 9, 2024
b4ca49d
Replace real PV prefix with fake
dan-fernandes Dec 9, 2024
d028438
Add mock_vtrgt_vout_propogation, remove set_vout_mock fixtures
dan-fernandes Dec 10, 2024
318fcd6
Remove unused import
dan-fernandes Dec 10, 2024
0bb79d8
Merge branch 'main' into bimorph-mirrors
dan-fernandes Dec 10, 2024
448eb19
Fix import for ophyd async 0.9.0a1
dan-fernandes Dec 10, 2024
7272218
Update src/dodal/devices/bimorph_mirror.py
dan-fernandes Dec 11, 2024
3237790
Update src/dodal/devices/bimorph_mirror.py
dan-fernandes Dec 11, 2024
7953ceb
Update src/dodal/devices/bimorph_mirror.py
dan-fernandes Dec 11, 2024
d06a8ab
Remove BimorphMirror.number_of_channels
dan-fernandes Dec 11, 2024
db19e2a
Rename BimorphMirror.alltrgt_proc, .on_off for readability
dan-fernandes Dec 11, 2024
095861d
Rename BimorphMirrorChannel.vtrgt, .vout for readbility
dan-fernandes Dec 11, 2024
8ceaad1
Change BimorphMirror.set type hinting
dan-fernandes Dec 11, 2024
86d9cf2
Replace BimorphMirror.set sequential input validation with collection
dan-fernandes Dec 12, 2024
0bfb429
Add test_init_mirror_with_zero_channels
dan-fernandes Dec 12, 2024
bfe6832
Ensure bimorph has finished moving after set
DiamondRC Jan 7, 2025
289a324
Merge branch 'main' into bimorph-mirrors
DiamondRC Jan 7, 2025
5b1beca
wait for value
DiamondRC Jan 7, 2025
b79924d
Update test_bimorph_mirror.py
DiamondRC Jan 7, 2025
18f6438
Crop PV name for BUSY toggle
DiamondRC Jan 7, 2025
d3a80ae
Crop PV name for BUSY toggle
DiamondRC Jan 7, 2025
8f98f54
await IDLE status
DiamondRC Jan 7, 2025
519349e
Update test to account for idling
DiamondRC Jan 8, 2025
b849a67
Make BimorphMirrorChannel Movable, add set method
dan-fernandes Jan 9, 2025
4fe2693
Merge branch 'main' into bimorph-mirrors
dan-fernandes Jan 9, 2025
489c931
Remove unnecessary fixture from test_bimorph_mirror_channel_set
dan-fernandes Jan 9, 2025
10e1430
Write bimorph_optimisation plan
dan-fernandes Jan 9, 2025
ea2e1c8
Make BimorphMirror.set set to target_voltage in serial, and wait chec…
dan-fernandes Jan 16, 2025
502040c
Add wait for BimorphMirrorStatus.IDLE before trigger in BimorphMirror…
dan-fernandes Jan 16, 2025
3b6c62d
Refactor mock_vtrgt_vout_propogation to use callback_on_mock_put
dan-fernandes Jan 16, 2025
792d8e1
Add mock_bimorph_mirror_status_functionality
dan-fernandes Jan 16, 2025
2049ac1
Aggregate mock_vtrgt_vout_propogation, mock_bimorph_mirror_status_fun…
dan-fernandes Jan 16, 2025
62c50f2
Make test_set_channels_waits_for_vout_readback check subset of call_a…
dan-fernandes Jan 16, 2025
08091ab
Add bimorph_functionality fixture to test_set_channels_allows_tolerance
dan-fernandes Jan 16, 2025
fe8bae5
Merge branch 'main' into bimorph-mirrors
dan-fernandes Jan 16, 2025
c81c50c
Remove tolerance in BimorphMirror.set
dan-fernandes Jan 16, 2025
6ceefb6
Merge branch 'main' into bimorph-mirrors
dan-fernandes Jan 16, 2025
eec80b4
Remove unused argument in BimorphMirror.set
dan-fernandes Jan 16, 2025
cfa4185
Add comment to BimorphMirror.set explaining serial set
dan-fernandes Jan 16, 2025
15c7077
Refactor test_bimorph_mirror to use mirror_with_mocked_put fixture
dan-fernandes Jan 16, 2025
b70f283
Fix SlitDimension X datatype
dan-fernandes Jan 17, 2025
9f3b9f7
Fix move_slits dimension comparison
dan-fernandes Jan 17, 2025
9782433
Add test_birmorph.py with test_move_slits
dan-fernandes Jan 17, 2025
4b2da37
Add docstring to slits fixture
dan-fernandes Jan 17, 2025
0356666
Merge branch 'bimorph-mirrors' into 230-bimorph-optimisation-plan
dan-fernandes Jan 17, 2025
15592d9
Add oav fixture, test_bimorph_optimisaiton skeleton
dan-fernandes Jan 17, 2025
1f990f9
Add parameters to test_bimorph_optimisation, add initial_voltage_list…
dan-fernandes Jan 20, 2025
40e7eac
Fix not awaiting coroutine
dan-fernandes Jan 20, 2025
ed7571d
Add plan execution to test_bimorph_optimisation
dan-fernandes Jan 20, 2025
01c53e9
Add mock velocity value to slits fixture, remove breakpoint
dan-fernandes Jan 20, 2025
64ee4c8
Fix outer func decorators
dan-fernandes Jan 20, 2025
66303a5
Instantiate SimDetector in DeviceCollector context
dan-fernandes Jan 20, 2025
c9caa1b
Fix bps.trigger_and_read parameters
dan-fernandes Jan 20, 2025
bd3feec
Fix oav fixture, add move_slits_message_generator, inner_scan_message…
dan-fernandes Jan 21, 2025
0fd0ab9
Add mirror fixture
dan-fernandes Jan 21, 2025
ea9a044
Add setup_message_generator, outer_message_generator
dan-fernandes Jan 23, 2025
bf0b540
Add mirror_with_mocked_put fixture
dan-fernandes Jan 24, 2025
a0d92cf
Refactor capture_bimorph_state, restore_bimorph_state out of plan
dan-fernandes Jan 24, 2025
fbffa39
Remove unnecessary comment
dan-fernandes Jan 24, 2025
2b91275
Add test_save_and_restore
dan-fernandes Jan 24, 2025
80bc22c
Add test_inner_scan
dan-fernandes Jan 24, 2025
494a858
Comlete test_bimorph_optimisation test
dan-fernandes Jan 24, 2025
3694a6d
Change test parameters
dan-fernandes Jan 24, 2025
1e772d1
Add whitespace
dan-fernandes Jan 24, 2025
2f7ec85
Add typing to mirror_with_mocked_put status function
dan-fernandes Jan 24, 2025
fba60a7
Add type hinting to mirror_with_mocked_put vout_propogation_and_statu…
dan-fernandes Jan 24, 2025
4c6403b
Rename all ..vout.. references to ..output_voltage..
dan-fernandes Jan 24, 2025
597198a
Make BimorphMirror.set use set_and_wait_for_other_value rather than t…
dan-fernandes Jan 24, 2025
bad136f
Rewrite mirror_with_mocked_put to not use default arguments in helper…
dan-fernandes Jan 24, 2025
3e05c45
Renamed functions in mirror_with_mocked_put fixture for readability
dan-fernandes Jan 27, 2025
5f5b0a0
Refactor test_bimorph_optimisation to be method in TestBimorphOptimis…
dan-fernandes Jan 27, 2025
7c30be5
Refactor mocks in TestBimorphOptimisation to be class parametrization…
dan-fernandes Jan 27, 2025
258df0e
Add start_state and mock_capture_bimorph_state fixtures, add test_set…
dan-fernandes Jan 28, 2025
4742d3f
Add TestOptimisation.test_bimorph_puts
dan-fernandes Jan 28, 2025
6dd19ed
Rename TestOptimisation.test_bimorph_puts -> .test_plan_puts_to_bimorph
dan-fernandes Jan 28, 2025
7de0d01
Add TestBimorphOptimisation.test_plan_calls_inner_scan
dan-fernandes Jan 28, 2025
6c4700c
Add TestBimorphOptimisation.test_plan_sets_mirror_start_position
dan-fernandes Jan 28, 2025
8634c72
Rename TestBimorphOptimisation.test -> .test_bimorph_state_captured
dan-fernandes Jan 28, 2025
7ae4b7e
Change placement of initial_voltage_list logic in multiple tests
dan-fernandes Jan 28, 2025
b006813
Refactor TestBimorphOptimisation.mock_capture_bimorph_state for reada…
dan-fernandes Jan 28, 2025
16c2b10
Add docstring to TestBimorphOptimisation
dan-fernandes Jan 28, 2025
b137191
Add type hinting where lacking
dan-fernandes Jan 28, 2025
f0e4877
Set DEFAULT_TIMEOUT to 60
dan-fernandes Jan 28, 2025
80b480a
Merge branch 'bimorph-mirrors' into 230-bimorph-optimisation-plan
dan-fernandes Jan 28, 2025
dae23a1
Change BimorphMirror.set to write to output_voltage and to not trigge…
dan-fernandes Jan 28, 2025
5aa7c20
Remove BimorphMirror.commit_target_voltages
dan-fernandes Jan 28, 2025
316ff61
Remove test_set_channels_triggers_alltrgt_proc
dan-fernandes Jan 28, 2025
e8e36c3
Change test_set_channels_waits_for_readback to read from output_voltage
dan-fernandes Jan 28, 2025
4b6a65b
Make test_set_one_channel read from output_voltage
dan-fernandes Jan 28, 2025
5d0de0b
Merge branch 'main' into bimorph-mirrors
dan-fernandes Jan 28, 2025
5d626bb
Rewrite inner_scan, outer docstrings
dan-fernandes Jan 28, 2025
f0d956b
Replace oav parameter with detectors readable list
dan-fernandes Feb 4, 2025
2050d9d
Add detectors fixture, make test_inner_scan use fixture
dan-fernandes Feb 4, 2025
f096dee
Have test_inner_scan assert new dd mock_move_slitcall_args_list rathe…
dan-fernandes Feb 4, 2025
1f1edaa
Refactor test_inner_scan to TestInnerScan.test_inner_scan_moves_slits
dan-fernandes Feb 4, 2025
0080a2c
Add TestInnerScan.test_inner_scan_triggers_and_reads
dan-fernandes Feb 4, 2025
84c6871
Fix @stage_deecorator parameters
dan-fernandes Feb 4, 2025
4efba98
Make all TestBimorphOptimisation tests use detectors fixture rather t…
dan-fernandes Feb 4, 2025
3d72ea5
Add run_metadata param to inner_scan
dan-fernandes Feb 11, 2025
28e6cec
Merge from main
dan-fernandes Feb 11, 2025
dc6c5d5
Replace all DeviceCollector with init_devices
dan-fernandes Feb 11, 2025
5df6853
Correct import
dan-fernandes Feb 11, 2025
e46d7f1
Add missing
dan-fernandes Feb 11, 2025
7e32439
Add close_run calls
dan-fernandes Feb 11, 2025
fd38f0d
Move open_run to start of plan, fix indentation error
dan-fernandes Feb 11, 2025
60da4a3
Replace plans wrapping inner_scan with pure inner_scan as it is now a…
dan-fernandes Feb 11, 2025
99698c6
In outer() use new dict for each run_metadata
dan-fernandes Feb 11, 2025
35be22e
Fix inner_run parameters
dan-fernandes Feb 11, 2025
ae627db
Add TestInnerScan.test_inner_scan_writes_run_metadata, and run_metada…
dan-fernandes Feb 11, 2025
bbcd92f
Reduce fixture permutations
dan-fernandes Feb 11, 2025
b9a4f63
Add TestIntegration
dan-fernandes Feb 12, 2025
76860b1
Make inner and outer create nested runs
dan-fernandes Feb 17, 2025
a80d326
Remove mock=True from oav fixture
dan-fernandes Feb 17, 2025
25ab7d1
Add prepare detectors in inner_scan
dan-fernandes Feb 18, 2025
829b1de
Add mock=True to oav fixture
dan-fernandes Feb 18, 2025
5f171ca
Remove mock=True from OAV fixture
dan-fernandes Feb 18, 2025
165d779
Set number_of_triggers in detector preperation to 1
dan-fernandes Feb 18, 2025
953b9ee
Remove outer run
dan-fernandes Feb 18, 2025
317980a
Use different stream for each pencil beam scan
dan-fernandes Feb 19, 2025
a2da5fe
Add stream_name
dan-fernandes Feb 19, 2025
ea302d8
Remove commented out code
dan-fernandes Feb 19, 2025
508ddb8
Update inner_scan docstring
dan-fernandes Feb 19, 2025
25e59ea
Replace TestInnerScan fixture and params from scan_metadata to stream…
dan-fernandes Feb 19, 2025
8411322
Fix TestInnerScan.test_inner_scan_triggers_and_reads
dan-fernandes Feb 19, 2025
86beae4
Remove uneccesary variable assignment
dan-fernandes Feb 19, 2025
16d02b3
Prepare detectors before first declare_stream
dan-fernandes Feb 19, 2025
6b96759
Remove run_metadata
dan-fernandes Feb 19, 2025
b690c84
Add metadata to outer_scan run
dan-fernandes Feb 20, 2025
63801c9
Add TestBimorphOptimisation.test_metadata
dan-fernandes Feb 20, 2025
7d2efd6
Add validate_bimorph_plan, check_valid_bimorph_state
dan-fernandes Feb 21, 2025
ccb5f4c
Add bimorph plan validation
dan-fernandes Feb 24, 2025
adb6b98
Add status wait to channel set
dan-fernandes Feb 25, 2025
a983c7f
Make BimorphMirrorChannel.set literally just set target voltage
dan-fernandes Feb 25, 2025
0ef082e
Change bimorph_optimisation to move bimorph via full mirror, rather t…
dan-fernandes Feb 25, 2025
fcd188b
Change BimorphMirrorChannel.set to set output_voltage, not target_vol…
dan-fernandes Feb 25, 2025
17611c0
Have restore_bimorph_state move bimorph via mirror, not individual ch…
dan-fernandes Feb 25, 2025
53b9623
Change BimorphMirror.set to accept array param rather than mapping
dan-fernandes Feb 25, 2025
a29589f
Change BimorphMirror.set to set in parallel
dan-fernandes Feb 25, 2025
bdb7eb0
Add BimorphMirror.commit_target_voltages
dan-fernandes Feb 25, 2025
1f6ea96
Update tests to reflect BimorphMirror.set interface change
dan-fernandes Feb 25, 2025
97cc869
Replace DeviceCollector with init_devices
dan-fernandes Feb 25, 2025
aa61a07
Remove test_set_one_channel
dan-fernandes Feb 25, 2025
4139398
Merge branch 'bimorph-mirrors' into 230-bimorph-optimisation-plan
dan-fernandes Feb 25, 2025
c707e45
Fix syntax
dan-fernandes Feb 25, 2025
9603175
Make bimorph_optimisation move mirror with array rather than dict
dan-fernandes Feb 25, 2025
94f0163
Mak restore_bimorph_state write to mirror with list rather than dict
dan-fernandes Feb 25, 2025
c8117c6
Fix test_save_and_restore fixture
dan-fernandes Feb 25, 2025
9070309
Add configurable slit settle time
dan-fernandes Feb 26, 2025
191169f
Add move to start voltage list before first inner_scan
dan-fernandes Feb 26, 2025
d445d53
Add slit settle time after move to initial position
dan-fernandes Feb 28, 2025
384b889
Add bimorph settle time after moving into pos
dan-fernandes Feb 28, 2025
b590177
Move bimorph starting position out of outer scan
dan-fernandes Feb 28, 2025
ddf18f9
Move all start position movements into outer_scan
dan-fernandes Feb 28, 2025
347a6a0
Add test_bimorph_position_generator, fix TestBimorphOptimisation.test…
dan-fernandes Feb 28, 2025
969c3c0
Add bimorph_position_generator
dan-fernandes Feb 28, 2025
7fc763e
Merge branch 'main' into 230-bimorph-optimisation-plan
dan-fernandes Mar 4, 2025
2fda319
Make bimorph_position_generator return copy of internal list
dan-fernandes Mar 5, 2025
b65c3b9
Fix bimorph_position_generator returning internal list
dan-fernandes Mar 5, 2025
d3ad288
Add TestBimorphPositionGenerator
dan-fernandes Mar 5, 2025
3b28d46
Rework bimorph_position_generator to reduce copying mutables
dan-fernandes Mar 5, 2025
4594f88
Remove BimorphMirrorChannel.set
dan-fernandes Mar 5, 2025
dd55bf9
Merge branch 'bimorph-mirrors' into 230-bimorph-optimisation-plan
dan-fernandes Mar 5, 2025
24d13f8
Add TestPlanValidation
dan-fernandes Mar 5, 2025
3059eb8
Fix bimorph_optimisation type ignore
dan-fernandes Mar 5, 2025
bbf2fbf
Fix type checking
dan-fernandes Mar 5, 2025
c2bff4a
Merge main into 230-bimorph-optimisation-plan
dan-fernandes Apr 25, 2025
0f61605
Replace PatternDetector with SimBlobDetector
dan-fernandes Apr 25, 2025
5446488
Fix BimorphMirror inheritance
dan-fernandes Apr 25, 2025
ad69f9f
Improve test speeds
dan-fernandes Apr 25, 2025
125bf33
Fix (badly) initial_voltage_list
dan-fernandes Apr 25, 2025
2bd0816
Fix test_copies_list positions
dan-fernandes Apr 25, 2025
5719d46
Merge branch 'main' into 230-bimorph-optimisation-plan
Apr 30, 2025
b868e43
Export bimorph_optimisation plan
Apr 30, 2025
86edd88
Remove uneccesary default argument
dan-fernandes Apr 30, 2025
e0757d6
Make SlitDimension inherit from Enum and str
May 2, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
65 changes: 29 additions & 36 deletions src/dodal/devices/bimorph_mirror.py
Original file line number Diff line number Diff line change
@@ -1,17 +1,16 @@
import asyncio
from collections.abc import Mapping
from typing import Annotated as A

from bluesky.protocols import Movable
from ophyd_async.core import (
DEFAULT_TIMEOUT,
AsyncStatus,
DeviceVector,
SignalR,
SignalRW,
SignalW,
StandardReadable,
StrictEnum,
set_and_wait_for_other_value,
wait_for_value,
)
from ophyd_async.core import StandardReadableFormat as Format
Expand All @@ -23,6 +22,8 @@
epics_signal_x,
)

DEFAULT_TIMEOUT = 60


class BimorphMirrorOnOff(StrictEnum):
ON = "ON"
Expand All @@ -41,7 +42,7 @@ class BimorphMirrorStatus(StrictEnum):
ERROR = "Error"


class BimorphMirrorChannel(StandardReadable, Movable[float], EpicsDevice):
class BimorphMirrorChannel(StandardReadable, EpicsDevice):
"""Collection of PVs comprising a single bimorph channel.

Attributes:
Expand All @@ -56,23 +57,13 @@ class BimorphMirrorChannel(StandardReadable, Movable[float], EpicsDevice):
status: A[SignalR[BimorphMirrorOnOff], PvSuffix("STATUS"), Format.CONFIG_SIGNAL]
shift: A[SignalW[float], PvSuffix("SHIFT")]

@AsyncStatus.wrap
async def set(self, value: float):
"""Sets channel's VOUT to given value.

Args:
value: float to set VOUT to
"""
await self.output_voltage.set(value)


class BimorphMirror(StandardReadable, Movable[Mapping[int, float]]):
class BimorphMirror(StandardReadable, Movable):
"""Class to represent CAENels Bimorph Mirrors.

Attributes:
channels: DeviceVector of BimorphMirrorChannel, indexed from 1, for each channel
enabled: Writeable BimorphOnOff
commit_target_voltages: Procable signal that writes values in each channel's VTRGT to VOUT
status: Readable BimorphMirrorStatus Busy/Idle status
err: Alarm status"""

Expand Down Expand Up @@ -103,49 +94,51 @@ def __init__(self, prefix: str, number_of_channels: int, name=""):
super().__init__(name=name)

@AsyncStatus.wrap
async def set(self, value: Mapping[int, float], tolerance: float = 0.0001) -> None:
"""Sets bimorph voltages in parrallel via target voltage and all proc.
async def set(self, value: list[float]) -> None:
"""Sets bimorph voltages in parallel via target voltage and all proc.

Args:
value: Dict of channel numbers to target voltages
value: List of float target voltages

Raises:
ValueError: On set to non-existent channel"""

if any(key not in self.channels for key in value):
if len(value) != len(self.channels):
raise ValueError(
f"Attempting to put to non-existent channels: {[key for key in value if (key not in self.channels)]}"
f"Length of value input array does not match number of \
channels: {len(value)} and {len(self.channels)}"
)

# Write target voltages:
await asyncio.gather(
*[
self.channels[i].target_voltage.set(target, wait=True)
for i, target in value.items()
]
)
# Write target voltages in serial
# Voltages are written in serial as bimorph PSU cannot handle simultaneous sets
for i, target in enumerate(value):
await wait_for_value(
self.status, BimorphMirrorStatus.IDLE, timeout=DEFAULT_TIMEOUT
)
await set_and_wait_for_other_value(
self.channels[i + 1].target_voltage,
target,
self.status,
BimorphMirrorStatus.BUSY,
)

# Trigger set target voltages:
await wait_for_value(
self.status, BimorphMirrorStatus.IDLE, timeout=DEFAULT_TIMEOUT
)
await self.commit_target_voltages.trigger()

# Wait for values to propogate to voltage out rbv:
await asyncio.gather(
*[
wait_for_value(
self.channels[i].output_voltage,
tolerance_func_builder(tolerance, target),
self.channels[i + 1].output_voltage,
target,
timeout=DEFAULT_TIMEOUT,
)
for i, target in value.items()
for i, target in enumerate(value)
],
wait_for_value(
self.status, BimorphMirrorStatus.IDLE, timeout=DEFAULT_TIMEOUT
),
)


def tolerance_func_builder(tolerance: float, target_value: float):
def is_within_value(x):
return abs(x - target_value) <= tolerance

return is_within_value
3 changes: 2 additions & 1 deletion src/dodal/plans/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
from .bimorph import bimorph_optimisation
from .scanspec import spec_scan
from .wrapped import count

__all__ = ["count", "spec_scan"]
__all__ = ["count", "spec_scan", "bimorph_optimisation"]
Loading
Loading