Commit 46679d89 authored by Jasem Mutlaq's avatar Jasem Mutlaq
Browse files

Use a timer instead of single shot in order to control it. Disable preemptive...

Use a timer instead of single shot in order to control it. Disable preemptive shutdown in case the scheduler was manually stopped
parent cee89a5d
......@@ -571,7 +571,10 @@ void Scheduler::removeJob()
void Scheduler::toggleScheduler()
{
if (state == SCHEDULER_RUNNIG)
{
preemptiveShutdown = false;
stop();
}
else
start();
}
......@@ -624,6 +627,8 @@ void Scheduler::stop()
return;
}
sleepTimer.stop();
sleepTimer.disconnect();
sleepLabel->hide();
pi->stopAnimation();
startB->setText("Start Scheduler");
......@@ -995,8 +1000,10 @@ void Scheduler::evaluateJobs()
weatherLabel->hide();
checkShutdownState();
// Restart 10 minutes before next job
QTimer::singleShot( (nextObservationTime*1000 - (1000*Options::leadTime()*60*2)), this, SLOT(wakeUpScheduler()));
// Wake up 10 minutes before next job is ready
sleepTimer.setInterval((nextObservationTime*1000 - (1000*Options::leadTime()*60*2)));
connect(&sleepTimer, SIGNAL(timeout()), this, SLOT(wakeUpScheduler()));
sleepTimer.start();
}
// Otherise, check if the next observation time exceeds the job lead time (default 5 minutes)
else if (nextObservationTime > (Options::leadTime()*60))
......@@ -1020,7 +1027,10 @@ void Scheduler::evaluateJobs()
//weatherCheck->setEnabled(false);
//weatherLabel->hide();
QTimer::singleShot( (nextObservationTime*1000 - (1000*Options::leadTime()*60)), this, SLOT(wakeUpScheduler()));
// Wake up 5 minutes (default) before next job is ready
sleepTimer.setInterval((nextObservationTime*1000 - (1000*Options::leadTime()*60)));
connect(&sleepTimer, SIGNAL(timeout()), this, SLOT(wakeUpScheduler()));
sleepTimer.start();
}
}
}
......@@ -1612,6 +1622,12 @@ bool Scheduler::checkShutdownState()
weatherTimer.stop();
weatherTimer.disconnect();
if (preemptiveShutdown == false)
{
sleepTimer.stop();
sleepTimer.disconnect();
}
if (warmCCDCheck->isEnabled() && warmCCDCheck->isChecked())
{
appendLogText(i18n("Warming up CCD..."));
......
......@@ -396,6 +396,7 @@ private:
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.
QTimer sleepTimer; // Timer to put the scheduler into sleep mode until a job is ready
uint8_t noWeatherCounter; // Keep track of how many times we didn't recieve weather updates
bool preemptiveShutdown; // Are we shutting down until later?
bool jobEvaluationOnly; // Only run job evaluation
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment