Skip to content
Snippets Groups Projects
Commit 0b75c7ec authored by Alessio Igor Bogani's avatar Alessio Igor Bogani
Browse files

Add psname and channel properties

parent fb9f48e6
Branches master
Tags 1.2.2
No related merge requests found
...@@ -169,26 +169,96 @@ void Ionpump::init_device() ...@@ -169,26 +169,96 @@ void Ionpump::init_device()
attrs.clear(); attrs.clear();
/*----- PROTECTED REGION END -----*/ // Ionpump::init_device_before /*----- 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 -----*/ /*----- PROTECTED REGION ID(Ionpump::init_device) ENABLED START -----*/
// Initialize device // Initialize device
char attr[20]; char attr[20];
try { try {
get_ps_name(); if (psname.empty() || channel == 255)
get_ps_name();
else {
devps = new Tango::DeviceProxy(psname);
}
sprintf(attr,"State%d",channel); sprintf(attr,"State%d",channel);
attrs.push_back(attr); attrs.push_back(attr);
sprintf(attr,"Status%d",channel); sprintf(attr,"Status%d",channel);
attrs.push_back(attr); attrs.push_back(attr);
} catch(Tango::DevFailed &e) { } catch(Tango::DevFailed &e) {
cout << "Can't get dual name" << endl; cout << "Can't get name of the power-supply" << endl;
exit(1); exit(1);
} }
/*----- PROTECTED REGION END -----*/ // Ionpump::init_device /*----- 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) ...@@ -262,7 +332,7 @@ void Ionpump::read_Pressure(Tango::Attribute &attr)
} }
catch(Tango::DevFailed &e) { catch(Tango::DevFailed &e) {
TangoSys_MemStream out_stream; TangoSys_MemStream out_stream;
out_stream << "Reading dual failed" << ends; out_stream << "Reading power-supply failed" << ends;
Tango::Except::re_throw_exception(e, Tango::Except::re_throw_exception(e,
(const char *)"Error reading pressure", (const char *)"Error reading pressure",
out_stream.str(), out_stream.str(),
...@@ -398,23 +468,22 @@ void Ionpump::add_dynamic_commands() ...@@ -398,23 +468,22 @@ void Ionpump::add_dynamic_commands()
// Additional Methods // Additional Methods
//+------------------------------------------------------------------ //+------------------------------------------------------------------
/** /**
* method: Dual::get_ps_name() * method: Ionpump::get_ps_name()
* Get ps name * Get ps name
* *
*/ */
//+------------------------------------------------------------------ //+------------------------------------------------------------------
void Ionpump::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 // Add your own code to control device here
using namespace Tango;
char count; char count;
Database *db = new Database(); Tango::Database *db = new Tango::Database();
int found_flag = 0; int found_flag = 0;
DbData db_data_ps; Tango::DbData db_data_ps;
db_data_ps.push_back(DbDatum("power_supply")); db_data_ps.push_back(Tango::DbDatum("power_supply"));
db->get_property("vacuum",db_data_ps); db->get_property("vacuum",db_data_ps);
if (db_data_ps[0].is_empty()) { if (db_data_ps[0].is_empty()) {
...@@ -422,7 +491,7 @@ void Ionpump::get_ps_name() ...@@ -422,7 +491,7 @@ void Ionpump::get_ps_name()
Tango::Except::throw_exception( Tango::Except::throw_exception(
(const char *) "Cant'find vacuum ps device in database", (const char *) "Cant'find vacuum ps device in database",
(const char *) "No ps devices found", (const char *) "No ps devices found",
(const char *) "Dual::get_sip_names()",Tango::ERR); (const char *) "Ionpump::get_ps_name()",Tango::ERR);
} }
else { else {
vector<string> device_names_ps; vector<string> device_names_ps;
...@@ -477,7 +546,7 @@ void Ionpump::get_ps_name() ...@@ -477,7 +546,7 @@ void Ionpump::get_ps_name()
Tango::Except::throw_exception( Tango::Except::throw_exception(
(const char *) "No ps found", (const char *) "No ps found",
(const char *) "Invalid vacuum PS resource format", (const char *) "Invalid vacuum PS resource format",
(const char *) "Dual::get_sip_names()",Tango::ERR); (const char *) "Ionpump::get_ps_name()",Tango::ERR);
} }
else { else {
...@@ -485,11 +554,6 @@ void Ionpump::get_ps_name() ...@@ -485,11 +554,6 @@ void Ionpump::get_ps_name()
try { try {
devps = new Tango::DeviceProxy(psname); 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) { catch(Tango::DevFailed &e) {
cout << device_name << ": not found ps device " + psname << " channel " << channel << endl; cout << device_name << ": not found ps device " + psname << " channel " << channel << endl;
...@@ -502,7 +566,7 @@ void Ionpump::get_ps_name() ...@@ -502,7 +566,7 @@ void Ionpump::get_ps_name()
void Ionpump::get_statmask() 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 0 = off(0) --- on(1)
* bit 1 = loc(0) --- rem(1) * bit 1 = loc(0) --- rem(1)
......
...@@ -73,6 +73,12 @@ public: ...@@ -73,6 +73,12 @@ public:
/*----- PROTECTED REGION END -----*/ // Ionpump::Data Members /*----- PROTECTED REGION END -----*/ // Ionpump::Data Members
// Device property data members
public:
// Psname:
std::string psname;
// Channel:
Tango::DevUShort channel;
// Attribute data members // Attribute data members
public: public:
...@@ -120,6 +126,10 @@ public: ...@@ -120,6 +126,10 @@ public:
* Initialize the device * Initialize the device
*/ */
virtual void init_device(); virtual void init_device();
/*
* Read the device properties from database
*/
void get_device_property();
/* /*
* Always executed method before execution command method. * Always executed method before execution command method.
*/ */
...@@ -193,13 +203,7 @@ public: ...@@ -193,13 +203,7 @@ public:
// Additional Method prototypes // Additional Method prototypes
protected : protected :
Tango::DeviceProxy *devps; // dual device server 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_ps_name(void);
void get_statmask(void); void get_statmask(void);
......
<?xml version="1.0" encoding="ASCII"?> <?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"> <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"> <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=""/> <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=""/> <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> </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"> <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."> <argin description="none.">
<type xsi:type="pogoDsl:VoidType"/> <type xsi:type="pogoDsl:VoidType"/>
......
...@@ -220,6 +220,32 @@ void IonpumpClass::set_default_property() ...@@ -220,6 +220,32 @@ void IonpumpClass::set_default_property()
// Set Default Class Properties // Set Default Class Properties
// Set Default device 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);
} }
//-------------------------------------------------------- //--------------------------------------------------------
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment