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 | exposeOUT->setText(QString("%L1").arg(downloadTimeLeft, 0, 'd', 2)); | ||||
2223 | emit newDownloadProgress(downloadTimeLeft); | ||||
2224 | } | ||||
2225 | } | ||||
2226 | } | ||||
2227 | | ||||
2197 | void Capture::setExposureProgress(ISD::CCDChip * tChip, double value, IPState state) | 2228 | void Capture::setExposureProgress(ISD::CCDChip * tChip, double value, IPState state) | ||
2198 | { | 2229 | { | ||
2199 | if (targetChip != tChip || targetChip->getCaptureMode() != FITS_NORMAL || meridianFlipStage >= MF_ALIGNING) | 2230 | if (targetChip != tChip || targetChip->getCaptureMode() != FITS_NORMAL || meridianFlipStage >= MF_ALIGNING) | ||
2200 | return; | 2231 | return; | ||
2201 | 2232 | | |||
2202 | exposeOUT->setText(QString("%L1").arg(value, 0, 'd', 2)); | 2233 | exposeOUT->setText(QString("%L1").arg(value, 0, 'd', 2)); | ||
2203 | 2234 | | |||
2204 | if (activeJob) | 2235 | if (activeJob) | ||
▲ Show 20 Lines • Show All 45 Lines • ▼ Show 20 Line(s) | 2267 | { | |||
2250 | if (guideState == GUIDE_GUIDING && Options::guiderType() == 0 && suspendGuideOnDownload) | 2281 | if (guideState == GUIDE_GUIDING && Options::guiderType() == 0 && suspendGuideOnDownload) | ||
2251 | { | 2282 | { | ||
2252 | qCDebug(KSTARS_EKOS_CAPTURE) << "Autoguiding suspended until primary CCD chip completes downloading..."; | 2283 | qCDebug(KSTARS_EKOS_CAPTURE) << "Autoguiding suspended until primary CCD chip completes downloading..."; | ||
2253 | emit suspendGuiding(); | 2284 | emit suspendGuiding(); | ||
2254 | } | 2285 | } | ||
2255 | 2286 | | |||
2256 | secondsLabel->setText(i18n("Downloading...")); | 2287 | secondsLabel->setText(i18n("Downloading...")); | ||
2257 | 2288 | | |||
2289 | //This will start the clock to see how long the download takes. | ||||
2290 | downloadTimer.start(); | ||||
2291 | downloadProgressTimer.start(); | ||||
2292 | | ||||
2293 | | ||||
2258 | //disconnect(currentCCD, &ISD::CCD::newExposureValue(ISD::CCDChip*,double,IPState)), this, &Ekos::Capture::updateCaptureProgress(ISD::CCDChip*,double,IPState))); | 2294 | //disconnect(currentCCD, &ISD::CCD::newExposureValue(ISD::CCDChip*,double,IPState)), this, &Ekos::Capture::updateCaptureProgress(ISD::CCDChip*,double,IPState))); | ||
2259 | } | 2295 | } | ||
2260 | // JM: Don't change to i18np, value is DOUBLE, not Integer. | 2296 | // JM: Don't change to i18np, value is DOUBLE, not Integer. | ||
2261 | else if (value <= 1) | 2297 | else if (value <= 1) | ||
2262 | secondsLabel->setText(i18n("second left")); | 2298 | secondsLabel->setText(i18n("second left")); | ||
2263 | else | 2299 | else | ||
2264 | secondsLabel->setText(i18n("seconds left")); | 2300 | secondsLabel->setText(i18n("seconds left")); | ||
2265 | } | 2301 | } | ||
▲ Show 20 Lines • Show All 2162 Lines • ▼ Show 20 Line(s) | 4457 | { | |||
4428 | return -1; | 4464 | return -1; | ||
4429 | } | 4465 | } | ||
4430 | 4466 | | |||
4431 | int Capture::getJobRemainingTime(SequenceJob * job) | 4467 | int Capture::getJobRemainingTime(SequenceJob * job) | ||
4432 | { | 4468 | { | ||
4433 | int remaining = 0; | 4469 | int remaining = 0; | ||
4434 | 4470 | | |||
4435 | if (job->getStatus() == SequenceJob::JOB_BUSY) | 4471 | if (job->getStatus() == SequenceJob::JOB_BUSY) | ||
4436 | remaining += (job->getExposure() + job->getDelay() / 1000) * (job->getCount() - job->getCompleted()) + | 4472 | remaining += (job->getExposure() + getEstimatedDownloadTime() + job->getDelay() / 1000) * (job->getCount() - job->getCompleted()) + | ||
4437 | job->getExposeLeft(); | 4473 | job->getExposeLeft() + getEstimatedDownloadTime(); | ||
4438 | else | 4474 | else | ||
wreissenberger: Could be shortened to
```
int remaining = (job->getExposure() + getEstimatedDownloadTime() +… | |||||
4439 | remaining += (job->getExposure() + job->getDelay() / 1000) * (job->getCount() - job->getCompleted()); | 4475 | remaining += (job->getExposure() + getEstimatedDownloadTime() + job->getDelay() / 1000) * (job->getCount() - job->getCompleted()); | ||
4440 | 4476 | | |||
4441 | return remaining; | 4477 | return remaining; | ||
4442 | } | 4478 | } | ||
4443 | 4479 | | |||
4444 | int Capture::getOverallRemainingTime() | 4480 | int Capture::getOverallRemainingTime() | ||
4445 | { | 4481 | { | ||
4446 | double remaining = 0; | 4482 | double remaining = 0; | ||
4447 | 4483 | | |||
▲ Show 20 Lines • Show All 2072 Lines • ▼ Show 20 Line(s) | 6542 | { | |||
6520 | else if (currentCCD->getProperty("CCD_CONTROLS")) | 6556 | else if (currentCCD->getProperty("CCD_CONTROLS")) | ||
6521 | { | 6557 | { | ||
6522 | return customProps["CCD_CONTROLS"].value("Gain", -1); | 6558 | return customProps["CCD_CONTROLS"].value("Gain", -1); | ||
6523 | } | 6559 | } | ||
6524 | 6560 | | |||
6525 | return -1; | 6561 | return -1; | ||
6526 | } | 6562 | } | ||
6527 | 6563 | | |||
6564 | double Capture::getEstimatedDownloadTime() | ||||
6565 | { | ||||
6566 | double total=0; | ||||
6567 | foreach(double dlTime, downloadTimes) | ||||
6568 | total+=dlTime; | ||||
6569 | if(downloadTimes.count()==0) | ||||
6570 | return 0; | ||||
6571 | else | ||||
6572 | return total/downloadTimes.count(); | ||||
6573 | } | ||||
6574 | | ||||
6528 | } | 6575 | } |
Could be shortened to