Skip to content
Snippets Groups Projects
AccessConf.h 8.58 KiB
Newer Older
/*----- PROTECTED REGION ID(AccessConf.h) ENABLED START -----*/
//=============================================================================
//
// file :        AccessConf.h
//
// description : Include for the AccessConf class.
//
// project :     Storage Ring Access.
//
// $Author: graziano $
//
// $Revision: 1.7 $
// $Date: 2019-11-06 08:38:53 $
//
// SVN only:
// $HeadURL:  $
//
// CVS only:
// $Source: /home/cvsadm/cvsroot/fermi/servers/accessconf/src/AccessConf.h,v $
// $Log: AccessConf.h,v $
// Revision 1.7  2019-11-06 08:38:53  graziano
// Fixed
//
// Revision 1.6  2019-11-06 08:23:36  graziano
// Added cutoff_ind to change/disable index for cutoff
//
// Revision 1.5  2017-08-23 14:16:23  claudio
// #1554 tango-9.2.5a
//
// Revision 1.4  2016-01-07 10:44:44  graziano
// fixed
//
// Revision 1.3  2013-08-20 07:06:01  graziano
// event support
//
// Revision 1.2  2012-10-31 17:40:12  graziano
// fixed for valves
//
// Revision 1.1  2012-10-30 09:29:15  graziano
// *** empty log message ***
//
//
//
//=============================================================================
//                This file is generated by POGO
//        (Program Obviously used to Generate tango Object)
//=============================================================================


#ifndef ACCESSCONF_H
#define ACCESSCONF_H


#include <tango.h>

#define MAX_ATTR_SIZE 100

/*----- PROTECTED REGION END -----*/


/**
 *	AccessConf class Description:
 *	
 */

namespace AccessConf_ns
{
	/*----- PROTECTED REGION ID(AccessConf::Additional Class Declarations) ENABLED START -----*/

	//		Additional Class Declarations
class EventCallBack : public Tango::CallBack
{
	public:
		EventCallBack();
		~EventCallBack(void);
		void push_event(Tango::EventData* ev);
		void init(Tango::DeviceImpl *p);
	private:
		Tango::DeviceImpl *mydevice;
	//vector<DeviceImpl *> mydevices;
};

typedef struct
{
	string remote_attr_name;
	unsigned int attr_index;
	unsigned int remote_index;
	string descr;
	string comment;
	string type;
	//Tango::DevBoolean val;

} attr_desc_t;

typedef struct
{
	Tango::DevBoolean val[MAX_ATTR_SIZE];

} attr_val_t;

typedef struct
{
	vector<Tango::DevBoolean> val_b;
	vector<string> val_s;
	vector<Tango::DevBoolean> val_b_ev;
	vector<string> val_s_ev;
	vector<string> loc_attr_name;	//list of local attributes interested in this remote value
} rem_val_t;

typedef struct
{
	char val[MAX_ATTR_SIZE][128];

} attr_val_string_t;

typedef struct
{
	string remote_cmd_name;
	int cmd_code;
	int cmd_offset;
	int cmd_offset2;
	int cmd_offset3;
	int cmd_offset4;
	string pass;

} cmd_desc_t;

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


class AccessConf : public TANGO_BASE_CLASS
{

	friend class CmdClass;
	/*----- PROTECTED REGION ID(AccessConf::Data Members) ENABLED START -----*/

	//		Add your own data members
public:
	/**
	 * This command gets the device state (stored in its <i>device_state</i> data member) and returns it to the caller.
	 *	@return	State Code
	 *	@exception DevFailed
	 */
		virtual Tango::DevState	dev_state();
	/**
	 * This command gets the device status (stored in its <i>device_status</i> data member) and returns it to the caller.
	 *	@return	Status description
	 *	@exception DevFailed
	 */
		virtual Tango::ConstDevString	dev_status();
protected:

    map<string,vector<attr_desc_t> >   att_data;
    map<string,attr_val_t >   att_value;
    map<string,attr_val_string_t >   att_value_string;
    vector<string> remote_attr;
    map<string,string> remote_type;
    //map<string,vector<Tango::DevBoolean> >   remote_att_value;
    map<string,rem_val_t >   remote_att_value;

    vector<unsigned int> eid;
    EventCallBack ecb;
    friend class EventCallBack;

    Tango::DevState	ll_state;
    void string_explode(string, string, vector<string>*);
    void init_attributeprop();
    long create_dynamic_command(const char* cmd_name, Tango::CmdArgType type_in, Tango::CmdArgType type_out, long size_in, long size_out);
    void create_dynamic_attributes(vector<string> attr_config);
    void extract_values(Tango::DeviceAttribute *attr_value, vector<Tango::DevBoolean> &v_bo, vector<string> &v_string);

    Tango::DeviceProxy *lldevice;

    struct timeval last_read;

