Skip to content
Snippets Groups Projects

Compare revisions

Changes are shown as if the source revision was being merged into the target revision. Learn more about comparing revisions.

Source

Select target project
No results found

Target

Select target project
  • dt/ds/simulatede2ps
1 result
Show changes
Commits on Source (2)
.nse_depinfo*
bin
obj
# Eclipse
.cproject
.project
.settings
NAME_SRV = simulatede2ps-srv
include ../makefiles/Make-9.3.6.in
#
# Resource backup , created Wed Oct 16 17:04:36 CEST 2024
#
#---------------------------------------------------------
# SERVER simulatede2ps-srv/test, SimulatedE2PS device declaration
#---------------------------------------------------------
simulatede2ps-srv/test/DEVICE/SimulatedE2PS: "test/power_supply/psceh16",\
"test/power_supply/psceh20",\
"test/power_supply/pscev16",\
"test/power_supply/pscev20",\
"test/power_supply/psq13",\
"test/power_supply/psq24",\
"test/power_supply/pss16",\
"test/power_supply/pss20"
# --- test/power_supply/psceh16 properties
test/power_supply/psceh16->polled_attr: current,\
500,\
currentset,\
500,\
state,\
3000
# --- test/power_supply/psceh16 attribute properties
test/power_supply/psceh16/current->abs_change: -1e-05,\
1e-05
test/power_supply/psceh16/current->max_value: 25.0
test/power_supply/psceh16/current->min_value: -25.0
test/power_supply/psceh16/currentSet->abs_change: -1e-05,\
1e-05
test/power_supply/psceh16/currentSet->max_value: 25.0
test/power_supply/psceh16/currentSet->min_value: -25.0
# --- test/power_supply/psceh20 properties
test/power_supply/psceh20->polled_attr: current,\
500,\
currentset,\
500,\
state,\
3000
# --- test/power_supply/psceh20 attribute properties
test/power_supply/psceh20/current->abs_change: -1e-05,\
1e-05
test/power_supply/psceh20/current->max_value: 25.0
test/power_supply/psceh20/current->min_value: -25.0
test/power_supply/psceh20/currentSet->abs_change: -1e-05,\
1e-05
test/power_supply/psceh20/currentSet->max_value: 25.0
test/power_supply/psceh20/currentSet->min_value: -25.0
# --- test/power_supply/pscev16 properties
test/power_supply/pscev16->polled_attr: current,\
500,\
currentset,\
500,\
state,\
3000
# --- test/power_supply/pscev16 attribute properties
test/power_supply/pscev16/current->abs_change: -1e-05,\
1e-05
test/power_supply/pscev16/current->max_value: 25.0
test/power_supply/pscev16/current->min_value: -25.0
test/power_supply/pscev16/currentSet->abs_change: -1e-05,\
1e-05
test/power_supply/pscev16/currentSet->max_value: 25.0
test/power_supply/pscev16/currentSet->min_value: -25.0
# --- test/power_supply/pscev20 properties
test/power_supply/pscev20->polled_attr: current,\
500,\
currentset,\
500,\
state,\
3000
# --- test/power_supply/pscev20 attribute properties
test/power_supply/pscev20/current->abs_change: -1e-05,\
1e-05
test/power_supply/pscev20/current->max_value: 25.0
test/power_supply/pscev20/current->min_value: -25.0
test/power_supply/pscev20/currentSet->abs_change: -1e-05,\
1e-05
test/power_supply/pscev20/currentSet->max_value: 25.0
test/power_supply/pscev20/currentSet->min_value: -25.0
# --- test/power_supply/psq13 properties
test/power_supply/psq13->polled_attr: current,\
500,\
currentset,\
500,\
state,\
3000
# --- test/power_supply/psq13 attribute properties
test/power_supply/psq13/current->abs_change: -1e-05,\
1e-05
test/power_supply/psq13/current->max_value: 100.0
test/power_supply/psq13/current->min_value: -100.0
test/power_supply/psq13/currentSet->abs_change: -1e-05,\
1e-05
test/power_supply/psq13/currentSet->max_value: 25.0
test/power_supply/psq13/currentSet->min_value: -25.0
# --- test/power_supply/psq24 properties
test/power_supply/psq24->polled_attr: current,\
500,\
currentset,\
500,\
state,\
3000
# --- test/power_supply/psq24 attribute properties
test/power_supply/psq24/current->abs_change: -1e-05,\
1e-05
test/power_supply/psq24/current->max_value: 100.0
test/power_supply/psq24/current->min_value: -100.0
test/power_supply/psq24/currentSet->abs_change: -1e-05,\
1e-05
test/power_supply/psq24/currentSet->max_value: 25.0
test/power_supply/psq24/currentSet->min_value: -25.0
# --- test/power_supply/pss16 properties
test/power_supply/pss16->polled_attr: current,\
500,\
currentset,\
500,\
state,\
3000
# --- test/power_supply/pss16 attribute properties
test/power_supply/pss16/current->abs_change: -1e-05,\
1e-05
test/power_supply/pss16/current->max_value: 100.0
test/power_supply/pss16/current->min_value: -100.0
test/power_supply/pss16/currentSet->abs_change: -1e-05,\
1e-05
test/power_supply/pss16/currentSet->max_value: 25.0
test/power_supply/pss16/currentSet->min_value: -25.0
# --- test/power_supply/pss20 properties
test/power_supply/pss20->polled_attr: current,\
500,\
currentset,\
500,\
state,\
3000
# --- test/power_supply/pss20 attribute properties
test/power_supply/pss20/current->abs_change: -1e-05,\
1e-05
test/power_supply/pss20/current->max_value: 100.0
test/power_supply/pss20/current->min_value: -100.0
test/power_supply/pss20/currentSet->abs_change: -1e-05,\
1e-05
test/power_supply/pss20/currentSet->max_value: 25.0
test/power_supply/pss20/currentSet->min_value: -25.0
#---------------------------------------------------------
# CLASS SimulatedE2PS properties
#---------------------------------------------------------
CLASS/SimulatedE2PS->Description: "Simulated power supply for Elettra 2.0 tests (digiltal twin).",\
"Tango interface Loosely based on NGPS tango device"
CLASS/SimulatedE2PS->InheritedFrom: TANGO_BASE_CLASS
CLASS/SimulatedE2PS->ProjectTitle: SimulatedE2PS
# CLASS SimulatedE2PS attribute properties
# --- dserver/simulatede2ps-srv/test properties
dserver/simulatede2ps-srv/test->polling_threads_pool_conf: "test/power_supply/psq13,test/power_supply/psq24,test/power_supply/pss16,test/power_supply/pss20,test/power_supply/psceh16,test/power_supply/psceh20,test/power_supply/pscev16,test/power_supply/pscev20"
/*----- PROTECTED REGION ID(SimulatedE2PS::ClassFactory.cpp) ENABLED START -----*/
/* clang-format on */
//=============================================================================
//
// file : ClassFactory.cpp
//
// description : C++ source for the class_factory method of the DServer
// device class. This method is responsible for the creation of
// all class singleton for a device server. It is called
// at device server startup.
//
// 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 <tango/tango.h>
#include "SimulatedE2PSClass.h"
// Add class header files if needed
/**
* Create SimulatedE2PS Class singleton and store it in DServer object.
*/
void Tango::DServer::class_factory()
{
// Add method class init if needed
add_class(SimulatedE2PS_ns::SimulatedE2PSClass::init("SimulatedE2PS"));
}
/* clang-format off */
/*----- PROTECTED REGION END -----*/ // SimulatedE2PS::ClassFactory.cpp
/*----- 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"
/* 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
// StartCycling | start_cycling
// Abort | abort
// Fault | fault
//================================================================
//================================================================
// Attributes managed are:
//================================================================
// current | Tango::DevDouble Scalar
// voltage | Tango::DevDouble Scalar
// currentSet | Tango::DevDouble Scalar
// CurrentRipple | Tango::DevDouble Scalar
// AddRipple | Tango::DevBoolean Scalar
//================================================================
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
* 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
*/
//--------------------------------------------------------
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
/* clang-format off */
/*----- PROTECTED REGION END -----*/ // SimulatedE2PS::delete_device
}
//--------------------------------------------------------
/**
* Method : SimulatedE2PS::init_device()
* Description: will be called at device initialization.
*/
//--------------------------------------------------------
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();
/*----- PROTECTED REGION ID(SimulatedE2PS::init_device) ENABLED START -----*/
/* clang-format on */
// Initialize device
// Initialise variables to default values
_current= 0.0;
_current_read= 0.0;
_voltage= 0.1;
_current_ripple = currentRipple;
_add_ripple = false;
_ohm = 0.2; // load resistance in ohm
_busy = false;
thread_running=false;
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!
set_state(Tango::OFF);
set_status("Off");
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"));
// 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;
}
/*----- 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
}
//--------------------------------------------------------
/**
* Method : SimulatedE2PS::always_executed_hook()
* Description: method always executed before any command is executed
*/
//--------------------------------------------------------
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
*/
//--------------------------------------------------------
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
*/
//--------------------------------------------------------
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
*
* 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
double delta;
if (_add_ripple)
delta = drand48()-0.5; // use anothe random distribution?
else
delta = 0.0;
if(get_state() == Tango::OFF){
_current_read = 0.0; //delta * _current_ripple;
}
else{
_current_read = _current +( delta * _current_ripple );
}
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
*
* 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);
/*----- PROTECTED REGION ID(SimulatedE2PS::write_current) ENABLED START -----*/
/* clang-format on */
// Add your own code
_current = w_val;
/* clang-format off */
/*----- PROTECTED REGION END -----*/ // SimulatedE2PS::write_current
}
//--------------------------------------------------------
/**
* Read attribute voltage related method
* Description: The powersupply voltage in volts.
*
* 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.
*
* 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: Amplitude of current ripple (noise) added to output.
* 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: Amplitude of current ripple (noise) added to output.
* 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;
/* clang-format off */
/*----- PROTECTED REGION END -----*/ // SimulatedE2PS::write_AddRipple
}
//--------------------------------------------------------
/**
* Method : SimulatedE2PS::add_dynamic_attributes()
* Description: Create the dynamic attributes if any
* 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.
*
*/
//--------------------------------------------------------
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);
set_status("On");
push_change_event("State");
/* clang-format off */
/*----- PROTECTED REGION END -----*/ // SimulatedE2PS::on
}
//--------------------------------------------------------
/**
* Command Off related method
* Description: Switch power supply OFF.
*
*/
//--------------------------------------------------------
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);
set_status("Off");
push_change_event("State");
;
// 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.
*
*/
//--------------------------------------------------------
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);
set_status("Off");
push_change_event("State");
}
/* clang-format off */
/*----- PROTECTED REGION END -----*/ // SimulatedE2PS::reset
}
//--------------------------------------------------------
/**
* Command StartCycling related method
*
*
*/
//--------------------------------------------------------
void SimulatedE2PS::start_cycling()
{
DEBUG_STREAM << "SimulatedE2PS::StartCycling() - " << device_name << std::endl;
/*----- PROTECTED REGION ID(SimulatedE2PS::start_cycling) ENABLED START -----*/
/* clang-format on */
// Add your own code
/* clang-format off */
/*----- PROTECTED REGION END -----*/ // SimulatedE2PS::start_cycling
}
//--------------------------------------------------------
/**
* Command Abort related method
* Description: stop ramp or cycling
*
*/
//--------------------------------------------------------
void SimulatedE2PS::abort()
{
DEBUG_STREAM << "SimulatedE2PS::Abort() - " << device_name << std::endl;
/*----- PROTECTED REGION ID(SimulatedE2PS::abort) ENABLED START -----*/
/* clang-format on */
// Add your own code
/* clang-format off */
/*----- PROTECTED REGION END -----*/ // SimulatedE2PS::abort
}
//--------------------------------------------------------
/**
* Command Fault related method
* Description: Force a simulated faulty condtion
*
*/
//--------------------------------------------------------
void SimulatedE2PS::fault()
{
DEBUG_STREAM << "SimulatedE2PS::Fault() - " << device_name << std::endl;
/*----- PROTECTED REGION ID(SimulatedE2PS::fault) ENABLED START -----*/
/* clang-format on */
// Add your own code
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);
push_change_event("current", &_current_read);
push_change_event("currentSet", &_current);
set_state(Tango::FAULT);
set_status("Fault");
push_change_event("State");
/* clang-format off */
/*----- PROTECTED REGION END -----*/ // SimulatedE2PS::fault
}
//--------------------------------------------------------
/**
* Method : SimulatedE2PS::add_dynamic_commands()
* Description: Create the dynamic commands if any
* 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 */
/*----- PROTECTED REGION END -----*/ // SimulatedE2PS::namespace_ending
} // namespace
/*----- PROTECTED REGION ID(SimulatedE2PS.h) ENABLED START -----*/
/* clang-format on */
//=============================================================================
//
// file : SimulatedE2PS.h
//
// description : Include file for the SimulatedE2PS class
//
// 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)
//=============================================================================
#ifndef SimulatedE2PS_H
#define SimulatedE2PS_H
#include <tango/tango.h>
/* clang-format off */
/*----- PROTECTED REGION END -----*/ // SimulatedE2PS.h
#ifdef TANGO_LOG
// cppTango after c934adea (Merge branch 'remove-cout-definition' into 'main', 2022-05-23)
// nothing to do
#else
// cppTango 9.3-backports and older
#define TANGO_LOG cout
#define TANGO_LOG_INFO cout2
#define TANGO_LOG_DEBUG cout3
#endif // TANGO_LOG
/**
* SimulatedE2PS class description:
* Simulated power supply for Elettra 2.0 tests (digiltal twin).
* Tango interface Loosely based on NGPS tango device
*/
namespace SimulatedE2PS_ns
{
/*----- PROTECTED REGION ID(SimulatedE2PS::Additional Class Declarations) ENABLED START -----*/
/* clang-format on */
// Additional Class Declarations
/* clang-format off */
/*----- PROTECTED REGION END -----*/ // SimulatedE2PS::Additional Class Declarations
class SimulatedE2PS : public TANGO_BASE_CLASS
{
/*----- PROTECTED REGION ID(SimulatedE2PS::Data Members) ENABLED START -----*/
/* clang-format on */
// Add your own data members
friend class cyclethread;
protected :
double _current;
double _current_read;
double _current_ripple;
double _voltage;
double _ohm;
bool _busy;
bool _add_ripple;
unsigned int rand_r_seed;
class cyclethread *cycleloop;
bool thread_running;
bool abortflag;
//void psdelay();
Tango::WAttribute *attr_current;
/* clang-format off */
/*----- PROTECTED REGION END -----*/ // SimulatedE2PS::Data Members
// Device property data members
public:
// CurrentRipple: Residual current oscillation [A]
//
// The simulator adds noise of CurrenRipple amplitude to the reading
Tango::DevDouble currentRipple;
// Attribute data members
public:
Tango::DevDouble *attr_current_read;
Tango::DevDouble *attr_voltage_read;
Tango::DevDouble *attr_currentSet_read;
Tango::DevDouble *attr_CurrentRipple_read;
Tango::DevBoolean *attr_AddRipple_read;
// Constructors and destructors
public:
/**
* Constructs a newly device object.
*
* @param cl Class.
* @param s Device Name
*/
SimulatedE2PS(Tango::DeviceClass *cl,std::string &s);
/**
* Constructs a newly device object.
*
* @param cl Class.
* @param s Device Name
*/
SimulatedE2PS(Tango::DeviceClass *cl,const char *s);
/**
* Constructs a newly device object.
*
* @param cl Class.
* @param s Device name
* @param d Device description.
*/
SimulatedE2PS(Tango::DeviceClass *cl,const char *s,const char *d);
/**
* The device object destructor.
*/
~SimulatedE2PS();
// 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 : SimulatedE2PS::read_attr_hardware()
* Description: Hardware acquisition for attributes.
*/
//--------------------------------------------------------
virtual void read_attr_hardware(std::vector<long> &attr_list);
//--------------------------------------------------------
/*
* Method : SimulatedE2PS::write_attr_hardware()
* Description: Hardware writing for attributes.
*/
//--------------------------------------------------------
virtual void write_attr_hardware(std::vector<long> &attr_list);
/**
* Attribute current related methods
* Description: The powersupply current setting in amps
*
* Data type: Tango::DevDouble
* Attr type: Scalar
*/
virtual void read_current(Tango::Attribute &attr);
virtual void write_current(Tango::WAttribute &attr);
virtual bool is_current_allowed(Tango::AttReqType type);
/**
* Attribute voltage related methods
* Description: The powersupply voltage in volts.
*
* Data type: Tango::DevDouble
* Attr type: Scalar
*/
virtual void read_voltage(Tango::Attribute &attr);
virtual bool is_voltage_allowed(Tango::AttReqType type);
/**
* Attribute currentSet related methods
* Description: The current set value as stored in the powersupply.
*
* Data type: Tango::DevDouble
* Attr type: Scalar
*/
virtual void read_currentSet(Tango::Attribute &attr);
virtual bool is_currentSet_allowed(Tango::AttReqType type);
/**
* Attribute CurrentRipple related methods
* Description: Amplitude of current ripple (noise) added to output.
* Initial value from property CurrentRipple
*
* Data type: Tango::DevDouble
* Attr type: Scalar
*/
virtual void read_CurrentRipple(Tango::Attribute &attr);
virtual void write_CurrentRipple(Tango::WAttribute &attr);
virtual bool is_CurrentRipple_allowed(Tango::AttReqType type);
/**
* Attribute AddRipple related methods
* Description: Switch on/off current ripple. If False the power supply is ideal :no noise.
*
* Data type: Tango::DevBoolean
* Attr type: Scalar
*/
virtual void read_AddRipple(Tango::Attribute &attr);
virtual void write_AddRipple(Tango::WAttribute &attr);
virtual bool is_AddRipple_allowed(Tango::AttReqType type);
//--------------------------------------------------------
/**
* Method : SimulatedE2PS::add_dynamic_attributes()
* Description: Add dynamic attributes if any.
*/
//--------------------------------------------------------
void add_dynamic_attributes();
// Command related methods
public:
/**
* Command On related method
* Description: Switch powersupply ON.
*
*/
virtual void on();
virtual bool is_On_allowed(const CORBA::Any &any);
/**
* Command Off related method
* Description: Switch power supply OFF.
*
*/
virtual void off();
virtual bool is_Off_allowed(const CORBA::Any &any);
/**
* Command Reset related method
* Description: Reset the powersupply to a well known state.
*
*/
virtual void reset();
virtual bool is_Reset_allowed(const CORBA::Any &any);
/**
* Command StartCycling related method
*
*
*/
virtual void start_cycling();
virtual bool is_StartCycling_allowed(const CORBA::Any &any);
/**
* Command Abort related method
* Description: stop ramp or cycling
*
*/
virtual void abort();
virtual bool is_Abort_allowed(const CORBA::Any &any);
/**
* Command Fault related method
* Description: Force a simulated faulty condtion
*
*/
virtual void fault();
virtual bool is_Fault_allowed(const CORBA::Any &any);
//--------------------------------------------------------
/**
* Method : SimulatedE2PS::add_dynamic_commands()
* Description: Add dynamic commands if any.
*/
//--------------------------------------------------------
void add_dynamic_commands();
/*----- PROTECTED REGION ID(SimulatedE2PS::Additional Method prototypes) ENABLED START -----*/
/* clang-format on */
// Additional Method prototypes
/* clang-format off */
/*----- PROTECTED REGION END -----*/ // SimulatedE2PS::Additional Method prototypes
};
/*----- PROTECTED REGION ID(SimulatedE2PS::Additional Classes Definitions) ENABLED START -----*/
/* clang-format on */
// Additional Classes Definitions
/* clang-format off */
/*----- PROTECTED REGION END -----*/ // SimulatedE2PS::Additional Classes Definitions
} // End of namespace
#endif // SimulatedE2PS_H
<?xml version="1.0" encoding="ASCII"?>
<pogoDsl:PogoSystem xmi:version="2.0" xmlns:xmi="http://www.omg.org/XMI" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:pogoDsl="http://tango.org/pogo/PogoDsl">
<classes name="SimulatedE2PS" pogoRevision="9.9">
<description description="Simulated power supply for Elettra 2.0 tests (digiltal twin).&#xA;Tango interface Loosely based on NGPS tango device" title="SimulatedE2PS" sourcePath="/home/claudio/src/gitlab/dt/ds/simulatede2ps/src" language="Cpp" filestogenerate="XMI file,Code files,Protected Regions" license="GPL" copyright="" hasMandatoryProperty="false" hasConcreteProperty="true" hasAbstractCommand="false" hasAbstractAttribute="false">
<inheritances classname="Device_Impl" sourcePath=""/>
<identification contact="at elettra.eu - claudio.scafuri" author="claudio.scafuri" emailDomain="elettra.eu" classFamily="Simulators" siteSpecific="" platform="All Platforms" bus="Not Applicable" manufacturer="none" reference="">
<keyWords>Power supply</keyWords>
<keyWords>simulator</keyWords>
<keyWords>Elettra 2.0</keyWords>
<keyWords>Digital twin</keyWords>
</identification>
</description>
<deviceProperties name="CurrentRipple" description="Residual current oscillation [A]&#xA;&#xA;The simulator adds noise of CurrenRipple amplitude to the reading">
<type xsi:type="pogoDsl:DoubleType"/>
<status abstract="false" inherited="false" concrete="true" concreteHere="true"/>
<DefaultPropValue>0.0025</DefaultPropValue>
</deviceProperties>
<commands name="State" description="This command gets the device state (stored in its device_state data member) and returns it to the caller." execMethod="dev_state" displayLevel="OPERATOR" polledPeriod="0">
<argin description="none">
<type xsi:type="pogoDsl:VoidType"/>
</argin>
<argout description="Device state">
<type xsi:type="pogoDsl:StateType"/>
</argout>
<status abstract="true" inherited="true" concrete="true"/>
</commands>
<commands name="Status" description="This command gets the device status (stored in its device_status data member) and returns it to the caller." execMethod="dev_status" displayLevel="OPERATOR" polledPeriod="0">
<argin description="none">
<type xsi:type="pogoDsl:VoidType"/>
</argin>
<argout description="Device status">
<type xsi:type="pogoDsl:ConstStringType"/>
</argout>
<status abstract="true" inherited="true" concrete="true"/>
</commands>
<commands name="On" description="Switch powersupply ON." execMethod="on" displayLevel="OPERATOR" polledPeriod="0" isDynamic="false">
<argin description="">
<type xsi:type="pogoDsl:VoidType"/>
</argin>
<argout description="">
<type xsi:type="pogoDsl:VoidType"/>
</argout>
<status abstract="false" inherited="false" concrete="true" concreteHere="true"/>
<excludedStates>UNKNOWN</excludedStates>
<excludedStates>FAULT</excludedStates>
</commands>
<commands name="Off" description="Switch power supply OFF." execMethod="off" displayLevel="OPERATOR" polledPeriod="0" isDynamic="false">
<argin description="">
<type xsi:type="pogoDsl:VoidType"/>
</argin>
<argout description="">
<type xsi:type="pogoDsl:VoidType"/>
</argout>
<status abstract="false" inherited="false" concrete="true" concreteHere="true"/>
<excludedStates>UNKNOWN</excludedStates>
<excludedStates>FAULT</excludedStates>
</commands>
<commands name="Reset" description="Reset the powersupply to a well known state." execMethod="reset" displayLevel="OPERATOR" polledPeriod="0" isDynamic="false">
<argin description="">
<type xsi:type="pogoDsl:VoidType"/>
</argin>
<argout description="">
<type xsi:type="pogoDsl:VoidType"/>
</argout>
<status abstract="false" inherited="false" concrete="true" concreteHere="true"/>
<excludedStates>UNKNOWN</excludedStates>
</commands>
<commands name="StartCycling" description="" execMethod="start_cycling" displayLevel="OPERATOR" polledPeriod="0" isDynamic="false">
<argin description="">
<type xsi:type="pogoDsl:VoidType"/>
</argin>
<argout description="">
<type xsi:type="pogoDsl:VoidType"/>
</argout>
<status abstract="false" inherited="false" concrete="true" concreteHere="true"/>
<excludedStates>UNKNOWN</excludedStates>
<excludedStates>FAULT</excludedStates>
</commands>
<commands name="Abort" description="stop ramp or cycling" execMethod="abort" displayLevel="OPERATOR" polledPeriod="0" isDynamic="false">
<argin description="">
<type xsi:type="pogoDsl:VoidType"/>
</argin>
<argout description="">
<type xsi:type="pogoDsl:VoidType"/>
</argout>
<status abstract="false" inherited="false" concrete="true" concreteHere="true"/>
<excludedStates>UNKNOWN</excludedStates>
<excludedStates>FAULT</excludedStates>
</commands>
<commands name="Fault" description="Force a simulated faulty condtion" execMethod="fault" displayLevel="EXPERT" polledPeriod="0" isDynamic="false">
<argin description="">
<type xsi:type="pogoDsl:VoidType"/>
</argin>
<argout description="">
<type xsi:type="pogoDsl:VoidType"/>
</argout>
<status abstract="false" inherited="false" concrete="true" concreteHere="true"/>
</commands>
<attributes name="current" attType="Scalar" rwType="READ_WRITE" displayLevel="OPERATOR" polledPeriod="0" maxX="" maxY="" allocReadMember="false" isDynamic="false">
<dataType xsi:type="pogoDsl:DoubleType"/>
<changeEvent fire="false" libCheckCriteria="false"/>
<archiveEvent fire="false" libCheckCriteria="false"/>
<dataReadyEvent fire="false" libCheckCriteria="true"/>
<status abstract="false" inherited="false" concrete="true" concreteHere="true"/>
<properties description="The powersupply current setting in amps" label="current" unit="A" standardUnit="1" displayUnit="A" format="%6.4f" maxValue="" minValue="" maxAlarm="" minAlarm="" maxWarning="" minWarning="" deltaTime="" deltaValue=""/>
<readExcludedStates>UNKNOWN</readExcludedStates>
<readExcludedStates>FAULT</readExcludedStates>
<writeExcludedStates>UNKNOWN</writeExcludedStates>
<writeExcludedStates>FAULT</writeExcludedStates>
<writeExcludedStates>RUNNING</writeExcludedStates>
<writeExcludedStates>MOVING</writeExcludedStates>
<writeExcludedStates>OFF</writeExcludedStates>
</attributes>
<attributes name="voltage" attType="Scalar" rwType="READ" displayLevel="OPERATOR" polledPeriod="0" maxX="" maxY="" allocReadMember="false" isDynamic="false">
<dataType xsi:type="pogoDsl:DoubleType"/>
<changeEvent fire="false" libCheckCriteria="false"/>
<archiveEvent fire="false" libCheckCriteria="false"/>
<dataReadyEvent fire="false" libCheckCriteria="true"/>
<status abstract="false" inherited="false" concrete="true" concreteHere="true"/>
<properties description="The powersupply voltage in volts." label="" unit="V" standardUnit="1" displayUnit="V" format="%6.4f" maxValue="" minValue="" maxAlarm="" minAlarm="" maxWarning="" minWarning="" deltaTime="" deltaValue=""/>
<readExcludedStates>UNKNOWN</readExcludedStates>
</attributes>
<attributes name="currentSet" attType="Scalar" rwType="READ" displayLevel="OPERATOR" polledPeriod="0" maxX="" maxY="" allocReadMember="false" isDynamic="false">
<dataType xsi:type="pogoDsl:DoubleType"/>
<changeEvent fire="false" libCheckCriteria="false"/>
<archiveEvent fire="false" libCheckCriteria="false"/>
<dataReadyEvent fire="false" libCheckCriteria="true"/>
<status abstract="false" inherited="false" concrete="true" concreteHere="true"/>
<properties description="The current set value as stored in the powersupply." label="" unit="A" standardUnit="1" displayUnit="A" format="%6.4f" maxValue="" minValue="" maxAlarm="" minAlarm="" maxWarning="" minWarning="" deltaTime="" deltaValue=""/>
<readExcludedStates>UNKNOWN</readExcludedStates>
</attributes>
<attributes name="CurrentRipple" attType="Scalar" rwType="READ_WRITE" displayLevel="EXPERT" polledPeriod="0" maxX="" maxY="" allocReadMember="false" isDynamic="false">
<dataType xsi:type="pogoDsl:DoubleType"/>
<changeEvent fire="false" libCheckCriteria="false"/>
<archiveEvent fire="false" libCheckCriteria="false"/>
<dataReadyEvent fire="false" libCheckCriteria="true"/>
<status abstract="false" inherited="false" concrete="true" concreteHere="true"/>
<properties description="Amplitude of current ripple (noise) added to output.&#xA;Initial value from property CurrentRipple" label="current ripple (noise)" unit="A" standardUnit="1" displayUnit="A" format="%6.6f" maxValue="" minValue="" maxAlarm="" minAlarm="" maxWarning="" minWarning="" deltaTime="" deltaValue=""/>
</attributes>
<attributes name="AddRipple" attType="Scalar" rwType="READ_WRITE" displayLevel="EXPERT" polledPeriod="0" maxX="" maxY="" allocReadMember="false" isDynamic="false">
<dataType xsi:type="pogoDsl:BooleanType"/>
<changeEvent fire="false" libCheckCriteria="false"/>
<archiveEvent fire="false" libCheckCriteria="false"/>
<dataReadyEvent fire="false" libCheckCriteria="true"/>
<status abstract="false" inherited="false" concrete="true" concreteHere="true"/>
<properties description="Switch on/off current ripple. If False the power supply is ideal :no noise." label="add current ripple" unit="" standardUnit="" displayUnit="" format="" maxValue="" minValue="" maxAlarm="" minAlarm="" maxWarning="" minWarning="" deltaTime="" deltaValue=""/>
</attributes>
<states name="UNKNOWN" description="initialization failed or incomlete">
<status abstract="false" inherited="false" concrete="true" concreteHere="true"/>
</states>
<states name="ON" description="power supply on">
<status abstract="false" inherited="false" concrete="true" concreteHere="true"/>
</states>
<states name="FAULT" description="power supply in fault - not sourcing cuurent">
<status abstract="false" inherited="false" concrete="true" concreteHere="true"/>
</states>
<states name="RUNNING" description="magnet cycling running">
<status abstract="false" inherited="false" concrete="true" concreteHere="true"/>
</states>
<states name="MOVING" description="output current changing">
<status abstract="false" inherited="false" concrete="true" concreteHere="true"/>
</states>
<states name="OFF" description="power supply off , not sourcing current">
<status abstract="false" inherited="false" concrete="true" concreteHere="true"/>
</states>
<preferences docHome="./doc_html" makefileHome="$(TANGO_HOME)"/>
</classes>
</pogoDsl:PogoSystem>
/*----- 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
/*----- PROTECTED REGION ID(SimulatedE2PSClass.h) ENABLED START -----*/
/* clang-format on */
//=============================================================================
//
// file : SimulatedE2PSClass.h
//
// description : Include for the SimulatedE2PS root class.
// This class is the singleton class for
// the SimulatedE2PS device class.
// It contains all properties and methods which the
// SimulatedE2PS requires only once e.g. the commands.
//
// 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)
//=============================================================================
#ifndef SimulatedE2PSClass_H
#define SimulatedE2PSClass_H
#include <tango/tango.h>
#include "SimulatedE2PS.h"
/* clang-format off */
/*----- PROTECTED REGION END -----*/ // SimulatedE2PSClass.h
namespace SimulatedE2PS_ns
{
/*----- PROTECTED REGION ID(SimulatedE2PSClass::classes for dynamic creation) ENABLED START -----*/
/* clang-format on */
/* clang-format off */
/*----- PROTECTED REGION END -----*/ // SimulatedE2PSClass::classes for dynamic creation
//=========================================
// Define classes for attributes
//=========================================
// Attribute current class definition
class currentAttrib: public Tango::Attr
{
public:
currentAttrib():Attr("current",
Tango::DEV_DOUBLE, Tango::READ_WRITE) {}
~currentAttrib() {}
virtual void read(Tango::DeviceImpl *dev,Tango::Attribute &att)
{(static_cast<SimulatedE2PS *>(dev))->read_current(att);}
virtual void write(Tango::DeviceImpl *dev,Tango::WAttribute &att)
{(static_cast<SimulatedE2PS *>(dev))->write_current(att);}
virtual bool is_allowed(Tango::DeviceImpl *dev,Tango::AttReqType ty)
{return (static_cast<SimulatedE2PS *>(dev))->is_current_allowed(ty);}
};
// Attribute voltage class definition
class voltageAttrib: public Tango::Attr
{
public:
voltageAttrib():Attr("voltage",
Tango::DEV_DOUBLE, Tango::READ) {}
~voltageAttrib() {}
virtual void read(Tango::DeviceImpl *dev,Tango::Attribute &att)
{(static_cast<SimulatedE2PS *>(dev))->read_voltage(att);}
virtual bool is_allowed(Tango::DeviceImpl *dev,Tango::AttReqType ty)
{return (static_cast<SimulatedE2PS *>(dev))->is_voltage_allowed(ty);}
};
// Attribute currentSet class definition
class currentSetAttrib: public Tango::Attr
{
public:
currentSetAttrib():Attr("currentSet",
Tango::DEV_DOUBLE, Tango::READ) {}
~currentSetAttrib() {}
virtual void read(Tango::DeviceImpl *dev,Tango::Attribute &att)
{(static_cast<SimulatedE2PS *>(dev))->read_currentSet(att);}
virtual bool is_allowed(Tango::DeviceImpl *dev,Tango::AttReqType ty)
{return (static_cast<SimulatedE2PS *>(dev))->is_currentSet_allowed(ty);}
};
// Attribute CurrentRipple class definition
class CurrentRippleAttrib: public Tango::Attr
{
public:
CurrentRippleAttrib():Attr("CurrentRipple",
Tango::DEV_DOUBLE, Tango::READ_WRITE) {}
~CurrentRippleAttrib() {}
virtual void read(Tango::DeviceImpl *dev,Tango::Attribute &att)
{(static_cast<SimulatedE2PS *>(dev))->read_CurrentRipple(att);}
virtual void write(Tango::DeviceImpl *dev,Tango::WAttribute &att)
{(static_cast<SimulatedE2PS *>(dev))->write_CurrentRipple(att);}
virtual bool is_allowed(Tango::DeviceImpl *dev,Tango::AttReqType ty)
{return (static_cast<SimulatedE2PS *>(dev))->is_CurrentRipple_allowed(ty);}
};
// Attribute AddRipple class definition
class AddRippleAttrib: public Tango::Attr
{
public:
AddRippleAttrib():Attr("AddRipple",
Tango::DEV_BOOLEAN, Tango::READ_WRITE) {}
~AddRippleAttrib() {}
virtual void read(Tango::DeviceImpl *dev,Tango::Attribute &att)
{(static_cast<SimulatedE2PS *>(dev))->read_AddRipple(att);}
virtual void write(Tango::DeviceImpl *dev,Tango::WAttribute &att)
{(static_cast<SimulatedE2PS *>(dev))->write_AddRipple(att);}
virtual bool is_allowed(Tango::DeviceImpl *dev,Tango::AttReqType ty)
{return (static_cast<SimulatedE2PS *>(dev))->is_AddRipple_allowed(ty);}
};
//=========================================
// Define classes for commands
//=========================================
// Command On class definition
class OnClass : public Tango::Command
{
public:
OnClass(const char *cmd_name,
Tango::CmdArgType in,
Tango::CmdArgType out,
const char *in_desc,
const char *out_desc,
Tango::DispLevel level)
:Command(cmd_name,in,out,in_desc,out_desc, level) {}
OnClass(const char *cmd_name,
Tango::CmdArgType in,
Tango::CmdArgType out)
:Command(cmd_name,in,out) {}
~OnClass() {}
virtual CORBA::Any *execute (Tango::DeviceImpl *dev, const CORBA::Any &any);
virtual bool is_allowed (Tango::DeviceImpl *dev, const CORBA::Any &any)
{return (static_cast<SimulatedE2PS *>(dev))->is_On_allowed(any);}
};
// Command Off class definition
class OffClass : public Tango::Command
{
public:
OffClass(const char *cmd_name,
Tango::CmdArgType in,
Tango::CmdArgType out,
const char *in_desc,
const char *out_desc,
Tango::DispLevel level)
:Command(cmd_name,in,out,in_desc,out_desc, level) {}
OffClass(const char *cmd_name,
Tango::CmdArgType in,
Tango::CmdArgType out)
:Command(cmd_name,in,out) {}
~OffClass() {}
virtual CORBA::Any *execute (Tango::DeviceImpl *dev, const CORBA::Any &any);
virtual bool is_allowed (Tango::DeviceImpl *dev, const CORBA::Any &any)
{return (static_cast<SimulatedE2PS *>(dev))->is_Off_allowed(any);}
};
// Command Reset class definition
class ResetClass : public Tango::Command
{
public:
ResetClass(const char *cmd_name,
Tango::CmdArgType in,
Tango::CmdArgType out,
const char *in_desc,
const char *out_desc,
Tango::DispLevel level)
:Command(cmd_name,in,out,in_desc,out_desc, level) {}
ResetClass(const char *cmd_name,
Tango::CmdArgType in,
Tango::CmdArgType out)
:Command(cmd_name,in,out) {}
~ResetClass() {}
virtual CORBA::Any *execute (Tango::DeviceImpl *dev, const CORBA::Any &any);
virtual bool is_allowed (Tango::DeviceImpl *dev, const CORBA::Any &any)
{return (static_cast<SimulatedE2PS *>(dev))->is_Reset_allowed(any);}
};
// Command StartCycling class definition
class StartCyclingClass : public Tango::Command
{
public:
StartCyclingClass(const char *cmd_name,
Tango::CmdArgType in,
Tango::CmdArgType out,
const char *in_desc,
const char *out_desc,
Tango::DispLevel level)
:Command(cmd_name,in,out,in_desc,out_desc, level) {}
StartCyclingClass(const char *cmd_name,
Tango::CmdArgType in,
Tango::CmdArgType out)
:Command(cmd_name,in,out) {}
~StartCyclingClass() {}
virtual CORBA::Any *execute (Tango::DeviceImpl *dev, const CORBA::Any &any);
virtual bool is_allowed (Tango::DeviceImpl *dev, const CORBA::Any &any)
{return (static_cast<SimulatedE2PS *>(dev))->is_StartCycling_allowed(any);}
};
// Command Abort class definition
class AbortClass : public Tango::Command
{
public:
AbortClass(const char *cmd_name,
Tango::CmdArgType in,
Tango::CmdArgType out,
const char *in_desc,
const char *out_desc,
Tango::DispLevel level)
:Command(cmd_name,in,out,in_desc,out_desc, level) {}
AbortClass(const char *cmd_name,
Tango::CmdArgType in,
Tango::CmdArgType out)
:Command(cmd_name,in,out) {}
~AbortClass() {}
virtual CORBA::Any *execute (Tango::DeviceImpl *dev, const CORBA::Any &any);
virtual bool is_allowed (Tango::DeviceImpl *dev, const CORBA::Any &any)
{return (static_cast<SimulatedE2PS *>(dev))->is_Abort_allowed(any);}
};
// Command Fault class definition
class FaultClass : public Tango::Command
{
public:
FaultClass(const char *cmd_name,
Tango::CmdArgType in,
Tango::CmdArgType out,
const char *in_desc,
const char *out_desc,
Tango::DispLevel level)
:Command(cmd_name,in,out,in_desc,out_desc, level) {}
FaultClass(const char *cmd_name,
Tango::CmdArgType in,
Tango::CmdArgType out)
:Command(cmd_name,in,out) {}
~FaultClass() {}
virtual CORBA::Any *execute (Tango::DeviceImpl *dev, const CORBA::Any &any);
virtual bool is_allowed (Tango::DeviceImpl *dev, const CORBA::Any &any)
{return (static_cast<SimulatedE2PS *>(dev))->is_Fault_allowed(any);}
};
/**
* The SimulatedE2PSClass singleton definition
*/
#ifdef _TG_WINDOWS_
class __declspec(dllexport) SimulatedE2PSClass : public Tango::DeviceClass
#else
class SimulatedE2PSClass : public Tango::DeviceClass
#endif
{
/*----- PROTECTED REGION ID(SimulatedE2PSClass::Additional DServer data members) ENABLED START -----*/
/* clang-format on */
// Add your own code
/* clang-format off */
/*----- PROTECTED REGION END -----*/ // SimulatedE2PSClass::Additional DServer data members
public:
// write class properties data members
Tango::DbData cl_prop;
Tango::DbData cl_def_prop;
Tango::DbData dev_def_prop;
// Method prototypes
static SimulatedE2PSClass *init(const char *);
static SimulatedE2PSClass *instance();
~SimulatedE2PSClass();
Tango::DbDatum get_class_property(std::string &);
Tango::DbDatum get_default_device_property(std::string &);
Tango::DbDatum get_default_class_property(std::string &);
protected:
SimulatedE2PSClass(std::string &);
static SimulatedE2PSClass *_instance;
void command_factory();
void attribute_factory(std::vector<Tango::Attr *> &);
void pipe_factory();
void write_class_property();
void set_default_property();
void get_class_property();
std::string get_cvstag();
std::string get_cvsroot();
private:
void device_factory(TANGO_UNUSED(const Tango::DevVarStringArray *));
void create_static_attribute_list(std::vector<Tango::Attr *> &);
void erase_dynamic_attributes(const Tango::DevVarStringArray *,std::vector<Tango::Attr *> &);
std::vector<std::string> defaultAttList;
Tango::Attr *get_attr_object_by_name(std::vector<Tango::Attr *> &att_list, std::string attname);
};
} // End of namespace
#endif // SimulatedE2PS_H
/*----- PROTECTED REGION ID(SimulatedE2PSStateMachine.cpp) ENABLED START -----*/
/* clang-format on */
//=============================================================================
//
// file : SimulatedE2PSStateMachine.cpp
//
// description : State machine file for the SimulatedE2PS class
//
// 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"
/* clang-format off */
/*----- PROTECTED REGION END -----*/ // SimulatedE2PS::SimulatedE2PSStateMachine.cpp
//================================================================
// States | Description
//================================================================
// UNKNOWN | initialization failed or incomlete
// ON | power supply on
// FAULT | power supply in fault - not sourcing cuurent
// RUNNING | magnet cycling running
// MOVING | output current changing
// OFF | power supply off , not sourcing current
namespace SimulatedE2PS_ns
{
//=================================================
// Attributes Allowed Methods
//=================================================
//--------------------------------------------------------
/**
* Method : SimulatedE2PS::is_current_allowed()
* Description: Execution allowed for current attribute
*/
//--------------------------------------------------------
bool SimulatedE2PS::is_current_allowed(TANGO_UNUSED(Tango::AttReqType type))
{
// Check access type.
if ( type!=Tango::READ_REQ )
{
// Compare device state with not allowed states for WRITE
if (get_state()==Tango::UNKNOWN ||
get_state()==Tango::FAULT ||
get_state()==Tango::RUNNING ||
get_state()==Tango::MOVING ||
get_state()==Tango::OFF)
{
/*----- PROTECTED REGION ID(SimulatedE2PS::currentStateAllowed_WRITE) ENABLED START -----*/
/* clang-format on */
/* clang-format off */
/*----- PROTECTED REGION END -----*/ // SimulatedE2PS::currentStateAllowed_WRITE
return false;
}
return true;
}
else
// Check access type.
if ( type==Tango::READ_REQ )
{
// Compare device state with not allowed states for READ
if (get_state()==Tango::UNKNOWN ||
get_state()==Tango::FAULT)
{
/*----- PROTECTED REGION ID(SimulatedE2PS::currentStateAllowed_READ) ENABLED START -----*/
/* clang-format on */
/* clang-format off */
/*----- PROTECTED REGION END -----*/ // SimulatedE2PS::currentStateAllowed_READ
return false;
}
return true;
}
return true;
}
//--------------------------------------------------------
/**
* Method : SimulatedE2PS::is_voltage_allowed()
* Description: Execution allowed for voltage attribute
*/
//--------------------------------------------------------
bool SimulatedE2PS::is_voltage_allowed(TANGO_UNUSED(Tango::AttReqType type))
{
// Check access type.
if ( type==Tango::READ_REQ )
{
// Compare device state with not allowed states for READ
if (get_state()==Tango::UNKNOWN)
{
/*----- PROTECTED REGION ID(SimulatedE2PS::voltageStateAllowed_READ) ENABLED START -----*/
/* clang-format on */
/* clang-format off */
/*----- PROTECTED REGION END -----*/ // SimulatedE2PS::voltageStateAllowed_READ
return false;
}
return true;
}
return true;
}
//--------------------------------------------------------
/**
* Method : SimulatedE2PS::is_currentSet_allowed()
* Description: Execution allowed for currentSet attribute
*/
//--------------------------------------------------------
bool SimulatedE2PS::is_currentSet_allowed(TANGO_UNUSED(Tango::AttReqType type))
{
// Check access type.
if ( type==Tango::READ_REQ )
{
// Compare device state with not allowed states for READ
if (get_state()==Tango::UNKNOWN)
{
/*----- PROTECTED REGION ID(SimulatedE2PS::currentSetStateAllowed_READ) ENABLED START -----*/
/* clang-format on */
/* clang-format off */
/*----- PROTECTED REGION END -----*/ // SimulatedE2PS::currentSetStateAllowed_READ
return false;
}
return true;
}
return true;
}
//--------------------------------------------------------
/**
* Method : SimulatedE2PS::is_CurrentRipple_allowed()
* Description: Execution allowed for CurrentRipple attribute
*/
//--------------------------------------------------------
bool SimulatedE2PS::is_CurrentRipple_allowed(TANGO_UNUSED(Tango::AttReqType type))
{
// Not any excluded states for CurrentRipple attribute in Write access.
/*----- PROTECTED REGION ID(SimulatedE2PS::CurrentRippleStateAllowed_WRITE) ENABLED START -----*/
/* clang-format on */
/* clang-format off */
/*----- PROTECTED REGION END -----*/ // SimulatedE2PS::CurrentRippleStateAllowed_WRITE
// Not any excluded states for CurrentRipple attribute in read access.
/*----- PROTECTED REGION ID(SimulatedE2PS::CurrentRippleStateAllowed_READ) ENABLED START -----*/
/* clang-format on */
/* clang-format off */
/*----- PROTECTED REGION END -----*/ // SimulatedE2PS::CurrentRippleStateAllowed_READ
return true;
}
//--------------------------------------------------------
/**
* Method : SimulatedE2PS::is_AddRipple_allowed()
* Description: Execution allowed for AddRipple attribute
*/
//--------------------------------------------------------
bool SimulatedE2PS::is_AddRipple_allowed(TANGO_UNUSED(Tango::AttReqType type))
{
// Not any excluded states for AddRipple attribute in Write access.
/*----- PROTECTED REGION ID(SimulatedE2PS::AddRippleStateAllowed_WRITE) ENABLED START -----*/
/* clang-format on */
/* clang-format off */
/*----- PROTECTED REGION END -----*/ // SimulatedE2PS::AddRippleStateAllowed_WRITE
// Not any excluded states for AddRipple attribute in read access.
/*----- PROTECTED REGION ID(SimulatedE2PS::AddRippleStateAllowed_READ) ENABLED START -----*/
/* clang-format on */
/* clang-format off */
/*----- PROTECTED REGION END -----*/ // SimulatedE2PS::AddRippleStateAllowed_READ
return true;
}
//=================================================
// Commands Allowed Methods
//=================================================
//--------------------------------------------------------
/**
* Method : SimulatedE2PS::is_On_allowed()
* Description: Execution allowed for On attribute
*/
//--------------------------------------------------------
bool SimulatedE2PS::is_On_allowed(TANGO_UNUSED(const CORBA::Any &any))
{
// Compare device state with not allowed states.
if (get_state()==Tango::UNKNOWN ||
get_state()==Tango::FAULT)
{
/*----- PROTECTED REGION ID(SimulatedE2PS::OnStateAllowed) ENABLED START -----*/
/* clang-format on */
/* clang-format off */
/*----- PROTECTED REGION END -----*/ // SimulatedE2PS::OnStateAllowed
return false;
}
return true;
}
//--------------------------------------------------------
/**
* Method : SimulatedE2PS::is_Off_allowed()
* Description: Execution allowed for Off attribute
*/
//--------------------------------------------------------
bool SimulatedE2PS::is_Off_allowed(TANGO_UNUSED(const CORBA::Any &any))
{
// Compare device state with not allowed states.
if (get_state()==Tango::UNKNOWN ||
get_state()==Tango::FAULT)
{
/*----- PROTECTED REGION ID(SimulatedE2PS::OffStateAllowed) ENABLED START -----*/
/* clang-format on */
/* clang-format off */
/*----- PROTECTED REGION END -----*/ // SimulatedE2PS::OffStateAllowed
return false;
}
return true;
}
//--------------------------------------------------------
/**
* Method : SimulatedE2PS::is_Reset_allowed()
* Description: Execution allowed for Reset attribute
*/
//--------------------------------------------------------
bool SimulatedE2PS::is_Reset_allowed(TANGO_UNUSED(const CORBA::Any &any))
{
// Compare device state with not allowed states.
if (get_state()==Tango::UNKNOWN)
{
/*----- PROTECTED REGION ID(SimulatedE2PS::ResetStateAllowed) ENABLED START -----*/
/* clang-format on */
/* clang-format off */
/*----- PROTECTED REGION END -----*/ // SimulatedE2PS::ResetStateAllowed
return false;
}
return true;
}
//--------------------------------------------------------
/**
* Method : SimulatedE2PS::is_StartCycling_allowed()
* Description: Execution allowed for StartCycling attribute
*/
//--------------------------------------------------------
bool SimulatedE2PS::is_StartCycling_allowed(TANGO_UNUSED(const CORBA::Any &any))
{
// Compare device state with not allowed states.
if (get_state()==Tango::UNKNOWN ||
get_state()==Tango::FAULT)
{
/*----- PROTECTED REGION ID(SimulatedE2PS::StartCyclingStateAllowed) ENABLED START -----*/
/* clang-format on */
/* clang-format off */
/*----- PROTECTED REGION END -----*/ // SimulatedE2PS::StartCyclingStateAllowed
return false;
}
return true;
}
//--------------------------------------------------------
/**
* Method : SimulatedE2PS::is_Abort_allowed()
* Description: Execution allowed for Abort attribute
*/
//--------------------------------------------------------
bool SimulatedE2PS::is_Abort_allowed(TANGO_UNUSED(const CORBA::Any &any))
{
// Compare device state with not allowed states.
if (get_state()==Tango::UNKNOWN ||
get_state()==Tango::FAULT)
{
/*----- PROTECTED REGION ID(SimulatedE2PS::AbortStateAllowed) ENABLED START -----*/
/* clang-format on */
/* clang-format off */
/*----- PROTECTED REGION END -----*/ // SimulatedE2PS::AbortStateAllowed
return false;
}
return true;
}
//--------------------------------------------------------
/**
* Method : SimulatedE2PS::is_Fault_allowed()
* Description: Execution allowed for Fault attribute
*/
//--------------------------------------------------------
bool SimulatedE2PS::is_Fault_allowed(TANGO_UNUSED(const CORBA::Any &any))
{
// Not any excluded states for Fault command.
/*----- PROTECTED REGION ID(SimulatedE2PS::FaultStateAllowed) ENABLED START -----*/
/* clang-format on */
/* clang-format off */
/*----- PROTECTED REGION END -----*/ // SimulatedE2PS::FaultStateAllowed
return true;
}
/*----- PROTECTED REGION ID(SimulatedE2PS::SimulatedE2PSStateAllowed.AdditionalMethods) ENABLED START -----*/
/* clang-format on */
// Additional Methods
/* clang-format off */
/*----- PROTECTED REGION END -----*/ // SimulatedE2PS::SimulatedE2PSStateAllowed.AdditionalMethods
} // End of namespace
/*----- PROTECTED REGION ID(SimulatedE2PS::main.cpp) ENABLED START -----*/
/* clang-format on */
//=============================================================================
//
// file : main.cpp
//
// description : C++ source for the SimulatedE2PS device server main.
// The main rule is to initialise (and create) the Tango
// system and to create the DServerClass singleton.
// The main should be the same for every Tango device server.
//
// 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 <tango/tango.h>
// Check if crash reporting is used.
#if defined(ENABLE_CRASH_REPORT)
# include <crashreporting/crash_report.h>
#else
# define DECLARE_CRASH_HANDLER
# define INSTALL_CRASH_HANDLER
#endif
DECLARE_CRASH_HANDLER
int main(int argc,char *argv[])
{
INSTALL_CRASH_HANDLER
Tango::Util *tg = nullptr;
try
{
// Initialise the device server
//----------------------------------------
tg = Tango::Util::init(argc,argv);
// Create the device server singleton
// which will create everything
//----------------------------------------
tg->server_init(false);
// Run the endless loop
//----------------------------------------
std::cout << "Ready to accept request" << std::endl;
tg->server_run();
}
catch (std::bad_alloc &)
{
std::cout << "Can't allocate memory to store device object !!!" << std::endl;
std::cout << "Exiting" << std::endl;
}
catch (CORBA::Exception &e)
{
Tango::Except::print_exception(e);
std::cout << "Received a CORBA_Exception" << std::endl;
std::cout << "Exiting" << std::endl;
}
if(tg)
{
tg->server_cleanup();
}
return(0);
}
/* clang-format off */
/*----- PROTECTED REGION END -----*/ // SimulatedE2PS::main.cpp