summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJasem Mutlaq <[email protected]>2015-09-15 12:00:12 +0300
committerJasem Mutlaq <[email protected]>2015-09-15 12:00:12 +0300
commit31b4be6fd08fa156a94324214c00fabaec58b591 (patch)
tree06a3b63c75401c846abb88e4cad4837a82a38b5e
parent69873ca8313b77d3ac2e90dff8d0d2201054af9c (diff)
+ On INDI connection success, we must always run INDI property check.
+ Calculate predawn limit before a job is run to check it against current local time + Set scheduler job score to BAD_SCORE if its startup condition changes to START_AT so that it gets checked against the timer the next time it is polled.
-rw-r--r--kstars/ekos/scheduler.cpp56
-rw-r--r--kstars/ekos/scheduler.h13
2 files changed, 57 insertions, 12 deletions
diff --git a/kstars/ekos/scheduler.cpp b/kstars/ekos/scheduler.cpp
index 76885ef..c2e1b3f 100644
--- a/kstars/ekos/scheduler.cpp
+++ b/kstars/ekos/scheduler.cpp
@@ -686,7 +686,7 @@ void Scheduler::start()
job->setState(SchedulerJob::JOB_IDLE);
job->setStage(SchedulerJob::STAGE_IDLE);
}
- }
+ }
addToQueueB->setEnabled(false);
removeFromQueueB->setEnabled(false);
@@ -738,6 +738,8 @@ void Scheduler::evaluateJobs()
{
//appendLogText(i18n("%1 observation job is scheduled at %2", job->getName(), job->getStartupTime().toString()));
job->setState(SchedulerJob::JOB_SCHEDULED);
+ // Since it's scheduled, we need to skip it now and re-check it later since its startup condition changed to START_AT
+ job->setScore(BAD_SCORE);
continue;
}
else
@@ -766,6 +768,8 @@ void Scheduler::evaluateJobs()
{
appendLogText(i18n("%1 observation job is scheduled at %2", job->getName(), job->getStartupTime().toString()));
job->setState(SchedulerJob::JOB_SCHEDULED);
+ // Since it's scheduled, we need to skip it now and re-check it later since its startup condition changed to START_AT
+ job->setScore(BAD_SCORE);
continue;
}
else
@@ -1336,6 +1340,26 @@ int16_t Scheduler::getAltitudeScore(SchedulerJob *job, QDateTime when)
return score;
}
+double Scheduler::getCurrentMoonSeparation(SchedulerJob *job)
+{
+ // Get target altitude given the time
+ SkyPoint p = job->getTargetCoords();
+ QDateTime midnight( KStarsData::Instance()->lt().date(), QTime() );
+ KStarsDateTime ut = geo->LTtoUT( midnight );
+ KStarsDateTime myUT = ut.addSecs(KStarsData::Instance()->lt().time().msecsSinceStartOfDay()/1000);
+ dms LST = geo->GSTtoLST( myUT.gst() );
+ p.EquatorialToHorizontal( &LST, geo->lat() );
+
+ // Update moon
+ ut = geo->LTtoUT(KStarsData::Instance()->lt());
+ KSNumbers ksnum(ut.djd());
+ LST = geo->GSTtoLST( ut.gst() );
+ moon->updateCoords(&ksnum, true, geo->lat(), &LST);
+
+ // Moon/Sky separation p
+ return moon->angularDistanceTo(&p).Degrees();
+}
+
int16_t Scheduler::getMoonSeparationScore(SchedulerJob *job, QDateTime when)
{
int16_t score=0;
@@ -1413,6 +1437,7 @@ void Scheduler::calculateDawnDusk()
QTime dusk = QTime(0,0,0).addSecs(Dusk*24*3600);
appendLogText(i18n("Dawn is at %1, Dusk is at %2, and current time is %3", dawn.toString(), dusk.toString(), now.toString()));
+
}
void Scheduler::executeJob(SchedulerJob *job)
@@ -1421,6 +1446,8 @@ void Scheduler::executeJob(SchedulerJob *job)
currentJob->setState(SchedulerJob::JOB_BUSY);
+ updatePreDawn();
+
// No need to continue evaluating jobs as we already have one.
disconnect(KStars::Instance()->data()->clock(), SIGNAL(timeAdvanced()), this, SLOT(checkStatus()));
@@ -1489,8 +1516,8 @@ bool Scheduler::checkINDIState()
QDBusReply<int> isINDIConnected = ekosInterface->call(QDBus::AutoDetect,"getINDIConnectionStatus");
if (isINDIConnected.value()== EkosManager::STATUS_SUCCESS)
{
- indiState = INDI_READY;
- return true;
+ indiState = INDI_PROPERTY_CHECK;
+ return false;
}
else
{
@@ -1920,11 +1947,11 @@ void Scheduler::checkJobStage()
SkyPoint p = currentJob->getTargetCoords();
p.EquatorialToHorizontal(KStarsData::Instance()->lst(), geo->lat());
- double moonScore = getMoonSeparationScore(currentJob, KStarsData::Instance()->lt());
+ double moonSeparation = getCurrentMoonSeparation(currentJob);
- if (moonScore < 0)
+ if (moonSeparation < currentJob->getMinMoonSeparation())
{
- appendLogText(i18n("Current moon separation is lower than %1 minimum constraint (%2 degrees), aborting job...", currentJob->getName(),
+ appendLogText(i18n("Current moon separation (%1 degrees) is lower than %2 minimum constraint (%3 degrees), aborting job...", moonSeparation, currentJob->getName(),
currentJob->getMinMoonSeparation()));
currentJob->setState(SchedulerJob::JOB_ABORTED);
@@ -1934,12 +1961,7 @@ void Scheduler::checkJobStage()
}
}
- // #4 Check if we're not at dawn
- double earlyDawn = Dawn - Options::preDawnTime()/(60.0 * 24.0);
- int dayOffset=0;
- if (KStarsData::Instance()->lt().time().hour() > 12)
- dayOffset=1;
- QDateTime preDawnDateTime(KStarsData::Instance()->lt().date().addDays(dayOffset), QTime::fromMSecsSinceStartOfDay(earlyDawn * 24 * 3600 * 1000));
+ // #4 Check if we're not at dawn
if (KStarsData::Instance()->lt() > preDawnDateTime)
{
@@ -3049,6 +3071,16 @@ void Scheduler::clearScriptURL()
}
}
+void Scheduler::updatePreDawn()
+{
+ double earlyDawn = Dawn - Options::preDawnTime()/(60.0 * 24.0);
+ int dayOffset=0;
+ if (KStarsData::Instance()->lt().time().hour() > 12)
+ dayOffset=1;
+ preDawnDateTime.setDate(KStarsData::Instance()->lt().date().addDays(dayOffset));
+ preDawnDateTime.setTime(QTime::fromMSecsSinceStartOfDay(earlyDawn * 24 * 3600 * 1000));
+}
+
}
diff --git a/kstars/ekos/scheduler.h b/kstars/ekos/scheduler.h
index 2f1dd4c..410c96e 100644
--- a/kstars/ekos/scheduler.h
+++ b/kstars/ekos/scheduler.h
@@ -346,6 +346,18 @@ private:
double findAltitude(const SkyPoint & target, const QDateTime when);
/**
+ * @brief getCurrentMoonSeparation Get current moon separation in degrees at current time for the given job
+ * @param job scheduler job
+ * @return Separation in degrees
+ */
+ double getCurrentMoonSeparation(SchedulerJob *job);
+
+ /**
+ * @brief updatePreDawn Update predawn time depending on current time and user offset
+ */
+ void updatePreDawn();
+
+ /**
* @brief estimateJobTime Estimates the time the job takes to complete based on the sequence file and what modules to utilize during the observation run.
* @param job target job
* @return Estimated time in seconds.
@@ -395,6 +407,7 @@ private:
QProcess scriptProcess; // Startup and Shutdown scripts process
double Dawn, Dusk; // Store day fraction of dawn and dusk to calculate dark skies range
+ QDateTime preDawnDateTime; // Pre-dawn is where we stop all jobs, it is a user-configurable value before Dawn.
bool mDirty; // Was job modified and needs saving?
IPState weatherStatus; // Keep watch of weather status
QTimer weatherTimer; // Call checkWeather when weatherTimer time expires. It is equal to the UpdatePeriod time in INDI::Weather device.