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

MMCore getInstance idea #32

Open
xcasas opened this issue May 17, 2021 · 2 comments
Open

MMCore getInstance idea #32

xcasas opened this issue May 17, 2021 · 2 comments

Comments

@xcasas
Copy link

xcasas commented May 17, 2021

Hey :)

I was reading the manuscript and you mention that it should be possible to have other implementations where pointers to the devices would be possible and I just thought of this idea:

  1. You could have a function in MMCore called getInstance or getPointer, for example, and send as a parameter the device name. I think that would be very beneficial for languages like python, where we could do something like:
  • MMCore add device Camera
  • MMCore initialize device Camera
  • MMCore getInstance Camera

And then, one could directly have that pointer associated with an object in some object-oriented language like Python. The only thing is that:

  1. It would be nice if it is then possible to call functions from that device directly by using the pointer. So in that case, then the class could directly call, for example, camera.snapImage(), instead of core.snapImage(). That would be nice for using multiple cameras, in my opinion.

I don't know if it makes sense. I hope I understood the scope correctly. But in this case, you could keep the same architecture as now, everything going through the MMCore but at the same time enable modularity from other languages.

@rwb27
Copy link

rwb27 commented May 25, 2021

I have used a similar pattern in a Python library (nplab) where we had a method to return an instance, and also a method to return all instances (e.g. if you have more than one camera or stage). I guess there is already a notion of the default camera/stage in MMCore, so unlike my implementation, there's a well-defined behaviour for which device you get if you have several!

@xcasas
Copy link
Author

xcasas commented May 25, 2021

That's exactly what I was thinking actually, I think it's a really nice implementation you have in the class Instrument in nplab/init.py, since all your devices (I think) are a subclass of Instrument then that function will be inherited. That could be done similarly in MMCore with MMDevice, although it probably needs to be a bit different since it will be called from other programming languages like Java or Python, but I guess it could be done the same way pymmcore returns a pointer to MMCore.

As you said I think for MMCore initially there was a clear behaviour, but I'm thinking if people want to use the device layer exclusively, they could highly benefit from that. I have been trying myself to do that but since I have one class per device it was hard to think of an architecture compatible with MMCore.

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

No branches or pull requests

2 participants