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 Init();
00658
00664 void SetCooler( bool TurnOn );
00665
00670 Apg::CoolerStatus GetCoolerStatus();
00671
00676 bool IsCoolerOn();
00677
00682 double GetTempCcd();
00683
00692 void SetCcdAdcResolution(Apg::Resolution res);
00693
00698 Apg::Resolution GetCcdAdcResolution();
00699
00704 void SetCcdAdcSpeed(Apg::AdcSpeed speed);
00705
00710 Apg::AdcSpeed GetCcdAdcSpeed();
00711
00716 uint16_t GetMaxBinCols();
00717
00722 uint16_t GetMaxBinRows();
00723
00729 uint16_t GetMaxImgCols();
00730
00736 uint16_t GetMaxImgRows();
00737
00743 uint16_t GetTotalRows();
00744
00750 uint16_t GetTotalCols();
00751
00758 uint16_t GetNumOverscanCols();
00759
00764 bool IsInterline();
00765
00770 CamModel::PlatformType GetPlatformType();
00771
00777 void SetLedAState( Apg::LedState state );
00778
00783 Apg::LedState GetLedAState();
00784
00790 void SetLedBState( Apg::LedState state );
00791
00796 Apg::LedState GetLedBState();
00797
00803 void SetLedMode( Apg::LedMode mode );
00804
00809 Apg::LedMode GetLedMode();
00810
00816 std::string GetInfo();
00817
00822 std::string GetModel();
00823
00828 std::string GetSensor();
00829
00842 void SetFlushCommands( bool Disable );
00843
00848 bool AreFlushCmdsDisabled();
00849
00861 void SetPostExposeFlushing( bool Disable );
00862
00867 bool IsPostExposeFlushingDisabled();
00868
00873 double GetPixelWidth();
00874
00879 double GetPixelHeight();
00880
00885 double GetMinExposureTime();
00886
00891 double GetMaxExposureTime();
00892
00897 bool IsColor();
00898
00903 bool IsCoolingSupported();
00904
00909 bool IsCoolingRegulated();
00910
00915 double GetInputVoltage();
00916
00921 CamModel::InterfaceType GetInterfaceType();
00922
00930 void GetUsbVendorInfo( uint16_t & VendorId,
00931 uint16_t & ProductId, uint16_t & DeviceId);
00932
00937 bool IsCCD();
00938
00947 void PauseTimer( bool TurnOn );
00948
00954 bool IsSerialASupported();
00955
00961 bool IsSerialBSupported();
00962
00972 void SetFlushBinningRows( uint16_t bin );
00973
00978 uint16_t GetFlushBinningRows();
00979
00984 bool IsOverscanDigitized();
00985
00993 void SetDigitizeOverscan( const bool TurnOn );
00994
01002 void SetAdcGain( uint16_t gain, int32_t ad, int32_t channel );
01003
01010 uint16_t GetAdcGain( int32_t ad, int32_t channel );
01011
01019 void SetAdcOffset( uint16_t offset, int32_t ad, int32_t channel );
01020
01027 uint16_t GetAdcOffset( int32_t ad, int32_t channel );
01028
01032 bool IsInitialized() { return m_IsInitialized; }
01033
01037 bool IsConnected() { return m_IsConnected; }
01038
01045 void SetAdSimMode( bool TurnOn );
01046
01051 bool IsAdSimModeOn();
01052
01060 void SetLedBrightness( double PercentIntensity );
01061
01068 double GetLedBrightness();
01069
01074 std::string GetDriverVersion();
01075
01080 std::string GetUsbFirmwareVersion();
01081
01086 std::string GetSerialNumber();
01087
01095 void CloseConnection();
01096
01097
01098
01110 virtual void OpenConnection( const std::string & ioType,
01111 const std::string & DeviceAddr,
01112 const uint16_t FirmwareRev,
01113 const uint16_t Id ) = 0;
01114
01125 virtual void StartExposure( double Duration, bool IsLight ) = 0;
01126
01131 virtual CameraStatusRegs GetStatus() = 0;
01132
01137 virtual Apg::Status GetImagingStatus() = 0;
01138
01144 virtual void GetImage( std::vector<uint16_t> & out ) = 0;
01145
01155 virtual void StopExposure( bool Digitize ) = 0;
01156
01161 virtual uint32_t GetAvailableMemory() = 0;
01162
01167 virtual int32_t GetNumAds() = 0;
01168
01173 virtual int32_t GetNumAdChannels() = 0;
01174
01180 virtual double GetCoolerDrive() = 0;
01181
01192 virtual void SetFanMode( Apg::FanMode mode, bool PreCondCheck = true ) = 0;
01193
01198 virtual Apg::FanMode GetFanMode() = 0;
01199
01206 virtual double GetTempHeatsink() = 0;
01207
01208 protected:
01209 ApogeeCam(CamModel::PlatformType platform) ;
01210
01211 void VerifyFrmwrRev();
01212 void LogConnectAndDisconnect( bool Connect );
01213
01214 void ExectuePreFlash();
01215 void SetExpsoureTime( double Duration );
01216 void IssueExposeCmd( bool IsLight );
01217
01218 void IsThereAStatusError( uint16_t statusReg );
01219
01220 bool IsImgDone( const CameraStatusRegs & statusObj);
01221 Apg::Status LogAndReturnStatus( Apg::Status status,
01222 const CameraStatusRegs & statusObj);
01223
01224 void SupsendCooler( bool & resume );
01225 void ResumeCooler();
01226 void WaitForCoolerSuspendBit( const uint16_t mask, const bool IsHigh );
01227
01228 void InitShutterCloseDelay();
01229
01230 void StopExposureModeNorm( bool Digitize );
01231 void Reset(bool Flush);
01232
01233 void HardStopExposure( const std::string & msg );
01234 void GrabImageAndThrowItAway();
01235
01236 void AdcParamCheck( const int32_t ad,
01237 const int32_t channel, const std::string & fxName );
01238
01239 void SetNumAdOutputs( const uint16_t num );
01240
01241 bool CheckAndWaitForStatus( Apg::Status desired, Apg::Status & acutal );
01242 void CancelExposureNoThrow();
01243 double DefaultGetTempHeatsink();
01244
01245
01246 virtual void CfgCamFromId( uint16_t CameraId ) = 0;
01247 virtual void ExposureAndGetImgRC(uint16_t & r, uint16_t & c) = 0;
01248 virtual uint16_t ExposureZ() = 0;
01249 virtual uint16_t GetImageZ() = 0;
01250 virtual uint16_t GetIlluminationMask() = 0;
01251 virtual void FixImgFromCamera( const std::vector<uint16_t> & data,
01252 std::vector<uint16_t> & out, int32_t rows, int32_t cols) = 0;
01253
01254
01255
01256 #ifdef WIN_OS
01257 template class DLL_EXPORT std::tr1::shared_ptr<CameraIo>;
01258 template class DLL_EXPORT std::tr1::shared_ptr<PlatformData>;
01259 template class DLL_EXPORT std::tr1::shared_ptr<CApnCamData>;
01260 template class DLL_EXPORT std::tr1::shared_ptr<ModeFsm>;
01261 template class DLL_EXPORT std::tr1::shared_ptr<CcdAcqParams>;
01262 #endif
01263
01264 std::tr1::shared_ptr<CameraIo> m_CamIo;
01265 std::tr1::shared_ptr<PlatformData> m_CameraConsts;
01266 std::tr1::shared_ptr<CApnCamData> m_CamCfgData;
01267 std::tr1::shared_ptr<ModeFsm> m_CamMode;
01268 std::tr1::shared_ptr<CcdAcqParams> m_CcdAcqSettings;
01269
01270
01271
01272 CamModel::PlatformType m_PlatformType;
01273 const std::string m_fileName;
01274 uint16_t m_FirmwareVersion;
01275 uint16_t m_Id;
01276 uint16_t m_NumImgsDownloaded;
01277 bool m_ImageInProgress;
01278 bool m_IsPreFlashOn;
01279 bool m_IsInitialized;
01280 bool m_IsConnected;
01281
01282 private:
01283
01284
01285
01286
01287 ApogeeCam(const ApogeeCam&);
01288 ApogeeCam& operator=(ApogeeCam&);
01289 };
01290
01291 #endif