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
00697 void SetCcdAdcSpeed(Apg::AdcSpeed speed);
00698
00703 Apg::AdcSpeed GetCcdAdcSpeed();
00704
00709 uint16_t GetMaxBinCols();
00710
00715 uint16_t GetMaxBinRows();
00716
00722 uint16_t GetMaxImgCols();
00723
00729 uint16_t GetMaxImgRows();
00730
00736 uint16_t GetTotalRows();
00737
00743 uint16_t GetTotalCols();
00744
00751 uint16_t GetNumOverscanCols();
00752
00757 bool IsInterline();
00758
00763 CamModel::PlatformType GetPlatformType();
00764
00770 void SetLedAState( Apg::LedState state );
00771
00776 Apg::LedState GetLedAState();
00777
00783 void SetLedBState( Apg::LedState state );
00784
00789 Apg::LedState GetLedBState();
00790
00796 void SetLedMode( Apg::LedMode mode );
00797
00802 Apg::LedMode GetLedMode();
00803
00809 std::string GetInfo();
00810
00815 std::string GetModel();
00816
00821 std::string GetSensor();
00822
00835 void SetFlushCommands( bool Disable );
00836
00841 bool AreFlushCmdsDisabled();
00842
00854 void SetPostExposeFlushing( bool Disable );
00855
00860 bool IsPostExposeFlushingDisabled();
00861
00866 double GetPixelWidth();
00867
00872 double GetPixelHeight();
00873
00878 double GetMinExposureTime();
00879
00884 double GetMaxExposureTime();
00885
00890 bool IsColor();
00891
00896 bool IsCoolingSupported();
00897
00902 bool IsCoolingRegulated();
00903
00908 double GetInputVoltage();
00909
00914 CamModel::InterfaceType GetInterfaceType();
00915
00923 void GetUsbVendorInfo( uint16_t & VendorId,
00924 uint16_t & ProductId, uint16_t & DeviceId);
00925
00930 bool IsCCD();
00931
00940 void PauseTimer( bool TurnOn );
00941
00947 bool IsSerialASupported();
00948
00954 bool IsSerialBSupported();
00955
00965 void SetFlushBinningRows( uint16_t bin );
00966
00971 uint16_t GetFlushBinningRows();
00972
00977 bool IsOverscanDigitized();
00978
00986 void SetDigitizeOverscan( const bool TurnOn );
00987
00995 void SetAdcGain( uint16_t gain, int32_t ad, int32_t channel );
00996
01003 uint16_t GetAdcGain( int32_t ad, int32_t channel );
01004
01012 void SetAdcOffset( uint16_t offset, int32_t ad, int32_t channel );
01013
01020 uint16_t GetAdcOffset( int32_t ad, int32_t channel );
01021
01025 bool IsInitialized() { return m_IsInitialized; }
01026
01030 bool IsConnected() { return m_IsConnected; }
01031
01038 void SetAdSimMode( bool TurnOn );
01039
01044 bool IsAdSimModeOn();
01045
01053 void SetLedBrightness( double PercentIntensity );
01054
01061 double GetLedBrightness();
01062
01067 std::string GetDriverVersion();
01068
01073 std::string GetUsbFirmwareVersion();
01074
01079 std::string GetSerialNumber();
01080
01088 void CloseConnection();
01089
01090
01091
01103 virtual void OpenConnection( const std::string & ioType,
01104 const std::string & DeviceAddr,
01105 const uint16_t FirmwareRev,
01106 const uint16_t Id ) = 0;
01107
01113 virtual void Init() = 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 void DefaultInit();
01246 void ClearAllRegisters();
01247
01248
01249 virtual void CfgCamFromId( uint16_t CameraId ) = 0;
01250 virtual void ExposureAndGetImgRC(uint16_t & r, uint16_t & c) = 0;
01251 virtual uint16_t ExposureZ() = 0;
01252 virtual uint16_t GetImageZ() = 0;
01253 virtual uint16_t GetIlluminationMask() = 0;
01254 virtual void FixImgFromCamera( const std::vector<uint16_t> & data,
01255 std::vector<uint16_t> & out, int32_t rows, int32_t cols) = 0;
01256
01257
01258
01259 #ifdef WIN_OS
01260 template class DLL_EXPORT std::tr1::shared_ptr<CameraIo>;
01261 template class DLL_EXPORT std::tr1::shared_ptr<PlatformData>;
01262 template class DLL_EXPORT std::tr1::shared_ptr<CApnCamData>;
01263 template class DLL_EXPORT std::tr1::shared_ptr<ModeFsm>;
01264 template class DLL_EXPORT std::tr1::shared_ptr<CcdAcqParams>;
01265 #endif
01266
01267 std::tr1::shared_ptr<CameraIo> m_CamIo;
01268 std::tr1::shared_ptr<PlatformData> m_CameraConsts;
01269 std::tr1::shared_ptr<CApnCamData> m_CamCfgData;
01270 std::tr1::shared_ptr<ModeFsm> m_CamMode;
01271 std::tr1::shared_ptr<CcdAcqParams> m_CcdAcqSettings;
01272
01273
01274
01275 CamModel::PlatformType m_PlatformType;
01276 const std::string m_fileName;
01277 uint16_t m_FirmwareVersion;
01278 uint16_t m_Id;
01279 uint16_t m_NumImgsDownloaded;
01280 bool m_ImageInProgress;
01281 bool m_IsPreFlashOn;
01282 bool m_IsInitialized;
01283 bool m_IsConnected;
01284
01285 private:
01286
01287
01288
01289
01290 ApogeeCam(const ApogeeCam&);
01291 ApogeeCam& operator=(ApogeeCam&);
01292 };
01293
01294 #endif