indiccd.h 6.94 KB
Newer Older
Jasem Mutlaq's avatar
Jasem Mutlaq committed
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
/*  INDI CCD
    Copyright (C) 2012 Jasem Mutlaq <mutlaqja@ikarustech.com>

    This application is free software; you can redistribute it and/or
    modify it under the terms of the GNU General Public
    License as published by the Free Software Foundation; either
    version 2 of the License, or (at your option) any later version.
 */


#ifndef INDICCD_H
#define INDICCD_H

#include "indistd.h"

16
#include <QStringList>
17 18 19 20 21 22
#include <QPointer>

#include <fitsviewer/fitsviewer.h>
#include <fitsviewer/fitsdata.h>

#include <auxiliary/imageviewer.h>
23

24
class FITSView;
25

26
class StreamWG;
27

28
/**
29 30 31
 * \namespace ISD
 *
 *  ISD is a collection of INDI Standard Devices. It encapsulates common types of INDI devices such as telescopes and CCDs.
32 33
 *
 */
Jasem Mutlaq's avatar
Jasem Mutlaq committed
34 35 36
namespace ISD
{

Jasem Mutlaq's avatar
Jasem Mutlaq committed
37 38
class CCD;

39
/**
40 41
 * @class CCDChip
 * CCDChip class controls a particular chip in CCD device. While most amateur CCDs only have a single chip on the CCD, some
42 43
 * CCDs have additional chips targetted for guiding purposes.
 */
44 45 46 47 48
class CCDChip
{
public:
    typedef enum { PRIMARY_CCD, GUIDE_CCD } ChipType;

Jasem Mutlaq's avatar
Jasem Mutlaq committed
49
    CCDChip(ISD::CCD *ccd, ChipType cType);
50

51 52
    FITSView * getImageView(FITSMode imageType);
    void setImageView(FITSView *image, FITSMode imageType);
53 54 55 56 57
    void setCaptureMode(FITSMode mode) { captureMode = mode; }
    void setCaptureFilter(FITSScale fType) { captureFilter = fType; }

    // Common commands
    bool getFrame(int *x, int *y, int *w, int *h);
58
    bool getFrameMinMax(int *minX, int *maxX, int *minY, int *maxY, int *minW, int *maxW, int *minH, int *maxH);
59
    bool setFrame(int x, int y, int w, int h);
60 61 62 63

    // Pixel size
    bool getPixelSize(double &x, double &y);

64 65
    //bool getFocusFrame(int *x, int *y, int *w, int *h);
    //bool setFocusFrame(int x, int y, int w, int h);
66
    bool resetFrame();
67 68
    bool capture(double exposure);
    bool setFrameType(CCDFrameType fType);
69
    bool setFrameType(const QString & name);
70
    CCDFrameType getFrameType();
71 72 73 74
    bool setBinning(int bin_x, int bin_y);
    bool setBinning(CCDBinType binType);
    CCDBinType getBinning();
    bool getBinning(int *bin_x, int *bin_y);
75
    bool getMaxBin(int *max_xbin, int *max_ybin);
Henry de Valence's avatar
Henry de Valence committed
76
    ChipType getType() const { return type; }
77
    ISD::CCD *getCCD() { return parentCCD;}
78

79
    bool isCapturing();
80 81
    bool abortExposure();

Henry de Valence's avatar
Henry de Valence committed
82 83 84
    FITSMode getCaptureMode() const { return captureMode;}
    FITSScale getCaptureFilter() const { return captureFilter; }
    bool isBatchMode() const { return batchMode; }
85
    void setBatchMode(bool enable) { batchMode = enable; }
Henry de Valence's avatar
Henry de Valence committed
86
    QStringList getFrameTypes() const { return frameTypes; }
87
    void addFrameLabel(const QString & label) { frameTypes << label; }
88
    void clearFrameTypes() { frameTypes.clear();}
89

90 91 92 93 94 95 96 97 98
    bool canBin() const;
    void setCanBin(bool value);

    bool canSubframe() const;
    void setCanSubframe(bool value);

    bool canAbort() const;
    void setCanAbort(bool value);

99 100
    FITSData *getImageData() const;
    void setImageData(FITSData *value);
101

Jasem Mutlaq's avatar
Jasem Mutlaq committed
102 103 104 105 106
    int getISOIndex() const;
    bool setISOIndex(int value);

    QStringList getISOList() const;

107
private:
108
    QPointer<FITSView> normalImage, focusImage, guideImage, calibrationImage, alignImage;
109
    FITSData *imageData;
110 111 112 113 114
    FITSMode captureMode;
    FITSScale captureFilter;
    INDI::BaseDevice *baseDevice;
    ClientManager *clientManager;
    ChipType type;
115
    bool batchMode;
Jasem Mutlaq's avatar
Jasem Mutlaq committed
116
    bool displayFITS;
117
    QStringList frameTypes;
118 119
    bool CanBin;
    bool CanSubframe;
Jasem Mutlaq's avatar
Jasem Mutlaq committed
120 121
    bool CanAbort;
    ISD::CCD *parentCCD;
122
    //int fx,fy,fw,fh;
123

124 125
};

126
/**
127 128
 * @class CCD
 * CCD class controls an INDI CCD device. It can be used to issue and abort capture commands, receive and process BLOBs,
129 130 131 132
 * and return information on the capabilities of the CCD.
 *
 * @author Jasem Mutlaq
 */
Jasem Mutlaq's avatar
Jasem Mutlaq committed
133 134 135 136 137 138 139 140 141
class CCD : public DeviceDecorator
{
    Q_OBJECT

public:

