sequencejob.h 7.62 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27
/*  Ekos Capture tool
    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 SEQUENCEJOB_H
#define SEQUENCEJOB_H

#include <QTableWidgetItem>

#include "indi/indistd.h"
#include "indi/indiccd.h"

/**
 *@class SequenceJob
 *@short Sequence Job is a container for the details required to capture a series of images.
 *@author Jasem Mutlaq
 *@version 1.0
 */
namespace Ekos
{
class SequenceJob : public QObject
{
28 29 30 31
    Q_OBJECT

  public:
    typedef enum { JOB_IDLE, JOB_BUSY, JOB_ERROR, JOB_ABORTED, JOB_DONE } JOBStatus;
32 33
    typedef enum
    {
34 35 36 37 38 39
        CAPTURE_OK,
        CAPTURE_FRAME_ERROR,
        CAPTURE_BIN_ERROR,
        CAPTURE_FILTER_BUSY,
        CAPTURE_FOCUS_ERROR
    } CAPTUREResult;
40 41 42 43 44 45 46
    typedef enum
    {
        ACTION_FILTER,
        ACTION_TEMPERATURE,
        ACTION_POST_FOCUS,
        ACTION_ROTATOR
    } PrepareActions;
47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71

    SequenceJob();
    ~SequenceJob() {}

    CAPTUREResult capture(bool noCaptureFilter);
    void reset();
    void abort();
    void done();
    void prepareCapture();

    JOBStatus getStatus() { return status; }
    const QString &getStatusString() { return statusStrings[status]; }
    bool isPreview() { return preview; }
    int getDelay() { return delay; }
    int getCount() { return count; }
    unsigned int getCompleted() { return completed; }
    const QString &getRawPrefix() { return rawPrefix; }
    double getExposure() const { return exposure; }

    void setActiveCCD(ISD::CCD *ccd) { activeCCD = ccd; }
    ISD::CCD *getActiveCCD() { return activeCCD; }

    void setActiveFilter(ISD::GDInterface *filter) { activeFilter = filter; }
    ISD::GDInterface *getActiveFilter() { return activeFilter; }

72 73 74
    void setActiveRotator(ISD::GDInterface *rotator) { activeRotator = rotator; }
    ISD::GDInterface *getActiveRotator() { return activeRotator; }

75 76 77 78 79 80 81 82 83 84
    void setActiveChip(ISD::CCDChip *chip) { activeChip = chip; }
    ISD::CCDChip *getActiveChip() { return activeChip; }

    void setFITSDir(const QString &dir) { fitsDir = dir; }
    const QString &getFITSDir() { return fitsDir; }

    void setTargetFilter(int pos, const QString &name);
    int getTargetFilter() { return targetFilter; }
    int getCurrentFilter() const;
    void setCurrentFilter(int value);
85

86
    const QString &getFilterName() { return filter; }
87

88 89
    void setFrameType(CCDFrameType type);
    CCDFrameType getFrameType() { return frameType; }
90

91 92
    void setCaptureFilter(FITSScale capFilter) { captureFilter = capFilter; }
    FITSScale getCaptureFilter() { return captureFilter; }
93

94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190
    void setPreview(bool enable) { preview = enable; }
    void setFullPrefix(const QString &cprefix) { fullPrefix = cprefix; }
    const QString &getFullPrefix() { return fullPrefix; }
    void setFrame(int in_x, int in_y, int in_w, int in_h)
    {
        x = in_x;
        y = in_y;
        w = in_w;
        h = in_h;
    }

    int getSubX() { return x; }
    int getSubY() { return y; }
    int getSubW() { return w; }
    int getSubH() { return h; }

    void setBin(int xbin, int ybin)
    {
        binX = xbin;
        binY = ybin;
    }
    int getXBin() { return binX; }
    int getYBin() { return binY; }

    void setDelay(int in_delay) { delay = in_delay; }
    void setCount(int in_count) { count = in_count; }
    void setExposure(double duration) { exposure = duration; }
    void setStatusCell(QTableWidgetItem *cell) { statusCell = cell; }
    void setCompleted(unsigned int in_completed) { completed = in_completed; }
    int getISOIndex() const;
    void setISOIndex(int value);

    double getExposeLeft() const;
    void setExposeLeft(double value);
    void resetStatus();

    void setPrefixSettings(const QString &rawFilePrefix, bool filterEnabled, bool exposureEnabled, bool tsEnabled);
    void getPrefixSettings(QString &rawFilePrefix, bool &filterEnabled, bool &exposureEnabled, bool &tsEnabled);

