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

KDE's Doxygen guidelines are available online.