1 | /* |
---|
2 | IEQ45 Driver |
---|
3 | Copyright (C) 2011 Nacho Mas (mas.ignacio@gmail.com). Only litle changes |
---|
4 | from lx200basic made it by Jasem Mutlaq (mutlaqja@ikarustech.com) |
---|
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 | |
---|
22 | #ifndef IEQ45DRIVER_H |
---|
23 | #define IEQ45DRIVER_H |
---|
24 | |
---|
25 | /* Slew speeds */ |
---|
26 | enum TSlew { IEQ45_SLEW_MAX, IEQ45_SLEW_FIND, IEQ45_SLEW_CENTER, IEQ45_SLEW_GUIDE}; |
---|
27 | /* Alignment modes */ |
---|
28 | enum TAlign { IEQ45_ALIGN_POLAR, IEQ45_ALIGN_ALTAZ, IEQ45_ALIGN_LAND }; |
---|
29 | /* Directions */ |
---|
30 | enum TDirection { IEQ45_NORTH, IEQ45_WEST, IEQ45_EAST, IEQ45_SOUTH, IEQ45_ALL}; |
---|
31 | /* Formats of Right ascention and Declenation */ |
---|
32 | enum TFormat { IEQ45_SHORT_FORMAT, IEQ45_LONG_FORMAT}; |
---|
33 | /* Time Format */ |
---|
34 | enum TTimeFormat { IEQ45_24, IEQ45_AM, IEQ45_PM}; |
---|
35 | /* Focus operation */ |
---|
36 | enum TFocusMotion { IEQ45_FOCUSIN, IEQ45_FOCUSOUT }; |
---|
37 | enum TFocusSpeed { IEQ45_HALTFOCUS = 0, IEQ45_FOCUSSLOW, IEQ45_FOCUSFAST}; |
---|
38 | /* Library catalogs */ |
---|
39 | enum TCatalog { IEQ45_STAR_C, IEQ45_DEEPSKY_C}; |
---|
40 | /* Frequency mode */ |
---|
41 | enum StarCatalog { IEQ45_STAR, IEQ45_SAO, IEQ45_GCVS }; |
---|
42 | /* Deep Sky Catalogs */ |
---|
43 | enum DeepSkyCatalog { IEQ45_NGC, IEQ45_IC, IEQ45_UGC, IEQ45_CALDWELL, IEQ45_ARP, IEQ45_ABELL, IEQ45_MESSIER_C}; |
---|
44 | /* Mount tracking frequency, in Hz */ |
---|
45 | enum TFreq { IEQ45_TRACK_SIDERAL, IEQ45_TRACK_LUNAR, IEQ45_TRACK_SOLAR,IEQ45_TRACK_ZERO}; |
---|
46 | |
---|
47 | |
---|
48 | #define MaxReticleDutyCycle 15 |
---|
49 | #define MaxFocuserSpeed 4 |
---|
50 | |
---|
51 | /* GET formatted sexagisemal value from device, return as double */ |
---|
52 | #define getIEQ45RA(fd, x) getCommandSexa(fd, x, ":GR#") //OK |
---|
53 | #define getIEQ45DEC(fd, x) getCommandSexa(fd, x, ":GD#") //OK |
---|
54 | //#define getObjectRA(fd, x) getCommandSexa(fd, x, ":Gr#") //NO OK |
---|
55 | //#define getObjectDEC(fd, x) getCommandSexa(fd, x, ":Gd#") //NO OK |
---|
56 | //#define getLocalTime12(fd, x) getCommandSexa(fd, x, ":Ga#") //NO OK |
---|
57 | #define getLocalTime24(fd, x) getCommandSexa(fd, x, ":GL#") //OK |
---|
58 | #define getSDTime(fd, x) getCommandSexa(fd, x, ":GS#") //OK |
---|
59 | #define getIEQ45Alt(fd, x) getCommandSexa(fd, x, ":GA#") //OK |
---|
60 | #define getIEQ45Az(fd, x) getCommandSexa(fd, x, ":GZ#") //OK |
---|
61 | |
---|
62 | /* GET String from device and store in supplied buffer x */ |
---|
63 | //#define getObjectInfo(fd, x) getCommandString(fd, x, ":LI#") //NO OK |
---|
64 | //#define getVersionDate(fd, x) getCommandString(fd, x, ":GVD#") //NO OK |
---|
65 | //#define getVersionTime(fd, x) getCommandString(fd, x, ":GVT#") //NO OK |
---|
66 | //#define getFullVersion(fd, x) getCommandString(fd, x, ":GVF#") //NO OK |
---|
67 | //#define getVersionNumber(fd, x) getCommandString(fd, x, ":GVN#") //NO OK |
---|
68 | //#define getProductName(fd, x) getCommandString(fd, x, ":GVP#") //NO OK |
---|
69 | //#define turnGPS_StreamOn(fd) getCommandString(fd, x, ":gps#") //NO OK |
---|
70 | |
---|
71 | /* GET Int from device and store in supplied pointer to integer x */ |
---|
72 | #define getUTCOffset(fd, x) getCommandInt(fd, x, ":GG#") //OK |
---|
73 | //#define getMaxElevationLimit(fd, x) getCommandInt(fd, x, ":Go#") //NO OK |
---|
74 | //#define getMinElevationLimit(fd, x) getCommandInt(fd, x, ":Gh#") //NO OK |
---|
75 | |
---|
76 | /* Generic set, x is an integer */ |
---|
77 | //#define setReticleDutyFlashCycle(fd, x) setCommandInt(fd, x, ":BD") |
---|
78 | #define setReticleFlashRate(fd, x) setCommandInt(fd, x, ":B") |
---|
79 | #define setFocuserSpeed(fd, x) setCommandInt(fd, x, ":F") |
---|
80 | #define setSlewSpeed(fd, x) setCommandInt(fd, x, ":Sw") |
---|
81 | |
---|
82 | /* Set X:Y:Z */ |
---|
83 | #define setLocalTime(fd, x,y,z) setCommandXYZ(fd, x,y,z, ":SL") |
---|
84 | #define setSDTime(fd, x,y,z) setCommandXYZ(fd, x,y,z, ":SS") |
---|
85 | |
---|
86 | /* GPS Specefic */ |
---|
87 | #define turnGPSOn(fd) write(fd, ":g+#", 5) |
---|
88 | #define turnGPSOff(fd) write(fd, ":g-#", 5) |
---|
89 | #define alignGPSScope(fd) write(fd, ":Aa#", 5) |
---|
90 | #define gpsSleep(fd) write(fd, ":hN#", 5) |
---|
91 | #define gpsWakeUp(fd) write(fd, ":hW#", 5); |
---|
92 | #define gpsRestart(fd) write(fd, ":I#", 4); |
---|
93 | #define updateGPS_System(fd) setStandardProcedure(fd, ":gT#") |
---|
94 | #define enableDecAltPec(fd) write(fd, ":QA+#", 6) |
---|
95 | #define disableDecAltPec(fd) write(fd, ":QA-#", 6) |
---|
96 | #define enableRaAzPec(fd) write(fd, ":QZ+#", 6) |
---|
97 | #define disableRaAzPec(fd) write(fd, ":QZ-#", 6) |
---|
98 | #define activateAltDecAntiBackSlash(fd) write(fd, "$BAdd#", 7) |
---|
99 | #define activateAzRaAntiBackSlash(fd) write(fd, "$BZdd#", 7) |
---|
100 | #define SelenographicSync(fd) write(fd, ":CL#", 5); |
---|
101 | |
---|
102 | #define slewToAltAz(fd) setStandardProcedure(fd, ":MA#") |
---|
103 | #define toggleTimeFormat(fd) write(fd, ":H#", 4) |
---|
104 | #define increaseReticleBrightness(fd) write(fd, ":B+#", 5) |
---|
105 | #define decreaseReticleBrightness(fd) write(fd, ":B-#", 5) |
---|
106 | #define turnFanOn(fd) write(fd, ":f+#", 5) |
---|
107 | #define turnFanOff(fd) write(fd, ":f-#", 5) |
---|
108 | #define seekHomeAndSave(fd) write(fd, ":hS#", 5) |
---|
109 | #define seekHomeAndSet(fd) write(fd, ":hF#", 5) |
---|
110 | #define turnFieldDeRotatorOn(fd) write(fd, ":r+#", 5) |
---|
111 | #define turnFieldDeRotatorOff(fd) write(fd, ":r-#", 5) |
---|
112 | #define slewToPark(fd) write(fd, ":hP#", 5) |
---|
113 | |
---|
114 | |
---|
115 | #ifdef __cplusplus |
---|
116 | extern "C" { |
---|
117 | #endif |
---|
118 | |
---|
119 | /************************************************************************** |
---|
120 | Basic I/O - OBSELETE |
---|
121 | **************************************************************************/ |
---|
122 | /*int openPort(const char *portID); |
---|
123 | int portRead(char *buf, int nbytes, int timeout); |
---|
124 | int portWrite(const char * buf); |
---|
125 | int IEQ45readOut(int timeout); |
---|
126 | int Connect(const char* device); |
---|
127 | void Disconnect();*/ |
---|
128 | |
---|
129 | /************************************************************************** |
---|
130 | Diagnostics |
---|
131 | **************************************************************************/ |
---|
132 | char ACK(int fd); |
---|
133 | /*int testTelescope(); |
---|
134 | int testAP();*/ |
---|
135 | int check_IEQ45_connection(int fd); |
---|
136 | |
---|
137 | /************************************************************************** |
---|
138 | Get Commands: store data in the supplied buffer. Return 0 on success or -1 on failure |
---|
139 | **************************************************************************/ |
---|
140 | |
---|
141 | /* Get Double from Sexagisemal */ |
---|
142 | int getCommandSexa(int fd, double *value, const char *cmd); |
---|
143 | /* Get String */ |
---|
144 | int getCommandString(int fd, char *data, const char* cmd); |
---|
145 | /* Get Int */ |
---|
146 | int getCommandInt(int fd, int *value, const char* cmd); |
---|
147 | /* Get tracking frequency */ |
---|
148 | int getTrackFreq(int fd, double * value); |
---|
149 | /* Get site Latitude */ |
---|
150 | int getSiteLatitude(int fd, int *dd, int *mm); |
---|
151 | /* Get site Longitude */ |
---|
152 | int getSiteLongitude(int fd, int *ddd, int *mm); |
---|
153 | /* Get Calender data */ |
---|
154 | int getCalenderDate(int fd, char *date); |
---|
155 | /* Get site Name */ |
---|
156 | int getSiteName(int fd, char *siteName, int siteNum); |
---|
157 | /* Get Number of Bars */ |
---|
158 | int getNumberOfBars(int fd, int *value); |
---|
159 | /* Get Home Search Status */ |
---|
160 | int getHomeSearchStatus(int fd, int *status); |
---|
161 | /* Get OTA Temperature */ |
---|
162 | int getOTATemp(int fd, double * value); |
---|
163 | /* Get time format: 12 or 24 */ |
---|
164 | int getTimeFormat(int fd, int *format); |
---|
165 | /* Get RA, DEC from Sky Commander controller */ |
---|
166 | int updateSkyCommanderCoord(int fd, double *ra, double *dec); |
---|
167 | /* Get RA, DEC from Intelliscope/SkyWizard controllers */ |
---|
168 | int updateIntelliscopeCoord (int fd, double *ra, double *dec); |
---|
169 | |
---|
170 | /************************************************************************** |
---|
171 | Set Commands |
---|
172 | **************************************************************************/ |
---|
173 | |
---|
174 | /* Set Int */ |
---|
175 | int setCommandInt(int fd, int data, const char *cmd); |
---|
176 | /* Set Sexigesimal */ |
---|
177 | int setCommandXYZ(int fd, int x, int y, int z, const char *cmd); |
---|
178 | /* Common routine for Set commands */ |
---|
179 | int setStandardProcedure(int fd, char * writeData); |
---|
180 | /* Set Slew Mode */ |
---|
181 | int setSlewMode(int fd, int slewMode); |
---|
182 | /* Set Alignment mode */ |
---|
183 | int setAlignmentMode(int fd, unsigned int alignMode); |
---|
184 | /* Set Object RA */ |
---|
185 | int setObjectRA(int fd, double ra); |
---|
186 | /* set Object DEC */ |
---|
187 | int setObjectDEC(int fd, double dec); |
---|
188 | /* Set Calender date */ |
---|
189 | int setCalenderDate(int fd, int dd, int mm, int yy); |
---|
190 | /* Set UTC offset */ |
---|
191 | int setUTCOffset(int fd, double hours); |
---|
192 | /* Set Track Freq */ |
---|
193 | int setTrackFreq(int fd, double trackF); |
---|
194 | /* Set current site longitude */ |
---|
195 | int setSiteLongitude(int fd, double Long); |
---|
196 | /* Set current site latitude */ |
---|
197 | int setSiteLatitude(int fd, double Lat); |
---|
198 | /* Set Object Azimuth */ |
---|
199 | int setObjAz(int fd, double az); |
---|
200 | /* Set Object Altitude */ |
---|
201 | int setObjAlt(int fd, double alt); |
---|
202 | /* Set site name */ |
---|
203 | int setSiteName(int fd, char * siteName, int siteNum); |
---|
204 | /* Set maximum slew rate */ |
---|
205 | int setMaxSlewRate(int fd, int slewRate); |
---|
206 | /* Set focuser motion */ |
---|
207 | int setFocuserMotion(int fd, int motionType); |
---|
208 | /* SET GPS Focuser raneg (1 to 4) */ |
---|
209 | int setGPSFocuserSpeed (int fd, int speed); |
---|
210 | /* Set focuser speed mode */ |
---|
211 | int setFocuserSpeedMode (int fd, int speedMode); |
---|
212 | /* Set minimum elevation limit */ |
---|
213 | int setMinElevationLimit(int fd, int min); |
---|
214 | /* Set maximum elevation limit */ |
---|
215 | int setMaxElevationLimit(int fd, int max); |
---|
216 | |
---|
217 | /************************************************************************** |
---|
218 | Motion Commands |
---|
219 | **************************************************************************/ |
---|
220 | /* Slew to the selected coordinates */ |
---|
221 | int Slew(int fd); |
---|
222 | /* Synchronize to the selected coordinates and return the matching object if any */ |
---|
223 | int Sync(int fd, char *matchedObject); |
---|
224 | /* Abort slew in all axes */ |
---|
225 | int abortSlew(int fd); |
---|
226 | /* Move into one direction, two valid directions can be stacked */ |
---|
227 | int MoveTo(int fd, int direction); |
---|
228 | /* Halt movement in a particular direction */ |
---|
229 | int HaltMovement(int fd, int direction); |
---|
230 | /* Select the tracking mode */ |
---|
231 | int selectTrackingMode(int fd, int trackMode); |
---|
232 | /* Select Astro-Physics tracking mode */ |
---|
233 | int selectAPTrackingMode(int fd, int trackMode); |
---|
234 | /* Send Pulse-Guide command (timed guide move), two valid directions can be stacked */ |
---|
235 | int SendPulseCmd(int fd, int direction, int duration_msec); |
---|
236 | |
---|
237 | /************************************************************************** |
---|
238 | Other Commands |
---|
239 | **************************************************************************/ |
---|
240 | /* Ensures IEQ45 RA/DEC format is long */ |
---|
241 | int checkIEQ45Format(int fd); |
---|
242 | /* Select a site from the IEQ45 controller */ |
---|
243 | int selectSite(int fd, int siteNum); |
---|
244 | /* Select a catalog object */ |
---|
245 | int selectCatalogObject(int fd, int catalog, int NNNN); |
---|
246 | /* Select a sub catalog */ |
---|
247 | int selectSubCatalog(int fd, int catalog, int subCatalog); |
---|
248 | |
---|
249 | #ifdef __cplusplus |
---|
250 | } |
---|
251 | #endif |
---|
252 | |
---|
253 | #endif |
---|