Changeset View
Changeset View
Standalone View
Standalone View
kstars/ekos/mount/mount.cpp
Show All 40 Lines | |||||
41 | 41 | | |||
42 | extern const char *libindi_strings_context; | 42 | extern const char *libindi_strings_context; | ||
43 | 43 | | |||
44 | #define UPDATE_DELAY 1000 | 44 | #define UPDATE_DELAY 1000 | ||
45 | #define ABORT_DISPATCH_LIMIT 3 | 45 | #define ABORT_DISPATCH_LIMIT 3 | ||
46 | 46 | | |||
47 | namespace Ekos | 47 | namespace Ekos | ||
48 | { | 48 | { | ||
49 | | ||||
49 | Mount::Mount() | 50 | Mount::Mount() | ||
50 | { | 51 | { | ||
51 | setupUi(this); | 52 | setupUi(this); | ||
52 | 53 | | |||
53 | new MountAdaptor(this); | 54 | new MountAdaptor(this); | ||
54 | QDBusConnection::sessionBus().registerObject("/KStars/Ekos/Mount", this); | 55 | QDBusConnection::sessionBus().registerObject("/KStars/Ekos/Mount", this); | ||
56 | // Set up DBus interfaces | ||||
57 | QPointer<QDBusInterface> ekosInterface = new QDBusInterface("org.kde.kstars", "/KStars/Ekos", "org.kde.kstars.Ekos", | ||||
58 | QDBusConnection::sessionBus(), this); | ||||
59 | qDBusRegisterMetaType<SkyPoint>(); | ||||
60 | | ||||
61 | // Connecting DBus signals | ||||
62 | connect(ekosInterface, SIGNAL(newModule(QString)), this, SLOT(registerNewModule(QString))); | ||||
55 | 63 | | |||
56 | currentTelescope = nullptr; | 64 | currentTelescope = nullptr; | ||
57 | 65 | | |||
58 | abortDispatch = -1; | 66 | abortDispatch = -1; | ||
59 | 67 | | |||
60 | minAltLimit->setValue(Options::minimumAltLimit()); | 68 | minAltLimit->setValue(Options::minimumAltLimit()); | ||
61 | maxAltLimit->setValue(Options::maximumAltLimit()); | 69 | maxAltLimit->setValue(Options::maximumAltLimit()); | ||
62 | 70 | | |||
▲ Show 20 Lines • Show All 262 Lines • ▼ Show 20 Line(s) | 330 | { | |||
325 | trackingGroup->setEnabled(false); | 333 | trackingGroup->setEnabled(false); | ||
326 | } | 334 | } | ||
327 | 335 | | |||
328 | ITextVectorProperty *tvp = currentTelescope->getBaseDevice()->getText("SCOPE_CONFIG_NAME"); | 336 | ITextVectorProperty *tvp = currentTelescope->getBaseDevice()->getText("SCOPE_CONFIG_NAME"); | ||
329 | if (tvp) | 337 | if (tvp) | ||
330 | scopeConfigNameEdit->setText(tvp->tp[0].text); | 338 | scopeConfigNameEdit->setText(tvp->tp[0].text); | ||
331 | } | 339 | } | ||
332 | 340 | | |||
341 | void Mount::registerNewModule(const QString &name) | ||||
342 | { | ||||
343 | if (name == "Capture") | ||||
344 | { | ||||
345 | captureInterface = new QDBusInterface("org.kde.kstars", "/KStars/Ekos/Capture", "org.kde.kstars.Ekos.Capture", | ||||
346 | QDBusConnection::sessionBus(), this); | ||||
347 | } | ||||
348 | | ||||
349 | } | ||||
350 | | ||||
351 | | ||||
333 | void Mount::updateText(ITextVectorProperty *tvp) | 352 | void Mount::updateText(ITextVectorProperty *tvp) | ||
334 | { | 353 | { | ||
335 | if (!strcmp(tvp->name, "SCOPE_CONFIG_NAME")) | 354 | if (!strcmp(tvp->name, "SCOPE_CONFIG_NAME")) | ||
336 | { | 355 | { | ||
337 | scopeConfigNameEdit->setText(tvp->tp[0].text); | 356 | scopeConfigNameEdit->setText(tvp->tp[0].text); | ||
338 | } | 357 | } | ||
339 | } | 358 | } | ||
340 | 359 | | |||
▲ Show 20 Lines • Show All 447 Lines • ▼ Show 20 Line(s) | 787 | { | |||
788 | return slew(ra.Hours(), de.Degrees()); | 807 | return slew(ra.Hours(), de.Degrees()); | ||
789 | } | 808 | } | ||
790 | 809 | | |||
791 | bool Mount::slew(double RA, double DEC) | 810 | bool Mount::slew(double RA, double DEC) | ||
792 | { | 811 | { | ||
793 | if (currentTelescope == nullptr || currentTelescope->isConnected() == false) | 812 | if (currentTelescope == nullptr || currentTelescope->isConnected() == false) | ||
794 | return false; | 813 | return false; | ||
795 | 814 | | |||
815 | dms lst = KStarsData::Instance()->geo()->GSTtoLST(KStarsData::Instance()->clock()->utc().gst()); | ||||
816 | double HA = lst.Hours() - RA; | ||||
817 | if (HA > 12.0) | ||||
818 | HA -= 24.0; | ||||
819 | | ||||
820 | setInitialHA(HA); | ||||
821 | | ||||
822 | currentTargetPosition.setRA(RA); | ||||
823 | currentTargetPosition.setDec(DEC); | ||||
824 | | ||||
796 | return currentTelescope->Slew(RA, DEC); | 825 | return currentTelescope->Slew(RA, DEC); | ||
797 | } | 826 | } | ||
798 | 827 | | |||
828 | bool Mount::executeMeridianFlip() { | ||||
829 | if (getInitialHA() > 0) | ||||
830 | // no meridian flip necessary | ||||
831 | return false; | ||||
832 | | ||||
833 | dms lst = KStarsData::Instance()->geo()->GSTtoLST(KStarsData::Instance()->clock()->utc().gst()); | ||||
834 | double HA = lst.Hours() - currentTargetPosition.ra().Hours(); | ||||
835 | if (HA > 12.0) | ||||
TallFurryMan: I'm not sure this is correct : hours are reduced to [0,24[, so you need proper sign management… | |||||
Well, maybe, but this is the original code. At least now it is more or less properly encapsulated. I tend to leave it as is. wreissenberger: Well, maybe, but this is the original code. At least now it is more or less properly… | |||||
836 | // no meridian flip necessary | ||||
837 | return false; | ||||
838 | | ||||
839 | // execute meridian flip | ||||
840 | slew(currentTargetPosition.ra().Hours(), currentTargetPosition.dec().Degrees()); | ||||
TallFurryMan: Missing management of return code. | |||||
841 | return true; | ||||
842 | | ||||
843 | } | ||||
844 | | ||||
845 | SkyPoint Mount::currentTarget() | ||||
846 | { | ||||
847 | return currentTargetPosition; | ||||
848 | } | ||||
849 | | ||||
850 | | ||||
851 | | ||||
799 | bool Mount::sync(const QString &RA, const QString &DEC) | 852 | bool Mount::sync(const QString &RA, const QString &DEC) | ||
800 | { | 853 | { | ||
801 | dms ra, de; | 854 | dms ra, de; | ||
802 | 855 | | |||
803 | ra = dms::fromString(RA, false); | 856 | ra = dms::fromString(RA, false); | ||
804 | de = dms::fromString(DEC, true); | 857 | de = dms::fromString(DEC, true); | ||
805 | 858 | | |||
806 | if (m_J2000Check->property("checked").toBool()) | 859 | if (m_J2000Check->property("checked").toBool()) | ||
▲ Show 20 Lines • Show All 56 Lines • ▼ Show 20 Line(s) | |||||
863 | 916 | | |||
864 | double Mount::hourAngle() | 917 | double Mount::hourAngle() | ||
865 | { | 918 | { | ||
866 | dms lst = KStarsData::Instance()->geo()->GSTtoLST(KStarsData::Instance()->clock()->utc().gst()); | 919 | dms lst = KStarsData::Instance()->geo()->GSTtoLST(KStarsData::Instance()->clock()->utc().gst()); | ||
867 | dms ha(lst.Degrees() - telescopeCoord.ra().Degrees()); | 920 | dms ha(lst.Degrees() - telescopeCoord.ra().Degrees()); | ||
868 | double HA = ha.Hours(); | 921 | double HA = ha.Hours(); | ||
869 | 922 | | |||
870 | if (HA > 12.0) | 923 | if (HA > 12.0) | ||
871 | return (24 - HA); | 924 | return (HA - 24.0); | ||
872 | else | 925 | else | ||
873 | return HA; | 926 | return HA; | ||
874 | } | 927 | } | ||
875 | 928 | | |||
876 | QList<double> Mount::telescopeInfo() | 929 | QList<double> Mount::telescopeInfo() | ||
877 | { | 930 | { | ||
878 | QList<double> info; | 931 | QList<double> info; | ||
879 | 932 | | |||
▲ Show 20 Lines • Show All 343 Lines • Show Last 20 Lines |
I'm not sure this is correct : hours are reduced to [0,24[, so you need proper sign management to handle rising/setting limit. But I didn't redo the maths. Took some hair in D16429...