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

Moving functios to detect sequence completion to scheduler to better estimate...

Moving functios to detect sequence completion to scheduler to better estimate time and also start capture immediately if only calibraton frames are left in the queue
parent 0d00f76e
......@@ -48,6 +48,8 @@
#define MF_RA_DIFF_LIMIT 4
#define MAX_CAPTURE_RETRIES 3
#define SQ_FORMAT_VERSION 1.5
namespace Ekos
{
......@@ -58,7 +60,7 @@ Capture::Capture()
new CaptureAdaptor(this);
QDBusConnection::sessionBus().registerObject("/KStars/Ekos/Capture", this);
dirPath = QUrl(QDir::homePath());
dirPath = QUrl::fromLocalFile(QDir::homePath());
state = CAPTURE_IDLE;
focusState = FOCUS_IDLE;
......@@ -1257,7 +1259,10 @@ void Capture::captureImage()
}
if (currentCCD->getUploadMode() != ISD::CCD::UPLOAD_LOCAL)
{
checkSeqBoundary(activeJob->getFITSDir());
currentCCD->setNextSequenceID(nextSequenceID);
}
state = CAPTURE_CAPTURING;
......@@ -1340,31 +1345,14 @@ bool Capture::resumeCapture()
/*******************************************************************************/
void Capture::updateSequencePrefix( const QString &newPrefix, const QString &dir)
{
//static QString lastDir=QDir::homePath();
seqPrefix = newPrefix;
// If it doesn't exist, create it
QDir().mkpath(dir);
/*if (dir != lastDir)
{
seqWatcher->removeDir(lastDir);
lastDir = dir;
}
seqWatcher->addDir(dir, KDirWatch::WatchFiles);*/
nextSequenceID = 1;
//checkSeqBoundary(dir);
}
/*void Capture::checkSeqFile(const QString &path)
{
checkSeqBoundary(QFileInfo(path).absolutePath());
}*/
/*******************************************************************************/
/* Determine the next file number sequence. That is, if we have file1.png */
/* and file2.png, then the next sequence should be file3.png */
......@@ -1403,9 +1391,7 @@ void Capture::checkSeqBoundary(const QString &path)
nextSequenceID = newFileIndex + 1;
}
}
currentCCD->setNextSequenceID(nextSequenceID);
}
}
void Capture::appendLogText(const QString &text)
......@@ -1926,11 +1912,12 @@ void Capture::executeJob()
imgProgress->setValue(seqCurrentCount);
if (currentCCD->getUploadMode() != ISD::CCD::UPLOAD_LOCAL)
updateSequencePrefix(activeJob->getPrefix(), activeJob->getFITSDir());
updateSequencePrefix(activeJob->getFullPrefix(), activeJob->getFITSDir());
}
// 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)
//if (ignoreJobProgress == false && Options::rememberJobProgress() && activeJob->isPreview() == false)
if (ignoreJobProgress == false && activeJob->isPreview() == false)
{
checkSeqBoundary(activeJob->getFITSDir());
......@@ -1955,6 +1942,8 @@ void Capture::executeJob()
// Emit progress update
emit newImage(NULL, activeJob);
}
currentCCD->setNextSequenceID(nextSequenceID);
}
// Update button status
......@@ -2191,6 +2180,7 @@ bool Capture::loadSequenceQueue(const QString &fileURL)
queueTable->removeRow(0);
LilXML *xmlParser = newLilXML();
char errmsg[MAXRBUF];
XMLEle *root = NULL;
XMLEle *ep;
......@@ -2202,6 +2192,13 @@ bool Capture::loadSequenceQueue(const QString &fileURL)
if (root)
{
double sqVersion= atof(findXMLAttValu(root, "version"));
if (sqVersion < SQ_FORMAT_VERSION)
{
appendLogText(i18n("Deprecated sequence file format version %1. Please construct a new sequence file.", sqVersion));
return false;
}
for (ep = nextXMLEle(root, 1) ; ep != NULL ; ep = nextXMLEle(root, 0))
{
if (!strcmp(tagXMLEle(ep), "GuideDeviation"))
......@@ -2264,8 +2261,7 @@ bool Capture::loadSequenceQueue(const QString &fileURL)
mDirty = false;
delLilXML(xmlParser);
if (Options::rememberJobProgress())
ignoreJobProgress = false;
ignoreJobProgress = !(Options::rememberJobProgress());
return true;
......@@ -2319,7 +2315,8 @@ bool Capture::processJobInfo(XMLEle *root)
}
else if (!strcmp(tagXMLEle(ep), "Filter"))
{
FilterPosCombo->setCurrentIndex(atoi(pcdataXMLEle(ep))-1);
//FilterPosCombo->setCurrentIndex(atoi(pcdataXMLEle(ep))-1);
FilterPosCombo->setCurrentText(pcdataXMLEle(ep));
}
else if (!strcmp(tagXMLEle(ep), "Type"))
{
......@@ -2523,7 +2520,7 @@ bool Capture::saveSequenceQueue(const QString &path)
QTextStream outstream(&file);
outstream << "<?xml version=\"1.0\" encoding=\"UTF-8\"?>" << endl;
outstream << "<SequenceQueue version='1.4'>" << endl;
outstream << "<SequenceQueue version='" << SQ_FORMAT_VERSION << "'>" << endl;
outstream << "<GuideDeviation enabled='" << (guideDeviationCheck->isChecked() ? "true" : "false") << "'>" << guideDeviation->value() << "</GuideDeviation>" << endl;
outstream << "<Autofocus enabled='" << (autofocusCheck->isChecked() ? "true" : "false") << "'>" << HFRPixels->value() << "</Autofocus>" << endl;
outstream << "<MeridianFlip enabled='" << (meridianCheck->isChecked() ? "true" : "false") << "'>" << meridianHours->value() << "</MeridianFlip>" << endl;
......@@ -2547,7 +2544,8 @@ bool Capture::saveSequenceQueue(const QString &path)
if (job->getTargetTemperature() != INVALID_TEMPERATURE)
outstream << "<Temperature force='" << (job->getEnforceTemperature() ? "true":"false") << "'>" << job->getTargetTemperature() << "</Temperature>" << endl;
if (job->getTargetFilter() >= 0)
outstream << "<Filter>" << job->getTargetFilter() << "</Filter>" << endl;
//outstream << "<Filter>" << job->getTargetFilter() << "</Filter>" << endl;
outstream << "<Filter>" << job->getFilterName() << "</Filter>" << endl;
outstream << "<Type>" << frameTypeCombo->itemText(job->getFrameType()) << "</Type>" << endl;
outstream << "<Prefix>" << endl;
//outstream << "<CompletePrefix>" << job->getPrefix() << "</CompletePrefix>" << endl;
......@@ -3847,61 +3845,6 @@ bool Capture::processPostCaptureCalibrationStage()
return true;
}
bool Capture::isSequenceFileComplete(const QString &fileURL)
{
// If we don't remember job progress, then no sequence would be complete
if (Options::rememberJobProgress() == false)
return false;
// We cannot know if the job is complete if the upload mode is local since we cannot inspect the files
if (currentCCD && currentCCD->getUploadMode() == ISD::CCD::UPLOAD_LOCAL)
return false;
if (Options::captureLogging())
{
qDebug() << "Capture: Loading sequence to check for completion: " << fileURL;
}
bool rc = loadSequenceQueue(fileURL);
if (rc == false)
return false;
ignoreJobProgress = false;
QStringList jobDirs;
int totalJobCount = 0, totalFileCount=0;
foreach(SequenceJob *job, jobs)
{
jobDirs << job->getFITSDir();
totalJobCount += job->getCount();
}
jobDirs.removeDuplicates();
if (Options::captureLogging())
{
qDebug() << "Capture: Total Job Count --> " << totalFileCount;
qDebug() << "Capture: isSequenceFileComplete directories --> " << jobDirs;
}
foreach(QString dir, jobDirs)
{
QDir oneDir(dir);
oneDir.setFilter(QDir::Files | QDir::NoDotAndDotDot);
totalFileCount += oneDir.count();
if (Options::captureLogging())
{
qDebug() << "Capture: Directory " << dir << " file count is " << oneDir.count() << " and total count is " << totalFileCount;
}
}
clearSequenceQueue();
return (totalFileCount >= totalJobCount);
}
void Capture::setNewRemoteFile(QString file)
{
appendLogText(i18n("Remote image saved to %1", file));
......
......@@ -116,13 +116,7 @@ public:
* Returns the overall sequence queue status. If there are no jobs pending, it returns "Invalid". If all jobs are idle, it returns "Idle". If all jobs are complete, it returns "Complete". If one or more jobs are aborted
* it returns "Aborted" unless it was temporarily aborted due to guiding deviations, then it would return "Suspended". If one or more jobs have errors, it returns "Error". If any jobs is under progress, returns "Running".
*/
Q_SCRIPTABLE QString getSequenceQueueStatus();
/** DBUS interface function.
* 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 QString &fileURL);
Q_SCRIPTABLE QString getSequenceQueueStatus();
/** DBUS interface function.
* Loads the Ekos Sequence Queue file in the Sequence Queue. Jobs are appended to existing jobs.
......
......@@ -240,22 +240,22 @@ void SequenceJob::setExposeLeft(double value)
exposeLeft = value;
}
void SequenceJob::setPrefixSettings(const QString &prefix, bool filterEnabled, bool exposureEnabled, bool tsEnabled)
void SequenceJob::setPrefixSettings(const QString &rawFilePrefix, bool filterEnabled, bool exposureEnabled, bool tsEnabled)
{
rawPrefix = prefix;
rawPrefix = rawFilePrefix;
filterPrefixEnabled = filterEnabled;
expPrefixEnabled = exposureEnabled;
timeStampPrefixEnabled = tsEnabled;
timeStampPrefixEnabled = tsEnabled;
}
void SequenceJob::getPrefixSettings(QString &prefix, bool &filterEnabled, bool &exposureEnabled, bool &tsEnabled)
void SequenceJob::getPrefixSettings(QString &rawFilePrefix, bool &filterEnabled, bool &exposureEnabled, bool &tsEnabled)
{
prefix = rawPrefix;
rawFilePrefix = rawPrefix;
filterEnabled = filterPrefixEnabled;
exposureEnabled = expPrefixEnabled;
tsEnabled = timeStampPrefixEnabled;
}
double SequenceJob::getCurrentTemperature() const
{
return currentTemperature;
......
......@@ -47,8 +47,7 @@ class SequenceJob : public QObject
bool isPreview() { return preview;}
int getDelay() { return delay;}
int getCount() { return count;}
unsigned int getCompleted() { return completed; }
const QString & getPrefix() { return fullPrefix;}
unsigned int getCompleted() { return completed; }
const QString & getRawPrefix() { return rawPrefix;}
double getExposure() const { return exposure;}
......@@ -79,6 +78,7 @@ class SequenceJob : public QObject
void setPreview(bool enable) { preview = enable; }
void setFullPrefix(const QString &cprefix) { fullPrefix = cprefix;}
const QString & getFullPrefix() { return fullPrefix;}
void setFrame(int in_x, int in_y, int in_w, int in_h) { x=in_x; y=in_y; w=in_w; h=in_h; }
int getSubX() { return x;}
......@@ -101,8 +101,9 @@ class SequenceJob : public QObject
double getExposeLeft() const;
void setExposeLeft(double value);
void resetStatus();
void setPrefixSettings(const QString &fullPrefix, bool filterEnabled, bool exposureEnabled, bool tsEnabled);
void getPrefixSettings(QString &fullPrefix, bool &filterEnabled, bool &exposureEnabled, bool &tsEnabled);
void setPrefixSettings(const QString &rawFilePrefix, bool filterEnabled, bool exposureEnabled, bool tsEnabled);
void getPrefixSettings(QString &rawFilePrefix, bool &filterEnabled, bool &exposureEnabled, bool &tsEnabled);
bool isFilterPrefixEnabled() { return filterPrefixEnabled; }
bool isExposurePrefixEnabled() { return expPrefixEnabled; }
......
......@@ -1909,7 +1909,7 @@ void EkosManager::updateCaptureProgress(QImage *image, Ekos::SequenceJob *job)
// Image is set to NULL only on initial capture start up
int completed = (image == NULL) ? job->getCompleted() : job->getCompleted()+1;
sequenceLabel->setText(QString("Job # %1/%2 %3 (%4/%5)").arg(captureProcess->getActiveJobID()+1).arg(captureProcess->getJobCount()).arg(job->getPrefix()).arg(completed).arg(job->getCount()));
sequenceLabel->setText(QString("Job # %1/%2 %3 (%4/%5)").arg(captureProcess->getActiveJobID()+1).arg(captureProcess->getJobCount()).arg(job->getFullPrefix()).arg(completed).arg(job->getCount()));
sequenceProgress->setRange(0, job->getCount());
sequenceProgress->setValue(completed);
}
......
This diff is collapsed.
......@@ -30,6 +30,8 @@ class SkyObject;
namespace Ekos
{
class SequenceJob;
/**
* @brief The Ekos scheduler is a simple scheduler class to orchestrate automated multi object observation jobs.
* @author Jasem Mutlaq
......@@ -470,8 +472,7 @@ private:
* @param job target job
* @return Estimated time in seconds.
*/
bool estimateJobTime(SchedulerJob *job);
double estimateSequenceTime(XMLEle *root, int *totalCount);
bool estimateJobTime(SchedulerJob *schedJob);
/**
* @brief createJobSequence Creates a job sequence for the mosaic tool given the prefix and output dir. The currently selected sequence file is modified
......@@ -488,6 +489,10 @@ private:
bool isWeatherOK(SchedulerJob *job);
SequenceJob * processJobInfo(XMLEle *root, SchedulerJob *schedJob);
bool loadSequenceQueue(const QString &fileURL, SchedulerJob *schedJob, QList<SequenceJob*> &jobs, bool &hasAutoFocus);
int getCompletedFiles(const QString &path, const QString &seqPrefix);
Ekos::Scheduler *ui;
//DBus interfaces
......
......@@ -414,6 +414,16 @@ void SchedulerJob::setEstimatedTimeCell(QTableWidgetItem *value)
estimatedTimeCell = value;
}
bool SchedulerJob::getLightFramesRequired() const
{
return lightFramesRequired;
}
void SchedulerJob::setLightFramesRequired(bool value)
{
lightFramesRequired = value;
}
void SchedulerJob::setTargetCoords(dms ra, dms dec)
......
......@@ -75,9 +75,6 @@ public:
JOBStatus getState() const;
void setState(const JOBStatus &value);
//FITSStatus getFITSState() const;
//void setFITSState(const FITSStatus &value);
int getScore() const;
void setScore(int value);
......@@ -116,12 +113,14 @@ public:
QTableWidgetItem *getEstimatedTimeCell() const;
void setEstimatedTimeCell(QTableWidgetItem *value);
bool getLightFramesRequired() const;
void setLightFramesRequired(bool value);
private:
QString name;
SkyPoint targetCoords;
JOBStatus state;
//FITSStatus fitsState;
JOBStage stage;
......@@ -156,7 +155,7 @@ private:
QString dateTimeDisplayFormat;
QString profile;
bool lightFramesRequired = false;
};
#endif // SchedulerJob_H
......@@ -23,11 +23,7 @@
<method name="loadSequenceQueue">
<arg type="b" direction="out"/>
<arg name="fileURL" type="s" direction="in"/>
</method>
<method name="isSequenceFileComplete">
<arg type="b" direction="out"/>
<arg name="fileURL" type="s" direction="in"/>
</method>
</method>
<method name="clearSequenceQueue">
<annotation name="org.freedesktop.DBus.Method.NoReply" value="true"/>
</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