From 11d1c4449a5a259975bff737a51d224d36267334 Mon Sep 17 00:00:00 2001 From: "Mark A. Tsuchida" Date: Thu, 19 Oct 2023 15:23:36 -0500 Subject: [PATCH] MMCore: Add getDeviceInitializationState() --- MMCore/Devices/DeviceInstance.h | 3 +++ MMCore/MMCore.cpp | 25 ++++++++++++++++++++++++- MMCore/MMCore.h | 7 +++++++ MMCoreJ_wrap/pom.xml | 2 +- 4 files changed, 35 insertions(+), 2 deletions(-) diff --git a/MMCore/Devices/DeviceInstance.h b/MMCore/Devices/DeviceInstance.h index 760e46031..0919ca1a4 100644 --- a/MMCore/Devices/DeviceInstance.h +++ b/MMCore/Devices/DeviceInstance.h @@ -90,6 +90,9 @@ class DeviceInstance // Callback API int LogMessage(const char* msg, bool debugOnly); + bool IsInitialized() const { return initialized_; } + bool HasInitializationBeenAttempted() const { return initializeCalled_; } + protected: // The DeviceInstance object owns the raw device pointer (pDevice) as soon // as the constructor is called, even if the constructor throws. diff --git a/MMCore/MMCore.cpp b/MMCore/MMCore.cpp index f88bb60ec..bf0ace683 100644 --- a/MMCore/MMCore.cpp +++ b/MMCore/MMCore.cpp @@ -113,7 +113,7 @@ using namespace std; * (Keep the 3 numbers on one line to make it easier to look at diffs when * merging/rebasing.) */ -const int MMCore_versionMajor = 10, MMCore_versionMinor = 6, MMCore_versionPatch = 0; +const int MMCore_versionMajor = 10, MMCore_versionMinor = 7, MMCore_versionPatch = 0; /////////////////////////////////////////////////////////////////////////////// @@ -963,6 +963,29 @@ void CMMCore::initializeDevice(const char* label ///< the device to initialize } +/** + * Queries the initialization state of the given device. + * + * @param label the device label + */ +DeviceInitializationState +CMMCore::getDeviceInitializationState(const char* label) const throw (CMMError) +{ + std::shared_ptr pDevice = deviceManager_->GetDevice(label); + + mm::DeviceModuleLockGuard guard(pDevice); + if (pDevice->IsInitialized()) + { + return DeviceInitializationState::InitializedSuccessfully; + } + if (pDevice->HasInitializationBeenAttempted()) + { + return DeviceInitializationState::InitializationFailed; + } + return DeviceInitializationState::Uninitialized; +} + + /** * Updates the state of the entire hardware. diff --git a/MMCore/MMCore.h b/MMCore/MMCore.h index 71addcb64..fa0aaa1f9 100644 --- a/MMCore/MMCore.h +++ b/MMCore/MMCore.h @@ -112,6 +112,12 @@ namespace mm { typedef unsigned int* imgRGB32; +enum DeviceInitializationState { + Uninitialized, + InitializedSuccessfully, + InitializationFailed, +}; + /// The Micro-Manager Core. /** @@ -147,6 +153,7 @@ class CMMCore void unloadAllDevices() throw (CMMError); void initializeAllDevices() throw (CMMError); void initializeDevice(const char* label) throw (CMMError); + DeviceInitializationState getDeviceInitializationState(const char* label) const throw (CMMError); void reset() throw (CMMError); void unloadLibrary(const char* moduleName) throw (CMMError); diff --git a/MMCoreJ_wrap/pom.xml b/MMCoreJ_wrap/pom.xml index 35699836b..8923fec73 100644 --- a/MMCoreJ_wrap/pom.xml +++ b/MMCoreJ_wrap/pom.xml @@ -3,7 +3,7 @@ org.micro-manager.mmcorej MMCoreJ jar - 10.6.0 + 10.7.0 Micro-Manager Java Interface to MMCore Micro-Manager is open source software for control of automated/motorized microscopes. This specific packages provides the Java interface to the device abstractino layer (MMCore) that is written in C++ with a C-interface http://micro-manager.org