7#include <indi/indidevice.h>
11#include "clientmanagerlite.h"
12#include "inditelescopelite.h"
14#include "kstarslite.h"
15#include "skymaplite.h"
17TelescopeLite::TelescopeLite(INDI::BaseDevice *device)
18 : minAlt(-1), maxAlt(-1), IsParked(
false), clientManager(
KStarsLite::Instance()->clientManagerLite()),
19 baseDevice(device), slewRateIndex(0)
21 setDeviceName(device->getDeviceName());
23 connect(clientManager, &ClientManagerLite::newINDIProperty,
this, &TelescopeLite::updateSlewRate);
24 connect(clientManager, &ClientManagerLite::newINDISwitch,
this, &TelescopeLite::updateSlewRate);
27void TelescopeLite::updateSlewRate(
const QString &deviceName,
const QString &propName)
29 if (deviceName == baseDevice->getDeviceName() && propName ==
"TELESCOPE_SLEW_RATE")
31 auto slewRateSP = baseDevice->getSwitch(
"TELESCOPE_SLEW_RATE");
41 m_slewRateLabels.
clear();
46 emit slewRateUpdate(index, m_slewRateLabels.
size());
51TelescopeLite::~TelescopeLite()
55void TelescopeLite::setSlewDecreasable(
bool slewDecreasable)
57 if (m_slewDecreasable != slewDecreasable)
59 m_slewDecreasable = slewDecreasable;
60 emit slewDecreasableChanged(slewDecreasable);
64void TelescopeLite::setSlewIncreasable(
bool slewIncreasable)
66 if (m_slewIncreasable != slewIncreasable)
68 m_slewIncreasable = slewIncreasable;
69 emit slewIncreasableChanged(slewIncreasable);
73void TelescopeLite::setSlewRateLabel(
const QString &slewRateLabel)
75 if (m_slewRateLabel != slewRateLabel)
77 m_slewRateLabel = slewRateLabel;
78 emit slewRateLabelChanged(slewRateLabel);
82void TelescopeLite::setDeviceName(
const QString &deviceName)
84 if (m_deviceName != deviceName)
86 m_deviceName = deviceName;
87 emit deviceNameChanged(deviceName);
91void TelescopeLite::registerProperty(INDI::Property
prop)
93 if (
prop->isNameMatch(
"TELESCOPE_INFO"))
95 auto ti =
prop->getNumber();
104 if (
prop->isNameMatch(
"TELESCOPE_PARK"))
110 auto sp =
svp->findWidgetByName(
"PARK");
121 if (!
strcmp(
nvp->name,
"EQUATORIAL_EOD_COORD"))
126 if (RA ==
nullptr ||
DEC ==
nullptr)
129 currentCoord.
setRA(RA->value);
139 if (!
strcmp(
nvp->name,
"EQUATORIAL_COORD"))
144 if (RA ==
nullptr ||
DEC ==
nullptr)
147 currentCoord.
setRA0(RA->value);
158 if (!
strcmp(
nvp->name,
"HORIZONTAL_COORD"))
163 if (Az ==
nullptr || Alt ==
nullptr)
166 currentCoord.
setAz(Az->value);
167 currentCoord.
setAlt(Alt->value);
199bool TelescopeLite::canGuide()
201 auto raPulse = baseDevice->getNumber(
"TELESCOPE_TIMED_GUIDE_WE");
202 auto decPulse = baseDevice->getNumber(
"TELESCOPE_TIMED_GUIDE_NS");
207bool TelescopeLite::canSync()
209 auto motionSP = baseDevice->getSwitch(
"ON_COORD_SET");
216 return (
syncSW !=
nullptr);
219bool TelescopeLite::canPark()
221 auto parkSP = baseDevice->getSwitch(
"TELESCOPE_PARK");
228 return (
parkSW !=
nullptr);
231bool TelescopeLite::isSlewing()
233 auto EqProp = baseDevice->getNumber(
"EQUATORIAL_EOD_COORD");
240bool TelescopeLite::isInMotion()
243 bool inSlew = isSlewing();
245 auto movementSP = baseDevice->getSwitch(
"TELESCOPE_MOTION_NS");
249 movementSP = baseDevice->getSwitch(
"TELESCOPE_MOTION_WE");
265 auto EqProp = baseDevice->getNumber(
"EQUATORIAL_EOD_COORD");
269 EqProp = baseDevice->getNumber(
"EQUATORIAL_COORD");
274 auto HorProp = baseDevice->getNumber(
"HORIZONTAL_COORD");
299 ScopeTarget->EquatorialToHorizontal(KStarsData::Instance()->lst(), KStarsData::Instance()->
geo()->lat());
355 clientManager->sendNewNumber(
EqProp);
365 clientManager->sendNewNumber(
HorProp);
373bool TelescopeLite::slew(
double ra,
double dec)
380 return slew(&target);
385 auto motionSP = baseDevice->getSwitch(
"ON_COORD_SET");
402 clientManager->sendNewSwitch(
motionSP);
404 if (Options::iNDILogging())
411bool TelescopeLite::sync(
double ra,
double dec)
418 return sync(&target);
423 auto motionSP = baseDevice->getSwitch(
"ON_COORD_SET");
437 clientManager->sendNewSwitch(
motionSP);
439 if (Options::iNDILogging())
440 qDebug() <<
"ISD:Telescope: Syncing...";
446bool TelescopeLite::abort()
448 auto motionSP = baseDevice->getSwitch(
"TELESCOPE_ABORT_MOTION");
458 if (Options::iNDILogging())
459 qDebug() <<
"ISD:Telescope: Aborted." <<
endl;
462 clientManager->sendNewSwitch(
motionSP);
467bool TelescopeLite::park()
469 auto parkSP = baseDevice->getSwitch(
"TELESCOPE_PARK");
479 if (Options::iNDILogging())
480 qDebug() <<
"ISD:Telescope: Parking..." <<
endl;
484 clientManager->sendNewSwitch(
parkSP);
489bool TelescopeLite::unPark()
491 auto parkSP = baseDevice->getSwitch(
"TELESCOPE_PARK");
501 if (Options::iNDILogging())
502 qDebug() <<
"ISD:Telescope: UnParking..." <<
endl;
506 clientManager->sendNewSwitch(
parkSP);
511bool TelescopeLite::getEqCoords(
double *ra,
double *dec)
513 auto EqProp = baseDevice->getNumber(
"EQUATORIAL_EOD_COORD");
526 *ra =
RAEle->getValue();
532bool TelescopeLite::moveNS(TelescopeMotionNS dir, TelescopeMotionCommand
cmd)
534 auto motionSP = baseDevice->getSwitch(
"TELESCOPE_MOTION_NS");
554 if (
cmd == MOTION_START)
556 if (dir == MOTION_NORTH)
562 if (
cmd == MOTION_STOP)
564 if (dir == MOTION_NORTH)
570 clientManager->sendNewSwitch(
motionSP);
575bool TelescopeLite::moveWE(TelescopeMotionWE dir, TelescopeMotionCommand
cmd)
577 auto motionSP = baseDevice->getSwitch(
"TELESCOPE_MOTION_WE");
597 if (
cmd == MOTION_START)
599 if (dir == MOTION_WEST)
605 if (
cmd == MOTION_STOP)
607 if (dir == MOTION_WEST)
613 clientManager->sendNewSwitch(
motionSP);
618bool TelescopeLite::setSlewRate(
int index)
620 auto slewRateSP = baseDevice->getSwitch(
"TELESCOPE_SLEW_RATE");
642 slewRateIndex = index;
643 setSlewRateLabel(
slewRateSP->at(index)->getLabel());
644 setSlewDecreasable(index != 0);
653bool TelescopeLite::decreaseSlewRate()
655 return setSlewRate(slewRateIndex - 1);
658bool TelescopeLite::increaseSlewRate()
660 return setSlewRate(slewRateIndex + 1);
663void TelescopeLite::setAltLimits(
double minAltitude,
double maxAltitude)
665 minAlt = minAltitude;
666 maxAlt = maxAltitude;
669bool TelescopeLite::isParked()
This class loads QML files and connects SkyMapLite and KStarsData Unlike KStars class it is not a mai...
static KStarsLite * Instance()
The sky coordinates of a point in the sky.
void apparentCoord(long double jd0, long double jdf)
Computes the apparent coordinates for this SkyPoint for any epoch, accounting for the effects of prec...
void setDec(dms d)
Sets Dec, the current Declination.
void setRA(dms &r)
Sets RA, the current Right Ascension.
void setRA0(dms r)
Sets RA0, the catalog Right Ascension.
void setAlt(dms alt)
Sets Alt, the Altitude.
void HorizontalToEquatorial(const dms *LST, const dms *lat)
Determine the (RA, Dec) coordinates of the SkyPoint from its (Altitude, Azimuth) coordinates,...
void setAz(dms az)
Sets Az, the Azimuth.
void setDec0(dms d)
Sets Dec0, the catalog Declination.
An angle, stored as degrees, but expressible in many ways.
GeoCoordinates geo(const QVariant &location)
void push_back(parameter_type value)
qsizetype size() const const
QTextStream & dec(QTextStream &stream)
QTextStream & endl(QTextStream &stream)
QFuture< ArgsType< Signal > > connect(Sender *sender, Signal signal)