| 1 |
/* |
| 2 |
INDI Driver for Kepler sCMOS camera. |
| 3 |
Copyright (C) 2022 Jasem Mutlaq ([email protected]) |
| 4 |
|
| 5 |
This library is free software; you can redistribute it and/or |
| 6 |
modify it under the terms of the GNU Lesser General Public |
| 7 |
License as published by the Free Software Foundation; either |
| 8 |
version 2.1 of the License, or (at your option) any later version. |
| 9 |
|
| 10 |
This library is distributed in the hope that it will be useful, |
| 11 |
but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 12 |
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
| 13 |
Lesser General Public License for more details. |
| 14 |
|
| 15 |
You should have received a copy of the GNU Lesser General Public |
| 16 |
License along with this library; if not, write to the Free Software |
| 17 |
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA |
| 18 |
*/ |
| 19 |
|
| 20 |
#pragma once |
| 21 |
|
| 22 |
#include <libflipro.h> |
| 23 |
#include <indiccd.h> |
| 24 |
#include <indipropertyswitch.h> |
| 25 |
#include <indipropertytext.h> |
| 26 |
#include <indipropertylight.h> |
| 27 |
#include <indipropertyblob.h> |
| 28 |
|
| 29 |
#include <inditimer.h> |
| 30 |
#include <indisinglethreadpool.h> |
| 31 |
|
| 32 |
class Kepler : public INDI::CCD |
| 33 |
{ |
| 34 |
public: |
| 35 |
Kepler(const FPRODEVICEINFO &info, std::wstring name); |
| 36 |
virtual ~Kepler() override; |
| 37 |
|
| 38 |
const char *getDefaultName() override; |
| 39 |
|
| 40 |
bool initProperties() override; |
| 41 |
void ISGetProperties(const char *dev) override; |
| 42 |
bool updateProperties() override; |
| 43 |
|
| 44 |
bool Connect() override; |
| 45 |
bool Disconnect() override; |
| 46 |
|
| 47 |
bool StartExposure(float duration) override; |
| 48 |
bool AbortExposure() override; |
| 49 |
|
| 50 |
virtual bool ISNewNumber(const char *dev, const char *name, double values[], char *names[], int n) override; |
| 51 |
virtual bool ISNewSwitch(const char *dev, const char *name, ISState *states, char *names[], int n) override; |
| 52 |
virtual bool ISNewText(const char *dev, const char *name, char *texts[], char *names[], int n) override; |
| 53 |
|
| 54 |
protected: |
| 55 |
virtual int SetTemperature(double temperature) override; |
| 56 |
virtual bool UpdateCCDFrame(int x, int y, int w, int h) override; |
| 57 |
virtual bool UpdateCCDBin(int binx, int biny) override; |
| 58 |
virtual bool UpdateCCDFrameType(INDI::CCDChip::CCD_FRAME fType) override; |
| 59 |
|
| 60 |
virtual void debugTriggered(bool enable) override; |
| 61 |
virtual bool saveConfigItems(FILE *fp) override; |
| 62 |
|
| 63 |
virtual void addFITSKeywords(INDI::CCDChip *targetChip) override; |
| 64 |
virtual void UploadComplete(INDI::CCDChip *targetChip) override; |
| 65 |
|
| 66 |
private: |
| 67 |
|
| 68 |
//**************************************************************************************** |
| 69 |
// INDI Properties |
| 70 |
//**************************************************************************************** |
| 71 |
INDI::PropertySwitch CommunicationMethodSP {2}; |
| 72 |
|
| 73 |
|
| 74 |
// Gain |
| 75 |
INDI::PropertySwitch LowGainSP {0}; |
| 76 |
INDI::PropertySwitch HighGainSP {0}; |
| 77 |
|
| 78 |
// Cooler & Fan |
| 79 |
INDI::PropertyNumber CoolerDutyNP {1}; |
| 80 |
INDI::PropertySwitch FanSP {2}; |
| 81 |
|
| 82 |
// Merging |
| 83 |
INDI::PropertySwitch MergeMethodSP {2}; |
| 84 |
INDI::PropertySwitch MergePlanesSP {3}; |
| 85 |
INDI::PropertySwitch RequestStatSP {2}; |
| 86 |
INDI::PropertyText MergeCalibrationFilesTP {2}; |
| 87 |
enum |
| 88 |
{ |
| 89 |
CALIBRATION_DARK, |
| 90 |
CALIBRATION_FLAT |
| 91 |
}; |
| 92 |
|
| 93 |
// Black Level Adjust |
| 94 |
INDI::PropertyNumber BlackLevelNP {1}; |
| 95 |
|
| 96 |
// GPS State |
| 97 |
INDI::PropertyLight GPSStateLP {3}; |
| 98 |
|
| 99 |
#ifdef LEGACY_MODE |
| 100 |
//**************************************************************************************** |
| 101 |
// Legacy INDI Properties |
| 102 |
//**************************************************************************************** |
| 103 |
INDI::PropertyNumber ExpValuesNP {11}; |
| 104 |
enum |
| 105 |
{ |
| 106 |
ExpTime, |
| 107 |
ROIW, |
| 108 |
ROIH, |
| 109 |
OSW, |
| 110 |
OSH, |
| 111 |
BinW, |
| 112 |
BinH, |
| 113 |
ROIX, |
| 114 |
ROIY, |
| 115 |
Shutter, |
| 116 |
Type |
| 117 |
}; |
| 118 |
INDI::PropertySwitch ExposureTriggerSP {1}; |
| 119 |
INDI::PropertyNumber TemperatureSetNP {1}; |
| 120 |
INDI::PropertyNumber TemperatureReadNP {2}; |
| 121 |
double m_ExposureRequest {1}; |
| 122 |
#endif |
| 123 |
|
| 124 |
|
| 125 |
//**************************************************************************************** |
| 126 |
// Communication Functions |
| 127 |
//**************************************************************************************** |
| 128 |
bool setup(); |
| 129 |
void prepareUnpacked(); |
| 130 |
void readTemperature(); |
| 131 |
void readGPS(); |
| 132 |
|
| 133 |
//**************************************************************************************** |
| 134 |
// Workers |
| 135 |
//**************************************************************************************** |
| 136 |
void workerStreamVideo(const std::atomic_bool &isAboutToQuit); |
| 137 |
void workerExposure(const std::atomic_bool &isAboutToQuit, float duration); |
| 138 |
|
| 139 |
//**************************************************************************************** |
| 140 |
// Variables |
| 141 |
//**************************************************************************************** |
| 142 |
FPRODEVICEINFO m_CameraInfo; |
| 143 |
int32_t m_CameraHandle; |
| 144 |
FPROCAP m_CameraCapabilities; |
| 145 |
uint32_t m_CameraCapabilitiesSize {0}; |
| 146 |
|
| 147 |
uint8_t m_ExposureRetry {0}; |
| 148 |
INDI::SingleThreadPool m_Worker; |
| 149 |
uint32_t m_TotalFrameBufferSize {0}; |
| 150 |
|
| 151 |
// Merging |
| 152 |
uint8_t *m_FrameBuffer {nullptr}; |
| 153 |
FPROUNPACKEDIMAGES fproUnpacked; |
| 154 |
FPROUNPACKEDSTATS fproStats; |
| 155 |
FPRO_HWMERGEENABLE mergeEnables; |
| 156 |
|
| 157 |
// GPS |
| 158 |
FPROGPSSTATE m_LastGPSState {FPRO_GPS_NOT_DETECTED}; |
| 159 |
|
| 160 |
// Temperature |
| 161 |
INDI::Timer m_TemperatureTimer; |
| 162 |
INDI::Timer m_GPSTimer; |
| 163 |
|
| 164 |
// Gain Tables |
| 165 |
FPROGAINVALUE *m_LowGainTable {nullptr}; |
| 166 |
FPROGAINVALUE *m_HighGainTable {nullptr}; |
| 167 |
|
| 168 |
static std::map<FPRODEVICETYPE, double> SensorPixelSize; |
| 169 |
static constexpr double TEMPERATURE_THRESHOLD {0.1}; |
| 170 |
static constexpr double TEMPERATURE_FREQUENCY_BUSY {1000}; |
| 171 |
static constexpr double TEMPERATURE_FREQUENCY_IDLE {5000}; |
| 172 |
static constexpr uint32_t GPS_TIMER_PERIOD {5000}; |
| 173 |
|
| 174 |
static constexpr const char *GPS_TAB {"GPS"}; |
| 175 |
static constexpr const char *LEGACY_TAB {"Legacy"}; |
| 176 |
}; |