Skip to content
Snippets Groups Projects
Commit 048fd816 authored by Sonia Minolli's avatar Sonia Minolli
Browse files

Add bias property (TANGODEVIC-135)

parent 4205f66b
No related branches found
No related tags found
No related merge requests found
......@@ -98,10 +98,10 @@ static const char *RcsId = "$Header: /users/chaize/newsvn/cvsroot/Instrumentatio
//===================================================================
//
// The following table gives the correspondance
// between commands and method's name.
// The following table gives the correspondence
// between commands and method name.
//
// Command's name | Method's name
// Command name | Method name
// ----------------------------------------
// State | dev_state()
// Status | dev_status()
......@@ -187,6 +187,11 @@ namespace LoCuM_4_ns
// Initialise variables to default values
//--------------------------------------------
_biasDefined = false;
_biasDefinedOk = false;
_biasSetAtInit = false;
_biasAlarm = false;
get_device_property();
CREATE_SCALAR_ATTRIBUTE(attr_gain_read);
......@@ -215,6 +220,7 @@ namespace LoCuM_4_ns
//------------------------------------------------------------------
Tango::DbData dev_prop;
dev_prop.push_back(Tango::DbDatum("SerialProxyName"));
dev_prop.push_back(Tango::DbDatum("Bias"));
// Call database and extract values
//--------------------------------------------
......@@ -228,18 +234,46 @@ namespace LoCuM_4_ns
// Try to initialize SerialProxyName from class property
cl_prop = ds_class->get_class_property(dev_prop[++i].name);
if (cl_prop.is_empty()==false) cl_prop >> serialProxyName;
else {
// Try to initialize SerialProxyName from default device value
def_prop = ds_class->get_default_device_property(dev_prop[i].name);
if (def_prop.is_empty()==false) def_prop >> serialProxyName;
}
// And try to extract SerialProxyName value from database
if (dev_prop[i].is_empty()==false) dev_prop[i] >> serialProxyName;
// Try to initialize Bias from class property
cl_prop = ds_class->get_class_property(dev_prop[++i].name);
if (cl_prop.is_empty()==false) cl_prop >> bias;
else {
// Try to initialize Bias from default device value
def_prop = ds_class->get_default_device_property(dev_prop[i].name);
if (def_prop.is_empty()==false) def_prop >> bias;
}
// And try to extract Bias value from database
if (dev_prop[i].is_empty()==false) dev_prop[i] >> bias;
// End of Automatic code generation
//------------------------------------------------------------------
if ((this->bias.compare("") != 0) &&
(this->bias.compare("NONE") != 0))
{
_biasDefined = true;
if ((this->bias.compare("PLUS") == 0) ||
(this->bias.compare("MINUS") == 0) ||
(this->bias.compare("EXT") == 0) ||
(this->bias.compare("DEF") == 0))
{
_biasDefinedOk = true;
}
}
INFO_STREAM << "serial proxy = " << serialProxyName << endl;
INFO_STREAM << "BIAS = " << bias << endl;
}
//+----------------------------------------------------------------------------
//
......@@ -276,6 +310,11 @@ namespace LoCuM_4_ns
DEBUG_STREAM << "LoCuM_4::read_attr_hardware(vector<long> &attr_list) entering... "<< endl;
// Add your own code here
// get current Locum config
this->get_config();
// update bias value
this->get_bias(this->response);
}
//+----------------------------------------------------------------------------
//
......@@ -288,10 +327,13 @@ namespace LoCuM_4_ns
{
DEBUG_STREAM << "LoCuM_4::read_gain(Tango::Attribute &attr) entering... "<< endl;
this->get_config();
//this->get_config(); -- done in read_attr_hw()
// response string like "S1_100�A,S2_Plus,HV_OFF,Ext_OFF,Bias+_ON,Auto_OFF,"
_DEV_TRY(*attr_gain_read = get_range(response), "get range value", "LoCuM_4::read_gain");
_DEV_TRY(
*attr_gain_read = get_range(this->response),
"get range value",
"LoCuM_4::read_gain");
attr.set_value(attr_gain_read);
}
......@@ -463,25 +505,47 @@ Tango::DevString LoCuM_4::send_locum4_command(Tango::DevString argin)
// create devices proxy if it does not exist
dev_status_ = "serial proxy = " + serialProxyName + "\n";
// Add your own code to control device here
if(mySerial==0)
// check bias property value
if (_biasDefined && !_biasDefinedOk)
{
argout = Tango::FAULT;
dev_status_ += "The value defined in the Bias property " + bias + " is not correct.\nPlease use one of these value : PLUS, MINUS, EXT or DEF.";
}
else if(mySerial==0)
{
dev_status_ += "no more communication with locum4 amplifier\n";
argout = Tango::FAULT;
}
else
{
// check ALARM state
if (_biasAlarm)
{
argout = Tango::ALARM;
dev_status_ = "The current bias value differs from the bias property value!";
}
else
{
dev_status_ += "Bias voltage source is set to : " + this->_biasValue + ".\n";
if (_biasSetAtInit)
{
dev_status_ += "Bias value has been set at initialization time with property value.\n";
}
if ( !this->_isHV_On )
{
dev_status_ += "HV is \"OFF\".\n";
}
else
{
dev_status_ += "HV is \"ON\".\n";
}
dev_status_ += "locum is fine \n";
argout = Tango::ON;
}
}
set_state(argout);
return argout;
......@@ -710,14 +774,35 @@ Tango::DevString LoCuM_4::send_locum4_command(Tango::DevString argin)
{
//- get locum config
this->get_config();
//- check that range == 1000, S2_value2 == Minus (BIAS voltage source) and HV_value3 == ON
double range = this->get_range(this->response);
if ( range != DEFAULT_RANGE )
this->set_manual_range(DEFAULT_RANGE);
//- extract S2 value : the BIAS voltage source
size_t s2_ValIdx = this->response.find("S2_");
size_t s2_EndIdx = this->response.find(",",s2_ValIdx);
this->_biasValue = this->response.substr(s2_ValIdx, s2_EndIdx-s2_ValIdx);
// check current bias & property (if set)
if (_biasDefinedOk)
{
if (bias.compare(_biasValue) != 0)
{
// current bias value differs from property => force new bias value
std::string l_bias = "CONF:BIAS:SOURCE:" + this->bias;
_DEV_TRY(
write_read(l_bias,false),
"write bias",
"LoCuM_4::configure");
_biasSetAtInit = true;
}
}
//- extract S3 value
size_t s3_ValIdx = this->response.find("HV_ON");
if ( s3_ValIdx == std::string::npos )
......@@ -869,4 +954,36 @@ Tango::DevString LoCuM_4::send_locum4_command(Tango::DevString argin)
(const char*) "LoCuM_4::convert_range_double_to_string()");
}
}
// ********************************************************************************************
// get_bias()
//
// description:
// 1 - search the bias field in the string returned after sending "conf?" command
// 2 - update bias value
//
// **********************************************************************************************
void LoCuM_4::get_bias(std::string config)
{
//- extract S2 value : the BIAS voltage source
size_t s2_ValIdx = config.find("S2_");
size_t s2_EndIdx = config.find(",",s2_ValIdx);
this->_biasValue = config.substr(s2_ValIdx, s2_EndIdx-s2_ValIdx);
// check bias value (if defined)
if (_biasDefinedOk)
{
if (bias.compare(this->_biasValue) != 0)
{
// The current bias value differs from the property value
_biasAlarm = true;
}
else
{
_biasAlarm = false;
}
}
}
} // namespace
......@@ -99,6 +99,7 @@ namespace LoCuM_4_ns
* Device States Description:
* Tango::FAULT : serial line communication broken
* Tango::ON : by defaut the initial state is ON
* Tango::ALARM : Configured bias not properly set on hardware
*/
......@@ -128,6 +129,10 @@ public :
* name of the serial line proxy used
*/
string serialProxyName;
/**
* Bias of the LoCuM, among : PLUS, MINUS, EXT, DEF
*/
string bias;
//@}
/**@name Constructors
......@@ -286,6 +291,10 @@ private:
std::string dev_status_;
std::string _biasValue;
bool _isHV_On; //- High Voltage state
bool _biasAlarm; //- true if current bias differs from property value
bool _biasDefined; //- true if bias property is set
bool _biasDefinedOk; //- true if bias property is properly defined
bool _biasSetAtInit; //- true if bias value set at init
//methodes
std::string write_read(std::string cmd_to_send,bool reading_expected);
......@@ -294,6 +303,7 @@ private:
std::string convert_range_double_to_string(double value);
void get_config(void);
void configure(void);
void get_bias(std::string config);
};
} // namespace_ns
......
static const char *ClassId = "$Id: $";
static const char *CvsPath = "$Source: $";
static const char *SvnPath = "$HeadURL: $";
static const char *RcsId = "$Header: /users/chaize/newsvn/cvsroot/Instrumentation/LoCuM_4/src/LoCuM_4Class.cpp,v 1.13 2010-03-26 09:31:17 vince_soleil Exp $";
static const char *TagName = "$Name: not supported by cvs2svn $";
static const char *HttpServer= "http://www.esrf.fr/computing/cs/tango/tango_doc/ds_doc/";
......@@ -465,6 +468,22 @@ void LoCuM_4Class::set_default_property()
prop_name = "SerialProxyName";
prop_desc = "name of the serial line proxy used";
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 = "Bias";
prop_desc = "Bias of the LoCuM, among : PLUS, MINUS, EXT, DEF";
prop_def = "NONE";
vect_data.clear();
vect_data.push_back("NONE");
if (prop_def.length()>0)
{
Tango::DbDatum data(prop_name);
......@@ -513,17 +532,23 @@ void LoCuM_4Class::write_class_property()
description << str_desc;
data.push_back(description);
// put cvs location
string rcsId(RcsId);
// put cvs or svn location
string filename(classname);
start = rcsId.find("/");
filename += "Class.cpp";
// Create a string with the class ID to
// get the string into the binary
string class_id(ClassId);
// check for cvs information
string src_path(CvsPath);
start = src_path.find("/");
if (start!=string::npos)
{
filename += "Class.cpp";
end = rcsId.find(filename);
end = src_path.find(filename);
if (end>start)
{
string strloc = rcsId.substr(start, end-start);
string strloc = src_path.substr(start, end-start);
// Check if specific repository
start = strloc.find("/cvsroot/");
if (start!=string::npos && start>0)
......@@ -537,12 +562,35 @@ void LoCuM_4Class::write_class_property()
data.push_back(cvs_loc);
}
}
// check for svn information
else
{
string src_path(SvnPath);
start = src_path.find("://");
if (start!=string::npos)
{
end = src_path.find(filename);
if (end>start)
{
header = "$HeadURL: ";
start = header.length();
string strloc = src_path.substr(start, (end-start));
Tango::DbDatum svn_loc("svn_location");
svn_loc << strloc;
data.push_back(svn_loc);
}
}
}
// Get CVS or SVN revision tag
// Get CVS tag revision
// CVS tag
string tagname(TagName);
header = "$Name: ";
start = header.length();
string endstr(" $");
end = tagname.find(endstr);
if (end!=string::npos && end>start)
{
......@@ -552,6 +600,30 @@ void LoCuM_4Class::write_class_property()
data.push_back(cvs_tag);
}
// SVN tag
string svnpath(SvnPath);
header = "$HeadURL: ";
start = header.length();
end = svnpath.find(endstr);
if (end!=string::npos && end>start)
{
string strloc = svnpath.substr(start, end-start);
string tagstr ("/tags/");
start = strloc.find(tagstr);
if ( start!=string::npos )
{
start = start + tagstr.length();
end = strloc.find(filename);
string strtag = strloc.substr(start, end-start-1);
Tango::DbDatum svn_tag("svn_tag");
svn_tag << strtag;
data.push_back(svn_tag);
}
}
// Get URL location
string httpServ(HttpServer);
if (httpServ.length()>0)
......
......@@ -192,7 +192,11 @@ public:
// The LoCuM_4Class singleton definition
//
class LoCuM_4Class : public Tango::DeviceClass
class
#ifdef _TG_WINDOWS_
__declspec(dllexport)
#endif
LoCuM_4Class : public Tango::DeviceClass
{
public:
// properties member data
......@@ -221,6 +225,8 @@ protected:
void attribute_factory(vector<Tango::Attr *> &);
void write_class_property();
void set_default_property();
string get_cvstag();
string get_cvsroot();
private:
void device_factory(const Tango::DevVarStringArray *);
......
/**
* Device Class Identification:
*
* Class Name : LoCuM_4
* Contact : sebastien.gara@nexeya.com
* Class Family : Miscellaneous
* Platform : All Platforms
* Bus : Not Applicable
* Manufacturer : none
* Reference :
*/
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment