Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Move onPropertyChanged("Core" calls to their respective setters #451

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 4 additions & 5 deletions MMCore/CoreProperty.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -166,11 +166,10 @@ 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);
}

// 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
Expand Down
45 changes: 45 additions & 0 deletions MMCore/MMCore.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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");
}
}

/**
Expand Down Expand Up @@ -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");
}
}

/**
Expand Down Expand Up @@ -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");
}
}

/**
Expand Down Expand Up @@ -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());
}
}

/**
Expand Down Expand Up @@ -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());
}
}

/**
Expand All @@ -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());
}
}


Expand All @@ -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());
}
}

/**
Expand Down Expand Up @@ -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());
}
}

Expand Down Expand Up @@ -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());
}
}

/**
Expand All @@ -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());
}
}

/**
Expand All @@ -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());
}
}

/**
Expand Down Expand Up @@ -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());
}
}

/**
Expand Down Expand Up @@ -4225,6 +4259,17 @@ double CMMCore::getExposure(const char* label) throw (CMMError)
return 0.0;
}


void CMMCore::setTimeoutMs(long timeoutMs)
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👀 @marktsuchida did i move this out of MMCore.h correctly?

{
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.
*
Expand Down
2 changes: 1 addition & 1 deletion MMCore/MMCore.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down