-
Notifications
You must be signed in to change notification settings - Fork 25
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
Adding driver and controller classes for Kinetix and Vimba cameras #216
Conversation
src/ophyd_async/epics/areadetector/controllers/kinetix_controller.py
Outdated
Show resolved
Hide resolved
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 could we have some tests too?
A subset of https://github.com/bluesky/ophyd-async/blob/main/tests/epics/areadetector/test_aravis.py would be good
I note that the vimba driver should probably use the deadtime calculations from aravis, and the aravis driver should use the gated modes from vimba, but I'll make a separate issue for that
super().__init__(prefix) | ||
# self.pixel_format = ad_rw(PixelFormat, prefix + "PixelFormat") | ||
self.trigger_mode = ad_rw(KinetixTriggerMode, prefix + "TriggerMode") | ||
self.mode = ad_rw(KinetixReadoutMode, prefix + "ReadoutPortIdx") |
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.
For areaDetector I've tended to name the attribute after the PV suffix, is there a reason to name this mode
rather than readout_port_idx
or readout_mode
?
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 had ReadoutMode
originally, but changed it because I couldn't make the linter happy actually...
I didn't want to use ReadoutModeIdx
because I think treating it as a ReadoutMode
selection rather than an index in the list is better.
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 you point me to the corresponding record in the template please?
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.
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 these enum strings be pushed down to the template? Then having a ReadoutMode
PV would make more sense...
I've tried not to add any translation in the "bucket of PVs" layer, and put the logic in the Controller
, but I guess that is difficult here as the attribute isn't used in the controller.
Either way, I think readout_mode
for the attribute and KinetixReadoutMode
are reasonable names, is the linter happy with those?
def __init__( | ||
self, | ||
driver: KinetixDriver, | ||
good_states: Set[DetectorState] = set(DEFAULT_GOOD_STATES), |
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 don't know enough about AD DetectorStates, so I ignored this param for the Pilatus and Aravis- do we think it's important to expose? I can go back and adjust those detectors before there's any pickup.
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 see no reason to have to override the good states when instantiating the Controller, I think we know up front what are the good states for a given detector.
@jwlodek any reason you added it as an init arg? If not then I recommend we:
good_states: Set[DetectorState] = set(DEFAULT_GOOD_STATES), |
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.
The only reason was that it was done this way for the Pilatus when I was writing these classes.
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.
For the Pilatus and the Aravis we've also created fooDetector types- partly because we didn't want to split the implementation of the device between two repositories- should we stick with that format (and have facility specific handling limited to calling the constructor fo the StandardDetector), or should the StandardDetectorImplementation be in facility specific code?
Having thought about this a bit more, I think I would prefer this pattern: class FooDetector(StandardDetector):
def __init__(
self,
drv_prefix: str,
hdf_prefix: str,
...,
name: str = "",
):
self.drv = ADFoo(drv_prefix)
self.hdf = NDFileHDF(hdf_prefix)
super().__init__(
FooController(self.drv),
HDFWriter(self.hdf, ...),
...,
name=name
) Then we instantiate as @jwlodek @DiamondJoseph what do you think? |
I would go a step further: class FooDetector(StandardDetector):
def __init__(
self,
prefix: str, # Use base prefix as only positional arg
drv_prefix: str = 'cam1:', # Add defaults for drv/hdf component after base prefix
hdf_prefix: str = 'HDF1:',
...,
name: str = "",
):
self.drv = ADFoo(f'{prefix}{drv_prefix}')
self.hdf = NDFileHDF(f'{prefix}{drv_prefix}')
super().__init__(
FooController(self.drv),
HDFWriter(self.hdf, ...),
...,
name=name
) In 99% of cases at NSLS2 we leave the foo = FooDetector('XF:31ID1-ES{My-Det:1}') for example. If DLS use different defaults rather than |
@coretl could we merge this PR in before we make further changes to the format of the various classes? I'd like to be able to close out this branch and re-sync with main. |
534d5e1
to
3a79f7c
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.
Pilatus is now using the default GOOD_STATES from the ADBaseDriver, I'd like to see that consistent until we find a detector that isn't just taking GOOD_STATES. The exact form of FooDetector we can continue to quibble about.
eek pushed the big rebase button prematurely |
I've made a new issue from the "What form should StandardDetector.init take" |
Removed the states set kwarg. |
src/ophyd_async/epics/areadetector/controllers/kinetix_controller.py
Outdated
Show resolved
Hide resolved
src/ophyd_async/epics/areadetector/controllers/kinetix_controller.py
Outdated
Show resolved
Hide resolved
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'd prefer to get the mode
-> readout_mode
change (or similar) in soon, but happy to merge this and do a separate PR later if that is better
Addresses #210