Instrument Neutral Distributed Interface INDI  2.0.2
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"
24 
25 #define USE_SIM_TAB
26 
43 {
44  public:
45  ScopeSim();
46  virtual ~ScopeSim() = default;
47 
48  virtual const char *getDefaultName() override;
49  virtual bool Connect() override;
50  virtual bool Disconnect() override;
51  virtual bool ReadScopeStatus() override;
52  virtual bool initProperties() override;
53  virtual void ISGetProperties(const char *dev) override;
54  virtual bool updateProperties() override;
55 
56  virtual bool ISNewNumber(const char *dev, const char *name, double values[], char *names[], int n) override;
57  virtual bool ISNewSwitch(const char *dev, const char *name, ISState *states, char *names[], int n) override;
58 
59  protected:
60  // Slew Rate
61  virtual bool MoveNS(INDI_DIR_NS dir, TelescopeMotionCommand command) override;
62  virtual bool MoveWE(INDI_DIR_WE dir, TelescopeMotionCommand command) override;
63  virtual bool Abort() override;
64 
65  virtual IPState GuideNorth(uint32_t ms) override;
66  virtual IPState GuideSouth(uint32_t ms) override;
67  virtual IPState GuideEast(uint32_t ms) override;
68  virtual IPState GuideWest(uint32_t ms) override;
69 
70  virtual bool SetTrackMode(uint8_t mode) override;
71  virtual bool SetTrackEnabled(bool enabled) override;
72  virtual bool SetTrackRate(double raRate, double deRate) override;
73 
74  virtual bool Goto(double, double) override;
75  virtual bool Park() override;
76  virtual bool UnPark() override;
77  virtual bool Sync(double ra, double dec) override;
78 
79  // Parking
80  virtual bool SetCurrentPark() override;
81  virtual bool SetDefaultPark() override;
82  virtual bool updateLocation(double latitude, double longitude, double elevation) override;
83 
84  virtual bool saveConfigItems(FILE *fp) override;
85 
86  private:
87  double currentRA { 0 };
88  double currentDEC { 90 };
89  double targetRA { 0 };
90  double targetDEC { 0 };
91 
93  void StartSlew(double ra, double dec, TelescopeStatus status);
94 
95  // bool forceMeridianFlip { false }; // #PS: unused
96  unsigned int DBG_SCOPE { 0 };
97 
98  int mcRate = 0;
99 
100  // double guiderEWTarget[2];
101  // double guiderNSTarget[2];
102 
103  bool guidingNS = false;
104  bool guidingEW = false;
105 
106  INumber GuideRateN[2];
107  INumberVectorProperty GuideRateNP;
108 
109  Axis axisPrimary { "HaAxis" }; // hour angle mount axis
110  Axis axisSecondary { "DecAxis" }; // declination mount axis
111 
112  int m_PierSide {-1};
113  int m_MountType {-1};
114 
115  Alignment alignment;
116  bool updateMountAndPierSide();
117 
118 #ifdef USE_SIM_TAB
119  // Simulator Tab properties
120  // Scope type and alignment
121  ISwitch mountTypeS[3];
122  ISwitchVectorProperty mountTypeSP;
123  ISwitch simPierSideS[2];
124  ISwitchVectorProperty simPierSideSP;
125 
126  INumber mountModelN[6];
127  INumberVectorProperty mountModelNP;
128  INumber mountAxisN[2];
129  INumberVectorProperty mountAxisNP;
130 
131  INumber flipHourAngleN[1];
132  INumberVectorProperty flipHourAngleNP;
133 #endif
134 
135 };
136 
The Alignment class This converts between the mount axis angles and the sky hour angle and declinatio...
The Axis class Implements a generic Axis which can be used for equatorial or AltAz mounts for both ax...
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 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 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 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 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:150
IPState
Property state.
Definition: indiapi.h:160
INDI_DIR_WE
Definition: indibasetypes.h:55
INDI_DIR_NS
Definition: indibasetypes.h:48
One number descriptor.
One switch descriptor.
Number vector property descriptor.
Definition: indiapi.h:319
Switch vector property descriptor.
Definition: indiapi.h:367