Skip to content
Snippets Groups Projects
AlarmHandlerClass.cpp 50.2 KiB
Newer Older
/*----- PROTECTED REGION ID(AlarmHandlerClass.cpp) ENABLED START -----*/
//=============================================================================
//
// file :        AlarmHandlerClass.cpp
// description : C++ source for the AlarmHandlerClass.
//               A singleton class derived from DeviceClass.
//               It implements the command and attribute list
//               and all properties and methods required
//               by the AlarmHandler once per process.
// project :     Elettra alarm handler device server
//
// 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)
//=============================================================================


#include <AlarmHandlerClass.h>
/*----- PROTECTED REGION END -----*/	//	AlarmHandlerClass.cpp

//-------------------------------------------------------------------
/**
 *	Create AlarmHandlerClass singleton and
 *	return it in a C function for Python usage
 */
//-------------------------------------------------------------------
extern "C" {
#ifdef _TG_WINDOWS_

__declspec(dllexport)

#endif

	Tango::DeviceClass *_create_AlarmHandler_class(const char *name) {
		return AlarmHandler_ns::AlarmHandlerClass::init(name);
namespace AlarmHandler_ns
{
//===================================================================
//	Initialize pointer for singleton pattern
//===================================================================
AlarmHandlerClass *AlarmHandlerClass::_instance = NULL;

//--------------------------------------------------------
/**
 * method : 		AlarmHandlerClass::AlarmHandlerClass(string &s)
 * description : 	constructor for the AlarmHandlerClass
 *
 * @param s	The class name
 */
//--------------------------------------------------------
AlarmHandlerClass::AlarmHandlerClass(string &s):Tango::DeviceClass(s)
	TANGO_LOG_INFO << "Entering AlarmHandlerClass constructor" << endl;
	get_class_property();
	/*----- PROTECTED REGION ID(AlarmHandlerClass::constructor) ENABLED START -----*/
	/*----- PROTECTED REGION END -----*/	//	AlarmHandlerClass::constructor
	TANGO_LOG_INFO << "Leaving AlarmHandlerClass constructor" << endl;
}

//--------------------------------------------------------
/**
 * method : 		AlarmHandlerClass::~AlarmHandlerClass()
 * description : 	destructor for the AlarmHandlerClass
 */
//--------------------------------------------------------
AlarmHandlerClass::~AlarmHandlerClass()
	/*----- PROTECTED REGION ID(AlarmHandlerClass::destructor) ENABLED START -----*/
	/*----- PROTECTED REGION END -----*/	//	AlarmHandlerClass::destructor

	_instance = NULL;
}


//--------------------------------------------------------
/**
 * method : 		AlarmHandlerClass::init
 * description : 	Create the object if not already done.
 *                  Otherwise, just return a pointer to the object
 *
 * @param	name	The class name
 */
//--------------------------------------------------------
AlarmHandlerClass *AlarmHandlerClass::init(const char *name)
			_instance = new AlarmHandlerClass(s);
		}
		catch (bad_alloc &)
		{
			throw;
		}
	}
	return _instance;
}

//--------------------------------------------------------
/**
 * method : 		AlarmHandlerClass::instance
 * description : 	Check if object already created,
 *                  and return a pointer to the object
 */
//--------------------------------------------------------
AlarmHandlerClass *AlarmHandlerClass::instance()
{
	if (_instance == NULL)
	{
		cerr << "Class is not initialised !!" << endl;
		exit(-1);
	}
	return _instance;
}



//===================================================================
//	Command execution method calls
//===================================================================
//--------------------------------------------------------
/**
 * method : 		AckClass::execute()
 * description : 	method to trigger the execution of the command.
 *
 * @param	device	The device on which the command must be executed
 * @param	in_any	The command input data
 *
 *	returns The command output data (packed in the Any object)
 */
//--------------------------------------------------------
CORBA::Any *AckClass::execute(Tango::DeviceImpl *device, const CORBA::Any &in_any)
{
	TANGO_LOG_INFO << "AckClass::execute(): arrived" << endl;
	const Tango::DevVarStringArray *argin;
	extract(in_any, argin);
	((static_cast<AlarmHandler *>(device))->ack(argin));
	return new CORBA::Any();
}

//--------------------------------------------------------
/**
 * method : 		LoadClass::execute()
 * description : 	method to trigger the execution of the command.
 *
 * @param	device	The device on which the command must be executed
 * @param	in_any	The command input data
 *
 *	returns The command output data (packed in the Any object)
 */
