Instrument Neutral Distributed Interface INDI  2.0.2
lx200ap.h
Go to the documentation of this file.
1 /*
2  Astro-Physics INDI driver
3 
4  Copyright (C) 2014 Jasem Mutlaq
5 
6  Based on INDI Astrophysics Driver by Markus Wildi
7 
8  This library is free software; you can redistribute it and/or
9  modify it under the terms of the GNU Lesser General Public
10  License as published by the Free Software Foundation; either
11  version 2.1 of the License, or (at your option) any later version.
12 
13  This library is distributed in the hope that it will be useful,
14  but WITHOUT ANY WARRANTY; without even the implied warranty of
15  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16  Lesser General Public License for more details.
17 
18  You should have received a copy of the GNU Lesser General Public
19  License along with this library; if not, write to the Free Software
20  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
21 */
22 
23 #pragma once
24 
25 #include "lx200generic.h"
26 #define MOUNTNOTINITIALIZED 0
27 #define MOUNTINITIALIZED 1
28 
30 {
31  public:
33 
39  typedef enum { PARK_LAST = 0, PARK_CUSTOM = 0, PARK_PARK1 = 1, PARK_PARK2 = 2, PARK_PARK3 = 3, PARK_PARK4 = 4} ParkPosition;
41  virtual bool ISNewNumber(const char *dev, const char *name, double values[], char *names[], int n) override;
42  virtual bool ISNewSwitch(const char *dev, const char *name, ISState *states, char *names[], int n) override;
43  virtual void ISGetProperties(const char *dev) override;
44 
45  protected:
46 
47  virtual const char *getDefaultName() override;
48  virtual bool initProperties() override;
49  virtual bool updateProperties() override;
50 
51  virtual bool ReadScopeStatus() override;
52  virtual bool Handshake() override;
53  virtual bool Disconnect() override;
54  virtual bool Connect() override;
55 
56  // Parking
57  virtual bool SetCurrentPark() override;
58  virtual bool SetDefaultPark() override;
59  virtual bool Park() override;
60  virtual bool UnPark() override;
61 
62  virtual bool Sync(double ra, double dec) override;
63  virtual bool Goto(double, double) override;
64  virtual bool updateTime(ln_date *utc, double utc_offset) override;
65  virtual bool updateLocation(double latitude, double longitude, double elevation) override;
66  virtual bool SetSlewRate(int index) override;
67  bool updateAPSlewRate(int index);
68 
69  // Guide Commands
70  virtual IPState GuideNorth(uint32_t ms) override;
71  virtual IPState GuideSouth(uint32_t ms) override;
72  virtual IPState GuideEast(uint32_t ms) override;
73  virtual IPState GuideWest(uint32_t ms) override;
74  virtual int SendPulseCmd(int8_t direction, uint32_t duration_msec) override;
75  virtual bool GuideNS(INDI_DIR_NS dir, TelescopeMotionCommand command);
76  virtual bool GuideWE(INDI_DIR_WE dir, TelescopeMotionCommand command);
77 
78  // Pulse Guide specific to AstroPhysics
79  static void pulseGuideTimeoutHelperWE(void * p);
80  static void pulseGuideTimeoutHelperNS(void * p);
81  static void simulGuideTimeoutHelperWE(void * p);
82  static void simulGuideTimeoutHelperNS(void * p);
83  void AstroPhysicsGuideTimeoutWE(bool simul);
84  void AstroPhysicsGuideTimeoutNS(bool simul);
85 
86  virtual bool getUTFOffset(double *offset) override;
87  // Tracking
88  virtual bool SetTrackMode(uint8_t mode) override;
89  virtual bool SetTrackEnabled(bool enabled) override;
90  virtual bool SetTrackRate(double raRate, double deRate) override;
91 
92  // NSWE Motion Commands
93  virtual bool MoveNS(INDI_DIR_NS dir, TelescopeMotionCommand command) override;
94  virtual bool MoveWE(INDI_DIR_WE dir, TelescopeMotionCommand command) override;
95 
96  virtual bool saveConfigItems(FILE *fp) override;
97 
98  virtual void debugTriggered(bool enable) override;
99 
101 
104 
109 
112 
115 
118 
122 
125 
128 
131 
134 
137 
138  private:
139 #ifdef no
140  bool initMount();
141 #endif
142 
143  // Side of pier
144  void syncSideOfPier();
145 #ifdef no
146  bool IsMountInitialized(bool *initialized);
147 #endif
148  bool IsMountParked(bool *isParked);
149  bool getMountStatus(bool *isParked);
150  bool getFirmwareVersion(void);
151  bool calcParkPosition(ParkPosition pos, double *parkAlt, double *parkAz);
152  void disclaimerMessage(void);
153 
154  //bool timeUpdated=false, locationUpdated=false;
155  ControllerVersion firmwareVersion = MCV_UNKNOWN;
156  ServoVersion servoType = GTOCP_UNKNOWN;
157 
158  double currentAlt = 0, currentAz = 0;
159  double lastRA = 0, lastDE = 0;
160  double lastAZ = 0, lastAL = 0;
161 
162  //int GuideNSTID;
163  //int GuideWETID;
164 
165  //bool motionCommanded=false; // 2020-05-24, wildi, never reset
166  //bool mountInitialized=false;
167  int rememberSlewRate = { -1 };
168  uint8_t initStatus = MOUNTNOTINITIALIZED;
169 };
bool isParked()
isParked is mount currently parked?
virtual bool initProperties() override
Called to initialize basic properties required all the time.
Definition: lx200ap.cpp:79
ISwitchVectorProperty StartUpSP
Definition: lx200ap.h:103
ISwitchVectorProperty APSlewSpeedSP
Definition: lx200ap.h:114
virtual bool UnPark() override
Unpark the telescope if already parked.
Definition: lx200ap.cpp:1867
ISwitchVectorProperty APGuideSpeedSP
Definition: lx200ap.h:124
ISwitch APSlewSpeedS[3]
Definition: lx200ap.h:113
virtual bool SetTrackMode(uint8_t mode) override
SetTrackMode Set active tracking mode. Do not change track state.
Definition: lx200ap.cpp:2162
virtual bool updateLocation(double latitude, double longitude, double elevation) override
Update telescope location settings.
Definition: lx200ap.cpp:1673
static void pulseGuideTimeoutHelperWE(void *p)
Definition: lx200ap.cpp:1413
virtual bool Connect() override
Connect to the device. INDI::DefaultDevice implementation connects to appropriate connection interfac...
Definition: lx200ap.cpp:66
virtual bool SetTrackEnabled(bool enabled) override
SetTrackEnabled Engages or disengages mount tracking. If there are no tracking modes available,...
Definition: lx200ap.cpp:2188
INumber APUTCOffsetN[1]
Definition: lx200ap.h:133
virtual bool Goto(double, double) override
Move the scope to the supplied RA and DEC coordinates.
Definition: lx200ap.cpp:1138
virtual bool SetTrackRate(double raRate, double deRate) override
SetTrackRate Set custom tracking rates.
Definition: lx200ap.cpp:2201
INumber HorizontalCoordsN[2]
Definition: lx200ap.h:110
ISwitchVectorProperty SwapSP
Definition: lx200ap.h:117
virtual IPState GuideWest(uint32_t ms) override
Guide west for ms milliseconds. West is defined as RA-.
Definition: lx200ap.cpp:1366
ISwitch APGuideSpeedS[3]
Definition: lx200ap.h:123
virtual bool Park() override
Park the telescope to its home position.
Definition: lx200ap.cpp:1740
void AstroPhysicsGuideTimeoutNS(bool simul)
Definition: lx200ap.cpp:1446
virtual const char * getDefaultName() override
Definition: lx200ap.cpp:61
virtual bool SetDefaultPark() override
SetDefaultPark Set default coordinates/encoders value as the desired parking position.
Definition: lx200ap.cpp:2095
ISwitch SwapS[2]
Definition: lx200ap.h:116
ISwitch SyncCMRS[2]
Definition: lx200ap.h:119
virtual bool Sync(double ra, double dec) override
Set the telescope current RA and DEC coordinates to the supplied RA and DEC coordinates.
Definition: lx200ap.cpp:1558
virtual IPState GuideEast(uint32_t ms) override
Guide east for ms milliseconds. East is defined as RA+.
Definition: lx200ap.cpp:1324
bool updateAPSlewRate(int index)
Definition: lx200ap.cpp:1213
IText VersionT[1]
Definition: lx200ap.h:135
ISwitchVectorProperty UnparkFromSP
Definition: lx200ap.h:127
virtual int SendPulseCmd(int8_t direction, uint32_t duration_msec) override
Definition: lx200ap.cpp:1464
ISwitch ParkToS[5]
Definition: lx200ap.h:129
static void simulGuideTimeoutHelperWE(void *p)
Definition: lx200ap.cpp:1423
void handleGTOCP2MotionBug()
static void pulseGuideTimeoutHelperNS(void *p)
Definition: lx200ap.cpp:1408
ITextVectorProperty VersionTP
Definition: lx200ap.h:136
ISwitch StartUpS[2]
Definition: lx200ap.h:102
virtual bool SetCurrentPark() override
SetCurrentPark Set current coordinates/encoders value as the desired parking position.
Definition: lx200ap.cpp:2074
virtual bool GuideNS(INDI_DIR_NS dir, TelescopeMotionCommand command)
Definition: lx200ap.cpp:2284
INumber APSiderealTimeN[1]
Definition: lx200ap.h:107
INumberVectorProperty APUTCOffsetNP
Definition: lx200ap.h:132
virtual bool Handshake() override
perform handshake with device to check communication
Definition: lx200ap.cpp:1469
INumberVectorProperty HorizontalCoordsNP
Definition: lx200ap.h:111
static void simulGuideTimeoutHelperNS(void *p)
Definition: lx200ap.cpp:1418
virtual IPState GuideSouth(uint32_t ms) override
Guide south for ms milliseconds. South is defined as DEC-.
Definition: lx200ap.cpp:1282
ISwitchVectorProperty ParkToSP
Definition: lx200ap.h:130
virtual bool GuideWE(INDI_DIR_WE dir, TelescopeMotionCommand command)
Definition: lx200ap.cpp:2297
virtual bool getUTFOffset(double *offset) override
Definition: lx200ap.cpp:2228
virtual bool Disconnect() override
Disconnect from device.
Definition: lx200ap.cpp:1544
virtual bool MoveWE(INDI_DIR_WE dir, TelescopeMotionCommand command) override
Move the telescope in the direction dir.
Definition: lx200ap.cpp:2262
INumberVectorProperty APSiderealTimeNP
Definition: lx200ap.h:108
virtual bool updateTime(ln_date *utc, double utc_offset) override
Update telescope time, date, and UTC offset.
Definition: lx200ap.cpp:1610
INumber HourangleCoordsN[2]
Definition: lx200ap.h:105
virtual bool updateProperties() override
Called when connected state changes, to add/remove properties.
Definition: lx200ap.cpp:203
virtual bool ISNewSwitch(const char *dev, const char *name, ISState *states, char *names[], int n) override
Process the client newSwitch command.
Definition: lx200ap.cpp:506
ISwitchVectorProperty SyncCMRSP
Definition: lx200ap.h:120
virtual IPState GuideNorth(uint32_t ms) override
Guide north for ms milliseconds. North is defined as DEC+.
Definition: lx200ap.cpp:1239
void AstroPhysicsGuideTimeoutWE(bool simul)
Definition: lx200ap.cpp:1428
virtual void debugTriggered(bool enable) override
Inform driver that the debug option was triggered. This function is called after setDebug is triggere...
Definition: lx200ap.cpp:1717
INumberVectorProperty HourangleCoordsNP
Definition: lx200ap.h:106
virtual bool ISNewNumber(const char *dev, const char *name, double values[], char *names[], int n) override
Process the client newNumber command.
Definition: lx200ap.cpp:446
virtual bool MoveNS(INDI_DIR_NS dir, TelescopeMotionCommand command) override
Start or Stop the telescope motion in the direction dir.
Definition: lx200ap.cpp:2239
ISwitch UnparkFromS[5]
Definition: lx200ap.h:126
virtual bool SetSlewRate(int index) override
SetSlewRate Set desired slew rate index.
Definition: lx200ap.cpp:1729
virtual bool saveConfigItems(FILE *fp) override
saveConfigItems Save specific properties in the provide config file handler. Child class usually over...
Definition: lx200ap.cpp:2148
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...
Definition: lx200ap.cpp:176
virtual bool ReadScopeStatus() override
Read telescope status.
Definition: lx200ap.cpp:850
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
#define MOUNTNOTINITIALIZED
Definition: lx200ap.h:26
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