kstars
CameraIO_Linux.h
Go to the documentation of this file.00001
00002
00003
00005
00006 #if !defined(AFX_CAMERAIO_H__A2882C82_7CFB_11D4_9155_0060676644C1__INCLUDED_)
00007 #define AFX_CAMERAIO_H__A2882C82_7CFB_11D4_9155_0060676644C1__INCLUDED_
00008
00009 #include "Apogee.h"
00010
00011 enum Camera_Interface{
00012 Camera_Interface_ISA = 0,
00013 Camera_Interface_PPI,
00014 Camera_Interface_PCI
00015 };
00016
00017 enum Camera_SensorType{
00018 Camera_SensorType_CCD = 0,
00019 Camera_SensorType_CMOS
00020 };
00021
00022 const long MAXCOLUMNS = 16383;
00023 const long MAXROWS = 16383;
00024 const long MAXHBIN = 8;
00025 const long MAXVBIN = 255;
00026
00027
00028 const long NumWriteRegisters = 8;
00029
00030 const long RegISA_Command = 0x000;
00031 const long Reg_Command = 0;
00032 const unsigned short RegBit_TDIMode = 0x1;
00033 const unsigned short RegBit_StartTimer = 0x2;
00034 const unsigned short RegBit_ShutterOverride = 0x4;
00035 const unsigned short RegBit_ResetSystem = 0x8;
00036 const unsigned short RegBit_FIFOCache = 0x10;
00037 const unsigned short RegBit_TriggerEnable = 0x20;
00038 const unsigned short RegBit_StopFlushing = 0x40;
00039 const unsigned short RegBit_ShutterEnable = 0x80;
00040 const unsigned short RegBit_CoolerShutdown = 0x100;
00041 const unsigned short RegBit_DoneReading = 0x200;
00042 const unsigned short RegBit_TimerLoad = 0x400;
00043 const unsigned short RegBit_StartNextLine = 0x800;
00044 const unsigned short RegBit_StartFlushing = 0x1000;
00045 const unsigned short RegBit_Focus = 0x2000;
00046 const unsigned short RegBit_CableLength = 0x4000;
00047 const unsigned short RegBit_CoolerEnable = 0x8000;
00048
00049 const long RegISA_Timer = 0x002;
00050 const long Reg_Timer = 1;
00051 const unsigned short RegBitShift_Timer = 0;
00052 const unsigned short RegBitMask_Timer = 0xFFFF;
00053
00054 const long RegISA_VBinning = 0x004;
00055 const long Reg_VBinning = 2;
00056 const unsigned short RegBitShift_Timer2 = 0;
00057 const unsigned short RegBitMask_Timer2 = 0xF;
00058 const unsigned short RegBitShift_VBinning = 0x8;
00059 const unsigned short RegBitMask_VBinning = 0xFF;
00060
00061 const long RegISA_AICCounter = 0x006;
00062 const long Reg_AICCounter = 3;
00063 const unsigned short RegBitShift_AICCounter = 0;
00064 const unsigned short RegBitMask_AICCounter = 0xFFF;
00065 const unsigned short RegBitShift_Test2 = 0xC;
00066 const unsigned short RegBitMask_Test2 = 0xF;
00067
00068 const long RegISA_TempSetPoint = 0x008;
00069 const long Reg_TempSetPoint = 4;
00070 const unsigned short RegBitShift_TempSetPoint = 0;
00071 const unsigned short RegBitMask_TempSetPoint = 0xFF;
00072 const unsigned short RegBitShift_PortControl = 0x8;
00073 const unsigned short RegBitMask_PortControl = 0xFF;
00074
00075 const long RegISA_PixelCounter = 0x00a;
00076 const long Reg_PixelCounter = 5;
00077 const unsigned short RegBitShift_PixelCounter = 0;
00078 const unsigned short RegBitMask_PixelCounter = 0xFFF;
00079 const unsigned short RegBitShift_HBinning = 0xC;
00080 const unsigned short RegBitMask_HBinning = 0x7;
00081 const unsigned short RegBit_LoopLock = 0x8000;
00082
00083 const long RegISA_LineCounter = 0x00c;
00084 const long Reg_LineCounter = 6;
00085 const unsigned short RegBitShift_LineCounter = 0;
00086 const unsigned short RegBitMask_LineCounter = 0xFFF;
00087 const unsigned short RegBitShift_Mode = 0xC;
00088 const unsigned short RegBitMask_Mode = 0xF;
00089
00090 const long RegISA_BICCounter = 0x00e;
00091 const long Reg_BICCounter = 7;
00092 const unsigned short RegBitShift_BICCounter = 0;
00093 const unsigned short RegBitMask_BICCounter = 0xFFF;
00094 const unsigned short RegBitShift_Test = 0xC;
00095 const unsigned short RegBitMask_Test = 0xF;
00096
00097 const long RegISA_ImageData = 0x000;
00098 const long Reg_ImageData = 8;
00099 const unsigned short RegBitShift_ImageData = 0;
00100 const unsigned short RegBitMask_ImageData = 0xFFFF;
00101
00102 const long RegISA_TempData = 0x002;
00103 const long Reg_TempData = 9;
00104 const unsigned short RegBitShift_TempData = 0;
00105 const unsigned short RegBitMask_TempData = 0xFF;
00106
00107 const long RegISA_Status = 0x006;
00108 const long Reg_Status = 10;
00109 const unsigned short RegBit_Exposing = 0x1;
00110 const unsigned short RegBit_LineDone = 0x2;
00111 const unsigned short RegBit_CacheReadOK = 0x4;
00112 const unsigned short RegBit_TempAtMin = 0x10;
00113 const unsigned short RegBit_TempAtMax = 0x20;
00114 const unsigned short RegBit_ShutdownComplete = 0x40;
00115 const unsigned short RegBit_TempAtSetPoint = 0x80;
00116 const unsigned short RegBit_GotTrigger = 0x400;
00117 const unsigned short RegBit_FrameDone = 0x800;
00118 const unsigned short RegBit_LoopbackTest = 0x8000;
00119
00120 const long RegISA_CommandReadback = 0x008;
00121 const long Reg_CommandReadback = 11;
00122
00123
00124 const long RegPCI_Command = 0x000;
00125 const long RegPCI_CommandRead = 0x020;
00126 const long RegPCI_Timer = 0x004;
00127 const long RegPCI_TimerRead = 0x024;
00128 const long RegPCI_VBinning = 0x008;
00129 const long RegPCI_VBinningRead = 0x028;
00130 const long RegPCI_AICCounter = 0x00C;
00131 const long RegPCI_AICCounterRead = 0x02C;
00132 const long RegPCI_TempSetPoint = 0x010;
00133 const long RegPCI_TempSetPointRead = 0x030;
00134 const long RegPCI_PixelCounter = 0x014;
00135 const long RegPCI_PixelCounterRead = 0x034;
00136 const long RegPCI_LineCounter = 0x018;
00137 const long RegPCI_LineCounterRead = 0x038;
00138 const long RegPCI_BICCounter = 0x01C;
00139 const long RegPCI_BICCounterRead = 0x03C;
00140 const long RegPCI_ImageData = 0x000;
00141 const long RegPCI_TempData = 0x004;
00142 const long RegPCI_Status = 0x00C;
00143 const long RegPCI_CommandReadback = 0x010;
00144
00145
00146
00147 class CCameraIO
00148 {
00149 public:
00150
00151 CCameraIO();
00152 virtual ~CCameraIO();
00153
00155
00156 bool InitDriver(unsigned short camnum);
00157 long ReadLine( long SkipPixels, long Pixels, unsigned short* pLineBuffer );
00158 long Write( unsigned short reg, unsigned short val );
00159 long Read( unsigned short reg, unsigned short& val );
00160
00162
00163
00164 Camera_Status read_Status();
00165
00166
00167
00168
00169
00170
00171
00172
00173
00174
00175 bool read_Present();
00176
00177 bool read_Shutter();
00178 void write_Shutter( bool val );
00179
00180 bool read_ForceShutterOpen();
00181 void write_ForceShutterOpen( bool val );
00182
00183 bool read_LongCable();
00184 void write_LongCable( bool val );
00185
00186 short read_Mode();
00187 void write_Mode( short val );
00188
00189 short read_TestBits();
00190 void write_TestBits( short val );
00191
00192 short read_Test2Bits();
00193 void write_Test2Bits( short val );
00194
00195 bool read_FastReadout();
00196 void write_FastReadout( bool val );
00197
00198 bool read_UseTrigger();
00199 void write_UseTrigger( bool val );
00200
00201 bool m_HighPriority;
00202
00203 short m_PPRepeat;
00204
00205 short m_DataBits;
00206
00207 bool m_FastShutter;
00208
00209 bool m_GuiderRelays;
00210
00211 short m_MaxBinX, m_MaxBinY;
00212
00213 double m_MaxExposure;
00214 double m_MinExposure;
00215
00216 double m_Timeout;
00217
00219
00220
00221
00222
00223 double read_CoolerSetPoint();
00224 void write_CoolerSetPoint( double val );
00225
00226 Camera_CoolerStatus read_CoolerStatus();
00227
00228 Camera_CoolerMode read_CoolerMode();
00229 void write_CoolerMode( Camera_CoolerMode val );
00230
00231 double read_Temperature();
00232
00233 bool m_TempControl;
00234 short m_TempCalibration;
00235 double m_TempScale;
00236
00238
00239
00240
00241 short m_BinX, m_BinY;
00242 short m_StartX, m_StartY;
00243 short m_NumX, m_NumY;
00244
00246
00247
00248
00249 short m_Columns, m_Rows;
00250 short m_ImgColumns, m_ImgRows;
00251 short m_SkipC, m_SkipR;
00252 short m_HFlush, m_VFlush;
00253 short m_BIC, m_BIR;
00254
00256
00257
00258 char m_Sensor[ 256 ];
00259 bool m_Color;
00260 double m_Noise;
00261 double m_Gain;
00262 double m_PixelXSize;
00263 double m_PixelYSize;
00264
00266
00267
00268
00269 void Reset();
00270
00271
00272
00273
00274
00275
00276
00277
00278
00279
00280 void Flush( short Rows = -1 );
00281
00282
00283 void AuxOutput( unsigned char val );
00284
00285
00286 void RegWrite( short reg, unsigned short val );
00287
00288
00289 void RegRead( short reg, unsigned short& val );
00290
00291
00292
00293 bool FilterHome();
00294
00295
00296 void FilterSet( short Slot );
00297
00299
00300
00301
00302
00303
00304
00305 bool Expose( double Duration, bool Light );
00306
00307
00308
00309 virtual bool GetImage( unsigned short* pImageData, short& xSize, short& ySize );
00310
00311
00312
00314
00315
00316
00317
00318
00319 bool DigitizeLine();
00320
00321
00322 bool GetLine( unsigned short* pLineData, short& xSize );
00323
00324
00325
00326
00328
00329
00330
00331
00332 bool Snap( double Duration, bool Light, unsigned short* pImageData, short& xSize, short& ySize );
00333
00334
00335
00336
00337 bool m_TDI;
00338
00339 bool m_WaitingforTrigger;
00340 bool m_WaitingforImage;
00341 bool m_WaitingforLine;
00342
00343 short m_RegisterOffset;
00344
00345 short m_FilterPosition;
00346 short m_FilterStepPos;
00347
00348 bool m_Shutter;
00349 Camera_Status m_Status;
00350
00351 Camera_Interface m_Interface;
00352
00353
00354
00355
00356 Camera_SensorType m_SensorType;
00357
00358
00359 Camera_CoolerStatus m_CoolerStatus;
00360 unsigned int m_IRQMask;
00361
00362
00363
00364
00365
00366
00367
00368
00369
00370 short m_ExposureBinX, m_ExposureBinY;
00371 short m_ExposureStartX, m_ExposureStartY;
00372 short m_ExposureNumX, m_ExposureNumY;
00373 short m_ExposureColumns, m_ExposureRows;
00374 short m_ExposureSkipC, m_ExposureSkipR;
00375 short m_ExposureHFlush, m_ExposureVFlush;
00376 short m_ExposureBIC, m_ExposureBIR;
00377 unsigned short m_ExposureAIC;
00378 unsigned short m_ExposureRemainingLines;
00379 unsigned short m_ExposureAIR;
00380
00382
00383 unsigned short m_RegShadow[ NumWriteRegisters ];
00384
00385 unsigned short m_FastShutterBits_Mode;
00386 unsigned short m_FastShutterBits_Test;
00387
00389
00390
00391 void LoadLineCounter( unsigned short rows );
00392 void LoadColumnLayout( unsigned short aic, unsigned short bic, unsigned short pixels );
00393 void LoadTimerAndBinning( double Duration, unsigned short HBin, unsigned short VBin );
00394
00395 void StartFlushing();
00396 void StopFlushing();
00397
00398 void InitDefaults();
00399 #ifndef WITHPPI
00400 long ReadImage(short unsigned int *);
00401 long InternalReadLine(bool, long int, long int, unsigned short *);
00402 #endif
00403
00404 private:
00405 unsigned short m_BaseAddressp2;
00406 unsigned int saveIRQS;
00407 int fileHandle;
00408 #ifdef WITHPPI
00409 inline void RegisterSelect( unsigned short reg );
00410 inline unsigned short INPW();
00411 inline void OUTPW( unsigned short val );
00412 #endif
00413
00414 };
00415
00416 #endif // !defined(AFX_CAMERAIO_H__A2882C82_7CFB_11D4_9155_0060676644C1__INCLUDED_)