LecroyInterface.h 11.1 KB
Newer Older
Alessio Igor Bogani's avatar
Alessio Igor Bogani committed
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
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
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
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
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
//=============================================================================
//
// file :        LecroyInterface.h
//
// description : Include for the LecroyInterface class.
//
// project :	
//
// $Author: claudio $
//
// $Revision: 1.3 $
//
// $Log: LecroyInterface.h,v $
// Revision 1.3  2020-01-13 14:06:27  claudio
// use TANG_BASE_CLASS
//
// Revision 1.2  2019-06-13 07:35:44  alessio
// Move to Tango 9
//
// Revision 1.1  2011-02-01 08:15:27  alessio
// Move source files to src/
//
// Revision 1.6  2009/01/14 11:06:09  enrico
// Completed comments and descriptions; generated documents.
// ME
//
// Revision 1.5  2008/09/26 15:03:48  enrico
// Added commands to read counters in Pass/Fail mode
// (i.e. GetPassFailTotCounter and GetPassFailPassedCounter)
// ME
//
// Revision 1.4  2008/09/25 09:49:52  enrico
// Added Normal/Stop trigger mode/Clear sweeps commands.
// ...waiting for Lecroy engineers about misfunction of MTPC? command.
// ME
//
// Revision 1.3  2008/07/09 10:45:11  enrico
// Memory leak resolved. ME
//
// Revision 1.2  2008/07/02 15:11:22  enrico
// Added Parameter command to allow request custom parameter data (P1-P4)
// Added attributes for wave parameters such as NominalBits, VerticalScaledData
// ecc.
//
//
// copyleft :   Sincrotrone Trieste S.C.p.A.
//              Strada Statale 14 - km 163,5 in AREA Science Park
//              34012 Basovizza, Trieste
//              ITALY
//
//=============================================================================
//
//  		This file is generated by POGO
//	(Program Obviously used to Generate tango Object)
//
//         (c) - Software Engineering Group - ESRF
//=============================================================================
#ifndef _LECROYINTERFACE_H
#define _LECROYINTERFACE_H

#include <tango.h>
//using namespace Tango;
#include <sys/time.h>
#include <time.h>
#include <stdlib.h>
#include <errno.h>
#include <string.h>
#include <sys/socket.h>
#include <sys/ioctl.h>
#include <netinet/in.h>
#include <arpa/inet.h>
#include <netdb.h>
#include "SocketLecroy.h"
#include "Waveform.h"
#include "WaveformException.h"

const short BUF_LEN=512;
const int MAX_STRING_LENGTH = 256;
const int MAX_SIZE = 150000;
//const int MAX_WAVEFORM_DATA_LENGTH = 150000;

/**
 * @author	$Author: claudio $
 * @version	$Revision: 1.3 $
 */

 //	Add your own constants definitions here.
 //-----------------------------------------------


namespace LecroyInterface_ns
{

/**
 * Class Description:
 * 
 */

/*
 *	Device States Description:
*  Tango::OPEN :   *
*  Tango::CLOSE :  *
*  Tango::FAULT :  *
*  Tango::ALARM :
 */


class LecroyInterface: public TANGO_BASE_CLASS
{
public :
	//	Add your own data members here
	//-----------------------------------------


