FrelonInterface.h 10.7 KB
Newer Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
//###########################################################################
// This file is part of LImA, a Library for Image Acquisition
//
// Copyright (C) : 2009-2011
// 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/>.
//###########################################################################
22
23
24
#ifndef FRELONINTERFACE_H
#define FRELONINTERFACE_H

25
#include "lima/HwInterface.h"
26
27
28
29
30
31
32
33
34
35
36
#include "EspiaBufferMgr.h"
#include "FrelonCamera.h"

namespace lima
{

namespace Frelon
{

class Interface;

37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
/*******************************************************************
 * \class AcqEndCallback
 * \brief Class executing camera commands at the end of acq.
 *******************************************************************/

class AcqEndCallback : public Espia::AcqEndCallback
{
	DEB_CLASS_NAMESPC(DebModCamera, "AcqEndCallback", "Frelon");

 public:
	AcqEndCallback(Camera& cam);
	virtual ~AcqEndCallback();

 protected:
	virtual void acqFinished(const HwFrameInfoType& /*finfo*/);

 private:
	Camera& m_cam;
};


58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
/*******************************************************************
 * \class EventCallback
 * \brief Bridge class transfering events from Acq -> HwEventCtrlObj
 *******************************************************************/

class EventCallback : public lima::EventCallback
{
	DEB_CLASS_NAMESPC(DebModCamera, "EventCallback", "Frelon");

 public:
	EventCallback(HwEventCtrlObj& ctrl_obj);
	virtual ~EventCallback();

 protected:
	virtual void processEvent(Event *event);

 private:
	HwEventCtrlObj& m_ctrl_obj;
};


79
80
81
82
83
84
85
/*******************************************************************
 * \class DetInfoCtrlObj
 * \brief Control object providing Frelon detector info interface
 *******************************************************************/

class DetInfoCtrlObj : public HwDetInfoCtrlObj
{
86
87
	DEB_CLASS_NAMESPC(DebModCamera, "DetInfoCtrlObj", "Frelon");

88
89
90
91
92
93
94
95
96
97
98
 public:
	DetInfoCtrlObj(Camera& cam);
	virtual ~DetInfoCtrlObj();

	virtual void getMaxImageSize(Size& max_image_size);
	virtual void getDetectorImageSize(Size& det_image_size);

	virtual void getDefImageType(ImageType& def_image_type);
	virtual void getCurrImageType(ImageType& curr_image_type);
	virtual void setCurrImageType(ImageType  curr_image_type);

99
	virtual void getPixelSize(double& x_size, double& y_size);
100
101
102
	virtual void getDetectorType(std::string& det_type);
	virtual void getDetectorModel(std::string& det_model);

ahoms's avatar
ahoms committed
103
104
105
106
	virtual void registerMaxImageSizeCallback(
					HwMaxImageSizeCallback& cb);
	virtual void unregisterMaxImageSizeCallback(
					HwMaxImageSizeCallback& cb);
107
108
109
110
111
112
113
114
115
116
117
118
119

 private:
	Camera& m_cam;
};


/*******************************************************************
 * \class BufferCtrlObj
 * \brief Control object providing Frelon buffering interface
 *******************************************************************/

class BufferCtrlObj : public HwBufferCtrlObj
{
120
121
	DEB_CLASS_NAMESPC(DebModCamera, "BufferCtrlObj", "Frelon");

122
123
124
125
126
 public:
	BufferCtrlObj(BufferCtrlMgr& buffer_mgr);
	virtual ~BufferCtrlObj();

	virtual void setFrameDim(const FrameDim& frame_dim);
127
	virtual void getFrameDim(      FrameDim& frame_dim);
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

	virtual void setNbBuffers(int  nb_buffers);
	virtual void getNbBuffers(int& nb_buffers);

	virtual void setNbConcatFrames(int  nb_concat_frames);
	virtual void getNbConcatFrames(int& nb_concat_frames);

	virtual void getMaxNbBuffers(int& max_nb_buffers);

	virtual void *getBufferPtr(int buffer_nb, int concat_frame_nb = 0);
	virtual void *getFramePtr(int acq_frame_nb);

	virtual void getStartTimestamp(Timestamp& start_ts);
	virtual void getFrameInfo(int acq_frame_nb, HwFrameInfoType& info);

	virtual void   registerFrameCallback(HwFrameCallback& frame_cb);
	virtual void unregisterFrameCallback(HwFrameCallback& frame_cb);

