Instrument Neutral Distributed Interface INDI  2.0.2
celestron.h
Go to the documentation of this file.
1 /*
2  Celestron Focuser for SCT and EDGEHD
3 
4  Copyright (C) 2019 Jasem Mutlaq (mutlaqja@ikarustech.com)
5  Copyright (C) 2019 Chris Rowland
6 
7  This library is free software; you can redistribute it and/or
8  modify it under the terms of the GNU Lesser General Public
9  License as published by the Free Software Foundation; either
10  version 2.1 of the License, or (at your option) any later version.
11 
12  This library is distributed in the hope that it will be useful,
13  but WITHOUT ANY WARRANTY; without even the implied warranty of
14  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15  Lesser General Public License for more details.
16 
17  You should have received a copy of the GNU Lesser General Public
18  License along with this library; if not, write to the Free Software
19  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
20 
21 */
22 
23 #pragma once
24 
25 #include "indifocuser.h"
26 
27 #include <chrono>
28 #include "celestronauxpacket.h"
29 
31 {
32  public:
33  CelestronSCT();
34 
35  const char * getDefaultName() override;
36  virtual bool initProperties() override;
37  virtual bool updateProperties() override;
38  //virtual bool ISNewNumber(const char * dev, const char * name, double values[], char * names[], int n) override;
39  virtual bool ISNewSwitch(const char *dev, const char *name, ISState *states, char *names[], int n) override;
40 
41  protected:
46  virtual bool Handshake() override;
47 
53  virtual IPState MoveAbsFocuser(uint32_t targetTicks) override;
54 
61  virtual IPState MoveRelFocuser(FocusDirection dir, uint32_t ticks) override;
62 
67  virtual bool AbortFocuser() override;
68 
73  virtual void TimerHit() override;
74  virtual bool SetFocuserBacklash(int32_t steps) override;
75 
76  private:
77  Aux::Communicator communicator;
78 
79  // Do we have a response from the focuser?
80  bool Ack();
81 
82  // Get initial focuser parameters when we first connect
83  bool getStartupParameters();
84 
88  // Read and update Position
89  bool readPosition();
90  // Are we moving?
91  bool isMoving();
92  // read limits
93  bool readLimits();
94 
98  bool startMove(uint32_t position);
99 
103  // INumber BacklashN[1];
104  // INumberVectorProperty BacklashNP;
105 
106  INumber FocusMinPosN[1];
107  INumberVectorProperty FocusMinPosNP;
108 
109  bool backlashMove; // set if a final move is needed
110  uint32_t finalPosition;
111 
112  ISwitch CalibrateS[2];
113  ISwitchVectorProperty CalibrateSP;
114 
115  IText CalibrateStateT[1] {};
116  ITextVectorProperty CalibrateStateTP;
117 
118  bool calibrateInProgress;
119  int calibrateState;
120  bool focuserIsCalibrated;
121 
125  // // Celestron Buffer
126  // static const uint8_t CELESTRON_LEN { 32 };
127  // // Celestorn Delimeter
128  // static const char CELESTRON_DEL { '#' };
129  // // Celestron Tiemout in seconds
130  // static const uint8_t CELESTRON_TIMEOUT { 3 };
131 };
The Communicator class handles high-level communication with the Celestron devices.
virtual bool updateProperties() override
updateProperties is called whenever there is a change in the CONNECTION status of the driver....
Definition: celestron.cpp:126
virtual bool ISNewSwitch(const char *dev, const char *name, ISState *states, char *names[], int n) override
Process the client newSwitch command.
Definition: celestron.cpp:267
virtual bool AbortFocuser() override
AbortFocuser Abort Focuser motion.
Definition: celestron.cpp:483
virtual IPState MoveAbsFocuser(uint32_t targetTicks) override
MoveAbsFocuser Move to an absolute target position.
Definition: celestron.cpp:317
virtual bool Handshake() override
Handshake Try to communicate with Focuser and see if there is a valid response.
Definition: celestron.cpp:156
virtual IPState MoveRelFocuser(FocusDirection dir, uint32_t ticks) override
MoveRelFocuser Move focuser for a relative amount of ticks in a specific direction.
Definition: celestron.cpp:375
virtual bool initProperties() override
Initilize properties initial state and value. The child class must implement this function.
Definition: celestron.cpp:50
virtual void TimerHit() override
TimerHit Primary Loop called every POLLMS milliseconds (set in Options) to check on the focuser statu...
Definition: celestron.cpp:389
virtual bool SetFocuserBacklash(int32_t steps) override
SetFocuserBacklash Set the focuser backlash compensation value.
Definition: celestron.cpp:495
const char * getDefaultName() override
Definition: celestron.cpp:168
ISState
Switch state.
Definition: indiapi.h:150
IPState
Property state.
Definition: indiapi.h:160
One number descriptor.
One switch descriptor.
One text descriptor.
Number vector property descriptor.
Definition: indiapi.h:319
Switch vector property descriptor.
Definition: indiapi.h:367
Text vector property descriptor.
Definition: indiapi.h:246