//--------------------------------------------------------
CORBA::Any *LoadClass::execute(Tango::DeviceImpl *device, const CORBA::Any &in_any)
{
	TANGO_LOG_INFO << "LoadClass::execute(): arrived" << endl;
	Tango::DevString argin;
	extract(in_any, argin);
	((static_cast<AlarmHandler *>(device))->load(argin));
	return new CORBA::Any();
}

//--------------------------------------------------------
/**
 * method : 		RemoveClass::execute()
 * description : 	method to trigger the execution of the command.
 *
 * @param	device	The device on which the command must be executed
 * @param	in_any	The command input data
 *
 *	returns The command output data (packed in the Any object)
 */
//--------------------------------------------------------
CORBA::Any *RemoveClass::execute(Tango::DeviceImpl *device, const CORBA::Any &in_any)
{
	TANGO_LOG_INFO << "RemoveClass::execute(): arrived" << endl;
	Tango::DevString argin;
	extract(in_any, argin);
	((static_cast<AlarmHandler *>(device))->remove(argin));
	return new CORBA::Any();
}

//--------------------------------------------------------
/**
 * description : 	method to trigger the execution of the command.
 *
 * @param	device	The device on which the command must be executed
 * @param	in_any	The command input data
 *
 *	returns The command output data (packed in the Any object)
 */
//--------------------------------------------------------
CORBA::Any *SearchAlarmClass::execute(Tango::DeviceImpl *device, const CORBA::Any &in_any)
	TANGO_LOG_INFO << "SearchAlarmClass::execute(): arrived" << endl;
	Tango::DevString argin;
	extract(in_any, argin);
	return insert((static_cast<AlarmHandler *>(device))->search_alarm(argin));
}

//--------------------------------------------------------
/**
 * description : 	method to trigger the execution of the command.
 *
 * @param	device	The device on which the command must be executed
 * @param	in_any	The command input data
 *
 *	returns The command output data (packed in the Any object)
 */
//--------------------------------------------------------
CORBA::Any *StopAudibleClass::execute(Tango::DeviceImpl *device, TANGO_UNUSED(const CORBA::Any &in_any))
	TANGO_LOG_INFO << "StopAudibleClass::execute(): arrived" << endl;
	((static_cast<AlarmHandler *>(device))->stop_audible());
	return new CORBA::Any();
}

//--------------------------------------------------------
/**
 * method : 		SilenceClass::execute()
 * description : 	method to trigger the execution of the command.
 *
 * @param	device	The device on which the command must be executed
 * @param	in_any	The command input data
 *
 *	returns The command output data (packed in the Any object)
 */
//--------------------------------------------------------
CORBA::Any *SilenceClass::execute(Tango::DeviceImpl *device, const CORBA::Any &in_any)
{
	TANGO_LOG_INFO << "SilenceClass::execute(): arrived" << endl;
	const Tango::DevVarStringArray *argin;
	extract(in_any, argin);
	((static_cast<AlarmHandler *>(device))->silence(argin));
	return new CORBA::Any();
}

//--------------------------------------------------------
/**
 * method : 		ModifyClass::execute()
 * description : 	method to trigger the execution of the command.
 *
 * @param	device	The device on which the command must be executed
 * @param	in_any	The command input data
 *
 *	returns The command output data (packed in the Any object)
 */