	//	Here is the Start of the automatic code generation part
	//-------------------------------------------------------------	
/**
 *	@name attributes
 *	Attributs member data.
 */
//@{
		Tango::DevString	*attr_TriggerTime_read;
		Tango::DevDouble	*attr_VerticalOffset_read;
		Tango::DevDouble	*attr_VerticalGain_read;
		Tango::DevDouble	*attr_HorizontalOffset_read;
		Tango::DevDouble	*attr_HorizontalInterval_read;
		Tango::DevShort	*attr_NominalBits_read;
		Tango::DevLong	*attr_WaveArray2_read;
		Tango::DevLong	*attr_WaveArray1_read;
		Tango::DevLong	*attr_WaveArrayCount_read;
		Tango::DevDouble	*attr_VerticalScaledData_read;
		Tango::DevShort	*attr_RawWaveformData_read;
//@}

/**
 *	@name Device properties
 *	Device properties member data.
 */
//@{
/**
 *	
 */
	string	ipAddress;
//@}

/**@name Constructors
 * Miscellaneous constructors */
//@{
/**
 * Constructs a newly allocated Command object.
 *
 *	@param cl	Class.
 *	@param s 	Device Name
 */
	LecroyInterface(Tango::DeviceClass *cl,string &s);
/**
 * Constructs a newly allocated Command object.
 *
 *	@param cl	Class.
 *	@param s 	Device Name
 */
	LecroyInterface(Tango::DeviceClass *cl,const char *s);
/**
 * Constructs a newly allocated Command object.
 *
 *	@param cl	Class.
 *	@param s 	Device name
 *	@param d	Device description.
 */
	LecroyInterface(Tango::DeviceClass *cl,const char *s,const char *d);
//@}

/**@name Destructor
 * Only one desctructor is defined for this class */
//@{
/**
 * The object desctructor.
 */	
	~LecroyInterface() {delete_device();};
/**
 *	will be called at device destruction or at init command.
 */
	void delete_device();
//@}

	
/**@name Miscellaneous methods */
//@{
/**
 *	Initialize the device
 */
	virtual void init_device();
/**
 *	Always executed method befor execution command method.
 */
	virtual void always_executed_hook();

//@}

/**
 * @name LecroyInterface methods prototypes
 */

//@{
/**
 *	Hardware acquisition for attributes.
 */
	virtual void read_attr_hardware(vector<long> &attr_list);
/**
 *	Extract real attribute values for TriggerTime acquisition result.
 */
	virtual void read_TriggerTime(Tango::Attribute &attr);
/**
 *	Extract real attribute values for VerticalOffset acquisition result.
 */
	virtual void read_VerticalOffset(Tango::Attribute &attr);
/**
 *	Extract real attribute values for VerticalGain acquisition result.
 */
	virtual void read_VerticalGain(Tango::Attribute &attr);
/**
 *	Extract real attribute values for HorizontalOffset acquisition result.
 */
	virtual void read_HorizontalOffset(Tango::Attribute &attr);
/**
 *	Extract real attribute values for HorizontalInterval acquisition result.
 */
	virtual void read_HorizontalInterval(Tango::Attribute &attr);
/**
 *	Extract real attribute values for NominalBits acquisition result.
 */
	virtual void read_NominalBits(Tango::Attribute &attr);
/**
 *	Extract real attribute values for WaveArray2 acquisition result.
 */
	virtual void read_WaveArray2(Tango::Attribute &attr);
/**
 *	Extract real attribute values for WaveArray1 acquisition result.
 */
	virtual void read_WaveArray1(Tango::Attribute &attr);
/**
 *	Extract real attribute values for WaveArrayCount acquisition result.
 */
	virtual void read_WaveArrayCount(Tango::Attribute &attr);
/**
 *	Extract real attribute values for VerticalScaledData acquisition result.
 */
	virtual void read_VerticalScaledData(Tango::Attribute &attr);
/**
 *	Extract real attribute values for RawWaveformData acquisition result.
 */
	virtual void read_RawWaveformData(Tango::Attribute &attr);
/**
 *	Read/Write allowed for TriggerTime attribute.
 */
	virtual bool is_TriggerTime_allowed(Tango::AttReqType type);
/**
 *	Read/Write allowed for VerticalOffset attribute.
 */
	virtual bool is_VerticalOffset_allowed(Tango::AttReqType type);
/**
 *	Read/Write allowed for VerticalGain attribute.
 */
	virtual bool is_VerticalGain_allowed(Tango::AttReqType type);
/**
 *	Read/Write allowed for HorizontalOffset attribute.
 */
	virtual bool is_HorizontalOffset_allowed(Tango::AttReqType type);
/**
 *	Read/Write allowed for HorizontalInterval attribute.
 */
	virtual bool is_HorizontalInterval_allowed(Tango::AttReqType type);
/**
 *	Read/Write allowed for NominalBits attribute.
 */
	virtual bool is_NominalBits_allowed(Tango::AttReqType type);
/**
 *	Read/Write allowed for WaveArray2 attribute.
 */
	virtual bool is_WaveArray2_allowed(Tango::AttReqType type);
/**
 *	Read/Write allowed for WaveArray1 attribute.
 */
	virtual bool is_WaveArray1_allowed(Tango::AttReqType type);
/**
 *	Read/Write allowed for WaveArrayCount attribute.
 */
	virtual bool is_WaveArrayCount_allowed(Tango::AttReqType type);
/**
 *	Read/Write allowed for VerticalScaledData attribute.
 */
	virtual bool is_VerticalScaledData_allowed(Tango::AttReqType type);
/**
 *	Read/Write allowed for RawWaveformData attribute.
 */
	virtual bool is_RawWaveformData_allowed(Tango::AttReqType type);
/**
 *	Execution allowed for Test command.
 */
	virtual bool is_Test_allowed(const CORBA::Any &any);
/**
 *	Execution allowed for GetRawWaveform command.
 */
	virtual bool is_GetRawWaveform_allowed(const CORBA::Any &any);
/**
 *	Execution allowed for SetChannel command.
 */
	virtual bool is_SetChannel_allowed(const CORBA::Any &any);
/**
 *	Execution allowed for GetParameter command.
 */
	virtual bool is_GetParameter_allowed(const CORBA::Any &any);
/**
 *	Execution allowed for SendCommand command.
 */
	virtual bool is_SendCommand_allowed(const CORBA::Any &any);
/**
 *	Execution allowed for StopAcquisition command.
 */
	virtual bool is_StopAcquisition_allowed(const CORBA::Any &any);
/**
 *	Execution allowed for StartAcquisition command.
 */
	virtual bool is_StartAcquisition_allowed(const CORBA::Any &any);
/**
 *	Execution allowed for ClearSweeps command.
 */
	virtual bool is_ClearSweeps_allowed(const CORBA::Any &any);
/**
 *	Execution allowed for GetPassFailTotCounter command.
 */
	virtual bool is_GetPassFailTotCounter_allowed(const CORBA::Any &any);
/**
 *	Execution allowed for GetPassFailPassedCounter command.
 */
	virtual bool is_GetPassFailPassedCounter_allowed(const CORBA::Any &any);
/**
 * Self explanatory: use at your own risk :)
 *	@return	
 *	@exception DevFailed
 */
	Tango::DevString	test();
/**
 * This commands fills and returns an array with the raw values of the waveform.
 *	@return	
 *	@exception DevFailed
 */
	Tango::DevVarShortArray	*get_raw_waveform();
/**
 * This command accepts a string (from C1 to C4 and from Z1 to Z4).
 *	The channel will be acquired when StartAcquisition command will be issued.
 *	At startup default channel is C1.
 *	@param	argin	
 *	@exception DevFailed
 */
	void	set_channel(Tango::DevString);
/**
 * This command returns the value of the parameter (configured directly on the oscilloscope).
 *	@param	argin	
 *	@return	
 *	@exception DevFailed
 */
	Tango::DevString	get_parameter(Tango::DevString);
/**
 * Send the command you type in argin to the scope.
 *	@param	argin	
 *	@return	
 *	@exception DevFailed
 */
	Tango::DevString	send_command(Tango::DevString);
/**
 * This command sets the STOP trigger mode
 *	@exception DevFailed
 */
	void	stop_acquisition();
/**
 * This command sets the NORMAL trigger mode.
 *	@exception DevFailed
 */
	void	start_acquisition();
/**
 * This command restarts the cumulative processing functions, e.g. FFT power average, Pass/Fail counters etc.
 *	@exception DevFailed
 */
	void	clear_sweeps();
/**
 * This command returns the total number of waveforms tested by Pass/Fail mask.
 *	@return	The counter
 *	@exception DevFailed
 */
	Tango::DevLong	get_pass_fail_tot_counter();
/**
 * This command returns the number of passed waveforms tested by Pass/Fail mask.
 *	@return	
 *	@exception DevFailed
 */
	Tango::DevLong	get_pass_fail_passed_counter();

/**
 *	Read the device properties from database
 */
	 void get_device_property();
//@}

	//	Here is the end of the automatic code generation part
	//-------------------------------------------------------------	



protected :	
	//	Add your own data members here
	//-----------------------------------------
	int		sockfd;
	struct		timeval tv;
	struct sockaddr_in	serv_addr;
	SocketLecroy*	ptr_com;
	bool		_is_communication_opened;
	WaveForm_data*	waveform_ptr;
	short*		data_value;
	double*		data_scaled_value;
	long		data_length;
	char		recvBuf[BUF_LEN];
	char		response[BUF_LEN];
	void		fileLogMsg(char *);
 	void		sendCmd (Tango::DevString cmd);
	void		getResponse();
	void		connect_loop();
	Tango::DevFailed lecroy_to_tango_exception(const lecroy::LecroyException& de);
};

}	// namespace_ns

#endif	// _LECROYINTERFACE_H