    map<string,cmd_desc_t>   cmd_data;

    char version_str[1024];
    char status_str[1024];
    Tango::DevString	*attr_status_read;
    Tango::DevState		state_event;

    bool ValveStat_initialized;
    bool created_attr;

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


//	Device property data members
public:		//	Low_level_srv:	
	string	low_level_srv;
	//	Attr_config_file:
	string	attr_config_file;
	//	Attr_config_prop:
	vector<string>	attr_config_prop;
	//	Cutoff_ind:
	Tango::DevLong	cutoff_ind;
	

//	Attribute data members
public:
	Tango::DevBoolean	*attr_BoolScalarDyn_read;
	Tango::DevBoolean	*attr_BoolSpectrumDyn_read;
	Tango::DevString	*attr_StringSpectrumDyn_read;
	Tango::DevString	*attr_Version_read;



//	Constructors and destructors
public:
	/**
	 * Constructs a newly allocated Command object.
	 *
	 *	@param cl	Class.
	 *	@param s 	Device Name
	 */
	AccessConf(Tango::DeviceClass *cl,string &s);
	/**
	 * Constructs a newly allocated Command object.
	 *
	 *	@param cl	Class.
	 *	@param s 	Device Name
	 */
	AccessConf(Tango::DeviceClass *cl,const char *s);
	/**
	 * Constructs a newly allocated Command object.
	 *
	 *	@param cl	Class.
	 *	@param s 	Device name
	 *	@param d	Device description.
	 */
	AccessConf(Tango::DeviceClass *cl,const char *s,const char *d);
	/**
	 * The object destructor.
	 */	
	~AccessConf() {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      : AccessConf::read_attr_hardware()
	 *	Description : Hardware acquisition for attributes.
	 */
	virtual void read_attr_hardware(vector<long> &attr_list);


	/**
	 *	BoolScalarDyn attribute related methods.
	 *	Description: 
	 *
	 *	Data type:	Tango::DevBoolean
	 *	Attr type:	Scalar 
	 */
	virtual void read_BoolScalarDyn(Tango::Attribute &attr);
	virtual bool is_BoolScalarDyn_allowed(Tango::AttReqType type);



	/**
	 *	BoolSpectrumDyn attribute related methods.
	 *	Description: 
	 *
	 *	Data type:	Tango::DevBoolean
	 *	Attr type:	Spectrum  max = 1000
	 */
	virtual void read_BoolSpectrumDyn(Tango::Attribute &attr);
	virtual bool is_BoolSpectrumDyn_allowed(Tango::AttReqType type);



	/**
	 *	StringSpectrumDyn attribute related methods.
	 *	Description:
	 *
	 *	Data type:	Tango::DevString
	 *	Attr type:	Spectrum  max = 1000
	 */
	virtual void read_StringSpectrumDyn(Tango::Attribute &attr);
	virtual bool is_StringSpectrumDyn_allowed(Tango::AttReqType type);


	/**
	 *	Version attribute related methods.
	 *	Description:
	 *
	 *	Data type:	Tango::DevBoolean
	 *	Attr type:	Scalar
	 */
	virtual void read_Version(Tango::Attribute &attr);
	virtual bool is_Version_allowed(Tango::AttReqType type);



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

//	Command related methods
public: 




	/*----- PROTECTED REGION ID(AccessConf::Additional Method prototypes) ENABLED START -----*/

	//	Additional Method prototypes

	/*----- PROTECTED REGION END -----*/	//	AccessConf::Additional Method prototypes

};

	/*----- PROTECTED REGION ID(AccessConf::Additional Classes Definitions) ENABLED START -----*/

	//	Additional Classes definitions
class CmdClass : public Tango::Command
{
public:
	CmdClass(const char   *name,
	               Tango::CmdArgType in,
				   Tango::CmdArgType out,
				   const char        *in_desc,
				   const char        *out_desc,
				   Tango::DispLevel  level,
				   int size_in,
				   Tango::DeviceImpl *dev)
	:Command(name,in,out,in_desc,out_desc, level)	{_max_in=size_in;};

	CmdClass(const char   *name,
	               Tango::CmdArgType in,
				   Tango::CmdArgType out,
				   int size_in,
				   Tango::DeviceImpl *dev)
	:Command(name,in,out)	{_max_in=size_in;};
	~CmdClass() {};

	virtual CORBA::Any *execute (Tango::DeviceImpl *dev, const CORBA::Any &any);
	virtual bool is_allowed (Tango::DeviceImpl *dev, const CORBA::Any &any)
	{return true/*(static_cast<TangoLib *>(dev))->is_Cmd_allowed(any)*/;}

	int _max_in;
	AccessConf *mydevice;
};

	/*----- PROTECTED REGION END -----*/	//	AccessConf::Additional Classes Definitions

} //	namespace

#endif	//	ACCESSCONF_H