/*----- PROTECTED REGION ID(DataVampire.h) ENABLED START -----*/
/* clang-format on */
//=============================================================================
//
// file :        DataVampire.h
//
// description : Include file for the DataVampire class
//
// project :     DataVampire
//
// This file is part of Tango device class.
//
// Tango 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.
//
// Tango 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 Tango.  If not, see <http://www.gnu.org/licenses/>.
//
//
//
//=============================================================================
//                This file is generated by POGO
//        (Program Obviously used to Generate tango Object)
//=============================================================================


#ifndef DataVampire_H
#define DataVampire_H

#include <ostream>
#include <iostream>
#include <vector>

#include <tango/tango.h>

#define DATAVAMPIRE_MAX_STR_LEN 256

#define DATAVAMPIRE_MAX_SIZE 200000

class acqthread;


/* clang-format off */
/*----- PROTECTED REGION END -----*/	//	DataVampire.h

/**
 *  DataVampire class description:
 *    Get vectors of 1D or 2D data and calculate sum, mean, horpos, verpos, horsigma, versigma, numsamples
 */

namespace DataVampire_ns
{
/*----- PROTECTED REGION ID(DataVampire::Additional Class Declarations) ENABLED START -----*/
/* clang-format on */
//	Additional Class Declarations
/* clang-format off */



/*----- PROTECTED REGION END -----*/	//	DataVampire::Additional Class Declarations

class DataVampire : public TANGO_BASE_CLASS
{

/*----- PROTECTED REGION ID(DataVampire::Data Members) ENABLED START -----*/
/* clang-format on */
//	Add your own data members
/* clang-format off */

public:
	friend class acqthread;

	struct acq_array_t 
	{
		int32_t bn;	
		double sum;
		double mean;
		double horpos;
		double verpos;
		double horposstd;
		double verposstd;
		double validvalues;
	};
	int array_idx;
	acq_array_t acq_array[DATAVAMPIRE_MAX_SIZE];

	Tango::DeviceProxy *device, *bn_device;
	std::string c_device_name, command_name, bn_device_name, bn_attr_name;

	uint32_t roi_dim;
	long cmd_in_type, cmd_out_type;
	int32_t num_rows_image, num_cols_image, num_cols_spectrum;
	int32_t last_bn;
	double frequency;

