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

Make StandardReadable into generic PluggableDevice #1144

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

coretl
Copy link
Collaborator

@coretl coretl commented Aug 4, 2023

This means we can write more complicated "plugs" for things like areaDetector filewriting, and form our classes by composition. For instance I imagine something like:

class PilatusArmingLogic:
    def __init__(self, device: PluggableDevice, drv: PilatusDriver):
        self.drv = drv
        add_readable_signals(device, config=[drv.acquire_time])
        # so flyscans can find the right logic for a device
        register_det_logic(self, device)
        device.add_plug(stage=self.setup, trigger=self.arm)
    
    @AsyncStatus.wrap
    def setup(self) -> None:
        await self.drv.wait_for_plugins.set(True)

    @AsyncStatus.wrap
    def arm(self, num_images: Optional[int] = None):
        await arm_ad_driver(self.drv, num_images)

    async def get_deadtime(self, exposure: float) -> float:
        # Just for flyscans
        # Might need to prod the driver to do these calcs
        return calc_deadtime(exposure, readout_time=0.02, frequency_accuracy=50)

class MyDetector(PluggableDevice):
    def __init__(self, prefix: str, settings: Dict[str, Any], name: Optional[str] = None):      
        self.drv = PilatusDriver(prefix + ":DRV")
        PilatusArmingLogic(self, self.drv,)
        self.hdf = NDFileHDF(prefix + ":HDF")
        HDFStreamingLogic(self, self.hdf)
        self.stat = NDFileStats(prefix + ":STAT")
        add_readable_signals(self, read=[self.stat.min, self.stat.max, self.stat.mean])
        self.add_plug(stage=SettingsLoader(self, settings)
        super().__init__(name)

@coretl coretl requested a review from rosesyrett August 4, 2023 15:18
@coretl
Copy link
Collaborator Author

coretl commented Aug 4, 2023

Linting won't pass until bluesky/bluesky#1590

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.

1 participant