Ejemplo n.º 1
0
def get_core_singleton(remote=False) -> CMMCorePlus:
    """Retrieve the MMCore singleton for this session.

    The first call to this function determines whether we're running remote or not.
    perhaps a temporary function for now...
    """
    global _SESSION_CORE
    if _SESSION_CORE is None:
        if remote:
            from pymmcore_plus import RemoteMMCore

            _SESSION_CORE = RemoteMMCore()  # type: ignore  # it has the same interface.
        else:
            _SESSION_CORE = CMMCorePlus.instance()
    return _SESSION_CORE
Ejemplo n.º 2
0
from pymmcore_plus import CMMCorePlus

# see https://github.com/tlambert03/useq-schema
sequence = MDASequence(
    channels=["DAPI", {
        "config": "FITC",
        "exposure": 50
    }],
    time_plan={
        "interval": 2,
        "loops": 5
    },
    z_plan={
        "range": 4,
        "step": 0.5
    },
    axis_order="tpcz",
)

mmc = CMMCorePlus.instance()
mmc.loadSystemConfiguration()


@mmc.mda.events.frameReady.connect
def new_frame(img, event):
    print(img.shape)


mda_thread = mmc.run_mda(sequence)
Ejemplo n.º 3
0
            Whether to force a change away from tracking the default camera.
        """
        if not force:
            raise RuntimeError(
                "Setting the camera on a DefaultCameraExposureWidget "
                "may cause it to malfunction. Either use *force=True* "
                " or create an ExposureWidget"
            )
        return super().setCamera(camera)

    def _camera_updated(self, value: str):
        # This will not always fire
        # see https://github.com/micro-manager/mmCoreAndDevices/issues/181
        self._camera = value
        # this will result in a double call of _on_load if this callback
        # was triggered by a configuration load. But I don't see an easy way around that
        # fortunately _on_load should be low cost
        self._on_load()


if __name__ == "__main__":  # pragma: no cover
    import sys

    from pymmcore_plus import CMMCorePlus  # noqa

    CMMCorePlus.instance().loadSystemConfiguration()
    app = QtW.QApplication(sys.argv)
    win = DefaultCameraExposureWidget()
    win.show()
    sys.exit(app.exec_())
Ejemplo n.º 4
0
from pymmcore_plus import CMMCorePlus

core = CMMCorePlus.instance()
core.loadSystemConfiguration()


# Note that when state devices change either the state or the label
# TWO propertyChanged events will be emitted, one for prop 'State'
# and one for prop 'Label'.
# Probably, best to check the property name and only respond to one of them
@core.events.propertyChanged.connect
def _on_prop_changed(dev, prop, value):
    if dev == "Objective" and prop == "Label":
        print("new objective is", value)


core.setState("Objective", 3)
Ejemplo n.º 5
0
def test_single_instance():
    core1 = CMMCorePlus.instance()
    core2 = CMMCorePlus.instance()
    assert core1 is core2