    bool isFilterPrefixEnabled() { return filterPrefixEnabled; }
    bool isExposurePrefixEnabled() { return expPrefixEnabled; }
    bool isTimestampPrefixEnabled() { return timeStampPrefixEnabled; }

    double getCurrentTemperature() const;
    void setCurrentTemperature(double value);

    double getTargetTemperature() const;
    void setTargetTemperature(double value);

    double getTargetADU() const;
    void setTargetADU(double value);

    double getTargetADUTolerance() const;
    void setTargetADUTolerance(double value);

    int getCaptureRetires() const;
    void setCaptureRetires(int value);

    FlatFieldSource getFlatFieldSource() const;
    void setFlatFieldSource(const FlatFieldSource &value);

    FlatFieldDuration getFlatFieldDuration() const;
    void setFlatFieldDuration(const FlatFieldDuration &value);

    SkyPoint getWallCoord() const;
    void setWallCoord(const SkyPoint &value);

    bool isPreMountPark() const;
    void setPreMountPark(bool value);

    bool isPreDomePark() const;
    void setPreDomePark(bool value);

    bool getEnforceTemperature() const;
    void setEnforceTemperature(bool value);

    QString getRootFITSDir() const;
    void setRootFITSDir(const QString &value);

    bool getFilterPostFocusReady() const;
    void setFilterPostFocusReady(bool value);

    QString getPostCaptureScript() const;
    void setPostCaptureScript(const QString &value);

    ISD::CCD::UploadMode getUploadMode() const;
    void setUploadMode(const ISD::CCD::UploadMode &value);

    QString getRemoteDir() const;
    void setRemoteDir(const QString &value);

    ISD::CCD::TransferFormat getTransforFormat() const;
    void setTransforFormat(const ISD::CCD::TransferFormat &value);

    double getGain() const;
    void setGain(double value);

191 192 193 194 195 196
    int32_t getTargetRotation() const;
    void setTargetRotation(int32_t value);

    void setCurrentRotation(int32_t value);

signals:
197 198 199
    void prepareComplete();
    void checkFocus();

200
private:
201 202 203
    QStringList statusStrings;
    ISD::CCDChip *activeChip;
    ISD::CCD *activeCCD;
204
    ISD::GDInterface *activeFilter=nullptr, *activeRotator=nullptr;
205 206 207 208 209 210 211 212 213 214 215 216 217

    double exposure;
    CCDFrameType frameType;
    int targetFilter;
    int currentFilter;

    QString filter;
    int binX, binY;
    int x, y, w, h;
    QString fullPrefix;
    int count;
    int delay;
    bool preview;
218 219
    //bool filterReady, temperatureReady, filterPostFocusReady, prepareReady;
    bool prepareReady;
220 221 222 223 224 225 226
    bool enforceTemperature;
    int isoIndex;
    int captureRetires;
    unsigned int completed;
    double exposeLeft;
    double currentTemperature, targetTemperature;
    double gain;
227 228
    // Rotation in absolute ticks, NOT angle
    int32_t targetRotation, currentRotation;
229 230 231 232 233
    FITSScale captureFilter;
    QTableWidgetItem *statusCell;
    QString fitsDir;
    QString rootFITSDir;
    QString postCaptureScript;
234

235
    ISD::CCD::UploadMode uploadMode = ISD::CCD::UPLOAD_CLIENT;
236

237 238
    // Transfer Format
    ISD::CCD::TransferFormat transforFormat = ISD::CCD::FORMAT_FITS;
239

240 241
    // TODO getters and settings
    QString remoteDir;
242

243 244
    bool typePrefixEnabled, filterPrefixEnabled, expPrefixEnabled, timeStampPrefixEnabled;
    QString rawPrefix;
245

246
    JOBStatus status;
247

248 249 250 251 252 253 254 255 256 257 258 259
    // Flat field variables
    struct
    {
        double targetADU;
        double targetADUTolerance;
        FlatFieldSource flatFieldSource;
        FlatFieldDuration flatFieldDuration;
        SkyPoint wallCoord;
        bool preMountPark;
        bool preDomePark;

    } calibrationSettings;
260 261 262 263

    QMap<PrepareActions, bool> prepareActions;
    bool areActionsReady();
    void setAllActionsReady();
264 265 266
};
}

267
#endif // SEQUENCEJOB_H