Skip to content

Commit ae4ced4

Browse files
author
mark
committed
Add home and stop functions for Z/focus stages
MMDevice and MMCore versions incremented. NewportCONEX adapter code updated to avoid name clash. git-svn-id: https://valelab.ucsf.edu/svn/micromanager2/trunk@15408 d0ab736e-dc22-4aeb-8dc9-08def0aa14fd
1 parent bc69f5d commit ae4ced4

10 files changed

Lines changed: 147 additions & 34 deletions

File tree

DeviceAdapters/NewportCONEX/Conex_Axis.cpp

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -370,7 +370,7 @@ int Conex_AxisBase::Stop()
370370
return ret;
371371
}
372372

373-
int Conex_AxisBase::Home()
373+
int Conex_AxisBase::BaseHome()
374374
{
375375
int ret;
376376

@@ -434,7 +434,7 @@ void Conex_AxisBase::test()
434434
{
435435
if ( !Referenced() )
436436
{
437-
Home();
437+
BaseHome();
438438
while (Moving()) ;
439439
}
440440
if ( !Enabled()) Enable();
@@ -560,7 +560,7 @@ int X_Axis::GetPositionSteps(long&)
560560
}
561561
int X_Axis::SetOrigin()
562562
{
563-
return Home();
563+
return BaseHome();
564564
}
565565

566566

@@ -618,7 +618,7 @@ int X_Axis::OnSearchHomeNow(MM::PropertyBase* pProp, MM::ActionType eAct)
618618
pProp->Get(value);
619619
if (value == g_SearchForHomeNowValue)
620620
{
621-
return Home();
621+
return BaseHome();
622622
}
623623
}
624624
return DEVICE_OK;
@@ -728,7 +728,7 @@ int Y_Axis::GetPositionSteps(long&)
728728
}
729729
int Y_Axis::SetOrigin()
730730
{
731-
return Home();
731+
return BaseHome();
732732
}
733733

734734

@@ -786,7 +786,7 @@ int Y_Axis::OnSearchHomeNow(MM::PropertyBase* pProp, MM::ActionType eAct)
786786
pProp->Get(value);
787787
if (value == g_SearchForHomeNowValue)
788788
{
789-
return Home();
789+
return BaseHome();
790790
}
791791
}
792792
return DEVICE_OK;
@@ -895,7 +895,7 @@ int Z_Axis::GetPositionSteps(long&)
895895
}
896896
int Z_Axis::SetOrigin()
897897
{
898-
return Home();
898+
return BaseHome();
899899
}
900900

901901

@@ -953,7 +953,7 @@ int Z_Axis::OnSearchHomeNow(MM::PropertyBase* pProp, MM::ActionType eAct)
953953
pProp->Get(value);
954954
if (value == g_SearchForHomeNowValue)
955955
{
956-
return Home();
956+
return BaseHome();
957957
}
958958
}
959959
return DEVICE_OK;

DeviceAdapters/NewportCONEX/Conex_Axis.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ class Conex_AxisBase
7070
bool Ready();
7171
bool Enabled();
7272
int Stop();
73-
int Home();
73+
int BaseHome();
7474
int HomeCurrentPosition();
7575
int MoveRelative(double position);
7676
int MoveAbsolute( double target);

DeviceAdapters/SequenceTester/SequenceTester.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -275,6 +275,8 @@ class Tester1DStageBase : public TesterBase<CStageBase, TConcreteStage>
275275
virtual int GetPositionUm(double& pos);
276276
virtual int SetPositionSteps(long steps);
277277
virtual int GetPositionSteps(long& steps);
278+
virtual int Home();
279+
virtual int Stop();
278280
virtual int SetOrigin();
279281
virtual int GetLimits(double& lower, double& upper);
280282
virtual int IsStageSequenceable(bool& isSequenceable) const
@@ -288,6 +290,8 @@ class Tester1DStageBase : public TesterBase<CStageBase, TConcreteStage>
288290

289291
private:
290292
FloatSetting::Ptr zPositionUm_;
293+
OneShotSetting::Ptr home_;
294+
OneShotSetting::Ptr stop_;
291295
OneShotSetting::Ptr originSet_;
292296
};
293297

DeviceAdapters/SequenceTester/SequenceTesterImpl.h

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -206,6 +206,10 @@ Tester1DStageBase<TConcreteStage, UStepsPerMicrometer>::Initialize()
206206
zPositionUm_ = FloatSetting::New(Super::GetLogger(), This(),
207207
"ZPositionUm", 0.0, false);
208208
zPositionUm_->SetBusySetting(Super::GetBusySetting());
209+
home_ = OneShotSetting::New(Super::GetLogger(), This(), "Home");
210+
home_->SetBusySetting(Super::GetBusySetting());
211+
stop_ = OneShotSetting::New(Super::GetLogger(), This(), "Stop");
212+
stop_->SetBusySetting(Super::GetBusySetting());
209213
originSet_ = OneShotSetting::New(Super::GetLogger(), This(), "OriginSet");
210214
originSet_->SetBusySetting(Super::GetBusySetting());
211215

@@ -256,6 +260,26 @@ Tester1DStageBase<TConcreteStage, UStepsPerMicrometer>::GetPositionSteps(long& s
256260
}
257261

258262

263+
template <class TConcreteStage, long UStepsPerMicrometer>
264+
int
265+
Tester1DStageBase<TConcreteStage, UStepsPerMicrometer>::Home()
266+
{
267+
TesterHub::Guard g(Super::GetHub()->LockGlobalMutex());
268+
home_->MarkBusy();
269+
return home_->Set();
270+
}
271+
272+
273+
template <class TConcreteStage, long UStepsPerMicrometer>
274+
int
275+
Tester1DStageBase<TConcreteStage, UStepsPerMicrometer>::Stop()
276+
{
277+
TesterHub::Guard g(Super::GetHub()->LockGlobalMutex());
278+
stop_->MarkBusy();
279+
return stop_->Set();
280+
}
281+
282+
259283
template <class TConcreteStage, long UStepsPerMicrometer>
260284
int
261285
Tester1DStageBase<TConcreteStage, UStepsPerMicrometer>::SetOrigin()

MMCore/Devices/StageInstance.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,8 @@
2525
int StageInstance::SetPositionUm(double pos) { return GetImpl()->SetPositionUm(pos); }
2626
int StageInstance::SetRelativePositionUm(double d) { return GetImpl()->SetRelativePositionUm(d); }
2727
int StageInstance::Move(double velocity) { return GetImpl()->Move(velocity); }
28+
int StageInstance::Stop() { return GetImpl()->Stop(); }
29+
int StageInstance::Home() { return GetImpl()->Home(); }
2830
int StageInstance::SetAdapterOriginUm(double d) { return GetImpl()->SetAdapterOriginUm(d); }
2931
int StageInstance::GetPositionUm(double& pos) { return GetImpl()->GetPositionUm(pos); }
3032
int StageInstance::SetPositionSteps(long steps) { return GetImpl()->SetPositionSteps(steps); }

MMCore/Devices/StageInstance.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,8 @@ class StageInstance : public DeviceInstanceBase<MM::Stage>
3939
int SetPositionUm(double pos);
4040
int SetRelativePositionUm(double d);
4141
int Move(double velocity);
42+
int Stop();
43+
int Home();
4244
int SetAdapterOriginUm(double d);
4345
int GetPositionUm(double& pos);
4446
int SetPositionSteps(long steps);

MMCore/MMCore.cpp

Lines changed: 87 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ using namespace std;
104104
* of the public API of the Core), not just CMMCore.
105105
*/
106106
const int MMCore_versionMajor = 7;
107-
const int MMCore_versionMinor = 1;
107+
const int MMCore_versionMinor = 2;
108108
const int MMCore_versionPatch = 0;
109109

110110

@@ -1556,44 +1556,109 @@ double CMMCore::getYPosition() throw (CMMError)
15561556
}
15571557

15581558
/**
1559-
* stop the XY stage motors
1560-
* @param label the stage device label
1559+
* Stop the XY or focus/Z stage motors
1560+
*
1561+
* Not all stages support this operation; check before use.
1562+
*
1563+
* @param label the stage device label (either XY or focus/Z stage)
15611564
*/
15621565
void CMMCore::stop(const char* label) throw (CMMError)
15631566
{
1564-
boost::shared_ptr<XYStageInstance> pXYStage =
1565-
deviceManager_->GetDeviceOfType<XYStageInstance>(label);
1567+
boost::shared_ptr<DeviceInstance> stage =
1568+
deviceManager_->GetDevice(label);
15661569

1567-
mm::DeviceModuleLockGuard guard(pXYStage);
1568-
int ret = pXYStage->Stop();
1569-
if (ret != DEVICE_OK)
1570+
boost::shared_ptr<StageInstance> zStage =
1571+
boost::dynamic_pointer_cast<StageInstance>(stage);
1572+
if (zStage)
15701573
{
1571-
logError(label, getDeviceErrorText(ret, pXYStage).c_str());
1572-
throw CMMError(getDeviceErrorText(ret, pXYStage).c_str(), MMERR_DEVICE_GENERIC);
1574+
LOG_DEBUG(coreLogger_) << "Will stop stage " << label;
1575+
1576+
mm::DeviceModuleLockGuard guard(zStage);
1577+
int ret = zStage->Stop();
1578+
if (ret != DEVICE_OK)
1579+
{
1580+
logError(label, getDeviceErrorText(ret, zStage).c_str());
1581+
throw CMMError(getDeviceErrorText(ret, zStage));
1582+
}
1583+
1584+
LOG_DEBUG(coreLogger_) << "Did stop stage " << label;
1585+
return;
1586+
}
1587+
1588+
boost::shared_ptr<XYStageInstance> xyStage =
1589+
boost::dynamic_pointer_cast<XYStageInstance>(stage);
1590+
if (xyStage)
1591+
{
1592+
LOG_DEBUG(coreLogger_) << "Will stop xy stage " << label;
1593+
1594+
mm::DeviceModuleLockGuard guard(xyStage);
1595+
int ret = xyStage->Stop();
1596+
if (ret != DEVICE_OK)
1597+
{
1598+
logError(label, getDeviceErrorText(ret, xyStage).c_str());
1599+
throw CMMError(getDeviceErrorText(ret, xyStage));
1600+
}
1601+
1602+
LOG_DEBUG(coreLogger_) << "Did stop xy stage " << label;
1603+
return;
15731604
}
1574-
LOG_DEBUG(coreLogger_) << "Stopped xy stage " << label;
1605+
1606+
throw CMMError("Cannot stop " + ToQuotedString(label) +
1607+
": not a stage");
15751608
}
15761609

15771610
/**
1578-
* Calibrates and homes the XY stage.
1579-
* @param label the stage device label
1611+
* Perform a hardware homing operation for an XY or focus/Z stage.
1612+
*
1613+
* Not all stages support this operation. The user should be warned before
1614+
* calling this method, as it can cause large stage movements, potentially
1615+
* resulting in collision (e.g. with an expensive objective lens).
1616+
*
1617+
* @param label the stage device label (either XY or focus/Z stage)
15801618
*/
15811619
void CMMCore::home(const char* label) throw (CMMError)
15821620
{
1583-
boost::shared_ptr<XYStageInstance> pXYStage =
1584-
deviceManager_->GetDeviceOfType<XYStageInstance>(label);
1621+
boost::shared_ptr<DeviceInstance> stage =
1622+
deviceManager_->GetDevice(label);
15851623

1586-
LOG_DEBUG(coreLogger_) << "Will home xy stage " << label;
1624+
boost::shared_ptr<StageInstance> zStage =
1625+
boost::dynamic_pointer_cast<StageInstance>(stage);
1626+
if (zStage)
1627+
{
1628+
LOG_DEBUG(coreLogger_) << "Will home stage " << label;
15871629

1588-
mm::DeviceModuleLockGuard guard(pXYStage);
1589-
int ret = pXYStage->Home();
1590-
if (ret != DEVICE_OK)
1630+
mm::DeviceModuleLockGuard guard(zStage);
1631+
int ret = zStage->Home();
1632+
if (ret != DEVICE_OK)
1633+
{
1634+
logError(label, getDeviceErrorText(ret, zStage).c_str());
1635+
throw CMMError(getDeviceErrorText(ret, zStage));
1636+
}
1637+
1638+
LOG_DEBUG(coreLogger_) << "Did home stage " << label;
1639+
return;
1640+
}
1641+
1642+
boost::shared_ptr<XYStageInstance> xyStage =
1643+
boost::dynamic_pointer_cast<XYStageInstance>(stage);
1644+
if (xyStage)
15911645
{
1592-
logError(label, getDeviceErrorText(ret, pXYStage).c_str());
1593-
throw CMMError(getDeviceErrorText(ret, pXYStage).c_str(), MMERR_DEVICE_GENERIC);
1646+
LOG_DEBUG(coreLogger_) << "Will home xy stage " << label;
1647+
1648+
mm::DeviceModuleLockGuard guard(xyStage);
1649+
int ret = xyStage->Home();
1650+
if (ret != DEVICE_OK)
1651+
{
1652+
logError(label, getDeviceErrorText(ret, xyStage).c_str());
1653+
throw CMMError(getDeviceErrorText(ret, xyStage));
1654+
}
1655+
1656+
LOG_DEBUG(coreLogger_) << "Did home xy stage " << label;
1657+
return;
15941658
}
15951659

1596-
LOG_DEBUG(coreLogger_) << "Did home xy stage " << label;
1660+
throw CMMError("Cannot home " + ToQuotedString(label) +
1661+
": not a stage");
15971662
}
15981663

