Skip to content
Snippets Groups Projects
SimulatedE2PSClass.cpp 25.8 KiB
Newer Older
Claudio Scafuri's avatar
Claudio Scafuri committed
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767
/*----- PROTECTED REGION ID(SimulatedE2PSClass.cpp) ENABLED START -----*/
/* clang-format on */
//=============================================================================
//
// file :        SimulatedE2PSClass.cpp
//
// description : C++ source for the SimulatedE2PSClass.
//               A singleton class derived from DeviceClass.
//               It implements the command and attribute list
//               and all properties and methods required
//               by the SimulatedE2PS once per process.
//
// project :     SimulatedE2PS
//
// 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 "SimulatedE2PSClass.h"
/* clang-format off */
/*----- PROTECTED REGION END -----*/	//	SimulatedE2PSClass.cpp

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

__declspec(dllexport)

#endif

	Tango::DeviceClass *_create_SimulatedE2PS_class(const char *name) {
		return SimulatedE2PS_ns::SimulatedE2PSClass::init(name);
	}
}

namespace SimulatedE2PS_ns
{
//===================================================================
//	Initialize pointer for singleton pattern
//===================================================================
SimulatedE2PSClass *SimulatedE2PSClass::_instance = NULL;

//===================================================================
//	Class constants
//===================================================================
//--------------------------------------------------------
/**
 * method : 		SimulatedE2PSClass::SimulatedE2PSClass(std::string &s)
 * description : 	constructor for the SimulatedE2PSClass
 *
 * @param s	The class name
 */
//--------------------------------------------------------
SimulatedE2PSClass::SimulatedE2PSClass(std::string &s):Tango::DeviceClass(s)
{
	TANGO_LOG_INFO << "Entering SimulatedE2PSClass constructor" << std::endl;
	set_default_property();
	write_class_property();

	/*----- PROTECTED REGION ID(SimulatedE2PSClass::constructor) ENABLED START -----*/
	/* clang-format on */
	/* clang-format off */
	/*----- PROTECTED REGION END -----*/	//	SimulatedE2PSClass::constructor

	TANGO_LOG_INFO << "Leaving SimulatedE2PSClass constructor" << std::endl;
}

//--------------------------------------------------------
/**
 * method : 		SimulatedE2PSClass::~SimulatedE2PSClass()
 * description : 	destructor for the SimulatedE2PSClass
 */
//--------------------------------------------------------
SimulatedE2PSClass::~SimulatedE2PSClass()
{
	/*----- PROTECTED REGION ID(SimulatedE2PSClass::destructor) ENABLED START -----*/
	/* clang-format on */
	/* clang-format off */
	/*----- PROTECTED REGION END -----*/	//	SimulatedE2PSClass::destructor

	_instance = NULL;
}


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

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



//===================================================================
//	Command execution method calls
//===================================================================
//--------------------------------------------------------
/**
 * method : 		OnClass::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 *OnClass::execute(Tango::DeviceImpl *device, TANGO_UNUSED(const CORBA::Any &in_any))
{
	TANGO_LOG_INFO << "OnClass::execute(): arrived" << std::endl;
	((static_cast<SimulatedE2PS *>(device))->on());
	return new CORBA::Any();
}

//--------------------------------------------------------
/**
 * method : 		OffClass::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 *OffClass::execute(Tango::DeviceImpl *device, TANGO_UNUSED(const CORBA::Any &in_any))
{
	TANGO_LOG_INFO << "OffClass::execute(): arrived" << std::endl;
	((static_cast<SimulatedE2PS *>(device))->off());
	return new CORBA::Any();
}

//--------------------------------------------------------
/**
 * method : 		ResetClass::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 *ResetClass::execute(Tango::DeviceImpl *device, TANGO_UNUSED(const CORBA::Any &in_any))
{
	TANGO_LOG_INFO << "ResetClass::execute(): arrived" << std::endl;
	((static_cast<SimulatedE2PS *>(device))->reset());
	return new CORBA::Any();
}

//--------------------------------------------------------
/**
 * method : 		StartCyclingClass::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 *StartCyclingClass::execute(Tango::DeviceImpl *device, TANGO_UNUSED(const CORBA::Any &in_any))
{
	TANGO_LOG_INFO << "StartCyclingClass::execute(): arrived" << std::endl;
	((static_cast<SimulatedE2PS *>(device))->start_cycling());
	return new CORBA::Any();
}

//--------------------------------------------------------
/**
 * method : 		AbortClass::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 *AbortClass::execute(Tango::DeviceImpl *device, TANGO_UNUSED(const CORBA::Any &in_any))
{
	TANGO_LOG_INFO << "AbortClass::execute(): arrived" << std::endl;
	((static_cast<SimulatedE2PS *>(device))->abort());
	return new CORBA::Any();
}

//--------------------------------------------------------
/**
 * method : 		FaultClass::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 *FaultClass::execute(Tango::DeviceImpl *device, TANGO_UNUSED(const CORBA::Any &in_any))
{
	TANGO_LOG_INFO << "FaultClass::execute(): arrived" << std::endl;
	((static_cast<SimulatedE2PS *>(device))->fault());
	return new CORBA::Any();
}


//===================================================================
//	Properties management
//===================================================================
//--------------------------------------------------------
/**
 *	Method     : SimulatedE2PSClass::get_class_property()
 *	Description: Get the class property for specified name.
 */
//--------------------------------------------------------
Tango::DbDatum SimulatedE2PSClass::get_class_property(std::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     : SimulatedE2PSClass::get_default_device_property()
 *	Description: Return the default value for device property.
 */
//--------------------------------------------------------
Tango::DbDatum SimulatedE2PSClass::get_default_device_property(std::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     : SimulatedE2PSClass::get_default_class_property()
 *	Description: Return the default value for class property.
 */
//--------------------------------------------------------
Tango::DbDatum SimulatedE2PSClass::get_default_class_property(std::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     : SimulatedE2PSClass::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 SimulatedE2PSClass::set_default_property()
{
	std::string	prop_name;
	std::string	prop_desc;
	std::string	prop_def;
	std::vector<std::string>	vect_data;

	//	Set Default Class Properties

	//	Set Default device Properties
	prop_name = "CurrentRipple";
	prop_desc = "Residual current oscillation [A]\n\nThe simulator adds noise of CurrenRipple amplitude to the reading";
	prop_def  = "0.0025";
	vect_data.clear();
	vect_data.push_back("0.0025");
	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     : SimulatedE2PSClass::write_class_property()
 *	Description: Set class description fields as property in database
 */
//--------------------------------------------------------
void SimulatedE2PSClass::write_class_property()
{
	//	First time, check if database used
	if (Tango::Util::_UseDb == false)
		return;

	Tango::DbData	data;
	std::string	classname = get_name();
	std::string	header;

	//	Put title
	Tango::DbDatum	title("ProjectTitle");
	std::string	str_title("SimulatedE2PS");
	title << str_title;
	data.push_back(title);

	//	Put Description
	Tango::DbDatum	description("Description");
	std::vector<std::string>	str_desc;
	str_desc.push_back("Simulated power supply for Elettra 2.0 tests (digiltal twin).");
	str_desc.push_back("Tango interface Loosely based on NGPS tango device");
	description << str_desc;
	data.push_back(description);

	//  Put inheritance
	Tango::DbDatum	inher_datum("InheritedFrom");
	std::vector<std::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     : SimulatedE2PSClass::device_factory()
 *	Description: Create the device object(s)
 *                and store them in the device list
 */
//--------------------------------------------------------
void SimulatedE2PSClass::device_factory(const Tango::DevVarStringArray *devlist_ptr)
{
	/*----- PROTECTED REGION ID(SimulatedE2PSClass::device_factory_before) ENABLED START -----*/
/* clang-format on */
//	Add your own code
/* clang-format off */
/*----- PROTECTED REGION END -----*/	//	SimulatedE2PSClass::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() << std::endl;
		device_list.push_back(new SimulatedE2PS(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
		SimulatedE2PS *dev = static_cast<SimulatedE2PS *>(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(SimulatedE2PSClass::device_factory_after) ENABLED START -----*/
/* clang-format on */
//	Add your own code
/* clang-format off */
/*----- PROTECTED REGION END -----*/	//	SimulatedE2PSClass::device_factory_after
}
//--------------------------------------------------------
/**
 *	Method     : SimulatedE2PSClass::attribute_factory()
 *	Description: Create the attribute object(s)
 *                and store them in the attribute list
 */
//--------------------------------------------------------
void SimulatedE2PSClass::attribute_factory(std::vector<Tango::Attr *> &att_list)
{
	/*----- PROTECTED REGION ID(SimulatedE2PSClass::attribute_factory_before) ENABLED START -----*/
	/* clang-format on */
	//	Add your own code
	/* clang-format off */
	/*----- PROTECTED REGION END -----*/	//	SimulatedE2PSClass::attribute_factory_before
	//	Attribute : current
	currentAttrib	*current = new currentAttrib();
	Tango::UserDefaultAttrProp	current_prop;
	current_prop.set_description("The powersupply current setting in amps");
	current_prop.set_label("current");
	current_prop.set_unit("A");
	current_prop.set_standard_unit("1");
	current_prop.set_display_unit("A");
	current_prop.set_format("%6.4f");
	//	max_value	not set for current
	//	min_value	not set for current
	//	max_alarm	not set for current
	//	min_alarm	not set for current
	//	max_warning	not set for current
	//	min_warning	not set for current
	//	delta_t	not set for current
	//	delta_val	not set for current
	current->set_default_properties(current_prop);
	//	Not Polled
	current->set_disp_level(Tango::OPERATOR);
	//	Not Memorized
	att_list.push_back(current);

	//	Attribute : voltage
	voltageAttrib	*voltage = new voltageAttrib();
	Tango::UserDefaultAttrProp	voltage_prop;
	voltage_prop.set_description("The powersupply voltage in volts.");
	//	label	not set for voltage
	voltage_prop.set_unit("V");
	voltage_prop.set_standard_unit("1");
	voltage_prop.set_display_unit("V");
	voltage_prop.set_format("%6.4f");
	//	max_value	not set for voltage
	//	min_value	not set for voltage
	//	max_alarm	not set for voltage
	//	min_alarm	not set for voltage
	//	max_warning	not set for voltage
	//	min_warning	not set for voltage
	//	delta_t	not set for voltage
	//	delta_val	not set for voltage
	voltage->set_default_properties(voltage_prop);
	//	Not Polled
	voltage->set_disp_level(Tango::OPERATOR);
	//	Not Memorized
	att_list.push_back(voltage);

	//	Attribute : currentSet
	currentSetAttrib	*currentset = new currentSetAttrib();
	Tango::UserDefaultAttrProp	currentset_prop;
	currentset_prop.set_description("The current set value as stored in the powersupply.");
	//	label	not set for currentSet
	currentset_prop.set_unit("A");
	currentset_prop.set_standard_unit("1");
	currentset_prop.set_display_unit("A");
	currentset_prop.set_format("%6.4f");
	//	max_value	not set for currentSet
	//	min_value	not set for currentSet
	//	max_alarm	not set for currentSet
	//	min_alarm	not set for currentSet
	//	max_warning	not set for currentSet
	//	min_warning	not set for currentSet
	//	delta_t	not set for currentSet
	//	delta_val	not set for currentSet
	currentset->set_default_properties(currentset_prop);
	//	Not Polled
	currentset->set_disp_level(Tango::OPERATOR);
	//	Not Memorized
	att_list.push_back(currentset);

	//	Attribute : CurrentRipple
	CurrentRippleAttrib	*currentripple = new CurrentRippleAttrib();
	Tango::UserDefaultAttrProp	currentripple_prop;
	currentripple_prop.set_description("Amplitude of current ripple (noise) added to output.\nInitial value from property CurrentRipple");
	currentripple_prop.set_label("current ripple (noise)");
	currentripple_prop.set_unit("A");
	currentripple_prop.set_standard_unit("1");
	currentripple_prop.set_display_unit("A");
	currentripple_prop.set_format("%6.6f");
	//	max_value	not set for CurrentRipple
	//	min_value	not set for CurrentRipple
	//	max_alarm	not set for CurrentRipple
	//	min_alarm	not set for CurrentRipple
	//	max_warning	not set for CurrentRipple
	//	min_warning	not set for CurrentRipple
	//	delta_t	not set for CurrentRipple
	//	delta_val	not set for CurrentRipple
	currentripple->set_default_properties(currentripple_prop);
	//	Not Polled
	currentripple->set_disp_level(Tango::EXPERT);
	//	Not Memorized
	att_list.push_back(currentripple);

	//	Attribute : AddRipple
	AddRippleAttrib	*addripple = new AddRippleAttrib();
	Tango::UserDefaultAttrProp	addripple_prop;
	addripple_prop.set_description("Switch on/off current ripple. If False the power supply is ideal :no noise.");
	addripple_prop.set_label("add current ripple");
	//	unit	not set for AddRipple
	//	standard_unit	not set for AddRipple
	//	display_unit	not set for AddRipple
	//	format	not set for AddRipple
	//	max_value	not set for AddRipple
	//	min_value	not set for AddRipple
	//	max_alarm	not set for AddRipple
	//	min_alarm	not set for AddRipple
	//	max_warning	not set for AddRipple
	//	min_warning	not set for AddRipple
	//	delta_t	not set for AddRipple
	//	delta_val	not set for AddRipple
	addripple->set_default_properties(addripple_prop);
	//	Not Polled
	addripple->set_disp_level(Tango::EXPERT);
	//	Not Memorized
	att_list.push_back(addripple);


	//	Create a list of static attributes
	create_static_attribute_list(get_class_attr()->get_attr_list());
	/*----- PROTECTED REGION ID(SimulatedE2PSClass::attribute_factory_after) ENABLED START -----*/
	/* clang-format on */
	//	Add your own code
	/* clang-format off */
	/*----- PROTECTED REGION END -----*/	//	SimulatedE2PSClass::attribute_factory_after
}
//--------------------------------------------------------
/**
 *	Method     : SimulatedE2PSClass::pipe_factory()
 *	Description: Create the pipe object(s)
 *                and store them in the pipe list
 */
//--------------------------------------------------------
void SimulatedE2PSClass::pipe_factory()
{
	/*----- PROTECTED REGION ID(SimulatedE2PSClass::pipe_factory_before) ENABLED START -----*/
	/* clang-format on */
	//	Add your own code
	/* clang-format off */
	/*----- PROTECTED REGION END -----*/	//	SimulatedE2PSClass::pipe_factory_before
	/*----- PROTECTED REGION ID(SimulatedE2PSClass::pipe_factory_after) ENABLED START -----*/
	/* clang-format on */
	//	Add your own code
	/* clang-format off */
	/*----- PROTECTED REGION END -----*/	//	SimulatedE2PSClass::pipe_factory_after
}
//--------------------------------------------------------
/**
 *	Method     : SimulatedE2PSClass::command_factory()
 *	Description: Create the command object(s)
 *                and store them in the command list
 */
//--------------------------------------------------------
void SimulatedE2PSClass::command_factory()
{
	/*----- PROTECTED REGION ID(SimulatedE2PSClass::command_factory_before) ENABLED START -----*/
	/* clang-format on */
	//	Add your own code
	/* clang-format off */
	/*----- PROTECTED REGION END -----*/	//	SimulatedE2PSClass::command_factory_before


	//	Command On
	OnClass	*pOnCmd =
		new OnClass("On",
			Tango::DEV_VOID, Tango::DEV_VOID,
			"",
			"",
			Tango::OPERATOR);
	command_list.push_back(pOnCmd);

	//	Command Off
	OffClass	*pOffCmd =
		new OffClass("Off",
			Tango::DEV_VOID, Tango::DEV_VOID,
			"",
			"",
			Tango::OPERATOR);
	command_list.push_back(pOffCmd);

	//	Command Reset
	ResetClass	*pResetCmd =
		new ResetClass("Reset",
			Tango::DEV_VOID, Tango::DEV_VOID,
			"",
			"",
			Tango::OPERATOR);
	command_list.push_back(pResetCmd);

	//	Command StartCycling
	StartCyclingClass	*pStartCyclingCmd =
		new StartCyclingClass("StartCycling",
			Tango::DEV_VOID, Tango::DEV_VOID,
			"",
			"",
			Tango::OPERATOR);
	command_list.push_back(pStartCyclingCmd);

	//	Command Abort
	AbortClass	*pAbortCmd =
		new AbortClass("Abort",
			Tango::DEV_VOID, Tango::DEV_VOID,
			"",
			"",
			Tango::OPERATOR);
	command_list.push_back(pAbortCmd);

	//	Command Fault
	FaultClass	*pFaultCmd =
		new FaultClass("Fault",
			Tango::DEV_VOID, Tango::DEV_VOID,
			"",
			"",
			Tango::EXPERT);
	command_list.push_back(pFaultCmd);

	/*----- PROTECTED REGION ID(SimulatedE2PSClass::command_factory_after) ENABLED START -----*/
	/* clang-format on */
	//	Add your own code
	/* clang-format off */
	/*----- PROTECTED REGION END -----*/	//	SimulatedE2PSClass::command_factory_after
}

//===================================================================
//	Dynamic attributes related methods
//===================================================================

//--------------------------------------------------------
/**
 * method : 		SimulatedE2PSClass::create_static_attribute_list
 * description : 	Create the a list of static attributes
 *
 * @param	att_list	the created attribute list
 */
//--------------------------------------------------------
void SimulatedE2PSClass::create_static_attribute_list(std::vector<Tango::Attr *> &att_list)
{
	for (unsigned long i=0 ; i<att_list.size() ; i++)
	{
		std::string att_name(att_list[i]->get_name());
		std::transform(att_name.begin(), att_name.end(), att_name.begin(), ::tolower);
		defaultAttList.push_back(att_name);
	}

	TANGO_LOG_INFO << defaultAttList.size() << " attributes in default list" << std::endl;

	/*----- PROTECTED REGION ID(SimulatedE2PSClass::create_static_att_list) ENABLED START -----*/
	/* clang-format on */
	/* clang-format off */
	/*----- PROTECTED REGION END -----*/	//	SimulatedE2PSClass::create_static_att_list
}


//--------------------------------------------------------
/**
 * method : 		SimulatedE2PSClass::erase_dynamic_attributes
 * description : 	delete the dynamic attributes if any.
 *
 * @param	devlist_ptr	the device list pointer
 * @param	list of all attributes
 */
//--------------------------------------------------------
void SimulatedE2PSClass::erase_dynamic_attributes(const Tango::DevVarStringArray *devlist_ptr, std::vector<Tango::Attr *> &att_list)
{
	Tango::Util *tg = Tango::Util::instance();

	for (unsigned long i=0 ; i<devlist_ptr->length() ; i++)
	{
		Tango::DeviceImpl *dev_impl = tg->get_device_by_name(((std::string)(*devlist_ptr)[i]).c_str());
		SimulatedE2PS *dev = static_cast<SimulatedE2PS *> (dev_impl);

		std::vector<Tango::Attribute *> &dev_att_list = dev->get_device_attr()->get_attribute_list();
		std::vector<Tango::Attribute *>::iterator ite_att;
		for (ite_att=dev_att_list.begin() ; ite_att != dev_att_list.end() ; ++ite_att)
		{
			std::string att_name((*ite_att)->get_name_lower());
			if ((att_name == "state") || (att_name == "status"))
				continue;
			std::vector<std::string>::iterator ite_str = find(defaultAttList.begin(), defaultAttList.end(), att_name);
			if (ite_str == defaultAttList.end())
			{
				TANGO_LOG_INFO << att_name << " is a UNWANTED dynamic attribute for device " << (*devlist_ptr)[i] << std::endl;
				Tango::Attribute &att = dev->get_device_attr()->get_attr_by_name(att_name.c_str());
				dev->remove_attribute(att_list[att.get_attr_idx()], true, false);
				--ite_att;
			}
		}
	}
	/*----- PROTECTED REGION ID(SimulatedE2PSClass::erase_dynamic_attributes) ENABLED START -----*/
	/* clang-format on */
	/* clang-format off */
	/*----- PROTECTED REGION END -----*/	//	SimulatedE2PSClass::erase_dynamic_attributes
}

//--------------------------------------------------------
/**
 *	Method     : SimulatedE2PSClass::get_attr_object_by_name()
 *	Description: returns Tango::Attr * object found by name
 */
//--------------------------------------------------------
Tango::Attr *SimulatedE2PSClass::get_attr_object_by_name(std::vector<Tango::Attr *> &att_list, std::string attname)
{
	std::vector<Tango::Attr *>::iterator it;
	for (it=att_list.begin() ; it<att_list.end() ; ++it)
		if ((*it)->get_name()==attname)
			return (*it);
	//	Attr does not exist
	return NULL;
}


/*----- PROTECTED REGION ID(SimulatedE2PSClass::Additional Methods) ENABLED START -----*/
/* clang-format on */
/* clang-format off */
/*----- PROTECTED REGION END -----*/	//	SimulatedE2PSClass::Additional Methods
} //	namespace