SimuHwInterface.cpp 6.69 KB
Newer Older
ahoms's avatar
ahoms committed
1
2
3
#include "SimuHwInterface.h"

using namespace lima;
4
using namespace std;
ahoms's avatar
ahoms committed
5

6
7
8
9
/*******************************************************************
 * \brief SimuDetInfoCtrlObj constructor
 *******************************************************************/

10
11
12
13
14
15
16
17
18
19
20
21
SimuDetInfoCtrlObj::SimuDetInfoCtrlObj(Simulator& simu)
	: m_simu(simu)
{
	m_iscb_act = false;
}

SimuDetInfoCtrlObj::~SimuDetInfoCtrlObj()
{
}

void SimuDetInfoCtrlObj::getMaxImageSize(Size& max_image_size)
{
22
23
	FrameDim fdim;
	m_simu.getFrameDim(fdim);
24
	max_image_size = fdim.getSize();
25
26
27
28
}

void SimuDetInfoCtrlObj::getDetectorImageSize(Size& det_image_size)
{
29
	m_simu.getMaxImageSize(det_image_size);
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
}

void SimuDetInfoCtrlObj::getDefImageType(ImageType& def_image_type)
{
	def_image_type = Bpp16;
}

void SimuDetInfoCtrlObj::setCurrImageType(ImageType curr_image_type)
{
	FrameDim fdim;
	m_simu.getFrameDim(fdim);
	fdim.setImageType(curr_image_type);
	m_simu.setFrameDim(fdim);
}

void SimuDetInfoCtrlObj::getCurrImageType(ImageType& curr_image_type)
{
	FrameDim fdim;
	m_simu.getFrameDim(fdim);
	curr_image_type = fdim.getImageType();
}

void SimuDetInfoCtrlObj::getPixelSize(double& pixel_size)
{
	pixel_size = 1e-6;
}

57
void SimuDetInfoCtrlObj::getDetectorType(string& det_type)
58
59
60
61
{
	det_type = "Simulator";
}

62
void SimuDetInfoCtrlObj::getDetectorModel(string& det_model)
63
64
65
66
67
68
69
70
71
72
{
	det_model = "PeakGenerator";
}

void SimuDetInfoCtrlObj::setMaxImageSizeCallbackActive(bool cb_active)
{
	m_iscb_act = cb_active;
}


73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
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
223
224
225
226
227
/*******************************************************************
 * \brief SimuBufferCtrlObj constructor
 *******************************************************************/

SimuBufferCtrlObj::SimuBufferCtrlObj(Simulator& simu)
	: m_simu(simu), 
	  m_buffer_mgr(simu.getBufferMgr())
{
}

SimuBufferCtrlObj::~SimuBufferCtrlObj()
{
}

void SimuBufferCtrlObj::setFrameDim(const FrameDim& frame_dim)
{
	m_buffer_mgr.setFrameDim(frame_dim);
}

void SimuBufferCtrlObj::getFramedim(FrameDim& frame_dim)
{
	m_buffer_mgr.getFrameDim(frame_dim);
}

void SimuBufferCtrlObj::setNbBuffers(int nb_buffers)
{
	m_buffer_mgr.setNbBuffers(nb_buffers);
}

void SimuBufferCtrlObj::getNbBuffers(int& nb_buffers)
{
	m_buffer_mgr.getNbBuffers(nb_buffers);
}

void SimuBufferCtrlObj::setNbConcatFrames(int nb_concat_frames)
{
	m_buffer_mgr.setNbConcatFrames(nb_concat_frames);
}

void SimuBufferCtrlObj::getNbConcatFrames(int& nb_concat_frames)
{
	m_buffer_mgr.getNbConcatFrames(nb_concat_frames);
}

void SimuBufferCtrlObj::setNbAccFrames(int nb_acc_frames)
{
	m_buffer_mgr.setNbAccFrames(nb_acc_frames);
}

void SimuBufferCtrlObj::getNbAccFrames(int& nb_acc_frames)
{
	m_buffer_mgr.getNbAccFrames(nb_acc_frames);
}

void SimuBufferCtrlObj::getMaxNbBuffers(int& max_nb_buffers)
{
	m_buffer_mgr.getMaxNbBuffers(max_nb_buffers);
}

void *SimuBufferCtrlObj::getBufferPtr(int buffer_nb)
{
	return m_buffer_mgr.getBufferPtr(buffer_nb);
}

void *SimuBufferCtrlObj::getFramePtr(int acq_frame_nb)
{
	return m_buffer_mgr.getFramePtr(acq_frame_nb);
}

void SimuBufferCtrlObj::getStartTimestamp(Timestamp& start_ts)
{
	m_buffer_mgr.getStartTimestamp(start_ts);
}

void SimuBufferCtrlObj::getFrameInfo(int acq_frame_nb, HwFrameInfoType& info)
{
	m_buffer_mgr.getFrameInfo(acq_frame_nb, info);
}

void SimuBufferCtrlObj::registerFrameCallback(HwFrameCallback *frame_cb)
{
	m_buffer_mgr.registerFrameCallback(frame_cb);
}

