-
Notifications
You must be signed in to change notification settings - Fork 11
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
Fixes for ophyd-async 0.9.0a2 #1014
base: main
Are you sure you want to change the base?
Changes from 4 commits
aef44e7
56a931b
c62c022
da2aeb4
23e0c70
a9e0285
ddbc5d6
693f602
a6a3286
b0f01b6
658870e
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 |
---|---|---|
|
@@ -4,15 +4,15 @@ | |
from ophyd_async.core import ( | ||
DEFAULT_TIMEOUT, | ||
AsyncStatus, | ||
DetectorController, | ||
TriggerInfo, | ||
) | ||
from ophyd_async.epics import adcore | ||
from ophyd_async.epics.adcore import ADBaseController | ||
|
||
from dodal.devices.i13_1.merlin_io import MerlinDriverIO, MerlinImageMode | ||
|
||
|
||
class MerlinController(DetectorController): | ||
class MerlinController(ADBaseController): | ||
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 didn't properly check if this is correct but it looked about right |
||
def __init__( | ||
self, | ||
driver: MerlinDriverIO, | ||
|
@@ -37,11 +37,6 @@ async def prepare(self, trigger_info: TriggerInfo): | |
self.driver.image_mode.set(MerlinImageMode.MULTIPLE), | ||
) | ||
|
||
async def arm(self): | ||
self._arm_status = await adcore.start_acquiring_driver_and_ensure_status( | ||
self.driver, good_states=self.good_states, timeout=self.frame_timeout | ||
) | ||
|
||
async def wait_for_idle(self): | ||
if self._arm_status: | ||
await self._arm_status | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,8 +6,10 @@ | |
from typing import cast | ||
|
||
from bluesky.run_engine import RunEngine | ||
from ophyd_async.core import Device, save_device | ||
from ophyd_async.fastcs.panda import phase_sorter | ||
from ophyd_async.core import Device, YamlSettingsProvider | ||
from ophyd_async.plan_stubs import ( | ||
store_settings, | ||
) | ||
|
||
from dodal.beamlines import module_name_for_beamline | ||
from dodal.utils import make_device | ||
|
@@ -17,27 +19,35 @@ def main(argv: list[str]): | |
"""CLI Utility to save the panda configuration.""" | ||
parser = ArgumentParser(description="Save an ophyd_async panda to yaml") | ||
parser.add_argument( | ||
"--beamline", help="beamline to save from e.g. i03. Defaults to BEAMLINE" | ||
"--beamline", help="Beamline to save from e.g. i03. Defaults to BEAMLINE" | ||
) | ||
parser.add_argument( | ||
"--device-name", | ||
help='name of the device. The default is "panda"', | ||
help='Name of the device. The default is "panda"', | ||
default="panda", | ||
) | ||
parser.add_argument( | ||
"--file-name", | ||
help="Name of the output save file", | ||
default="panda_settings.yaml", | ||
) | ||
parser.add_argument( | ||
"--output-directory", help="Directory in which save file is output" | ||
) | ||
parser.add_argument( | ||
"-f", | ||
"--force", | ||
action=argparse.BooleanOptionalAction, | ||
help="Force overwriting an existing file", | ||
) | ||
parser.add_argument("output_file", help="output filename") | ||
|
||
# this exit()s with message/help unless args parsed successfully | ||
args = parser.parse_args(argv[1:]) | ||
|
||
beamline = args.beamline | ||
device_name = args.device_name | ||
output_file = args.output_file | ||
file_name = args.file_name | ||
output_directory = args.output_directory | ||
force = args.force | ||
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 think you could just leave the options unchanged and do
then you wouldn't need two parameters. It's a bit strange to make the output directory a mandatory option but the filename optional, normally the output file is the last parameter for most tools |
||
|
||
if beamline: | ||
|
@@ -49,19 +59,19 @@ def main(argv: list[str]): | |
sys.stderr.write("BEAMLINE not set and --beamline not specified\n") | ||
return 1 | ||
|
||
if Path(output_file).exists() and not force: | ||
if Path(file_name).exists() and not force: | ||
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. doesn't this now need to be 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. Yeah thanks, good catch |
||
sys.stderr.write( | ||
f"Output file {output_file} already exists and --force not specified." | ||
f"Output file {file_name} already exists and --force not specified." | ||
) | ||
return 1 | ||
|
||
_save_panda(beamline, device_name, output_file) | ||
_save_panda(beamline, device_name, output_directory, file_name) | ||
|
||
print("Done.") | ||
return 0 | ||
|
||
|
||
def _save_panda(beamline, device_name, output_file): | ||
def _save_panda(beamline, device_name, output_directory, file_name): | ||
RE = RunEngine() | ||
print("Creating devices...") | ||
module_name = module_name_for_beamline(beamline) | ||
|
@@ -72,13 +82,16 @@ def _save_panda(beamline, device_name, output_file): | |
sys.exit(1) | ||
|
||
panda = devices[device_name] | ||
print(f"Saving to {output_file} from {device_name} on {beamline}...") | ||
_save_panda_to_file(RE, cast(Device, panda), output_file) | ||
print(f"Saving to {file_name} from {device_name} on {beamline}...") | ||
_save_panda_to_yaml(RE, cast(Device, panda), file_name, output_directory) | ||
|
||
|
||
def _save_panda_to_file(RE: RunEngine, panda: Device, path: str): | ||
def _save_panda_to_yaml( | ||
RE: RunEngine, panda: Device, file_name: str, output_directory: str | ||
): | ||
def save_to_file(): | ||
yield from save_device(panda, path, sorter=phase_sorter) | ||
provider = YamlSettingsProvider(output_directory) | ||
yield from store_settings(provider, file_name, panda) | ||
|
||
RE(save_to_file()) | ||
|
||
|
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.
Can we at least be consistent about whether or not we are using
HDF5_PREFIX
?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.
I've adjusted all of the existing beamlines to make use of it- and CAM_SUFFIX/DET_SUFFIX to at least make it clear we have 2 standards and absolutely for sure definitely never any more.