Kstars

indicamera.h
1/*
2 SPDX-FileCopyrightText: 2012 Jasem Mutlaq <mutlaqja@ikarustech.com>
3
4 SPDX-License-Identifier: GPL-2.0-or-later
5*/
6
7#pragma once
8
9#include "fitsviewer/fitsdata.h"
10#include "indiconcretedevice.h"
11#include "indicamerachip.h"
12
13#include "wsmedia.h"
14#include "auxiliary/imageviewer.h"
15#include "fitsviewer/fitsdata.h"
16
17#include <QStringList>
18#include <QPointer>
19#include <QtConcurrent>
20
21#include <memory>
22
23class FITSView;
24class QTimer;
25class StreamWG;
26
27/**
28 * \namespace ISD
29 *
30 * ISD is a collection of INDI Standard Devices. It encapsulates common types of INDI devices such as telescopes and CCDs.
31 *
32 */
33namespace ISD
34{
35class CameraChip;
36
37/**
38 * @class Camera
39 * Camera class controls an INDI Camera device. It can be used to issue and abort capture commands, receive and process BLOBs,
40 * and return information on the capabilities of the camera.
41 *
42 * @author Jasem Mutlaq
43 */
44class Camera : public ConcreteDevice
45{
47 Q_PROPERTY(bool StreamingEnabled MEMBER m_StreamingEnabled)
48
49 public:
51 virtual ~Camera() override;
52
53 typedef enum { UPLOAD_CLIENT, UPLOAD_LOCAL, UPLOAD_BOTH } UploadMode;
54 enum BlobType
55 {
56 BLOB_IMAGE,
57 BLOB_FITS,
58 BLOB_XISF,
59 BLOB_RAW,
60 BLOB_OTHER
61 } BType;
62 typedef enum { TELESCOPE_PRIMARY, TELESCOPE_GUIDE, TELESCOPE_UNKNOWN } TelescopeType;
63 typedef enum
64 {
65 ERROR_CAPTURE, /** INDI Camera error */
66 ERROR_SAVE, /** Saving to disk error */
67 ERROR_LOAD, /** Loading image buffer error */
68 ERROR_VIEWER /** Loading in FITS Viewer Error */
70
71 void registerProperty(INDI::Property prop) override;
72 void removeProperty(INDI::Property prop) override;
73
74 void processSwitch(INDI::Property prop) override;
75 void processText(INDI::Property prop) override;
76 void processNumber(INDI::Property prop) override;
77 bool processBLOB(INDI::Property prop) override;
78
79 // Does it an on-chip dedicated guide head?
80 bool hasGuideHead();
81 // Does it report temperature?
82 bool hasCooler();
83 // Can temperature be controlled?
84 bool canCool()
85 {
86 return CanCool;
87 }
88 // Does it have active cooler on/off controls?
89 bool hasCoolerControl();
90 bool setCoolerControl(bool enable);
91 bool isCoolerOn();
92 // Does it have a video stream?
93 bool hasVideoStream()
94 {
95 return HasVideoStream;
96 }
97
98 // Temperature controls
99 bool getTemperature(double *value);
100 bool setTemperature(double value);
101
102 // Temperature Regulation
103 bool getTemperatureRegulation(double &ramp, double &threshold);
104 bool setTemperatureRegulation(double ramp, double threshold);
105
106 bool setScopeInfo(double focalLength, double aperture);
107
108 // Utility functions
109 void setSeqPrefix(const QString &preFix)
110 {
111 seqPrefix = preFix;
112 }
113 void setNextSequenceID(int count)
114 {
115 nextSequenceID = count;
116 }
117
118 // Gain controls
119 bool hasGain()
120 {
121 return gainN != nullptr;
122 }
123 bool getGain(double *value);
124 IPerm getGainPermission() const
125 {
126 return gainPerm;
127 }
128 bool setGain(double value);
129 bool getGainMinMaxStep(double *min, double *max, double *step);
130
131 // offset controls
132 bool hasOffset()
133 {
134 return offsetN != nullptr;
135 }
136 bool getOffset(double *value);
137 IPerm getOffsetPermission() const
138 {
139 return offsetPerm;
140 }
141 bool setOffset(double value);
142 bool getOffsetMinMaxStep(double *min, double *max, double *step);
143
144 // Rapid Guide
145 bool configureRapidGuide(CameraChip *targetChip, bool autoLoop, bool sendImage = false, bool showMarker = false);
146 bool setRapidGuide(CameraChip *targetChip, bool enable);
147
148 // Upload Settings
149 void updateUploadSettings(const QString &uploadDirectory, const QString &uploadFile);
150 UploadMode getUploadMode();
151 bool setUploadMode(UploadMode mode);
152
153 // Encoding Format
154 const QString &getEncodingFormat() const
155 {
156 return m_EncodingFormat;
157 }
158 bool setEncodingFormat(const QString &value);
159 const QStringList &getEncodingFormats() const
160 {
161 return m_EncodingFormats;
162 }
163
164 // Capture Format
165 const QStringList &getCaptureFormats() const
166 {
167 return m_CaptureFormats;
168 }
169 QString getCaptureFormat() const;
170 bool setCaptureFormat(const QString &format);
171
172 // BLOB control
173 bool isBLOBEnabled();
174 bool setBLOBEnabled(bool enable, const QString &prop = QString());
175
176 // Video Stream
177 bool setVideoStreamEnabled(bool enable);
178 bool resetStreamingFrame();
179 bool setStreamingFrame(int x, int y, int w, int h);
180 bool isStreamingEnabled();
181 bool setStreamExposure(double duration);
182 bool getStreamExposure(double *duration);
183 bool setStreamLimits(uint16_t maxBufferSize, uint16_t maxPreviewFPS);
184
185 // Video Recording
186 bool setSERNameDirectory(const QString &filename, const QString &directory);
187 bool getSERNameDirectory(QString &filename, QString &directory);
188 bool startRecording();
189 bool startDurationRecording(double duration);
190 bool startFramesRecording(uint32_t frames);
191 bool stopRecording();
192
193 // Telescope type
194 TelescopeType getTelescopeType()
195 {
196 return telescopeType;
197 }
198 bool setTelescopeType(TelescopeType type);
199
200 // Update FITS Header
201 bool setFITSHeaders(const QList<FITSData::Record> &values);
202
203 CameraChip *getChip(CameraChip::ChipType cType);
204
205 bool setFastExposureEnabled(bool enable);
206 bool isFastExposureEnabled() const
207 {
208 return m_FastExposureEnabled;
209 }
210 bool setFastCount(uint32_t count);
211
212 const QMap<QString, double> &getExposurePresets() const
213 {
214 return m_ExposurePresets;
215 }
216 const QPair<double, double> getExposurePresetsMinMax() const
217 {
218 return m_ExposurePresetsMinMax;
219 }
220
221 /**
222 * @brief saveCurrentImage save the image that is currently in the image data buffer
223 * @return true if saving succeeded
224 */
225 bool saveCurrentImage(QString &filename);
226
227
228 public slots:
229 void StreamWindowHidden();
230 // Blob manager
231 void setBLOBManager(const char *device, INDI::Property prop);
232
233 protected slots:
234 void setWSBLOB(const QByteArray &message, const QString &extension);
235
236 signals:
237 void newTemperatureValue(double value);
238 void newExposureValue(ISD::CameraChip *chip, double value, IPState state);
239 void newGuideStarData(ISD::CameraChip *chip, double dx, double dy, double fit);
240 void newBLOBManager(INDI::Property prop);
241 void newRemoteFile(QString);
242 void coolerToggled(bool enabled);
243 void error(ErrorType type);
244 // Video
245 void videoStreamToggled(bool enabled);
246 void videoRecordToggled(bool enabled);
247 void newFPS(double instantFPS, double averageFPS);
248 void newVideoFrame(const QSharedPointer<QImage> &frame);
249 // Data
250 void newImage(const QSharedPointer<FITSData> &data, const QString &extension = "");
251 // View
252 void newView(const QSharedPointer<FITSView> &view);
253
254 private:
255 void processStream(INDI::Property prop);
256 bool WriteImageFileInternal(const QString &filename, char *buffer, const size_t size);
257
258 bool HasGuideHead { false };
259 bool HasCooler { false };
260 bool CanCool { false };
261 bool HasCoolerControl { false };
262 bool HasVideoStream { false };
263 bool m_FastExposureEnabled { false };
264 QString seqPrefix;
265
266 int nextSequenceID { 0 };
267 std::unique_ptr<StreamWG> streamWindow;
268 int streamW { 0 };
269 int streamH { 0 };
270 int normalTabID { -1 };
271 int calibrationTabID { -1 };
272 int focusTabID { -1 };
273 int guideTabID { -1 };
274 int alignTabID { -1 };
275
276 INDI::Property primaryCCDBLOB;
277
278 std::unique_ptr<CameraChip> primaryChip;
279 std::unique_ptr<CameraChip> guideChip;
280 std::unique_ptr<WSMedia> m_Media;
281 QString m_EncodingFormat {"FITS"};
282 QStringList m_EncodingFormats;
283 QStringList m_CaptureFormats;
284 bool m_StreamingEnabled {true};
285 int m_CaptureFormatIndex {-1};
286 TelescopeType telescopeType { TELESCOPE_UNKNOWN };
287
288 // Gain, since it is spread among different vector properties, let's try to find the property itself.
289 INumber *gainN { nullptr };
290 IPerm gainPerm { IP_RO };
291
292 INumber *offsetN { nullptr };
293 IPerm offsetPerm { IP_RO };
294
295 QPointer<ImageViewer> m_ImageViewerWindow;
296
297 QDateTime m_LastNotificationTS;
298
299 // Typically for DSLRs
300 QMap<QString, double> m_ExposurePresets;
301 QPair<double, double> m_ExposurePresetsMinMax;
302
303 // Used when writing the image fits file to disk in a separate thread.
304 void updateFileBuffer(INDI::Property prop, bool is_fits);
305 char *fileWriteBuffer { nullptr };
306 int fileWriteBufferSize { 0 };
307 QString fileWriteFilename;
308 QFuture<void> fileWriteThread;
309};
310}
CameraChip class controls a particular chip in camera.
Camera class controls an INDI Camera device.
Definition indicamera.h:45
@ ERROR_LOAD
Saving to disk error.
Definition indicamera.h:67
@ ERROR_VIEWER
Loading image buffer error.
Definition indicamera.h:68
@ ERROR_SAVE
INDI Camera error.
Definition indicamera.h:66
bool saveCurrentImage(QString &filename)
saveCurrentImage save the image that is currently in the image data buffer
The ConcreteDevice class.
GenericDevice is the Generic Device for INDI devices.
Definition indistd.h:117
ISD is a collection of INDI Standard Devices.
Q_OBJECTQ_OBJECT
Q_PROPERTY(...)
QObject * parent() const const
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Mon Nov 18 2024 12:16:41 by doxygen 1.12.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.