From f4221fb64651bd21f56c6a7b3af34fb0566c292b Mon Sep 17 00:00:00 2001 From: Lars Kool Date: Wed, 21 Aug 2024 09:37:42 +0200 Subject: [PATCH] Fixed bug with getting/setting current pumps --- MMCore/MMCore.cpp | 76 ++++++++++++++++++++++++++++++++++++ MMCore/MMCore.h | 6 +++ MMDevice/MMDeviceConstants.h | 2 + 3 files changed, 84 insertions(+) diff --git a/MMCore/MMCore.cpp b/MMCore/MMCore.cpp index 0f36782f9..632201904 100644 --- a/MMCore/MMCore.cpp +++ b/MMCore/MMCore.cpp @@ -3571,6 +3571,82 @@ void CMMCore::setCameraDevice(const char* cameraLabel) throw (CMMError) } } +/** + * Returns the label of the currently selected PressurePump device. + * @return pressure pump name + */ +std::string CMMCore::getPressurePumpDevice() +{ + std::shared_ptr pPressurePump = currentPressurePump_.lock(); + if (pPressurePump) + { + return pPressurePump->GetLabel(); + } + return std::string(); +} + +/** + * Returns the label of the currently selected VolumetricPump device. + * @return volumetric pump name + */ +std::string CMMCore::getVolumetricPumpDevice() +{ + std::shared_ptr pVolumetricPump = currentVolumetricPump_.lock(); + if (pVolumetricPump) + { + return pVolumetricPump->GetLabel(); + } + return std::string(); +} + +/** + * Sets the current PressurePump device. + */ +void CMMCore::setPressurePumpDevice(const char* pressurePumpLabel) throw (CMMError) +{ + if (pressurePumpLabel && strlen(pressurePumpLabel) > 0) + { + currentPressurePump_ = + deviceManager_->GetDeviceOfType(pressurePumpLabel); + LOG_INFO(coreLogger_) << "Default pressure pump set to " << pressurePumpLabel; + } + else + { + currentPressurePump_.reset(); + LOG_INFO(coreLogger_) << "Default pressure pump unset"; + } + properties_->Refresh(); // TODO: more efficient + std::string newPumpLabel = getPressurePumpDevice(); + { + MMThreadGuard scg(stateCacheLock_); + stateCache_.addSetting(PropertySetting(MM::g_Keyword_CoreDevice, MM::g_Keyword_CorePressurePump, newPumpLabel.c_str())); + } +} + +/** + * Sets the current PressurePump device. + */ +void CMMCore::setVolumetricPumpDevice(const char* volumetricPumpLabel) throw (CMMError) +{ + if (volumetricPumpLabel && strlen(volumetricPumpLabel) > 0) + { + currentVolumetricPump_ = + deviceManager_->GetDeviceOfType(volumetricPumpLabel); + LOG_INFO(coreLogger_) << "Default volumetric pump set to " << volumetricPumpLabel; + } + else + { + currentPressurePump_.reset(); + LOG_INFO(coreLogger_) << "Default volumetric pump unset"; + } + properties_->Refresh(); // TODO: more efficient + std::string newPumpLabel = getVolumetricPumpDevice(); + { + MMThreadGuard scg(stateCacheLock_); + stateCache_.addSetting(PropertySetting(MM::g_Keyword_CoreDevice, MM::g_Keyword_CorePressurePump, newPumpLabel.c_str())); + } +} + /** * Returns all property names supported by the device. * diff --git a/MMCore/MMCore.h b/MMCore/MMCore.h index 759fda0be..4e411e98f 100644 --- a/MMCore/MMCore.h +++ b/MMCore/MMCore.h @@ -282,6 +282,8 @@ class CMMCore std::string getPressurePumpDevice(); std::string getVolumetricPumpDevice(); std::string getChannelGroup(); + std::string getPressurePumpDevice(); + std::string getVolumetricPumpDevice(); void setCameraDevice(const char* cameraLabel) throw (CMMError); void setShutterDevice(const char* shutterLabel) throw (CMMError); void setFocusDevice(const char* focusLabel) throw (CMMError); @@ -293,6 +295,8 @@ class CMMCore void setPressurePumpDevice(const char* pumpLabel) throw (CMMError); void setVolumetricPumpDevice(const char* pumpLabel) throw (CMMError); void setChannelGroup(const char* channelGroup) throw (CMMError); + void setPressurePumpDevice(const char* galvoLabel) throw (CMMError); + void setVolumetricPumpDevice(const char* galvoLabel) throw (CMMError); ///@} /** \name System state cache. @@ -685,6 +689,8 @@ class CMMCore std::weak_ptr currentAutofocusDevice_; std::weak_ptr currentSLMDevice_; std::weak_ptr currentGalvoDevice_; + std::weak_ptr currentPressurePump_; + std::weak_ptr currentVolumetricPump_; std::weak_ptr currentImageProcessor_; std::weak_ptr currentPressurePump_; std::weak_ptr currentVolumetricPump_; diff --git a/MMDevice/MMDeviceConstants.h b/MMDevice/MMDeviceConstants.h index bdb2215b9..3f56ee8a3 100644 --- a/MMDevice/MMDeviceConstants.h +++ b/MMDevice/MMDeviceConstants.h @@ -134,6 +134,8 @@ namespace MM { const char* const g_Keyword_CorePressurePump = "PressurePump"; const char* const g_Keyword_CoreVolumetricPump = "VolumetricPump"; const char* const g_Keyword_CoreTimeoutMs = "TimeoutMs"; + const char* const g_Keyword_CorePressurePump = "PressurePump"; + const char* const g_Keyword_CoreVolumetricPump = "VolumetricPump"; const char* const g_Keyword_Channel = "Channel"; const char* const g_Keyword_Version = "Version"; const char* const g_Keyword_ColorMode = "ColorMode";