/*----- PROTECTED REGION ID(Mks651dClass.cpp) ENABLED START -----*/ static const char *RcsId = "$Id: Mks651dClass.cpp,v 1.2 2012-03-08 09:50:01 mdm Exp $"; static const char *TagName = "$Name: $"; static const char *CvsPath = "$Source: /home/cvsadm/cvsroot/fermi/servers/651d/src/Mks651dClass.cpp,v $"; static const char *SvnPath = "$HeadURL: $"; static const char *HttpServer = "http://www.esrf.eu/computing/cs/tango/tango_doc/ds_doc/"; //============================================================================= // // file : Mks651dClass.cpp // // description : C++ source for the Mks651dClass. A singleton // class derived from DeviceClass. It implements the // command list and all properties and methods required // by the �name� once per process. // // project : Mks651d. // // $Author: mdm $ // // $Revision: 1.2 $ // $Date: 2012-03-08 09:50:01 $ // // SVN only: // $HeadURL: $ // // CVS only: // $Source: /home/cvsadm/cvsroot/fermi/servers/651d/src/Mks651dClass.cpp,v $ // $Log: Mks651dClass.cpp,v $ // Revision 1.2 2012-03-08 09:50:01 mdm // New version of server // // //============================================================================= // This file is generated by POGO // (Program Obviously used to Generate tango Object) //============================================================================= #include <Mks651dClass.h> /*----- PROTECTED REGION END -----*/ //------------------------------------------------------------------- /** * Create Mks651dClass singleton and * return it in a C function for Python usage */ //------------------------------------------------------------------- extern "C" { #ifdef _TG_WINDOWS_ __declspec(dllexport) #endif Tango::DeviceClass *_create_Mks651d_class(const char *name) { return Mks651d_ns::Mks651dClass::init(name); } } namespace Mks651d_ns { //=================================================================== // Initialize pointer for singleton pattern //=================================================================== Mks651dClass *Mks651dClass::_instance = NULL; //-------------------------------------------------------- /** * method : Mks651dClass::Mks651dClass(string &s) * description : constructor for the Mks651dClass * * @param s The class name */ //-------------------------------------------------------- Mks651dClass::Mks651dClass(string &s):DeviceClass(s) { cout2 << "Entering Mks651dClass constructor" << endl; set_default_property(); get_class_property(); write_class_property(); /*----- PROTECTED REGION ID(Mks651d::Class::constructor) ENABLED START -----*/ /*----- PROTECTED REGION END -----*/ // Mks651d::Class::constructor cout2 << "Leaving Mks651dClass constructor" << endl; } //-------------------------------------------------------- /** * method : Mks651dClass::~Mks651dClass() * description : destructor for the Mks651dClass */ //-------------------------------------------------------- Mks651dClass::~Mks651dClass() { /*----- PROTECTED REGION ID(Mks651d::Class::destructor) ENABLED START -----*/ /*----- PROTECTED REGION END -----*/ // Mks651d::Class::destructor _instance = NULL; } //-------------------------------------------------------- /** * method : Mks651dClass::init * description : Create the object if not already done. * Otherwise, just return a pointer to the object * * @param name The class name */ //-------------------------------------------------------- Mks651dClass *Mks651dClass::init(const char *name) { if (_instance == NULL) { try { string s(name); _instance = new Mks651dClass(s); } catch (bad_alloc) { throw; } } return _instance; } //-------------------------------------------------------- /** * method : Mks651dClass::instance * description : Check if object already created, * and return a pointer to the object */ //-------------------------------------------------------- Mks651dClass *Mks651dClass::instance() { if (_instance == NULL) { cerr << "Class is not initialised !!" << endl; exit(-1); } return _instance; } //=================================================================== // Command execution method calls //=================================================================== //-------------------------------------------------------- /** * method : OpenClass::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 *OpenClass::execute(Tango::DeviceImpl *device, const CORBA::Any &in_any) { cout2 << "OpenClass::execute(): arrived" << endl; ((static_cast<Mks651d *>(device))->open()); return new CORBA::Any(); } //-------------------------------------------------------- /** * method : CloseClass::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 *CloseClass::execute(Tango::DeviceImpl *device, const CORBA::Any &in_any) { cout2 << "CloseClass::execute(): arrived" << endl; ((static_cast<Mks651d *>(device))->close()); return new CORBA::Any(); } //-------------------------------------------------------- /** * method : StopClass::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 *StopClass::execute(Tango::DeviceImpl *device, const CORBA::Any &in_any) { cout2 << "StopClass::execute(): arrived" << endl; ((static_cast<Mks651d *>(device))->stop()); return new CORBA::Any(); } //-------------------------------------------------------- /** * method : SelectSPClass::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 *SelectSPClass::execute(Tango::DeviceImpl *device, const CORBA::Any &in_any) { cout2 << "SelectSPClass::execute(): arrived" << endl; Tango::DevShort argin; extract(in_any, argin); ((static_cast<Mks651d *>(device))->select_sp(argin)); return new CORBA::Any(); } //-------------------------------------------------------- /** * method : ReadSPLevelClass::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 *ReadSPLevelClass::execute(Tango::DeviceImpl *device, const CORBA::Any &in_any) { cout2 << "ReadSPLevelClass::execute(): arrived" << endl; Tango::DevShort argin; extract(in_any, argin); return insert((static_cast<Mks651d *>(device))->read_splevel(argin)); } //-------------------------------------------------------- /** * method : WriteSPLevelClass::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 *WriteSPLevelClass::execute(Tango::DeviceImpl *device, const CORBA::Any &in_any) { cout2 << "WriteSPLevelClass::execute(): arrived" << endl; const Tango::DevVarDoubleArray *argin; extract(in_any, argin); ((static_cast<Mks651d *>(device))->write_splevel(argin)); return new CORBA::Any(); } //-------------------------------------------------------- /** * method : ReadSPTypeClass::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 *ReadSPTypeClass::execute(Tango::DeviceImpl *device, const CORBA::Any &in_any) { cout2 << "ReadSPTypeClass::execute(): arrived" << endl; Tango::DevShort argin; extract(in_any, argin); return insert((static_cast<Mks651d *>(device))->read_sptype(argin)); } //-------------------------------------------------------- /** * method : WriteSPTypeClass::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 *WriteSPTypeClass::execute(Tango::DeviceImpl *device, const CORBA::Any &in_any) { cout2 << "WriteSPTypeClass::execute(): arrived" << endl; const Tango::DevVarShortArray *argin; extract(in_any, argin); ((static_cast<Mks651d *>(device))->write_sptype(argin)); return new CORBA::Any(); } //-------------------------------------------------------- /** * method : ReadSoftStartClass::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 *ReadSoftStartClass::execute(Tango::DeviceImpl *device, const CORBA::Any &in_any) { cout2 << "ReadSoftStartClass::execute(): arrived" << endl; Tango::DevShort argin; extract(in_any, argin); return insert((static_cast<Mks651d *>(device))->read_soft_start(argin)); } //-------------------------------------------------------- /** * method : WriteSoftStartClass::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 *WriteSoftStartClass::execute(Tango::DeviceImpl *device, const CORBA::Any &in_any) { cout2 << "WriteSoftStartClass::execute(): arrived" << endl; const Tango::DevVarDoubleArray *argin; extract(in_any, argin); ((static_cast<Mks651d *>(device))->write_soft_start(argin)); return new CORBA::Any(); } //-------------------------------------------------------- /** * method : ReadSPGainClass::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 *ReadSPGainClass::execute(Tango::DeviceImpl *device, const CORBA::Any &in_any) { cout2 << "ReadSPGainClass::execute(): arrived" << endl; Tango::DevShort argin; extract(in_any, argin); return insert((static_cast<Mks651d *>(device))->read_spgain(argin)); } //-------------------------------------------------------- /** * method : WriteSPGainClass::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 *WriteSPGainClass::execute(Tango::DeviceImpl *device, const CORBA::Any &in_any) { cout2 << "WriteSPGainClass::execute(): arrived" << endl; const Tango::DevVarDoubleArray *argin; extract(in_any, argin); ((static_cast<Mks651d *>(device))->write_spgain(argin)); return new CORBA::Any(); } //-------------------------------------------------------- /** * method : ReadSPLeadClass::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 *ReadSPLeadClass::execute(Tango::DeviceImpl *device, const CORBA::Any &in_any) { cout2 << "ReadSPLeadClass::execute(): arrived" << endl; Tango::DevShort argin; extract(in_any, argin); return insert((static_cast<Mks651d *>(device))->read_splead(argin)); } //-------------------------------------------------------- /** * method : WriteSPLeadClass::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 *WriteSPLeadClass::execute(Tango::DeviceImpl *device, const CORBA::Any &in_any) { cout2 << "WriteSPLeadClass::execute(): arrived" << endl; const Tango::DevVarLongArray *argin; extract(in_any, argin); ((static_cast<Mks651d *>(device))->write_splead(argin)); return new CORBA::Any(); } //-------------------------------------------------------- /** * method : ReadThresholdClass::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 *ReadThresholdClass::execute(Tango::DeviceImpl *device, const CORBA::Any &in_any) { cout2 << "ReadThresholdClass::execute(): arrived" << endl; Tango::DevShort argin; extract(in_any, argin); return insert((static_cast<Mks651d *>(device))->read_threshold(argin)); } //-------------------------------------------------------- /** * method : WriteThresholdClass::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 *WriteThresholdClass::execute(Tango::DeviceImpl *device, const CORBA::Any &in_any) { cout2 << "WriteThresholdClass::execute(): arrived" << endl; const Tango::DevVarDoubleArray *argin; extract(in_any, argin); ((static_cast<Mks651d *>(device))->write_threshold(argin)); return new CORBA::Any(); } //-------------------------------------------------------- /** * method : StartLearningClass::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 *StartLearningClass::execute(Tango::DeviceImpl *device, const CORBA::Any &in_any) { cout2 << "StartLearningClass::execute(): arrived" << endl; ((static_cast<Mks651d *>(device))->start_learning()); return new CORBA::Any(); } //-------------------------------------------------------- /** * method : StopLearningClass::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 *StopLearningClass::execute(Tango::DeviceImpl *device, const CORBA::Any &in_any) { cout2 << "StopLearningClass::execute(): arrived" << endl; ((static_cast<Mks651d *>(device))->stop_learning()); return new CORBA::Any(); } //-------------------------------------------------------- /** * method : LearnAnalogClass::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 *LearnAnalogClass::execute(Tango::DeviceImpl *device, const CORBA::Any &in_any) { cout2 << "LearnAnalogClass::execute(): arrived" << endl; ((static_cast<Mks651d *>(device))->learn_analog()); return new CORBA::Any(); } //-------------------------------------------------------- /** * method : CalibrateAdcClass::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 *CalibrateAdcClass::execute(Tango::DeviceImpl *device, const CORBA::Any &in_any) { cout2 << "CalibrateAdcClass::execute(): arrived" << endl; Tango::DevDouble argin; extract(in_any, argin); ((static_cast<Mks651d *>(device))->calibrate_adc(argin)); return new CORBA::Any(); } //-------------------------------------------------------- /** * method : ZeroSensorClass::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 *ZeroSensorClass::execute(Tango::DeviceImpl *device, const CORBA::Any &in_any) { cout2 << "ZeroSensorClass::execute(): arrived" << endl; ((static_cast<Mks651d *>(device))->zero_sensor()); return new CORBA::Any(); } //-------------------------------------------------------- /** * method : RemoveZeroClass::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 *RemoveZeroClass::execute(Tango::DeviceImpl *device, const CORBA::Any &in_any) { cout2 << "RemoveZeroClass::execute(): arrived" << endl; ((static_cast<Mks651d *>(device))->remove_zero()); return new CORBA::Any(); } //-------------------------------------------------------- /** * method : SetZeroClass::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 *SetZeroClass::execute(Tango::DeviceImpl *device, const CORBA::Any &in_any) { cout2 << "SetZeroClass::execute(): arrived" << endl; Tango::DevDouble argin; extract(in_any, argin); ((static_cast<Mks651d *>(device))->set_zero(argin)); return new CORBA::Any(); } //-------------------------------------------------------- /** * method : LearnZeroClass::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 *LearnZeroClass::execute(Tango::DeviceImpl *device, const CORBA::Any &in_any) { cout2 << "LearnZeroClass::execute(): arrived" << endl; ((static_cast<Mks651d *>(device))->learn_zero()); return new CORBA::Any(); } //-------------------------------------------------------- /** * method : DirectCommandClass::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 *DirectCommandClass::execute(Tango::DeviceImpl *device, const CORBA::Any &in_any) { cout2 << "DirectCommandClass::execute(): arrived" << endl; Tango::DevString argin; extract(in_any, argin); return insert((static_cast<Mks651d *>(device))->direct_command(argin)); } //=================================================================== // Properties management //=================================================================== //-------------------------------------------------------- /** * method : Mks651dClass::get_class_property * description : Get the class property for specified name. * * @param name The property name */ //-------------------------------------------------------- Tango::DbDatum Mks651dClass::get_class_property(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 : Mks651d::Mks651dClass::get_default_device_property()() * Description : Return the default value for device property. */ //-------------------------------------------------------- Tango::DbDatum Mks651dClass::get_default_device_property(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 : Mks651d::Mks651dClass::get_default_class_property()() * Description : Return the default value for class property. */ //-------------------------------------------------------- Tango::DbDatum Mks651dClass::get_default_class_property(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 : Mks651d::Mks651dClass::get_class_property() * Description : // Add your own code to initialize */ //-------------------------------------------------------- void Mks651dClass::get_class_property() { } //-------------------------------------------------------- /** * Method : Mks651d::Mks651dClass::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 Mks651dClass::set_default_property() { string prop_name; string prop_desc; string prop_def; vector<string> vect_data; // Set Default Class Properties // Set Default Device Properties prop_name = "SerialDevice"; prop_desc = ""; prop_def = "undefined\n"; vect_data.clear(); vect_data.push_back("undefined"); 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 = "Timeout"; prop_desc = ""; prop_def = "3500\n"; vect_data.clear(); vect_data.push_back("3500"); 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 = "MaxBackOff"; prop_desc = ""; prop_def = "60\n"; vect_data.clear(); vect_data.push_back("60"); 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 = "ShowPressure"; prop_desc = ""; prop_def = "false\n"; vect_data.clear(); vect_data.push_back("false"); 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 : Mks651d::Mks651dClass::write_class_property() * Description : Set class description fields as property in database */ //-------------------------------------------------------- void Mks651dClass::write_class_property() { // First time, check if database used if (Tango::Util::_UseDb == false) return; Tango::DbData data; string classname = get_name(); string header; string::size_type start, end; // Put title Tango::DbDatum title("ProjectTitle"); string str_title("Mks651d"); title << str_title; data.push_back(title); // Put Description Tango::DbDatum description("Description"); vector<string> str_desc; str_desc.push_back(""); description << str_desc; data.push_back(description); // put cvs or svn location string filename("Mks651d"); filename += "Class.cpp"; // check for cvs information string src_path(CvsPath); start = src_path.find("/"); if (start!=string::npos) { end = src_path.find(filename); if (end>start) { string strloc = src_path.substr(start, end-start); // Check if specific repository start = strloc.find("/cvsroot/"); if (start!=string::npos && start>0) { string repository = strloc.substr(0, start); if (repository.find("/segfs/")!=string::npos) strloc = "ESRF:" + strloc.substr(start, strloc.length()-start); } Tango::DbDatum cvs_loc("cvs_location"); cvs_loc << strloc; 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 // CVS tag string tagname(TagName); header = "$Name: "; start = header.length(); string endstr(" $"); end = tagname.find(endstr); if (end!=string::npos && end>start) { string strtag = tagname.substr(start, end-start); Tango::DbDatum cvs_tag("cvs_tag"); cvs_tag << strtag; 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) { Tango::DbDatum db_doc_url("doc_url"); db_doc_url << httpServ; data.push_back(db_doc_url); } // Put inheritance Tango::DbDatum inher_datum("InheritedFrom"); vector<string> inheritance; inheritance.push_back("Device_Impl"); inher_datum << inheritance; data.push_back(inher_datum); // Call database and and values get_db_class()->put_property(data); } //=================================================================== // Factory methods //=================================================================== //-------------------------------------------------------- /** * method : Mks651dClass::device_factory * description : Create the device object(s) * and store them in the device list * * @param *devlist_ptr The device name list */ //-------------------------------------------------------- void Mks651dClass::device_factory(const Tango::DevVarStringArray *devlist_ptr) { /*----- PROTECTED REGION ID(Mks651d::Class::device_factory_before) ENABLED START -----*/ // Add your own code /*----- PROTECTED REGION END -----*/ // Mks651d::Class::device_factory_before // Create devices and add it into the device list for (unsigned long i=0 ; i<devlist_ptr->length() ; i++) { cout4 << "Device name : " << (*devlist_ptr)[i].in() << endl; device_list.push_back(new Mks651d(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 Mks651d *dev = static_cast<Mks651d *>(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(Mks651d::Class::device_factory_after) ENABLED START -----*/ // Add your own code /*----- PROTECTED REGION END -----*/ // Mks651d::Class::device_factory_after } //-------------------------------------------------------- /** * Method : Mks651d::Mks651dClass::attribute_factory() * Description : Create the attribute object(s) * and store them in the attribute list */ //-------------------------------------------------------- void Mks651dClass::attribute_factory(vector<Tango::Attr *> &att_list) { /*----- PROTECTED REGION ID(Mks651d::Class::attribute_factory_before) ENABLED START -----*/ // Add your own code /*----- PROTECTED REGION END -----*/ // Mks651d::Class::attribute_factory_before // Attribute : Pressure PressureAttrib *pressure = new PressureAttrib(); Tango::UserDefaultAttrProp pressure_prop; // description not set for Pressure // label not set for Pressure // unit not set for Pressure // standard_unit not set for Pressure // display_unit not set for Pressure // format not set for Pressure // max_value not set for Pressure // min_value not set for Pressure // max_alarm not set for Pressure // min_alarm not set for Pressure // max_warning not set for Pressure // min_warning not set for Pressure // delta_t not set for Pressure // delta_val not set for Pressure pressure->set_default_properties(pressure_prop); // Not Polled pressure->set_disp_level(Tango::OPERATOR); // Not memorized // Pressure does not fire change event // Pressure does not fire archive event // Pressure does not fire data_ready event att_list.push_back(pressure); // Attribute : Position PositionAttrib *position = new PositionAttrib(); Tango::UserDefaultAttrProp position_prop; // description not set for Position // label not set for Position // unit not set for Position // standard_unit not set for Position // display_unit not set for Position // format not set for Position // max_value not set for Position // min_value not set for Position // max_alarm not set for Position // min_alarm not set for Position // max_warning not set for Position // min_warning not set for Position // delta_t not set for Position // delta_val not set for Position position->set_default_properties(position_prop); // Not Polled position->set_disp_level(Tango::OPERATOR); // Not memorized // Position does not fire change event // Position does not fire archive event // Position does not fire data_ready event att_list.push_back(position); // Attribute : ControlType ControlTypeAttrib *controltype = new ControlTypeAttrib(); Tango::UserDefaultAttrProp controltype_prop; controltype_prop.set_description("Control type\n0 = self tuning\n1 = PID"); // label not set for ControlType // unit not set for ControlType // standard_unit not set for ControlType // display_unit not set for ControlType // format not set for ControlType // max_value not set for ControlType // min_value not set for ControlType // max_alarm not set for ControlType // min_alarm not set for ControlType // max_warning not set for ControlType // min_warning not set for ControlType // delta_t not set for ControlType // delta_val not set for ControlType controltype->set_default_properties(controltype_prop); // Not Polled controltype->set_disp_level(Tango::EXPERT); // Not memorized // ControlType does not fire change event // ControlType does not fire archive event // ControlType does not fire data_ready event att_list.push_back(controltype); // Attribute : SensorType SensorTypeAttrib *sensortype = new SensorTypeAttrib(); Tango::UserDefaultAttrProp sensortype_prop; sensortype_prop.set_description("Sensor type\n0 = Absolute\n1 = Differential"); // label not set for SensorType // unit not set for SensorType // standard_unit not set for SensorType // display_unit not set for SensorType // format not set for SensorType // max_value not set for SensorType // min_value not set for SensorType // max_alarm not set for SensorType // min_alarm not set for SensorType // max_warning not set for SensorType // min_warning not set for SensorType // delta_t not set for SensorType // delta_val not set for SensorType sensortype->set_default_properties(sensortype_prop); // Not Polled sensortype->set_disp_level(Tango::EXPERT); // Not memorized // SensorType does not fire change event // SensorType does not fire archive event // SensorType does not fire data_ready event att_list.push_back(sensortype); // Attribute : SensorVoltage SensorVoltageAttrib *sensorvoltage = new SensorVoltageAttrib(); Tango::UserDefaultAttrProp sensorvoltage_prop; sensorvoltage_prop.set_description("Sensor voltage range:\n0 = 1 Volt\n1 = 5 Volts\n2 = 10 Volts"); // label not set for SensorVoltage // unit not set for SensorVoltage // standard_unit not set for SensorVoltage // display_unit not set for SensorVoltage // format not set for SensorVoltage // max_value not set for SensorVoltage // min_value not set for SensorVoltage // max_alarm not set for SensorVoltage // min_alarm not set for SensorVoltage // max_warning not set for SensorVoltage // min_warning not set for SensorVoltage // delta_t not set for SensorVoltage // delta_val not set for SensorVoltage sensorvoltage->set_default_properties(sensorvoltage_prop); // Not Polled sensorvoltage->set_disp_level(Tango::EXPERT); // Not memorized // SensorVoltage does not fire change event // SensorVoltage does not fire archive event // SensorVoltage does not fire data_ready event att_list.push_back(sensorvoltage); // Attribute : SensorRange SensorRangeAttrib *sensorrange = new SensorRangeAttrib(); Tango::UserDefaultAttrProp sensorrange_prop; sensorrange_prop.set_description("Sensor range:\n00 = 0.1\n01 = 0.2\n02 = 0.5\n03 = 1\n04 = 2\n05 = 5\n06 = 10\n07 = 50\n08 = 100\n09 = 500\n10 = 1000\n11 = 5000\n12 = 10000\n13 = 1.3\n14 = 2.66\n15 = 13.33\n16 = 133.3\n17 = 1333\n18 = 6666\n19 = 13332"); // label not set for SensorRange // unit not set for SensorRange // standard_unit not set for SensorRange // display_unit not set for SensorRange // format not set for SensorRange // max_value not set for SensorRange // min_value not set for SensorRange // max_alarm not set for SensorRange // min_alarm not set for SensorRange // max_warning not set for SensorRange // min_warning not set for SensorRange // delta_t not set for SensorRange // delta_val not set for SensorRange sensorrange->set_default_properties(sensorrange_prop); // Not Polled sensorrange->set_disp_level(Tango::EXPERT); // Not memorized // SensorRange does not fire change event // SensorRange does not fire archive event // SensorRange does not fire data_ready event att_list.push_back(sensorrange); // Attribute : ControlMode ControlModeAttrib *controlmode = new ControlModeAttrib(); Tango::UserDefaultAttrProp controlmode_prop; controlmode_prop.set_description("Control type:\n0 = direct\n1 = reverse"); // label not set for ControlMode // unit not set for ControlMode // standard_unit not set for ControlMode // display_unit not set for ControlMode // format not set for ControlMode // max_value not set for ControlMode // min_value not set for ControlMode // max_alarm not set for ControlMode // min_alarm not set for ControlMode // max_warning not set for ControlMode // min_warning not set for ControlMode // delta_t not set for ControlMode // delta_val not set for ControlMode controlmode->set_default_properties(controlmode_prop); // Not Polled controlmode->set_disp_level(Tango::EXPERT); // Not memorized // ControlMode does not fire change event // ControlMode does not fire archive event // ControlMode does not fire data_ready event att_list.push_back(controlmode); // Attribute : ValveType ValveTypeAttrib *valvetype = new ValveTypeAttrib(); Tango::UserDefaultAttrProp valvetype_prop; valvetype_prop.set_description("Valve type:\n1 = Std 253\n2 = Fast 253\n3 = 653"); // label not set for ValveType // unit not set for ValveType // standard_unit not set for ValveType // display_unit not set for ValveType // format not set for ValveType // max_value not set for ValveType // min_value not set for ValveType // max_alarm not set for ValveType // min_alarm not set for ValveType // max_warning not set for ValveType // min_warning not set for ValveType // delta_t not set for ValveType // delta_val not set for ValveType valvetype->set_default_properties(valvetype_prop); // Not Polled valvetype->set_disp_level(Tango::EXPERT); // Not memorized // ValveType does not fire change event // ValveType does not fire archive event // ValveType does not fire data_ready event att_list.push_back(valvetype); // Attribute : AnalogSPRange AnalogSPRangeAttrib *analogsprange = new AnalogSPRangeAttrib(); Tango::UserDefaultAttrProp analogsprange_prop; analogsprange_prop.set_description("0 = 5 Volts\n1 = 10 Volts"); // label not set for AnalogSPRange // unit not set for AnalogSPRange // standard_unit not set for AnalogSPRange // display_unit not set for AnalogSPRange // format not set for AnalogSPRange // max_value not set for AnalogSPRange // min_value not set for AnalogSPRange // max_alarm not set for AnalogSPRange // min_alarm not set for AnalogSPRange // max_warning not set for AnalogSPRange // min_warning not set for AnalogSPRange // delta_t not set for AnalogSPRange // delta_val not set for AnalogSPRange analogsprange->set_default_properties(analogsprange_prop); // Not Polled analogsprange->set_disp_level(Tango::EXPERT); // Not memorized // AnalogSPRange does not fire change event // AnalogSPRange does not fire archive event // AnalogSPRange does not fire data_ready event att_list.push_back(analogsprange); // Attribute : SelectedSP SelectedSPAttrib *selectedsp = new SelectedSPAttrib(); Tango::UserDefaultAttrProp selectedsp_prop; selectedsp_prop.set_description("0 = setpoint analog\n1 = setpoint A\n2 = setpoint B\n3 = setpoint C\n4 = setpoint D\n5 = setpoint E"); // label not set for SelectedSP // unit not set for SelectedSP // standard_unit not set for SelectedSP // display_unit not set for SelectedSP // format not set for SelectedSP // max_value not set for SelectedSP // min_value not set for SelectedSP // max_alarm not set for SelectedSP // min_alarm not set for SelectedSP // max_warning not set for SelectedSP // min_warning not set for SelectedSP // delta_t not set for SelectedSP // delta_val not set for SelectedSP selectedsp->set_default_properties(selectedsp_prop); // Not Polled selectedsp->set_disp_level(Tango::OPERATOR); // Not memorized // SelectedSP does not fire change event // SelectedSP does not fire archive event // SelectedSP does not fire data_ready event att_list.push_back(selectedsp); // Attribute : PowerFailResponse PowerFailResponseAttrib *powerfailresponse = new PowerFailResponseAttrib(); Tango::UserDefaultAttrProp powerfailresponse_prop; powerfailresponse_prop.set_description("Power fail response:\n0 = disabled\n1 = open at power fail\n2 = close at power fail"); // label not set for PowerFailResponse // unit not set for PowerFailResponse // standard_unit not set for PowerFailResponse // display_unit not set for PowerFailResponse // format not set for PowerFailResponse // max_value not set for PowerFailResponse // min_value not set for PowerFailResponse // max_alarm not set for PowerFailResponse // min_alarm not set for PowerFailResponse // max_warning not set for PowerFailResponse // min_warning not set for PowerFailResponse // delta_t not set for PowerFailResponse // delta_val not set for PowerFailResponse powerfailresponse->set_default_properties(powerfailresponse_prop); // Not Polled powerfailresponse->set_disp_level(Tango::EXPERT); // Not memorized // PowerFailResponse does not fire change event // PowerFailResponse does not fire archive event // PowerFailResponse does not fire data_ready event att_list.push_back(powerfailresponse); // Create a list of static attributes create_static_attribute_list(get_class_attr()->get_attr_list()); /*----- PROTECTED REGION ID(Mks651d::Class::attribute_factory_after) ENABLED START -----*/ // Add your own code /*----- PROTECTED REGION END -----*/ // Mks651d::Class::attribute_factory_after } //-------------------------------------------------------- /** * Method : Mks651d::Mks651dClass::command_factory() * Description : Create the command object(s) * and store them in the command list */ //-------------------------------------------------------- void Mks651dClass::command_factory() { /*----- PROTECTED REGION ID(Mks651d::Class::command_factory_before) ENABLED START -----*/ /*----- PROTECTED REGION END -----*/ // Mks651d::Class::command_factory_before OpenClass *pOpenCmd = new OpenClass("Open", Tango::DEV_VOID, Tango::DEV_VOID, "", "", Tango::OPERATOR); command_list.push_back(pOpenCmd); CloseClass *pCloseCmd = new CloseClass("Close", Tango::DEV_VOID, Tango::DEV_VOID, "", "", Tango::OPERATOR); command_list.push_back(pCloseCmd); StopClass *pStopCmd = new StopClass("Stop", Tango::DEV_VOID, Tango::DEV_VOID, "", "", Tango::OPERATOR); command_list.push_back(pStopCmd); SelectSPClass *pSelectSPCmd = new SelectSPClass("SelectSP", Tango::DEV_SHORT, Tango::DEV_VOID, "1 setpoint A\n2 setpoint B\n3 setpoint C\n4 setpoint D\n5 setpoint E\n6 setpoint Analog", "", Tango::EXPERT); command_list.push_back(pSelectSPCmd); ReadSPLevelClass *pReadSPLevelCmd = new ReadSPLevelClass("ReadSPLevel", Tango::DEV_SHORT, Tango::DEV_DOUBLE, "1 setpoint A\n2 setpoint B\n3 setpoint C\n4 setpoint D\n5 setpoint E\n6 setpoint Analog", "value is the % of FS\npressure for pressure setpoint\nposition for position setpoint", Tango::EXPERT); command_list.push_back(pReadSPLevelCmd); WriteSPLevelClass *pWriteSPLevelCmd = new WriteSPLevelClass("WriteSPLevel", Tango::DEVVAR_DOUBLEARRAY, Tango::DEV_VOID, "argin = setpoint, value\n\nsetpoint\n1 setpoint A\n2 setpoint B\n3 setpoint C\n4 setpoint D\n5 setpoint E\n6 setpoint Analog\n\nvalue \n(for setpoint A-E)\n0-100 \n(for analog setpoint)\n0 = 100%\n1 = 10%", "", Tango::EXPERT); command_list.push_back(pWriteSPLevelCmd); ReadSPTypeClass *pReadSPTypeCmd = new ReadSPTypeClass("ReadSPType", Tango::DEV_SHORT, Tango::DEV_SHORT, "1 setpoint A\n2 setpoint B\n3 setpoint C\n4 setpoint D\n5 setpoint E\n6 setpoint Analog", "0 = position\n1 = pressure", Tango::EXPERT); command_list.push_back(pReadSPTypeCmd); WriteSPTypeClass *pWriteSPTypeCmd = new WriteSPTypeClass("WriteSPType", Tango::DEVVAR_SHORTARRAY, Tango::DEV_VOID, "argin = setpoint, value\n\nsetpoint\n1 setpoint A\n2 setpoint B\n3 setpoint C\n4 setpoint D\n5 setpoint E\n6 setpoint Analog\n\nvalue \n0 = position\n1 = control", "", Tango::EXPERT); command_list.push_back(pWriteSPTypeCmd); ReadSoftStartClass *pReadSoftStartCmd = new ReadSoftStartClass("ReadSoftStart", Tango::DEV_SHORT, Tango::DEV_DOUBLE, "1 setpoint A\n2 setpoint B\n3 setpoint C\n4 setpoint D\n5 setpoint E\n6 setpoint Analog\n7 valve open\n8 valve close", "value is % of full speed", Tango::EXPERT); command_list.push_back(pReadSoftStartCmd); WriteSoftStartClass *pWriteSoftStartCmd = new WriteSoftStartClass("WriteSoftStart", Tango::DEVVAR_DOUBLEARRAY, Tango::DEV_VOID, "argin = setpoint, value\n\nsetpoint\n1 setpoint A\n2 setpoint B\n3 setpoint C\n4 setpoint D\n5 setpoint E\n6 setpoint Analog\n7 valve open \n8 valve close\n\nvalue is % of full speed\n0-100", "", Tango::EXPERT); command_list.push_back(pWriteSoftStartCmd); ReadSPGainClass *pReadSPGainCmd = new ReadSPGainClass("ReadSPGain", Tango::DEV_SHORT, Tango::DEV_DOUBLE, "1 setpoint A\n2 setpoint B\n3 setpoint C\n4 setpoint D\n5 setpoint E", "value is % of gain", Tango::EXPERT); command_list.push_back(pReadSPGainCmd); WriteSPGainClass *pWriteSPGainCmd = new WriteSPGainClass("WriteSPGain", Tango::DEVVAR_DOUBLEARRAY, Tango::DEV_VOID, "argin = setpoint, value\n\nsetpoint\n1 setpoint A\n2 setpoint B\n3 setpoint C\n4 setpoint D\n5 setpoint E\n\nvalue is % of gain\n0-100", "", Tango::EXPERT); command_list.push_back(pWriteSPGainCmd); ReadSPLeadClass *pReadSPLeadCmd = new ReadSPLeadClass("ReadSPLead", Tango::DEV_SHORT, Tango::DEV_LONG, "1 setpoint A\n2 setpoint B\n3 setpoint C\n4 setpoint D\n5 setpoint E", "value is seconds", Tango::EXPERT); command_list.push_back(pReadSPLeadCmd); WriteSPLeadClass *pWriteSPLeadCmd = new WriteSPLeadClass("WriteSPLead", Tango::DEVVAR_LONGARRAY, Tango::DEV_VOID, "argin = setpoint, value\n\nsetpoint\n1 setpoint A\n2 setpoint B\n3 setpoint C\n4 setpoint D\n5 setpoint E\n\nvalue is seconds", "", Tango::EXPERT); command_list.push_back(pWriteSPLeadCmd); ReadThresholdClass *pReadThresholdCmd = new ReadThresholdClass("ReadThreshold", Tango::DEV_SHORT, Tango::DEV_DOUBLE, "1 = Low threshold 1\n2 = High threshold 1\n3 = Low threshold 2\n4 = High threshold 2", "value is % of F.S.", Tango::EXPERT); command_list.push_back(pReadThresholdCmd); WriteThresholdClass *pWriteThresholdCmd = new WriteThresholdClass("WriteThreshold", Tango::DEVVAR_DOUBLEARRAY, Tango::DEV_VOID, "argin = limit, value\n\nlimit\n1 = Low threshold 1\n2 = High threshold 1\n3 = Low threshold 2\n4 = High threshold 2\n\nvalue is % of F.S.\n0-100", "", Tango::EXPERT); command_list.push_back(pWriteThresholdCmd); StartLearningClass *pStartLearningCmd = new StartLearningClass("StartLearning", Tango::DEV_VOID, Tango::DEV_VOID, "", "", Tango::EXPERT); command_list.push_back(pStartLearningCmd); StopLearningClass *pStopLearningCmd = new StopLearningClass("StopLearning", Tango::DEV_VOID, Tango::DEV_VOID, "", "", Tango::EXPERT); command_list.push_back(pStopLearningCmd); LearnAnalogClass *pLearnAnalogCmd = new LearnAnalogClass("LearnAnalog", Tango::DEV_VOID, Tango::DEV_VOID, "", "", Tango::EXPERT); command_list.push_back(pLearnAnalogCmd); CalibrateAdcClass *pCalibrateAdcCmd = new CalibrateAdcClass("CalibrateAdc", Tango::DEV_DOUBLE, Tango::DEV_VOID, "Assign the value to the converter reading of the pressure channel.", "", Tango::EXPERT); command_list.push_back(pCalibrateAdcCmd); ZeroSensorClass *pZeroSensorCmd = new ZeroSensorClass("ZeroSensor", Tango::DEV_VOID, Tango::DEV_VOID, "", "", Tango::EXPERT); command_list.push_back(pZeroSensorCmd); RemoveZeroClass *pRemoveZeroCmd = new RemoveZeroClass("RemoveZero", Tango::DEV_VOID, Tango::DEV_VOID, "", "", Tango::EXPERT); command_list.push_back(pRemoveZeroCmd); SetZeroClass *pSetZeroCmd = new SetZeroClass("SetZero", Tango::DEV_DOUBLE, Tango::DEV_VOID, "value is % F.S. of the base pressure reading", "", Tango::EXPERT); command_list.push_back(pSetZeroCmd); LearnZeroClass *pLearnZeroCmd = new LearnZeroClass("LearnZero", Tango::DEV_VOID, Tango::DEV_VOID, "", "", Tango::EXPERT); command_list.push_back(pLearnZeroCmd); DirectCommandClass *pDirectCommandCmd = new DirectCommandClass("DirectCommand", Tango::DEV_STRING, Tango::DEV_STRING, "", "", Tango::EXPERT); command_list.push_back(pDirectCommandCmd); /*----- PROTECTED REGION ID(Mks651d::Class::command_factory_after) ENABLED START -----*/ /*----- PROTECTED REGION END -----*/ // Mks651d::Class::command_factory_after } //=================================================================== // Dynamic attributes related methods //=================================================================== //-------------------------------------------------------- /** * method : Mks651dClass::create_static_attribute_list * description : Create the a list of static attributes * * @param att_list the ceated attribute list */ //-------------------------------------------------------- void Mks651dClass::create_static_attribute_list(vector<Tango::Attr *> &att_list) { for (unsigned long i=0 ; i<att_list.size() ; i++) { string att_name(att_list[i]->get_name()); transform(att_name.begin(), att_name.end(), att_name.begin(), ::tolower); defaultAttList.push_back(att_name); } cout2 << defaultAttList.size() << " attributes in default list" << endl; /*----- PROTECTED REGION ID(Mks651d::Class::create_static_att_list) ENABLED START -----*/ /*----- PROTECTED REGION END -----*/ // Mks651d::Class::create_static_att_list } //-------------------------------------------------------- /** * method : Mks651dClass::erase_dynamic_attributes * description : delete the dynamic attributes if any. * * @param devlist_ptr the device list pointer * @param list of all attributes */ //-------------------------------------------------------- void Mks651dClass::erase_dynamic_attributes(const Tango::DevVarStringArray *devlist_ptr, 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(((string)(*devlist_ptr)[i]).c_str()); Mks651d *dev = static_cast<Mks651d *> (dev_impl); vector<Tango::Attribute *> &dev_att_list = dev->get_device_attr()->get_attribute_list(); vector<Tango::Attribute *>::iterator ite_att; for (ite_att=dev_att_list.begin() ; ite_att != dev_att_list.end() ; ++ite_att) { string att_name((*ite_att)->get_name_lower()); if ((att_name == "state") || (att_name == "status")) continue; vector<string>::iterator ite_str = find(defaultAttList.begin(), defaultAttList.end(), att_name); if (ite_str == defaultAttList.end()) { cout2 << att_name << " is a UNWANTED dynamic attribute for device " << (*devlist_ptr)[i] << 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); --ite_att; } } } /*----- PROTECTED REGION ID(Mks651d::Class::erase_dynamic_attributes) ENABLED START -----*/ /*----- PROTECTED REGION END -----*/ // Mks651d::Class::erase_dynamic_attributes } /*----- PROTECTED REGION ID(Mks651d::Class::Additional Methods) ENABLED START -----*/ /*----- PROTECTED REGION END -----*/ // Mks651d::Class::Additional Methods } // namespace