source: BAORadio/libindi/libindi/libs/indibase/indiccd.h @ 642

Last change on this file since 642 was 642, checked in by frichard, 12 years ago

-Alignement des antennes
-Version 0.0.9 de libindi

File size: 10.3 KB
Line 
1/*******************************************************************************
2  Copyright(c) 2010, 2011 Gerry Rozema, 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
20#ifndef INDI_CCD_H
21#define INDI_CCD_H
22
23#include <fitsio.h>
24
25#include "defaultdriver.h"
26#include "indiguiderinterface.h"
27
28extern const char *IMAGE_SETTINGS_TAB;
29extern const char *IMAGE_INFO_TAB;
30extern const char *GUIDE_HEAD_TAB;
31extern const char *GUIDE_CONTROL_TAB;
32
33class CCDChip
34{
35
36public:
37    CCDChip();
38    ~CCDChip();
39
40    typedef enum { LIGHT_FRAME=0, BIAS_FRAME, DARK_FRAME, FLAT_FRAME } CCD_FRAME;
41
42    int getXRes() { return XRes; }
43    int getYRes() { return YRes; }
44    int getSubX() { return SubX; }
45    int getSubY() { return SubY; }
46    int getSubW() { return SubW; }
47    int getSubH() { return SubH; }
48    int getBinX() { return BinX; }
49    int getBinY() { return BinY; }
50    int getPixelSizeX() { return PixelSizex; }
51    int getPixelSizeY() { return PixelSizey; }
52    int getBPP() { return BPP; }
53    int getFrameBufferSize() { return RawFrameSize; }
54    double getExposure() { return ImageExposureN[0].value; }
55    char *getFrameBuffer() { return RawFrame; }
56    bool isCompressed() { return SendCompressed; }
57    bool isInterlaced() { return Interlaced; }
58    CCD_FRAME getFrameType() { return FrameType; }
59
60    void setResolutoin(int x, int y);
61    void setFrame(int subx, int suby, int subw, int subh);
62    void setBin(int hor, int ver);
63    void setPixelSize(int x, int y);
64    void setCompressed (bool cmp);
65    void setInterlaced(bool intr);
66    void setFrameBufferSize(int nbuf);
67    void setBPP(int bpp);
68    int setFrameType(CCD_FRAME);
69    void setExposure(double duration);
70    void setExposureFailed();
71
72private:
73
74    int XRes;   //  native resolution of the ccd
75    int YRes;   //  ditto
76    int SubX;   //  left side of the subframe we are requesting
77    int SubY;   //  top of the subframe requested
78    int SubW;   //  width of the subframe
79    int SubH;   //  height of the subframe
80    int BinX;   //  Binning requested in the x direction
81    int BinY;   //  Binning requested in the Y direction
82    float PixelSizex;   //  pixel size in microns, x direction
83    float PixelSizey;   //  pixel size in microns, y direction
84    int BPP;            //  Bytes per Pixel
85    bool Interlaced;
86    char *RawFrame;
87    int RawFrameSize;
88    bool SendCompressed;
89    CCD_FRAME FrameType;
90
91    INumberVectorProperty *ImageExposureNP;
92    INumber ImageExposureN[1];
93
94    INumberVectorProperty *ImageFrameNP;
95    INumber ImageFrameN[4];
96
97    INumberVectorProperty *ImageBinNP;
98    INumber ImageBinN[2];
99
100    INumberVectorProperty *ImagePixelSizeNP;
101    INumber ImagePixelSizeN[6];
102
103    ISwitch FrameTypeS[4];
104    ISwitchVectorProperty *FrameTypeSP;
105
106    ISwitch CompressS[2];
107    ISwitchVectorProperty *CompressSP;
108
109    IBLOB FitsB;
110    IBLOBVectorProperty *FitsBP;
111
112    friend class INDI::CCD;
113};
114
115/**
116 * \class INDI::CCD
117   \brief Class to provide general functionality of CCD cameras with a single CCD sensor, or a primary CCD sensor in addition to a secondary CCD guide head.
118
119   It also implements the interface to perform guiding. The class enable the ability to \e snoop on telescope equatorial coordinates and record them in the
120   FITS file before upload. Developers need to subclass INDI::CCD to implement any driver for CCD cameras within INDI.
121
122\author Gerry Rozema, Jasem Mutlaq
123*/
124class INDI::CCD : public INDI::DefaultDriver, INDI::GuiderInterface
125{
126      public:
127        CCD();
128        virtual ~CCD();
129
130        virtual bool initProperties();
131        virtual bool updateProperties();
132        virtual void ISGetProperties (const char *dev);
133        virtual bool ISNewNumber (const char *dev, const char *name, double values[], char *names[], int n);
134        virtual bool ISNewSwitch (const char *dev, const char *name, ISState *states, char *names[], int n);
135        virtual bool ISNewText (const char *dev, const char *name, char *texts[], char *names[], int n);
136        virtual void ISSnoopDevice (XMLEle *root);
137
138     protected:
139        /** \brief Start exposing primary CCD chip
140            \param duration Duration in seconds
141            \return 0 if OK and exposure will take some time to complete, 1 if exposure is short and complete already (e.g. bias), -1 on error.
142            \note This function is not implemented in INDI::CCD, it must be implemented in the child class
143        */
144        virtual int StartExposure(float duration);
145
146        /** \brief Uploads primary CCD exposed buffer as FITS to the client. Dervied classes should class this function when an exposure is complete.
147             \note This function is not implemented in INDI::CCD, it must be implemented in the child class
148        */
149        virtual bool ExposureComplete();
150
151        /** \brief Abort ongoing exposure
152            \return true is abort is successful, false otherwise.
153            \note This function is not implemented in INDI::CCD, it must be implemented in the child class
154        */
155        virtual bool AbortExposure();
156
157        /** \brief Start exposing guide CCD chip
158            \param duration Duration in seconds
159            \return 0 if OK and exposure will take some time to complete, 1 if exposure is short and complete already (e.g. bias), -1 on error.
160            \note This function is not implemented in INDI::CCD, it must be implemented in the child class
161        */
162        virtual int StartGuideExposure(float duration);
163
164        /** \brief Abort ongoing exposure
165            \return true is abort is successful, false otherwise.
166            \note This function is not implemented in INDI::CCD, it must be implemented in the child class
167        */
168        virtual bool AbortGuideExposure();
169
170        /** \brief Uploads Guide head CCD exposed buffer as FITS to the client. Dervied classes should class this function when an exposure is complete.
171            \note This function is not implemented in INDI::CCD, it must be implemented in the child class
172        */
173        virtual bool GuideExposureComplete();
174
175        /** \brief INDI::CCD calls this function when CCD Frame dimension needs to be updated in the hardware. Derived classes should implement this function
176            \param x Subframe X coordinate in pixels.
177            \param y Subframe Y coordinate in pixels.
178            \param w Subframe width in pixels.
179            \param h Subframe height in pixels.
180            \note (0,0) is defined as most left, top pixel in the subframe.
181            \return true is CCD chip update is successful, false otherwise.
182            \note This function is not implemented in INDI::CCD, it must be implemented in the child class
183        */
184        virtual bool updateCCDFrame(int x, int y, int w, int h);
185
186        /** \brief INDI::CCD calls this function when CCD Binning needs to be updated in the hardware. Derived classes should implement this function
187            \param hor Horizontal binning.
188            \param ver Vertical binning.
189            \return true is CCD chip update is successful, false otherwise.
190            \note This function is not implemented in INDI::CCD, it must be implemented in the child class
191        */
192        virtual bool updateCCDBin(int hor, int ver);
193
194
195        /** \brief Setup CCD paramters for primary CCD. Child classes call this function to update CCD paramaters
196            \param x Frame X coordinates in pixels.
197            \param y Frame Y coordinates in pixels.
198            \param bpp Bits Per Pixels.
199            \param xf X pixel size in microns.
200            \param yf Y pixel size in microns.
201        */
202        virtual void SetCCDParams(int x,int y,int bpp,float xf,float yf);
203
204        /** \brief Setup CCD paramters for guide head CCD. Child classes call this function to update CCD paramaters
205            \param x Frame X coordinates in pixels.
206            \param y Frame Y coordinates in pixels.
207            \param bpp Bits Per Pixels.
208            \param xf X pixel size in microns.
209            \param yf Y pixel size in microns.
210        */
211        virtual void SetGuidHeadParams(int x,int y,int bpp,float xf,float yf);
212
213
214        /** \brief Guide northward for ms milliseconds
215            \param ms Duration in milliseconds.
216            \note This function is not implemented in INDI::CCD, it must be implemented in the child class
217            \return True if successful, false otherwise.
218        */
219        virtual bool GuideNorth(float ms);
220
221        /** \brief Guide southward for ms milliseconds
222            \param ms Duration in milliseconds.
223            \note This function is not implemented in INDI::CCD, it must be implemented in the child class
224            \return 0 if successful, -1 otherwise.
225        */
226        virtual bool GuideSouth(float ms);
227
228        /** \brief Guide easward for ms milliseconds
229            \param ms Duration in milliseconds.
230            \note This function is not implemented in INDI::CCD, it must be implemented in the child class
231            \return 0 if successful, -1 otherwise.
232        */
233        virtual bool GuideEast(float ms);
234
235        /** \brief Guide westward for ms milliseconds
236            \param ms Duration in milliseconds.
237            \note This function is not implemented in INDI::CCD, it must be implemented in the child class
238            \return 0 if successful, -1 otherwise.
239        */
240        virtual bool GuideWest(float ms);
241
242        float RA;
243        float Dec;
244        bool HasGuideHead;
245        bool HasSt4Port;
246        bool InExposure;
247
248        CCDChip PrimaryCCD;
249        CCDChip GuideCCD;
250
251 private:
252    //  We are going to snoop these from a telescope
253    INumberVectorProperty EqNP;
254    INumber EqN[2];
255
256    ITextVectorProperty *TelescopeTP;
257    IText TelescopeT[1];
258
259    void addFITSKeywords(fitsfile *fptr);
260    int uploadfile(void *fitsdata,int total);
261
262};
263
264#endif // INDI:CCD_H
Note: See TracBrowser for help on using the repository browser.