	omni_mutex *mutex;
	bool abort_flag;
	acqthread *acqloop;


/*----- PROTECTED REGION END -----*/	//	DataVampire::Data Members

//	Device property data members
public:
	//	HorCalib:	
	vector<Tango::DevDouble>	horCalib;
	//	VerCalib:	
	vector<Tango::DevDouble>	verCalib;
	//	RoiParam:	
	vector<Tango::DevLong>	roiParam;
	//	CommandString:	
	string	commandString;
	//	BunchNumberString:	
	string	bunchNumberString;

//	Attribute data members
public:
	Tango::DevDouble	*attr_MinThreshold_read;
	Tango::DevDouble	*attr_MaxThreshold_read;
	Tango::DevString	*attr_CommandString_read;
	Tango::DevLong	*attr_PollingPeriod_read;
	Tango::DevLong	*attr_PollingSamples_read;
	Tango::DevDouble	*attr_Sum_read;
	Tango::DevDouble	*attr_Mean_read;
	Tango::DevDouble	*attr_HorPos_read;
	Tango::DevDouble	*attr_VerPos_read;
	Tango::DevDouble	*attr_HorPosStd_read;
	Tango::DevLong	*attr_ValidValues_read;
	Tango::DevBoolean	*attr_EnableAcquisition_read;
	Tango::DevLong	*attr_CacheSize_read;
	Tango::DevLong	*attr_AutoBackgroundSamples_read;
	Tango::DevBoolean	*attr_PostAcqRoi_read;
	Tango::DevLong	*attr_Width_read;
	Tango::DevLong	*attr_Height_read;
	Tango::DevDouble	*attr_VerPosStd_read;
	Tango::DevBoolean	*attr_EnablePolling_read;
	Tango::DevLong	*attr_RoiParam_read;
	Tango::DevDouble	*attr_Spectrum_read;
	Tango::DevDouble	*attr_HorBackground_read;
	Tango::DevDouble	*attr_VerBackground_read;
	Tango::DevDouble	*attr_Image_read;

//	Constructors and destructors
public:
	/**
	 * Constructs a newly device object.
	 *
	 *	@param cl	Class.
	 *	@param s 	Device Name
	 */
	DataVampire(Tango::DeviceClass *cl,string &s);
	/**
	 * Constructs a newly device object.
	 *
	 *	@param cl	Class.
	 *	@param s 	Device Name
	 */
	DataVampire(Tango::DeviceClass *cl,const char *s);
	/**
	 * Constructs a newly device object.
	 *
	 *	@param cl	Class.
	 *	@param s 	Device name
	 *	@param d	Device description.
	 */
	DataVampire(Tango::DeviceClass *cl,const char *s,const char *d);
	/**
	 * The device object destructor.
	 */
	~DataVampire() {delete_device();};


//	Miscellaneous methods
public:
	/*
	 *	will be called at device destruction or at init command.
	 */
	void delete_device();
	/*
	 *	Initialize the device
	 */
	virtual void init_device();
	/*
	 *	Read the device properties from database
	 */
	void get_device_property();
	/*
	 *	Always executed method before execution command method.
	 */
	virtual void always_executed_hook();


//	Attribute methods
public:
	//--------------------------------------------------------
	/*
	 *	Method      : DataVampire::read_attr_hardware()
	 *	Description : Hardware acquisition for attributes.
	 */
	//--------------------------------------------------------
	virtual void read_attr_hardware(vector<long> &attr_list);
	//--------------------------------------------------------
	/*
	 *	Method      : DataVampire::write_attr_hardware()
	 *	Description : Hardware writing for attributes.
	 */
	//--------------------------------------------------------
	virtual void write_attr_hardware(vector<long> &attr_list);

/**
 *	Attribute MinThreshold related methods
 *	Description: 
 *
 *	Data type:	Tango::DevDouble
 *	Attr type:	Scalar
 */
	virtual void read_MinThreshold(Tango::Attribute &attr);
	virtual void write_MinThreshold(Tango::WAttribute &attr);
	virtual bool is_MinThreshold_allowed(Tango::AttReqType type);
/**
 *	Attribute MaxThreshold related methods
 *	Description: 
 *
 *	Data type:	Tango::DevDouble
 *	Attr type:	Scalar
 */
	virtual void read_MaxThreshold(Tango::Attribute &attr);
	virtual void write_MaxThreshold(Tango::WAttribute &attr);
	virtual bool is_MaxThreshold_allowed(Tango::AttReqType type);
/**
 *	Attribute CommandString related methods
 *	Description: 
 *
 *	Data type:	Tango::DevString
 *	Attr type:	Scalar
 */
	virtual void read_CommandString(Tango::Attribute &attr);
	virtual void write_CommandString(Tango::WAttribute &attr);
	virtual bool is_CommandString_allowed(Tango::AttReqType type);
/**
 *	Attribute PollingPeriod related methods
 *	Description: -1: disabled
 *
 *	Data type:	Tango::DevLong
 *	Attr type:	Scalar
 */
	virtual void read_PollingPeriod(Tango::Attribute &attr);
	virtual void write_PollingPeriod(Tango::WAttribute &attr);
	virtual bool is_PollingPeriod_allowed(Tango::AttReqType type);
/**
 *	Attribute PollingSamples related methods
 *	Description: -1: disabled
 *
 *	Data type:	Tango::DevLong
 *	Attr type:	Scalar
 */
	virtual void read_PollingSamples(Tango::Attribute &attr);
	virtual void write_PollingSamples(Tango::WAttribute &attr);
	virtual bool is_PollingSamples_allowed(Tango::AttReqType type);
/**
 *	Attribute Sum related methods
 *	Description: 
 *
 *	Data type:	Tango::DevDouble
 *	Attr type:	Scalar
 */
	virtual void read_Sum(Tango::Attribute &attr);
	virtual bool is_Sum_allowed(Tango::AttReqType type);
/**
 *	Attribute Mean related methods
 *	Description: 
 *
 *	Data type:	Tango::DevDouble
 *	Attr type:	Scalar
 */
	virtual void read_Mean(Tango::Attribute &attr);
	virtual bool is_Mean_allowed(Tango::AttReqType type);
/**
 *	Attribute HorPos related methods
 *	Description: 
 *
 *	Data type:	Tango::DevDouble
 *	Attr type:	Scalar
 */
	virtual void read_HorPos(Tango::Attribute &attr);
	virtual bool is_HorPos_allowed(Tango::AttReqType type);
/**
 *	Attribute VerPos related methods
 *	Description: 
 *
 *	Data type:	Tango::DevDouble
 *	Attr type:	Scalar
 */
	virtual void read_VerPos(Tango::Attribute &attr);
	virtual bool is_VerPos_allowed(Tango::AttReqType type);
/**
 *	Attribute HorPosStd related methods
 *	Description: 
 *
 *	Data type:	Tango::DevDouble
 *	Attr type:	Scalar
 */
	virtual void read_HorPosStd(Tango::Attribute &attr);
	virtual bool is_HorPosStd_allowed(Tango::AttReqType type);
/**
 *	Attribute ValidValues related methods
 *	Description: 
 *
 *	Data type:	Tango::DevLong
 *	Attr type:	Scalar
 */
	virtual void read_ValidValues(Tango::Attribute &attr);
	virtual bool is_ValidValues_allowed(Tango::AttReqType type);
/**
 *	Attribute EnableAcquisition related methods
 *	Description: 
 *
 *	Data type:	Tango::DevBoolean
 *	Attr type:	Scalar
 */
	virtual void read_EnableAcquisition(Tango::Attribute &attr);
	virtual void write_EnableAcquisition(Tango::WAttribute &attr);
	virtual bool is_EnableAcquisition_allowed(Tango::AttReqType type);
/**
 *	Attribute CacheSize related methods
 *	Description: 
 *
 *	Data type:	Tango::DevLong
 *	Attr type:	Scalar
 */
	virtual void read_CacheSize(Tango::Attribute &attr);
	virtual void write_CacheSize(Tango::WAttribute &attr);
	virtual bool is_CacheSize_allowed(Tango::AttReqType type);
/**
 *	Attribute AutoBackgroundSamples related methods
 *	Description: 0 to disable
 *
 *	Data type:	Tango::DevLong
 *	Attr type:	Scalar
 */
	virtual void read_AutoBackgroundSamples(Tango::Attribute &attr);
	virtual void write_AutoBackgroundSamples(Tango::WAttribute &attr);
	virtual bool is_AutoBackgroundSamples_allowed(Tango::AttReqType type);
/**
 *	Attribute PostAcqRoi related methods
 *	Description: 
 *
 *	Data type:	Tango::DevBoolean
 *	Attr type:	Scalar
 */
	virtual void read_PostAcqRoi(Tango::Attribute &attr);
	virtual void write_PostAcqRoi(Tango::WAttribute &attr);
	virtual bool is_PostAcqRoi_allowed(Tango::AttReqType type);
/**
 *	Attribute Width related methods
 *	Description: 
 *
 *	Data type:	Tango::DevLong
 *	Attr type:	Scalar
 */
	virtual void read_Width(Tango::Attribute &attr);
	virtual void write_Width(Tango::WAttribute &attr);
	virtual bool is_Width_allowed(Tango::AttReqType type);
/**
 *	Attribute Height related methods
 *	Description: 
 *
 *	Data type:	Tango::DevLong
 *	Attr type:	Scalar
 */
	virtual void read_Height(Tango::Attribute &attr);
	virtual void write_Height(Tango::WAttribute &attr);
	virtual bool is_Height_allowed(Tango::AttReqType type);
/**
 *	Attribute VerPosStd related methods
 *	Description: 
 *
 *	Data type:	Tango::DevDouble
 *	Attr type:	Scalar
 */
	virtual void read_VerPosStd(Tango::Attribute &attr);
	virtual bool is_VerPosStd_allowed(Tango::AttReqType type);
/**
 *	Attribute EnablePolling related methods
 *	Description: 
 *
 *	Data type:	Tango::DevBoolean
 *	Attr type:	Scalar
 */
	virtual void read_EnablePolling(Tango::Attribute &attr);
	virtual void write_EnablePolling(Tango::WAttribute &attr);
	virtual bool is_EnablePolling_allowed(Tango::AttReqType type);
/**
 *	Attribute RoiParam related methods
 *	Description: 
 *
 *	Data type:	Tango::DevLong
 *	Attr type:	Spectrum max = 4
 */
	virtual void read_RoiParam(Tango::Attribute &attr);
	virtual void write_RoiParam(Tango::WAttribute &attr);
	virtual bool is_RoiParam_allowed(Tango::AttReqType type);
/**
 *	Attribute Spectrum related methods
 *	Description: 
 *
 *	Data type:	Tango::DevDouble
 *	Attr type:	Spectrum max = 1000000
 */
	virtual void read_Spectrum(Tango::Attribute &attr);
	virtual bool is_Spectrum_allowed(Tango::AttReqType type);
/**
 *	Attribute HorBackground related methods
 *	Description: 
 *
 *	Data type:	Tango::DevDouble
 *	Attr type:	Spectrum max = 1000000
 */
	virtual void read_HorBackground(Tango::Attribute &attr);
	virtual bool is_HorBackground_allowed(Tango::AttReqType type);
/**
 *	Attribute VerBackground related methods
 *	Description: 
 *
 *	Data type:	Tango::DevDouble
 *	Attr type:	Spectrum max = 1000000
 */
	virtual void read_VerBackground(Tango::Attribute &attr);
	virtual bool is_VerBackground_allowed(Tango::AttReqType type);
/**
 *	Attribute Image related methods
 *	Description: 
 *
 *	Data type:	Tango::DevDouble
 *	Attr type:	Image max = 5000 x 5000
 */
	virtual void read_Image(Tango::Attribute &attr);
	virtual bool is_Image_allowed(Tango::AttReqType type);


