Skip to content

pass function to device server instead of class with args as a separate argument #154

Closed
@carandraug

Description

@carandraug

Currently, the configuration of a device server is as follow:

DEVICES = [
    device(TestStage, 'localhost', 8009,
           conf={'limits' : {'X' : AxisLimits(0, 5000),
                             'Y' : AxisLimits(0, 5000)}}),
]

However, would be nice if instead one could pass a function that returns a device (or list of devices). Something like this:

def device_factory():
    return TestStage({'X' : AxisLimits(0, 5000), 'Y' : AxisLimits(0, 5000)})

DEVICES = [
    device(device_factory, 'localhost', 8009),
]

Other than making it easier to construct some devices, the main reason is to enable have multiple devices on the same process. For most cases we want to have them in separate processes to avoid the GIL. However, in some cases we want instead to make it easier to pass data between devices. These are cases where we need to processing (typically an image) such as the Aurox. Actually, this has already been mentioned before (see comments and review of #124). We are currently abusing ControllerDevice to achieve this, but having the ability to pass a function that will construct the devices would solve that. We could then have something like:

def func():
    camera = CameraDevice(whatever_args)
    aurox = AuroxDevice(camera)
    return [camera, aurox]

DEVICES = [
    device(func, hostame, port)
]

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions