Instrument Neutral Distributed Interface INDI 2.2.5
dsc.cpp
Go to the documentation of this file.
1/*******************************************************************************
2 Copyright(c) 2017 Jasem Mutlaq. All rights reserved.
3
4 It just gets the encoder position and outputs current coordinates.
5 Calibratoin and syncing not supported yet.
6
7 This library is free software; you can redistribute it and/or
8 modify it under the terms of the GNU Library General Public
9 License version 2 as published by the Free Software Foundation.
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 Library General Public License for more details.
15 .
16 You should have received a copy of the GNU Library General Public License
17 along with this library; see the file COPYING.LIB. If not, write to
18 the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
19 Boston, MA 02110-1301, USA.
20*******************************************************************************/
21
22#include "dsc.h"
23
24#include "indicom.h"
25
26#include <cstring>
27#include <memory>
28#include <regex>
29#include <termios.h>
30#include <unistd.h>
31
32#define DSC_TIMEOUT 2
33#define AXIS_TAB "Axis Settings"
34
35#include <alignment/DriverCommon.h> // For DBG_ALIGNMENT
36using namespace INDI::AlignmentSubsystem;
37
38// We declare an auto pointer to DSC.
39std::unique_ptr<DSC> dsc(new DSC());
40
45
47{
48 return (const char *)"Digital Setting Circle";
49}
50
52{
54
55 // Raw encoder values
56 IUFillNumber(&EncoderN[AXIS1_ENCODER], "AXIS1_ENCODER", "Axis 1", "%0.f", 0, 1e6, 0, 0);
57 IUFillNumber(&EncoderN[AXIS2_ENCODER], "AXIS2_ENCODER", "Axis 2", "%0.f", 0, 1e6, 0, 0);
58 IUFillNumber(&EncoderN[AXIS1_RAW_ENCODER], "AXIS1_RAW_ENCODER", "RAW Axis 1", "%0.f", -1e6, 1e6, 0, 0);
59 IUFillNumber(&EncoderN[AXIS2_RAW_ENCODER], "AXIS2_RAW_ENCODER", "RAW Axis 2", "%0.f", -1e6, 1e6, 0, 0);
60 IUFillNumberVector(&EncoderNP, EncoderN, 4, getDeviceName(), "DCS_ENCODER", "Encoders", MAIN_CONTROL_TAB, IP_RO, 0,
61 IPS_IDLE);
62
63 // Encoder Settings
64 IUFillNumber(&AxisSettingsN[AXIS1_TICKS], "AXIS1_TICKS", "#1 ticks/rev", "%g", 256, 1e6, 0, 4096);
65 IUFillNumber(&AxisSettingsN[AXIS1_DEGREE_OFFSET], "AXIS1_DEGREE_OFFSET", "#1 Degrees Offset", "%g", -180, 180, 30,
66 0);
67 IUFillNumber(&AxisSettingsN[AXIS2_TICKS], "AXIS2_TICKS", "#2 ticks/rev", "%g", 256, 1e6, 0, 4096);
68 IUFillNumber(&AxisSettingsN[AXIS2_DEGREE_OFFSET], "AXIS2_DEGREE_OFFSET", "#2 Degrees Offset", "%g", -180, 180, 30,
69 0);
70 IUFillNumberVector(&AxisSettingsNP, AxisSettingsN, 4, getDeviceName(), "AXIS_SETTINGS", "Axis Resolution", AXIS_TAB,
71 IP_RW, 0, IPS_IDLE);
72
73 // Axis Range
74 IUFillSwitch(&AxisRangeS[AXIS_FULL_STEP], "AXIS_FULL_STEP", "Full Step", ISS_ON);
75 IUFillSwitch(&AxisRangeS[AXIS_HALF_STEP], "AXIS_HALF_STEP", "Half Step", ISS_OFF);
76 IUFillSwitchVector(&AxisRangeSP, AxisRangeS, 2, getDeviceName(), "AXIS_RANGE", "Axis Range", AXIS_TAB, IP_RW,
78
79 // Reverse Encoder Direction
80 IUFillSwitch(&ReverseS[AXIS1_ENCODER], "AXIS1_REVERSE", "Axis 1", ISS_OFF);
81 IUFillSwitch(&ReverseS[AXIS2_ENCODER], "AXIS2_REVERSE", "Axis 2", ISS_OFF);
82 IUFillSwitchVector(&ReverseSP, ReverseS, 2, getDeviceName(), "AXIS_REVERSE", "Reverse", AXIS_TAB, IP_RW,
84
85
87
88 // Offsets applied to raw encoder values to adjust them as necessary
89#if 0
90 IUFillNumber(&EncoderOffsetN[OFFSET_AXIS1_SCALE], "OFFSET_AXIS1_SCALE", "#1 Ticks Scale", "%g", 0, 1e6, 0, 1);
91 IUFillNumber(&EncoderOffsetN[OFFSET_AXIS1_OFFSET], "OFFSET_AXIS1_OFFSET", "#1 Ticks Offset", "%g", -1e6, 1e6, 0, 0);
92 IUFillNumber(&EncoderOffsetN[AXIS1_DEGREE_OFFSET], "AXIS1_DEGREE_OFFSET", "#1 Degrees Offset", "%g", -180, 180, 30, 0);
93 IUFillNumber(&EncoderOffsetN[OFFSET_AXIS2_SCALE], "OFFSET_AIXS2_SCALE", "#2 Ticks Scale", "%g", 0, 1e6, 0, 1);
94 IUFillNumber(&EncoderOffsetN[OFFSET_AXIS2_OFFSET], "OFFSET_AXIS2_OFFSET", "#2 Ticks Offset", "%g", -1e6, 1e6, 0, 0);
95 IUFillNumber(&EncoderOffsetN[AXIS2_DEGREE_OFFSET], "AXIS2_DEGREE_OFFSET", "#2 Degrees Offset", "%g", -180, 180, 30, 0);
96 IUFillNumberVector(&EncoderOffsetNP, EncoderOffsetN, 6, getDeviceName(), "AXIS_OFFSET", "Offsets", AXIS_TAB, IP_RW, 0,
97 IPS_IDLE);
98#endif
99
100 // Simulation encoder values
101 IUFillNumber(&SimEncoderN[AXIS1_ENCODER], "AXIS1_ENCODER", "Axis 1", "%0.f", -1e6, 1e6, 0, 0);
102 IUFillNumber(&SimEncoderN[AXIS2_ENCODER], "AXIS2_ENCODER", "Axis 2", "%0.f", -1e6, 1e6, 0, 0);
103 IUFillNumberVector(&SimEncoderNP, SimEncoderN, 2, getDeviceName(), "SIM_ENCODER", "Sim Encoders", MAIN_CONTROL_TAB,
104 IP_RW, 0, IPS_IDLE);
105
107
109
110 return true;
111}
112
114{
116
117 if (isConnected())
118 {
119 defineProperty(&EncoderNP);
120 defineProperty(&AxisSettingsNP);
121 defineProperty(&AxisRangeSP);
122 defineProperty(&ReverseSP);
123 //defineProperty(&EncoderOffsetNP);
124
125 if (isSimulation())
126 defineProperty(&SimEncoderNP);
127
129 }
130 else
131 {
132 deleteProperty(EncoderNP.name);
133 deleteProperty(AxisSettingsNP.name);
134 deleteProperty(AxisRangeSP.name);
135 deleteProperty(ReverseSP.name);
136 //deleteProperty(EncoderOffsetNP.name);
137
138 if (isSimulation())
139 deleteProperty(SimEncoderNP.name);
140 }
141
142 return true;
143}
144
146{
148
149 IUSaveConfigNumber(fp, &AxisSettingsNP);
150 //IUSaveConfigNumber(fp, &EncoderOffsetNP);
151 IUSaveConfigSwitch(fp, &AxisRangeSP);
152 IUSaveConfigSwitch(fp, &ReverseSP);
153
154 return true;
155}
156
157bool DSC::ISNewText(const char *dev, const char *name, char *texts[], char *names[], int n)
158{
159 ProcessAlignmentTextProperties(this, name, texts, names, n);
160
161 return INDI::Telescope::ISNewText(dev, name, texts, names, n);
162}
163
164bool DSC::ISNewNumber(const char *dev, const char *name, double values[], char *names[], int n)
165{
166 if (dev != nullptr && strcmp(dev, getDeviceName()) == 0)
167 {
168 if (strcmp(name, AxisSettingsNP.name) == 0)
169 {
170 IUUpdateNumber(&AxisSettingsNP, values, names, n);
171 AxisSettingsNP.s = IPS_OK;
172 IDSetNumber(&AxisSettingsNP, nullptr);
173 return true;
174 }
175
176 /*if(strcmp(name,EncoderOffsetNP.name) == 0)
177 {
178 IUUpdateNumber(&EncoderOffsetNP, values, names, n);
179 EncoderOffsetNP.s = IPS_OK;
180 IDSetNumber(&EncoderOffsetNP, nullptr);
181 return true;
182 }*/
183
184 if (strcmp(name, SimEncoderNP.name) == 0)
185 {
186 IUUpdateNumber(&SimEncoderNP, values, names, n);
187 SimEncoderNP.s = IPS_OK;
188 IDSetNumber(&SimEncoderNP, nullptr);
189 return true;
190 }
191
192 ProcessAlignmentNumberProperties(this, name, values, names, n);
193 }
194
195 return INDI::Telescope::ISNewNumber(dev, name, values, names, n);
196}
197
198bool DSC::ISNewSwitch(const char *dev, const char *name, ISState *states, char *names[], int n)
199{
200 if (dev != nullptr && strcmp(dev, getDeviceName()) == 0)
201 {
202 if (strcmp(name, ReverseSP.name) == 0)
203 {
204 IUUpdateSwitch(&ReverseSP, states, names, n);
205 ReverseSP.s = IPS_OK;
206 IDSetSwitch(&ReverseSP, nullptr);
207 return true;
208 }
209
210 if (strcmp(name, AxisRangeSP.name) == 0)
211 {
212 IUUpdateSwitch(&AxisRangeSP, states, names, n);
213 AxisRangeSP.s = IPS_OK;
214
215 if (AxisRangeS[AXIS_FULL_STEP].s == ISS_ON)
216 {
217 LOGF_INFO("Axis range is from 0 to %.f", AxisSettingsN[AXIS1_TICKS].value);
218 }
219 else
220 {
221 LOGF_INFO("Axis range is from -%.f to %.f",
222 AxisSettingsN[AXIS1_TICKS].value / 2, AxisSettingsN[AXIS1_TICKS].value / 2);
223 }
224 IDSetSwitch(&AxisRangeSP, nullptr);
225 return true;
226 }
227
228 ProcessAlignmentSwitchProperties(this, name, states, names, n);
229 }
230
231 return INDI::Telescope::ISNewSwitch(dev, name, states, names, n);
232}
233
235{
236 return true;
237}
238
240{
241 // Send 'Q'
242 char CR[1] = { 0x51 };
243 // Response
244 char response[18] = { 0 };
245 int rc = 0, nbytes_read = 0, nbytes_written = 0;
246
247 LOGF_DEBUG("CMD: %#02X", CR[0]);
248
249 if (isSimulation())
250 {
251 snprintf(response, 18, "%06.f\t%06.f", SimEncoderN[AXIS1_ENCODER].value, SimEncoderN[AXIS2_ENCODER].value);
252 }
253 else
254 {
255 tcflush(PortFD, TCIFLUSH);
256
257 if ((rc = tty_write(PortFD, CR, 1, &nbytes_written)) != TTY_OK)
258 {
259 char errmsg[256];
260 tty_error_msg(rc, errmsg, 256);
261 LOGF_ERROR("Error writing to device %s (%d)", errmsg, rc);
262 return false;
263 }
264
265 // Read until we encounter a CR
266 if ((rc = tty_read_section(PortFD, response, 0x0D, DSC_TIMEOUT, &nbytes_read)) != TTY_OK)
267 {
268 // if we read enough, let's try to process, otherwise throw error
269 // 6 characters for each number
270 if (nbytes_read < 12)
271 {
272 char errmsg[256];
273 tty_error_msg(rc, errmsg, 256);
274 LOGF_ERROR("Error reading from device %s (%d)", errmsg, rc);
275 return false;
276 }
277 }
278 }
279
280 LOGF_DEBUG("RES: %s", response);
281
282 double Axis1Encoder = 0, Axis2Encoder = 0;
283 std::regex rgx(R"((\+?\-?\d+)\s(\+?\-?\d+))");
284 std::smatch match;
285 std::string input(response);
286
287 if (std::regex_search(input, match, rgx))
288 {
289 Axis1Encoder = atof(match.str(1).c_str());
290 Axis2Encoder = atof(match.str(2).c_str());
291 }
292 else
293 {
294 LOGF_ERROR("Error processing response: %s", response);
295 EncoderNP.s = IPS_ALERT;
296 IDSetNumber(&EncoderNP, nullptr);
297 return false;
298 }
299
300 LOGF_DEBUG("Raw Axis encoders. Axis1: %g Axis2: %g", Axis1Encoder, Axis2Encoder);
301
302 EncoderN[AXIS1_RAW_ENCODER].value = Axis1Encoder;
303 EncoderN[AXIS2_RAW_ENCODER].value = Axis2Encoder;
304
305 // Convert Half Step to Full Step
306 if (AxisRangeS[AXIS_HALF_STEP].s == ISS_ON)
307 {
308 if (Axis1Encoder < 0)
309 Axis1Encoder += AxisSettingsN[AXIS1_TICKS].value;
310
311 if (Axis2Encoder < 0)
312 Axis2Encoder += AxisSettingsN[AXIS2_TICKS].value;
313 }
314
315 // Calculate reverse values
316 double Axis1 = Axis1Encoder;
317 if (ReverseS[AXIS1_ENCODER].s == ISS_ON)
318 Axis1 = AxisSettingsN[AXIS1_TICKS].value - Axis1;
319
320#if 0
321 if (Axis1Diff < 0)
322 Axis1Diff += AxisSettingsN[AXIS1_TICKS].value;
323 else if (Axis1Diff > AxisSettingsN[AXIS1_TICKS].value)
324 Axis1Diff -= AxisSettingsN[AXIS1_TICKS].value;
325#endif
326
327 double Axis2 = Axis2Encoder;
328 if (ReverseS[AXIS2_ENCODER].s == ISS_ON)
329 Axis2 = AxisSettingsN[AXIS2_TICKS].value - Axis2;
330
331 LOGF_DEBUG("Axis encoders after reverse. Axis1: %g Axis2: %g", Axis1, Axis2);
332
333 // Apply raw offsets
334
335 // It seems having encoder offsets like this is confusing for users
336 //Axis1 = (Axis1 * EncoderOffsetN[OFFSET_AXIS1_SCALE].value + EncoderOffsetN[OFFSET_AXIS1_OFFSET].value);
337 //Axis2 = (Axis2 * EncoderOffsetN[OFFSET_AXIS2_SCALE].value + EncoderOffsetN[OFFSET_AXIS2_OFFSET].value);
338
339 //LOGF_DEBUG("Axis encoders after raw offsets. Axis1: %g Axis2: %g", Axis1, Axis2);
340
341 EncoderN[AXIS1_ENCODER].value = Axis1;
342 EncoderN[AXIS2_ENCODER].value = Axis2;
343 EncoderNP.s = IPS_OK;
344 IDSetNumber(&EncoderNP, nullptr);
345
346 double Axis1Degrees = (Axis1 / AxisSettingsN[AXIS1_TICKS].value * 360.0) + AxisSettingsN[AXIS1_DEGREE_OFFSET].value;
347 double Axis2Degrees = (Axis2 / AxisSettingsN[AXIS2_TICKS].value * 360.0) + AxisSettingsN[AXIS2_DEGREE_OFFSET].value;
348
349 Axis1Degrees = range360(Axis1Degrees);
350 Axis2Degrees = range360(Axis2Degrees);
351
352 // Adjust for LST
353 double LST = get_local_sidereal_time(m_Location.longitude);
354
355 // Final aligned equatorial position
357
358 // Now we proceed depending on mount type
359 if (getMountType() != MOUNT_ALTAZ)
360 {
361 encoderEquatorialCoordinates.rightascension = Axis1Degrees / 15.0;
362
363 encoderEquatorialCoordinates.rightascension += LST;
364 encoderEquatorialCoordinates.rightascension = range24(encoderEquatorialCoordinates.rightascension);
365
366 encoderEquatorialCoordinates.declination = rangeDec(Axis2Degrees);
367
368 // Do alignment
369 eq = TelescopeEquatorialToSky();
370 }
371 else
372 {
373 encoderHorizontalCoordinates.azimuth = Axis1Degrees;
374 encoderHorizontalCoordinates.azimuth += 180;
375 encoderHorizontalCoordinates.azimuth = range360(encoderHorizontalCoordinates.azimuth);
376
377 encoderHorizontalCoordinates.altitude = Axis2Degrees;
378
379 // Do alignment
380 eq = TelescopeHorizontalToSky();
381
382 char AzStr[64], AltStr[64];
383 fs_sexa(AzStr, Axis1Degrees, 2, 3600);
384 fs_sexa(AltStr, Axis2Degrees, 2, 3600);
385 LOGF_DEBUG("Current Az: %s Current Alt: %s", AzStr, AltStr);
386 }
387
388 // Now feed the rest of the system with corrected data
389 NewRaDec(eq.rightascension, eq.declination);
390 return true;
391}
392
393bool DSC::Sync(double ra, double dec)
394{
395 AlignmentDatabaseEntry NewEntry;
396 INDI::IEquatorialCoordinates RaDec { 0, 0 };
397 INDI::IHorizontalCoordinates AltAz { 0, 0 };
398
399 if (getMountType() != MOUNT_ALTAZ)
400 {
401 double LST = get_local_sidereal_time(m_Location.longitude);
402 RaDec.rightascension = range24(LST - encoderEquatorialCoordinates.rightascension);
403 RaDec.declination = encoderEquatorialCoordinates.declination;
404 }
405 else
406 {
407 AltAz.azimuth = encoderHorizontalCoordinates.azimuth;
408 AltAz.altitude = encoderHorizontalCoordinates.altitude;
409 }
410
411 NewEntry.ObservationJulianDate = ln_get_julian_from_sys();
412 NewEntry.RightAscension = ra;
413 NewEntry.Declination = dec;
414
415 if (getMountType() != MOUNT_ALTAZ)
417 else
419
420 NewEntry.PrivateDataSize = 0;
421 DEBUGF(INDI::AlignmentSubsystem::DBG_ALIGNMENT, "New sync point Date %lf RA %lf DEC %lf TDV(x %lf y %lf z %lf)",
422 NewEntry.ObservationJulianDate, NewEntry.RightAscension, NewEntry.Declination, NewEntry.TelescopeDirection.x,
423 NewEntry.TelescopeDirection.y, NewEntry.TelescopeDirection.z);
424
425 if (!CheckForDuplicateSyncPoint(NewEntry))
426 {
427 GetAlignmentDatabase().push_back(NewEntry);
428
429 // Tell the client about size change
430 UpdateSize();
431
432 // Tell the math plugin to reinitialise
433 Initialise(this);
434
435 return true;
436 }
437
438 return false;
439}
440
441INDI::IEquatorialCoordinates DSC::TelescopeEquatorialToSky()
442{
443 double RightAscension, Declination;
445
446 if (GetAlignmentDatabase().size() > 1)
447 {
448 TelescopeDirectionVector TDV;
449
450 /* and here we convert from ra/dec to hour angle / dec before calling alignment stuff */
451 double lha, lst;
453 lha = get_local_hour_angle(lst, encoderEquatorialCoordinates.rightascension);
454 // convert lha to degrees
455 lha = lha * 360 / 24;
456 eq.rightascension = lha;
457 eq.declination = encoderEquatorialCoordinates.declination;
459
460 if (!TransformTelescopeToCelestialJD(TDV, RightAscension, Declination, ln_get_julian_from_sys()))
461 {
462 RightAscension = encoderEquatorialCoordinates.rightascension;
463 Declination = encoderEquatorialCoordinates.declination;
464 }
465 }
466 else
467 {
468 // With less than 2 align points
469 // Just return raw data
470 RightAscension = encoderEquatorialCoordinates.rightascension;
471 Declination = encoderEquatorialCoordinates.declination;
472 }
473
474 eq.rightascension = RightAscension;
475 eq.declination = Declination;
476 return eq;
477}
478
479INDI::IEquatorialCoordinates DSC::TelescopeHorizontalToSky()
480{
481 INDI::IEquatorialCoordinates eq { 0, 0 };
482 TelescopeDirectionVector TDV = TelescopeDirectionVectorFromAltitudeAzimuth(encoderHorizontalCoordinates);
483 double RightAscension, Declination;
484
485 if (!TransformTelescopeToCelestialJD(TDV, RightAscension, Declination, ln_get_julian_from_sys()))
486 {
487 INDI::IEquatorialCoordinates EquatorialCoordinates {0, 0};
488 TelescopeDirectionVector RotatedTDV(TDV);
489
491 {
492 case ZENITH:
493 break;
494
496 // Rotate the TDV coordinate system anticlockwise (positive) around the y axis by 90 minus
497 // the (positive)observatory latitude. The vector itself is rotated clockwise
498 RotatedTDV.RotateAroundY(90.0 - m_Location.latitude);
499 AltitudeAzimuthFromTelescopeDirectionVector(RotatedTDV, encoderHorizontalCoordinates);
500 break;
501
503 // Rotate the TDV coordinate system clockwise (negative) around the y axis by 90 plus
504 // the (negative)observatory latitude. The vector itself is rotated anticlockwise
505 RotatedTDV.RotateAroundY(-90.0 - m_Location.latitude);
506 AltitudeAzimuthFromTelescopeDirectionVector(RotatedTDV, encoderHorizontalCoordinates);
507 break;
508 }
509
510 INDI::HorizontalToEquatorial(&encoderHorizontalCoordinates, &m_Location, ln_get_julian_from_sys(), &EquatorialCoordinates);
511 RightAscension = EquatorialCoordinates.rightascension;
512 Declination = EquatorialCoordinates.declination;
513 }
514
515 eq.rightascension = RightAscension;
516 eq.declination = Declination;
517 return eq;
518}
519
520bool DSC::updateLocation(double latitude, double longitude, double elevation)
521{
522 UpdateLocation(latitude, longitude, elevation);
523 return true;
524}
525
527{
528 if (!isConnected())
529 return;
530
531 if (enable)
532 {
533 defineProperty(&SimEncoderNP);
534 }
535 else
536 {
537 deleteProperty(SimEncoderNP.name);
538 }
539}
Definition dsc.h:32
virtual bool saveConfigItems(FILE *fp) override
saveConfigItems Save specific properties in the provide config file handler. Child class usually over...
Definition dsc.cpp:145
virtual bool ISNewSwitch(const char *dev, const char *name, ISState *states, char *names[], int n) override
Process the client newSwitch command.
Definition dsc.cpp:198
virtual bool Sync(double ra, double dec) override
Set the telescope current RA and DEC coordinates to the supplied RA and DEC coordinates.
Definition dsc.cpp:393
virtual bool ReadScopeStatus() override
Read telescope status.
Definition dsc.cpp:239
virtual bool initProperties() override
Called to initialize basic properties required all the time.
Definition dsc.cpp:51
virtual const char * getDefaultName() override
Definition dsc.cpp:46
virtual bool updateLocation(double latitude, double longitude, double elevation) override
Update telescope location settings.
Definition dsc.cpp:520
virtual bool Handshake() override
perform handshake with device to check communication
Definition dsc.cpp:234
virtual bool ISNewText(const char *dev, const char *name, char *texts[], char *names[], int n) override
Process the client newSwitch command.
Definition dsc.cpp:157
virtual bool ISNewNumber(const char *dev, const char *name, double values[], char *names[], int n) override
Process the client newNumber command.
Definition dsc.cpp:164
virtual bool updateProperties() override
Called when connected state changes, to add/remove properties.
Definition dsc.cpp:113
virtual void simulationTriggered(bool enable) override
Inform driver that the simulation option was triggered. This function is called after setSimulation i...
Definition dsc.cpp:526
DSC()
Definition dsc.cpp:41
void ProcessAlignmentNumberProperties(Telescope *pTelescope, const char *name, double values[], char *names[], int n)
Call this function from within the ISNewNumber processing path. The function will handle any alignmen...
void ProcessAlignmentSwitchProperties(Telescope *pTelescope, const char *name, ISState *states, char *names[], int n)
Call this function from within the ISNewSwitch processing path. The function will handle any alignmen...
void InitAlignmentProperties(Telescope *pTelescope)
Initialize alignment subsystem properties. It is recommended to call this function within initPropert...
void ProcessAlignmentTextProperties(Telescope *pTelescope, const char *name, char *texts[], char *names[], int n)
Call this function from within the ISNewText processing path. The function will handle any alignment ...
bool CheckForDuplicateSyncPoint(const AlignmentDatabaseEntry &CandidateEntry, double Tolerance=0.1) const
Check if a entry already exists in the database.
AlignmentDatabaseType & GetAlignmentDatabase()
Get a reference to the in memory database.
void UpdateLocation(double latitude, double longitude, double elevation)
Call this function from within the updateLocation processing path.
void UpdateSize()
Call this function when the number of entries in the database changes.
bool TransformTelescopeToCelestialJD(const TelescopeDirectionVector &ApparentTelescopeDirectionVector, double &RightAscension, double &Declination, double JulianDate)
TransformTelescopeToCelestialJD Transforms Mount Coords to Celestial (Sky) Coordinates.
bool Initialise(InMemoryDatabase *pInMemoryDatabase)
Initialise or re-initialise the math plugin. Re-reading the in memory database as necessary.
MountAlignment_t GetApproximateMountAlignment()
Get the approximate alignment of the mount.
void SetAlignmentSubsystemActive(bool enable)
SetAlignmentSubsystemActive Enable or Disable alignment subsystem.
const TelescopeDirectionVector TelescopeDirectionVectorFromAltitudeAzimuth(INDI::IHorizontalCoordinates HorizontalCoordinates)
Calculates a normalised direction vector from the supplied altitude and azimuth.
const TelescopeDirectionVector TelescopeDirectionVectorFromLocalHourAngleDeclination(INDI::IEquatorialCoordinates EquatorialCoordinates)
Calculates a telescope direction vector from the supplied local hour angle and declination.
void AltitudeAzimuthFromTelescopeDirectionVector(const TelescopeDirectionVector TelescopeDirectionVector, INDI::IHorizontalCoordinates &HorizontalCoordinates)
Calculates an altitude and azimuth from the supplied normalised direction vector and declination.
bool isConnected() const
virtual bool deleteProperty(const char *propertyName)
Delete a property and unregister it. It will also be deleted from all clients.
void defineProperty(INumberVectorProperty *property)
bool isSimulation() const
void addAuxControls()
Add Debug, Simulation, and Configuration options to the driver.
TelescopeMountType getMountType() const
void SetTelescopeCapability(uint32_t cap, uint8_t slewRateCount)
SetTelescopeCapability sets the Telescope capabilities. All capabilities must be initialized.
virtual bool initProperties() override
Called to initialize basic properties required all the time.
virtual bool ISNewText(const char *dev, const char *name, char *texts[], char *names[], int n) override
Process the client newSwitch command.
virtual bool updateProperties() override
Called when connected state changes, to add/remove properties.
virtual bool ISNewNumber(const char *dev, const char *name, double values[], char *names[], int n) override
Process the client newNumber command.
IGeographicCoordinates m_Location
void NewRaDec(double ra, double dec)
The child class calls this function when it has updates.
virtual bool saveConfigItems(FILE *fp) override
saveConfigItems Save specific properties in the provide config file handler. Child class usually over...
void setMountType(TelescopeMountType type)
setMountType Report the mount type in TELESCOPE_MOUNT_TYPE. Drivers call it when the type is fixed by...
virtual bool ISNewSwitch(const char *dev, const char *name, ISState *states, char *names[], int n) override
Process the client newSwitch command.
const char * MAIN_CONTROL_TAB
MAIN_CONTROL_TAB Where all the primary controls for the device are located.
#define DSC_TIMEOUT
Definition dsc.cpp:32
#define AXIS_TAB
Definition dsc.cpp:33
std::unique_ptr< DSC > dsc(new DSC())
INDI::PropertyNumber LocationNP
double ra
double dec
ISState
Switch state.
Definition indiapi.h:148
@ ISS_OFF
Definition indiapi.h:149
@ ISS_ON
Definition indiapi.h:150
@ IP_RW
Definition indiapi.h:184
@ IP_RO
Definition indiapi.h:182
@ IPS_ALERT
Definition indiapi.h:162
@ IPS_IDLE
Definition indiapi.h:159
@ IPS_OK
Definition indiapi.h:160
@ ISR_1OFMANY
Definition indiapi.h:171
@ ISR_NOFMANY
Definition indiapi.h:173
int tty_read_section(int fd, char *buf, char stop_char, int timeout, int *nbytes_read)
read buffer from terminal with a delimiter
Definition indicom.c:653
int tty_write(int fd, const char *buf, int nbytes, int *nbytes_written)
Writes a buffer to fd.
Definition indicom.c:418
double range24(double r)
range24 Limits a number to be between 0-24 range.
Definition indicom.c:1311
double range360(double r)
range360 Limits an angle to be between 0-360 degrees.
Definition indicom.c:1321
double rangeDec(double decdegrees)
rangeDec Limits declination value to be in -90 to 90 range.
Definition indicom.c:1341
void tty_error_msg(int err_code, char *err_msg, int err_msg_len)
Retrieve the tty error message.
Definition indicom.c:1243
int fs_sexa(char *out, double a, int w, int fracbase)
Converts a sexagesimal number to a string. sprint the variable a in sexagesimal format into out[].
Definition indicom.c:130
double get_local_hour_angle(double sideral_time, double ra)
get_local_hour_angle Returns local hour angle of an object
Definition indicom.c:1379
Implementations for common driver routines.
@ TTY_OK
Definition indicom.h:54
double get_local_sidereal_time(double longitude)
get_local_sidereal_time Returns local sidereal time given longitude and system clock.
void IUSaveConfigSwitch(FILE *fp, const ISwitchVectorProperty *svp)
Add a switch vector property value to the configuration file.
Definition indidevapi.c:33
void IUFillNumberVector(INumberVectorProperty *nvp, INumber *np, int nnp, const char *dev, const char *name, const char *label, const char *group, IPerm p, double timeout, IPState s)
Assign attributes for a number vector property. The vector's auxiliary elements will be set to NULL.
Definition indidevapi.c:490
void IUSaveConfigNumber(FILE *fp, const INumberVectorProperty *nvp)
Add a number vector property value to the configuration file.
Definition indidevapi.c:23
void IUFillSwitch(ISwitch *sp, const char *name, const char *label, ISState s)
Assign attributes for a switch property. The switch's auxiliary elements will be set to NULL.
Definition indidevapi.c:376
void IUFillNumber(INumber *np, const char *name, const char *label, const char *format, double min, double max, double step, double value)
Assign attributes for a number property. The number's auxiliary elements will be set to NULL.
Definition indidevapi.c:398
void IUFillSwitchVector(ISwitchVectorProperty *svp, ISwitch *sp, int nsp, const char *dev, const char *name, const char *label, const char *group, IPerm p, ISRule r, double timeout, IPState s)
Assign attributes for a switch vector property. The vector's auxiliary elements will be set to NULL.
Definition indidevapi.c:453
int IUUpdateSwitch(ISwitchVectorProperty *svp, ISState *states, char *names[], int n)
Update all switches in a switch vector property.
void IDSetNumber(const INumberVectorProperty *nvp, const char *fmt,...)
void IDSetSwitch(const ISwitchVectorProperty *svp, const char *fmt,...)
int IUUpdateNumber(INumberVectorProperty *nvp, double values[], char *names[], int n)
Update all numbers in a number vector property.
*brief user defined string literal for JSON values *sa std::size_t n
#define LOGF_INFO(fmt,...)
Definition indilogger.h:82
#define LOGF_DEBUG(fmt,...)
Definition indilogger.h:83
#define LOGF_ERROR(fmt,...)
Definition indilogger.h:80
#define DEBUGF(priority, msg,...)
Definition indilogger.h:57
#define getDeviceName
INumber eq[]
Namespace to encapsulate the INDI Alignment Subsystem classes. For more information see "INDI Alignme...
void HorizontalToEquatorial(IHorizontalCoordinates *object, IGeographicCoordinates *observer, double JD, IEquatorialCoordinates *position)
HorizontalToEquatorial Calculate Equatorial EOD Coordinates from horizontal coordinates.
Definition libastro.cpp:161
Entry in the in memory alignment database.
Definition Common.h:152
double RightAscension
Right ascension in decimal hours. N.B. libnova works in decimal degrees so conversion is always neede...
Definition Common.h:190
TelescopeDirectionVector TelescopeDirection
Normalised vector giving telescope pointing direction. This is referred to elsewhere as the "apparent...
Definition Common.h:197
double Declination
Declination in decimal degrees.
Definition Common.h:193
int PrivateDataSize
This size in bytes of any private data.
Definition Common.h:203