EigerCamera.h 6.54 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
44
45
46
namespace eigerapi
{
  class Requests;
}

47
48
49
50
namespace lima
{
   namespace Eiger
   {
51
     class SavingCtrlObj;
Sebastien Petitdemange's avatar
Sebastien Petitdemange committed
52
     class Stream;
53
54
55
56
   /*******************************************************************
   * \class Camera
   * \brief object controlling the Eiger camera via EigerAPI
   *******************************************************************/
57
     class LIBEIGER Camera : public HwMaxImageSizeCallbackGen, public EventCallbackGen
58
59
60
	{
		DEB_CLASS_NAMESPC(DebModCamera, "Camera", "Eiger");
		friend class Interface;
61
		friend class SavingCtrlObj;
Sebastien Petitdemange's avatar
Sebastien Petitdemange committed
62
		friend class Stream;
63
64
65

		public:

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

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

			void initialize();
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92

			void startAcq();
			void stopAcq();
			void prepareAcq();

			// -- detector info object
			void getImageType(ImageType& type);
			void setImageType(ImageType type);

			void getDetectorType(std::string& type);
			void getDetectorModel(std::string& model);
			void getDetectorImageSize(Size& size);
			void getDetectorMaxImageSize(Size& size);

			//-- Synch control object
			bool checkTrigMode(TrigMode trig_mode);
			void setTrigMode(TrigMode  mode);
			void getTrigMode(TrigMode& mode);

93
			void setExpTime(double  exp_time, bool force = false);
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
			void getExpTime(double& exp_time);

			void setLatTime(double  lat_time);
			void getLatTime(double& lat_time);

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

			void setNbFrames(int  nb_frames);
			void getNbFrames(int& nb_frames);
			void getNbHwAcquiredFrames(int &nb_acq_frames);

			bool isBinningAvailable();

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

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

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

117
118
			void getTemperature(double&);
			void getHumidity(double&);
119
         
120
			void setCountrateCorrection(bool);
121
			void getCountrateCorrection(bool&);
122
			void setFlatfieldCorrection(bool);
123
			void getFlatfieldCorrection(bool&);
124
125
			void setAutoSummation(bool);
			void getAutoSummation(bool&);
126
		    void setEfficiencyCorrection(bool);
127
		    void getEfficiencyCorrection(bool& value);
128
			void setPixelMask(bool);
129
			void getPixelMask(bool&);
130
			void setThresholdEnergy(double);
131
			void getThresholdEnergy(double&);
132
			void setVirtualPixelCorrection(bool);
133
			void getVirtualPixelCorrection(bool&);
134
			void setPhotonEnergy(double);
135
136
137
138
139
140
141
142
143
144
145
146
147
            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&);
148
   			void setCompression(bool);
149
150
			void getCompressionType(CompressionType&) const;
			void setCompressionType(CompressionType);
151
152
			void getSerieId(int&);
			void deleteMemoryFiles();
153
			void disarm();
154

Sebastien Petitdemange's avatar
Sebastien Petitdemange committed
155
			const std::string& getDetectorIp() const;
156
		private:
157
158
159
160
161
			enum InternalStatus {IDLE,RUNNING,ERROR};
			class AcqCallback;
			friend class AcqCallback;
			class InitCallback;
			friend class InitCallback;
162
			void initialiseController(); /// Used during plug-in initialization
163
			void _acquisition_finished(bool);
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183

			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); }
			};


184
185
186
			//-----------------------------------------------------------------------------
			//- lima stuff
			int                       m_nb_frames;
187
188
			Cache<unsigned int>       m_nb_images;
			Cache<unsigned int>       m_nb_triggers;
189
190
			int                       m_image_number;
			double                    m_latency_time;
191
			Cache<TrigMode>           m_trig_mode;
192
193

			//- camera stuff
194
			ApiGeneration             m_api;
195
196
			std::string               m_detector_model;
			std::string               m_detector_type;
197
			unsigned int		  m_maxImageWidth, m_maxImageHeight;
198
			ImageType                 m_detectorImageType;
199

200
201
202
                        InternalStatus m_initilize_state;
			InternalStatus m_trigger_state;
			int	       m_serie_id;
203
204
205
206
207
			//- EigerAPI stuff
			eigerapi::Requests*	  m_requests;
         
			double                    m_temperature;
			double                    m_humidity;
208
209
			Cache<double>             m_exp_time;
			Cache<double>             m_frame_time;
210
			double		          m_readout_time;
211
			double                    m_x_pixelsize, m_y_pixelsize;
212
			Cond			  m_cond;
Sebastien Petitdemange's avatar
Sebastien Petitdemange committed
213
			std::string		  m_detector_ip;
214
			double			  m_min_frame_time;
215
216
217
218
219
220
	};
	} // namespace Eiger
} // namespace lima


#endif // EIGERCAMERA_H