Instrument Neutral Distributed Interface INDI  2.0.2
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()
40  {
41  return PortFD;
42  }
43 
44  protected:
45  virtual bool Connect() override;
46  virtual bool Disconnect() override;
47  virtual bool Handshake() override;
48  virtual IPState MoveAbsFocuser(uint32_t targetTicks) override;
49  virtual IPState MoveRelFocuser(FocusDirection dir, uint32_t ticks) override;
50  virtual bool AbortFocuser() override;
51  virtual void TimerHit() override;
52  virtual bool saveConfigItems(FILE *fp) override;
53  virtual bool SyncFocuser(uint32_t ticks) override;
54 
55  private:
56  void GetFocusParams();
57  bool updateStepMode();
58  bool updateStepDelay();
59  bool updateTemperature();
60  bool updatePosition();
61  bool isMoving();
62  bool Ack();
63 
64  bool gotoAbsPosition(uint32_t position);
65  bool setStepMode(FocusStepMode mode);
66  bool setStepDelay(uint8_t delay);
67  bool setTemperatureCalibration(double calibration);
68  bool setTemperatureCoefficient(double coefficient);
69  bool setTemperatureCompensation(bool enable);
70 
71  double targetPos { 0 };
72  double lastPos { 0 };
73  double lastTemperature { 0 };
74 
75  ISwitch StepModeS[2];
76  ISwitchVectorProperty StepModeSP;
77 
78  INumber StepDelayN[1];
79  INumberVectorProperty StepDelayNP;
80 
81  INumber TemperatureSettingN[2];
82  INumberVectorProperty TemperatureSettingNP;
83 
84  INumber TemperatureN[1];
85  INumberVectorProperty TemperatureNP;
86 
87  ISwitch TemperatureCompensateS[2];
88  ISwitchVectorProperty TemperatureCompensateSP;
89 
90  const uint8_t m_ID;
91  static constexpr const uint8_t DRO_CMD = 16;
92  static constexpr const char *SETTINGS_TAB = "Settings";
93 };
virtual bool AbortFocuser() override
AbortFocuser all focus motion.
int getPortFD()
Definition: moonlite_dro.h:39
virtual void TimerHit() override
Callback function to be called once SetTimer duration elapses.
virtual bool saveConfigItems(FILE *fp) override
saveConfigItems Saves the Device Port and Focuser Presets in the configuration file
const char * getDefaultName() override
virtual bool Connect() override
Connect to the device. INDI::DefaultDevice implementation connects to appropriate connection interfac...
virtual bool Disconnect() override
Disconnect from device.
virtual bool initProperties() override
Initilize properties initial state and value. The child class must implement this function.
void remoteDisconnect()
virtual bool Handshake() override
perform handshake with device to check communication
virtual bool ISNewSwitch(const char *dev, const char *name, ISState *states, char *names[], int n) override
Process the client newSwitch command.
MoonLiteDRO(int ID)
virtual IPState MoveRelFocuser(FocusDirection dir, uint32_t ticks) override
MoveFocuser the focuser to an relative position.
virtual bool ISNewNumber(const char *dev, const char *name, double values[], char *names[], int n) override
Process the client newNumber command.
virtual IPState MoveAbsFocuser(uint32_t targetTicks) override
MoveFocuser the focuser to an absolute position.
virtual bool SyncFocuser(uint32_t ticks) override
SyncFocuser Set current position to ticks without moving the focuser.
virtual bool updateProperties() override
updateProperties is called whenever there is a change in the CONNECTION status of the driver....
ISState
Switch state.
Definition: indiapi.h:150
IPState
Property state.
Definition: indiapi.h:160
One number descriptor.
One switch descriptor.
Number vector property descriptor.
Definition: indiapi.h:319
Switch vector property descriptor.
Definition: indiapi.h:367