	//--------------------------------------------------------
	/**
	 *	Method      : DataVampire::add_dynamic_attributes()
	 *	Description : Add dynamic attributes if any.
	 */
	//--------------------------------------------------------
	void add_dynamic_attributes();




//	Command related methods
public:
	/**
	 *	Command GetSum related method
	 *	Description: 
	 *
	 *	@param argin mode,samples; mode,bunch start,bunch end
	 *	@returns values
	 */
	virtual Tango::DevVarDoubleArray *get_sum(const Tango::DevVarLongArray *argin);
	virtual bool is_GetSum_allowed(const CORBA::Any &any);
	/**
	 *	Command GetMean related method
	 *	Description: 
	 *
	 *	@param argin mode,samples; mode,bunch start,bunch end
	 *	@returns values
	 */
	virtual Tango::DevVarDoubleArray *get_mean(const Tango::DevVarLongArray *argin);
	virtual bool is_GetMean_allowed(const CORBA::Any &any);
	/**
	 *	Command GetHorPos related method
	 *	Description: 
	 *
	 *	@param argin mode,samples; mode,bunch start,bunch end
	 *	@returns values
	 */
	virtual Tango::DevVarDoubleArray *get_hor_pos(const Tango::DevVarLongArray *argin);
	virtual bool is_GetHorPos_allowed(const CORBA::Any &any);
	/**
	 *	Command GetVerPos related method
	 *	Description: 
	 *
	 *	@param argin mode,samples; mode,bunch start,bunch end
	 *	@returns values
	 */
	virtual Tango::DevVarDoubleArray *get_ver_pos(const Tango::DevVarLongArray *argin);
	virtual bool is_GetVerPos_allowed(const CORBA::Any &any);
	/**
	 *	Command GetHorPosStd related method
	 *	Description: 
	 *
	 *	@param argin mode,samples; mode,bunch start,bunch end
	 *	@returns values
	 */
	virtual Tango::DevVarDoubleArray *get_hor_pos_std(const Tango::DevVarLongArray *argin);
	virtual bool is_GetHorPosStd_allowed(const CORBA::Any &any);
	/**
	 *	Command GetVerPosStd related method
	 *	Description: 
	 *
	 *	@param argin mode,samples; mode,bunch start,bunch end
	 *	@returns values
	 */
	virtual Tango::DevVarDoubleArray *get_ver_pos_std(const Tango::DevVarLongArray *argin);
	virtual bool is_GetVerPosStd_allowed(const CORBA::Any &any);
	/**
	 *	Command GetValidValues related method
	 *	Description: 
	 *
	 *	@param argin mode,samples; mode,bunch start,bunch end
	 *	@returns values
	 */
	virtual Tango::DevVarDoubleArray *get_valid_values(const Tango::DevVarLongArray *argin);
	virtual bool is_GetValidValues_allowed(const CORBA::Any &any);
	/**
	 *	Command SetBackground related method
	 *	Description: 
	 *
	 */
	virtual void set_background();
	virtual bool is_SetBackground_allowed(const CORBA::Any &any);


