30static std::unique_ptr<Esatto> sesto(
new Esatto());
56 setConnectionParams();
59 FirmwareTP[FIRMWARE_SN].
fill(
"SERIALNUMBER",
"Serial Number",
"");
60 FirmwareTP[FIRMWARE_VERSION].
fill(
"VERSION",
"Version",
"");
64 VoltageNP[VOLTAGE_12V].
fill(
"VOLTAGE_12V",
"12v",
"%.2f", 0, 100, 0., 0.);
65 VoltageNP[VOLTAGE_USB].
fill(
"VOLTAGE_USB",
"USB",
"%.2f", 0, 100, 0., 0.);
69 TemperatureNP[TEMPERATURE_MOTOR].
fill(
"TEMPERATURE",
"Motor (c)",
"%.2f", -50, 70., 0., 0.);
70 TemperatureNP[TEMPERATURE_EXTERNAL].
fill(
"TEMPERATURE_ETX",
"External (c)",
"%.2f", -50, 70., 0., 0.);
74 FastMoveSP[FASTMOVE_IN].
fill(
"FASTMOVE_IN",
"Move In",
ISS_OFF);
75 FastMoveSP[FASTMOVE_OUT].
fill(
"FASTMOVE_OUT",
"Move out",
ISS_OFF);
76 FastMoveSP[FASTMOVE_STOP].
fill(
"FASTMOVE_STOP",
"Stop",
ISS_OFF);
119 if (updateVoltageIn())
122 if (updateTemperature())
148 LOG_INFO(
"Error retrieving data from device, please ensure focuser is powered and the port is correct.");
163bool Esatto::updateTemperature()
169 else if ( m_Esatto->getMotorTemp(
temperature) ==
false)
175 TemperatureNP[TEMPERATURE_MOTOR].setValue(
temperature);
182 TemperatureNP[TEMPERATURE_EXTERNAL].setValue(
temperature);
184 TemperatureNP[TEMPERATURE_EXTERNAL].setValue(-273.15);
193bool Esatto::updatePosition()
198 else if (m_Esatto->getAbsolutePosition(steps) ==
false)
208bool Esatto::updateVoltageIn()
211 if (m_Esatto->getVoltage12v(voltage))
212 VoltageNP[VOLTAGE_12V].setValue(voltage);
215 if (m_Esatto->getVoltageUSB(voltage))
216 VoltageNP[VOLTAGE_USB].setValue(voltage);
230 FastMoveSP.
update(states, names, n);
233 switch (current_switch)
236 m_Esatto->fastMoveIn();
239 m_Esatto->fastMoveOut();
261 if (m_Esatto->goAbsolutePosition(targetTicks) ==
false)
273 int relativeTicks = ((dir ==
FOCUS_INWARD) ? -ticks : ticks) * reversed;
274 double newPosition =
FocusAbsPosNP[0].getValue() + relativeTicks;
289 return m_Esatto->stop();
305 bool rc = updatePosition();
306 if (rc && (std::abs(lastPos -
FocusAbsPosNP[0].getValue()) > 0))
321 if (m_TemperatureCounter++ == TEMPERATURE_FREQUENCY)
323 rc = updateTemperature();
326 if (rc && (std::abs(m_LastTemperature[TEMPERATURE_EXTERNAL] - TemperatureNP[TEMPERATURE_EXTERNAL].value) >=
327 MEASUREMENT_THRESHOLD ||
328 std::abs(m_LastTemperature[TEMPERATURE_MOTOR] - TemperatureNP[TEMPERATURE_MOTOR].value) >= MEASUREMENT_THRESHOLD ))
330 m_LastTemperature[TEMPERATURE_EXTERNAL] = TemperatureNP[TEMPERATURE_EXTERNAL].value;
331 m_LastTemperature[TEMPERATURE_MOTOR] = TemperatureNP[TEMPERATURE_MOTOR].value;
332 TemperatureNP.
apply();
335 if (updateVoltageIn())
337 if (std::abs(m_LastVoltage[VOLTAGE_12V] - VoltageNP[VOLTAGE_12V].getValue()) >= MEASUREMENT_THRESHOLD ||
338 std::abs(m_LastVoltage[VOLTAGE_USB] - VoltageNP[VOLTAGE_USB].getValue()) >= MEASUREMENT_THRESHOLD)
340 m_LastVoltage[VOLTAGE_12V] = VoltageNP[VOLTAGE_12V].getValue();
341 m_LastVoltage[VOLTAGE_USB] = VoltageNP[VOLTAGE_USB].getValue();
343 if (VoltageNP[VOLTAGE_12V].getValue() < 11.0)
344 LOG_WARN(
"Please check 12v DC power supply is connected.");
347 m_TemperatureCounter = 0;
356bool Esatto::getStartupValues()
358 auto rc1 = updatePosition();
360 auto rc2 = m_Esatto->getBacklash(steps);
364 auto rc3 = updateMaxLimit();
366 return rc1 && rc2 && rc3;
383 std::string response;
386 if(m_Esatto->getSerialNumber(response))
387 LOGF_INFO(
"Serial number: %s", response.c_str());
391 FirmwareTP[FIRMWARE_SN].setText(response.c_str());
393 if (m_Esatto->getFirmwareVersion(response))
395 LOGF_INFO(
"Firmware version: %s", response.c_str());
396 IUSaveText(&FirmwareTP[FIRMWARE_VERSION], response.c_str());
405void Esatto::setConnectionParams()
416 return m_Esatto->setBacklash(steps);
422bool Esatto::updateMaxLimit()
424 uint32_t maxLimit = 0;
426 if (m_Esatto->getMaxPosition(maxLimit) ==
false)
void setWordSize(const uint8_t &value)
setWordSize Set word size to be used in the serial connection. Default 8
void setDefaultBaudRate(BaudRate newRate)
setDefaultBaudRate Set default baud rate. The default baud rate is 9600 unless otherwise changed by t...
const char * getDefaultName() override
virtual bool ISNewSwitch(const char *dev, const char *name, ISState *states, char *names[], int n) override
Processes incoming new switch states from the client for this device. Handles updates to FocuserInter...
virtual bool AbortFocuser() override
AbortFocuser all focus motion.
virtual IPState MoveRelFocuser(FocusDirection dir, uint32_t ticks) override
MoveFocuser the focuser to an relative position.
virtual IPState MoveAbsFocuser(uint32_t targetTicks) override
MoveFocuser the focuser to an absolute position.
virtual bool SetFocuserBacklash(int32_t steps) override
SetFocuserBacklash Set the focuser backlash compensation value.
virtual bool initProperties() override
Initializes the default properties for the focuser device. Sets up standard INDI properties,...
virtual bool Handshake() override
Performs a device-specific handshake after a connection is established. This method should be overrid...
virtual void TimerHit() override
Callback function to be called once SetTimer duration elapses.
virtual bool ReverseFocuser(bool enabled) override
ReverseFocuser Reverse focuser motion direction.
virtual bool updateProperties() override
Updates the state and definition of properties based on the current connection status....
void setDefaultPollingPeriod(uint32_t msec)
setDefaultPollingPeriod Change the default polling period to call TimerHit() function in the driver.
void setVersion(uint16_t vMajor, uint16_t vMinor)
Set driver version information to be defined in DRIVER_INFO property as vMajor.vMinor.
virtual bool deleteProperty(const char *propertyName)
Delete a property and unregister it. It will also be deleted from all clients.
void defineProperty(INumberVectorProperty *property)
uint32_t getCurrentPollingPeriod() const
getCurrentPollingPeriod Return the current polling period.
bool isSimulation() const
void addAuxControls()
Add Debug, Simulation, and Configuration options to the driver.
int SetTimer(uint32_t ms)
Set a timer to call the function TimerHit after ms milliseconds.
INDI::PropertyNumber FocusRelPosNP
INDI::PropertySwitch FocusReverseSP
void SetCapability(uint32_t cap)
FI::SetCapability sets the focuser capabilities. All capabilities must be initialized.
INDI::PropertyNumber FocusMaxPosNP
INDI::PropertyNumber FocusBacklashNP
INDI::PropertyNumber FocusAbsPosNP
virtual bool ISNewSwitch(const char *dev, const char *name, ISState *states, char *names[], int n) override
Processes incoming new switch states from the client for this device. Handles updates to FocuserInter...
virtual bool updateProperties() override
Updates the state and definition of properties based on the current connection status....
virtual bool initProperties() override
Initializes the default properties for the focuser device. Sets up standard INDI properties,...
Connection::Serial * serialConnection
INDI::PropertyNumber PresetNP
void setState(IPState state)
void apply(const char *format,...) const ATTRIBUTE_FORMAT_PRINTF(2
const char * getName() const
bool isNameMatch(const char *otherName) const
void setPermission(IPerm permission)
void fill(const char *device, const char *name, const char *label, const char *group, IPerm permission, double timeout, IPState state)
bool update(const ISState states[], const char *const names[], int n)
int findOnSwitchIndex() const
void fill(const char *device, const char *name, const char *label, const char *group, IPerm permission, ISRule rule, double timeout, IPState state)
void fill(const char *device, const char *name, const char *label, const char *group, IPerm permission, double timeout, IPState state)
const char * CONNECTION_TAB
CONNECTION_TAB Where all device connection settings (serial, usb, ethernet) are defined and controlle...
const char * MAIN_CONTROL_TAB
MAIN_CONTROL_TAB Where all the primary controls for the device are located.
void IUSaveText(IText *tp, const char *newtext)
Function to reliably save new text in a IText.
#define LOGF_INFO(fmt,...)