30 static 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);
120 if (updateVoltageIn())
123 if (updateTemperature())
149 LOG_INFO(
"Error retrieving data from device, please ensure focuser is powered and the port is correct.");
164 bool Esatto::updateTemperature()
166 double temperature = 0;
170 else if ( m_Esatto->getMotorTemp(temperature) ==
false)
173 if (temperature > 90)
176 TemperatureNP[TEMPERATURE_MOTOR].setValue(temperature);
180 if (m_Esatto->getExternalTemp(temperature))
182 if (temperature < 90)
183 TemperatureNP[TEMPERATURE_EXTERNAL].setValue(temperature);
185 TemperatureNP[TEMPERATURE_EXTERNAL].setValue(-273.15);
194 bool Esatto::updatePosition()
199 else if (m_Esatto->getAbsolutePosition(steps) ==
false)
209 bool Esatto::updateVoltageIn()
212 if (m_Esatto->getVoltage12v(voltage))
213 VoltageNP[VOLTAGE_12V].setValue(voltage);
216 if (m_Esatto->getVoltageUSB(voltage))
217 VoltageNP[VOLTAGE_USB].setValue(voltage);
231 FastMoveSP.
update(states, names, n);
234 switch (current_switch)
237 m_Esatto->fastMoveIn();
240 m_Esatto->fastMoveOut();
262 if (m_Esatto->goAbsolutePosition(targetTicks) ==
false)
274 int relativeTicks = ((dir ==
FOCUS_INWARD) ? -ticks : ticks) * reversed;
275 double newPosition =
FocusAbsPosN[0].value + relativeTicks;
290 return m_Esatto->stop();
306 bool rc = updatePosition();
307 if (rc && (std::abs(lastPos -
FocusAbsPosN[0].value) > 0)) {
320 if (m_TemperatureCounter++ == TEMPERATURE_FREQUENCY)
322 auto lastValue = TemperatureNP[0].value;
323 rc = updateTemperature();
324 if (rc && std::abs(lastValue - TemperatureNP[0].value) >= 0.1)
325 TemperatureNP.
apply();
327 auto current12V = VoltageNP[VOLTAGE_12V].getValue();
328 auto currentUSB = VoltageNP[VOLTAGE_USB].getValue();
329 if (updateVoltageIn())
331 if (std::abs(current12V - VoltageNP[VOLTAGE_12V].getValue()) >= 0.1 ||
332 std::abs(currentUSB - VoltageNP[VOLTAGE_USB].getValue()) >= 0.1)
335 if (VoltageNP[VOLTAGE_12V].getValue() < 11.0)
336 LOG_WARN(
"Please check 12v DC power supply is connected.");
339 m_TemperatureCounter = 0;
348 bool Esatto::getStartupValues()
350 auto rc1 = updatePosition();
352 auto rc2 = m_Esatto->getBacklash(steps);
356 auto rc3 = updateMaxLimit();
358 return rc1 && rc2 && rc3;
375 std::string response;
378 if(m_Esatto->getSerialNumber(response))
379 LOGF_INFO(
"Serial number: %s", response.c_str());
383 FirmwareTP[FIRMWARE_SN].setText(response.c_str());
385 if (m_Esatto->getFirmwareVersion(response))
387 LOGF_INFO(
"Firmware version: %s", response.c_str());
388 IUSaveText(&FirmwareTP[FIRMWARE_VERSION], response.c_str());
397 void Esatto::setConnectionParams()
408 return m_Esatto->setBacklash(steps);
414 bool Esatto::updateMaxLimit()
416 uint32_t maxLimit = 0;
418 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
Process the client newSwitch command.
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
Initilize properties initial state and value. The child class must implement this function.
virtual bool Handshake() override
perform handshake with device to check communication
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
updateProperties is called whenever there is a change in the CONNECTION status of the driver....
const char * getDeviceName() const
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.
INumberVectorProperty FocusAbsPosNP
INumberVectorProperty FocusRelPosNP
ISwitchVectorProperty FocusReverseSP
void SetCapability(uint32_t cap)
FI::SetCapability sets the focuser capabilities. All capabilities must be initialized.
INumber FocusBacklashN[1]
INumberVectorProperty FocusMaxPosNP
virtual bool ISNewSwitch(const char *dev, const char *name, ISState *states, char *names[], int n) override
Process the client newSwitch command.
virtual bool updateProperties() override
updateProperties is called whenever there is a change in the CONNECTION status of the driver....
virtual bool initProperties() override
Initilize properties initial state and value. The child class must implement this function.
Connection::Serial * serialConnection
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 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 * MAIN_CONTROL_TAB
MAIN_CONTROL_TAB Where all the primary controls for the device are located.
void IUFillNumberVector(INumberVectorProperty *nvp, INumber *np, int nnp, const char *dev, const char *name, const char *label, const char *group, IPerm p, double timeout, IPState s)
Assign attributes for a number vector property. The vector's auxiliary elements will be set to NULL.
int IUFindOnSwitchIndex(const ISwitchVectorProperty *svp)
Returns the index of first ON switch it finds in the vector switch property.
void IUSaveText(IText *tp, const char *newtext)
Function to reliably save new text in a IText.
void IDSetNumber(const INumberVectorProperty *nvp, const char *fmt,...)
#define LOGF_INFO(fmt,...)
const char * CONNECTION_TAB