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 const QString &getStreamEncoding() const
164 {
165 return m_StreamEncoding;
166 }
167 bool setStreamEncoding(const QString &value);
168 const QStringList &getStreamEncodings() const
169 {
170 return m_StreamEncodings;
171 }
172 const QString &getStreamRecording() const
173 {
174 return m_StreamRecording;
175 }
176 bool setStreamRecording(const QString &value);
177 const QStringList &getVideoFormats() const
178 {
179 return m_VideoFormats;
180 }
181
182 // Capture Format
183 const QStringList &getCaptureFormats() const
184 {
185 return m_CaptureFormats;
186 }
187 QString getCaptureFormat() const;
188 bool setCaptureFormat(const QString &format);
189
190 // BLOB control
191 bool isBLOBEnabled();
192 bool setBLOBEnabled(bool enable, const QString &prop = QString());
193
194 // Video Stream
195 bool setVideoStreamEnabled(bool enable);
196 bool resetStreamingFrame();
197 bool setStreamingFrame(int x, int y, int w, int h);
198 bool isStreamingEnabled();
199 bool setStreamExposure(double duration);
200 bool getStreamExposure(double *duration);
201 bool setStreamLimits(uint16_t maxBufferSize, uint16_t maxPreviewFPS);
202
203 // Video Recording
204 bool setSERNameDirectory(const QString &filename, const QString &directory);
205 bool getSERNameDirectory(QString &filename, QString &directory);
206 bool startRecording();
207 bool startDurationRecording(double duration);
208 bool startFramesRecording(uint32_t frames);
209 bool stopRecording();
210
211 // Telescope type
212 TelescopeType getTelescopeType()
213 {
214 return telescopeType;
215 }
216 bool setTelescopeType(TelescopeType type);
217
218 // Update FITS Header
219 bool setFITSHeaders(const QList<FITSData::Record> &values);
220
221 CameraChip *getChip(CameraChip::ChipType cType);
222
223 bool setFastExposureEnabled(bool enable);
224 bool isFastExposureEnabled() const
225 {
226 return m_FastExposureEnabled;
227 }
228 bool setFastCount(uint32_t count);
229
230 const QMap<QString, double> &getExposurePresets() const
231 {
232 return m_ExposurePresets;
233 }
234 const QPair<double, double> getExposurePresetsMinMax() const
235 {
236 return m_ExposurePresetsMinMax;
237 }
238
239 /**
240 * @brief saveCurrentImage save the image that is currently in the image data buffer
241 * @return true if saving succeeded
242 */
243 bool saveCurrentImage(QString &filename);
244
245
246 public slots:
247 void StreamWindowHidden();
248 // Blob manager
249 void setBLOBManager(const char *device, INDI::Property prop);
250
251 protected slots:
252 void setWSBLOB(const QByteArray &message, const QString &extension);
253
254 signals:
255 void newTemperatureValue(double value);
256 void newExposureValue(ISD::CameraChip *chip, double value, IPState state);
257 void newGuideStarData(ISD::CameraChip *chip, double dx, double dy, double fit);
258 void newBLOBManager(INDI::Property prop);
259 void newRemoteFile(QString);
260 void coolerToggled(bool enabled);
261 void error(ErrorType type);
262 // Video
263 void updateVideoWindow(int width, int height, bool streamEnabled);
264 void closeVideoWindow();
265 void videoStreamToggled(bool enabled);
266 void showVideoFrame(INDI::Property prop, int width, int height);
267 void videoRecordToggled(bool enabled);
268 void newFPS(double instantFPS, double averageFPS);
269 void newVideoFrame(const QSharedPointer<QImage> &frame);
270 // Data
271 void newImage(const QSharedPointer<FITSData> &data, const QString &extension = "");
272 // View
273 void newView(const QSharedPointer<FITSView> &view);
274
275 private:
276 void processStream(INDI::Property prop);
277 bool WriteImageFileInternal(const QString &filename, char *buffer, const size_t size);
278
279 bool HasGuideHead { false };
280 bool HasCooler { false };
281 bool CanCool { false };
282 bool HasCoolerControl { false };
283 bool HasVideoStream { false };
284 bool m_isStreamEnabled { false };
285 bool m_FastExposureEnabled { false };
286 QString seqPrefix;
287
288 int nextSequenceID { 0 };
289 int streamW { 0 };
290 int streamH { 0 };
291 int normalTabID { -1 };
292 int calibrationTabID { -1 };
293 int focusTabID { -1 };
294 int guideTabID { -1 };
295 int alignTabID { -1 };
296
297 INDI::Property primaryCCDBLOB;
298
299 std::unique_ptr<CameraChip> primaryChip;
300 std::unique_ptr<CameraChip> guideChip;
301 std::unique_ptr<WSMedia> m_Media;
302 QString m_EncodingFormat {"FITS"};
303 QString m_StreamEncoding {"RAW"};
304 QString m_StreamRecording {"SER"};
305 QStringList m_EncodingFormats;
306 QStringList m_StreamEncodings;
307 QStringList m_CaptureFormats;
308 QStringList m_VideoFormats;
309 bool m_StreamingEnabled {true};
310 int m_CaptureFormatIndex {-1};
311 TelescopeType telescopeType { TELESCOPE_UNKNOWN };
312
313 // Gain, since it is spread among different vector properties, let's try to find the property itself.
314 INumber *gainN { nullptr };
315 IPerm gainPerm { IP_RO };
316
317 INumber *offsetN { nullptr };
318 IPerm offsetPerm { IP_RO };
319
320 QPointer<ImageViewer> m_ImageViewerWindow;
321
322 QDateTime m_LastNotificationTS;
323
324 // Typically for DSLRs
325 QMap<QString, double> m_ExposurePresets;
326 QPair<double, double> m_ExposurePresetsMinMax;
327
328 // Used when writing the image fits file to disk in a separate thread.
329 void updateFileBuffer(INDI::Property prop, bool is_fits);
330 char *fileWriteBuffer { nullptr };
331 int fileWriteBufferSize { 0 };
332 QString fileWriteFilename;
333 QFuture<void> fileWriteThread;
334};
335}
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 Sat Dec 21 2024 17:04:46 by doxygen 1.12.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.