From 393392094a8f96be1c42abb9392a87b88376b7e6 Mon Sep 17 00:00:00 2001 From: Talley Lambert Date: Wed, 13 Mar 2024 11:58:20 -0400 Subject: [PATCH 1/3] move core property change callbacks --- MMCore/CoreProperty.cpp | 5 ----- MMCore/MMCore.cpp | 45 +++++++++++++++++++++++++++++++++++++++++ 2 files changed, 45 insertions(+), 5 deletions(-) diff --git a/MMCore/CoreProperty.cpp b/MMCore/CoreProperty.cpp index ce5a43f5d..473543b5f 100644 --- a/MMCore/CoreProperty.cpp +++ b/MMCore/CoreProperty.cpp @@ -166,11 +166,6 @@ void CorePropertyCollection::Execute(const char* propName, const char* value) // should never get here... assert(!"Unable to execute set property command.\n"); } - - if (core_->externalCallback_) - { - core_->externalCallback_->onPropertyChanged("Core", propName, value); - } } std::string CorePropertyCollection::Get(const char* propName) const diff --git a/MMCore/MMCore.cpp b/MMCore/MMCore.cpp index 4bef95471..3a2f31468 100644 --- a/MMCore/MMCore.cpp +++ b/MMCore/MMCore.cpp @@ -804,6 +804,9 @@ void CMMCore::unloadAllDevices() throw (CMMError) logError("MMCore::unloadAllDevices", err.getMsg().c_str()); throw; } + if (externalCallback_) { + externalCallback_->onPropertyChanged(MM::g_Keyword_CoreDevice, MM::g_Keyword_CoreInitialize, "0"); + } } /** @@ -871,6 +874,9 @@ void CMMCore::initializeAllDevices() throw (CMMError) LOG_INFO(coreLogger_) << "Finished initializing " << devices.size() << " devices"; updateCoreProperties(); + if (externalCallback_) { + externalCallback_->onPropertyChanged(MM::g_Keyword_CoreDevice, MM::g_Keyword_CoreInitialize, "1"); + } } /** @@ -2424,6 +2430,9 @@ void CMMCore::setAutoShutter(bool state) stateCache_.addSetting(PropertySetting(MM::g_Keyword_CoreDevice, MM::g_Keyword_CoreAutoShutter, state ? "1" : "0")); } LOG_DEBUG(coreLogger_) << "Autoshutter turned " << (state ? "on" : "off"); + if (externalCallback_) { + externalCallback_->onPropertyChanged(MM::g_Keyword_CoreDevice, MM::g_Keyword_CoreAutoShutter, state ? "1" : "0"); + } } /** @@ -3250,6 +3259,9 @@ void CMMCore::setAutoFocusDevice(const char* autofocusLabel) throw (CMMError) MMThreadGuard scg(stateCacheLock_); stateCache_.addSetting(PropertySetting(MM::g_Keyword_CoreDevice, MM::g_Keyword_CoreAutoFocus, newAutofocusLabel.c_str())); } + if (externalCallback_) { + externalCallback_->onPropertyChanged(MM::g_Keyword_CoreDevice, MM::g_Keyword_CoreAutoFocus, newAutofocusLabel.c_str()); + } } /** @@ -3317,6 +3329,9 @@ void CMMCore::setImageProcessorDevice(const char* procLabel) throw (CMMError) MMThreadGuard scg(stateCacheLock_); stateCache_.addSetting(PropertySetting(MM::g_Keyword_CoreDevice, MM::g_Keyword_CoreImageProcessor, newProcLabel.c_str())); } + if (externalCallback_) { + externalCallback_->onPropertyChanged(MM::g_Keyword_CoreDevice, MM::g_Keyword_CoreImageProcessor, newProcLabel.c_str()); + } } /** @@ -3341,6 +3356,9 @@ void CMMCore::setSLMDevice(const char* slmLabel) throw (CMMError) MMThreadGuard scg(stateCacheLock_); stateCache_.addSetting(PropertySetting(MM::g_Keyword_CoreDevice, MM::g_Keyword_CoreSLM, newSLMLabel.c_str())); } + if (externalCallback_) { + externalCallback_->onPropertyChanged(MM::g_Keyword_CoreDevice, MM::g_Keyword_CoreSLM, newSLMLabel.c_str()); + } } @@ -3366,6 +3384,9 @@ void CMMCore::setGalvoDevice(const char* galvoLabel) throw (CMMError) MMThreadGuard scg(stateCacheLock_); stateCache_.addSetting(PropertySetting(MM::g_Keyword_CoreDevice, MM::g_Keyword_CoreGalvo, newGalvoLabel.c_str())); } + if (externalCallback_) { + externalCallback_->onPropertyChanged(MM::g_Keyword_CoreDevice, MM::g_Keyword_CoreGalvo, newGalvoLabel.c_str()); + } } /** @@ -3396,6 +3417,7 @@ void CMMCore::setChannelGroup(const char* chGroup) throw (CMMError) if (externalCallback_ != 0) { externalCallback_->onChannelGroupChanged(channelGroup_.c_str()); + externalCallback_->onPropertyChanged(MM::g_Keyword_CoreDevice, MM::g_Keyword_CoreChannelGroup, channelGroup_.c_str()); } } @@ -3455,6 +3477,9 @@ void CMMCore::setShutterDevice(const char* shutterLabel) throw (CMMError) MMThreadGuard scg(stateCacheLock_); stateCache_.addSetting(PropertySetting(MM::g_Keyword_CoreDevice, MM::g_Keyword_CoreShutter, newShutterLabel.c_str())); } + if (externalCallback_) { + externalCallback_->onPropertyChanged(MM::g_Keyword_CoreDevice, MM::g_Keyword_CoreShutter, newShutterLabel.c_str()); + } } /** @@ -3480,6 +3505,9 @@ void CMMCore::setFocusDevice(const char* focusLabel) throw (CMMError) MMThreadGuard scg(stateCacheLock_); stateCache_.addSetting(PropertySetting(MM::g_Keyword_CoreDevice, MM::g_Keyword_CoreFocus, newFocusLabel.c_str())); } + if (externalCallback_) { + externalCallback_->onPropertyChanged(MM::g_Keyword_CoreDevice, MM::g_Keyword_CoreFocus, newFocusLabel.c_str()); + } } /** @@ -3503,6 +3531,9 @@ void CMMCore::setXYStageDevice(const char* xyDeviceLabel) throw (CMMError) MMThreadGuard scg(stateCacheLock_); stateCache_.addSetting(PropertySetting(MM::g_Keyword_CoreDevice, MM::g_Keyword_CoreXYStage, newXYStageLabel.c_str())); } + if (externalCallback_) { + externalCallback_->onPropertyChanged(MM::g_Keyword_CoreDevice, MM::g_Keyword_CoreXYStage, newXYStageLabel.c_str()); + } } /** @@ -3542,6 +3573,9 @@ void CMMCore::setCameraDevice(const char* cameraLabel) throw (CMMError) MMThreadGuard scg(stateCacheLock_); stateCache_.addSetting(PropertySetting(MM::g_Keyword_CoreDevice, MM::g_Keyword_CoreCamera, newCameraLabel.c_str())); } + if (externalCallback_) { + externalCallback_->onPropertyChanged(MM::g_Keyword_CoreDevice, MM::g_Keyword_CoreCamera, newCameraLabel.c_str()); + } } /** @@ -4225,6 +4259,17 @@ double CMMCore::getExposure(const char* label) throw (CMMError) return 0.0; } + +void CMMCore::setTimeoutMs(long timeoutMs) +{ + if (timeoutMs > 0) { + timeoutMs_ = timeoutMs; + if (externalCallback_) { + externalCallback_->onPropertyChanged(MM::g_Keyword_CoreDevice, MM::g_Keyword_CoreTimeoutMs, std::to_string(timeoutMs).c_str()); + } + } +} + /** * Set the hardware region of interest for the current camera. * From 5d324b2e403b8d50b1791485822b12b44612518d Mon Sep 17 00:00:00 2001 From: Talley Lambert Date: Wed, 13 Mar 2024 11:59:58 -0400 Subject: [PATCH 2/3] add note --- MMCore/CoreProperty.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/MMCore/CoreProperty.cpp b/MMCore/CoreProperty.cpp index 473543b5f..ae0afc3e8 100644 --- a/MMCore/CoreProperty.cpp +++ b/MMCore/CoreProperty.cpp @@ -166,6 +166,10 @@ void CorePropertyCollection::Execute(const char* propName, const char* value) // should never get here... assert(!"Unable to execute set property command.\n"); } + + // Note to developers. If you add a new propName case here, you must add a corresponding + // externalCallback_->onPropertyChanged(MM::g_Keyword_CoreDevice + // call to respective core_->setX method } std::string CorePropertyCollection::Get(const char* propName) const From 03e5087087273e0fe264544d3570d6176cba2442 Mon Sep 17 00:00:00 2001 From: Talley Lambert Date: Wed, 13 Mar 2024 12:00:51 -0400 Subject: [PATCH 3/3] update .h --- MMCore/MMCore.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/MMCore/MMCore.h b/MMCore/MMCore.h index d06d86013..d6d9d7188 100644 --- a/MMCore/MMCore.h +++ b/MMCore/MMCore.h @@ -261,7 +261,7 @@ class CMMCore void setDeviceDelayMs(const char* label, double delayMs) throw (CMMError); bool usesDeviceDelay(const char* label) throw (CMMError); - void setTimeoutMs(long timeoutMs) {if (timeoutMs > 0) timeoutMs_ = timeoutMs;} + void setTimeoutMs(long timeoutMs); long getTimeoutMs() { return timeoutMs_;} void sleep(double intervalMs) const;