1 /*
2     Pulsar 2 INDI driver
3 
4     Copyright (C) 2016, 2017 Jasem Mutlaq and Camiel Severijns
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 "lx200generic.h"
24 
25 
26 class LX200Pulsar2 : public LX200Generic
27 {
28   public:
29     LX200Pulsar2();
~LX200Pulsar2()30     virtual ~LX200Pulsar2() {}
31 
32 	static constexpr char const *ADVANCED_TAB = "Advanced Setup";
33 	static constexpr bool verboseLogging = false;
34 	static constexpr char Null = '\0';
35 
36 
37     virtual const char *getDefaultName() override;
38 
39     virtual bool Connect() override;
40     virtual bool Disconnect() override;
41     virtual bool Handshake() override;
42     virtual bool ReadScopeStatus() override;
43     virtual void ISGetProperties(const char *dev) override;
44     virtual bool initProperties() override;
45     virtual bool updateProperties() override;
46     virtual bool ISNewNumber(const char *dev, const char *name, double values[], char *names[], int n) override;
47     virtual bool ISNewSwitch(const char *dev, const char *name, ISState *states, char *names[], int n) override;
48     virtual bool ISNewText(const char *dev, const char *name, char *texts[], char *names[], int n) override;
49 
50     static const unsigned int numPulsarTrackingRates = 7;
51 
52   protected:
53     virtual bool SetSlewRate(int index) override;
54     virtual bool MoveNS(INDI_DIR_NS dir, TelescopeMotionCommand command) override;
55     virtual bool MoveWE(INDI_DIR_WE dir, TelescopeMotionCommand command) override;
56     virtual bool Abort() override;
57 
58     virtual IPState GuideNorth(uint32_t ms) override;
59     virtual IPState GuideSouth(uint32_t ms) override;
60     virtual IPState GuideEast(uint32_t ms) override;
61     virtual IPState GuideWest(uint32_t ms) override;
62 
63     virtual bool updateTime(ln_date *utc, double utc_offset) override;
64     virtual bool updateLocation(double latitude, double longitude, double elevation) override;
65 
66     virtual bool Goto(double, double) override;
67     virtual bool Park() override;
68     virtual bool Sync(double ra, double dec) override;
69     virtual bool UnPark() override;
70 
71     virtual bool isSlewComplete() override;
72     virtual bool checkConnection() override;
73 
74     virtual void getBasicData() override;
75 
76 
77     // Pier Side
78     ISwitch PierSideS[2];
79     ISwitchVectorProperty PierSideSP;
80 	ISwitch PierSideToggleS[1];
81 	ISwitchVectorProperty PierSideToggleSP;
82 
83     // Tracking Rates
84     ISwitchVectorProperty TrackingRateIndSP;
85     ISwitch TrackingRateIndS[numPulsarTrackingRates];
86 
87     // Guide Speed Indicator
88     INumberVectorProperty GuideSpeedIndNP;
89     INumber GuideSpeedIndN[1];
90     // Center Speed Indicator
91     INumberVectorProperty CenterSpeedIndNP;
92     INumber CenterSpeedIndN[1];
93     // Find Speed Indicator
94     INumberVectorProperty FindSpeedIndNP;
95     INumber FindSpeedIndN[1];
96     // Slew Speed Indicator
97     INumberVectorProperty SlewSpeedIndNP;
98     INumber SlewSpeedIndN[1];
99     // GoTo Speed Indicator
100     INumberVectorProperty GoToSpeedIndNP;
101     INumber GoToSpeedIndN[1];
102 
103 	// Ramp
104 	INumberVectorProperty RampNP;
105 	INumber RampN[2];
106 
107 	// Reduction
108 	INumberVectorProperty ReductionNP;
109 	INumber ReductionN[2];
110 
111 	// Maingear
112 	INumberVectorProperty MaingearNP;
113 	INumber MaingearN[2];
114 
115 	// Backlash
116 	INumberVectorProperty BacklashNP;
117 	INumber BacklashN[2];
118 
119 	// Home Position
120 	INumberVectorProperty HomePositionNP;
121 	INumber HomePositionN[2];
122 
123 	// SwapTubeDelay
124 	INumberVectorProperty SwapTubeDelayNP;
125 	INumber SwapTubeDelayN[1];
126 
127 	// Mount Type
128 	ISwitchVectorProperty MountTypeSP;
129 	ISwitch MountTypeS[3];
130 
131     // Periodic error correction on or off
132     ISwitchVectorProperty PeriodicErrorCorrectionSP;
133     ISwitch PeriodicErrorCorrectionS[2];
134 
135     // Pole crossing on or off
136     ISwitchVectorProperty PoleCrossingSP;
137     ISwitch PoleCrossingS[2];
138 
139     // Refraction correction on or off
140     ISwitchVectorProperty RefractionCorrectionSP;
141     ISwitch RefractionCorrectionS[2];
142 
143 	// Rotation RA
144 	ISwitchVectorProperty RotationRASP;
145 	ISwitch RotationRAS[2];
146 	// Rotation DEC
147 	ISwitchVectorProperty RotationDecSP;
148 	ISwitch RotationDecS[2];
149 
150 	// User1 Rate
151 	INumberVectorProperty UserRate1NP;
152 	INumber UserRate1N[2];
153 
154 
155 	// Tracking Current
156 	INumberVectorProperty TrackingCurrentNP;
157 	INumber TrackingCurrentN[1]; // only one entry for both RA and Dec
158 	// Stop Current
159 	INumberVectorProperty StopCurrentNP;
160 	INumber StopCurrentN[1]; // only one entry for both RA and Dec
161 	// GoTo Current
162 	INumberVectorProperty GoToCurrentNP;
163 	INumber GoToCurrentN[1]; // only one entry for both RA and Dec
164 
165   private:
166 
167     bool storeScopeLocation();
168     virtual bool sendScopeTime() override;
169 
170     bool isSlewing();
171     bool just_started_slewing;
172 
173 	bool local_properties_updated = false;
174 	bool initialization_complete = false;  // actually completion of getBasicData
175 
176 };
177