Skip to content
Snippets Groups Projects
Code owners
Assign users and groups as approvers for specific file changes. Learn more.
AcquireWaveformLecroy.h 9.96 KiB
//*******************************************************************************
//* Copyright (c) 2008-2014 Synchrotron SOLEIL
//* All rights reserved. This program and the accompanying materials
//* are made available under the terms of the GNU Lesser Public License v3
//* which accompanies this distribution, and is available at
//* http://www.gnu.org/licenses/lgpl.html
//******************************************************************************
//=============================================================================
//
// file :        AcquireWaveformLecroy.h
//
// description : Include for the AcquireWaveformLecroy class.
//
// project :	Acquire_Waveform_Lecroy_Prj
//
// $Author: xavela $
//
// $Revision: 1.10 $
//
// $Log: not supported by cvs2svn $
// Revision 1.9  2010/03/25 17:02:18  vince_soleil
// "Migration_Tango7"
//
// Revision 1.8  2008/04/24 13:08:44  syldup
// no message
//
// Revision 1.7  2008/02/28 09:02:05  xavela
// xavier :
// StateMachine file added !! (oups)
//
// Revision 1.5  2004/10/18 13:17:49  xavela
// xavier : add an attr waveArray2.
// Sorts attr in expert and operator view with Pogo.
// Inconsistencies removed.
//
// Revision 1.4  2004/10/07 09:21:18  xavela
// xavier : no cout now.
//
// Revision 1.3  2004/10/05 13:11:11  xavela
// Xavier : previous commit failed.
//
// 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>
#include <yat4tango/InnerAppender.h>
#include <yat4tango/YatLogAdapter.h>
//using namespace Tango;
#include "SocketLecroy.h"
#include "SocketException.h"
#include "Waveform.h"
#include "WaveformException.h"

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

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


namespace AcquireWaveformLecroy_ns
{

/**
 * 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_4Impl
{
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_waveArrayCount_read;
		Tango::DevLong	*attr_waveArray2_read;
		Tango::DevLong	*attr_waveArray1_read;
		Tango::DevDouble	*attr_verticalScaledData_read;
		Tango::DevShort	*attr_rawWaveformData_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 *cl,string &s);
/**
 * Constructs a newly allocated Command object.
 *
 *	@param cl	Class.
 *	@param s 	Device Name
 */
	AcquireWaveformLecroy(Tango::DeviceClass *cl,const char *s);
/**
 * Constructs a newly allocated Command object.
 *
 *	@param cl	Class.
 *	@param s 	Device name
 *	@param d	Device description.
 */
	AcquireWaveformLecroy(Tango::DeviceClass *cl,const char *s,const char *d);
//@}

/**@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 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 waveArrayCount acquisition result.
 */
	virtual void read_waveArrayCount(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 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 waveArrayCount attribute.
 */
	virtual bool is_waveArrayCount_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 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 WriteRead command.
 */
	virtual bool is_WriteRead_allowed(const CORBA::Any &any);
/**
 * Command to send a specific command to the Lecroy device
 *	@param	argin	command to send
 *	@return	device response (if any)
 *	@exception DevFailed
 */
	Tango::DevString	write_read(Tango::DevString);

/**
 *	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;
	char*			      _deviceResponse;
	short*			    data_value;
	long			      data_length;
	bool			      _is_communication_opened;

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

	void reallocate_spectrums(long new_data_size);
};

}	// namespace_ns

#endif	// _ACQUIREWAVEFORMLECROY_H