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_REMOTE)
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_REMOTE);
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, job) ==
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);
1508 const bool isVideo = captureTypeS->currentText() == CAPTURE_TYPE_VIDEO;
1521 generatePreviewFilename();
1528 qWarning(KSTARS_EKOS_CAPTURE) <<
"syncGuiToJob with null job.";
1533 const auto roi = job->getCoreProperty(SequenceJob::SJ_ROI).toRect();
1535 captureTypeS->setCurrentIndex(job->getFrameType());
1536 captureFormatS->setCurrentText(job->getCoreProperty(SequenceJob::SJ_Format).toString());
1537 captureEncodingS->setCurrentText(job->getCoreProperty(SequenceJob::SJ_Encoding).toString());
1538 captureExposureN->setValue(job->getCoreProperty(SequenceJob::SJ_Exposure).toDouble());
1539 captureBinHN->setValue(job->getCoreProperty(SequenceJob::SJ_Binning).toPoint().x());
1540 captureBinVN->setValue(job->getCoreProperty(SequenceJob::SJ_Binning).toPoint().y());
1541 captureFrameXN->setValue(roi.x());
1542 captureFrameYN->setValue(roi.y());
1543 captureFrameWN->setValue(roi.width());
1544 captureFrameHN->setValue(roi.height());
1545 FilterPosCombo->setCurrentIndex(job->getTargetFilter() - 1);
1546 captureCountN->setValue(job->getCoreProperty(SequenceJob::SJ_Count).toInt());
1547 captureDelayN->setValue(job->getCoreProperty(SequenceJob::SJ_Delay).toInt() / 1000);
1548 targetNameT->setText(job->getCoreProperty(SequenceJob::SJ_TargetName).toString());
1549 fileDirectoryT->setText(job->getCoreProperty(SequenceJob::SJ_LocalDirectory).toString());
1550 selectUploadMode(job->getUploadMode());
1551 fileRemoteDirT->setText(job->getCoreProperty(SequenceJob::SJ_RemoteDirectory).toString());
1552 placeholderFormatT->setText(job->getCoreProperty(SequenceJob::SJ_PlaceholderFormat).toString());
1553 formatSuffixN->setValue(job->getCoreProperty(SequenceJob::SJ_PlaceholderSuffix).toUInt());
1556 cameraTemperatureS->setChecked(job->getCoreProperty(SequenceJob::SJ_EnforceTemperature).toBool());
1557 if (job->getCoreProperty(SequenceJob::SJ_EnforceTemperature).toBool())
1558 cameraTemperatureN->setValue(job->getTargetTemperature());
1561 m_LimitsUI->guideDitherPerJobFrequency->setValue(job->getCoreProperty(
1562 SequenceJob::SJ_DitherPerJobFrequency).toInt());
1563 syncLimitSettings();
1566 calibrationB->setEnabled(job->getFrameType() != FRAME_LIGHT);
1567 generateDarkFlatsB->setEnabled(job->getFrameType() != FRAME_LIGHT);
1569 if (job->getFlatFieldDuration() == DURATION_MANUAL)
1570 m_CalibrationUI->captureCalibrationDurationManual->setChecked(
true);
1572 m_CalibrationUI->captureCalibrationUseADU->setChecked(
true);
1575 const auto action = job->getCalibrationPreAction();
1576 if (action & CAPTURE_PREACTION_WALL)
1578 m_CalibrationUI->azBox->setText(job->getWallCoord().az().toDMSString());
1579 m_CalibrationUI->altBox->setText(job->getWallCoord().alt().toDMSString());
1581 m_CalibrationUI->captureCalibrationWall->setChecked(action & CAPTURE_PREACTION_WALL);
1582 m_CalibrationUI->captureCalibrationParkMount->setChecked(action & CAPTURE_PREACTION_PARK_MOUNT);
1583 m_CalibrationUI->captureCalibrationParkDome->setChecked(action & CAPTURE_PREACTION_PARK_DOME);
1586 switch (job->getFlatFieldDuration())
1588 case DURATION_MANUAL:
1589 m_CalibrationUI->captureCalibrationDurationManual->setChecked(
true);
1593 m_CalibrationUI->captureCalibrationUseADU->setChecked(
true);
1594 m_CalibrationUI->captureCalibrationADUValue->setValue(job->getCoreProperty(SequenceJob::SJ_TargetADU).toUInt());
1595 m_CalibrationUI->captureCalibrationADUTolerance->setValue(job->getCoreProperty(
1596 SequenceJob::SJ_TargetADUTolerance).toUInt());
1597 m_CalibrationUI->captureCalibrationSkyFlats->setChecked(job->getCoreProperty(SequenceJob::SJ_SkyFlat).toBool());
1601 m_scriptsManager->setScripts(job->getScripts());
1604 customPropertiesDialog()->setCustomProperties(job->getCustomProperties());
1607 captureISOS->setCurrentIndex(job->getCoreProperty(SequenceJob::SJ_ISOIndex).toInt());
1609 double gain = getGain();
1611 captureGainN->setValue(gain);
1613 captureGainN->setValue(GainSpinSpecialValue);
1615 double offset = getOffset();
1617 captureOffsetN->setValue(offset);
1619 captureOffsetN->setValue(OffsetSpinSpecialValue);
1622 generatePreviewFilename();
1624 if (m_RotatorControlPanel)
1626 if (job->getTargetRotation() != Ekos::INVALID_VALUE)
1629 m_RotatorControlPanel->setCameraPA(job->getTargetRotation());
1637 if (Options::alignCheckFrequency() == 0)
1639 targetDriftLabel->setVisible(
false);
1640 targetDrift->setVisible(
false);
1641 targetDriftUnit->setVisible(
false);
1645void Camera::syncFrameType(
const QString &name)
1647 if (!activeCamera() || name != activeCamera()->getDeviceName())
1652 captureTypeS->clear();
1655 captureTypeS->setEnabled(
false);
1658 captureTypeS->setEnabled(
true);
1659 captureTypeS->addItems(frameTypes);
1660 ISD::CameraChip *tChip = devices()->getActiveCamera()->getChip(ISD::CameraChip::PRIMARY_CCD);
1661 captureTypeS->setCurrentIndex(tChip->getFrameType());
1665void Camera::syncCameraInfo()
1667 if (!activeCamera())
1670 const QString timestamp = KStarsData::Instance()->
lt().
toString(
"yyyy-MM-dd hh:mm");
1671 storeTrainKeyString(KEY_TIMESTAMP, timestamp);
1673 if (activeCamera()->hasCooler())
1675 cameraTemperatureS->setEnabled(
true);
1676 cameraTemperatureN->setEnabled(
true);
1678 if (activeCamera()->getPermission(
"CCD_TEMPERATURE") != IP_RO)
1680 double min, max, step;
1681 setTemperatureB->setEnabled(
true);
1682 cameraTemperatureN->setReadOnly(
false);
1683 cameraTemperatureS->setEnabled(
true);
1684 temperatureRegulationB->setEnabled(
true);
1685 activeCamera()->getMinMaxStep(
"CCD_TEMPERATURE",
"CCD_TEMPERATURE_VALUE", &min, &max, &step);
1686 cameraTemperatureN->setMinimum(min);
1687 cameraTemperatureN->setMaximum(max);
1688 cameraTemperatureN->setSingleStep(1);
1689 bool isChecked = activeCamera()->getDriverInfo()->getAuxInfo().value(
QString(
"%1_TC").arg(activeCamera()->getDeviceName()),
1691 cameraTemperatureS->setChecked(isChecked);
1697 isChecked ?
"1" :
"0" } );
1698 storeTrainKey(KEY_TEMPERATURE, temperatureList);
1702 setTemperatureB->setEnabled(
false);
1703 cameraTemperatureN->setReadOnly(
true);
1704 cameraTemperatureS->setEnabled(
false);
1705 cameraTemperatureS->setChecked(
false);
1706 temperatureRegulationB->setEnabled(
false);
1710 storeTrainKey(KEY_TEMPERATURE, temperatureList);
1713 double temperature = 0;
1714 if (activeCamera()->getTemperature(&temperature))
1716 temperatureOUT->setText(
QString(
"%L1º").arg(temperature, 0,
'f', 1));
1717 if (cameraTemperatureN->cleanText().isEmpty())
1718 cameraTemperatureN->setValue(temperature);
1723 cameraTemperatureS->setEnabled(
false);
1724 cameraTemperatureN->setEnabled(
false);
1725 temperatureRegulationB->setEnabled(
false);
1726 cameraTemperatureN->clear();
1727 temperatureOUT->clear();
1728 setTemperatureB->setEnabled(
false);
1731 auto isoList = devices()->getActiveChip()->getISOList();
1732 captureISOS->blockSignals(
true);
1733 captureISOS->setEnabled(
false);
1734 captureISOS->clear();
1737 if (isoList.isEmpty())
1739 captureISOS->setEnabled(
false);
1740 if (settings().contains(KEY_ISOS))
1742 settings().remove(KEY_ISOS);
1743 m_DebounceTimer.
start();
1745 if (settings().contains(KEY_INDEX))
1747 settings().remove(KEY_INDEX);
1748 m_DebounceTimer.
start();
1753 captureISOS->setEnabled(
true);
1754 captureISOS->addItems(isoList);
1755 const int isoIndex = devices()->getActiveChip()->getISOIndex();
1756 captureISOS->setCurrentIndex(isoIndex);
1759 storeTrainKey(KEY_ISOS, isoList);
1760 storeTrainKeyString(KEY_INDEX,
QString(
"%1").arg(isoIndex));
1764 double pixelX = 0, pixelY = 0;
1765 bool rc = devices()->getActiveChip()->getImageInfo(w, h, pixelX, pixelY, bbp);
1766 bool isModelInDB = state()->isModelinDSLRInfo(
QString(activeCamera()->getDeviceName()));
1769 if (rc ==
true && (pixelX == 0.0 || pixelY == 0.0 || isModelInDB ==
false))
1773 if (isModelInDB ==
false)
1780 process()->syncDSLRToTargetChip(model);
1784 captureISOS->blockSignals(
false);
1787 if (activeCamera()->hasGain())
1789 double min, max, step, value, targetCustomGain;
1790 activeCamera()->getGainMinMaxStep(&min, &max, &step);
1793 GainSpinSpecialValue = min - step;
1794 captureGainN->setRange(GainSpinSpecialValue, max);
1795 captureGainN->setSpecialValueText(
i18n(
"--"));
1796 captureGainN->setEnabled(
true);
1797 captureGainN->setSingleStep(step);
1798 activeCamera()->getGain(&value);
1801 targetCustomGain = getGain();
1805 if (targetCustomGain > 0)
1806 captureGainN->setValue(targetCustomGain);
1808 captureGainN->setValue(GainSpinSpecialValue);
1810 captureGainN->setReadOnly(activeCamera()->getGainPermission() == IP_RO);
1814 if (captureGainN->value() != GainSpinSpecialValue)
1815 setGain(captureGainN->value());
1822 captureGainN->setEnabled(
false);
1823 currentGainLabel->clear();
1827 if (activeCamera()->hasOffset())
1829 double min, max, step, value, targetCustomOffset;
1830 activeCamera()->getOffsetMinMaxStep(&min, &max, &step);
1833 OffsetSpinSpecialValue = min - step;
1834 captureOffsetN->setRange(OffsetSpinSpecialValue, max);
1835 captureOffsetN->setSpecialValueText(
i18n(
"--"));
1836 captureOffsetN->setEnabled(
true);
1837 captureOffsetN->setSingleStep(step);
1838 activeCamera()->getOffset(&value);
1841 targetCustomOffset = getOffset();
1845 if (targetCustomOffset > 0)
1846 captureOffsetN->setValue(targetCustomOffset);
1848 captureOffsetN->setValue(OffsetSpinSpecialValue);
1850 captureOffsetN->setReadOnly(activeCamera()->getOffsetPermission() == IP_RO);
1854 if (captureOffsetN->value() != OffsetSpinSpecialValue)
1855 setOffset(captureOffsetN->value());
1862 captureOffsetN->setEnabled(
false);
1863 currentOffsetLabel->clear();
1867void Camera::createNewJobTableRow(
SequenceJob * job)
1869 int currentRow = queueTable->rowCount();
1870 queueTable->insertRow(currentRow);
1906 queueTable->setItem(currentRow, JOBTABLE_COL_STATUS, status);
1907 queueTable->setItem(currentRow, JOBTABLE_COL_FILTER, filter);
1908 queueTable->setItem(currentRow, JOBTABLE_COL_COUNTS, count);
1909 queueTable->setItem(currentRow, JOBTABLE_COL_EXP, exp);
1910 queueTable->setItem(currentRow, JOBTABLE_COL_TYPE, type);
1911 queueTable->setItem(currentRow, JOBTABLE_COL_BINNING, bin);
1912 queueTable->setItem(currentRow, JOBTABLE_COL_ISO, iso);
1913 queueTable->setItem(currentRow, JOBTABLE_COL_OFFSET, offset);
1916 updateJobTable(job,
true);
1919 QJsonObject jsonJob = createJsonJob(job, currentRow);
1920 state()->getSequence().append(jsonJob);
1921 emit sequenceChanged(state()->getSequence());
1923 removeFromQueueB->setEnabled(
true);
1932 int row = state()->allJobs().indexOf(job);
1933 if (row >= 0 && row < queueTable->rowCount())
1935 updateCellStyle(queueTable->item(row, JOBTABLE_COL_STATUS), job->getStatus() == JOB_BUSY);
1936 updateCellStyle(queueTable->item(row, JOBTABLE_COL_FILTER), job->getStatus() == JOB_BUSY);
1937 updateCellStyle(queueTable->item(row, JOBTABLE_COL_COUNTS), job->getStatus() == JOB_BUSY);
1938 updateCellStyle(queueTable->item(row, JOBTABLE_COL_EXP), job->getStatus() == JOB_BUSY);
1939 updateCellStyle(queueTable->item(row, JOBTABLE_COL_TYPE), job->getStatus() == JOB_BUSY);
1940 updateCellStyle(queueTable->item(row, JOBTABLE_COL_BINNING), job->getStatus() == JOB_BUSY);
1941 updateCellStyle(queueTable->item(row, JOBTABLE_COL_ISO), job->getStatus() == JOB_BUSY);
1942 updateCellStyle(queueTable->item(row, JOBTABLE_COL_OFFSET), job->getStatus() == JOB_BUSY);
1948 if (cell ==
nullptr)
1952 font.setBold(active);
1953 font.setItalic(active);
1957bool Camera::syncControl(
const QVariantMap &settings,
const QString &key,
QWidget * widget)
1970 const int value = settings[key].toInt(&ok);
1979 const double value = settings[key].toDouble(&ok);
1984 if (pDSB == captureGainN)
1986 if (captureGainN->value() != GainSpinSpecialValue)
1987 setGain(captureGainN->value());
1991 else if (pDSB == captureOffsetN)
1993 if (captureOffsetN->value() != OffsetSpinSpecialValue)
1994 setOffset(captureOffsetN->value());
2003 const bool value = settings[key].toBool();
2010 const bool value = settings[key].toBool();
2018 const QString value = settings[key].toString();
2030 const auto value = settings[key].toString();
2033 if (pLineEdit == fileRemoteDirT)
2034 generatePreviewFilename();
2041void Camera::moveJob(
bool up)
2043 int currentRow = queueTable->currentRow();
2044 int destinationRow =
up ? currentRow - 1 : currentRow + 1;
2046 int columnCount = queueTable->columnCount();
2048 if (currentRow < 0 || destinationRow < 0 || destinationRow >= queueTable->rowCount())
2051 for (
int i = 0; i < columnCount; i++)
2056 queueTable->setItem(destinationRow, i, selectedLine);
2057 queueTable->setItem(currentRow, i, counterpart);
2060 SequenceJob * job = state()->allJobs().takeAt(currentRow);
2062 state()->allJobs().removeOne(job);
2063 state()->allJobs().insert(destinationRow, job);
2065 QJsonArray seqArray = state()->getSequence();
2066 QJsonObject currentJob = seqArray[currentRow].toObject();
2067 seqArray.
replace(currentRow, seqArray[destinationRow]);
2068 seqArray.
replace(destinationRow, currentJob);
2069 emit sequenceChanged(seqArray);
2071 queueTable->selectRow(destinationRow);
2073 state()->setDirty(
true);
2076void Camera::removeJobFromQueue()
2078 int currentRow = queueTable->currentRow();
2081 currentRow = queueTable->rowCount() - 1;
2083 removeJob(currentRow);
2086 if (queueTable->rowCount() == 0)
2089 if (currentRow > queueTable->rowCount())
2090 queueTable->selectRow(queueTable->rowCount() - 1);
2092 queueTable->selectRow(currentRow);
2095void Camera::saveFITSDirectory()
2105void Camera::updateCaptureFormats()
2107 if (!activeCamera())
return;
2112 QString currentType = captureTypeS->currentText();
2114 captureTypeS->blockSignals(
true);
2115 captureTypeS->
clear();
2118 captureTypeS->setEnabled(
false);
2121 captureTypeS->setEnabled(
true);
2122 captureTypeS->addItems(frameTypes);
2124 if (currentType ==
"")
2127 captureTypeS->setCurrentIndex(devices()->getActiveChip()->getFrameType());
2128 currentType = captureTypeS->currentText();
2131 captureTypeS->setCurrentText(currentType);
2133 captureTypeS->blockSignals(
false);
2135 const bool isVideo = currentType == CAPTURE_TYPE_VIDEO;
2138 captureFormatS->blockSignals(
true);
2139 captureFormatS->clear();
2140 const auto list = isVideo ? activeCamera()->getVideoFormats() : activeCamera()->getCaptureFormats();
2141 captureFormatS->addItems(list);
2142 storeTrainKey(KEY_FORMATS, list);
2143 captureFormatS->setCurrentText(activeCamera()->getCaptureFormat());
2144 captureFormatS->blockSignals(
false);
2147 captureEncodingS->blockSignals(
true);
2148 captureEncodingS->clear();
2149 captureEncodingS->addItems(isVideo ? activeCamera()->getStreamEncodings() : activeCamera()->getEncodingFormats());
2150 captureEncodingS->setCurrentText(isVideo ? activeCamera()->getStreamEncoding() : activeCamera()->getEncodingFormat());
2151 captureEncodingS->blockSignals(
false);
2154void Camera::updateHFRCheckAlgo()
2157 const bool threshold = (m_LimitsUI->hFRCheckAlgorithm->currentIndex() != HFR_CHECK_FIXED);
2158 m_LimitsUI->hFRThresholdPercentage->setEnabled(threshold);
2159 m_LimitsUI->limitFocusHFRThresholdLabel->setEnabled(threshold);
2160 m_LimitsUI->limitFocusHFRPercentLabel->setEnabled(threshold);
2161 state()->updateHFRThreshold();
2164void Camera::clearAutoFocusHFR()
2166 if (Options::hFRCheckAlgorithm() == HFR_CHECK_FIXED)
2169 m_LimitsUI->hFRDeviation->setValue(0);
2179void Camera::clearCameraConfiguration()
2185 devices()->getActiveCamera()->setConfig(PURGE_CONFIG);
2186 KStarsData::Instance()->
userdb()->DeleteDSLRInfo(devices()->getActiveCamera()->getDeviceName());
2188 QStringList shutterfulCCDs = Options::shutterfulCCDs();
2189 QStringList shutterlessCCDs = Options::shutterlessCCDs();
2192 if (shutterfulCCDs.
contains(devices()->getActiveCamera()->getDeviceName()))
2194 shutterfulCCDs.
removeOne(devices()->getActiveCamera()->getDeviceName());
2195 Options::setShutterfulCCDs(shutterfulCCDs);
2197 if (shutterlessCCDs.
contains(devices()->getActiveCamera()->getDeviceName()))
2199 shutterlessCCDs.
removeOne(devices()->getActiveCamera()->getDeviceName());
2200 Options::setShutterlessCCDs(shutterlessCCDs);
2204 if (captureISOS && captureISOS->count() > 0)
2210 KSMessageBox::Instance()->questionYesNo(
i18n(
"Reset %1 configuration to default?",
2211 devices()->getActiveCamera()->getDeviceName()),
2212 i18n(
"Confirmation"), 30);
2215void Camera::editFilterName()
2220 for (
int index = 0; index < FilterPosCombo->count(); index++)
2221 labels << FilterPosCombo->itemText(index);
2223 if (editFilterNameInternal(labels, newLabels))
2225 FilterPosCombo->clear();
2226 FilterPosCombo->addItems(newLabels);
2231 if (devices()->filterWheel() ==
nullptr || state()->getCurrentFilterPosition() < 1)
2234 QStringList labels = filterManager()->getFilterLabels();
2236 if (editFilterNameInternal(labels, newLabels))
2237 filterManager()->setFilterNames(newLabels);
2248 for (uint8_t i = 0; i < labels.
count(); i++)
2250 QLabel *existingLabel =
new QLabel(
QString(
"%1. <b>%2</b>").arg(i + 1).arg(labels[i]), &filterDialog);
2252 newLabelEdits.
append(newLabel);
2253 formLayout->
addRow(existingLabel, newLabel);
2256 QString title = m_standAlone ?
2257 "Edit Filter Names" : devices()->filterWheel()->getDeviceName();
2268 for (uint8_t i = 0; i < labels.
count(); i++)
2269 results << newLabelEdits[i]->text();
2270 newLabels = results;
2276void Camera::updateVideoDurationUnit()
2278 if (videoDurationUnitCB->currentIndex() == 0)
2281 videoDurationSB->setValue(videoDurationSB->value() * captureExposureN->value());
2282 videoDurationSB->setDecimals(2);
2287 videoDurationSB->setValue(videoDurationSB->value() / captureExposureN->value());
2288 videoDurationSB->setDecimals(0);
2292void Camera::loadGlobalSettings()
2297 QVariantMap settings;
2301 if (oneWidget->objectName() ==
"opticalTrainCombo")
2304 key = oneWidget->objectName();
2305 value = Options::self()->property(key.
toLatin1());
2306 if (value.
isValid() && oneWidget->count() > 0)
2308 oneWidget->setCurrentText(value.
toString());
2309 settings[key] = value;
2312 QCDEBUG <<
"Option" << key <<
"not found!";
2318 key = oneWidget->objectName();
2319 value = Options::self()->property(key.
toLatin1());
2322 oneWidget->setValue(value.
toDouble());
2323 settings[key] = value;
2326 QCDEBUG <<
"Option" << key <<
"not found!";
2332 key = oneWidget->objectName();
2333 value = Options::self()->property(key.
toLatin1());
2336 oneWidget->setValue(value.
toInt());
2337 settings[key] = value;
2340 QCDEBUG <<
"Option" << key <<
"not found!";
2346 key = oneWidget->objectName();
2347 value = Options::self()->property(key.
toLatin1());
2350 oneWidget->setChecked(value.
toBool());
2351 settings[key] = value;
2354 QCDEBUG <<
"Option" << key <<
"not found!";
2360 if (oneWidget->isCheckable())
2362 key = oneWidget->objectName();
2363 value = Options::self()->property(key.
toLatin1());
2366 oneWidget->setChecked(value.
toBool());
2367 settings[key] = value;
2370 QCDEBUG <<
"Option" << key <<
"not found!";
2377 key = oneWidget->objectName();
2378 value = Options::self()->property(key.
toLatin1());
2381 oneWidget->setChecked(value.
toBool());
2382 settings[key] = value;
2389 if (oneWidget->objectName() ==
"qt_spinbox_lineedit" || oneWidget->isReadOnly())
2391 key = oneWidget->objectName();
2392 value = Options::self()->property(key.
toLatin1());
2395 oneWidget->setText(value.
toString());
2396 settings[key] = value;
2399 m_GlobalSettings = settings;
2400 setSettings(settings);
2403bool Camera::checkUploadPaths(FilenamePreviewType filenamePreview,
SequenceJob *job)
2406 if (filenamePreview != FILENAME_NOT_PREVIEW)
2409 if (fileUploadModeS->currentIndex() != ISD::Camera::UPLOAD_CLIENT && job->getRemoteDirectory().toString().isEmpty())
2411 KSNotification::error(
i18n(
"You must set local or remote directory for Remotely & Both modes."));
2415 if (fileUploadModeS->currentIndex() != ISD::Camera::UPLOAD_REMOTE && fileDirectoryT->text().isEmpty())
2417 KSNotification::error(
i18n(
"You must set local directory for Locally & Both modes."));
2430 bool isDarkFlat = job->jobType() == SequenceJob::JOBTYPE_DARKFLAT;
2431 jsonJob.
insert(
"Filter", FilterPosCombo->itemText(job->getTargetFilter() - 1));
2432 jsonJob.
insert(
"Count", queueTable->item(currentRow, JOBTABLE_COL_COUNTS)->text());
2433 jsonJob.
insert(
"Exp", queueTable->item(currentRow, JOBTABLE_COL_EXP)->text());
2434 jsonJob.
insert(
"Type", isDarkFlat ?
i18n(
"Dark Flat") : queueTable->item(currentRow, JOBTABLE_COL_TYPE)->text());
2435 jsonJob.
insert(
"Bin", queueTable->item(currentRow, JOBTABLE_COL_BINNING)->text());
2436 jsonJob.
insert(
"ISO/Gain", queueTable->item(currentRow, JOBTABLE_COL_ISO)->text());
2437 jsonJob.
insert(
"Offset", queueTable->item(currentRow, JOBTABLE_COL_OFFSET)->text());
2438 jsonJob.
insert(
"Encoding", job->getCoreProperty(SequenceJob::SJ_Encoding).toJsonValue());
2439 jsonJob.
insert(
"Format", job->getCoreProperty(SequenceJob::SJ_Format).toJsonValue());
2440 jsonJob.
insert(
"Temperature", job->getTargetTemperature());
2441 jsonJob.
insert(
"EnforceTemperature", job->getCoreProperty(SequenceJob::SJ_EnforceTemperature).toJsonValue());
2442 jsonJob.
insert(
"DitherPerJobFrequency", job->getCoreProperty(SequenceJob::SJ_DitherPerJobFrequency).toJsonValue());
2447void Camera::generatePreviewFilename()
2449 if (state()->isCaptureRunning() ==
false)
2451 placeholderFormatT->setToolTip(previewFilename( fileUploadModeS->currentIndex() == ISD::Camera::UPLOAD_REMOTE ?
2452 FILENAME_REMOTE_PREVIEW : FILENAME_LOCAL_PREVIEW ));
2453 emit newLocalPreview(placeholderFormatT->toolTip());
2455 if (fileUploadModeS->currentIndex() != ISD::Camera::UPLOAD_CLIENT)
2456 fileRemoteDirT->setToolTip(previewFilename( FILENAME_REMOTE_PREVIEW ));
2460QString Camera::previewFilename(FilenamePreviewType previewType)
2466 if (previewType == FILENAME_LOCAL_PREVIEW)
2468 if(!fileDirectoryT->text().endsWith(separator) && !placeholderFormatT->text().startsWith(separator))
2469 placeholderFormatT->setText(separator + placeholderFormatT->text());
2470 m_format = fileDirectoryT->text() + placeholderFormatT->text() + formatSuffixN->prefix() +
2471 formatSuffixN->cleanText();
2473 else if (previewType == FILENAME_REMOTE_PREVIEW)
2474 m_format = fileRemoteDirT->text().
isEmpty() ? fileDirectoryT->text() : fileRemoteDirT->text();
2482 else if (state()->sequenceURL().toLocalFile().isEmpty() && m_format.
contains(
"%f"))
2483 previewText = (
"Save the sequence file to show filename preview");
2487 SequenceJob *m_job = createJob(SequenceJob::JOBTYPE_PREVIEW, previewType);
2488 if (m_job ==
nullptr)
2492 if (state()->sequenceURL().toLocalFile().isEmpty())
2498 previewSeq = state()->sequenceURL().toLocalFile();
2499 auto m_placeholderPath = PlaceholderPath(previewSeq);
2502 if (captureEncodingS->currentText() ==
"FITS")
2503 extension =
".fits";
2504 else if (captureEncodingS->currentText() ==
"XISF")
2505 extension =
".xisf";
2507 extension =
".[NATIVE]";
2508 previewText = m_placeholderPath.generateSequenceFilename(*m_job, previewType == FILENAME_LOCAL_PREVIEW,
true, 1,
2509 extension,
"",
false);
2512 m_job->deleteLater();
2516 if (previewType == FILENAME_REMOTE_PREVIEW)
2517 previewText.
replace(separator,
"/");
2524 countCell->
setText(
QString(
"%L1/%L2").arg(job->getCompleted()).
arg(job->getCoreProperty(SequenceJob::SJ_Count).toInt()));
2527void Camera::addDSLRInfo(
const QString &model, uint32_t maxW, uint32_t maxH,
double pixelW,
double pixelH)
2530 auto pos = std::find_if(state()->DSLRInfos().
begin(), state()->DSLRInfos().
end(), [model](
const auto & oneDSLRInfo)
2532 return (oneDSLRInfo[
"Model"] == model);
2535 if (
pos != state()->DSLRInfos().
end())
2537 KStarsData::Instance()->
userdb()->DeleteDSLRInfo(model);
2538 state()->DSLRInfos().removeOne(*
pos);
2542 oneDSLRInfo[
"Model"] = model;
2543 oneDSLRInfo[
"Width"] = maxW;
2544 oneDSLRInfo[
"Height"] = maxH;
2545 oneDSLRInfo[
"PixelW"] = pixelW;
2546 oneDSLRInfo[
"PixelH"] = pixelH;
2548 KStarsData::Instance()->
userdb()->AddDSLRInfo(oneDSLRInfo);
2549 KStarsData::Instance()->
userdb()->GetAllDSLRInfos(state()->DSLRInfos());
2551 updateFrameProperties();
2552 process()->resetFrame();
2553 process()->syncDSLRToTargetChip(model);
2556 if (m_DSLRInfoDialog)
2557 m_DSLRInfoDialog.reset();
2562 process()->startNextPendingJob();
2565void Camera::stop(CaptureState targetState)
2567 process()->stopCapturing(targetState);
2572 process()->pauseCapturing();
2573 updateStartButtons(
false,
true);
2576void Camera::toggleSequence()
2578 const CaptureState capturestate = state()->getCaptureState();
2580 updateStartButtons(
true,
false);
2582 process()->toggleSequence();
2585void Camera::toggleVideo(
bool enabled)
2587 process()->toggleVideo(
enabled);
2590void Camera::restartCamera(
const QString &name)
2592 process()->restartCamera(name);
2595void Camera::cullToDSLRLimits()
2597 QString model(devices()->getActiveCamera()->getDeviceName());
2600 auto pos = std::find_if(state()->DSLRInfos().
begin(),
2603 return (oneDSLRInfo[
"Model"] == model);
2606 if (
pos != state()->DSLRInfos().
end())
2608 if (captureFrameWN->maximum() == 0 || captureFrameWN->maximum() > (*
pos)[
"Width"].toInt())
2610 captureFrameWN->setValue((*
pos)[
"Width"].toInt());
2611 captureFrameWN->setMaximum((*
pos)[
"Width"].toInt());
2614 if (captureFrameHN->maximum() == 0 || captureFrameHN->maximum() > (*
pos)[
"Height"].toInt())
2616 captureFrameHN->setValue((*
pos)[
"Height"].toInt());
2617 captureFrameHN->setMaximum((*
pos)[
"Height"].toInt());
2622void Camera::resetFrameToZero()
2624 captureFrameXN->setMinimum(0);
2625 captureFrameXN->setMaximum(0);
2626 captureFrameXN->setValue(0);
2628 captureFrameYN->setMinimum(0);
2629 captureFrameYN->setMaximum(0);
2630 captureFrameYN->setValue(0);
2632 captureFrameWN->setMinimum(0);
2633 captureFrameWN->setMaximum(0);
2634 captureFrameWN->setValue(0);
2636 captureFrameHN->setMinimum(0);
2637 captureFrameHN->setMaximum(0);
2638 captureFrameHN->setValue(0);
2641void Camera::updateFrameProperties(
int reset)
2643 if (!devices()->getActiveCamera())
2646 int binx = 1, biny = 1;
2647 double min, max, step;
2648 int xstep = 0, ystep = 0;
2651 QString exposureProp = state()->useGuideHead() ?
QString(
"GUIDER_EXPOSURE") :
QString(
"CCD_EXPOSURE");
2652 QString exposureElem = state()->useGuideHead() ?
QString(
"GUIDER_EXPOSURE_VALUE") :
2653 QString(
"CCD_EXPOSURE_VALUE");
2654 devices()->setActiveChip(state()->useGuideHead() ?
2655 devices()->getActiveCamera()->getChip(
2656 ISD::CameraChip::GUIDE_CCD) :
2657 devices()->getActiveCamera()->getChip(ISD::CameraChip::PRIMARY_CCD));
2659 captureFrameWN->setEnabled(devices()->getActiveChip()->canSubframe());
2660 captureFrameHN->setEnabled(devices()->getActiveChip()->canSubframe());
2661 captureFrameXN->setEnabled(devices()->getActiveChip()->canSubframe());
2662 captureFrameYN->setEnabled(devices()->getActiveChip()->canSubframe());
2664 captureBinHN->setEnabled(devices()->getActiveChip()->canBin());
2665 captureBinVN->setEnabled(devices()->getActiveChip()->canBin());
2668 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 <<
2669 10 << 20 << 30 << 40 << 50 << 60 << 120 << 180 << 300 << 600 << 900 << 1200 << 1800;
2671 if (devices()->getActiveCamera()->getMinMaxStep(exposureProp, exposureElem, &min, &max, &step))
2674 captureExposureN->setDecimals(6);
2676 captureExposureN->setDecimals(3);
2677 for(
int i = 0; i < exposureValues.
count(); i++)
2679 double value = exposureValues.
at(i);
2680 if(value < min || value > max)
2688 exposureValues.
append(max);
2691 captureExposureN->setRecommendedValues(exposureValues);
2692 state()->setExposureRange(exposureValues.
first(), exposureValues.
last());
2694 if (devices()->getActiveCamera()->getMinMaxStep(frameProp,
"WIDTH", &min, &max, &step))
2703 xstep =
static_cast<int>(max * 0.05);
2705 xstep =
static_cast<int>(step);
2707 if (min >= 0 && max > 0)
2709 captureFrameWN->setMinimum(
static_cast<int>(min));
2710 captureFrameWN->setMaximum(
static_cast<int>(max));
2711 captureFrameWN->setSingleStep(xstep);
2717 if (devices()->getActiveCamera()->getMinMaxStep(frameProp,
"HEIGHT", &min, &max, &step))
2726 ystep =
static_cast<int>(max * 0.05);
2728 ystep =
static_cast<int>(step);
2730 if (min >= 0 && max > 0)
2732 captureFrameHN->setMinimum(
static_cast<int>(min));
2733 captureFrameHN->setMaximum(
static_cast<int>(max));
2734 captureFrameHN->setSingleStep(ystep);
2740 if (devices()->getActiveCamera()->getMinMaxStep(frameProp,
"X", &min, &max, &step))
2751 if (min >= 0 && max > 0)
2753 captureFrameXN->setMinimum(
static_cast<int>(min));
2754 captureFrameXN->setMaximum(
static_cast<int>(max));
2755 captureFrameXN->setSingleStep(
static_cast<int>(step));
2761 if (devices()->getActiveCamera()->getMinMaxStep(frameProp,
"Y", &min, &max, &step))
2772 if (min >= 0 && max > 0)
2774 captureFrameYN->setMinimum(
static_cast<int>(min));
2775 captureFrameYN->setMaximum(
static_cast<int>(max));
2776 captureFrameYN->setSingleStep(
static_cast<int>(step));
2783 if (state()->useGuideHead() ==
false)
2786 const QString ccdGainKeyword = devices()->getActiveCamera()->getProperty(
"CCD_GAIN") ?
"CCD_GAIN" :
"CCD_CONTROLS";
2787 storeTrainKeyString(KEY_GAIN_KWD, ccdGainKeyword);
2789 const QString ccdOffsetKeyword = devices()->getActiveCamera()->getProperty(
"CCD_OFFSET") ?
"CCD_OFFSET" :
"CCD_CONTROLS";
2790 storeTrainKeyString(KEY_OFFSET_KWD, ccdOffsetKeyword);
2792 if (reset == 1 || state()->frameSettings().contains(devices()->getActiveChip()) ==
false)
2794 QVariantMap settings;
2798 settings[
"w"] = captureFrameWN->maximum();
2799 settings[
"h"] = captureFrameHN->maximum();
2800 settings[
"binx"] = captureBinHN->value();
2801 settings[
"biny"] = captureBinVN->value();
2803 state()->frameSettings()[devices()->getActiveChip()] = settings;
2805 else if (reset == 2 && state()->frameSettings().contains(devices()->getActiveChip()))
2807 QVariantMap settings = state()->frameSettings()[devices()->getActiveChip()];
2810 x = settings[
"x"].toInt();
2811 y = settings[
"y"].toInt();
2812 w = settings[
"w"].toInt();
2813 h = settings[
"h"].toInt();
2816 x = qBound(captureFrameXN->minimum(),
x, captureFrameXN->maximum() - 1);
2817 y = qBound(captureFrameYN->minimum(),
y, captureFrameYN->maximum() - 1);
2818 w = qBound(captureFrameWN->minimum(), w, captureFrameWN->maximum());
2819 h = qBound(captureFrameHN->minimum(), h, captureFrameHN->maximum());
2825 settings[
"binx"] = captureBinHN->value();
2826 settings[
"biny"] = captureBinVN->value();
2828 state()->frameSettings()[devices()->getActiveChip()] = settings;
2831 if (state()->frameSettings().contains(devices()->getActiveChip()))
2833 QVariantMap settings = state()->frameSettings()[devices()->getActiveChip()];
2834 int x = settings[
"x"].toInt();
2835 int y = settings[
"y"].toInt();
2836 int w = settings[
"w"].toInt();
2837 int h = settings[
"h"].toInt();
2839 if (devices()->getActiveChip()->canBin())
2841 devices()->getActiveChip()->getMaxBin(&binx, &biny);
2842 captureBinHN->setMaximum(binx);
2843 captureBinVN->setMaximum(biny);
2845 captureBinHN->setValue(settings[
"binx"].toInt());
2846 captureBinVN->setValue(settings[
"biny"].toInt());
2850 captureBinHN->setValue(1);
2851 captureBinVN->setValue(1);
2855 captureFrameXN->setValue(
x);
2857 captureFrameYN->setValue(
y);
2859 captureFrameWN->setValue(w);
2861 captureFrameHN->setValue(h);
2867void Camera::setGain(
double value)
2871 setStandAloneGain(value);
2874 if (!devices()->getActiveCamera())
2878 process()->updateGain(value, customProps);
2879 customPropertiesDialog()->setCustomProperties(customProps);
2883double Camera::getGain()
2885 return devices()->cameraGain(customPropertiesDialog()->getCustomProperties());
2888void Camera::setOffset(
double value)
2892 setStandAloneOffset(value);
2895 if (!devices()->getActiveCamera())
2900 process()->updateOffset(value, customProps);
2901 customPropertiesDialog()->setCustomProperties(customProps);
2904double Camera::getOffset()
2906 return devices()->cameraOffset(customPropertiesDialog()->getCustomProperties());
2909void Camera::setRotator(
QString name)
2913 rotatorB->setEnabled(
false);
2914 if (Rotator && !m_RotatorControlPanel.
isNull())
2915 m_RotatorControlPanel->close();
2920 Manager::Instance()->getRotatorController(name, m_RotatorControlPanel);
2921 m_RotatorControlPanel->initRotator(opticalTrainCombo->currentText(), devices().data(),
2925 m_RotatorControlPanel->show();
2926 m_RotatorControlPanel->raise();
2928 rotatorB->setEnabled(
true);
2930 else if (Options::astrometryUseRotator())
2932 RotatorUtils::Instance()->initRotatorUtils(opticalTrainCombo->currentText());
2936void Camera::setMaximumGuidingDeviation(
bool enable,
double value)
2938 m_LimitsUI->enforceGuideDeviation->setChecked(enable);
2940 m_LimitsUI->guideDeviation->setValue(value);
2943void Camera::setInSequenceFocus(
bool enable,
double HFR)
2945 m_LimitsUI->enforceAutofocusHFR->setChecked(enable);
2947 m_LimitsUI->hFRDeviation->setValue(HFR);
2950bool Camera::loadSequenceQueue(
const QString &fileURL,
QString targetName)
2952 QFile sFile(fileURL);
2955 QString message =
i18n(
"Unable to open file %1", fileURL);
2956 KSNotification::sorry(message,
i18n(
"Could Not Open File"));
2960 state()->clearCapturedFramesMap();
2961 clearSequenceQueue();
2964 const bool result = process()->loadSequenceQueue(fileURL, targetName, !m_standAlone);
2966 if (result ==
false)
2970 setObserverName(state()->observerName());
2973 if (state()->allJobs().
size() > 0)
2974 syncGUIToJob(state()->allJobs().first());
2977 queueSaveB->setToolTip(
"Save to " + sFile.fileName());
2982bool Camera::saveSequenceQueue(
const QString &path)
2985 return process()->saveSequenceQueue(path);
2988void Camera::updateCameraStatus(CaptureState status)
2991 emit newStatus(status, opticalTrain(), cameraId());
2994void Camera::clearSequenceQueue()
2996 state()->setActiveJob(
nullptr);
2997 while (queueTable->rowCount() > 0)
2998 queueTable->removeRow(0);
2999 qDeleteAll(state()->allJobs());
3000 state()->allJobs().clear();
3002 while (state()->getSequence().count())
3003 state()->getSequence().pop_back();
3004 emit sequenceChanged(state()->getSequence());
3007QVariantMap Camera::getAllSettings()
const
3009 QVariantMap settings;
3015 auto name = oneWidget->objectName();
3016 if (name ==
"qt_spinbox_lineedit")
3018 settings.insert(name, oneWidget->text());
3023 settings.insert(oneWidget->objectName(), oneWidget->currentText());
3027 settings.insert(oneWidget->objectName(), oneWidget->value());
3031 settings.insert(oneWidget->objectName(), oneWidget->value());
3035 settings.insert(oneWidget->objectName(), oneWidget->isChecked());
3039 if (oneWidget->isCheckable())
3040 settings.insert(oneWidget->objectName(), oneWidget->isChecked());
3044 settings.insert(oneWidget->objectName(), oneWidget->isChecked());
3049void Camera::setAllSettings(
const QVariantMap &settings,
const QVariantMap * standAloneSettings)
3053 disconnectSyncSettings();
3055 for (
auto &name : settings.keys())
3061 syncControl(settings, name, comboBox);
3069 syncControl(settings, name, doubleSpinBox);
3077 syncControl(settings, name, spinBox);
3085 syncControl(settings, name, checkbox);
3091 if (groupbox && groupbox->isCheckable())
3093 syncControl(settings, name, groupbox);
3101 syncControl(settings, name, radioButton);
3109 syncControl(settings, name, lineEdit);
3115 for (
auto &key : settings.keys())
3117 auto value = settings[key];
3119 Options::self()->setProperty(key.
toLatin1(), value);
3121 m_settings[key] = value;
3122 m_GlobalSettings[key] = value;
3125 if (standAloneSettings && standAloneSettings->size() > 0)
3127 for (
const auto &k : standAloneSettings->keys())
3128 m_settings[k] = (*standAloneSettings)[k];
3131 emit settingsUpdated(getAllSettings());
3136 const int id = OpticalTrainManager::Instance()->id(opticalTrainCombo->currentText());
3137 OpticalTrainSettings::Instance()->setOpticalTrainID(
id);
3138 OpticalTrainSettings::Instance()->setOneSetting(OpticalTrainSettings::Capture, m_settings);
3139 Options::setCaptureTrainID(
id);
3142 connectSyncSettings();
3145void Camera::setupOpticalTrainManager()
3147 connect(OpticalTrainManager::Instance(), &OpticalTrainManager::updated,
this, &Camera::refreshOpticalTrain);
3150 OpticalTrainManager::Instance()->openEditor(opticalTrainCombo->currentText());
3154 ProfileSettings::Instance()->setOneSetting(ProfileSettings::CaptureOpticalTrain,
3155 OpticalTrainManager::Instance()->
id(opticalTrainCombo->itemText(index)));
3156 refreshOpticalTrain();
3157 emit trainChanged();
3161void Camera::refreshOpticalTrain()
3163 opticalTrainCombo->blockSignals(
true);
3164 opticalTrainCombo->clear();
3165 opticalTrainCombo->addItems(OpticalTrainManager::Instance()->getTrainNames());
3166 trainB->setEnabled(
true);
3168 QVariant trainID = ProfileSettings::Instance()->getOneSetting(ProfileSettings::CaptureOpticalTrain);
3169 if (m_standAlone || trainID.
isValid())
3171 auto id = m_standAlone ? Options::captureTrainID() : trainID.toUInt();
3172 Options::setCaptureTrainID(
id);
3175 if (OpticalTrainManager::Instance()->exists(
id) ==
false)
3177 qCWarning(KSTARS_EKOS_CAPTURE) <<
"Optical train doesn't exist for id" << id;
3178 id = OpticalTrainManager::Instance()->id(opticalTrainCombo->itemText(0));
3181 auto name = OpticalTrainManager::Instance()->name(
id);
3183 opticalTrainCombo->setCurrentText(name);
3185 process()->refreshOpticalTrain(name);
3191 OpticalTrainSettings::Instance()->setOpticalTrainID(
id);
3192 auto settings = OpticalTrainSettings::Instance()->getOneSetting(OpticalTrainSettings::Capture);
3193 if (settings.isValid())
3195 auto map = settings.toJsonObject().toVariantMap();
3196 if (map != m_settings)
3198 QVariantMap standAloneSettings = copyStandAloneSettings(m_settings);
3200 setAllSettings(map, &standAloneSettings);
3204 setSettings(m_GlobalSettings);
3207 opticalTrainCombo->blockSignals(
false);
3210void Camera::selectOpticalTrain(
QString name)
3212 opticalTrainCombo->setCurrentText(name);
3215void Camera::syncLimitSettings()
3217 m_LimitsUI->enforceStartGuiderDrift->setChecked(Options::enforceStartGuiderDrift());
3218 m_LimitsUI->startGuideDeviation->setValue(Options::startGuideDeviation());
3219 m_LimitsUI->enforceGuideDeviation->setChecked(Options::enforceGuideDeviation());
3220 m_LimitsUI->guideDeviation->setValue(Options::guideDeviation());
3221 m_LimitsUI->guideDeviationReps->setValue(
static_cast<int>(Options::guideDeviationReps()));
3222 m_LimitsUI->enforceAutofocusHFR->setChecked(Options::enforceAutofocusHFR());
3223 m_LimitsUI->hFRThresholdPercentage->setValue(Options::hFRThresholdPercentage());
3224 m_LimitsUI->hFRDeviation->setValue(Options::hFRDeviation());
3225 m_LimitsUI->inSequenceCheckFrames->setValue(Options::inSequenceCheckFrames());
3226 m_LimitsUI->hFRCheckAlgorithm->setCurrentIndex(Options::hFRCheckAlgorithm());
3227 m_LimitsUI->enforceAutofocusOnTemperature->setChecked(Options::enforceAutofocusOnTemperature());
3228 m_LimitsUI->maxFocusTemperatureDelta->setValue(Options::maxFocusTemperatureDelta());
3229 m_LimitsUI->enforceRefocusEveryN->setChecked(Options::enforceRefocusEveryN());
3230 m_LimitsUI->refocusEveryN->setValue(
static_cast<int>(Options::refocusEveryN()));
3231 m_LimitsUI->refocusAfterMeridianFlip->setChecked(Options::refocusAfterMeridianFlip());
3234void Camera::settleSettings()
3236 state()->setDirty(
true);
3237 emit settingsUpdated(getAllSettings());
3239 const int id = OpticalTrainManager::Instance()->id(opticalTrainCombo->currentText());
3240 OpticalTrainSettings::Instance()->setOpticalTrainID(
id);
3241 OpticalTrainSettings::Instance()->setOneSetting(OpticalTrainSettings::Capture, m_settings);
3242 Options::setCaptureTrainID(
id);
3245void Camera::syncSettings()
3261 value = dsb->
value();
3267 value = sb->
value();
3285 settings().remove(key);
3304 settings()[key] = value;
3305 m_GlobalSettings[key] = value;
3307 Options::self()->setProperty(key.
toLatin1(), value);
3308 m_DebounceTimer.
start();
3312void Camera::connectSyncSettings()
3332 if (oneWidget->isCheckable())
3342 if (oneWidget->objectName() ==
"qt_spinbox_lineedit" || oneWidget->isReadOnly())
3351void Camera::disconnectSyncSettings()
3371 if (oneWidget->isCheckable())
3381 if (oneWidget->objectName() ==
"qt_spinbox_lineedit")
3389 if (!m_settings.contains(key) || m_settings[key].toStringList() != list)
3391 m_settings[key] =
list;
3392 m_DebounceTimer.
start();
3396void Camera::storeTrainKeyString(
const QString &key,
const QString &str)
3398 if (!m_settings.contains(key) || m_settings[key].toString() != str)
3400 m_settings[key] = str;
3401 m_DebounceTimer.
start();
3405void Camera::setupFilterManager()
3408 if (filterManager())
3409 filterManager()->disconnect(
this);
3412 Manager::Instance()->createFilterManager(devices()->filterWheel());
3415 Manager::Instance()->getFilterManager(devices()->filterWheel()->getDeviceName(), m_FilterManager);
3417 devices()->setFilterManager(m_FilterManager);
3419 connect(filterManager().
get(), &FilterManager::updated,
this, [
this]()
3421 emit filterManagerUpdated(devices()->filterWheel());
3425 connect(filterManager().
get(), &FilterManager::newStatus,
this, &Camera::newFilterStatus);
3429 filterManager()->refreshFilterModel();
3430 filterManager()->show();
3431 filterManager()->raise();
3434 connect(filterManager().
get(), &FilterManager::failed,
this, [
this]()
3438 appendLogText(
i18n(
"Filter operation failed."));
3444 connect(filterManager().
get(), &FilterManager::newStatus,
this, &Camera::setFilterStatus);
3446 connect(filterManager().
get(), &FilterManager::labelsChanged,
this, [
this]()
3448 FilterPosCombo->clear();
3449 FilterPosCombo->addItems(filterManager()->getFilterLabels());
3450 FilterPosCombo->setCurrentIndex(filterManager()->getFilterPosition() - 1);
3451 updateCurrentFilterPosition();
3452 storeTrainKey(KEY_FILTERS, filterManager()->getFilterLabels());
3455 connect(filterManager().
get(), &FilterManager::positionChanged,
this, [
this]()
3457 FilterPosCombo->setCurrentIndex(filterManager()->getFilterPosition() - 1);
3458 updateCurrentFilterPosition();
3462void Camera::clearFilterManager()
3465 if (m_FilterManager)
3466 m_FilterManager->disconnect(
this);
3469 m_FilterManager.
clear();
3470 devices()->clearFilterManager();
3473void Camera::refreshFilterSettings()
3475 FilterPosCombo->clear();
3477 if (!devices()->filterWheel())
3479 FilterPosLabel->setEnabled(
false);
3480 FilterPosCombo->setEnabled(
false);
3481 filterEditB->setEnabled(
false);
3482 filterManagerB->setEnabled(
false);
3484 clearFilterManager();
3488 FilterPosLabel->setEnabled(
true);
3489 FilterPosCombo->setEnabled(
true);
3490 filterEditB->setEnabled(
true);
3491 filterManagerB->setEnabled(
true);
3493 setupFilterManager();
3495 process()->updateFilterInfo();
3497 const auto labels = process()->filterLabels();
3498 FilterPosCombo->addItems(labels);
3501 storeTrainKey(KEY_FILTERS, labels);
3503 updateCurrentFilterPosition();
3505 filterEditB->setEnabled(state()->getCurrentFilterPosition() > 0);
3506 filterManagerB->setEnabled(state()->getCurrentFilterPosition() > 0);
3508 FilterPosCombo->setCurrentIndex(state()->getCurrentFilterPosition() - 1);
3511void Camera::updateCurrentFilterPosition()
3513 const QString currentFilterText = FilterPosCombo->itemText(m_FilterManager->getFilterPosition() - 1);
3514 state()->setCurrentFilterPosition(m_FilterManager->getFilterPosition(),
3516 m_FilterManager->getFilterLock(currentFilterText));
3520void Camera::setFilterWheel(
QString name)
3526 if (devices()->filterWheel() && devices()->filterWheel()->getDeviceName() == name)
3528 refreshFilterSettings();
3532 auto isConnected = devices()->filterWheel() && devices()->filterWheel()->isConnected();
3533 FilterPosLabel->setEnabled(isConnected);
3534 FilterPosCombo->setEnabled(isConnected);
3535 filterManagerB->setEnabled(isConnected);
3537 refreshFilterSettings();
3539 if (devices()->filterWheel())
3540 emit settingsUpdated(getAllSettings());
3545 return m_DeviceAdaptor->getActiveCamera();
3550 QVariant trainID = ProfileSettings::Instance()->getOneSetting(ProfileSettings::CaptureOpticalTrain);
3551 if (activeCamera() && trainID.
isValid())
3553 auto id = trainID.
toUInt();
3554 auto name = OpticalTrainManager::Instance()->name(
id);
3555 return OpticalTrainManager::Instance()->getScope(name);
3561double Camera::currentReducer()
3563 QVariant trainID = ProfileSettings::Instance()->getOneSetting(ProfileSettings::CaptureOpticalTrain);
3564 if (activeCamera() && trainID.
isValid())
3566 auto id = trainID.
toUInt();
3567 auto name = OpticalTrainManager::Instance()->name(
id);
3568 return OpticalTrainManager::Instance()->getReducer(name);
3574double Camera::currentAperture()
3576 auto scope = currentScope();
3578 double focalLength = scope[
"focal_length"].toDouble(-1);
3579 double aperture = scope[
"aperture"].toDouble(-1);
3580 double focalRatio = scope[
"focal_ratio"].toDouble(-1);
3583 if (aperture < 0 && focalRatio > 0)
3584 aperture = focalLength * focalRatio;
3589void Camera::updateMeridianFlipStage(MeridianFlipState::MFStage stage)
3592 if (state()->getMeridianFlipState()->getMeridianFlipStage() != stage)
3596 case MeridianFlipState::MF_READY:
3604 case MeridianFlipState::MF_INITIATED:
3605 captureStatusWidget->setStatus(
i18n(
"Meridian Flip..."),
Qt::yellow);
3606 KSNotification::event(
QLatin1String(
"MeridianFlipStarted"),
i18n(
"Meridian flip started"), KSNotification::Capture);
3609 case MeridianFlipState::MF_COMPLETED:
3610 captureStatusWidget->setStatus(
i18n(
"Flip complete."),
Qt::yellow);
3619void Camera::openExposureCalculatorDialog()
3621 QCINFO <<
"Instantiating an Exposure Calculator";
3624 double preferredSkyQuality = 20.5;
3626 auto scope = currentScope();
3627 double focalRatio = scope[
"focal_ratio"].toDouble(-1);
3629 auto reducedFocalLength = currentReducer() * scope[
"focal_length"].toDouble(-1);
3630 auto aperture = currentAperture();
3631 auto reducedFocalRatio = (focalRatio > 0 || aperture == 0) ? focalRatio : reducedFocalLength / aperture;
3633 if (devices()->getActiveCamera() !=
nullptr)
3635 QCINFO <<
"set ExposureCalculator preferred camera to active camera id: "
3636 << devices()->getActiveCamera()->getDeviceName();
3640 preferredSkyQuality,
3642 devices()->getActiveCamera()->getDeviceName()));
3644 anExposureCalculatorDialog->show();
3647void Camera::handleScriptsManager()
3653 m_scriptsManager->setScripts(old_scripts);
3656void Camera::showTemperatureRegulation()
3658 if (!devices()->getActiveCamera())
3661 double currentRamp, currentThreshold;
3662 if (!devices()->getActiveCamera()->getTemperatureRegulation(currentRamp, currentThreshold))
3665 double rMin, rMax, rStep, tMin, tMax, tStep;
3667 devices()->getActiveCamera()->getMinMaxStep(
"CCD_TEMP_RAMP",
"RAMP_SLOPE", &rMin, &rMax, &rStep);
3668 devices()->getActiveCamera()->getMinMaxStep(
"CCD_TEMP_RAMP",
"RAMP_THRESHOLD", &tMin, &tMax, &tStep);
3670 QLabel rampLabel(
i18nc(
"Maximum temperature variation over time when regulating.",
"Ramp (°C/min):"));
3677 "<p>Maximum temperature change per minute when cooling or warming the camera. Set zero to disable."
3678 "<p>This setting is read from and stored in the INDI camera driver configuration."
3681 QLabel thresholdLabel(
i18nc(
"Temperature threshold above which regulation triggers.",
"Threshold (°C):"));
3686 thresholdSpin.
setValue(currentThreshold);
3688 "<p>Maximum difference between camera and target temperatures triggering regulation."
3689 "<p>This setting is read from and stored in the INDI camera driver configuration."
3693 layout.addRow(&rampLabel, &rampSpin);
3694 layout.addRow(&thresholdLabel, &thresholdSpin);
3700 dialog->setWindowTitle(
i18nc(
"@title:window",
"Set Temperature Regulation"));
3702 dialog->setLayout(&
layout);
3703 dialog->setMinimumWidth(300);
3707 if (devices()->getActiveCamera())
3708 devices()->getActiveCamera()->setTemperatureRegulation(rampSpin.
value(), thresholdSpin.
value());
3712void Camera::createDSLRDialog()
3714 m_DSLRInfoDialog.reset(
new DSLRInfo(
this, devices()->getActiveCamera()));
3716 connect(m_DSLRInfoDialog.get(), &DSLRInfo::infoChanged,
this, [
this]()
3718 if (devices()->getActiveCamera())
3719 addDSLRInfo(QString(devices()->getActiveCamera()->getDeviceName()),
3720 m_DSLRInfoDialog->sensorMaxWidth,
3721 m_DSLRInfoDialog->sensorMaxHeight,
3722 m_DSLRInfoDialog->sensorPixelW,
3723 m_DSLRInfoDialog->sensorPixelH);
3726 m_DSLRInfoDialog->show();
3728 emit dslrInfoRequested(devices()->getActiveCamera()->getDeviceName());
3731void Camera::showObserverDialog()
3736 for (
auto &o : m_observerList)
3737 observers <<
QString(
"%1 %2").
arg(o->name(), o->surname());
3739 QDialog observersDialog(
this);
3740 observersDialog.setWindowTitle(
i18nc(
"@title:window",
"Select Current Observer"));
3744 QComboBox observerCombo(&observersDialog);
3745 observerCombo.addItems(observers);
3746 observerCombo.setCurrentText(getObserverName());
3750 manageObserver.setFixedSize(
QSize(32, 32));
3753 manageObserver.setToolTip(
i18n(
"Manage Observers"));
3762 for (
auto &o : m_observerList)
3763 observers <<
QString(
"%1 %2").
arg(o->name(), o->surname());
3765 observerCombo.
clear();
3766 observerCombo.addItems(observers);
3767 observerCombo.setCurrentText(getObserverName());
3776 observersDialog.setLayout(
layout);
3778 observersDialog.exec();
3779 setObserverName(observerCombo.currentText());
3782void Camera::onStandAloneShow(
QShowEvent * event)
3784 OpticalTrainSettings::Instance()->setOpticalTrainID(Options::captureTrainID());
3785 auto oneSetting = OpticalTrainSettings::Instance()->getOneSetting(OpticalTrainSettings::Capture);
3786 setSettings(oneSetting.toJsonObject().toVariantMap());
3791 captureGainN->setValue(GainSpinSpecialValue);
3792 captureOffsetN->setValue(OffsetSpinSpecialValue);
3794 m_standAloneUseCcdGain =
true;
3795 m_standAloneUseCcdOffset =
true;
3796 if (m_settings.contains(KEY_GAIN_KWD) && m_settings[KEY_GAIN_KWD].toString() ==
"CCD_CONTROLS")
3797 m_standAloneUseCcdGain =
false;
3798 if (m_settings.contains(KEY_OFFSET_KWD) && m_settings[KEY_OFFSET_KWD].toString() ==
"CCD_CONTROLS")
3799 m_standAloneUseCcdOffset =
false;
3805 if (captureGainN->value() != GainSpinSpecialValue)
3806 setGain(captureGainN->value());
3814 if (captureOffsetN->value() != OffsetSpinSpecialValue)
3815 setOffset(captureOffsetN->value());
3821void Camera::setStandAloneGain(
double value)
3825 if (m_standAloneUseCcdGain)
3830 ccdGain[
"GAIN"] = value;
3831 propertyMap[
"CCD_GAIN"] = ccdGain;
3835 propertyMap[
"CCD_GAIN"].
remove(
"GAIN");
3836 if (propertyMap[
"CCD_GAIN"].
size() == 0)
3837 propertyMap.
remove(
"CCD_GAIN");
3845 ccdGain[
"Gain"] = value;
3846 propertyMap[
"CCD_CONTROLS"] = ccdGain;
3850 propertyMap[
"CCD_CONTROLS"].
remove(
"Gain");
3851 if (propertyMap[
"CCD_CONTROLS"].
size() == 0)
3852 propertyMap.
remove(
"CCD_CONTROLS");
3856 m_customPropertiesDialog->setCustomProperties(propertyMap);
3859void Camera::setStandAloneOffset(
double value)
3863 if (m_standAloneUseCcdOffset)
3868 ccdOffset[
"OFFSET"] = value;
3869 propertyMap[
"CCD_OFFSET"] = ccdOffset;
3873 propertyMap[
"CCD_OFFSET"].
remove(
"OFFSET");
3874 if (propertyMap[
"CCD_OFFSET"].
size() == 0)
3875 propertyMap.
remove(
"CCD_OFFSET");
3883 ccdOffset[
"Offset"] = value;
3884 propertyMap[
"CCD_CONTROLS"] = ccdOffset;
3888 propertyMap[
"CCD_CONTROLS"].
remove(
"Offset");
3889 if (propertyMap[
"CCD_CONTROLS"].
size() == 0)
3890 propertyMap.
remove(
"CCD_CONTROLS");
3894 m_customPropertiesDialog->setCustomProperties(propertyMap);
3897void Camera::setVideoStreamEnabled(
bool enabled)
3901 liveVideoB->setChecked(
true);
3906 liveVideoB->setChecked(
false);
3912void Camera::setCoolerToggled(
bool enabled)
3914 auto isToggled = (!
enabled && coolerOnB->isChecked()) || (
enabled && coolerOffB->isChecked());
3916 coolerOnB->blockSignals(
true);
3917 coolerOnB->setChecked(
enabled);
3918 coolerOnB->blockSignals(
false);
3920 coolerOffB->blockSignals(
true);
3921 coolerOffB->setChecked(!
enabled);
3922 coolerOffB->blockSignals(
false);
3925 appendLogText(
enabled ?
i18n(
"Cooler is on") :
i18n(
"Cooler is off"));
3928void Camera::setFilterStatus(FilterState filterState)
3930 if (filterState != state()->getFilterManagerState())
3931 QCDEBUG <<
"Filter state changed from" << Ekos::getFilterStatusString(
3932 state()->getFilterManagerState()) <<
"to" << Ekos::getFilterStatusString(filterState);
3935 switch (filterState)
3938 appendLogText(
i18n(
"Changing focus offset by %1 steps...",
3939 filterManager()->getTargetFilterOffset()));
3943 appendLogText(
i18n(
"Changing filter to %1...",
3944 FilterPosCombo->itemText(filterManager()->getTargetFilterPosition() - 1)));
3947 case FILTER_AUTOFOCUS:
3948 appendLogText(
i18n(
"Auto focus on filter change..."));
3949 clearAutoFocusHFR();
3953 if (state()->getFilterManagerState() == FILTER_CHANGE)
3955 appendLogText(
i18n(
"Filter set to %1.",
3956 FilterPosCombo->itemText(filterManager()->getTargetFilterPosition() - 1)));
3964 state()->setFilterManagerState(filterState);
3967 captureStatusWidget->setFilterState(filterState);
3970void Camera::resetJobs()
3976 if (m_JobUnderEdit ==
true)
3978 SequenceJob * job = state()->allJobs().at(queueTable->currentRow());
3982 updateJobTable(job);
3988 nullptr,
i18n(
"Are you sure you want to reset status of all jobs?"),
i18n(
"Reset job status"),
3997 updateJobTable(job);
4002 state()->clearCapturedFramesMap();
4005 state()->setIgnoreJobProgress(Options::alwaysResetSequenceWhenStarting());
4008 startB->setEnabled(
true);
4013 if (i.
row() < 0 || (i.
row() + 1) > state()->allJobs().
size())
4018 if (job ==
nullptr || job->jobType() == SequenceJob::JOBTYPE_DARKFLAT)
4023 if (state()->isBusy())
4026 if (state()->allJobs().
size() >= 2)
4028 queueUpB->setEnabled(i.
row() > 0);
4029 queueDownB->setEnabled(i.
row() + 1 < state()->allJobs().
size());
4038 if (selectJob(i) ==
false)
4041 appendLogText(
i18n(
"Editing job #%1...", i.
row() + 1));
4044 addToQueueB->setToolTip(
i18n(
"Apply job changes."));
4045 removeFromQueueB->setToolTip(
i18n(
"Cancel job changes."));
4048 previewB->setDefault(
false);
4049 addToQueueB->setDefault(
true);
4051 m_JobUnderEdit =
true;
4055void Camera::resetJobEdit(
bool cancelled)
4057 if (cancelled ==
true)
4058 appendLogText(
i18n(
"Editing job canceled."));
4060 m_JobUnderEdit =
false;
4063 addToQueueB->setToolTip(
i18n(
"Add job to sequence queue"));
4064 removeFromQueueB->setToolTip(
i18n(
"Remove job from sequence queue"));
4066 addToQueueB->setDefault(
false);
4067 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)
KIOCORE_EXPORT void add(const QString &fileClass, const QString &directory)
QAction * up(const QObject *recvr, const char *slot, QObject *parent)
QString name(StandardAction id)
const QList< QKeySequence > & begin()
QString label(StandardShortcut id)
const QList< QKeySequence > & end()
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