moved kdeaccessibility kdeaddons kdeadmin kdeartwork kdebindings kdeedu kdegames...
[kdeedu.git] / kstars / kstars / indi / apogee_ppi.h
blob998a83903f45720b9e145c7683a460f8a1e01e38
1 #if 0
2 Apogee PPI
3 INDI Interface for Apogee PPI
4 Copyright (C) 2005 Jasem Mutlaq (mutlaqja AT ikarustech DOT com)
6 This library is free software; you can redistribute it and/or
7 modify it under the terms of the GNU Lesser General Public
8 License as published by the Free Software Foundation; either
9 version 2.1 of the License, or (at your option) any later version.
11 This library is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 Lesser General Public License for more details.
16 You should have received a copy of the GNU Lesser General Public
17 License along with this library; if not, write to the Free Software
18 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20 #endif
22 #ifndef APOGEE_PPI_H
23 #define APOGEE_PPI_H
25 #include <stdio.h>
26 #include <stdlib.h>
27 #include <string.h>
28 #include <stdarg.h>
29 #include <math.h>
30 #include <unistd.h>
31 #include <time.h>
32 #include <fcntl.h>
33 #include <errno.h>
35 #include "fitsrw.h"
36 #include "indidevapi.h"
37 #include "eventloop.h"
38 #include "indicom.h"
39 #include "apogee/CameraIO_Linux.h"
41 #define mydev "Apogee PPI"
43 #define COMM_GROUP "Communication"
44 #define EXPOSE_GROUP "Expose"
45 #define IMAGE_GROUP "Image Settings"
46 #define DATA_GROUP "Data Channel"
48 #define POLLMS 1000 /* Polling time (ms) */
49 #define TEMP_THRESHOLD .25 /* Differential temperature threshold (C)*/
51 #define MAX_PIXELS 4096
52 #define MAXHBIN 8
53 #define MAXVBIN 64
54 #define MIN_CCD_TEMP -60
55 #define MAX_CCD_TEMP 40
56 #define MAXCOLUMNS 16383
57 #define MAXROWS 16383
58 #define MAXTOTALCOLUMNS 16383
59 #define MAXTOTALROWS 16383
61 #define FILENAMESIZ 2048
62 #define LIBVERSIZ 1024
63 #define PREFIXSIZ 64
64 #define PIPEBUFSIZ 8192
65 #define FRAME_ILEN 64
67 #define getBigEndian(p) ( ((p & 0xff) << 8) | (p >> 8))
69 class ApogeeCam {
71 public:
73 ApogeeCam();
74 ~ApogeeCam();
76 /* INDI Functions that must be called from indidrivermain */
77 void ISGetProperties (const char *dev);
78 void ISNewSwitch (const char *dev, const char *name, ISState *states, char *names[], int n);
79 void ISNewText (const char *dev, const char *name, char *texts[], char *names[], int n);
80 void ISNewNumber (const char *dev, const char *name, double values[], char *names[], int n);
82 private:
84 /* Structs */
85 struct
87 short width;
88 short height;
89 int frameType;
90 int expose;
91 double temperature;
92 int binX, binY;
93 unsigned short *img;
94 } APGFrame;
96 enum { LIGHT_FRAME , BIAS_FRAME, DARK_FRAME, FLAT_FRAME };
98 /* Switches */
99 ISwitch PowerS[2];
100 ISwitch *ApogeeModelS;
101 ISwitch FrameTypeS[4];
103 /* Numbers */
104 INumber FrameN[4];
105 INumber BinningN[2];
106 INumber ExposeTimeN[1];
107 INumber TemperatureN[1];
108 INumber DataChannelN[1];
110 /* BLOBs */
111 IBLOB imageB;
113 /* Switch vectors */
114 ISwitchVectorProperty PowerSP; /* Connection switch */
115 ISwitchVectorProperty ApogeeModelSP; /* Apogee Model */
116 ISwitchVectorProperty FrameTypeSP; /* Frame type */
118 /* Number vectors */
119 INumberVectorProperty FrameNP; /* Frame specs */
120 INumberVectorProperty BinningNP; /* Binning */
121 INumberVectorProperty ExposeTimeNP; /* Exposure */
122 INumberVectorProperty TemperatureNP; /* Temperature control */
125 /* BLOB vectors */
126 IBLOBVectorProperty imageBP; /* Data stream */
128 /* Other */
129 static int streamTimerID; /* Stream ID */
130 double targetTemp; /* Target temperature */
131 CCameraIO *cam; /* Apogee Camera object */
133 /* Functions */
135 /* General */
136 void initProperties();
137 bool loadXMLModel();
138 bool initCamera();
140 /* CCD */
141 void getBasicData(void);
142 void handleExposure(void *);
143 void connectCCD(void);
144 void uploadFile(char * filename);
145 int writeFITS(char *filename, char errmsg[]);
146 int setImageArea(char errmsg[]);
147 void grabImage(void);
148 int isCCDConnected(void);
150 /* Power */
151 int checkPowerS(ISwitchVectorProperty *sp);
152 int checkPowerN(INumberVectorProperty *np);
153 int checkPowerT(ITextVectorProperty *tp);
155 /* Helper functions */
156 int manageDefaults(char errmsg[]);
157 int getOnSwitch(ISwitchVectorProperty *sp);
158 FITS_HDU_LIST * create_fits_header (FITS_FILE *ofp, uint width, uint height, uint bpp);
159 static void ISStaticPoll(void *);
160 void ISPoll();
161 unsigned short hextoi(char* instr);
165 double min(void);
166 double max(void);
169 #endif