Instrument Neutral Distributed Interface INDI 2.2.5
ioptronv3.cpp
Go to the documentation of this file.
1/*
2 INDI IOptron v3 Driver for firmware version 20171001 or later.
3
4 Copyright (C) 2018 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 Updated for PEC V3
21*/
22
23#include "ioptronv3.h"
26#include "indicom.h"
27
28#include <libnova/transform.h>
29#include <libnova/sidereal_time.h>
30
31#include <memory>
32
33#include <cmath>
34#include <cstring>
35
36using namespace IOPv3;
37
38#define MOUNTINFO_TAB "Mount Info"
39// #define PEC_TAB "PEC" //Not Needed
40
41// We declare an auto pointer to IOptronV3.
42static std::unique_ptr<IOptronV3> scope(new IOptronV3());
43
44/* Constructor */
46{
47 setVersion(1, 7);
48
49 driver.reset(new Driver(getDeviceName()));
50
51 scopeInfo.gpsStatus = GPS_OFF;
52 scopeInfo.trackRate = TR_SIDEREAL;
53 scopeInfo.systemStatus = ST_TRACKING_PEC_OFF;
54 scopeInfo.slewRate = SR_MAX;
55 scopeInfo.timeSource = TS_RS232;
56 scopeInfo.hemisphere = HEMI_NORTH;
57
58 DBG_SCOPE = INDI::Logger::getInstance().addDebugLevel("Scope Verbose", "SCOPE");
59
74 9
75 );
76}
77
79{
80 return "iOptronV3";
81}
82
84{
86
87 // Slew Rates
88 SlewRateSP[0].setLabel("1x");
89 SlewRateSP[1].setLabel("2x");
90 SlewRateSP[2].setLabel("8x");
91 SlewRateSP[3].setLabel("16x");
92 SlewRateSP[4].setLabel("64x");
93 SlewRateSP[5].setLabel("128x");
94 SlewRateSP[6].setLabel("256x");
95 SlewRateSP[7].setLabel("512x");
96 SlewRateSP[8].setLabel("MAX");
97 SlewRateSP.reset();
98 // 64x is the default
99 SlewRateSP[4].setState(ISS_ON);
100
101 // Max is the default
102 SlewRateSP[8].setState(ISS_ON);
103
104 /* Firmware */
105 IUFillText(&FirmwareT[FW_MODEL], "Model", "", nullptr);
106 IUFillText(&FirmwareT[FW_BOARD], "Board", "", nullptr);
107 IUFillText(&FirmwareT[FW_CONTROLLER], "Controller", "", nullptr);
108 IUFillText(&FirmwareT[FW_RA], "RA", "", nullptr);
109 IUFillText(&FirmwareT[FW_DEC], "DEC", "", nullptr);
110 IUFillTextVector(&FirmwareTP, FirmwareT, 5, getDeviceName(), "Firmware Info", "", MOUNTINFO_TAB, IP_RO, 0,
111 IPS_IDLE);
112
113 /* Tracking Mode */
114 AddTrackMode("TRACK_SIDEREAL", "Sidereal", true);
115 AddTrackMode("TRACK_LUNAR", "Lunar");
116 AddTrackMode("TRACK_SOLAR", "Solar");
117 AddTrackMode("TRACK_KING", "King");
118 AddTrackMode("TRACK_CUSTOM", "Custom");
119
120 /* GPS Status */
121 IUFillSwitch(&GPSStatusS[GPS_OFF], "Off", "", ISS_ON);
122 IUFillSwitch(&GPSStatusS[GPS_ON], "On", "", ISS_OFF);
123 IUFillSwitch(&GPSStatusS[GPS_DATA_OK], "Data OK", "", ISS_OFF);
124 IUFillSwitchVector(&GPSStatusSP, GPSStatusS, 3, getDeviceName(), "GPS_STATUS", "GPS", MOUNTINFO_TAB, IP_RO,
126
127 /* Time Source */
128 IUFillSwitch(&TimeSourceS[TS_RS232], "RS232", "", ISS_ON);
129 IUFillSwitch(&TimeSourceS[TS_CONTROLLER], "Controller", "", ISS_OFF);
130 IUFillSwitch(&TimeSourceS[TS_GPS], "GPS", "", ISS_OFF);
131 IUFillSwitchVector(&TimeSourceSP, TimeSourceS, 3, getDeviceName(), "TIME_SOURCE", "Time Source", MOUNTINFO_TAB,
133
134 /* Hemisphere */
135 IUFillSwitch(&HemisphereS[HEMI_SOUTH], "South", "", ISS_OFF);
136 IUFillSwitch(&HemisphereS[HEMI_NORTH], "North", "", ISS_ON);
137 IUFillSwitchVector(&HemisphereSP, HemisphereS, 2, getDeviceName(), "HEMISPHERE", "Hemisphere", MOUNTINFO_TAB, IP_RO,
139
140 /* v3.0 Create PEC Training switches */
141 // PEC Training
142 IUFillSwitch(&PECTrainingS[0], "PEC_Recording", "Record", ISS_OFF);
143 IUFillSwitch(&PECTrainingS[1], "PEC_Status", "Status", ISS_OFF);
144 IUFillSwitchVector(&PECTrainingSP, PECTrainingS, 2, getDeviceName(), "PEC_TRAINING", "Training", MOTION_TAB, IP_RW,
145 ISR_ATMOST1, 0,
146 IPS_IDLE);
147
148 // Create PEC Training Information */
149 IUFillText(&PECInfoT[0], "PEC_INFO", "Status", "");
150 IUFillTextVector(&PECInfoTP, PECInfoT, 1, getDeviceName(), "PEC_INFOS", "Data", MOTION_TAB,
151 IP_RO, 60, IPS_IDLE);
152 // End Mod */
153
154 /* How fast do we guide compared to sidereal rate */
155 IUFillNumber(&GuideRateN[0], "RA_GUIDE_RATE", "x Sidereal", "%g", 0.01, 0.9, 0.1, 0.5);
156 IUFillNumber(&GuideRateN[1], "DE_GUIDE_RATE", "x Sidereal", "%g", 0.1, 0.99, 0.1, 0.5);
157 IUFillNumberVector(&GuideRateNP, GuideRateN, 2, getDeviceName(), "GUIDE_RATE", "Guiding Rate", MOTION_TAB, IP_RW, 0,
158 IPS_IDLE);
159
160
161 /* Slew Mode. Normal vs Counter Weight up */
162 IUFillSwitch(&SlewModeS[IOP_CW_NORMAL], "Normal", "Normal", ISS_ON);
163 IUFillSwitch(&SlewModeS[IOP_CW_UP], "Counterweight UP", "Counterweight up", ISS_OFF);
164 IUFillSwitchVector(&SlewModeSP, SlewModeS, 2, getDeviceName(), "Slew Type", "Slew Type", MOTION_TAB, IP_RW, ISR_1OFMANY, 0,
165 IPS_IDLE);
166
167 /* Daylight Savings */
168 IUFillSwitch(&DaylightS[0], "ON", "ON", ISS_OFF);
169 IUFillSwitch(&DaylightS[1], "OFF", "OFF", ISS_ON);
170 IUFillSwitchVector(&DaylightSP, DaylightS, 2, getDeviceName(), "DaylightSaving", "Daylight Savings", SITE_TAB, IP_RW,
171 ISR_1OFMANY, 0,
172 IPS_IDLE);
173
174 /* Counter Weight State */
175 IUFillSwitch(&CWStateS[IOP_CW_NORMAL], "Normal", "Normal", ISS_ON);
176 IUFillSwitch(&CWStateS[IOP_CW_UP], "Up", "Up", ISS_OFF);
177 IUFillSwitchVector(&CWStateSP, CWStateS, 2, getDeviceName(), "CWState", "Counter weights", MOTION_TAB, IP_RO, ISR_1OFMANY,
178 0, IPS_IDLE);
179
180 /* Meridian Behavior */
181 MeridianActionSP[IOP_MB_STOP].fill("IOP_MB_STOP", "Stop", ISS_ON);
182 MeridianActionSP[IOP_MB_FLIP].fill("IOP_MB_FLIP", "Flip", ISS_OFF);
183 MeridianActionSP.fill(getDeviceName(), "MERIDIAN_ACTION", "Action", MB_TAB, IP_RW, ISR_1OFMANY, 0, IPS_IDLE);
184 MeridianActionSP.load();
185
186 /* Meridian Limit */
187 MeridianLimitNP[0].fill("VALUE", "Degrees", "%.f", 0, 10, 1, 0);
188 MeridianLimitNP.fill(getDeviceName(), "MERIDIAN_LIMIT", "Limit", MB_TAB, IP_RW, 60, IPS_IDLE);
189 MeridianLimitNP.load();
190
191 if (strstr(getDeviceName(), "iMate"))
192 serialConnection->setDefaultPort("/dev/ttyS7");
193
194 // Baud rates.
195 // 230400 for 120
196 // 115000 for everything else
197 if (strstr(getDeviceName(), "120"))
199 else
201
202 // Default WiFi connection parameters
203 tcpConnection->setDefaultHost("10.10.100.254");
204 tcpConnection->setDefaultPort(8899);
205
207
209
211
213
215
217 currentDEC = LocationNP[LOCATION_LATITUDE].getValue() > 0 ? 90 : -90;
218 driver->setSimLongLat(LocationNP[LOCATION_LONGITUDE].getValue() > 180 ? LocationNP[LOCATION_LONGITUDE].getValue() - 360 :
220
221 return true;
222}
223
225{
227
228 if (isConnected())
229 {
230 /* v3.0 Create PEC switches */
231 defineProperty(&PECTrainingSP);
232 defineProperty(&PECInfoTP);
233 // End Mod */
234
235 defineProperty(&GuideRateNP);
236
237 defineProperty(&FirmwareTP);
238 defineProperty(&GPSStatusSP);
239 defineProperty(&TimeSourceSP);
240 defineProperty(&HemisphereSP);
241 defineProperty(&SlewModeSP);
242 defineProperty(&DaylightSP);
243 defineProperty(&CWStateSP);
244
245 defineProperty(MeridianActionSP);
246 defineProperty(MeridianLimitNP);
247
248 getStartupData();
249 }
250 else
251 {
252 /* v3.0 Delete PEC switches */
253 deleteProperty(PECTrainingSP.name);
254 deleteProperty(PECInfoTP.name);
255 // End Mod*/
256
257 deleteProperty(GuideRateNP.name);
258
259 deleteProperty(FirmwareTP.name);
260 deleteProperty(GPSStatusSP.name);
261 deleteProperty(TimeSourceSP.name);
262 deleteProperty(HemisphereSP.name);
263 deleteProperty(SlewModeSP.name);
264 deleteProperty(DaylightSP.name);
265 deleteProperty(CWStateSP.name);
266
267 deleteProperty(MeridianActionSP);
268 deleteProperty(MeridianLimitNP);
269 }
270
272
273 return true;
274}
275
276void IOptronV3::getStartupData()
277{
278 LOG_DEBUG("Getting firmware data...");
279 if (driver->getFirmwareInfo(&firmwareInfo))
280 {
281 IUSaveText(&FirmwareT[0], firmwareInfo.Model.c_str());
282 IUSaveText(&FirmwareT[1], firmwareInfo.MainBoardFirmware.c_str());
283 IUSaveText(&FirmwareT[2], firmwareInfo.ControllerFirmware.c_str());
284 IUSaveText(&FirmwareT[3], firmwareInfo.RAFirmware.c_str());
285 IUSaveText(&FirmwareT[4], firmwareInfo.DEFirmware.c_str());
286
287 FirmwareTP.s = IPS_OK;
288 IDSetText(&FirmwareTP, nullptr);
289
290 // Alt-Az models and dual-mode mounts in Alt-Az mode: "... AA", HAZ (unless "... EQ"), AZ Mount Pro
291 const std::string &model = firmwareInfo.Model;
292 auto endsWith = [&model](const char *suffix)
293 {
294 const size_t len = strlen(suffix);
295 return model.size() >= len && model.compare(model.size() - len, len, suffix) == 0;
296 };
297 const bool altAz = endsWith(" AA") || model.find("AZ Mount") != std::string::npos ||
298 (model.rfind("HAZ", 0) == 0 && !endsWith(" EQ"));
300 }
301
302 LOG_DEBUG("Getting guiding rate...");
303 double RARate = 0, DERate = 0;
304 if (driver->getGuideRate(&RARate, &DERate))
305 {
306 GuideRateN[RA_AXIS].value = RARate;
307 GuideRateN[DEC_AXIS].value = DERate;
308 IDSetNumber(&GuideRateNP, nullptr);
309 }
310
311 int utcOffsetMinutes = 0;
312 bool dayLightSavings = false;
313 double JD = 0;
314 if (driver->getUTCDateTime(&JD, &utcOffsetMinutes, &dayLightSavings))
315 {
316 time_t utc_time;
317 ln_get_timet_from_julian(JD, &utc_time);
318
319 // UTC Time
320 char ts[32] = {0};
321 struct tm *utc;
322 utc = gmtime(&utc_time);
323 strftime(ts, sizeof(ts), "%Y-%m-%dT%H:%M:%S", utc);
324 TimeTP[UTC].setText(ts);
325 LOGF_INFO("Mount UTC: %s", ts);
326
327 // UTC Offset
328 char offset[8] = {0};
329 // 2021-05-12 JM: Account for daylight savings
330 if (dayLightSavings)
331 utcOffsetMinutes += 60;
332
333 snprintf(offset, 8, "%.2f", utcOffsetMinutes / 60.0);
334 TimeTP[OFFSET].setText(offset);
335 LOGF_INFO("Mount UTC Offset: %s", offset);
336
337 TimeTP.setState(IPS_OK);
338 TimeTP.apply();
339
340 LOGF_INFO("Mount Daylight Savings: %s", dayLightSavings ? "ON" : "OFF");
341 DaylightS[0].s = dayLightSavings ? ISS_ON : ISS_OFF;
342 DaylightS[1].s = !dayLightSavings ? ISS_ON : ISS_OFF;
343 DaylightSP.s = IPS_OK;
344 IDSetSwitch(&DaylightSP, nullptr);
345 }
346
347 // Get Longitude and Latitude from mount
348 double longitude = 0, latitude = 0;
349 if (driver->getStatus(&scopeInfo))
350 {
351 LocationNP[LOCATION_LATITUDE].setValue(scopeInfo.latitude);
352 // Convert to INDI standard longitude (0 to 360 Eastward)
353 LocationNP[LOCATION_LONGITUDE].setValue((scopeInfo.longitude < 0) ? scopeInfo.longitude + 360 : scopeInfo.longitude);
354 LocationNP.setState(IPS_OK);
355
356 LocationNP.apply();
357
358 char l[32] = {0}, L[32] = {0};
359 fs_sexa(l, LocationNP[LOCATION_LATITUDE].getValue(), 3, 3600);
360 fs_sexa(L, LocationNP[LOCATION_LONGITUDE].getValue(), 4, 3600);
361
362 LOGF_INFO("Mount Location: Lat %.32s - Long %.32s", l, L);
363
364 saveConfig(true, "GEOGRAPHIC_COORD");
365 }
366 else if (IUGetConfigNumber(getDeviceName(), "GEOGRAPHIC_COORD", "LONG", &longitude) == 0 &&
367 IUGetConfigNumber(getDeviceName(), "GEOGRAPHIC_COORD", "LAT", &latitude) == 0)
368 {
369 LocationNP[LOCATION_LATITUDE].setValue(latitude);
370 LocationNP[LOCATION_LONGITUDE].setValue(longitude);
371 LocationNP.setState(IPS_OK);
372
373 LocationNP.apply();
374 }
375
376 IOP_MB_STATE action;
377 uint8_t degrees = 0;
378 if (driver->getMeridianBehavior(action, degrees))
379 {
380 MeridianActionSP.reset();
381 MeridianActionSP[action].setState(ISS_ON);
382 MeridianActionSP.setState(IPS_OK);
383 MeridianLimitNP[0].setValue(degrees);
384
385 LOGF_INFO("Reading mount meridian behavior: When mount reaches %.f degrees past meridian, it will %s.",
386 MeridianLimitNP[0].getValue(), MeridianActionSP[IOP_MB_STOP].getState() == ISS_ON ? "stop" : "flip");
387 }
388
389 double parkAZ = LocationNP[LOCATION_LATITUDE].getValue() >= 0 ? 0 : 180;
390 double parkAL = LocationNP[LOCATION_LATITUDE].getValue();
391 if (InitPark())
392 {
393 // If loading parking data is successful, we just set the default parking values.
394 SetAxis1ParkDefault(parkAZ);
395 SetAxis2ParkDefault(parkAL);
396 }
397 else
398 {
399 // Otherwise, we set all parking data to default in case no parking data is found.
400 SetAxis1Park(parkAZ);
401 SetAxis2Park(parkAL);
402 SetAxis1ParkDefault(parkAZ);
403 SetAxis2ParkDefault(parkAL);
404
405 driver->setParkAz(parkAZ);
406 driver->setParkAlt(parkAL);
407 }
408
409 /* v3.0 Read PEC State at startup */
410 IOPInfo newInfo;
411 if (driver->getStatus(&newInfo))
412 {
413 switch (newInfo.systemStatus)
414 {
415 case ST_STOPPED:
416 case ST_PARKED:
417 case ST_HOME:
418 case ST_SLEWING:
420 case ST_GUIDING:
421
424 GetPECDataStatus(true);
425 break;
426
429 GetPECDataStatus(true);
430 break;
431 }
432 scopeInfo = newInfo;
433 }
434
435 if (isSimulation())
436 {
437 if (isParked())
438 driver->setSimSytemStatus(ST_PARKED);
439 else
440 driver->setSimSytemStatus(ST_STOPPED);
441 }
442}
443
444bool IOptronV3::ISNewNumber(const char *dev, const char *name, double values[], char *names[], int n)
445{
446 // Check guider interface
447 if (GI::processNumber(dev, name, values, names, n))
448 return true;
449
450 if (dev != nullptr && strcmp(dev, getDeviceName()) == 0)
451 {
452 // Guiding Rate
453 if (!strcmp(name, GuideRateNP.name))
454 {
455 IUUpdateNumber(&GuideRateNP, values, names, n);
456
457 if (driver->setGuideRate(GuideRateN[RA_AXIS].value, GuideRateN[DEC_AXIS].value))
458 GuideRateNP.s = IPS_OK;
459 else
460 GuideRateNP.s = IPS_ALERT;
461
462 IDSetNumber(&GuideRateNP, nullptr);
463
464 return true;
465 }
466
467 /****************************************
468 Meridian Flip Limit
469 *****************************************/
470 if (MeridianLimitNP.isNameMatch(name))
471 {
472 auto lastLimit = MeridianLimitNP[0].getValue();
473 MeridianLimitNP.update(values, names, n);
474 // Only update driver if there is an actual change
475 if (lastLimit != MeridianLimitNP[0].getValue())
476 {
477 MeridianLimitNP.setState(driver->setMeridianBehavior(static_cast<IOP_MB_STATE>(MeridianActionSP.findOnSwitchIndex()),
478 MeridianLimitNP[0].getValue()) ? IPS_OK : IPS_ALERT);
479 if (MeridianLimitNP.getState() == IPS_OK)
480 {
481 LOGF_INFO("Setting mount meridian behavior: When mount reaches %.f degrees past meridian, it will %s.",
482 MeridianLimitNP[0].getValue(), MeridianActionSP[IOP_MB_STOP].getState() == ISS_ON ? "stop" : "flip");
483 }
484 }
485 else
486 MeridianLimitNP.setState(IPS_OK);
487
488 MeridianLimitNP.apply();
489 saveConfig(MeridianLimitNP);
490 return true;
491 }
492 }
493
494 return INDI::Telescope::ISNewNumber(dev, name, values, names, n);
495}
496
497bool IOptronV3::ISNewSwitch(const char *dev, const char *name, ISState *states, char *names[], int n)
498{
499 if (!strcmp(getDeviceName(), dev))
500 {
501 /*******************************************************
502 * Slew Mode Operations
503 *******************************************************/
504 if (!strcmp(name, SlewModeSP.name))
505 {
506 IUUpdateSwitch(&SlewModeSP, states, names, n);
507 SlewModeSP.s = IPS_OK;
508 IDSetSwitch(&SlewModeSP, nullptr);
509 return true;
510 }
511
512 /*******************************************************
513 * Daylight Savings Operations
514 *******************************************************/
515 if (!strcmp(name, DaylightSP.name))
516 {
517 IUUpdateSwitch(&DaylightSP, states, names, n);
518
519 if (driver->setDaylightSaving(DaylightS[0].s == ISS_ON))
520 DaylightSP.s = IPS_OK;
521 else
522 DaylightSP.s = IPS_ALERT;
523
524 IDSetSwitch(&DaylightSP, nullptr);
525 return true;
526 }
527
528 /*******************************************************
529 * Meridian Action Operations
530 *******************************************************/
531 if (MeridianActionSP.isNameMatch(name))
532 {
533 auto lastAction = MeridianActionSP.findOnSwitchIndex();
534 MeridianActionSP.update(states, names, n);
535
536 if (lastAction != MeridianActionSP.findOnSwitchIndex())
537 {
538 MeridianActionSP.setState(driver->setMeridianBehavior(static_cast<IOP_MB_STATE>(MeridianActionSP.findOnSwitchIndex()),
539 MeridianLimitNP[0].getValue()) ? IPS_OK : IPS_ALERT);
540 if (MeridianActionSP.getState() == IPS_OK)
541 {
542 LOGF_INFO("Setting mount meridian behavior: When mount reaches %.f degrees past meridian, it will %s.",
543 MeridianLimitNP[0].getValue(), MeridianActionSP[IOP_MB_STOP].getState() == ISS_ON ? "stop" : "flip");
544 }
545 }
546 else
547 MeridianActionSP.setState(IPS_OK);
548 MeridianActionSP.apply();
549 saveConfig(MeridianActionSP);
550 return true;
551 }
552
553 /* v3.0 PEC add controls and calls to the driver */
554 if (PECStateSP.isNameMatch(name))
555 {
556 PECStateSP.update(states, names, n);
557
558 if(PECStateSP[PEC_OFF].getState() == ISS_ON)
559 {
560 // PEC OFF
561 if(isTraining)
562 {
563 // Training check
564 LOGF_WARN("Mount PEC busy recording, %d s", PECTime);
565 }
566 else
567 {
568 driver->setPECEnabled(false);
569 PECStateSP.setState(IPS_OK);
570 LOG_INFO("Disabling PEC Chip");
571 }
572 }
573 else
574 {
575 // PEC ON
576 if (GetPECDataStatus(true))
577 {
578 // Data Check
579 driver->setPECEnabled(true);
580 PECStateSP.setState(IPS_BUSY);
581 LOG_INFO("Enabling PEC Chip");
582 }
583 }
584 PECStateSP.apply();
585 return true;
586 }
587
588 /* v3.0 PEC add Training Controls to the Driver */
589 if (!strcmp(name, PECTrainingSP.name))
590 {
591 IUUpdateSwitch(&PECTrainingSP, states, names, n);
592 if(isTraining)
593 {
594 // Check if already training
595 if(IUFindOnSwitchIndex(&PECTrainingSP) == 1)
596 {
597 // Train Check Status
598 LOGF_WARN("Mount PEC busy recording, %d s", PECTime);
599 }
600
601 if(IUFindOnSwitchIndex(&PECTrainingSP) == 0)
602 {
603 // Train Cancel
604 driver->setPETEnabled(false);
605 isTraining = false;
606 PECTrainingSP.s = IPS_ALERT;
607 LOG_WARN("PEC Training cancelled by user, chip disabled");
608 }
609 }
610 else
611 {
612 if(IUFindOnSwitchIndex(&PECTrainingSP) == 0)
613 {
615 {
616 // Train if tracking /guiding
617 driver->setPETEnabled(true);
618 isTraining = true;
619 PECTime = 0;
620 PECTrainingSP.s = IPS_BUSY;
621 LOG_INFO("PEC recording started...");
622 }
623 else
624 {
625 LOG_WARN("PEC Training only possible while guiding");
626 PECTrainingSP.s = IPS_IDLE;
627 }
628 }
629 if(IUFindOnSwitchIndex(&PECTrainingSP) == 1)
630 {
631 // Train Status
632 GetPECDataStatus(true);
633 }
634 }
635 IDSetSwitch(&PECTrainingSP, nullptr);
636 return true;
637 }
638 }
639
640 return INDI::Telescope::ISNewSwitch(dev, name, states, names, n);
641}
642
644{
645 bool rc = false;
646
647 IOPInfo newInfo;
648
649 if (isSimulation())
650 mountSim();
651
652 // Do not query mount if parked already.
654 return true;
655
656 rc = driver->getStatus(&newInfo);
657
658 if (rc)
659 {
660 if (IUFindOnSwitchIndex(&GPSStatusSP) != newInfo.gpsStatus)
661 {
662 IUResetSwitch(&GPSStatusSP);
663 GPSStatusS[newInfo.gpsStatus].s = ISS_ON;
664 IDSetSwitch(&GPSStatusSP, nullptr);
665 }
666
667 if (IUFindOnSwitchIndex(&TimeSourceSP) != newInfo.timeSource)
668 {
669 IUResetSwitch(&TimeSourceSP);
670 TimeSourceS[newInfo.timeSource].s = ISS_ON;
671 IDSetSwitch(&TimeSourceSP, nullptr);
672 }
673
674 if (IUFindOnSwitchIndex(&HemisphereSP) != newInfo.hemisphere)
675 {
676 IUResetSwitch(&HemisphereSP);
677 HemisphereS[newInfo.hemisphere].s = ISS_ON;
678 IDSetSwitch(&HemisphereSP, nullptr);
679 }
680
681 if (SlewRateSP.findOnSwitchIndex() != newInfo.slewRate - 1)
682 {
683 SlewRateSP.reset();
684 SlewRateSP[newInfo.slewRate - 1].setState(ISS_ON);
685 SlewRateSP.apply();
686 }
687
688 switch (newInfo.systemStatus)
689 {
690 case ST_STOPPED:
691 TrackModeSP.setState(IPS_IDLE);
693 break;
694 case ST_PARKED:
695 TrackModeSP.setState(IPS_IDLE);
697 if (!isParked())
698 SetParked(true);
699 if (HomeSP.getState() == IPS_BUSY)
700 {
701 HomeSP.reset();
702 HomeSP.setState(IPS_OK);
703 HomeSP.apply();
704 }
705 break;
706 case ST_HOME:
707 TrackModeSP.setState(IPS_IDLE);
709 if (HomeSP.getState() == IPS_BUSY)
710 {
711 HomeSP.reset();
712 HomeSP.setState(IPS_OK);
713 HomeSP.apply();
714 }
715 break;
716 case ST_SLEWING:
720 break;
723 case ST_GUIDING:
726 TrackModeSP.setState(IPS_BUSY);
728 if (scopeInfo.systemStatus == ST_SLEWING)
729 LOG_INFO("Slew complete, tracking...");
730 else if (scopeInfo.systemStatus == ST_MERIDIAN_FLIPPING)
731 LOG_INFO("Meridian flip complete, tracking...");
732 break;
733 }
734
735 if (TrackModeSP.findOnSwitchIndex() != newInfo.trackRate)
736 {
737 TrackModeSP.reset();
738 TrackModeSP[newInfo.trackRate].setState(ISS_ON);
739 TrackModeSP.apply();
740 }
741
742 scopeInfo = newInfo;
743 }
744
745 /* v3.0 Monitor PEC Training */
746 if (isTraining)
747 {
749 {
750 if(GetPECDataStatus(false))
751 {
752 LOGF_INFO("%d second worm cycle recorded", PECTime);
753 PECTrainingSP.s = IPS_OK;
754 isTraining = false;
755 }
756 else
757 {
758 PECTime = PECTime + 1 * getCurrentPollingPeriod() / 1000;
759 char PECText[MAXINDILABEL] = {0};
760 snprintf(PECText, MAXINDILABEL, "Recording: %d s", PECTime);
761 IUSaveText(&PECInfoT[0], PECText);
762 }
763 }
764 else
765 {
766 driver->setPETEnabled(false);
767 PECTrainingSP.s = IPS_ALERT;
768 LOGF_ERROR("Tracking error, recording cancelled %d s", PECTime);
769 IUSaveText(&PECInfoT[0], "Cancelled");
770 }
771 IDSetText(&PECInfoTP, nullptr);
772 IDSetSwitch(&PECTrainingSP, nullptr);
773 }
774 // End Mod */
775
777 IOP_CW_STATE cwState = IOP_CW_NORMAL;
778
779 double previousRA = currentRA, previousDE = currentDEC;
780 rc = driver->getCoords(&currentRA, &currentDEC, &pierState, &cwState);
781 if (rc)
782 {
783 // Add Extra Logging info
784 if (isDebug())
785 {
786 char RAStr[64] = {0}, DecStr[64] = {0}, AzStr[64] = {0}, AltStr[64] = {0};
787 fs_sexa(RAStr, currentRA, 2, 3600);
788 fs_sexa(DecStr, currentDEC, 2, 3600);
789 INDI::IEquatorialCoordinates equatorialCoords {currentRA, currentDEC};
790 INDI::IHorizontalCoordinates horizontalCoords {0, 0};
791 INDI::EquatorialToHorizontal(&equatorialCoords, &m_Location, ln_get_julian_from_sys(), &horizontalCoords);
792 fs_sexa(AzStr, horizontalCoords.azimuth, 2, 3600);
793 fs_sexa(AltStr, horizontalCoords.altitude, 2, 3600);
794 std::string pierSide = "Uknkown";
795 if (pierState == IOP_PIER_EAST)
796 pierSide = "East";
797 else if (pierState == IOP_PIER_WEST)
798 pierSide = "West";
799 DEBUGF(DBG_SCOPE, "RA: %s DE: %s AZ: %s AL: %s PierSide: %s CWState %d", RAStr, DecStr, AzStr, AltStr, pierSide.c_str(), cwState);
800 }
801
802 // 2021.11.30 JM: This is a hack to circumvent a bug in iOptorn firmware
803 // the "system status" bit is set to SLEWING even when parking is done (2), it never
804 // changes to (6) which indicates it has parked. So we use a counter to check if there
805 // is no longer any motion.
807 {
808 if (std::abs(previousRA - currentRA) < 0.01 && std::abs(previousDE - currentDEC) < 0.01)
809 {
810 m_ParkingCounter++;
811 if (m_ParkingCounter >= MAX_PARK_COUNTER)
812 {
813 m_ParkingCounter = 0;
814 SetTrackEnabled(false);
815 SetParked(true);
816 }
817 }
818 }
819 if (pierState == IOP_PIER_UNKNOWN)
821 else
823
824 if (IUFindOnSwitchIndex(&CWStateSP) != cwState)
825 {
826 IUResetSwitch(&CWStateSP);
827 CWStateS[cwState].s = ISS_ON;
828 IDSetSwitch(&CWStateSP, nullptr);
829 }
830
831 NewRaDec(currentRA, currentDEC);
832 }
833
834 return rc;
835}
836
837bool IOptronV3::Goto(double ra, double de)
838{
839 targetRA = ra;
840 targetDEC = de;
841 char RAStr[64] = {0}, DecStr[64] = {0};
842
843 fs_sexa(RAStr, targetRA, 2, 3600);
844 fs_sexa(DecStr, targetDEC, 2, 3600);
845
846 if (driver->setRA(ra) == false || driver->setDE(de) == false)
847 {
848 LOG_ERROR("Error setting RA/DEC.");
849 return false;
850 }
851
852 bool rc = false;
853 if (IUFindOnSwitchIndex(&SlewModeSP) == IOP_CW_NORMAL)
854 rc = driver->slewNormal();
855 else
856 rc = driver->slewCWUp();
857
858 if (rc == false)
859 {
860 LOG_ERROR("Failed to slew.");
861 return false;
862 }
863
865
866 LOGF_INFO("Slewing to RA: %s - DEC: %s", RAStr, DecStr);
867 return true;
868}
869
870bool IOptronV3::Sync(double ra, double de)
871{
872 if (driver->setRA(ra) == false || driver->setDE(de) == false)
873 {
874 LOG_ERROR("Error setting RA/DEC.");
875 return false;
876 }
877
878 if (driver->sync() == false)
879 {
880 LOG_ERROR("Failed to sync.");
881 }
882
883 EqNP.setState(IPS_OK);
884
885 currentRA = ra;
886 currentDEC = de;
887
888 NewRaDec(currentRA, currentDEC);
889
890 return true;
891}
892
894{
895 return driver->abort();
896}
897
899{
900 // if (firmwareInfo.Model.find("CEM") == std::string::npos &&
901 // firmwareInfo.Model.find("iEQ45 Pro") == std::string::npos &&
902 // firmwareInfo.Model.find("iEQ35") == std::string::npos)
903 // {
904 // LOG_ERROR("Parking is not supported in this mount model.");
905 // return false;
906 // }
907
908 if (driver->park())
909 {
911 m_ParkingCounter = 0;
912 LOG_INFO("Parking is in progress...");
913
914 return true;
915 }
916 else
917 return false;
918}
919
921{
922 // if (firmwareInfo.Model.find("CEM") == std::string::npos &&
923 // firmwareInfo.Model.find("iEQ45 Pro") == std::string::npos &&
924 // firmwareInfo.Model.find("iEQ35") == std::string::npos)
925 // {
926 // LOG_ERROR("Unparking is not supported in this mount model.");
927 // return false;
928 // }
929
930 if (driver->unpark())
931 {
932 SetParked(false);
934 return true;
935 }
936 else
937 return false;
938}
939
941{
942 driver->setSimulation(isSimulation());
943
944 if (driver->checkConnection(PortFD) == false)
945 return false;
946
947 return true;
948}
949
950bool IOptronV3::updateTime(ln_date *utc, double utc_offset)
951{
952 // No communications while parked.
954 return true;
955
956 bool rc1 = driver->setUTCDateTime(ln_get_julian_day(utc));
957
958 bool rc2 = driver->setUTCOffset(utc_offset * 60);
959
960 return (rc1 && rc2);
961}
962
963bool IOptronV3::updateLocation(double latitude, double longitude, double elevation)
964{
965 INDI_UNUSED(elevation);
966
967 // No communications while parked.
969 return true;
970
971 if (longitude > 180)
972 longitude -= 360;
973
974 if (driver->setLongitude(longitude) == false)
975 {
976 LOG_ERROR("Failed to set longitude.");
977 return false;
978 }
979
980 if (driver->setLatitude(latitude) == false)
981 {
982 LOG_ERROR("Failed to set longitude.");
983 return false;
984 }
985
986 char l[32] = {0}, L[32] = {0};
987 fs_sexa(l, latitude, 3, 3600);
988 fs_sexa(L, longitude, 4, 3600);
989
990 LOGF_INFO("Site location updated to Lat %.32s - Long %.32s", l, L);
991
992 return true;
993}
994
996{
997 driver->setDebug(enable);
998}
999
1001{
1002 driver->setSimulation(enable);
1003}
1004
1006{
1007 if (TrackState == SCOPE_PARKED)
1008 {
1009 LOG_ERROR("Please unpark the mount before issuing any motion commands.");
1010 return false;
1011 }
1012
1013 switch (command)
1014 {
1015 case MOTION_START:
1016 if (driver->startMotion(dir == DIRECTION_NORTH ? IOP_N : IOP_S) == false)
1017 {
1018 LOG_ERROR("Error setting N/S motion direction.");
1019 return false;
1020 }
1021 else
1022 LOGF_INFO("Moving toward %s.", (dir == DIRECTION_NORTH) ? "North" : "South");
1023 break;
1024
1025 case MOTION_STOP:
1026 if (driver->stopMotion(dir == DIRECTION_NORTH ? IOP_N : IOP_S) == false)
1027 {
1028 LOG_ERROR("Error stopping N/S motion.");
1029 return false;
1030 }
1031 else
1032 LOGF_INFO("%s motion stopped.", (dir == DIRECTION_NORTH) ? "North" : "South");
1033 break;
1034 }
1035
1036 return true;
1037}
1038
1040{
1041 if (TrackState == SCOPE_PARKED)
1042 {
1043 LOG_ERROR("Please unpark the mount before issuing any motion commands.");
1044 return false;
1045 }
1046
1047 switch (command)
1048 {
1049 case MOTION_START:
1050 if (driver->startMotion(dir == DIRECTION_WEST ? IOP_W : IOP_E) == false)
1051 {
1052 LOG_ERROR("Error setting N/S motion direction.");
1053 return false;
1054 }
1055 else
1056 LOGF_INFO("Moving toward %s.", (dir == DIRECTION_WEST) ? "West" : "East");
1057 break;
1058
1059 case MOTION_STOP:
1060 if (driver->stopMotion(dir == DIRECTION_WEST ? IOP_W : IOP_E) == false)
1061 {
1062 LOG_ERROR("Error stopping W/E motion.");
1063 return false;
1064 }
1065 else
1066 LOGF_INFO("%s motion stopped.", (dir == DIRECTION_WEST) ? "West" : "East");
1067 break;
1068 }
1069
1070 return true;
1071}
1072
1074{
1075 bool rc = driver->startGuide(IOP_N, (uint32_t)ms);
1076 return (rc ? IPS_OK : IPS_ALERT);
1077}
1078
1080{
1081 bool rc = driver->startGuide(IOP_S, (uint32_t)ms);
1082 return (rc ? IPS_OK : IPS_ALERT);
1083}
1084
1086{
1087 bool rc = driver->startGuide(IOP_E, (uint32_t)ms);
1088 return (rc ? IPS_OK : IPS_ALERT);
1089}
1090
1092{
1093 bool rc = driver->startGuide(IOP_W, (uint32_t)ms);
1094 return (rc ? IPS_OK : IPS_ALERT);
1095}
1096
1098{
1099 IOP_SLEW_RATE rate = static_cast<IOP_SLEW_RATE>(index);
1100 return driver->setSlewRate(rate);
1101}
1102
1104{
1106
1107 IUSaveConfigSwitch(fp, &SlewModeSP);
1108 IUSaveConfigSwitch(fp, &DaylightSP);
1109
1110 MeridianLimitNP.save(fp);
1111 MeridianActionSP.save(fp);
1112
1113 return true;
1114}
1115
1117{
1118 static struct timeval ltv;
1119 struct timeval tv;
1120 double dt, da, dx;
1121 int nlocked;
1122
1123 /* update elapsed time since last poll, don't presume exactly POLLMS */
1124 gettimeofday(&tv, nullptr);
1125
1126 if (ltv.tv_sec == 0 && ltv.tv_usec == 0)
1127 ltv = tv;
1128
1129 dt = tv.tv_sec - ltv.tv_sec + (tv.tv_usec - ltv.tv_usec) / 1e6;
1130 ltv = tv;
1131 double currentSlewRate = Driver::IOP_SLEW_RATES[SlewRateSP.findOnSwitchIndex()] * TRACKRATE_SIDEREAL / 3600.0;
1132 da = currentSlewRate * dt;
1133
1134 /* Process per current state. We check the state of EQUATORIAL_COORDS and act accordingly */
1135 switch (TrackState)
1136 {
1137 case SCOPE_IDLE:
1138 currentRA += (TrackRateNP[AXIS_RA].getValue() / 3600.0 * dt) / 15.0;
1139 currentRA = range24(currentRA);
1140 break;
1141
1142 case SCOPE_TRACKING:
1143 if (TrackModeSP[TR_CUSTOM].getState() == ISS_ON)
1144 {
1145 currentRA += ( ((TRACKRATE_SIDEREAL / 3600.0) - (TrackRateNP[AXIS_RA].getValue() / 3600.0)) * dt) / 15.0;
1146 currentDEC += ( (TrackRateNP[AXIS_DE].getValue() / 3600.0) * dt);
1147 }
1148 break;
1149
1150 case SCOPE_SLEWING:
1151 case SCOPE_PARKING:
1152 /* slewing - nail it when both within one pulse @ SLEWRATE */
1153 nlocked = 0;
1154
1155 dx = targetRA - currentRA;
1156
1157 // Take shortest path
1158 if (fabs(dx) > 12)
1159 dx *= -1;
1160
1161 if (fabs(dx) <= da)
1162 {
1163 currentRA = targetRA;
1164 nlocked++;
1165 }
1166 else if (dx > 0)
1167 currentRA += da / 15.;
1168 else
1169 currentRA -= da / 15.;
1170
1171 if (currentRA < 0)
1172 currentRA += 24;
1173 else if (currentRA > 24)
1174 currentRA -= 24;
1175
1176 dx = targetDEC - currentDEC;
1177 if (fabs(dx) <= da)
1178 {
1179 currentDEC = targetDEC;
1180 nlocked++;
1181 }
1182 else if (dx > 0)
1183 currentDEC += da;
1184 else
1185 currentDEC -= da;
1186
1187 if (nlocked == 2)
1188 {
1190 driver->setSimSytemStatus(ST_TRACKING_PEC_OFF);
1191 else
1192 driver->setSimSytemStatus(ST_PARKED);
1193 }
1194
1195 break;
1196
1197 default:
1198 break;
1199 }
1200
1201 driver->setSimRA(currentRA);
1202 driver->setSimDE(currentDEC);
1203}
1204
1206{
1207 INDI::IEquatorialCoordinates equatorialCoords {currentRA, currentDEC};
1208 INDI::IHorizontalCoordinates horizontalCoords {0, 0};
1209 INDI::EquatorialToHorizontal(&equatorialCoords, &m_Location, ln_get_julian_from_sys(), &horizontalCoords);
1210 double parkAZ = horizontalCoords.azimuth;
1211 // Wrap to 0
1212 if (parkAZ >= 360)
1213 parkAZ = 0;
1214 double parkAlt = horizontalCoords.altitude;
1215 char AzStr[16], AltStr[16];
1216 fs_sexa(AzStr, parkAZ, 2, 3600);
1217 fs_sexa(AltStr, parkAlt, 2, 3600);
1218 LOGF_DEBUG("Setting current parking position to coordinates Az (%s) Alt (%s)...", AzStr, AltStr);
1219 SetAxis1Park(parkAZ);
1220 SetAxis2Park(parkAlt);
1221 driver->setParkAz(parkAZ);
1222 driver->setParkAlt(parkAlt);
1223 return true;
1224}
1225
1227{
1228 // By default azimuth 0
1229 SetAxis1Park(0);
1230 // Altitude = latitude of observer
1232 driver->setParkAz(0);
1233 driver->setParkAlt(LocationNP[LOCATION_LATITUDE].getValue());
1234 return true;
1235}
1236
1237bool IOptronV3::SetTrackMode(uint8_t mode)
1238{
1239 IOP_TRACK_RATE rate = static_cast<IOP_TRACK_RATE>(mode);
1240
1241 if (driver->setTrackMode(rate))
1242 return true;
1243
1244 return false;
1245}
1246
1247bool IOptronV3::SetTrackRate(double raRate, double deRate)
1248{
1249 INDI_UNUSED(deRate);
1250
1251 // Convert to arcsecs/s to rate
1252 double ieqRARate = raRate / TRACKRATE_SIDEREAL;
1253
1254 if (ieqRARate < 0.1 || ieqRARate > 1.9)
1255 {
1256 LOG_ERROR("Rate is outside permitted limits of 0.1 to 1.9 sidereal rate (1.504 to 28.578 arcsecs/s)");
1257 return false;
1258 }
1259
1260
1261 if (driver->setCustomRATrackRate(ieqRARate))
1262 return true;
1263
1264 return false;
1265}
1266
1268{
1269 if (enabled)
1270 {
1271 // If we are engaging tracking, let us first set tracking mode, and if we have custom mode, then tracking rate.
1272 // NOTE: Is this the correct order? or should tracking be switched on first before making these changes? Need to test.
1273 SetTrackMode(TrackModeSP.findOnSwitchIndex());
1274 if (TrackModeSP[TR_CUSTOM].getState() == ISS_ON)
1275 SetTrackRate(TrackRateNP[AXIS_RA].getValue(), TrackRateNP[AXIS_DE].getValue());
1276 }
1277
1278 return driver->setTrackEnabled(enabled);
1279}
1280
1281/* v3.0 PEC add data status to the Driver */
1282bool IOptronV3::GetPECDataStatus(bool enabled)
1283{
1284 if(driver->getPETEnabled(true))
1285 {
1286 if (enabled)
1287 {
1288 IUSaveText(&PECInfoT[0], "Recorded");
1289 IDSetText(&PECInfoTP, nullptr);
1290 LOG_INFO("Mount PEC Chip Ready and Trained");
1291 }
1292 return true;
1293 }
1294 else
1295 {
1296 if (enabled)
1297 {
1298 IUSaveText(&PECInfoT[0], "None");
1299 IDSetText(&PECInfoTP, nullptr);
1300 LOG_INFO("Mount PEC Chip Needs Training");
1301 }
1302 }
1303 return false;
1304}
1305
1307{
1308 switch (action)
1309 {
1310 case HOME_FIND:
1311 if (firmwareInfo.Model.find("CEM") == std::string::npos &&
1312 firmwareInfo.Model.find("GEM45") == std::string::npos &&
1313 firmwareInfo.Model.find("HAE") == std::string::npos &&
1314 firmwareInfo.Model.find("HAZ") == std::string::npos &&
1315 firmwareInfo.Model.find("HEM") == std::string::npos)
1316 {
1317 LOG_WARN("Home search is not supported in this model.");
1318 return IPS_ALERT;
1319 }
1320
1321 if (driver->findHome() == false)
1322 {
1323 return IPS_ALERT;
1324 }
1325
1326 LOG_INFO("Searching for home position...");
1327 return IPS_BUSY;
1328
1329 case HOME_SET:
1330 if (driver->setCurrentHome() == false)
1331 {
1332 return IPS_ALERT;
1333 }
1334
1335 LOG_INFO("Home position set to current coordinates.");
1336 return IPS_OK;
1337
1338 case HOME_GO:
1339 if (driver->gotoHome() == false)
1340 {
1341 return IPS_ALERT;
1342 }
1343
1344 LOG_INFO("Slewing to home position...");
1345 return IPS_BUSY;
1346
1347 default:
1348 return IPS_ALERT;
1349 }
1350
1351 return IPS_ALERT;
1352}
@ FW_MODEL
@ FW_DEC
@ FW_RA
@ GPS_OFF
@ GPS_ON
#define MOUNTINFO_TAB
bool isConnected() const
virtual bool saveConfig(bool silent=false, const char *property=nullptr)
Save the current properties in a configuration file.
void setDriverInterface(uint32_t value)
setInterface Set driver interface. By default the driver interface is set to GENERAL_DEVICE....
void setVersion(uint16_t vMajor, uint16_t vMinor)
Set driver version information to be defined in DRIVER_INFO property as vMajor.vMinor.
virtual bool deleteProperty(const char *propertyName)
Delete a property and unregister it. It will also be deleted from all clients.
void defineProperty(INumberVectorProperty *property)
uint32_t getCurrentPollingPeriod() const
getCurrentPollingPeriod Return the current polling period.
bool isSimulation() const
void addAuxControls()
Add Debug, Simulation, and Configuration options to the driver.
uint32_t getDriverInterface() const
bool updateProperties()
updateProperties Define or Delete Rotator properties based on the connection status of the base devic...
void initProperties(const char *groupName)
Initialize guider properties. It is recommended to call this function within initProperties() of your...
bool processNumber(const char *dev, const char *name, double values[], char *names[], int n)
Call this function whenever client updates GuideNSNP or GuideWSP properties in the primary device....
static Logger & getInstance()
Method to get a reference to the object (i.e., Singleton) It is a static method.
int addDebugLevel(const char *debugLevelName, const char *LoggingLevelName)
Adds a new debugging level to the driver.
TelescopeStatus TrackState
void SetAxis1Park(double value)
SetRAPark Set current RA/AZ parking position. The data park file (stored in ~/.indi/ParkData....
void SetAxis1ParkDefault(double steps)
SetRAPark Set default RA/AZ parking position.
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.
bool isParked()
isParked is mount currently parked?
virtual int AddTrackMode(const char *name, const char *label, bool isDefault=false)
AddTrackMode.
Connection::Serial * serialConnection
virtual bool updateProperties() override
Called when connected state changes, to add/remove properties.
virtual void SetParked(bool isparked)
SetParked Change the mount parking status. The data park file (stored in ~/.indi/ParkData....
Connection::TCP * tcpConnection
void setPECState(TelescopePECState state)
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.
void setPierSide(TelescopePierSide side)
bool InitPark()
InitPark Loads parking data (stored in ~/.indi/ParkData.xml) that contains parking status and parking...
virtual bool saveConfigItems(FILE *fp) override
saveConfigItems Save specific properties in the provide config file handler. Child class usually over...
void SetAxis2Park(double steps)
SetDEPark Set current DEC/ALT parking position. The data park file (stored in ~/.indi/ParkData....
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.
void SetParkDataType(TelescopeParkData type)
setParkDataType Sets the type of parking data stored in the park data file and presented to the user.
void SetAxis2ParkDefault(double steps)
SetDEParkDefault Set default DEC/ALT parking position.
static const uint16_t IOP_SLEW_RATES[]
virtual bool Goto(double ra, double de) override
Move the scope to the supplied RA and DEC coordinates.
virtual IPState GuideSouth(uint32_t ms) override
Guide south for ms milliseconds. South is defined as DEC-.
virtual bool saveConfigItems(FILE *fp) override
saveConfigItems Save specific properties in the provide config file handler. Child class usually over...
virtual bool MoveNS(INDI_DIR_NS dir, TelescopeMotionCommand command) override
Start or Stop the telescope motion in the direction dir.
virtual bool SetTrackRate(double raRate, double deRate) override
SetTrackRate Set custom tracking rates.
virtual const char * getDefaultName() override
Definition ioptronv3.cpp:78
virtual bool SetTrackMode(uint8_t mode) override
SetTrackMode Set active tracking mode. Do not change track state.
virtual bool ISNewNumber(const char *dev, const char *name, double values[], char *names[], int n) override
Process the client newNumber command.
virtual IPState ExecuteHomeAction(TelescopeHomeAction action) override
Execute a homing action.
virtual bool MoveWE(INDI_DIR_WE dir, TelescopeMotionCommand command) override
Move the telescope in the direction dir.
virtual bool Park() override
Park the telescope to its home position.
virtual bool UnPark() override
Unpark the telescope if already parked.
virtual void simulationTriggered(bool enable) override
Inform driver that the simulation option was triggered. This function is called after setSimulation i...
virtual bool SetCurrentPark() override
SetCurrentPark Set current coordinates/encoders value as the desired parking position.
void mountSim()
virtual IPState GuideNorth(uint32_t ms) override
Guide north for ms milliseconds. North is defined as DEC+.
virtual bool updateLocation(double latitude, double longitude, double elevation) override
Update telescope location settings.
virtual bool Sync(double ra, double de) override
Set the telescope current RA and DEC coordinates to the supplied RA and DEC coordinates.
virtual bool Handshake() override
perform handshake with device to check communication
virtual bool SetTrackEnabled(bool enabled) override
SetTrackEnabled Engages or disengages mount tracking. If there are no tracking modes available,...
virtual bool ReadScopeStatus() override
Read telescope status.
virtual bool ISNewSwitch(const char *dev, const char *name, ISState *states, char *names[], int n) override
Process the client newSwitch command.
virtual bool SetDefaultPark() override
SetDefaultPark Set default coordinates/encoders value as the desired parking position.
virtual bool updateProperties() override
Called when connected state changes, to add/remove properties.
virtual void debugTriggered(bool enable) override
Inform driver that the debug option was triggered. This function is called after setDebug is triggere...
virtual bool updateTime(ln_date *utc, double utc_offset) override
Update telescope time, date, and UTC offset.
virtual IPState GuideEast(uint32_t ms) override
Guide east for ms milliseconds. East is defined as RA+.
virtual bool Abort() override
Abort any telescope motion including tracking if possible.
virtual bool initProperties() override
Called to initialize basic properties required all the time.
Definition ioptronv3.cpp:83
virtual IPState GuideWest(uint32_t ms) override
Guide west for ms milliseconds. West is defined as RA-.
virtual bool SetSlewRate(int index) override
SetSlewRate Set desired slew rate index.
const char * MOTION_TAB
MOTION_TAB Where all the motion control properties of the device are located.
const char * SITE_TAB
SITE_TAB Where all site information setting are located.
INDI::PropertyNumber TrackRateNP
INDI::PropertyNumber EqNP
INDI::PropertySwitch PECStateSP
INDI::PropertySwitch HomeSP
INDI::PropertySwitch SlewRateSP
INDI::PropertySwitch TrackModeSP
INDI::PropertyText TimeTP
INDI::PropertyNumber LocationNP
double ra
@ TR_SIDEREAL
@ TR_CUSTOM
@ TS_RS232
@ TS_CONTROLLER
@ HEMI_NORTH
@ HEMI_SOUTH
@ FW_CONTROLLER
@ FW_BOARD
@ GPS_DATA_OK
@ ST_STOPPED
@ ST_MERIDIAN_FLIPPING
@ ST_PARKED
@ ST_TRACKING_PEC_ON
@ ST_TRACKING_PEC_OFF
@ ST_SLEWING
@ ST_GUIDING
@ ST_HOME
#define RA_AXIS
#define DEC_AXIS
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
IPState
Property state.
Definition indiapi.h:158
@ IPS_BUSY
Definition indiapi.h:161
@ IPS_ALERT
Definition indiapi.h:162
@ IPS_IDLE
Definition indiapi.h:159
@ IPS_OK
Definition indiapi.h:160
#define MAXINDILABEL
Definition indiapi.h:190
@ ISR_1OFMANY
Definition indiapi.h:171
@ ISR_ATMOST1
Definition indiapi.h:172
@ AXIS_DE
@ AXIS_RA
INDI_DIR_WE
@ DIRECTION_WEST
INDI_DIR_NS
@ DIRECTION_NORTH
double range24(double r)
range24 Limits a number to be between 0-24 range.
Definition indicom.c:1311
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
Implementations for common driver routines.
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
int IUFindOnSwitchIndex(const ISwitchVectorProperty *svp)
Returns the index of first ON switch it finds in the vector switch property.
Definition indidevapi.c:337
void IUResetSwitch(ISwitchVectorProperty *svp)
Reset all switches in a switch vector property to OFF.
Definition indidevapi.c:366
void IUFillTextVector(ITextVectorProperty *tvp, IText *tp, int ntp, const char *dev, const char *name, const char *label, const char *group, IPerm p, double timeout, IPState s)
Assign attributes for a text vector property. The vector's auxiliary elements will be set to NULL.
Definition indidevapi.c:509
void IUSaveText(IText *tp, const char *newtext)
Function to reliably save new text in a IText.
Definition indidevapi.c:44
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 IUFillText(IText *tp, const char *name, const char *label, const char *initialText)
Assign attributes for a text property. The text's auxiliary elements will be set to NULL.
Definition indidevapi.c:416
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
#define INDI_UNUSED(x)
Definition indidevapi.h:132
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 IUGetConfigNumber(const char *dev, const char *property, const char *member, double *value)
IUGetConfigNumber Opens configuration file and reads single number property.
Definition indidriver.c:846
int IUUpdateNumber(INumberVectorProperty *nvp, double values[], char *names[], int n)
Update all numbers in a number vector property.
void IDSetText(const ITextVectorProperty *tvp, const char *fmt,...)
INDI::GuiderInterface GI
*brief user defined string literal for JSON values *sa std::size_t n
#define LOGF_INFO(fmt,...)
Definition indilogger.h:82
#define LOG_DEBUG(txt)
Definition indilogger.h:75
#define LOGF_WARN(fmt,...)
Definition indilogger.h:81
#define LOG_WARN(txt)
Definition indilogger.h:73
#define LOGF_DEBUG(fmt,...)
Definition indilogger.h:83
#define LOG_ERROR(txt)
Shorter logging macros. In order to use these macros, the function (or method) "getDeviceName()" must...
Definition indilogger.h:72
#define LOGF_ERROR(fmt,...)
Definition indilogger.h:80
#define LOG_INFO(txt)
Definition indilogger.h:74
#define DEBUGF(priority, msg,...)
Definition indilogger.h:57
#define TRACKRATE_SIDEREAL
Definition indimacros.h:39
#define getDeviceName
void EquatorialToHorizontal(IEquatorialCoordinates *object, IGeographicCoordinates *observer, double JD, IHorizontalCoordinates *position)
EquatorialToHorizontal Calculate horizontal coordinates from equatorial coordinates.
Definition libastro.cpp:141
Encapsulates classes and structures required for iOptron Command Set v3 implementation.
@ IOP_PIER_UNKNOWN
std::string ControllerFirmware
std::string MainBoardFirmware
IOP_GPS_STATUS gpsStatus
IOP_HEMISPHERE hemisphere
IOP_SYSTEM_STATUS systemStatus
IOP_TRACK_RATE trackRate
IOP_SLEW_RATE slewRate
IOP_TIME_SOURCE timeSource