kstars
apogee_ppi.h
Go to the documentation of this file.00001 #if 0
00002 Apogee PPI
00003 INDI Interface for Apogee PPI
00004 Copyright (C) 2005 Jasem Mutlaq (mutlaqja AT ikarustech DOT com)
00005
00006 This library is free software; you can redistribute it and/or
00007 modify it under the terms of the GNU Lesser General Public
00008 License as published by the Free Software Foundation; either
00009 version 2.1 of the License, or (at your option) any later version.
00010
00011 This library is distributed in the hope that it will be useful,
00012 but WITHOUT ANY WARRANTY; without even the implied warranty of
00013 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
00014 Lesser General Public License for more details.
00015
00016 You should have received a copy of the GNU Lesser General Public
00017 License along with this library; if not, write to the Free Software
00018 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
00019
00020 #endif
00021
00022 #ifndef APOGEE_PPI_H
00023 #define APOGEE_PPI_H
00024
00025 #include <stdio.h>
00026 #include <stdlib.h>
00027 #include <string.h>
00028 #include <stdarg.h>
00029 #include <math.h>
00030 #include <unistd.h>
00031 #include <time.h>
00032 #include <fcntl.h>
00033 #include <errno.h>
00034
00035 #include "fitsrw.h"
00036 #include "indidevapi.h"
00037 #include "eventloop.h"
00038 #include "indicom.h"
00039 #include "apogee/CameraIO_Linux.h"
00040
00041 #define mydev "Apogee PPI"
00042
00043 #define COMM_GROUP "Communication"
00044 #define EXPOSE_GROUP "Expose"
00045 #define IMAGE_GROUP "Image Settings"
00046 #define DATA_GROUP "Data Channel"
00047
00048 #define POLLMS 1000
00049 #define TEMP_THRESHOLD .25
00050
00051 #define MAX_PIXELS 4096
00052 #define MAXHBIN 8
00053 #define MAXVBIN 64
00054 #define MIN_CCD_TEMP -60
00055 #define MAX_CCD_TEMP 40
00056 #define MAXCOLUMNS 16383
00057 #define MAXROWS 16383
00058 #define MAXTOTALCOLUMNS 16383
00059 #define MAXTOTALROWS 16383
00060
00061 #define FILENAMESIZ 2048
00062 #define LIBVERSIZ 1024
00063 #define PREFIXSIZ 64
00064 #define PIPEBUFSIZ 8192
00065 #define FRAME_ILEN 64
00066
00067 #define getBigEndian(p) ( ((p & 0xff) << 8) | (p >> 8))
00068
00069 class ApogeeCam {
00070
00071 public:
00072
00073 ApogeeCam();
00074 ~ApogeeCam();
00075
00076
00077 void ISGetProperties (const char *dev);
00078 void ISNewSwitch (const char *dev, const char *name, ISState *states, char *names[], int n);
00079 void ISNewText (const char *dev, const char *name, char *texts[], char *names[], int n);
00080 void ISNewNumber (const char *dev, const char *name, double values[], char *names[], int n);
00081 void ISPoll();
00082
00083 private:
00084
00085
00086 struct
00087 {
00088 short width;
00089 short height;
00090 int frameType;
00091 int expose;
00092 double temperature;
00093 int binX, binY;
00094 unsigned short *img;
00095 } APGFrame;
00096
00097 enum { LIGHT_FRAME , BIAS_FRAME, DARK_FRAME, FLAT_FRAME };
00098
00099
00100 ISwitch PowerS[2];
00101 ISwitch *ApogeeModelS;
00102 ISwitch FrameTypeS[4];
00103
00104
00105 INumber FrameN[4];
00106 INumber BinningN[2];
00107 INumber ExposeTimeN[1];
00108 INumber TemperatureN[1];
00109 INumber DataChannelN[1];
00110
00111
00112 IBLOB imageB;
00113
00114
00115 ISwitchVectorProperty PowerSP;
00116 ISwitchVectorProperty ApogeeModelSP;
00117 ISwitchVectorProperty FrameTypeSP;
00118
00119
00120 INumberVectorProperty FrameNP;
00121 INumberVectorProperty BinningNP;
00122 INumberVectorProperty ExposeTimeNP;
00123 INumberVectorProperty TemperatureNP;
00124
00125
00126
00127 IBLOBVectorProperty imageBP;
00128
00129
00130 static int streamTimerID;
00131 double targetTemp;
00132 CCameraIO *cam;
00133
00134
00135
00136
00137 void initProperties();
00138 bool loadXMLModel();
00139 bool initCamera();
00140
00141
00142 void getBasicData(void);
00143 void handleExposure(void *);
00144 void connectCCD(void);
00145 void uploadFile(char * filename);
00146 int writeFITS(char *filename, char errmsg[]);
00147 int setImageArea(char errmsg[]);
00148 void grabImage(void);
00149 int isCCDConnected(void);
00150
00151
00152 int checkPowerS(ISwitchVectorProperty *sp);
00153 int checkPowerN(INumberVectorProperty *np);
00154 int checkPowerT(ITextVectorProperty *tp);
00155
00156
00157 int manageDefaults(char errmsg[]);
00158 int getOnSwitch(ISwitchVectorProperty *sp);
00159 FITS_HDU_LIST * create_fits_header (FITS_FILE *ofp, uint width, uint height, uint bpp);
00160 unsigned short hextoi(char* instr);
00161 double min();
00162 double max();
00163
00164 };
00165
00166 #endif
00167