Instrument Neutral Distributed Interface INDI  1.9.5
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 
26 namespace iEQ
27 {
28 
29 typedef enum { GPS_OFF, GPS_ON, GPS_DATA_OK } GPSStatus;
30 typedef enum
31 {
40 } SystemStatus;
41 
43 typedef enum { SR_1, SR_2, SR_3, SR_4, SR_5, SR_6, SR_7, SR_8, SR_MAX } SlewRate;
45 typedef enum { HEMI_SOUTH, HEMI_NORTH } Hemisphere;
47 typedef enum { RA_AXIS, DEC_AXIS } Axis;
48 typedef enum { IEQ_N, IEQ_S, IEQ_W, IEQ_E } Direction;
50 
52 
56 class Base
57 {
58  public:
59 
60  Base();
61  virtual ~Base() = default;
62 
63  typedef struct
64  {
72  double longitude;
73  double latitude;
74  } Info;
75 
76  typedef struct
77  {
78  std::string Model;
79  std::string MainBoardFirmware;
80  std::string ControllerFirmware;
81  std::string RAFirmware;
82  std::string DEFirmware;
83  } FirmwareInfo;
84 
85  typedef struct
86  {
87  std::string code;
88  std::string model;
89  std::string firmware;
90  } MountInfo;
91 
92  void setDebugEnabled(bool enable)
93  {
94  m_IsDebug = enable;
95  }
96  void setDeviceName(const std::string &name)
97  {
99  }
100  const char *getDeviceName()
101  {
102  return m_DeviceName.c_str();
103  }
104 
105  /**************************************************************************
106  Get Info
107  **************************************************************************/
109  bool getStatus(Info *info);
111  bool getModel();
113  bool getMainFirmware();
115  bool getRADEFirmware();
117  bool getCoords(double *ra, double *dec);
119  bool getUTCDateTime(double *utc_hours, int *yy, int *mm, int *dd, int *hh, int *minute, int *ss);
122  {
123  return m_FirmwareInfo;
124  }
125 
126  bool getPierSide(IEQ_PIER_SIDE * pierSide);
127  private:
128  // read from mount using the GEA command
129  double haAxis; // not sure, try degrees to start with
130  double decAxis; // degrees, zero at 90 dec, sign determines pointing state
131  double Ra; // read from mount
132  double Dec;
133  Info info;
134  public:
135 
136  /**************************************************************************
137  Communication
138  **************************************************************************/
145  bool initCommunication(int fd);
146 
158  bool sendCommand(const char * cmd, char * res = nullptr, int cmd_len = -1, int res_len = -1);
159 
167  void hexDump(char * buf, const char * data, int size);
168 
175  bool isCommandSupported(const std::string &command, bool silent = false);
176 
177 
178  /**************************************************************************
179  Motion
180  **************************************************************************/
181  virtual bool startMotion(Direction dir);
182  virtual bool stopMotion(Direction dir);
183  virtual bool setSlewRate(SlewRate rate);
184  virtual bool setCustomRATrackRate(double rate);
185  virtual bool setTrackMode(TrackRate rate);
186  virtual bool setTrackEnabled(bool enabled);
187  virtual bool abort();
188  virtual bool slew();
189  virtual bool sync();
190  virtual bool setRA(double ra);
191  virtual bool setDE(double dec);
192  virtual bool setAz(double az);
193  virtual bool setAlt(double alt);
194 
195  /**************************************************************************
196  Home
197  **************************************************************************/
198  virtual bool findHome();
199  virtual bool gotoHome();
200  virtual bool setCurrentHome();
201 
202  /**************************************************************************
203  Park
204  **************************************************************************/
205  virtual bool park();
206  virtual bool unpark();
207  virtual bool setParkAz(double az);
208  virtual bool setParkAlt(double alt);
209 
210  /**************************************************************************
211  Guide
212  **************************************************************************/
213  virtual bool setGuideRate(double raRate, double deRate);
214  virtual bool getGuideRate(double * raRate, double * deRate);
215  virtual bool startGuide(Direction dir, uint32_t ms);
216 
217  /**************************************************************************
218  Time & Location
219  **************************************************************************/
220  virtual bool setLongitude(double longitude);
221  virtual bool setLatitude(double latitude);
222  virtual bool setLocalDate(int yy, int mm, int dd);
223  virtual bool setLocalTime(int hh, int mm, int ss);
224  virtual bool setUTCOffset(double offset_hours);
225  virtual bool setDST(bool enabled);
226 
227  protected:
228 
229  int m_PortFD {-1};
230  std::string m_DeviceName { "iEQ" };
231  bool m_IsDebug { false };
232  static const uint8_t DRIVER_TIMEOUT { 3 };
233  static const uint8_t DRIVER_LEN { 64 };
234  static const char DRIVER_STOP_CHAR { '#' };
235 
237 
238  const std::vector<MountInfo> m_MountList =
239  {
240  {"0010", "Cube II EQ", "160610"},
241  {"0011", "Smart EQ Pro+", "161028"},
242  {"0025", "CEM25", "170106"},
243  {"0026", "CEM25-EC", "170518"},
244  {"0030", "iEQ30 Pro", "161101"},
245  {"0040", "CEM40", "181018"},
246  {"0041", "CEM40-EC", "181018"},
247  {"0043", "GEM45", "191018"},
248  {"0044", "GEM45-EC", "191018"},
249  {"0045", "iEQ45 Pro EQ", "161101"},
250  {"0046", "iEQ45 Pro AA", "161101"},
251  {"0060", "CEM60", "161101"},
252  {"0061", "CEM60-EC", "161101"},
253  {"5010", "Cube II AA", "160610"},
254  {"5035", "AZ Mount Pro", "170410"},
255  };
256 
264  double DecodeString(const char * data, size_t size, double factor);
265 
272  int DecodeString(const char * data, size_t size);
273 
274  constexpr static const double ieqDegrees { 60.0 * 60.0 * 100.0 };
275  constexpr static const double ieqHours { 60.0 * 60.0 * 1000.0 };
276 };
277 
278 class Simulator: public Base
279 {
280  Simulator();
281  virtual ~Simulator();
282 
283 
284 };
285 
286 }
iEQ::Base::setDeviceName
void setDeviceName(const std::string &name)
Definition: ieqdriverbase.h:96
iEQ::ST_HOME
@ ST_HOME
Definition: ieqdriverbase.h:39
iEQ::Base::setAlt
virtual bool setAlt(double alt)
Definition: ieqdriverbase.cpp:419
iEQ::Base::getDeviceName
const char * getDeviceName()
Definition: ieqdriverbase.h:100
iEQ::FW_MODEL
@ FW_MODEL
Definition: ieqdriverbase.h:46
cmd
__u8 cmd[4]
Definition: pwc-ioctl.h:4
iEQ::ST_TRACKING_PEC_ON
@ ST_TRACKING_PEC_ON
Definition: ieqdriverbase.h:37
iEQ::Base::getPierSide
bool getPierSide(IEQ_PIER_SIDE *pierSide)
Definition: ieqdriverbase.cpp:625
iEQ::HEMI_NORTH
@ HEMI_NORTH
Definition: ieqdriverbase.h:45
fd
int fd
Definition: indiserver.c:117
iEQ::GPS_OFF
@ GPS_OFF
Definition: ieqdriverbase.h:29
iEQ::Hemisphere
Hemisphere
Definition: ieqdriverbase.h:45
iEQ::Base::setCustomRATrackRate
virtual bool setCustomRATrackRate(double rate)
Definition: ieqdriverbase.cpp:245
iEQ::IEQ_PIER_UNKNOWN
@ IEQ_PIER_UNKNOWN
Definition: ieqdriverbase.h:51
iEQ::Base::FirmwareInfo
Definition: ieqdriverbase.h:76
iEQ::GPS_ON
@ GPS_ON
Definition: ieqdriverbase.h:29
iEQ::Base::m_PortFD
int m_PortFD
Definition: ieqdriverbase.h:229
iEQ::IEQ_PIER_UNCERTAIN
@ IEQ_PIER_UNCERTAIN
Definition: ieqdriverbase.h:51
iEQ::RA_AXIS
@ RA_AXIS
Definition: ieqdriverbase.h:47
iEQ::Base::startMotion
virtual bool startMotion(Direction dir)
Definition: ieqdriverbase.cpp:138
iEQ::Base::setLocalTime
virtual bool setLocalTime(int hh, int mm, int ss)
Definition: ieqdriverbase.cpp:498
iEQ::Base::setDebugEnabled
void setDebugEnabled(bool enable)
Definition: ieqdriverbase.h:92
iEQ::SR_7
@ SR_7
Definition: ieqdriverbase.h:43
iEQ::FW_CONTROLLER
@ FW_CONTROLLER
Definition: ieqdriverbase.h:46
iEQ::Base::setTrackEnabled
virtual bool setTrackEnabled(bool enabled)
Definition: ieqdriverbase.cpp:374
iEQ::SR_5
@ SR_5
Definition: ieqdriverbase.h:43
iEQ::TR_SOLAR
@ TR_SOLAR
Definition: ieqdriverbase.h:42
iEQ::Base::setLatitude
virtual bool setLatitude(double latitude)
Definition: ieqdriverbase.cpp:477
iEQ::Base::setAz
virtual bool setAz(double az)
Definition: ieqdriverbase.cpp:406
iEQ::Base::Info::gpsStatus
GPSStatus gpsStatus
Definition: ieqdriverbase.h:65
iEQ::SlewRate
SlewRate
Definition: ieqdriverbase.h:43
iEQ::FW_DEC
@ FW_DEC
Definition: ieqdriverbase.h:46
iEQ::Base::m_MountList
const std::vector< MountInfo > m_MountList
Definition: ieqdriverbase.h:238
iEQ::Base::Info::hemisphere
Hemisphere hemisphere
Definition: ieqdriverbase.h:71
iEQ::TS_GPS
@ TS_GPS
Definition: ieqdriverbase.h:44
iEQ::Base::m_DeviceName
std::string m_DeviceName
Definition: ieqdriverbase.h:230
iEQ::TS_RS232
@ TS_RS232
Definition: ieqdriverbase.h:44
iEQ::Base::m_FirmwareInfo
FirmwareInfo m_FirmwareInfo
Definition: ieqdriverbase.h:236
iEQ::IEQ_PIER_EAST
@ IEQ_PIER_EAST
Definition: ieqdriverbase.h:51
iEQ::TR_CUSTOM
@ TR_CUSTOM
Definition: ieqdriverbase.h:42
iEQ::TR_SIDEREAL
@ TR_SIDEREAL
Definition: ieqdriverbase.h:42
iEQ::TrackRate
TrackRate
Definition: ieqdriverbase.h:42
iEQ::TR_KING
@ TR_KING
Definition: ieqdriverbase.h:42
iEQ::Base::gotoHome
virtual bool gotoHome()
Definition: ieqdriverbase.cpp:198
iEQ::Base::getCoords
bool getCoords(double *ra, double *dec)
Definition: ieqdriverbase.cpp:525
iEQ::Base::FirmwareInfo::ControllerFirmware
std::string ControllerFirmware
Definition: ieqdriverbase.h:80
iEQ::Base::Info::systemStatus
SystemStatus systemStatus
Definition: ieqdriverbase.h:66
iEQ::Base::Info::rememberSystemStatus
SystemStatus rememberSystemStatus
Definition: ieqdriverbase.h:67
iEQ::Base::DRIVER_TIMEOUT
static const uint8_t DRIVER_TIMEOUT
Definition: ieqdriverbase.h:232
iEQ::Base::m_IsDebug
bool m_IsDebug
Definition: ieqdriverbase.h:231
iEQ::Base::setLongitude
virtual bool setLongitude(double longitude)
Definition: ieqdriverbase.cpp:466
iEQ::Base::Info::trackRate
TrackRate trackRate
Definition: ieqdriverbase.h:68
iEQ::Base::setUTCOffset
virtual bool setUTCOffset(double offset_hours)
Definition: ieqdriverbase.cpp:514
iEQ::Base::setCurrentHome
virtual bool setCurrentHome()
Definition: ieqdriverbase.cpp:204
iEQ::Base::unpark
virtual bool unpark()
Definition: ieqdriverbase.cpp:341
iEQ::Base::isCommandSupported
bool isCommandSupported(const std::string &command, bool silent=false)
isCommandSupported Check if specific iOptron command is supported for this mount model
Definition: ieqdriverbase.cpp:771
iEQ::Base::FirmwareInfo::MainBoardFirmware
std::string MainBoardFirmware
Definition: ieqdriverbase.h:79
iEQ::Axis
Axis
Definition: ieqdriverbase.h:47
iEQ::HomeOperation
HomeOperation
Definition: ieqdriverbase.h:49
iEQ::FW_BOARD
@ FW_BOARD
Definition: ieqdriverbase.h:46
iEQ::Base
The BaseFirmware class provides control for iOptron version 2014 v2.0 protocol.
Definition: ieqdriverbase.h:56
iEQ::SR_6
@ SR_6
Definition: ieqdriverbase.h:43
iEQ::Base::Info::longitude
double longitude
Definition: ieqdriverbase.h:72
iEQ::Base::FirmwareInfo::DEFirmware
std::string DEFirmware
Definition: ieqdriverbase.h:82
iEQ::ST_SLEWING
@ ST_SLEWING
Definition: ieqdriverbase.h:34
iEQ::Base::MountInfo::firmware
std::string firmware
Definition: ieqdriverbase.h:89
iEQ::Base::Info::latitude
double latitude
Definition: ieqdriverbase.h:73
iEQ::Base::Base
Base()
Definition: ieqdriverbase.cpp:38
iEQ
Definition: ieqdriverbase.cpp:35
ra
double ra
Definition: ieqprolegacydriver.cpp:43
iEQ::Simulator
Definition: ieqdriverbase.h:278
iEQ::GPS_DATA_OK
@ GPS_DATA_OK
Definition: ieqdriverbase.h:29
iEQ::Base::setGuideRate
virtual bool setGuideRate(double raRate, double deRate)
Definition: ieqdriverbase.cpp:262
iEQ::FirmwareItem
FirmwareItem
Definition: ieqdriverbase.h:46
iEQ::ST_GUIDING
@ ST_GUIDING
Definition: ieqdriverbase.h:35
iEQ::Base::DRIVER_STOP_CHAR
static const char DRIVER_STOP_CHAR
Definition: ieqdriverbase.h:234
iEQ::Base::setTrackMode
virtual bool setTrackMode(TrackRate rate)
Definition: ieqdriverbase.cpp:218
iEQ::ST_TRACKING_PEC_OFF
@ ST_TRACKING_PEC_OFF
Definition: ieqdriverbase.h:33
iEQ::Base::setParkAlt
virtual bool setParkAlt(double alt)
Definition: ieqdriverbase.cpp:448
iEQ::Base::ieqHours
constexpr static const double ieqHours
Definition: ieqdriverbase.h:275
dec
double dec
Definition: ieqprolegacydriver.cpp:44
iEQ::Base::setSlewRate
virtual bool setSlewRate(SlewRate rate)
Definition: ieqdriverbase.cpp:210
iEQ::SR_MAX
@ SR_MAX
Definition: ieqdriverbase.h:43
iEQ::SystemStatus
SystemStatus
Definition: ieqdriverbase.h:30
iEQ::Base::setParkAz
virtual bool setParkAz(double az)
Definition: ieqdriverbase.cpp:432
iEQ::IEQ_FIND_HOME
@ IEQ_FIND_HOME
Definition: ieqdriverbase.h:49
iEQ::Base::setLocalDate
virtual bool setLocalDate(int yy, int mm, int dd)
Definition: ieqdriverbase.cpp:488
iEQ::Base::FirmwareInfo::Model
std::string Model
Definition: ieqdriverbase.h:78
iEQ::Base::MountInfo::code
std::string code
Definition: ieqdriverbase.h:87
iEQ::IEQ_SET_HOME
@ IEQ_SET_HOME
Definition: ieqdriverbase.h:49
iEQ::Base::findHome
virtual bool findHome()
Definition: ieqdriverbase.cpp:188
iEQ::Base::DecodeString
double DecodeString(const char *data, size_t size, double factor)
DecodeString converts the string to a double by dividing by the factor.
Definition: ieqdriverbase.cpp:820
iEQ::IEQ_S
@ IEQ_S
Definition: ieqdriverbase.h:48
iEQ::Base::setRA
virtual bool setRA(double ra)
Definition: ieqdriverbase.cpp:380
iEQ::SR_2
@ SR_2
Definition: ieqdriverbase.h:43
iEQ::Base::getGuideRate
virtual bool getGuideRate(double *raRate, double *deRate)
Definition: ieqdriverbase.cpp:279
iEQ::Base::Info
Definition: ieqdriverbase.h:63
iEQ::SR_8
@ SR_8
Definition: ieqdriverbase.h:43
iEQ::FW_RA
@ FW_RA
Definition: ieqdriverbase.h:46
iEQ::Base::stopMotion
virtual bool stopMotion(Direction dir)
Definition: ieqdriverbase.cpp:167
iEQ::IEQ_N
@ IEQ_N
Definition: ieqdriverbase.h:48
iEQ::Base::startGuide
virtual bool startGuide(Direction dir, uint32_t ms)
Definition: ieqdriverbase.cpp:297
iEQ::Base::sync
virtual bool sync()
Definition: ieqdriverbase.cpp:368
iEQ::Base::getRADEFirmware
bool getRADEFirmware()
Definition: ieqdriverbase.cpp:118
name
const char * name
Definition: indiserver.c:116
iEQ::DEC_AXIS
@ DEC_AXIS
Definition: ieqdriverbase.h:47
iEQ::Base::setDE
virtual bool setDE(double dec)
Definition: ieqdriverbase.cpp:393
iEQ::Base::getStatus
bool getStatus(Info *info)
Definition: ieqdriverbase.cpp:580
iEQ::IEQ_W
@ IEQ_W
Definition: ieqdriverbase.h:48
iEQ::Base::initCommunication
bool initCommunication(int fd)
initCommunication Checks if communication with the mount is working
Definition: ieqdriverbase.cpp:42
iEQ::TS_CONTROLLER
@ TS_CONTROLLER
Definition: ieqdriverbase.h:44
iEQ::IEQ_E
@ IEQ_E
Definition: ieqdriverbase.h:48
iEQ::Base::getModel
bool getModel()
Definition: ieqdriverbase.cpp:72
iEQ::ST_PARKED
@ ST_PARKED
Definition: ieqdriverbase.h:38
iEQ::Base::getUTCDateTime
bool getUTCDateTime(double *utc_hours, int *yy, int *mm, int *dd, int *hh, int *minute, int *ss)
Definition: ieqdriverbase.cpp:539
iEQ::IEQ_PIER_SIDE
IEQ_PIER_SIDE
Definition: ieqdriverbase.h:51
iEQ::GPSStatus
GPSStatus
Definition: ieqdriverbase.h:29
iEQ::HEMI_SOUTH
@ HEMI_SOUTH
Definition: ieqdriverbase.h:45
iEQ::Base::MountInfo
Definition: ieqdriverbase.h:85
iEQ::Base::MountInfo::model
std::string model
Definition: ieqdriverbase.h:88
iEQ::ST_MERIDIAN_FLIPPING
@ ST_MERIDIAN_FLIPPING
Definition: ieqdriverbase.h:36
iEQ::Base::~Base
virtual ~Base()=default
iEQ::Base::ieqDegrees
constexpr static const double ieqDegrees
Definition: ieqdriverbase.h:274
iEQ::Base::park
virtual bool park()
Definition: ieqdriverbase.cpp:326
iEQ::Base::hexDump
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
Definition: ieqdriverbase.cpp:762
iEQ::Base::abort
virtual bool abort()
Definition: ieqdriverbase.cpp:350
iEQ::TR_LUNAR
@ TR_LUNAR
Definition: ieqdriverbase.h:42
iEQ::Direction
Direction
Definition: ieqdriverbase.h:48
iEQ::Base::getFirmwareInfo
const FirmwareInfo & getFirmwareInfo() const
Definition: ieqdriverbase.h:121
iEQ::Base::Info::slewRate
SlewRate slewRate
Definition: ieqdriverbase.h:69
iEQ::Base::setDST
virtual bool setDST(bool enabled)
Definition: ieqdriverbase.cpp:508
iEQ::Base::sendCommand
bool sendCommand(const char *cmd, char *res=nullptr, int cmd_len=-1, int res_len=-1)
sendCommand Send a string command to device.
Definition: ieqdriverbase.cpp:703
iEQ::IEQ_PIER_WEST
@ IEQ_PIER_WEST
Definition: ieqdriverbase.h:51
iEQ::SR_4
@ SR_4
Definition: ieqdriverbase.h:43
iEQ::SR_1
@ SR_1
Definition: ieqdriverbase.h:43
iEQ::IEQ_GOTO_HOME
@ IEQ_GOTO_HOME
Definition: ieqdriverbase.h:49
iEQ::Base::DRIVER_LEN
static const uint8_t DRIVER_LEN
Definition: ieqdriverbase.h:233
FirmwareInfo
struct FirmwareInfo FirmwareInfo
iEQ::Base::Info::timeSource
TimeSource timeSource
Definition: ieqdriverbase.h:70
iEQ::Base::FirmwareInfo::RAFirmware
std::string RAFirmware
Definition: ieqdriverbase.h:81
iEQ::SR_3
@ SR_3
Definition: ieqdriverbase.h:43
iEQ::TimeSource
TimeSource
Definition: ieqdriverbase.h:44
iEQ::Base::slew
virtual bool slew()
Definition: ieqdriverbase.cpp:356
iEQ::Base::getMainFirmware
bool getMainFirmware()
Definition: ieqdriverbase.cpp:98
iEQ::ST_STOPPED
@ ST_STOPPED
Definition: ieqdriverbase.h:32