Commit 60f6852d authored by Jasem Mutlaq's avatar Jasem Mutlaq

Add support to device profile selection in scheduler module

parent c958c155
......@@ -2048,6 +2048,15 @@ bool EkosManager::setProfile(const QString &profileName)
return true;
}
QStringList EkosManager::getProfiles()
{
QStringList profiles;
for (int i=0; i < profileCombo->count(); i++)
profiles << profileCombo->itemText(i);
return profiles;
}
void EkosManager::addProfile()
{
......
......@@ -80,14 +80,18 @@ public:
/*@{*/
/** DBUS interface function.
* set Ekos connection mode.
* @param isLocal if true, it will establish INDI server locally, otherwise it will connect to a remote INDI server as defined in the Ekos options or by the user.
* /note This function must be called before all functions in Ekos DBUS Interface.
* set Current device profile.
* @param profileName Profile name
* @return True if profile is set, false if not found.
*/
//Q_SCRIPTABLE Q_NOREPLY void setConnectionMode(bool isLocal);
Q_SCRIPTABLE bool setProfile(const QString &profileName);
/** DBUS interface function
* @brief getProfiles Return a list of all device profiles
* @return List of device profiles
*/
Q_SCRIPTABLE QStringList getProfiles();
/** DBUS interface function.
* @retrun INDI connection status (0 Idle, 1 Pending, 2 Connected, 3 Error)
*/
......
......@@ -190,6 +190,8 @@ Scheduler::Scheduler()
connect(twilightCheck, SIGNAL(toggled(bool)), this, SLOT(checkTwilightWarning(bool)));
loadProfiles();
}
Scheduler::~Scheduler()
......@@ -205,6 +207,7 @@ void Scheduler::watchJobChanges(bool enable)
connect(startupScript, SIGNAL(editingFinished()), this, SLOT(setDirty()));
connect(shutdownScript, SIGNAL(editingFinished()), this, SLOT(setDirty()));
connect(profileCombo, SIGNAL(currentIndexChanged(int)), this, SLOT(setDirty()));
connect(stepsButtonGroup, SIGNAL(buttonToggled(int,bool)), this, SLOT(setDirty()));
connect(startupButtonGroup, SIGNAL(buttonToggled(int,bool)), this, SLOT(setDirty()));
connect(constraintButtonGroup, SIGNAL(buttonToggled(int,bool)), this, SLOT(setDirty()));
......@@ -228,6 +231,7 @@ void Scheduler::watchJobChanges(bool enable)
disconnect(startupScript, SIGNAL(editingFinished()), this, SLOT(setDirty()));
disconnect(shutdownScript, SIGNAL(editingFinished()), this, SLOT(setDirty()));
disconnect(profileCombo, SIGNAL(currentIndexChanged(int)), this, SLOT(setDirty()));
disconnect(stepsButtonGroup, SIGNAL(buttonToggled(int,bool)), this, SLOT(setDirty()));
disconnect(startupButtonGroup, SIGNAL(buttonToggled(int,bool)), this, SLOT(setDirty()));
disconnect(constraintButtonGroup, SIGNAL(buttonToggled(int,bool)), this, SLOT(setDirty()));
......@@ -440,6 +444,7 @@ void Scheduler::saveJob()
job->setDateTimeDisplayFormat(startupTimeEdit->displayFormat());
job->setSequenceFile(sequenceURL);
job->setProfile(profileCombo->currentText());
fitsURL = QUrl::fromLocalFile(fitsEdit->text());
job->setFITSFile(fitsURL);
......@@ -633,6 +638,8 @@ void Scheduler::loadJob(QModelIndex i)
sequenceEdit->setText(job->getSequenceFile().path());
sequenceURL = job->getSequenceFile();
profileCombo->setCurrentText(job->getProfile());
trackStepCheck->setChecked(job->getStepPipeline() & SchedulerJob::USE_TRACK);
focusStepCheck->setChecked(job->getStepPipeline() & SchedulerJob::USE_FOCUS);
alignStepCheck->setChecked(job->getStepPipeline() & SchedulerJob::USE_ALIGN);
......@@ -2016,6 +2023,13 @@ bool Scheduler::checkStartupState()
return true;
}
if (profileCombo->currentText() != i18n("Default"))
{
QList<QVariant> profile;
profile.append(profileCombo->currentText());
ekosInterface->callWithArgumentList(QDBus::AutoDetect,"setProfile", profile);
}
if (startupScriptURL.isEmpty() == false)
{
startupState = STARTUP_SCRIPT;
......@@ -3121,6 +3135,10 @@ bool Scheduler::processJobInfo(XMLEle *root)
}
}
}
else if (!strcmp(tagXMLEle(ep), "Profile"))
{
profileCombo->setCurrentText(pcdataXMLEle(ep));
}
else if (!strcmp(tagXMLEle(ep), "Steps"))
{
XMLEle *module;
......@@ -3275,6 +3293,7 @@ bool Scheduler::saveScheduler(const QUrl &fileURL)
outstream << "<Condition value='" << job->getCompletionTime().toString(Qt::ISODate) << "'>At</Condition>" << endl;
outstream << "</CompletionCondition>" << endl;
outstream << "<Profile>" << job->getProfile() << "</Profile>" << endl;
outstream << "<Steps>" << endl;
if (job->getStepPipeline() & SchedulerJob::USE_TRACK)
outstream << "<Step>Track</Step>" << endl;
......@@ -4524,6 +4543,23 @@ void Scheduler::runShutdownProcedure()
}
}
void Scheduler::loadProfiles()
{
QString currentProfile = profileCombo->currentText();
QDBusReply<QStringList> profiles = ekosInterface->call(QDBus::AutoDetect,"getProfiles");
if (profiles.error().type() == QDBusError::NoError)
{
profileCombo->blockSignals(true);
profileCombo->clear();
profileCombo->addItem(i18n("Default"));
profileCombo->addItems(profiles);
profileCombo->setCurrentText(currentProfile);
profileCombo->blockSignals(false);
}
}
}
......@@ -480,6 +480,8 @@ private:
*/
bool createJobSequence(XMLEle *root, const QString &prefix, const QString &outputDir);
void loadProfiles();
XMLEle * getSequenceJobRoot();
bool isWeatherOK(SchedulerJob *job);
......
......@@ -7,7 +7,7 @@
<x>0</x>
<y>0</y>
<width>722</width>
<height>436</height>
<height>460</height>
</rect>
</property>
<layout class="QVBoxLayout" name="verticalLayout_6">
......@@ -88,7 +88,7 @@
</property>
</widget>
</item>
<item row="4" column="2">
<item row="5" column="2">
<layout class="QHBoxLayout" name="horizontalLayout_11">
<item>
<widget class="QCheckBox" name="trackStepCheck">
......@@ -266,7 +266,7 @@
</item>
</layout>
</item>
<item row="4" column="0">
<item row="5" column="0">
<widget class="QLabel" name="label_4">
<property name="toolTip">
<string>Select which steps to execute before starting the capture process.</string>
......@@ -296,6 +296,25 @@
</property>
</widget>
</item>
<item row="4" column="0">
<widget class="QLabel" name="label_9">
<property name="toolTip">
<string>Ekos Device Profile</string>
</property>
<property name="text">
<string>Profile:</string>
</property>
</widget>
</item>
<item row="4" column="2">
<widget class="QComboBox" name="profileCombo">
<item>
<property name="text">
<string>Default</string>
</property>
</item>
</widget>
</item>
</layout>
</item>
<item>
......@@ -1195,24 +1214,24 @@
<resources/>
<connections/>
<buttongroups>
<buttongroup name="startupButtonGroup"/>
<buttongroup name="stepsButtonGroup">
<buttongroup name="constraintButtonGroup">
<property name="exclusive">
<bool>false</bool>
</property>
</buttongroup>
<buttongroup name="constraintButtonGroup">
<buttongroup name="startupProcedureButtonGroup">
<property name="exclusive">
<bool>false</bool>
</property>
</buttongroup>
<buttongroup name="shutdownProcedureGroup">
<buttongroup name="startupButtonGroup"/>
<buttongroup name="completionButtonGroup"/>
<buttongroup name="stepsButtonGroup">
<property name="exclusive">
<bool>false</bool>
</property>
</buttongroup>
<buttongroup name="completionButtonGroup"/>
<buttongroup name="startupProcedureButtonGroup">
<buttongroup name="shutdownProcedureGroup">
<property name="exclusive">
<bool>false</bool>
</property>
......
......@@ -387,6 +387,16 @@ void SchedulerJob::setEnforceTwilight(bool value)
enforceTwilight = value;
}
QString SchedulerJob::getProfile() const
{
return profile;
}
void SchedulerJob::setProfile(const QString &value)
{
profile = value;
}
void SchedulerJob::setTargetCoords(dms ra, dms dec)
......
......@@ -110,6 +110,9 @@ public:
bool getEnforceTwilight() const;
void setEnforceTwilight(bool value);
QString getProfile() const;
void setProfile(const QString &value);
private:
QString name;
......@@ -148,6 +151,7 @@ private:
double Dawn, Dusk;
QString dateTimeDisplayFormat;
QString profile;
};
......
......@@ -19,6 +19,9 @@
<method name="stop">
<arg type="b" direction="out"/>
</method>
<method name="getProfiles">
<arg type="as" direction="out"/>
</method>
<method name="setProfile">
<arg name="profileName" type="s" direction="in"/>
<arg type="b" direction="out"/>
......
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