Instrument Neutral Distributed Interface INDI 2.2.5
telescope_simulator.h
Go to the documentation of this file.
1/*******************************************************************************
2 Copyright(c) 2015 Jasem Mutlaq. All rights reserved.
3
4 This library is free software; you can redistribute it and/or
5 modify it under the terms of the GNU Library General Public
6 License version 2 as published by the Free Software Foundation.
7 .
8 This library is distributed in the hope that it will be useful,
9 but WITHOUT ANY WARRANTY; without even the implied warranty of
10 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11 Library General Public License for more details.
12 .
13 You should have received a copy of the GNU Library General Public License
14 along with this library; see the file COPYING.LIB. If not, write to
15 the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
16 Boston, MA 02110-1301, USA.
17*******************************************************************************/
18
19#pragma once
20
21#include "indiguiderinterface.h"
22#include "inditelescope.h"
23#include "scopesim_helper.h"
25
26#define USE_SIM_TAB
27
45{
46 public:
47 ScopeSim();
48 virtual ~ScopeSim() = default;
49
50 virtual const char *getDefaultName() override;
51 virtual bool Connect() override;
52 virtual bool Disconnect() override;
53 virtual bool ReadScopeStatus() override;
54 virtual bool initProperties() override;
55 virtual void ISGetProperties(const char *dev) override;
56 virtual bool updateProperties() override;
57
58 virtual bool ISNewNumber(const char *dev, const char *name, double values[], char *names[], int n) override;
59 virtual bool ISNewSwitch(const char *dev, const char *name, ISState *states, char *names[], int n) override;
60 virtual bool ISNewText(const char *dev, const char *name, char *texts[], char *names[], int n) override;
61 virtual bool ISSnoopDevice(XMLEle *root) override;
62
63 protected:
64 // Slew Rate
65 virtual bool MoveNS(INDI_DIR_NS dir, TelescopeMotionCommand command) override;
66 virtual bool MoveWE(INDI_DIR_WE dir, TelescopeMotionCommand command) override;
67 virtual bool Abort() override;
68
69 virtual IPState GuideNorth(uint32_t ms) override;
70 virtual IPState GuideSouth(uint32_t ms) override;
71 virtual IPState GuideEast(uint32_t ms) override;
72 virtual IPState GuideWest(uint32_t ms) override;
73
74 virtual bool SetTrackMode(uint8_t mode) override;
75 virtual bool SetTrackEnabled(bool enabled) override;
76 virtual bool SetTrackRate(double raRate, double deRate) override;
77
78 virtual bool Goto(double, double) override;
79 virtual bool Park() override;
80 virtual bool UnPark() override;
81 virtual bool Sync(double ra, double dec) override;
82
83 // Parking
84 virtual bool SetCurrentPark() override;
85 virtual bool SetDefaultPark() override;
86 virtual bool updateLocation(double latitude, double longitude, double elevation) override;
87 virtual bool updateTime(ln_date *utc, double utc_offset) override;
88
89 // Home
90 virtual IPState ExecuteHomeAction(TelescopeHomeAction action) override;
91
92 virtual bool saveConfigItems(FILE *fp) override;
93
94 private:
95 double m_currentRA { 0 };
96 double m_currentDEC { 90 };
97 double m_currentAz { 180 }; // INDI Az convention: 0=North, increasing eastward
98 double m_currentAlt { 0 };
99 double m_targetRA { 0 };
100 double m_targetDEC { 0 };
102 void StartSlew(double ra, double dec, TelescopeStatus status);
103
106 void guideAltAzDecomposed(double dNS, double dEW, uint32_t ms);
107
109 void updateCurrentCoordsFromAxes();
110
112 void setTargetFromAxisPosition(Angle primary, Angle secondary);
113
114 unsigned int DBG_SCOPE { 0 };
115
116 int mcRate = 0;
117
118 // double guiderEWTarget[2];
119 // double guiderNSTarget[2];
120
121 bool guidingNS = false;
122 bool guidingEW = false;
123
124 uint32_t applyDecBacklash(double rate, uint32_t ms);
125 uint32_t backlashComputation(uint32_t ms);
126
127 // In milliseconds. Doesn't depend on guide rate.
128 uint32_t m_DecGuideBacklashMs { 30 };
129 // True if last dec guide pulse was north. Actually a little more complicated
130 // than that because of pier side...
131 bool m_GuideDecLastNorth = false;
132 // Will be between 0 and decGuideBacklash. When guide pulses change directions,
133 // a pulse may not completely clear the backlash. This is how much is left
134 // after that pulse.
135 uint32_t m_DecGuideRemainingBacklash { 0 };
136
137 INDI::PropertyNumber GuideRateNP {2};
138 enum
139 {
140 GUIDE_RATE_WE,
141 GUIDE_RATE_NS
142 };
143
144 double m_Home[2] = {0, 0};
145
146 Axis axisPrimary { "Primary Axis" }; // entails angle of mount for primary axis
147 Axis axisSecondary { "Secondary Axis" }; // entails angle of mount for secondary axis ("mechanical DEC")
148
149 int m_PierSide {-1};
150 int m_MountType {-1};
151
152 Alignment alignment;
153
154 // Parabolic Alt-Az tracking window: three sky positions bracketing the current time,
155 // used to fit a 2nd-order polynomial for axis rate prediction.
156 INDI::IHorizontalCoordinates m_TrackingWindowCoords[3] {};
157 bool m_IsPipelinePrimed { false };
158 double m_LastTrackingRA { 0 };
159 double m_LastTrackingDec { 0 };
160
161 bool updateMountAndPierSide();
162
163#ifdef USE_SIM_TAB
164 // Simulator Tab properties
165 // Scope type and alignment
166 INDI::PropertySwitch mountTypeSP {3};
167 enum
168 {
169 ALTAZ,
170 EQ_FORK,
171 EQ_GEM
172 };
173
174 INDI::PropertySwitch simPierSideSP {2};
175 enum
176 {
177 PS_OFF,
178 PS_ON
179 };
180
181 INDI::PropertyNumber mountModelNP {6};
182 enum
183 {
184 MM_IH,
185 MM_ID,
186 MM_CH,
187 MM_NP,
188 MM_MA,
189 MM_ME
190 };
191
192 INDI::PropertyNumber mountAxisNP {2};
193 enum
194 {
195 PRIMARY,
196 SECONDARY
197 };
198
199 INDI::PropertyNumber flipHourAngleNP {1};
200 INDI::PropertyNumber decBacklashNP {1};
201
202 INDI::PropertyText PACDeviceTP {1};
203 double m_snoopedAzError { 0 };
204 double m_snoopedAltError { 0 };
205
206#endif
207
208 // True pointing position (Wallace errors applied) published as EQUATORIAL_PE so the
209 // CCD simulator can generate star fields at the physically-correct sky position while
210 // EQUATORIAL_EOD_COORD carries the raw encoder position for the INDI alignment module.
211 INDI::PropertyNumber EqPENP {2};
212 enum { PE_RA = 0, PE_DEC = 1 };
213
214};
215
The Alignment class This converts between the mount axis angles and the sky hour angle and declinatio...
The Angle class This class implements an angle type. This holds an angle that is always in the range ...
The Axis class Implements a generic Axis which can be used for equatorial or AltAz mounts for both ax...
This class encapsulates all the alignment subsystem classes that are useful to driver implementations...
The ScopeSim class provides a simple mount simulator of an equatorial mount.
virtual bool ReadScopeStatus() override
Read telescope status.
virtual bool SetTrackMode(uint8_t mode) override
SetTrackMode Set active tracking mode. Do not change track state.
virtual bool Abort() override
Abort any telescope motion including tracking if possible.
virtual bool saveConfigItems(FILE *fp) override
saveConfigItems Save specific properties in the provide config file handler. Child class usually over...
virtual bool ISNewSwitch(const char *dev, const char *name, ISState *states, char *names[], int n) override
Process the client newSwitch command.
virtual bool ISNewNumber(const char *dev, const char *name, double values[], char *names[], int n) override
Process the client newNumber command.
virtual IPState ExecuteHomeAction(TelescopeHomeAction action) override
Execute a homing action.
virtual const char * getDefaultName() override
virtual bool Disconnect() override
Disconnect from device.
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 updateTime(ln_date *utc, double utc_offset) override
Update telescope time, date, and UTC offset.
virtual bool SetCurrentPark() override
SetCurrentPark Set current coordinates/encoders value as the desired parking position.
virtual IPState GuideSouth(uint32_t ms) override
Guide south for ms milliseconds. South is defined as DEC-.
virtual bool Goto(double, double) override
Move the scope to the supplied RA and DEC coordinates.
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 ISNewText(const char *dev, const char *name, char *texts[], char *names[], int n) override
Process the client newSwitch command.
virtual bool Park() override
Park the telescope to its home position.
virtual bool SetDefaultPark() override
SetDefaultPark Set default coordinates/encoders value as the desired parking position.
virtual bool updateProperties() override
Called when connected state changes, to add/remove properties.
virtual bool Connect() override
Connect to the device. INDI::DefaultDevice implementation connects to appropriate connection interfac...
virtual IPState GuideWest(uint32_t ms) override
Guide west for ms milliseconds. West is defined as RA-.
virtual IPState GuideNorth(uint32_t ms) override
Guide north for ms milliseconds. North is defined as DEC+.
virtual bool MoveWE(INDI_DIR_WE dir, TelescopeMotionCommand command) override
Move the telescope in the direction dir.
virtual bool SetTrackEnabled(bool enabled) override
SetTrackEnabled Engages or disengages mount tracking. If there are no tracking modes available,...
virtual bool updateLocation(double latitude, double longitude, double elevation) override
Update telescope location settings.
virtual bool SetTrackRate(double raRate, double deRate) override
SetTrackRate Set custom tracking rates.
virtual bool ISSnoopDevice(XMLEle *root) override
Process a snoop event from INDI server. This function is called when a snooped property is updated in...
virtual bool MoveNS(INDI_DIR_NS dir, TelescopeMotionCommand command) override
Start or Stop the telescope motion in the direction dir.
virtual ~ScopeSim()=default
virtual bool initProperties() override
Called to initialize basic properties required all the time.
virtual bool UnPark() override
Unpark the telescope if already parked.
virtual IPState GuideEast(uint32_t ms) override
Guide east for ms milliseconds. East is defined as RA+.
double ra
double dec
ISState
Switch state.
Definition indiapi.h:148
IPState
Property state.
Definition indiapi.h:158
INDI_DIR_WE
INDI_DIR_NS