8#include "indifocuser.h"
9#include "clientmanager.h"
14void Focuser::registerProperty(INDI::Property prop)
16 if (!prop.getRegistered())
19 if (prop.isNameMatch(
"FOCUS_MAX"))
21 auto nvp = prop.getNumber();
22 m_maxPosition = nvp->at(0)->getValue();
25 ConcreteDevice::registerProperty(prop);
28void Focuser::processNumber(INDI::Property prop)
30 auto nvp = prop.getNumber();
31 if (prop.isNameMatch(
"FOCUS_MAX"))
33 m_maxPosition = nvp->at(0)->getValue();
37bool Focuser::focusIn()
39 auto focusProp =
getSwitch(
"FOCUS_MOTION");
44 auto inFocus = focusProp->findWidgetByName(
"FOCUS_INWARD");
49 if (inFocus->getState() == ISS_ON)
53 inFocus->setState(ISS_ON);
62 auto focusStop =
getSwitch(
"FOCUS_ABORT_MOTION");
67 focusStop->at(0)->setState(ISS_ON);
73bool Focuser::focusOut()
75 auto focusProp =
getSwitch(
"FOCUS_MOTION");
80 auto outFocus = focusProp->findWidgetByName(
"FOCUS_OUTWARD");
85 if (outFocus->getState() == ISS_ON)
89 outFocus->setState(ISS_ON);
96bool Focuser::getFocusDirection(ISD::Focuser::FocusDirection *dir)
98 auto focusProp =
getSwitch(
"FOCUS_MOTION");
103 auto inFocus = focusProp->findWidgetByName(
"FOCUS_INWARD");
108 if (inFocus->getState() == ISS_ON)
111 *
dir = FOCUS_OUTWARD;
116bool Focuser::moveByTimer(
int msecs)
118 auto focusProp = getNumber(
"FOCUS_TIMER");
123 focusProp->at(0)->setValue(msecs);
130bool Focuser::moveAbs(
int steps)
132 auto focusProp = getNumber(
"ABS_FOCUS_POSITION");
137 focusProp->at(0)->setValue(steps);
144bool Focuser::canAbsMove()
146 auto focusProp = getNumber(
"ABS_FOCUS_POSITION");
154bool Focuser::moveRel(
int steps)
156 INDI::PropertyView<INumber> *focusProp;
158 if(canManualFocusDriveMove())
160 focusProp = getNumber(
"manualfocusdrive");
163 if (!getFocusDirection(&dir))
165 if (dir == FOCUS_INWARD)
167 else if (dir == FOCUS_OUTWARD)
171 if (steps == getLastManualFocusDriveValue())
175 if (deviation == NIKONZ6)
183 focusProp = getNumber(
"REL_FOCUS_POSITION");
189 focusProp->at(0)->setValue(steps);
196bool Focuser::canRelMove()
198 auto focusProp = getNumber(
"REL_FOCUS_POSITION");
206bool Focuser::canManualFocusDriveMove()
208 auto focusProp = getNumber(
"manualfocusdrive");
216double Focuser::getLastManualFocusDriveValue()
218 auto focusProp = getNumber(
"manualfocusdrive");
223 return focusProp->at(0)->getValue();
227bool Focuser::canTimerMove()
229 auto focusProp = getNumber(
"FOCUS_TIMER");
237bool Focuser::setMaxPosition(uint32_t steps)
239 auto focusProp = getNumber(
"FOCUS_MAX");
244 focusProp->at(0)->setValue(steps);
250bool Focuser::hasBacklash()
252 auto focusProp = getNumber(
"FOCUS_BACKLASH_STEPS");
253 return (focusProp !=
nullptr);
256bool Focuser::setBacklash(int32_t steps)
258 auto focusToggle =
getSwitch(
"FOCUS_BACKLASH_TOGGLE");
263 if (steps != 0 && focusToggle->at(0)->getState() != ISS_ON)
265 focusToggle->reset();
266 focusToggle->at(0)->setState(ISS_ON);
267 focusToggle->at(1)->setState(ISS_OFF);
271 auto focusProp = getNumber(
"FOCUS_BACKLASH_STEPS");
275 focusProp->at(0)->setValue(steps);
279 if (steps == 0 && focusToggle->at(0)->getState() == ISS_ON)
281 focusToggle->reset();
282 focusToggle->at(0)->setState(ISS_OFF);
283 focusToggle->at(1)->setState(ISS_ON);
289int32_t Focuser::getBacklash()
291 auto focusProp = getNumber(
"FOCUS_BACKLASH_STEPS");
295 return focusProp->at(0)->getValue();
298bool Focuser::hasDeviation()
300 if (getDeviceName() ==
"Nikon DSLR Z6")
void sendNewProperty(INDI::Property prop)
Send new property command to server.
INDI::PropertyView< ISwitch > * getSwitch(const QString &name) const
ISD is a collection of INDI Standard Devices.
KIOCORE_EXPORT QString dir(const QString &fileClass)