From 5ed0c930ba54d734bc2ff358fa026461b3583e0d Mon Sep 17 00:00:00 2001 From: Claudio Scafuri <claudio.scafuri@elettra.eu> Date: Mon, 6 Jul 2020 14:35:55 +0200 Subject: [PATCH] imported from cvs repo AbstarctClasses7/SupervisedID release_04 --- ClassFactory.cpp | 56 +++++++ SupervisedID.cpp | 226 ++++++++++++++++++++++++++ SupervisedID.h | 194 +++++++++++++++++++++++ SupervisedID.xmi | 63 ++++++++ SupervisedIDClass.cpp | 298 +++++++++++++++++++++++++++++++++++ SupervisedIDClass.h | 102 ++++++++++++ SupervisedIDStateMachine.cpp | 114 ++++++++++++++ 7 files changed, 1053 insertions(+) create mode 100644 ClassFactory.cpp create mode 100644 SupervisedID.cpp create mode 100644 SupervisedID.h create mode 100644 SupervisedID.xmi create mode 100644 SupervisedIDClass.cpp create mode 100644 SupervisedIDClass.h create mode 100644 SupervisedIDStateMachine.cpp diff --git a/ClassFactory.cpp b/ClassFactory.cpp new file mode 100644 index 0000000..e11b119 --- /dev/null +++ b/ClassFactory.cpp @@ -0,0 +1,56 @@ +/*----- PROTECTED REGION ID(SupervisedID::ClassFactory.cpp) ENABLED START -----*/ +static const char *RcsId = "$Id: ClassFactory.cpp,v 1.1 2014-04-23 08:48:47 claudio 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 : Supervised ID: common interface for supervised insertion devices +// +// This file is part of Tango device class. +// +// Tango is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// Tango is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with Tango. If not, see <http://www.gnu.org/licenses/>. +// +// $Author: claudio $ +// +// $Revision: 1.1 $ +// $Date: 2014-04-23 08:48:47 $ +// +// $HeadURL: $ +// +//============================================================================= +// This file is generated by POGO +// (Program Obviously used to Generate tango Object) +//============================================================================= + +#include <tango.h> +#include <SupervisedIDClass.h> + +// Add class header files if needed + + +/** + * Create SupervisedID Class singleton and store it in DServer object. + */ + +void Tango::DServer::class_factory() +{ + // Add method class init if needed + add_class(SupervisedID_ns::SupervisedIDClass::init("SupervisedID")); +} +/*----- PROTECTED REGION END -----*/ // SupervisedID::ClassFactory.cpp diff --git a/SupervisedID.cpp b/SupervisedID.cpp new file mode 100644 index 0000000..c5aa89f --- /dev/null +++ b/SupervisedID.cpp @@ -0,0 +1,226 @@ +/*----- PROTECTED REGION ID(SupervisedID.cpp) ENABLED START -----*/ +static const char *RcsId = "$Id: SupervisedID.cpp,v 1.2 2014-04-14 14:51:54 claudio Exp $"; +//============================================================================= +// +// file : SupervisedID.cpp +// +// description : C++ source for the SupervisedID 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 +// SupervisedID are implemented in this file. +// +// project : Supervised ID: common interface for supervised insertion devices. +// +// $Author: claudio $ +// +// $Revision: 1.2 $ +// $Date: 2014-04-14 14:51:54 $ +// +// SVN only: +// $HeadURL: $ +// +// CVS only: +// $Source: /home/cvsadm/cvsroot/AbstractClasses7/SupervisedID/SupervisedID.cpp,v $ +// $Log: SupervisedID.cpp,v $ +// Revision 1.2 2014-04-14 14:51:54 claudio +// for 8.1.2.c and pogo-8 +// +// Revision 1.1.1.1 2012-03-05 14:01:56 claudio +// frist import +// +// +//============================================================================= +// This file is generated by POGO +// (Program Obviously used to Generate tango Object) +//============================================================================= + + +#include <SupervisedID.h> +#include <SupervisedIDClass.h> + +/*----- PROTECTED REGION END -----*/ // SupervisedID.cpp + +/** + * SupervisedID class description: + * This abstract class incapsulates the common interface for insertion devices used + * under ID supervisor. The "supervisor" can inhibi/allow the operations on the insertion device + * and impose limits on the permited range. + */ + +//================================================================ +// The following table gives the correspondence +// between command and method names. +// +// Command name | Method name +//================================================================ +// State | Inherited (no method) +// Status | Inherited (no method) +//================================================================ + +//================================================================ +// Attributes managed are: +//================================================================ +// Enabled | Tango::DevBoolean Scalar +// Ready | Tango::DevBoolean Scalar +// StatRF | Tango::DevBoolean Spectrum ( max = 32) +//================================================================ + +namespace SupervisedID_ns +{ +/*----- PROTECTED REGION ID(SupervisedID::namespace_starting) ENABLED START -----*/ + + // static initializations + + /*----- PROTECTED REGION END -----*/ // SupervisedID::namespace_starting + +//-------------------------------------------------------- +/** + * Method : SupervisedID::SupervisedID() + * Description : Constructors for a Tango device + * implementing the classSupervisedID + */ +//-------------------------------------------------------- +SupervisedID::SupervisedID(Tango::DeviceClass *cl, string &s) + : TANGO_BASE_CLASS(cl, s.c_str()) +{ + /*----- PROTECTED REGION ID(SupervisedID::constructor_1) ENABLED START -----*/ + + init_device(); + + /*----- PROTECTED REGION END -----*/ // SupervisedID::constructor_1 +} +//-------------------------------------------------------- +SupervisedID::SupervisedID(Tango::DeviceClass *cl, const char *s) + : TANGO_BASE_CLASS(cl, s) +{ + /*----- PROTECTED REGION ID(SupervisedID::constructor_2) ENABLED START -----*/ + + init_device(); + + /*----- PROTECTED REGION END -----*/ // SupervisedID::constructor_2 +} +//-------------------------------------------------------- +SupervisedID::SupervisedID(Tango::DeviceClass *cl, const char *s, const char *d) + : TANGO_BASE_CLASS(cl, s, d) +{ + /*----- PROTECTED REGION ID(SupervisedID::constructor_3) ENABLED START -----*/ + + init_device(); + + /*----- PROTECTED REGION END -----*/ // SupervisedID::constructor_3 +} + +//-------------------------------------------------------- +/** + * Method : SupervisedID::delete_device() + * Description : will be called at device destruction or at init command + */ +//-------------------------------------------------------- +void SupervisedID::delete_device() +{ + DEBUG_STREAM << "SupervisedID::delete_device() " << device_name << endl; + /*----- PROTECTED REGION ID(SupervisedID::delete_device) ENABLED START -----*/ + + // Delete device allocated objects + + /*----- PROTECTED REGION END -----*/ // SupervisedID::delete_device +} + +//-------------------------------------------------------- +/** + * Method : SupervisedID::init_device() + * Description : will be called at device initialization. + */ +//-------------------------------------------------------- +void SupervisedID::init_device() +{ + DEBUG_STREAM << "SupervisedID::init_device() create device " << device_name << endl; + /*----- PROTECTED REGION ID(SupervisedID::init_device_before) ENABLED START -----*/ + + // Initialization before get_device_property() call + + /*----- PROTECTED REGION END -----*/ // SupervisedID::init_device_before + + // No device property to be read from database + + + /*----- PROTECTED REGION ID(SupervisedID::init_device) ENABLED START -----*/ + + // Initialize device + + /*----- PROTECTED REGION END -----*/ // SupervisedID::init_device +} + + +//-------------------------------------------------------- +/** + * Method : SupervisedID::always_executed_hook() + * Description : method always executed before any command is executed + */ +//-------------------------------------------------------- +void SupervisedID::always_executed_hook() +{ + INFO_STREAM << "SupervisedID::always_executed_hook() " << device_name << endl; + /*----- PROTECTED REGION ID(SupervisedID::always_executed_hook) ENABLED START -----*/ + + // code always executed before all requests + + /*----- PROTECTED REGION END -----*/ // SupervisedID::always_executed_hook +} + +//-------------------------------------------------------- +/** + * Method : SupervisedID::read_attr_hardware() + * Description : Hardware acquisition for attributes + */ +//-------------------------------------------------------- +void SupervisedID::read_attr_hardware(TANGO_UNUSED(vector<long> &attr_list)) +{ + DEBUG_STREAM << "SupervisedID::read_attr_hardware(vector<long> &attr_list) entering... " << endl; + /*----- PROTECTED REGION ID(SupervisedID::read_attr_hardware) ENABLED START -----*/ + + // Add your own code + + /*----- PROTECTED REGION END -----*/ // SupervisedID::read_attr_hardware +} +//-------------------------------------------------------- +/** + * Method : SupervisedID::write_attr_hardware() + * Description : Hardware writing for attributes + */ +//-------------------------------------------------------- +void SupervisedID::write_attr_hardware(TANGO_UNUSED(vector<long> &attr_list)) +{ + DEBUG_STREAM << "SupervisedID::write_attr_hardware(vector<long> &attr_list) entering... " << endl; + /*----- PROTECTED REGION ID(SupervisedID::write_attr_hardware) ENABLED START -----*/ + + // Add your own code + + /*----- PROTECTED REGION END -----*/ // SupervisedID::write_attr_hardware +} + + +//-------------------------------------------------------- +/** + * Method : SupervisedID::add_dynamic_attributes() + * Description : Create the dynamic attributes if any + * for specified device. + */ +//-------------------------------------------------------- +void SupervisedID::add_dynamic_attributes() +{ + /*----- PROTECTED REGION ID(SupervisedID::add_dynamic_attributes) ENABLED START -----*/ + + // Add your own code to create and add dynamic attributes if any + + /*----- PROTECTED REGION END -----*/ // SupervisedID::add_dynamic_attributes +} + + +/*----- PROTECTED REGION ID(SupervisedID::namespace_ending) ENABLED START -----*/ + + // Additional Methods + + /*----- PROTECTED REGION END -----*/ // SupervisedID::namespace_ending +} // namespace diff --git a/SupervisedID.h b/SupervisedID.h new file mode 100644 index 0000000..6ad1865 --- /dev/null +++ b/SupervisedID.h @@ -0,0 +1,194 @@ +/*----- PROTECTED REGION ID(SupervisedID.h) ENABLED START -----*/ +//============================================================================= +// +// file : SupervisedID.h +// +// description : Include for the SupervisedID class. +// +// project : Supervised ID: common interface for supervised insertion devices. +// +// $Author: claudio $ +// +// $Revision: 1.2 $ +// $Date: 2014-04-14 14:51:54 $ +// +// SVN only: +// $HeadURL: $ +// +// CVS only: +// $Source: /home/cvsadm/cvsroot/AbstractClasses7/SupervisedID/SupervisedID.h,v $ +// $Log: SupervisedID.h,v $ +// Revision 1.2 2014-04-14 14:51:54 claudio +// for 8.1.2.c and pogo-8 +// +// Revision 1.1.1.1 2012-03-05 14:01:56 claudio +// frist import +// +// +//============================================================================= +// This file is generated by POGO +// (Program Obviously used to Generate tango Object) +//============================================================================= + + +#ifndef SUPERVISEDID_H +#define SUPERVISEDID_H + + +#include <tango.h> + +/*----- PROTECTED REGION END -----*/ // SupervisedID.h + +/** + * SupervisedID class description: + * This abstract class incapsulates the common interface for insertion devices used + * under ID supervisor. The "supervisor" can inhibi/allow the operations on the insertion device + * and impose limits on the permited range. + */ + +namespace SupervisedID_ns +{ +/*----- PROTECTED REGION ID(SupervisedID::Additional Class Declarations) ENABLED START -----*/ + + // Additional Class Declarations + + /*----- PROTECTED REGION END -----*/ // SupervisedID::Additional Class Declarations + +class SupervisedID : public TANGO_BASE_CLASS +{ + +/*----- PROTECTED REGION ID(SupervisedID::Data Members) ENABLED START -----*/ + + // Add your own data members + + /*----- PROTECTED REGION END -----*/ // SupervisedID::Data Members + + +// Attribute data members +public: + +// Constructors and destructors +public: + /** + * Constructs a newly device object. + * + * @param cl Class. + * @param s Device Name + */ + SupervisedID(Tango::DeviceClass *cl,string &s); + /** + * Constructs a newly device object. + * + * @param cl Class. + * @param s Device Name + */ + SupervisedID(Tango::DeviceClass *cl,const char *s); + /** + * Constructs a newly device object. + * + * @param cl Class. + * @param s Device name + * @param d Device description. + */ + SupervisedID(Tango::DeviceClass *cl,const char *s,const char *d); + /** + * The device object destructor. + */ + ~SupervisedID() {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(); + /* + * Always executed method before execution command method. + */ + virtual void always_executed_hook(); + + +// Attribute methods +public: + //-------------------------------------------------------- + /* + * Method : SupervisedID::read_attr_hardware() + * Description : Hardware acquisition for attributes. + */ + //-------------------------------------------------------- + virtual void read_attr_hardware(vector<long> &attr_list); + //-------------------------------------------------------- + /* + * Method : SupervisedID::write_attr_hardware() + * Description : Hardware writing for attributes. + */ + //-------------------------------------------------------- + virtual void write_attr_hardware(vector<long> &attr_list); + +/** + * Attribute Enabled related methods + * Description: True when + * + * Data type: Tango::DevBoolean + * Attr type: Scalar + */ + virtual void read_Enabled(Tango::Attribute &attr) = 0; + virtual void write_Enabled(Tango::WAttribute &attr) = 0; + virtual bool is_Enabled_allowed(Tango::AttReqType type); +/** + * Attribute Ready related methods + * Description: true when operating condtions of the ID make it operable by the beamlines: + * - good flags and in range. + * + * Data type: Tango::DevBoolean + * Attr type: Scalar + */ + virtual void read_Ready(Tango::Attribute &attr) = 0; + virtual bool is_Ready_allowed(Tango::AttReqType type); +/** + * Attribute StatRF related methods + * Description: bit mask for compatibility with old style software + * Holds the ready and enabled bits together + * + * Data type: Tango::DevBoolean + * Attr type: Spectrum max = 32 + */ + virtual void read_StatRF(Tango::Attribute &attr) = 0; + virtual bool is_StatRF_allowed(Tango::AttReqType type); + + + //-------------------------------------------------------- + /** + * Method : SupervisedID::add_dynamic_attributes() + * Description : Add dynamic attributes if any. + */ + //-------------------------------------------------------- + void add_dynamic_attributes(); + + + +// Command related methods +public: + + +/*----- PROTECTED REGION ID(SupervisedID::Additional Method prototypes) ENABLED START -----*/ + + // Additional Method prototypes + + /*----- PROTECTED REGION END -----*/ // SupervisedID::Additional Method prototypes +}; + +/*----- PROTECTED REGION ID(SupervisedID::Additional Classes Definitions) ENABLED START -----*/ + + // Additional Classes definitions + + /*----- PROTECTED REGION END -----*/ // SupervisedID::Additional Classes Definitions + +} // End of namespace + +#endif // SupervisedID_H diff --git a/SupervisedID.xmi b/SupervisedID.xmi new file mode 100644 index 0000000..cc61afb --- /dev/null +++ b/SupervisedID.xmi @@ -0,0 +1,63 @@ +<?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="SupervisedID" pogoRevision="8.3"> + <description description="This abstract class incapsulates the common interface for insertion devices used
under ID supervisor. The "supervisor" can inhibi/allow the operations on the insertion device
and impose limits on the permited range." title="Supervised ID: common interface for supervised insertion devices" sourcePath="/home/claudio/devel/AbstractClasses7/SupervisedID" language="Cpp" filestogenerate="XMI file,Code files" hasMandatoryProperty="false" hasConcreteProperty="false" hasAbstractCommand="false" hasAbstractAttribute="true"> + <inheritances classname="Device_4Impl" sourcePath=""/> + <identification contact="at elettra.trieste.it - claudio.scafuri" author="claudio.scafuri" emailDomain="elettra.trieste.it" classFamily="Controllers" siteSpecific="" platform="All Platforms" bus="Not Applicable" manufacturer="none" reference=""/> + </description> + <commands name="State" description="This command gets the device state (stored in its <i>device_state</i> data member) and returns it to the caller." execMethod="dev_state" displayLevel="OPERATOR" polledPeriod="0"> + <argin description="none."> + <type xsi:type="pogoDsl:VoidType"/> + </argin> + <argout description="State Code"> + <type xsi:type="pogoDsl:StateType"/> + </argout> + <status abstract="true" inherited="true" concrete="true" concreteHere="false"/> + </commands> + <commands name="Status" description="This command gets the device status (stored in its <i>device_status</i> data member) and returns it to the caller." execMethod="dev_status" displayLevel="OPERATOR" polledPeriod="0"> + <argin description="none."> + <type xsi:type="pogoDsl:VoidType"/> + </argin> + <argout description="Status description"> + <type xsi:type="pogoDsl:ConstStringType"/> + </argout> + <status abstract="true" inherited="true" concrete="true" concreteHere="false"/> + </commands> + <attributes name="Enabled" attType="Scalar" rwType="READ_WRITE" displayLevel="OPERATOR" polledPeriod="2000" maxX="0" maxY="0" allocReadMember="false" isDynamic="false"> + <dataType xsi:type="pogoDsl:BooleanType"/> + <changeEvent fire="false" libCheckCriteria="false"/> + <archiveEvent fire="false" libCheckCriteria="false"/> + <dataReadyEvent fire="false" libCheckCriteria="true"/> + <status abstract="true" concrete="false" concreteHere="false"/> + <properties description="True when" label="Enabled" unit="" standardUnit="" displayUnit="" format="" maxValue="" minValue="" maxAlarm="" minAlarm="" maxWarning="" minWarning="" deltaTime="" deltaValue=""/> + </attributes> + <attributes name="Ready" attType="Scalar" rwType="READ" displayLevel="OPERATOR" polledPeriod="2000" maxX="0" maxY="0" allocReadMember="false" isDynamic="false"> + <dataType xsi:type="pogoDsl:BooleanType"/> + <dataReadyEvent fire="false" libCheckCriteria="true"/> + <status abstract="true" concrete="false" concreteHere="false"/> + <properties description="true when operating condtions of the ID make it operable by the beamlines:
- good flags and in range." label="ready" unit="" standardUnit="" displayUnit="" format="" maxValue="" minValue="" maxAlarm="" minAlarm="" maxWarning="" minWarning="" deltaTime="" deltaValue=""/> + </attributes> + <attributes name="StatRF" attType="Spectrum" rwType="READ" displayLevel="OPERATOR" polledPeriod="2000" maxX="32" maxY="0" allocReadMember="false" isDynamic="false"> + <dataType xsi:type="pogoDsl:BooleanType"/> + <dataReadyEvent fire="false" libCheckCriteria="true"/> + <status abstract="true" concrete="false" concreteHere="false"/> + <properties description="bit mask for compatibility with old style software
Holds the ready and enabled bits together" label="" unit="" standardUnit="" displayUnit="" format="" maxValue="" minValue="" maxAlarm="" minAlarm="" maxWarning="" minWarning="" deltaTime="" deltaValue=""/> + </attributes> + <states name="ON" description="Device OK"> + <status abstract="false" inherited="false" concrete="true" concreteHere="true"/> + </states> + <states name="FAULT" description="Device not working - broken ID"> + <status abstract="false" inherited="false" concrete="true" concreteHere="true"/> + </states> + <states name="UNKNOWN" description="Device not working - unknow reason/condition"> + <status abstract="false" inherited="false" concrete="true" concreteHere="true"/> + </states> + <states name="RUNNING" description="Device gap is moving"> + <status abstract="false" inherited="false" concrete="true" concreteHere="true"/> + </states> + <states name="DISABLE" description="Device not remotely operable"> + <status abstract="false" inherited="false" concrete="true" concreteHere="true"/> + </states> + <preferences docHome="./doc_html" makefileHome="/usr/local/tango-8.1.2.c/share/pogo/preferences"/> + </classes> +</pogoDsl:PogoSystem> diff --git a/SupervisedIDClass.cpp b/SupervisedIDClass.cpp new file mode 100644 index 0000000..663cb33 --- /dev/null +++ b/SupervisedIDClass.cpp @@ -0,0 +1,298 @@ +/*----- PROTECTED REGION ID(SupervisedIDClass.cpp) ENABLED START -----*/ +static const char *RcsId = "$Id: SupervisedIDClass.cpp,v 1.2 2014-04-14 14:51:54 claudio Exp $"; +static const char *TagName = "$Name: $"; +static const char *CvsPath = "$Source: /home/cvsadm/cvsroot/AbstractClasses7/SupervisedID/SupervisedIDClass.cpp,v $"; +static const char *SvnPath = "$HeadURL: $"; +static const char *HttpServer = "http://www.esrf.eu/computing/cs/tango/tango_doc/ds_doc/"; +//============================================================================= +// +// file : SupervisedIDClass.cpp +// +// description : C++ source for the SupervisedIDClass. A singleton +// class derived from DeviceClass. It implements the +// command list and all properties and methods required +// by the «name» once per process. +// +// project : Supervised ID: common interface for supervised insertion devices. +// +// $Author: claudio $ +// +// $Revision: 1.2 $ +// $Date: 2014-04-14 14:51:54 $ +// +// SVN only: +// $HeadURL: $ +// +// CVS only: +// $Source: /home/cvsadm/cvsroot/AbstractClasses7/SupervisedID/SupervisedIDClass.cpp,v $ +// $Log: SupervisedIDClass.cpp,v $ +// Revision 1.2 2014-04-14 14:51:54 claudio +// for 8.1.2.c and pogo-8 +// +// Revision 1.1.1.1 2012-03-05 14:01:56 claudio +// frist import +// +// +//============================================================================= +// This file is generated by POGO +// (Program Obviously used to Generate tango Object) +//============================================================================= + + +#include <SupervisedIDClass.h> + +/*----- PROTECTED REGION END -----*/ // SupervisedIDClass.cpp + +//------------------------------------------------------------------- +/** + * Create SupervisedIDClass singleton and + * return it in a C function for Python usage + */ +//------------------------------------------------------------------- +extern "C" { +#ifdef _TG_WINDOWS_ + +__declspec(dllexport) + +#endif + + Tango::DeviceClass *_create_SupervisedID_class(const char *name) { + return SupervisedID_ns::SupervisedIDClass::init(name); + } +} + +namespace SupervisedID_ns +{ +//=================================================================== +// Initialize pointer for singleton pattern +//=================================================================== +SupervisedIDClass *SupervisedIDClass::_instance = NULL; + +//-------------------------------------------------------- +/** + * method : SupervisedIDClass::SupervisedIDClass(string &s) + * description : constructor for the SupervisedIDClass + * + * @param s The class name + */ +//-------------------------------------------------------- +SupervisedIDClass::SupervisedIDClass(string &s):Tango::DeviceClass(s) +{ + cout2 << "Entering SupervisedIDClass constructor" << endl; + set_default_property(); + write_class_property(); + + /*----- PROTECTED REGION ID(SupervisedIDClass::constructor) ENABLED START -----*/ + + /*----- PROTECTED REGION END -----*/ // SupervisedIDClass::constructor + + cout2 << "Leaving SupervisedIDClass constructor" << endl; +} + +//-------------------------------------------------------- +/** + * method : SupervisedIDClass::~SupervisedIDClass() + * description : destructor for the SupervisedIDClass + */ +//-------------------------------------------------------- +SupervisedIDClass::~SupervisedIDClass() +{ + /*----- PROTECTED REGION ID(SupervisedIDClass::destructor) ENABLED START -----*/ + + /*----- PROTECTED REGION END -----*/ // SupervisedIDClass::destructor + + _instance = NULL; +} + + +//-------------------------------------------------------- +/** + * method : SupervisedIDClass::init + * description : Create the object if not already done. + * Otherwise, just return a pointer to the object + * + * @param name The class name + */ +//-------------------------------------------------------- +SupervisedIDClass *SupervisedIDClass::init(const char *name) +{ + if (_instance == NULL) + { + try + { + string s(name); + _instance = new SupervisedIDClass(s); + } + catch (bad_alloc &) + { + throw; + } + } + return _instance; +} + +//-------------------------------------------------------- +/** + * method : SupervisedIDClass::instance + * description : Check if object already created, + * and return a pointer to the object + */ +//-------------------------------------------------------- +SupervisedIDClass *SupervisedIDClass::instance() +{ + if (_instance == NULL) + { + cerr << "Class is not initialised !!" << endl; + exit(-1); + } + return _instance; +} + + + +//=================================================================== +// Command execution method calls +//=================================================================== + +//=================================================================== +// Properties management +//=================================================================== +//-------------------------------------------------------- +/** + * Method : SupervisedIDClass::get_class_property() + * Description : Get the class property for specified name. + */ +//-------------------------------------------------------- +Tango::DbDatum SupervisedIDClass::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 : SupervisedIDClass::get_default_device_property() + * Description : Return the default value for device property. + */ +//-------------------------------------------------------- +Tango::DbDatum SupervisedIDClass::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 : SupervisedIDClass::get_default_class_property() + * Description : Return the default value for class property. + */ +//-------------------------------------------------------- +Tango::DbDatum SupervisedIDClass::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 : SupervisedIDClass::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 SupervisedIDClass::set_default_property() +{ + string prop_name; + string prop_desc; + string prop_def; + vector<string> vect_data; + + // Set Default Class Properties + + // Set Default device Properties +} + +//-------------------------------------------------------- +/** + * Method : SupervisedIDClass::write_class_property() + * Description : Set class description fields as property in database + */ +//-------------------------------------------------------- +void SupervisedIDClass::write_class_property() +{ +} + +//=================================================================== +// Factory methods +//=================================================================== + +//-------------------------------------------------------- +/** + * Method : SupervisedIDClass::device_factory() + * Description : Create the device object(s) + * and store them in the device list + */ +//-------------------------------------------------------- +void SupervisedIDClass::device_factory(const Tango::DevVarStringArray *devlist_ptr) +{ +// This class is not concrete and cannot implement devices +} +//-------------------------------------------------------- +/** + * Method : SupervisedIDClass::attribute_factory() + * Description : Create the attribute object(s) + * and store them in the attribute list + */ +//-------------------------------------------------------- +void SupervisedIDClass::attribute_factory(vector<Tango::Attr *> &att_list) +{ + /*----- PROTECTED REGION ID(SupervisedIDClass::attribute_factory_before) ENABLED START -----*/ + + // Add your own code + + /*----- PROTECTED REGION END -----*/ // SupervisedIDClass::attribute_factory_before + + + + /*----- PROTECTED REGION ID(SupervisedIDClass::attribute_factory_after) ENABLED START -----*/ + + // Add your own code + + /*----- PROTECTED REGION END -----*/ // SupervisedIDClass::attribute_factory_after +} +//-------------------------------------------------------- +/** + * Method : SupervisedIDClass::command_factory() + * Description : Create the command object(s) + * and store them in the command list + */ +//-------------------------------------------------------- +void SupervisedIDClass::command_factory() +{ + /*----- PROTECTED REGION ID(SupervisedIDClass::command_factory_before) ENABLED START -----*/ + + /*----- PROTECTED REGION END -----*/ // SupervisedIDClass::command_factory_before + + + /*----- PROTECTED REGION ID(SupervisedIDClass::command_factory_after) ENABLED START -----*/ + + /*----- PROTECTED REGION END -----*/ // SupervisedIDClass::command_factory_after +} + + +/*----- PROTECTED REGION ID(SupervisedIDClass::Additional Methods) ENABLED START -----*/ + + /*----- PROTECTED REGION END -----*/ // SupervisedIDClass::Additional Methods +} // namespace diff --git a/SupervisedIDClass.h b/SupervisedIDClass.h new file mode 100644 index 0000000..25d7c94 --- /dev/null +++ b/SupervisedIDClass.h @@ -0,0 +1,102 @@ +/*----- PROTECTED REGION ID(SupervisedIDClass.h) ENABLED START -----*/ +//============================================================================= +// +// file : SupervisedIDClass.h +// +// description : Include for the SupervisedIDClass root class. +// This class is the singleton class for. +// the SupervisedID device class.. +// It contains all properties and methods which the . +// SupervisedID requires only once e.g. the commands. +// +// project : Supervised ID: common interface for supervised insertion devices. +// +// $Author: claudio $ +// +// $Revision: 1.2 $ +// $Date: 2014-04-14 14:51:54 $ +// +// SVN only: +// $HeadURL: $ +// +// CVS only: +// $Source: /home/cvsadm/cvsroot/AbstractClasses7/SupervisedID/SupervisedIDClass.h,v $ +// $Log: SupervisedIDClass.h,v $ +// Revision 1.2 2014-04-14 14:51:54 claudio +// for 8.1.2.c and pogo-8 +// +// Revision 1.1.1.1 2012-03-05 14:01:56 claudio +// frist import +// +// +//============================================================================= +// This file is generated by POGO +// (Program Obviously used to Generate tango Object) +//============================================================================= + + +#ifndef SUPERVISEDIDCLASS_H +#define SUPERVISEDIDCLASS_H + +#include <tango.h> +#include <SupervisedID.h> + +/*----- PROTECTED REGION END -----*/ // SupervisedIDClass.h + + +namespace SupervisedID_ns +{ +/*----- PROTECTED REGION ID(SupervisedIDClass::classes for dynamic creation) ENABLED START -----*/ + + /*----- PROTECTED REGION END -----*/ // SupervisedIDClass::classes for dynamic creation + +//========================================= +// Define classes for attributes +//========================================= + +/** + * The SupervisedIDClass singleton definition + */ + +#ifdef _TG_WINDOWS_ +class __declspec(dllexport) SupervisedIDClass : public Tango::DeviceClass +#else +class SupervisedIDClass : public Tango::DeviceClass +#endif +{ + /*----- PROTECTED REGION ID(SupervisedIDClass::Additionnal DServer data members) ENABLED START -----*/ + + /*----- PROTECTED REGION END -----*/ // SupervisedIDClass::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 SupervisedIDClass *init(const char *); + static SupervisedIDClass *instance(); + ~SupervisedIDClass(); + Tango::DbDatum get_class_property(string &); + Tango::DbDatum get_default_device_property(string &); + Tango::DbDatum get_default_class_property(string &); + + protected: + SupervisedIDClass(string &); + static SupervisedIDClass *_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 *); +}; + +} // End of namespace + +#endif // SupervisedID_H diff --git a/SupervisedIDStateMachine.cpp b/SupervisedIDStateMachine.cpp new file mode 100644 index 0000000..d41f8cf --- /dev/null +++ b/SupervisedIDStateMachine.cpp @@ -0,0 +1,114 @@ +/*----- PROTECTED REGION ID(SupervisedIDStateMachine.cpp) ENABLED START -----*/ +static const char *RcsId = "$Id: SupervisedIDStateMachine.cpp,v 1.2 2014-04-14 14:52:01 claudio Exp $"; +//============================================================================= +// +// file : SupervisedIDStateMachine.cpp +// +// description : C++ source for the SupervisedID and its alowed +// methods for commands and attributes +// +// project : Supervised ID: common interface for supervised insertion devices. +// +// $Author: claudio $ +// +// $Revision: 1.2 $ +// $Date: 2014-04-14 14:52:01 $ +// +// SVN only: +// $HeadURL: $ +// +// CVS only: +// $Source: /home/cvsadm/cvsroot/AbstractClasses7/SupervisedID/SupervisedIDStateMachine.cpp,v $ +// $Log: SupervisedIDStateMachine.cpp,v $ +// Revision 1.2 2014-04-14 14:52:01 claudio +// for 8.1.2.c and pogo-8 +// +// Revision 1.1.1.1 2012-03-05 14:01:56 claudio +// frist import +// +// +//============================================================================= +// This file is generated by POGO +// (Program Obviously used to Generate tango Object) +//============================================================================= + + + +#include <SupervisedID.h> +#include <SupervisedIDClass.h> + +/*----- PROTECTED REGION END -----*/ // SupervisedID::SupervisedIDStateMachine.cpp + +//================================================================ +// States | Description +//================================================================ +// ON | Device OK +// FAULT | Device not working - broken ID +// UNKNOWN | Device not working - unknow reason/condition +// RUNNING | Device gap is moving +// DISABLE | Device not remotely operable + + +namespace SupervisedID_ns +{ +//================================================= +// Attributes Allowed Methods +//================================================= + +//-------------------------------------------------------- +/** + * Method : SupervisedID::is_Enabled_allowed() + * Description : Execution allowed for Enabled attribute + */ +//-------------------------------------------------------- +bool SupervisedID::is_Enabled_allowed(TANGO_UNUSED(Tango::AttReqType type)) +{ + // Not any excluded states for Enabled attribute in Write access. + /*----- PROTECTED REGION ID(SupervisedID::EnabledStateAllowed_WRITE) ENABLED START -----*/ + + /*----- PROTECTED REGION END -----*/ // SupervisedID::EnabledStateAllowed_WRITE + + // Not any excluded states for Enabled attribute in read access. + /*----- PROTECTED REGION ID(SupervisedID::EnabledStateAllowed_READ) ENABLED START -----*/ + + /*----- PROTECTED REGION END -----*/ // SupervisedID::EnabledStateAllowed_READ + return true; +} + +//-------------------------------------------------------- +/** + * Method : SupervisedID::is_Ready_allowed() + * Description : Execution allowed for Ready attribute + */ +//-------------------------------------------------------- +bool SupervisedID::is_Ready_allowed(TANGO_UNUSED(Tango::AttReqType type)) +{ + + // Not any excluded states for Ready attribute in read access. + /*----- PROTECTED REGION ID(SupervisedID::ReadyStateAllowed_READ) ENABLED START -----*/ + + /*----- PROTECTED REGION END -----*/ // SupervisedID::ReadyStateAllowed_READ + return true; +} + +//-------------------------------------------------------- +/** + * Method : SupervisedID::is_StatRF_allowed() + * Description : Execution allowed for StatRF attribute + */ +//-------------------------------------------------------- +bool SupervisedID::is_StatRF_allowed(TANGO_UNUSED(Tango::AttReqType type)) +{ + + // Not any excluded states for StatRF attribute in read access. + /*----- PROTECTED REGION ID(SupervisedID::StatRFStateAllowed_READ) ENABLED START -----*/ + + /*----- PROTECTED REGION END -----*/ // SupervisedID::StatRFStateAllowed_READ + return true; +} + +//================================================= +// Commands Allowed Methods +//================================================= + +} // End of namespace -- GitLab