//--------------------------------------------------------
CORBA::Any *ModifyClass::execute(Tango::DeviceImpl *device, const CORBA::Any &in_any)
{
	TANGO_LOG_INFO << "ModifyClass::execute(): arrived" << endl;
	Tango::DevString argin;
	extract(in_any, argin);
	((static_cast<AlarmHandler *>(device))->modify(argin));
//--------------------------------------------------------
/**
 * method : 		ShelveClass::execute()
 * description : 	method to trigger the execution of the command.
 *
 * @param	device	The device on which the command must be executed
 * @param	in_any	The command input data
 *
 *	returns The command output data (packed in the Any object)
 */
//--------------------------------------------------------
CORBA::Any *ShelveClass::execute(Tango::DeviceImpl *device, const CORBA::Any &in_any)
{
	TANGO_LOG_INFO << "ShelveClass::execute(): arrived" << endl;
	const Tango::DevVarStringArray *argin;
	extract(in_any, argin);
	((static_cast<AlarmHandler *>(device))->shelve(argin));
	return new CORBA::Any();
}

//--------------------------------------------------------
/**
 * method : 		EnableClass::execute()
 * description : 	method to trigger the execution of the command.
 *
 * @param	device	The device on which the command must be executed
 * @param	in_any	The command input data
 *
 *	returns The command output data (packed in the Any object)
 */
//--------------------------------------------------------
CORBA::Any *EnableClass::execute(Tango::DeviceImpl *device, const CORBA::Any &in_any)
{
	TANGO_LOG_INFO << "EnableClass::execute(): arrived" << endl;
	Tango::DevString argin;
	extract(in_any, argin);
	((static_cast<AlarmHandler *>(device))->enable(argin));
	return new CORBA::Any();
}

//--------------------------------------------------------
/**
 * method : 		DisableClass::execute()
 * description : 	method to trigger the execution of the command.
 *
 * @param	device	The device on which the command must be executed
 * @param	in_any	The command input data
 *
 *	returns The command output data (packed in the Any object)
 */
//--------------------------------------------------------
CORBA::Any *DisableClass::execute(Tango::DeviceImpl *device, const CORBA::Any &in_any)
{
	TANGO_LOG_INFO << "DisableClass::execute(): arrived" << endl;
	Tango::DevString argin;
	extract(in_any, argin);
	((static_cast<AlarmHandler *>(device))->disable(argin));
	return new CORBA::Any();
}

//--------------------------------------------------------
/**
 * method : 		ResetStatisticsClass::execute()
 * description : 	method to trigger the execution of the command.
 *
 * @param	device	The device on which the command must be executed
 * @param	in_any	The command input data
 *
 *	returns The command output data (packed in the Any object)
 */
//--------------------------------------------------------
CORBA::Any *ResetStatisticsClass::execute(Tango::DeviceImpl *device, TANGO_UNUSED(const CORBA::Any &in_any))
{
	TANGO_LOG_INFO << "ResetStatisticsClass::execute(): arrived" << endl;
	((static_cast<AlarmHandler *>(device))->reset_statistics());
//--------------------------------------------------------
/**
 * method : 		StopNewClass::execute()
 * description : 	method to trigger the execution of the command.
 *
 * @param	device	The device on which the command must be executed
 * @param	in_any	The command input data
 *
 *	returns The command output data (packed in the Any object)
 */
//--------------------------------------------------------
CORBA::Any *StopNewClass::execute(Tango::DeviceImpl *device, TANGO_UNUSED(const CORBA::Any &in_any))
{
	TANGO_LOG_INFO << "StopNewClass::execute(): arrived" << endl;
	((static_cast<AlarmHandler *>(device))->stop_new());
	return new CORBA::Any();
}

//--------------------------------------------------------
/**
 * method : 		GetAlarmInfoClass::execute()
 * description : 	method to trigger the execution of the command.
 *
 * @param	device	The device on which the command must be executed
 * @param	in_any	The command input data
 *
 *	returns The command output data (packed in the Any object)
 */
//--------------------------------------------------------
CORBA::Any *GetAlarmInfoClass::execute(Tango::DeviceImpl *device, const CORBA::Any &in_any)
{
	TANGO_LOG_INFO << "GetAlarmInfoClass::execute(): arrived" << endl;
	const Tango::DevVarStringArray *argin;
	extract(in_any, argin);
	return insert((static_cast<AlarmHandler *>(device))->get_alarm_info(argin));
}

//--------------------------------------------------------
/**
 * method : 		ReLoadAllClass::execute()
 * description : 	method to trigger the execution of the command.
 *
 * @param	device	The device on which the command must be executed
 * @param	in_any	The command input data
 *
 *	returns The command output data (packed in the Any object)
 */
//--------------------------------------------------------
CORBA::Any *ReLoadAllClass::execute(Tango::DeviceImpl *device, TANGO_UNUSED(const CORBA::Any &in_any))
{
	TANGO_LOG_INFO << "ReLoadAllClass::execute(): arrived" << endl;
	((static_cast<AlarmHandler *>(device))->re_load_all());
	return new CORBA::Any();
}


//===================================================================
//	Properties management
//===================================================================
//--------------------------------------------------------
/**
 *	Method      : AlarmHandlerClass::get_class_property()
 *	Description : Get the class property for specified name.
 */
//--------------------------------------------------------
Tango::DbDatum AlarmHandlerClass::get_class_property(string &prop_name)
{
	for (unsigned int i=0 ; i<cl_prop.size() ; i++)
		if (cl_prop[i].name == prop_name)
			return cl_prop[i];
	//	if not found, returns  an empty DbDatum
	return Tango::DbDatum(prop_name);
}

//--------------------------------------------------------
/**
 *	Method      : AlarmHandlerClass::get_default_device_property()
 *	Description : Return the default value for device property.
 */
//--------------------------------------------------------
Tango::DbDatum AlarmHandlerClass::get_default_device_property(string &prop_name)
{
	for (unsigned int i=0 ; i<dev_def_prop.size() ; i++)
		if (dev_def_prop[i].name == prop_name)
			return dev_def_prop[i];
	//	if not found, return  an empty DbDatum
	return Tango::DbDatum(prop_name);
}

//--------------------------------------------------------
/**
 *	Method      : AlarmHandlerClass::get_default_class_property()
 *	Description : Return the default value for class property.
 */
//--------------------------------------------------------
Tango::DbDatum AlarmHandlerClass::get_default_class_property(string &prop_name)
{
	for (unsigned int i=0 ; i<cl_def_prop.size() ; i++)
		if (cl_def_prop[i].name == prop_name)
			return cl_def_prop[i];
	//	if not found, return  an empty DbDatum
	return Tango::DbDatum(prop_name);
}

//--------------------------------------------------------
/**
 *	Method      : AlarmHandlerClass::get_class_property()
 *	Description : Read database to initialize class property data members.
 */
//--------------------------------------------------------
void AlarmHandlerClass::get_class_property()
{
	/*----- PROTECTED REGION ID(AlarmHandlerClass::get_class_property_before) ENABLED START -----*/
	
	//	Initialize class property data members
	
	/*----- PROTECTED REGION END -----*/	//	AlarmHandlerClass::get_class_property_before
	//	Read class properties from database.
	cl_prop.push_back(Tango::DbDatum("GroupNames"));
	cl_prop.push_back(Tango::DbDatum("SubscribeRetryPeriod"));
	cl_prop.push_back(Tango::DbDatum("StatisticsTimeWindow"));
	cl_prop.push_back(Tango::DbDatum("ErrorDelay"));
	cl_prop.push_back(Tango::DbDatum("SetAlarmQuality"));
	
	//	Call database and extract values
	if (Tango::Util::instance()->_UseDb==true)
		get_db_class()->get_property(cl_prop);
	Tango::DbDatum	def_prop;
	int	i = -1;

	//	Try to extract GroupNames value
	if (cl_prop[++i].is_empty()==false)	cl_prop[i]  >>  groupNames;
	else
	{
		//	Check default value for GroupNames
		def_prop = get_default_class_property(cl_prop[i].name);
		if (def_prop.is_empty()==false)
		{
			def_prop    >>  groupNames;
			cl_prop[i]  <<  groupNames;
		}
	}
	//	Try to extract SubscribeRetryPeriod value
	if (cl_prop[++i].is_empty()==false)	cl_prop[i]  >>  subscribeRetryPeriod;
	else
	{
		//	Check default value for SubscribeRetryPeriod
		def_prop = get_default_class_property(cl_prop[i].name);
		if (def_prop.is_empty()==false)
		{
			def_prop    >>  subscribeRetryPeriod;
			cl_prop[i]  <<  subscribeRetryPeriod;
		}
	}
	//	Try to extract StatisticsTimeWindow value
	if (cl_prop[++i].is_empty()==false)	cl_prop[i]  >>  statisticsTimeWindow;
	else
	{
		//	Check default value for StatisticsTimeWindow
		def_prop = get_default_class_property(cl_prop[i].name);
		if (def_prop.is_empty()==false)
		{
			def_prop    >>  statisticsTimeWindow;
			cl_prop[i]  <<  statisticsTimeWindow;
		}
	}
	//	Try to extract ErrorDelay value
	if (cl_prop[++i].is_empty()==false)	cl_prop[i]  >>  errorDelay;
	else
	{
		//	Check default value for ErrorDelay
		def_prop = get_default_class_property(cl_prop[i].name);
		if (def_prop.is_empty()==false)
		{
			def_prop    >>  errorDelay;
			cl_prop[i]  <<  errorDelay;
		}
	}
	//	Try to extract SetAlarmQuality value
	if (cl_prop[++i].is_empty()==false)	cl_prop[i]  >>  setAlarmQuality;
	else
	{
		//	Check default value for SetAlarmQuality
		def_prop = get_default_class_property(cl_prop[i].name);
		if (def_prop.is_empty()==false)
		{
			def_prop    >>  setAlarmQuality;
			cl_prop[i]  <<  setAlarmQuality;
		}
	}
	/*----- PROTECTED REGION ID(AlarmHandlerClass::get_class_property_after) ENABLED START -----*/
	
	//	Check class property data members init
	
	/*----- PROTECTED REGION END -----*/	//	AlarmHandlerClass::get_class_property_after

}

//--------------------------------------------------------
/**
 *	Method      : AlarmHandlerClass::set_default_property()
 *	Description : Set default property (class and device) for wizard.
 *                For each property, add to wizard property name and description.
 *                If default value has been set, add it to wizard property and
 *                store it in a DbDatum.
 */
//--------------------------------------------------------
void AlarmHandlerClass::set_default_property()
{
	string	prop_name;
	string	prop_desc;
	string	prop_def;
	vector<string>	vect_data;

	//	Set Default Class Properties
	prop_name = "GroupNames";
	prop_desc = "Labels for Group mask, first is for mask 0x00";
	prop_def  = "";
	vect_data.clear();
	if (prop_def.length()>0)
	{
		Tango::DbDatum	data(prop_name);
		data << vect_data ;
		cl_def_prop.push_back(data);
		add_wiz_class_prop(prop_name, prop_desc,  prop_def);
	}
	else
		add_wiz_class_prop(prop_name, prop_desc);
	prop_name = "SubscribeRetryPeriod";
	prop_desc = "Retry subscription period in seconds";
	prop_def  = "30";
	vect_data.clear();
	vect_data.push_back("30");
	if (prop_def.length()>0)
	{
		Tango::DbDatum	data(prop_name);
		data << vect_data ;
		cl_def_prop.push_back(data);
		add_wiz_class_prop(prop_name, prop_desc,  prop_def);
	}
	else
		add_wiz_class_prop(prop_name, prop_desc);
	prop_name = "StatisticsTimeWindow";
	prop_desc = "Time window to compute statistics in seconds";
	prop_def  = "60";
	vect_data.clear();
	vect_data.push_back("60");
	if (prop_def.length()>0)
	{
		Tango::DbDatum	data(prop_name);
		data << vect_data ;
		cl_def_prop.push_back(data);
		add_wiz_class_prop(prop_name, prop_desc,  prop_def);
	}
	else
		add_wiz_class_prop(prop_name, prop_desc);
	prop_name = "ErrorDelay";
	prop_desc = "Delay in seconds before changing to ERROR state after an exception is received.";
	prop_def  = "30";
	vect_data.clear();
	vect_data.push_back("30");
	if (prop_def.length()>0)
	{
		Tango::DbDatum	data(prop_name);
		data << vect_data ;
		cl_def_prop.push_back(data);
		add_wiz_class_prop(prop_name, prop_desc,  prop_def);
	}
	else
		add_wiz_class_prop(prop_name, prop_desc);
	prop_name = "SetAlarmQuality";
	prop_desc = "Set alarm attribute quality as computed using quality of attributes in the formula";
	prop_def  = "false";
	vect_data.clear();
	vect_data.push_back("false");
	if (prop_def.length()>0)
	{
		Tango::DbDatum	data(prop_name);
		data << vect_data ;
		cl_def_prop.push_back(data);
		add_wiz_class_prop(prop_name, prop_desc,  prop_def);
	}
	else
		add_wiz_class_prop(prop_name, prop_desc);

	//	Set Default device Properties
	prop_name = "GroupNames";
	prop_desc = "Labels for Group mask, first is for mask 0x00";
	prop_def  = "";
	vect_data.clear();
	if (prop_def.length()>0)
	{
		Tango::DbDatum	data(prop_name);
		data << vect_data ;
		dev_def_prop.push_back(data);
		add_wiz_dev_prop(prop_name, prop_desc,  prop_def);
	}
	else
		add_wiz_dev_prop(prop_name, prop_desc);
	prop_name = "SubscribeRetryPeriod";
	prop_desc = "Retry subscription period in seconds";
	prop_def  = "30";
	if (prop_def.length()>0)
	{
		Tango::DbDatum	data(prop_name);
		data << vect_data ;
		dev_def_prop.push_back(data);
		add_wiz_dev_prop(prop_name, prop_desc,  prop_def);
	}
	else
		add_wiz_dev_prop(prop_name, prop_desc);
	prop_name = "StatisticsTimeWindow";
	prop_desc = "Time window to compute statistics in seconds";
	prop_def  = "60";
	vect_data.clear();
	if (prop_def.length()>0)
	{
		Tango::DbDatum	data(prop_name);
		data << vect_data ;
		dev_def_prop.push_back(data);
		add_wiz_dev_prop(prop_name, prop_desc,  prop_def);
	}
	else
		add_wiz_dev_prop(prop_name, prop_desc);
	prop_name = "ErrorDelay";
	prop_desc = "Delay in seconds before changing to ERROR state after an exception is received.";
	prop_def  = "30";
	vect_data.clear();
	vect_data.push_back("30");
	if (prop_def.length()>0)
	{
		Tango::DbDatum	data(prop_name);
		data << vect_data ;
		dev_def_prop.push_back(data);
		add_wiz_dev_prop(prop_name, prop_desc,  prop_def);
	}
	else
		add_wiz_dev_prop(prop_name, prop_desc);
	prop_name = "SetAlarmQuality";
	prop_desc = "Set alarm attribute quality as computed using quality of attributes in the formula";
	prop_def  = "false";
	vect_data.clear();
	vect_data.push_back("false");
	if (prop_def.length()>0)
	{
		Tango::DbDatum	data(prop_name);
		data << vect_data ;
		dev_def_prop.push_back(data);
		add_wiz_dev_prop(prop_name, prop_desc,  prop_def);
	}
	else
		add_wiz_dev_prop(prop_name, prop_desc);
}

//--------------------------------------------------------
/**
 *	Method      : AlarmHandlerClass::write_class_property()
 *	Description : Set class description fields as property in database
 */
//--------------------------------------------------------
void AlarmHandlerClass::write_class_property()
{
	//	First time, check if database used
	if (Tango::Util::_UseDb == false)
		return;

	Tango::DbData	data;
	string	classname = get_name();
	string	header;
	string::size_type	start, end;

	//	Put title
	Tango::DbDatum	title("ProjectTitle");
	string	str_title("Elettra alarm handler device server");
	title << str_title;
	data.push_back(title);

	//	Put Description
	Tango::DbDatum	description("Description");
	vector<string>	str_desc;
	str_desc.push_back("Elettra alarm handler device server");
	description << str_desc;
	data.push_back(description);

	//  Put inheritance
	Tango::DbDatum	inher_datum("InheritedFrom");
	vector<string> inheritance;
	inheritance.push_back("TANGO_BASE_CLASS");
	inher_datum << inheritance;
	data.push_back(inher_datum);

	//	Call database and and values
	get_db_class()->put_property(data);
}

//===================================================================
//	Factory methods
//===================================================================

//--------------------------------------------------------
/**
 *	Method      : AlarmHandlerClass::device_factory()
 *	Description : Create the device object(s)
 *                and store them in the device list
 */
//--------------------------------------------------------
void AlarmHandlerClass::device_factory(const Tango::DevVarStringArray *devlist_ptr)
	/*----- PROTECTED REGION ID(AlarmHandlerClass::device_factory_before) ENABLED START -----*/
	/*----- PROTECTED REGION END -----*/	//	AlarmHandlerClass::device_factory_before

	//	Create devices and add it into the device list
	for (unsigned long i=0 ; i<devlist_ptr->length() ; i++)
	{
		TANGO_LOG_DEBUG << "Device name : " << (*devlist_ptr)[i].in() << endl;
		device_list.push_back(new AlarmHandler(this, (*devlist_ptr)[i]));
	}

	//	Manage dynamic attributes if any
	erase_dynamic_attributes(devlist_ptr, get_class_attr()->get_attr_list());

	//	Export devices to the outside world
	for (unsigned long i=1 ; i<=devlist_ptr->length() ; i++)
	{
		//	Add dynamic attributes if any
		AlarmHandler *dev = static_cast<AlarmHandler *>(device_list[device_list.size()-i]);
		dev->add_dynamic_attributes();

		//	Check before if database used.
		if ((Tango::Util::_UseDb == true) && (Tango::Util::_FileDb == false))
			export_device(dev);
		else
			export_device(dev, dev->get_name().c_str());
	}

	/*----- PROTECTED REGION ID(AlarmHandlerClass::device_factory_after) ENABLED START -----*/
	/*----- PROTECTED REGION END -----*/	//	AlarmHandlerClass::device_factory_after
}
//--------------------------------------------------------
/**
 *	Method      : AlarmHandlerClass::attribute_factory()
 *	Description : Create the attribute object(s)
 *                and store them in the attribute list
 */
//--------------------------------------------------------
void AlarmHandlerClass::attribute_factory(vector<Tango::Attr *> &att_list)
	/*----- PROTECTED REGION ID(AlarmHandlerClass::attribute_factory_before) ENABLED START -----*/
	/*----- PROTECTED REGION END -----*/	//	AlarmHandlerClass::attribute_factory_before
	//	Attribute : alarmAudible
	alarmAudibleAttrib	*alarmaudible = new alarmAudibleAttrib();
	Tango::UserDefaultAttrProp	alarmaudible_prop;
	alarmaudible_prop.set_description("True if there is at least one alarm that needs audible indication on the GUI");
	//	label	not set for alarmAudible
	//	unit	not set for alarmAudible
	//	standard_unit	not set for alarmAudible
	//	display_unit	not set for alarmAudible
	//	format	not set for alarmAudible
	//	max_value	not set for alarmAudible
	//	min_value	not set for alarmAudible
	//	max_alarm	not set for alarmAudible
	//	min_alarm	not set for alarmAudible
	//	max_warning	not set for alarmAudible
	//	min_warning	not set for alarmAudible
	//	delta_t	not set for alarmAudible
	//	delta_val	not set for alarmAudible
	alarmaudible->set_default_properties(alarmaudible_prop);
	alarmaudible->set_disp_level(Tango::OPERATOR);
	alarmaudible->set_change_event(true, true);
	alarmaudible->set_archive_event(true, true);
	att_list.push_back(alarmaudible);

	//	Attribute : StatisticsResetTime
	StatisticsResetTimeAttrib	*statisticsresettime = new StatisticsResetTimeAttrib();
	Tango::UserDefaultAttrProp	statisticsresettime_prop;
	statisticsresettime_prop.set_description("Time elapsed in seconds since last Resetstatistics");
	//	label	not set for StatisticsResetTime
	statisticsresettime_prop.set_unit("s");
	statisticsresettime_prop.set_standard_unit("1");
	statisticsresettime_prop.set_display_unit("s");
	//	format	not set for StatisticsResetTime
	//	max_value	not set for StatisticsResetTime
	//	min_value	not set for StatisticsResetTime
	//	max_alarm	not set for StatisticsResetTime
	//	min_alarm	not set for StatisticsResetTime
	//	max_warning	not set for StatisticsResetTime
	//	min_warning	not set for StatisticsResetTime
	//	delta_t	not set for StatisticsResetTime
	//	delta_val	not set for StatisticsResetTime
	
	statisticsresettime->set_default_properties(statisticsresettime_prop);
	//	Not Polled
	statisticsresettime->set_disp_level(Tango::OPERATOR);
	//	Not Memorized
	att_list.push_back(statisticsresettime);

	//	Attribute : alarm
	alarmAttrib	*alarm = new alarmAttrib();
	Tango::UserDefaultAttrProp	alarm_prop;
	//	description	not set for alarm
	//	label	not set for alarm
	//	unit	not set for alarm
	//	standard_unit	not set for alarm
	//	display_unit	not set for alarm
	//	format	not set for alarm
	//	max_value	not set for alarm
	//	min_value	not set for alarm
	//	max_alarm	not set for alarm
	//	min_alarm	not set for alarm
	//	max_warning	not set for alarm
	//	min_warning	not set for alarm
	//	delta_t	not set for alarm
	//	delta_val	not set for alarm
	
	alarm->set_default_properties(alarm_prop);
	//	Not Polled
	alarm->set_disp_level(Tango::OPERATOR);
	//	Not Memorized
	att_list.push_back(alarm);

	//	Attribute : alarmNormal
	alarmNormalAttrib	*alarmnormal = new alarmNormalAttrib();
	Tango::UserDefaultAttrProp	alarmnormal_prop;
	alarmnormal_prop.set_description("List of alarms in normal state");
	//	label	not set for alarmNormal
	//	unit	not set for alarmNormal
	//	standard_unit	not set for alarmNormal
	//	display_unit	not set for alarmNormal
	//	format	not set for alarmNormal
	//	max_value	not set for alarmNormal
	//	min_value	not set for alarmNormal
	//	max_alarm	not set for alarmNormal
	//	min_alarm	not set for alarmNormal
	//	max_warning	not set for alarmNormal
	//	min_warning	not set for alarmNormal
	//	delta_t	not set for alarmNormal
	//	delta_val	not set for alarmNormal
	alarmnormal->set_default_properties(alarmnormal_prop);
	alarmnormal->set_disp_level(Tango::OPERATOR);
	alarmnormal->set_change_event(true, true);
	alarmnormal->set_archive_event(true, true);
	att_list.push_back(alarmnormal);

	//	Attribute : alarmUnacknowledged
	alarmUnacknowledgedAttrib	*alarmunacknowledged = new alarmUnacknowledgedAttrib();
	Tango::UserDefaultAttrProp	alarmunacknowledged_prop;
	alarmunacknowledged_prop.set_description("List of alarms in unacknowledged state");
	//	label	not set for alarmUnacknowledged
	//	unit	not set for alarmUnacknowledged
	//	standard_unit	not set for alarmUnacknowledged
	//	display_unit	not set for alarmUnacknowledged
	//	format	not set for alarmUnacknowledged
	//	max_value	not set for alarmUnacknowledged
	//	min_value	not set for alarmUnacknowledged
	//	max_alarm	not set for alarmUnacknowledged
	//	min_alarm	not set for alarmUnacknowledged
	//	max_warning	not set for alarmUnacknowledged
	//	min_warning	not set for alarmUnacknowledged
	//	delta_t	not set for alarmUnacknowledged
	//	delta_val	not set for alarmUnacknowledged
	alarmunacknowledged->set_default_properties(alarmunacknowledged_prop);
	alarmunacknowledged->set_disp_level(Tango::OPERATOR);
	alarmunacknowledged->set_change_event(true, true);
	alarmunacknowledged->set_archive_event(true, true);
	att_list.push_back(alarmunacknowledged);

	//	Attribute : alarmAcknowledged
	alarmAcknowledgedAttrib	*alarmacknowledged = new alarmAcknowledgedAttrib();
	Tango::UserDefaultAttrProp	alarmacknowledged_prop;
	alarmacknowledged_prop.set_description("List of alarms in acknowledged state");
	//	label	not set for alarmAcknowledged
	//	unit	not set for alarmAcknowledged
	//	standard_unit	not set for alarmAcknowledged
	//	display_unit	not set for alarmAcknowledged
	//	format	not set for alarmAcknowledged
	//	max_value	not set for alarmAcknowledged
	//	min_value	not set for alarmAcknowledged
	//	max_alarm	not set for alarmAcknowledged
	//	min_alarm	not set for alarmAcknowledged
	//	max_warning	not set for alarmAcknowledged
	//	min_warning	not set for alarmAcknowledged
	//	delta_t	not set for alarmAcknowledged
	//	delta_val	not set for alarmAcknowledged
	alarmacknowledged->set_default_properties(alarmacknowledged_prop);
	alarmacknowledged->set_disp_level(Tango::OPERATOR);
	alarmacknowledged->set_change_event(true, true);
	alarmacknowledged->set_archive_event(true, true);
	att_list.push_back(alarmacknowledged);

	//	Attribute : alarmUnacknowledgedNormal
	alarmUnacknowledgedNormalAttrib	*alarmunacknowledgednormal = new alarmUnacknowledgedNormalAttrib();
	Tango::UserDefaultAttrProp	alarmunacknowledgednormal_prop;
	alarmunacknowledgednormal_prop.set_description("List of alarms in unacknowledged normal state");
	//	label	not set for alarmUnacknowledgedNormal
	//	unit	not set for alarmUnacknowledgedNormal
	//	standard_unit	not set for alarmUnacknowledgedNormal
	//	display_unit	not set for alarmUnacknowledgedNormal
	//	format	not set for alarmUnacknowledgedNormal
	//	max_value	not set for alarmUnacknowledgedNormal
	//	min_value	not set for alarmUnacknowledgedNormal
	//	max_alarm	not set for alarmUnacknowledgedNormal
	//	min_alarm	not set for alarmUnacknowledgedNormal
	//	max_warning	not set for alarmUnacknowledgedNormal
	//	min_warning	not set for alarmUnacknowledgedNormal
	//	delta_t	not set for alarmUnacknowledgedNormal
	//	delta_val	not set for alarmUnacknowledgedNormal
	alarmunacknowledgednormal->set_default_properties(alarmunacknowledgednormal_prop);
	alarmunacknowledgednormal->set_disp_level(Tango::OPERATOR);