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

Device Hierarchy #7

Open
nanthony21 opened this issue Mar 11, 2021 · 2 comments
Open

Device Hierarchy #7

nanthony21 opened this issue Mar 11, 2021 · 2 comments
Labels
MMDevice Related to the redesign of MMDevice API

Comments

@nanthony21
Copy link
Member

nanthony21 commented Mar 11, 2021

Should the inheritance structure of device types be more hierarchical?

Something like: ?
DataAcquisitionDevice:

  • Cameras (Acquisition2dDevice)
  • Photodiodes (Acquisition1dDevice)
  • Any other sensor that produces more data than is practical to transmit through properties.

PositionedDevice: (Indicates requirement for affine transform):

  • Camera
  • 2dStage
  • 1dStage
    ...
@henrypinkard henrypinkard changed the title GDOCS: Device Hierarchy Device Hierarchy Mar 23, 2021
@henrypinkard henrypinkard added the MMDevice Related to the redesign of MMDevice API label Mar 23, 2021
@campagnola
Copy link

@nanthony21 what is your intent here--to enforce common API across devices? Better code reuse?

I generally prefer shallow device class hierarchies with the ability for each device to implement different APIs depending on their capabilities. For example, a camera is a type of device that provides 2D imaging capabilities, but I might hesitate to subclass Camera from a more general 2D imaging device class. One implementation of this might look like:

camera = SomeCameraClass()
acq2d = camera.get_interface('acquisition2d')
image_data = acq2d.acquire_image()

It's a bit more verbose, but so much more scalable in that you can easily mix/match many different interfaces for your device to implement, while isolating the code for each of those. I'm happy to provide more detail on this, but from here the conversation dives deep into the "composition vs inheritance" debate and there are already a thousand articles on that topic elsewhere.

@nanthony21
Copy link
Member Author

I like this idea of allowing a single device to implement multiple device interfaces. I may be mistaken, but I think that currently if you have a single hardware device that fits into multiple categories the only solution is to write a separate device adapter class for each interface you want to implement and then tie them all together using a Hub device.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
MMDevice Related to the redesign of MMDevice API
Projects
None yet
Development

No branches or pull requests

3 participants