 private:
	BufferCtrlMgr& m_buffer_mgr;
};


/*******************************************************************
 * \class SyncCtrlObj
 * \brief Control object providing Frelon synchronization interface
 *******************************************************************/

class SyncCtrlObj : public HwSyncCtrlObj
{
158
159
	DEB_CLASS_NAMESPC(DebModCamera, "SyncCtrlObj", "Frelon");

160
 public:
161
	SyncCtrlObj(Espia::Acq& acq, Camera& cam);
162
163
	virtual ~SyncCtrlObj();

164
	virtual bool checkTrigMode(TrigMode trig_mode);
165
166
167
168
169
170
171
172
173
	virtual void setTrigMode(TrigMode  trig_mode);
	virtual void getTrigMode(TrigMode& trig_mode);

	virtual void setExpTime(double  exp_time);
	virtual void getExpTime(double& exp_time);

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

174
175
	virtual void setNbHwFrames(int  nb_frames);
	virtual void getNbHwFrames(int& nb_frames);
176
177
178
179

	virtual void getValidRanges(ValidRangesType& valid_ranges);

 private:
180
181
182
183
184
185
186
187
188
189
190
191
192
	class DeadTimeChangedCallback : public Camera::DeadTimeChangedCallback
	{
		DEB_CLASS_NAMESPC(DebModCamera, "DeadTimeChangedCallback", 
				  "Frelon::SynCtrlObj");
	public:
		DeadTimeChangedCallback(SyncCtrlObj *sync);
	protected:
		virtual void deadTimeChanged(double dead_time);
	private:
		friend class SyncCtrlObj;
		SyncCtrlObj *m_sync;
	};

193
194
	Espia::Acq& m_acq;
	Camera& m_cam;
195
	DeadTimeChangedCallback m_dead_time_cb;
196
197
198
199
200
};


/*******************************************************************
 * \class BinCtrlObj
201
 * \brief Control object providing Frelon binning interface
202
203
 *******************************************************************/

204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
class BinCtrlObj;

class BinChangedCallback 
{
	DEB_CLASS_NAMESPC(DebModCamera, "BinChangedCallback", "Frelon");

 public:
	BinChangedCallback();
	virtual ~BinChangedCallback();

 protected:
	virtual void hwBinChanged(const Bin& hw_bin) = 0;
	
 private:
	friend class BinCtrlObj;
	BinCtrlObj *m_bin_ctrl_obj;
};


223
224
class BinCtrlObj : public HwBinCtrlObj
{
225
226
	DEB_CLASS_NAMESPC(DebModCamera, "BinCtrlObj", "Frelon");

227
228
229
230
231
232
233
234
 public:
	BinCtrlObj(Camera& cam);
	virtual ~BinCtrlObj();

	virtual void setBin(const Bin& bin);
	virtual void getBin(Bin& bin);
	virtual void checkBin(Bin& bin);

235
236
237
	void registerBinChangedCallback  (BinChangedCallback& bin_chg_cb);
	void unregisterBinChangedCallback(BinChangedCallback& bin_chg_cb);

238
239
 private:
	Camera& m_cam;
240
	BinChangedCallback *m_bin_chg_cb;
241
242
243
};


244
245
246
247
248
/*******************************************************************
 * \class RoiCtrlObj
 * \brief Control object providing Frelon Roi interface
 *******************************************************************/

249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
class RoiCtrlObj;

class RoiChangedCallback 
{
	DEB_CLASS_NAMESPC(DebModCamera, "RoiChangedCallback", "Frelon");

 public:
	RoiChangedCallback();
	virtual ~RoiChangedCallback();

 protected:
	virtual void hwRoiChanged(const Roi& hw_roi) = 0;

 private:
	friend class RoiCtrlObj;
	RoiCtrlObj *m_roi_ctrl_obj;
};


268
269
class RoiCtrlObj : public HwRoiCtrlObj
{
270
271
	DEB_CLASS_NAMESPC(DebModCamera, "RoiCtrlObj", "Frelon");

272
 public:
273
	RoiCtrlObj(Espia::Acq& acq, Camera& cam);
274
275
276
277
	virtual ~RoiCtrlObj();

	virtual void setRoi(const Roi& set_roi);
	virtual void getRoi(Roi& hw_roi);
278
279
	virtual void checkRoi(const Roi& set_roi, Roi& hw_roi);

280
281
282
	void registerRoiChangedCallback  (RoiChangedCallback& roi_chg_cb);
	void unregisterRoiChangedCallback(RoiChangedCallback& roi_chg_cb);

283
 private:
284
285
286
287
	void checkEspiaRoi(const Roi& set_roi, Roi& hw_roi, 
			   Size& det_frame_size, Roi& espia_roi);

	Espia::Acq& m_acq;
288
	Camera& m_cam;
289
	RoiChangedCallback *m_roi_chg_cb;
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
};


/*******************************************************************
 * \class FlipCtrlObj
 * \brief Control object providing Frelon flip interface
 *******************************************************************/

class FlipCtrlObj : public HwFlipCtrlObj
{
	DEB_CLASS_NAMESPC(DebModCamera, "FlipCtrlObj", "Frelon");

 public:
	FlipCtrlObj(Camera& cam);
	virtual ~FlipCtrlObj();

	virtual void setFlip(const Flip& flip);
	virtual void getFlip(Flip& flip);
	virtual void checkFlip(Flip& flip);
309
310
311
312
313
314

 private:
	Camera& m_cam;
};


315
316
317
318
319
320
321
322
323
324
325
326
327
/*******************************************************************
 * \class ShutterCtrlObj
 * \brief Control object providing Frelon shutter interface
 *******************************************************************/

class ShutterCtrlObj : public HwShutterCtrlObj
{
	DEB_CLASS(DebModCamera, "ShutterCtrlObj");

public:
	ShutterCtrlObj(Camera& cam);
	virtual ~ShutterCtrlObj();

328
329
330
331
	virtual bool checkMode(ShutterMode shut_mode) const;
	virtual void getModeList(ShutterModeList&  mode_list) const;
	virtual void setMode(ShutterMode  shut_mode);
	virtual void getMode(ShutterMode& shut_mode) const;
332

333
	virtual void setState(bool  shut_open);
334
	virtual void getState(bool& shut_open) const;
335
336

	virtual void setOpenTime (double  shut_open_time);
337
	virtual void getOpenTime (double& shut_open_time) const;
338
	virtual void setCloseTime(double  shut_close_time);
339
	virtual void getCloseTime(double& shut_close_time) const;
340
341
342
343
344

 private:
	Camera& m_cam;
};

345
346
347
348
349
350
351
352
353
354
355
356
357
358
/*******************************************************************
 * \class EventCtrlObj
 * \brief Control object providing Frelon event interface
 *******************************************************************/

class EventCtrlObj : public HwEventCtrlObj
{
	DEB_CLASS(DebModCamera, "EventCtrlObj");

public:
	EventCtrlObj();
	virtual ~EventCtrlObj();
};

359
360
361
362
363
364
365
/*******************************************************************
 * \class Interface
 * \brief Frelon hardware interface
 *******************************************************************/

class Interface : public HwInterface
{
366
367
	DEB_CLASS_NAMESPC(DebModCamera, "Interface", "Frelon");

368
369
370
371
 public:
	Interface(Espia::Acq& acq, BufferCtrlMgr& buffer_mgr, Camera& cam);
	virtual ~Interface();

372
	virtual void getCapList(CapList&) const;
373
374
375
376
377
378

	virtual void reset(ResetLevel reset_level);
	virtual void prepareAcq();
	virtual void startAcq();
	virtual void stopAcq();
	virtual void getStatus(StatusType& status);
379
	virtual int getNbHwAcquiredFrames();
380

381
382
	void resetDefaults();

383
384
385
386
387
388
389
390
391
392
 private:
	Espia::Acq&    m_acq;
	BufferCtrlMgr& m_buffer_mgr;
	Camera&        m_cam;

	CapList m_cap_list;
	DetInfoCtrlObj m_det_info;
	BufferCtrlObj  m_buffer;
	SyncCtrlObj    m_sync;
	BinCtrlObj     m_bin;
393
	RoiCtrlObj     m_roi;
394
	FlipCtrlObj    m_flip;
395
	ShutterCtrlObj m_shutter;
396
397
398
399
	EventCtrlObj   m_event;

	Frelon::AcqEndCallback m_acq_end_cb;
	Frelon::EventCallback  m_event_cb;
400
401
402
403
404
405
406
407
408
409
};




} // namespace Frelon

} // namespace lima

#endif // FRELONINTERFACE_H