Commit 45c23031 authored by Jasem Mutlaq's avatar Jasem Mutlaq
Browse files

Add ability to manually trigger startup and shutdown procedures

parent e25ce00b
......@@ -160,7 +160,15 @@ Scheduler::Scheduler()
loadSequenceB->setIcon(QIcon::fromTheme("document-open"));
selectStartupScriptB->setIcon(QIcon::fromTheme("document-open"));
selectShutdownScriptB->setIcon(QIcon::fromTheme("document-open"));
selectFITSB->setIcon(QIcon::fromTheme("document-open"));
selectFITSB->setIcon(QIcon::fromTheme("document-open"));
startupB->setIcon(QIcon::fromTheme("media-playback-start"));
shutdownB->setIcon(QIcon::fromTheme("media-playback-start"));
connect(startupB, SIGNAL(clicked()), this, SLOT(runStartupProcedure()));
connect(shutdownB, SIGNAL(clicked()), this, SLOT(runShutdownProcedure()));
connect(this, SIGNAL(startupStateChanged(StartupState)), this, SLOT(updateStateGUI()));
connect(this, SIGNAL(shutdownStateChanged(ShutdownState)), this, SLOT(updateStateGUI()));
connect(selectObjectB,SIGNAL(clicked()),this,SLOT(selectObject()));
connect(selectFITSB,SIGNAL(clicked()),this,SLOT(selectFITS()));
......@@ -855,6 +863,9 @@ void Scheduler::stop()
loadAndSlewProgress=false;
autofocusCompleted=false;
startupB->setEnabled(true);
shutdownB->setEnabled(true);
// If soft shutdown, we return for now
if (preemptiveShutdown)
{
......@@ -931,6 +942,9 @@ void Scheduler::start()
mosaicB->setEnabled(false);
evaluateOnlyB->setEnabled(false);
startupB->setEnabled(false);
shutdownB->setEnabled(false);
schedulerTimer.start();
}
......@@ -2085,7 +2099,8 @@ bool Scheduler::checkShutdownState()
currentJob = NULL;
schedulerTimer.start();
if(state == SCHEDULER_RUNNIG)
schedulerTimer.start();
if (preemptiveShutdown == false)
{
......@@ -2182,7 +2197,6 @@ bool Scheduler::checkShutdownState()
return true;
case SHUTDOWN_ERROR:
//appendLogText(i18n("Shutdown script failed, aborting..."));
stop();
return true;
break;
......@@ -4072,7 +4086,7 @@ void Scheduler::checkCapParkingStatus()
if (startupState == STARTUP_UNPARKING_CAP)
{
startupState = STARTUP_COMPLETE;
appendLogText(i18n("Cap unparked."));
appendLogText(i18n("Cap unparked."));
}
break;
......@@ -4356,6 +4370,160 @@ void Scheduler::checkTwilightWarning(bool enabled)
}
}
void Scheduler::checkStartupProcedure()
{
if (checkStartupState() == false)
QTimer::singleShot(1000, this, SLOT(checkStartupProcedure()));
else
{
if (startupState == STARTUP_COMPLETE)
appendLogText(i18n("Manual startup procedure completed successfully."));
else if (startupState == STARTUP_ERROR)
appendLogText(i18n("Manual startup procedure terminated due to errors."));
startupB->setIcon(QIcon::fromTheme("media-playback-start"));
}
}
void Scheduler::runStartupProcedure()
{
if (startupState == STARTUP_IDLE || startupState == STARTUP_ERROR || startupState == STARTUP_COMPLETE)
{
if (KMessageBox::questionYesNo(NULL, i18n("Are you sure you want to execute the startup procedure manually?")) == KMessageBox::Yes)
{
appendLogText(i18n("Warning! Executing startup procedure manually..."));
startupB->setIcon(QIcon::fromTheme("media-playback-stop"));
startupState = STARTUP_IDLE;
checkStartupState();
QTimer::singleShot(1000, this, SLOT(checkStartupProcedure()));
}
}
else
{
switch (startupState)
{
case STARTUP_IDLE:
break;
case STARTUP_SCRIPT:
scriptProcess.terminate();
break;
case STARTUP_UNPARK_DOME:
break;
case STARTUP_UNPARKING_DOME:
domeInterface->call(QDBus::AutoDetect, "abort");
break;
case STARTUP_UNPARK_MOUNT:
break;
case STARTUP_UNPARKING_MOUNT:
mountInterface->call(QDBus::AutoDetect, "abort");
break;
case STARTUP_UNPARK_CAP:
break;
case STARTUP_UNPARKING_CAP:
break;
case STARTUP_COMPLETE:
break;
case STARTUP_ERROR:
break;
}
startupState = STARTUP_IDLE;
appendLogText(i18n("Startup procedure terminated."));
}
}
void Scheduler::checkShutdownProcedure()
{
// If shutdown procedure is not finished yet, let's check again in 1 second.
if (checkShutdownState() == false)
QTimer::singleShot(1000, this, SLOT(checkShutdownProcedure()));
else
{
if (shutdownState == SHUTDOWN_COMPLETE)
appendLogText(i18n("Manual shutdown procedure completed successfully."));
else if (shutdownState == SHUTDOWN_ERROR)
appendLogText(i18n("Manual shutdown procedure terminated due to errors."));
shutdownState = SHUTDOWN_IDLE;
shutdownB->setIcon(QIcon::fromTheme("media-playback-start"));
}
}
void Scheduler::runShutdownProcedure()
{
if (shutdownState == SHUTDOWN_IDLE || shutdownState == SHUTDOWN_ERROR || shutdownState == SHUTDOWN_COMPLETE)
{
if (KMessageBox::questionYesNo(NULL, i18n("Are you sure you want to execute the shutdown procedure manually?")) == KMessageBox::Yes)
{
appendLogText(i18n("Warning! Executing shutdown procedure manually..."));
shutdownB->setIcon(QIcon::fromTheme("media-playback-stop"));
shutdownState = SHUTDOWN_IDLE;
checkShutdownState();
QTimer::singleShot(1000, this, SLOT(checkShutdownProcedure()));
}
}
else
{
switch (shutdownState)
{
case SHUTDOWN_IDLE:
break;
case SHUTDOWN_SCRIPT:
break;
case SHUTDOWN_SCRIPT_RUNNING:
scriptProcess.terminate();
break;
case SHUTDOWN_PARK_DOME:
break;
case SHUTDOWN_PARKING_DOME:
domeInterface->call(QDBus::AutoDetect, "abort");
break;
case SHUTDOWN_PARK_MOUNT:
break;
case SHUTDOWN_PARKING_MOUNT:
mountInterface->call(QDBus::AutoDetect, "abort");
break;
case SHUTDOWN_PARK_CAP:
break;
case SHUTDOWN_PARKING_CAP:
break;
case SHUTDOWN_COMPLETE:
break;
case SHUTDOWN_ERROR:
break;
}
shutdownState = SHUTDOWN_IDLE;
appendLogText(i18n("Shutdown procedure terminated."));
}
}
}
......@@ -272,9 +272,15 @@ protected slots:
*/
void checkTwilightWarning(bool enabled);
void runStartupProcedure();
void checkStartupProcedure();
void runShutdownProcedure();
void checkShutdownProcedure();
signals:
void newLog();
void weatherChanged(IPState state);
void weatherChanged(IPState state);
private:
......
......@@ -6,11 +6,11 @@
<rect>
<x>0</x>
<y>0</y>
<width>649</width>
<width>722</width>
<height>436</height>
</rect>
</property>
<layout class="QVBoxLayout" name="verticalLayout_4">
<layout class="QVBoxLayout" name="verticalLayout_6">
<item>
<widget class="QGroupBox" name="groupBox">
<property name="title">
......@@ -878,7 +878,7 @@
<property name="title">
<string>Startup Procedure</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout_6">
<layout class="QVBoxLayout" name="verticalLayout_4">
<item>
<layout class="QHBoxLayout" name="horizontalLayout_16">
<item>
......@@ -939,6 +939,19 @@
</property>
</spacer>
</item>
<item>
<widget class="QPushButton" name="startupB">
<property name="maximumSize">
<size>
<width>32</width>
<height>32</height>
</size>
</property>
<property name="text">
<string/>
</property>
</widget>
</item>
</layout>
</item>
<item>
......@@ -980,6 +993,12 @@
</item>
<item>
<widget class="QGroupBox" name="groupBox_10">
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="toolTip">
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;One-time shutdown procedure to be executed after all scheduler jobs are completed. The script is executed &lt;span style=&quot; font-weight:600; text-decoration: underline;&quot;&gt;after&lt;/span&gt; the shutdown procedures (e.g. parking), if selected, are completed.&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
......@@ -1063,6 +1082,25 @@
</property>
</spacer>
</item>
<item>
<widget class="QPushButton" name="shutdownB">
<property name="minimumSize">
<size>
<width>0</width>
<height>0</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>32</width>
<height>32</height>
</size>
</property>
<property name="text">
<string/>
</property>
</widget>
</item>
</layout>
</item>
<item>
......@@ -1157,14 +1195,13 @@
<resources/>
<connections/>
<buttongroups>
<buttongroup name="constraintButtonGroup">
<buttongroup name="startupButtonGroup"/>
<buttongroup name="stepsButtonGroup">
<property name="exclusive">
<bool>false</bool>
</property>
</buttongroup>
<buttongroup name="startupButtonGroup"/>
<buttongroup name="completionButtonGroup"/>
<buttongroup name="startupProcedureButtonGroup">
<buttongroup name="constraintButtonGroup">
<property name="exclusive">
<bool>false</bool>
</property>
......@@ -1174,7 +1211,8 @@
<bool>false</bool>
</property>
</buttongroup>
<buttongroup name="stepsButtonGroup">
<buttongroup name="completionButtonGroup"/>
<buttongroup name="startupProcedureButtonGroup">
<property name="exclusive">
<bool>false</bool>
</property>
......
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