Instrument Neutral Distributed Interface INDI 2.2.5
lx200_pegasus_nyx101.h
Go to the documentation of this file.
1/*******************************************************************************
2 Copyright(c) 2021 Chrysikos Efstathios. All rights reserved.
3
4 Pegasus NYX
5
6 This program is free software; you can redistribute it and/or modify it
7 under the terms of the GNU General Public License as published by the Free
8 Software Foundation; either version 2 of the License, or (at your option)
9 any later version.
10
11 This program is distributed in the hope that it will be useful, but WITHOUT
12 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
14 more details.
15
16 You should have received a copy of the GNU Library General Public License
17 along with this library; see the file COPYING.LIB. If not, write to
18 the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
19 Boston, MA 02110-1301, USA.
20
21 The full GNU General Public License is included in this distribution in the
22 file called LICENSE.
23*******************************************************************************/
24#pragma once
25
26#include "lx200generic.h"
27
28#include <chrono>
29//#define DEBUG_NYX
30
31
33{
34 public:
36 virtual bool updateProperties() override;
37 virtual bool initProperties() 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#ifdef DEBUG_NYX
41 virtual bool ISNewText(const char *dev, const char *name, char *texts[], char *names[], int n) override;
42
43 INDI::PropertyText DebugCommandTP {1};
44#endif
45
46 protected:
47 virtual bool ReadScopeStatus() override;
48 virtual bool Goto(double ra, double dec) override;
49 virtual const char *getDefaultName() override;
50 virtual bool Park() override;
51 virtual bool UnPark() override;
52 virtual bool SetCurrentPark() override;
53 virtual bool SetDefaultPark() override;
54 virtual bool updateLocation(double latitude, double longitude, double elevation) override;
55 virtual bool setUTCOffset(double offset) override;
56 virtual bool setLocalDate(uint8_t days, uint8_t months, uint16_t years) override;
57 virtual bool SetTrackEnabled(bool enabled) override;
58 virtual bool SetTrackMode(uint8_t mode) override;
59 virtual bool SetSlewRate(int index) override;
60 virtual bool SetMountType(TelescopeMountType type) override;
61
62 // Homing
63 virtual IPState ExecuteHomeAction(TelescopeHomeAction action) override;
64
65 private:
66 static constexpr const uint8_t SLEW_MODES {10};
67 static constexpr const uint8_t DRIVER_LEN {64};
68 static const char DRIVER_STOP_CHAR { 0x23 };
69 static constexpr const uint8_t DRIVER_TIMEOUT {3};
70 // Guide rates selected by :R0# to :R2#.
71 static constexpr double GUIDE_RATES[] {0.25, 0.50, 1.00};
72 // How long the mount may keep reporting parked after an unpark request.
73 static constexpr std::chrono::seconds UNPARK_TIMEOUT {10};
74
75 bool m_UnparkPending {false};
76 std::chrono::steady_clock::time_point m_UnparkRequested;
77 // How long the mount may take to report parking ('I') or slewing after :hP#.
78 static constexpr std::chrono::seconds PARK_START_TIMEOUT {10};
79 std::chrono::steady_clock::time_point m_ParkRequested;
80 // The first status after :MS# can still report no slew ('N'). A GoTo is complete once the mount
81 // reported slewing, or after this time if it never did (a short slew between two polls).
82 static constexpr std::chrono::seconds SLEW_START_TIMEOUT {3};
83 std::chrono::steady_clock::time_point m_SlewRequested;
84 bool m_SlewSeen {true};
85
86 enum RefractionState
87 {
88 REFRACT_ON,
89 REFRACT_OFF
90 };
91
92 enum SafetyLimits
93 {
94 SET_SAFETY_LIMIT,
95 CLEAR_SAFETY_LIMIT
96 };
97
98 enum NYXTelescopeTrackMode
99 {
100 TRACK_SIDEREAL,
101 TRACK_SOLAR,
102 TRACK_LUNAR,
103 TRACK_KING
104 };
105
106 enum ElevationNumber
107 {
108 OVERHEAD,
109 HORIZON
110 };
111
112 // Guide rate (x sidereal) in the standard GUIDE_RATE form. The NYX has one rate for both axes.
113 INDI::PropertyNumber GuideRateNP {2};
114 // INDI::PropertySwitch HomeSP {1};
115 // INDI::PropertySwitch ResetHomeSP {1};
116 INDI::PropertyText Report {1};
117 INDI::PropertySwitch VerboseReportSP {2};
118 INDI::PropertyText IsTracking {1};
119 INDI::PropertyText IsSlewCompleted {1};
120 INDI::PropertyText IsParked {1};
121 INDI::PropertyText IsParkginInProgress {1};
122 INDI::PropertyText IsAtHomePosition {1};
123 INDI::PropertyText MountAltAz {1};
124 INDI::PropertyText MountEquatorial {1};
125 INDI::PropertyText PierNone {1};
126 INDI::PropertyText PierEast {1};
127 INDI::PropertyText PierWest {1};
128 INDI::PropertyText DoesRefractionComp {1};
129 INDI::PropertyText WaitingAtHome {1};
130 INDI::PropertyText IsHomePaused {1};
131 INDI::PropertyText ParkFailed {1};
132 INDI::PropertyText SlewingHome {1};
133 INDI::PropertySwitch FlipSP {1};
134 INDI::PropertySwitch RebootSP {1};
135 INDI::PropertySwitch RefractSP {2};
136 INDI::PropertyNumber ElevationLimitNP {2};
137 INDI::PropertyNumber MeridianLimitNP {1};
138 INDI::PropertySwitch SafetyLimitSP {2};
139
140
141 bool sendCommand(const char * cmd, char * res = nullptr, int cmd_len = -1, int res_len = -1);
142 void hexDump(char * buf, const char * data, int size);
143 std::vector<std::string> split(const std::string &input, const std::string &regex);
144 bool goToPark();
145 bool goToUnPark();
146 bool setGuideRate(int rate);
147 static int nearestGuideRate(double rate);
148 void setGuideRateValue(int index);
149 bool verboseReport = false;
150 void SetPropertyText(INDI::PropertyText propertyTxt, IPState state);
151};
int SetSlewRate(void)
TelescopeMountType
Mount geometry reported in the standard TELESCOPE_MOUNT_TYPE property. The values are the indices of ...
virtual bool initProperties() override
Called to initialize basic properties required all the time.
virtual bool ISNewNumber(const char *dev, const char *name, double values[], char *names[], int n) override
Process the client newNumber command.
virtual bool SetCurrentPark() override
SetCurrentPark Set current coordinates/encoders value as the desired parking position.
virtual bool setUTCOffset(double offset) override
virtual bool SetDefaultPark() override
SetDefaultPark Set default coordinates/encoders value as the desired parking position.
virtual bool UnPark() override
Unpark the telescope if already parked.
virtual bool SetMountType(TelescopeMountType type) override
SetMountType Called when the user selects a different mount type in TELESCOPE_MOUNT_TYPE....
virtual bool setLocalDate(uint8_t days, uint8_t months, uint16_t years) override
virtual bool Goto(double ra, double dec) override
Move the scope to the supplied RA and DEC coordinates.
virtual bool SetTrackMode(uint8_t mode) override
SetTrackMode Set active tracking mode. Do not change track state.
virtual bool updateLocation(double latitude, double longitude, double elevation) override
Update telescope location settings.
virtual bool Park() override
Park the telescope to its home position.
virtual const char * getDefaultName() override
virtual bool SetTrackEnabled(bool enabled) override
SetTrackEnabled Engages or disengages mount tracking. If there are no tracking modes available,...
virtual bool updateProperties() override
Called when connected state changes, to add/remove properties.
virtual bool ReadScopeStatus() override
Read telescope status.
virtual bool ISNewSwitch(const char *dev, const char *name, ISState *states, char *names[], int n) override
Process the client newSwitch command.
virtual IPState ExecuteHomeAction(TelescopeHomeAction action) override
Execute a homing action.
virtual bool ISNewText(const char *dev, const char *name, char *texts[], char *names[], int n) override
Process the client newSwitch command.
double ra
double dec
ISState
Switch state.
Definition indiapi.h:148
IPState
Property state.
Definition indiapi.h:158
*brief user defined string literal for JSON values *sa std::size_t n
uint16_t type
Definition pwc-ioctl.h:0
uint8_t cmd[4]
Definition pwc-ioctl.h:2