• Skip to content
  • Skip to link menu
KDE 3.5 API Reference
  • KDE API Reference
  • API Reference
  • Sitemap
  • Contact Us
 

kstars

CameraIO_Linux.h

Go to the documentation of this file.
00001 // CameraIO.h: interface for the CCameraIO class.
00002 //
00003 // Copyright (c) 2000 Apogee Instruments Inc.
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 // Number of write only registers
00028 const long NumWriteRegisters = 8;
00029 
00030 const long RegISA_Command = 0x000;          // Register 1 in ISA firmware
00031 const long Reg_Command = 0;                 // Register 1 shadow
00032 const unsigned short RegBit_TDIMode = 0x1;          // Bit 0
00033 const unsigned short RegBit_StartTimer = 0x2;       // Bit 1
00034 const unsigned short RegBit_ShutterOverride = 0x4;  // Bit 2
00035 const unsigned short RegBit_ResetSystem = 0x8;      // Bit 3
00036 const unsigned short RegBit_FIFOCache = 0x10;       // Bit 4
00037 const unsigned short RegBit_TriggerEnable = 0x20;   // Bit 5
00038 const unsigned short RegBit_StopFlushing = 0x40;    // Bit 6
00039 const unsigned short RegBit_ShutterEnable = 0x80;   // Bit 7
00040 const unsigned short RegBit_CoolerShutdown = 0x100; // Bit 8
00041 const unsigned short RegBit_DoneReading = 0x200;    // Bit 9
00042 const unsigned short RegBit_TimerLoad = 0x400;      // Bit 10
00043 const unsigned short RegBit_StartNextLine = 0x800;  // Bit 11
00044 const unsigned short RegBit_StartFlushing = 0x1000; // Bit 12
00045 const unsigned short RegBit_Focus = 0x2000;         // Bit 13
00046 const unsigned short RegBit_CableLength = 0x4000;   // Bit 14
00047 const unsigned short RegBit_CoolerEnable = 0x8000;  // Bit 15
00048 
00049 const long RegISA_Timer = 0x002;            // Register 2 in ISA firmware
00050 const long Reg_Timer = 1;                   // Register 2 shadow
00051 const unsigned short RegBitShift_Timer = 0;         // Bit 0
00052 const unsigned short RegBitMask_Timer = 0xFFFF;     // 16 bits
00053 
00054 const long RegISA_VBinning = 0x004;         // Register 3 in ISA firmware
00055 const long Reg_VBinning = 2;                // Register 3 shadow
00056 const unsigned short RegBitShift_Timer2 = 0;        // Bit 0
00057 const unsigned short RegBitMask_Timer2 = 0xF;       // 4 bits
00058 const unsigned short RegBitShift_VBinning = 0x8;    // Bit 8
00059 const unsigned short RegBitMask_VBinning = 0xFF;    // 8 bits
00060 
00061 const long RegISA_AICCounter = 0x006;       // Register 4 in ISA firmware
00062 const long Reg_AICCounter = 3;              // Register 4 shadow
00063 const unsigned short RegBitShift_AICCounter = 0;    // Bit 0
00064 const unsigned short RegBitMask_AICCounter = 0xFFF; // 12 bits
00065 const unsigned short RegBitShift_Test2 = 0xC;       // Bit 12
00066 const unsigned short RegBitMask_Test2 = 0xF;        // 4 bits
00067 
00068 const long RegISA_TempSetPoint = 0x008;     // Register 5 in ISA firmware
00069 const long Reg_TempSetPoint = 4;            // Register 5 shadow
00070 const unsigned short RegBitShift_TempSetPoint = 0;  // Bit 0
00071 const unsigned short RegBitMask_TempSetPoint = 0xFF;// 8 bits
00072 const unsigned short RegBitShift_PortControl = 0x8; // Bit 8
00073 const unsigned short RegBitMask_PortControl = 0xFF; // 8 bits
00074 
00075 const long RegISA_PixelCounter = 0x00a;     // Register 6 in ISA firmware
00076 const long Reg_PixelCounter = 5;            // Register 6 shadow
00077 const unsigned short RegBitShift_PixelCounter = 0;      // Bit 0
00078 const unsigned short RegBitMask_PixelCounter = 0xFFF;   // 12 bits
00079 const unsigned short RegBitShift_HBinning = 0xC;        // Bit 12
00080 const unsigned short RegBitMask_HBinning = 0x7;         // 3 bits
00081 const unsigned short RegBit_LoopLock = 0x8000;          // Bit 15
00082 
00083 const long RegISA_LineCounter = 0x00c;      // Register 7 in ISA firmware
00084 const long Reg_LineCounter = 6;             // Register 7 shadow
00085 const unsigned short RegBitShift_LineCounter = 0;       // Bit 0
00086 const unsigned short RegBitMask_LineCounter = 0xFFF;    // 12 bits
00087 const unsigned short RegBitShift_Mode = 0xC;            // Bit 12
00088 const unsigned short RegBitMask_Mode = 0xF;             // 4 bits
00089 
00090 const long RegISA_BICCounter = 0x00e;       // Register 8 in ISA firmware
00091 const long Reg_BICCounter = 7;              // Register 8 shadow
00092 const unsigned short RegBitShift_BICCounter = 0;    // Bit 0
00093 const unsigned short RegBitMask_BICCounter = 0xFFF; // 12 bits
00094 const unsigned short RegBitShift_Test = 0xC;        // Bit 12
00095 const unsigned short RegBitMask_Test = 0xF;         // 4 bits
00096 
00097 const long RegISA_ImageData = 0x000;        // Register 9 in ISA firmware
00098 const long Reg_ImageData = 8;               // Register 9
00099 const unsigned short RegBitShift_ImageData = 0;     // Bit 0
00100 const unsigned short RegBitMask_ImageData = 0xFFFF; // 16 bits
00101 
00102 const long RegISA_TempData = 0x002;     // Register 10 in ISA firmware
00103 const long Reg_TempData = 9;                // Register 10
00104 const unsigned short RegBitShift_TempData = 0;  // Bit 0
00105 const unsigned short RegBitMask_TempData = 0xFF;    // 8 bits
00106 
00107 const long RegISA_Status = 0x006;           // Register 11 in firmware
00108 const long Reg_Status = 10;                 // Register 11
00109 const unsigned short RegBit_Exposing = 0x1;         // Bit 0
00110 const unsigned short RegBit_LineDone = 0x2;         // Bit 1
00111 const unsigned short RegBit_CacheReadOK = 0x4;      // Bit 2
00112 const unsigned short RegBit_TempAtMin = 0x10;       // Bit 4
00113 const unsigned short RegBit_TempAtMax = 0x20;       // Bit 5
00114 const unsigned short RegBit_ShutdownComplete = 0x40;// Bit 6
00115 const unsigned short RegBit_TempAtSetPoint = 0x80;  // Bit 7
00116 const unsigned short RegBit_GotTrigger = 0x400;     // Bit 10
00117 const unsigned short RegBit_FrameDone = 0x800;      // Bit 11
00118 const unsigned short RegBit_LoopbackTest = 0x8000;  // Bit 15
00119 
00120 const long RegISA_CommandReadback = 0x008;  // Register 12 in ISA firmware
00121 const long Reg_CommandReadback = 11;        // Register 12
00122 // Use RegBit offsets from Reg_Command
00123 
00124 const long RegPCI_Command               = 0x000;        // Register 1 in PCI firmware
00125 const long RegPCI_CommandRead   = 0x020;
00126 const long RegPCI_Timer                 = 0x004;        // Register 2 in PCI firmware
00127 const long RegPCI_TimerRead             = 0x024;
00128 const long RegPCI_VBinning              = 0x008;        // Register 3 in PCI firmware
00129 const long RegPCI_VBinningRead  = 0x028;
00130 const long RegPCI_AICCounter            = 0x00C;        // Register 4 in PCI firmware
00131 const long RegPCI_AICCounterRead        = 0x02C;
00132 const long RegPCI_TempSetPoint          = 0x010;        // Register 5 in PCI firmware
00133 const long RegPCI_TempSetPointRead      = 0x030;
00134 const long RegPCI_PixelCounter          = 0x014;        // Register 6 in PCI firmware
00135 const long RegPCI_PixelCounterRead      = 0x034;
00136 const long RegPCI_LineCounter           = 0x018;        // Register 7 in PCI firmware
00137 const long RegPCI_LineCounterRead       = 0x038;
00138 const long RegPCI_BICCounter            = 0x01C;        // Register 8 in PCI firmware
00139 const long RegPCI_BICCounterRead        = 0x03C;
00140 const long RegPCI_ImageData = 0x000;            // Register 9 in PCI firmware
00141 const long RegPCI_TempData = 0x004;                     // Register 10 in PCI firmware
00142 const long RegPCI_Status = 0x00C;                       // Register 11 in firmware
00143 const long RegPCI_CommandReadback = 0x010;      // Register 12 in PCI firmware
00144 
00145 
00146 
00147 class CCameraIO
00148 {
00149 public:
00150 
00151     CCameraIO();
00152     virtual ~CCameraIO();
00153 
00155     // Low level read write methods - Overridables
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     // Camera Settings
00163 
00164     Camera_Status read_Status();        // Current camera state
00165                                         // <0: error codes
00166                                         // 0: idle
00167                                         // 1: flushing
00168                                         // 2: waiting for trigger
00169                                         // 3: exposing
00170                                         // 4: reading
00171                                         // 5: downloading
00172                                         // 6: line ready
00173                                         // 7: image ready
00174 
00175     bool read_Present();                // True if camera is present, false otherwise.
00176     
00177     bool read_Shutter();                // Current shutter state, true = open, false = closed.
00178     void write_Shutter( bool val );
00179     
00180     bool read_ForceShutterOpen();               // True: Forces shutter permanently open. False: allows
00181     void write_ForceShutterOpen( bool val );    // normal shutter operation.
00182 
00183     bool read_LongCable();              // Long cable mode.
00184     void write_LongCable( bool val );           
00185 
00186     short read_Mode();                  // First four bits map to Mode bits used for
00187     void write_Mode( short val );       // special functions or camera configurations.
00188 
00189     short read_TestBits();              // First four bits to Test bits used for
00190     void write_TestBits( short val );       // troubleshooting.
00191     
00192     short read_Test2Bits();             // First four bits map to Test2 bits used for
00193     void write_Test2Bits( short val );  // special functions or camera configurations.
00194 
00195     bool read_FastReadout();                // Fast readout mode (used for focusing).
00196     void write_FastReadout( bool val ); // True means fast focus is on          
00197 
00198     bool read_UseTrigger();             // Triggered exposure mode.
00199     void write_UseTrigger( bool val );  // True means triggered exposure is on.
00200 
00201     bool m_HighPriority;        // Bost thread priority level during download
00202 
00203     short m_PPRepeat;           // Delay used on parallel port systems.
00204     
00205     short m_DataBits;           // Digitization resolution, 8 - 18.
00206 
00207     bool m_FastShutter;         // Capable of 0.001 sec exposure resolution
00208 
00209     bool m_GuiderRelays;        // Capable of outputing autoguider signals
00210 
00211     short m_MaxBinX, m_MaxBinY; // Maximum binning factors  
00212     
00213     double m_MaxExposure;   // Maximum exposure length
00214     double m_MinExposure;   // Minimum exposure length
00215 
00216     double m_Timeout;       // camera polling timeout value
00217 
00219     // Cooler Settings
00220     // N.B. DAC units = ( m_TempScale * CoolerSetPoint (deg. C ) ) + m_TempCalibration;
00221     // N.B. Temperature (deg. C) = (DAC units - m_TempCalibration) / m_TempScale
00222     
00223     double read_CoolerSetPoint();               // Returns/sets setpoint temperature in degrees
00224     void write_CoolerSetPoint( double val );    // Celcius.
00225 
00226     Camera_CoolerStatus read_CoolerStatus();    // Returns current cooler status
00227 
00228     Camera_CoolerMode read_CoolerMode();        // Returns/sets current cooler operation mode.
00229     void write_CoolerMode( Camera_CoolerMode val );
00230 
00231     double read_Temperature();  // Current temperature in degrees Celcius.
00232     
00233     bool m_TempControl;         // Temperature can be externally controlled
00234     short m_TempCalibration;    // Temperature calibration factor.
00235     double m_TempScale;         // Temperature scaling factor.
00236 
00238     // Exposure Settings
00239     // The following variables are latched in Expose method, until next Reset or GetImage
00240 
00241     short m_BinX, m_BinY;       // Horizontal and vertical binning.
00242     short m_StartX, m_StartY;   // Zero based subframe start position in unbinned pixels.
00243     short m_NumX, m_NumY;       // Subframe size in binned pixels.
00244 
00246     // Geometry Settings
00247     // The following variables are latched in Expose method, until next Reset or GetImage
00248     
00249     short m_Columns, m_Rows;        // Total columns/rows on CCD (physical).
00250     short m_ImgColumns, m_ImgRows;  // Unbinned columns/rows in imaging area
00251     short m_SkipC, m_SkipR;         // Deleted data columns/rows not to be displayed or saved
00252     short m_HFlush, m_VFlush;       // Horizontal/Vertical flush binning.
00253     short m_BIC, m_BIR;             // Before Image Column/Row count (dark non-imaging pixels).
00254     
00256     // CCD Settings
00257 
00258     char m_Sensor[ 256 ];   // Sensor model installed in camera (i.e. Sensor = SITe 502).
00259     bool m_Color;           // Sensor has color dyes
00260     double m_Noise;         // Read out noise in e-.
00261     double m_Gain;          // Gain in e-/ADU units.
00262     double m_PixelXSize;    // Size of pixel in X direction in micrometers.
00263     double m_PixelYSize;    // Size of pixel in Y direction in micrometers.
00264 
00266     // System methods
00267 
00268     // Resets camera to idle state, will terminate current exposure.
00269     void Reset();
00270 
00271     // Mask user requested set of IRQS
00272 //  void MaskIrqs();
00273 
00274     // Restore default IRQ mask
00275 //  void UnmaskIrqs();
00276 
00277     // Starts flushing the camera (which should be the normal idle state)
00278     // If Rows is non-negative, only the specified number of rows are flushed,
00279     // in which case the method will return only when flushing is completed.
00280     void Flush( short Rows = -1 );
00281 
00282     // Output byte to auxillary output port (e.g. for driving guider relays).
00283     void AuxOutput( unsigned char val );
00284 
00285     // Write a 16 bit value to register 1 to 8.
00286     void RegWrite( short reg, unsigned short val );
00287 
00288     // Read a 16 bit value from register 9 to 12.
00289     void RegRead( short reg, unsigned short& val );
00290 
00291     // Move the filterwheel to the home position - failure indicates no filterwheel
00292     //attached or broken filterwheel
00293     bool FilterHome();
00294     
00295     // Move filterwheel to the given slot
00296     void FilterSet( short Slot );
00297 
00299     // Normal exposure methods
00300 
00301     // The Duration parameter is the exposure time in seconds. The Light parameter controls
00302     // the status of the shutter during the exposure, Light = True opens the shutter, Light
00303     // = False closes the shutter. Returns immediately after invocation, poll the CameraStatus
00304     // property to determine the start time of a triggered exposure and the end of an exposure.
00305     bool Expose( double Duration, bool Light );
00306 
00307     // Returns the pImageData parameter which is a pointer to unsigned short data with NumX*NumY
00308     // elements.  Can be overridden if necessary
00309     virtual bool GetImage( unsigned short* pImageData, short& xSize, short& ySize );
00310 
00311     /*virtual bool BufferImage(char *bufferName );*/
00312 
00314     // Drift scan methods
00315 
00316     // Begins clocking and digitization of a single line of data begining with a vertical clock
00317     // sequence and ending with a buffer full of line data. Poll the CameraStatus property to
00318     // determine when the data is ready for download.
00319     bool DigitizeLine();
00320 
00321     // Returns the pLineData parameter which is a pointer to unsigned short data with NumX elements.
00322     bool GetLine( unsigned short* pLineData, short& xSize );
00323 
00324     /* TODO enable this back after removing some deps */
00325     /*bool BufferDriftScan(char *bufferName, int delay, int rowCount, int nblock , int npipe);*/
00326 
00328     // Easy to use methods
00329 
00330     // Combination of the Expose and GetImage methods. Blocks calling thread for duration
00331     // of exposure and readout.
00332     bool Snap( double Duration, bool Light, unsigned short* pImageData, short& xSize, short& ySize );
00333 
00334 // Internal variables to keep track of things that can not be read from the firmware
00335 // directly, or are a combination of firmware setting
00336 
00337     bool m_TDI;                 // Time drift integration mode
00338 
00339     bool m_WaitingforTrigger;   // camera is waiting for external trigger
00340     bool m_WaitingforImage;     // camera is exposing and wiating for an to available
00341     bool m_WaitingforLine;      // camera is clocking and digitizing a row of data
00342 
00343     short m_RegisterOffset;     // Offset from base address used in parallel port systems.
00344     
00345     short m_FilterPosition;     // Current filter position
00346     short m_FilterStepPos;      // Current filter position in our internal array
00347 
00348     bool m_Shutter;             // Last known shutter state
00349     Camera_Status m_Status;     // Last known camera status
00350 
00351     Camera_Interface m_Interface;       // String acronyms may be used in INI file.
00352                                         // 0 or ISA: Industry Standard Architecture bus
00353                                         // 1 or PPI: Parallel Port Interface 
00354                                         // 2 or PCI: Peripheral Component Interface
00355     
00356     Camera_SensorType m_SensorType;     // 0 or CCD: Charge Coupled Device
00357                                         // 1 or CMOS: Complementary Metal-Oxide-Silicon
00358 
00359     Camera_CoolerStatus m_CoolerStatus;     // Last known cooler status.
00360     unsigned int m_IRQMask;         // Set of IRQs masked on user request                                       // 0: Off
00361                                             // 1: Ramping to set point
00362                                             // 2: Correcting
00363                                             // 3: Ramping to ambient
00364                                             // 4: At ambient
00365                                             // 5: Max cooling limit
00366                                             // 6: Min cooling limit
00367                                             // 7: At set point
00368 
00369     // Latched public variables used during Exposure..GetImage sequence
00370     short m_ExposureBinX, m_ExposureBinY;       // Horizontal and vertical binning.
00371     short m_ExposureStartX, m_ExposureStartY;   // Subframe start position in unbinned pixels.
00372     short m_ExposureNumX, m_ExposureNumY;       // Subframe size in binned pixels.
00373     short m_ExposureColumns, m_ExposureRows;    // Total columns/rows on CCD (physical).
00374     short m_ExposureSkipC, m_ExposureSkipR;     // Deleted data columns/rows not to be displayed or saved to disk.
00375     short m_ExposureHFlush, m_ExposureVFlush;   // Horizontal/Vertical flush binning.
00376     short m_ExposureBIC, m_ExposureBIR;         // Before Image Column/Row count (dark non-imaging pixels).
00377     unsigned short m_ExposureAIC;               // Calculated After Image Column count (dark non-imaging pixels).
00378     unsigned short m_ExposureRemainingLines;    // Number of lines to be clocked out by GetImage
00379     unsigned short m_ExposureAIR;               // Number of lines to be flushed after GetImage
00380 
00382     // Write register shadow variables
00383     unsigned short m_RegShadow[ NumWriteRegisters ];
00384     
00385     unsigned short m_FastShutterBits_Mode;      // Mask to enable fast shutter mode
00386     unsigned short m_FastShutterBits_Test;      // Mask to enable fast shutter mode
00387     
00389     // Internal helper routines
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_)

kstars

Skip menu "kstars"
  • Main Page
  • Modules
  • Class Hierarchy
  • Alphabetical List
  • Class List
  • File List
  • Class Members
  • Related Pages

API Reference

Skip menu "API Reference"
  • keduca
  • kstars
Generated for API Reference by doxygen 1.5.9
This website is maintained by Adriaan de Groot and Allen Winter.
KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal