Instrument Neutral Distributed Interface INDI  2.0.2
ieqdriverbase.h
Go to the documentation of this file.
1 /*
2  IEQ Pro driver
3 
4  Copyright (C) 2015 Jasem Mutlaq
5 
6  This library is free software; you can redistribute it and/or
7  modify it under the terms of the GNU Lesser General Public
8  License as published by the Free Software Foundation; either
9  version 2.1 of the License, or (at your option) any later version.
10 
11  This library is distributed in the hope that it will be useful,
12  but WITHOUT ANY WARRANTY; without even the implied warranty of
13  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14  Lesser General Public License for more details.
15 
16  You should have received a copy of the GNU Lesser General Public
17  License along with this library; if not, write to the Free Software
18  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
19 */
20 
21 #pragma once
22 
23 #include <string>
24 #include <vector>
25 #include <cstdint>
26 
27 namespace iEQ
28 {
29 
30 typedef enum { GPS_OFF, GPS_ON, GPS_DATA_OK } GPSStatus;
31 typedef enum
32 {
40  ST_HOME
42 
44 typedef enum { SR_1, SR_2, SR_3, SR_4, SR_5, SR_6, SR_7, SR_8, SR_MAX } SlewRate;
46 typedef enum { HEMI_SOUTH, HEMI_NORTH } Hemisphere;
48 typedef enum { RA_AXIS, DEC_AXIS } Axis;
49 typedef enum { IEQ_N, IEQ_S, IEQ_W, IEQ_E } Direction;
51 
53 
57 class Base
58 {
59  public:
60 
61  Base();
62  virtual ~Base() = default;
63 
64  typedef struct
65  {
73  double longitude;
74  double latitude;
75  } Info;
76 
77  typedef struct
78  {
79  std::string Model;
80  std::string MainBoardFirmware;
81  std::string ControllerFirmware;
82  std::string RAFirmware;
83  std::string DEFirmware;
84  } FirmwareInfo;
85 
86  typedef struct
87  {
88  std::string code;
89  std::string model;
90  std::string firmware;
91  } MountInfo;
92 
93  void setDebugEnabled(bool enable)
94  {
95  m_IsDebug = enable;
96  }
97  void setDeviceName(const std::string &name)
98  {
99  m_DeviceName = name;
100  }
101  const char *getDeviceName()
102  {
103  return m_DeviceName.c_str();
104  }
105 
106  /**************************************************************************
107  Get Info
108  **************************************************************************/
110  bool getStatus(Info *info);
112  bool getModel();
114  bool getMainFirmware();
116  bool getRADEFirmware();
118  bool getCoords(double *ra, double *dec);
120  bool getUTCDateTime(double *utc_hours, int *yy, int *mm, int *dd, int *hh, int *minute, int *ss);
123  {
124  return m_FirmwareInfo;
125  }
126 
127  bool getPierSide(IEQ_PIER_SIDE * pierSide);
128  private:
129  // read from mount using the GEA command
130  double haAxis; // not sure, try degrees to start with
131  double decAxis; // degrees, zero at 90 dec, sign determines pointing state
132  double Ra; // read from mount
133  double Dec;
134  Info info;
135  public:
136 
137  /**************************************************************************
138  Communication
139  **************************************************************************/
146  bool initCommunication(int fd);
147 
159  bool sendCommand(const char * cmd, char * res = nullptr, int cmd_len = -1, int res_len = -1);
160 
168  void hexDump(char * buf, const char * data, int size);
169 
176  bool isCommandSupported(const std::string &command, bool silent = false);
177 
178 
179  /**************************************************************************
180  Motion
181  **************************************************************************/
182  virtual bool startMotion(Direction dir);
183  virtual bool stopMotion(Direction dir);
184  virtual bool setSlewRate(SlewRate rate);
185  virtual bool setCustomRATrackRate(double rate);
186  virtual bool setTrackMode(TrackRate rate);
187  virtual bool setTrackEnabled(bool enabled);
188  virtual bool abort();
189  virtual bool slew();
190  virtual bool sync();
191  virtual bool setRA(double ra);
192  virtual bool setDE(double dec);
193  virtual bool setAz(double az);
194  virtual bool setAlt(double alt);
195 
196  /**************************************************************************
197  Home
198  **************************************************************************/
199  virtual bool findHome();
200  virtual bool gotoHome();
201  virtual bool setCurrentHome();
202 
203  /**************************************************************************
204  Park
205  **************************************************************************/
206  virtual bool park();
207  virtual bool unpark();
208  virtual bool setParkAz(double az);
209  virtual bool setParkAlt(double alt);
210 
211  /**************************************************************************
212  Guide
213  **************************************************************************/
214  virtual bool setGuideRate(double raRate, double deRate);
215  virtual bool getGuideRate(double * raRate, double * deRate);
216  virtual bool startGuide(Direction dir, uint32_t ms);
217 
218  /**************************************************************************
219  Time & Location
220  **************************************************************************/
221  virtual bool setLongitude(double longitude);
222  virtual bool setLatitude(double latitude);
223  virtual bool setLocalDate(int yy, int mm, int dd);
224  virtual bool setLocalTime(int hh, int mm, int ss);
225  virtual bool setUTCOffset(double offset_hours);
226  virtual bool setDST(bool enabled);
227 
228  protected:
229 
230  int m_PortFD {-1};
231  std::string m_DeviceName { "iEQ" };
232  bool m_IsDebug { false };
233  static const uint8_t DRIVER_TIMEOUT { 3 };
234  static const uint8_t DRIVER_LEN { 64 };
235  static const char DRIVER_STOP_CHAR { '#' };
236 
238 
239  const std::vector<MountInfo> m_MountList =
240  {
241  {"0010", "Cube II EQ", "160610"},
242  {"0011", "Smart EQ Pro+", "161028"},
243  {"0025", "CEM25", "170106"},
244  {"0026", "CEM25-EC", "170518"},
245  {"0030", "iEQ30 Pro", "161101"},
246  {"0040", "CEM40", "181018"},
247  {"0041", "CEM40-EC", "181018"},
248  {"0043", "GEM45", "191018"},
249  {"0044", "GEM45-EC", "191018"},
250  {"0045", "iEQ45 Pro EQ", "161101"},
251  {"0046", "iEQ45 Pro AA", "161101"},
252  {"0060", "CEM60", "161101"},
253  {"0061", "CEM60-EC", "161101"},
254  {"5010", "Cube II AA", "160610"},
255  {"5035", "AZ Mount Pro", "170410"},
256  };
257 
265  double DecodeString(const char * data, size_t size, double factor);
266 
273  int DecodeString(const char * data, size_t size);
274 
275  constexpr static const double ieqDegrees { 60.0 * 60.0 * 100.0 };
276  constexpr static const double ieqHours { 60.0 * 60.0 * 1000.0 };
277 };
278 
279 class Simulator: public Base
280 {
281  Simulator();
282  virtual ~Simulator();
283 
284 
285 };
286 
287 }
The BaseFirmware class provides control for iOptron version 2014 v2.0 protocol.
Definition: ieqdriverbase.h:58
static const uint8_t DRIVER_LEN
bool getRADEFirmware()
void setDeviceName(const std::string &name)
Definition: ieqdriverbase.h:97
void hexDump(char *buf, const char *data, int size)
hexDump Helper function to print non-string commands to the logger so it is easier to debug
virtual bool setCurrentHome()
virtual bool setRA(double ra)
virtual bool setSlewRate(SlewRate rate)
bool getStatus(Info *info)
virtual bool slew()
FirmwareInfo m_FirmwareInfo
virtual bool setTrackEnabled(bool enabled)
bool initCommunication(int fd)
initCommunication Checks if communication with the mount is working
virtual bool setLocalDate(int yy, int mm, int dd)
virtual bool abort()
constexpr static const double ieqHours
std::string m_DeviceName
virtual bool park()
bool isCommandSupported(const std::string &command, bool silent=false)
isCommandSupported Check if specific iOptron command is supported for this mount model
virtual bool sync()
virtual bool setAlt(double alt)
bool getCoords(double *ra, double *dec)
virtual bool unpark()
bool getPierSide(IEQ_PIER_SIDE *pierSide)
double DecodeString(const char *data, size_t size, double factor)
DecodeString converts the string to a double by dividing by the factor.
virtual bool setParkAlt(double alt)
virtual bool setLatitude(double latitude)
virtual bool setParkAz(double az)
constexpr static const double ieqDegrees
virtual ~Base()=default
virtual bool getGuideRate(double *raRate, double *deRate)
bool getMainFirmware()
virtual bool setAz(double az)
virtual bool setDE(double dec)
const char * getDeviceName()
virtual bool setUTCOffset(double offset_hours)
virtual bool stopMotion(Direction dir)
virtual bool setGuideRate(double raRate, double deRate)
static const char DRIVER_STOP_CHAR
const std::vector< MountInfo > m_MountList
bool sendCommand(const char *cmd, char *res=nullptr, int cmd_len=-1, int res_len=-1)
sendCommand Send a string command to device.
virtual bool setDST(bool enabled)
void setDebugEnabled(bool enable)
Definition: ieqdriverbase.h:93
bool getUTCDateTime(double *utc_hours, int *yy, int *mm, int *dd, int *hh, int *minute, int *ss)
virtual bool setLongitude(double longitude)
virtual bool setCustomRATrackRate(double rate)
static const uint8_t DRIVER_TIMEOUT
virtual bool startGuide(Direction dir, uint32_t ms)
virtual bool gotoHome()
bool getModel()
virtual bool startMotion(Direction dir)
virtual bool setLocalTime(int hh, int mm, int ss)
virtual bool setTrackMode(TrackRate rate)
const FirmwareInfo & getFirmwareInfo() const
virtual bool findHome()
bool m_IsDebug
double ra
double dec
int fd
Definition: intelliscope.c:43
@ IEQ_E
Definition: ieqdriverbase.h:49
@ IEQ_W
Definition: ieqdriverbase.h:49
@ IEQ_N
Definition: ieqdriverbase.h:49
@ IEQ_S
Definition: ieqdriverbase.h:49
@ TR_SIDEREAL
Definition: ieqdriverbase.h:43
@ TR_SOLAR
Definition: ieqdriverbase.h:43
@ TR_KING
Definition: ieqdriverbase.h:43
@ TR_LUNAR
Definition: ieqdriverbase.h:43
@ TR_CUSTOM
Definition: ieqdriverbase.h:43
TimeSource
Definition: ieqdriverbase.h:45
@ TS_CONTROLLER
Definition: ieqdriverbase.h:45
@ TS_GPS
Definition: ieqdriverbase.h:45
@ TS_RS232
Definition: ieqdriverbase.h:45
@ SR_6
Definition: ieqdriverbase.h:44
@ SR_8
Definition: ieqdriverbase.h:44
@ SR_5
Definition: ieqdriverbase.h:44
@ SR_MAX
Definition: ieqdriverbase.h:44
@ SR_1
Definition: ieqdriverbase.h:44
@ SR_3
Definition: ieqdriverbase.h:44
@ SR_7
Definition: ieqdriverbase.h:44
@ SR_4
Definition: ieqdriverbase.h:44
@ SR_2
Definition: ieqdriverbase.h:44
FirmwareItem
Definition: ieqdriverbase.h:47
@ FW_MODEL
Definition: ieqdriverbase.h:47
@ FW_BOARD
Definition: ieqdriverbase.h:47
@ FW_RA
Definition: ieqdriverbase.h:47
@ FW_CONTROLLER
Definition: ieqdriverbase.h:47
@ FW_DEC
Definition: ieqdriverbase.h:47
@ GPS_ON
Definition: ieqdriverbase.h:30
@ GPS_OFF
Definition: ieqdriverbase.h:30
@ GPS_DATA_OK
Definition: ieqdriverbase.h:30
Hemisphere
Definition: ieqdriverbase.h:46
@ HEMI_NORTH
Definition: ieqdriverbase.h:46
@ HEMI_SOUTH
Definition: ieqdriverbase.h:46
SystemStatus
Definition: ieqdriverbase.h:32
@ ST_HOME
Definition: ieqdriverbase.h:40
@ ST_SLEWING
Definition: ieqdriverbase.h:35
@ ST_MERIDIAN_FLIPPING
Definition: ieqdriverbase.h:37
@ ST_TRACKING_PEC_OFF
Definition: ieqdriverbase.h:34
@ ST_STOPPED
Definition: ieqdriverbase.h:33
@ ST_TRACKING_PEC_ON
Definition: ieqdriverbase.h:38
@ ST_GUIDING
Definition: ieqdriverbase.h:36
@ ST_PARKED
Definition: ieqdriverbase.h:39
IEQ_PIER_SIDE
Definition: ieqdriverbase.h:52
@ IEQ_PIER_EAST
Definition: ieqdriverbase.h:52
@ IEQ_PIER_WEST
Definition: ieqdriverbase.h:52
@ IEQ_PIER_UNCERTAIN
Definition: ieqdriverbase.h:52
@ IEQ_PIER_UNKNOWN
Definition: ieqdriverbase.h:52
@ DEC_AXIS
Definition: ieqdriverbase.h:48
@ RA_AXIS
Definition: ieqdriverbase.h:48
HomeOperation
Definition: ieqdriverbase.h:50
@ IEQ_GOTO_HOME
Definition: ieqdriverbase.h:50
@ IEQ_FIND_HOME
Definition: ieqdriverbase.h:50
@ IEQ_SET_HOME
Definition: ieqdriverbase.h:50
struct FirmwareInfo FirmwareInfo
__u8 cmd[4]
Definition: pwc-ioctl.h:2
std::string MainBoardFirmware
Definition: ieqdriverbase.h:80
std::string ControllerFirmware
Definition: ieqdriverbase.h:81
TrackRate trackRate
Definition: ieqdriverbase.h:69
SystemStatus systemStatus
Definition: ieqdriverbase.h:67
TimeSource timeSource
Definition: ieqdriverbase.h:71
Hemisphere hemisphere
Definition: ieqdriverbase.h:72
SlewRate slewRate
Definition: ieqdriverbase.h:70
SystemStatus rememberSystemStatus
Definition: ieqdriverbase.h:68
GPSStatus gpsStatus
Definition: ieqdriverbase.h:66
std::string firmware
Definition: ieqdriverbase.h:90