Changeset View
Changeset View
Standalone View
Standalone View
kstars/ekos/scheduler/scheduler.cpp
- This file is larger than 256 KB, so syntax highlighting is disabled by default.
Show First 20 Lines • Show All 192 Lines • ▼ Show 20 Line(s) | 48 | { | |||
---|---|---|---|---|---|
193 | connect(pauseB, &QPushButton::clicked, this, &Scheduler::pause); | 193 | connect(pauseB, &QPushButton::clicked, this, &Scheduler::pause); | ||
194 | 194 | | |||
195 | connect(queueSaveAsB, &QPushButton::clicked, this, &Scheduler::saveAs); | 195 | connect(queueSaveAsB, &QPushButton::clicked, this, &Scheduler::saveAs); | ||
196 | connect(queueSaveB, &QPushButton::clicked, this, &Scheduler::save); | 196 | connect(queueSaveB, &QPushButton::clicked, this, &Scheduler::save); | ||
197 | connect(queueLoadB, &QPushButton::clicked, this, &Scheduler::load); | 197 | connect(queueLoadB, &QPushButton::clicked, this, &Scheduler::load); | ||
198 | 198 | | |||
199 | connect(twilightCheck, &QCheckBox::toggled, this, &Scheduler::checkTwilightWarning); | 199 | connect(twilightCheck, &QCheckBox::toggled, this, &Scheduler::checkTwilightWarning); | ||
200 | 200 | | |||
201 | // Connect simulation clock scale | ||||
202 | connect(KStarsData::Instance()->clock(), &SimClock::scaleChanged, this, &Scheduler::simClockScaleChanged); | ||||
203 | | ||||
201 | // restore default values for error handling strategy | 204 | // restore default values for error handling strategy | ||
202 | setErrorHandlingStrategy(static_cast<ErrorHandlingStrategy>(Options::errorHandlingStrategy())); | 205 | setErrorHandlingStrategy(static_cast<ErrorHandlingStrategy>(Options::errorHandlingStrategy())); | ||
203 | errorHandlingRescheduleErrorsCB->setChecked(Options::rescheduleErrors()); | 206 | errorHandlingRescheduleErrorsCB->setChecked(Options::rescheduleErrors()); | ||
204 | errorHandlingDelaySB->setValue(Options::errorHandlingStrategyDelay()); | 207 | errorHandlingDelaySB->setValue(Options::errorHandlingStrategyDelay()); | ||
205 | 208 | | |||
206 | // save new default values for error handling strategy | 209 | // save new default values for error handling strategy | ||
207 | 210 | | |||
208 | connect(errorHandlingRescheduleErrorsCB, &QPushButton::clicked, [this](bool checked) | 211 | connect(errorHandlingRescheduleErrorsCB, &QPushButton::clicked, [this](bool checked) | ||
▲ Show 20 Lines • Show All 159 Lines • ▼ Show 20 Line(s) | |||||
368 | void Scheduler::appendLogText(const QString &text) | 371 | void Scheduler::appendLogText(const QString &text) | ||
369 | { | 372 | { | ||
370 | /* FIXME: user settings for log length */ | 373 | /* FIXME: user settings for log length */ | ||
371 | int const max_log_count = 2000; | 374 | int const max_log_count = 2000; | ||
372 | if (m_LogText.size() > max_log_count) | 375 | if (m_LogText.size() > max_log_count) | ||
373 | m_LogText.removeLast(); | 376 | m_LogText.removeLast(); | ||
374 | 377 | | |||
375 | m_LogText.prepend(i18nc("log entry; %1 is the date, %2 is the text", "%1 %2", | 378 | m_LogText.prepend(i18nc("log entry; %1 is the date, %2 is the text", "%1 %2", | ||
376 | QDateTime::currentDateTime().toString("yyyy-MM-ddThh:mm:ss"), text)); | 379 | KStarsData::Instance()->lt().toString("yyyy-MM-ddThh:mm:ss"), text)); | ||
377 | 380 | | |||
378 | qCInfo(KSTARS_EKOS_SCHEDULER) << text; | 381 | qCInfo(KSTARS_EKOS_SCHEDULER) << text; | ||
379 | 382 | | |||
380 | emit newLog(text); | 383 | emit newLog(text); | ||
381 | } | 384 | } | ||
382 | 385 | | |||
383 | void Scheduler::clearLog() | 386 | void Scheduler::clearLog() | ||
384 | { | 387 | { | ||
▲ Show 20 Lines • Show All 1292 Lines • ▼ Show 20 Line(s) | 1666 | { | |||
1677 | { | 1680 | { | ||
1678 | // interrupt regular status checks during the sleep time | 1681 | // interrupt regular status checks during the sleep time | ||
1679 | schedulerTimer.stop(); | 1682 | schedulerTimer.stop(); | ||
1680 | 1683 | | |||
1681 | // but before we restart them, we wait for the given delay. | 1684 | // but before we restart them, we wait for the given delay. | ||
1682 | appendLogText(i18n("All jobs aborted. Waiting %1 seconds to re-schedule.", errorHandlingDelaySB->value())); | 1685 | appendLogText(i18n("All jobs aborted. Waiting %1 seconds to re-schedule.", errorHandlingDelaySB->value())); | ||
1683 | 1686 | | |||
1684 | // wait the given delay until the jobs will be evaluated again | 1687 | // wait the given delay until the jobs will be evaluated again | ||
1685 | sleepTimer.setInterval(( errorHandlingDelaySB->value() * 1000)); | 1688 | sleepTimer.setInterval(std::lround((errorHandlingDelaySB->value() * 1000) / KStarsData::Instance()->clock()->scale())); | ||
1686 | sleepTimer.start(); | 1689 | sleepTimer.start(); | ||
1687 | sleepLabel->setToolTip(i18n("Scheduler waits for a retry.")); | 1690 | sleepLabel->setToolTip(i18n("Scheduler waits for a retry.")); | ||
1688 | sleepLabel->show(); | 1691 | sleepLabel->show(); | ||
1689 | // we continue to determine which job should be running, when the delay is over | 1692 | // we continue to determine which job should be running, when the delay is over | ||
1690 | } | 1693 | } | ||
1691 | } | 1694 | } | ||
1692 | 1695 | | |||
1693 | /* If option says so, reorder by altitude and priority before sequencing */ | 1696 | /* If option says so, reorder by altitude and priority before sequencing */ | ||
▲ Show 20 Lines • Show All 2882 Lines • ▼ Show 20 Line(s) | 4577 | if (errorHandlingRestartImmediatelyButton->isChecked() && | |||
4576 | (currentJob->getState() == SchedulerJob::JOB_ERROR && errorHandlingRescheduleErrorsCB->isChecked()))) | 4579 | (currentJob->getState() == SchedulerJob::JOB_ERROR && errorHandlingRescheduleErrorsCB->isChecked()))) | ||
4577 | { | 4580 | { | ||
4578 | // reset the state so that it will be restarted | 4581 | // reset the state so that it will be restarted | ||
4579 | currentJob->setState(SchedulerJob::JOB_SCHEDULED); | 4582 | currentJob->setState(SchedulerJob::JOB_SCHEDULED); | ||
4580 | 4583 | | |||
4581 | appendLogText(i18n("Waiting %1 seconds to restart job '%2'.", errorHandlingDelaySB->value(), currentJob->getName())); | 4584 | appendLogText(i18n("Waiting %1 seconds to restart job '%2'.", errorHandlingDelaySB->value(), currentJob->getName())); | ||
4582 | 4585 | | |||
4583 | // wait the given delay until the jobs will be evaluated again | 4586 | // wait the given delay until the jobs will be evaluated again | ||
4584 | sleepTimer.setInterval(( errorHandlingDelaySB->value() * 1000)); | 4587 | sleepTimer.setInterval(std::lround((errorHandlingDelaySB->value() * 1000) / KStarsData::Instance()->clock()->scale())); | ||
4585 | sleepTimer.start(); | 4588 | sleepTimer.start(); | ||
4586 | sleepLabel->setToolTip(i18n("Scheduler waits for a retry.")); | 4589 | sleepLabel->setToolTip(i18n("Scheduler waits for a retry.")); | ||
4587 | sleepLabel->show(); | 4590 | sleepLabel->show(); | ||
4588 | return; | 4591 | return; | ||
4589 | } | 4592 | } | ||
4590 | 4593 | | |||
4591 | // otherwise start re-evaluation | 4594 | // otherwise start re-evaluation | ||
4592 | setCurrentJob(nullptr); | 4595 | setCurrentJob(nullptr); | ||
▲ Show 20 Lines • Show All 2105 Lines • ▼ Show 20 Line(s) | |||||
6698 | 6701 | | |||
6699 | void Scheduler::setEkosCommunicationStatus(Ekos::CommunicationStatus status) | 6702 | void Scheduler::setEkosCommunicationStatus(Ekos::CommunicationStatus status) | ||
6700 | { | 6703 | { | ||
6701 | qCDebug(KSTARS_EKOS_SCHEDULER) << "Scheduler Ekos status is" << status; | 6704 | qCDebug(KSTARS_EKOS_SCHEDULER) << "Scheduler Ekos status is" << status; | ||
6702 | 6705 | | |||
6703 | m_EkosCommunicationStatus = status; | 6706 | m_EkosCommunicationStatus = status; | ||
6704 | } | 6707 | } | ||
6705 | 6708 | | |||
6709 | void Scheduler::simClockScaleChanged(float newScale) | ||||
6710 | { | ||||
6711 | if (sleepTimer.isActive()) | ||||
6712 | { | ||||
6713 | QTime const remainingTimeMs = QTime::fromMSecsSinceStartOfDay(std::lround((double) sleepTimer.remainingTime() | ||||
6714 | * KStarsData::Instance()->clock()->scale() | ||||
6715 | / newScale)); | ||||
6716 | appendLogText(i18n("Sleeping for %2 on simulation clock update until observation job %1 is ready...", currentJob->getName(), | ||||
6717 | remainingTimeMs.toString("hh:mm:ss"))); | ||||
6718 | sleepTimer.stop(); | ||||
6719 | sleepTimer.start(remainingTimeMs.msecsSinceStartOfDay()); | ||||
6720 | } | ||||
6721 | } | ||||
6722 | | ||||
6706 | void Scheduler::registerNewModule(const QString &name) | 6723 | void Scheduler::registerNewModule(const QString &name) | ||
6707 | { | 6724 | { | ||
6708 | qCDebug(KSTARS_EKOS_SCHEDULER) << "Registering new Module (" << name << ")"; | 6725 | qCDebug(KSTARS_EKOS_SCHEDULER) << "Registering new Module (" << name << ")"; | ||
6709 | 6726 | | |||
6710 | if (name == "Focus") | 6727 | if (name == "Focus") | ||
6711 | { | 6728 | { | ||
6712 | delete focusInterface; | 6729 | delete focusInterface; | ||
6713 | focusInterface = new QDBusInterface("org.kde.kstars", "/KStars/Ekos/Focus", "org.kde.kstars.Ekos.Focus", | 6730 | focusInterface = new QDBusInterface("org.kde.kstars", "/KStars/Ekos/Focus", "org.kde.kstars.Ekos.Focus", | ||
▲ Show 20 Lines • Show All 553 Lines • ▼ Show 20 Line(s) | 7277 | { | |||
7267 | weatherLabel->hide(); | 7284 | weatherLabel->hide(); | ||
7268 | checkShutdownState(); | 7285 | checkShutdownState(); | ||
7269 | 7286 | | |||
7270 | //schedulerTimer.stop(); | 7287 | //schedulerTimer.stop(); | ||
7271 | 7288 | | |||
7272 | // Wake up when job is due. | 7289 | // Wake up when job is due. | ||
7273 | // FIXME: Implement waking up periodically before job is due for weather check. | 7290 | // FIXME: Implement waking up periodically before job is due for weather check. | ||
7274 | // int const nextWakeup = nextObservationTime < 60 ? nextObservationTime : 60; | 7291 | // int const nextWakeup = nextObservationTime < 60 ? nextObservationTime : 60; | ||
7275 | sleepTimer.setInterval( (nextObservationTime + 1) * 1000); | 7292 | sleepTimer.setInterval(std::lround(((nextObservationTime + 1) * 1000) / KStarsData::Instance()->clock()->scale())); | ||
7276 | sleepTimer.start(); | 7293 | sleepTimer.start(); | ||
7277 | 7294 | | |||
7278 | return true; | 7295 | return true; | ||
7279 | } | 7296 | } | ||
7280 | // Otherwise, sleep until job is ready | 7297 | // Otherwise, sleep until job is ready | ||
7281 | /* FIXME: if not parking, stop tracking maybe? this would prevent crashes or scheduler stops from leaving the mount to track and bump the pier */ | 7298 | /* FIXME: if not parking, stop tracking maybe? this would prevent crashes or scheduler stops from leaving the mount to track and bump the pier */ | ||
7282 | // If start up procedure is already complete, and we didn't issue any parking commands before and parking is checked and enabled | 7299 | // If start up procedure is already complete, and we didn't issue any parking commands before and parking is checked and enabled | ||
7283 | // Then we park the mount until next job is ready. But only if the job uses TRACK as its first step, otherwise we cannot get into position again. | 7300 | // Then we park the mount until next job is ready. But only if the job uses TRACK as its first step, otherwise we cannot get into position again. | ||
Show All 33 Lines | 7320 | { | |||
7317 | 7334 | | |||
7318 | /* FIXME: stop tracking now */ | 7335 | /* FIXME: stop tracking now */ | ||
7319 | 7336 | | |||
7320 | schedulerTimer.stop(); | 7337 | schedulerTimer.stop(); | ||
7321 | 7338 | | |||
7322 | // Wake up when job is due. | 7339 | // Wake up when job is due. | ||
7323 | // FIXME: Implement waking up periodically before job is due for weather check. | 7340 | // FIXME: Implement waking up periodically before job is due for weather check. | ||
7324 | // int const nextWakeup = nextObservationTime < 60 ? nextObservationTime : 60; | 7341 | // int const nextWakeup = nextObservationTime < 60 ? nextObservationTime : 60; | ||
7325 | sleepTimer.setInterval(( (nextObservationTime + 1) * 1000)); | 7342 | sleepTimer.setInterval(std::lround(((nextObservationTime + 1) * 1000) / KStarsData::Instance()->clock()->scale())); | ||
7326 | sleepTimer.start(); | 7343 | sleepTimer.start(); | ||
7327 | 7344 | | |||
7328 | return true; | 7345 | return true; | ||
7329 | } | 7346 | } | ||
7330 | 7347 | | |||
7331 | return false; | 7348 | return false; | ||
7332 | } | 7349 | } | ||
7333 | 7350 | | |||
7334 | } | 7351 | } |