Commit b0e0e34a authored by Jasem Mutlaq's avatar Jasem Mutlaq

+ Fix issue where parking mount and dome were not called if flat job was not...

+ Fix issue where parking mount and dome were not called if flat job was not at the beginning of the sequence.
+ Added tolerance parameter to ADU calculations instead of the hard-coded tolerance percentage settings.
parent 4abd745f
......@@ -6,8 +6,8 @@
<rect>
<x>0</x>
<y>0</y>
<width>475</width>
<height>241</height>
<width>434</width>
<height>235</height>
</rect>
</property>
<property name="windowTitle">
......@@ -15,7 +15,7 @@
</property>
<layout class="QVBoxLayout" name="verticalLayout_3">
<item>
<layout class="QHBoxLayout" name="horizontalLayout_3">
<layout class="QHBoxLayout" name="horizontalLayout_2">
<item>
<widget class="QGroupBox" name="groupBox">
<property name="toolTip">
......@@ -136,21 +136,21 @@
</property>
<layout class="QVBoxLayout" name="verticalLayout_2">
<item>
<widget class="QRadioButton" name="manualDurationC">
<property name="toolTip">
<string>Use the frame exposure value</string>
</property>
<property name="text">
<string>Manual</string>
</property>
<property name="checked">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout_2">
<item>
<layout class="QGridLayout" name="gridLayout">
<item row="0" column="0">
<widget class="QRadioButton" name="manualDurationC">
<property name="toolTip">
<string>Use the frame exposure value</string>
</property>
<property name="text">
<string>Manual</string>
</property>
<property name="checked">
<bool>true</bool>
</property>
</widget>
</item>
<item row="1" column="0">
<widget class="QRadioButton" name="ADUC">
<property name="toolTip">
<string>Calculate optimal exposure time given the required ADU. If a controllable device is selected, calculate optimal brightness.</string>
......@@ -160,10 +160,10 @@
</property>
</widget>
</item>
<item>
<item row="1" column="1">
<widget class="QSpinBox" name="ADUValue">
<property name="toolTip">
<string/>
<string>Calculate optimal exposure time given the required ADU. If a controllable device is selected, calculate optimal brightness.</string>
</property>
<property name="maximum">
<number>65535</number>
......@@ -173,6 +173,32 @@
</property>
</widget>
</item>
<item row="2" column="0">
<widget class="QLabel" name="label_3">
<property name="toolTip">
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;Accept ADU values that fall within this range around the desired ADU target. For example, if the ADU value was set to 10000 and the tolerance was set to 100, then frames with ADU values f 9900 and 10100 shall be accepted.&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
<property name="text">
<string>Tolerance:</string>
</property>
</widget>
</item>
<item row="2" column="1">
<widget class="QSpinBox" name="ADUTolerance">
<property name="toolTip">
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;Accept ADU values that fall within this range around the desired ADU target. For example, if the ADU value was set to 10000 and the tolerance was set to 100, then frames with ADU values f 9900 and 10100 shall be accepted.&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
<property name="maximum">
<number>50000</number>
</property>
<property name="singleStep">
<number>100</number>
</property>
<property name="value">
<number>1000</number>
</property>
</widget>
</item>
</layout>
</item>
<item>
......
......@@ -85,6 +85,7 @@ Capture::Capture()
guideChip = NULL;
targetADU = 0;
targetADUTolerance = 1000;
flatFieldDuration = DURATION_MANUAL;
flatFieldSource = SOURCE_MANUAL;
calibrationStage = CAL_NONE;
......@@ -210,7 +211,7 @@ Capture::Capture()
guideDeviationCheck->setChecked(Options::enforceGuideDeviation());
guideDeviation->setValue(Options::guideDeviation());
autofocusCheck->setChecked(Options::enforceAutofocus());
autofocusCheck->setChecked(Options::enforceAutofocus());
meridianCheck->setChecked(Options::autoMeridianFlip());
meridianHours->setValue(Options::autoMeridianHours());
useFITSViewerInCapture->setChecked(Options::useFITSViewerInCapture());
......@@ -1631,6 +1632,7 @@ void Capture::addJob(bool preview)
job->setPreDomePark(preDomePark);
job->setWallCoord(wallCoord);
job->setTargetADU(targetADU);
job->setTargetADUTolerance(targetADUTolerance);
imagePrefix = prefixIN->text();
......@@ -2099,23 +2101,37 @@ void Capture::executeJob()
useGuideHead = (activeJob->getActiveChip()->getType() == ISD::CCDChip::PRIMARY_CCD) ? false : true;
syncGUIToJob(activeJob);
// Check flat field frame requirements
if (activeJob->getFrameType() != FRAME_LIGHT && activeJob->isPreview() == false)
{
// Make sure we don't have any pre-capture pending jobs for flat frames
IPState rc = processPreCaptureCalibrationStage();
updatePreCaptureCalibrationStatus();
return;
}
if (rc == IPS_ALERT)
return;
else if (rc == IPS_BUSY)
{
secondsLabel->clear();
QTimer::singleShot(1000, this, SLOT(executeJob()));
return;
}
captureImage();
}
void Capture::updatePreCaptureCalibrationStatus()
{
// If process was aborted or stopped by the user
if (isBusy == false)
{
appendLogText(i18n("Warning: Calibration process was prematurely terminated."));
return;
}
syncGUIToJob(activeJob);
IPState rc = processPreCaptureCalibrationStage();
if (rc == IPS_ALERT)
return;
else if (rc == IPS_BUSY)
{
secondsLabel->clear();
QTimer::singleShot(1000, this, SLOT(updatePreCaptureCalibrationStatus()));
return;
}
captureImage();
}
......@@ -2560,6 +2576,12 @@ bool Capture::processJobInfo(XMLEle *root)
flatFieldDuration = DURATION_ADU;
targetADU = atof(pcdataXMLEle(aduEP));
}
aduEP= findXMLEle(subEP, "Tolerance");
if (aduEP)
{
targetADUTolerance = atof(pcdataXMLEle(aduEP));
}
}
subEP = findXMLEle(ep, "PreMountPark");
......@@ -2740,6 +2762,7 @@ bool Capture::saveSequenceQueue(const QString &path)
{
outstream << "<Type>ADU</Type>" << endl;
outstream << "<Value>" << job->getTargetADU() << "</Value>" << endl;
outstream << "<Tolerance>" << job->getTargetADUTolerance() << "</Tolerance>" << endl;
}
outstream << "</FlatDuration>" << endl;
......@@ -2815,6 +2838,7 @@ void Capture::syncGUIToJob(SequenceJob *job)
flatFieldDuration = job->getFlatFieldDuration();
flatFieldSource = job->getFlatFieldSource();
targetADU = job->getTargetADU();
targetADUTolerance= job->getTargetADUTolerance();
wallCoord = job->getWallCoord();
preMountPark = job->isPreMountPark();
preDomePark = job->isPreDomePark();
......@@ -3429,7 +3453,7 @@ double Capture::setCurrentADU(double value)
if (nextExposure == 0)
{
if (value < targetADU)
nextExposure = activeJob->getExposure()*1.5;
nextExposure = activeJob->getExposure()*1.25;
else
nextExposure = activeJob->getExposure()*.75;
}
......@@ -3589,6 +3613,7 @@ void Capture::openCalibrationDialog()
case DURATION_ADU:
calibrationOptions.ADUC->setChecked(true);
calibrationOptions.ADUValue->setValue(targetADU);
calibrationOptions.ADUTolerance->setValue(targetADUTolerance);
break;
}
......@@ -3630,6 +3655,7 @@ void Capture::openCalibrationDialog()
{
flatFieldDuration = DURATION_ADU;
targetADU = calibrationOptions.ADUValue->value();
targetADUTolerance = calibrationOptions.ADUTolerance->value();
}
preMountPark = calibrationOptions.parkMountC->isChecked();
......@@ -3899,6 +3925,12 @@ IPState Capture::processPreCaptureCalibrationStage()
bool Capture::processPostCaptureCalibrationStage()
{
// If there are no more images to capture, do not bother calculating next exposure
if (calibrationStage == CAL_CALIBRATION_COMPLETE && (seqCurrentCount+1) >= seqTotalCount)
{
return true;
}
// Check if we need to do flat field slope calculation if the user specified a desired ADU value
if (activeJob->getFrameType() == FRAME_FLAT && activeJob->getFlatFieldDuration() == DURATION_ADU && activeJob->getTargetADU() > 0)
{
......@@ -3910,19 +3942,15 @@ bool Capture::processPostCaptureCalibrationStage()
double currentADU = image_data->getADU();
//double currentSlope = ADUSlope;
double percentageDiff=0;
if (currentADU > activeJob->getTargetADU())
percentageDiff = activeJob->getTargetADU()/currentADU;
else
percentageDiff = currentADU / activeJob->getTargetADU();
double ADUDiff = fabs(currentADU-activeJob->getTargetADU());
// If it is within 2% of target ADU
if (percentageDiff >= 0.98)
// If it is within tolerance range of target ADU
if (ADUDiff <= targetADUTolerance)
{
if (calibrationStage == CAL_CALIBRATION)
{
appendLogText(i18n("Current ADU %1 within target ADU tolerance range.", QString::number(currentADU, 'f', 0)));
activeJob->setPreview(false);
activeJob->setPreview(false);
calibrationStage = CAL_CALIBRATION_COMPLETE;
startNextExposure();
return false;
......@@ -3935,7 +3963,7 @@ bool Capture::processPostCaptureCalibrationStage()
if (nextExposure <= 0)
{
appendLogText(i18n("Unable to calculate optimal exposure settings, please take the flats manually."));
appendLogText(i18n("Unable to calculate optimal exposure settings, please capture the flats manually."));
//activeJob->setTargetADU(0);
//targetADU = 0;
abort();
......
......@@ -431,6 +431,7 @@ private slots:
void openCalibrationDialog();
IPState processPreCaptureCalibrationStage();
bool processPostCaptureCalibrationStage();
void updatePreCaptureCalibrationStatus();
// Send image info
void sendNewImage(QImage *image, ISD::CCDChip *myChip);
......@@ -556,7 +557,7 @@ private:
// Flat field automation
QVector<double> ExpRaw, ADURaw;
double targetADU;
double targetADU, targetADUTolerance;
SkyPoint wallCoord;
bool preMountPark, preDomePark;
FlatFieldDuration flatFieldDuration;
......
......@@ -51,6 +51,7 @@ SequenceJob::SequenceJob()
calibrationSettings.flatFieldSource = SOURCE_MANUAL;
calibrationSettings.flatFieldDuration = DURATION_MANUAL;
calibrationSettings.targetADU = 0;
calibrationSettings.targetADUTolerance= 250;
calibrationSettings.preMountPark = false;
calibrationSettings.preDomePark = false;
......@@ -298,6 +299,17 @@ void SequenceJob::setTargetADU(double value)
{
calibrationSettings.targetADU = value;
}
double SequenceJob::getTargetADUTolerance() const
{
return calibrationSettings.targetADUTolerance;
}
void SequenceJob::setTargetADUTolerance(double value)
{
calibrationSettings.targetADUTolerance = value;
}
int SequenceJob::getCaptureRetires() const
{
return captureRetires;
......
......@@ -118,6 +118,9 @@ class SequenceJob : public QObject
double getTargetADU() const;
void setTargetADU(double value);
double getTargetADUTolerance() const;
void setTargetADUTolerance(double value);
int getCaptureRetires() const;
void setCaptureRetires(int value);
......@@ -210,6 +213,7 @@ private:
struct
{
double targetADU;
double targetADUTolerance;
FlatFieldSource flatFieldSource;
FlatFieldDuration flatFieldDuration;
SkyPoint wallCoord;
......
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