Instrument Neutral Distributed Interface INDI  2.0.2
lx200telescope.h
Go to the documentation of this file.
1 #ifndef LX200TELESCOPE_H
2 #define LX200TELESCOPE_H
3 
4 #pragma once
5 
6 /*
7  * Standard LX200 implementation.
8 
9  Copyright (C) 2003 - 2018 Jasem Mutlaq (mutlaqja@ikarustech.com)
10 
11  This library is free software;
12  you can redistribute it and / or
13  modify it under the terms of the GNU Lesser General Public
14  License as published by the Free Software Foundation;
15  either
16  version 2.1 of the License, or (at your option) any later version.
17 
18  This library is distributed in the hope that it will be useful,
19  but WITHOUT ANY WARRANTY;
20  without even the implied warranty of
21  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
22  Lesser General Public License for more details.
23 
24  You should have received a copy of the GNU Lesser General Public
25  License along with this library;
26  if not, write to the Free Software
27  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110 - 1301 USA
28  */
29 
30 #include "indiguiderinterface.h"
31 #include "indifocuserinterface.h"
32 #include "inditelescope.h"
33 
35 {
36  public:
42  enum
43  {
44  LX200_HAS_FOCUS = 1 << 0,
47  LX200_HAS_SITES = 1 << 3,
51 
52  uint32_t getLX200Capability() const
53  {
54  return genericCapability;
55  }
56  void setLX200Capability(uint32_t cap)
57  {
58  genericCapability = cap;
59  }
60 
61  virtual const char *getDefaultName() override;
62  virtual const char *getDriverName() override;
63  virtual bool Handshake() override;
64  virtual bool ReadScopeStatus() override;
65  virtual void ISGetProperties(const char *dev) override;
66  virtual bool initProperties() override;
67  virtual bool updateProperties() override;
68  virtual bool ISNewNumber(const char *dev, const char *name, double values[], char *names[], int n) override;
69  virtual bool ISNewSwitch(const char *dev, const char *name, ISState *states, char *names[], int n) override;
70  virtual bool ISNewText(const char *dev, const char *name, char *texts[], char *names[], int n) override;
71 
72  void updateFocusTimer();
73 
74  protected:
75  // Slew Rate
76  virtual bool SetSlewRate(int index) override;
77  // Track Mode (Sidereal, Solar..etc)
78  virtual bool SetTrackMode(uint8_t mode) override;
79 
80  // NSWE Motion Commands
81  virtual bool MoveNS(INDI_DIR_NS dir, TelescopeMotionCommand command) override;
82  virtual bool MoveWE(INDI_DIR_WE dir, TelescopeMotionCommand command) override;
83 
84  // Abort ALL motion
85  virtual bool Abort() override;
86 
87  // Time and Location
88  virtual bool updateTime(ln_date *utc, double utc_offset) override;
89  virtual bool updateLocation(double latitude, double longitude, double elevation) override;
90 
91  // Guide Commands
92  virtual IPState GuideNorth(uint32_t ms) override;
93  virtual IPState GuideSouth(uint32_t ms) override;
94  virtual IPState GuideEast(uint32_t ms) override;
95  virtual IPState GuideWest(uint32_t ms) override;
96 
97  // Guide Pulse Commands
98  virtual int SendPulseCmd(int8_t direction, uint32_t duration_msec);
99 
100  // Goto
101  virtual bool Goto(double ra, double dec) override;
102 
103  // Is slew over?
104  virtual bool isSlewComplete();
105 
106  // Park Mount
107  virtual bool Park() override;
108 
109  // Sync coordinates
110  virtual bool Sync(double ra, double dec) override;
111 
112  // Check if mount is responsive
113  virtual bool checkConnection();
114 
115  // Save properties in config file
116  virtual bool saveConfigItems(FILE *fp) override;
117 
118  // Action to perform when Debug is turned on or off
119  virtual void debugTriggered(bool enable) override;
120 
121  // Initial function to get data after connection is successful
122  virtual void getBasicData();
123 
124  // Get local calender date (NOT UTC) from mount. Expected format is YYYY-MM-DD
125  virtual bool getLocalDate(char *dateString);
126  virtual bool setLocalDate(uint8_t days, uint8_t months, uint16_t years);
127 
128  // Get Local time in 24 hour format from mount. Expected format is HH:MM:SS
129  virtual bool getLocalTime(char *timeString);
130  virtual bool setLocalTime24(uint8_t hour, uint8_t minute, uint8_t second);
131 
132  // Return UTC Offset from mount in hours.
133  virtual bool setUTCOffset(double offset);
134  virtual bool getUTFOffset(double * offset);
135 
136  // Send slew error message to client
137  virtual void slewError(int slewCode);
138 
139  // Get mount alignment type (AltAz..etc)
140  void getAlignment();
141 
142  // Send Mount time and location settings to client
143  virtual bool sendScopeTime();
144  virtual bool sendScopeLocation();
145 
146  // Update slew rate if different than current
147  bool updateSlewRate(int index);
148 
149  // Simulate Mount in simulation mode
150  void mountSim();
151 
152  // Focus functions
153  static void updateFocusHelper(void *p);
154  virtual bool AbortFocuser () override;
155  virtual bool ReverseFocuser(bool enabled) override;
156  virtual IPState MoveFocuser(FocusDirection dir, int speed, uint16_t duration) override;
157  virtual bool SetFocuserSpeed(int speed) override;
158 
159  static void guideTimeoutHelperNS(void *p);
160  static void guideTimeoutHelperWE(void *p);
161  void guideTimeoutNS();
162  void guideTimeoutWE();
163 
164  int GuideNSTID { -1 };
165  int GuideWETID { -1 };
166  int8_t guide_direction_ns { -1 };
167  int8_t guide_direction_we { -1 };
168 
169  int timeFormat = -1;
170  int currentSiteNum {0};
171  int trackingMode {0};
172 
174  uint8_t DBG_SCOPE {0};
175 
176  double JD {0};
177  double targetRA {0}, targetDEC {0};
178  double currentRA {0.0000001}, currentDEC {0.0000001};
180 
181  /* Telescope Alignment Mode */
184 
185  /* Tracking Frequency */
188 
189  /* Use pulse-guide commands */
192  bool usePulseCommand { false };
193 
194  /* Site Management */
197 
198  /* Site Name */
201 
202  /* Focus Mode */
205 
206  uint32_t genericCapability {0};
207 };
208 
209 #endif // LX200TELESCOPE_H
Provides interface to implement focuser functionality.
virtual bool initProperties() override
Called to initialize basic properties required all the time.
ISwitch UsePulseCmdS[2]
virtual bool Sync(double ra, double dec) override
Set the telescope current RA and DEC coordinates to the supplied RA and DEC coordinates.
uint32_t genericCapability
ISwitch FocusModeS[3]
int8_t guide_direction_we
static void guideTimeoutHelperNS(void *p)
INumber TrackFreqN[1]
virtual IPState GuideWest(uint32_t ms) override
Guide west for ms milliseconds. West is defined as RA-.
ITextVectorProperty SiteNameTP
virtual void slewError(int slewCode)
bool updateSlewRate(int index)
virtual bool SetSlewRate(int index) override
SetSlewRate Set desired slew rate index.
static void updateFocusHelper(void *p)
virtual bool getLocalDate(char *dateString)
virtual bool Park() override
Park the telescope to its home position.
virtual bool updateTime(ln_date *utc, double utc_offset) override
Update telescope time, date, and UTC offset.
virtual bool ISNewNumber(const char *dev, const char *name, double values[], char *names[], int n) override
Process the client newNumber command.
ISwitchVectorProperty AlignmentSP
virtual bool MoveNS(INDI_DIR_NS dir, TelescopeMotionCommand command) override
Start or Stop the telescope motion in the direction dir.
virtual IPState GuideSouth(uint32_t ms) override
Guide south for ms milliseconds. South is defined as DEC-.
virtual bool getUTFOffset(double *offset)
virtual bool sendScopeLocation()
bool sendLocationOnStartup
virtual bool updateLocation(double latitude, double longitude, double elevation) override
Update telescope location settings.
virtual bool isSlewComplete()
virtual bool Abort() override
Abort any telescope motion including tracking if possible.
virtual bool updateProperties() override
Called when connected state changes, to add/remove properties.
virtual const char * getDefaultName() override
static void guideTimeoutHelperWE(void *p)
virtual bool ReadScopeStatus() override
Read telescope status.
ISwitchVectorProperty FocusModeSP
virtual bool getLocalTime(char *timeString)
virtual bool saveConfigItems(FILE *fp) override
saveConfigItems Save specific properties in the provide config file handler. Child class usually over...
virtual bool MoveWE(INDI_DIR_WE dir, TelescopeMotionCommand command) override
Move the telescope in the direction dir.
uint32_t getLX200Capability() const
INumberVectorProperty TrackFreqNP
virtual void ISGetProperties(const char *dev) override
define the driver's properties to the client. Usually, only a minimum set of properties are defined t...
virtual void debugTriggered(bool enable) override
Inform driver that the debug option was triggered. This function is called after setDebug is triggere...
virtual bool ReverseFocuser(bool enabled) override
ReverseFocuser Reverse focuser motion direction.
@ LX200_HAS_PRECISE_TRACKING_FREQ
virtual bool ISNewText(const char *dev, const char *name, char *texts[], char *names[], int n) override
Process the client newSwitch command.
virtual bool checkConnection()
virtual bool ISNewSwitch(const char *dev, const char *name, ISState *states, char *names[], int n) override
Process the client newSwitch command.
virtual bool sendScopeTime()
virtual bool setLocalDate(uint8_t days, uint8_t months, uint16_t years)
virtual bool setLocalTime24(uint8_t hour, uint8_t minute, uint8_t second)
virtual bool AbortFocuser() override
AbortFocuser all focus motion.
ISwitch SiteS[4]
virtual IPState GuideEast(uint32_t ms) override
Guide east for ms milliseconds. East is defined as RA+.
virtual void getBasicData()
virtual bool Goto(double ra, double dec) override
Move the scope to the supplied RA and DEC coordinates.
virtual bool setUTCOffset(double offset)
IText SiteNameT[1]
ISwitch AlignmentS[3]
virtual bool SetTrackMode(uint8_t mode) override
SetTrackMode Set active tracking mode. Do not change track state.
virtual IPState GuideNorth(uint32_t ms) override
Guide north for ms milliseconds. North is defined as DEC+.
void setLX200Capability(uint32_t cap)
virtual IPState MoveFocuser(FocusDirection dir, int speed, uint16_t duration) override
MoveFocuser the focuser in a particular direction with a specific speed for a finite duration.
virtual bool SetFocuserSpeed(int speed) override
SetFocuserSpeed Set Focuser speed.
virtual bool Handshake() override
perform handshake with device to check communication
virtual int SendPulseCmd(int8_t direction, uint32_t duration_msec)
ISwitchVectorProperty SiteSP
virtual const char * getDriverName() override
int8_t guide_direction_ns
enum LX200Telescope::@186 LX200Capability
ISwitchVectorProperty UsePulseCmdSP
double ra
double dec
ISState
Switch state.
Definition: indiapi.h:150
IPState
Property state.
Definition: indiapi.h:160
INDI_DIR_WE
Definition: indibasetypes.h:55
INDI_DIR_NS
Definition: indibasetypes.h:48
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