diff --git a/kstars/ekos/auxiliary/dome.h b/kstars/ekos/auxiliary/dome.h --- a/kstars/ekos/auxiliary/dome.h +++ b/kstars/ekos/auxiliary/dome.h @@ -31,6 +31,7 @@ Q_PROPERTY(ISD::ParkStatus parkStatus READ parkStatus NOTIFY newParkStatus) Q_PROPERTY(bool canPark READ canPark) Q_PROPERTY(bool canAbsoluteMove READ canAbsoluteMove) + Q_PROPERTY(bool isMoving READ isMoving) Q_PROPERTY(double azimuthPosition READ azimuthPosition WRITE setAzimuthPosition NOTIFY azimuthPositionChanged) public: diff --git a/kstars/ekos/scheduler/scheduler.cpp b/kstars/ekos/scheduler/scheduler.cpp --- a/kstars/ekos/scheduler/scheduler.cpp +++ b/kstars/ekos/scheduler/scheduler.cpp @@ -3179,60 +3179,50 @@ if (!checkStatus()) return; + // #6 Check each stage is processing properly + // FIXME: Vanishing property should trigger a call to its event callback switch (currentJob->getStage()) { case SchedulerJob::STAGE_IDLE: getNextAction(); break; -#if 0 case SchedulerJob::STAGE_SLEWING: - { - QDBusReply slewStatus = mountInterface->call(QDBus::AutoDetect, "getSlewStatus"); - bool isDomeMoving = false; - - if (parkDomeCheck->isEnabled()) + case SchedulerJob::STAGE_RESLEWING: + // While slewing or re-slewing, check slew status can still be obtained { - QDBusReply domeReply = domeInterface->call(QDBus::AutoDetect, "isMoving"); - if (domeReply.error().type() == QDBusError::NoError && domeReply.value() == true) - isDomeMoving = true; - } + QVariant const slewStatus = mountInterface->property("slewStatus"); - if (slewStatus.error().type() == QDBusError::UnknownObject) - { - appendLogText(i18n("Warning: job '%1' lost connection to INDI while slewing, attempting to reconnect.", currentJob->getName())); - if (!manageConnectionLoss()) - currentJob->setState(SchedulerJob::JOB_ERROR); - return; + if (!slewStatus.isValid()) + { + appendLogText(i18n("Warning: job '%1' lost connection to the mount, attempting to reconnect.", currentJob->getName())); + if (!manageConnectionLoss()) + currentJob->setState(SchedulerJob::JOB_ERROR); + return; + } } + break; - qCDebug(KSTARS_EKOS_SCHEDULER) - << "Slewing Stage... Slew Status is " << pstateStr(static_cast(slewStatus.value())); - - if (slewStatus.value() == IPS_OK && isDomeMoving == false) - { - appendLogText(i18n("Job '%1' slew is complete.", currentJob->getName())); - currentJob->setStage(SchedulerJob::STAGE_SLEW_COMPLETE); - getNextAction(); - } - else if (slewStatus.value() == IPS_ALERT) + case SchedulerJob::STAGE_SLEW_COMPLETE: + case SchedulerJob::STAGE_RESLEWING_COMPLETE: + // When done slewing or re-slewing and we use a dome, only shift to the next action when the dome is done moving + if (m_DomeReady) { - appendLogText(i18n("Warning: job '%1' slew failed, marking terminated due to errors.", currentJob->getName())); - currentJob->setState(SchedulerJob::JOB_ERROR); + QVariant const isDomeMoving = domeInterface->property("isMoving"); - findNextJob(); - } - else if (slewStatus.value() == IPS_IDLE) - { - appendLogText(i18n("Warning: job '%1' found not slewing, restarting.", currentJob->getName())); - currentJob->setStage(SchedulerJob::STAGE_IDLE); + if (!isDomeMoving.isValid()) + { + appendLogText(i18n("Warning: job '%1' lost connection to the dome, attempting to reconnect.", currentJob->getName())); + if (!manageConnectionLoss()) + currentJob->setState(SchedulerJob::JOB_ERROR); + return; + } - getNextAction(); + if (!isDomeMoving.value()) + getNextAction(); } - } - break; -#endif - + else getNextAction(); + break; #if 0 case SchedulerJob::STAGE_FOCUSING: { @@ -3345,41 +3335,6 @@ break; #endif - case SchedulerJob::STAGE_RESLEWING: - { - QVariant isDomeMoving = false; - - qCDebug(KSTARS_EKOS_SCHEDULER) << "Re-slewing stage..."; - - if (m_DomeReady) - isDomeMoving = domeInterface->property("isMoving"); - - QVariant mountStatus = mountInterface->property("status"); - ISD::Telescope::Status status = static_cast(mountStatus.toInt()); - - if (status == ISD::Telescope::MOUNT_TRACKING && isDomeMoving == false) - { - appendLogText(i18n("Job '%1' repositioning is complete.", currentJob->getName())); - currentJob->setStage(SchedulerJob::STAGE_RESLEWING_COMPLETE); - getNextAction(); - } - else if (status == ISD::Telescope::MOUNT_ERROR) - { - appendLogText(i18n("Warning: job '%1' repositioning failed, marking terminated due to errors.", currentJob->getName())); - currentJob->setState(SchedulerJob::JOB_ERROR); - - findNextJob(); - } - else if (status == ISD::Telescope::MOUNT_IDLE) - { - appendLogText(i18n("Warning: job '%1' found not repositioning, restarting.", currentJob->getName())); - currentJob->setStage(SchedulerJob::STAGE_IDLE); - - getNextAction(); - } - } - break; - #if 0 case SchedulerJob::STAGE_GUIDING: { @@ -6586,84 +6541,66 @@ if (state == SCHEDULER_PAUSED || currentJob == nullptr) return; - qCDebug(KSTARS_EKOS_SCHEDULER) << "Mount State" << status; + qCDebug(KSTARS_EKOS_SCHEDULER) << "Mount State changed to" << status; /* If current job is scheduled and has not started yet, wait */ if (SchedulerJob::JOB_SCHEDULED == currentJob->getState()) - { - QDateTime const now = KStarsData::Instance()->lt(); - if (now < currentJob->getStartupTime()) + if ((QDateTime) KStarsData::Instance()->lt() < currentJob->getStartupTime()) return; - } switch (currentJob->getStage()) { case SchedulerJob::STAGE_SLEWING: { - QVariant isDomeMoving = false; - qCDebug(KSTARS_EKOS_SCHEDULER) << "Slewing stage..."; - if (m_DomeReady) - isDomeMoving = domeInterface->property("isMoving"); - - if (status == ISD::Telescope::MOUNT_TRACKING && isDomeMoving == false) + if (status == ISD::Telescope::MOUNT_TRACKING) { appendLogText(i18n("Job '%1' slew is complete.", currentJob->getName())); currentJob->setStage(SchedulerJob::STAGE_SLEW_COMPLETE); - getNextAction(); + /* getNextAction is deferred to checkJobStage for dome support */ } else if (status == ISD::Telescope::MOUNT_ERROR) { appendLogText(i18n("Warning: job '%1' slew failed, marking terminated due to errors.", currentJob->getName())); currentJob->setState(SchedulerJob::JOB_ERROR); - findNextJob(); } else if (status == ISD::Telescope::MOUNT_IDLE) { appendLogText(i18n("Warning: job '%1' found not slewing, restarting.", currentJob->getName())); currentJob->setStage(SchedulerJob::STAGE_IDLE); - getNextAction(); } } break; case SchedulerJob::STAGE_RESLEWING: { - QVariant isDomeMoving = false; - qCDebug(KSTARS_EKOS_SCHEDULER) << "Re-slewing stage..."; - if (m_DomeReady) - isDomeMoving = domeInterface->property("isMoving"); - - if (status == ISD::Telescope::MOUNT_TRACKING && isDomeMoving == false) + if (status == ISD::Telescope::MOUNT_TRACKING) { appendLogText(i18n("Job '%1' repositioning is complete.", currentJob->getName())); currentJob->setStage(SchedulerJob::STAGE_RESLEWING_COMPLETE); - getNextAction(); + /* getNextAction is deferred to checkJobStage for dome support */ } else if (status == ISD::Telescope::MOUNT_ERROR) { appendLogText(i18n("Warning: job '%1' repositioning failed, marking terminated due to errors.", currentJob->getName())); currentJob->setState(SchedulerJob::JOB_ERROR); - findNextJob(); } else if (status == ISD::Telescope::MOUNT_IDLE) { appendLogText(i18n("Warning: job '%1' found not repositioning, restarting.", currentJob->getName())); currentJob->setStage(SchedulerJob::STAGE_IDLE); - getNextAction(); } } break; - default: - break; + default: break; } } diff --git a/kstars/org.kde.kstars.Ekos.Dome.xml b/kstars/org.kde.kstars.Ekos.Dome.xml --- a/kstars/org.kde.kstars.Ekos.Dome.xml +++ b/kstars/org.kde.kstars.Ekos.Dome.xml @@ -19,8 +19,7 @@ - - +