moved kdeaccessibility kdeaddons kdeadmin kdeartwork kdebindings kdeedu kdegames...
[kdeedu.git] / kstars / kstars / indi / sbigccd.h
blob1c18643d90ad4dd377b4b6a8050052c881bcf22c
1 #if 0
2 INDI driver for SBIG CCD
3 Copyright (C) 2005 Chris Curran (ccurran AT planetcurran DOT com)
5 Based on Apogee PPI driver by Jasem Mutlaq (mutlaqja AT ikarustech DOT com)
7 This library is free software; you can redistribute it and/or
8 modify it under the terms of the GNU Lesser General Public
9 License as published by the Free Software Foundation; either
10 version 2.1 of the License, or (at your option) any later version.
12 This library is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 Lesser General Public License for more details.
17 You should have received a copy of the GNU Lesser General Public
18 License along with this library; if not, write to the Free Software
19 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
21 #endif
23 #ifndef SBIGCCD_H
24 #define SBIGCCD_H
26 #include <stdio.h>
27 #include <stdlib.h>
28 #include <string.h>
29 #include <stdarg.h>
30 #include <math.h>
31 #include <unistd.h>
32 #include <time.h>
33 #include <fcntl.h>
34 #include <errno.h>
36 #include "fitsrw.h"
37 #include "indidevapi.h"
38 #include "eventloop.h"
39 #include "indicom.h"
41 #define mydev "SBIG CCD"
43 #define COMM_GROUP "Communication"
44 #define EXPOSE_GROUP "Expose"
45 #define IMAGE_GROUP "Image Settings"
47 #define POLLMS 1000 /* Polling time (ms) */
48 #define TEMP_THRESHOLD .25 /* Differential temperature threshold (C)*/
50 #define MAX_PIXELS 4096
51 #define MAXHBIN 8
52 #define MAXVBIN 64
53 #define MIN_CCD_TEMP -60
54 #define MAX_CCD_TEMP 40
56 #define getBigEndian(p) ( ((p & 0xff) << 8) | (p >> 8))
58 class SBIGCam {
60 public:
62 SBIGCam();
63 ~SBIGCam();
65 /* INDI Functions that must be called from indidrivermain */
66 void ISGetProperties (const char *dev);
67 void ISNewSwitch (const char *dev, const char *name, ISState *states, char *names[], int n);
68 void ISNewText (const char *dev, const char *name, char *texts[], char *names[], int n);
69 void ISNewNumber (const char *dev, const char *name, double values[], char *names[], int n);
71 private:
73 /* Structs */
74 struct
76 short width;
77 short height;
78 int frameType;
79 int expose;
80 double temperature;
81 int binX, binY;
82 unsigned short *img;
83 } SBIGFrame;
85 enum { LIGHT_FRAME , BIAS_FRAME, DARK_FRAME, FLAT_FRAME };
87 /* Switches */
88 ISwitch PowerS[2];
89 ISwitch FrameTypeS[4];
91 /* Numbers */
92 INumber FrameN[4];
93 INumber BinningN[2];
94 INumber ExposeTimeN[1];
95 INumber TemperatureN[1];
97 /* BLOBs */
98 IBLOB imageB;
100 /* Switch vectors */
101 ISwitchVectorProperty PowerSP; /* Connection switch */
102 ISwitchVectorProperty FrameTypeSP; /* Frame type */
104 /* Number vectors */
105 INumberVectorProperty FrameNP; /* Frame specs */
106 INumberVectorProperty BinningNP; /* Binning */
107 INumberVectorProperty ExposeTimeNP; /* Exposure */
108 INumberVectorProperty TemperatureNP; /* Temperature control */
111 /* BLOB vectors */
112 IBLOBVectorProperty imageBP; /* Data stream */
114 /* Other */
115 double targetTemp; /* Target temperature */
117 /* Functions */
119 /* General */
120 void initProperties();
121 bool initCamera();
123 /* CCD */
124 void getBasicData(void);
125 void handleExposure(void *);
126 void connectCCD(void);
127 void uploadFile(char * filename);
128 int writeFITS(char *filename, char errmsg[]);
129 void grabImage(void);
130 int isCCDConnected(void);
132 /* Power */
133 int checkPowerS(ISwitchVectorProperty *sp);
134 int checkPowerN(INumberVectorProperty *np);
135 int checkPowerT(ITextVectorProperty *tp);
137 /* Helper functions */
138 int manageDefaults(char errmsg[]);
139 int getOnSwitch(ISwitchVectorProperty *sp);
140 FITS_HDU_LIST * create_fits_header (FITS_FILE *ofp, uint width, uint height, uint bpp);
141 static void ISStaticPoll(void *);
142 void ISPoll();
146 #endif