Instrument Neutral Distributed Interface INDI 2.2.5
indiccdchip.h
Go to the documentation of this file.
1/*******************************************************************************
2 Copyright(c) 2019 Jasem Mutlaq. All rights reserved.
3
4 This library is free software; you can redistribute it and/or
5 modify it under the terms of the GNU Library General Public
6 License version 2 as published by the Free Software Foundation.
7
8 This library is distributed in the hope that it will be useful,
9 but WITHOUT ANY WARRANTY; without even the implied warranty of
10 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11 Library General Public License for more details.
12
13 You should have received a copy of the GNU Library General Public License
14 along with this library; see the file COPYING.LIB. If not, write to
15 the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
16 Boston, MA 02110-1301, USA.
17*******************************************************************************/
18
19#pragma once
20
21#include "indiapi.h"
22#include "indidriver.h"
23#include "indipropertyswitch.h"
24#include "indipropertyblob.h"
25
26#include "indipropertynumber.h"
27
28#include <sys/time.h>
29#include <stdint.h>
30#include <fitsio.h>
31
32namespace INDI
33{
34
39{
40 public:
41 CCDChip();
42 ~CCDChip();
43
46 typedef enum { BIN_W, BIN_H } CCD_BIN_INDEX;
56
63 bool openFITSFile(uint32_t size, int &status);
64
65
70 bool finishFITSFile(int &status);
71
75 void closeFITSFile();
76
81 inline int getXRes() const
82 {
83 return XRes;
84 }
85
90 inline int getYRes() const
91 {
92 return YRes;
93 }
94
99 inline int getSubX() const
100 {
101 return SubX;
102 }
103
108 inline int getSubY() const
109 {
110 return SubY;
111 }
112
117 inline int getSubW() const
118 {
119 return SubW;
120 }
121
126 inline int getSubH() const
127 {
128 return SubH;
129 }
130
135 inline int getBinX() const
136 {
137 return BinX;
138 }
139
144 inline int getBinY() const
145 {
146 return BinY;
147 }
148
153 inline float getPixelSizeX() const
154 {
155 return PixelSizeX;
156 }
157
162 inline float getPixelSizeY() const
163 {
164 return PixelSizeY;
165 }
166
171 inline int getBPP() const
172 {
173 return BitsPerPixel;
174 }
175
180 inline int getFrameBufferSize() const
181 {
182 return RawFrameSize;
183 }
184
189 inline double getExposureLeft() const
190 {
191 return ImageExposureNP[0].getValue();
192 }
193
198 inline double getExposureDuration() const
199 {
200 return ExposureDuration;
201 }
202
207 const char *getExposureStartTime();
208
213 inline uint8_t *getFrameBuffer()
214 {
215 return RawFrame;
216 }
217
226 void setFrameBuffer(uint8_t *buffer)
227 {
228 RawFrame = buffer;
229 }
230
235 inline bool isCompressed() const
236 {
237 return SendCompressed;
238 }
239
244 // inline bool isInterlaced()
245 // {
246 // return Interlaced;
247 // }
248
253 inline CCD_FRAME getFrameType() const
254 {
255 return FrameType;
256 }
257
263 const char *getFrameTypeName(CCD_FRAME fType);
264
269 {
270 return ImagePixelSizeNP;
271 }
272
278 void setResolution(uint32_t x, uint32_t y);
279
287 void setFrame(uint32_t subx, uint32_t suby, uint32_t subw, uint32_t subh);
288
294 void setBin(uint8_t hor, uint8_t ver);
295
306 void setMinMaxStep(const char *property, const char *element, double min, double max, double step,
307 bool sendToClient = true);
308
314 void setPixelSize(double x, double y);
315
320 void setCompressed(bool cmp);
321
322 // /**
323 // * @brief setInterlaced Set whether the CCD chip is interlaced or not?
324 // * @param intr If true, the CCD chip is interlaced.
325 // */
326 // void setInterlaced(bool intr);
327
336 void setFrameBufferSize(uint32_t nbuf, bool allocMem = true);
337
342 void setBPP(uint8_t bpp);
343
349
356 void setExposureDuration(double duration);
357
363 void setExposureLeft(double duration);
364
368 void setExposureComplete();
369
373 void setExposureFailed();
374
378 int getNAxis() const;
379
384 void setNAxis(int value);
385
390 void setImageExtension(const char *ext);
391
396 {
397 return ImageExtention;
398 }
399
403 bool isExposing() const
404 {
405 return (ImageExposureNP.getState() == IPS_BUSY);
406 }
407
412 void binFrame();
413
418 void binBayerFrame();
419
420 fitsfile **fitsFilePointer()
421 {
422 return &m_FITSFilePointer;
423 }
424
426 {
427 return &m_FITSMemorySize;
428 }
429
431 {
432 return &m_FITSMemoryBlock;
433 }
434
435 private:
439
441 uint32_t XRes {0};
443 uint32_t YRes {0};
445 uint32_t SubX {0};
447 uint32_t SubY {0};
449 uint32_t SubW {0};
451 uint32_t SubH {0};
453 uint8_t BinX {1};
455 uint32_t BinY {1};
457 uint8_t NAxis {2};
459 double PixelSizeX {0};
461 double PixelSizeY {0};
463 uint8_t BitsPerPixel {8};
464 //bool Interlaced {false};
465 // RAW Frame for image data stored as bytes.
466 uint8_t *RawFrame {nullptr};
467 // RAW Frame size in bytes.
468 uint32_t RawFrameSize {0};
469 // BINNED Frame when software binning is used.
470 uint8_t *BinFrame {nullptr};
471 // Should we compress frame before transmission?
472 bool SendCompressed {false};
473 // Frame Type
474 CCD_FRAME FrameType {LIGHT_FRAME};
475 // Exposure duration in seconds.
476 double ExposureDuration {0};
477 // Exposure startup time
478 timeval StartExposureTime;
479 // Image extension type (e.g. jpg)
480 char ImageExtention[MAXINDIBLOBFMT];
481 void * m_FITSMemoryBlock {nullptr};
482 size_t m_FITSMemorySize {2880};
483 fitsfile * m_FITSFilePointer {nullptr};
484
488
492 INDI::PropertyNumber ImageExposureNP {1};
493
497 INDI::PropertySwitch AbortExposureSP {1};
498
502 INDI::PropertyNumber ImageFrameNP {4};
503
507 INDI::PropertyNumber ImageBinNP{2};
508 enum
509 {
510 HOR_BIN,
511 VER_BIN
512 };
516 INDI::PropertyNumber ImagePixelSizeNP {6};
517
521 INDI::PropertySwitch FrameTypeSP {4};
522
526 INDI::PropertySwitch CompressSP {2};
530 INDI::PropertyBlob FitsBP {1};
531
535 INDI::PropertySwitch ResetSP{1};
536
537 friend class CCD;
538 friend class StreamRecoder;
539
540#if 0
541 ISwitch RapidGuideS[2];
542 ISwitchVectorProperty RapidGuideSP;
543
544 ISwitch RapidGuideSetupS[3];
545 ISwitchVectorProperty RapidGuideSetupSP;
546
547 INumber RapidGuideDataN[3];
548 INumberVectorProperty RapidGuideDataNP;
549#endif
550
551};
552
553}
The CCDChip class provides functionality of a CCD Chip within a CCD.
Definition indiccdchip.h:39
void setExposureComplete()
setExposureComplete Mark exposure as complete by setting ImageExposure property to IPS_OK
char * getImageExtension()
void setFrameBuffer(uint8_t *buffer)
setFrameBuffer Set raw frame buffer pointer.
int getSubX() const
getSubX Get the starting left coordinates (X) of the frame.
Definition indiccdchip.h:99
int getSubY() const
getSubY Get the starting top coordinates (Y) of the frame.
bool finishFITSFile(int &status)
Finish any pending write to fits file.
float getPixelSizeY() const
getPixelSizeY Get vertical pixel size in microns.
void setExposureDuration(double duration)
setExposureDuration Set desired CCD frame exposure duration for next exposure. You must call this fun...
void setResolution(uint32_t x, uint32_t y)
setResolution set CCD Chip resolution
int getSubH() const
getSubH Get the height of the frame
double getExposureDuration() const
getExposureDuration Get requested exposure duration for the CCD chip in seconds.
void setCompressed(bool cmp)
setCompressed Set whether a frame is compressed after exposure?
int getBPP() const
getBPP Get CCD Chip depth (bits per pixel).
const char * getExposureStartTime()
getExposureStartTime
CCD_FRAME getFrameType() const
isInterlaced
int getBinY() const
getBinY Get vertical binning of the CCD chip.
void closeFITSFile()
closeFITSFile Close the in-memory FITS File.
float getPixelSizeX() const
getPixelSizeX Get horizontal pixel size in microns.
friend class StreamRecoder
void setFrame(uint32_t subx, uint32_t suby, uint32_t subw, uint32_t subh)
setFrame Set desired frame resolutoin for an exposure.
void setMinMaxStep(const char *property, const char *element, double min, double max, double step, bool sendToClient=true)
setMinMaxStep for a number property element
int getXRes() const
getXRes Get the horizontal resolution in pixels of the CCD Chip.
Definition indiccdchip.h:81
bool isExposing() const
int getBinX() const
getBinX Get horizontal binning of the CCD chip.
bool isCompressed() const
isCompressed
void setFrameType(CCD_FRAME type)
setFrameType Set desired frame type for next exposure.
void setImageExtension(const char *ext)
setImageExtension Set image extension
size_t * fitsMemorySizePointer()
void setPixelSize(double x, double y)
setPixelSize Set CCD Chip pixel size
uint8_t * getFrameBuffer()
getFrameBuffer Get raw frame buffer of the CCD chip.
void setExposureFailed()
setExposureFailed Alert the client that the exposure failed.
void setExposureLeft(double duration)
setExposureLeft Update exposure time left. Inform the client of the new exposure time left value.
int getSubW() const
getSubW Get the width of the frame
const char * getFrameTypeName(CCD_FRAME fType)
getFrameTypeName returns CCD Frame type name
double getExposureLeft() const
getExposureLeft Get exposure time left in seconds.
void setFrameBufferSize(uint32_t nbuf, bool allocMem=true)
setFrameBufferSize Set desired frame buffer size. The function will allocate memory accordingly....
int getFrameBufferSize() const
getFrameBufferSize Get allocated frame buffer size to hold the CCD image frame.
void ** fitsMemoryBlockPointer()
void setBin(uint8_t hor, uint8_t ver)
setBin Set CCD Chip binnig
int getNAxis() const
void binBayerFrame()
binBayerFrame Perform software binning on a 2x2 Bayer matrix CCD frame. Only use this function if har...
int getYRes() const
Get the vertical resolution in pixels of the CCD Chip.
Definition indiccdchip.h:90
void binFrame()
binFrame Perform software binning on the CCD frame. Only use this function if hardware binning is not...
fitsfile ** fitsFilePointer()
void setBPP(uint8_t bpp)
setBPP Set depth of CCD chip.
bool openFITSFile(uint32_t size, int &status)
openFITSFile Allocate memory buffer for internal FITS file structure and open
void setNAxis(int value)
setNAxis Set FITS number of axis
INDI::PropertyNumber getCCDInfo()
Return CCD Info Property.
Class to provide general functionality of CCD cameras with a single CCD sensor, or a primary CCD sens...
Definition indiccd.h:108
double max(void)
#define min(a, b)
Constants and Data structure definitions for the interface to the reference INDI C API implementation...
#define MAXINDIBLOBFMT
Definition indiapi.h:194
@ IPS_BUSY
Definition indiapi.h:161
Namespace to encapsulate INDI client, drivers, and mediator classes.
uint16_t type
Definition pwc-ioctl.h:0
One number descriptor.
One switch descriptor.
Number vector property descriptor.
Definition indiapi.h:317
Switch vector property descriptor.
Definition indiapi.h:365