Skip to content

Commit

Permalink
Merge pull request #386 from martinzak-zaber/zaber/fix-objective-changer
Browse files Browse the repository at this point in the history
Fixing objective changer.
  • Loading branch information
marktsuchida authored Oct 3, 2023
2 parents 020923b + dda1289 commit 87d7b03
Showing 1 changed file with 13 additions and 10 deletions.
23 changes: 13 additions & 10 deletions DeviceAdapters/Zaber/ObjectiveChanger.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -188,8 +188,8 @@ int ObjectiveChanger::GetPositionLabel(long pos, char* label) const
{
if (DEVICE_OK != CStateDeviceBase<ObjectiveChanger>::GetPositionLabel(pos, label))
{
std::stringstream labelStr("Objective ");
labelStr << pos + 1;
std::stringstream labelStr;
labelStr << "Objective " << pos + 1;
CDeviceUtils::CopyLimitedString(label, labelStr.str().c_str());
}

Expand Down Expand Up @@ -312,17 +312,15 @@ int ObjectiveChanger::PositionGetSet(MM::PropertyBase* pProp, MM::ActionType eAc
long indexToSet;
pProp->Get(indexToSet);

if (initialized_)
if (initialized_ && (indexToSet + 1) != currentObjective_)
{
if ((indexToSet >= 0) && (indexToSet < numPositions_))
{
return setObjective(indexToSet + 1, false);
}
else
if (indexToSet < 0 || indexToSet >= numPositions_)
{
this->LogMessage("Requested position is outside the legal range.\n", true);
return DEVICE_UNKNOWN_POSITION;
}

return setObjective(indexToSet + 1, false);
}
}

Expand All @@ -335,12 +333,17 @@ int ObjectiveChanger::FocusOffsetGetSet(MM::PropertyBase* pProp, MM::ActionType

if (eAct == MM::AfterSet)
{
pProp->Get(focusOffset_);
double newOffset;
pProp->Get(newOffset);
auto update = focusOffset_ != newOffset;
focusOffset_ = newOffset;
if (update) {
return setObjective(currentObjective_, true);
}
}
else if (eAct == MM::BeforeGet)
{
pProp->Set(focusOffset_);
return setObjective(currentObjective_, true);
}

return DEVICE_OK;
Expand Down

0 comments on commit 87d7b03

Please sign in to comment.