Skip to content
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
69 changes: 69 additions & 0 deletions MMCore/MMCore.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1523,6 +1523,15 @@ void CMMCore::setPosition(const char* label, double position) MMCORE_LEGACY_THRO
logError(pStage->GetName().c_str(), getDeviceErrorText(ret, pStage).c_str());
throw CMMError(getDeviceErrorText(ret, pStage).c_str(), MMERR_DEVICE_GENERIC);
}

// Update the lastSetPosition in the state cache
{
MMThreadGuard scg(stateCacheLock_);
stateCache_.addSetting(PropertySetting(label,
MM::g_Keyword_LastSetPosition,
CDeviceUtils::ConvertToString(position)));
}

}
/**
* Sets the position of the stage in microns. Uses the current Z positioner
Expand Down Expand Up @@ -1555,6 +1564,14 @@ void CMMCore::setRelativePosition(const char* label, double d) MMCORE_LEGACY_THR
logError(pStage->GetName().c_str(), getDeviceErrorText(ret, pStage).c_str());
throw CMMError(getDeviceErrorText(ret, pStage).c_str(), MMERR_DEVICE_GENERIC);
}

// clear lastSetPosition in the state cache, since it's guaranteed to be invalid now
// We could conceivably update it here, but that's more complex and error-prone
{
MMThreadGuard scg(stateCacheLock_);
if (stateCache_.isPropertyIncluded(label, MM::g_Keyword_LastSetPosition))
stateCache_.deleteSetting(label, MM::g_Keyword_LastSetPosition);
}
}

/**
Expand Down Expand Up @@ -1620,6 +1637,17 @@ void CMMCore::setXYPosition(const char* label, double x, double y) MMCORE_LEGACY
logError(pXYStage->GetName().c_str(), getDeviceErrorText(ret, pXYStage).c_str());
throw CMMError(getDeviceErrorText(ret, pXYStage).c_str(), MMERR_DEVICE_GENERIC);
}

// Update the lastSetPositionX/Y in the state cache
{
MMThreadGuard scg(stateCacheLock_);
stateCache_.addSetting(PropertySetting(label,
MM::g_Keyword_LastSetPositionX,
CDeviceUtils::ConvertToString(x)));
stateCache_.addSetting(PropertySetting(label,
MM::g_Keyword_LastSetPositionY,
CDeviceUtils::ConvertToString(y)));
}
}

/**
Expand Down Expand Up @@ -1655,6 +1683,16 @@ void CMMCore::setRelativeXYPosition(const char* label, double dx, double dy) MMC
logError(pXYStage->GetName().c_str(), getDeviceErrorText(ret, pXYStage).c_str());
throw CMMError(getDeviceErrorText(ret, pXYStage).c_str(), MMERR_DEVICE_GENERIC);
}

// clear lastSetPositionX/Y in the state cache, since it's guaranteed to be invalid now
// We could conceivably update it here, but that's more complex and error-prone
{
MMThreadGuard scg(stateCacheLock_);
if (stateCache_.isPropertyIncluded(label, MM::g_Keyword_LastSetPositionX))
stateCache_.deleteSetting(label, MM::g_Keyword_LastSetPositionX);
if (stateCache_.isPropertyIncluded(label, MM::g_Keyword_LastSetPositionY))
stateCache_.deleteSetting(label, MM::g_Keyword_LastSetPositionY);
}
}

/**
Expand Down Expand Up @@ -1890,6 +1928,16 @@ void CMMCore::setOriginXY(const char* label) MMCORE_LEGACY_THROW(CMMError)
}

LOG_DEBUG(coreLogger_) << "Zeroed xy stage " << label << " at current position";

{
MMThreadGuard scg(stateCacheLock_);
stateCache_.addSetting(PropertySetting(label,
MM::g_Keyword_LastSetPositionX,
"0"));
stateCache_.addSetting(PropertySetting(label,
MM::g_Keyword_LastSetPositionY,
"0"));
}
}

/**
Expand Down Expand Up @@ -1925,6 +1973,13 @@ void CMMCore::setOriginX(const char* label) MMCORE_LEGACY_THROW(CMMError)

LOG_DEBUG(coreLogger_) << "Zeroed x coordinate of xy stage " << label <<
" at current position";

{
MMThreadGuard scg(stateCacheLock_);
stateCache_.addSetting(PropertySetting(label,
MM::g_Keyword_LastSetPositionX,
"0"));
}
}

/**
Expand Down Expand Up @@ -1959,6 +2014,13 @@ void CMMCore::setOriginY(const char* label) MMCORE_LEGACY_THROW(CMMError)

LOG_DEBUG(coreLogger_) << "Zeroed y coordinate of xy stage " << label <<
" at current position";

{
MMThreadGuard scg(stateCacheLock_);
stateCache_.addSetting(PropertySetting(label,
MM::g_Keyword_LastSetPositionY,
"0"));
}
}

/**
Expand Down Expand Up @@ -1993,6 +2055,13 @@ void CMMCore::setOrigin(const char* label) MMCORE_LEGACY_THROW(CMMError)
}

LOG_DEBUG(coreLogger_) << "Zeroed stage " << label << " at current position";

{
MMThreadGuard scg(stateCacheLock_);
stateCache_.addSetting(PropertySetting(label,
MM::g_Keyword_LastSetPosition,
"0"));
}
}

/**
Expand Down
3 changes: 3 additions & 0 deletions MMDevice/MMDeviceConstants.h
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,9 @@ namespace MM {
const char* const g_Keyword_State = "State";
const char* const g_Keyword_Label = "Label";
const char* const g_Keyword_Position = "Position";
const char* const g_Keyword_LastSetPosition = "LastSetPosition";
const char* const g_Keyword_LastSetPositionX = "LastSetPositionX";
const char* const g_Keyword_LastSetPositionY = "LastSetPositionY";
const char* const g_Keyword_Type = "Type";
const char* const g_Keyword_Delay = "Delay_ms";
const char* const g_Keyword_BaudRate = "BaudRate";
Expand Down