EigerCamera.h 6.6 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
51
52
namespace lima
{
   namespace Eiger
   {
53
     class SavingCtrlObj;
Sebastien Petitdemange's avatar
Sebastien Petitdemange committed
54
     class Stream;
55
56
57
58
   /*******************************************************************
   * \class Camera
   * \brief object controlling the Eiger camera via EigerAPI
   *******************************************************************/
59
     class LIBEIGER Camera : public HwMaxImageSizeCallbackGen, public EventCallbackGen
60
61
62
	{
		DEB_CLASS_NAMESPC(DebModCamera, "Camera", "Eiger");
		friend class Interface;
63
		friend class SavingCtrlObj;
Sebastien Petitdemange's avatar
Sebastien Petitdemange committed
64
		friend class Stream;
65
66
67

		public:

68
		enum ApiGeneration { Eiger1, Eiger2 };
69
		enum Status { Ready, Initialising, Exposure, Readout, Fault };
70
		enum CompressionType {NoCompression,LZ4,BSLZ4};
71

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

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

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

95
			void setExpTime(double  exp_time, bool force = false);
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
			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();
113
			std::string getCamStatus();
114
115
116
//			void reset();

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

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

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

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


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

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

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


#endif // EIGERCAMERA_H