[education/kstars] kstars: Add simple option for camera warmup instead of asking users to create a task action for it.
Jasem Mutlaq <[email protected]>
| Newsgroups | gmane.comp.kde.cvs |
|---|---|
| Message-ID | <[email protected]> |
Git commit b4a3a673594c409394dad758a0b69acbf31217b9 by Jasem Mutlaq.
Committed on 27/07/2026 at 08:45.
Pushed by mutlaqja into branch 'master'.
Add simple option for camera warmup instead of asking users to create a task action for it.
M +51 -5 kstars/ekos/scheduler/opsscriptssettings.ui
M +46 -0 kstars/ekos/scheduler/taskqueue/queue/queuemanager.cpp
M +10 -0 kstars/kstars.kcfg
https://invent.kde.org/education/kstars/-/commit/b4a3a673594c409394dad758a0b69acbf31217b9
diff --git a/kstars/ekos/scheduler/opsscriptssettings.ui b/kstars/ekos/scheduler/opsscriptssettings.ui
index 7df069420e..42b7bae1d1 100644
--- a/kstars/ekos/scheduler/opsscriptssettings.ui
+++ b/kstars/ekos/scheduler/opsscriptssettings.ui
@@ -6,16 +6,13 @@
<rect>
<x>0</x>
<y>0</y>
- <width>231</width>
- <height>58</height>
+ <width>328</width>
+ <height>90</height>
</rect>
</property>
<property name="windowTitle">
<string>TabWidget</string>
</property>
- <property name="currentIndex" stdset="0">
- <number>1</number>
- </property>
<layout class="QVBoxLayout" name="verticalLayout">
<property name="spacing">
<number>3</number>
@@ -52,6 +49,55 @@
</property>
</widget>
</item>
+ <item>
+ <layout class="QHBoxLayout" name="horizontalLayout">
+ <item>
+ <widget class="QCheckBox" name="kcfg_CameraWarmupEnabled">
+ <property name="toolTip">
+ <string>Warm up the camera sensor before shutting down.</string>
+ </property>
+ <property name="text">
+ <string>Warm camera before shutdown</string>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QSpinBox" name="kcfg_CameraWarmupRamp">
+ <property name="toolTip">
+ <string>Temperature ramp rate for camera warmup in °C per minute.</string>
+ </property>
+ <property name="suffix">
+ <string> °C/min</string>
+ </property>
+ <property name="minimum">
+ <number>1</number>
+ </property>
+ <property name="maximum">
+ <number>30</number>
+ </property>
+ <property name="singleStep">
+ <number>1</number>
+ </property>
+ <property name="value">
+ <number>5</number>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <spacer name="horizontalSpacer">
+ <property name="orientation">
+ <enum>Qt::Orientation::Horizontal</enum>
+ </property>
+ <property name="sizeHint" stdset="0">
+ <size>
+ <width>40</width>
+ <height>20</height>
+ </size>
+ </property>
+ </spacer>
+ </item>
+ </layout>
+ </item>
<item>
<spacer name="verticalSpacer">
<property name="orientation">
diff --git a/kstars/ekos/scheduler/taskqueue/queue/queuemanager.cpp b/kstars/ekos/scheduler/taskqueue/queue/queuemanager.cpp
index 19064c4254..cfc7ff33b2 100644
--- a/kstars/ekos/scheduler/taskqueue/queue/queuemanager.cpp
+++ b/kstars/ekos/scheduler/taskqueue/queue/queuemanager.cpp
@@ -8,6 +8,7 @@
#include "../task.h"
#include "../tasktemplate.h"
#include "../templatemanager.h"
+#include "Options.h"
#include <QFile>
#include <QJsonDocument>
@@ -470,6 +471,51 @@ bool QueueManager::loadCollectionFromJson(const QJsonObject &json)
}
}
+ // If camera warmup is enabled and this is the Observatory Shutdown collection,
+ // ensure a warmup task is appended at the end
+ if (Options::cameraWarmupEnabled() &&
+ json["name"].toString() == "Observatory Shutdown Tasks")
+ {
+ // Check if a warmup task already exists in the queue
+ bool hasWarmup = false;
+ for (QueueItem *item : m_items)
+ {
+ Task *existingTask = item->task();
+ if (existingTask && (existingTask->templateId() == "camera_warm" ||
+ existingTask->templateId() == "camera_warm_passive"))
+ {
+ hasWarmup = true;
+ break;
+ }
+ }
+
+ if (!hasWarmup)
+ {
+ TaskTemplate *warmTmpl = templateMgr->getTemplate("camera_warm");
+ if (warmTmpl)
+ {
+ QMap<QString, QVariant> parameters;
+ parameters["target_temperature"] = 20;
+ parameters["ramp_slope"] = static_cast<int>(Options::cameraWarmupRamp());
+ parameters["tolerance"] = 2.0;
+ parameters["ramp_threshold"] = 0.5;
+ parameters["max_wait_time"] = 600;
+
+ Task *warmTask = new Task(this);
+ if (warmTask->instantiateFromTemplate(warmTmpl, "", parameters))
+ {
+ QueueItem *warmItem = new QueueItem(warmTask, this);
+ // Append at the end so warmup runs after all parking tasks
+ m_items.append(warmItem);
+ }
+ else
+ {
+ delete warmTask;
+ }
+ }
+ }
+ }
+
return true;
}
diff --git a/kstars/kstars.kcfg b/kstars/kstars.kcfg
index 453390fb11..1f39eaa85a 100644
--- a/kstars/kstars.kcfg
+++ b/kstars/kstars.kcfg
@@ -3422,6 +3422,16 @@
<label>Whether shutdown script, if exists, terminates INDI server in the process.</label>
<default>false</default>
</entry>
+ <entry name="CameraWarmupEnabled" type="Bool">
+ <label>Warm up the camera sensor before the shutdown sequence.</label>
+ <default>false</default>
+ </entry>
+ <entry name="CameraWarmupRamp" type="UInt">
+ <label>Camera warmup ramp rate in °C per minute.</label>
+ <default>5</default>
+ <min>1</min>
+ <max>30</max>
+ </entry>
<entry name="PreemptiveShutdown" type="Bool">
<label>Perform pre-emptive shutdown if no jobs are due for a number of hours.</label>
<default>true</default>