//=============================================================================
//
// file :        AcquireWaveformLecroy.h
//
// description : Include for the AcquireWaveformLecroy class.
//
// project :	Acquire_Waveform_Lecroy_Prj
//
// $Author: xavela $
//
// $Revision: 1.3 $
//
// $Log: not supported by cvs2svn $
// Revision 1.2  2004/10/05 13:09:10  xavela
// Xavier : memory allocation in read_attr_hardware() method.
// calculation of offset of the begining of the struct, which contains the context of the waveform acquisition, in the received block data.
//
// Revision 1.1.1.1  2004/09/29 15:42:14  syldup
// Initial import.
//
//
// copyleft :     Synchrotron SOLEIL
//                L'Orme des Merisiers
//                Saint-Aubin - BP 48

//
//=============================================================================
//
//  		This file is generated by POGO
//	(Program Obviously used to Generate tango Object)
//
//         (c) - Software Engineering Group - ESRF
//=============================================================================
#ifndef _ACQUIREWAVEFORMLECROY_H
#define _ACQUIREWAVEFORMLECROY_H

#include <tango.h>
//using namespace Tango;
#include "..\include\SocketLecroy.h"
#include "..\include\SocketException.h"
#include "..\include\Waveform.h"
#include "..\include\WaveformException.h"

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

 //	Add your own constants definitions here.
 //-----------------------------------------------
const int MAX_STRING_LENGTH = 256;
const int MAX_SIZE			= 150000;


namespace AcquireWaveformLecroy
{

/**
 * Class Description:
 * This class allows the acquisition of a waveform (the description and the data),
 *	from a specific channel and from any Lecroy scope series.
 *	The description is a structure which contains in particular :
 *	the length of the array 1 (the raw data)
 *	the length of the array 2 (2nd part of the calculated waveform data, if any)
 *	the timebase
 *	the total length of the acquired data (lgth array1 + lgth array2)
 *	.... its represents the context of the acquisition.
 *	
 *	NOTE :
 *	for all Lecroy scope, the port number is the same : 1861
 */

/*
 *	Device States Description:
 *	Tango::OPEN :	The socket TCP IP is successfully opened between the Lecroy scope and
 *			this DServer.
 *	Tango::CLOSE :	The communication between the Lecroy scope and the DServer is closed.
 *	Tango::FAULT :	The communication between the Lecroy scope and the DServer is not done.
 *	Tango::ALARM :	An error occured during a Write or Read command.
 */


class AcquireWaveformLecroy: public Tango::Device_2Impl
{
public :
	//	Add your own data members here
	//-----------------------------------------


	//	Here is the Start of the automatic code generation part
	//-------------------------------------------------------------	
/**
 *	@name attributes
 *	Attributs member data.
 */
//@{
		Tango::DevShort	*attr_rawWaveformData_read;
		Tango::DevDouble	*attr_verticalScaledData_read;
		Tango::DevLong	*attr_waveArray1_read;
		Tango::DevLong	*attr_waveArrayCount_read;
		Tango::DevShort	*attr_nominalBits_read;
		Tango::DevDouble	*attr_horizontalInterval_read;
		Tango::DevDouble	*attr_horizontalOffset_read;
		Tango::DevDouble	*attr_verticalGain_read;
		Tango::DevDouble	*attr_verticalOffset_read;
		Tango::DevString	*attr_triggerTime_read;
//@}

/**
 *	@name Device properties
 *	Device properties member data.
 */
//@{
/**
 *	The IP address of the Lecroy scope to build a connection with.
 */
	string	iPaddress;
/**
 *	The name of channel on which the acquisition will be done.
 *	This name must be composed with two caracters : (a letter followed by a number)
 *	C for a physical channel
 *	F for a calculated waveform
 *	M for a memorised waveform
 *	...
 *	Example : C2 (is the channel 2)
 *	Default : C1 (channel 1
 */
	string	channelName;
//@}

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

/**@name Destructor
 * Only one desctructor is defined for this class */
//@{
/**
 * The object desctructor.
 */	
	~AcquireWaveformLecroy() { 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 AcquireWaveformLecroy methods prototypes
 */

//@{
/**
 *	Hardware acquisition for attributes.
 */
	virtual void read_attr_hardware(vector<long> &attr_list);
/**
 *	Extract real attribute values from hardware acquisition result.
 */
	virtual void read_attr(Tango::Attribute &attr);

/**
 *	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
	//-----------------------------------------
	SocketLecroy	*ptr_com;
	WaveForm_data	*waveform_ptr;
	short*	data_value;
	double* data_scaled_value;

	//- Method to convert all lecroy exceptions (type Waveform or Socket exceptions) on Tango exception
	Tango::DevFailed lecroy_to_tango_exception(const lecroy::LecroyException& de);
};

}	// namespace

#endif	// _ACQUIREWAVEFORMLECROY_H