static const char *ClassId = "$Id: MCCE2ElectrometersClass.cpp,v 1.16 2012-10-03 14:59:19 xavela Exp $"; static const char *CvsPath = "$Source: /users/chaize/newsvn/cvsroot/Instrumentation/NovelecElectro/src/MCCE2ElectrometersClass.cpp,v $"; static const char *SvnPath = "$HeadURL: $"; static const char *RcsId = "$Header: /users/chaize/newsvn/cvsroot/Instrumentation/NovelecElectro/src/MCCE2ElectrometersClass.cpp,v 1.16 2012-10-03 14:59:19 xavela 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/"; //+============================================================================= // // file : MCCE2ElectrometersClass.cpp // // description : C++ source for the MCCE2ElectrometersClass. A singleton // class derived from DeviceClass. It implements the // command list and all properties and methods required // by the MCCE2Electrometers once per process. // // project : TANGO Device Server // // $Author: xavela $ // // $Revision: 1.16 $ // // $Log: not supported by cvs2svn $ // Revision 1.14 2010/06/10 15:12:05 xavela // TEST : control two channels with different MCCE2 // // // copyleft : Synchrotron SOLEIL // L'Orme des Merisiers // Saint-Aubin - BP 48 // FRANCE // //-============================================================================= // // This file is generated by POGO // (Program Obviously used to Generate tango Object) // // (c) - Software Engineering Group - ESRF //============================================================================= #include <tango.h> #include <MCCE2Electrometers.h> #include <MCCE2ElectrometersClass.h> //+---------------------------------------------------------------------------- /** * Create MCCE2ElectrometersClass singleton and return it in a C function for Python usage */ //+---------------------------------------------------------------------------- extern "C" { #ifdef WIN32 __declspec(dllexport) #endif Tango::DeviceClass *_create_MCCE2Electrometers_class(const char *name) { return MCCE2Electrometers_ns::MCCE2ElectrometersClass::init(name); } } namespace MCCE2Electrometers_ns { //+---------------------------------------------------------------------------- // // method : GetElectrometerTypeStrClass::execute() // // description : method to trigger the execution of the command. // PLEASE DO NOT MODIFY this method core without pogo // // in : - device : The device on which the command must be executed // - in_any : The command input data // // returns : The command output data (packed in the Any object) // //----------------------------------------------------------------------------- CORBA::Any *GetElectrometerTypeStrClass::execute(Tango::DeviceImpl *device,const CORBA::Any &in_any) { cout2 << "GetElectrometerTypeStrClass::execute(): arrived" << endl; Tango::DevUShort argin; extract(in_any, argin); return insert((static_cast<MCCE2Electrometers *>(device))->get_electrometer_type_str(argin)); } //+---------------------------------------------------------------------------- // // method : SetPolarityClass::execute() // // description : method to trigger the execution of the command. // PLEASE DO NOT MODIFY this method core without pogo // // in : - device : The device on which the command must be executed // - in_any : The command input data // // returns : The command output data (packed in the Any object) // //----------------------------------------------------------------------------- CORBA::Any *SetPolarityClass::execute(Tango::DeviceImpl *device,const CORBA::Any &in_any) { cout2 << "SetPolarityClass::execute(): arrived" << endl; Tango::DevString argin; extract(in_any, argin); ((static_cast<MCCE2Electrometers *>(device))->set_polarity(argin)); return new CORBA::Any(); } //+---------------------------------------------------------------------------- // // method : MCCE2_OFFCmd::execute() // // description : method to trigger the execution of the command. // PLEASE DO NOT MODIFY this method core without pogo // // in : - device : The device on which the command must be executed // - in_any : The command input data // // returns : The command output data (packed in the Any object) // //----------------------------------------------------------------------------- CORBA::Any *MCCE2_OFFCmd::execute(Tango::DeviceImpl *device,const CORBA::Any &in_any) { cout2 << "MCCE2_OFFCmd::execute(): arrived" << endl; ((static_cast<MCCE2Electrometers *>(device))->mcce2__off()); return new CORBA::Any(); } //+---------------------------------------------------------------------------- // // method : MCCE2_ONCmd::execute() // // description : method to trigger the execution of the command. // PLEASE DO NOT MODIFY this method core without pogo // // in : - device : The device on which the command must be executed // - in_any : The command input data // // returns : The command output data (packed in the Any object) // //----------------------------------------------------------------------------- CORBA::Any *MCCE2_ONCmd::execute(Tango::DeviceImpl *device,const CORBA::Any &in_any) { cout2 << "MCCE2_ONCmd::execute(): arrived" << endl; ((static_cast<MCCE2Electrometers *>(device))->mcce2__on()); return new CORBA::Any(); } //+---------------------------------------------------------------------------- // // method : SetGainCmd::execute() // // description : method to trigger the execution of the command. // PLEASE DO NOT MODIFY this method core without pogo // // in : - device : The device on which the command must be executed // - in_any : The command input data // // returns : The command output data (packed in the Any object) // //----------------------------------------------------------------------------- CORBA::Any *SetGainCmd::execute(Tango::DeviceImpl *device,const CORBA::Any &in_any) { cout2 << "SetGainCmd::execute(): arrived" << endl; Tango::DevUShort argin; extract(in_any, argin); ((static_cast<MCCE2Electrometers *>(device))->set_gain(argin)); return new CORBA::Any(); } //+---------------------------------------------------------------------------- // // method : GetGainCmd::execute() // // description : method to trigger the execution of the command. // PLEASE DO NOT MODIFY this method core without pogo // // in : - device : The device on which the command must be executed // - in_any : The command input data // // returns : The command output data (packed in the Any object) // //----------------------------------------------------------------------------- CORBA::Any *GetGainCmd::execute(Tango::DeviceImpl *device,const CORBA::Any &in_any) { cout2 << "GetGainCmd::execute(): arrived" << endl; return insert((static_cast<MCCE2Electrometers *>(device))->get_gain()); } //+---------------------------------------------------------------------------- // // method : GetModeCmd::execute() // // description : method to trigger the execution of the command. // PLEASE DO NOT MODIFY this method core without pogo // // in : - device : The device on which the command must be executed // - in_any : The command input data // // returns : The command output data (packed in the Any object) // //----------------------------------------------------------------------------- CORBA::Any *GetModeCmd::execute(Tango::DeviceImpl *device,const CORBA::Any &in_any) { cout2 << "GetModeCmd::execute(): arrived" << endl; return insert((static_cast<MCCE2Electrometers *>(device))->get_mode()); } //+---------------------------------------------------------------------------- // // method : SetRangeCmd::execute() // // description : method to trigger the execution of the command. // PLEASE DO NOT MODIFY this method core without pogo // // in : - device : The device on which the command must be executed // - in_any : The command input data // // returns : The command output data (packed in the Any object) // //----------------------------------------------------------------------------- CORBA::Any *SetRangeCmd::execute(Tango::DeviceImpl *device,const CORBA::Any &in_any) { cout2 << "SetRangeCmd::execute(): arrived" << endl; Tango::DevString argin; extract(in_any, argin); ((static_cast<MCCE2Electrometers *>(device))->set_range(argin)); return new CORBA::Any(); } //+---------------------------------------------------------------------------- // // method : GetRangeCmd::execute() // // description : method to trigger the execution of the command. // PLEASE DO NOT MODIFY this method core without pogo // // in : - device : The device on which the command must be executed // - in_any : The command input data // // returns : The command output data (packed in the Any object) // //----------------------------------------------------------------------------- CORBA::Any *GetRangeCmd::execute(Tango::DeviceImpl *device,const CORBA::Any &in_any) { cout2 << "GetRangeCmd::execute(): arrived" << endl; return insert((static_cast<MCCE2Electrometers *>(device))->get_range()); } //+---------------------------------------------------------------------------- // // method : RemoteCmd::execute() // // description : method to trigger the execution of the command. // PLEASE DO NOT MODIFY this method core without pogo // // in : - device : The device on which the command must be executed // - in_any : The command input data // // returns : The command output data (packed in the Any object) // //----------------------------------------------------------------------------- CORBA::Any *RemoteCmd::execute(Tango::DeviceImpl *device,const CORBA::Any &in_any) { cout2 << "RemoteCmd::execute(): arrived" << endl; ((static_cast<MCCE2Electrometers *>(device))->remote()); return new CORBA::Any(); } //+---------------------------------------------------------------------------- // // method : LocalCmd::execute() // // description : method to trigger the execution of the command. // PLEASE DO NOT MODIFY this method core without pogo // // in : - device : The device on which the command must be executed // - in_any : The command input data // // returns : The command output data (packed in the Any object) // //----------------------------------------------------------------------------- CORBA::Any *LocalCmd::execute(Tango::DeviceImpl *device,const CORBA::Any &in_any) { cout2 << "LocalCmd::execute(): arrived" << endl; ((static_cast<MCCE2Electrometers *>(device))->local()); return new CORBA::Any(); } //+---------------------------------------------------------------------------- // // method : GetHzFilterCmd::execute() // // description : method to trigger the execution of the command. // PLEASE DO NOT MODIFY this method core without pogo // // in : - device : The device on which the command must be excuted // - in_any : The command input data // // returns : The command output data (packed in the Any object) // //----------------------------------------------------------------------------- CORBA::Any *GetHzFilterCmd::execute(Tango::DeviceImpl *device,const CORBA::Any &in_any) { cout2 << "GetHzFilterCmd::execute(): arrived" << endl; return insert((static_cast<MCCE2Electrometers *>(device))->get_hz_filter()); } //+---------------------------------------------------------------------------- // // method : SetHzFilterCmd::execute() // // description : method to trigger the execution of the command. // PLEASE DO NOT MODIFY this method core without pogo // // in : - device : The device on which the command must be excuted // - in_any : The command input data // // returns : The command output data (packed in the Any object) // //----------------------------------------------------------------------------- CORBA::Any *SetHzFilterCmd::execute(Tango::DeviceImpl *device,const CORBA::Any &in_any) { cout2 << "SetHzFilterCmd::execute(): arrived" << endl; Tango::DevShort argin; extract(in_any, argin); ((static_cast<MCCE2Electrometers *>(device))->set_hz_filter(argin)); return new CORBA::Any(); } //+---------------------------------------------------------------------------- // // method : GetPolarityCmd::execute() // // description : method to trigger the execution of the command. // PLEASE DO NOT MODIFY this method core without pogo // // in : - device : The device on which the command must be excuted // - in_any : The command input data // // returns : The command output data (packed in the Any object) // //----------------------------------------------------------------------------- CORBA::Any *GetPolarityCmd::execute(Tango::DeviceImpl *device,const CORBA::Any &in_any) { cout2 << "GetPolarityCmd::execute(): arrived" << endl; return insert((static_cast<MCCE2Electrometers *>(device))->get_polarity()); } //+---------------------------------------------------------------------------- // // method : SetMeasureFunctionCmd::execute() // // description : method to trigger the execution of the command. // PLEASE DO NOT MODIFY this method core without pogo // // in : - device : The device on which the command must be excuted // - in_any : The command input data // // returns : The command output data (packed in the Any object) // //----------------------------------------------------------------------------- CORBA::Any *SetMeasureFunctionCmd::execute(Tango::DeviceImpl *device,const CORBA::Any &in_any) { cout2 << "SetMeasureFunctionCmd::execute(): arrived" << endl; ((static_cast<MCCE2Electrometers *>(device))->set_measure_function()); return new CORBA::Any(); } //+---------------------------------------------------------------------------- // // method : ClearRegistersClass::execute() // // description : method to trigger the execution of the command. // PLEASE DO NOT MODIFY this method core without pogo // // in : - device : The device on which the command must be excuted // - in_any : The command input data // // returns : The command output data (packed in the Any object) // //----------------------------------------------------------------------------- CORBA::Any *ClearRegistersClass::execute(Tango::DeviceImpl *device,const CORBA::Any &in_any) { cout2 << "ClearRegistersClass::execute(): arrived" << endl; ((static_cast<MCCE2Electrometers *>(device))->clear_registers()); return new CORBA::Any(); } //+---------------------------------------------------------------------------- // // method : RangeUPCmd::execute() // // description : method to trigger the execution of the command. // PLEASE DO NOT MODIFY this method core without pogo // // in : - device : The device on which the command must be excuted // - in_any : The command input data // // returns : The command output data (packed in the Any object) // //----------------------------------------------------------------------------- CORBA::Any *RangeUPCmd::execute(Tango::DeviceImpl *device,const CORBA::Any &in_any) { cout2 << "RangeUPCmd::execute(): arrived" << endl; ((static_cast<MCCE2Electrometers *>(device))->range_up()); return new CORBA::Any(); } //+---------------------------------------------------------------------------- // // method : RangeDOWNClass::execute() // // description : method to trigger the execution of the command. // PLEASE DO NOT MODIFY this method core without pogo // // in : - device : The device on which the command must be excuted // - in_any : The command input data // // returns : The command output data (packed in the Any object) // //----------------------------------------------------------------------------- CORBA::Any *RangeDOWNClass::execute(Tango::DeviceImpl *device,const CORBA::Any &in_any) { cout2 << "RangeDOWNClass::execute(): arrived" << endl; ((static_cast<MCCE2Electrometers *>(device))->range_down()); return new CORBA::Any(); } //+---------------------------------------------------------------------------- // // method : SetZeroVFFunctionCmd::execute() // // description : method to trigger the execution of the command. // PLEASE DO NOT MODIFY this method core without pogo // // in : - device : The device on which the command must be excuted // - in_any : The command input data // // returns : The command output data (packed in the Any object) // //----------------------------------------------------------------------------- CORBA::Any *SetZeroVFFunctionCmd::execute(Tango::DeviceImpl *device,const CORBA::Any &in_any) { cout2 << "SetZeroVFFunctionCmd::execute(): arrived" << endl; ((static_cast<MCCE2Electrometers *>(device))->set_zero_vffunction()); return new CORBA::Any(); } //+---------------------------------------------------------------------------- // // method : SetOffsetZeroV1FunctionCmd::execute() // // description : method to trigger the execution of the command. // PLEASE DO NOT MODIFY this method core without pogo // // in : - device : The device on which the command must be excuted // - in_any : The command input data // // returns : The command output data (packed in the Any object) // //----------------------------------------------------------------------------- CORBA::Any *SetOffsetZeroV1FunctionCmd::execute(Tango::DeviceImpl *device,const CORBA::Any &in_any) { cout2 << "SetOffsetZeroV1FunctionCmd::execute(): arrived" << endl; ((static_cast<MCCE2Electrometers *>(device))->set_offset_zero_v1_function()); return new CORBA::Any(); } //+---------------------------------------------------------------------------- // // method : SetLeakageZeroV2FunctionCmd::execute() // // description : method to trigger the execution of the command. // PLEASE DO NOT MODIFY this method core without pogo // // in : - device : The device on which the command must be excuted // - in_any : The command input data // // returns : The command output data (packed in the Any object) // //----------------------------------------------------------------------------- CORBA::Any *SetLeakageZeroV2FunctionCmd::execute(Tango::DeviceImpl *device,const CORBA::Any &in_any) { cout2 << "SetLeakageZeroV2FunctionCmd::execute(): arrived" << endl; ((static_cast<MCCE2Electrometers *>(device))->set_leakage_zero_v2_function()); return new CORBA::Any(); } //+---------------------------------------------------------------------------- // // method : SetTestFunctionCmd::execute() // // description : method to trigger the execution of the command. // PLEASE DO NOT MODIFY this method core without pogo // // in : - device : The device on which the command must be excuted // - in_any : The command input data // // returns : The command output data (packed in the Any object) // //----------------------------------------------------------------------------- CORBA::Any *SetTestFunctionCmd::execute(Tango::DeviceImpl *device,const CORBA::Any &in_any) { cout2 << "SetTestFunctionCmd::execute(): arrived" << endl; ((static_cast<MCCE2Electrometers *>(device))->set_test_function()); return new CORBA::Any(); } //+---------------------------------------------------------------------------- // // method : ResetClass::execute() // // description : method to trigger the execution of the command. // PLEASE DO NOT MODIFY this method core without pogo // // in : - device : The device on which the command must be excuted // - in_any : The command input data // // returns : The command output data (packed in the Any object) // //----------------------------------------------------------------------------- CORBA::Any *ResetClass::execute(Tango::DeviceImpl *device,const CORBA::Any &in_any) { cout2 << "ResetClass::execute(): arrived" << endl; ((static_cast<MCCE2Electrometers *>(device))->reset()); return new CORBA::Any(); } // //---------------------------------------------------------------- // Initialize pointer for singleton pattern //---------------------------------------------------------------- // MCCE2ElectrometersClass *MCCE2ElectrometersClass::_instance = NULL; //+---------------------------------------------------------------------------- // // method : MCCE2ElectrometersClass::MCCE2ElectrometersClass(string &s) // // description : constructor for the MCCE2ElectrometersClass // // in : - s : The class name // //----------------------------------------------------------------------------- MCCE2ElectrometersClass::MCCE2ElectrometersClass(string &s):DeviceClass(s) { cout2 << "Entering MCCE2ElectrometersClass constructor" << endl; set_default_property(); write_class_property(); get_class_property(); cout2 << "Leaving MCCE2ElectrometersClass constructor" << endl; } //+---------------------------------------------------------------------------- // // method : MCCE2ElectrometersClass::~MCCE2ElectrometersClass() // // description : destructor for the MCCE2ElectrometersClass // //----------------------------------------------------------------------------- MCCE2ElectrometersClass::~MCCE2ElectrometersClass() { _instance = NULL; } //+---------------------------------------------------------------------------- // // method : MCCE2ElectrometersClass::instance // // description : Create the object if not already done. Otherwise, just // return a pointer to the object // // in : - name : The class name // //----------------------------------------------------------------------------- MCCE2ElectrometersClass *MCCE2ElectrometersClass::init(const char *name) { if (_instance == NULL) { try { string s(name); _instance = new MCCE2ElectrometersClass(s); } catch (bad_alloc) { throw; } } return _instance; } MCCE2ElectrometersClass *MCCE2ElectrometersClass::instance() { if (_instance == NULL) { cerr << "Class is not initialised !!" << endl; exit(-1); } return _instance; } //+---------------------------------------------------------------------------- // // method : MCCE2ElectrometersClass::command_factory // // description : Create the command object(s) and store them in the // command list // //----------------------------------------------------------------------------- void MCCE2ElectrometersClass::command_factory() { command_list.push_back(new RangeUPCmd("RangeUP", Tango::DEV_VOID, Tango::DEV_VOID, "no argin", "no argout", Tango::OPERATOR)); command_list.push_back(new RangeDOWNClass("RangeDOWN", Tango::DEV_VOID, Tango::DEV_VOID, "no argin", "no argout", Tango::OPERATOR)); command_list.push_back(new SetZeroVFFunctionCmd("SetZeroVFFunction", Tango::DEV_VOID, Tango::DEV_VOID, "no argin", "no argout", Tango::EXPERT)); command_list.push_back(new SetOffsetZeroV1FunctionCmd("SetOffsetZeroV1Function", Tango::DEV_VOID, Tango::DEV_VOID, "no argin", "no argout", Tango::EXPERT)); command_list.push_back(new SetLeakageZeroV2FunctionCmd("SetLeakageZeroV2Function", Tango::DEV_VOID, Tango::DEV_VOID, "no argin", "no argout", Tango::EXPERT)); command_list.push_back(new SetTestFunctionCmd("SetTestFunction", Tango::DEV_VOID, Tango::DEV_VOID, "no argin", "no argout", Tango::EXPERT)); command_list.push_back(new SetMeasureFunctionCmd("SetMeasureFunction", Tango::DEV_VOID, Tango::DEV_VOID, "no argin", "no argout", Tango::EXPERT)); command_list.push_back(new MCCE2_ONCmd("MCCE2_ON", Tango::DEV_VOID, Tango::DEV_VOID, "no argin", "no argout", Tango::EXPERT)); command_list.push_back(new MCCE2_OFFCmd("MCCE2_OFF", Tango::DEV_VOID, Tango::DEV_VOID, "no argin", "no argout", Tango::EXPERT)); command_list.push_back(new LocalCmd("Local", Tango::DEV_VOID, Tango::DEV_VOID, "no argin", "no argout", Tango::EXPERT)); command_list.push_back(new RemoteCmd("Remote", Tango::DEV_VOID, Tango::DEV_VOID, "no argin", "no argout", Tango::EXPERT)); command_list.push_back(new ResetClass("Reset", Tango::DEV_VOID, Tango::DEV_VOID, "no argin", "no argout", Tango::OPERATOR)); command_list.push_back(new ClearRegistersClass("ClearRegisters", Tango::DEV_VOID, Tango::DEV_VOID, "no argin", "no argout", Tango::OPERATOR)); command_list.push_back(new GetRangeCmd("GetRange", Tango::DEV_VOID, Tango::DEV_STRING, "no argin", "The actual electrometer range", Tango::OPERATOR)); command_list.push_back(new SetRangeCmd("SetRange", Tango::DEV_STRING, Tango::DEV_VOID, "The range to apply on the electrometer", "no argout", Tango::OPERATOR)); command_list.push_back(new GetModeCmd("GetMode", Tango::DEV_VOID, Tango::DEV_STRING, "no argin", "The electrometer mode (MEASURE, LEAKAGE ...)", Tango::EXPERT)); command_list.push_back(new GetPolarityCmd("GetPolarity", Tango::DEV_VOID, Tango::DEV_STRING, "no argin", "The electrometer polarity", Tango::EXPERT)); command_list.push_back(new SetPolarityClass("SetPolarity", Tango::DEV_STRING, Tango::DEV_VOID, "POSITIVE or NEGATIVE", "no argout", Tango::OPERATOR)); command_list.push_back(new GetHzFilterCmd("GetHzFilter", Tango::DEV_VOID, Tango::DEV_SHORT, "no argin", "The MCCE2 cut-off frequency in Hz", Tango::EXPERT)); command_list.push_back(new SetHzFilterCmd("SetHzFilter", Tango::DEV_SHORT, Tango::DEV_VOID, "The MCCE2 cut-off frequency in Hz", "no argout", Tango::EXPERT)); command_list.push_back(new GetGainCmd("GetGain", Tango::DEV_VOID, Tango::DEV_SHORT, "no argin", "The MCCE2 gain", Tango::EXPERT)); command_list.push_back(new SetGainCmd("SetGain", Tango::DEV_USHORT, Tango::DEV_VOID, "The new MCCE-2 gain", "no argout", Tango::EXPERT)); command_list.push_back(new GetElectrometerTypeStrClass("GetElectrometerTypeStr", Tango::DEV_USHORT, Tango::DEV_STRING, "channel number", "the electrometer type as string", Tango::OPERATOR)); // add polling if any for (unsigned int i=0 ; i<command_list.size(); i++) { } } //+---------------------------------------------------------------------------- // // method : MCCE2ElectrometersClass::get_class_property // // description : Get the class property for specified name. // // in : string name : The property name // //+---------------------------------------------------------------------------- Tango::DbDatum MCCE2ElectrometersClass::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, return an empty DbDatum return Tango::DbDatum(prop_name); } //+---------------------------------------------------------------------------- // // method : MCCE2ElectrometersClass::get_default_device_property() // // description : Return the default value for device property. // //----------------------------------------------------------------------------- Tango::DbDatum MCCE2ElectrometersClass::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 : MCCE2ElectrometersClass::get_default_class_property() // // description : Return the default value for class property. // //----------------------------------------------------------------------------- Tango::DbDatum MCCE2ElectrometersClass::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 : MCCE2ElectrometersClass::device_factory // // description : Create the device object(s) and store them in the // device list // // in : Tango::DevVarStringArray *devlist_ptr : The device name list // //----------------------------------------------------------------------------- void MCCE2ElectrometersClass::device_factory(const Tango::DevVarStringArray *devlist_ptr) { // Create all devices.(Automatic code generation) //------------------------------------------------------------- for (unsigned long i=0 ; i < devlist_ptr->length() ; i++) { cout4 << "Device name : " << (*devlist_ptr)[i].in() << endl; // Create devices and add it into the device list //---------------------------------------------------- device_list.push_back(new MCCE2Electrometers(this, (*devlist_ptr)[i])); // Export device to the outside world // Check before if database used. //--------------------------------------------- if ((Tango::Util::_UseDb == true) && (Tango::Util::_FileDb == false)) export_device(device_list.back()); else export_device(device_list.back(), (*devlist_ptr)[i]); } // End of Automatic code generation //------------------------------------------------------------- } //+---------------------------------------------------------------------------- // Method: MCCE2ElectrometersClass::attribute_factory(vector<Tango::Attr *> &att_list) //----------------------------------------------------------------------------- void MCCE2ElectrometersClass::attribute_factory(vector<Tango::Attr *> &att_list) { // Attribute : electrometerChannel electrometerChannelAttrib *electrometer_channel = new electrometerChannelAttrib(); Tango::UserDefaultAttrProp electrometer_channel_prop; electrometer_channel_prop.set_label("electrometer channel"); electrometer_channel_prop.set_unit(" "); electrometer_channel_prop.set_standard_unit(" "); electrometer_channel_prop.set_display_unit(" "); electrometer_channel_prop.set_format("%1.0d"); electrometer_channel_prop.set_description("MCCE2 electrometer have two channels to support two amplifiers.\nWARN : default is 0 (please set this value first)."); electrometer_channel->set_default_properties(electrometer_channel_prop); att_list.push_back(electrometer_channel); // Attribute : range1 range1Attrib *range1 = new range1Attrib(); Tango::UserDefaultAttrProp range1_prop; range1_prop.set_label("range1"); range1_prop.set_unit(" "); range1_prop.set_standard_unit(" "); range1_prop.set_display_unit(" "); range1_prop.set_format("%s"); range1_prop.set_description("The channel one MCCE2 range."); range1->set_default_properties(range1_prop); att_list.push_back(range1); // Attribute : range2 range2Attrib *range2 = new range2Attrib(); Tango::UserDefaultAttrProp range2_prop; range2_prop.set_label("range2"); range2_prop.set_unit(" "); range2_prop.set_standard_unit(" "); range2_prop.set_display_unit(" "); range2_prop.set_format("%s"); range2_prop.set_description("The channel two MCCE range."); range2->set_default_properties(range2_prop); att_list.push_back(range2); // End of Automatic code generation //------------------------------------------------------------- } //+---------------------------------------------------------------------------- // // method : MCCE2ElectrometersClass::get_class_property() // // description : Read the class properties from database. // //----------------------------------------------------------------------------- void MCCE2ElectrometersClass::get_class_property() { // Initialize your default values here (if not done with POGO). //------------------------------------------------------------------ // Read class properties from database.(Automatic code generation) //------------------------------------------------------------------ // Call database and extract values //-------------------------------------------- if (Tango::Util::instance()->_UseDb==true) get_db_class()->get_property(cl_prop); Tango::DbDatum def_prop; int i = -1; // End of Automatic code generation //------------------------------------------------------------------ } //+---------------------------------------------------------------------------- // // method : MCCE2ElectrometersClass::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 MCCE2ElectrometersClass::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 = "CommunicationLinkName"; prop_desc = "The name of the device which manage the communication."; 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 = "Electrometer1Address"; prop_desc = "The first electrometer address configured. <br />\nNote : if not connected, push 0 or let empty the property."; 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 = "Electrometer2Address"; prop_desc = "The second electrometer address configured. <br />\nNote : if not connected, push 0 or let empty the property."; 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); } //+---------------------------------------------------------------------------- // // method : MCCE2ElectrometersClass::write_class_property // // description : Set class description as property in database // //----------------------------------------------------------------------------- void MCCE2ElectrometersClass::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("Novelec MCCE-2 Electrometers"); title << str_title; data.push_back(title); // Put Description Tango::DbDatum description("Description"); vector<string> str_desc; str_desc.push_back("This class allows you to control all MCCE-2 Novelec electrometers"); str_desc.push_back("through a Serial bus."); str_desc.push_back("<br> Supported types :"); str_desc.push_back("<br> Novelec Electrometers : MCCE2"); description << str_desc; data.push_back(description); // put cvs or svn location string filename(classname); 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) { 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_4Impl"); inher_datum << inheritance; data.push_back(inher_datum); // Call database and and values //-------------------------------------------- get_db_class()->put_property(data); } } // namespace