Changeset View
Changeset View
Standalone View
Standalone View
kstars/ekos/focus/focus.cpp
Show First 20 Lines • Show All 685 Lines • ▼ Show 20 Line(s) | 575 | { | |||
---|---|---|---|---|---|
686 | // Used for all the focuser types. | 686 | // Used for all the focuser types. | ||
687 | if (focusAlgorithm == FOCUS_LINEAR) | 687 | if (focusAlgorithm == FOCUS_LINEAR) | ||
688 | { | 688 | { | ||
689 | const int position = static_cast<int>(currentPosition); | 689 | const int position = static_cast<int>(currentPosition); | ||
690 | FocusAlgorithmInterface::FocusParams params( | 690 | FocusAlgorithmInterface::FocusParams params( | ||
691 | maxTravelIN->value(), stepIN->value(), position, absMotionMin, absMotionMax, | 691 | maxTravelIN->value(), stepIN->value(), position, absMotionMin, absMotionMax, | ||
692 | MAXIMUM_ABS_ITERATIONS, toleranceIN->value() / 100.0, filter()); | 692 | MAXIMUM_ABS_ITERATIONS, toleranceIN->value() / 100.0, filter()); | ||
693 | linearFocuser.reset(MakeLinearFocuser(params)); | 693 | linearFocuser.reset(MakeLinearFocuser(params)); | ||
694 | const int newPosition = adjustLinearPosition(position, linearFocuser->initialPosition()); | 694 | linearRequestedPosition = linearFocuser->initialPosition(); | ||
695 | const int newPosition = adjustLinearPosition(position, linearRequestedPosition); | ||||
695 | if (newPosition != position) | 696 | if (newPosition != position) | ||
696 | { | 697 | { | ||
697 | if (!changeFocus(newPosition - position)) | 698 | if (!changeFocus(newPosition - position)) | ||
698 | { | 699 | { | ||
699 | abort(); | 700 | abort(); | ||
700 | setAutoFocusResult(false); | 701 | setAutoFocusResult(false); | ||
701 | } | 702 | } | ||
702 | // Avoid the capture below. | 703 | // Avoid the capture below. | ||
▲ Show 20 Lines • Show All 1013 Lines • ▼ Show 20 Line(s) | 1683 | { | |||
1716 | return true; | 1717 | return true; | ||
1717 | } | 1718 | } | ||
1718 | 1719 | | |||
1719 | void Focus::autoFocusLinear() | 1720 | void Focus::autoFocusLinear() | ||
1720 | { | 1721 | { | ||
1721 | if (!autoFocusChecks()) | 1722 | if (!autoFocusChecks()) | ||
1722 | return; | 1723 | return; | ||
1723 | 1724 | | |||
1725 | if (!canAbsMove && !canRelMove && canTimerMove) | ||||
1726 | { | ||||
1727 | const bool kFixPosition = true; | ||||
1728 | if (kFixPosition && (linearRequestedPosition != static_cast<int>(currentPosition))) | ||||
1729 | { | ||||
1730 | qCDebug(KSTARS_EKOS_FOCUS) << "Linear: warning, changing position " << currentPosition << " to " | ||||
1731 | << linearRequestedPosition; | ||||
1732 | | ||||
1733 | currentPosition = linearRequestedPosition; | ||||
1734 | } | ||||
1735 | } | ||||
1736 | | ||||
1724 | hfr_position.append(currentPosition); | 1737 | hfr_position.append(currentPosition); | ||
1725 | hfr_value.append(currentHFR); | 1738 | hfr_value.append(currentHFR); | ||
1726 | 1739 | | |||
1727 | drawHFRPlot(); | 1740 | drawHFRPlot(); | ||
1728 | 1741 | | |||
1729 | if (hfr_position.size() > 3) | 1742 | if (hfr_position.size() > 3) | ||
1730 | { | 1743 | { | ||
1731 | polynomialFit.reset(new PolynomialFit(2, hfr_position, hfr_value)); | 1744 | polynomialFit.reset(new PolynomialFit(2, hfr_position, hfr_value)); | ||
Show All 23 Lines | 1761 | { | |||
1755 | polynomialGraph->setPen(pen); | 1768 | polynomialGraph->setPen(pen); | ||
1756 | polynomialFit->drawPolynomial(HFRPlot, polynomialGraph); | 1769 | polynomialFit->drawPolynomial(HFRPlot, polynomialGraph); | ||
1757 | 1770 | | |||
1758 | polynomialGraph->data()->clear(); | 1771 | polynomialGraph->data()->clear(); | ||
1759 | focusPoint->data()->clear(); | 1772 | focusPoint->data()->clear(); | ||
1760 | } | 1773 | } | ||
1761 | } | 1774 | } | ||
1762 | 1775 | | |||
1763 | const int nextPosition = adjustLinearPosition( | 1776 | linearRequestedPosition = linearFocuser->newMeasurement(currentPosition, currentHFR); | ||
1764 | static_cast<int>(currentPosition), | 1777 | const int nextPosition = adjustLinearPosition(static_cast<int>(currentPosition), linearRequestedPosition); | ||
1765 | linearFocuser->newMeasurement(currentPosition, currentHFR)); | 1778 | if (linearRequestedPosition == -1) | ||
1766 | if (nextPosition == -1) | | |||
1767 | { | 1779 | { | ||
1768 | if (linearFocuser->isDone() && linearFocuser->solution() != -1) | 1780 | if (linearFocuser->isDone() && linearFocuser->solution() != -1) | ||
1769 | { | 1781 | { | ||
1770 | appendLogText(i18np("Autofocus complete after %1 iteration.", | 1782 | appendLogText(i18np("Autofocus complete after %1 iteration.", | ||
1771 | "Autofocus complete after %1 iterations.", hfr_position.count())); | 1783 | "Autofocus complete after %1 iterations.", hfr_position.count())); | ||
1772 | stop(); | 1784 | stop(); | ||
1773 | setAutoFocusResult(true); | 1785 | setAutoFocusResult(true); | ||
1774 | } | 1786 | } | ||
▲ Show 20 Lines • Show All 495 Lines • ▼ Show 20 Line(s) | 2281 | { | |||
2270 | appendLogText(i18n("Focuser error, check INDI panel.")); | 2282 | appendLogText(i18n("Focuser error, check INDI panel.")); | ||
2271 | abort(); | 2283 | abort(); | ||
2272 | setAutoFocusResult(false); | 2284 | setAutoFocusResult(false); | ||
2273 | } | 2285 | } | ||
2274 | } | 2286 | } | ||
2275 | 2287 | | |||
2276 | void Focus::processFocusNumber(INumberVectorProperty *nvp) | 2288 | void Focus::processFocusNumber(INumberVectorProperty *nvp) | ||
2277 | { | 2289 | { | ||
2290 | qCDebug(KSTARS_EKOS_FOCUS) << QString("processFocusNumber %1 %2") | ||||
2291 | .arg(nvp->name).arg(nvp->s == IPS_OK ? "OK" : "ERROR"); | ||||
2292 | | ||||
2278 | // Return if it is not our current focuser | 2293 | // Return if it is not our current focuser | ||
2279 | if (strcmp(nvp->device, currentFocuser->getDeviceName())) | 2294 | if (strcmp(nvp->device, currentFocuser->getDeviceName())) | ||
2280 | return; | 2295 | return; | ||
2281 | 2296 | | |||
2282 | if (!strcmp(nvp->name, "FOCUS_BACKLASH_STEPS")) | 2297 | if (!strcmp(nvp->name, "FOCUS_BACKLASH_STEPS")) | ||
2283 | { | 2298 | { | ||
2284 | focusBacklashSpin->setValue(nvp->np[0].value); | 2299 | focusBacklashSpin->setValue(nvp->np[0].value); | ||
2285 | return; | 2300 | return; | ||
2286 | } | 2301 | } | ||
2287 | 2302 | | |||
2288 | if (!strcmp(nvp->name, "ABS_FOCUS_POSITION")) | 2303 | if (!strcmp(nvp->name, "ABS_FOCUS_POSITION")) | ||
2289 | { | 2304 | { | ||
2290 | INumber *pos = IUFindNumber(nvp, "FOCUS_ABSOLUTE_POSITION"); | 2305 | INumber *pos = IUFindNumber(nvp, "FOCUS_ABSOLUTE_POSITION"); | ||
2291 | if (pos) | 2306 | if (pos) | ||
2292 | { | 2307 | { | ||
2293 | currentPosition = pos->value; | 2308 | currentPosition = pos->value; | ||
2309 | qCDebug(KSTARS_EKOS_FOCUS) << QString("Abs Focuser position changed to %1").arg(currentPosition); | ||||
2294 | absTicksLabel->setText(QString::number(static_cast<int>(currentPosition))); | 2310 | absTicksLabel->setText(QString::number(static_cast<int>(currentPosition))); | ||
2295 | emit absolutePositionChanged(currentPosition); | 2311 | emit absolutePositionChanged(currentPosition); | ||
2296 | } | 2312 | } | ||
2297 | 2313 | | |||
2298 | if (adjustFocus && nvp->s == IPS_OK) | 2314 | if (adjustFocus && nvp->s == IPS_OK) | ||
2299 | { | 2315 | { | ||
2300 | adjustFocus = false; | 2316 | adjustFocus = false; | ||
2301 | lastFocusDirection = FOCUS_NONE; | 2317 | lastFocusDirection = FOCUS_NONE; | ||
▲ Show 20 Lines • Show All 56 Lines • ▼ Show 20 Line(s) | |||||
2358 | } | 2374 | } | ||
2359 | 2375 | | |||
2360 | if (!strcmp(nvp->name, "REL_FOCUS_POSITION")) | 2376 | if (!strcmp(nvp->name, "REL_FOCUS_POSITION")) | ||
2361 | { | 2377 | { | ||
2362 | INumber *pos = IUFindNumber(nvp, "FOCUS_RELATIVE_POSITION"); | 2378 | INumber *pos = IUFindNumber(nvp, "FOCUS_RELATIVE_POSITION"); | ||
2363 | if (pos && nvp->s == IPS_OK) | 2379 | if (pos && nvp->s == IPS_OK) | ||
2364 | { | 2380 | { | ||
2365 | currentPosition += pos->value * (lastFocusDirection == FOCUS_IN ? -1 : 1); | 2381 | currentPosition += pos->value * (lastFocusDirection == FOCUS_IN ? -1 : 1); | ||
2382 | qCDebug(KSTARS_EKOS_FOCUS) | ||||
2383 | << QString("Rel Focuser position changed by %1 to %2") | ||||
2384 | .arg(pos->value).arg(currentPosition); | ||||
2366 | absTicksLabel->setText(QString::number(static_cast<int>(currentPosition))); | 2385 | absTicksLabel->setText(QString::number(static_cast<int>(currentPosition))); | ||
2367 | emit absolutePositionChanged(currentPosition); | 2386 | emit absolutePositionChanged(currentPosition); | ||
2368 | } | 2387 | } | ||
2369 | 2388 | | |||
2370 | if (adjustFocus && nvp->s == IPS_OK) | 2389 | if (adjustFocus && nvp->s == IPS_OK) | ||
2371 | { | 2390 | { | ||
2372 | adjustFocus = false; | 2391 | adjustFocus = false; | ||
2373 | lastFocusDirection = FOCUS_NONE; | 2392 | lastFocusDirection = FOCUS_NONE; | ||
Show All 30 Lines | 2420 | { | |||
2404 | start(); | 2423 | start(); | ||
2405 | } | 2424 | } | ||
2406 | 2425 | | |||
2407 | if (canAbsMove == false && canRelMove == false && inAutoFocus) | 2426 | if (canAbsMove == false && canRelMove == false && inAutoFocus) | ||
2408 | { | 2427 | { | ||
2409 | // Used by the linear focus algorithm. Ignored if that's not in use for the timer-focuser. | 2428 | // Used by the linear focus algorithm. Ignored if that's not in use for the timer-focuser. | ||
2410 | INumber *pos = IUFindNumber(nvp, "FOCUS_TIMER_VALUE"); | 2429 | INumber *pos = IUFindNumber(nvp, "FOCUS_TIMER_VALUE"); | ||
2411 | if (pos) | 2430 | if (pos) | ||
2431 | { | ||||
2412 | currentPosition += pos->value * (lastFocusDirection == FOCUS_IN ? -1 : 1); | 2432 | currentPosition += pos->value * (lastFocusDirection == FOCUS_IN ? -1 : 1); | ||
2433 | qCDebug(KSTARS_EKOS_FOCUS) | ||||
2434 | << QString("Timer Focuser position changed by %1 to %2") | ||||
2435 | .arg(pos->value).arg(currentPosition); | ||||
2436 | } | ||||
2413 | autoFocusProcessPositionChange(nvp->s); | 2437 | autoFocusProcessPositionChange(nvp->s); | ||
2414 | } | 2438 | } | ||
2415 | else if (nvp->s == IPS_ALERT) | 2439 | else if (nvp->s == IPS_ALERT) | ||
2416 | appendLogText(i18n("Focuser error, check INDI panel.")); | 2440 | appendLogText(i18n("Focuser error, check INDI panel.")); | ||
2417 | 2441 | | |||
2418 | return; | 2442 | return; | ||
2419 | } | 2443 | } | ||
2420 | } | 2444 | } | ||
▲ Show 20 Lines • Show All 1230 Lines • Show Last 20 Lines |