Skip to content
Snippets Groups Projects
SimulatedE2PS.cpp 24.7 KiB
Newer Older
Claudio Scafuri's avatar
Claudio Scafuri committed
/*----- PROTECTED REGION ID(SimulatedE2PS.cpp) ENABLED START -----*/
/* clang-format on */
//=============================================================================
//
// file :        SimulatedE2PS.cpp
//
// description : C++ source for the SimulatedE2PS class and its commands.
//               The class is derived from Device. It represents the
//               CORBA servant object which will be accessed from the
//               network. All commands which can be executed on the
//               SimulatedE2PS are implemented in this file.
//
// 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 "SimulatedE2PS.h"
#include "SimulatedE2PSClass.h"
#include <random>
#include <chrono>
Claudio Scafuri's avatar
Claudio Scafuri committed
/* clang-format off */
/*----- PROTECTED REGION END -----*/	//	SimulatedE2PS.cpp

/**
 *  SimulatedE2PS class description:
 *    Simulated power supply for Elettra 2.0 tests (digiltal twin).
 *    Tango interface Loosely based on NGPS tango device
 */

//================================================================
//  The following table gives the correspondence
//  between command and method names.
//
//  Command name  |  Method name
//================================================================
//  State         |  Inherited (no method)
//  Status        |  Inherited (no method)
//  On            |  on
//  Off           |  off
//  Reset         |  reset
Claudio Scafuri's avatar
Claudio Scafuri committed
//  Fault         |  fault
Claudio Scafuri's avatar
Claudio Scafuri committed
//================================================================

//================================================================
//  Attributes managed are:
//================================================================
//  current        |  Tango::DevDouble	Scalar
//  voltage        |  Tango::DevDouble	Scalar
//  currentSet     |  Tango::DevDouble	Scalar
//  CurrentRipple  |  Tango::DevDouble	Scalar
//  AddRipple      |  Tango::DevBoolean	Scalar
//  RippleStdDev   |  Tango::DevDouble	Scalar
Claudio Scafuri's avatar
Claudio Scafuri committed
//================================================================

