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 All 22 Lines | |||||
23 | #include "skymapcomposite.h" | 23 | #include "skymapcomposite.h" | ||
24 | #include "auxiliary/QProgressIndicator.h" | 24 | #include "auxiliary/QProgressIndicator.h" | ||
25 | #include "dialogs/finddialog.h" | 25 | #include "dialogs/finddialog.h" | ||
26 | #include "ekos/manager.h" | 26 | #include "ekos/manager.h" | ||
27 | #include "ekos/capture/sequencejob.h" | 27 | #include "ekos/capture/sequencejob.h" | ||
28 | #include "skyobjects/starobject.h" | 28 | #include "skyobjects/starobject.h" | ||
29 | 29 | | |||
30 | #include <KNotifications/KNotification> | 30 | #include <KNotifications/KNotification> | ||
31 | #include <KConfigDialog> | ||||
31 | 32 | | |||
32 | #include <fitsio.h> | 33 | #include <fitsio.h> | ||
33 | #include <ekos_scheduler_debug.h> | 34 | #include <ekos_scheduler_debug.h> | ||
34 | 35 | | |||
35 | #define BAD_SCORE -1000 | 36 | #define BAD_SCORE -1000 | ||
36 | #define MAX_FAILURE_ATTEMPTS 5 | 37 | #define MAX_FAILURE_ATTEMPTS 5 | ||
37 | #define UPDATE_PERIOD_MS 1000 | 38 | #define UPDATE_PERIOD_MS 1000 | ||
38 | #define RESTART_GUIDING_DELAY_MS 5000 | 39 | #define RESTART_GUIDING_DELAY_MS 5000 | ||
▲ Show 20 Lines • Show All 174 Lines • ▼ Show 20 Line(s) | 213 | { | |||
213 | Q_UNUSED(button); | 214 | Q_UNUSED(button); | ||
214 | Options::setErrorHandlingStrategy(getErrorHandlingStrategy()); | 215 | Options::setErrorHandlingStrategy(getErrorHandlingStrategy()); | ||
215 | }); | 216 | }); | ||
216 | connect(errorHandlingDelaySB, static_cast<void (QSpinBox::*)(int)>(&QSpinBox::valueChanged), [this](int value) | 217 | connect(errorHandlingDelaySB, static_cast<void (QSpinBox::*)(int)>(&QSpinBox::valueChanged), [this](int value) | ||
217 | { | 218 | { | ||
218 | Options::setErrorHandlingStrategyDelay(value); | 219 | Options::setErrorHandlingStrategyDelay(value); | ||
219 | }); | 220 | }); | ||
220 | 221 | | |||
222 | connect(KConfigDialog::exists("settings"), &KConfigDialog::settingsChanged, this, &Scheduler::applyConfig); | ||||
223 | | ||||
224 | calculateDawnDusk(); | ||||
221 | 225 | | |||
222 | loadProfiles(); | 226 | loadProfiles(); | ||
223 | 227 | | |||
224 | watchJobChanges(true); | 228 | watchJobChanges(true); | ||
225 | } | 229 | } | ||
226 | 230 | | |||
227 | QString Scheduler::getCurrentJobName() | 231 | QString Scheduler::getCurrentJobName() | ||
228 | { | 232 | { | ||
▲ Show 20 Lines • Show All 148 Lines • ▼ Show 20 Line(s) | |||||
377 | } | 381 | } | ||
378 | 382 | | |||
379 | void Scheduler::clearLog() | 383 | void Scheduler::clearLog() | ||
380 | { | 384 | { | ||
381 | m_LogText.clear(); | 385 | m_LogText.clear(); | ||
382 | emit newLog(QString()); | 386 | emit newLog(QString()); | ||
383 | } | 387 | } | ||
384 | 388 | | |||
389 | void Scheduler::applyConfig() | ||||
390 | { | ||||
391 | calculateDawnDusk(); | ||||
392 | | ||||
393 | if (SCHEDULER_RUNNING != state) | ||||
394 | { | ||||
395 | jobEvaluationOnly = true; | ||||
396 | evaluateJobs(); | ||||
397 | } | ||||
398 | } | ||||
399 | | ||||
385 | void Scheduler::selectObject() | 400 | void Scheduler::selectObject() | ||
386 | { | 401 | { | ||
387 | if (FindDialog::Instance()->exec() == QDialog::Accepted) | 402 | if (FindDialog::Instance()->exec() == QDialog::Accepted) | ||
388 | { | 403 | { | ||
389 | SkyObject *object = FindDialog::Instance()->targetObject(); | 404 | SkyObject *object = FindDialog::Instance()->targetObject(); | ||
390 | addObject(object); | 405 | addObject(object); | ||
391 | } | 406 | } | ||
392 | } | 407 | } | ||
▲ Show 20 Lines • Show All 1981 Lines • ▼ Show 20 Line(s) | 2386 | qCInfo(KSTARS_EKOS_SCHEDULER) << QString("Job '%1' has a total score of %2 at %3.") | |||
2374 | .arg(when.toString(job->getDateTimeDisplayFormat())); | 2389 | .arg(when.toString(job->getDateTimeDisplayFormat())); | ||
2375 | 2390 | | |||
2376 | return total; | 2391 | return total; | ||
2377 | } | 2392 | } | ||
2378 | 2393 | | |||
2379 | void Scheduler::calculateDawnDusk() | 2394 | void Scheduler::calculateDawnDusk() | ||
2380 | { | 2395 | { | ||
2381 | KSAlmanac ksal; | 2396 | KSAlmanac ksal; | ||
2382 | Dawn = ksal.getDawnAstronomicalTwilight(); | 2397 | Dawn = ksal.getDawnAstronomicalTwilight() + Options::dawnOffset() / 24.0; | ||
2383 | Dusk = ksal.getDuskAstronomicalTwilight(); | 2398 | Dusk = ksal.getDuskAstronomicalTwilight() + Options::duskOffset() / 24.0; | ||
2384 | 2399 | | |||
2385 | //QTime now = KStarsData::Instance()->lt().time(); | 2400 | QTime const dawn = QTime(0, 0, 0).addSecs(Dawn * 24 * 3600); | ||
2386 | //QTime dawn = QTime(0, 0, 0).addSecs(Dawn * 24 * 3600); | 2401 | QTime const dusk = QTime(0, 0, 0).addSecs(Dusk * 24 * 3600); | ||
2387 | QTime dusk = QTime(0, 0, 0).addSecs(Dusk * 24 * 3600); | | |||
2388 | 2402 | | |||
2389 | duskDateTime.setDate(KStars::Instance()->data()->lt().date()); | 2403 | duskDateTime.setDate(KStars::Instance()->data()->lt().date()); | ||
2390 | duskDateTime.setTime(dusk); | 2404 | duskDateTime.setTime(dusk); | ||
2391 | 2405 | | |||
2392 | // FIXME: reduce spam by moving twilight time to a text label | 2406 | nightTime->setText(i18n("%1 - %2", dusk.toString("hh:mm"), dawn.toString("hh:mm"))); | ||
2393 | //appendLogText(i18n("Astronomical twilight: dusk at %1, dawn at %2, and current time is %3", | | |||
2394 | // dusk.toString(), dawn.toString(), now.toString())); | | |||
2395 | } | 2407 | } | ||
2396 | 2408 | | |||
2397 | void Scheduler::executeJob(SchedulerJob *job) | 2409 | void Scheduler::executeJob(SchedulerJob *job) | ||
2398 | { | 2410 | { | ||
2399 | // Some states have executeJob called after current job is cancelled - checkStatus does this | 2411 | // Some states have executeJob called after current job is cancelled - checkStatus does this | ||
2400 | if (job == nullptr) | 2412 | if (job == nullptr) | ||
2401 | return; | 2413 | return; | ||
2402 | 2414 | | |||
▲ Show 20 Lines • Show All 3654 Lines • ▼ Show 20 Line(s) | 6068 | else if (errorHandlingRestartImmediatelyButton->isChecked()) | |||
6057 | return ERROR_RESTART_IMMEDIATELY; | 6069 | return ERROR_RESTART_IMMEDIATELY; | ||
6058 | else | 6070 | else | ||
6059 | return ERROR_DONT_RESTART; | 6071 | return ERROR_DONT_RESTART; | ||
6060 | 6072 | | |||
6061 | } | 6073 | } | ||
6062 | 6074 | | |||
6063 | void Scheduler::setErrorHandlingStrategy(Scheduler::ErrorHandlingStrategy strategy) | 6075 | void Scheduler::setErrorHandlingStrategy(Scheduler::ErrorHandlingStrategy strategy) | ||
6064 | { | 6076 | { | ||
6065 | errorHandlingWaitLabel->setEnabled(strategy != ERROR_DONT_RESTART); | | |||
6066 | errorHandlingDelaySB->setEnabled(strategy != ERROR_DONT_RESTART); | 6077 | errorHandlingDelaySB->setEnabled(strategy != ERROR_DONT_RESTART); | ||
6067 | 6078 | | |||
6068 | switch (strategy) | 6079 | switch (strategy) | ||
6069 | { | 6080 | { | ||
6070 | case ERROR_RESTART_AFTER_TERMINATION: | 6081 | case ERROR_RESTART_AFTER_TERMINATION: | ||
6071 | errorHandlingRestartAfterAllButton->setChecked(true); | 6082 | errorHandlingRestartAfterAllButton->setChecked(true); | ||
6072 | break; | 6083 | break; | ||
6073 | case ERROR_RESTART_IMMEDIATELY: | 6084 | case ERROR_RESTART_IMMEDIATELY: | ||
▲ Show 20 Lines • Show All 1250 Lines • Show Last 20 Lines |