Instrument Neutral Distributed Interface INDI  2.0.2
lx200ap_v2.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 /***********************************************************************
26  * This file was copied an modified from lx200ap.h in Jan 2022.
27  *
28  * This is an update of the Wildi and Fulbright A-P drivers.
29  * It is currently being tested.
30  * You should not use this unless part of the test group.
31 ***********************************************************************/
32 
33 #include "lx200generic.h"
34 #include "lx200apdriver.h"
35 
36 #define MOUNTNOTINITIALIZED 0
37 #define MOUNTINITIALIZED 1
38 
40 {
41  public:
43 
49  // This is shared by ParkFrom and ParkTo, and should be coordinated with those.
50  typedef enum { PARK_LAST = 0, PARK_CUSTOM = 0, PARK_PARK1 = 1, PARK_PARK2 = 2, PARK_PARK3 = 3, PARK_PARK4 = 4, PARK_CURRENT = 5} ParkPosition;
51  virtual bool ISNewNumber(const char *dev, const char *name, double values[], char *names[], int n) override;
52  virtual bool ISNewSwitch(const char *dev, const char *name, ISState *states, char *names[], int n) override;
53  virtual void ISGetProperties(const char *dev) override;
54 
55  protected:
56 
57  virtual const char *getDefaultName() override;
58  virtual bool initProperties() override;
59  virtual bool updateProperties() override;
60 
61  virtual bool ReadScopeStatus() override;
62  virtual bool Handshake() override;
63  virtual bool Disconnect() override;
64  virtual bool Connect() override;
65 
66  // Parking
67  virtual bool SetCurrentPark() override;
68  virtual bool SetDefaultPark() override;
69  virtual bool Park() override;
70  virtual bool UnPark() override;
71 
72  virtual bool Sync(double ra, double dec) override;
73  virtual bool Goto(double, double) override;
74  virtual bool updateTime(ln_date *utc, double utc_offset) override;
75  virtual bool updateLocation(double latitude, double longitude, double elevation) override;
76  virtual bool SetSlewRate(int index) override;
77 
78  // Guide Commands
79  virtual IPState GuideNorth(uint32_t ms) override;
80  virtual IPState GuideSouth(uint32_t ms) override;
81  virtual IPState GuideEast(uint32_t ms) override;
82  virtual IPState GuideWest(uint32_t ms) override;
83  virtual int SendPulseCmd(int8_t direction, uint32_t duration_msec) override;
84  virtual bool GuideNS(INDI_DIR_NS dir, TelescopeMotionCommand command);
85  virtual bool GuideWE(INDI_DIR_WE dir, TelescopeMotionCommand command);
86 
87  // Pulse Guide specific to AstroPhysics
88  static void pulseGuideTimeoutHelperWE(void * p);
89  static void pulseGuideTimeoutHelperNS(void * p);
90  static void simulGuideTimeoutHelperWE(void * p);
91  static void simulGuideTimeoutHelperNS(void * p);
92  void AstroPhysicsGuideTimeoutWE(bool simul);
93  void AstroPhysicsGuideTimeoutNS(bool simul);
94 
95  virtual bool getUTFOffset(double *offset) override;
96  // Tracking
97  virtual bool SetTrackMode(uint8_t mode) override;
98  virtual bool SetTrackEnabled(bool enabled) override;
99  virtual bool SetTrackRate(double raRate, double deRate) override;
100 
101  // NSWE Motion Commands
102  virtual bool MoveNS(INDI_DIR_NS dir, TelescopeMotionCommand command) override;
103  virtual bool MoveWE(INDI_DIR_WE dir, TelescopeMotionCommand command) override;
104 
105  virtual bool saveConfigItems(FILE *fp) override;
106 
107  virtual void debugTriggered(bool enable) override;
108 
110 
113 
118 
121 
124 
127 
131 
134 
137 
140 
143 
146 
149 
152  bool homeAndReSyncEnabled { false };
154 
157 
160 
163 
166 
167  private:
168  bool ApInitialize();
169  void initRateLabels();
170  bool updateAPLocation(double latitude, double longitude, double elevation);
171  bool parkInternal();
172  bool isAPReady();
173  void setMajorMinorVersions(char *version);
174 
175  // Side of pier
176  void syncSideOfPier();
177 
178  bool IsMountParked(bool *isParked);
179  bool getFirmwareVersion(void);
180  bool calcParkPosition(ParkPosition pos, double *parkAlt, double *parkAz);
181  void disclaimerMessage(void);
182  bool getWormPosition(void);
183  bool getPECState(const char *statusString);
184  void processMountStatus(const char *statusString);
185  bool APSync(double ra, double dec, bool recalibrate = true);
186 
187  ControllerVersion firmwareVersion = MCV_UNKNOWN;
188  ServoVersion servoType = GTOCP_UNKNOWN;
189  int majorVersion;
190  int minorVersion;
191 
192 
193  double currentAlt = 0, currentAz = 0;
194  double lastRA = 0, lastDE = 0;
195  double lastAZ = 0, lastAL = 0;
196 
197  int rememberSlewRate = { -1 };
198 
199  bool apIsInitialized = false;
200  bool apLocationInitialized = false;
201  bool apTimeInitialized = false;
202  bool apInitializationChecked = false;
203 
204 };
bool isParked()
isParked is mount currently parked?
TelescopePECState getPECState()
virtual bool ISNewSwitch(const char *dev, const char *name, ISState *states, char *names[], int n) override
Process the client newSwitch command.
Definition: lx200ap_v2.cpp:732
virtual bool initProperties() override
Called to initialize basic properties required all the time.
Definition: lx200ap_v2.cpp:105
ITextVectorProperty APMountStatusTP
Definition: lx200ap_v2.h:162
ISwitch ParkToS[6]
Definition: lx200ap_v2.h:138
virtual bool SetCurrentPark() override
SetCurrentPark Set current coordinates/encoders value as the desired parking position.
ISwitchVectorProperty APSlewSpeedSP
Definition: lx200ap_v2.h:123
virtual IPState GuideNorth(uint32_t ms) override
Guide north for ms milliseconds. North is defined as DEC+.
INumber HorizontalCoordsN[2]
Definition: lx200ap_v2.h:119
virtual bool MoveWE(INDI_DIR_WE dir, TelescopeMotionCommand command) override
Move the telescope in the direction dir.
ISwitch UnparkFromS[5]
Definition: lx200ap_v2.h:135
virtual bool Handshake() override
perform handshake with device to check communication
ISwitch SyncCMRS[2]
Definition: lx200ap_v2.h:128
virtual IPState GuideWest(uint32_t ms) override
Guide west for ms milliseconds. West is defined as RA-.
INumberVectorProperty HourangleCoordsNP
Definition: lx200ap_v2.h:115
ISwitchVectorProperty ParkToSP
Definition: lx200ap_v2.h:139
ISwitch APSlewSpeedS[3]
Definition: lx200ap_v2.h:122
void AstroPhysicsGuideTimeoutNS(bool simul)
ITextVectorProperty APPECStateTP
Definition: lx200ap_v2.h:159
ITextVectorProperty VersionTP
Definition: lx200ap_v2.h:145
ISwitch APPECRecordS[2]
Definition: lx200ap_v2.h:165
INumberVectorProperty HorizontalCoordsNP
Definition: lx200ap_v2.h:120
virtual bool GuideNS(INDI_DIR_NS dir, TelescopeMotionCommand command)
ISwitch HomeAndReSyncS[1]
Definition: lx200ap_v2.h:151
virtual bool Park() override
Park the telescope to its home position.
virtual bool SetTrackMode(uint8_t mode) override
SetTrackMode Set active tracking mode. Do not change track state.
virtual bool updateProperties() override
Called when connected state changes, to add/remove properties.
Definition: lx200ap_v2.cpp:293
virtual bool SetTrackEnabled(bool enabled) override
SetTrackEnabled Engages or disengages mount tracking. If there are no tracking modes available,...
virtual void debugTriggered(bool enable) override
Inform driver that the debug option was triggered. This function is called after setDebug is triggere...
virtual bool UnPark() override
Unpark the telescope if already parked.
virtual bool updateLocation(double latitude, double longitude, double elevation) override
Update telescope location settings.
static void pulseGuideTimeoutHelperWE(void *p)
INumberVectorProperty APSiderealTimeNP
Definition: lx200ap_v2.h:117
virtual bool getUTFOffset(double *offset) override
INumberVectorProperty APUTCOffsetNP
Definition: lx200ap_v2.h:141
INumber APSiderealTimeN[1]
Definition: lx200ap_v2.h:116
INumber APUTCOffsetN[1]
Definition: lx200ap_v2.h:142
ISwitch SwapS[2]
Definition: lx200ap_v2.h:125
virtual bool Sync(double ra, double dec) override
Set the telescope current RA and DEC coordinates to the supplied RA and DEC coordinates.
static void pulseGuideTimeoutHelperNS(void *p)
ISwitch APGuideSpeedS[3]
Definition: lx200ap_v2.h:132
virtual int SendPulseCmd(int8_t direction, uint32_t duration_msec) override
virtual bool Goto(double, double) override
Move the scope to the supplied RA and DEC coordinates.
ISwitchVectorProperty SwapSP
Definition: lx200ap_v2.h:126
virtual bool ISNewNumber(const char *dev, const char *name, double values[], char *names[], int n) override
Process the client newNumber command.
Definition: lx200ap_v2.cpp:552
virtual IPState GuideEast(uint32_t ms) override
Guide east for ms milliseconds. East is defined as RA+.
ISwitchVectorProperty APGuideSpeedSP
Definition: lx200ap_v2.h:133
IText APMountStatusT[1]
Definition: lx200ap_v2.h:161
virtual bool SetDefaultPark() override
SetDefaultPark Set default coordinates/encoders value as the desired parking position.
virtual bool SetTrackRate(double raRate, double deRate) override
SetTrackRate Set custom tracking rates.
static void simulGuideTimeoutHelperNS(void *p)
ISwitchVectorProperty ManualSetParkedSP
Definition: lx200ap_v2.h:147
ISwitch StartUpS[2]
Definition: lx200ap_v2.h:111
virtual bool saveConfigItems(FILE *fp) override
saveConfigItems Save specific properties in the provide config file handler. Child class usually over...
ISwitchVectorProperty StartUpSP
Definition: lx200ap_v2.h:112
virtual IPState GuideSouth(uint32_t ms) override
Guide south for ms milliseconds. South is defined as DEC-.
APRateTableState rateTable
Definition: lx200ap_v2.h:153
ISwitchVectorProperty APPECRecordSP
Definition: lx200ap_v2.h:164
ISwitchVectorProperty SyncCMRSP
Definition: lx200ap_v2.h:129
ISwitchVectorProperty UnparkFromSP
Definition: lx200ap_v2.h:136
virtual bool ReadScopeStatus() override
Read telescope status.
Definition: lx200ap_v2.cpp:991
ISwitchVectorProperty HomeAndReSyncSP
Definition: lx200ap_v2.h:150
IText APPECStateT[1]
Definition: lx200ap_v2.h:158
virtual bool Disconnect() override
Disconnect from device.
void AstroPhysicsGuideTimeoutWE(bool simul)
void handleGTOCP2MotionBug()
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_v2.cpp:266
virtual bool SetSlewRate(int index) override
SetSlewRate Set desired slew rate index.
INumber HourangleCoordsN[2]
Definition: lx200ap_v2.h:114
INumberVectorProperty APWormPositionNP
Definition: lx200ap_v2.h:156
virtual bool Connect() override
Connect to the device. INDI::DefaultDevice implementation connects to appropriate connection interfac...
Definition: lx200ap_v2.cpp:90
virtual bool GuideWE(INDI_DIR_WE dir, TelescopeMotionCommand command)
virtual bool updateTime(ln_date *utc, double utc_offset) override
Update telescope time, date, and UTC offset.
static void simulGuideTimeoutHelperWE(void *p)
virtual bool MoveNS(INDI_DIR_NS dir, TelescopeMotionCommand command) override
Start or Stop the telescope motion in the direction dir.
ISwitch ManualSetParkedS[1]
Definition: lx200ap_v2.h:148
INumber APWormPositionN[1]
Definition: lx200ap_v2.h:155
virtual const char * getDefaultName() override
Definition: lx200ap_v2.cpp:85
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
APRateTableState
Definition: lx200apdriver.h:58
@ AP_RATE_TABLE_DEFAULT
Definition: lx200apdriver.h:63
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