Instrument Neutral Distributed Interface INDI 2.2.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#include <cstdint>
26
27namespace iEQ
28{
29
42
44typedef enum { SR_1, SR_2, SR_3, SR_4, SR_5, SR_6, SR_7, SR_8, SR_MAX } SlewRate;
48typedef enum { RA_AXIS, DEC_AXIS } Axis;
49typedef enum { IEQ_N, IEQ_S, IEQ_W, IEQ_E } Direction;
51
53
57class Base
58{
59 public:
60
61 Base();
62 virtual ~Base() = default;
63
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;
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
279class 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.
static const uint8_t DRIVER_LEN
bool getRADEFirmware()
void setDeviceName(const std::string &name)
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()
const FirmwareInfo & getFirmwareInfo() const
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()
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)
virtual ~Base()=default
virtual bool getGuideRate(double *raRate, double *deRate)
bool getMainFirmware()
virtual bool setAz(double az)
static constexpr const double ieqDegrees
virtual bool setDE(double dec)
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)
static constexpr const double ieqHours
bool getUTCDateTime(double *utc_hours, int *yy, int *mm, int *dd, int *hh, int *minute, int *ss)
virtual bool setLongitude(double longitude)
const char * getDeviceName()
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 setTrackMode(TrackRate rate)
virtual bool findHome()
#define setLocalTime(fd, x, y, z)
double ra
double dec
int fd
@ TR_SIDEREAL
@ TR_SOLAR
@ TR_KING
@ TR_LUNAR
@ TR_CUSTOM
@ TS_CONTROLLER
@ TS_RS232
@ FW_MODEL
@ FW_BOARD
@ FW_CONTROLLER
@ GPS_OFF
@ GPS_DATA_OK
@ HEMI_NORTH
@ HEMI_SOUTH
@ ST_HOME
@ ST_SLEWING
@ ST_MERIDIAN_FLIPPING
@ ST_TRACKING_PEC_OFF
@ ST_STOPPED
@ ST_TRACKING_PEC_ON
@ ST_GUIDING
@ ST_PARKED
IEQ_PIER_SIDE
@ IEQ_PIER_EAST
@ IEQ_PIER_WEST
@ IEQ_PIER_UNCERTAIN
@ IEQ_PIER_UNKNOWN
@ DEC_AXIS
@ RA_AXIS
HomeOperation
@ IEQ_GOTO_HOME
@ IEQ_FIND_HOME
@ IEQ_SET_HOME
uint8_t cmd[4]
Definition pwc-ioctl.h:2
std::string MainBoardFirmware
std::string ControllerFirmware
TrackRate trackRate
SystemStatus systemStatus
TimeSource timeSource
Hemisphere hemisphere
SystemStatus rememberSystemStatus
GPSStatus gpsStatus