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 263 Lines • ▼ Show 20 Line(s) | 331 | { | |||
326 | trackingGroup->setEnabled(false); | 334 | trackingGroup->setEnabled(false); | ||
327 | } | 335 | } | ||
328 | 336 | | |||
329 | ITextVectorProperty *tvp = currentTelescope->getBaseDevice()->getText("SCOPE_CONFIG_NAME"); | 337 | ITextVectorProperty *tvp = currentTelescope->getBaseDevice()->getText("SCOPE_CONFIG_NAME"); | ||
330 | if (tvp) | 338 | if (tvp) | ||
331 | scopeConfigNameEdit->setText(tvp->tp[0].text); | 339 | scopeConfigNameEdit->setText(tvp->tp[0].text); | ||
332 | } | 340 | } | ||
333 | 341 | | |||
342 | void Mount::registerNewModule(const QString &name) | ||||
343 | { | ||||
344 | if (name == "Capture") | ||||
345 | { | ||||
346 | captureInterface = new QDBusInterface("org.kde.kstars", "/KStars/Ekos/Capture", "org.kde.kstars.Ekos.Capture", | ||||
347 | QDBusConnection::sessionBus(), this); | ||||
348 | } | ||||
349 | | ||||
350 | } | ||||
351 | | ||||
352 | | ||||
334 | void Mount::updateText(ITextVectorProperty *tvp) | 353 | void Mount::updateText(ITextVectorProperty *tvp) | ||
335 | { | 354 | { | ||
336 | if (!strcmp(tvp->name, "SCOPE_CONFIG_NAME")) | 355 | if (!strcmp(tvp->name, "SCOPE_CONFIG_NAME")) | ||
337 | { | 356 | { | ||
338 | scopeConfigNameEdit->setText(tvp->tp[0].text); | 357 | scopeConfigNameEdit->setText(tvp->tp[0].text); | ||
339 | } | 358 | } | ||
340 | } | 359 | } | ||
341 | 360 | | |||
▲ Show 20 Lines • Show All 447 Lines • ▼ Show 20 Line(s) | 788 | { | |||
789 | return slew(ra.Hours(), de.Degrees()); | 808 | return slew(ra.Hours(), de.Degrees()); | ||
790 | } | 809 | } | ||
791 | 810 | | |||
792 | bool Mount::slew(double RA, double DEC) | 811 | bool Mount::slew(double RA, double DEC) | ||
793 | { | 812 | { | ||
794 | if (currentTelescope == nullptr || currentTelescope->isConnected() == false) | 813 | if (currentTelescope == nullptr || currentTelescope->isConnected() == false) | ||
795 | return false; | 814 | return false; | ||
796 | 815 | | |||
816 | dms lst = KStarsData::Instance()->geo()->GSTtoLST(KStarsData::Instance()->clock()->utc().gst()); | ||||
817 | double HA = lst.Hours() - RA; | ||||
818 | if (HA > 12.0) | ||||
819 | HA -= 24.0; | ||||
820 | | ||||
821 | setInitialHA(HA); | ||||
822 | | ||||
823 | currentTargetPosition.setRA(RA); | ||||
824 | currentTargetPosition.setDec(DEC); | ||||
825 | | ||||
797 | return currentTelescope->Slew(RA, DEC); | 826 | return currentTelescope->Slew(RA, DEC); | ||
798 | } | 827 | } | ||
799 | 828 | | |||
829 | bool Mount::executeMeridianFlip() { | ||||
830 | if (initialHA() > 0) | ||||
831 | // no meridian flip necessary | ||||
832 | return false; | ||||
833 | | ||||
834 | dms lst = KStarsData::Instance()->geo()->GSTtoLST(KStarsData::Instance()->clock()->utc().gst()); | ||||
835 | double HA = lst.Hours() - currentTargetPosition.ra().Hours(); | ||||
836 | 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… | |||||
837 | // no meridian flip necessary | ||||
838 | return false; | ||||
839 | | ||||
840 | // execute meridian flip | ||||
841 | slew(currentTargetPosition.ra().Hours(), currentTargetPosition.dec().Degrees()); | ||||
TallFurryMan: Missing management of return code. | |||||
842 | return true; | ||||
843 | | ||||
844 | } | ||||
845 | | ||||
846 | SkyPoint Mount::currentTarget() | ||||
847 | { | ||||
848 | return currentTargetPosition; | ||||
849 | } | ||||
850 | | ||||
851 | | ||||
852 | | ||||
800 | bool Mount::sync(const QString &RA, const QString &DEC) | 853 | bool Mount::sync(const QString &RA, const QString &DEC) | ||
801 | { | 854 | { | ||
802 | dms ra, de; | 855 | dms ra, de; | ||
803 | 856 | | |||
804 | ra = dms::fromString(RA, false); | 857 | ra = dms::fromString(RA, false); | ||
805 | de = dms::fromString(DEC, true); | 858 | de = dms::fromString(DEC, true); | ||
806 | 859 | | |||
807 | if (m_J2000Check->property("checked").toBool()) | 860 | if (m_J2000Check->property("checked").toBool()) | ||
▲ Show 20 Lines • Show All 56 Lines • ▼ Show 20 Line(s) | |||||
864 | 917 | | |||
865 | double Mount::hourAngle() | 918 | double Mount::hourAngle() | ||
866 | { | 919 | { | ||
867 | dms lst = KStarsData::Instance()->geo()->GSTtoLST(KStarsData::Instance()->clock()->utc().gst()); | 920 | dms lst = KStarsData::Instance()->geo()->GSTtoLST(KStarsData::Instance()->clock()->utc().gst()); | ||
868 | dms ha(lst.Degrees() - telescopeCoord.ra().Degrees()); | 921 | dms ha(lst.Degrees() - telescopeCoord.ra().Degrees()); | ||
869 | double HA = ha.Hours(); | 922 | double HA = ha.Hours(); | ||
870 | 923 | | |||
871 | if (HA > 12.0) | 924 | if (HA > 12.0) | ||
872 | return (24 - HA); | 925 | return (HA - 24.0); | ||
873 | else | 926 | else | ||
874 | return HA; | 927 | return HA; | ||
875 | } | 928 | } | ||
876 | 929 | | |||
877 | QList<double> Mount::telescopeInfo() | 930 | QList<double> Mount::telescopeInfo() | ||
878 | { | 931 | { | ||
879 | QList<double> info; | 932 | QList<double> info; | ||
880 | 933 | | |||
▲ Show 20 Lines • Show All 341 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...