Commit d3268221 authored by Jasem Mutlaq's avatar Jasem Mutlaq
Browse files

Setting DBus calls to QString since using QUrl is not supported. Fixing check...

Setting DBus calls to QString since using QUrl is not supported. Fixing check of sequence file completion and resumption.
parent 2dee1dd1
......@@ -54,7 +54,7 @@ Align::Align()
new AlignAdaptor(this);
QDBusConnection::sessionBus().registerObject("/KStars/Ekos/Align", this);
dirPath = QUrl(QDir::homePath());
dirPath = QDir::homePath();
currentCCD = NULL;
currentTelescope = NULL;
......@@ -1664,28 +1664,27 @@ void Align::getFormattedCoords(double ra, double dec, QString &ra_str, QString &
dec_str = QString("%1:%2:%3").arg(dec_s.degree(), 2, 10, QChar('0')).arg(dec_s.arcmin(), 2, 10, QChar('0')).arg(dec_s.arcsec(), 2, 10, QChar('0'));
}
void Align::loadAndSlew(QUrl fileURL)
void Align::loadAndSlew(QString fileURL)
{
if (fileURL.isEmpty())
fileURL = QFileDialog::getOpenFileUrl(KStars::Instance(), i18n("Load Image"), dirPath, "Images (*.fits *.fit *.jpg *.jpeg)");
fileURL = QFileDialog::getOpenFileName(KStars::Instance(), i18n("Load Image"), dirPath, "Images (*.fits *.fit *.jpg *.jpeg)");
if (fileURL.isEmpty())
return;
dirPath = QUrl(fileURL.url(QUrl::RemoveFilename));
QFileInfo fileInfo(fileURL);
dirPath = fileInfo.absolutePath();
loadSlewMode = true;
loadSlewState=IPS_BUSY;
slewR->setChecked(true);
//loadSlewIterations = loadSlewIterationsSpin->value();
solveB->setEnabled(false);
stopB->setEnabled(true);
pi->startAnimation();
startSovling(fileURL.path(), false);
startSovling(fileURL, false);
}
void Align::setExposure(double value)
......
......@@ -278,7 +278,7 @@ public slots:
* the telescope is pointing to the same coordinates of the image.
* @param fileURL URL to the image to solve
*/
Q_SCRIPTABLE Q_NOREPLY void loadAndSlew(QUrl fileURL = QUrl());
Q_SCRIPTABLE Q_NOREPLY void loadAndSlew(QString fileURL = QString());
void setLockedFilter(ISD::GDInterface *filter, int lockedPosition);
......@@ -454,7 +454,7 @@ private:
// Track which upload mode the CCD is set to. If set to UPLOAD_LOCAL, then we need to switch it to UPLOAD_CLIENT in order to do focusing, and then switch it back to UPLOAD_LOCAL
ISD::CCD::UploadMode rememberUploadMode;
QUrl dirPath;
QString dirPath;
// Dark Frame
int calibrationState;
......
......@@ -1610,23 +1610,28 @@ void Capture::executeJob()
}
// We check if the job is already fully or partially complete by checking how many files of its type exist on the file system unless ignoreJobProgress is set to true
if (ignoreJobProgress == false && Options::rememberJobProgress() && activeJob->isPreview() == false && seqFileCount > 0)
if (ignoreJobProgress == false && Options::rememberJobProgress() && activeJob->isPreview() == false)
{
// Fully complete
if (seqFileCount >= seqTotalCount)
checkSeqBoundary(activeJob->getFITSDir());
if (seqFileCount > 0)
{
seqCurrentCount=seqTotalCount;
// Fully complete
if (seqFileCount >= seqTotalCount)
{
seqCurrentCount=seqTotalCount;
activeJob->setCompleted(seqCurrentCount);
imgProgress->setValue(seqCurrentCount);
processJobCompletion();
return;
}
// Partially complete
seqCurrentCount=seqFileCount;
activeJob->setCompleted(seqCurrentCount);
currentImgCountOUT->setText( QString::number(seqCurrentCount));
imgProgress->setValue(seqCurrentCount);
processJobCompletion();
return;
}
// Partially complete
seqCurrentCount=seqFileCount;
activeJob->setCompleted(seqCurrentCount);
currentImgCountOUT->setText( QString::number(seqCurrentCount));
imgProgress->setValue(seqCurrentCount);
}
// Update button status
......@@ -1857,16 +1862,18 @@ void Capture::loadSequenceQueue()
dirPath = QUrl(fileURL.url(QUrl::RemoveFilename));
loadSequenceQueue(fileURL.path());
}
bool Capture::loadSequenceQueue(const QUrl &fileURL)
bool Capture::loadSequenceQueue(const QString &fileURL)
{
QFile sFile;
sFile.setFileName(fileURL.path());
sFile.setFileName(fileURL);
if ( !sFile.open( QIODevice::ReadOnly))
{
QString message = i18n( "Unable to open file %1", fileURL.path());
QString message = i18n( "Unable to open file %1", fileURL);
KMessageBox::sorry( 0, message, i18n( "Could Not Open File" ) );
return false;
}
......@@ -1956,7 +1963,7 @@ bool Capture::loadSequenceQueue(const QUrl &fileURL)
}
}
sequenceURL = fileURL;
sequenceURL = QUrl::fromLocalFile(fileURL);
mDirty = false;
delLilXML(xmlParser);
......@@ -3296,7 +3303,7 @@ bool Capture::processPostCaptureCalibrationStage()
return true;
}
bool Capture::isSequenceFileComplete(const QUrl &fileURL)
bool Capture::isSequenceFileComplete(const QString &fileURL)
{
// If we don't remember job progress, then no sequence would be complete
if (Options::rememberJobProgress() == false)
......@@ -3313,27 +3320,26 @@ bool Capture::isSequenceFileComplete(const QUrl &fileURL)
if (currentCCD && currentCCD->getUploadMode() == ISD::CCD::UPLOAD_LOCAL)
return false;
QString prevFITSDir, prevPrefix;
QStringList jobDirs;
int totalJobCount = 0, totalFileCount=0;
foreach(SequenceJob *job, jobs)
{
updateSequencePrefix(job->getPrefix(), job->getFITSDir());
jobDirs << job->getFITSDir();
totalJobCount += job->getCount();
}
// We only count files if prefix or directory is different
// Otherwise there is no way to distinguish among files
if (job->getPrefix() != prevPrefix || job->getFITSDir() != prevFITSDir)
{
totalFileCount += seqFileCount;
prevPrefix = job->getPrefix();
prevFITSDir= job->getFITSDir();
}
jobDirs.removeDuplicates();
foreach(QString dir, jobDirs)
{
QDir oneDir(dir);
oneDir.setFilter(QDir::Files | QDir::NoDotAndDotDot);
totalFileCount += oneDir.count();
}
clearSequenceQueue();
return (totalJobCount == totalFileCount);
return (totalFileCount >= totalJobCount);
}
bool Capture::isFITSDirUnique(SequenceJob *job)
......
......@@ -120,13 +120,13 @@ public:
* Opens a sequence files and checks whether the jobs contained within are complete or not. The check is done by quering the file system for the produced files for each job.
* If returns true if all jobs are complete, false otherwise.sudo
*/
Q_SCRIPTABLE bool isSequenceFileComplete(const QUrl &fileURL);
Q_SCRIPTABLE bool isSequenceFileComplete(const QString &fileURL);
/** DBUS interface function.
* Loads the Ekos Sequence Queue file in the Sequence Queue. Jobs are appended to existing jobs.
* @param fileURL full URL of the filename
*/
Q_SCRIPTABLE bool loadSequenceQueue(const QUrl &fileURL);
Q_SCRIPTABLE bool loadSequenceQueue(const QString &fileURL);
/** DBUS interface function.
* Enables or disables the maximum guiding deviation and sets its value.
......
......@@ -1105,7 +1105,7 @@ void Scheduler::evaluateJobs()
// If time is far in the future, we make the score negative
else
{
if (calculateJobScore(job, job->getStartupTime()) < 0)
if (job->getState() == SchedulerJob::JOB_EVALUATION && calculateJobScore(job, job->getStartupTime()) < 0)
{
appendLogText(i18n("%1 observation job evaluation failed with a score of %2. Aborting job...", job->getName(), score));
job->setState(SchedulerJob::JOB_INVALID);
......@@ -2934,18 +2934,19 @@ void Scheduler::load()
return;
}
loadScheduler(fileURL);
dirPath = QUrl(fileURL.url(QUrl::RemoveFilename));
loadScheduler(fileURL.path());
}
bool Scheduler::loadScheduler(const QUrl & fileURL)
bool Scheduler::loadScheduler(const QString &fileURL)
{
QFile sFile;
sFile.setFileName(fileURL.path());
sFile.setFileName(fileURL);
if ( !sFile.open( QIODevice::ReadOnly))
{
QString message = i18n( "Unable to open file %1", fileURL.path());
QString message = i18n( "Unable to open file %1", fileURL);
KMessageBox::sorry( 0, message, i18n( "Could Not Open File" ) );
return false;
}
......@@ -2988,7 +2989,10 @@ bool Scheduler::loadScheduler(const QUrl & fileURL)
const char *proc = pcdataXMLEle(procedure);
if (!strcmp(proc, "StartupScript"))
{
startupScript->setText(findXMLAttValu(procedure, "value"));
startupScriptURL = QUrl::fromUserInput(startupScript->text());
}
else if (!strcmp(proc, "UnparkDome"))
unparkDomeCheck->setChecked(true);
else if (!strcmp(proc, "UnparkMount"))
......@@ -3011,7 +3015,10 @@ bool Scheduler::loadScheduler(const QUrl & fileURL)
const char *proc = pcdataXMLEle(procedure);
if (!strcmp(proc, "ShutdownScript"))
{
shutdownScript->setText(findXMLAttValu(procedure, "value"));
shutdownScriptURL = QUrl::fromUserInput(shutdownScript->text());
}
else if (!strcmp(proc, "ParkDome"))
parkDomeCheck->setChecked(true);
else if (!strcmp(proc, "ParkMount"))
......@@ -3033,7 +3040,7 @@ bool Scheduler::loadScheduler(const QUrl & fileURL)
}
}
schedulerURL = fileURL;
schedulerURL = QUrl::fromLocalFile(fileURL);
mosaicB->setEnabled(true);
mDirty = false;
delLilXML(xmlParser);
......@@ -3569,7 +3576,7 @@ void Scheduler::startCapture()
{
captureInterface->call(QDBus::AutoDetect,"clearSequenceQueue");
QString url = currentJob->getSequenceFile().toString(QUrl::PreferLocalFile);
QString url = currentJob->getSequenceFile().path();
QList<QVariant> dbusargs;
dbusargs.append(url);
......
......@@ -134,7 +134,7 @@ public:
* @param fileURL path to a file
* @return true if loading file is successful, false otherwise.
*/
Q_SCRIPTABLE bool loadScheduler(const QUrl &fileURL);
Q_SCRIPTABLE bool loadScheduler(const QString &fileURL);
/** DBUS interface function.
* @brief Resets all jobs to IDLE
......
......@@ -12,8 +12,7 @@
<arg type="b" direction="out"/>
</method>
<method name="loadAndSlew">
<arg name="fileURL" type="QUrl" direction="in"/>
<annotation name="org.qtproject.QtDBus.QtTypeName.In0" value="QUrl"/>
<arg name="fileURL" type="s" direction="in"/>
<annotation name="org.freedesktop.DBus.Method.NoReply" value="true"/>
</method>
<method name="setCCD">
......
......@@ -18,13 +18,11 @@
</method>
<method name="loadSequenceQueue">
<arg type="b" direction="out"/>
<arg name="fileURL" type="QUrl" direction="in"/>
<annotation name="org.qtproject.QtDBus.QtTypeName.In0" value="QUrl"/>
<arg name="fileURL" type="s" direction="in"/>
</method>
<method name="isSequenceFileComplete">
<arg type="b" direction="out"/>
<arg name="fileURL" type="QUrl" direction="in"/>
<annotation name="org.qtproject.QtDBus.QtTypeName.In0" value="QUrl"/>
<arg name="fileURL" type="s" direction="in"/>
</method>
<method name="clearSequenceQueue">
<annotation name="org.freedesktop.DBus.Method.NoReply" value="true"/>
......
......@@ -8,7 +8,7 @@
<annotation name="org.freedesktop.DBus.Method.NoReply" value="true"/>
</method>
<method name="loadScheduler">
<arg name="fileURL" type="QUrl" direction="in"/>
<arg name="fileURL" type="s" direction="in"/>
<arg type="b" direction="out"/>
<annotation name="org.qtproject.QtDBus.QtTypeName.In0" value="QUrl"/>
</method>
......
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