Commit f9ca2d3a authored by Jasem Mutlaq's avatar Jasem Mutlaq

Add either filter or sequence number as subdirectory under image type

parent 3e44c69f
......@@ -301,6 +301,13 @@ void Capture::start()
initialHA = getCurrentHA();
meridianFlipStage = MF_NONE;
// Check if we need to update the sequence directory numbers before starting
for (int i=0; i < jobs.count(); i++)
{
if (jobs.at(i)->getFITSDir().endsWith("Sequence_"))
jobs.at(i)->setFITSDir(QString("%1%2").arg(jobs.at(i)->getFITSDir()).arg(i));
}
prepareJob(first_job);
}
......@@ -1227,9 +1234,6 @@ void Capture::addJob(bool preview)
job->setCaptureFilter((FITSScale) filterCombo->currentIndex());
if (preview == false)
job->setFITSDir(preview ? fitsDir->text() : fitsDir->text() + "/" + frameTypeCombo->currentText());
job->setFlatFieldDuration(flatFieldDuration);
job->setFlatFieldSource(flatFieldSource);
job->setPreMountPark(preMountPark);
......@@ -1241,9 +1245,9 @@ void Capture::addJob(bool preview)
constructPrefix(imagePrefix);
job->setPrefixSettings(prefixIN->text(), frameTypeCheck->isChecked(), filterCheck->isChecked(), expDurationCheck->isChecked(), ISOCheck->isChecked());
job->setPrefixSettings(prefixIN->text(), filterCheck->isChecked(), expDurationCheck->isChecked(), ISOCheck->isChecked());
job->setFrameType(frameTypeCombo->currentIndex(), frameTypeCombo->currentText());
job->setPrefix(imagePrefix);
job->setFullPrefix(imagePrefix);
if (filterSlot != NULL && currentFilter != NULL)
job->setTargetFilter(FilterPosCombo->currentIndex()+1, FilterPosCombo->currentText());
......@@ -1262,12 +1266,24 @@ void Capture::addJob(bool preview)
job->setFrame(frameXIN->value(), frameYIN->value(), frameWIN->value(), frameHIN->value());
// Nothing more to do if preview
if (preview)
return;
if (jobUnderEdit == false)
{
jobs.append(job);
// Nothing more to do if preview
if (preview)
return;
job->setRootFITSDir(fitsDir->text());
QString finalFITSDir = fitsDir->text() + QDir::separator() + frameTypeCombo->currentText();
if (job->getFilterName().isEmpty() == false)
finalFITSDir += QDir::separator() + job->getFilterName();
else
finalFITSDir += QDir::separator() + "Sequence_";
job->setFITSDir(finalFITSDir);
}
int currentRow = 0;
if (jobUnderEdit == false)
......@@ -1947,9 +1963,6 @@ bool Capture::processJobInfo(XMLEle *root)
subEP = findXMLEle(ep, "RawPrefix");
if (subEP)
prefixIN->setText(pcdataXMLEle(subEP));
subEP = findXMLEle(ep, "TypeEnabled");
if (subEP)
frameTypeCheck->setChecked( !strcmp("1", pcdataXMLEle(subEP)));
subEP = findXMLEle(ep, "FilterEnabled");
if (subEP)
filterCheck->setChecked( !strcmp("1", pcdataXMLEle(subEP)));
......@@ -2115,7 +2128,7 @@ bool Capture::saveSequenceQueue(const QString &path)
{
QFile file;
QString rawPrefix;
bool typeEnabled, filterEnabled, expEnabled, tsEnabled;
bool filterEnabled, expEnabled, tsEnabled;
file.setFileName(path);
......@@ -2136,7 +2149,7 @@ bool Capture::saveSequenceQueue(const QString &path)
outstream << "<Park enabled='" << (parkCheck->isChecked() ? "true" : "false") << "'></Park>" << endl;
foreach(SequenceJob *job, jobs)
{
job->getPrefixSettings(rawPrefix, typeEnabled, filterEnabled, expEnabled, tsEnabled);
job->getPrefixSettings(rawPrefix, filterEnabled, expEnabled, tsEnabled);
outstream << "<Job>" << endl;
......@@ -2157,8 +2170,7 @@ bool Capture::saveSequenceQueue(const QString &path)
outstream << "<Type>" << frameTypeCombo->itemText(job->getFrameType()) << "</Type>" << endl;
outstream << "<Prefix>" << endl;
//outstream << "<CompletePrefix>" << job->getPrefix() << "</CompletePrefix>" << endl;
outstream << "<RawPrefix>" << rawPrefix << "</RawPrefix>" << endl;
outstream << "<TypeEnabled>" << (typeEnabled ? 1 : 0) << "</TypeEnabled>" << endl;
outstream << "<RawPrefix>" << rawPrefix << "</RawPrefix>" << endl;
outstream << "<FilterEnabled>" << (filterEnabled ? 1 : 0) << "</FilterEnabled>" << endl;
outstream << "<ExpEnabled>" << (expEnabled ? 1 : 0) << "</ExpEnabled>" << endl;
outstream << "<TimeStampEnabled>" << (tsEnabled ? 1 : 0) << "</TimeStampEnabled>" << endl;
......@@ -2166,8 +2178,7 @@ bool Capture::saveSequenceQueue(const QString &path)
outstream << "<Count>" << job->getCount() << "</Count>" << endl;
// ms to seconds
outstream << "<Delay>" << job->getDelay()/1000 << "</Delay>" << endl;
QString rootDir = job->getFITSDir();
rootDir = rootDir.remove(QString("/%1").arg(frameTypeCombo->itemText(job->getFrameType())));
QString rootDir = job->getRootFITSDir();
outstream << "<FITSDirectory>" << rootDir << "</FITSDirectory>" << endl;
if (job->getISOIndex() != -1)
outstream << "<ISOIndex>" << (job->getISOIndex()) << "</ISOIndex>" << endl;
......@@ -2238,9 +2249,9 @@ void Capture::ignoreSequenceHistory()
void Capture::syncGUIToJob(SequenceJob *job)
{
QString rawPrefix;
bool typeEnabled, filterEnabled, expEnabled, tsEnabled;
bool filterEnabled, expEnabled, tsEnabled;
job->getPrefixSettings(rawPrefix, typeEnabled, filterEnabled, expEnabled, tsEnabled);
job->getPrefixSettings(rawPrefix, filterEnabled, expEnabled, tsEnabled);
exposureIN->setValue(job->getExposure());
binXIN->setValue(job->getXBin());
......@@ -2252,7 +2263,6 @@ void Capture::syncGUIToJob(SequenceJob *job)
FilterPosCombo->setCurrentIndex(job->getTargetFilter()-1);
frameTypeCombo->setCurrentIndex(job->getFrameType());
prefixIN->setText(rawPrefix);
frameTypeCheck->setChecked(typeEnabled);
filterCheck->setChecked(filterEnabled);
expDurationCheck->setChecked(expEnabled);
ISOCheck->setChecked(tsEnabled);
......@@ -2271,7 +2281,7 @@ void Capture::syncGUIToJob(SequenceJob *job)
preMountPark = job->isPreMountPark();
preDomePark = job->isPreDomePark();
QString rootDir = job->getFITSDir();
QString rootDir = job->getRootFITSDir();
rootDir = rootDir.remove(QString("/%1").arg(frameTypeCombo->currentText()));
fitsDir->setText(rootDir);
......@@ -2312,26 +2322,25 @@ void Capture::resetJobEdit()
void Capture::constructPrefix(QString &imagePrefix)
{
if (frameTypeCheck->isChecked())
{
if (imagePrefix.isEmpty() == false)
imagePrefix += '_';
imagePrefix += frameTypeCombo->currentText();
}
if (imagePrefix.isEmpty() == false)
imagePrefix += '_';
imagePrefix += frameTypeCombo->currentText();
if (filterCheck->isChecked() && FilterPosCombo->currentText().isEmpty() == false &&
frameTypeCombo->currentText().compare("Bias", Qt::CaseInsensitive) &&
frameTypeCombo->currentText().compare("Dark", Qt::CaseInsensitive))
frameTypeCombo->currentText().compare("Dark", Qt::CaseInsensitive))
{
if (imagePrefix.isEmpty() == false || frameTypeCheck->isChecked())
imagePrefix += '_';
//if (imagePrefix.isEmpty() == false || frameTypeCheck->isChecked())
imagePrefix += '_';
imagePrefix += FilterPosCombo->currentText();
}
if (expDurationCheck->isChecked())
{
if (imagePrefix.isEmpty() == false || frameTypeCheck->isChecked())
imagePrefix += '_';
//if (imagePrefix.isEmpty() == false || frameTypeCheck->isChecked())
imagePrefix += '_';
imagePrefix += QString::number(exposureIN->value(), 'd', 0) + QString("_secs");
}
......@@ -3233,20 +3242,27 @@ bool Capture::isSequenceFileComplete(const QUrl &fileURL)
if (currentCCD && currentCCD->getUploadMode() == ISD::CCD::UPLOAD_LOCAL)
return false;
QString prevFITSDir, prevPrefix;
int totalJobCount = 0, totalFileCount=0;
foreach(SequenceJob *job, jobs)
{
updateSequencePrefix(job->getPrefix(), job->getFITSDir());
if (seqFileCount < job->getCount())
{
clearSequenceQueue();
return false;
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();
}
}
clearSequenceQueue();
return true;
return (totalJobCount == totalFileCount);
}
bool Capture::isFITSDirUnique(SequenceJob *job)
......
......@@ -513,19 +513,6 @@
</item>
<item row="5" column="2" colspan="2">
<layout class="QHBoxLayout" name="horizontalLayout_16">
<item>
<widget class="QCheckBox" name="frameTypeCheck">
<property name="toolTip">
<string>Append the active CCD frame type to the prefix</string>
</property>
<property name="text">
<string>Type</string>
</property>
<property name="checked">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<widget class="QCheckBox" name="filterCheck">
<property name="toolTip">
......@@ -559,6 +546,19 @@
</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>
<item row="6" column="1">
......
......@@ -102,7 +102,7 @@ void SequenceJob::prepareCapture()
activeCCD->setISOMode(timeStampPrefixEnabled);
activeCCD->setSeqPrefix(prefix);
activeCCD->setSeqPrefix(fullPrefix);
if (activeChip->isBatchMode())
activeCCD->updateUploadSettings();
......@@ -232,19 +232,18 @@ void SequenceJob::setExposeLeft(double value)
exposeLeft = value;
}
void SequenceJob::setPrefixSettings(const QString &prefix, bool typeEnabled, bool filterEnabled, bool exposureEnabled, bool tsEnabled)
void SequenceJob::setPrefixSettings(const QString &prefix, bool filterEnabled, bool exposureEnabled, bool tsEnabled)
{
rawPrefix = prefix;
typePrefixEnabled = typeEnabled;
filterPrefixEnabled = filterEnabled;
expPrefixEnabled = exposureEnabled;
timeStampPrefixEnabled = tsEnabled;
}
void SequenceJob::getPrefixSettings(QString &prefix, bool &typeEnabled, bool &filterEnabled, bool &exposureEnabled, bool &tsEnabled)
void SequenceJob::getPrefixSettings(QString &prefix, bool &filterEnabled, bool &exposureEnabled, bool &tsEnabled)
{
prefix = rawPrefix;
typeEnabled = typePrefixEnabled;
filterEnabled = filterPrefixEnabled;
exposureEnabled = expPrefixEnabled;
tsEnabled = timeStampPrefixEnabled;
......@@ -354,6 +353,16 @@ void SequenceJob::setEnforceTemperature(bool value)
enforceTemperature = value;
}
QString SequenceJob::getRootFITSDir() const
{
return rootFITSDir;
}
void SequenceJob::setRootFITSDir(const QString &value)
{
rootFITSDir = value;
}
int SequenceJob::getISOIndex() const
{
return isoIndex;
......
......@@ -48,7 +48,8 @@ class SequenceJob : public QObject
int getDelay() { return delay;}
int getCount() { return count;}
unsigned int getCompleted() { return completed; }
const QString & getPrefix() { return prefix;}
const QString & getPrefix() { return fullPrefix;}
const QString & getRawPrefix() { return rawPrefix;}
double getExposure() const { return exposure;}
void setActiveCCD(ISD::CCD *ccd) { activeCCD = ccd; }
......@@ -73,7 +74,7 @@ class SequenceJob : public QObject
int getFrameType() { return frameType;}
void setCaptureFilter(FITSScale capFilter) { captureFilter = capFilter; }
void setPreview(bool enable) { preview = enable; }
void setPrefix(const QString &cprefix) { prefix = cprefix;}
void setFullPrefix(const QString &cprefix) { fullPrefix = cprefix;}
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;}
int getSubY() { return y;}
......@@ -94,10 +95,9 @@ class SequenceJob : public QObject
double getExposeLeft() const;
void setExposeLeft(double value);
void resetStatus();
void setPrefixSettings(const QString &prefix, bool typeEnabled, bool filterEnabled, bool exposureEnabled, bool tsEnabled);
void getPrefixSettings(QString &prefix, bool &typeEnabled, bool &filterEnabled, bool &exposureEnabled, bool &tsEnabled);
void setPrefixSettings(const QString &fullPrefix, bool filterEnabled, bool exposureEnabled, bool tsEnabled);
void getPrefixSettings(QString &fullPrefix, bool &filterEnabled, bool &exposureEnabled, bool &tsEnabled);
bool isTypePrefixEnabled() { return typePrefixEnabled; }
bool isFilterPrefixEnabled() { return filterPrefixEnabled; }
bool isExposurePrefixEnabled() { return expPrefixEnabled; }
bool isTimestampPrefixEnabled() { return timeStampPrefixEnabled;}
......@@ -132,6 +132,9 @@ class SequenceJob : public QObject
bool getEnforceTemperature() const;
void setEnforceTemperature(bool value);
QString getRootFITSDir() const;
void setRootFITSDir(const QString &value);
signals:
void prepareComplete();
......@@ -152,7 +155,7 @@ private:
int imageType;
int binX, binY;
int x,y,w,h;
QString prefix;
QString fullPrefix;
int count;
int delay;
bool preview;
......@@ -166,6 +169,7 @@ private:
FITSScale captureFilter;
QTableWidgetItem *statusCell;
QString fitsDir;
QString rootFITSDir;
bool typePrefixEnabled, filterPrefixEnabled, expPrefixEnabled, timeStampPrefixEnabled;
QString rawPrefix;
......
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