libapogee
3.0.2865
|
00001 00014 #ifndef APOGEECAM_INCLUDE_H__ 00015 #define APOGEECAM_INCLUDE_H__ 00016 00017 #include <string> 00018 #include <vector> 00019 #include <stdint.h> 00020 00021 00022 #ifdef WIN_OS 00023 #include <memory> 00024 #else 00025 #include <tr1/memory> 00026 #endif 00027 00028 #include "CameraStatusRegs.h" 00029 #include "CameraInfo.h" 00030 #include "DefDllExport.h" 00031 00032 00033 00034 class PlatformData; 00035 class CApnCamData; 00036 class CameraIo; 00037 class ModeFsm; 00038 class CcdAcqParams; 00039 00040 class DLL_EXPORT ApogeeCam 00041 { 00042 public: 00043 00047 virtual ~ApogeeCam(); 00048 00057 void Reset(); 00058 00064 uint16_t ReadReg( uint16_t reg ); 00065 00071 void WriteReg( uint16_t reg, uint16_t value); 00072 00079 void SetRoiNumRows( uint16_t rows ); 00080 00088 void SetRoiNumCols( uint16_t cols ); 00089 00094 uint16_t GetRoiNumRows(); 00095 00100 uint16_t GetRoiNumCols(); 00101 00107 void SetRoiStartRow( uint16_t row ); 00108 00114 void SetRoiStartCol( uint16_t col ); 00115 00120 uint16_t GetRoiStartRow(); 00121 00126 uint16_t GetRoiStartCol(); 00127 00135 void SetRoiBinRow( uint16_t bin ); 00136 00141 uint16_t GetRoiBinRow(); 00142 00150 void SetRoiBinCol( uint16_t bin ); 00151 00156 uint16_t GetRoiBinCol(); 00157 00162 uint16_t GetFirmwareRev(); 00163 00170 void SetImageCount( uint16_t count ); 00171 00176 uint16_t GetImageCount(); 00177 00184 uint16_t GetImgSequenceCount(); 00185 00193 void SetSequenceDelay( double delay ); 00194 00200 double GetSequenceDelay(); 00201 00210 void SetVariableSequenceDelay( bool variable ); 00211 00216 bool GetVariableSequenceDelay(); 00217 00225 void SetTdiRate( double TdiRate ); 00226 00231 double GetTdiRate(); 00232 00241 void SetTdiRows( uint16_t TdiRows ); 00242 00247 uint16_t GetTdiRows(); 00248 00255 uint16_t GetTdiCounter(); 00256 00266 void SetTdiBinningRows( uint16_t bin ); 00267 00272 uint16_t GetTdiBinningRows(); 00273 00282 void SetKineticsSectionHeight( uint16_t height ); 00283 00288 uint16_t GetKineticsSectionHeight(); 00289 00297 void SetKineticsSections( uint16_t sections ); 00298 00303 uint16_t GetKineticsSections(); 00304 00313 void SetKineticsShiftInterval( double interval ); 00314 00319 double GetKineticsShiftInterval(); 00320 00330 void SetShutterStrobePosition( double position ); 00331 00336 double GetShutterStrobePosition(); 00337 00346 void SetShutterStrobePeriod( double period ); 00347 00352 double GetShutterStrobePeriod(); 00353 00364 void SetShutterCloseDelay( double delay ); 00365 00370 double GetShutterCloseDelay(); 00371 00382 void SetCoolerBackoffPoint( double point ); 00383 00388 double GetCoolerBackoffPoint(); 00389 00400 void SetCoolerSetPoint( double point ); 00401 00406 double GetCoolerSetPoint(); 00407 00412 Apg::CameraMode GetCameraMode(); 00413 00420 void SetCameraMode( Apg::CameraMode mode ); 00421 00433 void SetFastSequence( bool TurnOn ); 00434 00439 bool IsFastSequenceOn(); 00440 00453 void SetBulkDownload( bool TurnOn ); 00454 00459 bool IsBulkDownloadOn(); 00460 00485 void SetIoPortAssignment( uint16_t assignment ); 00486 00491 uint16_t GetIoPortAssignment(); 00492 00497 void SetIoPortBlankingBits( uint16_t blankingBits ); 00498 00503 uint16_t GetIoPortBlankingBits(); 00504 00518 void SetIoPortDirection( uint16_t direction ); 00519 00524 uint16_t GetIoPortDirection(); 00525 00534 void SetIoPortData( uint16_t data ); 00535 00540 uint16_t GetIoPortData(); 00541 00549 void SetPreFlash( bool TurnOn ) { m_IsPreFlashOn = TurnOn; } 00550 00555 bool GetPreFlash() { return m_IsPreFlashOn; } 00556 00565 void SetExternalTrigger( bool TurnOn, Apg::TriggerMode trigMode, 00566 Apg::TriggerType trigType ); 00567 00572 bool IsTriggerNormEachOn(); 00573 00578 bool IsTriggerNormGroupOn(); 00579 00584 bool IsTriggerTdiKinEachOn(); 00585 00590 bool IsTriggerTdiKinGroupOn(); 00591 00596 bool IsTriggerExternalShutterOn(); 00597 00602 bool IsTriggerExternalReadoutOn(); 00603 00609 void SetShutterState( Apg::ShutterState state ); 00610 00615 Apg::ShutterState GetShutterState(); 00616 00622 bool IsShutterForcedOpen(); 00623 00629 bool IsShutterForcedClosed(); 00630 00635 bool IsShutterOpen(); 00636 00643 void SetShutterAmpCtrl( bool TurnOn ); 00644 00650 bool IsShutterAmpCtrlOn(); 00651 00657 void SetCooler( bool TurnOn ); 00658 00663 Apg::CoolerStatus GetCoolerStatus(); 00664 00669 bool IsCoolerOn(); 00670 00675 double GetTempCcd(); 00676 00685 void SetCcdAdcResolution(Apg::Resolution res); 00686 00691 Apg::Resolution GetCcdAdcResolution(); 00692 00701 void SetCcdAdcSpeed(Apg::AdcSpeed speed); 00702 00707 Apg::AdcSpeed GetCcdAdcSpeed(); 00708 00713 uint16_t GetMaxBinCols(); 00714 00719 uint16_t GetMaxBinRows(); 00720 00726 uint16_t GetMaxImgCols(); 00727 00733 uint16_t GetMaxImgRows(); 00734 00740 uint16_t GetTotalRows(); 00741 00747 uint16_t GetTotalCols(); 00748 00755 uint16_t GetNumOverscanCols(); 00756 00761 bool IsInterline(); 00762 00767 CamModel::PlatformType GetPlatformType(); 00768 00774 void SetLedAState( Apg::LedState state ); 00775 00780 Apg::LedState GetLedAState(); 00781 00787 void SetLedBState( Apg::LedState state ); 00788 00793 Apg::LedState GetLedBState(); 00794 00800 void SetLedMode( Apg::LedMode mode ); 00801 00806 Apg::LedMode GetLedMode(); 00807 00813 std::string GetInfo(); 00814 00819 std::string GetModel(); 00820 00825 std::string GetSensor(); 00826 00839 void SetFlushCommands( bool Disable ); 00840 00845 bool AreFlushCmdsDisabled(); 00846 00858 void SetPostExposeFlushing( bool Disable ); 00859 00864 bool IsPostExposeFlushingDisabled(); 00865 00870 double GetPixelWidth(); 00871 00876 double GetPixelHeight(); 00877 00882 double GetMinExposureTime(); 00883 00888 double GetMaxExposureTime(); 00889 00894 bool IsColor(); 00895 00900 bool IsCoolingSupported(); 00901 00906 bool IsCoolingRegulated(); 00907 00912 double GetInputVoltage(); 00913 00918 CamModel::InterfaceType GetInterfaceType(); 00919 00927 void GetUsbVendorInfo( uint16_t & VendorId, 00928 uint16_t & ProductId, uint16_t & DeviceId); 00929 00934 bool IsCCD(); 00935 00944 void PauseTimer( bool TurnOn ); 00945 00951 bool IsSerialASupported(); 00952 00958 bool IsSerialBSupported(); 00959 00969 void SetFlushBinningRows( uint16_t bin ); 00970 00975 uint16_t GetFlushBinningRows(); 00976 00981 bool IsOverscanDigitized(); 00982 00990 void SetDigitizeOverscan( const bool TurnOn ); 00991 00999 void SetAdcGain( uint16_t gain, int32_t ad, int32_t channel ); 01000 01007 uint16_t GetAdcGain( int32_t ad, int32_t channel ); 01008 01016 void SetAdcOffset( uint16_t offset, int32_t ad, int32_t channel ); 01017 01024 uint16_t GetAdcOffset( int32_t ad, int32_t channel ); 01025 01029 bool IsInitialized() { return m_IsInitialized; } 01030 01034 bool IsConnected() { return m_IsConnected; } 01035 01042 void SetAdSimMode( bool TurnOn ); 01043 01048 bool IsAdSimModeOn(); 01049 01057 void SetLedBrightness( double PercentIntensity ); 01058 01065 double GetLedBrightness(); 01066 01071 std::string GetDriverVersion(); 01072 01077 std::string GetUsbFirmwareVersion(); 01078 01083 std::string GetSerialNumber(); 01084 01085 // ****** PURE VIRTUAL INTERFACE ******** 01086 01098 virtual void OpenConnection( const std::string & ioType, 01099 const std::string & DeviceAddr, 01100 const uint16_t FirmwareRev, 01101 const uint16_t Id ) = 0; 01102 01110 virtual void CloseConnection() = 0; 01111 01117 virtual void Init() = 0; 01118 01129 virtual void StartExposure( double Duration, bool IsLight ) = 0; 01130 01135 virtual CameraStatusRegs GetStatus() = 0; 01136 01141 virtual Apg::Status GetImagingStatus() = 0; 01142 01148 virtual void GetImage( std::vector<uint16_t> & out ) = 0; 01149 01159 virtual void StopExposure( bool Digitize ) = 0; 01160 01165 virtual uint32_t GetAvailableMemory() = 0; 01166 01171 virtual int32_t GetNumAds() = 0; 01172 01177 virtual int32_t GetNumAdChannels() = 0; 01178 01184 virtual double GetCoolerDrive() = 0; 01185 01196 virtual void SetFanMode( Apg::FanMode mode, bool PreCondCheck = true ) = 0; 01197 01202 virtual Apg::FanMode GetFanMode() = 0; 01203 01210 virtual double GetTempHeatsink() = 0; 01211 01212 protected: 01213 ApogeeCam(CamModel::PlatformType platform) ; 01214 01215 void VerifyFrmwrRev(); 01216 void LogConnectAndDisconnect( bool Connect ); 01217 01218 void ExectuePreFlash(); 01219 void SetExpsoureTime( double Duration ); 01220 void IssueExposeCmd( bool IsLight ); 01221 01222 void IsThereAStatusError( uint16_t statusReg ); 01223 01224 bool IsImgDone( const CameraStatusRegs & statusObj); 01225 Apg::Status LogAndReturnStatus( Apg::Status status, 01226 const CameraStatusRegs & statusObj); 01227 01228 void SupsendCooler( bool & resume ); 01229 void ResumeCooler(); 01230 void WaitForCoolerSuspendBit( const uint16_t mask, const bool IsHigh ); 01231 01232 void InitShutterCloseDelay(); 01233 01234 void StopExposureModeNorm( bool Digitize ); 01235 void Reset(bool Flush); 01236 01237 void HardStopExposure( const std::string & msg ); 01238 void GrabImageAndThrowItAway(); 01239 01240 void AdcParamCheck( const int32_t ad, 01241 const int32_t channel, const std::string & fxName ); 01242 01243 void SetNumAdOutputs( const uint16_t num ); 01244 01245 bool CheckAndWaitForStatus( Apg::Status desired, Apg::Status & acutal ); 01246 void CancelExposureNoThrow(); 01247 double DefaultGetTempHeatsink(); 01248 01249 void DefaultInit(); 01250 void ClearAllRegisters(); 01251 void DefaultCfgCamFromId( uint16_t CameraId ); 01252 void DefaultSetFanMode( Apg::FanMode mode, bool PreCondCheck ); 01253 Apg::FanMode DefaultGetFanMode(); 01254 void DefaultCloseConnection(); 01255 01256 // ****** PURE VIRTUAL INTERFACE ******** 01257 virtual void CfgCamFromId( uint16_t CameraId ) = 0; 01258 virtual void ExposureAndGetImgRC(uint16_t & r, uint16_t & c) = 0; 01259 virtual uint16_t ExposureZ() = 0; 01260 virtual uint16_t GetImageZ() = 0; 01261 virtual uint16_t GetIlluminationMask() = 0; 01262 virtual void FixImgFromCamera( const std::vector<uint16_t> & data, 01263 std::vector<uint16_t> & out, int32_t rows, int32_t cols) = 0; 01264 01265 //this code removes vc++ compiler warning C4251 01266 //from http://www.unknownroad.com/rtfm/VisualStudio/warningC4251.html 01267 #ifdef WIN_OS 01268 template class DLL_EXPORT std::tr1::shared_ptr<CameraIo>; 01269 template class DLL_EXPORT std::tr1::shared_ptr<PlatformData>; 01270 template class DLL_EXPORT std::tr1::shared_ptr<CApnCamData>; 01271 template class DLL_EXPORT std::tr1::shared_ptr<ModeFsm>; 01272 template class DLL_EXPORT std::tr1::shared_ptr<CcdAcqParams>; 01273 #endif 01274 01275 std::tr1::shared_ptr<CameraIo> m_CamIo; 01276 std::tr1::shared_ptr<PlatformData> m_CameraConsts; 01277 std::tr1::shared_ptr<CApnCamData> m_CamCfgData; 01278 std::tr1::shared_ptr<ModeFsm> m_CamMode; 01279 std::tr1::shared_ptr<CcdAcqParams> m_CcdAcqSettings; 01280 01281 01282 01283 CamModel::PlatformType m_PlatformType; 01284 const std::string m_fileName; 01285 uint16_t m_FirmwareVersion; 01286 uint16_t m_Id; 01287 uint16_t m_NumImgsDownloaded; 01288 bool m_ImageInProgress; 01289 bool m_IsPreFlashOn; 01290 bool m_IsInitialized; 01291 bool m_IsConnected; 01292 01293 private: 01294 01295 //disabling the copy ctor and assignment operator 01296 //generated by the compiler - don't want them 01297 //Effective C++ Item 6 01298 ApogeeCam(const ApogeeCam&); 01299 ApogeeCam& operator=(ApogeeCam&); 01300 }; 01301 01302 #endif