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(); @@ -716,6 +720,7 @@ void resumeGuiding(); void newImage(Ekos::SequenceJob *job); void newExposureProgress(Ekos::SequenceJob *job); + void newDownloadProgress(double); void sequenceChanged(const QJsonArray &sequence); void settingsUpdated(const QJsonObject &settings); void newMeridianFlipStatus(Mount::MeridianFlipStatus status); @@ -933,5 +938,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.", dLTimeString, estimatedTimeString)); + // In case we're framing, let's start if (m_isLooping) { @@ -2194,6 +2211,20 @@ 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) + { + exposeOUT->setText(QString("%L1").arg(downloadTimeLeft, 0, 'd', 2)); + emit newDownloadProgress(downloadTimeLeft); + } + } +} + void Capture::setExposureProgress(ISD::CCDChip * tChip, double value, IPState state) { if (targetChip != tChip || targetChip->getCaptureMode() != FITS_NORMAL || meridianFlipStage >= MF_ALIGNING) @@ -2255,6 +2286,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. @@ -4433,10 +4469,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->getExposeLeft() + getEstimatedDownloadTime(); 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 +6561,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/manager.h b/kstars/ekos/manager.h --- a/kstars/ekos/manager.h +++ b/kstars/ekos/manager.h @@ -371,6 +371,7 @@ // Capture Summary void updateCaptureStatus(CaptureState status); void updateCaptureProgress(SequenceJob *job); + void updateDownloadProgress(double timeLeft); void updateExposureProgress(SequenceJob *job); void updateCaptureCountDown(); diff --git a/kstars/ekos/manager.cpp b/kstars/ekos/manager.cpp --- a/kstars/ekos/manager.cpp +++ b/kstars/ekos/manager.cpp @@ -2043,6 +2043,7 @@ summaryPreview->loadFITS(filename); } }); + connect(captureProcess.get(), &Ekos::Capture::newDownloadProgress, this, &Ekos::Manager::updateDownloadProgress); connect(captureProcess.get(), &Ekos::Capture::newExposureProgress, this, &Ekos::Manager::updateExposureProgress); captureGroup->setEnabled(true); sequenceProgress->setEnabled(true); @@ -2810,10 +2811,17 @@ } } +void Manager::updateDownloadProgress(double timeLeft) +{ + imageCountDown.setHMS(0, 0, 0); + imageCountDown = imageCountDown.addSecs(timeLeft); + imageRemainingTime->setText(imageCountDown.toString("hh:mm:ss")); +} + void Manager::updateExposureProgress(Ekos::SequenceJob * job) { imageCountDown.setHMS(0, 0, 0); - imageCountDown = imageCountDown.addSecs(job->getExposeLeft()); + imageCountDown = imageCountDown.addSecs(job->getExposeLeft() + captureProcess->getEstimatedDownloadTime()); if (imageCountDown.hour() == 23) imageCountDown.setHMS(0, 0, 0);