Skip to content

Commit

Permalink
Merge pull request #395 from micro-manager/query-device-init
Browse files Browse the repository at this point in the history
MMCore: Add getDeviceInitializationState()
  • Loading branch information
marktsuchida authored Oct 20, 2023
2 parents 49822fd + 11d1c44 commit 0fbf881
Show file tree
Hide file tree
Showing 4 changed files with 35 additions and 2 deletions.
3 changes: 3 additions & 0 deletions MMCore/Devices/DeviceInstance.h
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
25 changes: 24 additions & 1 deletion MMCore/MMCore.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;


///////////////////////////////////////////////////////////////////////////////
Expand Down Expand Up @@ -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<DeviceInstance> 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.
Expand Down
7 changes: 7 additions & 0 deletions MMCore/MMCore.h
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,12 @@ namespace mm {

typedef unsigned int* imgRGB32;

enum DeviceInitializationState {
Uninitialized,
InitializedSuccessfully,
InitializationFailed,
};


/// The Micro-Manager Core.
/**
Expand Down Expand Up @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion MMCoreJ_wrap/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<groupId>org.micro-manager.mmcorej</groupId>
<artifactId>MMCoreJ</artifactId>
<packaging>jar</packaging>
<version>10.6.0</version>
<version>10.7.0</version>
<name>Micro-Manager Java Interface to MMCore</name>
<description>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</description>
<url>http://micro-manager.org</url>
Expand Down

0 comments on commit 0fbf881

Please sign in to comment.