37#ifdef _USE_SYSTEM_JSONLIB
38#include <nlohmann/json.hpp>
61 virtual bool ISNewText(
const char *dev,
const char *name,
char *texts[],
char *names[],
int n)
override;
62 virtual bool ISNewNumber(
const char *dev,
const char *name,
double values[],
char *names[],
int n)
override;
63 virtual bool ISNewSwitch(
const char *dev,
const char *name,
ISState *states,
char *names[],
int n)
override;
97 } __attribute__((packed));
107 std::string m_ConfigHost;
108 std::string m_ConfigPort;
111 bool m_ExposureInProgress {
false};
112 std::string m_CurrentReadoutModeName {
"0"};
113 int m_CurrentReadoutModeIndex {0};
114 uint32_t m_MaxADU { 0 };
115 uint8_t m_SensorType { 0 };
116 int m_CameraXSize {1}, m_CameraYSize {1};
117 double m_PixelSizeX {1.0}, m_PixelSizeY {1.0};
118 std::string m_Description, m_DriverInfo, m_DriverVersion, m_CameraName;
119 double m_GainMin {0}, m_GainMax {0};
120 uint8_t m_BayerOffsetX {0}, m_BayerOffsetY {0};
121 double m_ElectronsPerADU {0};
122 double m_FullWellCapacity {0};
125 std::unique_ptr<httplib::Client> httpClient;
126 bool sendAlpacaGET(
const std::string &endpoint,
nlohmann::json &response);
128 std::string getAlpacaURL(
const std::string &endpoint);
129 uint32_t m_ClientTransactionID {1};
141 uint8_t bayer_offset_x;
142 uint8_t bayer_offset_y;
145 ImageMetadata m_CurrentImage;
146 bool alpacaGetImageReady();
147 bool alpacaGetImageArrayImageBytes(uint8_t** buffer,
size_t* buffer_size, ImageBytesMetadata* metadata);
148 bool alpacaGetImageArrayJSON(ImageMetadata &meta, uint8_t** buffer,
size_t* buffer_size);
149 bool downloadImage();
150 bool processImageBytesData(uint8_t* buffer,
size_t buffer_size,
const ImageBytesMetadata &metadata);
151 bool processMonoImage(uint8_t* buffer);
152 bool processColorImage(uint8_t* buffer);
155 void convertImageBytesToINDI2D(uint8_t* src_buffer, uint16_t* dst_buffer, uint32_t width, uint32_t height,
156 int32_t transmission_type);
157 void convertImageBytesToINDI3D(uint8_t* src_buffer, uint16_t* dst_buffer, uint32_t width, uint32_t height, uint32_t planes,
158 int32_t transmission_type);
161 void translateCoordinates(uint8_t* buffer,
const ImageMetadata &meta);
162 virtual void addFITSKeywords(
INDI::CCDChip * targetChip, std::vector<INDI::FITSRecord> &fitsKeywords)
override;
166 void workerExposure(
const std::atomic_bool &isAboutToQuit,
float duration);
169 void updateCoolerStatus();
170 void updateCameraState();
171 void updateReadoutModes();
172 void updateCameraCapabilities();
175 std::string getSensorTypeString(uint8_t sensorType);
189 bool m_GainIsList {
false};
190 bool m_OffsetIsList {
false};
194 enum { FAST_READOUT_ENABLE, FAST_READOUT_DISABLE };
195 bool m_HasFastReadout {
false};
203 bool m_HasGain {
false};
204 bool m_HasOffset {
false};
205 bool m_CanPulseGuide {
false};
206 bool m_CanAbortExposure {
false};
207 bool m_CanStopExposure {
false};
208 bool m_CanAsymmetricBin {
false};
209 bool m_HasCoolerPower {
false};
210 bool m_HasPercentCompleted {
true};
211 bool m_HasLastExposureDuration {
true};
214 bool m_PulseGuiding {
false};
219 void temperatureTimerTimeout();
220 double m_CurrentTemperature {0};
221 double m_TargetTemperature {std::numeric_limits<double>::quiet_NaN()};
223 static const constexpr char* CONNECTION_TAB =
"Connection";
224 static constexpr int TEMP_TIMER_MS = 10000;
226 static constexpr double TEMP_THRESHOLD = 0.25;
virtual bool SetCaptureFormat(uint8_t index) override
SetCaptureFormat Set Active Capture format.
virtual bool UpdateCCDFrame(int x, int y, int w, int h) override
CCD calls this function when CCD Frame dimension needs to be updated in the hardware....
virtual bool ISNewNumber(const char *dev, const char *name, double values[], char *names[], int n) override
Process the client newNumber command.
virtual bool AbortExposure() override
Abort ongoing exposure.
const char * getDefaultName() override
virtual IPState GuideNorth(uint32_t ms) override
Guide northward for ms milliseconds.
virtual IPState GuideEast(uint32_t ms) override
Guide easward for ms milliseconds.
void TimerHit() override
Callback function to be called once SetTimer duration elapses.
uint32_t getTransactionId()
void setDefaultServerAddress(const char *host, const char *port, bool force=false)
bool updateProperties() override
updateProperties is called whenever there is a change in the CONNECTION status of the driver....
virtual bool ISNewSwitch(const char *dev, const char *name, ISState *states, char *names[], int n) override
Process the client newSwitch command.
virtual bool parseImageBytesMetadata(ImageBytesMetadata *metadata, size_t body_size)
virtual int SetTemperature(double temperature) override
Set CCD temperature.
virtual bool StartExposure(float duration) override
Start exposing primary CCD chip.
virtual bool initProperties() override
Initialize properties initial state and value. The child class must implement this function.
virtual IPState GuideSouth(uint32_t ms) override
Guide southward for ms milliseconds.
bool Connect() override
Connect to the device. INDI::DefaultDevice implementation connects to appropriate connection interfac...
void ISGetProperties(const char *dev) override
define the driver's properties to the client. Usually, only a minimum set of properties are defined t...
virtual ~AlpacaCCD()=default
virtual bool ISNewText(const char *dev, const char *name, char *texts[], char *names[], int n) override
Process the client newSwitch command.
virtual bool UpdateCCDBin(int hor, int ver) override
CCD calls this function when CCD Binning needs to be updated in the hardware. Derived classes should ...
bool Disconnect() override
Disconnect from device.
virtual std::string buildAlpacaFormData(const nlohmann::json &request)
virtual bool saveConfigItems(FILE *fp) override
saveConfigItems Save configuration items in XML file.
virtual IPState GuideWest(uint32_t ms) override
Guide westward for ms milliseconds.
The CCDChip class provides functionality of a CCD Chip within a CCD.
Class to provide general functionality of CCD cameras with a single CCD sensor, or a primary CCD sens...
The Timer class provides repetitive and single-shot timers.
a class to store JSON values