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 
25 typedef enum { GPS_OFF, GPS_ON, GPS_DATA_OK } IEQ_GPS_STATUS;
26 typedef enum {
27     ST_STOPPED,
28     ST_TRACKING_PEC_OFF,
29     ST_SLEWING,
30     ST_GUIDING,
31     ST_MERIDIAN_FLIPPING,
32     ST_TRACKING_PEC_ON,
33     ST_PARKED,
34     ST_HOME
35 } IEQ_SYSTEM_STATUS;
36 typedef enum { TR_SIDEREAL, TR_LUNAR, TR_SOLAR, TR_KING, TR_CUSTOM } IEQ_TRACK_RATE;
37 typedef enum { SR_1, SR_2, SR_3, SR_4, SR_5, SR_6, SR_7, SR_8, SR_MAX } IEQ_SLEW_RATE;
38 typedef enum { TS_RS232, TS_CONTROLLER, TS_GPS } IEQ_TIME_SOURCE;
39 typedef enum { HEMI_SOUTH, HEMI_NORTH } IEQ_HEMISPHERE;
40 typedef enum { FW_MODEL, FW_BOARD, FW_CONTROLLER, FW_RA, FW_DEC } IEQ_FIRMWARE;
41 typedef enum { RA_AXIS, DEC_AXIS } IEQ_AXIS;
42 typedef enum { IEQ_N, IEQ_S, IEQ_W, IEQ_E } IEQ_DIRECTION;
43 typedef enum { IEQ_FIND_HOME, IEQ_SET_HOME, IEQ_GOTO_HOME } IEQ_HOME_OPERATION;
44 
45 typedef struct
46 {
47     IEQ_GPS_STATUS gpsStatus;
48     IEQ_SYSTEM_STATUS systemStatus;
49     IEQ_SYSTEM_STATUS rememberSystemStatus;
50     IEQ_TRACK_RATE trackRate;
51     IEQ_SLEW_RATE slewRate;
52     IEQ_TIME_SOURCE timeSource;
53     IEQ_HEMISPHERE hemisphere;
54 } IEQInfo;
55 
56 typedef struct
57 {
58     std::string Model;
59     std::string MainBoardFirmware;
60     std::string ControllerFirmware;
61     std::string RAFirmware;
62     std::string DEFirmware;
63 } FirmwareInfo;
64 
65 /**************************************************************************
66  Misc.
67 **************************************************************************/
68 
69 void set_ieqpro_debug(bool enable);
70 void set_ieqpro_simulation(bool enable);
71 void set_ieqpro_device(const char *name);
72 
73 /**************************************************************************
74  Simulation
75 **************************************************************************/
76 void set_sim_gps_status(IEQ_GPS_STATUS value);
77 void set_sim_system_status(IEQ_SYSTEM_STATUS value);
78 void set_sim_track_rate(IEQ_TRACK_RATE value);
79 void set_sim_slew_rate(IEQ_SLEW_RATE value);
80 void set_sim_time_source(IEQ_TIME_SOURCE value);
81 void set_sim_hemisphere(IEQ_HEMISPHERE value);
82 void set_sim_ra(double ra);
83 void set_sim_dec(double dec);
84 void set_sim_guide_rate(double rate);
85 
86 /**************************************************************************
87  Diagnostics
88 **************************************************************************/
89 bool check_ieqpro_connection(int fd);
90 
91 /**************************************************************************
92  Get Info
93 **************************************************************************/
94 /** Get iEQ current status info */
95 bool get_ieqpro_status(int fd, IEQInfo *info);
96 /** Get All firmware informatin in addition to mount model */
97 bool get_ieqpro_firmware(int fd, FirmwareInfo *info);
98 /** Get mainboard and controller firmware only */
99 bool get_ieqpro_main_firmware(int fd, FirmwareInfo *info);
100 /** Get RA and DEC firmware info */
101 bool get_ieqpro_radec_firmware(int fd, FirmwareInfo *info);
102 /** Get Mount model */
103 bool get_ieqpro_model(int fd, FirmwareInfo *info);
104 /** Get RA/DEC */
105 bool get_ieqpro_coords(int fd, double *ra, double *dec);
106 /** Get UTC/Date/Time */
107 bool get_ieqpro_utc_date_time(int fd, double *utc_hours, int *yy, int *mm, int *dd, int *hh, int *minute, int *ss);
108 
109 /**************************************************************************
110  Motion
111 **************************************************************************/
112 bool start_ieqpro_motion(int fd, IEQ_DIRECTION dir);
113 bool stop_ieqpro_motion(int fd, IEQ_DIRECTION dir);
114 bool set_ieqpro_slew_rate(int fd, IEQ_SLEW_RATE rate);
115 bool set_ieqpro_custom_ra_track_rate(int fd, double rate);
116 bool set_ieqpro_custom_de_track_rate(int fd, double rate);
117 bool set_ieqpro_track_mode(int fd, IEQ_TRACK_RATE rate);
118 bool set_ieqpro_track_enabled(int fd, bool enabled);
119 bool abort_ieqpro(int fd);
120 bool slew_ieqpro(int fd);
121 bool sync_ieqpro(int fd);
122 bool set_ieqpro_ra(int fd, double ra);
123 bool set_ieqpro_dec(int fd, double dec);
124 
125 /**************************************************************************
126  Home
127 **************************************************************************/
128 bool find_ieqpro_home(int fd);
129 bool goto_ieqpro_home(int fd);
130 bool set_ieqpro_current_home(int fd);
131 
132 /**************************************************************************
133  Park
134 **************************************************************************/
135 bool park_ieqpro(int fd);
136 bool unpark_ieqpro(int fd);
137 
138 /**************************************************************************
139  Guide
140 **************************************************************************/
141 bool set_ieqpro_guide_rate(int fd, double raRate, double deRate);
142 bool get_ieqpro_guide_rate(int fd, double *raRate, double *deRate);
143 bool start_ieqpro_guide(int fd, IEQ_DIRECTION dir, uint32_t ms);
144 
145 /**************************************************************************
146  Time & Location
147 **************************************************************************/
148 bool set_ieqpro_longitude(int fd, double longitude);
149 bool set_ieqpro_latitude(int fd, double latitude);
150 bool get_ieqpro_longitude(int fd, double *longitude);
151 bool get_ieqpro_latitude(int fd, double *latitude);
152 bool set_ieqpro_local_date(int fd, int yy, int mm, int dd);
153 bool set_ieqpro_local_time(int fd, int hh, int mm, int ss);
154 bool set_ieqpro_utc_offset(int fd, double offset_hours);
155 bool set_ieqpro_daylight_saving(int fd, bool enabled);
156