summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel Leu <[email protected]>2015-06-27 19:01:28 +0300
committerDaniel Leu <[email protected]>2015-06-27 19:01:28 +0300
commitd02e8190b5b47cb4e13b052e039d852661910589 (patch)
treea5e4e7b6258fd6c083d9351839837ba2dbbe66e2
parent087208582d008705262934d82bfa2dbc88fb09fb (diff)
Midterm commit: Telescope and ccd sims working fine under Now button functionality(Dbus calls)
-rw-r--r--kstars/CMakeLists.txt2
-rw-r--r--kstars/ekos/ekosmanager.cpp5
-rw-r--r--kstars/ekos/ekosmanager.h2
-rw-r--r--kstars/ekos/scheduler.cpp624
-rw-r--r--kstars/ekos/scheduler.h44
-rw-r--r--kstars/ekos/scheduler.ui658
6 files changed, 1335 insertions, 0 deletions
diff --git a/kstars/CMakeLists.txt b/kstars/CMakeLists.txt
index 5b9a6a9..4db47ab 100644
--- a/kstars/CMakeLists.txt
+++ b/kstars/CMakeLists.txt
@@ -74,6 +74,7 @@ if (INDI_FOUND)
if (CFITSIO_FOUND)
set(ekosui_SRCS
+ ekos/scheduler.ui
ekos/opsekos.ui
ekos/ekosmanager.ui
ekos/capture.ui
@@ -86,6 +87,7 @@ if (CFITSIO_FOUND)
)
set(ekos_SRCS
+ ekos/scheduler.cpp
ekos/ekosmanager.cpp
ekos/capture.cpp
ekos/focus.cpp
diff --git a/kstars/ekos/ekosmanager.cpp b/kstars/ekos/ekosmanager.cpp
index 70ecc34..5df6ec6 100644
--- a/kstars/ekos/ekosmanager.cpp
+++ b/kstars/ekos/ekosmanager.cpp
@@ -112,6 +112,9 @@ EkosManager::EkosManager()
else
initRemoteDrivers();
+ schedulerProcess = new Ekos::Scheduler();
+ toolsWidget->addTab( schedulerProcess, xi18n("Scheduler"));
+
}
EkosManager::~EkosManager()
@@ -121,6 +124,7 @@ EkosManager::~EkosManager()
delete guideProcess;
delete alignProcess;
delete mountProcess;
+ delete schedulerProcess;
}
void EkosManager::setConnectionMode(bool isLocal)
@@ -683,6 +687,7 @@ void EkosManager::reset()
guideProcess = NULL;
alignProcess = NULL;
mountProcess = NULL;
+ schedulerProcess = NULL;
guiderCCDName = "";
primaryCCDName = "";
diff --git a/kstars/ekos/ekosmanager.h b/kstars/ekos/ekosmanager.h
index 1ff53e5..c53dde4 100644
--- a/kstars/ekos/ekosmanager.h
+++ b/kstars/ekos/ekosmanager.h
@@ -20,6 +20,7 @@
#include "guide.h"
#include "align.h"
#include "mount.h"
+#include "scheduler.h"
#include <QDialog>
#include <QHash>
@@ -218,6 +219,7 @@ protected slots:
Ekos::Guide *guideProcess;
Ekos::Align *alignProcess;
Ekos::Mount *mountProcess;
+ Ekos::Scheduler *schedulerProcess;
QString guiderCCDName;
QString primaryCCDName;
diff --git a/kstars/ekos/scheduler.cpp b/kstars/ekos/scheduler.cpp
new file mode 100644
index 0000000..626b320
--- /dev/null
+++ b/kstars/ekos/scheduler.cpp
@@ -0,0 +1,624 @@
+/* Ekos Scheduler Module
+ Copyright (C) 2015 Daniel Leu <[email protected]>
+
+ This application is free software; you can redistribute it and/or
+ modify it under the terms of the GNU General Public
+ License as published by the Free Software Foundation; either
+ version 2 of the License, or (at your option) any later version.
+ */
+
+#include "Options.h"
+
+#include <KMessageBox>
+#include <KLocalizedString>
+#include <KPlotting/KPlotWidget>
+#include <KPlotting/KPlotObject>
+#include <KPlotting/KPlotAxis>
+#include <QtDBus>
+#include <QFileDialog>
+#include <QtXml>
+
+#include "indi/driverinfo.h"
+#include "indi/indicommon.h"
+#include "indi/clientmanager.h"
+#include "indi/indifilter.h"
+
+#include "fitsviewer/fitsviewer.h"
+#include "fitsviewer/fitstab.h"
+#include "fitsviewer/fitsview.h"
+#include "ekosmanager.h"
+#include "Options.h"
+
+#include "ksnotify.h"
+#include "kstars.h"
+#include "kstars.cpp"
+#include "focusadaptor.h"
+
+#include "focus.h"
+
+#include <basedevice.h>
+#include "scheduler.h"
+
+namespace Ekos
+{
+
+struct Sequence {
+ float exposure;
+ int binx;
+ int biny;
+ int framex;
+ int framey;
+ int W;
+ int H;
+ int count;
+ int delay;
+
+ bool type;
+ bool filter;
+ bool duration;
+ bool TS;
+
+ QString Type;
+ QString Filter;
+ QString FITSDir;
+};
+
+struct Observable {
+QString name;
+QString RA;
+QString DEC;
+QString startTime;
+QString finTime;
+QString fileName;
+
+SkyObject *ob;
+mutable Sequence seq;
+
+float alt;
+float MoonSep;
+int hours;
+int mins;
+
+bool Now;
+bool specTime;
+bool specAlt;
+bool moonSep;
+bool merFlip;
+
+bool whenSeqComp;
+bool loop;
+bool onTime;
+};
+
+int tableCountRow=0;
+int tableCountCol;
+
+QVector<Observable> objects;
+SkyObject *o;
+
+Scheduler::Scheduler()
+{
+ setupUi(this);
+ QDBusConnection::sessionBus().registerObject("/KStars/Ekos/Scheduler", this);
+ // connect(SelectButton,SIGNAL(clicked()),this,SLOT(newslot()));
+ connect(SelectButton,SIGNAL(clicked()),this,SLOT(selectSlot()));
+ connect(addToQueueB,SIGNAL(clicked()),this,SLOT(addToTableSlot()));
+ connect(removeFromQueueB,SIGNAL(clicked()),this,SLOT(removeTableSlot()));
+ connect(AddButton_3,SIGNAL(clicked()),this,SLOT(setSequenceSlot()));
+ connect(startButton,SIGNAL(clicked()),this,SLOT(startSlot()));
+ connect(queueSaveAsB,SIGNAL(clicked()),this,SLOT(saveSlot()));
+}
+
+void Scheduler::processSession(int i){
+ //Dbus
+ QDBusConnection bus = QDBusConnection::sessionBus();
+ QDBusInterface *interface = new QDBusInterface("org.kde.kstars",
+ "/KStars/INDI",
+ "org.kde.kstars.INDI",
+ bus,
+ this);
+
+ //INDI
+ //Alternative method
+ Options::setTelescopeDriver("Telescope Simulator");
+ Options::setCCDDriver("CCD Simulator");
+ EkosManager *ob;
+ ob = KStars::Instance()->ekosManager();
+ ob->processINDI();
+ //
+
+ //DBUS method-currently not working
+// QList<QVariant> args;
+// args.append("7624");
+// args.append("indi_simulator_telescope");
+// args.append("indi_simulator_ccd");
+// QDBusReply<int> reply = interface->callWithArgumentList(QDBus::AutoDetect,"start",args);
+// qDebug()<<reply;
+// if (reply.isValid())
+// {
+// QMessageBox::information(NULL, "Good", "Good");
+// }
+ //
+
+ QEventLoop loop;
+ QTimer::singleShot(3000, &loop, SLOT(quit()));
+ loop.exec();
+
+ //Telescope
+ QList<QVariant> args2;
+ args2.append("Telescope Simulator");
+ args2.append("CONNECTION");
+ args2.append("CONNECT");
+ args2.append("On");
+ QDBusReply<QString> reply2 = interface->callWithArgumentList(QDBus::AutoDetect,"setSwitch",args2);
+ QList<QVariant> args3;
+ args3.append("Telescope Simulator");
+ args3.append("CONNECTION");
+ interface->callWithArgumentList(QDBus::AutoDetect,"sendProperty",args3);
+
+ QDBusReply<QString> reply3 = interface->callWithArgumentList(QDBus::AutoDetect,"getPropertyState",args3);
+
+ //CCD
+ QList<QVariant> args4;
+ args4.append("CCD Simulator");
+ args4.append("CONNECTION");
+ args4.append("CONNECT");
+ args4.append("On");
+ QDBusReply<QString> reply4 = interface->callWithArgumentList(QDBus::AutoDetect,"setSwitch",args4);
+ QList<QVariant> args5;
+ args5.append("CCD Simulator");
+ args5.append("CONNECTION");
+ interface->callWithArgumentList(QDBus::AutoDetect,"sendProperty",args5);
+
+ QDBusReply<QString> reply5 = interface->callWithArgumentList(QDBus::AutoDetect,"getPropertyState",args5);
+ QEventLoop loop2;
+ QTimer::singleShot(5000, &loop2, SLOT(quit()));
+ loop2.exec();
+
+ //Telescope
+ QList<QVariant> args6;
+ args6.append("Telescope Simulator");
+ args6.append("EQUATORIAL_EOD_COORD");
+ args6.append("RA");
+ args6.append(objects.at(i).ob->ra().Hours());
+
+ QDBusReply<QString> reply6 = interface->callWithArgumentList(QDBus::AutoDetect,"setNumber",args6);
+ //DEC
+ QList<QVariant> args7;
+ args7.append("Telescope Simulator");
+ args7.append("EQUATORIAL_EOD_COORD");
+ args7.append("DEC");
+ args7.append(objects.at(i).ob->dec().Degrees());
+ QDBusReply<QString> reply7 = interface->callWithArgumentList(QDBus::AutoDetect,"setNumber",args7);
+
+ QList<QVariant> argsaux;
+ argsaux.append("Telescope Simulator");
+ argsaux.append("EQUATORIAL_EOD_COORD");
+ QDBusReply<QString> replyaux = interface->callWithArgumentList(QDBus::AutoDetect,"sendProperty",argsaux);
+
+ //Waiting for slew
+ while(true){
+ QDBusReply<QString> replys = interface->callWithArgumentList(QDBus::AutoDetect,"getPropertyState",argsaux);
+ if(replys.value().toStdString()!="Ok")
+ {
+ QEventLoop loop;
+ QTimer::singleShot(1000, &loop, SLOT(quit()));
+ loop.exec();
+ }
+ else break;
+ }
+
+ //CCD Exposure
+ //Binning
+ QList<QVariant> args11;
+ args11.append("CCD Simulator");
+ args11.append("CCD_BINNING");
+ args11.append("HOR_BIN");
+ args11.append(objects.at(i).seq.binx);
+ QDBusReply<QString> reply11 = interface->callWithArgumentList(QDBus::AutoDetect,"setNumber",args11);
+
+ QList<QVariant> args10;
+ args10.append("CCD Simulator");
+ args10.append("CCD_BINNING");
+ args10.append("VER_BIN");
+ args10.append(objects.at(i).seq.biny);
+ QDBusReply<QString> reply10 = interface->callWithArgumentList(QDBus::AutoDetect,"setNumber",args10);
+
+ QList<QVariant> argsbin;
+ argsbin.append("CCD Simulator");
+ argsbin.append("CCD_BINNING");
+ QDBusReply<QString> replybin = interface->callWithArgumentList(QDBus::AutoDetect,"sendProperty",argsbin);
+
+ //Type
+ QList<QVariant> argst;
+ argst.append("CCD Simulator");
+ argst.append("CCD_FRAME_TYPE");
+ if(!qstrcmp(objects.at(i).seq.Type.toStdString().c_str(),"Light"))
+ argst.append("FRAME_LIGHT");
+ if(!qstrcmp(objects.at(i).seq.Type.toStdString().c_str(),"Bias"))
+ argst.append("FRAME_BIAS");
+ if(!qstrcmp(objects.at(i).seq.Type.toStdString().c_str(),"Dark"))
+ argst.append("FRAME_DARK");
+ if(!qstrcmp(objects.at(i).seq.Type.toStdString().c_str(),"Flat"))
+ argst.append("FRAME_FLAT");
+ argst.append("On");
+ interface->callWithArgumentList(QDBus::AutoDetect,"setSwitch",argst);
+
+ QList<QVariant> argstt;
+ argstt.append("CCD Simulator");
+ argstt.append("CCD_FRAME_TYPE");
+ interface->callWithArgumentList(QDBus::AutoDetect,"sendProperty",argstt);
+
+ //Frame
+ QList<QVariant> argsf;
+ argsf.append("CCD Simulator");
+ argsf.append("CCD_FRAME");
+ argsf.append("X");
+ argsf.append(objects.at(i).seq.framex);
+ interface->callWithArgumentList(QDBus::AutoDetect,"setNumber",argsf);
+
+ argsf.clear();
+ argsf.append("CCD Simulator");
+ argsf.append("CCD_FRAME");
+ argsf.append("Y");
+ argsf.append(objects.at(i).seq.framey);
+ interface->callWithArgumentList(QDBus::AutoDetect,"setNumber",argsf);
+
+ argsf.clear();
+ argsf.append("CCD Simulator");
+ argsf.append("CCD_FRAME");
+ argsf.append("WIDTH");
+ argsf.append(objects.at(i).seq.W);
+ interface->callWithArgumentList(QDBus::AutoDetect,"setNumber",argsf);
+
+ argsf.clear();
+ argsf.append("CCD Simulator");
+ argsf.append("CCD_FRAME");
+ argsf.append("HEIGHT");
+ argsf.append(objects.at(i).seq.H);
+ interface->callWithArgumentList(QDBus::AutoDetect,"setNumber",argsf);
+
+ //Exposure
+ QList<QVariant> args8;
+ args8.append("CCD Simulator");
+ args8.append("CCD_EXPOSURE");
+ args8.append("CCD_EXPOSURE_VALUE");
+ args8.append(objects.at(i).seq.exposure);
+ QDBusReply<QString> reply8 = interface->callWithArgumentList(QDBus::AutoDetect,"setNumber",args8);
+
+ QList<QVariant> args9;
+ args9.append("CCD Simulator");
+ args9.append("CCD_EXPOSURE");
+ QDBusReply<QString> reply9 = interface->callWithArgumentList(QDBus::AutoDetect,"sendProperty",args9);
+
+ //Waiting for exposure
+ while(true){
+ QDBusReply<QString> replye = interface->callWithArgumentList(QDBus::AutoDetect,"getPropertyState",args9);
+ if(replye.value().toStdString()!="Ok")
+ {
+ QEventLoop loop;
+ QTimer::singleShot(1000, &loop, SLOT(quit()));
+ loop.exec();
+ }
+ else break;
+ }
+}
+
+void Scheduler::saveSlot()
+{
+ //Write xml
+ QDomDocument document;
+
+ //Root element
+ QDomElement root = document.createElement("Observable");
+ document.appendChild(root);
+
+ int i;
+ for(i=0;i<objects.length();i++)
+ {
+ QDomElement obj = document.createElement("Object");
+ obj.setAttribute("Name",objects.at(i).name);
+ obj.setAttribute("RA",objects.at(i).RA);
+ obj.setAttribute("DEC",objects.at(i).DEC);
+ obj.setAttribute("Sequence",objects.at(i).fileName);
+ obj.setAttribute("Now",objects.at(i).Now);
+ obj.setAttribute("On Time",objects.at(i).onTime);
+ obj.setAttribute("On Alt",objects.at(i).specAlt);
+ obj.setAttribute("Start Time",objects.at(i).specTime);
+ obj.setAttribute("MoonSep",objects.at(i).moonSep);
+ obj.setAttribute("MoonSepVal",objects.at(i).MoonSep);
+ obj.setAttribute("MerFlip",objects.at(i).merFlip);
+ obj.setAttribute("Loop",objects.at(i).loop);
+ obj.setAttribute("When Seq completes",objects.at(i).whenSeqComp);
+ obj.setAttribute("FinTime",objects.at(i).onTime);
+ obj.setAttribute("FinTimeVal",objects.at(i).finTime);
+ root.appendChild(obj);
+ }
+
+ QFile file("SchedulerQueue.sch");
+ file.open(QIODevice::ReadWrite | QIODevice::Text);
+ QTextStream stream(&file);
+ stream<<document.toString();
+ file.close();
+}
+
+void Scheduler::startSlot()
+{
+ int i;
+
+ for(i=0;i<objects.length();i++)
+ {
+ QUrl fileURL = objects.at(i).fileName;
+ if (fileURL.isEmpty())
+ return;
+
+ if (fileURL.isValid() == false)
+ {
+ QString message = xi18n( "Invalid URL: %1", fileURL.path() );
+ KMessageBox::sorry( 0, message, xi18n( "Invalid URL" ) );
+ return;
+ }
+
+ QFile sFile;
+ sFile.setFileName(fileURL.path());
+
+ if ( !sFile.open( QIODevice::ReadOnly))
+ {
+ QString message = xi18n( "Unable to open file %1", fileURL.path());
+ KMessageBox::sorry( 0, message, xi18n( "Could Not Open File" ) );
+ return;
+ }
+
+ LilXML *xmlParser = newLilXML();
+ char errmsg[MAXRBUF];
+ XMLEle *root = NULL;
+ XMLEle *ep1;
+ char c;
+
+ while ( sFile.getChar(&c))
+ {
+ root = readXMLEle(xmlParser, c, errmsg);
+
+ if (root)
+ {
+ for (ep1 = nextXMLEle(root, 1) ; ep1 != NULL ; ep1 = nextXMLEle(root, 0))
+ {
+
+ XMLEle *ep;
+ XMLEle *subEP;
+
+ for (ep = nextXMLEle(ep1, 1) ; ep != NULL ; ep = nextXMLEle(ep1, 0))
+ {
+ if (!strcmp(tagXMLEle(ep), "Exposure"))
+ objects.at(i).seq.exposure = atof(pcdataXMLEle(ep));
+ else if (!strcmp(tagXMLEle(ep), "Binning"))
+ {
+ subEP = findXMLEle(ep, "X");
+ if (subEP)
+ objects.at(i).seq.binx = atoi(pcdataXMLEle(subEP));
+ subEP = findXMLEle(ep, "Y");
+ if (subEP)
+ objects.at(i).seq.biny = atoi(pcdataXMLEle(subEP));
+ }
+ else if (!strcmp(tagXMLEle(ep), "Frame"))
+ {
+ subEP = findXMLEle(ep, "X");
+ if (subEP)
+ objects.at(i).seq.framex = atoi(pcdataXMLEle(subEP));
+ subEP = findXMLEle(ep, "Y");
+ if (subEP)
+ objects.at(i).seq.framey = atoi(pcdataXMLEle(subEP));
+ subEP = findXMLEle(ep, "W");
+ if (subEP)
+ objects.at(i).seq.W = atoi(pcdataXMLEle(subEP));
+ subEP = findXMLEle(ep, "H");
+ if (subEP)
+ objects.at(i).seq.H = atoi(pcdataXMLEle(subEP));
+ }
+ else if (!strcmp(tagXMLEle(ep), "Filter"))
+ {
+ if(atoi(pcdataXMLEle(ep))==1)
+ objects.at(i).seq.Filter = "Red";
+ if(atoi(pcdataXMLEle(ep))==2)
+ objects.at(i).seq.Filter = "Green";
+ if(atoi(pcdataXMLEle(ep))==3)
+ objects.at(i).seq.Filter = "Blue";
+ if(atoi(pcdataXMLEle(ep))==4)
+ objects.at(i).seq.Filter = "H_Alpha";
+ if(atoi(pcdataXMLEle(ep))==5)
+ objects.at(i).seq.Filter = "Luminosity";
+ }
+ else if (!strcmp(tagXMLEle(ep), "Type"))
+ {
+ if(atoi(pcdataXMLEle(ep))==0)
+ objects.at(i).seq.Type = "Light";
+ if(atoi(pcdataXMLEle(ep))==1)
+ objects.at(i).seq.Type = "Bias";
+ if(atoi(pcdataXMLEle(ep))==2)
+ objects.at(i).seq.Type = "Dark";
+ if(atoi(pcdataXMLEle(ep))==3)
+ objects.at(i).seq.Type = "Flat";
+ }
+ else if (!strcmp(tagXMLEle(ep), "Count"))
+ {
+ objects.at(i).seq.count = atoi(pcdataXMLEle(ep));
+ }
+ else if (!strcmp(tagXMLEle(ep), "Delay"))
+ {
+ objects.at(i).seq.delay = atoi(pcdataXMLEle(ep));
+ }
+ else if (!strcmp(tagXMLEle(ep), "FITSDirectory"))
+ {
+ objects.at(i).seq.FITSDir = pcdataXMLEle(ep);
+ }
+ }
+
+ }
+ delXMLEle(root);
+ }
+ }
+ }
+
+ for(i=0;i<objects.length();i++){
+ if(objects.at(i).Now==true)
+ {
+ processSession(i);
+ tableWidget->setItem(i,tableCountCol+1,new QTableWidgetItem("Done"));
+ }
+
+ //Currently not working
+// if(objects.at(i).specTime==true)
+// {
+// while(true){
+// QEventLoop loop;
+// QTimer::singleShot(10000, &loop, SLOT(quit()));
+// loop.exec();
+// if(objects.at(i).hours==QTime::currentTime().hour() && objects.at(i).mins == QTime::currentTime().minute())
+// break;
+// }
+// processSession(i);
+// }
+ //
+ }
+}
+
+void Scheduler::setSequenceSlot()
+{
+ QString fileName = QFileDialog::getOpenFileName(this, tr("Open File"),
+ "",
+ tr("Seq Files (*.esq)"));
+ lineEdit_3->setText(fileName);
+}
+
+void Scheduler::addToTableSlot()
+{
+ if(lineEdit_6->text().length()!=0 && lineEdit_2->text().length()!=0 && lineEdit->text().length()!=0 && lineEdit_3->text().length()!=0)
+ {
+ //Adding to vector
+ //Start up
+ Observable newOb;
+ newOb.ob=o;
+ newOb.name = lineEdit_6->text();
+ newOb.RA = lineEdit->text();
+ newOb.DEC = lineEdit_2->text();
+ newOb.fileName = lineEdit_3->text();
+ if(OnButton->isChecked()){
+ newOb.specTime = true;
+ newOb.startTime = dateTimeEdit->time().toString();
+ newOb.hours = dateTimeEdit->time().hour();
+ newOb.mins = dateTimeEdit->time().minute();
+ }
+ else if(NowButton->isChecked()){
+ newOb.Now = true;
+ newOb.startTime = QTime::currentTime().toString();
+ newOb.hours = QTime::currentTime().hour();
+ newOb.mins = QTime::currentTime().minute();
+ }
+ else if(altButton->isChecked()){
+ newOb.specAlt = true;
+ newOb.alt = doubleSpinBox->value();
+ }
+
+ //Constraints
+ if(moonSepBox->isChecked()){
+ newOb.moonSep = true;
+ newOb.MoonSep = doubleSpinBox_3->value();
+ }
+ else if(merFlipBox->isChecked())
+ newOb.merFlip = true;
+
+ //Completion
+ if(onFinButton->isChecked()){
+ newOb.onTime = true;
+ newOb.finTime = dateTimeEdit_2->time().toString();
+ }
+ else if(seqCompButton->isChecked())
+ newOb.whenSeqComp = true;
+ else if(loopButton->isChecked())
+ newOb.loop = true;
+
+ objects.append(newOb);
+
+ //Adding to table
+ tableCountCol=0;
+ const int currentRow = tableWidget->rowCount();
+ tableWidget->setRowCount(currentRow + 1);
+ tableWidget->setItem(tableCountRow,tableCountCol,new QTableWidgetItem(lineEdit_6->text()));
+ tableWidget->setItem(tableCountRow,tableCountCol+1,new QTableWidgetItem("Idle"));
+ tableWidget->setItem(tableCountRow,tableCountCol+2,new QTableWidgetItem(dateTimeEdit->time().toString()));
+ if(onFinButton->isChecked())
+ tableWidget->setItem(tableCountRow,tableCountCol+3,new QTableWidgetItem(dateTimeEdit_2->time().toString()));
+ else
+ tableWidget->setItem(tableCountRow,tableCountCol+3,new QTableWidgetItem("N/S"));
+ tableCountRow++;
+ lineEdit->clear();
+ lineEdit_2->clear();
+ lineEdit_6->clear();
+ }
+ else
+ QMessageBox::information(NULL, "Error", "All fields must be completed");
+}
+
+void Scheduler::removeTableSlot()
+{
+ tableWidget->removeRow(tableWidget->currentRow());
+ tableCountRow--;
+}
+
+void Scheduler::selectSlot()
+{
+ QPointer<FindDialog> fd = new FindDialog( KStars::Instance() );
+ if ( fd->exec() == QDialog::Accepted ) {
+ o = fd->selectedObject();
+ if( o != 0 ) {
+ lineEdit_6->setText(o->name());
+ lineEdit->setText(o->ra().toHMSString());
+ lineEdit_2->setText(o->dec().toDMSString());
+ }
+ }
+ delete fd;
+}
+
+
+
+//Check if weather is good. This works. I won t
+//add this to the functionallity for the purpose of testing
+int Scheduler::checkWeather()
+{
+ QEventLoop eventLoop;
+
+ // "quit()" the event-loop, when the network request "finished()"
+ QNetworkAccessManager mgr;
+ QObject::connect(&mgr, SIGNAL(finished(QNetworkReply*)), &eventLoop, SLOT(quit()));
+
+ // the HTTP request
+ QString oras="Bucharest";
+ QNetworkRequest req( QUrl( QString(("http://api.openweathermap.org/data/2.5/weather?q=%1")).arg(oras) ));
+ QNetworkReply *reply = mgr.get(req);
+ QTimer::singleShot(5000, &eventLoop, SLOT(quit()));
+ eventLoop.exec();
+ QString strReply = (QString)reply->readAll();
+ // ui->textEdit->setText(strReply);
+
+ QStringList cloudStatus;
+ QJsonDocument jsonResponse = QJsonDocument::fromJson(strReply.toUtf8());
+ QJsonObject jsonObject = jsonResponse.object();
+ QJsonArray jsonArray = jsonObject["weather"].toArray();
+
+ foreach (const QJsonValue & value, jsonArray) {
+ QJsonObject obj = value.toObject();
+ cloudStatus.append(obj["description"].toString());
+ }
+ // textEdit->setText(cloudStatus[0]);
+ int res = QString::compare(cloudStatus[0],"Sky is Clear",Qt::CaseInsensitive);
+ if(res == 0)
+ return 1;
+ else return 0;
+}
+//
+Scheduler::~Scheduler()
+{
+
+}
+
+}
diff --git a/kstars/ekos/scheduler.h b/kstars/ekos/scheduler.h
new file mode 100644
index 0000000..dc6903f
--- /dev/null
+++ b/kstars/ekos/scheduler.h
@@ -0,0 +1,44 @@
+/* Ekos Scheduler Module
+ Copyright (C) 2015 Daniel Leu <[email protected]>
+
+ This application is free software; you can redistribute it and/or
+ modify it under the terms of the GNU General Public
+ License as published by the Free Software Foundation; either
+ version 2 of the License, or (at your option) any later version.
+ */
+
+
+#ifndef SCHEDULER_H
+#define SCHEDULER_H
+
+#include <QMainWindow>
+#include "ui_scheduler.h"
+#include <QtDBus/QtDBus>
+#include "scheduler.h"
+
+namespace Ekos {
+
+class Scheduler : public QWidget, public Ui::Scheduler
+{
+ Q_OBJECT
+
+public:
+ Scheduler();
+ ~Scheduler();
+ int checkWeather();
+ void processSession(int i);
+
+public slots:
+ void selectSlot();
+ void addToTableSlot();
+ void removeTableSlot();
+ void setSequenceSlot();
+ void startSlot();
+ void saveSlot();
+
+private:
+ Ekos::Scheduler *ui;
+};
+}
+
+#endif // SCHEDULER_H
diff --git a/kstars/ekos/scheduler.ui b/kstars/ekos/scheduler.ui
new file mode 100644
index 0000000..23ac2bc
--- /dev/null
+++ b/kstars/ekos/scheduler.ui
@@ -0,0 +1,658 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<ui version="4.0">
+ <class>Scheduler</class>
+ <widget class="QWidget" name="Scheduler">
+ <property name="geometry">
+ <rect>
+ <x>0</x>
+ <y>0</y>
+ <width>772</width>
+ <height>503</height>
+ </rect>
+ </property>
+ <layout class="QVBoxLayout" name="verticalLayout_7">
+ <item>
+ <widget class="QGroupBox" name="groupBox">
+ <property name="title">
+ <string>1. Object &amp;&amp; Sequence Selection</string>
+ </property>
+ <layout class="QHBoxLayout" name="horizontalLayout_12">
+ <item>
+ <layout class="QVBoxLayout" name="verticalLayout_2">
+ <item>
+ <layout class="QFormLayout" name="formLayout">
+ <item row="0" column="0">
+ <widget class="QLabel" name="label_7">
+ <property name="text">
+ <string>Name:</string>
+ </property>
+ </widget>
+ </item>
+ <item row="0" column="1">
+ <widget class="QLineEdit" name="lineEdit_6"/>
+ </item>
+ <item row="1" column="0">
+ <widget class="QLabel" name="label">
+ <property name="text">
+ <string>RA (J2000):</string>
+ </property>
+ </widget>
+ </item>
+ <item row="1" column="1">
+ <widget class="QLineEdit" name="lineEdit"/>
+ </item>
+ <item row="2" column="0">
+ <widget class="QLabel" name="label_2">
+ <property name="text">
+ <string>DEC (J2000):</string>
+ </property>
+ </widget>
+ </item>
+ <item row="2" column="1">
+ <widget class="QLineEdit" name="lineEdit_2"/>
+ </item>
+ </layout>
+ </item>
+ <item>
+ <layout class="QHBoxLayout" name="horizontalLayout_2">
+ <item>
+ <widget class="QPushButton" name="SelectButton">
+ <property name="text">
+ <string>Select Object...</string>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QPushButton" name="AddButton_2">
+ <property name="text">
+ <string>Select FITS...</string>
+ </property>
+ </widget>
+ </item>
+ </layout>
+ </item>
+ <item>
+ <layout class="QHBoxLayout" name="horizontalLayout_3">
+ <item>
+ <widget class="QLabel" name="label_3">
+ <property name="text">
+ <string>Sequence:</string>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QLineEdit" name="lineEdit_3">
+ <property name="enabled">
+ <bool>true</bool>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QPushButton" name="AddButton_3">
+ <property name="text">
+ <string>Load Sequence...</string>
+ </property>
+ </widget>
+ </item>
+ </layout>
+ </item>
+ <item>
+ <layout class="QHBoxLayout" name="horizontalLayout_11">
+ <item>
+ <widget class="QLabel" name="label_4">
+ <property name="text">
+ <string>Modules:</string>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QCheckBox" name="checkBox_7">
+ <property name="text">
+ <string>Astrometry</string>
+ </property>
+ <property name="checked">
+ <bool>true</bool>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QCheckBox" name="checkBox_8">
+ <property name="text">
+ <string>Guide</string>
+ </property>
+ <property name="checked">
+ <bool>true</bool>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QCheckBox" name="checkBox_9">
+ <property name="text">
+ <string>Focus</string>
+ </property>
+ <property name="checked">
+ <bool>true</bool>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <spacer name="horizontalSpacer_9">
+ <property name="orientation">
+ <enum>Qt::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">
+ <enum>Qt::Vertical</enum>
+ </property>
+ <property name="sizeHint" stdset="0">
+ <size>
+ <width>20</width>
+ <height>40</height>
+ </size>
+ </property>
+ </spacer>
+ </item>
+ </layout>
+ </item>
+ <item>
+ <layout class="QVBoxLayout" name="verticalLayout">
+ <item>
+ <layout class="QHBoxLayout" name="horizontalLayout_14">
+ <item>
+ <widget class="QPushButton" name="addToQueueB">
+ <property name="enabled">
+ <bool>true</bool>
+ </property>
+ <property name="minimumSize">
+ <size>
+ <width>32</width>
+ <height>32</height>
+ </size>
+ </property>
+ <property name="maximumSize">
+ <size>
+ <width>32</width>
+ <height>32</height>
+ </size>
+ </property>
+ <property name="text">
+ <string>Add</string>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QPushButton" name="removeFromQueueB">
+ <property name="enabled">
+ <bool>true</bool>
+ </property>
+ <property name="minimumSize">
+ <size>
+ <width>32</width>
+ <height>32</height>
+ </size>
+ </property>
+ <property name="maximumSize">
+ <size>
+ <width>32</width>
+ <height>32</height>
+ </size>
+ </property>
+ <property name="text">
+ <string>Rem</string>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QPushButton" name="queueUpB">
+ <property name="enabled">
+ <bool>false</bool>
+ </property>
+ <property name="minimumSize">
+ <size>
+ <width>32</width>
+ <height>32</height>
+ </size>
+ </property>
+ <property name="maximumSize">
+ <size>
+ <width>32</width>
+ <height>32</height>
+ </size>
+ </property>
+ <property name="text">
+ <string/>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QPushButton" name="queueDownB">
+ <property name="enabled">
+ <bool>false</bool>
+ </property>
+ <property name="minimumSize">
+ <size>
+ <width>32</width>
+ <height>32</height>
+ </size>
+ </property>
+ <property name="maximumSize">
+ <size>
+ <width>32</width>
+ <height>32</height>
+ </size>
+ </property>
+ <property name="text">
+ <string/>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QPushButton" name="resetB">
+ <property name="enabled">
+ <bool>false</bool>
+ </property>
+ <property name="minimumSize">
+ <size>
+ <width>32</width>
+ <height>32</height>
+ </size>
+ </property>
+ <property name="maximumSize">
+ <size>
+ <width>32</width>
+ <height>32</height>
+ </size>
+ </property>
+ <property name="toolTip">
+ <string>Reset status of all jobs</string>
+ </property>
+ <property name="text">
+ <string/>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <spacer name="horizontalSpacer">
+ <property name="orientation">
+ <enum>Qt::Horizontal</enum>
+ </property>
+ <property name="sizeHint" stdset="0">
+ <size>
+ <width>40</width>
+ <height>20</height>
+ </size>
+ </property>
+ </spacer>
+ </item>
+ <item>
+ <widget class="QPushButton" name="queueLoadB">
+ <property name="minimumSize">
+ <size>
+ <width>32</width>
+ <height>32</height>
+ </size>
+ </property>
+ <property name="maximumSize">
+ <size>
+ <width>32</width>
+ <height>32</height>
+ </size>
+ </property>
+ <property name="text">
+ <string/>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QPushButton" name="queueSaveAsB">
+ <property name="enabled">
+ <bool>true</bool>
+ </property>
+ <property name="minimumSize">
+ <size>
+ <width>32</width>
+ <height>32</height>
+ </size>
+ </property>
+ <property name="maximumSize">
+ <size>
+ <width>32</width>
+ <height>32</height>
+ </size>
+ </property>
+ <property name="text">
+ <string>Save</string>
+ </property>
+ </widget>
+ </item>
+ </layout>
+ </item>
+ <item>
+ <widget class="QTableWidget" name="tableWidget">
+ <property name="rowCount">
+ <number>0</number>
+ </property>
+ <column>
+ <property name="text">
+ <string>Name</string>
+ </property>
+ </column>
+ <column>
+ <property name="text">
+ <string>Status</string>
+ </property>
+ </column>
+ <column>
+ <property name="text">
+ <string>Start Time</string>
+ </property>
+ </column>
+ <column>
+ <property name="text">
+ <string>End Time</string>
+ </property>
+ </column>
+ </widget>
+ </item>
+ </layout>
+ </item>
+ </layout>
+ <zorder></zorder>
+ </widget>
+ </item>
+ <item>
+ <layout class="QVBoxLayout" name="verticalLayout_6">
+ <item>
+ <layout class="QHBoxLayout" name="horizontalLayout_9">
+ <item>
+ <widget class="QGroupBox" name="groupBox_7">
+ <property name="title">
+ <string>2. Startup Conditions</string>
+ </property>
+ <layout class="QVBoxLayout" name="verticalLayout_3">
+ <item>
+ <widget class="QRadioButton" name="NowButton">
+ <property name="text">
+ <string>Now</string>
+ </property>
+ <property name="checked">
+ <bool>true</bool>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <layout class="QHBoxLayout" name="horizontalLayout_4">
+ <item>
+ <widget class="QRadioButton" name="OnButton">
+ <property name="text">
+ <string>On</string>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QDateTimeEdit" name="dateTimeEdit"/>
+ </item>
+ <item>
+ <spacer name="horizontalSpacer_3">
+ <property name="orientation">
+ <enum>Qt::Horizontal</enum>
+ </property>
+ <property name="sizeHint" stdset="0">
+ <size>
+ <width>40</width>
+ <height>20</height>
+ </size>
+ </property>
+ </spacer>
+ </item>
+ </layout>
+ </item>
+ <item>
+ <layout class="QHBoxLayout" name="horizontalLayout_5">
+ <item>
+ <widget class="QRadioButton" name="altButton">
+ <property name="text">
+ <string>When A&amp;lt &gt;</string>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QDoubleSpinBox" name="doubleSpinBox"/>
+ </item>
+ <item>
+ <spacer name="horizontalSpacer_4">
+ <property name="orientation">
+ <enum>Qt::Horizontal</enum>
+ </property>
+ <property name="sizeHint" stdset="0">
+ <size>
+ <width>40</width>
+ <height>20</height>
+ </size>
+ </property>
+ </spacer>
+ </item>
+ </layout>
+ </item>
+ </layout>
+ </widget>
+ </item>
+ <item>
+ <widget class="QGroupBox" name="groupBox_8">
+ <property name="title">
+ <string>3. Constraints</string>
+ </property>
+ <layout class="QVBoxLayout" name="verticalLayout_4">
+ <item>
+ <layout class="QHBoxLayout" name="horizontalLayout_6">
+ <item>
+ <widget class="QCheckBox" name="checkBox_4">
+ <property name="text">
+ <string>Alt &gt; </string>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QDoubleSpinBox" name="doubleSpinBox_2"/>
+ </item>
+ <item>
+ <spacer name="horizontalSpacer_5">
+ <property name="orientation">
+ <enum>Qt::Horizontal</enum>
+ </property>
+ <property name="sizeHint" stdset="0">
+ <size>
+ <width>40</width>
+ <height>20</height>
+ </size>
+ </property>
+ </spacer>
+ </item>
+ </layout>
+ </item>
+ <item>
+ <layout class="QHBoxLayout" name="horizontalLayout_7">
+ <item>
+ <widget class="QCheckBox" name="moonSepBox">
+ <property name="text">
+ <string>Moon Separation &gt; </string>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QDoubleSpinBox" name="doubleSpinBox_3"/>
+ </item>
+ <item>
+ <spacer name="horizontalSpacer_6">
+ <property name="orientation">
+ <enum>Qt::Horizontal</enum>
+ </property>
+ <property name="sizeHint" stdset="0">
+ <size>
+ <width>40</width>
+ <height>20</height>
+ </size>
+ </property>
+ </spacer>
+ </item>
+ </layout>
+ </item>
+ <item>
+ <widget class="QCheckBox" name="merFlipBox">
+ <property name="text">
+ <string>No Meridian Flip</string>
+ </property>
+ </widget>
+ </item>
+ </layout>
+ </widget>
+ </item>
+ <item>
+ <widget class="QGroupBox" name="groupBox_9">
+ <property name="title">
+ <string>4. Completion</string>
+ </property>
+ <layout class="QVBoxLayout" name="verticalLayout_5">
+ <item>
+ <widget class="QRadioButton" name="seqCompButton">
+ <property name="text">
+ <string>When Se&amp;quence is complete</string>
+ </property>
+ <property name="checked">
+ <bool>true</bool>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QRadioButton" name="loopButton">
+ <property name="text">
+ <string>Loop until ter&amp;minated</string>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <layout class="QHBoxLayout" name="horizontalLayout_8">
+ <item>
+ <widget class="QRadioButton" name="onFinButton">
+ <property name="text">
+ <string>On</string>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QDateTimeEdit" name="dateTimeEdit_2"/>
+ </item>
+ <item>
+ <spacer name="horizontalSpacer_7">
+ <property name="orientation">
+ <enum>Qt::Horizontal</enum>
+ </property>
+ <property name="sizeHint" stdset="0">
+ <size>
+ <width>40</width>
+ <height>20</height>
+ </size>
+ </property>
+ </spacer>
+ </item>
+ </layout>
+ </item>
+ </layout>
+ </widget>
+ </item>
+ </layout>
+ </item>
+ <item>
+ <widget class="QGroupBox" name="groupBox_10">
+ <property name="title">
+ <string>5. Shutdown</string>
+ </property>
+ <layout class="QHBoxLayout" name="horizontalLayout">
+ <item>
+ <widget class="QCheckBox" name="checkBox">
+ <property name="enabled">
+ <bool>false</bool>
+ </property>
+ <property name="text">
+ <string>Park Scope</string>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QCheckBox" name="checkBox_3">
+ <property name="enabled">
+ <bool>false</bool>
+ </property>
+ <property name="text">
+ <string>Warm up CCD</string>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QCheckBox" name="checkBox_2">
+ <property name="enabled">
+ <bool>false</bool>
+ </property>
+ <property name="text">
+ <string>Close Dome</string>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <spacer name="horizontalSpacer_8">
+ <property name="orientation">
+ <enum>Qt::Horizontal</enum>
+ </property>
+ <property name="sizeHint" stdset="0">
+ <size>
+ <width>40</width>
+ <height>20</height>
+ </size>
+ </property>
+ </spacer>
+ </item>
+ </layout>
+ </widget>
+ </item>
+ </layout>
+ </item>
+ <item>
+ <layout class="QHBoxLayout" name="horizontalLayout_10">
+ <item>
+ <widget class="QPushButton" name="startButton">
+ <property name="text">
+ <string>Start Scheduler</string>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <spacer name="horizontalSpacer_2">
+ <property name="orientation">
+ <enum>Qt::Horizontal</enum>
+ </property>
+ <property name="sizeHint" stdset="0">
+ <size>
+ <width>40</width>
+ <height>20</height>
+ </size>
+ </property>
+ </spacer>
+ </item>
+ </layout>
+ </item>
+ </layout>
+ </widget>
+ <resources/>
+ <connections/>
+</ui>