diff --git a/kstars/ekos/capture/capture.h b/kstars/ekos/capture/capture.h --- a/kstars/ekos/capture/capture.h +++ b/kstars/ekos/capture/capture.h @@ -356,6 +356,8 @@ */ void addDSLRInfo(const QString &model, uint32_t maxW, uint32_t maxH, double pixelW, double pixelH); + double getEstimatedDownloadTime(); + public slots: /** \addtogroup CaptureDBusInterface @@ -701,6 +703,8 @@ */ void registerNewModule(const QString &name); + void setDownloadProgress(); + signals: Q_SCRIPTABLE void newLog(const QString &text); Q_SCRIPTABLE void meridianFlipStarted(); @@ -933,5 +937,9 @@ QPointer ISOCombo; QPointer GainSpin; double GainSpinSpecialValue; + + QList downloadTimes; + QTime downloadTimer; + QTimer downloadProgressTimer; }; } diff --git a/kstars/ekos/capture/capture.cpp b/kstars/ekos/capture/capture.cpp --- a/kstars/ekos/capture/capture.cpp +++ b/kstars/ekos/capture/capture.cpp @@ -363,6 +363,13 @@ QList qButtons = findChildren(); for (auto &button : qButtons) button->setAutoDefault(false); + + //This Timer will update the Exposure time in the capture module to display the estimated download time left + //It will also update the Exposure time left in the Summary Screen. + //It fires every 100 ms while images are downloading. + downloadProgressTimer.setInterval(100); + connect(&downloadProgressTimer, &QTimer::timeout, this, &Ekos::Capture::setDownloadProgress); + } Capture::~Capture() @@ -1507,6 +1514,16 @@ captureTimeout.stop(); captureTimeoutCounter = 0; + downloadProgressTimer.stop(); + + //This determines the time since the image started downloading + //Then it gets the estimated time left and displays it in the log. + double currentDownloadTime = downloadTimer.elapsed()/1000.0; + downloadTimes << currentDownloadTime; + QString dLTimeString = QString::number(currentDownloadTime, 'd', 2); + QString estimatedTimeString = QString::number(getEstimatedDownloadTime(), 'd', 2); + appendLogText(i18n("Download Time: %1 s, New Download Time Estimate: %2 s.").arg(dLTimeString).arg(estimatedTimeString)); + // In case we're framing, let's start if (m_isLooping) { @@ -2194,6 +2211,21 @@ emit newLog(QString()); } +//This method will update the Capture Module and Summary Screen's estimate of how much time is left in the download +void Capture::setDownloadProgress() +{ + if (activeJob) + { + double downloadTimeLeft = getEstimatedDownloadTime() - downloadTimer.elapsed()/1000.0; + if(downloadTimeLeft > 0) + { + activeJob->setExposeAndDownloadTimeLeft(downloadTimeLeft); + exposeOUT->setText(QString("%L1").arg(downloadTimeLeft, 0, 'd', 2)); + emit newExposureProgress(activeJob); + } + } +} + void Capture::setExposureProgress(ISD::CCDChip * tChip, double value, IPState state) { if (targetChip != tChip || targetChip->getCaptureMode() != FITS_NORMAL || meridianFlipStage >= MF_ALIGNING) @@ -2203,7 +2235,7 @@ if (activeJob) { - activeJob->setExposeLeft(value); + activeJob->setExposeAndDownloadTimeLeft(value + getEstimatedDownloadTime()); emit newExposureProgress(activeJob); } @@ -2235,7 +2267,7 @@ if (activeJob != nullptr && state == IPS_OK) { activeJob->setCaptureRetires(0); - activeJob->setExposeLeft(0); + activeJob->setExposeAndDownloadTimeLeft(0); if (currentCCD && currentCCD->getUploadMode() == ISD::CCD::UPLOAD_LOCAL) { @@ -2255,6 +2287,11 @@ secondsLabel->setText(i18n("Downloading...")); + //This will start the clock to see how long the download takes. + downloadTimer.start(); + downloadProgressTimer.start(); + + //disconnect(currentCCD, &ISD::CCD::newExposureValue(ISD::CCDChip*,double,IPState)), this, &Ekos::Capture::updateCaptureProgress(ISD::CCDChip*,double,IPState))); } // JM: Don't change to i18np, value is DOUBLE, not Integer. @@ -3135,7 +3172,7 @@ } // We don't enforce limit on previews - if (guideDeviationCheck->isChecked() == false || (activeJob && (activeJob->isPreview() || activeJob->getExposeLeft() == 0))) + if (guideDeviationCheck->isChecked() == false || (activeJob && (activeJob->isPreview() || activeJob->getExposureAndDownloadTimeLeft() == 0))) return; double deviation_rms = sqrt(delta_ra * delta_ra + delta_dec * delta_dec); @@ -4411,7 +4448,7 @@ if (id < jobs.count()) { SequenceJob * job = jobs.at(id); - return job->getExposeLeft(); + return job->getExposureAndDownloadTimeLeft(); } return -1; @@ -4433,10 +4470,10 @@ int remaining = 0; if (job->getStatus() == SequenceJob::JOB_BUSY) - remaining += (job->getExposure() + job->getDelay() / 1000) * (job->getCount() - job->getCompleted()) + - job->getExposeLeft(); + remaining += (job->getExposure() + getEstimatedDownloadTime() + job->getDelay() / 1000) * (job->getCount() - job->getCompleted()) + + job->getExposureAndDownloadTimeLeft(); else - remaining += (job->getExposure() + job->getDelay() / 1000) * (job->getCount() - job->getCompleted()); + remaining += (job->getExposure() + getEstimatedDownloadTime() + job->getDelay() / 1000) * (job->getCount() - job->getCompleted()); return remaining; } @@ -6525,4 +6562,15 @@ return -1; } +double Capture::getEstimatedDownloadTime() +{ + double total=0; + foreach(double dlTime, downloadTimes) + total+=dlTime; + if(downloadTimes.count()==0) + return 0; + else + return total/downloadTimes.count(); +} + } diff --git a/kstars/ekos/capture/sequencejob.h b/kstars/ekos/capture/sequencejob.h --- a/kstars/ekos/capture/sequencejob.h +++ b/kstars/ekos/capture/sequencejob.h @@ -239,8 +239,8 @@ int getISOIndex() const; void setISOIndex(int value); - double getExposeLeft() const; - void setExposeLeft(double value); + double getExposureAndDownloadTimeLeft() const; + void setExposeAndDownloadTimeLeft(double value); void resetStatus(); void setPrefixSettings(const QString &rawFilePrefix, bool filterEnabled, bool exposureEnabled, bool tsEnabled); @@ -359,7 +359,7 @@ int isoIndex { -1 }; int captureRetires { 0 }; unsigned int completed { 0 }; - double exposeLeft { 0 }; + double exposeAndDownloadTimeLeft { 0 }; double currentTemperature { 0 }; double targetTemperature { 0 }; double gain { -1 }; diff --git a/kstars/ekos/capture/sequencejob.cpp b/kstars/ekos/capture/sequencejob.cpp --- a/kstars/ekos/capture/sequencejob.cpp +++ b/kstars/ekos/capture/sequencejob.cpp @@ -46,7 +46,7 @@ { setStatus(JOB_IDLE); setCompleted(0); - exposeLeft = 0; + exposeAndDownloadTimeLeft = 0; captureRetires = 0; m_JobProgressIgnored = false; } @@ -319,7 +319,7 @@ //status = JOB_BUSY; setStatus(getStatus()); - exposeLeft = exposure; + exposeAndDownloadTimeLeft = exposure; activeChip->capture(exposure); @@ -337,14 +337,14 @@ frameType = type; } -double SequenceJob::getExposeLeft() const +double SequenceJob::getExposureAndDownloadTimeLeft() const { - return exposeLeft; + return exposeAndDownloadTimeLeft; } -void SequenceJob::setExposeLeft(double value) +void SequenceJob::setExposeAndDownloadTimeLeft(double value) { - exposeLeft = value; + exposeAndDownloadTimeLeft = value; } void SequenceJob::setPrefixSettings(const QString &rawFilePrefix, bool filterEnabled, bool exposureEnabled, diff --git a/kstars/ekos/manager.cpp b/kstars/ekos/manager.cpp --- a/kstars/ekos/manager.cpp +++ b/kstars/ekos/manager.cpp @@ -2813,18 +2813,18 @@ void Manager::updateExposureProgress(Ekos::SequenceJob * job) { imageCountDown.setHMS(0, 0, 0); - imageCountDown = imageCountDown.addSecs(job->getExposeLeft()); + imageCountDown = imageCountDown.addSecs(job->getExposureAndDownloadTimeLeft()); if (imageCountDown.hour() == 23) imageCountDown.setHMS(0, 0, 0); - imageProgress->setRange(0, job->getExposure()); - imageProgress->setValue(job->getExposeLeft()); + imageProgress->setRange(0, job->getExposure() + captureProcess->getEstimatedDownloadTime()); + imageProgress->setValue(job->getExposureAndDownloadTimeLeft()); imageRemainingTime->setText(imageCountDown.toString("hh:mm:ss")); QJsonObject status { - {"expv", job->getExposeLeft()}, + {"expv", job->getExposureAndDownloadTimeLeft()}, {"expr", job->getExposure()} };