namespace SimulatedE2PS_ns
{
/*----- PROTECTED REGION ID(SimulatedE2PS::namespace_starting) ENABLED START -----*/
/* clang-format on */
//	static initializations
/* clang-format off */
/*----- PROTECTED REGION END -----*/	//	SimulatedE2PS::namespace_starting

//--------------------------------------------------------
/**
 *	Method     : SimulatedE2PS::SimulatedE2PS()
 *	Description: Constructors for a Tango device
Claudio Scafuri's avatar
Claudio Scafuri committed
 *                implementing the classSimulatedE2PS
 */
//--------------------------------------------------------
SimulatedE2PS::SimulatedE2PS(Tango::DeviceClass *cl, std::string &s)
 : TANGO_BASE_CLASS(cl, s.c_str())
{
	/*----- PROTECTED REGION ID(SimulatedE2PS::constructor_1) ENABLED START -----*/
	/* clang-format on */
	init_device();
	/* clang-format off */
	/*----- PROTECTED REGION END -----*/	//	SimulatedE2PS::constructor_1
}
//--------------------------------------------------------
SimulatedE2PS::SimulatedE2PS(Tango::DeviceClass *cl, const char *s)
 : TANGO_BASE_CLASS(cl, s)
{
	/*----- PROTECTED REGION ID(SimulatedE2PS::constructor_2) ENABLED START -----*/
	/* clang-format on */
	init_device();
	/* clang-format off */
	/*----- PROTECTED REGION END -----*/	//	SimulatedE2PS::constructor_2
}
//--------------------------------------------------------
SimulatedE2PS::SimulatedE2PS(Tango::DeviceClass *cl, const char *s, const char *d)
 : TANGO_BASE_CLASS(cl, s, d)
{
	/*----- PROTECTED REGION ID(SimulatedE2PS::constructor_3) ENABLED START -----*/
	/* clang-format on */
	init_device();
	/* clang-format off */
	/*----- PROTECTED REGION END -----*/	//	SimulatedE2PS::constructor_3
}
//--------------------------------------------------------
SimulatedE2PS::~SimulatedE2PS()
{
	delete_device();
}

//--------------------------------------------------------
/**
 *	Method     : SimulatedE2PS::delete_device()
 *	Description: will be called at device destruction or at init command
Claudio Scafuri's avatar
Claudio Scafuri committed
 */
//--------------------------------------------------------
void SimulatedE2PS::delete_device()
{
	DEBUG_STREAM << "SimulatedE2PS::delete_device() " << device_name << std::endl;
	/*----- PROTECTED REGION ID(SimulatedE2PS::delete_device) ENABLED START -----*/
	/* clang-format on */
	//	Delete device allocated objects
	delete distribution;
	delete generator;
Claudio Scafuri's avatar
Claudio Scafuri committed
	/* clang-format off */
	/*----- PROTECTED REGION END -----*/	//	SimulatedE2PS::delete_device
}

//--------------------------------------------------------
/**
 *	Method     : SimulatedE2PS::init_device()
 *	Description: will be called at device initialization.
Claudio Scafuri's avatar
Claudio Scafuri committed
 */
//--------------------------------------------------------
void SimulatedE2PS::init_device()
{
	DEBUG_STREAM << "SimulatedE2PS::init_device() create device " << device_name << std::endl;
	/*----- PROTECTED REGION ID(SimulatedE2PS::init_device_before) ENABLED START -----*/
	/* clang-format on */
	//	Initialization before get_device_property() call
	/* clang-format off */
	/*----- PROTECTED REGION END -----*/	//	SimulatedE2PS::init_device_before


	//	Get the device properties from database
	get_device_property();
Claudio Scafuri's avatar
Claudio Scafuri committed

	/*----- PROTECTED REGION ID(SimulatedE2PS::init_device) ENABLED START -----*/
	/* clang-format on */
	//	Initialize device
	// Initialise variables to default values

	// crate normal distibuytion rando generator;
	 unsigned seed = std::chrono::system_clock::now().time_since_epoch().count(); //change seed at each initailization - otherwise it is repeatable!
	 generator = new std::default_random_engine(seed);
	 distribution = new std::normal_distribution<double>(0.0,rippleStdDev);
Claudio Scafuri's avatar
Claudio Scafuri committed
	_current= 0.0;
	_current_read= 0.0;
	_voltage= 0.1;
	_ripple_std_dev = rippleStdDev;
Claudio Scafuri's avatar
Claudio Scafuri committed
	_ohm = 0.2; // load resistance in ohm
	Tango::MultiAttribute *attr_list = get_device_attr();
	attr_current = &(attr_list->get_w_attr_by_name("current"));
	try{
		attr_current->set_write_value(_current);
	}
	catch(...){} // ignore error!
Claudio Scafuri's avatar
Claudio Scafuri committed
	set_state(Tango::OFF);
	set_status("Off");
Claudio Scafuri's avatar
Claudio Scafuri committed
	INFO_STREAM << "SimulatedE2PS::init_device() create device  end " << device_name << endl;
	/* clang-format off */
	/*----- PROTECTED REGION END -----*/	//	SimulatedE2PS::init_device
}

//--------------------------------------------------------
/**
 *	Method     : SimulatedE2PS::get_device_property()
 *	Description: Read database to initialize property data members.
 */
//--------------------------------------------------------
void SimulatedE2PS::get_device_property()
{
	/*----- PROTECTED REGION ID(SimulatedE2PS::get_device_property_before) ENABLED START -----*/
	/* clang-format on */
	//	Initialize property data members
	/* clang-format off */
	/*----- PROTECTED REGION END -----*/	//	SimulatedE2PS::get_device_property_before


	//	Read device properties from database.
	Tango::DbData	dev_prop;
	dev_prop.push_back(Tango::DbDatum("CurrentRipple"));
	dev_prop.push_back(Tango::DbDatum("RippleStdDev"));

	//	is there at least one property to be read ?
	if (dev_prop.size()>0)
	{
		//	Call database and extract values
		if (Tango::Util::instance()->_UseDb==true)
			get_db_device()->get_property(dev_prop);

		//	get instance on SimulatedE2PSClass to get class property
		Tango::DbDatum	def_prop, cl_prop;
		SimulatedE2PSClass	*ds_class =
			(static_cast<SimulatedE2PSClass *>(get_device_class()));
		int	i = -1;

		//	Try to initialize CurrentRipple from class property
		cl_prop = ds_class->get_class_property(dev_prop[++i].name);
		if (cl_prop.is_empty()==false)	cl_prop  >>  currentRipple;
		else {
			//	Try to initialize CurrentRipple from default device value
			def_prop = ds_class->get_default_device_property(dev_prop[i].name);
			if (def_prop.is_empty()==false)	def_prop  >>  currentRipple;
		}
		//	And try to extract CurrentRipple value from database
		if (dev_prop[i].is_empty()==false)	dev_prop[i]  >>  currentRipple;

		//	Try to initialize RippleStdDev from class property
		cl_prop = ds_class->get_class_property(dev_prop[++i].name);
		if (cl_prop.is_empty()==false)	cl_prop  >>  rippleStdDev;
		else {
			//	Try to initialize RippleStdDev from default device value
			def_prop = ds_class->get_default_device_property(dev_prop[i].name);
			if (def_prop.is_empty()==false)	def_prop  >>  rippleStdDev;
		}
		//	And try to extract RippleStdDev value from database
		if (dev_prop[i].is_empty()==false)	dev_prop[i]  >>  rippleStdDev;

	}

	/*----- PROTECTED REGION ID(SimulatedE2PS::get_device_property_after) ENABLED START -----*/
	/* clang-format on */
	//	Check device property data members init
	/* clang-format off */
	/*----- PROTECTED REGION END -----*/	//	SimulatedE2PS::get_device_property_after
}
Claudio Scafuri's avatar
Claudio Scafuri committed

//--------------------------------------------------------
/**
 *	Method     : SimulatedE2PS::always_executed_hook()
 *	Description: method always executed before any command is executed
Claudio Scafuri's avatar
Claudio Scafuri committed
 */
//--------------------------------------------------------
void SimulatedE2PS::always_executed_hook()
{
	DEBUG_STREAM << "SimulatedE2PS::always_executed_hook()  " << device_name << std::endl;
	/*----- PROTECTED REGION ID(SimulatedE2PS::always_executed_hook) ENABLED START -----*/
	/* clang-format on */
	//	code always executed before all requests
	/* clang-format off */
	/*----- PROTECTED REGION END -----*/	//	SimulatedE2PS::always_executed_hook
}

//--------------------------------------------------------
/**
 *	Method     : SimulatedE2PS::read_attr_hardware()
 *	Description: Hardware acquisition for attributes
Claudio Scafuri's avatar
Claudio Scafuri committed
 */
//--------------------------------------------------------
void SimulatedE2PS::read_attr_hardware(TANGO_UNUSED(std::vector<long> &attr_list))
{
	DEBUG_STREAM << "SimulatedE2PS::read_attr_hardware(std::vector<long> &attr_list) entering... " << std::endl;
	/*----- PROTECTED REGION ID(SimulatedE2PS::read_attr_hardware) ENABLED START -----*/
	/* clang-format on */
	//	Add your own code
	/* clang-format off */
	/*----- PROTECTED REGION END -----*/	//	SimulatedE2PS::read_attr_hardware
}
//--------------------------------------------------------
/**
 *	Method     : SimulatedE2PS::write_attr_hardware()
 *	Description: Hardware writing for attributes
Claudio Scafuri's avatar
Claudio Scafuri committed
 */
//--------------------------------------------------------
void SimulatedE2PS::write_attr_hardware(TANGO_UNUSED(std::vector<long> &attr_list))
{
	DEBUG_STREAM << "SimulatedE2PS::write_attr_hardware(std::vector<long> &attr_list) entering... " << std::endl;
	/*----- PROTECTED REGION ID(SimulatedE2PS::write_attr_hardware) ENABLED START -----*/
	/* clang-format on */
	//	Add your own code
	/* clang-format off */
	/*----- PROTECTED REGION END -----*/	//	SimulatedE2PS::write_attr_hardware
}

//--------------------------------------------------------
/**
 *	Read attribute current related method
 *	Description: The powersupply current setting in amps
Claudio Scafuri's avatar
Claudio Scafuri committed
 *
 *	Data type:	Tango::DevDouble
 *	Attr type:	Scalar
 */
//--------------------------------------------------------
void SimulatedE2PS::read_current(Tango::Attribute &attr)
{
	DEBUG_STREAM << "SimulatedE2PS::read_current(Tango::Attribute &attr) entering... " << std::endl;
	/*----- PROTECTED REGION ID(SimulatedE2PS::read_current) ENABLED START -----*/
	/* clang-format on */
	//	Set the attribute value
		//delta = drand48()-0.5; // use anothe random distribution?
	    delta =  (*distribution)((*generator)); // normal distributed ripple
Claudio Scafuri's avatar
Claudio Scafuri committed
	if(get_state() == Tango::OFF){
		_current_read = 0.0; //delta * _current_ripple;
Claudio Scafuri's avatar
Claudio Scafuri committed
	}
	else{
		_current_read = _current +( delta * _current_ripple );
Claudio Scafuri's avatar
Claudio Scafuri committed
	}
	attr.set_value(&_current_read);
	/* clang-format off */
	/*----- PROTECTED REGION END -----*/	//	SimulatedE2PS::read_current
}
//--------------------------------------------------------
/**
 *	Write attribute current related method
 *	Description: The powersupply current setting in amps
Claudio Scafuri's avatar
Claudio Scafuri committed
 *
 *	Data type:	Tango::DevDouble
 *	Attr type:	Scalar
 */
//--------------------------------------------------------
void SimulatedE2PS::write_current(Tango::WAttribute &attr)
{
	DEBUG_STREAM << "SimulatedE2PS::write_current(Tango::WAttribute &attr) entering... " << std::endl;
	//	Retrieve write value
	Tango::DevDouble	w_val;
	attr.get_write_value(w_val);
Claudio Scafuri's avatar
Claudio Scafuri committed
	/*----- PROTECTED REGION ID(SimulatedE2PS::write_current) ENABLED START -----*/
	/* clang-format on */
	//	Add your own code
Claudio Scafuri's avatar
Claudio Scafuri committed
	_current = w_val;
	push_change_event("Current", &_current); //force update in any case

Claudio Scafuri's avatar
Claudio Scafuri committed
	/* clang-format off */
	/*----- PROTECTED REGION END -----*/	//	SimulatedE2PS::write_current
}
//--------------------------------------------------------
/**
 *	Read attribute voltage related method
 *	Description: The powersupply voltage in volts.
Claudio Scafuri's avatar
Claudio Scafuri committed
 *
 *	Data type:	Tango::DevDouble
 *	Attr type:	Scalar
 */
//--------------------------------------------------------
void SimulatedE2PS::read_voltage(Tango::Attribute &attr)
{
	DEBUG_STREAM << "SimulatedE2PS::read_voltage(Tango::Attribute &attr) entering... " << std::endl;
	/*----- PROTECTED REGION ID(SimulatedE2PS::read_voltage) ENABLED START -----*/
	/* clang-format on */
	//	Set the attribute value
	attr.set_value(&_voltage);
	/* clang-format off */
	/*----- PROTECTED REGION END -----*/	//	SimulatedE2PS::read_voltage
}
//--------------------------------------------------------
/**
 *	Read attribute currentSet related method
 *	Description: The current set value as stored in the powersupply.
Claudio Scafuri's avatar
Claudio Scafuri committed
 *
 *	Data type:	Tango::DevDouble
 *	Attr type:	Scalar
 */
//--------------------------------------------------------
void SimulatedE2PS::read_currentSet(Tango::Attribute &attr)
{
	DEBUG_STREAM << "SimulatedE2PS::read_currentSet(Tango::Attribute &attr) entering... " << std::endl;
	/*----- PROTECTED REGION ID(SimulatedE2PS::read_currentSet) ENABLED START -----*/
	/* clang-format on */
	//	Set the attribute value
	attr.set_value(&_current);
	/* clang-format off */
	/*----- PROTECTED REGION END -----*/	//	SimulatedE2PS::read_currentSet
}
//--------------------------------------------------------
/**
 *	Read attribute CurrentRipple related method
 *	Description: multiplication factor  of current ripple (noise) added to output. The current ripple is obtained form a normal distribution of mean 0 and standard deviation = RippleStdDev
 *               Initial value from property CurrentRipple
 *
 *	Data type:	Tango::DevDouble
 *	Attr type:	Scalar
 */
//--------------------------------------------------------
void SimulatedE2PS::read_CurrentRipple(Tango::Attribute &attr)
{
	DEBUG_STREAM << "SimulatedE2PS::read_CurrentRipple(Tango::Attribute &attr) entering... " << std::endl;
	/*----- PROTECTED REGION ID(SimulatedE2PS::read_CurrentRipple) ENABLED START -----*/
	/* clang-format on */
	//	Set the attribute value
	attr.set_value(&_current_ripple);
	/* clang-format off */
	/*----- PROTECTED REGION END -----*/	//	SimulatedE2PS::read_CurrentRipple
}
//--------------------------------------------------------
/**
 *	Write attribute CurrentRipple related method
 *	Description: multiplication factor  of current ripple (noise) added to output. The current ripple is obtained form a normal distribution of mean 0 and standard deviation = RippleStdDev
 *               Initial value from property CurrentRipple
 *
 *	Data type:	Tango::DevDouble
 *	Attr type:	Scalar
 */
//--------------------------------------------------------
void SimulatedE2PS::write_CurrentRipple(Tango::WAttribute &attr)
{
	DEBUG_STREAM << "SimulatedE2PS::write_CurrentRipple(Tango::WAttribute &attr) entering... " << std::endl;
	//	Retrieve write value
	Tango::DevDouble	w_val;
	attr.get_write_value(w_val);
	/*----- PROTECTED REGION ID(SimulatedE2PS::write_CurrentRipple) ENABLED START -----*/
	/* clang-format on */
	//	Add your own code
	_current_ripple = w_val;
	/* clang-format off */
	/*----- PROTECTED REGION END -----*/	//	SimulatedE2PS::write_CurrentRipple
}
//--------------------------------------------------------
/**
 *	Read attribute AddRipple related method
 *	Description: Switch on/off current ripple. If False the power supply is ideal :no noise.
 *
 *	Data type:	Tango::DevBoolean
 *	Attr type:	Scalar
 */
//--------------------------------------------------------
void SimulatedE2PS::read_AddRipple(Tango::Attribute &attr)
{
	DEBUG_STREAM << "SimulatedE2PS::read_AddRipple(Tango::Attribute &attr) entering... " << std::endl;
	/*----- PROTECTED REGION ID(SimulatedE2PS::read_AddRipple) ENABLED START -----*/
	/* clang-format on */
	//	Set the attribute value
	attr.set_value(&_add_ripple);
	/* clang-format off */
	/*----- PROTECTED REGION END -----*/	//	SimulatedE2PS::read_AddRipple
}
//--------------------------------------------------------
/**
 *	Write attribute AddRipple related method
 *	Description: Switch on/off current ripple. If False the power supply is ideal :no noise.
 *
 *	Data type:	Tango::DevBoolean
 *	Attr type:	Scalar
 */
//--------------------------------------------------------
void SimulatedE2PS::write_AddRipple(Tango::WAttribute &attr)
{
	DEBUG_STREAM << "SimulatedE2PS::write_AddRipple(Tango::WAttribute &attr) entering... " << std::endl;
	//	Retrieve write value
	Tango::DevBoolean	w_val;
	attr.get_write_value(w_val);
	/*----- PROTECTED REGION ID(SimulatedE2PS::write_AddRipple) ENABLED START -----*/
	/* clang-format on */
	//	Add your own code
	_add_ripple = w_val;
	if (!_add_ripple) {
		_current_read = _current;
		push_change_event("current", &_current_read);
	}
	/* clang-format off */
	/*----- PROTECTED REGION END -----*/	//	SimulatedE2PS::write_AddRipple
}
//--------------------------------------------------------
/**
 *	Read attribute RippleStdDev related method
 *	Description: Standard deviation of current ripple (noise) normal rando generator added to output.
 *               Initial value from property RippleStdDev
 *
 *	Data type:	Tango::DevDouble
 *	Attr type:	Scalar
 */
//--------------------------------------------------------
void SimulatedE2PS::read_RippleStdDev(Tango::Attribute &attr)
{
	DEBUG_STREAM << "SimulatedE2PS::read_RippleStdDev(Tango::Attribute &attr) entering... " << std::endl;
	/*----- PROTECTED REGION ID(SimulatedE2PS::read_RippleStdDev) ENABLED START -----*/
	/* clang-format on */
	//	Set the attribute value
	attr.set_value(&_ripple_std_dev);
	/* clang-format off */
	/*----- PROTECTED REGION END -----*/	//	SimulatedE2PS::read_RippleStdDev
}
//--------------------------------------------------------
/**
 *	Write attribute RippleStdDev related method
 *	Description: Standard deviation of current ripple (noise) normal rando generator added to output.
 *               Initial value from property RippleStdDev
 *
 *	Data type:	Tango::DevDouble
 *	Attr type:	Scalar
 */
//--------------------------------------------------------
void SimulatedE2PS::write_RippleStdDev(Tango::WAttribute &attr)
{
	DEBUG_STREAM << "SimulatedE2PS::write_RippleStdDev(Tango::WAttribute &attr) entering... " << std::endl;
	//	Retrieve write value
	Tango::DevDouble	w_val;
	attr.get_write_value(w_val);
	/*----- PROTECTED REGION ID(SimulatedE2PS::write_RippleStdDev) ENABLED START -----*/
	/* clang-format on */
	//	Add your own code
	_ripple_std_dev = w_val;
	std::normal_distribution<double>::param_type d2(0.0,_ripple_std_dev);
	distribution->param(d2);

	/* clang-format off */
	/*----- PROTECTED REGION END -----*/	//	SimulatedE2PS::write_RippleStdDev
}
Claudio Scafuri's avatar
Claudio Scafuri committed

//--------------------------------------------------------
/**
 *	Method     : SimulatedE2PS::add_dynamic_attributes()
 *	Description: Create the dynamic attributes if any
Claudio Scafuri's avatar
Claudio Scafuri committed
 *                for specified device.
 */
//--------------------------------------------------------
void SimulatedE2PS::add_dynamic_attributes()
{
	/*----- PROTECTED REGION ID(SimulatedE2PS::add_dynamic_attributes) ENABLED START -----*/
	/* clang-format on */
	//	Add your own code to create and add dynamic attributes if any
	/* clang-format off */
	/*----- PROTECTED REGION END -----*/	//	SimulatedE2PS::add_dynamic_attributes
}

//--------------------------------------------------------
/**
 *	Command On related method
 *	Description: Switch powersupply ON.
Claudio Scafuri's avatar
Claudio Scafuri committed
 *
 */
//--------------------------------------------------------
void SimulatedE2PS::on()
{
	DEBUG_STREAM << "SimulatedE2PS::On()  - " << device_name << std::endl;
	/*----- PROTECTED REGION ID(SimulatedE2PS::on) ENABLED START -----*/
	/* clang-format on */

	//	Add your own code
	set_state(Tango::ON);
Claudio Scafuri's avatar
Claudio Scafuri committed
	set_status("On");
	push_change_event("State");
	push_change_event("current",&_current_read);
	push_change_event("currentSet",&_current);
Claudio Scafuri's avatar
Claudio Scafuri committed

	/* clang-format off */
	/*----- PROTECTED REGION END -----*/	//	SimulatedE2PS::on
}
//--------------------------------------------------------
/**
 *	Command Off related method
 *	Description: Switch power supply OFF.
Claudio Scafuri's avatar
Claudio Scafuri committed
 *
 */
//--------------------------------------------------------
void SimulatedE2PS::off()
{
	DEBUG_STREAM << "SimulatedE2PS::Off()  - " << device_name << std::endl;
	/*----- PROTECTED REGION ID(SimulatedE2PS::off) ENABLED START -----*/
	/* clang-format on */
	_current_read = 0.0;
	_current = 0.0;
	_voltage = 0.0;
	attr_current->set_write_value(_current);
	push_change_event("current",&_current_read);
	push_change_event("currentSet",&_current);
	set_state(Tango::OFF);
Claudio Scafuri's avatar
Claudio Scafuri committed
	set_status("Off");
	push_change_event("State");
;
Claudio Scafuri's avatar
Claudio Scafuri committed
	//	Add your own code

	/* clang-format off */
	/*----- PROTECTED REGION END -----*/	//	SimulatedE2PS::off
}
//--------------------------------------------------------
/**
 *	Command Reset related method
 *	Description: Reset the powersupply to a well known state.
Claudio Scafuri's avatar
Claudio Scafuri committed
 *
 */
//--------------------------------------------------------
void SimulatedE2PS::reset()
{
	DEBUG_STREAM << "SimulatedE2PS::Reset()  - " << device_name << std::endl;
	/*----- PROTECTED REGION ID(SimulatedE2PS::reset) ENABLED START -----*/
	/* clang-format on */

	//	Add your own code
	if(get_state() == Tango::FAULT){
		set_state(Tango::OFF);
Claudio Scafuri's avatar
Claudio Scafuri committed
		set_status("Off");
		push_change_event("State");
	}
Claudio Scafuri's avatar
Claudio Scafuri committed

	/* clang-format off */
	/*----- PROTECTED REGION END -----*/	//	SimulatedE2PS::reset
}
//--------------------------------------------------------
/**
Claudio Scafuri's avatar
Claudio Scafuri committed
 *	Command Fault related method
 *	Description: Force a simulated faulty condtion
Claudio Scafuri's avatar
Claudio Scafuri committed
 *
 */
//--------------------------------------------------------
void SimulatedE2PS::fault()
{
Claudio Scafuri's avatar
Claudio Scafuri committed
	DEBUG_STREAM << "SimulatedE2PS::Fault()  - " << device_name << std::endl;
Claudio Scafuri's avatar
Claudio Scafuri committed
	/*----- PROTECTED REGION ID(SimulatedE2PS::fault) ENABLED START -----*/
	/* clang-format on */

	//	Add your own code
Claudio Scafuri's avatar
Claudio Scafuri committed
	if (get_state() == Tango::FAULT) return; // command is idempotent
	_current_read = 0.0;
	_current = 0.0;
	_voltage = 0.0;
	attr_current->set_write_value(_current);
Claudio Scafuri's avatar
Claudio Scafuri committed
	push_change_event("current", &_current_read);
	push_change_event("currentSet", &_current);
	set_state(Tango::FAULT);
Claudio Scafuri's avatar
Claudio Scafuri committed
	set_status("Fault");
	push_change_event("State");
Claudio Scafuri's avatar
Claudio Scafuri committed
	/* clang-format off */
	/*----- PROTECTED REGION END -----*/	//	SimulatedE2PS::fault
}
//--------------------------------------------------------
/**
 *	Method     : SimulatedE2PS::add_dynamic_commands()
 *	Description: Create the dynamic commands if any
Claudio Scafuri's avatar
Claudio Scafuri committed
 *                for specified device.
 */
//--------------------------------------------------------
void SimulatedE2PS::add_dynamic_commands()
{
	/*----- PROTECTED REGION ID(SimulatedE2PS::add_dynamic_commands) ENABLED START -----*/
	/* clang-format on */
	//	Add your own code to create and add dynamic commands if any
	/* clang-format off */
	/*----- PROTECTED REGION END -----*/	//	SimulatedE2PS::add_dynamic_commands
}

/*----- PROTECTED REGION ID(SimulatedE2PS::namespace_ending) ENABLED START -----*/
/* clang-format on */
//	Additional Methods
/* clang-format off */// //--------------------------------------------------------
// /**
//  *	Command StartCycling related method
//  *
//  *
//  */
// //--------------------------------------------------------
// void SimulatedE2PS::start_cycling()
// {
// 	DEBUG_STREAM << "SimulatedE2PS::StartCycling()  - " << device_name << std::endl;
// 	/* clang-format on */
// 	//	Add your own code
// 	/* clang-format off */
// }

// //--------------------------------------------------------
// /**
//  *	Command Abort related method
//  *	Description: stop ramp or cycling
//  *
//  */
// //--------------------------------------------------------
// void SimulatedE2PS::abort()
// {
// 	DEBUG_STREAM << "SimulatedE2PS::Abort()  - " << device_name << std::endl;
// 	/* clang-format on */
// 	//	Add your own code
// 	/* clang-format off */
// }


Claudio Scafuri's avatar
Claudio Scafuri committed
/*----- PROTECTED REGION END -----*/	//	SimulatedE2PS::namespace_ending
} //	namespace