    CCD(GDInterface *iPtr);
    ~CCD();

142
    typedef enum { UPLOAD_CLIENT, UPLOAD_LOCAL, UPLOAD_BOTH } UploadMode;
143
    typedef enum { FORMAT_FITS, FORMAT_NATIVE } TransferFormat;
144 145
    enum BlobType { BLOB_IMAGE, BLOB_FITS, BLOB_RAW, BLOB_OTHER} BType;

146
    void registerProperty(INDI::Property *prop);
Jasem Mutlaq's avatar
Jasem Mutlaq committed
147 148 149 150 151 152 153
    void processSwitch(ISwitchVectorProperty *svp);
    void processText(ITextVectorProperty* tvp);
    void processNumber(INumberVectorProperty *nvp);
    void processLight(ILightVectorProperty *lvp);
    void processBLOB(IBLOB *bp);

    DeviceFamily getType() { return dType;}
Jasem Mutlaq's avatar
Jasem Mutlaq committed
154
    bool hasGuideHead();
Jasem Mutlaq's avatar
Jasem Mutlaq committed
155
    bool hasCooler();
156
    bool hasCoolerControl();
157
    bool hasVideoStream() { return HasVideoStream; }
158
    bool setCoolerControl(bool enable);
Jasem Mutlaq's avatar
Jasem Mutlaq committed
159

Jasem Mutlaq's avatar
Jasem Mutlaq committed
160
    // Utitlity functions
161
    bool getTemperature(double *value);
Jasem Mutlaq's avatar
Jasem Mutlaq committed
162
    bool setTemperature(double value);
Jasem Mutlaq's avatar
Jasem Mutlaq committed
163 164
    void setISOMode(bool enable) { ISOMode = enable; }
    void setSeqPrefix(const QString &preFix) { seqPrefix = preFix; }
165
    void setNextSequenceID(int count) { nextSequenceID = count; }
Jasem Mutlaq's avatar
Jasem Mutlaq committed
166
    void setFilter(const QString & newFilter) { filter = newFilter;}
167 168

    // Rapid Guide
169 170
    bool configureRapidGuide(CCDChip *targetChip, bool autoLoop, bool sendImage=false, bool showMarker=false);
    bool setRapidGuide(CCDChip *targetChip, bool enable);
171 172

    // Upload Settings
173
    void updateUploadSettings(const QString &remoteDir);
174
    UploadMode getUploadMode();
175
    bool setUploadMode(UploadMode mode);
176

177 178 179 180
    // Transfer Format
    TransferFormat getTransferFormat() { return transferFormat; }
    bool setTransformFormat(CCD::TransferFormat format);

181 182
    // Video Stream
    bool setVideoStreamEnabled(bool enable);
183
    bool isStreamingEnabled();
184

185 186 187 188 189 190 191 192
    // Video Recording
    bool setSERNameDirectory(const QString &filename, const QString &directory);
    bool getSERNameDirectory(QString &filename, QString &directory);
    bool startRecording();
    bool startDurationRecording(double duration);
    bool startFramesRecording(uint32_t frames);
    bool stopRecording();

Jasem Mutlaq's avatar
Jasem Mutlaq committed
193
    FITSViewer *getViewer() { return fv;}
194
    CCDChip * getChip(CCDChip::ChipType cType);
195
    void setFITSDir(const QString &dir) { fitsDir = dir;}
196

Jasem Mutlaq's avatar
Jasem Mutlaq committed
197 198
public slots:
    void FITSViewerDestroyed();
199
    void StreamWindowHidden();
Jasem Mutlaq's avatar
Jasem Mutlaq committed
200

201
signals:
202
    //void FITSViewerClosed();
Jasem Mutlaq's avatar
Jasem Mutlaq committed
203
    void newTemperatureValue(double value);
204
    void newExposureValue(ISD::CCDChip *chip, double value, IPState state);
205
    void newGuideStarData(ISD::CCDChip *chip, double dx, double dy, double fit);
206
    void newRemoteFile(QString);
207
    void newImage(QImage *image, ISD::CCDChip *targetChip);
208
    void videoStreamToggled(bool enabled);
209
    void videoRecordToggled(bool enabled);
210

211
private:
Jasem Mutlaq's avatar
Jasem Mutlaq committed
212 213 214
    void addFITSKeywords(QString filename);
    QString filter;

Jasem Mutlaq's avatar
Jasem Mutlaq committed
215
    bool ISOMode;
216
    bool HasGuideHead;
Jasem Mutlaq's avatar
Jasem Mutlaq committed
217
    bool HasCooler;
218
    bool HasCoolerControl;
219
    bool HasVideoStream;
Jasem Mutlaq's avatar
Jasem Mutlaq committed
220
    QString		seqPrefix;
221
    QString     fitsDir;
222
    char BLOBFilename[MAXINDIFILENAME];
223
    int nextSequenceID;
Jasem Mutlaq's avatar
Jasem Mutlaq committed
224
    StreamWG *streamWindow;
225
    int streamW, streamH;
226
    ISD::ST4 *ST4Driver;
227
    int normalTabID, calibrationTabID, focusTabID, guideTabID, alignTabID;
228
    CCDChip *primaryChip, *guideChip;
229
    TransferFormat transferFormat;
230 231 232 233 234

    QPointer<FITSViewer> fv;
    QPointer<ImageViewer> imageViewer;


Jasem Mutlaq's avatar
Jasem Mutlaq committed
235 236 237 238
};

}
#endif // INDICCD_H