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
  • cs/ds/ionpump
1 result
Show changes
Commits on Source (1)
......@@ -169,26 +169,96 @@ void Ionpump::init_device()
attrs.clear();
/*----- PROTECTED REGION END -----*/ // Ionpump::init_device_before
// No device property to be read from database
// Get the device properties from database
get_device_property();
/*----- PROTECTED REGION ID(Ionpump::init_device) ENABLED START -----*/
// Initialize device
char attr[20];
try {
get_ps_name();
if (psname.empty() || channel == 255)
get_ps_name();
else {
devps = new Tango::DeviceProxy(psname);
}
sprintf(attr,"State%d",channel);
attrs.push_back(attr);
sprintf(attr,"Status%d",channel);
attrs.push_back(attr);
} catch(Tango::DevFailed &e) {
cout << "Can't get dual name" << endl;
cout << "Can't get name of the power-supply" << endl;
exit(1);
}
/*----- PROTECTED REGION END -----*/ // Ionpump::init_device
}
//--------------------------------------------------------
/**
* Method : Ionpump::get_device_property()
* Description: Read database to initialize property data members.
*/
//--------------------------------------------------------
void Ionpump::get_device_property()
{
/*----- PROTECTED REGION ID(Ionpump::get_device_property_before) ENABLED START -----*/
/* clang-format on */
// Initialize property data members
channel = 255;
/* clang-format off */
/*----- PROTECTED REGION END -----*/ // Ionpump::get_device_property_before
// Read device properties from database.
Tango::DbData dev_prop;
dev_prop.push_back(Tango::DbDatum("Psname"));
dev_prop.push_back(Tango::DbDatum("Channel"));
// 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 IonpumpClass to get class property
Tango::DbDatum def_prop, cl_prop;
IonpumpClass *ds_class =
(static_cast<IonpumpClass *>(get_device_class()));
int i = -1;
// Try to initialize Psname from class property
cl_prop = ds_class->get_class_property(dev_prop[++i].name);
if (cl_prop.is_empty()==false) cl_prop >> psname;
else {
// Try to initialize Psname from default device value
def_prop = ds_class->get_default_device_property(dev_prop[i].name);
if (def_prop.is_empty()==false) def_prop >> psname;
}
// And try to extract Psname value from database
if (dev_prop[i].is_empty()==false) dev_prop[i] >> psname;
// Try to initialize Channel from class property
cl_prop = ds_class->get_class_property(dev_prop[++i].name);
if (cl_prop.is_empty()==false) cl_prop >> channel;
else {
// Try to initialize Channel from default device value
def_prop = ds_class->get_default_device_property(dev_prop[i].name);
if (def_prop.is_empty()==false) def_prop >> channel;
}
// And try to extract Channel value from database
if (dev_prop[i].is_empty()==false) dev_prop[i] >> channel;
}
/*----- PROTECTED REGION ID(Ionpump::get_device_property_after) ENABLED START -----*/
/* clang-format on */
// Check device property data members init
/* clang-format off */
/*----- PROTECTED REGION END -----*/ // Ionpump::get_device_property_after
}
//--------------------------------------------------------
/**
......@@ -262,7 +332,7 @@ void Ionpump::read_Pressure(Tango::Attribute &attr)
}
catch(Tango::DevFailed &e) {
TangoSys_MemStream out_stream;
out_stream << "Reading dual failed" << ends;
out_stream << "Reading power-supply failed" << ends;
Tango::Except::re_throw_exception(e,
(const char *)"Error reading pressure",
out_stream.str(),
......@@ -398,23 +468,22 @@ void Ionpump::add_dynamic_commands()
// Additional Methods
//+------------------------------------------------------------------
/**
* method: Dual::get_ps_name()
* method: Ionpump::get_ps_name()
* Get ps name
*
*/
//+------------------------------------------------------------------
void Ionpump::get_ps_name()
{
DEBUG_STREAM << "Dual::get_ps_name(): entering... !" << endl;
DEBUG_STREAM << "Ionpump::get_ps_name(): entering... !" << endl;
// Add your own code to control device here
using namespace Tango;
char count;
Database *db = new Database();
Tango::Database *db = new Tango::Database();
int found_flag = 0;
DbData db_data_ps;
db_data_ps.push_back(DbDatum("power_supply"));
Tango::DbData db_data_ps;
db_data_ps.push_back(Tango::DbDatum("power_supply"));
db->get_property("vacuum",db_data_ps);
if (db_data_ps[0].is_empty()) {
......@@ -422,7 +491,7 @@ void Ionpump::get_ps_name()
Tango::Except::throw_exception(
(const char *) "Cant'find vacuum ps device in database",
(const char *) "No ps devices found",
(const char *) "Dual::get_sip_names()",Tango::ERR);
(const char *) "Ionpump::get_ps_name()",Tango::ERR);
}
else {
vector<string> device_names_ps;
......@@ -477,7 +546,7 @@ void Ionpump::get_ps_name()
Tango::Except::throw_exception(
(const char *) "No ps found",
(const char *) "Invalid vacuum PS resource format",
(const char *) "Dual::get_sip_names()",Tango::ERR);
(const char *) "Ionpump::get_ps_name()",Tango::ERR);
}
else {
......@@ -485,11 +554,6 @@ void Ionpump::get_ps_name()
try {
devps = new Tango::DeviceProxy(psname);
/* connect to ps device (dual) */
if (devps->ping()) {
cout << device_name << ": found ps device " + psname << " channel " << channel << endl;
devps->set_timeout_millis(IONPUMP_DEV_TOUT);
}
}
catch(Tango::DevFailed &e) {
cout << device_name << ": not found ps device " + psname << " channel " << channel << endl;
......@@ -502,7 +566,7 @@ void Ionpump::get_ps_name()
void Ionpump::get_statmask()
{
DEBUG_STREAM << "Dual::get_statmask(): entering... !" << endl;
DEBUG_STREAM << "Ionpump::get_statmask(): entering... !" << endl;
/*
* bit 0 = off(0) --- on(1)
* bit 1 = loc(0) --- rem(1)
......
......@@ -73,6 +73,12 @@ public:
/*----- PROTECTED REGION END -----*/ // Ionpump::Data Members
// Device property data members
public:
// Psname:
std::string psname;
// Channel:
Tango::DevUShort channel;
// Attribute data members
public:
......@@ -120,6 +126,10 @@ public:
* Initialize the device
*/
virtual void init_device();
/*
* Read the device properties from database
*/
void get_device_property();
/*
* Always executed method before execution command method.
*/
......@@ -193,13 +203,7 @@ public:
// Additional Method prototypes
protected :
Tango::DeviceProxy *devps; // dual device server
unsigned short channel;
string psname;
/*
* get_sip_names()
* Get sip names from database
*/
void get_ps_name(void);
void get_statmask(void);
......
<?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://www.esrf.fr/tango/pogo/PogoDsl">
<classes name="Ionpump" pogoRevision="9.7">
<description description="This is the device server of the ion pump." title="Ionpump device server" sourcePath="/home/alessio/Sources/git-trees/4uhv/deps/ionpump/src" language="Cpp" filestogenerate="XMI file,Code files,Protected Regions" license="GPL" hasMandatoryProperty="false" hasConcreteProperty="false" hasAbstractCommand="false" hasAbstractAttribute="false">
<description description="This is the device server of the ion pump." title="Ionpump device server" sourcePath="/home/alessio/Sources/git-trees/ionpump/src" language="Cpp" filestogenerate="XMI file,Code files,Protected Regions" license="GPL" hasMandatoryProperty="false" hasConcreteProperty="true" hasAbstractCommand="false" hasAbstractAttribute="false">
<inheritances classname="Device_4Impl" sourcePath=""/>
<identification contact="at elettra.eu> - Alessio Igor Bogani &lt;alessio.bogani" author="Alessio Igor Bogani &lt;alessio.bogani" emailDomain="elettra.eu>" classFamily="Vacuum" siteSpecific="" platform="Unix Like" bus="Socket" manufacturer="" reference=""/>
</description>
<deviceProperties name="Psname" description="">
<type xsi:type="pogoDsl:StringType"/>
<status abstract="false" inherited="false" concrete="true" concreteHere="true"/>
</deviceProperties>
<deviceProperties name="Channel" description="">
<type xsi:type="pogoDsl:UShortType"/>
<status abstract="false" inherited="false" concrete="true" concreteHere="true"/>
</deviceProperties>
<commands name="State" description="This command gets the device state (stored in its &lt;i>device_state&lt;/i> data member) and returns it to the caller." execMethod="dev_state" displayLevel="OPERATOR" polledPeriod="0">
<argin description="none.">
<type xsi:type="pogoDsl:VoidType"/>
......
......@@ -220,6 +220,32 @@ void IonpumpClass::set_default_property()
// Set Default Class Properties
// Set Default device Properties
prop_name = "Psname";
prop_desc = "";
prop_def = "";
vect_data.clear();
if (prop_def.length()>0)
{
Tango::DbDatum data(prop_name);
data << vect_data ;
dev_def_prop.push_back(data);
add_wiz_dev_prop(prop_name, prop_desc, prop_def);
}
else
add_wiz_dev_prop(prop_name, prop_desc);
prop_name = "Channel";
prop_desc = "";
prop_def = "";
vect_data.clear();
if (prop_def.length()>0)
{
Tango::DbDatum data(prop_name);
data << vect_data ;
dev_def_prop.push_back(data);
add_wiz_dev_prop(prop_name, prop_desc, prop_def);
}
else
add_wiz_dev_prop(prop_name, prop_desc);
}
//--------------------------------------------------------
......