1 #if 0
2 LX200 Generic
3 Copyright (C) 2003 - 2017 Jasem Mutlaq (mutlaqja@ikarustech.com)
4 
5 This library is free software;
6 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;
9 either
10 version 2.1 of the License, or (at your option) any later version.
11 
12 This library is distributed in the hope that it will be useful,
13      but WITHOUT ANY WARRANTY;
14 without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
16 Lesser General Public License for more details.
17 
18 You should have received a copy of the GNU Lesser General Public
19 License along with this library;
20 if not, write to the Free Software
21 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110 - 1301  USA
22 
23 2013 - 10 - 27:
24 Updated driver to use INDI::Telescope (JM)
25 2015 - 11 - 25:
26     Use variable POLLMS instead of static POLLMS
27 
28 #endif
29 
30 #include "lx200generic.h"
31 
32 #include "lx200_10micron.h"
33 #include "lx200_16.h"
34 #include "lx200_OnStep.h"
35 #include "lx200ap_experimental.h"
36 #include "lx200ap_gtocp2.h"
37 #include "lx200ap.h"
38 #include "lx200classic.h"
39 #include "lx200fs2.h"
40 #include "lx200gemini.h"
41 #include "lx200pulsar2.h"
42 #include "lx200ss2000pc.h"
43 #include "lx200zeq25.h"
44 #include "lx200gotonova.h"
45 #include "ioptronHC8406.h"
46 #include <cmath>
47 #include <memory>
48 #include <cstring>
49 #include <unistd.h>
50 #include "eq500x.h"
51 
52 /* There is _one_ binary for all LX200 drivers, but each binary is renamed
53 ** to its device name (i.e. lx200gps, lx200_16..etc). The main function will
54 ** fetch from std args the binary name and ISInit will create the apporpiate
55 ** device afterwards. If the binary name does not match any known devices,
56 ** we simply create a generic device.
57 */
58 extern char *__progname;
59 
60 #define LX200_TRACK 0
61 #define LX200_SYNC  1
62 
63 static class Loader
64 {
65     std::unique_ptr<LX200Generic> telescope;
66 public:
Loader()67     Loader()
68     {
69         if (strstr(__progname, "indi_lx200classic"))
70         {
71             IDLog("initializing from LX200 classic device...\n");
72             telescope.reset(new LX200Classic());
73         }
74         else if (strstr(__progname, "indi_lx200_OnStep"))
75         {
76             IDLog("initializing from LX200 OnStep device...\n");
77             telescope.reset(new LX200_OnStep());
78         }
79         else if (strstr(__progname, "indi_lx200gps"))
80         {
81             IDLog("initializing from LX200 GPS device...\n");
82             telescope.reset(new LX200GPS());
83         }
84         else if (strstr(__progname, "indi_lx200_16"))
85         {
86             IDLog("Initializing from LX200 16 device...\n");
87             telescope.reset(new LX200_16());
88         }
89         else if (strstr(__progname, "indi_lx200autostar"))
90         {
91             IDLog("initializing from Autostar device...\n");
92             telescope.reset(new LX200Autostar());
93         }
94         else if (strstr(__progname, "indi_lx200ap_experimental"))
95         {
96             IDLog("initializing from Astrophysics Experimental device...\n");
97             telescope.reset(new LX200AstroPhysicsExperimental());
98         }
99         else if (strstr(__progname, "indi_lx200ap_gtocp2"))
100         {
101             IDLog("initializing from Astrophysics GTOCP2 device...\n");
102             telescope.reset(new LX200AstroPhysicsGTOCP2());
103         }
104         else if (strstr(__progname, "indi_lx200ap"))
105         {
106             IDLog("initializing from Astrophysics device...\n");
107             telescope.reset(new LX200AstroPhysics());
108         }
109         else if (strstr(__progname, "indi_lx200gemini"))
110         {
111             IDLog("initializing from Losmandy Gemini device...\n");
112             telescope.reset(new LX200Gemini());
113         }
114         else if (strstr(__progname, "indi_lx200zeq25"))
115         {
116             IDLog("initializing from ZEQ25 device...\n");
117             telescope.reset(new LX200ZEQ25());
118         }
119         else if (strstr(__progname, "indi_lx200gotonova"))
120         {
121             IDLog("initializing from GotoNova device...\n");
122             telescope.reset(new LX200GotoNova());
123         }
124         else if (strstr(__progname, "indi_ioptronHC8406"))
125         {
126             IDLog("initializing from ioptron telescope Hand Controller HC8406 device...\n");
127             telescope.reset(new ioptronHC8406());
128         }
129         else if (strstr(__progname, "indi_lx200pulsar2"))
130         {
131             IDLog("initializing from pulsar2 device...\n");
132             telescope.reset(new LX200Pulsar2());
133         }
134         else if (strstr(__progname, "indi_lx200ss2000pc"))
135         {
136             IDLog("initializing from skysensor2000pc device...\n");
137             telescope.reset(new LX200SS2000PC());
138         }
139         else if (strstr(__progname, "indi_lx200fs2"))
140         {
141             IDLog("initializing from Astro-Electronic FS-2...\n");
142             telescope.reset(new LX200FS2());
143         }
144         else if (strstr(__progname, "indi_lx200_10micron"))
145         {
146             IDLog("initializing for 10Micron mount...\n");
147             telescope.reset(new LX200_10MICRON());
148         }
149         else if (strstr(__progname, "indi_eq500x"))
150         {
151             IDLog("initializing for EQ500X mount...\n");
152             telescope.reset(new EQ500X());
153         }
154         // be nice and give them a generic device
155         else
156             telescope.reset(new LX200Generic());
157     }
158 } loader;
159 
160 /**************************************************
161 *** LX200 Generic Implementation
162 ***************************************************/
163 
LX200Generic()164 LX200Generic::LX200Generic()
165 {
166     setVersion(2, 1);
167 
168     currentSiteNum = 1;
169     trackingMode   = LX200_TRACK_SIDEREAL;
170     GuideNSTID     = 0;
171     GuideWETID     = 0;
172 
173     DBG_SCOPE = INDI::Logger::getInstance().addDebugLevel("Scope Verbose", "SCOPE");
174 
175     setLX200Capability(LX200_HAS_FOCUS | LX200_HAS_TRACKING_FREQ | LX200_HAS_ALIGNMENT_TYPE | LX200_HAS_SITES |
176                        LX200_HAS_PULSE_GUIDING);
177 
178     SetTelescopeCapability(TELESCOPE_CAN_PARK | TELESCOPE_CAN_SYNC | TELESCOPE_CAN_GOTO | TELESCOPE_CAN_ABORT |
179                            TELESCOPE_HAS_TIME | TELESCOPE_HAS_LOCATION | TELESCOPE_HAS_TRACK_MODE,
180                            4);
181 
182     LOG_DEBUG("Initializing from Generic LX200 device...");
183 }
184