7 #include <basedevice.h>
8 #include "indifocuser.h"
9 #include "clientmanager.h"
14 void 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);
28 void Focuser::processNumber(INumberVectorProperty *nvp)
30 if (!strcmp(nvp->name,
"FOCUS_MAX"))
32 m_maxPosition = nvp->np[0].value;
36 bool Focuser::focusIn()
38 auto focusProp =
getSwitch(
"FOCUS_MOTION");
43 auto inFocus = focusProp->findWidgetByName(
"FOCUS_INWARD");
48 if (inFocus->getState() == ISS_ON)
52 inFocus->setState(ISS_ON);
61 auto focusStop =
getSwitch(
"FOCUS_ABORT_MOTION");
66 focusStop->at(0)->setState(ISS_ON);
72 bool Focuser::focusOut()
74 auto focusProp =
getSwitch(
"FOCUS_MOTION");
79 auto outFocus = focusProp->findWidgetByName(
"FOCUS_OUTWARD");
84 if (outFocus->getState() == ISS_ON)
88 outFocus->setState(ISS_ON);
95 bool Focuser::getFocusDirection(ISD::Focuser::FocusDirection *dir)
97 auto focusProp =
getSwitch(
"FOCUS_MOTION");
102 auto inFocus = focusProp->findWidgetByName(
"FOCUS_INWARD");
107 if (inFocus->getState() == ISS_ON)
110 *
dir = FOCUS_OUTWARD;
115 bool Focuser::moveByTimer(
int msecs)
117 auto focusProp = getNumber(
"FOCUS_TIMER");
122 focusProp->at(0)->setValue(msecs);
129 bool Focuser::moveAbs(
int steps)
131 auto focusProp = getNumber(
"ABS_FOCUS_POSITION");
136 focusProp->at(0)->setValue(steps);
143 bool Focuser::canAbsMove()
145 auto focusProp = getNumber(
"ABS_FOCUS_POSITION");
153 bool Focuser::moveRel(
int steps)
155 INDI::PropertyView<INumber> *focusProp;
157 if(canManualFocusDriveMove())
159 focusProp = getNumber(
"manualfocusdrive");
162 getFocusDirection(&dir);
163 if (dir == FOCUS_INWARD)
165 else if (dir == FOCUS_OUTWARD)
169 if (steps == getLastManualFocusDriveValue())
173 if (deviation == NIKONZ6)
181 focusProp = getNumber(
"REL_FOCUS_POSITION");
187 focusProp->at(0)->setValue(steps);
194 bool Focuser::canRelMove()
196 auto focusProp = getNumber(
"REL_FOCUS_POSITION");
204 bool Focuser::canManualFocusDriveMove()
206 auto focusProp = getNumber(
"manualfocusdrive");
214 double Focuser::getLastManualFocusDriveValue()
216 auto focusProp = getNumber(
"manualfocusdrive");
221 return focusProp->at(0)->getValue();
225 bool Focuser::canTimerMove()
227 auto focusProp = getNumber(
"FOCUS_TIMER");
235 bool Focuser::setMaxPosition(uint32_t steps)
237 auto focusProp = getNumber(
"FOCUS_MAX");
242 focusProp->at(0)->setValue(steps);
248 bool Focuser::hasBacklash()
250 auto focusProp = getNumber(
"FOCUS_BACKLASH_STEPS");
251 return (focusProp !=
nullptr);
254 bool Focuser::setBacklash(int32_t steps)
256 auto focusToggle =
getSwitch(
"FOCUS_BACKLASH_TOGGLE");
261 if (steps != 0 && focusToggle->at(0)->getState() != ISS_ON)
263 focusToggle->reset();
264 focusToggle->at(0)->setState(ISS_ON);
265 focusToggle->at(1)->setState(ISS_OFF);
269 auto focusProp = getNumber(
"FOCUS_BACKLASH_STEPS");
273 focusProp->at(0)->setValue(steps);
277 if (steps == 0 && focusToggle->at(0)->getState() == ISS_ON)
279 focusToggle->reset();
280 focusToggle->at(0)->setState(ISS_OFF);
281 focusToggle->at(1)->setState(ISS_ON);
287 int32_t Focuser::getBacklash()
289 auto focusProp = getNumber(
"FOCUS_BACKLASH_STEPS");
293 return focusProp->at(0)->getValue();
296 bool Focuser::hasDeviation()
298 if (getDeviceName() ==
"Nikon DSLR Z6")