Instrument Neutral Distributed Interface INDI 2.2.5
lx200_TeenAstro.h
Go to the documentation of this file.
1/*
2 LX200_TeenAstro
3
4 Based on LX200_OnStep and others
5 François Desvallées https://github.com/fdesvallees
6
7 Copyright (C) 2005 Jasem Mutlaq ([email protected])
8
9 This library is free software; you can redistribute it and/or
10 modify it under the terms of the GNU Lesser General Public
11 License as published by the Free Software Foundation; either
12 version 2.1 of the License, or (at your option) any later version.
13
14 This library is distributed in the hope that it will be useful,
15 but WITHOUT ANY WARRANTY; without even the implied warranty of
16 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17 Lesser General Public License for more details.
18
19 You should have received a copy of the GNU Lesser General Public
20 License along with this library; if not, write to the Free Software
21 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
22
23*/
24
25#pragma once
26
27#include "indiguiderinterface.h"
28#include "inditelescope.h"
29#include "lx200driver.h"
30#include "indicom.h"
31
32#define RB_MAX_LEN 64
33#define INITIAL_GUIDE_RATE 0.50
34
36{
37 public:
39 ~LX200_TeenAstro() override = default;
40
41 virtual const char *getDefaultName() override;
42 virtual const char *getDriverName() override;
43 virtual bool Handshake() override;
44 virtual bool ReadScopeStatus() override;
45 virtual void ISGetProperties(const char *dev) override;
46 virtual bool initProperties() override;
47 virtual bool updateProperties() override;
48
49 virtual bool ISNewNumber(const char *dev, const char *name, double values[], char *names[], int n) override;
50 virtual bool ISNewSwitch(const char *dev, const char *name, ISState *states, char *names[], int n) override;
51 virtual bool ISNewText(const char *dev, const char *name, char *texts[], char *names[], int n) override;
52
53 protected:
54 virtual bool MoveNS(INDI_DIR_NS dir, TelescopeMotionCommand command) override;
55 virtual bool MoveWE(INDI_DIR_WE dir, TelescopeMotionCommand command) override;
56 virtual bool Abort() override;
57 virtual bool Goto(double, double) override;
58 virtual bool Sync(double ra, double dec) override;
59 virtual void getBasicData(); // Initial function to get data after connection is successful
60 virtual bool Park() override;
61 virtual bool UnPark() override;
62 virtual bool SetCurrentPark() override;
63 virtual bool SetTrackEnabled(bool enabled) override;
64 virtual bool updateLocation(double latitude, double longitude, double elevation) override;
65 virtual void debugTriggered(bool enable) override;
66 virtual bool SetTrackMode(uint8_t mode) override;
67 //GUIDE: guiding functions
68 virtual IPState GuideNorth(uint32_t ms) override;
69 virtual IPState GuideSouth(uint32_t ms) override;
70 virtual IPState GuideEast(uint32_t ms) override;
71 virtual IPState GuideWest(uint32_t ms) override;
72 virtual bool saveConfigItems(FILE *fp) override;
73
74
75 private:
76 bool Move(TDirection dir, TelescopeMotionCommand command);
77 bool selectSlewRate(int index);
78 bool isSlewComplete();
79 void slewError(int slewCode);
80 void mountSim();
81 bool SetGuideRate(float);
82
83 bool getLocalDate(char *dateString);
84 bool setLocalDate(uint8_t days, uint8_t months, uint16_t years);
85
86 bool getSiteIndex(int *ndxP);
87 bool getSlewRate(int *srP);
88 bool setSite(int ndx); // used instead of selectSite from lx200 driver
89 bool getSiteElevation(int *elevationP);
90 bool setSiteElevation(double elevation);
91 bool getLocation(void); // read sites from TeenAstro
92
93 // Get Local time in 24 hour format from mount. Expected format is HH:MM:SS
94 bool getLocalTime(char *timeString);
95 bool setLocalTime24(uint8_t hour, uint8_t minute, uint8_t second);
96
97 // Return UTC Offset from mount in hours.
98 bool setUTCOffset(double offset);
99 bool getUTFOffset(double * offset);
100
101 void handleStatusChange(void);
102 void SendPulseCmd(int8_t direction, uint32_t duration_msec);
103 void sendCommand(const char *cmd);
104 void updateMountStatus(char);
105 void updateSlewRate(void);
106
107 // Send Mount time and location settings to client
108 bool sendScopeTime();
109 bool sendScopeLocation();
110
111 void guideTimeoutNS();
112 void guideTimeoutWE();
113
114 static void guideTimeoutHelperNS(void * p);
115 static void guideTimeoutHelperWE(void * p);
116
117 // User interface
118
119 INumber SlewAccuracyN[2];
120 INumberVectorProperty SlewAccuracyNP;
121
122 ISwitchVectorProperty HomePauseSP;
123 ISwitch HomePauseS[3];
124
125 ISwitchVectorProperty SetHomeSP;
126 ISwitch SetHomeS[2];
127
128 ITextVectorProperty VersionTP;
129 IText VersionT[5] {};
130
131 ISwitch SlewRateS[5];
132 ISwitchVectorProperty SlewRateSP;
133
134 INumber GuideRateN[1];
135 INumberVectorProperty GuideRateNP;
136
137 ISwitch TATrackModeS[3];
138 ISwitchVectorProperty TATrackModeSP;
139
140 // Site Management
142 ISwitch SiteS[4];
143 int currentSiteNum {0}; // on TeenAstro, sites are numbered 0 to 3, not 1 to 4 like on the Meade standard
144
145 // Site Name
146 ITextVectorProperty SiteNameTP;
147 IText SiteNameT[1] {};
148
149 // Error Status
150 ITextVectorProperty ErrorStatusTP;
151 IText ErrorStatusT[1] {};
152
153 double targetRA = 0, targetDEC = 0;
154 double currentRA = 0, currentDEC = 0;
155 uint32_t DBG_SCOPE = 0;
156 char OSStat[RB_MAX_LEN];
157 char OldOSStat[RB_MAX_LEN];
158 const char *statusCommand; // :GU# for version 1.1, :GXI# for 1.2 and later
159 const char *guideSpeedCommand; // :SXR0
160
161 int GuideNSTID { -1 };
162 int GuideWETID { -1 };
163
164};
virtual const char * getDriverName() override
virtual bool Goto(double, double) override
Move the scope to the supplied RA and DEC coordinates.
virtual bool SetTrackEnabled(bool enabled) override
SetTrackEnabled Engages or disengages mount tracking. If there are no tracking modes available,...
virtual bool MoveNS(INDI_DIR_NS dir, TelescopeMotionCommand command) override
Start or Stop the telescope motion in the direction dir.
virtual bool saveConfigItems(FILE *fp) override
saveConfigItems Save specific properties in the provide config file handler. Child class usually over...
virtual IPState GuideSouth(uint32_t ms) override
Guide south for ms milliseconds. South is defined as DEC-.
virtual IPState GuideWest(uint32_t ms) override
Guide west for ms milliseconds. West is defined as RA-.
virtual bool SetCurrentPark() override
SetCurrentPark Set current coordinates/encoders value as the desired parking position.
~LX200_TeenAstro() override=default
virtual bool SetTrackMode(uint8_t mode) override
SetTrackMode Set active tracking mode. Do not change track state.
virtual void debugTriggered(bool enable) override
Inform driver that the debug option was triggered. This function is called after setDebug is triggere...
virtual bool Sync(double ra, double dec) override
Set the telescope current RA and DEC coordinates to the supplied RA and DEC coordinates.
virtual bool ISNewSwitch(const char *dev, const char *name, ISState *states, char *names[], int n) override
Process the client newSwitch command.
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 bool Handshake() override
perform handshake with device to check communication
virtual IPState GuideEast(uint32_t ms) override
Guide east for ms milliseconds. East is defined as RA+.
virtual const char * getDefaultName() override
virtual bool updateLocation(double latitude, double longitude, double elevation) override
Update telescope location settings.
virtual bool initProperties() override
Called to initialize basic properties required all the time.
virtual bool ReadScopeStatus() override
Read telescope status.
virtual bool UnPark() override
Unpark the telescope if already parked.
virtual bool Park() override
Park the telescope to its home position.
virtual bool ISNewNumber(const char *dev, const char *name, double values[], char *names[], int n) override
Process the client newNumber command.
virtual bool ISNewText(const char *dev, const char *name, char *texts[], char *names[], int n) override
Process the client newSwitch command.
virtual void getBasicData()
virtual bool MoveWE(INDI_DIR_WE dir, TelescopeMotionCommand command) override
Move the telescope in the direction dir.
virtual bool updateProperties() override
Called when connected state changes, to add/remove properties.
virtual bool Abort() override
Abort any telescope motion including tracking if possible.
virtual IPState GuideNorth(uint32_t ms) override
Guide north for ms milliseconds. North is defined as DEC+.
double ra
double dec
ISState
Switch state.
Definition indiapi.h:148
IPState
Property state.
Definition indiapi.h:158
INDI_DIR_WE
INDI_DIR_NS
Implementations for common driver routines.
#define RB_MAX_LEN
TDirection
Definition lx200driver.h:40
uint8_t cmd[4]
Definition pwc-ioctl.h:2
One number descriptor.
One switch descriptor.
One text descriptor.
Number vector property descriptor.
Definition indiapi.h:317
Switch vector property descriptor.
Definition indiapi.h:365
Text vector property descriptor.
Definition indiapi.h:244