Instrument Neutral Distributed Interface INDI  2.0.2
skywatcherAltAzSimple.h
Go to the documentation of this file.
1 
16 #pragma once
17 
18 #include "indiguiderinterface.h"
19 #include "skywatcherAPI.h"
20 
23 
24 struct GuidingPulse
25 {
26  float DeltaAlt { 0 };
27  float DeltaAz { 0 };
28 };
29 
30 
32  public INDI::Telescope,
34 {
35  public:
37  virtual ~SkywatcherAltAzSimple() = default;
38 
39  // overrides of base class virtual functions
40  virtual bool Abort() override;
41  virtual bool Handshake() override;
42  virtual const char *getDefaultName() override;
43  virtual bool Goto(double ra, double dec) override;
44  virtual bool initProperties() override;
45  virtual void ISGetProperties(const char *dev) override;
46  virtual bool ISNewBLOB(const char *dev, const char *name, int sizes[], int blobsizes[], char *blobs[],
47  char *formats[], char *names[], int n) override;
48  virtual bool ISNewNumber(const char *dev, const char *name, double values[], char *names[], int n) override;
49  virtual bool ISNewSwitch(const char *dev, const char *name, ISState *states, char *names[], int n) override;
50  virtual bool ISNewText(const char *dev, const char *name, char *texts[], char *names[], int n) override;
51  double GetSlewRate();
52  virtual bool MoveNS(INDI_DIR_NS dir, TelescopeMotionCommand command) override;
53  virtual bool MoveWE(INDI_DIR_WE dir, TelescopeMotionCommand command) override;
54  double GetParkDeltaAz(ParkDirection_t target_direction, ParkPosition_t target_position);
55  virtual bool Park() override;
56  virtual bool UnPark() override;
57  virtual bool ReadScopeStatus() override;
58  virtual bool saveConfigItems(FILE *fp) override;
59  virtual bool Sync(double ra, double dec) override;
60  virtual void TimerHit() override;
61  virtual bool updateProperties() override;
62  virtual IPState GuideNorth(uint32_t ms) override;
63  virtual IPState GuideSouth(uint32_t ms) override;
64  virtual IPState GuideEast(uint32_t ms) override;
65  virtual IPState GuideWest(uint32_t ms) override;
66 
67  private:
68  void ResetGuidePulses();
69  void UpdateScopeConfigSwitch();
70  int recover_tty_reconnect();
71  void UpdateDetailedMountInformation(bool InformClient);
72  INDI::IHorizontalCoordinates GetAltAzPosition(double ra, double dec, double offset_in_sec = 0);
73  INDI::IEquatorialCoordinates GetRaDecPosition(double alt, double az);
74  void LogMessage(const char* format, ...);
75 
76  // Properties
77 
78  static constexpr const char *DetailedMountInfoPage { "Detailed Mount Information" };
79  enum
80  {
81  MOTOR_CONTROL_FIRMWARE_VERSION,
82  MOUNT_CODE,
83  MOUNT_NAME,
84  IS_DC_MOTOR
85  };
86  IText BasicMountInfoT[4] {};
87  ITextVectorProperty BasicMountInfoTP;
88 
89  enum
90  {
91  MICROSTEPS_PER_REVOLUTION,
92  STEPPER_CLOCK_FREQUENCY,
93  HIGH_SPEED_RATIO,
94  MICROSTEPS_PER_WORM_REVOLUTION
95  };
96  INumber AxisOneInfoN[4];
97  INumberVectorProperty AxisOneInfoNP;
98  INumber AxisTwoInfoN[4];
99  INumberVectorProperty AxisTwoInfoNP;
100  enum
101  {
102  FULL_STOP,
103  SLEWING,
104  SLEWING_TO,
105  SLEWING_FORWARD,
106  HIGH_SPEED,
107  NOT_INITIALISED
108  };
109  ISwitch AxisOneStateS[6];
110  ISwitchVectorProperty AxisOneStateSP;
111  ISwitch AxisTwoStateS[6];
112  ISwitchVectorProperty AxisTwoStateSP;
113  enum
114  {
115  RAW_MICROSTEPS,
116  MICROSTEPS_PER_ARCSEC,
117  OFFSET_FROM_INITIAL,
118  DEGREES_FROM_INITIAL
119  };
120  INumber AxisOneEncoderValuesN[4];
121  INumberVectorProperty AxisOneEncoderValuesNP;
122  INumber AxisTwoEncoderValuesN[4];
123  INumberVectorProperty AxisTwoEncoderValuesNP;
124 
125  // A switch for silent/highspeed slewing modes
126  enum
127  {
128  SLEW_SILENT,
129  SLEW_NORMAL
130  };
131  ISwitch SlewModesS[2];
132  ISwitchVectorProperty SlewModesSP;
133 
134  // A switch for wedge mode
135  enum
136  {
137  WEDGE_SIMPLE,
138  WEDGE_EQ,
139  WEDGE_DISABLED
140  };
141  ISwitch WedgeModeS[3];
142  ISwitchVectorProperty WedgeModeSP;
143 
144  // A switch for tracking logging
145  enum
146  {
147  TRACKLOG_ENABLED,
148  TRACKLOG_DISABLED
149  };
150  ISwitch TrackLogModeS[2];
151  ISwitchVectorProperty TrackLogModeSP;
152 
153  // Guiding rates (RA/Dec)
154  INumber GuidingRatesN[2];
155  INumberVectorProperty GuidingRatesNP;
156 
157  // Tracking values
158  INumber TrackingValuesN[3];
159  INumberVectorProperty TrackingValuesNP;
160 
161  // A switch for park movement directions (clockwise/counterclockwise)
162  ISwitch ParkMovementDirectionS[2];
163  ISwitchVectorProperty ParkMovementDirectionSP;
164 
165  // A switch for park positions
166  ISwitch ParkPositionS[4];
167  ISwitchVectorProperty ParkPositionSP;
168 
169  // A switch for unpark positions
170  ISwitch UnparkPositionS[4];
171  ISwitchVectorProperty UnparkPositionSP;
172 
173  // Tracking
174  INDI::IEquatorialCoordinates CurrentTrackingTarget { 0, 0 };
175  long OldTrackingTarget[2] { 0, 0 };
176  INDI::IHorizontalCoordinates CurrentAltAz { 0, 0 };
177  bool ResetTrackingSeconds { false };
178  int TrackingMsecs { 0 };
179  int TrackingStartTimer { 0 };
180  double GuideDeltaAlt { 0 };
181  double GuideDeltaAz { 0 };
182  int TimeoutDuration { 500 };
183  const std::string TrackLogFileName;
184  int UpdateCount { 0 };
185 
187  std::string SerialPortName;
189  bool RecoverAfterReconnection { false };
190  bool VerboseScopeStatus { false };
191 
192  std::vector<GuidingPulse> GuidingPulses;
193 
194  bool moving { false };
195 };
virtual bool saveConfigItems(FILE *fp) override
saveConfigItems Save specific properties in the provide config file handler. Child class usually over...
virtual const char * getDefaultName() override
virtual bool Abort() override
Abort any telescope motion including tracking if possible.
virtual IPState GuideSouth(uint32_t ms) override
Guide south for ms milliseconds. South is defined as DEC-.
virtual IPState GuideEast(uint32_t ms) override
Guide east for ms milliseconds. East is defined as RA+.
virtual bool initProperties() override
Called to initialize basic properties required all the time.
virtual bool updateProperties() override
Called when connected state changes, to add/remove properties.
virtual bool MoveWE(INDI_DIR_WE dir, TelescopeMotionCommand command) override
Move the telescope in the direction dir.
virtual bool ISNewBLOB(const char *dev, const char *name, int sizes[], int blobsizes[], char *blobs[], char *formats[], char *names[], int n) override
Process the client newBLOB command.
virtual bool ISNewNumber(const char *dev, const char *name, double values[], char *names[], int n) override
Process the client newNumber command.
virtual bool ReadScopeStatus() override
Read telescope status.
virtual ~SkywatcherAltAzSimple()=default
virtual IPState GuideWest(uint32_t ms) override
Guide west for ms milliseconds. West is defined as RA-.
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 Goto(double ra, double dec) override
Move the scope to the supplied RA and DEC coordinates.
virtual bool Handshake() override
perform handshake with device to check communication
virtual bool Park() override
Park the telescope to its home position.
virtual bool Sync(double ra, double dec) override
Set the telescope current RA and DEC coordinates to the supplied RA and DEC coordinates.
virtual IPState GuideNorth(uint32_t ms) override
Guide north for ms milliseconds. North is defined as DEC+.
virtual bool ISNewSwitch(const char *dev, const char *name, ISState *states, char *names[], int n) override
Process the client newSwitch command.
virtual bool UnPark() override
Unpark the telescope if already parked.
virtual bool MoveNS(INDI_DIR_NS dir, TelescopeMotionCommand command) override
Start or Stop the telescope motion in the direction dir.
virtual void TimerHit() override
Called when setTimer() time is up.
virtual bool ISNewText(const char *dev, const char *name, char *texts[], char *names[], int n) override
Process the client newSwitch command.
double GetParkDeltaAz(ParkDirection_t target_direction, ParkPosition_t target_position)
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
ParkDirection_t
ParkPosition_t
@ PARK_CLOCKWISE
@ PARK_COUNTERCLOCKWISE
@ PARK_SOUTH
@ PARK_NORTH
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