From 81d91d9f5a61b686570e56c519fa5a2b555f1456 Mon Sep 17 00:00:00 2001 From: Claudio Scafuri <claudio.scafuri@elettra.eu> Date: Tue, 10 Dec 2019 09:44:45 +0100 Subject: [PATCH] first git import based on CVS release_09 --- .gitignore | 18 + LICENSE | 165 +++++++++ Makefile | 6 + README.md | 34 ++ src/ClassFactory.cpp | 52 +++ src/Vg.cpp | 728 +++++++++++++++++++++++++++++++++++++++ src/Vg.h | 227 +++++++++++++ src/Vg.xmi | 107 ++++++ src/VgClass.cpp | 751 +++++++++++++++++++++++++++++++++++++++++ src/VgClass.h | 200 +++++++++++ src/VgStateMachine.cpp | 185 ++++++++++ src/devicestate.h | 21 ++ src/main.cpp | 73 ++++ 13 files changed, 2567 insertions(+) create mode 100644 .gitignore create mode 100644 LICENSE create mode 100644 Makefile create mode 100644 src/ClassFactory.cpp create mode 100644 src/Vg.cpp create mode 100644 src/Vg.h create mode 100644 src/Vg.xmi create mode 100644 src/VgClass.cpp create mode 100644 src/VgClass.h create mode 100644 src/VgStateMachine.cpp create mode 100644 src/devicestate.h create mode 100644 src/main.cpp diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..0ea3d3f --- /dev/null +++ b/.gitignore @@ -0,0 +1,18 @@ +.pydevproject +.project +.cproject +.settings +obj +bin +core* +*~ +*.pyc +*.so +*.so* +.pylintrc +.metadata +.idea +.cvsignore +.nse_depinfo +software +oldsrc diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..65c5ca8 --- /dev/null +++ b/LICENSE @@ -0,0 +1,165 @@ + GNU LESSER GENERAL PUBLIC LICENSE + Version 3, 29 June 2007 + + Copyright (C) 2007 Free Software Foundation, Inc. <http://fsf.org/> + Everyone is permitted to copy and distribute verbatim copies + of this license document, but changing it is not allowed. + + + This version of the GNU Lesser General Public License incorporates +the terms and conditions of version 3 of the GNU General Public +License, supplemented by the additional permissions listed below. + + 0. Additional Definitions. + + As used herein, "this License" refers to version 3 of the GNU Lesser +General Public License, and the "GNU GPL" refers to version 3 of the GNU +General Public License. + + "The Library" refers to a covered work governed by this License, +other than an Application or a Combined Work as defined below. + + An "Application" is any work that makes use of an interface provided +by the Library, but which is not otherwise based on the Library. +Defining a subclass of a class defined by the Library is deemed a mode +of using an interface provided by the Library. + + A "Combined Work" is a work produced by combining or linking an +Application with the Library. The particular version of the Library +with which the Combined Work was made is also called the "Linked +Version". + + The "Minimal Corresponding Source" for a Combined Work means the +Corresponding Source for the Combined Work, excluding any source code +for portions of the Combined Work that, considered in isolation, are +based on the Application, and not on the Linked Version. + + The "Corresponding Application Code" for a Combined Work means the +object code and/or source code for the Application, including any data +and utility programs needed for reproducing the Combined Work from the +Application, but excluding the System Libraries of the Combined Work. + + 1. Exception to Section 3 of the GNU GPL. + + You may convey a covered work under sections 3 and 4 of this License +without being bound by section 3 of the GNU GPL. + + 2. Conveying Modified Versions. + + If you modify a copy of the Library, and, in your modifications, a +facility refers to a function or data to be supplied by an Application +that uses the facility (other than as an argument passed when the +facility is invoked), then you may convey a copy of the modified +version: + + a) under this License, provided that you make a good faith effort to + ensure that, in the event an Application does not supply the + function or data, the facility still operates, and performs + whatever part of its purpose remains meaningful, or + + b) under the GNU GPL, with none of the additional permissions of + this License applicable to that copy. + + 3. Object Code Incorporating Material from Library Header Files. + + The object code form of an Application may incorporate material from +a header file that is part of the Library. You may convey such object +code under terms of your choice, provided that, if the incorporated +material is not limited to numerical parameters, data structure +layouts and accessors, or small macros, inline functions and templates +(ten or fewer lines in length), you do both of the following: + + a) Give prominent notice with each copy of the object code that the + Library is used in it and that the Library and its use are + covered by this License. + + b) Accompany the object code with a copy of the GNU GPL and this license + document. + + 4. Combined Works. + + You may convey a Combined Work under terms of your choice that, +taken together, effectively do not restrict modification of the +portions of the Library contained in the Combined Work and reverse +engineering for debugging such modifications, if you also do each of +the following: + + a) Give prominent notice with each copy of the Combined Work that + the Library is used in it and that the Library and its use are + covered by this License. + + b) Accompany the Combined Work with a copy of the GNU GPL and this license + document. + + c) For a Combined Work that displays copyright notices during + execution, include the copyright notice for the Library among + these notices, as well as a reference directing the user to the + copies of the GNU GPL and this license document. + + d) Do one of the following: + + 0) Convey the Minimal Corresponding Source under the terms of this + License, and the Corresponding Application Code in a form + suitable for, and under terms that permit, the user to + recombine or relink the Application with a modified version of + the Linked Version to produce a modified Combined Work, in the + manner specified by section 6 of the GNU GPL for conveying + Corresponding Source. + + 1) Use a suitable shared library mechanism for linking with the + Library. A suitable mechanism is one that (a) uses at run time + a copy of the Library already present on the user's computer + system, and (b) will operate properly with a modified version + of the Library that is interface-compatible with the Linked + Version. + + e) Provide Installation Information, but only if you would otherwise + be required to provide such information under section 6 of the + GNU GPL, and only to the extent that such information is + necessary to install and execute a modified version of the + Combined Work produced by recombining or relinking the + Application with a modified version of the Linked Version. (If + you use option 4d0, the Installation Information must accompany + the Minimal Corresponding Source and Corresponding Application + Code. If you use option 4d1, you must provide the Installation + Information in the manner specified by section 6 of the GNU GPL + for conveying Corresponding Source.) + + 5. Combined Libraries. + + You may place library facilities that are a work based on the +Library side by side in a single library together with other library +facilities that are not Applications and are not covered by this +License, and convey such a combined library under terms of your +choice, if you do both of the following: + + a) Accompany the combined library with a copy of the same work based + on the Library, uncombined with any other library facilities, + conveyed under the terms of this License. + + b) Give prominent notice with the combined library that part of it + is a work based on the Library, and explaining where to find the + accompanying uncombined form of the same work. + + 6. Revised Versions of the GNU Lesser General Public License. + + The Free Software Foundation may publish revised and/or new versions +of the GNU Lesser General Public License from time to time. Such new +versions will be similar in spirit to the present version, but may +differ in detail to address new problems or concerns. + + Each version is given a distinguishing version number. If the +Library as you received it specifies that a certain numbered version +of the GNU Lesser General Public License "or any later version" +applies to it, you have the option of following the terms and +conditions either of that published version or of any later version +published by the Free Software Foundation. If the Library as you +received it does not specify a version number of the GNU Lesser +General Public License, you may choose any version of the GNU Lesser +General Public License ever published by the Free Software Foundation. + + If the Library as you received it specifies that a proxy can decide +whether future versions of the GNU Lesser General Public License shall +apply, that proxy's public statement of acceptance of any version is +permanent authorization for you to choose that version for the +Library. diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..e8ad5d8 --- /dev/null +++ b/Makefile @@ -0,0 +1,6 @@ +NAME_SRV = vg-srv + +CXXFLAGS = +LDFLAGS = + +include ../makefiles/Make-9.3.3.in diff --git a/README.md b/README.md index e69de29..8f8607d 100644 --- a/README.md +++ b/README.md @@ -0,0 +1,34 @@ +# Project Name + +vg + +## Description + +Tango device server for Vacuum Gauge + + +## Installation + +See your institue guidelines for deploying and configuring a Tango device server. + +## Usage + +The server is designed for controlling remotely a a Vacuum Gauge as used in atypical particle accelerator + + + +## History + + +2019-12-10 : project created on gitlab, derived from CVS release_09 + +## Credits + + +Elettra-Sincrotrone Trieste S.C.p.A. di interesse nazionale +Strada Statale 14 - km 163,5 in AREA Science Park +34149 Basovizza, Trieste ITALY + +## License + +GPL 3 diff --git a/src/ClassFactory.cpp b/src/ClassFactory.cpp new file mode 100644 index 0000000..5347ab7 --- /dev/null +++ b/src/ClassFactory.cpp @@ -0,0 +1,52 @@ +/*----- PROTECTED REGION ID(Vg::ClassFactory.cpp) ENABLED START -----*/ +static const char *RcsId = "$Id: ClassFactory.cpp,v 1.2 2012-07-18 09:59:24 mdm Exp $"; +//============================================================================= +// +// file : ClassFactory.cpp +// +// description : C++ source for the class_factory method of the DServer +// device class. This method is responsible for the creation of +// all class singleton for a device server. It is called +// at device server startup. +// +// project : Vg. +// +// $Author: mdm $ +// +// $Revision: 1.2 $ +// $Date: 2012-07-18 09:59:24 $ +// +// SVN only: +// $HeadURL: $ +// +// CVS only: +// $Source: /home/cvsadm/cvsroot/fermi/servers/vg/src/ClassFactory.cpp,v $ +// $Log: ClassFactory.cpp,v $ +// Revision 1.2 2012-07-18 09:59:24 mdm +// New version, before test +// +// +//============================================================================= +// This file is generated by POGO +// (Program Obviously used to Generate tango Object) +//============================================================================= + + +#include <tango.h> +#include <VgClass.h> + +// Add class header files if needed + + +/** + * Create Vg Class singleton and store it in DServer object. + */ + +void Tango::DServer::class_factory() +{ + // Add method class init if needed + + add_class(Vg_ns::VgClass::init("Vg")); +} + +/*----- PROTECTED REGION END -----*/ diff --git a/src/Vg.cpp b/src/Vg.cpp new file mode 100644 index 0000000..4e06e26 --- /dev/null +++ b/src/Vg.cpp @@ -0,0 +1,728 @@ +/*----- PROTECTED REGION ID(Vg.cpp) ENABLED START -----*/ +static const char *RcsId = "$Id: Vg.cpp,v 1.10 2016-10-18 16:06:08 claudio Exp $"; +//============================================================================= +// +// file : Vg.cpp +// +// description : C++ source for the Vg and its commands. +// The class is derived from Device. It represents the +// CORBA servant object which will be accessed from the +// network. All commands which can be executed on the +// Vg are implemented in this file. +// +// project : Vg. +// +// $Author: claudio $ +// +// $Revision: 1.10 $ +// $Date: 2016-10-18 16:06:08 $ +// +// SVN only: +// $HeadURL: $ +// +// CVS only: +// $Source: /home/cvsadm/cvsroot/fermi/servers/vg/src/Vg.cpp,v $ +// $Log: Vg.cpp,v $ +// Revision 1.10 2016-10-18 16:06:08 claudio +// tango9 +// +// Revision 1.9 2013-06-17 10:30:32 lorenzo +// Added DeviceState attribute +// +// Revision 1.8 2013-06-05 15:41:02 lorenzo +// Tango 8.0.5 +// +// Revision 1.7 2012-09-10 08:07:44 mdm +// Unregister name fix +// +// Revision 1.6 2012-07-18 09:59:24 mdm +// New version, before test +// +// +//============================================================================= +// This file is generated by POGO +// (Program Obviously used to Generate tango Object) +//============================================================================= + + +#include <Vg.h> +#include <VgClass.h> + +#include "devicestate.h" + +/*----- PROTECTED REGION END -----*/ + + +/** + * Vg class description: + * + */ + +//================================================================ +// +// The following table gives the correspondence +// between command and method names. +// +// Command name | Method name +//---------------------------------------------------------------- +// State | Inherited (no method) +// Status | Inherited (no method) +// On | on +// Off | off +//================================================================ + +namespace Vg_ns +{ + /*----- PROTECTED REGION ID(Vg::namespace_starting) ENABLED START -----*/ + + // static initializations + + /*----- PROTECTED REGION END -----*/ // Vg::namespace_starting + + + +//-------------------------------------------------------- +/** + * Method : Vg::Vg() + * Description : Constructors for a Tango device + * implementing the class Vg + */ +//-------------------------------------------------------- +Vg::Vg(Tango::DeviceClass *cl, string &s) + : TANGO_BASE_CLASS(cl, s.c_str()) +{ + /*----- PROTECTED REGION ID(Vg::constructor_1) ENABLED START -----*/ + + init_device(); + + /*----- PROTECTED REGION END -----*/ // Vg::constructor_1 +} +//-------------------------------------------------------- +Vg::Vg(Tango::DeviceClass *cl, const char *s) + : TANGO_BASE_CLASS(cl, s) +{ + /*----- PROTECTED REGION ID(Vg::constructor_2) ENABLED START -----*/ + + init_device(); + + /*----- PROTECTED REGION END -----*/ // Vg::constructor_2 +} +//-------------------------------------------------------- +Vg::Vg(Tango::DeviceClass *cl, const char *s, const char *d) + : TANGO_BASE_CLASS(cl, s, d) +{ + /*----- PROTECTED REGION ID(Vg::constructor_3) ENABLED START -----*/ + + init_device(); + + /*----- PROTECTED REGION END -----*/ // Vg::constructor_3 +} + + +//-------------------------------------------------------- +/** + * Method : Vg::delete_device()() + * Description : will be called at device destruction or at init command + */ +//-------------------------------------------------------- +void Vg::delete_device() +{ + /*----- PROTECTED REGION ID(Vg::delete_device) ENABLED START -----*/ + + if(init_completed) + { + try + { + unregister_name(); + } + catch (Tango::DevFailed &ex) + { + exception_handler(ex, Tango::FAULT, "Vg::delete_device"); + } + } + + if(tpg_proxy) + { + delete tpg_proxy; + tpg_proxy = 0; + } + + /*----- PROTECTED REGION END -----*/ // Vg::delete_device + delete[] attr_Pressure_read; + delete[] attr_DeviceState_read; + +} + + +//-------------------------------------------------------- +/** + * Method : Vg::init_device() + * Description : // will be called at device initialization. + */ +//-------------------------------------------------------- +void Vg::init_device() +{ + DEBUG_STREAM << "Vg::init_device() create device " << device_name << endl; + + /*----- PROTECTED REGION ID(Vg::init_device_before) ENABLED START -----*/ + + set_state(Tango::INIT); + set_status("Device initialization"); + + tpg_proxy = 0; + + init_completed = false; + current_back_off = 1; + last_exception_t = 0; + + /*----- PROTECTED REGION END -----*/ // Vg::init_device_before + + // Get the device properties (if any) from database + get_device_property(); + + attr_Pressure_read = new Tango::DevDouble[1]; + attr_DeviceState_read = new Tango::DevUChar[1]; + + /*----- PROTECTED REGION ID(Vg::init_device) ENABLED START -----*/ + + if(get_state() != Tango::FAULT) + { + try + { + tpg_proxy = new Tango::DeviceProxy(tpgDevice); + tpg_proxy->set_timeout_millis(timeout); + + register_name(); + + init_completed = true; + } + catch (Tango::DevFailed &ex) + { + exception_handler(ex, Tango::FAULT, "Vg::init_device"); + } + } + + /*----- PROTECTED REGION END -----*/ // Vg::init_device +} + + + +//-------------------------------------------------------- +/** + * Method : Vg::get_device_property() + * Description : // Add your own code to initialize + */ +//-------------------------------------------------------- +void Vg::get_device_property() +{ + /*----- PROTECTED REGION ID(Vg::get_device_property_before) ENABLED START -----*/ + + // Initialize property data members + + /*----- PROTECTED REGION END -----*/ // Vg::get_device_property_before + + + // Read device properties from database. + Tango::DbData dev_prop; + dev_prop.push_back(Tango::DbDatum("TpgDevice")); + dev_prop.push_back(Tango::DbDatum("Channel")); + dev_prop.push_back(Tango::DbDatum("Timeout")); + dev_prop.push_back(Tango::DbDatum("MaxBackOff")); + + // is there at least one property to be read ? + if (dev_prop.size()>0) + { + // Call database and extract values + if (Tango::Util::instance()->_UseDb==true) + get_db_device()->get_property(dev_prop); + + // get instance on VgClass to get class property + Tango::DbDatum def_prop, cl_prop; + VgClass *ds_class = + (static_cast<VgClass *>(get_device_class())); + int i = -1; + + // Try to initialize TpgDevice from class property + cl_prop = ds_class->get_class_property(dev_prop[++i].name); + if (cl_prop.is_empty()==false) cl_prop >> tpgDevice; + else { + // Try to initialize TpgDevice from default device value + def_prop = ds_class->get_default_device_property(dev_prop[i].name); + if (def_prop.is_empty()==false) def_prop >> tpgDevice; + } + // And try to extract TpgDevice value from database + if (dev_prop[i].is_empty()==false) dev_prop[i] >> tpgDevice; + + // Try to initialize Channel from class property + cl_prop = ds_class->get_class_property(dev_prop[++i].name); + if (cl_prop.is_empty()==false) cl_prop >> channel; + else { + // Try to initialize Channel from default device value + def_prop = ds_class->get_default_device_property(dev_prop[i].name); + if (def_prop.is_empty()==false) def_prop >> channel; + } + // And try to extract Channel value from database + if (dev_prop[i].is_empty()==false) dev_prop[i] >> channel; + + // Try to initialize Timeout from class property + cl_prop = ds_class->get_class_property(dev_prop[++i].name); + if (cl_prop.is_empty()==false) cl_prop >> timeout; + else { + // Try to initialize Timeout from default device value + def_prop = ds_class->get_default_device_property(dev_prop[i].name); + if (def_prop.is_empty()==false) def_prop >> timeout; + } + // And try to extract Timeout value from database + if (dev_prop[i].is_empty()==false) dev_prop[i] >> timeout; + + // Try to initialize MaxBackOff from class property + cl_prop = ds_class->get_class_property(dev_prop[++i].name); + if (cl_prop.is_empty()==false) cl_prop >> maxBackOff; + else { + // Try to initialize MaxBackOff from default device value + def_prop = ds_class->get_default_device_property(dev_prop[i].name); + if (def_prop.is_empty()==false) def_prop >> maxBackOff; + } + // And try to extract MaxBackOff value from database + if (dev_prop[i].is_empty()==false) dev_prop[i] >> maxBackOff; + + + } + /*----- PROTECTED REGION ID(Vg::get_device_property_after) ENABLED START -----*/ + + if(dev_prop[0].is_empty()) + { + set_state(Tango::FAULT); + set_status("TpgDevice property not defined"); + return; + } + + if(tpgDevice.empty() || tpgDevice.compare("undefined") == 0) + { + set_state(Tango::FAULT); + set_status("TpgDevice property is empty"); + return; + } + + if(dev_prop[1].is_empty()) + { + set_state(Tango::FAULT); + set_status("Channel property not defined"); + return; + } + + if(channel == -1) + { + set_state(Tango::FAULT); + set_status("Channel property is empty"); + return; + } + + if(dev_prop[2].is_empty()) + { + WARN_STREAM << "Timeout property not defined, default: " << timeout << endl; + } + + if(timeout < 1 || timeout > 10000) + { + set_state(Tango::FAULT); + set_status("Timeout invalid value, valid range [1,10000]"); + return; + } + + if(dev_prop[3].is_empty()) + { + WARN_STREAM << "MaxBackOff property not defined, default: " << maxBackOff << endl; + } + + if(maxBackOff < 0 || maxBackOff > 600) + { + set_state(Tango::FAULT); + set_status("MaxBackOff invalid value, valid range [0,600]"); + return; + } + + /*----- PROTECTED REGION END -----*/ // Vg::get_device_property_after + +} + +//-------------------------------------------------------- +/** + * Method : Vg::always_executed_hook() + * Description : method always executed before any command is executed + */ +//-------------------------------------------------------- +void Vg::always_executed_hook() +{ + INFO_STREAM << "Vg::always_executed_hook() " << device_name << endl; + /*----- PROTECTED REGION ID(Vg::always_executed_hook) ENABLED START -----*/ + + if(update_allowed()) + { + update_state(); + } + + /*----- PROTECTED REGION END -----*/ // Vg::always_executed_hook +} + + + +//-------------------------------------------------------- +/** + * Method : Vg::read_attr_hardware() + * Description : Hardware acquisition for attributes. + */ +//-------------------------------------------------------- +void Vg::read_attr_hardware(vector<long> &attr_list) +{ + DEBUG_STREAM << "Vg::read_attr_hardware(vector<long> &attr_list) entering... " << endl; + /*----- PROTECTED REGION ID(Vg::read_attr_hardware) ENABLED START -----*/ + + // Add your own code + + /*----- PROTECTED REGION END -----*/ // Vg::read_attr_hardware + +} + + +//-------------------------------------------------------- +/** + * Read Pressure attribute + * Description: + * + * Data type: Tango::DevDouble + * Attr type: Scalar + */ +//-------------------------------------------------------- +void Vg::read_Pressure(Tango::Attribute &attr) +{ + DEBUG_STREAM << "Vg::read_Pressure(Tango::Attribute &attr) entering... " << endl; + /*----- PROTECTED REGION ID(Vg::read_Pressure) ENABLED START -----*/ + + try + { + stringstream attr_name; + attr_name << "Pressure_" << channel; + + tpg_proxy->read_attribute(attr_name.str().c_str()) >> *attr_Pressure_read; + + attr.set_value(attr_Pressure_read); + } + catch (Tango::DevFailed &ex) + { + exception_handler(ex, Tango::FAULT, "Vg::read_Pressure"); + } + + /*----- PROTECTED REGION END -----*/ // Vg::read_Pressure +} +//-------------------------------------------------------- +/** + * Read DeviceState attribute + * Description: + * + * Data type: Tango::DevUChar + * Attr type: Scalar + */ +//-------------------------------------------------------- +void Vg::read_DeviceState(Tango::Attribute &attr) +{ + DEBUG_STREAM << "Vg::read_DeviceState(Tango::Attribute &attr) entering... " << endl; + /*----- PROTECTED REGION ID(Vg::read_DeviceState) ENABLED START -----*/ + + // Set the attribute value + attr.set_value(attr_DeviceState_read); + + /*----- PROTECTED REGION END -----*/ // Vg::read_DeviceState +} + +//-------------------------------------------------------- +/** + * Write DeviceState attribute values to hardware. + * + * Data type: Tango::DevUChar + * Attr type: Scalar + */ +//-------------------------------------------------------- +void Vg::write_DeviceState(Tango::WAttribute &attr) +{ + DEBUG_STREAM << "Vg::write_DeviceState(Tango::Attribute &attr) entering... " << endl; + + // Retrieve write value + Tango::DevUChar w_val; + attr.get_write_value(w_val); + + /*----- PROTECTED REGION ID(Vg::write_DeviceState) ENABLED START -----*/ + + if (w_val >= DEVICESTATE_T_SIZE) { + Tango::Except::throw_exception("", "Value out of range", \ + "Vg::write_DeviceState()"); + } + *attr_DeviceState_read = w_val; + + /*----- PROTECTED REGION END -----*/ // Vg::write_DeviceState +} + + +//-------------------------------------------------------- +/** + * Method : Vg::VgClass::add_dynamic_attributes() + * Description : Create the dynamic attributes if any + * for specified device. + */ +//-------------------------------------------------------- +void Vg::add_dynamic_attributes() +{ + /*----- PROTECTED REGION ID(Vg::Class::add_dynamic_attributes) ENABLED START -----*/ + + // Add your own code to create and add dynamic attributes if any + + /*----- PROTECTED REGION END -----*/ // Vg::Class::add_dynamic_attributes + +} + + + +//======================================================== +// Command execution methods +//======================================================== + +//-------------------------------------------------------- +/** + * Execute the On command: + * Description: + * + * @param argin + * @returns + */ +//-------------------------------------------------------- +void Vg::on() +{ + DEBUG_STREAM << "Vg::On() - " << device_name << endl; + /*----- PROTECTED REGION ID(Vg::on) ENABLED START -----*/ + + try + { + Tango::DeviceData dev_data; + dev_data << channel; + + tpg_proxy->command_inout("SensorOn", dev_data); + } + catch (Tango::DevFailed &ex) + { + exception_handler(ex, Tango::FAULT, "Vg::on"); + } + + /*----- PROTECTED REGION END -----*/ // Vg::on + +} + +//-------------------------------------------------------- +/** + * Execute the Off command: + * Description: + * + * @param argin + * @returns + */ +//-------------------------------------------------------- +void Vg::off() +{ + DEBUG_STREAM << "Vg::Off() - " << device_name << endl; + /*----- PROTECTED REGION ID(Vg::off) ENABLED START -----*/ + + try + { + Tango::DeviceData dev_data; + dev_data << channel; + + tpg_proxy->command_inout("SensorOff", dev_data); + } + catch (Tango::DevFailed &ex) + { + exception_handler(ex, Tango::FAULT, "Vg::off"); + } + + /*----- PROTECTED REGION END -----*/ // Vg::off + +} + + + /*----- PROTECTED REGION ID(Vg::namespace_ending) ENABLED START -----*/ + +//======================================================== +// Private methods +//======================================================== + +//+------------------------------------------------------------------ +/** + * method: Vg::is_update_state_allowed + */ +//+------------------------------------------------------------------ +bool Vg::update_allowed() +{ + DEBUG_STREAM << "Vg::update_allowed() - " << device_name << endl; + + bool is_allowed = false; + + if(init_completed) + { + if(get_state() == Tango::FAULT) + { + time_t now; + time(&now); + + double elapsed_t = difftime(now, last_exception_t); + + WARN_STREAM << "Back off: " << elapsed_t << "/" << current_back_off << " : " << maxBackOff << endl; + + if(elapsed_t >= current_back_off) + { + is_allowed = true; + current_back_off = current_back_off * 2; + + if(current_back_off > maxBackOff) + { + current_back_off = maxBackOff; + } + } + } + else + { + current_back_off = 1; + is_allowed = true; + } + } + + return is_allowed; +} + +//+------------------------------------------------------------------ +/** + * method: Vg::update_channel_state + */ +//+------------------------------------------------------------------ +void Vg::update_state() +{ + DEBUG_STREAM << "Vg::update_state() - " << device_name << endl; + + try + { + Tango::DevState old_state = get_state(); + + stringstream attr_name; + attr_name << "State_" << channel; + + Tango::DeviceAttribute dev_attr = tpg_proxy->read_attribute(attr_name.str().c_str()); + + Tango::DevState new_state; + dev_attr >> new_state; + + + if(old_state == Tango::FAULT && + new_state != Tango::FAULT) + register_name(); + + set_state(new_state); + + + attr_name.str(""); + attr_name << "Status_" << channel; + + dev_attr = tpg_proxy->read_attribute(attr_name.str().c_str()); + + string new_status; + dev_attr >> new_status; + + set_status(new_status); + } + catch (Tango::DevFailed &ex) + { + exception_handler(ex, Tango::FAULT, "Vg::update_state"); + } +} + +//+------------------------------------------------------------------ +/** + * method: Vg::register_name + */ +//+------------------------------------------------------------------ +void Vg::register_name() throw(Tango::DevFailed) +{ + INFO_STREAM << "Vg::register_name(" << device_name << "," + << channel << ") - " << device_name << endl; + + Tango::DevVarLongStringArray* array = new Tango::DevVarLongStringArray(); + + array->lvalue.length(1); + array->lvalue[0] = channel; + + array->svalue.length(1); + array->svalue[0] = CORBA::string_dup(device_name.c_str()); + + + Tango::DeviceData dev_data; + dev_data << array; + + tpg_proxy->command_inout("RegisterName", dev_data); +} + +//+------------------------------------------------------------------ +/** + * method: Vg::unregister_name + */ +//+------------------------------------------------------------------ +void Vg::unregister_name() throw(Tango::DevFailed) +{ + INFO_STREAM << "Vg::unregister_name(" << device_name << "," + << channel << ") - " << device_name << endl; + + Tango::DeviceData dev_data; + dev_data << channel; + + tpg_proxy->command_inout("UnregisterName", dev_data); +} + +//+------------------------------------------------------------------ +/** + * method: Vg::exception_handler + */ +//+------------------------------------------------------------------ +void Vg::exception_handler(Tango::DevFailed &ex, Tango::DevState new_state, const std::string base_msg) +{ + time(&last_exception_t); + + std::stringstream msg; + + msg << base_msg << " : "; + for (unsigned int i=0; i<ex.errors.length(); i++) + { + msg << ex.errors[i].reason.in() << endl; + msg << ex.errors[i].desc.in() << endl; + msg << ex.errors[i].origin.in() << endl; + } + msg << ends; + + ERROR_STREAM << msg.str() << endl; + + set_state(new_state); + set_status(msg.str()); +} +// //-------------------------------------------------------- +// /** +// * Read DeviceStatus attribute +// * Description: +// * +// * Data type: Tango::DevString +// * Attr type: Scalar +// */ +// //-------------------------------------------------------- +// void Vg::read_DeviceStatus(Tango::Attribute &attr) +// { +// DEBUG_STREAM << "Vg::read_DeviceStatus(Tango::Attribute &attr) entering... " << endl; +// // Set the attribute value +// attr.set_value(attr_DeviceStatus_read); +// } + + + /*----- PROTECTED REGION END -----*/ // Vg::namespace_ending +} // namespace diff --git a/src/Vg.h b/src/Vg.h new file mode 100644 index 0000000..67a5e44 --- /dev/null +++ b/src/Vg.h @@ -0,0 +1,227 @@ +/*----- PROTECTED REGION ID(Vg.h) ENABLED START -----*/ +//============================================================================= +// +// file : Vg.h +// +// description : Include for the Vg class. +// +// project : Vg. +// +// $Author: claudio $ +// +// $Revision: 1.8 $ +// $Date: 2016-10-18 16:06:08 $ +// +// SVN only: +// $HeadURL: $ +// +// CVS only: +// $Source: /home/cvsadm/cvsroot/fermi/servers/vg/src/Vg.h,v $ +// $Log: Vg.h,v $ +// Revision 1.8 2016-10-18 16:06:08 claudio +// tango9 +// +// Revision 1.7 2013-06-17 10:30:32 lorenzo +// Added DeviceState attribute +// +// Revision 1.6 2013-06-05 15:41:02 lorenzo +// Tango 8.0.5 +// +// Revision 1.5 2012-07-18 09:59:24 mdm +// New version, before test +// +// +//============================================================================= +// This file is generated by POGO +// (Program Obviously used to Generate tango Object) +//============================================================================= + + +#ifndef VG_H +#define VG_H + + +#include <tango.h> + +/*----- PROTECTED REGION END -----*/ + + +/** + * Vg class Description: + * + */ + +namespace Vg_ns +{ + /*----- PROTECTED REGION ID(Vg::Additional Class Declarations) ENABLED START -----*/ + + // Additional Class Declarations + + /*----- PROTECTED REGION END -----*/ // Vg::Additional Class Declarations + + + class Vg : public TANGO_BASE_CLASS +{ + + + /*----- PROTECTED REGION ID(Vg::Data Members) ENABLED START -----*/ + + static const size_t STRING_SIZE = 1024; + + Tango::DeviceProxy *tpg_proxy; + + bool init_completed; + double current_back_off; + time_t last_exception_t; + + /*----- PROTECTED REGION END -----*/ // Vg::Data Members + + +// Device property data members +public: // TpgDevice: + string tpgDevice; + // Channel: + Tango::DevShort channel; + // Timeout: + Tango::DevLong timeout; + // MaxBackOff: + Tango::DevLong maxBackOff; + + +// Attribute data members +public: + Tango::DevDouble *attr_Pressure_read; + Tango::DevUChar *attr_DeviceState_read; + + + +// Constructors and destructors +public: + /** + * Constructs a newly allocated Command object. + * + * @param cl Class. + * @param s Device Name + */ + Vg(Tango::DeviceClass *cl,string &s); + /** + * Constructs a newly allocated Command object. + * + * @param cl Class. + * @param s Device Name + */ + Vg(Tango::DeviceClass *cl,const char *s); + /** + * Constructs a newly allocated Command object. + * + * @param cl Class. + * @param s Device name + * @param d Device description. + */ + Vg(Tango::DeviceClass *cl,const char *s,const char *d); + /** + * The object destructor. + */ + ~Vg() {delete_device();}; + + + +// Miscellaneous methods +public: + /** + * will be called at device destruction or at init command. + */ + void delete_device(); + /** + * Initialize the device + */ + virtual void init_device(); + /** + * Read the device properties from database + */ + void get_device_property(); + /** + * Always executed method before execution command method. + */ + virtual void always_executed_hook(); + + +// Attribute methods +public: + /** + * Method : Vg::read_attr_hardware() + * Description : Hardware acquisition for attributes. + */ + virtual void read_attr_hardware(vector<long> &attr_list); + + + /** + * Pressure attribute related methods. + * Description: + * + * Data type: Tango::DevDouble + * Attr type: Scalar + */ + virtual void read_Pressure(Tango::Attribute &attr); + virtual bool is_Pressure_allowed(Tango::AttReqType type); + + + + /** + * DeviceState attribute related methods. + * Description: + * + * Data type: Tango::DevUChar + * Attr type: Scalar + */ + virtual void read_DeviceState(Tango::Attribute &attr); + virtual void write_DeviceState(Tango::WAttribute &attr); + virtual bool is_DeviceState_allowed(Tango::AttReqType type); + + + + /** + * Method : Vg::add_dynamic_attributes() + * Description : Add dynamic attributes if any. + */ + void add_dynamic_attributes(); + +// Command related methods +public: + + + /** + * Command On related methods. + */ + void on(); + virtual bool is_On_allowed(const CORBA::Any &any); + + /** + * Command Off related methods. + */ + void off(); + virtual bool is_Off_allowed(const CORBA::Any &any); + + + + /*----- PROTECTED REGION ID(Vg::Additional Method prototypes) ENABLED START -----*/ + + bool update_allowed(); + void update_state(); + void register_name() throw(Tango::DevFailed); + void unregister_name() throw(Tango::DevFailed); + void exception_handler(Tango::DevFailed &, Tango::DevState, const std::string); + + /*----- PROTECTED REGION END -----*/ // Vg::Additional Method prototypes + +}; + + /*----- PROTECTED REGION ID(Vg::Additional Classes Definitions) ENABLED START -----*/ + + // Additional Classes definitions + + /*----- PROTECTED REGION END -----*/ // Vg::Additional Classes Definitions + +} // namespace + +#endif // VG_H diff --git a/src/Vg.xmi b/src/Vg.xmi new file mode 100644 index 0000000..d3147d6 --- /dev/null +++ b/src/Vg.xmi @@ -0,0 +1,107 @@ +<?xml version="1.0" encoding="ASCII"?> +<pogoDsl:PogoSystem xmi:version="2.0" xmlns:xmi="http://www.omg.org/XMI" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:pogoDsl="http://www.esrf.fr/tango/pogo/PogoDsl"> + <classes name="Vg"> + <description description="" title="Vg" sourcePath="/home/lorenzo/src/a/fermi/servers/vg/src" language="Cpp" filestogenerate="XMI file,Code files" hasAbstractCommand="false" hasAbstractAttribute="false"> + <inheritances classname="Device_Impl" sourcePath=""/> + <identification contact="at elettra.trieste.it - marco.demarco" author="marco.demarco" emailDomain="elettra.trieste.it" classFamily="Vacuum" siteSpecific="" platform="Unix Like" bus="TCP/UDP" manufacturer="none" reference=""/> + <comments commandsTable="//================================================================
//
// The following table gives the correspondence
// between command and method names.
//
// Command name | Method name
//----------------------------------------------------------------
// State | Inherited (no method)
// Status | Inherited (no method)
// On | on
// Off | off
//================================================================"/> + </description> + <deviceProperties name="TpgDevice" description=""> + <type xsi:type="pogoDsl:StringType"/> + <status abstract="false" inherited="false" concrete="true" concreteHere="true"/> + <DefaultPropValue>undefined</DefaultPropValue> + </deviceProperties> + <deviceProperties name="Channel" description=""> + <type xsi:type="pogoDsl:ShortType"/> + <status abstract="false" inherited="false" concrete="true" concreteHere="true"/> + <DefaultPropValue>-1</DefaultPropValue> + </deviceProperties> + <deviceProperties name="Timeout" description=""> + <type xsi:type="pogoDsl:IntType"/> + <status abstract="false" inherited="false" concrete="true" concreteHere="true"/> + <DefaultPropValue>3000</DefaultPropValue> + </deviceProperties> + <deviceProperties name="MaxBackOff" description=""> + <type xsi:type="pogoDsl:IntType"/> + <status abstract="false" inherited="false" concrete="true" concreteHere="true"/> + <DefaultPropValue>60</DefaultPropValue> + </deviceProperties> + <commands name="State" description="This command gets the device state (stored in its device_state data member) and returns it to the caller." execMethod="dev_state" displayLevel="OPERATOR"> + <argin description="none"> + <type xsi:type="pogoDsl:VoidType"/> + </argin> + <argout description="Device state"> + <type xsi:type="pogoDsl:StateType"/> + </argout> + <status abstract="true" inherited="true" concrete="true"/> + </commands> + <commands name="Status" description="This command gets the device status (stored in its device_status data member) and returns it to the caller." execMethod="dev_status" displayLevel="OPERATOR"> + <argin description="none"> + <type xsi:type="pogoDsl:VoidType"/> + </argin> + <argout description="Device status"> + <type xsi:type="pogoDsl:ConstStringType"/> + </argout> + <status abstract="true" inherited="true" concrete="true"/> + </commands> + <commands name="On" description="" execMethod="on" displayLevel="EXPERT"> + <argin description=""> + <type xsi:type="pogoDsl:VoidType"/> + </argin> + <argout description=""> + <type xsi:type="pogoDsl:VoidType"/> + </argout> + <status abstract="false" inherited="false" concrete="true" concreteHere="true"/> + <excludedStates>ON</excludedStates> + <excludedStates>DISABLE</excludedStates> + <excludedStates>FAULT</excludedStates> + </commands> + <commands name="Off" description="" execMethod="off" displayLevel="EXPERT"> + <argin description=""> + <type xsi:type="pogoDsl:VoidType"/> + </argin> + <argout description=""> + <type xsi:type="pogoDsl:VoidType"/> + </argout> + <status abstract="false" inherited="false" concrete="true" concreteHere="true"/> + <excludedStates>OFF</excludedStates> + <excludedStates>DISABLE</excludedStates> + <excludedStates>FAULT</excludedStates> + </commands> + <attributes name="Pressure" attType="Scalar" rwType="READ" displayLevel="OPERATOR" maxX="" maxY="" allocReadMember="true"> + <dataType xsi:type="pogoDsl:DoubleType"/> + <changeEvent fire="false" libCheckCriteria="true"/> + <archiveEvent fire="false" libCheckCriteria="true"/> + <dataReadyEvent fire="false" libCheckCriteria="true"/> + <status abstract="false" inherited="false" concrete="true" concreteHere="true"/> + <properties description="" label="" unit="mbar" standardUnit="mbar" displayUnit="mbar" format="" maxValue="" minValue="" maxAlarm="" minAlarm="" maxWarning="" minWarning="" deltaTime="" deltaValue=""/> + <readExcludedStates>OFF</readExcludedStates> + <readExcludedStates>DISABLE</readExcludedStates> + <readExcludedStates>FAULT</readExcludedStates> + </attributes> + <attributes name="DeviceState" attType="Scalar" rwType="READ_WRITE" displayLevel="OPERATOR" maxX="" maxY="" memorized="true" allocReadMember="true"> + <dataType xsi:type="pogoDsl:UCharType"/> + <changeEvent fire="false" libCheckCriteria="true"/> + <archiveEvent fire="false" libCheckCriteria="true"/> + <dataReadyEvent fire="false" libCheckCriteria="true"/> + <status abstract="false" inherited="false" concrete="true" concreteHere="true"/> + <properties description="" label="" unit="" standardUnit="" displayUnit="" format="" maxValue="" minValue="" maxAlarm="" minAlarm="" maxWarning="" minWarning="" deltaTime="" deltaValue=""/> + </attributes> + <states name="ON" description=""> + <status abstract="false" inherited="false" concrete="true" concreteHere="true"/> + </states> + <states name="OFF" description=""> + <status abstract="false" inherited="false" concrete="true" concreteHere="true"/> + </states> + <states name="ALARM" description=""> + <status abstract="false" inherited="false" concrete="true" concreteHere="true"/> + </states> + <states name="DISABLE" description=""> + <status abstract="false" inherited="false" concrete="true" concreteHere="true"/> + </states> + <states name="FAULT" description=""> + <status abstract="false" inherited="false" concrete="true" concreteHere="true"/> + </states> + <preferences docHome="./doc_html" makefileHome="/usr/local/tango-7.2.6/share/pogo/preferences"/> + </classes> +</pogoDsl:PogoSystem> diff --git a/src/VgClass.cpp b/src/VgClass.cpp new file mode 100644 index 0000000..6453527 --- /dev/null +++ b/src/VgClass.cpp @@ -0,0 +1,751 @@ +/*----- PROTECTED REGION ID(VgClass.cpp) ENABLED START -----*/ +static const char *RcsId = "$Id: VgClass.cpp,v 1.6 2013-06-17 10:30:33 lorenzo Exp $"; +static const char *TagName = "$Name: $"; +static const char *CvsPath = "$Source: /home/cvsadm/cvsroot/fermi/servers/vg/src/VgClass.cpp,v $"; +static const char *SvnPath = "$HeadURL: $"; +static const char *HttpServer = "http://www.esrf.eu/computing/cs/tango/tango_doc/ds_doc/"; +//============================================================================= +// +// file : VgClass.cpp +// +// description : C++ source for the VgClass. A singleton +// class derived from DeviceClass. It implements the +// command list and all properties and methods required +// by the «name» once per process. +// +// project : Vg. +// +// $Author: lorenzo $ +// +// $Revision: 1.6 $ +// $Date: 2013-06-17 10:30:33 $ +// +// SVN only: +// $HeadURL: $ +// +// CVS only: +// $Source: /home/cvsadm/cvsroot/fermi/servers/vg/src/VgClass.cpp,v $ +// $Log: VgClass.cpp,v $ +// Revision 1.6 2013-06-17 10:30:33 lorenzo +// Added DeviceState attribute +// +// Revision 1.5 2013-06-05 15:41:02 lorenzo +// Tango 8.0.5 +// +// Revision 1.4 2012-07-18 09:59:24 mdm +// New version, before test +// +// +//============================================================================= +// This file is generated by POGO +// (Program Obviously used to Generate tango Object) +//============================================================================= + + +#include <VgClass.h> + +/*----- PROTECTED REGION END -----*/ + +//------------------------------------------------------------------- +/** + * Create VgClass singleton and + * return it in a C function for Python usage + */ +//------------------------------------------------------------------- +extern "C" { +#ifdef _TG_WINDOWS_ + +__declspec(dllexport) + +#endif + + Tango::DeviceClass *_create_Vg_class(const char *name) { + return Vg_ns::VgClass::init(name); + } +} + + +namespace Vg_ns +{ + + +//=================================================================== +// Initialize pointer for singleton pattern +//=================================================================== +VgClass *VgClass::_instance = NULL; + +//-------------------------------------------------------- +/** + * method : VgClass::VgClass(string &s) + * description : constructor for the VgClass + * + * @param s The class name + */ +//-------------------------------------------------------- +VgClass::VgClass(string &s):DeviceClass(s) +{ + cout2 << "Entering VgClass constructor" << endl; + set_default_property(); + get_class_property(); + write_class_property(); + + /*----- PROTECTED REGION ID(Vg::Class::constructor) ENABLED START -----*/ + + /*----- PROTECTED REGION END -----*/ // Vg::Class::constructor + + cout2 << "Leaving VgClass constructor" << endl; +} + + +//-------------------------------------------------------- +/** + * method : VgClass::~VgClass() + * description : destructor for the VgClass + */ +//-------------------------------------------------------- +VgClass::~VgClass() +{ + /*----- PROTECTED REGION ID(Vg::Class::destructor) ENABLED START -----*/ + + /*----- PROTECTED REGION END -----*/ // Vg::Class::destructor + + _instance = NULL; +} + + +//-------------------------------------------------------- +/** + * method : VgClass::init + * description : Create the object if not already done. + * Otherwise, just return a pointer to the object + * + * @param name The class name + */ +//-------------------------------------------------------- +VgClass *VgClass::init(const char *name) +{ + if (_instance == NULL) + { + try + { + string s(name); + _instance = new VgClass(s); + } + catch (bad_alloc) + { + throw; + } + } + return _instance; +} + +//-------------------------------------------------------- +/** + * method : VgClass::instance + * description : Check if object already created, + * and return a pointer to the object + */ +//-------------------------------------------------------- +VgClass *VgClass::instance() +{ + if (_instance == NULL) + { + cerr << "Class is not initialised !!" << endl; + exit(-1); + } + return _instance; +} + + + + +//=================================================================== +// Command execution method calls +//=================================================================== +//-------------------------------------------------------- +/** + * method : OnClass::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 *OnClass::execute(Tango::DeviceImpl *device, const CORBA::Any &in_any) +{ + cout2 << "OnClass::execute(): arrived" << endl; + + + ((static_cast<Vg *>(device))->on()); + return new CORBA::Any(); +} +//-------------------------------------------------------- +/** + * method : OffClass::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 *OffClass::execute(Tango::DeviceImpl *device, const CORBA::Any &in_any) +{ + cout2 << "OffClass::execute(): arrived" << endl; + + + ((static_cast<Vg *>(device))->off()); + return new CORBA::Any(); +} + + + + +//=================================================================== +// Properties management +//=================================================================== + +//-------------------------------------------------------- +/** + * method : VgClass::get_class_property + * description : Get the class property for specified name. + * + * @param name The property name + */ +//-------------------------------------------------------- +Tango::DbDatum VgClass::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 : Vg::VgClass::get_default_device_property()() + * Description : Return the default value for device property. + */ +//-------------------------------------------------------- +Tango::DbDatum VgClass::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 : Vg::VgClass::get_default_class_property()() + * Description : Return the default value for class property. + */ +//-------------------------------------------------------- +Tango::DbDatum VgClass::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 : Vg::VgClass::get_class_property() + * Description : // Add your own code to initialize + */ +//-------------------------------------------------------- +void VgClass::get_class_property() +{ +} + + +//-------------------------------------------------------- +/** + * Method : Vg::VgClass::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 VgClass::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 = "TpgDevice"; + 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 = "Channel"; + prop_desc = ""; + prop_def = "-1\n"; + vect_data.clear(); + vect_data.push_back("-1"); + 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 = "3000\n"; + vect_data.clear(); + vect_data.push_back("3000"); + 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); +} + + +//-------------------------------------------------------- +/** + * Method : Vg::VgClass::write_class_property() + * Description : Set class description fields as property in database + */ +//-------------------------------------------------------- +void VgClass::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("Vg"); + 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("Vg"); + 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 : VgClass::device_factory + * description : Create the device object(s) + * and store them in the device list + * + * @param *devlist_ptr The device name list + */ +//-------------------------------------------------------- +void VgClass::device_factory(const Tango::DevVarStringArray *devlist_ptr) +{ + + /*----- PROTECTED REGION ID(Vg::Class::device_factory_before) ENABLED START -----*/ + + // Add your own code + + /*----- PROTECTED REGION END -----*/ // Vg::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 Vg(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 + Vg *dev = static_cast<Vg *>(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(Vg::Class::device_factory_after) ENABLED START -----*/ + + // Add your own code + + /*----- PROTECTED REGION END -----*/ // Vg::Class::device_factory_after + + +} + + +//-------------------------------------------------------- +/** + * Method : Vg::VgClass::attribute_factory() + * Description : Create the attribute object(s) + * and store them in the attribute list + */ +//-------------------------------------------------------- +void VgClass::attribute_factory(vector<Tango::Attr *> &att_list) +{ + /*----- PROTECTED REGION ID(Vg::Class::attribute_factory_before) ENABLED START -----*/ + + // Add your own code + + /*----- PROTECTED REGION END -----*/ // Vg::Class::attribute_factory_before + + + // Attribute : Pressure + PressureAttrib *pressure = new PressureAttrib(); + Tango::UserDefaultAttrProp pressure_prop; + // description not set for Pressure + // label not set for Pressure + pressure_prop.set_unit("mbar"); + pressure_prop.set_standard_unit("mbar"); + pressure_prop.set_display_unit("mbar"); + // 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 : DeviceState + DeviceStateAttrib *devicestate = new DeviceStateAttrib(); + Tango::UserDefaultAttrProp devicestate_prop; + // description not set for DeviceState + // label not set for DeviceState + // unit not set for DeviceState + // standard_unit not set for DeviceState + // display_unit not set for DeviceState + // format not set for DeviceState + // max_value not set for DeviceState + // min_value not set for DeviceState + // max_alarm not set for DeviceState + // min_alarm not set for DeviceState + // max_warning not set for DeviceState + // min_warning not set for DeviceState + // delta_t not set for DeviceState + // delta_val not set for DeviceState + devicestate->set_default_properties(devicestate_prop); + // Not Polled + devicestate->set_disp_level(Tango::OPERATOR); + devicestate->set_memorized(); + devicestate->set_memorized_init(false); + // DeviceState does not fire change event + // DeviceState does not fire archive event + // DeviceState does not fire data_ready event + att_list.push_back(devicestate); + + + // Create a list of static attributes + create_static_attribute_list(get_class_attr()->get_attr_list()); + + /*----- PROTECTED REGION ID(Vg::Class::attribute_factory_after) ENABLED START -----*/ + + // Add your own code + + /*----- PROTECTED REGION END -----*/ // Vg::Class::attribute_factory_after + +} + + +//-------------------------------------------------------- +/** + * Method : Vg::VgClass::command_factory() + * Description : Create the command object(s) + * and store them in the command list + */ +//-------------------------------------------------------- +void VgClass::command_factory() +{ + /*----- PROTECTED REGION ID(Vg::Class::command_factory_before) ENABLED START -----*/ + + /*----- PROTECTED REGION END -----*/ // Vg::Class::command_factory_before + + OnClass *pOnCmd = + new OnClass("On", + Tango::DEV_VOID, Tango::DEV_VOID, + "", + "", + Tango::EXPERT); + command_list.push_back(pOnCmd); + OffClass *pOffCmd = + new OffClass("Off", + Tango::DEV_VOID, Tango::DEV_VOID, + "", + "", + Tango::EXPERT); + command_list.push_back(pOffCmd); + + /*----- PROTECTED REGION ID(Vg::Class::command_factory_after) ENABLED START -----*/ + + /*----- PROTECTED REGION END -----*/ // Vg::Class::command_factory_after + +} + + + + +//=================================================================== +// Dynamic attributes related methods +//=================================================================== + + +//-------------------------------------------------------- +/** + * method : VgClass::create_static_attribute_list + * description : Create the a list of static attributes + * + * @param att_list the ceated attribute list + */ +//-------------------------------------------------------- +void VgClass::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(Vg::Class::create_static_att_list) ENABLED START -----*/ + + /*----- PROTECTED REGION END -----*/ // Vg::Class::create_static_att_list + +} + + +//-------------------------------------------------------- +/** + * method : VgClass::erase_dynamic_attributes + * description : delete the dynamic attributes if any. + * + * @param devlist_ptr the device list pointer + * @param list of all attributes + */ +//-------------------------------------------------------- +void VgClass::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()); + Vg *dev = static_cast<Vg *> (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(Vg::Class::erase_dynamic_attributes) ENABLED START -----*/ + + /*----- PROTECTED REGION END -----*/ // Vg::Class::erase_dynamic_attributes + +} + + + + /*----- PROTECTED REGION ID(Vg::Class::Additional Methods) ENABLED START -----*/ + + /*----- PROTECTED REGION END -----*/ // Vg::Class::Additional Methods + +} // namespace diff --git a/src/VgClass.h b/src/VgClass.h new file mode 100644 index 0000000..b8b4b9d --- /dev/null +++ b/src/VgClass.h @@ -0,0 +1,200 @@ +/*----- PROTECTED REGION ID(VgClass.h) ENABLED START -----*/ +//============================================================================= +// +// file : VgClass.h +// +// description : Include for the VgClass root class. +// This class is the singleton class for. +// the Vg device class.. +// It contains all properties and methods which the . +// Vg requires only once e.g. the commands. +// +// project : Vg. +// +// $Author: lorenzo $ +// +// $Revision: 1.6 $ +// $Date: 2013-06-17 10:30:33 $ +// +// SVN only: +// $HeadURL: $ +// +// CVS only: +// $Source: /home/cvsadm/cvsroot/fermi/servers/vg/src/VgClass.h,v $ +// $Log: VgClass.h,v $ +// Revision 1.6 2013-06-17 10:30:33 lorenzo +// Added DeviceState attribute +// +// Revision 1.5 2013-06-05 15:41:02 lorenzo +// Tango 8.0.5 +// +// Revision 1.4 2012-07-18 09:59:24 mdm +// New version, before test +// +// +//============================================================================= +// This file is generated by POGO +// (Program Obviously used to Generate tango Object) +//============================================================================= + + +#ifndef VGCLASS_H +#define VGCLASS_H + +#include <tango.h> +#include <Vg.h> + +/*----- PROTECTED REGION END -----*/ + +namespace Vg_ns +{ + /*----- PROTECTED REGION ID(Vg::classes for dynamic creation) ENABLED START -----*/ + + /*----- PROTECTED REGION END -----*/ // Vg::classes for dynamic creation + + + +//========================================= +// Define classes for attributes +//========================================= +// Attribute Pressure class definition +class PressureAttrib: public Tango::Attr +{ +public: + PressureAttrib():Attr("Pressure", + Tango::DEV_DOUBLE, Tango::READ) {}; + ~PressureAttrib() {}; + + virtual void read(Tango::DeviceImpl *dev,Tango::Attribute &att) + {(static_cast<Vg *>(dev))->read_Pressure(att);} + virtual bool is_allowed(Tango::DeviceImpl *dev,Tango::AttReqType ty) + {return (static_cast<Vg *>(dev))->is_Pressure_allowed(ty);} +}; + +// Attribute DeviceState class definition +class DeviceStateAttrib: public Tango::Attr +{ +public: + DeviceStateAttrib():Attr("DeviceState", + Tango::DEV_UCHAR, Tango::READ_WRITE) {}; + ~DeviceStateAttrib() {}; + + virtual void read(Tango::DeviceImpl *dev,Tango::Attribute &att) + {(static_cast<Vg *>(dev))->read_DeviceState(att);} + virtual void write(Tango::DeviceImpl *dev,Tango::WAttribute &att) + {(static_cast<Vg *>(dev))->write_DeviceState(att);} + virtual bool is_allowed(Tango::DeviceImpl *dev,Tango::AttReqType ty) + {return (static_cast<Vg *>(dev))->is_DeviceState_allowed(ty);} +}; + + + + + +//========================================= +// Define classes for commands +//========================================= +// Command On class definition +class OnClass : public Tango::Command +{ +public: + OnClass(const char *name, + Tango::CmdArgType in, + Tango::CmdArgType out, + const char *in_desc, + const char *out_desc, + Tango::DispLevel level) + :Command(name,in,out,in_desc,out_desc, level) {}; + + OnClass(const char *name, + Tango::CmdArgType in, + Tango::CmdArgType out) + :Command(name,in,out) {}; + ~OnClass() {}; + + virtual CORBA::Any *execute (Tango::DeviceImpl *dev, const CORBA::Any &any); + virtual bool is_allowed (Tango::DeviceImpl *dev, const CORBA::Any &any) + {return (static_cast<Vg *>(dev))->is_On_allowed(any);} +}; + +// Command Off class definition +class OffClass : public Tango::Command +{ +public: + OffClass(const char *name, + Tango::CmdArgType in, + Tango::CmdArgType out, + const char *in_desc, + const char *out_desc, + Tango::DispLevel level) + :Command(name,in,out,in_desc,out_desc, level) {}; + + OffClass(const char *name, + Tango::CmdArgType in, + Tango::CmdArgType out) + :Command(name,in,out) {}; + ~OffClass() {}; + + virtual CORBA::Any *execute (Tango::DeviceImpl *dev, const CORBA::Any &any); + virtual bool is_allowed (Tango::DeviceImpl *dev, const CORBA::Any &any) + {return (static_cast<Vg *>(dev))->is_Off_allowed(any);} +}; + + + + + +/** + * The TemplateDevServClass singleton definition + */ + +class +#ifdef _TG_WINDOWS_ + __declspec(dllexport) +#endif + VgClass : public Tango::DeviceClass +{ + /*----- PROTECTED REGION ID(Vg::Additionnal DServer data members) ENABLED START -----*/ + + /*----- PROTECTED REGION END -----*/ // Vg::Additionnal DServer data members + + + +public: +// write class properties data members + Tango::DbData cl_prop; + Tango::DbData cl_def_prop; + Tango::DbData dev_def_prop; + +// Method prototypes + static VgClass *init(const char *); + static VgClass *instance(); + ~VgClass(); + Tango::DbDatum get_class_property(string &); + Tango::DbDatum get_default_device_property(string &); + Tango::DbDatum get_default_class_property(string &); + +protected: + VgClass(string &); + static VgClass *_instance; + void command_factory(); + void attribute_factory(vector<Tango::Attr *> &); + void write_class_property(); + void set_default_property(); + void get_class_property(); + string get_cvstag(); + string get_cvsroot(); + +private: + void device_factory(const Tango::DevVarStringArray *); + void create_static_attribute_list(vector<Tango::Attr *> &); + void erase_dynamic_attributes(const Tango::DevVarStringArray *,vector<Tango::Attr *> &); + vector<string> defaultAttList; + + +}; + +} // namespace + +#endif // VGCLASS_H + diff --git a/src/VgStateMachine.cpp b/src/VgStateMachine.cpp new file mode 100644 index 0000000..f98c896 --- /dev/null +++ b/src/VgStateMachine.cpp @@ -0,0 +1,185 @@ +/*----- PROTECTED REGION ID(VgStateMachine.cpp) ENABLED START -----*/ +static const char *RcsId = "$Id: VgStateMachine.cpp,v 1.6 2013-06-17 10:30:33 lorenzo Exp $"; +//============================================================================= +// +// file : VgStateMachine.cpp +// +// description : C++ source for the «name» and its alowed +// methods for commands and attributes +// +// project : Vg. +// +// $Author: lorenzo $ +// +// $Revision: 1.6 $ +// $Date: 2013-06-17 10:30:33 $ +// +// SVN only: +// $HeadURL: $ +// +// CVS only: +// $Source: /home/cvsadm/cvsroot/fermi/servers/vg/src/VgStateMachine.cpp,v $ +// $Log: VgStateMachine.cpp,v $ +// Revision 1.6 2013-06-17 10:30:33 lorenzo +// Added DeviceState attribute +// +// Revision 1.5 2013-06-05 15:41:02 lorenzo +// Tango 8.0.5 +// +// Revision 1.4 2012-07-18 09:59:24 mdm +// New version, before test +// +// +//============================================================================= +// This file is generated by POGO +// (Program Obviously used to Generate tango Object) +//============================================================================= + + + +#include <Vg.h> +#include <VgClass.h> + +/*----- PROTECTED REGION END -----*/ + + +/* + * Vg states description: + * + * ON : + * OFF : + * ALARM : + * DISABLE : + * FAULT : + */ + +namespace Vg_ns +{ + +//================================================= +// Attributes Allowed Methods +//================================================= + +//-------------------------------------------------------- +/** + * Method : Vg::is_PressureState_allowed() + * Description : Execution allowed for Pressure attribute. + */ +//-------------------------------------------------------- + +bool Vg::is_Pressure_allowed(Tango::AttReqType type) +{ + if ( // Compare device state with not allowed states for READ + get_state() == Tango::OFF || + get_state() == Tango::DISABLE || + get_state() == Tango::FAULT) + { + + /*----- PROTECTED REGION ID(Vg::read_PressureStateAllowed_READ) ENABLED START -----*/ + + /*----- PROTECTED REGION END -----*/ // Vg::read_PressureStateAllowed_READ + + return false; + } + return true; +} + +//-------------------------------------------------------- +/** + * Method : Vg::is_DeviceStateState_allowed() + * Description : Execution allowed for DeviceState attribute. + */ +//-------------------------------------------------------- + +bool Vg::is_DeviceState_allowed(Tango::AttReqType type) +{ + // Check if access type. + if ( type!=Tango::READ_REQ ) + { + // Not any excluded states for DeviceState attribute in WRITE access. + + /*----- PROTECTED REGION ID(Vg::DeviceStateStateAllowed_WRITE) ENABLED START -----*/ + + /*----- PROTECTED REGION END -----*/ // Vg::DeviceStateStateAllowed_WRITE + + return true; + } + else + // Not any excluded states for DeviceState attribute in READ access. + + /*----- PROTECTED REGION ID(Vg::read_DeviceStateStateAllowed_READ) ENABLED START -----*/ + + /*----- PROTECTED REGION END -----*/ // Vg::read_DeviceStateStateAllowed_READ + + return true; +} + + + /*----- PROTECTED REGION ID(Vg::are_dynamic_attributes_allowed) ENABLED START -----*/ + + // Add your code to check if dynamic attributes are alowed + + /*----- PROTECTED REGION END -----*/ // Vg::are_dynamic_attributes_allowed + + +//================================================= +// Commands Allowed Methods +//================================================= + + +//-------------------------------------------------------- +/** + * Method : Vg::is_OnState_allowed() + * Description : Execution allowed for On command. + */ +//-------------------------------------------------------- + +bool Vg::is_On_allowed(const CORBA::Any &any) +{ + if ( // Compare device state with not allowed states for command + get_state() == Tango::ON || + get_state() == Tango::DISABLE || + get_state() == Tango::FAULT) + { + + /*----- PROTECTED REGION ID(Vg::OnStateAllowed) ENABLED START -----*/ + + /*----- PROTECTED REGION END -----*/ // Vg::OnStateAllowed + + return false; + } + return true; +} + +//-------------------------------------------------------- +/** + * Method : Vg::is_OffState_allowed() + * Description : Execution allowed for Off command. + */ +//-------------------------------------------------------- + +bool Vg::is_Off_allowed(const CORBA::Any &any) +{ + if ( // Compare device state with not allowed states for command + get_state() == Tango::OFF || + get_state() == Tango::DISABLE || + get_state() == Tango::FAULT) + { + + /*----- PROTECTED REGION ID(Vg::OffStateAllowed) ENABLED START -----*/ + + /*----- PROTECTED REGION END -----*/ // Vg::OffStateAllowed + + return false; + } + return true; +} + + + /*----- PROTECTED REGION ID(Vg::are_dynamic_commands_allowed) ENABLED START -----*/ + + // Add your code to check if dynamic commands are alowed + + /*----- PROTECTED REGION END -----*/ // Vg::are_dynamic_commands_allowed + +} // namespace Vg_ns diff --git a/src/devicestate.h b/src/devicestate.h new file mode 100644 index 0000000..b5233dd --- /dev/null +++ b/src/devicestate.h @@ -0,0 +1,21 @@ +/* + * devicestate.h + * + * LP - 2013.01.03 + */ + +#ifndef DEVICESTATE_H +#define DEVICESTATE_H + +typedef enum { + UNKNOWN, + ONLINE, + OFFLINE, + SERVICE, + TEST, + DEVICESTATE_T_SIZE +} devicestate_t; + +#endif /* DEVICESTATE_H */ + +/* EOF */ diff --git a/src/main.cpp b/src/main.cpp new file mode 100644 index 0000000..4456eae --- /dev/null +++ b/src/main.cpp @@ -0,0 +1,73 @@ +/*PROTECTED REGION ID(Vg::main.cpp) ENABLED START*/ +static const char *RcsId = "$Id: main.cpp,v 1.2 2012-07-18 09:59:24 mdm Exp $"; +//============================================================================= +// +// file : Vg.cpp +// +// description : C++ source for the Vg device server main. +// The main rule is to initialise (and create) the Tango +// system and to create the DServerClass singleton. +// The main should be the same for every Tango device server. +// +// project : Vg. +// +// $Author: mdm $ +// +// $Revision: 1.2 $ +// $Date: 2012-07-18 09:59:24 $ +// +// SVN only: +// $HeadURL: $ +// +// CVS only: +// $Source: /home/cvsadm/cvsroot/fermi/servers/vg/src/main.cpp,v $ +// $Log: main.cpp,v $ +// Revision 1.2 2012-07-18 09:59:24 mdm +// New version, before test +// +// +//============================================================================= +// This file is generated by POGO +// (Program Obviously used to Generate tango Object) +//============================================================================= + +#include <tango.h> + + +int main(int argc,char *argv[]) +{ + Tango::Util *tg = NULL; + try + { + // Initialise the device server + //---------------------------------------- + tg = Tango::Util::init(argc,argv); + + // Create the device server singleton + // which will create everything + //---------------------------------------- + tg->server_init(false); + + // Run the endless loop + //---------------------------------------- + cout << "Ready to accept request" << endl; + tg->server_run(); + } + catch (bad_alloc) + { + cout << "Can't allocate memory to store device object !!!" << endl; + cout << "Exiting" << endl; + } + catch (CORBA::Exception &e) + { + Tango::Except::print_exception(e); + + cout << "Received a CORBA_Exception" << endl; + cout << "Exiting" << endl; + } + if (tg!=NULL) + tg->server_cleanup(); + return(0); +} +/*PROTECTED REGION END*/ +//======================================================== -- GitLab