EigerCamera.h 6.38 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

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

65
66
67
68
 public:
  enum ApiGeneration { Eiger1, Eiger2 };
  enum Status { Ready, Initialising, Exposure, Readout, Fault };
  enum CompressionType {NoCompression,LZ4,BSLZ4};
69

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

73
  void initialize();
74

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

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

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

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

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

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

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

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

106
  bool isBinningAvailable();
107

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

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

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

117
118
  void getTemperature(double&);
  void getHumidity(double&);
119
         
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
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
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
214
215
216
217
218
219
220
221
222
  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);
  void getCompressionType(CompressionType&) const;
  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;

  enum InternalStatus {IDLE,RUNNING,ERROR};
  class AcqCallback;
  friend class AcqCallback;
  class InitCallback;
  friend class InitCallback;
  void initialiseController(); /// Used during plug-in initialization
  void _acquisition_finished(bool);

  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;

  InternalStatus            m_initilize_state;
  InternalStatus            m_trigger_state;
  int                       m_serie_id;
  //- EigerAPI stuff
  eigerapi::Requests*       m_requests;
       
  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;
};

} // namespace Eiger
223
224
225
226
} // namespace lima


#endif // EIGERCAMERA_H