Changeset View
Changeset View
Standalone View
Standalone View
kstars/ekos/scheduler/schedulerjob.cpp
Show First 20 Lines • Show All 41 Lines • ▼ Show 20 Line(s) | 40 | { | |||
---|---|---|---|---|---|
42 | 42 | | |||
43 | /* Keep startup time and condition valid */ | 43 | /* Keep startup time and condition valid */ | ||
44 | if (value.isValid()) | 44 | if (value.isValid()) | ||
45 | startupCondition = START_AT; | 45 | startupCondition = START_AT; | ||
46 | else | 46 | else | ||
47 | startupCondition = fileStartupCondition; | 47 | startupCondition = fileStartupCondition; | ||
48 | 48 | | |||
49 | // Refresh altitude - invalid date/time is taken care of when rendering | 49 | // Refresh altitude - invalid date/time is taken care of when rendering | ||
50 | altitudeAtStartup = Ekos::Scheduler::findAltitude(targetCoords, startupTime, &isSettingAtStartup); | 50 | altitudeAtStartup = Ekos::ScheduleStrategy::findAltitude(targetCoords, startupTime, &isSettingAtStartup); | ||
51 | 51 | | |||
52 | /* Refresh estimated time - which update job cells */ | 52 | /* Refresh estimated time - which update job cells */ | ||
53 | setEstimatedTime(estimatedTime); | 53 | setEstimatedTime(estimatedTime); | ||
54 | } | 54 | } | ||
55 | 55 | | |||
56 | void SchedulerJob::setSequenceFile(const QUrl &value) | 56 | void SchedulerJob::setSequenceFile(const QUrl &value) | ||
57 | { | 57 | { | ||
58 | sequenceFile = value; | 58 | sequenceFile = value; | ||
Show All 21 Lines | |||||
80 | 80 | | |||
81 | void SchedulerJob::setCompletionTime(const QDateTime &value) | 81 | void SchedulerJob::setCompletionTime(const QDateTime &value) | ||
82 | { | 82 | { | ||
83 | /* If completion time is valid, automatically switch condition to FINISH_AT */ | 83 | /* If completion time is valid, automatically switch condition to FINISH_AT */ | ||
84 | if (value.isValid()) | 84 | if (value.isValid()) | ||
85 | { | 85 | { | ||
86 | setCompletionCondition(FINISH_AT); | 86 | setCompletionCondition(FINISH_AT); | ||
87 | completionTime = value; | 87 | completionTime = value; | ||
88 | altitudeAtCompletion = Ekos::Scheduler::findAltitude(targetCoords, completionTime, &isSettingAtCompletion); | 88 | altitudeAtCompletion = Ekos::ScheduleStrategy::findAltitude(targetCoords, completionTime, &isSettingAtCompletion); | ||
89 | setEstimatedTime(-1); | 89 | setEstimatedTime(-1); | ||
90 | } | 90 | } | ||
91 | /* If completion time is invalid, and job is looping, keep completion time undefined */ | 91 | /* If completion time is invalid, and job is looping, keep completion time undefined */ | ||
92 | else if (FINISH_LOOP == completionCondition) | 92 | else if (FINISH_LOOP == completionCondition) | ||
93 | { | 93 | { | ||
94 | completionTime = QDateTime(); | 94 | completionTime = QDateTime(); | ||
95 | altitudeAtCompletion = Ekos::Scheduler::findAltitude(targetCoords, completionTime, &isSettingAtCompletion); | 95 | altitudeAtCompletion = Ekos::ScheduleStrategy::findAltitude(targetCoords, completionTime, &isSettingAtCompletion); | ||
96 | setEstimatedTime(-1); | 96 | setEstimatedTime(-1); | ||
97 | } | 97 | } | ||
98 | /* If completion time is invalid, deduce completion from startup and duration */ | 98 | /* If completion time is invalid, deduce completion from startup and duration */ | ||
99 | else if (startupTime.isValid()) | 99 | else if (startupTime.isValid()) | ||
100 | { | 100 | { | ||
101 | completionTime = startupTime.addSecs(estimatedTime); | 101 | completionTime = startupTime.addSecs(estimatedTime); | ||
102 | altitudeAtCompletion = Ekos::Scheduler::findAltitude(targetCoords, completionTime, &isSettingAtCompletion); | 102 | altitudeAtCompletion = Ekos::ScheduleStrategy::findAltitude(targetCoords, completionTime, &isSettingAtCompletion); | ||
103 | updateJobCells(); | 103 | updateJobCells(); | ||
104 | } | 104 | } | ||
105 | /* Else just refresh estimated time - which update job cells */ | 105 | /* Else just refresh estimated time - which update job cells */ | ||
106 | else setEstimatedTime(estimatedTime); | 106 | else setEstimatedTime(estimatedTime); | ||
107 | 107 | | |||
108 | 108 | | |||
109 | /* Invariants */ | 109 | /* Invariants */ | ||
110 | Q_ASSERT_X(completionTime.isValid() ? | 110 | Q_ASSERT_X(completionTime.isValid() ? | ||
▲ Show 20 Lines • Show All 216 Lines • ▼ Show 20 Line(s) | 316 | { | |||
327 | { | 327 | { | ||
328 | estimatedTime = startupTime.secsTo(completionTime); | 328 | estimatedTime = startupTime.secsTo(completionTime); | ||
329 | } | 329 | } | ||
330 | /* If completion time isn't fixed, estimated time adjusts completion time */ | 330 | /* If completion time isn't fixed, estimated time adjusts completion time */ | ||
331 | else if (FINISH_AT != completionCondition && FINISH_LOOP != completionCondition) | 331 | else if (FINISH_AT != completionCondition && FINISH_LOOP != completionCondition) | ||
332 | { | 332 | { | ||
333 | estimatedTime = value; | 333 | estimatedTime = value; | ||
334 | completionTime = startupTime.addSecs(value); | 334 | completionTime = startupTime.addSecs(value); | ||
335 | altitudeAtCompletion = Ekos::Scheduler::findAltitude(targetCoords, completionTime, &isSettingAtCompletion); | 335 | altitudeAtCompletion = Ekos::ScheduleStrategy::findAltitude(targetCoords, completionTime, &isSettingAtCompletion); | ||
336 | } | 336 | } | ||
337 | /* Else estimated time is simply stored as is - covers FINISH_LOOP from setCompletionTime */ | 337 | /* Else estimated time is simply stored as is - covers FINISH_LOOP from setCompletionTime */ | ||
338 | else estimatedTime = value; | 338 | else estimatedTime = value; | ||
339 | 339 | | |||
340 | updateJobCells(); | 340 | updateJobCells(); | ||
341 | } | 341 | } | ||
342 | 342 | | |||
343 | void SchedulerJob::setInSequenceFocus(bool value) | 343 | void SchedulerJob::setInSequenceFocus(bool value) | ||
▲ Show 20 Lines • Show All 178 Lines • ▼ Show 20 Line(s) | 489 | { | |||
522 | if (nullptr != startupCell->tableWidget()) | 522 | if (nullptr != startupCell->tableWidget()) | ||
523 | startupCell->tableWidget()->resizeColumnToContents(startupCell->column()); | 523 | startupCell->tableWidget()->resizeColumnToContents(startupCell->column()); | ||
524 | } | 524 | } | ||
525 | 525 | | |||
526 | if (nullptr != altitudeCell) | 526 | if (nullptr != altitudeCell) | ||
527 | { | 527 | { | ||
528 | // FIXME: Cache altitude calculations | 528 | // FIXME: Cache altitude calculations | ||
529 | bool is_setting = false; | 529 | bool is_setting = false; | ||
530 | double const alt = Ekos::Scheduler::findAltitude(targetCoords, QDateTime(), &is_setting); | 530 | double const alt = Ekos::ScheduleStrategy::findAltitude(targetCoords, QDateTime(), &is_setting); | ||
531 | 531 | | |||
532 | altitudeCell->setText(QString("%1%L2°") | 532 | altitudeCell->setText(QString("%1%L2°") | ||
533 | .arg(QChar(is_setting ? 0x2193 : 0x2191)) | 533 | .arg(QChar(is_setting ? 0x2193 : 0x2191)) | ||
534 | .arg(alt, 0, 'f', 1)); | 534 | .arg(alt, 0, 'f', 1)); | ||
535 | 535 | | |||
536 | if (nullptr != altitudeCell->tableWidget()) | 536 | if (nullptr != altitudeCell->tableWidget()) | ||
537 | altitudeCell->tableWidget()->resizeColumnToContents(altitudeCell->column()); | 537 | altitudeCell->tableWidget()->resizeColumnToContents(altitudeCell->column()); | ||
538 | } | 538 | } | ||
▲ Show 20 Lines • Show All 138 Lines • ▼ Show 20 Line(s) | |||||
677 | { | 677 | { | ||
678 | return job1->getPriority() < job2->getPriority(); | 678 | return job1->getPriority() < job2->getPriority(); | ||
679 | } | 679 | } | ||
680 | 680 | | |||
681 | bool SchedulerJob::decreasingAltitudeOrder(SchedulerJob const *job1, SchedulerJob const *job2, QDateTime const &when) | 681 | bool SchedulerJob::decreasingAltitudeOrder(SchedulerJob const *job1, SchedulerJob const *job2, QDateTime const &when) | ||
682 | { | 682 | { | ||
683 | bool A_is_setting = job1->isSettingAtStartup; | 683 | bool A_is_setting = job1->isSettingAtStartup; | ||
684 | double const altA = when.isValid() ? | 684 | double const altA = when.isValid() ? | ||
685 | Ekos::Scheduler::findAltitude(job1->getTargetCoords(), when, &A_is_setting) : | 685 | Ekos::ScheduleStrategy::findAltitude(job1->getTargetCoords(), when, &A_is_setting) : | ||
686 | job1->altitudeAtStartup; | 686 | job1->altitudeAtStartup; | ||
687 | 687 | | |||
688 | bool B_is_setting = job2->isSettingAtStartup; | 688 | bool B_is_setting = job2->isSettingAtStartup; | ||
689 | double const altB = when.isValid() ? | 689 | double const altB = when.isValid() ? | ||
690 | Ekos::Scheduler::findAltitude(job2->getTargetCoords(), when, &B_is_setting) : | 690 | Ekos::ScheduleStrategy::findAltitude(job2->getTargetCoords(), when, &B_is_setting) : | ||
691 | job2->altitudeAtStartup; | 691 | job2->altitudeAtStartup; | ||
692 | 692 | | |||
693 | // Sort with the setting target first | 693 | // Sort with the setting target first | ||
694 | if (A_is_setting && !B_is_setting) | 694 | if (A_is_setting && !B_is_setting) | ||
695 | return true; | 695 | return true; | ||
696 | else if (!A_is_setting && B_is_setting) | 696 | else if (!A_is_setting && B_is_setting) | ||
697 | return false; | 697 | return false; | ||
698 | 698 | | |||
699 | // If both targets rise or set, sort by decreasing altitude, considering a setting target is prioritary | 699 | // If both targets rise or set, sort by decreasing altitude, considering a setting target is prioritary | ||
700 | return (A_is_setting && B_is_setting) ? altA < altB : altB < altA; | 700 | return (A_is_setting && B_is_setting) ? altA < altB : altB < altA; | ||
701 | } | 701 | } | ||
702 | 702 | | |||
703 | bool SchedulerJob::increasingStartupTimeOrder(SchedulerJob const *job1, SchedulerJob const *job2) | 703 | bool SchedulerJob::increasingStartupTimeOrder(SchedulerJob const *job1, SchedulerJob const *job2) | ||
704 | { | 704 | { | ||
705 | return job1->getStartupTime() < job2->getStartupTime(); | 705 | return job1->getStartupTime() < job2->getStartupTime(); | ||
706 | } | 706 | } |