Instrument Neutral Distributed Interface INDI  1.9.5
moonlite_dro.h
Go to the documentation of this file.
1 /*
2  Moonlite DRO Dual Focuser
3  Copyright (C) 2018 Jasem Mutlaq (mutlaqja@ikarustech.com)
4 
5  This library is free software; you can redistribute it and/or
6  modify it under the terms of the GNU Lesser General Public
7  License as published by the Free Software Foundation; either
8  version 2.1 of the License, or (at your option) any later version.
9 
10  This library is distributed in the hope that it will be useful,
11  but WITHOUT ANY WARRANTY; without even the implied warranty of
12  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13  Lesser General Public License for more details.
14 
15  You should have received a copy of the GNU Lesser General Public
16  License along with this library; if not, write to the Free Software
17  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
18 
19 */
20 
21 #pragma once
22 
23 #include "indifocuser.h"
24 
25 class MoonLiteDRO : public INDI::Focuser
26 {
27  public:
28  MoonLiteDRO(int ID);
29 
31 
32  const char *getDefaultName() override;
33  virtual bool initProperties() override;
34  virtual bool updateProperties() override;
35  virtual bool ISNewNumber(const char *dev, const char *name, double values[], char *names[], int n) override;
36  virtual bool ISNewSwitch(const char *dev, const char *name, ISState *states, char *names[], int n) override;
37 
38  void remoteDisconnect();
39  int getPortFD() { return PortFD; }
40 
41 protected:
42  virtual bool Connect() override;
43  virtual bool Disconnect() override;
44  virtual bool Handshake() override;
45  virtual IPState MoveAbsFocuser(uint32_t targetTicks) override;
46  virtual IPState MoveRelFocuser(FocusDirection dir, uint32_t ticks) override;
47  virtual bool AbortFocuser() override;
48  virtual void TimerHit() override;
49  virtual bool saveConfigItems(FILE *fp) override;
50  virtual bool SyncFocuser(uint32_t ticks) override;
51 
52  private:
53  void GetFocusParams();
54  bool updateStepMode();
55  bool updateStepDelay();
56  bool updateTemperature();
57  bool updatePosition();
58  bool isMoving();
59  bool Ack();
60 
61  bool gotoAbsPosition(uint32_t position);
62  bool setStepMode(FocusStepMode mode);
63  bool setStepDelay(uint8_t delay);
64  bool setTemperatureCalibration(double calibration);
65  bool setTemperatureCoefficient(double coefficient);
66  bool setTemperatureCompensation(bool enable);
67 
68  double targetPos { 0 };
69  double lastPos { 0 };
70  double lastTemperature { 0 };
71 
72  ISwitch StepModeS[2];
73  ISwitchVectorProperty StepModeSP;
74 
75  INumber StepDelayN[1];
76  INumberVectorProperty StepDelayNP;
77 
78  INumber TemperatureSettingN[2];
79  INumberVectorProperty TemperatureSettingNP;
80 
81  INumber TemperatureN[1];
82  INumberVectorProperty TemperatureNP;
83 
84  ISwitch TemperatureCompensateS[2];
85  ISwitchVectorProperty TemperatureCompensateSP;
86 
87  const uint8_t m_ID;
88  static constexpr const uint8_t DRO_CMD = 16;
89  static constexpr const char *SETTINGS_TAB = "Settings";
90 };
MoonLiteDRO::MoveAbsFocuser
virtual IPState MoveAbsFocuser(uint32_t targetTicks) override
MoveFocuser the focuser to an absolute position.
Definition: moonlite_dro.cpp:851
IPState
IPState
Property state.
Definition: indiapi.h:158
ISwitch
One switch descriptor.
INumber
One number descriptor.
MoonLiteDRO::Connect
virtual bool Connect() override
Connect to the device. INDI::DefaultDevice implementation connects to appropriate connection interfac...
Definition: moonlite_dro.cpp:140
MoonLiteDRO::FOCUS_FULL_STEP
@ FOCUS_FULL_STEP
Definition: moonlite_dro.h:30
MoonLiteDRO::saveConfigItems
virtual bool saveConfigItems(FILE *fp) override
saveConfigItems Saves the Device Port and Focuser Presets in the configuration file
Definition: moonlite_dro.cpp:957
MoonLiteDRO::initProperties
virtual bool initProperties() override
Initilize properties initial state and value. The child class must implement this function.
Definition: moonlite_dro.cpp:47
indifocuser.h
MoonLiteDRO::MoonLiteDRO
MoonLiteDRO(int ID)
Definition: moonlite_dro.cpp:39
MoonLiteDRO::TimerHit
virtual void TimerHit() override
Callback function to be called once SetTimer duration elapses.
Definition: moonlite_dro.cpp:888
MoonLiteDRO::FOCUS_HALF_STEP
@ FOCUS_HALF_STEP
Definition: moonlite_dro.h:30
_INumberVectorProperty
Number vector property descriptor.
Definition: indiapi.h:317
INDI::Focuser::PortFD
int PortFD
Definition: indifocuser.h:116
MoonLiteDRO::Disconnect
virtual bool Disconnect() override
Disconnect from device.
Definition: moonlite_dro.cpp:156
MoonLiteDRO::FocusStepMode
FocusStepMode
Definition: moonlite_dro.h:30
MoonLiteDRO::Handshake
virtual bool Handshake() override
perform handshake with device to check communication
Definition: moonlite_dro.cpp:184
MoonLiteDRO::AbortFocuser
virtual bool AbortFocuser() override
AbortFocuser all focus motion.
Definition: moonlite_dro.cpp:936
MoonLiteDRO::updateProperties
virtual bool updateProperties() override
updateProperties is called whenever there is a change in the CONNECTION status of the driver....
Definition: moonlite_dro.cpp:103
name
const char * name
Definition: indiserver.c:116
MoonLiteDRO::remoteDisconnect
void remoteDisconnect()
Definition: moonlite_dro.cpp:170
INDI::FocuserInterface::FocusDirection
FocusDirection
Definition: indifocuserinterface.h:66
MoonLiteDRO::ISNewNumber
virtual bool ISNewNumber(const char *dev, const char *name, double values[], char *names[], int n) override
Process the client newNumber command.
Definition: moonlite_dro.cpp:795
MoonLiteDRO
Definition: moonlite_dro.h:25
MoonLiteDRO::SyncFocuser
virtual bool SyncFocuser(uint32_t ticks) override
SyncFocuser Set current position to ticks without moving the focuser.
Definition: moonlite_dro.cpp:573
MoonLiteDRO::MoveRelFocuser
virtual IPState MoveRelFocuser(FocusDirection dir, uint32_t ticks) override
MoveFocuser the focuser to an relative position.
Definition: moonlite_dro.cpp:867
ISState
ISState
Switch state.
Definition: indiapi.h:148
INDI::Focuser
Definition: indifocuser.h:43
MoonLiteDRO::getDefaultName
const char * getDefaultName() override
Definition: moonlite_dro.cpp:196
MoonLiteDRO::getPortFD
int getPortFD()
Definition: moonlite_dro.h:39
MoonLiteDRO::ISNewSwitch
virtual bool ISNewSwitch(const char *dev, const char *name, ISState *states, char *names[], int n) override
Process the client newSwitch command.
Definition: moonlite_dro.cpp:730
_ISwitchVectorProperty
Switch vector property descriptor.
Definition: indiapi.h:365