Commit 5c42a17f authored by Jasem Mutlaq's avatar Jasem Mutlaq
Browse files

Store startup and shutdown procedures in the scheduler list file

parent ae1a3f58
......@@ -107,9 +107,6 @@ Scheduler::Scheduler()
selectShutdownScriptB->setIcon(QIcon::fromTheme("document-open"));
selectFITSB->setIcon(QIcon::fromTheme("document-open"));
clearStartupB->setIcon(QIcon::fromTheme("edit-clear"));
clearShutdownB->setIcon(QIcon::fromTheme("edit-clear"));
connect(selectObjectB,SIGNAL(clicked()),this,SLOT(selectObject()));
connect(selectFITSB,SIGNAL(clicked()),this,SLOT(selectFITS()));
connect(loadSequenceB,SIGNAL(clicked()),this,SLOT(selectSequence()));
......@@ -127,23 +124,8 @@ Scheduler::Scheduler()
connect(queueSaveB,SIGNAL(clicked()),this,SLOT(save()));
connect(queueLoadB,SIGNAL(clicked()),this,SLOT(load()));
connect(clearStartupB, SIGNAL(clicked()), this, SLOT(clearScriptURL()));
connect(clearShutdownB, SIGNAL(clicked()), this, SLOT(clearScriptURL()));
// Load scheduler settings
startupScript->setText(Options::startupScript());
startupScriptURL = QUrl(Options::startupScript());
shutdownScript->setText(Options::shutdownScript());
shutdownScriptURL = QUrl(Options::shutdownScript());
weatherCheck->setChecked(Options::enforceWeather());
warmCCDCheck->setChecked(Options::warmUpCCD());
parkMountCheck->setChecked(Options::parkMount());
parkDomeCheck->setChecked(Options::parkDome());
unparkMountCheck->setChecked(Options::unParkMount());
unparkDomeCheck->setChecked(Options::unParkDome());
connect(startupScript, SIGNAL(editingFinished()), this, SLOT(setDirty()));
connect(shutdownScript, SIGNAL(editingFinished()), this, SLOT(setDirty()));
}
Scheduler::~Scheduler()
......@@ -229,6 +211,7 @@ void Scheduler::selectStartupScript()
if (startupScriptURL.isEmpty())
return;
mDirty=true;
startupScript->setText(startupScriptURL.path());
}
......@@ -238,12 +221,10 @@ void Scheduler::selectShutdownScript()
if (shutdownScriptURL.isEmpty())
return;
mDirty=true;
shutdownScript->setText(shutdownScriptURL.path());
}
void Scheduler::addJob()
{
......@@ -656,15 +637,22 @@ void Scheduler::start()
if(state == SCHEDULER_RUNNIG)
return;
startupScriptURL = QUrl::fromUserInput(startupScript->text());
if (shutdownScript->text().isEmpty() == false && startupScriptURL.isValid() == false)
{
appendLogText(i18n("Startup script URL %1 is not valid.", startupScript->text()));
return;
}
shutdownScriptURL= QUrl::fromUserInput(shutdownScript->text());
if (shutdownScript->text().isEmpty() == false && shutdownScriptURL.isValid() == false)
{
appendLogText(i18n("Shutdown script URL %1 is not valid.", shutdownScript->text()));
return;
}
// Save settings
Options::setEnforceWeather(weatherCheck->isChecked());
Options::setStartupScript(startupScript->text());
Options::setShutdownScript(shutdownScript->text());
Options::setWarmUpCCD(warmCCDCheck->isChecked());
Options::setParkMount(parkMountCheck->isChecked());
Options::setParkDome(parkDomeCheck->isChecked());
Options::setUnParkMount(unparkMountCheck->isChecked());
Options::setUnParkDome(unparkDomeCheck->isChecked());
pi->startAnimation();
......@@ -2324,7 +2312,50 @@ bool Scheduler::loadScheduler(const QUrl & fileURL)
{
for (ep = nextXMLEle(root, 1) ; ep != NULL ; ep = nextXMLEle(root, 0))
{
processJobInfo(ep);
const char *tag = tagXMLEle(ep);
if (!strcmp(tag, "Job"))
processJobInfo(ep);
else if (!strcmp(tag, "StartupProcedure"))
{
XMLEle *procedure;
startupScript->clear();
unparkDomeCheck->setChecked(false);
unparkMountCheck->setChecked(false);
for (procedure = nextXMLEle(ep, 1) ; procedure != NULL ; procedure = nextXMLEle(ep, 0))
{
const char *proc = pcdataXMLEle(procedure);
if (!strcmp(proc, "StartupScript"))
startupScript->setText(findXMLAttValu(procedure, "value"));
else if (!strcmp(proc, "UnparkDome"))
unparkDomeCheck->setChecked(true);
else if (!strcmp(proc, "UnparkMount"))
unparkMountCheck->setChecked(true);
}
}
else if (!strcmp(tag, "ShutdownProcedure"))
{
XMLEle *procedure;
shutdownScript->clear();
warmCCDCheck->setChecked(false);
parkDomeCheck->setChecked(false);
parkMountCheck->setChecked(false);
for (procedure = nextXMLEle(ep, 1) ; procedure != NULL ; procedure = nextXMLEle(ep, 0))
{
const char *proc = pcdataXMLEle(procedure);
if (!strcmp(proc, "ShutdownScript"))
shutdownScript->setText(findXMLAttValu(procedure, "value"));
else if (!strcmp(proc, "ParkDome"))
parkDomeCheck->setChecked(true);
else if (!strcmp(proc, "ParkMount"))
parkMountCheck->setChecked(true);
else if (!strcmp(proc, "WarmCCD"))
warmCCDCheck->setChecked(true);
}
}
}
delXMLEle(root);
}
......@@ -2557,6 +2588,26 @@ bool Scheduler::saveScheduler(const QUrl &fileURL)
outstream << "</Job>" << endl;
}
outstream << "<StartupProcedure>" << endl;
if (startupScript->text().isEmpty() == false)
outstream << "<Procedure value='" << startupScript->text() << "'>StartupScript</Procedure>" << endl;
if (unparkDomeCheck->isChecked())
outstream << "<Procedure>UnparkDome</Procedure>" << endl;
if (unparkMountCheck->isChecked())
outstream << "<Procedure>UnparkMount</Procedure>" << endl;
outstream << "</StartupProcedure>" << endl;
outstream << "<ShutdownProcedure>" << endl;
if (warmCCDCheck->isChecked())
outstream << "<Procedure>WarmCCD</Procedure>" << endl;
if (parkMountCheck->isChecked())
outstream << "<Procedure>ParkMount</Procedure>" << endl;
if (parkDomeCheck->isChecked())
outstream << "<Procedure>ParkDome</Procedure>" << endl;
if (shutdownScript->text().isEmpty() == false)
outstream << "<Procedure value='" << shutdownScript->text() << "'>ShutdownScript</Procedure>" << endl;
outstream << "</ShutdownProcedure>" << endl;
outstream << "</SchedulerList>" << endl;
appendLogText(i18n("Scheduler list saved to %1", fileURL.path()));
......@@ -3114,27 +3165,6 @@ void Scheduler::startJobEvaluation()
evaluateJobs();
}
void Scheduler::clearScriptURL()
{
QPushButton *scriptSender = (QPushButton*) (sender());
if (scriptSender == NULL)
return;
if (scriptSender == clearStartupB)
{
startupScript->clear();
startupScriptURL = QUrl();
Options::setStartupScript(QString());
}
else
{
shutdownScript->clear();
shutdownScriptURL = QUrl();
Options::setShutdownScript(QString());
}
}
void Scheduler::updatePreDawn()
{
double earlyDawn = Dawn - Options::preDawnTime()/(60.0 * 24.0);
......
......@@ -163,8 +163,6 @@ protected slots:
void resetJobEdit();
void clearScriptURL();
/**
* @brief checkJobStatus Check the overall state of the scheduler, Ekos, and INDI. When all is OK, it call evaluateJobs();
*/
......
......@@ -762,6 +762,9 @@
<item>
<widget class="QLineEdit" name="startupScript">
<property name="readOnly">
<bool>false</bool>
</property>
<property name="clearButtonEnabled">
<bool>true</bool>
</property>
</widget>
......@@ -779,19 +782,6 @@
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="clearStartupB">
<property name="maximumSize">
<size>
<width>32</width>
<height>32</height>
</size>
</property>
<property name="text">
<string/>
</property>
</widget>
</item>
</layout>
</item>
</layout>
......@@ -874,6 +864,9 @@
<item>
<widget class="QLineEdit" name="shutdownScript">
<property name="readOnly">
<bool>false</bool>
</property>
<property name="clearButtonEnabled">
<bool>true</bool>
</property>
</widget>
......@@ -891,19 +884,6 @@
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="clearShutdownB">
<property name="maximumSize">
<size>
<width>32</width>
<height>32</height>
</size>
</property>
<property name="text">
<string/>
</property>
</widget>
</item>
</layout>
</item>
</layout>
......
......@@ -1679,32 +1679,6 @@
<label>Weather conditions must remain safe while observatory is online.</label>
<default>false</default>
</entry>
<entry name="startupScript" type="String">
<label>One-time startup script to be executed before starting Ekos devices.</label>
</entry>
<entry name="shutdownScript" type="String">
<label>One-time shutdown procedure to be executed after all scheduler jobs are completed. The script is executed after the initial shutdown procedures (e.g. parking), if selected, are completed.</label>
</entry>
<entry name="WarmUpCCD" type="Bool">
<label>Warm up CCD if supported on shutdown.</label>
<default>false</default>
</entry>
<entry name="ParkMount" type="Bool">
<label>Park mount on shutdown.</label>
<default>false</default>
</entry>
<entry name="ParkDome" type="Bool">
<label>Park dome on shutdown.</label>
<default>false</default>
</entry>
<entry name="UnParkMount" type="Bool">
<label>UnPark mount on startup.</label>
<default>false</default>
</entry>
<entry name="UnParkDome" type="Bool">
<label>UnPark dome on startup.</label>
<default>false</default>
</entry>
<entry name="preemptiveShutdown" type="Bool">
<label>Perform pre-emptive strike if no jobs are due for a number of hours.</label>
<default>false</default>
......
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