void SimuBufferCtrlObj::unregisterFrameCallback(HwFrameCallback *frame_cb)
{
	m_buffer_mgr.unregisterFrameCallback(frame_cb);
}


/*******************************************************************
 * \brief SimuSyncCtrlObj constructor
 *******************************************************************/

SimuSyncCtrlObj::SimuSyncCtrlObj(Simulator& simu)
	: m_simu(simu)
{
}

SimuSyncCtrlObj::~SimuSyncCtrlObj()
{
}

void SimuSyncCtrlObj::setTrigMode(TrigMode trig_mode)
{
	trig_mode = IntTrig;
}

void SimuSyncCtrlObj::getTrigMode(TrigMode& trig_mode)
{
	if (trig_mode != IntTrig)
		throw LIMA_HW_EXC(InvalidValue, "Invalid (external) trigger");
}

void SimuSyncCtrlObj::setExpTime(double exp_time)
{
	m_simu.setExpTime(exp_time);
}

void SimuSyncCtrlObj::getExpTime(double& exp_time)
{
	m_simu.getExpTime(exp_time);
}

void SimuSyncCtrlObj::setLatTime(double lat_time)
{
	m_simu.setLatTime(lat_time);
}

void SimuSyncCtrlObj::getLatTime(double& lat_time)
{
	m_simu.getLatTime(lat_time);
}

void SimuSyncCtrlObj::setNbFrames(int nb_frames)
{
	m_simu.setNbFrames(nb_frames);
}

void SimuSyncCtrlObj::getNbFrames(int& nb_frames)
{
	m_simu.getNbFrames(nb_frames);
}

void SimuSyncCtrlObj::getValidRanges(ValidRangesType& valid_ranges)
{
	double min_time = 10e-9;;
	double max_time = 1e6;
	valid_ranges.min_exp_time = min_time;
	valid_ranges.max_exp_time = max_time;
	valid_ranges.min_lat_time = min_time;
	valid_ranges.max_lat_time = max_time;
}


228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
/*******************************************************************
 * \brief SimuBinCtrlObj constructor
 *******************************************************************/

SimuBinCtrlObj::SimuBinCtrlObj(Simulator& simu)
	: m_simu(simu)
{
}

SimuBinCtrlObj::~SimuBinCtrlObj()
{
}

void SimuBinCtrlObj::setBin(const Bin& bin)
{
	m_simu.setBin(bin);
}

void SimuBinCtrlObj::getBin(Bin& bin)
{
	m_simu.getBin(bin);
}

void SimuBinCtrlObj::checkBin(Bin& bin)
{
	m_simu.checkBin(bin);
}


257
258
259
/*******************************************************************
 * \brief SimuHwInterface constructor
 *******************************************************************/
ahoms's avatar
ahoms committed
260
261

SimuHwInterface::SimuHwInterface(Simulator& simu)
262
263
	: m_simu(simu), m_det_info(simu), m_buffer(simu), m_sync(simu),
	  m_bin(simu)
ahoms's avatar
ahoms committed
264
{
265
266
	HwDetInfoCtrlObj *det_info = &m_det_info;
	m_cap_list.push_back(HwCap(det_info));
ahoms's avatar
ahoms committed
267

268
269
	HwBufferCtrlObj *buffer = &m_buffer;
	m_cap_list.push_back(HwCap(buffer));
ahoms's avatar
ahoms committed
270

271
272
	HwSyncCtrlObj *sync = &m_sync;
	m_cap_list.push_back(HwCap(sync));
273
274
275

	HwBinCtrlObj *bin = &m_bin;
	m_cap_list.push_back(HwCap(bin));
ahoms's avatar
ahoms committed
276
277
}

278
279
280
281
282
283
284
285
286
287
288
SimuHwInterface::~SimuHwInterface()
{
}

const HwInterface::CapList& SimuHwInterface::getCapList() const
{
	return m_cap_list;
}

void SimuHwInterface::reset(ResetLevel reset_level)
{
289
	m_simu.reset();
290
291
292
293
294
295
296
297
}

void SimuHwInterface::prepareAcq()
{
}

void SimuHwInterface::startAcq()
{
298
	m_simu.startAcq();
299
300
301
302
}

void SimuHwInterface::stopAcq()
{
303
	m_simu.stopAcq();
304
305
306
307
}

void SimuHwInterface::getStatus(StatusType& status)
{
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
	Simulator::Status simu_status = m_simu.getStatus();
	switch (simu_status) {
	case Simulator::Ready:
		status.acq = AcqReady;
		status.det = DetIdle;
		break;
	case Simulator::Exposure:
		status.det = Exposure;
		goto Running;
	case Simulator::Readout:
		status.det = Readout;
		goto Running;
	case Simulator::Latency:
		status.det = Latency;
	Running:
		status.acq = AcqRunning;
		break;
	}
	status.det_mask = DetStatus(Exposure | Readout | Latency);
327
328
329
330
331
332
333
}

int SimuHwInterface::getNbAcquiredFrames()
{
	return m_simu.getNbAcquiredFrames();
}