Skip to content

Add an optional profiles argument for @devices.factory() #1918

@oliwenmandiamond

Description

@oliwenmandiamond

For I07, they have two end stations, eh1 and eh2. They can only have one experiment at a time.

If it's in eh1 it will use everything in eh1 only. 

If it's in eh2 it will use everything in eh1 except the diffractometer and detectors and everything in eh2. 

If there is an experiment in eh1 they may do commissioning in eh2 at the same time so would require only things in eh2. 

So there are three cases: 

  • ["common", "eh1"]
  • ["common", "eh2"]
  • ["eh2"]

As of current, we have DeviceManager.include(shared_devices) for compulsory shared components between endstations of beamlines. However, we don't take into account any hardware which is optional. I think a solution to this is allow devices to have an optional argument for a profile when using factory. Then when using from BlueAPI end, you can select which profiles you want to load from DeviceManager.

E.g dodal side for a beamline:

devices = DeviceManager()

@devices.factory(profile="eh1")
def device1() -> Device:
    return Device()

@devices.factory(profile="eh2")
def device2() -> Device:
    return Device()

# Default is profile="common"
@devices.factory()
def common_device() -> Device:
    return Device()

Then with DeviceManager when it comes to loading the devices from BlueAPI, we have the following options to load in with the specific group of devices we need:
EH1

devices.build_and_connect(profiles = ["eh1", "common"])

EH2

devices.build_and_connect(profiles = ["eh2", "common"])

EH2 commissioning only

devices.build_and_connect(profiles = ["eh2"])

If beamlines are not interested in this feature, they can ignore it as the default will be profiles = ["common"] so nothing changes for them as it will load in all devices.

Metadata

Metadata

Assignees

No one assigned

    Labels

    DesignDiscussion about the internal design of the repoenhancementNew feature or request

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions