@@ -104,7 +104,7 @@ using namespace std;
104104 * of the public API of the Core), not just CMMCore.
105105 */
106106const int MMCore_versionMajor = 7 ;
107- const int MMCore_versionMinor = 1 ;
107+ const int MMCore_versionMinor = 2 ;
108108const 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 */
15621565void 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 */
15811619void 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/* *
0 commit comments