8#include "capturemodulestate.h"
12#include "kstarsdata.h"
13#include "auxiliary/ksmessagebox.h"
14#include "ekos/manager.h"
15#include "ekos/auxiliary/darklibrary.h"
16#include "ekos/auxiliary/filtermanager.h"
17#include "ekos/auxiliary/opticaltrainmanager.h"
18#include "ekos/auxiliary/opticaltrainsettings.h"
19#include "ekos/auxiliary/profilesettings.h"
20#include "ekos/auxiliary/rotatorutils.h"
21#include "capturedeviceadaptor.h"
22#include "cameraprocess.h"
23#include "sequencequeue.h"
24#include "scriptsmanager.h"
25#include "dslrinfodialog.h"
26#include "ui_dslrinfo.h"
27#include "exposurecalculator/exposurecalculatordialog.h"
29#include "indi/driverinfo.h"
30#include "indi/indirotator.h"
31#include "oal/observeradd.h"
33#include <ekos_capture_debug.h>
40#define KEY_FORMATS "formatsList"
41#define KEY_GAIN_KWD "ccdGainKeyword"
42#define KEY_OFFSET_KWD "ccdOffsetKeyword"
43#define KEY_TEMPERATURE "ccdTemperatures"
44#define KEY_TIMESTAMP "timestamp"
45#define KEY_FILTERS "filtersList"
46#define KEY_ISOS "isoList"
47#define KEY_INDEX "isoIndex"
48#define KEY_GAIN_KWD "ccdGainKeyword"
49#define KEY_OFFSET_KWD "ccdOffsetKeyword"
51#define QCDEBUG qCDebug(KSTARS_EKOS_CAPTURE) << QString("[%1]").arg(getCameraName())
52#define QCINFO qCInfo(KSTARS_EKOS_CAPTURE) << QString("[%1]").arg(getCameraName())
53#define QCWARNING qCWarning(KSTARS_EKOS_CAPTURE) << QString("[%1]").arg(getCameraName())
57const QStringList standAloneKeys = {KEY_FORMATS, KEY_GAIN_KWD, KEY_OFFSET_KWD,
58 KEY_TEMPERATURE, KEY_TIMESTAMP, KEY_FILTERS,
59 KEY_ISOS, KEY_INDEX, KEY_GAIN_KWD, KEY_OFFSET_KWD
61QVariantMap copyStandAloneSettings(
const QVariantMap &settings)
63 QVariantMap foundSettings;
64 for (
const auto &k : standAloneKeys)
66 auto v = settings.find(k);
67 if (v != settings.end())
68 foundSettings[k] = *v;
77Camera::Camera(
int id,
bool standAlone,
QWidget *parent)
78 :
QWidget{parent}, m_standAlone(standAlone), m_cameraId(id)
83Camera::Camera(
bool standAlone,
QWidget *parent) :
QWidget{parent}, m_standAlone(standAlone), m_cameraId(0)
88void Ekos::Camera::init()
91 m_cameraState.
reset(
new CameraState());
92 m_DeviceAdaptor.
reset(
new CaptureDeviceAdaptor());
93 m_cameraProcess.reset(
new CameraProcess(state(), m_DeviceAdaptor));
95 m_customPropertiesDialog.reset(
new CustomProperties());
96 m_LimitsDialog =
new QDialog(
this);
97 m_LimitsUI.reset(
new Ui::Limits());
98 m_LimitsUI->setupUi(m_LimitsDialog);
100 m_CalibrationDialog =
new QDialog(
this);
101 m_CalibrationUI.reset(
new Ui::Calibration());
102 m_CalibrationUI->setupUi(m_CalibrationDialog);
104 m_scriptsManager =
new ScriptsManager(
this);
109 auto title =
i18n(
"Capture Sequence Editor: %1", m_LimitsDialog->windowTitle());
110 m_LimitsDialog->setWindowTitle(title);
111 title =
i18n(
"Capture Sequence Editor: %1", m_scriptsManager->windowTitle());
112 m_scriptsManager->setWindowTitle(title);
120 videoDurationUnitCB->addItem(
i18n(
"sec"));
121 videoDurationUnitCB->addItem(
i18n(
"frames"));
124 targetDriftLabel->setVisible(
false);
125 targetDrift->setVisible(
false);
126 targetDriftUnit->setVisible(
false);
127 avgDownloadTime->setVisible(
false);
128 avgDownloadLabel->setVisible(
false);
129 secLabel->setVisible(
false);
130 darkB->setChecked(Options::autoDark());
170 addToQueueB->setToolTip(
i18n(
"Add job to sequence queue"));
171 removeFromQueueB->setToolTip(
i18n(
"Remove job from sequence queue"));
173 if (Options::remoteCaptureDirectory().isEmpty() ==
false)
175 fileRemoteDirT->setText(Options::remoteCaptureDirectory());
178 if(!Options::captureDirectory().isEmpty())
179 fileDirectoryT->setText(Options::captureDirectory());
188 for (
auto &button : qButtons)
189 button->setAutoDefault(
false);
193 refreshOpticalTrain();
198 foreach (
auto job, state()->allJobs())
201 state()->allJobs().clear();
204void Camera::initCamera()
206 KStarsData::Instance()->
userdb()->GetAllDSLRInfos(state()->DSLRInfos());
207 state()->getSequenceQueue()->loadOptions();
209 if (state()->DSLRInfos().count() > 0)
211 QCDEBUG <<
"DSLR Cameras Info:";
212 QCDEBUG << state()->DSLRInfos();
215 setupOpticalTrainManager();
218 state()->getMeridianFlipState();
235 restartCamera(activeCamera()->getDeviceName());
240 static_cast<void(Camera::*)()
>(&Camera::saveSequenceQueue));
243 &Camera::selectedJobChanged);
247 resetJobEdit(m_JobUnderEdit);
272 connect(m_FilterManager.
get(), &FilterManager::ready,
this, &Camera::updateCurrentFilterPosition);
277 state()->updateHFRThreshold();
278 generatePreviewFilename();
289 m_CalibrationUI->captureCalibrationParkMount->setChecked(false);
294 m_CalibrationUI->captureCalibrationWall->setChecked(false);
304 if (devices()->getActiveCamera())
306 QVariantMap auxInfo = devices()->getActiveCamera()->getDriverInfo()->getAuxInfo();
307 auxInfo[
QString(
"%1_TC").
arg(devices()->getActiveCamera()->getDeviceName())] = toggled;
308 devices()->getActiveCamera()->getDriverInfo()->setAuxInfo(auxInfo);
313 if (devices()->getActiveCamera())
314 devices()->getActiveCamera()->setTemperature(cameraTemperatureN->value());
318 if (devices()->getActiveCamera())
319 devices()->getActiveCamera()->setCoolerControl(
true);
323 if (devices()->getActiveCamera())
324 devices()->getActiveCamera()->setCoolerControl(
false);
330 placeholderFormatT->setText(KSUtils::getDefaultPath(
"PlaceholderFormat"));
334 &Camera::checkFrameType);
338 &Camera::updateVideoDurationUnit);
343 if (checked == false)
344 state()->getRefocusState()->setInSequenceFocus(false);
350 connect(m_cameraState.
get(), &CameraState::newLimitFocusHFR,
this, [
this](
double hfr)
352 m_LimitsUI->hFRDeviation->setValue(hfr);
355 state()->getCaptureDelayTimer().setSingleShot(
true);
359 state()->getCaptureTimeout().setSingleShot(
true);
365 &Camera::checkUploadMode);
369 customPropertiesDialog()->
show();
370 customPropertiesDialog()->
raise();
373 connect(customPropertiesDialog(), &CustomProperties::valueChanged,
this, [&]()
375 const double newGain = getGain();
376 if (captureGainN && newGain >= 0)
377 captureGainN->setValue(newGain);
378 const int newOffset = getOffset();
380 captureOffsetN->setValue(newOffset);
384 connect(m_cameraState.
data(), &CameraState::newStatus, captureStatusWidget, &LedStatusWidget::setCaptureState);
389 loadGlobalSettings();
390 connectSyncSettings();
394 updateHFRCheckAlgo();
397 updateHFRCheckAlgo();
400 updateHFRCheckAlgo();
407 generatePreviewFilename();
412 generatePreviewFilename();
416 &Camera::generatePreviewFilename);
419 generatePreviewFilename();
420 QCDEBUG <<
"Changed target to" << targetNameT->text() <<
"because of user edit";
423 placeholderFormatT->setText(Options::placeholderFormat());
426 generatePreviewFilename();
430 connect(m_cameraState.
data(), &CameraState::captureBusy,
this, &Camera::setBusy);
431 connect(m_cameraState.
data(), &CameraState::startCapture,
this, &Camera::start);
432 connect(m_cameraState.
data(), &CameraState::abortCapture,
this, &Camera::abort);
433 connect(m_cameraState.
data(), &CameraState::suspendCapture,
this, &Camera::suspend);
434 connect(m_cameraState.
data(), &CameraState::newLog,
this, &Camera::appendLogText);
435 connect(m_cameraState.
data(), &CameraState::sequenceChanged,
this, &Camera::sequenceChanged);
436 connect(m_cameraState.
data(), &CameraState::updatePrepareState,
this, &Camera::updatePrepareState);
437 connect(m_cameraState.
data(), &CameraState::newFocusStatus,
this, &Camera::updateFocusStatus);
438 connect(m_cameraState.
data(), &CameraState::runAutoFocus,
this,
439 [&](AutofocusReason autofocusReason,
const QString & reasonInfo)
441 emit runAutoFocus(autofocusReason, reasonInfo, opticalTrain());
443 connect(m_cameraState.
data(), &CameraState::resetFocusFrame,
this, [&]()
445 emit resetFocusFrame(opticalTrain());
447 connect(m_cameraState.
data(), &CameraState::adaptiveFocus,
this, [&]()
449 emit adaptiveFocus(opticalTrain());
451 connect(m_cameraProcess.data(), &CameraProcess::abortFocus,
this, [&]()
453 emit abortFocus(opticalTrain());
455 connect(m_cameraState.
data(), &CameraState::newMeridianFlipStage,
this, &Camera::updateMeridianFlipStage);
456 connect(m_cameraState.
data(), &CameraState::guideAfterMeridianFlip,
this, &Camera::guideAfterMeridianFlip);
457 connect(m_cameraState.
data(), &CameraState::resetNonGuidedDither,
this, [&]()
461 emit resetNonGuidedDither();
463 connect(m_cameraState.
data(), &CameraState::newStatus,
this, &Camera::updateCameraStatus);
464 connect(m_cameraState.
data(), &CameraState::meridianFlipStarted,
this, [&]()
466 emit meridianFlipStarted(opticalTrain());
469 connect(m_cameraProcess.data(), &CameraProcess::refreshCamera,
this, &Camera::updateCamera);
470 connect(m_cameraProcess.data(), &CameraProcess::sequenceChanged,
this, &Camera::sequenceChanged);
471 connect(m_cameraProcess.data(), &CameraProcess::addJob,
this, &Camera::addJob);
472 connect(m_cameraProcess.data(), &CameraProcess::newExposureProgress,
this, [&](
SequenceJob * job)
474 emit newExposureProgress(job, opticalTrain());
476 connect(m_cameraProcess.data(), &CameraProcess::newDownloadProgress,
this, [&](
double downloadTimeLeft)
478 emit updateDownloadProgress(downloadTimeLeft, opticalTrain());
482 emit newImage(job, data, opticalTrain());
484 connect(m_cameraProcess.data(), &CameraProcess::captureComplete,
this, [&](
const QVariantMap & metadata)
486 emit captureComplete(metadata, opticalTrain());
488 connect(m_cameraProcess.data(), &CameraProcess::updateCaptureCountDown,
this, &Camera::updateCaptureCountDown);
489 connect(m_cameraProcess.data(), &CameraProcess::processingFITSfinished,
this, &Camera::processingFITSfinished);
490 connect(m_cameraProcess.data(), &CameraProcess::captureStopped,
this, &Camera::captureStopped);
491 connect(m_cameraProcess.data(), &CameraProcess::darkFrameCompleted,
this, &Camera::imageCapturingCompleted);
492 connect(m_cameraProcess.data(), &CameraProcess::updateMeridianFlipStage,
this, &Camera::updateMeridianFlipStage);
493 connect(m_cameraProcess.data(), &CameraProcess::syncGUIToJob,
this, &Camera::syncGUIToJob);
494 connect(m_cameraProcess.data(), &CameraProcess::refreshCameraSettings,
this, &Camera::refreshCameraSettings);
495 connect(m_cameraProcess.data(), &CameraProcess::updateFrameProperties,
this, &Camera::updateFrameProperties);
496 connect(m_cameraProcess.data(), &CameraProcess::rotatorReverseToggled,
this, &Camera::setRotatorReversed);
497 connect(m_cameraProcess.data(), &CameraProcess::refreshFilterSettings,
this, &Camera::refreshFilterSettings);
498 connect(m_cameraProcess.data(), &CameraProcess::suspendGuiding,
this, &Camera::suspendGuiding);
499 connect(m_cameraProcess.data(), &CameraProcess::resumeGuiding,
this, &Camera::resumeGuiding);
500 connect(m_cameraProcess.data(), &CameraProcess::driverTimedout,
this, &Camera::driverTimedout);
501 connect(m_cameraProcess.data(), &CameraProcess::createJob, [
this](SequenceJob::SequenceJobType jobType)
504 process()->jobCreated(createJob(jobType));
506 connect(m_cameraProcess.data(), &CameraProcess::updateJobTable,
this, &Camera::updateJobTable);
507 connect(m_cameraProcess.data(), &CameraProcess::newLog,
this, &Camera::appendLogText);
508 connect(m_cameraProcess.data(), &CameraProcess::stopCapture,
this, &Camera::stop);
509 connect(m_cameraProcess.data(), &CameraProcess::jobStarting,
this, &Camera::jobStarting);
510 connect(m_cameraProcess.data(), &CameraProcess::cameraReady,
this, &Camera::ready);
511 connect(m_cameraProcess.data(), &CameraProcess::captureAborted,
this, &Camera::captureAborted);
512 connect(m_cameraProcess.data(), &CameraProcess::captureRunning,
this, &Camera::captureRunning);
513 connect(m_cameraProcess.data(), &CameraProcess::captureImageStarted,
this, &Camera::captureImageStarted);
514 connect(m_cameraProcess.data(), &CameraProcess::jobExecutionPreparationStarted,
this,
515 &Camera::jobExecutionPreparationStarted);
516 connect(m_cameraProcess.data(), &CameraProcess::jobPrepared,
this, &Camera::jobPrepared);
517 connect(m_cameraProcess.data(), &CameraProcess::captureTarget,
this, &Camera::setTargetName);
518 connect(m_cameraProcess.data(), &CameraProcess::downloadingFrame,
this, [
this]()
520 captureStatusWidget->setStatus(i18n(
"Downloading..."), Qt::yellow);
522 connect(m_cameraProcess.data(), &CameraProcess::requestAction,
this, [&](CaptureWorkflowActionType action)
524 emit requestAction(m_cameraId, action);
528 connect(m_cameraState.
data(), &CameraState::executeActiveJob, m_cameraProcess.data(),
530 connect(m_cameraState.
data(), &CameraState::captureStarted, m_cameraProcess.data(),
532 connect(m_cameraState.
data(), &CameraState::requestAction,
this, [&](CaptureWorkflowActionType action)
534 emit requestAction(m_cameraId, action);
536 connect(m_cameraState.
data(), &CameraState::checkFocus,
this, [&](
double hfr)
538 emit checkFocus(hfr, opticalTrain());
540 connect(m_cameraState.
data(), &CameraState::resetNonGuidedDither,
this, [&]()
543 emit resetNonGuidedDither();
547 connect(m_DeviceAdaptor.
data(), &CaptureDeviceAdaptor::newCCDTemperatureValue,
this,
549 connect(m_DeviceAdaptor.
data(), &CaptureDeviceAdaptor::CameraConnected,
this, [
this](
bool connected)
551 CaptureSettingsGroup->setEnabled(connected);
552 fileSettingsGroup->setEnabled(connected);
553 sequenceBox->setEnabled(connected);
554 for (auto &oneChild : sequenceControlsButtonGroup->buttons())
555 oneChild->setEnabled(connected);
558 trainLayout->setEnabled(true);
560 connect(m_DeviceAdaptor.
data(), &CaptureDeviceAdaptor::FilterWheelConnected,
this, [
this](
bool connected)
562 FilterPosLabel->setEnabled(connected);
563 FilterPosCombo->setEnabled(connected);
564 filterManagerB->setEnabled(connected);
566 connect(m_DeviceAdaptor.
data(), &CaptureDeviceAdaptor::newRotator,
this, &Camera::setRotator);
567 connect(m_DeviceAdaptor.
data(), &CaptureDeviceAdaptor::newRotatorAngle,
this, &Camera::updateRotatorAngle,
569 connect(m_DeviceAdaptor.
data(), &CaptureDeviceAdaptor::newFilterWheel,
this, &Camera::setFilterWheel);
572 connect(m_cameraState.
data(), &CameraState::newFilterPosition,
573 m_DeviceAdaptor.
data(), &CaptureDeviceAdaptor::setFilterPosition);
574 connect(m_cameraState.
data(), &CameraState::abortFastExposure,
575 m_DeviceAdaptor.
data(), &CaptureDeviceAdaptor::abortFastExposure);
578 connect(m_DeviceAdaptor.
data(), &CaptureDeviceAdaptor::scopeStatusChanged,
579 m_cameraState.
data(), &CameraState::setScopeState);
580 connect(m_DeviceAdaptor.
data(), &CaptureDeviceAdaptor::pierSideChanged,
581 m_cameraState.
data(), &CameraState::setPierSide);
582 connect(m_DeviceAdaptor.
data(), &CaptureDeviceAdaptor::scopeParkStatusChanged,
583 m_cameraState.
data(), &CameraState::setScopeParkState);
584 connect(m_DeviceAdaptor.
data(), &CaptureDeviceAdaptor::domeStatusChanged,
585 m_cameraState.
data(), &CameraState::setDomeState);
586 connect(m_DeviceAdaptor.
data(), &CaptureDeviceAdaptor::dustCapStatusChanged,
587 m_cameraState.
data(), &CameraState::dustCapStateChanged);
590void Camera::updateRotatorAngle(
double value)
592 IPState RState = devices()->rotator()->absoluteAngleState();
593 if (RState == IPS_OK)
594 m_RotatorControlPanel->updateRotator(value);
596 m_RotatorControlPanel->updateGauge(value);
599void Camera::setRotatorReversed(
bool toggled)
601 m_RotatorControlPanel->reverseDirection->setEnabled(
true);
602 m_RotatorControlPanel->reverseDirection->blockSignals(
true);
603 m_RotatorControlPanel->reverseDirection->setChecked(toggled);
604 m_RotatorControlPanel->reverseDirection->blockSignals(
false);
607void Camera::updateCCDTemperature(
double value)
609 if (cameraTemperatureS->isEnabled() ==
false && devices()->getActiveCamera())
611 if (devices()->getActiveCamera()->getPermission(
"CCD_TEMPERATURE") != IP_RO)
612 process()->checkCamera();
615 temperatureOUT->setText(
QString(
"%L1º").arg(value, 0,
'f', 1));
617 if (cameraTemperatureN->cleanText().isEmpty())
618 cameraTemperatureN->setValue(value);
621void Camera::setFocusStatus(FocusState newstate)
624 state()->updateFocusState(newstate);
627void Camera::updateFocusStatus(FocusState newstate)
629 if ((state()->getRefocusState()->isRefocusing()
630 || state()->getRefocusState()->isInSequenceFocus()) && activeJob()
631 && activeJob()->getStatus() == JOB_BUSY)
636 appendLogText(
i18n(
"Focus complete."));
637 captureStatusWidget->setStatus(
i18n(
"Focus complete."),
Qt::yellow);
641 captureStatusWidget->setStatus(
i18n(
"Autofocus failed."),
Qt::darkRed);
650void Camera::updateCamera(
bool isValid)
652 auto isConnected = activeCamera() && activeCamera()->isConnected();
653 CaptureSettingsGroup->setEnabled(isConnected);
654 fileSettingsGroup->setEnabled(isConnected);
655 sequenceBox->setEnabled(isConnected);
656 for (
auto &oneChild : sequenceControlsButtonGroup->buttons())
657 oneChild->setEnabled(isConnected);
661 auto name = activeCamera()->getDeviceName();
662 opticalTrainCombo->setToolTip(
QString(
"%1 @ %2").arg(name, currentScope()[
"name"].
toString()));
663 emit settingsUpdated(getAllSettings());
664 emit refreshCamera(m_cameraId,
true);
667 emit refreshCamera(m_cameraId,
false);
671void Camera::refreshCameraSettings()
675 auto camera = activeCamera();
676 auto targetChip = devices()->getActiveChip();
678 if (!m_standAlone && (!camera || !targetChip || !targetChip->getCCD() || targetChip->isCapturing()))
684 if (camera->hasCoolerControl())
686 coolerOnB->setEnabled(
true);
687 coolerOffB->setEnabled(
true);
688 coolerOnB->setChecked(camera->isCoolerOn());
689 coolerOffB->setChecked(!camera->isCoolerOn());
693 coolerOnB->setEnabled(
false);
694 coolerOnB->setChecked(
false);
695 coolerOffB->setEnabled(
false);
696 coolerOffB->setChecked(
false);
699 updateFrameProperties();
701 updateCaptureFormats();
703 customPropertiesDialog()->setCCD(camera);
705 liveVideoB->setEnabled(camera->hasVideoStream());
706 if (camera->hasVideoStream())
707 setVideoStreamEnabled(camera->isStreamingEnabled());
723 DarkLibrary::Instance()->checkCamera();
726void Camera::processCameraNumber(INDI::Property prop)
728 if (devices()->getActiveCamera() ==
nullptr)
731 if ((prop.isNameMatch(
"CCD_FRAME") && state()->useGuideHead() ==
false) ||
732 (prop.isNameMatch(
"GUIDER_FRAME") && state()->useGuideHead()))
733 updateFrameProperties();
734 else if ((prop.isNameMatch(
"CCD_INFO") && state()->useGuideHead() ==
false) ||
735 (prop.isNameMatch(
"GUIDER_INFO") && state()->useGuideHead()))
736 updateFrameProperties(1);
737 else if (prop.isNameMatch(
"CCD_TRANSFER_FORMAT") || prop.isNameMatch(
"CCD_CAPTURE_FORMAT"))
738 updateCaptureFormats();
739 else if (prop.isNameMatch(
"CCD_CONTROLS"))
741 auto nvp = prop.getNumber();
742 auto gain = nvp->findWidgetByName(
"Gain");
745 auto offset = nvp->findWidgetByName(
"Offset");
749 else if (prop.isNameMatch(
"CCD_GAIN"))
751 auto nvp = prop.getNumber();
752 currentGainLabel->setText(
QString::number(nvp->at(0)->getValue(),
'f', 0));
754 else if (prop.isNameMatch(
"CCD_OFFSET"))
756 auto nvp = prop.getNumber();
757 currentOffsetLabel->setText(
QString::number(nvp->at(0)->getValue(),
'f', 0));
762void Camera::updateTargetDistance(
double targetDiff)
765 targetDriftLabel->setVisible(
true);
766 targetDrift->setVisible(
true);
767 targetDriftUnit->setVisible(
true);
769 targetDrift->setText(
QString(
"%L1").arg(targetDiff, 0,
'd', 1));
781 return CCDFrameTypeNames[
type];
787 return CCDFrameTypeNames[
type];
789 return QString(
"%1 %2").
arg(filter).
arg(CCDFrameTypeNames[type]);
795 return CCDFrameTypeNames[
type];
800void Camera::captureRunning()
802 emit captureStarting(activeJob()->getCoreProperty(SequenceJob::SJ_Exposure).toDouble(),
803 activeJob()->getCoreProperty(SequenceJob::SJ_Filter).
toString());
804 if (isActiveJobPreview())
805 frameInfoLabel->setText(
"Expose (-/-):");
806 else if (activeJob()->getFrameType() != FRAME_VIDEO)
807 frameInfoLabel->setText(
QString(
"%1 (%L2/%L3):").arg(frameLabel(activeJob()->getFrameType(),
808 activeJob()->getCoreProperty(SequenceJob::SJ_Filter).
toString()))
809 .arg(activeJob()->getCompleted()).arg(activeJob()->getCoreProperty(
810 SequenceJob::SJ_Count).toInt()));
812 frameInfoLabel->setText(
QString(
"%1 (%2x%L3s):").arg(frameLabel(activeJob()->getFrameType(),
813 activeJob()->getCoreProperty(SequenceJob::SJ_Filter).
toString()))
814 .arg(activeJob()->getCoreProperty(SequenceJob::SJ_Count).toInt())
815 .arg(activeJob()->getCoreProperty(SequenceJob::SJ_Exposure).toDouble(), 0,
'f', 3));
818 avgDownloadTime->setVisible(
true);
819 avgDownloadLabel->setVisible(
true);
820 secLabel->setVisible(
true);
822 avgDownloadTime->setText(
QString(
"%L1").arg(state()->averageDownloadTime(), 0,
'd', 2));
825 if (state()->isLooping() ==
false)
827 if (activeJob()->getFrameType() == FRAME_VIDEO)
828 appendLogText(
i18n(
"Capturing %1 x %2-second %3 video...",
829 activeJob()->getCoreProperty(SequenceJob::SJ_Count).toInt(),
830 QString(
"%L1").arg(activeJob()->getCoreProperty(SequenceJob::SJ_Exposure).toDouble(), 0,
'f', 3),
831 activeJob()->getCoreProperty(SequenceJob::SJ_Filter).
toString()));
833 else if (activeJob()->jobType() != SequenceJob::JOBTYPE_PREVIEW)
834 appendLogText(
i18n(
"Capturing %1-second %2 image...",
835 QString(
"%L1").arg(activeJob()->getCoreProperty(SequenceJob::SJ_Exposure).toDouble(), 0,
'f', 3),
836 activeJob()->getCoreProperty(SequenceJob::SJ_Filter).
toString()));
840void Camera::captureImageStarted()
842 if (devices()->filterWheel() !=
nullptr)
846 process()->updateFilterInfo();
847 updateCurrentFilterPosition();
851 if (activeJob()->getCalibrationStage() == SequenceJobState::CAL_CALIBRATION)
852 captureStatusWidget->setStatus(
i18n(
"Calibrating..."),
Qt::yellow);
855void Camera::jobExecutionPreparationStarted()
857 if (activeJob() ==
nullptr)
860 qWarning(KSTARS_EKOS_CAPTURE) <<
"jobExecutionPreparationStarted with null state()->getActiveJob().";
863 if (activeJob()->jobType() == SequenceJob::JOBTYPE_PREVIEW)
864 updateStartButtons(
true,
false);
869 int index = state()->allJobs().indexOf(job);
871 queueTable->selectRow(index);
873 if (activeJob()->jobType() != SequenceJob::JOBTYPE_PREVIEW)
876 imgProgress->setEnabled(
true);
877 imgProgress->setMaximum(activeJob()->getCoreProperty(SequenceJob::SJ_Count).toInt());
878 imgProgress->setValue(activeJob()->getCompleted());
882void Camera::setTargetName(
const QString &newTargetName)
885 if (activeJob() ==
nullptr)
888 targetNameT->setText(newTargetName);
889 auto rows = queueTable->selectionModel()->selectedRows();
893 int pos = rows.constFirst().row();
895 if (state()->allJobs().
size() >
pos)
896 state()->allJobs().at(
pos)->setCoreProperty(SequenceJob::SJ_TargetName, newTargetName);
899 emit captureTarget(newTargetName);
903void Camera::jobStarting()
905 if (m_LimitsUI->enforceAutofocusHFR->isChecked() && state()->getRefocusState()->isAutoFocusReady() ==
false)
906 appendLogText(
i18n(
"Warning: in-sequence focusing is selected but autofocus process was not started."));
907 if (m_LimitsUI->enforceAutofocusOnTemperature->isChecked()
908 && state()->getRefocusState()->isAutoFocusReady() ==
false)
909 appendLogText(
i18n(
"Warning: temperature delta check is selected but autofocus process was not started."));
911 updateStartButtons(
true,
false);
915void Camera::capturePreview()
917 process()->capturePreview();
920void Camera::startFraming()
922 process()->capturePreview(
true);
925void Camera::generateDarkFlats()
927 const auto existingJobs = state()->allJobs().size();
928 uint8_t jobsAdded = 0;
930 for (
int i = 0; i < existingJobs; i++)
932 if (state()->allJobs().at(i)->getFrameType() != FRAME_FLAT)
935 syncGUIToJob(state()->allJobs().at(i));
937 captureTypeS->setCurrentIndex(FRAME_DARK);
938 createJob(SequenceJob::JOBTYPE_DARKFLAT);
944 appendLogText(
i18np(
"One dark flats job was created.",
"%1 dark flats jobs were created.", jobsAdded));
948void Camera::updateDownloadProgress(
double downloadTimeLeft,
const QString &devicename)
950 frameRemainingTime->setText(state()->imageCountDown().
toString(
"hh:mm:ss"));
951 emit newDownloadProgress(downloadTimeLeft, devicename);
954void Camera::updateCaptureCountDown(
int deltaMillis)
956 state()->imageCountDownAddMSecs(deltaMillis);
957 state()->sequenceCountDownAddMSecs(deltaMillis);
958 frameRemainingTime->setText(state()->imageCountDown().
toString(
"hh:mm:ss"));
959 if (!isActiveJobPreview())
960 jobRemainingTime->setText(state()->sequenceCountDown().
toString(
"hh:mm:ss"));
962 jobRemainingTime->setText(
"--:--:--");
968 createNewJobTableRow(job);
971void Camera::editJobFinished()
973 if (queueTable->currentRow() < 0)
974 QCWARNING <<
"Editing finished, but no row selected!";
976 int currentRow = queueTable->currentRow();
977 SequenceJob *job = state()->allJobs().at(currentRow);
978 updateJobFromUI(job);
981 updateJobTable(job,
true);
984 QJsonObject jsonJob = createJsonJob(job, currentRow);
985 state()->getSequence().replace(currentRow, jsonJob);
986 emit sequenceChanged(state()->getSequence());
989 appendLogText(
i18n(
"Job #%1 changes applied.", currentRow + 1));
992void Camera::imageCapturingCompleted()
1000 if (state()->isLooping())
1008 if (devices()->getActiveCamera()->isFastExposureEnabled() ==
false)
1009 DarkLibrary::Instance()->disconnect(
this);
1012 if (thejob->getCoreProperty(SequenceJob::SJ_Exposure).toDouble() >= 1)
1013 KSNotification::event(
QLatin1String(
"EkosCaptureImageReceived"),
i18n(
"Captured image received"),
1014 KSNotification::Capture);
1017 if (thejob->jobType() == SequenceJob::JOBTYPE_PREVIEW)
1021 imgProgress->setValue(thejob->getCompleted());
1024void Camera::captureStopped()
1026 imgProgress->reset();
1027 imgProgress->setEnabled(
false);
1029 frameRemainingTime->setText(
"--:--:--");
1030 jobRemainingTime->setText(
"--:--:--");
1031 frameInfoLabel->setText(
i18n(
"Expose (-/-):"));
1034 auto captureState = state()->getCaptureState();
1036 updateStartButtons(
false,
false);
1039void Camera::processingFITSfinished(
bool success)
1042 if (success ==
false)
1046 if (devices()->getActiveCamera()
1047 && devices()->getActiveCamera()->getUploadMode() != ISD::Camera::UPLOAD_LOCAL)
1048 previewB->setEnabled(
true);
1050 imageCapturingCompleted();
1053void Camera::checkFrameType(
int index)
1055 updateCaptureFormats();
1057 calibrationB->setEnabled(index != FRAME_LIGHT);
1058 generateDarkFlatsB->setEnabled(index != FRAME_LIGHT);
1059 const bool isVideo = captureTypeS->currentText() == CAPTURE_TYPE_VIDEO;
1060 exposureOptions->setCurrentIndex(isVideo ? 1 : 0);
1061 exposureOptionsLabel->setToolTip(isVideo ?
i18n(
"Duration of the video sequence") :
i18n(
"Number of images to capture"));
1062 exposureOptionsLabel->setText(isVideo ?
i18n(
"Duration:") :
i18n(
"Count:"));
1063 exposureLabel->setToolTip(isVideo ?
i18n(
"Exposure time in seconds of a single video frame") :
1064 i18n(
"Exposure time in seconds for individual images"));
1068 selectUploadMode(ISD::Camera::UPLOAD_LOCAL);
1070 checkUploadMode(fileUploadModeS->currentIndex());
1073void Camera::updateStartButtons(
bool start,
bool pause)
1079 startB->setToolTip(
i18n(
"Stop Sequence"));
1085 startB->setToolTip(
i18n(pause ?
"Resume Sequence" :
"Start Sequence"));
1087 pauseB->setEnabled(start && !pause);
1090void Camera::setBusy(
bool enable)
1092 previewB->setEnabled(!enable);
1093 loopB->setEnabled(!enable);
1094 opticalTrainCombo->setEnabled(!enable);
1095 trainB->setEnabled(!enable);
1102void Camera::updatePrepareState(CaptureState prepareState)
1104 state()->setCaptureState(prepareState);
1106 if (activeJob() ==
nullptr)
1108 qWarning(KSTARS_EKOS_CAPTURE) <<
"updatePrepareState with null activeJob().";
1113 switch (prepareState)
1116 appendLogText(
i18n(
"Setting temperature to %1 °C...", activeJob()->getTargetTemperature()));
1117 captureStatusWidget->setStatus(
i18n(
"Set Temp to %1 °C...", activeJob()->getTargetTemperature()),
1121 appendLogText(
i18n(
"Waiting for guide drift below %1\"...", Options::startGuideDeviation()));
1122 captureStatusWidget->setStatus(
i18n(
"Wait for Guider < %1\"...", Options::startGuideDeviation()),
Qt::yellow);
1126 appendLogText(
i18n(
"Setting camera to %1 degrees E of N...", activeJob()->getTargetRotation()));
1127 captureStatusWidget->setStatus(
i18n(
"Set Camera to %1 deg...", activeJob()->getTargetRotation()),
1137SequenceJob *Camera::createJob(SequenceJob::SequenceJobType jobtype, FilenamePreviewType filenamePreview)
1141 updateJobFromUI(job, filenamePreview);
1144 if (jobtype == SequenceJob::JOBTYPE_PREVIEW || filenamePreview != FILENAME_NOT_PREVIEW)
1148 if (checkUploadPaths(filenamePreview) ==
false)
1152 state()->allJobs().append(job);
1155 createNewJobTableRow(job);
1160bool Camera::removeJob(
int index)
1172 if (index < 0 || index >= state()->allJobs().count())
1175 queueTable->removeRow(index);
1176 QJsonArray seqArray = state()->getSequence();
1178 state()->setSequence(seqArray);
1179 emit sequenceChanged(seqArray);
1181 if (state()->allJobs().empty())
1186 state()->removeCapturedFrameCount(job->getSignature(), job->getCompleted());
1188 state()->allJobs().removeOne(job);
1189 if (job == activeJob())
1190 state()->setActiveJob(
nullptr);
1194 if (queueTable->rowCount() == 0)
1195 removeFromQueueB->setEnabled(
false);
1197 if (queueTable->rowCount() == 1)
1199 queueUpB->setEnabled(
false);
1200 queueDownB->setEnabled(
false);
1203 if (index < queueTable->rowCount())
1204 queueTable->selectRow(index);
1205 else if (queueTable->rowCount() > 0)
1206 queueTable->selectRow(queueTable->rowCount() - 1);
1208 if (queueTable->rowCount() == 0)
1210 queueSaveAsB->setEnabled(
false);
1211 queueSaveB->setEnabled(
false);
1212 resetB->setEnabled(
false);
1215 state()->setDirty(
true);
1220bool Camera::modifyJob(
int index)
1228 if (index < 0 || index >= state()->allJobs().count())
1231 queueTable->selectRow(index);
1232 auto modelIndex = queueTable->model()->index(index, 0);
1233 editJob(modelIndex);
1237void Camera::loadSequenceQueue()
1241 "Ekos Sequence Queue (*.esq)");
1245 if (fileURL.
isValid() ==
false)
1248 KSNotification::sorry(message,
i18n(
"Invalid URL"));
1257void Camera::saveSequenceQueue()
1259 QUrl backupCurrent = state()->sequenceURL();
1261 if (state()->sequenceURL().toLocalFile().startsWith(
QLatin1String(
"/tmp/"))
1262 || state()->sequenceURL().toLocalFile().contains(
"/Temp"))
1263 state()->setSequenceURL(
QUrl(
""));
1266 if (state()->dirty() ==
false && !state()->sequenceURL().isEmpty())
1269 if (state()->sequenceURL().isEmpty())
1272 "Save Ekos Sequence Queue"),
1274 "Ekos Sequence Queue (*.esq)"));
1276 if (state()->sequenceURL().isEmpty())
1278 state()->setSequenceURL(backupCurrent);
1284 if (state()->sequenceURL().toLocalFile().endsWith(
QLatin1String(
".esq")) ==
false)
1285 state()->setSequenceURL(
QUrl(
"file:" + state()->sequenceURL().toLocalFile() +
".esq"));
1289 if (state()->sequenceURL().
isValid())
1292 if ((process()->saveSequenceQueue(state()->sequenceURL().toLocalFile(), !m_standAlone)) ==
false)
1294 KSNotification::error(
i18n(
"Failed to save sequence queue"),
i18n(
"Save"));
1298 state()->setDirty(
false);
1302 QString message =
i18n(
"Invalid URL: %1", state()->sequenceURL().url());
1303 KSNotification::sorry(message,
i18n(
"Invalid URL"));
1308void Camera::saveSequenceQueueAs()
1310 state()->setSequenceURL(
QUrl(
""));
1311 saveSequenceQueue();
1314void Camera::updateJobTable(
SequenceJob * job,
bool full)
1319 while (iter.hasNext())
1320 updateJobTable(iter.next(), full);
1325 int row = state()->allJobs().indexOf(job);
1326 if (row >= 0 && row < queueTable->rowCount())
1328 updateRowStyle(job);
1331 status->setText(job->getStatusString());
1332 updateJobTableCountCell(job, count);
1336 bool isDarkFlat = job->jobType() == SequenceJob::JOBTYPE_DARKFLAT;
1339 if (FilterPosCombo->findText(job->getCoreProperty(SequenceJob::SJ_Filter).toString()) >= 0 &&
1340 (captureTypeS->currentIndex() == FRAME_LIGHT || captureTypeS->currentIndex() == FRAME_FLAT
1341 || captureTypeS->currentIndex() == FRAME_VIDEO || isDarkFlat) )
1342 filter->setText(job->getCoreProperty(SequenceJob::SJ_Filter).toString());
1347 exp->
setText(
QString(
"%L1").arg(job->getCoreProperty(SequenceJob::SJ_Exposure).toDouble(), 0,
'f',
1348 captureExposureN->decimals()));
1351 type->setText(isDarkFlat ?
i18n(
"Dark Flat") : CCDFrameTypeNames[job->getFrameType()]);
1354 QPoint binning = job->getCoreProperty(SequenceJob::SJ_Binning).toPoint();
1358 if (job->getCoreProperty(SequenceJob::SJ_ISOIndex).toInt() != -1)
1359 iso->
setText(captureISOS->itemText(job->getCoreProperty(SequenceJob::SJ_ISOIndex).toInt()));
1360 else if (job->getCoreProperty(SequenceJob::SJ_Gain).toDouble() >= 0)
1366 if (job->getCoreProperty(SequenceJob::SJ_Offset).toDouble() >= 0)
1373 queueTable->resizeColumnsToContents();
1377 if (queueTable->rowCount() > 0)
1379 queueSaveAsB->setEnabled(
true);
1380 queueSaveB->setEnabled(
true);
1381 resetB->setEnabled(
true);
1382 state()->setDirty(
true);
1385 if (queueTable->rowCount() > 1)
1387 queueUpB->setEnabled(
true);
1388 queueDownB->setEnabled(
true);
1394void Camera::updateJobFromUI(
SequenceJob * job, FilenamePreviewType filenamePreview)
1396 job->setCoreProperty(SequenceJob::SJ_Format, captureFormatS->currentText());
1397 job->setCoreProperty(SequenceJob::SJ_Encoding, captureEncodingS->currentText());
1400 job->setISO(captureISOS->currentIndex());
1402 job->setCoreProperty(SequenceJob::SJ_Gain, getGain());
1403 job->setCoreProperty(SequenceJob::SJ_Offset, getOffset());
1405 if (cameraTemperatureN->isEnabled())
1407 job->setCoreProperty(SequenceJob::SJ_EnforceTemperature, cameraTemperatureS->isChecked());
1408 job->setTargetTemperature(cameraTemperatureN->value());
1411 job->setScripts(m_scriptsManager->getScripts());
1412 job->setUploadMode(
static_cast<ISD::Camera::UploadMode
>(fileUploadModeS->currentIndex()));
1415 job->setFlatFieldDuration(m_CalibrationUI->captureCalibrationDurationManual->isChecked() ? DURATION_MANUAL :
1418 int action = CAPTURE_PREACTION_NONE;
1419 if (m_CalibrationUI->captureCalibrationParkMount->isChecked())
1420 action |= CAPTURE_PREACTION_PARK_MOUNT;
1421 if (m_CalibrationUI->captureCalibrationParkDome->isChecked())
1422 action |= CAPTURE_PREACTION_PARK_DOME;
1423 if (m_CalibrationUI->captureCalibrationWall->isChecked())
1425 bool azOk =
false, altOk =
false;
1426 auto wallAz = m_CalibrationUI->azBox->createDms(&azOk);
1427 auto wallAlt = m_CalibrationUI->altBox->createDms(&altOk);
1431 action = (action & ~CAPTURE_PREACTION_PARK_MOUNT) | CAPTURE_PREACTION_WALL;
1433 wallSkyPoint.
setAz(wallAz);
1434 wallSkyPoint.
setAlt(wallAlt);
1435 job->setWallCoord(wallSkyPoint);
1439 if (m_CalibrationUI->captureCalibrationUseADU->isChecked())
1441 job->setCoreProperty(SequenceJob::SJ_TargetADU, m_CalibrationUI->captureCalibrationADUValue->value());
1442 job->setCoreProperty(SequenceJob::SJ_TargetADUTolerance,
1443 m_CalibrationUI->captureCalibrationADUTolerance->value());
1444 job->setCoreProperty(SequenceJob::SJ_SkyFlat, m_CalibrationUI->captureCalibrationSkyFlats->isChecked());
1447 job->setCalibrationPreAction(action);
1449 job->setFrameType(
static_cast<CCDFrameType
>(qMax(0, captureTypeS->currentIndex())));
1451 if (FilterPosCombo->currentIndex() != -1 && (m_standAlone || devices()->filterWheel() !=
nullptr))
1452 job->setTargetFilter(FilterPosCombo->currentIndex() + 1, FilterPosCombo->currentText());
1454 job->setCoreProperty(SequenceJob::SJ_Exposure, captureExposureN->value());
1456 if (captureTypeS->currentText() == CAPTURE_TYPE_VIDEO)
1458 if (videoDurationUnitCB->currentIndex() == 0)
1460 job->setCoreProperty(SequenceJob::SJ_Count,
static_cast<int>(videoDurationSB->value() / captureExposureN->value()));
1463 job->setCoreProperty(SequenceJob::SJ_Count,
static_cast<int>(videoDurationSB->value()));
1467 job->setCoreProperty(SequenceJob::SJ_Count, captureCountN->value());
1469 job->setCoreProperty(SequenceJob::SJ_Binning,
QPoint(captureBinHN->value(), captureBinVN->value()));
1472 job->setCoreProperty(SequenceJob::SJ_Delay, captureDelayN->value() * 1000);
1475 job->setCustomProperties(customPropertiesDialog()->getCustomProperties());
1477 job->setCoreProperty(SequenceJob::SJ_ROI,
QRect(captureFrameXN->value(), captureFrameYN->value(),
1478 captureFrameWN->value(),
1479 captureFrameHN->value()));
1480 job->setCoreProperty(SequenceJob::SJ_RemoteDirectory, fileRemoteDirT->text());
1481 job->setCoreProperty(SequenceJob::SJ_LocalDirectory, fileDirectoryT->text());
1482 job->setCoreProperty(SequenceJob::SJ_TargetName, targetNameT->text());
1483 job->setCoreProperty(SequenceJob::SJ_PlaceholderFormat, placeholderFormatT->text());
1484 job->setCoreProperty(SequenceJob::SJ_PlaceholderSuffix, formatSuffixN->value());
1486 job->setCoreProperty(SequenceJob::SJ_DitherPerJobFrequency, m_LimitsUI->guideDitherPerJobFrequency->value());
1488 auto placeholderPath = PlaceholderPath();
1489 placeholderPath.updateFullPrefix(job, placeholderFormatT->text());
1491 QString signature = placeholderPath.generateSequenceFilename(*job,
1492 filenamePreview != FILENAME_REMOTE_PREVIEW,
true, 1,
1493 ".fits",
"",
false,
true);
1494 job->setCoreProperty(SequenceJob::SJ_Signature, signature);
1498void Camera::selectUploadMode(
int index)
1500 fileUploadModeS->setCurrentIndex(index);
1501 checkUploadMode(index);
1504void Camera::checkUploadMode(
int index)
1506 fileRemoteDirT->setEnabled(index != ISD::Camera::UPLOAD_CLIENT);
1507 fileDirectoryT->setEnabled(index != ISD::Camera::UPLOAD_LOCAL);
1509 const bool isVideo = captureTypeS->currentText() == CAPTURE_TYPE_VIDEO;
1522 generatePreviewFilename();
1529 qWarning(KSTARS_EKOS_CAPTURE) <<
"syncGuiToJob with null job.";
1534 const auto roi = job->getCoreProperty(SequenceJob::SJ_ROI).toRect();
1536 captureTypeS->setCurrentIndex(job->getFrameType());
1537 captureFormatS->setCurrentText(job->getCoreProperty(SequenceJob::SJ_Format).toString());
1538 captureEncodingS->setCurrentText(job->getCoreProperty(SequenceJob::SJ_Encoding).toString());
1539 captureExposureN->setValue(job->getCoreProperty(SequenceJob::SJ_Exposure).toDouble());
1540 captureBinHN->setValue(job->getCoreProperty(SequenceJob::SJ_Binning).toPoint().x());
1541 captureBinVN->setValue(job->getCoreProperty(SequenceJob::SJ_Binning).toPoint().y());
1542 captureFrameXN->setValue(roi.x());
1543 captureFrameYN->setValue(roi.y());
1544 captureFrameWN->setValue(roi.width());
1545 captureFrameHN->setValue(roi.height());
1546 FilterPosCombo->setCurrentIndex(job->getTargetFilter() - 1);
1547 captureCountN->setValue(job->getCoreProperty(SequenceJob::SJ_Count).toInt());
1548 captureDelayN->setValue(job->getCoreProperty(SequenceJob::SJ_Delay).toInt() / 1000);
1549 targetNameT->setText(job->getCoreProperty(SequenceJob::SJ_TargetName).toString());
1550 fileDirectoryT->setText(job->getCoreProperty(SequenceJob::SJ_LocalDirectory).toString());
1551 selectUploadMode(job->getUploadMode());
1552 fileRemoteDirT->setText(job->getCoreProperty(SequenceJob::SJ_RemoteDirectory).toString());
1553 placeholderFormatT->setText(job->getCoreProperty(SequenceJob::SJ_PlaceholderFormat).toString());
1554 formatSuffixN->setValue(job->getCoreProperty(SequenceJob::SJ_PlaceholderSuffix).toUInt());
1557 cameraTemperatureS->setChecked(job->getCoreProperty(SequenceJob::SJ_EnforceTemperature).toBool());
1558 if (job->getCoreProperty(SequenceJob::SJ_EnforceTemperature).toBool())
1559 cameraTemperatureN->setValue(job->getTargetTemperature());
1562 m_LimitsUI->guideDitherPerJobFrequency->setValue(job->getCoreProperty(
1563 SequenceJob::SJ_DitherPerJobFrequency).toInt());
1564 syncLimitSettings();
1567 calibrationB->setEnabled(job->getFrameType() != FRAME_LIGHT);
1568 generateDarkFlatsB->setEnabled(job->getFrameType() != FRAME_LIGHT);
1570 if (job->getFlatFieldDuration() == DURATION_MANUAL)
1571 m_CalibrationUI->captureCalibrationDurationManual->setChecked(
true);
1573 m_CalibrationUI->captureCalibrationUseADU->setChecked(
true);
1576 const auto action = job->getCalibrationPreAction();
1577 if (action & CAPTURE_PREACTION_WALL)
1579 m_CalibrationUI->azBox->setText(job->getWallCoord().az().toDMSString());
1580 m_CalibrationUI->altBox->setText(job->getWallCoord().alt().toDMSString());
1582 m_CalibrationUI->captureCalibrationWall->setChecked(action & CAPTURE_PREACTION_WALL);
1583 m_CalibrationUI->captureCalibrationParkMount->setChecked(action & CAPTURE_PREACTION_PARK_MOUNT);
1584 m_CalibrationUI->captureCalibrationParkDome->setChecked(action & CAPTURE_PREACTION_PARK_DOME);
1587 switch (job->getFlatFieldDuration())
1589 case DURATION_MANUAL:
1590 m_CalibrationUI->captureCalibrationDurationManual->setChecked(
true);
1594 m_CalibrationUI->captureCalibrationUseADU->setChecked(
true);
1595 m_CalibrationUI->captureCalibrationADUValue->setValue(job->getCoreProperty(SequenceJob::SJ_TargetADU).toUInt());
1596 m_CalibrationUI->captureCalibrationADUTolerance->setValue(job->getCoreProperty(
1597 SequenceJob::SJ_TargetADUTolerance).toUInt());
1598 m_CalibrationUI->captureCalibrationSkyFlats->setChecked(job->getCoreProperty(SequenceJob::SJ_SkyFlat).toBool());
1602 m_scriptsManager->setScripts(job->getScripts());
1605 customPropertiesDialog()->setCustomProperties(job->getCustomProperties());
1608 captureISOS->setCurrentIndex(job->getCoreProperty(SequenceJob::SJ_ISOIndex).toInt());
1610 double gain = getGain();
1612 captureGainN->setValue(gain);
1614 captureGainN->setValue(GainSpinSpecialValue);
1616 double offset = getOffset();
1618 captureOffsetN->setValue(offset);
1620 captureOffsetN->setValue(OffsetSpinSpecialValue);
1623 generatePreviewFilename();
1625 if (m_RotatorControlPanel)
1627 if (job->getTargetRotation() != Ekos::INVALID_VALUE)
1630 m_RotatorControlPanel->setCameraPA(job->getTargetRotation());
1638 if (Options::alignCheckFrequency() == 0)
1640 targetDriftLabel->setVisible(
false);
1641 targetDrift->setVisible(
false);
1642 targetDriftUnit->setVisible(
false);
1646void Camera::syncFrameType(
const QString &name)
1648 if (!activeCamera() || name != activeCamera()->getDeviceName())
1653 captureTypeS->clear();
1656 captureTypeS->setEnabled(
false);
1659 captureTypeS->setEnabled(
true);
1660 captureTypeS->addItems(frameTypes);
1661 ISD::CameraChip *tChip = devices()->getActiveCamera()->getChip(ISD::CameraChip::PRIMARY_CCD);
1662 captureTypeS->setCurrentIndex(tChip->getFrameType());
1666void Camera::syncCameraInfo()
1668 if (!activeCamera())
1671 const QString timestamp = KStarsData::Instance()->
lt().
toString(
"yyyy-MM-dd hh:mm");
1672 storeTrainKeyString(KEY_TIMESTAMP, timestamp);
1674 if (activeCamera()->hasCooler())
1676 cameraTemperatureS->setEnabled(
true);
1677 cameraTemperatureN->setEnabled(
true);
1679 if (activeCamera()->getPermission(
"CCD_TEMPERATURE") != IP_RO)
1681 double min, max, step;
1682 setTemperatureB->setEnabled(
true);
1683 cameraTemperatureN->setReadOnly(
false);
1684 cameraTemperatureS->setEnabled(
true);
1685 temperatureRegulationB->setEnabled(
true);
1686 activeCamera()->getMinMaxStep(
"CCD_TEMPERATURE",
"CCD_TEMPERATURE_VALUE", &min, &max, &step);
1687 cameraTemperatureN->setMinimum(min);
1688 cameraTemperatureN->setMaximum(max);
1689 cameraTemperatureN->setSingleStep(1);
1690 bool isChecked = activeCamera()->getDriverInfo()->getAuxInfo().value(
QString(
"%1_TC").arg(activeCamera()->getDeviceName()),
1692 cameraTemperatureS->setChecked(isChecked);
1698 isChecked ?
"1" :
"0" } );
1699 storeTrainKey(KEY_TEMPERATURE, temperatureList);
1703 setTemperatureB->setEnabled(
false);
1704 cameraTemperatureN->setReadOnly(
true);
1705 cameraTemperatureS->setEnabled(
false);
1706 cameraTemperatureS->setChecked(
false);
1707 temperatureRegulationB->setEnabled(
false);
1711 storeTrainKey(KEY_TEMPERATURE, temperatureList);
1714 double temperature = 0;
1715 if (activeCamera()->getTemperature(&temperature))
1717 temperatureOUT->setText(
QString(
"%L1º").arg(temperature, 0,
'f', 1));
1718 if (cameraTemperatureN->cleanText().isEmpty())
1719 cameraTemperatureN->setValue(temperature);
1724 cameraTemperatureS->setEnabled(
false);
1725 cameraTemperatureN->setEnabled(
false);
1726 temperatureRegulationB->setEnabled(
false);
1727 cameraTemperatureN->clear();
1728 temperatureOUT->clear();
1729 setTemperatureB->setEnabled(
false);
1732 auto isoList = devices()->getActiveChip()->getISOList();
1733 captureISOS->blockSignals(
true);
1734 captureISOS->setEnabled(
false);
1735 captureISOS->clear();
1738 if (isoList.isEmpty())
1740 captureISOS->setEnabled(
false);
1741 if (settings().contains(KEY_ISOS))
1743 settings().remove(KEY_ISOS);
1744 m_DebounceTimer.
start();
1746 if (settings().contains(KEY_INDEX))
1748 settings().remove(KEY_INDEX);
1749 m_DebounceTimer.
start();
1754 captureISOS->setEnabled(
true);
1755 captureISOS->addItems(isoList);
1756 const int isoIndex = devices()->getActiveChip()->getISOIndex();
1757 captureISOS->setCurrentIndex(isoIndex);
1760 storeTrainKey(KEY_ISOS, isoList);
1761 storeTrainKeyString(KEY_INDEX,
QString(
"%1").arg(isoIndex));
1765 double pixelX = 0, pixelY = 0;
1766 bool rc = devices()->getActiveChip()->getImageInfo(w, h, pixelX, pixelY, bbp);
1767 bool isModelInDB = state()->isModelinDSLRInfo(
QString(activeCamera()->getDeviceName()));
1770 if (rc ==
true && (pixelX == 0.0 || pixelY == 0.0 || isModelInDB ==
false))
1774 if (isModelInDB ==
false)
1781 process()->syncDSLRToTargetChip(model);
1785 captureISOS->blockSignals(
false);
1788 if (activeCamera()->hasGain())
1790 double min, max, step, value, targetCustomGain;
1791 activeCamera()->getGainMinMaxStep(&min, &max, &step);
1794 GainSpinSpecialValue = min - step;
1795 captureGainN->setRange(GainSpinSpecialValue, max);
1796 captureGainN->setSpecialValueText(
i18n(
"--"));
1797 captureGainN->setEnabled(
true);
1798 captureGainN->setSingleStep(step);
1799 activeCamera()->getGain(&value);
1802 targetCustomGain = getGain();
1806 if (targetCustomGain > 0)
1807 captureGainN->setValue(targetCustomGain);
1809 captureGainN->setValue(GainSpinSpecialValue);
1811 captureGainN->setReadOnly(activeCamera()->getGainPermission() == IP_RO);
1815 if (captureGainN->value() != GainSpinSpecialValue)
1816 setGain(captureGainN->value());
1823 captureGainN->setEnabled(
false);
1824 currentGainLabel->clear();
1828 if (activeCamera()->hasOffset())
1830 double min, max, step, value, targetCustomOffset;
1831 activeCamera()->getOffsetMinMaxStep(&min, &max, &step);
1834 OffsetSpinSpecialValue = min - step;
1835 captureOffsetN->setRange(OffsetSpinSpecialValue, max);
1836 captureOffsetN->setSpecialValueText(
i18n(
"--"));
1837 captureOffsetN->setEnabled(
true);
1838 captureOffsetN->setSingleStep(step);
1839 activeCamera()->getOffset(&value);
1842 targetCustomOffset = getOffset();
1846 if (targetCustomOffset > 0)
1847 captureOffsetN->setValue(targetCustomOffset);
1849 captureOffsetN->setValue(OffsetSpinSpecialValue);
1851 captureOffsetN->setReadOnly(activeCamera()->getOffsetPermission() == IP_RO);
1855 if (captureOffsetN->value() != OffsetSpinSpecialValue)
1856 setOffset(captureOffsetN->value());
1863 captureOffsetN->setEnabled(
false);
1864 currentOffsetLabel->clear();
1868void Camera::createNewJobTableRow(
SequenceJob * job)
1870 int currentRow = queueTable->rowCount();
1871 queueTable->insertRow(currentRow);
1907 queueTable->setItem(currentRow, JOBTABLE_COL_STATUS, status);
1908 queueTable->setItem(currentRow, JOBTABLE_COL_FILTER, filter);
1909 queueTable->setItem(currentRow, JOBTABLE_COL_COUNTS, count);
1910 queueTable->setItem(currentRow, JOBTABLE_COL_EXP, exp);
1911 queueTable->setItem(currentRow, JOBTABLE_COL_TYPE, type);
1912 queueTable->setItem(currentRow, JOBTABLE_COL_BINNING, bin);
1913 queueTable->setItem(currentRow, JOBTABLE_COL_ISO, iso);
1914 queueTable->setItem(currentRow, JOBTABLE_COL_OFFSET, offset);
1917 updateJobTable(job,
true);
1920 QJsonObject jsonJob = createJsonJob(job, currentRow);
1921 state()->getSequence().append(jsonJob);
1922 emit sequenceChanged(state()->getSequence());
1924 removeFromQueueB->setEnabled(
true);
1933 int row = state()->allJobs().indexOf(job);
1934 if (row >= 0 && row < queueTable->rowCount())
1936 updateCellStyle(queueTable->item(row, JOBTABLE_COL_STATUS), job->getStatus() == JOB_BUSY);
1937 updateCellStyle(queueTable->item(row, JOBTABLE_COL_FILTER), job->getStatus() == JOB_BUSY);
1938 updateCellStyle(queueTable->item(row, JOBTABLE_COL_COUNTS), job->getStatus() == JOB_BUSY);
1939 updateCellStyle(queueTable->item(row, JOBTABLE_COL_EXP), job->getStatus() == JOB_BUSY);
1940 updateCellStyle(queueTable->item(row, JOBTABLE_COL_TYPE), job->getStatus() == JOB_BUSY);
1941 updateCellStyle(queueTable->item(row, JOBTABLE_COL_BINNING), job->getStatus() == JOB_BUSY);
1942 updateCellStyle(queueTable->item(row, JOBTABLE_COL_ISO), job->getStatus() == JOB_BUSY);
1943 updateCellStyle(queueTable->item(row, JOBTABLE_COL_OFFSET), job->getStatus() == JOB_BUSY);
1949 if (cell ==
nullptr)
1953 font.setBold(active);
1954 font.setItalic(active);
1958bool Camera::syncControl(
const QVariantMap &settings,
const QString &key,
QWidget * widget)
1971 const int value = settings[key].toInt(&ok);
1980 const double value = settings[key].toDouble(&ok);
1985 if (pDSB == captureGainN)
1987 if (captureGainN->value() != GainSpinSpecialValue)
1988 setGain(captureGainN->value());
1992 else if (pDSB == captureOffsetN)
1994 if (captureOffsetN->value() != OffsetSpinSpecialValue)
1995 setOffset(captureOffsetN->value());
2004 const bool value = settings[key].toBool();
2011 const bool value = settings[key].toBool();
2013 pRadioButton->
click();
2019 const QString value = settings[key].toString();
2031 const bool value = settings[key].toBool();
2033 pRadioButton->
click();
2038 const auto value = settings[key].toString();
2041 if (pLineEdit == fileRemoteDirT)
2042 generatePreviewFilename();
2049void Camera::moveJob(
bool up)
2051 int currentRow = queueTable->currentRow();
2052 int destinationRow =
up ? currentRow - 1 : currentRow + 1;
2054 int columnCount = queueTable->columnCount();
2056 if (currentRow < 0 || destinationRow < 0 || destinationRow >= queueTable->rowCount())
2059 for (
int i = 0; i < columnCount; i++)
2064 queueTable->setItem(destinationRow, i, selectedLine);
2065 queueTable->setItem(currentRow, i, counterpart);
2068 SequenceJob * job = state()->allJobs().takeAt(currentRow);
2070 state()->allJobs().removeOne(job);
2071 state()->allJobs().insert(destinationRow, job);
2073 QJsonArray seqArray = state()->getSequence();
2074 QJsonObject currentJob = seqArray[currentRow].toObject();
2075 seqArray.
replace(currentRow, seqArray[destinationRow]);
2076 seqArray.
replace(destinationRow, currentJob);
2077 emit sequenceChanged(seqArray);
2079 queueTable->selectRow(destinationRow);
2081 state()->setDirty(
true);
2084void Camera::removeJobFromQueue()
2086 int currentRow = queueTable->currentRow();
2089 currentRow = queueTable->rowCount() - 1;
2091 removeJob(currentRow);
2094 if (queueTable->rowCount() == 0)
2097 if (currentRow > queueTable->rowCount())
2098 queueTable->selectRow(queueTable->rowCount() - 1);
2100 queueTable->selectRow(currentRow);
2103void Camera::saveFITSDirectory()
2113void Camera::updateCaptureFormats()
2118 QString currentType = captureTypeS->currentText();
2120 captureTypeS->blockSignals(
true);
2121 captureTypeS->
clear();
2124 captureTypeS->setEnabled(
false);
2127 captureTypeS->setEnabled(
true);
2128 captureTypeS->addItems(frameTypes);
2130 if (currentType ==
"")
2133 captureTypeS->setCurrentIndex(devices()->getActiveChip()->getFrameType());
2134 currentType = captureTypeS->currentText();
2137 captureTypeS->setCurrentText(currentType);
2139 captureTypeS->blockSignals(
false);
2141 const bool isVideo = currentType == CAPTURE_TYPE_VIDEO;
2144 captureFormatS->blockSignals(
true);
2145 captureFormatS->clear();
2146 const auto list = isVideo ? activeCamera()->getVideoFormats() : activeCamera()->getCaptureFormats();
2147 captureFormatS->addItems(list);
2148 storeTrainKey(KEY_FORMATS, list);
2150 captureFormatS->setCurrentText(activeCamera()->getCaptureFormat());
2151 captureFormatS->blockSignals(
false);
2154 captureEncodingS->blockSignals(
true);
2155 captureEncodingS->clear();
2156 captureEncodingS->addItems(isVideo ? activeCamera()->getStreamEncodings() : activeCamera()->getEncodingFormats());
2157 captureEncodingS->setCurrentText(isVideo ? activeCamera()->getStreamEncoding() : activeCamera()->getEncodingFormat());
2158 captureEncodingS->blockSignals(
false);
2161void Camera::updateHFRCheckAlgo()
2164 const bool threshold = (m_LimitsUI->hFRCheckAlgorithm->currentIndex() != HFR_CHECK_FIXED);
2165 m_LimitsUI->hFRThresholdPercentage->setEnabled(threshold);
2166 m_LimitsUI->limitFocusHFRThresholdLabel->setEnabled(threshold);
2167 m_LimitsUI->limitFocusHFRPercentLabel->setEnabled(threshold);
2168 state()->updateHFRThreshold();
2171void Camera::clearAutoFocusHFR()
2173 if (Options::hFRCheckAlgorithm() == HFR_CHECK_FIXED)
2176 m_LimitsUI->hFRDeviation->setValue(0);
2186void Camera::clearCameraConfiguration()
2192 devices()->getActiveCamera()->setConfig(PURGE_CONFIG);
2193 KStarsData::Instance()->
userdb()->DeleteDSLRInfo(devices()->getActiveCamera()->getDeviceName());
2195 QStringList shutterfulCCDs = Options::shutterfulCCDs();
2196 QStringList shutterlessCCDs = Options::shutterlessCCDs();
2199 if (shutterfulCCDs.
contains(devices()->getActiveCamera()->getDeviceName()))
2201 shutterfulCCDs.
removeOne(devices()->getActiveCamera()->getDeviceName());
2202 Options::setShutterfulCCDs(shutterfulCCDs);
2204 if (shutterlessCCDs.
contains(devices()->getActiveCamera()->getDeviceName()))
2206 shutterlessCCDs.
removeOne(devices()->getActiveCamera()->getDeviceName());
2207 Options::setShutterlessCCDs(shutterlessCCDs);
2211 if (captureISOS && captureISOS->count() > 0)
2217 KSMessageBox::Instance()->questionYesNo(
i18n(
"Reset %1 configuration to default?",
2218 devices()->getActiveCamera()->getDeviceName()),
2219 i18n(
"Confirmation"), 30);
2222void Camera::editFilterName()
2227 for (
int index = 0; index < FilterPosCombo->count(); index++)
2228 labels << FilterPosCombo->itemText(index);
2230 if (editFilterNameInternal(labels, newLabels))
2232 FilterPosCombo->clear();
2233 FilterPosCombo->addItems(newLabels);
2238 if (devices()->filterWheel() ==
nullptr || state()->getCurrentFilterPosition() < 1)
2241 QStringList labels = filterManager()->getFilterLabels();
2243 if (editFilterNameInternal(labels, newLabels))
2244 filterManager()->setFilterNames(newLabels);
2255 for (uint8_t i = 0; i < labels.
count(); i++)
2257 QLabel *existingLabel =
new QLabel(
QString(
"%1. <b>%2</b>").arg(i + 1).arg(labels[i]), &filterDialog);
2259 newLabelEdits.
append(newLabel);
2260 formLayout->
addRow(existingLabel, newLabel);
2263 QString title = m_standAlone ?
2264 "Edit Filter Names" : devices()->filterWheel()->getDeviceName();
2275 for (uint8_t i = 0; i < labels.
count(); i++)
2276 results << newLabelEdits[i]->text();
2277 newLabels = results;
2283void Camera::updateVideoDurationUnit()
2285 if (videoDurationUnitCB->currentIndex() == 0)
2288 videoDurationSB->setValue(videoDurationSB->value() * captureExposureN->value());
2289 videoDurationSB->setDecimals(2);
2294 videoDurationSB->setValue(videoDurationSB->value() / captureExposureN->value());
2295 videoDurationSB->setDecimals(0);
2299void Camera::loadGlobalSettings()
2304 QVariantMap settings;
2308 if (oneWidget->objectName() ==
"opticalTrainCombo")
2311 key = oneWidget->objectName();
2312 value = Options::self()->property(key.
toLatin1());
2313 if (value.
isValid() && oneWidget->count() > 0)
2315 oneWidget->setCurrentText(value.
toString());
2316 settings[key] = value;
2319 QCDEBUG <<
"Option" << key <<
"not found!";
2325 key = oneWidget->objectName();
2326 value = Options::self()->property(key.
toLatin1());
2329 oneWidget->setValue(value.
toDouble());
2330 settings[key] = value;
2333 QCDEBUG <<
"Option" << key <<
"not found!";
2339 key = oneWidget->objectName();
2340 value = Options::self()->property(key.
toLatin1());
2343 oneWidget->setValue(value.
toInt());
2344 settings[key] = value;
2347 QCDEBUG <<
"Option" << key <<
"not found!";
2353 key = oneWidget->objectName();
2354 value = Options::self()->property(key.
toLatin1());
2357 oneWidget->setChecked(value.
toBool());
2358 settings[key] = value;
2361 QCDEBUG <<
"Option" << key <<
"not found!";
2367 if (oneWidget->isCheckable())
2369 key = oneWidget->objectName();
2370 value = Options::self()->property(key.
toLatin1());
2373 oneWidget->setChecked(value.
toBool());
2374 settings[key] = value;
2377 QCDEBUG <<
"Option" << key <<
"not found!";
2384 key = oneWidget->objectName();
2385 value = Options::self()->property(key.
toLatin1());
2388 oneWidget->setChecked(value.
toBool());
2389 settings[key] = value;
2396 if (oneWidget->objectName() ==
"qt_spinbox_lineedit" || oneWidget->isReadOnly())
2398 key = oneWidget->objectName();
2399 value = Options::self()->property(key.
toLatin1());
2402 oneWidget->setText(value.
toString());
2403 settings[key] = value;
2406 m_GlobalSettings = settings;
2407 setSettings(settings);
2410bool Camera::checkUploadPaths(FilenamePreviewType filenamePreview)
2413 if (filenamePreview != FILENAME_NOT_PREVIEW)
2416 if (fileUploadModeS->currentIndex() != ISD::Camera::UPLOAD_CLIENT && fileRemoteDirT->text().isEmpty())
2418 KSNotification::error(
i18n(
"You must set remote directory for Local & Both modes."));
2422 if (fileUploadModeS->currentIndex() != ISD::Camera::UPLOAD_LOCAL && fileDirectoryT->text().isEmpty())
2424 KSNotification::error(
i18n(
"You must set local directory for Client & Both modes."));
2437 bool isDarkFlat = job->jobType() == SequenceJob::JOBTYPE_DARKFLAT;
2438 jsonJob.
insert(
"Filter", FilterPosCombo->itemText(job->getTargetFilter() - 1));
2439 jsonJob.
insert(
"Count", queueTable->item(currentRow, JOBTABLE_COL_COUNTS)->text());
2440 jsonJob.
insert(
"Exp", queueTable->item(currentRow, JOBTABLE_COL_EXP)->text());
2441 jsonJob.
insert(
"Type", isDarkFlat ?
i18n(
"Dark Flat") : queueTable->item(currentRow, JOBTABLE_COL_TYPE)->text());
2442 jsonJob.
insert(
"Bin", queueTable->item(currentRow, JOBTABLE_COL_BINNING)->text());
2443 jsonJob.
insert(
"ISO/Gain", queueTable->item(currentRow, JOBTABLE_COL_ISO)->text());
2444 jsonJob.
insert(
"Offset", queueTable->item(currentRow, JOBTABLE_COL_OFFSET)->text());
2445 jsonJob.
insert(
"Encoding", job->getCoreProperty(SequenceJob::SJ_Encoding).toJsonValue());
2446 jsonJob.
insert(
"Format", job->getCoreProperty(SequenceJob::SJ_Format).toJsonValue());
2447 jsonJob.
insert(
"Temperature", job->getTargetTemperature());
2448 jsonJob.
insert(
"EnforceTemperature", job->getCoreProperty(SequenceJob::SJ_EnforceTemperature).toJsonValue());
2449 jsonJob.
insert(
"DitherPerJobFrequency", job->getCoreProperty(SequenceJob::SJ_DitherPerJobFrequency).toJsonValue());
2454void Camera::generatePreviewFilename()
2456 if (state()->isCaptureRunning() ==
false)
2458 placeholderFormatT->setToolTip(previewFilename( fileUploadModeS->currentIndex() == ISD::Camera::UPLOAD_LOCAL ?
2459 FILENAME_REMOTE_PREVIEW : FILENAME_LOCAL_PREVIEW ));
2460 emit newLocalPreview(placeholderFormatT->toolTip());
2462 if (fileUploadModeS->currentIndex() != ISD::Camera::UPLOAD_CLIENT)
2463 fileRemoteDirT->setToolTip(previewFilename( FILENAME_REMOTE_PREVIEW ));
2467QString Camera::previewFilename(FilenamePreviewType previewType)
2473 if (previewType == FILENAME_LOCAL_PREVIEW)
2475 if(!fileDirectoryT->text().endsWith(separator) && !placeholderFormatT->text().startsWith(separator))
2476 placeholderFormatT->setText(separator + placeholderFormatT->text());
2477 m_format = fileDirectoryT->text() + placeholderFormatT->text() + formatSuffixN->prefix() +
2478 formatSuffixN->cleanText();
2480 else if (previewType == FILENAME_REMOTE_PREVIEW)
2481 m_format = fileRemoteDirT->text();
2489 else if (state()->sequenceURL().toLocalFile().isEmpty() && m_format.
contains(
"%f"))
2490 previewText = (
"Save the sequence file to show filename preview");
2494 SequenceJob *m_job = createJob(SequenceJob::JOBTYPE_PREVIEW, previewType);
2495 if (m_job ==
nullptr)
2499 if (state()->sequenceURL().toLocalFile().isEmpty())
2505 previewSeq = state()->sequenceURL().toLocalFile();
2506 auto m_placeholderPath = PlaceholderPath(previewSeq);
2509 if (captureEncodingS->currentText() ==
"FITS")
2510 extension =
".fits";
2511 else if (captureEncodingS->currentText() ==
"XISF")
2512 extension =
".xisf";
2514 extension =
".[NATIVE]";
2515 previewText = m_placeholderPath.generateSequenceFilename(*m_job, previewType == FILENAME_LOCAL_PREVIEW,
true, 1,
2516 extension,
"",
false);
2519 m_job->deleteLater();
2523 if (previewType == FILENAME_REMOTE_PREVIEW)
2524 previewText.
replace(separator,
"/");
2531 countCell->
setText(
QString(
"%L1/%L2").arg(job->getCompleted()).
arg(job->getCoreProperty(SequenceJob::SJ_Count).toInt()));
2534void Camera::addDSLRInfo(
const QString &model, uint32_t maxW, uint32_t maxH,
double pixelW,
double pixelH)
2537 auto pos = std::find_if(state()->DSLRInfos().
begin(), state()->DSLRInfos().
end(), [model](
const auto & oneDSLRInfo)
2539 return (oneDSLRInfo[
"Model"] == model);
2542 if (
pos != state()->DSLRInfos().
end())
2544 KStarsData::Instance()->
userdb()->DeleteDSLRInfo(model);
2545 state()->DSLRInfos().removeOne(*
pos);
2549 oneDSLRInfo[
"Model"] = model;
2550 oneDSLRInfo[
"Width"] = maxW;
2551 oneDSLRInfo[
"Height"] = maxH;
2552 oneDSLRInfo[
"PixelW"] = pixelW;
2553 oneDSLRInfo[
"PixelH"] = pixelH;
2555 KStarsData::Instance()->
userdb()->AddDSLRInfo(oneDSLRInfo);
2556 KStarsData::Instance()->
userdb()->GetAllDSLRInfos(state()->DSLRInfos());
2558 updateFrameProperties();
2559 process()->resetFrame();
2560 process()->syncDSLRToTargetChip(model);
2563 if (m_DSLRInfoDialog)
2564 m_DSLRInfoDialog.reset();
2569 process()->startNextPendingJob();
2572void Camera::stop(CaptureState targetState)
2574 process()->stopCapturing(targetState);
2579 process()->pauseCapturing();
2580 updateStartButtons(
false,
true);
2583void Camera::toggleSequence()
2585 const CaptureState capturestate = state()->getCaptureState();
2587 updateStartButtons(
true,
false);
2589 process()->toggleSequence();
2592void Camera::toggleVideo(
bool enabled)
2594 process()->toggleVideo(
enabled);
2597void Camera::restartCamera(
const QString &name)
2599 process()->restartCamera(name);
2602void Camera::cullToDSLRLimits()
2604 QString model(devices()->getActiveCamera()->getDeviceName());
2607 auto pos = std::find_if(state()->DSLRInfos().
begin(),
2610 return (oneDSLRInfo[
"Model"] == model);
2613 if (
pos != state()->DSLRInfos().
end())
2615 if (captureFrameWN->maximum() == 0 || captureFrameWN->maximum() > (*
pos)[
"Width"].toInt())
2617 captureFrameWN->setValue((*
pos)[
"Width"].toInt());
2618 captureFrameWN->setMaximum((*
pos)[
"Width"].toInt());
2621 if (captureFrameHN->maximum() == 0 || captureFrameHN->maximum() > (*
pos)[
"Height"].toInt())
2623 captureFrameHN->setValue((*
pos)[
"Height"].toInt());
2624 captureFrameHN->setMaximum((*
pos)[
"Height"].toInt());
2629void Camera::resetFrameToZero()
2631 captureFrameXN->setMinimum(0);
2632 captureFrameXN->setMaximum(0);
2633 captureFrameXN->setValue(0);
2635 captureFrameYN->setMinimum(0);
2636 captureFrameYN->setMaximum(0);
2637 captureFrameYN->setValue(0);
2639 captureFrameWN->setMinimum(0);
2640 captureFrameWN->setMaximum(0);
2641 captureFrameWN->setValue(0);
2643 captureFrameHN->setMinimum(0);
2644 captureFrameHN->setMaximum(0);
2645 captureFrameHN->setValue(0);
2648void Camera::updateFrameProperties(
int reset)
2650 if (!devices()->getActiveCamera())
2653 int binx = 1, biny = 1;
2654 double min, max, step;
2655 int xstep = 0, ystep = 0;
2658 QString exposureProp = state()->useGuideHead() ?
QString(
"GUIDER_EXPOSURE") :
QString(
"CCD_EXPOSURE");
2659 QString exposureElem = state()->useGuideHead() ?
QString(
"GUIDER_EXPOSURE_VALUE") :
2660 QString(
"CCD_EXPOSURE_VALUE");
2661 devices()->setActiveChip(state()->useGuideHead() ?
2662 devices()->getActiveCamera()->getChip(
2663 ISD::CameraChip::GUIDE_CCD) :
2664 devices()->getActiveCamera()->getChip(ISD::CameraChip::PRIMARY_CCD));
2666 captureFrameWN->setEnabled(devices()->getActiveChip()->canSubframe());
2667 captureFrameHN->setEnabled(devices()->getActiveChip()->canSubframe());
2668 captureFrameXN->setEnabled(devices()->getActiveChip()->canSubframe());
2669 captureFrameYN->setEnabled(devices()->getActiveChip()->canSubframe());
2671 captureBinHN->setEnabled(devices()->getActiveChip()->canBin());
2672 captureBinVN->setEnabled(devices()->getActiveChip()->canBin());
2675 exposureValues << 0.01 << 0.02 << 0.05 << 0.1 << 0.2 << 0.25 << 0.5 << 1 << 1.5 << 2 << 2.5 << 3 << 5 << 6 << 7 << 8 << 9 <<
2676 10 << 20 << 30 << 40 << 50 << 60 << 120 << 180 << 300 << 600 << 900 << 1200 << 1800;
2678 if (devices()->getActiveCamera()->getMinMaxStep(exposureProp, exposureElem, &min, &max, &step))
2681 captureExposureN->setDecimals(6);
2683 captureExposureN->setDecimals(3);
2684 for(
int i = 0; i < exposureValues.
count(); i++)
2686 double value = exposureValues.
at(i);
2687 if(value < min || value > max)
2695 exposureValues.
append(max);
2698 captureExposureN->setRecommendedValues(exposureValues);
2699 state()->setExposureRange(exposureValues.
first(), exposureValues.
last());
2701 if (devices()->getActiveCamera()->getMinMaxStep(frameProp,
"WIDTH", &min, &max, &step))
2710 xstep =
static_cast<int>(max * 0.05);
2712 xstep =
static_cast<int>(step);
2714 if (min >= 0 && max > 0)
2716 captureFrameWN->setMinimum(
static_cast<int>(min));
2717 captureFrameWN->setMaximum(
static_cast<int>(max));
2718 captureFrameWN->setSingleStep(xstep);
2724 if (devices()->getActiveCamera()->getMinMaxStep(frameProp,
"HEIGHT", &min, &max, &step))
2733 ystep =
static_cast<int>(max * 0.05);
2735 ystep =
static_cast<int>(step);
2737 if (min >= 0 && max > 0)
2739 captureFrameHN->setMinimum(
static_cast<int>(min));
2740 captureFrameHN->setMaximum(
static_cast<int>(max));
2741 captureFrameHN->setSingleStep(ystep);
2747 if (devices()->getActiveCamera()->getMinMaxStep(frameProp,
"X", &min, &max, &step))
2758 if (min >= 0 && max > 0)
2760 captureFrameXN->setMinimum(
static_cast<int>(min));
2761 captureFrameXN->setMaximum(
static_cast<int>(max));
2762 captureFrameXN->setSingleStep(
static_cast<int>(step));
2768 if (devices()->getActiveCamera()->getMinMaxStep(frameProp,
"Y", &min, &max, &step))
2779 if (min >= 0 && max > 0)
2781 captureFrameYN->setMinimum(
static_cast<int>(min));
2782 captureFrameYN->setMaximum(
static_cast<int>(max));
2783 captureFrameYN->setSingleStep(
static_cast<int>(step));
2790 if (state()->useGuideHead() ==
false)
2793 const QString ccdGainKeyword = devices()->getActiveCamera()->getProperty(
"CCD_GAIN") ?
"CCD_GAIN" :
"CCD_CONTROLS";
2794 storeTrainKeyString(KEY_GAIN_KWD, ccdGainKeyword);
2796 const QString ccdOffsetKeyword = devices()->getActiveCamera()->getProperty(
"CCD_OFFSET") ?
"CCD_OFFSET" :
"CCD_CONTROLS";
2797 storeTrainKeyString(KEY_OFFSET_KWD, ccdOffsetKeyword);
2799 if (reset == 1 || state()->frameSettings().contains(devices()->getActiveChip()) ==
false)
2801 QVariantMap settings;
2805 settings[
"w"] = captureFrameWN->maximum();
2806 settings[
"h"] = captureFrameHN->maximum();
2807 settings[
"binx"] = captureBinHN->value();
2808 settings[
"biny"] = captureBinVN->value();
2810 state()->frameSettings()[devices()->getActiveChip()] = settings;
2812 else if (reset == 2 && state()->frameSettings().contains(devices()->getActiveChip()))
2814 QVariantMap settings = state()->frameSettings()[devices()->getActiveChip()];
2817 x = settings[
"x"].toInt();
2818 y = settings[
"y"].toInt();
2819 w = settings[
"w"].toInt();
2820 h = settings[
"h"].toInt();
2823 x = qBound(captureFrameXN->minimum(),
x, captureFrameXN->maximum() - 1);
2824 y = qBound(captureFrameYN->minimum(),
y, captureFrameYN->maximum() - 1);
2825 w = qBound(captureFrameWN->minimum(), w, captureFrameWN->maximum());
2826 h = qBound(captureFrameHN->minimum(), h, captureFrameHN->maximum());
2832 settings[
"binx"] = captureBinHN->value();
2833 settings[
"biny"] = captureBinVN->value();
2835 state()->frameSettings()[devices()->getActiveChip()] = settings;
2838 if (state()->frameSettings().contains(devices()->getActiveChip()))
2840 QVariantMap settings = state()->frameSettings()[devices()->getActiveChip()];
2841 int x = settings[
"x"].toInt();
2842 int y = settings[
"y"].toInt();
2843 int w = settings[
"w"].toInt();
2844 int h = settings[
"h"].toInt();
2846 if (devices()->getActiveChip()->canBin())
2848 devices()->getActiveChip()->getMaxBin(&binx, &biny);
2849 captureBinHN->setMaximum(binx);
2850 captureBinVN->setMaximum(biny);
2852 captureBinHN->setValue(settings[
"binx"].toInt());
2853 captureBinVN->setValue(settings[
"biny"].toInt());
2857 captureBinHN->setValue(1);
2858 captureBinVN->setValue(1);
2862 captureFrameXN->setValue(
x);
2864 captureFrameYN->setValue(
y);
2866 captureFrameWN->setValue(w);
2868 captureFrameHN->setValue(h);
2874void Camera::setGain(
double value)
2878 setStandAloneGain(value);
2881 if (!devices()->getActiveCamera())
2885 process()->updateGain(value, customProps);
2886 customPropertiesDialog()->setCustomProperties(customProps);
2890double Camera::getGain()
2892 return devices()->cameraGain(customPropertiesDialog()->getCustomProperties());
2895void Camera::setOffset(
double value)
2899 setStandAloneOffset(value);
2902 if (!devices()->getActiveCamera())
2907 process()->updateOffset(value, customProps);
2908 customPropertiesDialog()->setCustomProperties(customProps);
2911double Camera::getOffset()
2913 return devices()->cameraOffset(customPropertiesDialog()->getCustomProperties());
2916void Camera::setRotator(
QString name)
2920 rotatorB->setEnabled(
false);
2921 if (Rotator && !m_RotatorControlPanel.
isNull())
2922 m_RotatorControlPanel->close();
2927 Manager::Instance()->getRotatorController(name, m_RotatorControlPanel);
2928 m_RotatorControlPanel->initRotator(opticalTrainCombo->currentText(), devices().data(),
2932 m_RotatorControlPanel->show();
2933 m_RotatorControlPanel->raise();
2935 rotatorB->setEnabled(
true);
2937 else if (Options::astrometryUseRotator())
2939 RotatorUtils::Instance()->initRotatorUtils(opticalTrainCombo->currentText());
2943void Camera::setMaximumGuidingDeviation(
bool enable,
double value)
2945 m_LimitsUI->enforceGuideDeviation->setChecked(enable);
2947 m_LimitsUI->guideDeviation->setValue(value);
2950void Camera::setInSequenceFocus(
bool enable,
double HFR)
2952 m_LimitsUI->enforceAutofocusHFR->setChecked(enable);
2954 m_LimitsUI->hFRDeviation->setValue(HFR);
2957bool Camera::loadSequenceQueue(
const QString &fileURL,
QString targetName)
2959 QFile sFile(fileURL);
2962 QString message =
i18n(
"Unable to open file %1", fileURL);
2963 KSNotification::sorry(message,
i18n(
"Could Not Open File"));
2967 state()->clearCapturedFramesMap();
2968 clearSequenceQueue();
2971 const bool result = process()->loadSequenceQueue(fileURL, targetName, !m_standAlone);
2973 if (result ==
false)
2977 setObserverName(state()->observerName());
2980 if (state()->allJobs().
size() > 0)
2981 syncGUIToJob(state()->allJobs().first());
2984 queueSaveB->setToolTip(
"Save to " + sFile.fileName());
2989bool Camera::saveSequenceQueue(
const QString &path)
2992 return process()->saveSequenceQueue(path);
2995void Camera::updateCameraStatus(CaptureState status)
2998 emit newStatus(status, opticalTrain(), cameraId());
3001void Camera::clearSequenceQueue()
3003 state()->setActiveJob(
nullptr);
3004 while (queueTable->rowCount() > 0)
3005 queueTable->removeRow(0);
3006 qDeleteAll(state()->allJobs());
3007 state()->allJobs().clear();
3009 while (state()->getSequence().count())
3010 state()->getSequence().pop_back();
3011 emit sequenceChanged(state()->getSequence());
3014QVariantMap Camera::getAllSettings()
const
3016 QVariantMap settings;
3022 auto name = oneWidget->objectName();
3023 if (name ==
"qt_spinbox_lineedit")
3025 settings.insert(name, oneWidget->text());
3030 settings.insert(oneWidget->objectName(), oneWidget->currentText());
3034 settings.insert(oneWidget->objectName(), oneWidget->value());
3038 settings.insert(oneWidget->objectName(), oneWidget->value());
3042 settings.insert(oneWidget->objectName(), oneWidget->isChecked());
3046 if (oneWidget->isCheckable())
3047 settings.insert(oneWidget->objectName(), oneWidget->isChecked());
3051 settings.insert(oneWidget->objectName(), oneWidget->isChecked());
3056void Camera::setAllSettings(
const QVariantMap &settings,
const QVariantMap * standAloneSettings)
3060 disconnectSyncSettings();
3062 for (
auto &name : settings.keys())
3068 syncControl(settings, name, comboBox);
3076 syncControl(settings, name, doubleSpinBox);
3084 syncControl(settings, name, spinBox);
3092 syncControl(settings, name, checkbox);
3098 if (groupbox && groupbox->isCheckable())
3100 syncControl(settings, name, groupbox);
3108 syncControl(settings, name, radioButton);
3116 syncControl(settings, name, lineEdit);
3122 for (
auto &key : settings.keys())
3124 auto value = settings[key];
3126 Options::self()->setProperty(key.
toLatin1(), value);
3128 m_settings[key] = value;
3129 m_GlobalSettings[key] = value;
3132 if (standAloneSettings && standAloneSettings->size() > 0)
3134 for (
const auto &k : standAloneSettings->keys())
3135 m_settings[k] = (*standAloneSettings)[k];
3138 emit settingsUpdated(getAllSettings());
3143 const int id = OpticalTrainManager::Instance()->id(opticalTrainCombo->currentText());
3144 OpticalTrainSettings::Instance()->setOpticalTrainID(
id);
3145 OpticalTrainSettings::Instance()->setOneSetting(OpticalTrainSettings::Capture, m_settings);
3146 Options::setCaptureTrainID(
id);
3149 connectSyncSettings();
3152void Camera::setupOpticalTrainManager()
3154 connect(OpticalTrainManager::Instance(), &OpticalTrainManager::updated,
this, &Camera::refreshOpticalTrain);
3157 OpticalTrainManager::Instance()->openEditor(opticalTrainCombo->currentText());
3161 ProfileSettings::Instance()->setOneSetting(ProfileSettings::CaptureOpticalTrain,
3162 OpticalTrainManager::Instance()->
id(opticalTrainCombo->itemText(index)));
3163 refreshOpticalTrain();
3164 emit trainChanged();
3168void Camera::refreshOpticalTrain()
3170 opticalTrainCombo->blockSignals(
true);
3171 opticalTrainCombo->clear();
3172 opticalTrainCombo->addItems(OpticalTrainManager::Instance()->getTrainNames());
3173 trainB->setEnabled(
true);
3175 QVariant trainID = ProfileSettings::Instance()->getOneSetting(ProfileSettings::CaptureOpticalTrain);
3176 if (m_standAlone || trainID.
isValid())
3178 auto id = m_standAlone ? Options::captureTrainID() : trainID.toUInt();
3179 Options::setCaptureTrainID(
id);
3182 if (OpticalTrainManager::Instance()->exists(
id) ==
false)
3184 qCWarning(KSTARS_EKOS_CAPTURE) <<
"Optical train doesn't exist for id" << id;
3185 id = OpticalTrainManager::Instance()->id(opticalTrainCombo->itemText(0));
3188 auto name = OpticalTrainManager::Instance()->name(
id);
3190 opticalTrainCombo->setCurrentText(name);
3192 process()->refreshOpticalTrain(name);
3198 OpticalTrainSettings::Instance()->setOpticalTrainID(
id);
3199 auto settings = OpticalTrainSettings::Instance()->getOneSetting(OpticalTrainSettings::Capture);
3200 if (settings.isValid())
3202 auto map = settings.toJsonObject().toVariantMap();
3203 if (map != m_settings)
3205 QVariantMap standAloneSettings = copyStandAloneSettings(m_settings);
3207 setAllSettings(map, &standAloneSettings);
3211 setSettings(m_GlobalSettings);
3214 opticalTrainCombo->blockSignals(
false);
3217void Camera::selectOpticalTrain(
QString name)
3219 opticalTrainCombo->setCurrentText(name);
3222void Camera::syncLimitSettings()
3224 m_LimitsUI->enforceStartGuiderDrift->setChecked(Options::enforceStartGuiderDrift());
3225 m_LimitsUI->startGuideDeviation->setValue(Options::startGuideDeviation());
3226 m_LimitsUI->enforceGuideDeviation->setChecked(Options::enforceGuideDeviation());
3227 m_LimitsUI->guideDeviation->setValue(Options::guideDeviation());
3228 m_LimitsUI->guideDeviationReps->setValue(
static_cast<int>(Options::guideDeviationReps()));
3229 m_LimitsUI->enforceAutofocusHFR->setChecked(Options::enforceAutofocusHFR());
3230 m_LimitsUI->hFRThresholdPercentage->setValue(Options::hFRThresholdPercentage());
3231 m_LimitsUI->hFRDeviation->setValue(Options::hFRDeviation());
3232 m_LimitsUI->inSequenceCheckFrames->setValue(Options::inSequenceCheckFrames());
3233 m_LimitsUI->hFRCheckAlgorithm->setCurrentIndex(Options::hFRCheckAlgorithm());
3234 m_LimitsUI->enforceAutofocusOnTemperature->setChecked(Options::enforceAutofocusOnTemperature());
3235 m_LimitsUI->maxFocusTemperatureDelta->setValue(Options::maxFocusTemperatureDelta());
3236 m_LimitsUI->enforceRefocusEveryN->setChecked(Options::enforceRefocusEveryN());
3237 m_LimitsUI->refocusEveryN->setValue(
static_cast<int>(Options::refocusEveryN()));
3238 m_LimitsUI->refocusAfterMeridianFlip->setChecked(Options::refocusAfterMeridianFlip());
3241void Camera::settleSettings()
3243 state()->setDirty(
true);
3244 emit settingsUpdated(getAllSettings());
3246 const int id = OpticalTrainManager::Instance()->id(opticalTrainCombo->currentText());
3247 OpticalTrainSettings::Instance()->setOpticalTrainID(
id);
3248 OpticalTrainSettings::Instance()->setOneSetting(OpticalTrainSettings::Capture, m_settings);
3249 Options::setCaptureTrainID(
id);
3252void Camera::syncSettings()
3268 value = dsb->
value();
3274 value = sb->
value();
3292 settings().remove(key);
3311 settings()[key] = value;
3312 m_GlobalSettings[key] = value;
3314 Options::self()->setProperty(key.
toLatin1(), value);
3315 m_DebounceTimer.
start();
3319void Camera::connectSyncSettings()
3339 if (oneWidget->isCheckable())
3349 if (oneWidget->objectName() ==
"qt_spinbox_lineedit" || oneWidget->isReadOnly())
3358void Camera::disconnectSyncSettings()
3378 if (oneWidget->isCheckable())
3388 if (oneWidget->objectName() ==
"qt_spinbox_lineedit")
3396 if (!m_settings.contains(key) || m_settings[key].toStringList() != list)
3398 m_settings[key] =
list;
3399 m_DebounceTimer.
start();
3403void Camera::storeTrainKeyString(
const QString &key,
const QString &str)
3405 if (!m_settings.contains(key) || m_settings[key].toString() != str)
3407 m_settings[key] = str;
3408 m_DebounceTimer.
start();
3412void Camera::setupFilterManager()
3415 if (filterManager())
3416 filterManager()->disconnect(
this);
3419 Manager::Instance()->createFilterManager(devices()->filterWheel());
3422 Manager::Instance()->getFilterManager(devices()->filterWheel()->getDeviceName(), m_FilterManager);
3424 devices()->setFilterManager(m_FilterManager);
3426 connect(filterManager().
get(), &FilterManager::updated,
this, [
this]()
3428 emit filterManagerUpdated(devices()->filterWheel());
3432 connect(filterManager().
get(), &FilterManager::newStatus,
this, &Camera::newFilterStatus);
3436 filterManager()->refreshFilterModel();
3437 filterManager()->show();
3438 filterManager()->raise();
3441 connect(filterManager().
get(), &FilterManager::failed,
this, [
this]()
3445 appendLogText(
i18n(
"Filter operation failed."));
3451 connect(filterManager().
get(), &FilterManager::newStatus,
this, &Camera::setFilterStatus);
3453 connect(filterManager().
get(), &FilterManager::labelsChanged,
this, [
this]()
3455 FilterPosCombo->clear();
3456 FilterPosCombo->addItems(filterManager()->getFilterLabels());
3457 FilterPosCombo->setCurrentIndex(filterManager()->getFilterPosition() - 1);
3458 updateCurrentFilterPosition();
3459 storeTrainKey(KEY_FILTERS, filterManager()->getFilterLabels());
3462 connect(filterManager().
get(), &FilterManager::positionChanged,
this, [
this]()
3464 FilterPosCombo->setCurrentIndex(filterManager()->getFilterPosition() - 1);
3465 updateCurrentFilterPosition();
3469void Camera::clearFilterManager()
3472 if (m_FilterManager)
3473 m_FilterManager->disconnect(
this);
3476 m_FilterManager.
clear();
3477 devices()->clearFilterManager();
3480void Camera::refreshFilterSettings()
3482 FilterPosCombo->clear();
3484 if (!devices()->filterWheel())
3486 FilterPosLabel->setEnabled(
false);
3487 FilterPosCombo->setEnabled(
false);
3488 filterEditB->setEnabled(
false);
3489 filterManagerB->setEnabled(
false);
3491 clearFilterManager();
3495 FilterPosLabel->setEnabled(
true);
3496 FilterPosCombo->setEnabled(
true);
3497 filterEditB->setEnabled(
true);
3498 filterManagerB->setEnabled(
true);
3500 setupFilterManager();
3502 process()->updateFilterInfo();
3504 const auto labels = process()->filterLabels();
3505 FilterPosCombo->addItems(labels);
3508 storeTrainKey(KEY_FILTERS, labels);
3510 updateCurrentFilterPosition();
3512 filterEditB->setEnabled(state()->getCurrentFilterPosition() > 0);
3513 filterManagerB->setEnabled(state()->getCurrentFilterPosition() > 0);
3515 FilterPosCombo->setCurrentIndex(state()->getCurrentFilterPosition() - 1);
3518void Camera::updateCurrentFilterPosition()
3520 const QString currentFilterText = FilterPosCombo->itemText(m_FilterManager->getFilterPosition() - 1);
3521 state()->setCurrentFilterPosition(m_FilterManager->getFilterPosition(),
3523 m_FilterManager->getFilterLock(currentFilterText));
3527void Camera::setFilterWheel(
QString name)
3533 if (devices()->filterWheel() && devices()->filterWheel()->getDeviceName() == name)
3535 refreshFilterSettings();
3539 auto isConnected = devices()->filterWheel() && devices()->filterWheel()->isConnected();
3540 FilterPosLabel->setEnabled(isConnected);
3541 FilterPosCombo->setEnabled(isConnected);
3542 filterManagerB->setEnabled(isConnected);
3544 refreshFilterSettings();
3546 if (devices()->filterWheel())
3547 emit settingsUpdated(getAllSettings());
3552 return m_DeviceAdaptor->getActiveCamera();
3557 QVariant trainID = ProfileSettings::Instance()->getOneSetting(ProfileSettings::CaptureOpticalTrain);
3558 if (activeCamera() && trainID.
isValid())
3560 auto id = trainID.
toUInt();
3561 auto name = OpticalTrainManager::Instance()->name(
id);
3562 return OpticalTrainManager::Instance()->getScope(name);
3568double Camera::currentReducer()
3570 QVariant trainID = ProfileSettings::Instance()->getOneSetting(ProfileSettings::CaptureOpticalTrain);
3571 if (activeCamera() && trainID.
isValid())
3573 auto id = trainID.
toUInt();
3574 auto name = OpticalTrainManager::Instance()->name(
id);
3575 return OpticalTrainManager::Instance()->getReducer(name);
3581double Camera::currentAperture()
3583 auto scope = currentScope();
3585 double focalLength = scope[
"focal_length"].toDouble(-1);
3586 double aperture = scope[
"aperture"].toDouble(-1);
3587 double focalRatio = scope[
"focal_ratio"].toDouble(-1);
3590 if (aperture < 0 && focalRatio > 0)
3591 aperture = focalLength * focalRatio;
3596void Camera::updateMeridianFlipStage(MeridianFlipState::MFStage stage)
3599 if (state()->getMeridianFlipState()->getMeridianFlipStage() != stage)
3603 case MeridianFlipState::MF_READY:
3611 case MeridianFlipState::MF_INITIATED:
3612 captureStatusWidget->setStatus(
i18n(
"Meridian Flip..."),
Qt::yellow);
3613 KSNotification::event(
QLatin1String(
"MeridianFlipStarted"),
i18n(
"Meridian flip started"), KSNotification::Capture);
3616 case MeridianFlipState::MF_COMPLETED:
3617 captureStatusWidget->setStatus(
i18n(
"Flip complete."),
Qt::yellow);
3626void Camera::openExposureCalculatorDialog()
3628 QCINFO <<
"Instantiating an Exposure Calculator";
3631 double preferredSkyQuality = 20.5;
3633 auto scope = currentScope();
3634 double focalRatio = scope[
"focal_ratio"].toDouble(-1);
3636 auto reducedFocalLength = currentReducer() * scope[
"focal_length"].toDouble(-1);
3637 auto aperture = currentAperture();
3638 auto reducedFocalRatio = (focalRatio > 0 || aperture == 0) ? focalRatio : reducedFocalLength / aperture;
3640 if (devices()->getActiveCamera() !=
nullptr)
3642 QCINFO <<
"set ExposureCalculator preferred camera to active camera id: "
3643 << devices()->getActiveCamera()->getDeviceName();
3647 preferredSkyQuality,
3649 devices()->getActiveCamera()->getDeviceName()));
3651 anExposureCalculatorDialog->show();
3654void Camera::handleScriptsManager()
3660 m_scriptsManager->setScripts(old_scripts);
3663void Camera::showTemperatureRegulation()
3665 if (!devices()->getActiveCamera())
3668 double currentRamp, currentThreshold;
3669 if (!devices()->getActiveCamera()->getTemperatureRegulation(currentRamp, currentThreshold))
3672 double rMin, rMax, rStep, tMin, tMax, tStep;
3674 devices()->getActiveCamera()->getMinMaxStep(
"CCD_TEMP_RAMP",
"RAMP_SLOPE", &rMin, &rMax, &rStep);
3675 devices()->getActiveCamera()->getMinMaxStep(
"CCD_TEMP_RAMP",
"RAMP_THRESHOLD", &tMin, &tMax, &tStep);
3677 QLabel rampLabel(
i18nc(
"Maximum temperature variation over time when regulating.",
"Ramp (°C/min):"));
3684 "<p>Maximum temperature change per minute when cooling or warming the camera. Set zero to disable."
3685 "<p>This setting is read from and stored in the INDI camera driver configuration."
3688 QLabel thresholdLabel(
i18nc(
"Temperature threshold above which regulation triggers.",
"Threshold (°C):"));
3693 thresholdSpin.
setValue(currentThreshold);
3695 "<p>Maximum difference between camera and target temperatures triggering regulation."
3696 "<p>This setting is read from and stored in the INDI camera driver configuration."
3700 layout.addRow(&rampLabel, &rampSpin);
3701 layout.addRow(&thresholdLabel, &thresholdSpin);
3707 dialog->setWindowTitle(
i18nc(
"@title:window",
"Set Temperature Regulation"));
3709 dialog->setLayout(&
layout);
3710 dialog->setMinimumWidth(300);
3714 if (devices()->getActiveCamera())
3715 devices()->getActiveCamera()->setTemperatureRegulation(rampSpin.
value(), thresholdSpin.
value());
3719void Camera::createDSLRDialog()
3721 m_DSLRInfoDialog.reset(
new DSLRInfo(
this, devices()->getActiveCamera()));
3723 connect(m_DSLRInfoDialog.get(), &DSLRInfo::infoChanged,
this, [
this]()
3725 if (devices()->getActiveCamera())
3726 addDSLRInfo(QString(devices()->getActiveCamera()->getDeviceName()),
3727 m_DSLRInfoDialog->sensorMaxWidth,
3728 m_DSLRInfoDialog->sensorMaxHeight,
3729 m_DSLRInfoDialog->sensorPixelW,
3730 m_DSLRInfoDialog->sensorPixelH);
3733 m_DSLRInfoDialog->show();
3735 emit dslrInfoRequested(devices()->getActiveCamera()->getDeviceName());
3738void Camera::showObserverDialog()
3743 for (
auto &o : m_observerList)
3744 observers <<
QString(
"%1 %2").
arg(o->name(), o->surname());
3746 QDialog observersDialog(
this);
3747 observersDialog.setWindowTitle(
i18nc(
"@title:window",
"Select Current Observer"));
3751 QComboBox observerCombo(&observersDialog);
3752 observerCombo.addItems(observers);
3753 observerCombo.setCurrentText(getObserverName());
3757 manageObserver.setFixedSize(
QSize(32, 32));
3760 manageObserver.setToolTip(
i18n(
"Manage Observers"));
3769 for (
auto &o : m_observerList)
3770 observers <<
QString(
"%1 %2").
arg(o->name(), o->surname());
3772 observerCombo.
clear();
3773 observerCombo.addItems(observers);
3774 observerCombo.setCurrentText(getObserverName());
3783 observersDialog.setLayout(
layout);
3785 observersDialog.exec();
3786 setObserverName(observerCombo.currentText());
3789void Camera::onStandAloneShow(
QShowEvent * event)
3791 OpticalTrainSettings::Instance()->setOpticalTrainID(Options::captureTrainID());
3792 auto oneSetting = OpticalTrainSettings::Instance()->getOneSetting(OpticalTrainSettings::Capture);
3793 setSettings(oneSetting.toJsonObject().toVariantMap());
3798 captureGainN->setValue(GainSpinSpecialValue);
3799 captureOffsetN->setValue(OffsetSpinSpecialValue);
3801 m_standAloneUseCcdGain =
true;
3802 m_standAloneUseCcdOffset =
true;
3803 if (m_settings.contains(KEY_GAIN_KWD) && m_settings[KEY_GAIN_KWD].toString() ==
"CCD_CONTROLS")
3804 m_standAloneUseCcdGain =
false;
3805 if (m_settings.contains(KEY_OFFSET_KWD) && m_settings[KEY_OFFSET_KWD].toString() ==
"CCD_CONTROLS")
3806 m_standAloneUseCcdOffset =
false;
3812 if (captureGainN->value() != GainSpinSpecialValue)
3813 setGain(captureGainN->value());
3821 if (captureOffsetN->value() != OffsetSpinSpecialValue)
3822 setOffset(captureOffsetN->value());
3828void Camera::setStandAloneGain(
double value)
3832 if (m_standAloneUseCcdGain)
3837 ccdGain[
"GAIN"] = value;
3838 propertyMap[
"CCD_GAIN"] = ccdGain;
3842 propertyMap[
"CCD_GAIN"].
remove(
"GAIN");
3843 if (propertyMap[
"CCD_GAIN"].
size() == 0)
3844 propertyMap.
remove(
"CCD_GAIN");
3852 ccdGain[
"Gain"] = value;
3853 propertyMap[
"CCD_CONTROLS"] = ccdGain;
3857 propertyMap[
"CCD_CONTROLS"].
remove(
"Gain");
3858 if (propertyMap[
"CCD_CONTROLS"].
size() == 0)
3859 propertyMap.
remove(
"CCD_CONTROLS");
3863 m_customPropertiesDialog->setCustomProperties(propertyMap);
3866void Camera::setStandAloneOffset(
double value)
3870 if (m_standAloneUseCcdOffset)
3875 ccdOffset[
"OFFSET"] = value;
3876 propertyMap[
"CCD_OFFSET"] = ccdOffset;
3880 propertyMap[
"CCD_OFFSET"].
remove(
"OFFSET");
3881 if (propertyMap[
"CCD_OFFSET"].
size() == 0)
3882 propertyMap.
remove(
"CCD_OFFSET");
3890 ccdOffset[
"Offset"] = value;
3891 propertyMap[
"CCD_CONTROLS"] = ccdOffset;
3895 propertyMap[
"CCD_CONTROLS"].
remove(
"Offset");
3896 if (propertyMap[
"CCD_CONTROLS"].
size() == 0)
3897 propertyMap.
remove(
"CCD_CONTROLS");
3901 m_customPropertiesDialog->setCustomProperties(propertyMap);
3904void Camera::setVideoStreamEnabled(
bool enabled)
3908 liveVideoB->setChecked(
true);
3913 liveVideoB->setChecked(
false);
3919void Camera::setCoolerToggled(
bool enabled)
3921 auto isToggled = (!
enabled && coolerOnB->isChecked()) || (
enabled && coolerOffB->isChecked());
3923 coolerOnB->blockSignals(
true);
3924 coolerOnB->setChecked(
enabled);
3925 coolerOnB->blockSignals(
false);
3927 coolerOffB->blockSignals(
true);
3928 coolerOffB->setChecked(!
enabled);
3929 coolerOffB->blockSignals(
false);
3932 appendLogText(
enabled ?
i18n(
"Cooler is on") :
i18n(
"Cooler is off"));
3935void Camera::setFilterStatus(FilterState filterState)
3937 if (filterState != state()->getFilterManagerState())
3938 QCDEBUG <<
"Filter state changed from" << Ekos::getFilterStatusString(
3939 state()->getFilterManagerState()) <<
"to" << Ekos::getFilterStatusString(filterState);
3942 switch (filterState)
3945 appendLogText(
i18n(
"Changing focus offset by %1 steps...",
3946 filterManager()->getTargetFilterOffset()));
3950 appendLogText(
i18n(
"Changing filter to %1...",
3951 FilterPosCombo->itemText(filterManager()->getTargetFilterPosition() - 1)));
3954 case FILTER_AUTOFOCUS:
3955 appendLogText(
i18n(
"Auto focus on filter change..."));
3956 clearAutoFocusHFR();
3960 if (state()->getFilterManagerState() == FILTER_CHANGE)
3962 appendLogText(
i18n(
"Filter set to %1.",
3963 FilterPosCombo->itemText(filterManager()->getTargetFilterPosition() - 1)));
3971 state()->setFilterManagerState(filterState);
3974 captureStatusWidget->setFilterState(filterState);
3977void Camera::resetJobs()
3983 if (m_JobUnderEdit ==
true)
3985 SequenceJob * job = state()->allJobs().at(queueTable->currentRow());
3989 updateJobTable(job);
3995 nullptr,
i18n(
"Are you sure you want to reset status of all jobs?"),
i18n(
"Reset job status"),
4004 updateJobTable(job);
4009 state()->clearCapturedFramesMap();
4012 state()->setIgnoreJobProgress(Options::alwaysResetSequenceWhenStarting());
4015 startB->setEnabled(
true);
4020 if (i.
row() < 0 || (i.
row() + 1) > state()->allJobs().
size())
4025 if (job ==
nullptr || job->jobType() == SequenceJob::JOBTYPE_DARKFLAT)
4030 if (state()->isBusy())
4033 if (state()->allJobs().
size() >= 2)
4035 queueUpB->setEnabled(i.
row() > 0);
4036 queueDownB->setEnabled(i.
row() + 1 < state()->allJobs().
size());
4045 if (selectJob(i) ==
false)
4048 appendLogText(
i18n(
"Editing job #%1...", i.
row() + 1));
4051 addToQueueB->setToolTip(
i18n(
"Apply job changes."));
4052 removeFromQueueB->setToolTip(
i18n(
"Cancel job changes."));
4055 previewB->setDefault(
false);
4056 addToQueueB->setDefault(
true);
4058 m_JobUnderEdit =
true;
4062void Camera::resetJobEdit(
bool cancelled)
4064 if (cancelled ==
true)
4065 appendLogText(
i18n(
"Editing job canceled."));
4067 m_JobUnderEdit =
false;
4070 addToQueueB->setToolTip(
i18n(
"Add job to sequence queue"));
4071 removeFromQueueB->setToolTip(
i18n(
"Remove job from sequence queue"));
4073 addToQueueB->setDefault(
false);
4074 previewB->setDefault(
true);
void processCaptureTimeout()
processCaptureTimeout If exposure timed out, let's handle it.
Q_SCRIPTABLE void resetFrame()
resetFrame Reset frame settings of the camera
Q_SCRIPTABLE void executeJob()
executeJob Start the execution of activeJob by initiating updatePreCaptureCalibrationStatus().
void captureStarted(CaptureResult rc)
captureStarted Manage the result when capturing has been started
void processCaptureError(ISD::Camera::ErrorType type)
processCaptureError Handle when image capture fails
void captureImage()
captureImage Initiates image capture in the active job.
CameraChip class controls a particular chip in camera.
Camera class controls an INDI Camera device.
Rotator class handles control of INDI Rotator devices.
bool GetAllObservers(QList< OAL::Observer * > &observer_list)
Updates the passed reference of observer_list with all observers The original content of the list is ...
const KStarsDateTime & lt() const
static KStars * Instance()
KStarsData * data() const
Dialog to add new observers.
Sequence Job is a container for the details required to capture a series of images.
The sky coordinates of a point in the sky.
void setAlt(dms alt)
Sets Alt, the Altitude.
void setAz(dms az)
Sets Az, the Azimuth.
QString i18np(const char *singular, const char *plural, const TYPE &arg...)
QString i18nc(const char *context, const char *text, const TYPE &arg...)
QString i18n(const char *text, const TYPE &arg...)
Type type(const QSqlDatabase &db)
char * toString(const EngineQuery &query)
Ekos is an advanced Astrophotography tool for Linux.
@ CAPTURE_SETTING_ROTATOR
@ CAPTURE_CHANGING_FILTER
@ CAPTURE_SETTING_TEMPERATURE
KIOCORE_EXPORT TransferJob * get(const QUrl &url, LoadType reload=NoReload, JobFlags flags=DefaultFlags)
ButtonCode warningContinueCancel(QWidget *parent, const QString &text, const QString &title=QString(), const KGuiItem &buttonContinue=KStandardGuiItem::cont(), const KGuiItem &buttonCancel=KStandardGuiItem::cancel(), const QString &dontAskAgainName=QString(), Options options=Notify)
bool isValid(QStringView ifopt)
KIOCORE_EXPORT QString dir(const QString &fileClass)
KIOCORE_EXPORT QStringList list(const QString &fileClass)
QString name(StandardAction id)
const QList< QKeySequence > & begin()
QString label(StandardShortcut id)
const QList< QKeySequence > & end()
const QList< QKeySequence > & up()
NETWORKMANAGERQT_EXPORT NetworkManager::Status status()
void doubleClicked(const QModelIndex &index)
QByteArray fromBase64(const QByteArray &base64, Base64Options options)
void activated(int index)
void currentIndexChanged(int index)
void setCurrentText(const QString &text)
void currentTextChanged(const QString &text)
QString toString(QStringView format, QCalendar cal) const const
QString toNativeSeparators(const QString &pathName)
void setMaximum(double max)
void setMinimum(double min)
void setSingleStep(double val)
void setValue(double val)
void valueChanged(double d)
QString getExistingDirectory(QWidget *parent, const QString &caption, const QString &dir, Options options)
QUrl getOpenFileUrl(QWidget *parent, const QString &caption, const QUrl &dir, const QString &filter, QString *selectedFilter, Options options, const QStringList &supportedSchemes)
QUrl getSaveFileUrl(QWidget *parent, const QString &caption, const QUrl &dir, const QString &filter, QString *selectedFilter, Options options, const QStringList &supportedSchemes)
bool isChecked() const const
QIcon fromTheme(const QString &name)
void currentRowChanged(const QModelIndex ¤t, const QModelIndex &previous)
void removeAt(qsizetype i)
void replace(qsizetype i, const QJsonValue &value)
iterator insert(QLatin1StringView key, const QJsonValue &value)
void setText(const QString &)
void textChanged(const QString &text)
void textEdited(const QString &text)
void append(QList< T > &&value)
const_reference at(qsizetype i) const const
qsizetype count() const const
bool isEmpty() const const
void prepend(parameter_type value)
void removeAt(qsizetype i)
bool removeOne(const AT &t)
size_type remove(const Key &key)
QMetaObject::Connection connect(const QObject *sender, PointerToMemberFunction signal, Functor functor)
bool disconnect(const QMetaObject::Connection &connection)
T findChild(const QString &name, Qt::FindChildOptions options) const const
QList< T > findChildren(Qt::FindChildOptions options) const const
T qobject_cast(QObject *object)
QObject * sender() const const
bool isNull() const const
bool restoreState(const QByteArray &state)
Qt::ItemFlags flags() const const
void setFlags(Qt::ItemFlags flags)
QStandardItem * item(int row, int column) const const
QString arg(Args &&... args) const const
bool contains(QChar ch, Qt::CaseSensitivity cs) const const
bool isEmpty() const const
qsizetype lastIndexOf(QChar ch, Qt::CaseSensitivity cs) const const
QString left(qsizetype n) const const
QString number(double n, char format, int precision)
QString & replace(QChar before, QChar after, Qt::CaseSensitivity cs)
bool startsWith(QChar c, Qt::CaseSensitivity cs) const const
QByteArray toLatin1() const const
bool contains(QLatin1StringView str, Qt::CaseSensitivity cs) const const
QTextStream & bin(QTextStream &stream)
void setText(const QString &text)
void setTextAlignment(Qt::Alignment alignment)
QFuture< void > filter(QThreadPool *pool, Sequence &sequence, KeepFunctor &&filterFunction)
QFuture< void > map(Iterator begin, Iterator end, MapFunctor &&function)
void setInterval(int msec)
void setSingleShot(bool singleShot)
QUrl fromLocalFile(const QString &localFile)
bool isEmpty() const const
bool isValid() const const
QString toLocalFile() const const
QString url(FormattingOptions options) const const
bool isValid() const const
bool toBool() const const
double toDouble(bool *ok) const const
int toInt(bool *ok) const const
QString toString() const const
uint toUInt(bool *ok) const const