Changeset View
Changeset View
Standalone View
Standalone View
kstars/ekos/capture/capture.cpp
Show First 20 Lines • Show All 357 Lines • ▼ Show 20 Line(s) | 51 | { | |||
---|---|---|---|---|---|
358 | // Load FIlter Offets | 358 | // Load FIlter Offets | ||
359 | //loadFilterOffsets(); | 359 | //loadFilterOffsets(); | ||
360 | 360 | | |||
361 | //Note: This is to prevent a button from being called the default button | 361 | //Note: This is to prevent a button from being called the default button | ||
362 | //and then executing when the user hits the enter key such as when on a Text Box | 362 | //and then executing when the user hits the enter key such as when on a Text Box | ||
363 | QList<QPushButton *> qButtons = findChildren<QPushButton *>(); | 363 | QList<QPushButton *> qButtons = findChildren<QPushButton *>(); | ||
364 | for (auto &button : qButtons) | 364 | for (auto &button : qButtons) | ||
365 | button->setAutoDefault(false); | 365 | button->setAutoDefault(false); | ||
366 | | ||||
367 | //This Timer will update the Exposure time in the capture module to display the estimated download time left | ||||
368 | //It will also update the Exposure time left in the Summary Screen. | ||||
369 | //It fires every 100 ms while images are downloading. | ||||
370 | downloadProgressTimer.setInterval(100); | ||||
371 | connect(&downloadProgressTimer, &QTimer::timeout, this, &Ekos::Capture::setDownloadProgress); | ||||
372 | | ||||
366 | } | 373 | } | ||
367 | 374 | | |||
368 | Capture::~Capture() | 375 | Capture::~Capture() | ||
369 | { | 376 | { | ||
370 | qDeleteAll(jobs); | 377 | qDeleteAll(jobs); | ||
371 | } | 378 | } | ||
372 | 379 | | |||
373 | void Capture::setDefaultCCD(QString ccd) | 380 | void Capture::setDefaultCCD(QString ccd) | ||
▲ Show 20 Lines • Show All 1128 Lines • ▼ Show 20 Line(s) | 1435 | { | |||
1502 | setCaptureComplete(); | 1509 | setCaptureComplete(); | ||
1503 | } | 1510 | } | ||
1504 | 1511 | | |||
1505 | bool Capture::setCaptureComplete() | 1512 | bool Capture::setCaptureComplete() | ||
1506 | { | 1513 | { | ||
1507 | captureTimeout.stop(); | 1514 | captureTimeout.stop(); | ||
1508 | captureTimeoutCounter = 0; | 1515 | captureTimeoutCounter = 0; | ||
1509 | 1516 | | |||
1517 | downloadProgressTimer.stop(); | ||||
1518 | | ||||
1519 | //This determines the time since the image started downloading | ||||
1520 | //Then it gets the estimated time left and displays it in the log. | ||||
1521 | double currentDownloadTime = downloadTimer.elapsed()/1000.0; | ||||
1522 | downloadTimes << currentDownloadTime; | ||||
1523 | QString dLTimeString = QString::number(currentDownloadTime, 'd', 2); | ||||
1524 | QString estimatedTimeString = QString::number(getEstimatedDownloadTime(), 'd', 2); | ||||
1525 | appendLogText(i18n("Download Time: %1 s, New Download Time Estimate: %2 s.").arg(dLTimeString).arg(estimatedTimeString)); | ||||
1526 | | ||||
1510 | // In case we're framing, let's start | 1527 | // In case we're framing, let's start | ||
1511 | if (m_isLooping) | 1528 | if (m_isLooping) | ||
1512 | { | 1529 | { | ||
1513 | sendNewImage(blobFilename, blobChip); | 1530 | sendNewImage(blobFilename, blobChip); | ||
1514 | secondsLabel->setText(i18n("Framing...")); | 1531 | secondsLabel->setText(i18n("Framing...")); | ||
1515 | activeJob->capture(darkSubCheck->isChecked() ? true : false); | 1532 | activeJob->capture(darkSubCheck->isChecked() ? true : false); | ||
1516 | return true; | 1533 | return true; | ||
1517 | } | 1534 | } | ||
▲ Show 20 Lines • Show All 671 Lines • ▼ Show 20 Line(s) | |||||
2189 | } | 2206 | } | ||
2190 | 2207 | | |||
2191 | void Capture::clearLog() | 2208 | void Capture::clearLog() | ||
2192 | { | 2209 | { | ||
2193 | m_LogText.clear(); | 2210 | m_LogText.clear(); | ||
2194 | emit newLog(QString()); | 2211 | emit newLog(QString()); | ||
2195 | } | 2212 | } | ||
2196 | 2213 | | |||
2214 | //This method will update the Capture Module and Summary Screen's estimate of how much time is left in the download | ||||
2215 | void Capture::setDownloadProgress() | ||||
2216 | { | ||||
2217 | if (activeJob) | ||||
2218 | { | ||||
2219 | double downloadTimeLeft = getEstimatedDownloadTime() - downloadTimer.elapsed()/1000.0; | ||||
2220 | if(downloadTimeLeft > 0) | ||||
2221 | { | ||||
2222 | activeJob->setExposeAndDownloadTimeLeft(downloadTimeLeft); | ||||
2223 | exposeOUT->setText(QString("%L1").arg(downloadTimeLeft, 0, 'd', 2)); | ||||
2224 | emit newExposureProgress(activeJob); | ||||
2225 | } | ||||
2226 | } | ||||
2227 | } | ||||
2228 | | ||||
2197 | void Capture::setExposureProgress(ISD::CCDChip * tChip, double value, IPState state) | 2229 | void Capture::setExposureProgress(ISD::CCDChip * tChip, double value, IPState state) | ||
2198 | { | 2230 | { | ||
2199 | if (targetChip != tChip || targetChip->getCaptureMode() != FITS_NORMAL || meridianFlipStage >= MF_ALIGNING) | 2231 | if (targetChip != tChip || targetChip->getCaptureMode() != FITS_NORMAL || meridianFlipStage >= MF_ALIGNING) | ||
2200 | return; | 2232 | return; | ||
2201 | 2233 | | |||
2202 | exposeOUT->setText(QString("%L1").arg(value, 0, 'd', 2)); | 2234 | exposeOUT->setText(QString("%L1").arg(value, 0, 'd', 2)); | ||
2203 | 2235 | | |||
2204 | if (activeJob) | 2236 | if (activeJob) | ||
2205 | { | 2237 | { | ||
2206 | activeJob->setExposeLeft(value); | 2238 | activeJob->setExposeAndDownloadTimeLeft(value + getEstimatedDownloadTime()); | ||
2207 | 2239 | | |||
2208 | emit newExposureProgress(activeJob); | 2240 | emit newExposureProgress(activeJob); | ||
2209 | } | 2241 | } | ||
2210 | 2242 | | |||
2211 | if (activeJob && state == IPS_ALERT) | 2243 | if (activeJob && state == IPS_ALERT) | ||
2212 | { | 2244 | { | ||
2213 | int retries = activeJob->getCaptureRetires() + 1; | 2245 | int retries = activeJob->getCaptureRetires() + 1; | ||
2214 | 2246 | | |||
Show All 15 Lines | |||||
2230 | return; | 2262 | return; | ||
2231 | } | 2263 | } | ||
2232 | 2264 | | |||
2233 | //qDebug() << "Exposure with value " << value << "state" << pstateStr(state); | 2265 | //qDebug() << "Exposure with value " << value << "state" << pstateStr(state); | ||
2234 | 2266 | | |||
2235 | if (activeJob != nullptr && state == IPS_OK) | 2267 | if (activeJob != nullptr && state == IPS_OK) | ||
2236 | { | 2268 | { | ||
2237 | activeJob->setCaptureRetires(0); | 2269 | activeJob->setCaptureRetires(0); | ||
2238 | activeJob->setExposeLeft(0); | 2270 | activeJob->setExposeAndDownloadTimeLeft(0); | ||
2239 | 2271 | | |||
2240 | if (currentCCD && currentCCD->getUploadMode() == ISD::CCD::UPLOAD_LOCAL) | 2272 | if (currentCCD && currentCCD->getUploadMode() == ISD::CCD::UPLOAD_LOCAL) | ||
2241 | { | 2273 | { | ||
2242 | if (activeJob && activeJob->getStatus() == SequenceJob::JOB_BUSY) | 2274 | if (activeJob && activeJob->getStatus() == SequenceJob::JOB_BUSY) | ||
2243 | { | 2275 | { | ||
2244 | newFITS(nullptr); | 2276 | newFITS(nullptr); | ||
2245 | return; | 2277 | return; | ||
2246 | } | 2278 | } | ||
2247 | } | 2279 | } | ||
2248 | 2280 | | |||
2249 | //if (isAutoGuiding && Options::useEkosGuider() && currentCCD->getChip(ISD::CCDChip::GUIDE_CCD) == guideChip) | 2281 | //if (isAutoGuiding && Options::useEkosGuider() && currentCCD->getChip(ISD::CCDChip::GUIDE_CCD) == guideChip) | ||
2250 | if (guideState == GUIDE_GUIDING && Options::guiderType() == 0 && suspendGuideOnDownload) | 2282 | if (guideState == GUIDE_GUIDING && Options::guiderType() == 0 && suspendGuideOnDownload) | ||
2251 | { | 2283 | { | ||
2252 | qCDebug(KSTARS_EKOS_CAPTURE) << "Autoguiding suspended until primary CCD chip completes downloading..."; | 2284 | qCDebug(KSTARS_EKOS_CAPTURE) << "Autoguiding suspended until primary CCD chip completes downloading..."; | ||
2253 | emit suspendGuiding(); | 2285 | emit suspendGuiding(); | ||
2254 | } | 2286 | } | ||
2255 | 2287 | | |||
2256 | secondsLabel->setText(i18n("Downloading...")); | 2288 | secondsLabel->setText(i18n("Downloading...")); | ||
2257 | 2289 | | |||
2290 | //This will start the clock to see how long the download takes. | ||||
2291 | downloadTimer.start(); | ||||
2292 | downloadProgressTimer.start(); | ||||
2293 | | ||||
2294 | | ||||
2258 | //disconnect(currentCCD, &ISD::CCD::newExposureValue(ISD::CCDChip*,double,IPState)), this, &Ekos::Capture::updateCaptureProgress(ISD::CCDChip*,double,IPState))); | 2295 | //disconnect(currentCCD, &ISD::CCD::newExposureValue(ISD::CCDChip*,double,IPState)), this, &Ekos::Capture::updateCaptureProgress(ISD::CCDChip*,double,IPState))); | ||
2259 | } | 2296 | } | ||
2260 | // JM: Don't change to i18np, value is DOUBLE, not Integer. | 2297 | // JM: Don't change to i18np, value is DOUBLE, not Integer. | ||
2261 | else if (value <= 1) | 2298 | else if (value <= 1) | ||
2262 | secondsLabel->setText(i18n("second left")); | 2299 | secondsLabel->setText(i18n("second left")); | ||
2263 | else | 2300 | else | ||
2264 | secondsLabel->setText(i18n("seconds left")); | 2301 | secondsLabel->setText(i18n("seconds left")); | ||
2265 | } | 2302 | } | ||
▲ Show 20 Lines • Show All 864 Lines • ▼ Show 20 Line(s) | 3165 | { | |||
3130 | resumeSequence(); | 3167 | resumeSequence(); | ||
3131 | // N.B. Set meridian flip stage AFTER resumeSequence() always | 3168 | // N.B. Set meridian flip stage AFTER resumeSequence() always | ||
3132 | setMeridianFlipStage(MF_NONE); | 3169 | setMeridianFlipStage(MF_NONE); | ||
3133 | return; | 3170 | return; | ||
3134 | } | 3171 | } | ||
3135 | } | 3172 | } | ||
3136 | 3173 | | |||
3137 | // We don't enforce limit on previews | 3174 | // We don't enforce limit on previews | ||
3138 | if (guideDeviationCheck->isChecked() == false || (activeJob && (activeJob->isPreview() || activeJob->getExposeLeft() == 0))) | 3175 | if (guideDeviationCheck->isChecked() == false || (activeJob && (activeJob->isPreview() || activeJob->getExposureAndDownloadTimeLeft() == 0))) | ||
3139 | return; | 3176 | return; | ||
3140 | 3177 | | |||
3141 | double deviation_rms = sqrt(delta_ra * delta_ra + delta_dec * delta_dec); | 3178 | double deviation_rms = sqrt(delta_ra * delta_ra + delta_dec * delta_dec); | ||
3142 | 3179 | | |||
3143 | QString deviationText = QString("%1").arg(deviation_rms, 0, 'f', 3); | 3180 | QString deviationText = QString("%1").arg(deviation_rms, 0, 'f', 3); | ||
3144 | 3181 | | |||
3145 | // If we have an active busy job, let's abort it if guiding deviation is exceeded. | 3182 | // If we have an active busy job, let's abort it if guiding deviation is exceeded. | ||
3146 | // And we accounted for the spike | 3183 | // And we accounted for the spike | ||
▲ Show 20 Lines • Show All 1259 Lines • ▼ Show 20 Line(s) | 4436 | { | |||
4406 | return -1; | 4443 | return -1; | ||
4407 | } | 4444 | } | ||
4408 | 4445 | | |||
4409 | double Capture::getJobExposureProgress(int id) | 4446 | double Capture::getJobExposureProgress(int id) | ||
4410 | { | 4447 | { | ||
4411 | if (id < jobs.count()) | 4448 | if (id < jobs.count()) | ||
4412 | { | 4449 | { | ||
4413 | SequenceJob * job = jobs.at(id); | 4450 | SequenceJob * job = jobs.at(id); | ||
4414 | return job->getExposeLeft(); | 4451 | return job->getExposureAndDownloadTimeLeft(); | ||
4415 | } | 4452 | } | ||
4416 | 4453 | | |||
4417 | return -1; | 4454 | return -1; | ||
4418 | } | 4455 | } | ||
4419 | 4456 | | |||
4420 | double Capture::getJobExposureDuration(int id) | 4457 | double Capture::getJobExposureDuration(int id) | ||
4421 | { | 4458 | { | ||
4422 | if (id < jobs.count()) | 4459 | if (id < jobs.count()) | ||
4423 | { | 4460 | { | ||
4424 | SequenceJob * job = jobs.at(id); | 4461 | SequenceJob * job = jobs.at(id); | ||
4425 | return job->getExposure(); | 4462 | return job->getExposure(); | ||
4426 | } | 4463 | } | ||
4427 | 4464 | | |||
4428 | return -1; | 4465 | return -1; | ||
4429 | } | 4466 | } | ||
4430 | 4467 | | |||
4431 | int Capture::getJobRemainingTime(SequenceJob * job) | 4468 | int Capture::getJobRemainingTime(SequenceJob * job) | ||
4432 | { | 4469 | { | ||
4433 | int remaining = 0; | 4470 | int remaining = 0; | ||
4434 | 4471 | | |||
4435 | if (job->getStatus() == SequenceJob::JOB_BUSY) | 4472 | if (job->getStatus() == SequenceJob::JOB_BUSY) | ||
4436 | remaining += (job->getExposure() + job->getDelay() / 1000) * (job->getCount() - job->getCompleted()) + | 4473 | remaining += (job->getExposure() + getEstimatedDownloadTime() + job->getDelay() / 1000) * (job->getCount() - job->getCompleted()) + | ||
4437 | job->getExposeLeft(); | 4474 | job->getExposureAndDownloadTimeLeft(); | ||
4438 | else | 4475 | else | ||
wreissenberger: Could be shortened to
```
int remaining = (job->getExposure() + getEstimatedDownloadTime() +… | |||||
4439 | remaining += (job->getExposure() + job->getDelay() / 1000) * (job->getCount() - job->getCompleted()); | 4476 | remaining += (job->getExposure() + getEstimatedDownloadTime() + job->getDelay() / 1000) * (job->getCount() - job->getCompleted()); | ||
4440 | 4477 | | |||
4441 | return remaining; | 4478 | return remaining; | ||
4442 | } | 4479 | } | ||
4443 | 4480 | | |||
4444 | int Capture::getOverallRemainingTime() | 4481 | int Capture::getOverallRemainingTime() | ||
4445 | { | 4482 | { | ||
4446 | double remaining = 0; | 4483 | double remaining = 0; | ||
4447 | 4484 | | |||
▲ Show 20 Lines • Show All 2072 Lines • ▼ Show 20 Line(s) | 6543 | { | |||
6520 | else if (currentCCD->getProperty("CCD_CONTROLS")) | 6557 | else if (currentCCD->getProperty("CCD_CONTROLS")) | ||
6521 | { | 6558 | { | ||
6522 | return customProps["CCD_CONTROLS"].value("Gain", -1); | 6559 | return customProps["CCD_CONTROLS"].value("Gain", -1); | ||
6523 | } | 6560 | } | ||
6524 | 6561 | | |||
6525 | return -1; | 6562 | return -1; | ||
6526 | } | 6563 | } | ||
6527 | 6564 | | |||
6565 | double Capture::getEstimatedDownloadTime() | ||||
6566 | { | ||||
6567 | double total=0; | ||||
6568 | foreach(double dlTime, downloadTimes) | ||||
6569 | total+=dlTime; | ||||
6570 | if(downloadTimes.count()==0) | ||||
6571 | return 0; | ||||
6572 | else | ||||
6573 | return total/downloadTimes.count(); | ||||
6574 | } | ||||
6575 | | ||||
6528 | } | 6576 | } |
Could be shortened to