libapogee  3.0.3234
ApogeeCam.h
1 
14 #ifndef APOGEECAM_INCLUDE_H__
15 #define APOGEECAM_INCLUDE_H__
16 
17 #include <string>
18 #include <vector>
19 #include <stdint.h>
20 
21 
22 #ifdef WIN_OS
23 #include <memory>
24 #else
25 #include <tr1/memory>
26 #endif
27 
28 #include "CameraStatusRegs.h"
29 #include "CameraInfo.h"
30 #include "DefDllExport.h"
31 
32 
33 
34 class PlatformData;
35 class CApnCamData;
36 class CameraIo;
37 class ModeFsm;
38 class CcdAcqParams;
39 class ApgTimer;
40 
41 class DLL_EXPORT ApogeeCam
42 {
43  public:
44 
48  virtual ~ApogeeCam();
49 
58  void Reset();
59 
65  uint16_t ReadReg( uint16_t reg );
66 
72  void WriteReg( uint16_t reg, uint16_t value);
73 
80  void SetRoiNumRows( uint16_t rows );
81 
89  void SetRoiNumCols( uint16_t cols );
90 
95  uint16_t GetRoiNumRows();
96 
101  uint16_t GetRoiNumCols();
102 
108  void SetRoiStartRow( uint16_t row );
109 
115  void SetRoiStartCol( uint16_t col );
116 
121  uint16_t GetRoiStartRow();
122 
127  uint16_t GetRoiStartCol();
128 
136  void SetRoiBinRow( uint16_t bin );
137 
142  uint16_t GetRoiBinRow();
143 
151  void SetRoiBinCol( uint16_t bin );
152 
157  uint16_t GetRoiBinCol();
158 
163  uint16_t GetFirmwareRev();
164 
171  void SetImageCount( uint16_t count );
172 
177  uint16_t GetImageCount();
178 
185  uint16_t GetImgSequenceCount();
186 
194  void SetSequenceDelay( double delay );
195 
201  double GetSequenceDelay();
202 
211  void SetVariableSequenceDelay( bool variable );
212 
217  bool GetVariableSequenceDelay();
218 
226  void SetTdiRate( double TdiRate );
227 
232  double GetTdiRate();
233 
242  void SetTdiRows( uint16_t TdiRows );
243 
248  uint16_t GetTdiRows();
249 
256  uint16_t GetTdiCounter();
257 
267  void SetTdiBinningRows( uint16_t bin );
268 
273  uint16_t GetTdiBinningRows();
274 
283  void SetKineticsSectionHeight( uint16_t height );
284 
289  uint16_t GetKineticsSectionHeight();
290 
298  void SetKineticsSections( uint16_t sections );
299 
304  uint16_t GetKineticsSections();
305 
314  void SetKineticsShiftInterval( double interval );
315 
320  double GetKineticsShiftInterval();
321 
331  void SetShutterStrobePosition( double position );
332 
337  double GetShutterStrobePosition();
338 
347  void SetShutterStrobePeriod( double period );
348 
353  double GetShutterStrobePeriod();
354 
365  void SetShutterCloseDelay( double delay );
366 
371  double GetShutterCloseDelay();
372 
383  void SetCoolerBackoffPoint( double point );
384 
389  double GetCoolerBackoffPoint();
390 
401  void SetCoolerSetPoint( double point );
402 
407  double GetCoolerSetPoint();
408 
413  Apg::CameraMode GetCameraMode();
414 
421  void SetCameraMode( Apg::CameraMode mode );
422 
434  void SetFastSequence( bool TurnOn );
435 
440  bool IsFastSequenceOn();
441 
454  void SetBulkDownload( bool TurnOn );
455 
460  bool IsBulkDownloadOn();
461 
473  void SetPipelineDownload( bool TurnOn );
474 
479  bool IsPipelineDownloadOn();
480 
505  void SetIoPortAssignment( uint16_t assignment );
506 
511  uint16_t GetIoPortAssignment();
512 
517  void SetIoPortBlankingBits( uint16_t blankingBits );
518 
523  uint16_t GetIoPortBlankingBits();
524 
538  void SetIoPortDirection( uint16_t direction );
539 
544  uint16_t GetIoPortDirection();
545 
554  void SetIoPortData( uint16_t data );
555 
560  uint16_t GetIoPortData();
561 
569  void SetPreFlash( bool TurnOn ) { m_IsPreFlashOn = TurnOn; }
570 
575  bool GetPreFlash() { return m_IsPreFlashOn; }
576 
585  void SetExternalTrigger( bool TurnOn, Apg::TriggerMode trigMode,
586  Apg::TriggerType trigType );
587 
592  bool IsTriggerNormEachOn();
593 
598  bool IsTriggerNormGroupOn();
599 
604  bool IsTriggerTdiKinEachOn();
605 
610  bool IsTriggerTdiKinGroupOn();
611 
616  bool IsTriggerExternalShutterOn();
617 
622  bool IsTriggerExternalReadoutOn();
623 
629  void SetShutterState( Apg::ShutterState state );
630 
635  Apg::ShutterState GetShutterState();
636 
642  bool IsShutterForcedOpen();
643 
649  bool IsShutterForcedClosed();
650 
655  bool IsShutterOpen();
656 
663  void SetShutterAmpCtrl( bool TurnOn );
664 
670  bool IsShutterAmpCtrlOn();
671 
677  void SetCooler( bool TurnOn );
678 
683  Apg::CoolerStatus GetCoolerStatus();
684 
689  bool IsCoolerOn();
690 
695  double GetTempCcd();
696 
705  void SetCcdAdcResolution(Apg::Resolution res);
706 
711  Apg::Resolution GetCcdAdcResolution();
712 
721  void SetCcdAdcSpeed(Apg::AdcSpeed speed);
722 
727  Apg::AdcSpeed GetCcdAdcSpeed();
728 
733  uint16_t GetMaxBinCols();
734 
739  uint16_t GetMaxBinRows();
740 
746  uint16_t GetMaxImgCols();
747 
753  uint16_t GetMaxImgRows();
754 
760  uint16_t GetTotalRows();
761 
767  uint16_t GetTotalCols();
768 
775  uint16_t GetNumOverscanCols();
776 
781  bool IsInterline();
782 
787  CamModel::PlatformType GetPlatformType();
788 
794  void SetLedAState( Apg::LedState state );
795 
800  Apg::LedState GetLedAState();
801 
807  void SetLedBState( Apg::LedState state );
808 
813  Apg::LedState GetLedBState();
814 
820  void SetLedMode( Apg::LedMode mode );
821 
826  Apg::LedMode GetLedMode();
827 
833  std::string GetInfo();
834 
839  std::string GetModel();
840 
845  std::string GetSensor();
846 
859  void SetFlushCommands( bool Disable );
860 
865  bool AreFlushCmdsDisabled();
866 
878  void SetPostExposeFlushing( bool Disable );
879 
884  bool IsPostExposeFlushingDisabled();
885 
890  double GetPixelWidth();
891 
896  double GetPixelHeight();
897 
902  double GetMinExposureTime();
903 
908  double GetMaxExposureTime();
909 
914  bool IsColor();
915 
920  bool IsCoolingSupported();
921 
926  bool IsCoolingRegulated();
927 
932  double GetInputVoltage();
933 
938  CamModel::InterfaceType GetInterfaceType();
939 
947  void GetUsbVendorInfo( uint16_t & VendorId,
948  uint16_t & ProductId, uint16_t & DeviceId);
949 
954  bool IsCCD();
955 
964  void PauseTimer( bool TurnOn );
965 
971  bool IsSerialASupported();
972 
978  bool IsSerialBSupported();
979 
989  void SetFlushBinningRows( uint16_t bin );
990 
995  uint16_t GetFlushBinningRows();
996 
1001  bool IsOverscanDigitized();
1002 
1010  void SetDigitizeOverscan( const bool TurnOn );
1011 
1019  void SetAdcGain( uint16_t gain, int32_t ad, int32_t channel );
1020 
1027  uint16_t GetAdcGain( int32_t ad, int32_t channel );
1028 
1036  void SetAdcOffset( uint16_t offset, int32_t ad, int32_t channel );
1037 
1044  uint16_t GetAdcOffset( int32_t ad, int32_t channel );
1045 
1049  bool IsInitialized() { return m_IsInitialized; }
1050 
1054  bool IsConnected() { return m_IsConnected; }
1055 
1062  void SetAdSimMode( bool TurnOn );
1063 
1068  bool IsAdSimModeOn();
1069 
1077  void SetLedBrightness( double PercentIntensity );
1078 
1085  double GetLedBrightness();
1086 
1091  std::string GetDriverVersion();
1092 
1097  std::string GetUsbFirmwareVersion();
1098 
1103  std::string GetSerialNumber();
1104 
1105 
1106  CamInfo::StrDb ReadStrDatabase();
1107  void WriteStrDatabase(CamInfo::StrDb &info);
1108 
1109  // ****** PURE VIRTUAL INTERFACE ********
1110 
1122  virtual void OpenConnection( const std::string & ioType,
1123  const std::string & DeviceAddr,
1124  const uint16_t FirmwareRev,
1125  const uint16_t Id ) = 0;
1126 
1134  virtual void CloseConnection() = 0;
1135 
1141  virtual void Init() = 0;
1142 
1153  virtual void StartExposure( double Duration, bool IsLight ) = 0;
1154 
1159  virtual CameraStatusRegs GetStatus() = 0;
1160 
1165  virtual Apg::Status GetImagingStatus() = 0;
1166 
1172  virtual void GetImage( std::vector<uint16_t> & out ) = 0;
1173 
1183  virtual void StopExposure( bool Digitize ) = 0;
1184 
1189  virtual uint32_t GetAvailableMemory() = 0;
1190 
1195  virtual int32_t GetNumAds() = 0;
1196 
1201  virtual int32_t GetNumAdChannels() = 0;
1202 
1208  virtual double GetCoolerDrive() = 0;
1209 
1220  virtual void SetFanMode( Apg::FanMode mode, bool PreCondCheck = true ) = 0;
1221 
1226  virtual Apg::FanMode GetFanMode() = 0;
1227 
1234  virtual double GetTempHeatsink() = 0;
1235 
1236  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);
1237  void UpdateAscentOrAltaF(const std::string FilenameFpga, const std::string FilenameFx2, const std::string FilenameDescriptor);
1238  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);
1239 
1240 
1241  protected:
1242  ApogeeCam(CamModel::PlatformType platform) ;
1243 
1244  void VerifyFrmwrRev();
1245  void LogConnectAndDisconnect( bool Connect );
1246 
1247  void ExectuePreFlash();
1248  void SetExpsoureTime( double Duration );
1249  void IssueExposeCmd( bool IsLight );
1250 
1251  void IsThereAStatusError( uint16_t statusReg );
1252 
1253  bool IsImgDone( const CameraStatusRegs & statusObj);
1254  Apg::Status LogAndReturnStatus( Apg::Status status,
1255  const CameraStatusRegs & statusObj);
1256 
1257  void SupsendCooler( bool & resume );
1258  void ResumeCooler();
1259  void WaitForCoolerSuspendBit( const uint16_t mask, const bool IsHigh );
1260 
1261  void InitShutterCloseDelay();
1262 
1263  void StopExposureModeNorm( bool Digitize );
1264  void Reset(bool Flush);
1265 
1266  void HardStopExposure( const std::string & msg );
1267  void GrabImageAndThrowItAway();
1268 
1269  void AdcParamCheck( const int32_t ad,
1270  const int32_t channel, const std::string & fxName );
1271 
1272  void SetNumAdOutputs( const uint16_t num );
1273 
1274  bool CheckAndWaitForStatus( Apg::Status desired, Apg::Status & acutal );
1275  void CancelExposureNoThrow();
1276  double DefaultGetTempHeatsink();
1277 
1278  void DefaultInit();
1279  void ClearAllRegisters();
1280  void DefaultCfgCamFromId( uint16_t CameraId );
1281  void DefaultSetFanMode( Apg::FanMode mode, bool PreCondCheck );
1282  Apg::FanMode DefaultGetFanMode();
1283  void DefaultCloseConnection();
1284 
1285  // ****** PURE VIRTUAL INTERFACE ********
1286  virtual void CfgCamFromId( uint16_t CameraId ) = 0;
1287  virtual void ExposureAndGetImgRC(uint16_t & r, uint16_t & c) = 0;
1288  virtual uint16_t ExposureZ() = 0;
1289  virtual uint16_t GetImageZ() = 0;
1290  virtual uint16_t GetIlluminationMask() = 0;
1291  virtual void FixImgFromCamera( const std::vector<uint16_t> & data,
1292  std::vector<uint16_t> & out, int32_t rows, int32_t cols) = 0;
1293 
1294 //this code removes vc++ compiler warning C4251
1295 //from http://www.unknownroad.com/rtfm/VisualStudio/warningC4251.html
1296 #ifdef WIN_OS
1297 #if _MSC_VER < 1600
1298  template class DLL_EXPORT std::tr1::shared_ptr<CameraIo>;
1299  template class DLL_EXPORT std::tr1::shared_ptr<PlatformData>;
1300  template class DLL_EXPORT std::tr1::shared_ptr<CApnCamData>;
1301  template class DLL_EXPORT std::tr1::shared_ptr<ModeFsm>;
1302  template class DLL_EXPORT std::tr1::shared_ptr<CcdAcqParams>;
1303  template class DLL_EXPORT std::tr1::shared_ptr<ApgTimer>;
1304 #endif
1305 #endif
1306 
1307  std::tr1::shared_ptr<CameraIo> m_CamIo;
1308  std::tr1::shared_ptr<PlatformData> m_CameraConsts;
1309  std::tr1::shared_ptr<CApnCamData> m_CamCfgData;
1310  std::tr1::shared_ptr<ModeFsm> m_CamMode;
1311  std::tr1::shared_ptr<CcdAcqParams> m_CcdAcqSettings;
1312  std::tr1::shared_ptr<ApgTimer> m_ExposureTimer;
1313 
1314  CamModel::PlatformType m_PlatformType;
1315  const std::string m_fileName;
1316  uint16_t m_FirmwareVersion;
1317  uint16_t m_Id;
1318  uint16_t m_NumImgsDownloaded;
1319  bool m_ImageInProgress;
1320  bool m_IsPreFlashOn;
1321  bool m_IsInitialized;
1322  bool m_IsConnected;
1323  double m_LastExposureTime;
1324 
1325  private:
1326 
1327  //disabling the copy ctor and assignment operator
1328  //generated by the compiler - don't want them
1329  //Effective C++ Item 6
1330  ApogeeCam(const ApogeeCam&);
1331  ApogeeCam& operator=(ApogeeCam&);
1332 };
1333 
1334 #endif
Base class for apogee cameras.
Definition: ApogeeCam.h:41
void SetPreFlash(bool TurnOn)
Definition: ApogeeCam.h:569
FanMode
Definition: CameraInfo.h:264
bool IsConnected()
Definition: ApogeeCam.h:1054
ShutterState
Definition: CameraInfo.h:340
bool GetPreFlash()
Definition: ApogeeCam.h:575
bool IsInitialized()
Definition: ApogeeCam.h:1049
Definition: CameraInfo.h:22
Class that wrapps the basic and advanced status structs.
Definition: CameraStatusRegs.h:20
CameraMode
Definition: CameraInfo.h:188
Status
Definition: CameraInfo.h:155