15991664
/**

MMCore/MMCore.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -490,8 +490,8 @@ class CMMCore
490490
double getYPosition(const char* xyStageLabel) throw (CMMError);
491491
double getXPosition() throw (CMMError);
492492
double getYPosition() throw (CMMError);
493-
void stop(const char* xyStageLabel) throw (CMMError);
494-
void home(const char* xyStageLabel) throw (CMMError);
493+
void stop(const char* xyOrZStageLabel) throw (CMMError);
494+
void home(const char* xyOrZStageLabel) throw (CMMError);
495495
void setOriginXY(const char* xyStageLabel) throw (CMMError);
496496
void setOriginXY() throw (CMMError);
497497
void setOriginX(const char* xyStageLabel) throw (CMMError);

MMDevice/DeviceBase.h

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1708,6 +1708,19 @@ class CStageBase : public CDeviceBase<MM::Stage, U>
17081708
return DEVICE_UNSUPPORTED_COMMAND;
17091709
}
17101710

1711+
virtual int Stop()
1712+
{
1713+
// Historycally, Move() has been in this interface longer than Stop(), so
1714+
// there is a chance that a stage implements Move() but not Stop(). In
1715+
// which case zero velocity is the best thing to do.
1716+
return Move(0.0);
1717+
}
1718+
1719+
virtual int Home()
1720+
{
1721+
return DEVICE_UNSUPPORTED_COMMAND;
1722+
}
1723+
17111724
virtual int GetStageSequenceMaxLength(long& /*nrEvents*/) const
17121725
{
17131726
return DEVICE_UNSUPPORTED_COMMAND;

MMDevice/MMDevice.h

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727
// Header version
2828
// If any of the class definitions changes, the interface version
2929
// must be incremented
30-
#define DEVICE_INTERFACE_VERSION 62
30+
#define DEVICE_INTERFACE_VERSION 63
3131
///////////////////////////////////////////////////////////////////////////////
3232

3333

@@ -608,12 +608,15 @@ namespace MM {
608608
virtual int SetPositionUm(double pos) = 0;
609609
virtual int SetRelativePositionUm(double d) = 0;
610610
virtual int Move(double velocity) = 0;
611+
virtual int Stop() = 0;
612+
virtual int Home() = 0;
611613
virtual int SetAdapterOriginUm(double d) = 0;
612614
virtual int GetPositionUm(double& pos) = 0;
613615
virtual int SetPositionSteps(long steps) = 0;
614616
virtual int GetPositionSteps(long& steps) = 0;
615617
virtual int SetOrigin() = 0;
616618
virtual int GetLimits(double& lower, double& upper) = 0;
619+
617620
/*
618621
* Returns whether a stage can be sequenced (synchronized by TTLs)
619622
* If returning true, then a Stage class should also inherit

0 commit comments

Comments
 (0)