EigerCamera.h 6.62 KB
Newer Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
//###########################################################################
// This file is part of LImA, a Library for Image Acquisition
//
// Copyright (C) : 2009-2014
// European Synchrotron Radiation Facility
// BP 220, Grenoble 38043
// FRANCE
//
// This is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation; either version 3 of the License, or
// (at your option) any later version.
//
// This software is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program; if not, see <http://www.gnu.org/licenses/>.
//###########################################################################
#ifndef EIGERCAMERA_H
#define EIGERCAMERA_H

#include "EigerCompatibility.h"
#if defined (__GNUC__) && (__GNUC__ == 3) && defined (__ELF__)
#   define GENAPI_DECL __attribute__((visibility("default")))
#   define GENAPI_DECL_ABSTRACT __attribute__((visibility("default")))
#endif


#include <stdlib.h>
#include <limits>
34
35
#include "lima/HwMaxImageSizeCallback.h"
#include "lima/ThreadUtils.h"
36
#include "lima/Event.h"
37

38
#include <eigerapi/EigerDefines.h>
39
40
41

#include <ostream>

42
43
DEB_GLOBAL_NAMESPC(DebModCamera, "Eiger");

44
45
46
47
48
namespace eigerapi
{
  class Requests;
}

49
50
namespace lima
{
51
52
53
54
55
namespace Eiger
{

class SavingCtrlObj;
class Stream;
56
class MultiParamRequest;
57

58
59
60
61
62
63
64
/*******************************************************************
 * \class Camera
 * \brief object controlling the Eiger camera via EigerAPI
 *******************************************************************/
class LIBEIGER Camera : public HwMaxImageSizeCallbackGen, public EventCallbackGen
{
  DEB_CLASS_NAMESPC(DebModCamera, "Camera", "Eiger");
65

66
67
 public:
  enum ApiGeneration { Eiger1, Eiger2 };
68
  enum Status { Initializing, Ready, Armed, Exposure, Fault };
69
  enum CompressionType {NoCompression,LZ4,BSLZ4};
70

71
72
  Camera(const std::string& detector_ip, ApiGeneration api = Eiger1);
  ~Camera();
73

74
  void initialize();
75

76
77
78
  void startAcq();
  void stopAcq();
  void prepareAcq();
79

80
81
82
  // -- detector info object
  void getImageType(ImageType& type);
  void setImageType(ImageType type);
83

84
85
86
87
  void getDetectorType(std::string& type);
  void getDetectorModel(std::string& model);
  void getDetectorImageSize(Size& size);
  void getDetectorMaxImageSize(Size& size);
88

89
90
91
92
  //-- Synch control object
  bool checkTrigMode(TrigMode trig_mode);
  void setTrigMode(TrigMode  mode);
  void getTrigMode(TrigMode& mode);
93

94
95
  void setExpTime(double  exp_time, bool force = false);
  void getExpTime(double& exp_time);
96

97
98
  void setLatTime(double  lat_time);
  void getLatTime(double& lat_time);
99

100
101
  void getExposureTimeRange(double& min_expo, double& max_expo) const;
  void getLatTimeRange(double& min_lat, double& max_lat) const;
102

103
104
105
  void setNbFrames(int  nb_frames);
  void getNbFrames(int& nb_frames);
  void getNbHwAcquiredFrames(int &nb_acq_frames);
106

107
  bool isBinningAvailable();
108

109
  void getPixelSize(double& sizex, double& sizey);
110

111
112
113
  Camera::Status getStatus();
  std::string getCamStatus();
//void reset();
114

115
116
  // -- Eiger specific
  void getApiGeneration(ApiGeneration&);
117

118
119
  void getTemperature(double&);
  void getHumidity(double&);
120
         
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
  void setCountrateCorrection(bool);
  void getCountrateCorrection(bool&);
  void setFlatfieldCorrection(bool);
  void getFlatfieldCorrection(bool&);
  void setAutoSummation(bool);
  void getAutoSummation(bool&);
  void setEfficiencyCorrection(bool);
  void getEfficiencyCorrection(bool& value);
  void setPixelMask(bool);
  void getPixelMask(bool&);
  void setThresholdEnergy(double);
  void getThresholdEnergy(double&);
  void setVirtualPixelCorrection(bool);
  void getVirtualPixelCorrection(bool&);
  void setPhotonEnergy(double);
  void getPhotonEnergy(double&);
  void setWavelength(double);
  void getWavelength(double&);
  void setBeamCenterX(double);
  void getBeamCenterX(double&);
  void setBeamCenterY(double);
  void getBeamCenterY(double&);
  void setDetectorDistance(double);
  void getDetectorDistance(double&);
  void getDataCollectionDate(std::string&);

  void getSoftwareVersion(std::string&);

  void getCompression(bool&);
  void setCompression(bool);
151
  void getCompressionType(CompressionType&);
152
153
154
155
156
157
158
159
160
161
162
  void setCompressionType(CompressionType);
  void getSerieId(int&);
  void deleteMemoryFiles();
  void disarm();

  const std::string& getDetectorIp() const;

 private:
  friend class Interface;
  friend class SavingCtrlObj;
  friend class Stream;
163
  friend class MultiParamRequest;
164
165

  enum InternalStatus {IDLE,RUNNING,ERROR};
166
167
  class TriggerCallback;
  friend class TriggerCallback;
168
169
  class InitCallback;
  friend class InitCallback;
170
171

  void _synchronize(); /// Used during plug-in initialization
172
  void _trigger_finished(bool);
173
  void _initialization_finished(bool ok);
174
  void _disarm();
175
176

  void _updateImageSize();
177

178
  bool allFramesAcquired();
179

180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
  template <typename T>
  struct Cache
  {
    T val;

    Cache() = default;
    Cache(T v) : val(v) {}

    operator T&() { return val; }

    Cache& operator =(T new_val)
    { val = new_val; return *this; }

    bool changed(T new_val)
    { std::swap(val, new_val); return (val != new_val); }
  };


  //-----------------------------------------------------------------------------
  //- lima stuff
  int                       m_nb_frames;
  Cache<unsigned int>       m_nb_images;
  Cache<unsigned int>       m_nb_triggers;
  int                       m_image_number;
  double                    m_latency_time;
  Cache<TrigMode>           m_trig_mode;

  //- camera stuff
  ApiGeneration             m_api;
  std::string               m_detector_model;
  std::string               m_detector_type;
  unsigned int              m_maxImageWidth, m_maxImageHeight;
  ImageType                 m_detectorImageType;

214
  InternalStatus            m_initialize_state;
215
  InternalStatus            m_trigger_state;
216
  bool                      m_armed;
217
218
219
  int                       m_serie_id;
  //- EigerAPI stuff
  eigerapi::Requests*       m_requests;
220

221
222
223
224
225
226
227
228
229
  double                    m_temperature;
  double                    m_humidity;
  Cache<double>             m_exp_time;
  Cache<double>             m_frame_time;
  double                    m_readout_time;
  double                    m_x_pixelsize, m_y_pixelsize;
  Cond                      m_cond;
  std::string               m_detector_ip;
  double                    m_min_frame_time;
230
  CompressionType           m_compression_type;
231
232
233
};

} // namespace Eiger
234
235
236
237
} // namespace lima


#endif // EIGERCAMERA_H