Commit 473f6cd4 authored by Jasem Mutlaq's avatar Jasem Mutlaq
Browse files

Add option so that INDI is disconnected before executing the shutdown script...

Add option so that INDI is disconnected before executing the shutdown script which could be terminating INDI server
parent 81137498
......@@ -6,15 +6,15 @@
<rect>
<x>0</x>
<y>0</y>
<width>504</width>
<height>394</height>
<width>871</width>
<height>657</height>
</rect>
</property>
<property name="windowTitle">
<string>TabWidget</string>
</property>
<property name="currentIndex">
<number>0</number>
<number>1</number>
</property>
<widget class="QWidget" name="generalTab">
<attribute name="title">
......@@ -166,6 +166,16 @@
</property>
</widget>
</item>
<item>
<widget class="QCheckBox" name="checkBox">
<property name="toolTip">
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;If the shutdown script terminates INDI server, enable this option so that no disconnection errors are generated.&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
<property name="text">
<string>Shutdown Script Terminiates INDI</string>
</property>
</widget>
</item>
<item>
<spacer name="verticalSpacer">
<property name="orientation">
......
......@@ -34,6 +34,7 @@
#include "ksutils.h"
#include "mosaic.h"
#include "skyobjects/starobject.h"
#include "ksnotification.h"
#define BAD_SCORE -1000
#define MAX_FAILURE_ATTEMPTS 3
......@@ -2158,7 +2159,10 @@ bool Scheduler::checkStartupState()
break;
case STARTUP_UNPARK_DOME:
if (currentJob->getLightFramesRequired())
// If there is no job in case of manual startup procedure,
// or if the job requires light frames, let's proceed with
// unparking the dome, otherwise startup process is complete.
if (currentJob == NULL || currentJob->getLightFramesRequired())
{
if (unparkDomeCheck->isEnabled() && unparkDomeCheck->isChecked())
unParkDome();
......@@ -2316,7 +2320,14 @@ bool Scheduler::checkShutdownState()
case SHUTDOWN_SCRIPT:
if (shutdownScriptURL.isEmpty() == false)
{
{
// Need to stop Ekos now before executing script if it happens to stop INDI
if (ekosState != EKOS_IDLE && Options::stopEkosAfterShutdown() && Options::shutdownScriptTerminatesINDI())
{
stopEkos();
return false;
}
shutdownState = SHUTDOWN_SCRIPT_RUNNING;
executeScript(shutdownScriptURL.toString(QUrl::PreferLocalFile));
}
......@@ -2444,8 +2455,8 @@ void Scheduler::checkStatus()
else
appendLogText(i18n("Shutdown procedure failed, aborting..."));
// Stop Ekos if there is no shutdown script since stopEkos is called right before executing the shutdown script
if (shutdownScriptURL.isEmpty() && Options::stopEkosAfterShutdown())
// Stop Ekos if required.
if (ekosState != EKOS_IDLE && Options::stopEkosAfterShutdown())
stopEkos();
// Stop Scheduler
......@@ -3855,9 +3866,11 @@ void Scheduler::stopEkos()
ekosInterface->call(QDBus::AutoDetect,"disconnectDevices");
ekosInterface->call(QDBus::AutoDetect,"stop");
startupState = STARTUP_IDLE;
shutdownState= SHUTDOWN_IDLE;
weatherStatus= IPS_IDLE;
ekosState = EKOS_IDLE;
indiState = INDI_IDLE;
//startupState = STARTUP_IDLE;
//shutdownState= SHUTDOWN_IDLE;
//weatherStatus= IPS_IDLE;
}
void Scheduler::setDirty()
......@@ -4653,6 +4666,12 @@ void Scheduler::runStartupProcedure()
{
if (startupState == STARTUP_IDLE || startupState == STARTUP_ERROR || startupState == STARTUP_COMPLETE)
{
if (indiState == INDI_IDLE)
{
KSNotification::sorry(i18n("Cannot run startup procedure while INDI devices are not online."));
return;
}
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..."));
......
......@@ -1751,6 +1751,10 @@
<entry name="StopEkosAfterShutdown" type="Bool">
<label>After shutdown procedure is successfully executed, shutdown INDI and Ekos.</label>
<default>true</default>
</entry>
<entry name="ShutdownScriptTerminatesINDI" type="Bool">
<label>Whether shutdown script, if exists, terminates INDI server in the process.</label>
<default>false</default>
</entry>
<entry name="PreemptiveShutdown" type="Bool">
<label>Perform pre-emptive shutdown if no jobs are due for a number of hours.</label>
......
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