Instrument Neutral Distributed Interface INDI 2.2.5
ioptronv3driver.h
Go to the documentation of this file.
1/*
2 INDI IOptron v3 Driver for firmware version 20171001 or later.
3
4 Copyright (C) 2018 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 <map>
25#include "indilogger.h"
26
32namespace IOPv3
33{
34
48typedef enum { SR_1 = 1, SR_2, SR_3, SR_4, SR_5, SR_6, SR_7, SR_8, SR_MAX } IOP_SLEW_RATE;
52typedef enum { RA_AXIS, DEC_AXIS } IOP_AXIS;
53typedef enum { IOP_N, IOP_S, IOP_W, IOP_E } IOP_DIRECTION;
58
71
72typedef struct
73{
74 std::string Model;
75 std::string MainBoardFirmware;
76 std::string ControllerFirmware;
77 std::string RAFirmware;
78 std::string DEFirmware;
80
81class Driver
82{
83
84 public:
85
86 explicit Driver(const char *deviceName);
87 ~Driver() = default;
88
89 static const std::map<std::string, std::string> models;
90 // Slew speeds. N.B. 1024 is arbitrary as the real max value different from
91 // one mount to another. It is used for simulation purposes only.
92 static const uint16_t IOP_SLEW_RATES[];
93
94 /**************************************************************************
95 Communication
96 **************************************************************************/
97 bool sendCommand(const char *command,
98 int count = 1,
99 char *response = nullptr,
100 int minimumCount = -1,
101 uint8_t timeout = IOP_TIMEOUT,
102 uint8_t debugLog = INDI::Logger::DBG_DEBUG);
103 bool sendCommandOk(const char *command);
104 bool checkConnection(int fd);
105
106 /**************************************************************************
107 Get Info
108 **************************************************************************/
110 bool getStatus(IOPInfo *info);
112 bool getFirmwareInfo(FirmwareInfo *info);
114 bool getCoords(double *ra, double *de, IOP_PIER_STATE *pierState, IOP_CW_STATE *cwState);
116 bool getUTCDateTime(double *JD, int *utcOffsetMinutes, bool *dayLightSaving);
117
118 /**************************************************************************
119 Motion
120 **************************************************************************/
121 bool startMotion(IOP_DIRECTION dir);
122 bool stopMotion(IOP_DIRECTION dir);
123 bool setSlewRate(IOP_SLEW_RATE rate);
124 bool setCustomRATrackRate(double rate);
125 bool setTrackMode(IOP_TRACK_RATE rate);
126 bool setTrackEnabled(bool enabled);
127 /* v3.0 Add in PEC Control */
128 bool setPECEnabled(bool enabled); // start / stop PEC
129 bool setPETEnabled(bool enabled); // record / cancel PEC
130 bool getPETEnabled(bool enabled); // check data / recording status
131 // End Mod */
132 bool abort();
133 bool slewNormal();
134 bool slewCWUp();
135 bool sync();
136 bool setRA(double ra);
137 bool setDE(double de);
138
139 /**************************************************************************
140 Home
141 **************************************************************************/
142 bool findHome();
143 bool gotoHome();
144 bool setCurrentHome();
145
146 /**************************************************************************
147 Park
148 **************************************************************************/
149 bool park();
150 bool unpark();
151 bool setParkAz(double az);
152 bool setParkAlt(double alt);
153
154 /**************************************************************************
155 Guide
156 **************************************************************************/
157 bool setGuideRate(double RARate, double DERate);
158 bool getGuideRate(double *RARate, double *DERate);
159 bool startGuide(IOP_DIRECTION dir, uint32_t ms);
160
161 /**************************************************************************
162 Meridian Behavior
163 **************************************************************************/
164 bool setMeridianBehavior(IOP_MB_STATE action, uint8_t degrees);
165 bool getMeridianBehavior(IOP_MB_STATE &action, uint8_t &degrees);
166
167 /**************************************************************************
168 Time & Location
169 **************************************************************************/
170 bool setLongitude(double longitude);
171 bool setLatitude(double latitude);
172 bool setUTCDateTime(double JD);
173 bool setUTCOffset(int offsetMinutes);
174 bool setDaylightSaving(bool enabled);
175
176 /**************************************************************************
177 Misc.
178 **************************************************************************/
179 void setDebug(bool enable);
180 void setSimulation(bool enable);
181
182 /**************************************************************************
183 Simulation
184 **************************************************************************/
188 void setSimSlewRate(IOP_SLEW_RATE value);
191 void setSimRA(double ra);
192 void setSimDE(double de);
193 void setSimLongLat(double longitude, double latitude);
194 void setSimGuideRate(double raRate, double deRate);
195
196 protected:
197
198 /**************************************************************************
199 Firmware Info
200 **************************************************************************/
202 bool getMainFirmware(std::string &mainFirmware, std::string &controllerFirmware);
204 bool getRADEFirmware(std::string &RAFirmware, std::string &DEFirmware);
206 bool getModel(std::string &model);
207
208 struct
209 {
210 double ra;
211 double de;
214 double JD;
217 uint8_t mb_limit;
221
224
225 private:
226 int PortFD = { -1 };
227 bool m_Debug = {false};
228 bool m_Simulation = {false};
229 const char *m_DeviceName;
230
231 // FD timeout in seconds
232 static const uint8_t IOP_TIMEOUT = 5;
233 // Buffer to store mount response
234 static const uint8_t IOP_BUFFER = 64;
235};
236
237}
bool setTrackMode(IOP_TRACK_RATE rate)
void setSimulation(bool enable)
static const std::map< std::string, std::string > models
bool setPETEnabled(bool enabled)
bool setCustomRATrackRate(double rate)
IOP_CW_STATE cw_state
bool setDaylightSaving(bool enabled)
bool startGuide(IOP_DIRECTION dir, uint32_t ms)
bool setRA(double ra)
bool getUTCDateTime(double *JD, int *utcOffsetMinutes, bool *dayLightSaving)
bool setMeridianBehavior(IOP_MB_STATE action, uint8_t degrees)
void setSimGPSstatus(IOP_GPS_STATUS value)
void setSimSlewRate(IOP_SLEW_RATE value)
~Driver()=default
bool getPETEnabled(bool enabled)
bool getGuideRate(double *RARate, double *DERate)
bool getRADEFirmware(std::string &RAFirmware, std::string &DEFirmware)
bool setGuideRate(double RARate, double DERate)
void setSimTrackRate(IOP_TRACK_RATE value)
bool getStatus(IOPInfo *info)
bool sendCommand(const char *command, int count=1, char *response=nullptr, int minimumCount=-1, uint8_t timeout=IOP_TIMEOUT, uint8_t debugLog=INDI::Logger::DBG_DEBUG)
void setSimTimeSource(IOP_TIME_SOURCE value)
void setSimGuideRate(double raRate, double deRate)
bool setParkAz(double az)
bool setParkAlt(double alt)
bool setLatitude(double latitude)
bool setLongitude(double longitude)
bool getCoords(double *ra, double *de, IOP_PIER_STATE *pierState, IOP_CW_STATE *cwState)
bool sendCommandOk(const char *command)
void setDebug(bool enable)
bool getMeridianBehavior(IOP_MB_STATE &action, uint8_t &degrees)
void setSimRA(double ra)
bool stopMotion(IOP_DIRECTION dir)
bool setTrackEnabled(bool enabled)
struct IOPv3::Driver::@351 simData
bool setSlewRate(IOP_SLEW_RATE rate)
bool checkConnection(int fd)
void setSimHemisphere(IOP_HEMISPHERE value)
IOP_MB_STATE mb_state
bool setDE(double de)
bool setUTCDateTime(double JD)
void setSimSytemStatus(IOP_SYSTEM_STATUS value)
void setSimLongLat(double longitude, double latitude)
bool setUTCOffset(int offsetMinutes)
void setSimDE(double de)
bool getFirmwareInfo(FirmwareInfo *info)
bool setPECEnabled(bool enabled)
bool startMotion(IOP_DIRECTION dir)
static const uint16_t IOP_SLEW_RATES[]
IOP_PIER_STATE pier_state
bool getMainFirmware(std::string &mainFirmware, std::string &controllerFirmware)
bool getModel(std::string &model)
int fd
Encapsulates classes and structures required for iOptron Command Set v3 implementation.
@ IOP_PIER_UNKNOWN
@ ST_TRACKING_PEC_ON
@ ST_TRACKING_PEC_OFF
@ ST_MERIDIAN_FLIPPING
std::string ControllerFirmware
std::string MainBoardFirmware
IOP_SYSTEM_STATUS rememberSystemStatus
IOP_GPS_STATUS gpsStatus
IOP_HEMISPHERE hemisphere
IOP_SYSTEM_STATUS systemStatus
IOP_TRACK_RATE trackRate
IOP_SLEW_RATE slewRate
IOP_TIME_SOURCE timeSource