From ae8673b89187090c150b60e17b6a302a71e1f70d Mon Sep 17 00:00:00 2001 From: Claudio Scafuri <claudio.scafuri@elettra.eu> Date: Thu, 15 Feb 2024 18:06:20 +0100 Subject: [PATCH] project startup --- .gitignore | 8 + Makefile | 3 + src/ClassFactory.cpp | 52 ++ src/SimulatedE2PS.cpp | 460 ++++++++++++ src/SimulatedE2PS.h | 270 +++++++ src/SimulatedE2PS.xmi | 111 +++ src/SimulatedE2PSClass.cpp | 707 ++++++++++++++++++ src/SimulatedE2PSClass.h | 294 ++++++++ src/SimulatedE2PSStateMachine.cpp | 213 ++++++ src/__pycache__/SimulatedE2PS.cpython-311.pyc | Bin 0 -> 5802 bytes src/main.cpp | 88 +++ 11 files changed, 2206 insertions(+) create mode 100644 .gitignore create mode 100644 Makefile create mode 100644 src/ClassFactory.cpp create mode 100644 src/SimulatedE2PS.cpp create mode 100644 src/SimulatedE2PS.h create mode 100644 src/SimulatedE2PS.xmi create mode 100644 src/SimulatedE2PSClass.cpp create mode 100644 src/SimulatedE2PSClass.h create mode 100644 src/SimulatedE2PSStateMachine.cpp create mode 100644 src/__pycache__/SimulatedE2PS.cpython-311.pyc create mode 100644 src/main.cpp diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..0d4c718 --- /dev/null +++ b/.gitignore @@ -0,0 +1,8 @@ +.nse_depinfo +bin +obj + +# Eclipse +.cproject +.project +.settings diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..fe1087f --- /dev/null +++ b/Makefile @@ -0,0 +1,3 @@ +NAME_SRV = simulatede2ps-srv + +include ../makefiles/Make-9.3.6.in diff --git a/src/ClassFactory.cpp b/src/ClassFactory.cpp new file mode 100644 index 0000000..cc15e02 --- /dev/null +++ b/src/ClassFactory.cpp @@ -0,0 +1,52 @@ +/*----- PROTECTED REGION ID(SimulatedE2PS::ClassFactory.cpp) ENABLED START -----*/ +/* clang-format on */ +//============================================================================= +// +// 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 : SimulatedE2PS +// +// 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/>. +// +// +// +//============================================================================= +// This file is generated by POGO +// (Program Obviously used to Generate tango Object) +//============================================================================= + +#include <tango/tango.h> +#include "SimulatedE2PSClass.h" + +// Add class header files if needed + + +/** + * Create SimulatedE2PS Class singleton and store it in DServer object. + */ + +void Tango::DServer::class_factory() +{ + // Add method class init if needed + add_class(SimulatedE2PS_ns::SimulatedE2PSClass::init("SimulatedE2PS")); +} +/* clang-format off */ +/*----- PROTECTED REGION END -----*/ // SimulatedE2PS::ClassFactory.cpp diff --git a/src/SimulatedE2PS.cpp b/src/SimulatedE2PS.cpp new file mode 100644 index 0000000..5b23c88 --- /dev/null +++ b/src/SimulatedE2PS.cpp @@ -0,0 +1,460 @@ +/*----- PROTECTED REGION ID(SimulatedE2PS.cpp) ENABLED START -----*/ +/* clang-format on */ +//============================================================================= +// +// file : SimulatedE2PS.cpp +// +// description : C++ source for the SimulatedE2PS class 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 +// SimulatedE2PS are implemented in this file. +// +// project : SimulatedE2PS +// +// 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/>. +// +// +// +//============================================================================= +// This file is generated by POGO +// (Program Obviously used to Generate tango Object) +//============================================================================= + + +#include "SimulatedE2PS.h" +#include "SimulatedE2PSClass.h" +/* clang-format off */ +/*----- PROTECTED REGION END -----*/ // SimulatedE2PS.cpp + +/** + * SimulatedE2PS class description: + * Simulated power supply for Elettra 2.0 tests (digiltal twin). + * Tango interface Loosely based on NGPS tango device + */ + +//================================================================ +// 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 +// Reset | reset +// StartCycling | start_cycling +// Abort | abort +// fault | fault +//================================================================ + +//================================================================ +// Attributes managed are: +//================================================================ +// current | Tango::DevDouble Scalar +// voltage | Tango::DevDouble Scalar +// currentSet | Tango::DevDouble Scalar +//================================================================ + +namespace SimulatedE2PS_ns +{ +/*----- PROTECTED REGION ID(SimulatedE2PS::namespace_starting) ENABLED START -----*/ +/* clang-format on */ +// static initializations +/* clang-format off */ +/*----- PROTECTED REGION END -----*/ // SimulatedE2PS::namespace_starting + +//-------------------------------------------------------- +/** + * Method : SimulatedE2PS::SimulatedE2PS() + * Description: Constructors for a Tango device + * implementing the classSimulatedE2PS + */ +//-------------------------------------------------------- +SimulatedE2PS::SimulatedE2PS(Tango::DeviceClass *cl, std::string &s) + : TANGO_BASE_CLASS(cl, s.c_str()) +{ + /*----- PROTECTED REGION ID(SimulatedE2PS::constructor_1) ENABLED START -----*/ + /* clang-format on */ + init_device(); + /* clang-format off */ + /*----- PROTECTED REGION END -----*/ // SimulatedE2PS::constructor_1 +} +//-------------------------------------------------------- +SimulatedE2PS::SimulatedE2PS(Tango::DeviceClass *cl, const char *s) + : TANGO_BASE_CLASS(cl, s) +{ + /*----- PROTECTED REGION ID(SimulatedE2PS::constructor_2) ENABLED START -----*/ + /* clang-format on */ + init_device(); + /* clang-format off */ + /*----- PROTECTED REGION END -----*/ // SimulatedE2PS::constructor_2 +} +//-------------------------------------------------------- +SimulatedE2PS::SimulatedE2PS(Tango::DeviceClass *cl, const char *s, const char *d) + : TANGO_BASE_CLASS(cl, s, d) +{ + /*----- PROTECTED REGION ID(SimulatedE2PS::constructor_3) ENABLED START -----*/ + /* clang-format on */ + init_device(); + /* clang-format off */ + /*----- PROTECTED REGION END -----*/ // SimulatedE2PS::constructor_3 +} +//-------------------------------------------------------- +SimulatedE2PS::~SimulatedE2PS() +{ + delete_device(); +} + +//-------------------------------------------------------- +/** + * Method : SimulatedE2PS::delete_device() + * Description: will be called at device destruction or at init command + */ +//-------------------------------------------------------- +void SimulatedE2PS::delete_device() +{ + DEBUG_STREAM << "SimulatedE2PS::delete_device() " << device_name << std::endl; + /*----- PROTECTED REGION ID(SimulatedE2PS::delete_device) ENABLED START -----*/ + /* clang-format on */ + // Delete device allocated objects + /* clang-format off */ + /*----- PROTECTED REGION END -----*/ // SimulatedE2PS::delete_device +} + +//-------------------------------------------------------- +/** + * Method : SimulatedE2PS::init_device() + * Description: will be called at device initialization. + */ +//-------------------------------------------------------- +void SimulatedE2PS::init_device() +{ + DEBUG_STREAM << "SimulatedE2PS::init_device() create device " << device_name << std::endl; + /*----- PROTECTED REGION ID(SimulatedE2PS::init_device_before) ENABLED START -----*/ + /* clang-format on */ + // Initialization before get_device_property() call + /* clang-format off */ + /*----- PROTECTED REGION END -----*/ // SimulatedE2PS::init_device_before + + // No device property to be read from database + + /*----- PROTECTED REGION ID(SimulatedE2PS::init_device) ENABLED START -----*/ + /* clang-format on */ + // Initialize device + // Initialise variables to default values + _current= 0.0; + _current_read= 0.0; + _voltage= 0.1; + _ohm = 0.2; // load resistance in ohm + _busy = false; + thread_running=false; + Tango::MultiAttribute *attr_list = get_device_attr(); + attr_current = &(attr_list->get_w_attr_by_name("current")); + try{ + attr_current->set_write_value(_current); + } + catch(...){} // ignore error! + set_state(Tango::ON); + INFO_STREAM << "SimulatedE2PS::init_device() create device end " << device_name << endl; + /* clang-format off */ + /*----- PROTECTED REGION END -----*/ // SimulatedE2PS::init_device +} + + +//-------------------------------------------------------- +/** + * Method : SimulatedE2PS::always_executed_hook() + * Description: method always executed before any command is executed + */ +//-------------------------------------------------------- +void SimulatedE2PS::always_executed_hook() +{ + DEBUG_STREAM << "SimulatedE2PS::always_executed_hook() " << device_name << std::endl; + /*----- PROTECTED REGION ID(SimulatedE2PS::always_executed_hook) ENABLED START -----*/ + /* clang-format on */ + // code always executed before all requests + /* clang-format off */ + /*----- PROTECTED REGION END -----*/ // SimulatedE2PS::always_executed_hook +} + +//-------------------------------------------------------- +/** + * Method : SimulatedE2PS::read_attr_hardware() + * Description: Hardware acquisition for attributes + */ +//-------------------------------------------------------- +void SimulatedE2PS::read_attr_hardware(TANGO_UNUSED(std::vector<long> &attr_list)) +{ + DEBUG_STREAM << "SimulatedE2PS::read_attr_hardware(std::vector<long> &attr_list) entering... " << std::endl; + /*----- PROTECTED REGION ID(SimulatedE2PS::read_attr_hardware) ENABLED START -----*/ + /* clang-format on */ + // Add your own code + /* clang-format off */ + /*----- PROTECTED REGION END -----*/ // SimulatedE2PS::read_attr_hardware +} +//-------------------------------------------------------- +/** + * Method : SimulatedE2PS::write_attr_hardware() + * Description: Hardware writing for attributes + */ +//-------------------------------------------------------- +void SimulatedE2PS::write_attr_hardware(TANGO_UNUSED(std::vector<long> &attr_list)) +{ + DEBUG_STREAM << "SimulatedE2PS::write_attr_hardware(std::vector<long> &attr_list) entering... " << std::endl; + /*----- PROTECTED REGION ID(SimulatedE2PS::write_attr_hardware) ENABLED START -----*/ + /* clang-format on */ + // Add your own code + /* clang-format off */ + /*----- PROTECTED REGION END -----*/ // SimulatedE2PS::write_attr_hardware +} + +//-------------------------------------------------------- +/** + * Read attribute current related method + * Description: The powersupply current setting in amps + * + * Data type: Tango::DevDouble + * Attr type: Scalar + */ +//-------------------------------------------------------- +void SimulatedE2PS::read_current(Tango::Attribute &attr) +{ + DEBUG_STREAM << "SimulatedE2PS::read_current(Tango::Attribute &attr) entering... " << std::endl; + /*----- PROTECTED REGION ID(SimulatedE2PS::read_current) ENABLED START -----*/ + /* clang-format on */ + // Set the attribute value + double delta=rand_r(&rand_r_seed)/RAND_MAX; + if(get_state() == Tango::OFF){ + delta +=0.5; + _current_read = delta *0.0001; + } + else{ + delta -=0.5; + _current_read = _current +( delta *0.0001 ); + } + attr.set_value(&_current_read); + /* clang-format off */ + /*----- PROTECTED REGION END -----*/ // SimulatedE2PS::read_current +} +//-------------------------------------------------------- +/** + * Write attribute current related method + * Description: The powersupply current setting in amps + * + * Data type: Tango::DevDouble + * Attr type: Scalar + */ +//-------------------------------------------------------- +void SimulatedE2PS::write_current(Tango::WAttribute &attr) +{ + DEBUG_STREAM << "SimulatedE2PS::write_current(Tango::WAttribute &attr) entering... " << std::endl; + // Retrieve write value + attr.get_write_value(_current_read); + attr.get_write_value(_current); + _voltage = _current * _ohm; + /*----- PROTECTED REGION ID(SimulatedE2PS::write_current) ENABLED START -----*/ + /* clang-format on */ + // Add your own code + /* clang-format off */ + /*----- PROTECTED REGION END -----*/ // SimulatedE2PS::write_current +} +//-------------------------------------------------------- +/** + * Read attribute voltage related method + * Description: The powersupply voltage in volts. + * + * Data type: Tango::DevDouble + * Attr type: Scalar + */ +//-------------------------------------------------------- +void SimulatedE2PS::read_voltage(Tango::Attribute &attr) +{ + DEBUG_STREAM << "SimulatedE2PS::read_voltage(Tango::Attribute &attr) entering... " << std::endl; + /*----- PROTECTED REGION ID(SimulatedE2PS::read_voltage) ENABLED START -----*/ + /* clang-format on */ + // Set the attribute value + attr.set_value(&_voltage); + /* clang-format off */ + /*----- PROTECTED REGION END -----*/ // SimulatedE2PS::read_voltage +} +//-------------------------------------------------------- +/** + * Read attribute currentSet related method + * Description: The current set value as stored in the powersupply. + * + * Data type: Tango::DevDouble + * Attr type: Scalar + */ +//-------------------------------------------------------- +void SimulatedE2PS::read_currentSet(Tango::Attribute &attr) +{ + DEBUG_STREAM << "SimulatedE2PS::read_currentSet(Tango::Attribute &attr) entering... " << std::endl; + /*----- PROTECTED REGION ID(SimulatedE2PS::read_currentSet) ENABLED START -----*/ + /* clang-format on */ + // Set the attribute value + attr.set_value(&_current); + /* clang-format off */ + /*----- PROTECTED REGION END -----*/ // SimulatedE2PS::read_currentSet +} + +//-------------------------------------------------------- +/** + * Method : SimulatedE2PS::add_dynamic_attributes() + * Description: Create the dynamic attributes if any + * for specified device. + */ +//-------------------------------------------------------- +void SimulatedE2PS::add_dynamic_attributes() +{ + /*----- PROTECTED REGION ID(SimulatedE2PS::add_dynamic_attributes) ENABLED START -----*/ + /* clang-format on */ + // Add your own code to create and add dynamic attributes if any + /* clang-format off */ + /*----- PROTECTED REGION END -----*/ // SimulatedE2PS::add_dynamic_attributes +} + +//-------------------------------------------------------- +/** + * Command On related method + * Description: Switch powersupply ON. + * + */ +//-------------------------------------------------------- +void SimulatedE2PS::on() +{ + DEBUG_STREAM << "SimulatedE2PS::On() - " << device_name << std::endl; + /*----- PROTECTED REGION ID(SimulatedE2PS::on) ENABLED START -----*/ + /* clang-format on */ + + // Add your own code + + /* clang-format off */ + /*----- PROTECTED REGION END -----*/ // SimulatedE2PS::on +} +//-------------------------------------------------------- +/** + * Command Off related method + * Description: Switch power supply OFF. + * + */ +//-------------------------------------------------------- +void SimulatedE2PS::off() +{ + DEBUG_STREAM << "SimulatedE2PS::Off() - " << device_name << std::endl; + /*----- PROTECTED REGION ID(SimulatedE2PS::off) ENABLED START -----*/ + /* clang-format on */ + + // Add your own code + + /* clang-format off */ + /*----- PROTECTED REGION END -----*/ // SimulatedE2PS::off +} +//-------------------------------------------------------- +/** + * Command Reset related method + * Description: Reset the powersupply to a well known state. + * + */ +//-------------------------------------------------------- +void SimulatedE2PS::reset() +{ + DEBUG_STREAM << "SimulatedE2PS::Reset() - " << device_name << std::endl; + /*----- PROTECTED REGION ID(SimulatedE2PS::reset) ENABLED START -----*/ + /* clang-format on */ + + // Add your own code + + /* clang-format off */ + /*----- PROTECTED REGION END -----*/ // SimulatedE2PS::reset +} +//-------------------------------------------------------- +/** + * Command StartCycling related method + * + * + */ +//-------------------------------------------------------- +void SimulatedE2PS::start_cycling() +{ + DEBUG_STREAM << "SimulatedE2PS::StartCycling() - " << device_name << std::endl; + /*----- PROTECTED REGION ID(SimulatedE2PS::start_cycling) ENABLED START -----*/ + /* clang-format on */ + + // Add your own code + + /* clang-format off */ + /*----- PROTECTED REGION END -----*/ // SimulatedE2PS::start_cycling +} +//-------------------------------------------------------- +/** + * Command Abort related method + * Description: stop ramp or cycling + * + */ +//-------------------------------------------------------- +void SimulatedE2PS::abort() +{ + DEBUG_STREAM << "SimulatedE2PS::Abort() - " << device_name << std::endl; + /*----- PROTECTED REGION ID(SimulatedE2PS::abort) ENABLED START -----*/ + /* clang-format on */ + + // Add your own code + + /* clang-format off */ + /*----- PROTECTED REGION END -----*/ // SimulatedE2PS::abort +} +//-------------------------------------------------------- +/** + * Command fault related method + * Description: Force a simulated faulty condtion + * + */ +//-------------------------------------------------------- +void SimulatedE2PS::fault() +{ + DEBUG_STREAM << "SimulatedE2PS::fault() - " << device_name << std::endl; + /*----- PROTECTED REGION ID(SimulatedE2PS::fault) ENABLED START -----*/ + /* clang-format on */ + + // Add your own code + + /* clang-format off */ + /*----- PROTECTED REGION END -----*/ // SimulatedE2PS::fault +} +//-------------------------------------------------------- +/** + * Method : SimulatedE2PS::add_dynamic_commands() + * Description: Create the dynamic commands if any + * for specified device. + */ +//-------------------------------------------------------- +void SimulatedE2PS::add_dynamic_commands() +{ + /*----- PROTECTED REGION ID(SimulatedE2PS::add_dynamic_commands) ENABLED START -----*/ + /* clang-format on */ + // Add your own code to create and add dynamic commands if any + /* clang-format off */ + /*----- PROTECTED REGION END -----*/ // SimulatedE2PS::add_dynamic_commands +} + +/*----- PROTECTED REGION ID(SimulatedE2PS::namespace_ending) ENABLED START -----*/ +/* clang-format on */ +// Additional Methods +/* clang-format off */ +/*----- PROTECTED REGION END -----*/ // SimulatedE2PS::namespace_ending +} // namespace diff --git a/src/SimulatedE2PS.h b/src/SimulatedE2PS.h new file mode 100644 index 0000000..6b44b49 --- /dev/null +++ b/src/SimulatedE2PS.h @@ -0,0 +1,270 @@ +/*----- PROTECTED REGION ID(SimulatedE2PS.h) ENABLED START -----*/ +/* clang-format on */ +//============================================================================= +// +// file : SimulatedE2PS.h +// +// description : Include file for the SimulatedE2PS class +// +// project : SimulatedE2PS +// +// 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/>. +// +// +// +//============================================================================= +// This file is generated by POGO +// (Program Obviously used to Generate tango Object) +//============================================================================= + + +#ifndef SimulatedE2PS_H +#define SimulatedE2PS_H + +#include <tango/tango.h> + +/* clang-format off */ +/*----- PROTECTED REGION END -----*/ // SimulatedE2PS.h + +#ifdef TANGO_LOG + // cppTango after c934adea (Merge branch 'remove-cout-definition' into 'main', 2022-05-23) + // nothing to do +#else + // cppTango 9.3-backports and older + #define TANGO_LOG cout + #define TANGO_LOG_INFO cout2 + #define TANGO_LOG_DEBUG cout3 +#endif // TANGO_LOG + +/** + * SimulatedE2PS class description: + * Simulated power supply for Elettra 2.0 tests (digiltal twin). + * Tango interface Loosely based on NGPS tango device + */ + + +namespace SimulatedE2PS_ns +{ +/*----- PROTECTED REGION ID(SimulatedE2PS::Additional Class Declarations) ENABLED START -----*/ +/* clang-format on */ +// Additional Class Declarations +/* clang-format off */ +/*----- PROTECTED REGION END -----*/ // SimulatedE2PS::Additional Class Declarations + +class SimulatedE2PS : public TANGO_BASE_CLASS +{ + +/*----- PROTECTED REGION ID(SimulatedE2PS::Data Members) ENABLED START -----*/ +/* clang-format on */ +// Add your own data members + friend class cyclethread; + protected : + double _current; + double _current_read; + double _voltage; + double _ohm; + bool _busy; + unsigned int rand_r_seed; + class cyclethread *cycleloop; + bool thread_running; + bool abortflag; + void psdelay(); + Tango::WAttribute *attr_current; +/* clang-format off */ +/*----- PROTECTED REGION END -----*/ // SimulatedE2PS::Data Members + + +// Attribute data members +public: + Tango::DevDouble *attr_current_read; + Tango::DevDouble *attr_voltage_read; + Tango::DevDouble *attr_currentSet_read; + +// Constructors and destructors +public: + /** + * Constructs a newly device object. + * + * @param cl Class. + * @param s Device Name + */ + SimulatedE2PS(Tango::DeviceClass *cl,std::string &s); + /** + * Constructs a newly device object. + * + * @param cl Class. + * @param s Device Name + */ + SimulatedE2PS(Tango::DeviceClass *cl,const char *s); + /** + * Constructs a newly device object. + * + * @param cl Class. + * @param s Device name + * @param d Device description. + */ + SimulatedE2PS(Tango::DeviceClass *cl,const char *s,const char *d); + /** + * The device object destructor. + */ + ~SimulatedE2PS(); + + +// 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 : SimulatedE2PS::read_attr_hardware() + * Description: Hardware acquisition for attributes. + */ + //-------------------------------------------------------- + virtual void read_attr_hardware(std::vector<long> &attr_list); + //-------------------------------------------------------- + /* + * Method : SimulatedE2PS::write_attr_hardware() + * Description: Hardware writing for attributes. + */ + //-------------------------------------------------------- + virtual void write_attr_hardware(std::vector<long> &attr_list); + +/** + * Attribute current related methods + * Description: The powersupply current setting in amps + * + * Data type: Tango::DevDouble + * Attr type: Scalar + */ + virtual void read_current(Tango::Attribute &attr); + virtual void write_current(Tango::WAttribute &attr); + virtual bool is_current_allowed(Tango::AttReqType type); +/** + * Attribute voltage related methods + * Description: The powersupply voltage in volts. + * + * Data type: Tango::DevDouble + * Attr type: Scalar + */ + virtual void read_voltage(Tango::Attribute &attr); + virtual bool is_voltage_allowed(Tango::AttReqType type); +/** + * Attribute currentSet related methods + * Description: The current set value as stored in the powersupply. + * + * Data type: Tango::DevDouble + * Attr type: Scalar + */ + virtual void read_currentSet(Tango::Attribute &attr); + virtual bool is_currentSet_allowed(Tango::AttReqType type); + + + //-------------------------------------------------------- + /** + * Method : SimulatedE2PS::add_dynamic_attributes() + * Description: Add dynamic attributes if any. + */ + //-------------------------------------------------------- + void add_dynamic_attributes(); + + + + +// Command related methods +public: + /** + * Command On related method + * Description: Switch powersupply ON. + * + */ + virtual void on(); + virtual bool is_On_allowed(const CORBA::Any &any); + /** + * Command Off related method + * Description: Switch power supply OFF. + * + */ + virtual void off(); + virtual bool is_Off_allowed(const CORBA::Any &any); + /** + * Command Reset related method + * Description: Reset the powersupply to a well known state. + * + */ + virtual void reset(); + virtual bool is_Reset_allowed(const CORBA::Any &any); + /** + * Command StartCycling related method + * + * + */ + virtual void start_cycling(); + virtual bool is_StartCycling_allowed(const CORBA::Any &any); + /** + * Command Abort related method + * Description: stop ramp or cycling + * + */ + virtual void abort(); + virtual bool is_Abort_allowed(const CORBA::Any &any); + /** + * Command fault related method + * Description: Force a simulated faulty condtion + * + */ + virtual void fault(); + virtual bool is_fault_allowed(const CORBA::Any &any); + + + //-------------------------------------------------------- + /** + * Method : SimulatedE2PS::add_dynamic_commands() + * Description: Add dynamic commands if any. + */ + //-------------------------------------------------------- + void add_dynamic_commands(); + +/*----- PROTECTED REGION ID(SimulatedE2PS::Additional Method prototypes) ENABLED START -----*/ +/* clang-format on */ +// Additional Method prototypes +/* clang-format off */ +/*----- PROTECTED REGION END -----*/ // SimulatedE2PS::Additional Method prototypes +}; + +/*----- PROTECTED REGION ID(SimulatedE2PS::Additional Classes Definitions) ENABLED START -----*/ +/* clang-format on */ +// Additional Classes Definitions + +/* clang-format off */ +/*----- PROTECTED REGION END -----*/ // SimulatedE2PS::Additional Classes Definitions + +} // End of namespace + +#endif // SimulatedE2PS_H diff --git a/src/SimulatedE2PS.xmi b/src/SimulatedE2PS.xmi new file mode 100644 index 0000000..9225f63 --- /dev/null +++ b/src/SimulatedE2PS.xmi @@ -0,0 +1,111 @@ +<?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="SimulatedE2PS" pogoRevision="9.8"> + <description description="Simulated power supply for Elettra 2.0 tests (digiltal twin).
Tango interface Loosely based on NGPS tango device" title="SimulatedE2PS" sourcePath="/homelocal/claudio/src/gitlab/dt/ds/simulatede2ps/src" language="Cpp" filestogenerate="XMI file,Code files,Protected Regions" license="GPL" copyright="" hasMandatoryProperty="false" hasConcreteProperty="false" hasAbstractCommand="false" hasAbstractAttribute="false"> + <inheritances classname="Device_Impl" sourcePath=""/> + <identification contact="at elettra.eu - claudio.scafuri" author="claudio.scafuri" emailDomain="elettra.eu" classFamily="Simulators" siteSpecific="" platform="All Platforms" bus="Not Applicable" manufacturer="none" reference=""> + <keyWords>Power supply</keyWords> + <keyWords>simulator</keyWords> + <keyWords>Elettra 2.0</keyWords> + <keyWords>Digital twin</keyWords> + </identification> + </description> + <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" polledPeriod="0"> + <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" polledPeriod="0"> + <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="Switch powersupply ON." execMethod="on" displayLevel="OPERATOR" polledPeriod="0" isDynamic="false"> + <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"/> + </commands> + <commands name="Off" description="Switch power supply OFF." execMethod="off" displayLevel="OPERATOR" polledPeriod="0" isDynamic="false"> + <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"/> + </commands> + <commands name="Reset" description="Reset the powersupply to a well known state." execMethod="reset" displayLevel="OPERATOR" polledPeriod="0" isDynamic="false"> + <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"/> + </commands> + <commands name="StartCycling" description="" execMethod="start_cycling" displayLevel="OPERATOR" polledPeriod="0" isDynamic="false"> + <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"/> + </commands> + <commands name="Abort" description="stop ramp or cycling" execMethod="abort" displayLevel="OPERATOR" polledPeriod="0" isDynamic="false"> + <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"/> + </commands> + <commands name="fault" description="Force a simulated faulty condtion" execMethod="fault" displayLevel="EXPERT" polledPeriod="0" isDynamic="false"> + <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"/> + </commands> + <attributes name="current" attType="Scalar" rwType="READ_WRITE" displayLevel="OPERATOR" polledPeriod="0" maxX="" maxY="" allocReadMember="false" isDynamic="false"> + <dataType xsi:type="pogoDsl:DoubleType"/> + <changeEvent fire="false" libCheckCriteria="false"/> + <archiveEvent fire="false" libCheckCriteria="false"/> + <dataReadyEvent fire="false" libCheckCriteria="true"/> + <status abstract="false" inherited="false" concrete="true" concreteHere="true"/> + <properties description="The powersupply current setting in amps" label="current" unit="A" standardUnit="1" displayUnit="A" format="%6.4f" maxValue="" minValue="" maxAlarm="" minAlarm="" maxWarning="" minWarning="" deltaTime="" deltaValue=""/> + </attributes> + <attributes name="voltage" attType="Scalar" rwType="READ" displayLevel="OPERATOR" polledPeriod="0" maxX="" maxY="" allocReadMember="false" isDynamic="false"> + <dataType xsi:type="pogoDsl:DoubleType"/> + <changeEvent fire="false" libCheckCriteria="false"/> + <archiveEvent fire="false" libCheckCriteria="false"/> + <dataReadyEvent fire="false" libCheckCriteria="true"/> + <status abstract="false" inherited="false" concrete="true" concreteHere="true"/> + <properties description="The powersupply voltage in volts." label="" unit="V" standardUnit="1" displayUnit="V" format="%6.4f" maxValue="" minValue="" maxAlarm="" minAlarm="" maxWarning="" minWarning="" deltaTime="" deltaValue=""/> + </attributes> + <attributes name="currentSet" attType="Scalar" rwType="READ" displayLevel="OPERATOR" polledPeriod="0" maxX="" maxY="" allocReadMember="false" isDynamic="false"> + <dataType xsi:type="pogoDsl:DoubleType"/> + <changeEvent fire="false" libCheckCriteria="false"/> + <archiveEvent fire="false" libCheckCriteria="false"/> + <dataReadyEvent fire="false" libCheckCriteria="true"/> + <status abstract="false" inherited="false" concrete="true" concreteHere="true"/> + <properties description="The current set value as stored in the powersupply." label="" unit="A" standardUnit="1" displayUnit="A" format="%6.4f" maxValue="" minValue="" maxAlarm="" minAlarm="" maxWarning="" minWarning="" deltaTime="" deltaValue=""/> + </attributes> + <preferences docHome="./doc_html" makefileHome="/usr/local/tango-9.3.6/share/pogo/preferences"/> + </classes> +</pogoDsl:PogoSystem> diff --git a/src/SimulatedE2PSClass.cpp b/src/SimulatedE2PSClass.cpp new file mode 100644 index 0000000..fd66f1c --- /dev/null +++ b/src/SimulatedE2PSClass.cpp @@ -0,0 +1,707 @@ +/*----- PROTECTED REGION ID(SimulatedE2PSClass.cpp) ENABLED START -----*/ +/* clang-format on */ +//============================================================================= +// +// file : SimulatedE2PSClass.cpp +// +// description : C++ source for the SimulatedE2PSClass. +// A singleton class derived from DeviceClass. +// It implements the command and attribute list +// and all properties and methods required +// by the SimulatedE2PS once per process. +// +// project : SimulatedE2PS +// +// 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/>. +// +// +// +//============================================================================= +// This file is generated by POGO +// (Program Obviously used to Generate tango Object) +//============================================================================= + + +#include "SimulatedE2PSClass.h" +/* clang-format off */ +/*----- PROTECTED REGION END -----*/ // SimulatedE2PSClass.cpp + +//------------------------------------------------------------------- +/** + * Create SimulatedE2PSClass singleton and + * return it in a C function for Python usage + */ +//------------------------------------------------------------------- +extern "C" { +#ifdef _TG_WINDOWS_ + +__declspec(dllexport) + +#endif + + Tango::DeviceClass *_create_SimulatedE2PS_class(const char *name) { + return SimulatedE2PS_ns::SimulatedE2PSClass::init(name); + } +} + +namespace SimulatedE2PS_ns +{ +//=================================================================== +// Initialize pointer for singleton pattern +//=================================================================== +SimulatedE2PSClass *SimulatedE2PSClass::_instance = NULL; + +//=================================================================== +// Class constants +//=================================================================== +//-------------------------------------------------------- +/** + * method : SimulatedE2PSClass::SimulatedE2PSClass(std::string &s) + * description : constructor for the SimulatedE2PSClass + * + * @param s The class name + */ +//-------------------------------------------------------- +SimulatedE2PSClass::SimulatedE2PSClass(std::string &s):Tango::DeviceClass(s) +{ + TANGO_LOG_INFO << "Entering SimulatedE2PSClass constructor" << std::endl; + set_default_property(); + write_class_property(); + + /*----- PROTECTED REGION ID(SimulatedE2PSClass::constructor) ENABLED START -----*/ + /* clang-format on */ + /* clang-format off */ + /*----- PROTECTED REGION END -----*/ // SimulatedE2PSClass::constructor + + TANGO_LOG_INFO << "Leaving SimulatedE2PSClass constructor" << std::endl; +} + +//-------------------------------------------------------- +/** + * method : SimulatedE2PSClass::~SimulatedE2PSClass() + * description : destructor for the SimulatedE2PSClass + */ +//-------------------------------------------------------- +SimulatedE2PSClass::~SimulatedE2PSClass() +{ + /*----- PROTECTED REGION ID(SimulatedE2PSClass::destructor) ENABLED START -----*/ + /* clang-format on */ + /* clang-format off */ + /*----- PROTECTED REGION END -----*/ // SimulatedE2PSClass::destructor + + _instance = NULL; +} + + +//-------------------------------------------------------- +/** + * method : SimulatedE2PSClass::init + * description : Create the object if not already done. + * Otherwise, just return a pointer to the object + * + * @param name The class name + */ +//-------------------------------------------------------- +SimulatedE2PSClass *SimulatedE2PSClass::init(const char *name) +{ + if (_instance == NULL) + { + try + { + std::string s(name); + _instance = new SimulatedE2PSClass(s); + } + catch (std::bad_alloc &) + { + throw; + } + } + return _instance; +} + +//-------------------------------------------------------- +/** + * method : SimulatedE2PSClass::instance + * description : Check if object already created, + * and return a pointer to the object + */ +//-------------------------------------------------------- +SimulatedE2PSClass *SimulatedE2PSClass::instance() +{ + if (_instance == NULL) + { + std::cerr << "Class is not initialised !!" << std::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, TANGO_UNUSED(const CORBA::Any &in_any)) +{ + TANGO_LOG_INFO << "OnClass::execute(): arrived" << std::endl; + ((static_cast<SimulatedE2PS *>(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, TANGO_UNUSED(const CORBA::Any &in_any)) +{ + TANGO_LOG_INFO << "OffClass::execute(): arrived" << std::endl; + ((static_cast<SimulatedE2PS *>(device))->off()); + return new CORBA::Any(); +} + +//-------------------------------------------------------- +/** + * method : ResetClass::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 *ResetClass::execute(Tango::DeviceImpl *device, TANGO_UNUSED(const CORBA::Any &in_any)) +{ + TANGO_LOG_INFO << "ResetClass::execute(): arrived" << std::endl; + ((static_cast<SimulatedE2PS *>(device))->reset()); + return new CORBA::Any(); +} + +//-------------------------------------------------------- +/** + * method : StartCyclingClass::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 *StartCyclingClass::execute(Tango::DeviceImpl *device, TANGO_UNUSED(const CORBA::Any &in_any)) +{ + TANGO_LOG_INFO << "StartCyclingClass::execute(): arrived" << std::endl; + ((static_cast<SimulatedE2PS *>(device))->start_cycling()); + return new CORBA::Any(); +} + +//-------------------------------------------------------- +/** + * method : AbortClass::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 *AbortClass::execute(Tango::DeviceImpl *device, TANGO_UNUSED(const CORBA::Any &in_any)) +{ + TANGO_LOG_INFO << "AbortClass::execute(): arrived" << std::endl; + ((static_cast<SimulatedE2PS *>(device))->abort()); + return new CORBA::Any(); +} + +//-------------------------------------------------------- +/** + * method : faultClass::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 *faultClass::execute(Tango::DeviceImpl *device, TANGO_UNUSED(const CORBA::Any &in_any)) +{ + TANGO_LOG_INFO << "faultClass::execute(): arrived" << std::endl; + ((static_cast<SimulatedE2PS *>(device))->fault()); + return new CORBA::Any(); +} + + +//=================================================================== +// Properties management +//=================================================================== +//-------------------------------------------------------- +/** + * Method : SimulatedE2PSClass::get_class_property() + * Description: Get the class property for specified name. + */ +//-------------------------------------------------------- +Tango::DbDatum SimulatedE2PSClass::get_class_property(std::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 : SimulatedE2PSClass::get_default_device_property() + * Description: Return the default value for device property. + */ +//-------------------------------------------------------- +Tango::DbDatum SimulatedE2PSClass::get_default_device_property(std::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 : SimulatedE2PSClass::get_default_class_property() + * Description: Return the default value for class property. + */ +//-------------------------------------------------------- +Tango::DbDatum SimulatedE2PSClass::get_default_class_property(std::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 : SimulatedE2PSClass::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 SimulatedE2PSClass::set_default_property() +{ + std::string prop_name; + std::string prop_desc; + std::string prop_def; + std::vector<std::string> vect_data; + + // Set Default Class Properties + + // Set Default device Properties +} + +//-------------------------------------------------------- +/** + * Method : SimulatedE2PSClass::write_class_property() + * Description: Set class description fields as property in database + */ +//-------------------------------------------------------- +void SimulatedE2PSClass::write_class_property() +{ +// First time, check if database used +if (Tango::Util::_UseDb == false) + return; + +Tango::DbData data; +std::string classname = get_name(); +std::string header; + +// Put title +Tango::DbDatum title("ProjectTitle"); +std::string str_title("SimulatedE2PS"); +title << str_title; +data.push_back(title); + +// Put Description +Tango::DbDatum description("Description"); +std::vector<std::string> str_desc; +str_desc.push_back("Simulated power supply for Elettra 2.0 tests (digiltal twin)."); +str_desc.push_back("Tango interface Loosely based on NGPS tango device"); +description << str_desc; +data.push_back(description); + +// Put inheritance +Tango::DbDatum inher_datum("InheritedFrom"); +std::vector<std::string> inheritance; +inheritance.push_back("TANGO_BASE_CLASS"); +inher_datum << inheritance; +data.push_back(inher_datum); + +// Call database and and values +get_db_class()->put_property(data); +} + +//=================================================================== +// Factory methods +//=================================================================== + +//-------------------------------------------------------- +/** + * Method : SimulatedE2PSClass::device_factory() + * Description: Create the device object(s) + * and store them in the device list + */ +//-------------------------------------------------------- +void SimulatedE2PSClass::device_factory(const Tango::DevVarStringArray *devlist_ptr) +{ +/*----- PROTECTED REGION ID(SimulatedE2PSClass::device_factory_before) ENABLED START -----*/ +/* clang-format on */ +// Add your own code +/* clang-format off */ +/*----- PROTECTED REGION END -----*/ // SimulatedE2PSClass::device_factory_before + +// Create devices and add it into the device list +for (unsigned long i=0 ; i<devlist_ptr->length() ; i++) +{ + TANGO_LOG_DEBUG << "Device name : " << (*devlist_ptr)[i].in() << std::endl; + device_list.push_back(new SimulatedE2PS(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 + SimulatedE2PS *dev = static_cast<SimulatedE2PS *>(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(SimulatedE2PSClass::device_factory_after) ENABLED START -----*/ +/* clang-format on */ +// Add your own code +/* clang-format off */ +/*----- PROTECTED REGION END -----*/ // SimulatedE2PSClass::device_factory_after +} +//-------------------------------------------------------- +/** + * Method : SimulatedE2PSClass::attribute_factory() + * Description: Create the attribute object(s) + * and store them in the attribute list + */ +//-------------------------------------------------------- +void SimulatedE2PSClass::attribute_factory(std::vector<Tango::Attr *> &att_list) +{ + /*----- PROTECTED REGION ID(SimulatedE2PSClass::attribute_factory_before) ENABLED START -----*/ + /* clang-format on */ + // Add your own code + /* clang-format off */ + /*----- PROTECTED REGION END -----*/ // SimulatedE2PSClass::attribute_factory_before + // Attribute : current + currentAttrib *current = new currentAttrib(); + Tango::UserDefaultAttrProp current_prop; + current_prop.set_description("The powersupply current setting in amps"); + current_prop.set_label("current"); + current_prop.set_unit("A"); + current_prop.set_standard_unit("1"); + current_prop.set_display_unit("A"); + current_prop.set_format("%6.4f"); + // max_value not set for current + // min_value not set for current + // max_alarm not set for current + // min_alarm not set for current + // max_warning not set for current + // min_warning not set for current + // delta_t not set for current + // delta_val not set for current + current->set_default_properties(current_prop); + // Not Polled + current->set_disp_level(Tango::OPERATOR); + // Not Memorized + att_list.push_back(current); + + // Attribute : voltage + voltageAttrib *voltage = new voltageAttrib(); + Tango::UserDefaultAttrProp voltage_prop; + voltage_prop.set_description("The powersupply voltage in volts."); + // label not set for voltage + voltage_prop.set_unit("V"); + voltage_prop.set_standard_unit("1"); + voltage_prop.set_display_unit("V"); + voltage_prop.set_format("%6.4f"); + // max_value not set for voltage + // min_value not set for voltage + // max_alarm not set for voltage + // min_alarm not set for voltage + // max_warning not set for voltage + // min_warning not set for voltage + // delta_t not set for voltage + // delta_val not set for voltage + voltage->set_default_properties(voltage_prop); + // Not Polled + voltage->set_disp_level(Tango::OPERATOR); + // Not Memorized + att_list.push_back(voltage); + + // Attribute : currentSet + currentSetAttrib *currentset = new currentSetAttrib(); + Tango::UserDefaultAttrProp currentset_prop; + currentset_prop.set_description("The current set value as stored in the powersupply."); + // label not set for currentSet + currentset_prop.set_unit("A"); + currentset_prop.set_standard_unit("1"); + currentset_prop.set_display_unit("A"); + currentset_prop.set_format("%6.4f"); + // max_value not set for currentSet + // min_value not set for currentSet + // max_alarm not set for currentSet + // min_alarm not set for currentSet + // max_warning not set for currentSet + // min_warning not set for currentSet + // delta_t not set for currentSet + // delta_val not set for currentSet + currentset->set_default_properties(currentset_prop); + // Not Polled + currentset->set_disp_level(Tango::OPERATOR); + // Not Memorized + att_list.push_back(currentset); + + + // Create a list of static attributes + create_static_attribute_list(get_class_attr()->get_attr_list()); + /*----- PROTECTED REGION ID(SimulatedE2PSClass::attribute_factory_after) ENABLED START -----*/ + /* clang-format on */ + // Add your own code + /* clang-format off */ + /*----- PROTECTED REGION END -----*/ // SimulatedE2PSClass::attribute_factory_after +} +//-------------------------------------------------------- +/** + * Method : SimulatedE2PSClass::pipe_factory() + * Description: Create the pipe object(s) + * and store them in the pipe list + */ +//-------------------------------------------------------- +void SimulatedE2PSClass::pipe_factory() +{ + /*----- PROTECTED REGION ID(SimulatedE2PSClass::pipe_factory_before) ENABLED START -----*/ + /* clang-format on */ + // Add your own code + /* clang-format off */ + /*----- PROTECTED REGION END -----*/ // SimulatedE2PSClass::pipe_factory_before + /*----- PROTECTED REGION ID(SimulatedE2PSClass::pipe_factory_after) ENABLED START -----*/ + /* clang-format on */ + // Add your own code + /* clang-format off */ + /*----- PROTECTED REGION END -----*/ // SimulatedE2PSClass::pipe_factory_after +} +//-------------------------------------------------------- +/** + * Method : SimulatedE2PSClass::command_factory() + * Description: Create the command object(s) + * and store them in the command list + */ +//-------------------------------------------------------- +void SimulatedE2PSClass::command_factory() +{ + /*----- PROTECTED REGION ID(SimulatedE2PSClass::command_factory_before) ENABLED START -----*/ + /* clang-format on */ + // Add your own code + /* clang-format off */ + /*----- PROTECTED REGION END -----*/ // SimulatedE2PSClass::command_factory_before + + + // Command On + OnClass *pOnCmd = + new OnClass("On", + Tango::DEV_VOID, Tango::DEV_VOID, + "", + "", + Tango::OPERATOR); + command_list.push_back(pOnCmd); + + // Command Off + OffClass *pOffCmd = + new OffClass("Off", + Tango::DEV_VOID, Tango::DEV_VOID, + "", + "", + Tango::OPERATOR); + command_list.push_back(pOffCmd); + + // Command Reset + ResetClass *pResetCmd = + new ResetClass("Reset", + Tango::DEV_VOID, Tango::DEV_VOID, + "", + "", + Tango::OPERATOR); + command_list.push_back(pResetCmd); + + // Command StartCycling + StartCyclingClass *pStartCyclingCmd = + new StartCyclingClass("StartCycling", + Tango::DEV_VOID, Tango::DEV_VOID, + "", + "", + Tango::OPERATOR); + command_list.push_back(pStartCyclingCmd); + + // Command Abort + AbortClass *pAbortCmd = + new AbortClass("Abort", + Tango::DEV_VOID, Tango::DEV_VOID, + "", + "", + Tango::OPERATOR); + command_list.push_back(pAbortCmd); + + // Command fault + faultClass *pfaultCmd = + new faultClass("fault", + Tango::DEV_VOID, Tango::DEV_VOID, + "", + "", + Tango::EXPERT); + command_list.push_back(pfaultCmd); + + /*----- PROTECTED REGION ID(SimulatedE2PSClass::command_factory_after) ENABLED START -----*/ + /* clang-format on */ + // Add your own code + /* clang-format off */ + /*----- PROTECTED REGION END -----*/ // SimulatedE2PSClass::command_factory_after +} + +//=================================================================== +// Dynamic attributes related methods +//=================================================================== + +//-------------------------------------------------------- +/** + * method : SimulatedE2PSClass::create_static_attribute_list + * description : Create the a list of static attributes + * + * @param att_list the created attribute list + */ +//-------------------------------------------------------- +void SimulatedE2PSClass::create_static_attribute_list(std::vector<Tango::Attr *> &att_list) +{ + for (unsigned long i=0 ; i<att_list.size() ; i++) + { + std::string att_name(att_list[i]->get_name()); + transform(att_name.begin(), att_name.end(), att_name.begin(), ::tolower); + defaultAttList.push_back(att_name); + } + + TANGO_LOG_INFO << defaultAttList.size() << " attributes in default list" << std::endl; + + /*----- PROTECTED REGION ID(SimulatedE2PSClass::create_static_att_list) ENABLED START -----*/ + /* clang-format on */ + /* clang-format off */ + /*----- PROTECTED REGION END -----*/ // SimulatedE2PSClass::create_static_att_list +} + + +//-------------------------------------------------------- +/** + * method : SimulatedE2PSClass::erase_dynamic_attributes + * description : delete the dynamic attributes if any. + * + * @param devlist_ptr the device list pointer + * @param list of all attributes + */ +//-------------------------------------------------------- +void SimulatedE2PSClass::erase_dynamic_attributes(const Tango::DevVarStringArray *devlist_ptr, std::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(((std::string)(*devlist_ptr)[i]).c_str()); + SimulatedE2PS *dev = static_cast<SimulatedE2PS *> (dev_impl); + + std::vector<Tango::Attribute *> &dev_att_list = dev->get_device_attr()->get_attribute_list(); + std::vector<Tango::Attribute *>::iterator ite_att; + for (ite_att=dev_att_list.begin() ; ite_att != dev_att_list.end() ; ++ite_att) + { + std::string att_name((*ite_att)->get_name_lower()); + if ((att_name == "state") || (att_name == "status")) + continue; + std::vector<std::string>::iterator ite_str = find(defaultAttList.begin(), defaultAttList.end(), att_name); + if (ite_str == defaultAttList.end()) + { + TANGO_LOG_INFO << att_name << " is a UNWANTED dynamic attribute for device " << (*devlist_ptr)[i] << std::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, false); + --ite_att; + } + } + } + /*----- PROTECTED REGION ID(SimulatedE2PSClass::erase_dynamic_attributes) ENABLED START -----*/ + /* clang-format on */ + /* clang-format off */ + /*----- PROTECTED REGION END -----*/ // SimulatedE2PSClass::erase_dynamic_attributes +} + +//-------------------------------------------------------- +/** + * Method : SimulatedE2PSClass::get_attr_object_by_name() + * Description: returns Tango::Attr * object found by name + */ +//-------------------------------------------------------- +Tango::Attr *SimulatedE2PSClass::get_attr_object_by_name(std::vector<Tango::Attr *> &att_list, std::string attname) +{ + std::vector<Tango::Attr *>::iterator it; + for (it=att_list.begin() ; it<att_list.end() ; ++it) + if ((*it)->get_name()==attname) + return (*it); + // Attr does not exist + return NULL; +} + + +/*----- PROTECTED REGION ID(SimulatedE2PSClass::Additional Methods) ENABLED START -----*/ +/* clang-format on */ +/* clang-format off */ +/*----- PROTECTED REGION END -----*/ // SimulatedE2PSClass::Additional Methods +} // namespace diff --git a/src/SimulatedE2PSClass.h b/src/SimulatedE2PSClass.h new file mode 100644 index 0000000..64d6ec1 --- /dev/null +++ b/src/SimulatedE2PSClass.h @@ -0,0 +1,294 @@ +/*----- PROTECTED REGION ID(SimulatedE2PSClass.h) ENABLED START -----*/ +/* clang-format on */ +//============================================================================= +// +// file : SimulatedE2PSClass.h +// +// description : Include for the SimulatedE2PS root class. +// This class is the singleton class for +// the SimulatedE2PS device class. +// It contains all properties and methods which the +// SimulatedE2PS requires only once e.g. the commands. +// +// project : SimulatedE2PS +// +// 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/>. +// +// +// +//============================================================================= +// This file is generated by POGO +// (Program Obviously used to Generate tango Object) +//============================================================================= + + +#ifndef SimulatedE2PSClass_H +#define SimulatedE2PSClass_H + +#include <tango/tango.h> +#include "SimulatedE2PS.h" + +/* clang-format off */ +/*----- PROTECTED REGION END -----*/ // SimulatedE2PSClass.h + + +namespace SimulatedE2PS_ns +{ +/*----- PROTECTED REGION ID(SimulatedE2PSClass::classes for dynamic creation) ENABLED START -----*/ +/* clang-format on */ + +/* clang-format off */ +/*----- PROTECTED REGION END -----*/ // SimulatedE2PSClass::classes for dynamic creation + +//========================================= +// Define classes for attributes +//========================================= +// Attribute current class definition +class currentAttrib: public Tango::Attr +{ +public: + currentAttrib():Attr("current", + Tango::DEV_DOUBLE, Tango::READ_WRITE) {}; + ~currentAttrib() {}; + virtual void read(Tango::DeviceImpl *dev,Tango::Attribute &att) + {(static_cast<SimulatedE2PS *>(dev))->read_current(att);} + virtual void write(Tango::DeviceImpl *dev,Tango::WAttribute &att) + {(static_cast<SimulatedE2PS *>(dev))->write_current(att);} + virtual bool is_allowed(Tango::DeviceImpl *dev,Tango::AttReqType ty) + {return (static_cast<SimulatedE2PS *>(dev))->is_current_allowed(ty);} +}; + +// Attribute voltage class definition +class voltageAttrib: public Tango::Attr +{ +public: + voltageAttrib():Attr("voltage", + Tango::DEV_DOUBLE, Tango::READ) {}; + ~voltageAttrib() {}; + virtual void read(Tango::DeviceImpl *dev,Tango::Attribute &att) + {(static_cast<SimulatedE2PS *>(dev))->read_voltage(att);} + virtual bool is_allowed(Tango::DeviceImpl *dev,Tango::AttReqType ty) + {return (static_cast<SimulatedE2PS *>(dev))->is_voltage_allowed(ty);} +}; + +// Attribute currentSet class definition +class currentSetAttrib: public Tango::Attr +{ +public: + currentSetAttrib():Attr("currentSet", + Tango::DEV_DOUBLE, Tango::READ) {}; + ~currentSetAttrib() {}; + virtual void read(Tango::DeviceImpl *dev,Tango::Attribute &att) + {(static_cast<SimulatedE2PS *>(dev))->read_currentSet(att);} + virtual bool is_allowed(Tango::DeviceImpl *dev,Tango::AttReqType ty) + {return (static_cast<SimulatedE2PS *>(dev))->is_currentSet_allowed(ty);} +}; + + +//========================================= +// Define classes for commands +//========================================= +// Command On class definition +class OnClass : public Tango::Command +{ +public: + OnClass(const char *cmd_name, + Tango::CmdArgType in, + Tango::CmdArgType out, + const char *in_desc, + const char *out_desc, + Tango::DispLevel level) + :Command(cmd_name,in,out,in_desc,out_desc, level) {}; + + OnClass(const char *cmd_name, + Tango::CmdArgType in, + Tango::CmdArgType out) + :Command(cmd_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<SimulatedE2PS *>(dev))->is_On_allowed(any);} +}; + +// Command Off class definition +class OffClass : public Tango::Command +{ +public: + OffClass(const char *cmd_name, + Tango::CmdArgType in, + Tango::CmdArgType out, + const char *in_desc, + const char *out_desc, + Tango::DispLevel level) + :Command(cmd_name,in,out,in_desc,out_desc, level) {}; + + OffClass(const char *cmd_name, + Tango::CmdArgType in, + Tango::CmdArgType out) + :Command(cmd_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<SimulatedE2PS *>(dev))->is_Off_allowed(any);} +}; + +// Command Reset class definition +class ResetClass : public Tango::Command +{ +public: + ResetClass(const char *cmd_name, + Tango::CmdArgType in, + Tango::CmdArgType out, + const char *in_desc, + const char *out_desc, + Tango::DispLevel level) + :Command(cmd_name,in,out,in_desc,out_desc, level) {}; + + ResetClass(const char *cmd_name, + Tango::CmdArgType in, + Tango::CmdArgType out) + :Command(cmd_name,in,out) {}; + ~ResetClass() {}; + + 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<SimulatedE2PS *>(dev))->is_Reset_allowed(any);} +}; + +// Command StartCycling class definition +class StartCyclingClass : public Tango::Command +{ +public: + StartCyclingClass(const char *cmd_name, + Tango::CmdArgType in, + Tango::CmdArgType out, + const char *in_desc, + const char *out_desc, + Tango::DispLevel level) + :Command(cmd_name,in,out,in_desc,out_desc, level) {}; + + StartCyclingClass(const char *cmd_name, + Tango::CmdArgType in, + Tango::CmdArgType out) + :Command(cmd_name,in,out) {}; + ~StartCyclingClass() {}; + + 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<SimulatedE2PS *>(dev))->is_StartCycling_allowed(any);} +}; + +// Command Abort class definition +class AbortClass : public Tango::Command +{ +public: + AbortClass(const char *cmd_name, + Tango::CmdArgType in, + Tango::CmdArgType out, + const char *in_desc, + const char *out_desc, + Tango::DispLevel level) + :Command(cmd_name,in,out,in_desc,out_desc, level) {}; + + AbortClass(const char *cmd_name, + Tango::CmdArgType in, + Tango::CmdArgType out) + :Command(cmd_name,in,out) {}; + ~AbortClass() {}; + + 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<SimulatedE2PS *>(dev))->is_Abort_allowed(any);} +}; + +// Command fault class definition +class faultClass : public Tango::Command +{ +public: + faultClass(const char *cmd_name, + Tango::CmdArgType in, + Tango::CmdArgType out, + const char *in_desc, + const char *out_desc, + Tango::DispLevel level) + :Command(cmd_name,in,out,in_desc,out_desc, level) {}; + + faultClass(const char *cmd_name, + Tango::CmdArgType in, + Tango::CmdArgType out) + :Command(cmd_name,in,out) {}; + ~faultClass() {}; + + 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<SimulatedE2PS *>(dev))->is_fault_allowed(any);} +}; + + +/** + * The SimulatedE2PSClass singleton definition + */ + +#ifdef _TG_WINDOWS_ +class __declspec(dllexport) SimulatedE2PSClass : public Tango::DeviceClass +#else +class SimulatedE2PSClass : public Tango::DeviceClass +#endif +{ + /*----- PROTECTED REGION ID(SimulatedE2PSClass::Additional DServer data members) ENABLED START -----*/ + /* clang-format on */ + // Add your own code + /* clang-format off */ + /*----- PROTECTED REGION END -----*/ // SimulatedE2PSClass::Additional 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 SimulatedE2PSClass *init(const char *); + static SimulatedE2PSClass *instance(); + ~SimulatedE2PSClass(); + Tango::DbDatum get_class_property(std::string &); + Tango::DbDatum get_default_device_property(std::string &); + Tango::DbDatum get_default_class_property(std::string &); + + protected: + SimulatedE2PSClass(std::string &); + static SimulatedE2PSClass *_instance; + void command_factory(); + void attribute_factory(std::vector<Tango::Attr *> &); + void pipe_factory(); + void write_class_property(); + void set_default_property(); + void get_class_property(); + std::string get_cvstag(); + std::string get_cvsroot(); + + private: + void device_factory(TANGO_UNUSED(const Tango::DevVarStringArray *)); + void create_static_attribute_list(std::vector<Tango::Attr *> &); + void erase_dynamic_attributes(const Tango::DevVarStringArray *,std::vector<Tango::Attr *> &); + std::vector<std::string> defaultAttList; + Tango::Attr *get_attr_object_by_name(std::vector<Tango::Attr *> &att_list, std::string attname); +}; + +} // End of namespace + +#endif // SimulatedE2PS_H diff --git a/src/SimulatedE2PSStateMachine.cpp b/src/SimulatedE2PSStateMachine.cpp new file mode 100644 index 0000000..3c22fad --- /dev/null +++ b/src/SimulatedE2PSStateMachine.cpp @@ -0,0 +1,213 @@ +/*----- PROTECTED REGION ID(SimulatedE2PSStateMachine.cpp) ENABLED START -----*/ +/* clang-format on */ +//============================================================================= +// +// file : SimulatedE2PSStateMachine.cpp +// +// description : State machine file for the SimulatedE2PS class +// +// project : SimulatedE2PS +// +// 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/>. +// +// +// +//============================================================================= +// This file is generated by POGO +// (Program Obviously used to Generate tango Object) +//============================================================================= + +#include "SimulatedE2PS.h" + +/* clang-format off */ +/*----- PROTECTED REGION END -----*/ // SimulatedE2PS::SimulatedE2PSStateMachine.cpp + +//================================================================ +// States | Description +//================================================================ + + +namespace SimulatedE2PS_ns +{ +//================================================= +// Attributes Allowed Methods +//================================================= + +//-------------------------------------------------------- +/** + * Method : SimulatedE2PS::is_current_allowed() + * Description: Execution allowed for current attribute + */ +//-------------------------------------------------------- +bool SimulatedE2PS::is_current_allowed(TANGO_UNUSED(Tango::AttReqType type)) +{ + // Not any excluded states for current attribute in Write access. + /*----- PROTECTED REGION ID(SimulatedE2PS::currentStateAllowed_WRITE) ENABLED START -----*/ + /* clang-format on */ + /* clang-format off */ + /*----- PROTECTED REGION END -----*/ // SimulatedE2PS::currentStateAllowed_WRITE + + // Not any excluded states for current attribute in read access. + /*----- PROTECTED REGION ID(SimulatedE2PS::currentStateAllowed_READ) ENABLED START -----*/ + /* clang-format on */ + /* clang-format off */ + /*----- PROTECTED REGION END -----*/ // SimulatedE2PS::currentStateAllowed_READ + return true; +} + +//-------------------------------------------------------- +/** + * Method : SimulatedE2PS::is_voltage_allowed() + * Description: Execution allowed for voltage attribute + */ +//-------------------------------------------------------- +bool SimulatedE2PS::is_voltage_allowed(TANGO_UNUSED(Tango::AttReqType type)) +{ + + // Not any excluded states for voltage attribute in read access. + /*----- PROTECTED REGION ID(SimulatedE2PS::voltageStateAllowed_READ) ENABLED START -----*/ + /* clang-format on */ + /* clang-format off */ + /*----- PROTECTED REGION END -----*/ // SimulatedE2PS::voltageStateAllowed_READ + return true; +} + +//-------------------------------------------------------- +/** + * Method : SimulatedE2PS::is_currentSet_allowed() + * Description: Execution allowed for currentSet attribute + */ +//-------------------------------------------------------- +bool SimulatedE2PS::is_currentSet_allowed(TANGO_UNUSED(Tango::AttReqType type)) +{ + + // Not any excluded states for currentSet attribute in read access. + /*----- PROTECTED REGION ID(SimulatedE2PS::currentSetStateAllowed_READ) ENABLED START -----*/ + /* clang-format on */ + /* clang-format off */ + /*----- PROTECTED REGION END -----*/ // SimulatedE2PS::currentSetStateAllowed_READ + return true; +} + + +//================================================= +// Commands Allowed Methods +//================================================= + +//-------------------------------------------------------- +/** + * Method : SimulatedE2PS::is_On_allowed() + * Description: Execution allowed for On attribute + */ +//-------------------------------------------------------- +bool SimulatedE2PS::is_On_allowed(TANGO_UNUSED(const CORBA::Any &any)) +{ + // Not any excluded states for On command. + /*----- PROTECTED REGION ID(SimulatedE2PS::OnStateAllowed) ENABLED START -----*/ + /* clang-format on */ + /* clang-format off */ + /*----- PROTECTED REGION END -----*/ // SimulatedE2PS::OnStateAllowed + return true; +} + +//-------------------------------------------------------- +/** + * Method : SimulatedE2PS::is_Off_allowed() + * Description: Execution allowed for Off attribute + */ +//-------------------------------------------------------- +bool SimulatedE2PS::is_Off_allowed(TANGO_UNUSED(const CORBA::Any &any)) +{ + // Not any excluded states for Off command. + /*----- PROTECTED REGION ID(SimulatedE2PS::OffStateAllowed) ENABLED START -----*/ + /* clang-format on */ + /* clang-format off */ + /*----- PROTECTED REGION END -----*/ // SimulatedE2PS::OffStateAllowed + return true; +} + +//-------------------------------------------------------- +/** + * Method : SimulatedE2PS::is_Reset_allowed() + * Description: Execution allowed for Reset attribute + */ +//-------------------------------------------------------- +bool SimulatedE2PS::is_Reset_allowed(TANGO_UNUSED(const CORBA::Any &any)) +{ + // Not any excluded states for Reset command. + /*----- PROTECTED REGION ID(SimulatedE2PS::ResetStateAllowed) ENABLED START -----*/ + /* clang-format on */ + /* clang-format off */ + /*----- PROTECTED REGION END -----*/ // SimulatedE2PS::ResetStateAllowed + return true; +} + +//-------------------------------------------------------- +/** + * Method : SimulatedE2PS::is_StartCycling_allowed() + * Description: Execution allowed for StartCycling attribute + */ +//-------------------------------------------------------- +bool SimulatedE2PS::is_StartCycling_allowed(TANGO_UNUSED(const CORBA::Any &any)) +{ + // Not any excluded states for StartCycling command. + /*----- PROTECTED REGION ID(SimulatedE2PS::StartCyclingStateAllowed) ENABLED START -----*/ + /* clang-format on */ + /* clang-format off */ + /*----- PROTECTED REGION END -----*/ // SimulatedE2PS::StartCyclingStateAllowed + return true; +} + +//-------------------------------------------------------- +/** + * Method : SimulatedE2PS::is_Abort_allowed() + * Description: Execution allowed for Abort attribute + */ +//-------------------------------------------------------- +bool SimulatedE2PS::is_Abort_allowed(TANGO_UNUSED(const CORBA::Any &any)) +{ + // Not any excluded states for Abort command. + /*----- PROTECTED REGION ID(SimulatedE2PS::AbortStateAllowed) ENABLED START -----*/ + /* clang-format on */ + /* clang-format off */ + /*----- PROTECTED REGION END -----*/ // SimulatedE2PS::AbortStateAllowed + return true; +} + +//-------------------------------------------------------- +/** + * Method : SimulatedE2PS::is_fault_allowed() + * Description: Execution allowed for fault attribute + */ +//-------------------------------------------------------- +bool SimulatedE2PS::is_fault_allowed(TANGO_UNUSED(const CORBA::Any &any)) +{ + // Not any excluded states for fault command. + /*----- PROTECTED REGION ID(SimulatedE2PS::faultStateAllowed) ENABLED START -----*/ + /* clang-format on */ + /* clang-format off */ + /*----- PROTECTED REGION END -----*/ // SimulatedE2PS::faultStateAllowed + return true; +} + + +/*----- PROTECTED REGION ID(SimulatedE2PS::SimulatedE2PSStateAllowed.AdditionalMethods) ENABLED START -----*/ +/* clang-format on */ +// Additional Methods +/* clang-format off */ +/*----- PROTECTED REGION END -----*/ // SimulatedE2PS::SimulatedE2PSStateAllowed.AdditionalMethods + +} // End of namespace diff --git a/src/__pycache__/SimulatedE2PS.cpython-311.pyc b/src/__pycache__/SimulatedE2PS.cpython-311.pyc new file mode 100644 index 0000000000000000000000000000000000000000..4776155043753eaeb9184c90b3b5939ccc153231 GIT binary patch literal 5802 zcmd5=&2JmW6`v)!ON!!(k}S*may_=2I&4y^apJTvjI=@|IZk6qwS+k4A&V7fD6PHZ zGP6smWZi-W1k{J1$f1RE=%I(gO<>=8>!tre!4^6Ydn!=$&>Ic8mz?_EEV<_Dqw>e4 z%iSMm=Dm6I=Dm4uX7`V}o+fbp>dn9M-%JwnPptGVwOiQxGZY>WMhb)}EM_YO1^(l< zQjQg33brNecsWr>$g&D$wV=wf24$_Fm6L^}tS6yQs*oxV6b8!aLRz+^plz@)Sk4qO zP#<9FjaWgCk*kCa?m(TZ595S9f+x5NLu`m;c9cSv4>SEv3|mDeMtJrilpY04fFLWj zDxX}oaWB1Um20-?akg-AWi|b*N~_K`7u2m)t9G5196=Xs?s>wb7xUkz9(O&LzRs)- z%l1s0dfQedmrt*ml?{hl6_1OOS>*I1$8kAyUpHOOs8gX!S65c4C%G8kvWh(YZ&Yk4 zr})WvzFyn7=0PzoY8Cj?<|Rum<`0-KvbA3GxSuRK<+52}xwt<#2dzJ?nYQKC{egMQ zt$xI}xb3H)->L_5f}T3^+!U6_*XmX7>nm23_f;da_Y-B)suV*@K|!to_}^Oxdp;nX zfQLyT#*{)FESq34uHM#q9ax+tm<o@^l8;jlQ($#?f~$}W_`#1VJQ_<s9()KrABDXO zsV+xPM&<y=0MmC!A<c#W2U!*{!-fHMHUc=rMgg<z1mG~p8j1QHT1KNSY;1=_TcWkX ziRY4X@)#*&&n0F27%3;8OUkKZq>Mk8l!;@coI)vl;x^=k;CejyPyt`U6I?*wZ|kXJ zWKOZ^Rg#+#I!I{zGELzM7w1dGB1(9Pc*JfHOnhtJsjb@>Z#5x!#q*UpUwNyczV>eZ zol@h%+9nUQ>L!RT7j+>=Sd|UP0n{v4-CW97nTL_5nZ+V^U0=1$b%@bKtzvn;?m{kL zreKDwW*Ee<ZPtUD21%!EdVZWaMPK>2ad!WhTMp!&4US`B(aq;HF$U%nrw}F(&_iMh zVH%+EHj3y|m2R1KjZ@R5uIC6yQ6S2T&MaRHy$TXA+v2nL3BUv5_0evJ<+~)h8ZevR zC5Ft%&@HHid0WyF*p3(G=3Kn-qibLu3o@I_U8zx+09^_eqgCNlx$rEYIwi>vE*8w= z`HestW>!_;cI6LRAkhetuAee`UQHQYEBcvUn*l!jTJaN*xl1liihi>=yXlm<?G#OW zwrHC*W;wI2D9&zJ9=LOsd9%!&b$dGrzgUGDkfS<P>*8A=tuYyG?$c`p$nGpall&_+ zw40jx@}0k>=x&O(QnWoWeLwNJ-us(5b3d`0nrz8?54w<upHOY-Ck+a)Ln~m_SmVld z?rl1Zn)bF?cPalFFT$3>=sJg`2FsvQr)zUdSC?sbkD=Bxru@>^M4SU@fl0)-q3DkV zl8l}tW7Bc&G|ojQco@$u=)H%!HRVsd2F2qiVCpch4`2xDIh1kOk2w|Gb!q}a3uc85 z!uh}|?z3t>EwhQt2b(aXa?c31v+c^A9VcGqWk=L0?DGypfH+Dn&_Zc_WAucAUhAln z&2h)iLk8*_5yplEWTV0Ba?J*-F_g#PP$6nXh(x)@BTV!fEZ?4A@?n=HaRDrMz%P1W zobGaOOh+9OA%2Sea|lQKU>L{`$X#+9{(}palhQbSgL^d*WQ<-?3F9=MQ^XlyKA>Ah zaFg|7tuYl<t)FH?@4XB_lXNsPJofo7TB(^p%P^Gy_3))WwaPtd<AaI?Hp|7tdFbt{ zG6lLQk<wsQ>)Uu<3RT=^y$JC$=;jUpNF4|C`-xXGV=tvg%t%505oYZ2A8N)fZ3}zn z5nkBA^q_;$tP$nT9;RHj-;dCxar$UC1NrA5!^Mri>*?JrX1xEQZzQXI5Jto5w&fK! zBm465(z9T>EN~~jOjqjiT#$!N{$s~tVfQ0~DYjf`3`g}}uIzxedtJwml4BenQTM}e zync0iFB;2>i?6J3e7RI=jO^36RQduv^+SZC7eYkSPeV;_aJL&y@~x<Q=7D5q(rs?r z^iIXuuD}@rvhOQvugbw1C!+ex#^1f@407QNUefm&c#jg^`}Lv?hr0by)=&EiRO=;z z;TKvDi=mEi2CGs5$41<Riouv6@g*mq&aFGb+iy+T_@{_9;eAu@9Y1Y+jXZukZmfpd zEjq9T!)kDQXCPWKYqnR19jn4T%c+E%FFOw@Z~r`G<6rtrKlaS@OSx${=NT2V%nid& z8%Eh-H5<zr!}tu|n!A*wVZZ^~Fa)lBF$mzNZ!FBs8#ixUTU!t#*pTcU64Tx71d^6K z%!${r(;EoiLwF0}ZG=k*Nd!EHi60<bM!16T9>R|iFo*cs!Y3;WH`c`a*dljy3{klo z$rmCC=b_1Mz(&;!f1OxdO?3#uILS`jx7tIK?d;5M_CkB;R9hczk59HwPPDV*?aZal z$Us(mLI9p3G_Uq`iEz$#^dxcuJVgM`Q8GIH#Uu)kaLxheC~}S>=cv~FursBqv_nD| zRn(s-9nyzsP0e&j2s3f@G)|xk>A0$6wF^+)M?H(wE{qaQZ{B=D6b*(4_=lQl-n@5f z=T;}Cp#*>@aiV2+Zaq<ZJRJ>5|7Sf_)E3|nZILwmit}ubpV=M%PA4AIz*hiI5#UIL z);ru>$&f46v!pcV!JR{eMTs%9_a;E}h0yCerInNtd>Xt<Eak592j$nn>&SPn!{;Vi zs#S`ZAr5_!qe0N-{e&qtTsX5OU>F$<P`(ajU%Ru7r2Ye(7(yn5U3lDc08R2AjbyUF z)mzy!t-(uh|DFMSRSGJt#3ea3Oc?kL%rJ7wQf@?Cg|5CTzt_ny_A|1ace&W&B2We` z5abRS?fAt@2DQL%XEL7%JjD8tXW;M;c?J(Ufr|53iiZ0)sVl*h-xI4q#lx+860j3j z6s0q!DhXIA0OLf_n;HDI$z&^fx5-Q^dbi1$R`hO@H(H0?ZE~@7^xY=;)?s%iO)}G8 zF1FI=o5_w=iYc(3563SSpGeBne)_r^SKfudj=&g6WbQZq9-nN*C)<fsbN=4q&SF#k NI&qSif@bNn{{r<-gg5{I literal 0 HcmV?d00001 diff --git a/src/main.cpp b/src/main.cpp new file mode 100644 index 0000000..281e19b --- /dev/null +++ b/src/main.cpp @@ -0,0 +1,88 @@ +/*----- PROTECTED REGION ID(SimulatedE2PS::main.cpp) ENABLED START -----*/ +/* clang-format on */ +//============================================================================= +// +// file : main.cpp +// +// description : C++ source for the SimulatedE2PS 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 : SimulatedE2PS +// +// 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/>. +// +// +// +//============================================================================= +// This file is generated by POGO +// (Program Obviously used to Generate tango Object) +//============================================================================= +#include <tango/tango.h> + +// Check if crash reporting is used. +#if defined(ENABLE_CRASH_REPORT) +# include <crashreporting/crash_report.h> +#else +# define DECLARE_CRASH_HANDLER +# define INSTALL_CRASH_HANDLER +#endif + +DECLARE_CRASH_HANDLER + +int main(int argc,char *argv[]) +{ + INSTALL_CRASH_HANDLER + Tango::Util *tg = nullptr; + 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 + //---------------------------------------- + std::cout << "Ready to accept request" << std::endl; + tg->server_run(); + } + catch (std::bad_alloc &) + { + std::cout << "Can't allocate memory to store device object !!!" << std::endl; + std::cout << "Exiting" << std::endl; + } + catch (CORBA::Exception &e) + { + Tango::Except::print_exception(e); + + std::cout << "Received a CORBA_Exception" << std::endl; + std::cout << "Exiting" << std::endl; + } + + if(tg) + { + tg->server_cleanup(); + } + return(0); +} + +/* clang-format off */ +/*----- PROTECTED REGION END -----*/ // SimulatedE2PS::main.cpp -- GitLab