	//--------------------------------------------------------
	/**
	 *	Method      : DataVampire::add_dynamic_commands()
	 *	Description : Add dynamic commands if any.
	 */
	//--------------------------------------------------------
	void add_dynamic_commands();

/*----- PROTECTED REGION ID(DataVampire::Additional Method prototypes) ENABLED START -----*/
/* clang-format on */
//	Additional Method prototypes
/* clang-format off */
void cmd_extract_values(Tango::DeviceData *cmd_value, std::vector<double> &val, std::vector<std::string> &val_string);
Tango::DeviceData cmd_insert_values(long cmd_type, std::vector<double> val, std::vector<std::string> val_string);
void string_explode(std::string str, std::string separator, std::vector<std::string>* results);
void store_roi_param(const Tango::DevLong *w_val, int size);
void store_command_string(Tango::DevString w_val);
void recover_data(const Tango::DevVarLongArray *argin, struct acq_buffer_t **rec_data);
void get_param_in(const Tango::DevVarLongArray *argin, int32_t *mode, int32_t *num_samples, int32_t *bn_start, int32_t *bn_en);
void store_circ_data(int32_t mode, int32_t num_samples, int32_t bn_start, int32_t bn_end);
void store_array_1D(Tango::DeviceData *cmd_value, int32_t bn_start, int32_t bn_end);
void store_array_2D(Tango::DeviceData *cmd_value, int32_t bn_start, int32_t bn_end);
int32_t get_start_index(int32_t mode, int32_t num_samples, int32_t bn_start, int32_t bn_end);



/*----- PROTECTED REGION END -----*/	//	DataVampire::Additional Method prototypes
};

/*----- PROTECTED REGION ID(DataVampire::Additional Classes Definitions) ENABLED START -----*/
/* clang-format on */
//	Additional Classes Definitions
/* clang-format off */
/*----- PROTECTED REGION END -----*/	//	DataVampire::Additional Classes Definitions

}	//	End of namespace

#endif   //	DataVampire_H