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 class ApgTimer;
00040
00041 class DLL_EXPORT ApogeeCam
00042 {
00043 public:
00044
00048 virtual ~ApogeeCam();
00049
00058 void Reset();
00059
00065 uint16_t ReadReg( uint16_t reg );
00066
00072 void WriteReg( uint16_t reg, uint16_t value);
00073
00080 void SetRoiNumRows( uint16_t rows );
00081
00089 void SetRoiNumCols( uint16_t cols );
00090
00095 uint16_t GetRoiNumRows();
00096
00101 uint16_t GetRoiNumCols();
00102
00108 void SetRoiStartRow( uint16_t row );
00109
00115 void SetRoiStartCol( uint16_t col );
00116
00121 uint16_t GetRoiStartRow();
00122
00127 uint16_t GetRoiStartCol();
00128
00136 void SetRoiBinRow( uint16_t bin );
00137
00142 uint16_t GetRoiBinRow();
00143
00151 void SetRoiBinCol( uint16_t bin );
00152
00157 uint16_t GetRoiBinCol();
00158
00163 uint16_t GetFirmwareRev();
00164
00171 void SetImageCount( uint16_t count );
00172
00177 uint16_t GetImageCount();
00178
00185 uint16_t GetImgSequenceCount();
00186
00194 void SetSequenceDelay( double delay );
00195
00201 double GetSequenceDelay();
00202
00211 void SetVariableSequenceDelay( bool variable );
00212
00217 bool GetVariableSequenceDelay();
00218
00226 void SetTdiRate( double TdiRate );
00227
00232 double GetTdiRate();
00233
00242 void SetTdiRows( uint16_t TdiRows );
00243
00248 uint16_t GetTdiRows();
00249
00256 uint16_t GetTdiCounter();
00257
00267 void SetTdiBinningRows( uint16_t bin );
00268
00273 uint16_t GetTdiBinningRows();
00274
00283 void SetKineticsSectionHeight( uint16_t height );
00284
00289 uint16_t GetKineticsSectionHeight();
00290
00298 void SetKineticsSections( uint16_t sections );
00299
00304 uint16_t GetKineticsSections();
00305
00314 void SetKineticsShiftInterval( double interval );
00315
00320 double GetKineticsShiftInterval();
00321
00331 void SetShutterStrobePosition( double position );
00332
00337 double GetShutterStrobePosition();
00338
00347 void SetShutterStrobePeriod( double period );
00348
00353 double GetShutterStrobePeriod();
00354
00365 void SetShutterCloseDelay( double delay );
00366
00371 double GetShutterCloseDelay();
00372
00383 void SetCoolerBackoffPoint( double point );
00384
00389 double GetCoolerBackoffPoint();
00390
00401 void SetCoolerSetPoint( double point );
00402
00407 double GetCoolerSetPoint();
00408
00413 Apg::CameraMode GetCameraMode();
00414
00421 void SetCameraMode( Apg::CameraMode mode );
00422
00434 void SetFastSequence( bool TurnOn );
00435
00440 bool IsFastSequenceOn();
00441
00454 void SetBulkDownload( bool TurnOn );
00455
00460 bool IsBulkDownloadOn();
00461
00473 void SetPipelineDownload( bool TurnOn );
00474
00479 bool IsPipelineDownloadOn();
00480
00505 void SetIoPortAssignment( uint16_t assignment );
00506
00511 uint16_t GetIoPortAssignment();
00512
00517 void SetIoPortBlankingBits( uint16_t blankingBits );
00518
00523 uint16_t GetIoPortBlankingBits();
00524
00538 void SetIoPortDirection( uint16_t direction );
00539
00544 uint16_t GetIoPortDirection();
00545
00554 void SetIoPortData( uint16_t data );
00555
00560 uint16_t GetIoPortData();
00561
00569 void SetPreFlash( bool TurnOn ) { m_IsPreFlashOn = TurnOn; }
00570
00575 bool GetPreFlash() { return m_IsPreFlashOn; }
00576
00585 void SetExternalTrigger( bool TurnOn, Apg::TriggerMode trigMode,
00586 Apg::TriggerType trigType );
00587
00592 bool IsTriggerNormEachOn();
00593
00598 bool IsTriggerNormGroupOn();
00599
00604 bool IsTriggerTdiKinEachOn();
00605
00610 bool IsTriggerTdiKinGroupOn();
00611
00616 bool IsTriggerExternalShutterOn();
00617
00622 bool IsTriggerExternalReadoutOn();
00623
00629 void SetShutterState( Apg::ShutterState state );
00630
00635 Apg::ShutterState GetShutterState();
00636
00642 bool IsShutterForcedOpen();
00643
00649 bool IsShutterForcedClosed();
00650
00655 bool IsShutterOpen();
00656
00663 void SetShutterAmpCtrl( bool TurnOn );
00664
00670 bool IsShutterAmpCtrlOn();
00671
00677 void SetCooler( bool TurnOn );
00678
00683 Apg::CoolerStatus GetCoolerStatus();
00684
00689 bool IsCoolerOn();
00690
00695 double GetTempCcd();
00696
00705 void SetCcdAdcResolution(Apg::Resolution res);
00706
00711 Apg::Resolution GetCcdAdcResolution();
00712
00721 void SetCcdAdcSpeed(Apg::AdcSpeed speed);
00722
00727 Apg::AdcSpeed GetCcdAdcSpeed();
00728
00733 uint16_t GetMaxBinCols();
00734
00739 uint16_t GetMaxBinRows();
00740
00746 uint16_t GetMaxImgCols();
00747
00753 uint16_t GetMaxImgRows();
00754
00760 uint16_t GetTotalRows();
00761
00767 uint16_t GetTotalCols();
00768
00775 uint16_t GetNumOverscanCols();
00776
00781 bool IsInterline();
00782
00787 CamModel::PlatformType GetPlatformType();
00788
00794 void SetLedAState( Apg::LedState state );
00795
00800 Apg::LedState GetLedAState();
00801
00807 void SetLedBState( Apg::LedState state );
00808
00813 Apg::LedState GetLedBState();
00814
00820 void SetLedMode( Apg::LedMode mode );
00821
00826 Apg::LedMode GetLedMode();
00827
00833 std::string GetInfo();
00834
00839 std::string GetModel();
00840
00845 std::string GetSensor();
00846
00859 void SetFlushCommands( bool Disable );
00860
00865 bool AreFlushCmdsDisabled();
00866
00878 void SetPostExposeFlushing( bool Disable );
00879
00884 bool IsPostExposeFlushingDisabled();
00885
00890 double GetPixelWidth();
00891
00896 double GetPixelHeight();
00897
00902 double GetMinExposureTime();
00903
00908 double GetMaxExposureTime();
00909
00914 bool IsColor();
00915
00920 bool IsCoolingSupported();
00921
00926 bool IsCoolingRegulated();
00927
00932 double GetInputVoltage();
00933
00938 CamModel::InterfaceType GetInterfaceType();
00939
00947 void GetUsbVendorInfo( uint16_t & VendorId,
00948 uint16_t & ProductId, uint16_t & DeviceId);
00949
00954 bool IsCCD();
00955
00964 void PauseTimer( bool TurnOn );
00965
00971 bool IsSerialASupported();
00972
00978 bool IsSerialBSupported();
00979
00989 void SetFlushBinningRows( uint16_t bin );
00990
00995 uint16_t GetFlushBinningRows();
00996
01001 bool IsOverscanDigitized();
01002
01010 void SetDigitizeOverscan( const bool TurnOn );
01011
01019 void SetAdcGain( uint16_t gain, int32_t ad, int32_t channel );
01020
01027 uint16_t GetAdcGain( int32_t ad, int32_t channel );
01028
01036 void SetAdcOffset( uint16_t offset, int32_t ad, int32_t channel );
01037
01044 uint16_t GetAdcOffset( int32_t ad, int32_t channel );
01045
01049 bool IsInitialized() { return m_IsInitialized; }
01050
01054 bool IsConnected() { return m_IsConnected; }
01055
01062 void SetAdSimMode( bool TurnOn );
01063
01068 bool IsAdSimModeOn();
01069
01077 void SetLedBrightness( double PercentIntensity );
01078
01085 double GetLedBrightness();
01086
01091 std::string GetDriverVersion();
01092
01097 std::string GetUsbFirmwareVersion();
01098
01103 std::string GetSerialNumber();
01104
01105
01106 CamInfo::StrDb ReadStrDatabase();
01107 void WriteStrDatabase(CamInfo::StrDb &info);
01108
01109
01110
01122 virtual void OpenConnection( const std::string & ioType,
01123 const std::string & DeviceAddr,
01124 const uint16_t FirmwareRev,
01125 const uint16_t Id ) = 0;
01126
01134 virtual void CloseConnection() = 0;
01135
01141 virtual void Init() = 0;
01142
01153 virtual void StartExposure( double Duration, bool IsLight ) = 0;
01154
01159 virtual CameraStatusRegs GetStatus() = 0;
01160
01165 virtual Apg::Status GetImagingStatus() = 0;
01166
01172 virtual void GetImage( std::vector<uint16_t> & out ) = 0;
01173
01183 virtual void StopExposure( bool Digitize ) = 0;
01184
01189 virtual uint32_t GetAvailableMemory() = 0;
01190
01195 virtual int32_t GetNumAds() = 0;
01196
01201 virtual int32_t GetNumAdChannels() = 0;
01202
01208 virtual double GetCoolerDrive() = 0;
01209
01220 virtual void SetFanMode( Apg::FanMode mode, bool PreCondCheck = true ) = 0;
01221
01226 virtual Apg::FanMode GetFanMode() = 0;
01227
01234 virtual double GetTempHeatsink() = 0;
01235
01236 void UpdateAlta(const std::string FilenameCamCon, const std::string FilenameBufCon, const std::string FilenameFx2, const std::string FilenameGpifCamCon, const std::string FilenameGpifBufCon, const std::string FilenameGpifFifo);
01237 void UpdateAscentOrAltaF(const std::string FilenameFpga, const std::string FilenameFx2, const std::string FilenameDescriptor);
01238 void UpdateAspen(const std::string FilenameFpga, const std::string FilenameFx2, const std::string FilenameDescriptor, const std::string FilenameWebPage, const std::string FilenameWebServer, const std::string FilenameWebCfg);
01239
01240
01241 protected:
01242 ApogeeCam(CamModel::PlatformType platform) ;
01243
01244 void VerifyFrmwrRev();
01245 void LogConnectAndDisconnect( bool Connect );
01246
01247 void ExectuePreFlash();
01248 void SetExpsoureTime( double Duration );
01249 void IssueExposeCmd( bool IsLight );
01250
01251 void IsThereAStatusError( uint16_t statusReg );
01252
01253 bool IsImgDone( const CameraStatusRegs & statusObj);
01254 Apg::Status LogAndReturnStatus( Apg::Status status,
01255 const CameraStatusRegs & statusObj);
01256
01257 void SupsendCooler( bool & resume );
01258 void ResumeCooler();
01259 void WaitForCoolerSuspendBit( const uint16_t mask, const bool IsHigh );
01260
01261 void InitShutterCloseDelay();
01262
01263 void StopExposureModeNorm( bool Digitize );
01264 void Reset(bool Flush);
01265
01266 void HardStopExposure( const std::string & msg );
01267 void GrabImageAndThrowItAway();
01268
01269 void AdcParamCheck( const int32_t ad,
01270 const int32_t channel, const std::string & fxName );
01271
01272 void SetNumAdOutputs( const uint16_t num );
01273
01274 bool CheckAndWaitForStatus( Apg::Status desired, Apg::Status & acutal );
01275 void CancelExposureNoThrow();
01276 double DefaultGetTempHeatsink();
01277
01278 void DefaultInit();
01279 void ClearAllRegisters();
01280 void DefaultCfgCamFromId( uint16_t CameraId );
01281 void DefaultSetFanMode( Apg::FanMode mode, bool PreCondCheck );
01282 Apg::FanMode DefaultGetFanMode();
01283 void DefaultCloseConnection();
01284
01285
01286 virtual void CfgCamFromId( uint16_t CameraId ) = 0;
01287 virtual void ExposureAndGetImgRC(uint16_t & r, uint16_t & c) = 0;
01288 virtual uint16_t ExposureZ() = 0;
01289 virtual uint16_t GetImageZ() = 0;
01290 virtual uint16_t GetIlluminationMask() = 0;
01291 virtual void FixImgFromCamera( const std::vector<uint16_t> & data,
01292 std::vector<uint16_t> & out, int32_t rows, int32_t cols) = 0;
01293
01294
01295
01296 #ifdef WIN_OS
01297 #if _MSC_VER < 1600
01298 template class DLL_EXPORT std::tr1::shared_ptr<CameraIo>;
01299 template class DLL_EXPORT std::tr1::shared_ptr<PlatformData>;
01300 template class DLL_EXPORT std::tr1::shared_ptr<CApnCamData>;
01301 template class DLL_EXPORT std::tr1::shared_ptr<ModeFsm>;
01302 template class DLL_EXPORT std::tr1::shared_ptr<CcdAcqParams>;
01303 template class DLL_EXPORT std::tr1::shared_ptr<ApgTimer>;
01304 #endif
01305 #endif
01306
01307 std::tr1::shared_ptr<CameraIo> m_CamIo;
01308 std::tr1::shared_ptr<PlatformData> m_CameraConsts;
01309 std::tr1::shared_ptr<CApnCamData> m_CamCfgData;
01310 std::tr1::shared_ptr<ModeFsm> m_CamMode;
01311 std::tr1::shared_ptr<CcdAcqParams> m_CcdAcqSettings;
01312 std::tr1::shared_ptr<ApgTimer> m_ExposureTimer;
01313
01314 CamModel::PlatformType m_PlatformType;
01315 const std::string m_fileName;
01316 uint16_t m_FirmwareVersion;
01317 uint16_t m_Id;
01318 uint16_t m_NumImgsDownloaded;
01319 bool m_ImageInProgress;
01320 bool m_IsPreFlashOn;
01321 bool m_IsInitialized;
01322 bool m_IsConnected;
01323 double m_LastExposureTime;
01324
01325 private:
01326
01327
01328
01329
01330 ApogeeCam(const ApogeeCam&);
01331 ApogeeCam& operator=(ApogeeCam&);
01332 };
01333
01334 #endif