From c1620c034a2c2df2afe2ff359519b38ba69d0763 Mon Sep 17 00:00:00 2001 From: Giulio Gaio <giulio.gaio@elettra.eu> Date: Fri, 14 Aug 2020 11:36:35 +0200 Subject: [PATCH] First import --- Makefile | 6 + src/ClassFactory.cpp | 50 +++ src/SeqUtils.cpp | 763 ++++++++++++++++++++++++++++++++ src/SeqUtils.h | 329 ++++++++++++++ src/SeqUtils.xmi | 185 ++++++++ src/SeqUtilsClass.cpp | 902 ++++++++++++++++++++++++++++++++++++++ src/SeqUtilsClass.h | 408 +++++++++++++++++ src/UtilsStateMachine.cpp | 386 ++++++++++++++++ src/main.cpp | 81 ++++ 9 files changed, 3110 insertions(+) create mode 100644 Makefile create mode 100644 src/ClassFactory.cpp create mode 100644 src/SeqUtils.cpp create mode 100644 src/SeqUtils.h create mode 100644 src/SeqUtils.xmi create mode 100644 src/SeqUtilsClass.cpp create mode 100644 src/SeqUtilsClass.h create mode 100644 src/UtilsStateMachine.cpp create mode 100644 src/main.cpp diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..b740453 --- /dev/null +++ b/Makefile @@ -0,0 +1,6 @@ +NAME_SRV = sequtils-srv + +CXXFLAGS = +LDFLAGS = + +include ../makefiles/Make-9.3.3.in diff --git a/src/ClassFactory.cpp b/src/ClassFactory.cpp new file mode 100644 index 0000000..00861c3 --- /dev/null +++ b/src/ClassFactory.cpp @@ -0,0 +1,50 @@ +/*----- PROTECTED REGION ID(SeqUtils::ClassFactory.cpp) ENABLED START -----*/ +//============================================================================= +// +// 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 : SeqUtils +// +// 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.h> +#include <SeqUtilsClass.h> + +// Add class header files if needed + + +/** + * Create SeqUtils Class singleton and store it in DServer object. + */ + +void Tango::DServer::class_factory() +{ + // Add method class init if needed + add_class(SeqUtils_ns::SeqUtilsClass::init("SeqUtils")); +} +/*----- PROTECTED REGION END -----*/ // SeqUtils::ClassFactory.cpp diff --git a/src/SeqUtils.cpp b/src/SeqUtils.cpp new file mode 100644 index 0000000..f67f8c6 --- /dev/null +++ b/src/SeqUtils.cpp @@ -0,0 +1,763 @@ +/*----- PROTECTED REGION ID(SeqUtils.cpp) ENABLED START -----*/ +//============================================================================= +// +// file : SeqUtils.cpp +// +// description : C++ source for the SeqUtils 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 +// SeqUtils are implemented in this file. +// +// project : SeqUtils +// +// 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 <SeqUtils.h> +#include <SeqUtilsClass.h> +#include <stdio.h> +#include <time.h> + +/*----- PROTECTED REGION END -----*/ // SeqUtils.cpp + +/** + * SeqUtils class description: + * It returns a random generated number, sec/nsec date + */ + +//================================================================ +// 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 +// SetFault | set_fault +// Start | start +// Stop | stop +//================================================================ + +//================================================================ +// Attributes managed are: +//================================================================ +// DRand | Tango::DevDouble Scalar +// DRandMin | Tango::DevDouble Scalar +// DRandMax | Tango::DevDouble Scalar +// LRand | Tango::DevLong Scalar +// LRandMin | Tango::DevLong Scalar +// LRandMax | Tango::DevLong Scalar +// Data | Tango::DevDouble Scalar +// Data1 | Tango::DevDouble Scalar +// LData | Tango::DevLong Scalar +// Date | Tango::DevLong Spectrum ( max = 2) +// LDate | Tango::DevLong Spectrum ( max = 2) +//================================================================ + +namespace SeqUtils_ns +{ +/*----- PROTECTED REGION ID(SeqUtils::namespace_starting) ENABLED START -----*/ + +// static initializations + +/*----- PROTECTED REGION END -----*/ // SeqUtils::namespace_starting + +//-------------------------------------------------------- +/** + * Method : SeqUtils::SeqUtils() + * Description : Constructors for a Tango device + * implementing the classSeqUtils + */ +//-------------------------------------------------------- +SeqUtils::SeqUtils(Tango::DeviceClass *cl, string &s) + : TANGO_BASE_CLASS(cl, s.c_str()) +{ + /*----- PROTECTED REGION ID(SeqUtils::constructor_1) ENABLED START -----*/ + init_device(); + + /*----- PROTECTED REGION END -----*/ // SeqUtils::constructor_1 +} +//-------------------------------------------------------- +SeqUtils::SeqUtils(Tango::DeviceClass *cl, const char *s) + : TANGO_BASE_CLASS(cl, s) +{ + /*----- PROTECTED REGION ID(SeqUtils::constructor_2) ENABLED START -----*/ + init_device(); + + /*----- PROTECTED REGION END -----*/ // SeqUtils::constructor_2 +} +//-------------------------------------------------------- +SeqUtils::SeqUtils(Tango::DeviceClass *cl, const char *s, const char *d) + : TANGO_BASE_CLASS(cl, s, d) +{ + /*----- PROTECTED REGION ID(SeqUtils::constructor_3) ENABLED START -----*/ + init_device(); + + /*----- PROTECTED REGION END -----*/ // SeqUtils::constructor_3 +} + +//-------------------------------------------------------- +/** + * Method : SeqUtils::delete_device() + * Description : will be called at device destruction or at init command + */ +//-------------------------------------------------------- +void SeqUtils::delete_device() +{ + DEBUG_STREAM << "SeqUtils::delete_device() " << device_name << endl; + /*----- PROTECTED REGION ID(SeqUtils::delete_device) ENABLED START -----*/ + + // Delete device allocated objects + + /*----- PROTECTED REGION END -----*/ // SeqUtils::delete_device + delete[] attr_DRand_read; + delete[] attr_DRandMin_read; + delete[] attr_DRandMax_read; + delete[] attr_LRand_read; + delete[] attr_LRandMin_read; + delete[] attr_LRandMax_read; + delete[] attr_Data_read; + delete[] attr_Data1_read; + delete[] attr_LData_read; + delete[] attr_Date_read; + delete[] attr_LDate_read; +} + +//-------------------------------------------------------- +/** + * Method : SeqUtils::init_device() + * Description : will be called at device initialization. + */ +//-------------------------------------------------------- +void SeqUtils::init_device() +{ + DEBUG_STREAM << "SeqUtils::init_device() create device " << device_name << endl; + /*----- PROTECTED REGION ID(SeqUtils::init_device_before) ENABLED START -----*/ + + // Initialization before get_device_property() call + + /*----- PROTECTED REGION END -----*/ // SeqUtils::init_device_before + + // No device property to be read from database + + attr_DRand_read = new Tango::DevDouble[1]; + attr_DRandMin_read = new Tango::DevDouble[1]; + attr_DRandMax_read = new Tango::DevDouble[1]; + attr_LRand_read = new Tango::DevLong[1]; + attr_LRandMin_read = new Tango::DevLong[1]; + attr_LRandMax_read = new Tango::DevLong[1]; + attr_Data_read = new Tango::DevDouble[1]; + attr_Data1_read = new Tango::DevDouble[1]; + attr_LData_read = new Tango::DevLong[1]; + attr_Date_read = new Tango::DevLong[2]; + attr_LDate_read = new Tango::DevLong[2]; + /*----- PROTECTED REGION ID(SeqUtils::init_device) ENABLED START -----*/ + + // Initialize device + *attr_DRandMin_read = -1; + *attr_DRandMax_read = 1; + *attr_LRandMin_read = -2147483646; + *attr_LRandMax_read = 2147483647; + + *attr_LData_read = 0; + *attr_Data_read = 0; + *attr_Data1_read = 0; + + set_state(Tango::ON); + srand(time(NULL)); + + + /*----- PROTECTED REGION END -----*/ // SeqUtils::init_device +} + + +//-------------------------------------------------------- +/** + * Method : SeqUtils::always_executed_hook() + * Description : method always executed before any command is executed + */ +//-------------------------------------------------------- +void SeqUtils::always_executed_hook() +{ + DEBUG_STREAM << "SeqUtils::always_executed_hook() " << device_name << endl; + /*----- PROTECTED REGION ID(SeqUtils::always_executed_hook) ENABLED START -----*/ + + // code always executed before all requests + + /*----- PROTECTED REGION END -----*/ // SeqUtils::always_executed_hook +} + +//-------------------------------------------------------- +/** + * Method : SeqUtils::read_attr_hardware() + * Description : Hardware acquisition for attributes + */ +//-------------------------------------------------------- +void SeqUtils::read_attr_hardware(TANGO_UNUSED(vector<long> &attr_list)) +{ + DEBUG_STREAM << "SeqUtils::read_attr_hardware(vector<long> &attr_list) entering... " << endl; + /*----- PROTECTED REGION ID(SeqUtils::read_attr_hardware) ENABLED START -----*/ + + // Add your own code + + /*----- PROTECTED REGION END -----*/ // SeqUtils::read_attr_hardware +} +//-------------------------------------------------------- +/** + * Method : SeqUtils::write_attr_hardware() + * Description : Hardware writing for attributes + */ +//-------------------------------------------------------- +void SeqUtils::write_attr_hardware(TANGO_UNUSED(vector<long> &attr_list)) +{ + DEBUG_STREAM << "SeqUtils::write_attr_hardware(vector<long> &attr_list) entering... " << endl; + /*----- PROTECTED REGION ID(SeqUtils::write_attr_hardware) ENABLED START -----*/ + + // Add your own code + + /*----- PROTECTED REGION END -----*/ // SeqUtils::write_attr_hardware +} + +//-------------------------------------------------------- +/** + * Read attribute DRand related method + * Description: + * + * Data type: Tango::DevDouble + * Attr type: Scalar + */ +//-------------------------------------------------------- +void SeqUtils::read_DRand(Tango::Attribute &attr) +{ + DEBUG_STREAM << "SeqUtils::read_DRand(Tango::Attribute &attr) entering... " << endl; + /*----- PROTECTED REGION ID(SeqUtils::read_DRand) ENABLED START -----*/ + // Set the attribute value + + double a = ((double)rand() / (double)RAND_MAX); + INFO_STREAM << __FUNCTION__ << " rand value: " << a << endl; + + + *attr_DRand_read = a * (*attr_DRandMax_read-*attr_DRandMin_read) + + *attr_DRandMin_read; + attr.set_value(attr_DRand_read); + + /*----- PROTECTED REGION END -----*/ // SeqUtils::read_DRand +} +//-------------------------------------------------------- +/** + * Read attribute DRandMin related method + * Description: + * + * Data type: Tango::DevDouble + * Attr type: Scalar + */ +//-------------------------------------------------------- +void SeqUtils::read_DRandMin(Tango::Attribute &attr) +{ + DEBUG_STREAM << "SeqUtils::read_DRandMin(Tango::Attribute &attr) entering... " << endl; + /*----- PROTECTED REGION ID(SeqUtils::read_DRandMin) ENABLED START -----*/ + // Set the attribute value + + attr.set_value(attr_DRandMin_read); + + /*----- PROTECTED REGION END -----*/ // SeqUtils::read_DRandMin +} +//-------------------------------------------------------- +/** + * Write attribute DRandMin related method + * Description: + * + * Data type: Tango::DevDouble + * Attr type: Scalar + */ +//-------------------------------------------------------- +void SeqUtils::write_DRandMin(Tango::WAttribute &attr) +{ + DEBUG_STREAM << "SeqUtils::write_DRandMin(Tango::WAttribute &attr) entering... " << endl; + // Retrieve write value + Tango::DevDouble w_val; + attr.get_write_value(w_val); + /*----- PROTECTED REGION ID(SeqUtils::write_DRandMin) ENABLED START -----*/ + *attr_DRandMin_read = w_val; + + /*----- PROTECTED REGION END -----*/ // SeqUtils::write_DRandMin +} +//-------------------------------------------------------- +/** + * Read attribute DRandMax related method + * Description: + * + * Data type: Tango::DevDouble + * Attr type: Scalar + */ +//-------------------------------------------------------- +void SeqUtils::read_DRandMax(Tango::Attribute &attr) +{ + DEBUG_STREAM << "SeqUtils::read_DRandMax(Tango::Attribute &attr) entering... " << endl; + /*----- PROTECTED REGION ID(SeqUtils::read_DRandMax) ENABLED START -----*/ + // Set the attribute value + attr.set_value(attr_DRandMax_read); + + /*----- PROTECTED REGION END -----*/ // SeqUtils::read_DRandMax +} +//-------------------------------------------------------- +/** + * Write attribute DRandMax related method + * Description: + * + * Data type: Tango::DevDouble + * Attr type: Scalar + */ +//-------------------------------------------------------- +void SeqUtils::write_DRandMax(Tango::WAttribute &attr) +{ + DEBUG_STREAM << "SeqUtils::write_DRandMax(Tango::WAttribute &attr) entering... " << endl; + // Retrieve write value + Tango::DevDouble w_val; + attr.get_write_value(w_val); + /*----- PROTECTED REGION ID(SeqUtils::write_DRandMax) ENABLED START -----*/ + *attr_DRandMax_read = w_val; + + /*----- PROTECTED REGION END -----*/ // SeqUtils::write_DRandMax +} +//-------------------------------------------------------- +/** + * Read attribute LRand related method + * Description: + * + * Data type: Tango::DevLong + * Attr type: Scalar + */ +//-------------------------------------------------------- +void SeqUtils::read_LRand(Tango::Attribute &attr) +{ + DEBUG_STREAM << "SeqUtils::read_LRand(Tango::Attribute &attr) entering... " << endl; + /*----- PROTECTED REGION ID(SeqUtils::read_LRand) ENABLED START -----*/ + // Set the attribute value + Tango::DevLong a = (Tango::DevLong)rand(); + INFO_STREAM << __FUNCTION__ << " rand value: " << a << endl; + + + *attr_LRand_read = (a %(*attr_LRandMax_read-*attr_LRandMin_read+1))+*attr_LRandMin_read; + attr.set_value(attr_LRand_read); + + /*----- PROTECTED REGION END -----*/ // SeqUtils::read_LRand +} +//-------------------------------------------------------- +/** + * Read attribute LRandMin related method + * Description: + * + * Data type: Tango::DevLong + * Attr type: Scalar + */ +//-------------------------------------------------------- +void SeqUtils::read_LRandMin(Tango::Attribute &attr) +{ + DEBUG_STREAM << "SeqUtils::read_LRandMin(Tango::Attribute &attr) entering... " << endl; + /*----- PROTECTED REGION ID(SeqUtils::read_LRandMin) ENABLED START -----*/ + // Set the attribute value + attr.set_value(attr_LRandMin_read); + + /*----- PROTECTED REGION END -----*/ // SeqUtils::read_LRandMin +} +//-------------------------------------------------------- +/** + * Write attribute LRandMin related method + * Description: + * + * Data type: Tango::DevLong + * Attr type: Scalar + */ +//-------------------------------------------------------- +void SeqUtils::write_LRandMin(Tango::WAttribute &attr) +{ + DEBUG_STREAM << "SeqUtils::write_LRandMin(Tango::WAttribute &attr) entering... " << endl; + // Retrieve write value + Tango::DevLong w_val; + attr.get_write_value(w_val); + /*----- PROTECTED REGION ID(SeqUtils::write_LRandMin) ENABLED START -----*/ + *attr_LRandMin_read = w_val; + + /*----- PROTECTED REGION END -----*/ // SeqUtils::write_LRandMin +} +//-------------------------------------------------------- +/** + * Read attribute LRandMax related method + * Description: + * + * Data type: Tango::DevLong + * Attr type: Scalar + */ +//-------------------------------------------------------- +void SeqUtils::read_LRandMax(Tango::Attribute &attr) +{ + DEBUG_STREAM << "SeqUtils::read_LRandMax(Tango::Attribute &attr) entering... " << endl; + /*----- PROTECTED REGION ID(SeqUtils::read_LRandMax) ENABLED START -----*/ + // Set the attribute value + attr.set_value(attr_LRandMax_read); + + /*----- PROTECTED REGION END -----*/ // SeqUtils::read_LRandMax +} +//-------------------------------------------------------- +/** + * Write attribute LRandMax related method + * Description: + * + * Data type: Tango::DevLong + * Attr type: Scalar + */ +//-------------------------------------------------------- +void SeqUtils::write_LRandMax(Tango::WAttribute &attr) +{ + DEBUG_STREAM << "SeqUtils::write_LRandMax(Tango::WAttribute &attr) entering... " << endl; + // Retrieve write value + Tango::DevLong w_val; + attr.get_write_value(w_val); + /*----- PROTECTED REGION ID(SeqUtils::write_LRandMax) ENABLED START -----*/ + *attr_LRandMax_read = w_val; + + /*----- PROTECTED REGION END -----*/ // SeqUtils::write_LRandMax +} +//-------------------------------------------------------- +/** + * Read attribute Data related method + * Description: + * + * Data type: Tango::DevDouble + * Attr type: Scalar + */ +//-------------------------------------------------------- +void SeqUtils::read_Data(Tango::Attribute &attr) +{ + DEBUG_STREAM << "SeqUtils::read_Data(Tango::Attribute &attr) entering... " << endl; + /*----- PROTECTED REGION ID(SeqUtils::read_Data) ENABLED START -----*/ + // Set the attribute value + attr.set_value(attr_Data_read); + + /*----- PROTECTED REGION END -----*/ // SeqUtils::read_Data +} +//-------------------------------------------------------- +/** + * Write attribute Data related method + * Description: + * + * Data type: Tango::DevDouble + * Attr type: Scalar + */ +//-------------------------------------------------------- +void SeqUtils::write_Data(Tango::WAttribute &attr) +{ + DEBUG_STREAM << "SeqUtils::write_Data(Tango::WAttribute &attr) entering... " << endl; + // Retrieve write value + Tango::DevDouble w_val; + attr.get_write_value(w_val); + /*----- PROTECTED REGION ID(SeqUtils::write_Data) ENABLED START -----*/ + *attr_Data_read = w_val; + + /*----- PROTECTED REGION END -----*/ // SeqUtils::write_Data +} +//-------------------------------------------------------- +/** + * Read attribute Data1 related method + * Description: + * + * Data type: Tango::DevDouble + * Attr type: Scalar + */ +//-------------------------------------------------------- +void SeqUtils::read_Data1(Tango::Attribute &attr) +{ + DEBUG_STREAM << "SeqUtils::read_Data1(Tango::Attribute &attr) entering... " << endl; + /*----- PROTECTED REGION ID(SeqUtils::read_Data1) ENABLED START -----*/ + // Set the attribute value + attr.set_value(attr_Data1_read); + + /*----- PROTECTED REGION END -----*/ // SeqUtils::read_Data1 +} +//-------------------------------------------------------- +/** + * Write attribute Data1 related method + * Description: + * + * Data type: Tango::DevDouble + * Attr type: Scalar + */ +//-------------------------------------------------------- +void SeqUtils::write_Data1(Tango::WAttribute &attr) +{ + DEBUG_STREAM << "SeqUtils::write_Data1(Tango::WAttribute &attr) entering... " << endl; + // Retrieve write value + Tango::DevDouble w_val; + attr.get_write_value(w_val); + /*----- PROTECTED REGION ID(SeqUtils::write_Data1) ENABLED START -----*/ + + + /*----- PROTECTED REGION END -----*/ // SeqUtils::write_Data1 +} +//-------------------------------------------------------- +/** + * Read attribute LData related method + * Description: + * + * Data type: Tango::DevLong + * Attr type: Scalar + */ +//-------------------------------------------------------- +void SeqUtils::read_LData(Tango::Attribute &attr) +{ + DEBUG_STREAM << "SeqUtils::read_LData(Tango::Attribute &attr) entering... " << endl; + /*----- PROTECTED REGION ID(SeqUtils::read_LData) ENABLED START -----*/ + // Set the attribute value + attr.set_value(attr_LData_read); + + /*----- PROTECTED REGION END -----*/ // SeqUtils::read_LData +} +//-------------------------------------------------------- +/** + * Write attribute LData related method + * Description: + * + * Data type: Tango::DevLong + * Attr type: Scalar + */ +//-------------------------------------------------------- +void SeqUtils::write_LData(Tango::WAttribute &attr) +{ + DEBUG_STREAM << "SeqUtils::write_LData(Tango::WAttribute &attr) entering... " << endl; + // Retrieve write value + Tango::DevLong w_val; + attr.get_write_value(w_val); + /*----- PROTECTED REGION ID(SeqUtils::write_LData) ENABLED START -----*/ + + + /*----- PROTECTED REGION END -----*/ // SeqUtils::write_LData +} +//-------------------------------------------------------- +/** + * Read attribute Date related method + * Description: + * + * Data type: Tango::DevLong + * Attr type: Spectrum max = 2 + */ +//-------------------------------------------------------- +void SeqUtils::read_Date(Tango::Attribute &attr) +{ + DEBUG_STREAM << "SeqUtils::read_Date(Tango::Attribute &attr) entering... " << endl; + /*----- PROTECTED REGION ID(SeqUtils::read_Date) ENABLED START -----*/ + // Set the attribute value + struct timespec t0; + clock_gettime(CLOCK_REALTIME, &t0); + + attr_Date_read[0] = (Tango::DevLong) t0.tv_sec; + attr_Date_read[1] = (Tango::DevLong) t0.tv_nsec; + + attr.set_value(attr_Date_read, 2); + + /*----- PROTECTED REGION END -----*/ // SeqUtils::read_Date +} +//-------------------------------------------------------- +/** + * Read attribute LDate related method + * Description: + * + * Data type: Tango::DevLong + * Attr type: Spectrum max = 2 + */ +//-------------------------------------------------------- +void SeqUtils::read_LDate(Tango::Attribute &attr) +{ + DEBUG_STREAM << "SeqUtils::read_LDate(Tango::Attribute &attr) entering... " << endl; + /*----- PROTECTED REGION ID(SeqUtils::read_LDate) ENABLED START -----*/ + // Set the attribute value + struct timespec t0; + clock_gettime(CLOCK_REALTIME, &t0); + + attr_LDate_read[0] = (Tango::DevLong64) t0.tv_sec; + attr_LDate_read[1] = (Tango::DevLong64) t0.tv_nsec; + + attr.set_value(attr_LDate_read, 2); + + /*----- PROTECTED REGION END -----*/ // SeqUtils::read_LDate +} + +//-------------------------------------------------------- +/** + * Method : SeqUtils::add_dynamic_attributes() + * Description : Create the dynamic attributes if any + * for specified device. + */ +//-------------------------------------------------------- +void SeqUtils::add_dynamic_attributes() +{ + /*----- PROTECTED REGION ID(SeqUtils::add_dynamic_attributes) ENABLED START -----*/ + + // Add your own code to create and add dynamic attributes if any + + /*----- PROTECTED REGION END -----*/ // SeqUtils::add_dynamic_attributes +} + +//-------------------------------------------------------- +/** + * Command On related method + * Description: + * + */ +//-------------------------------------------------------- +void SeqUtils::on() +{ + DEBUG_STREAM << "SeqUtils::On() - " << device_name << endl; + /*----- PROTECTED REGION ID(SeqUtils::on) ENABLED START -----*/ + + // Add your own code + set_state(Tango::ON); + /*----- PROTECTED REGION END -----*/ // SeqUtils::on +} +//-------------------------------------------------------- +/** + * Command Off related method + * Description: + * + */ +//-------------------------------------------------------- +void SeqUtils::off() +{ + DEBUG_STREAM << "SeqUtils::Off() - " << device_name << endl; + /*----- PROTECTED REGION ID(SeqUtils::off) ENABLED START -----*/ + + // Add your own code + *attr_Data_read = 0; + *attr_Data1_read = 0; + set_state(Tango::OFF); + /*----- PROTECTED REGION END -----*/ // SeqUtils::off +} +//-------------------------------------------------------- +/** + * Command Reset related method + * Description: + * + */ +//-------------------------------------------------------- +void SeqUtils::reset() +{ + DEBUG_STREAM << "SeqUtils::Reset() - " << device_name << endl; + /*----- PROTECTED REGION ID(SeqUtils::reset) ENABLED START -----*/ + + // Add your own code + *attr_Data_read = 0; + *attr_Data1_read = 0; + set_state(Tango::OFF); + /*----- PROTECTED REGION END -----*/ // SeqUtils::reset +} +//-------------------------------------------------------- +/** + * Command SetFault related method + * Description: + * + */ +//-------------------------------------------------------- +void SeqUtils::set_fault() +{ + DEBUG_STREAM << "SeqUtils::SetFault() - " << device_name << endl; + /*----- PROTECTED REGION ID(SeqUtils::set_fault) ENABLED START -----*/ + + // Add your own code + *attr_Data_read = 0; + *attr_Data1_read = 0; + set_state(Tango::FAULT); + /*----- PROTECTED REGION END -----*/ // SeqUtils::set_fault +} +//-------------------------------------------------------- +/** + * Command Start related method + * Description: + * + */ +//-------------------------------------------------------- +void SeqUtils::start() +{ + DEBUG_STREAM << "SeqUtils::Start() - " << device_name << endl; + /*----- PROTECTED REGION ID(SeqUtils::start) ENABLED START -----*/ + + // Add your own code + + /*----- PROTECTED REGION END -----*/ // SeqUtils::start +} +//-------------------------------------------------------- +/** + * Command Stop related method + * Description: + * + */ +//-------------------------------------------------------- +void SeqUtils::stop() +{ + DEBUG_STREAM << "SeqUtils::Stop() - " << device_name << endl; + /*----- PROTECTED REGION ID(SeqUtils::stop) ENABLED START -----*/ + + // Add your own code + + /*----- PROTECTED REGION END -----*/ // SeqUtils::stop +} +//-------------------------------------------------------- +/** + * Method : SeqUtils::add_dynamic_commands() + * Description : Create the dynamic commands if any + * for specified device. + */ +//-------------------------------------------------------- +void SeqUtils::add_dynamic_commands() +{ + /*----- PROTECTED REGION ID(SeqUtils::add_dynamic_commands) ENABLED START -----*/ + + // Add your own code to create and add dynamic commands if any + + /*----- PROTECTED REGION END -----*/ // SeqUtils::add_dynamic_commands +} + +/*----- PROTECTED REGION ID(SeqUtils::namespace_ending) ENABLED START -----*/ + +// Additional Methods +// //-------------------------------------------------------- +// /** +// * Command Standby related method +// * Description: +// * +// */ +// //-------------------------------------------------------- +// void SeqUtils::standby() +// { +// DEBUG_STREAM << "SeqUtils::Standby() - " << device_name << endl; +// +// // Add your own code +// set_state(Tango::STANDBY); +// } + + +/*----- PROTECTED REGION END -----*/ // SeqUtils::namespace_ending +} // namespace diff --git a/src/SeqUtils.h b/src/SeqUtils.h new file mode 100644 index 0000000..7a29606 --- /dev/null +++ b/src/SeqUtils.h @@ -0,0 +1,329 @@ +/*----- PROTECTED REGION ID(SeqUtils.h) ENABLED START -----*/ +//============================================================================= +// +// file : SeqUtils.h +// +// description : Include file for the SeqUtils class +// +// project : SeqUtils +// +// 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 SeqUtils_H +#define SeqUtils_H + +#include <tango.h> + + +/*----- PROTECTED REGION END -----*/ // SeqUtils.h + +/** + * SeqUtils class description: + * It returns a random generated number, sec/nsec date + */ + +namespace SeqUtils_ns +{ +/*----- PROTECTED REGION ID(SeqUtils::Additional Class Declarations) ENABLED START -----*/ + +// Additional Class Declarations + +/*----- PROTECTED REGION END -----*/ // SeqUtils::Additional Class Declarations + +class SeqUtils : public TANGO_BASE_CLASS +{ + +/*----- PROTECTED REGION ID(SeqUtils::Data Members) ENABLED START -----*/ + +// Add your own data members + +/*----- PROTECTED REGION END -----*/ // SeqUtils::Data Members + + +// Attribute data members +public: + Tango::DevDouble *attr_DRand_read; + Tango::DevDouble *attr_DRandMin_read; + Tango::DevDouble *attr_DRandMax_read; + Tango::DevLong *attr_LRand_read; + Tango::DevLong *attr_LRandMin_read; + Tango::DevLong *attr_LRandMax_read; + Tango::DevDouble *attr_Data_read; + Tango::DevDouble *attr_Data1_read; + Tango::DevLong *attr_LData_read; + Tango::DevLong *attr_Date_read; + Tango::DevLong *attr_LDate_read; + +// Constructors and destructors +public: + /** + * Constructs a newly device object. + * + * @param cl Class. + * @param s Device Name + */ + SeqUtils(Tango::DeviceClass *cl,string &s); + /** + * Constructs a newly device object. + * + * @param cl Class. + * @param s Device Name + */ + SeqUtils(Tango::DeviceClass *cl,const char *s); + /** + * Constructs a newly device object. + * + * @param cl Class. + * @param s Device name + * @param d Device description. + */ + SeqUtils(Tango::DeviceClass *cl,const char *s,const char *d); + /** + * The device object destructor. + */ + ~SeqUtils() {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 : SeqUtils::read_attr_hardware() + * Description : Hardware acquisition for attributes. + */ + //-------------------------------------------------------- + virtual void read_attr_hardware(vector<long> &attr_list); + //-------------------------------------------------------- + /* + * Method : SeqUtils::write_attr_hardware() + * Description : Hardware writing for attributes. + */ + //-------------------------------------------------------- + virtual void write_attr_hardware(vector<long> &attr_list); + +/** + * Attribute DRand related methods + * Description: + * + * Data type: Tango::DevDouble + * Attr type: Scalar + */ + virtual void read_DRand(Tango::Attribute &attr); + virtual bool is_DRand_allowed(Tango::AttReqType type); +/** + * Attribute DRandMin related methods + * Description: + * + * Data type: Tango::DevDouble + * Attr type: Scalar + */ + virtual void read_DRandMin(Tango::Attribute &attr); + virtual void write_DRandMin(Tango::WAttribute &attr); + virtual bool is_DRandMin_allowed(Tango::AttReqType type); +/** + * Attribute DRandMax related methods + * Description: + * + * Data type: Tango::DevDouble + * Attr type: Scalar + */ + virtual void read_DRandMax(Tango::Attribute &attr); + virtual void write_DRandMax(Tango::WAttribute &attr); + virtual bool is_DRandMax_allowed(Tango::AttReqType type); +/** + * Attribute LRand related methods + * Description: + * + * Data type: Tango::DevLong + * Attr type: Scalar + */ + virtual void read_LRand(Tango::Attribute &attr); + virtual bool is_LRand_allowed(Tango::AttReqType type); +/** + * Attribute LRandMin related methods + * Description: + * + * Data type: Tango::DevLong + * Attr type: Scalar + */ + virtual void read_LRandMin(Tango::Attribute &attr); + virtual void write_LRandMin(Tango::WAttribute &attr); + virtual bool is_LRandMin_allowed(Tango::AttReqType type); +/** + * Attribute LRandMax related methods + * Description: + * + * Data type: Tango::DevLong + * Attr type: Scalar + */ + virtual void read_LRandMax(Tango::Attribute &attr); + virtual void write_LRandMax(Tango::WAttribute &attr); + virtual bool is_LRandMax_allowed(Tango::AttReqType type); +/** + * Attribute Data related methods + * Description: + * + * Data type: Tango::DevDouble + * Attr type: Scalar + */ + virtual void read_Data(Tango::Attribute &attr); + virtual void write_Data(Tango::WAttribute &attr); + virtual bool is_Data_allowed(Tango::AttReqType type); +/** + * Attribute Data1 related methods + * Description: + * + * Data type: Tango::DevDouble + * Attr type: Scalar + */ + virtual void read_Data1(Tango::Attribute &attr); + virtual void write_Data1(Tango::WAttribute &attr); + virtual bool is_Data1_allowed(Tango::AttReqType type); +/** + * Attribute LData related methods + * Description: + * + * Data type: Tango::DevLong + * Attr type: Scalar + */ + virtual void read_LData(Tango::Attribute &attr); + virtual void write_LData(Tango::WAttribute &attr); + virtual bool is_LData_allowed(Tango::AttReqType type); +/** + * Attribute Date related methods + * Description: + * + * Data type: Tango::DevLong + * Attr type: Spectrum max = 2 + */ + virtual void read_Date(Tango::Attribute &attr); + virtual bool is_Date_allowed(Tango::AttReqType type); +/** + * Attribute LDate related methods + * Description: + * + * Data type: Tango::DevLong + * Attr type: Spectrum max = 2 + */ + virtual void read_LDate(Tango::Attribute &attr); + virtual bool is_LDate_allowed(Tango::AttReqType type); + + + //-------------------------------------------------------- + /** + * Method : SeqUtils::add_dynamic_attributes() + * Description : Add dynamic attributes if any. + */ + //-------------------------------------------------------- + void add_dynamic_attributes(); + + + + +// Command related methods +public: + /** + * Command On related method + * Description: + * + */ + virtual void on(); + virtual bool is_On_allowed(const CORBA::Any &any); + /** + * Command Off related method + * Description: + * + */ + virtual void off(); + virtual bool is_Off_allowed(const CORBA::Any &any); + /** + * Command Reset related method + * Description: + * + */ + virtual void reset(); + virtual bool is_Reset_allowed(const CORBA::Any &any); + /** + * Command SetFault related method + * Description: + * + */ + virtual void set_fault(); + virtual bool is_SetFault_allowed(const CORBA::Any &any); + /** + * Command Start related method + * Description: + * + */ + virtual void start(); + virtual bool is_Start_allowed(const CORBA::Any &any); + /** + * Command Stop related method + * Description: + * + */ + virtual void stop(); + virtual bool is_Stop_allowed(const CORBA::Any &any); + + + //-------------------------------------------------------- + /** + * Method : SeqUtils::add_dynamic_commands() + * Description : Add dynamic commands if any. + */ + //-------------------------------------------------------- + void add_dynamic_commands(); + +/*----- PROTECTED REGION ID(SeqUtils::Additional Method prototypes) ENABLED START -----*/ + +// Additional Method prototypes + +/*----- PROTECTED REGION END -----*/ // SeqUtils::Additional Method prototypes +}; + +/*----- PROTECTED REGION ID(SeqUtils::Additional Classes Definitions) ENABLED START -----*/ + +// Additional Classes Definitions + +/*----- PROTECTED REGION END -----*/ // SeqUtils::Additional Classes Definitions + +} // End of namespace + +#endif // SeqUtils_H diff --git a/src/SeqUtils.xmi b/src/SeqUtils.xmi new file mode 100644 index 0000000..40023b5 --- /dev/null +++ b/src/SeqUtils.xmi @@ -0,0 +1,185 @@ +<?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="SeqUtils" pogoRevision="9.4"> + <description description="It returns a random generated number, sec/nsec date" title="SeqUtils" sourcePath="/home/giulio/fermi/servers/sequtils/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 - giulio.gaio" author="giulio.gaio" emailDomain="elettra.eu" classFamily="System" siteSpecific="" platform="All Platforms" bus="Not Applicable" manufacturer="none" reference=""/> + </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="" 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"/> + <excludedStates>FAULT</excludedStates> + </commands> + <commands name="Off" description="" 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"/> + <excludedStates>FAULT</excludedStates> + </commands> + <commands name="Reset" description="" 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="SetFault" description="" execMethod="set_fault" 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="Start" description="" execMethod="start" 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="Stop" description="" execMethod="stop" 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> + <attributes name="DRand" attType="Scalar" rwType="READ" displayLevel="OPERATOR" polledPeriod="0" maxX="" maxY="" allocReadMember="true" 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="" label="" unit="" standardUnit="" displayUnit="" format="%f" maxValue="500000000000" minValue="-500000000000" maxAlarm="" minAlarm="" maxWarning="" minWarning="" deltaTime="" deltaValue=""/> + </attributes> + <attributes name="DRandMin" attType="Scalar" rwType="READ_WRITE" displayLevel="OPERATOR" polledPeriod="0" maxX="" maxY="" memorized="true" memorizedAtInit="true" allocReadMember="true" 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="" label="" unit="" standardUnit="" displayUnit="" format="%f" maxValue="500000000000" minValue="-500000000000" maxAlarm="" minAlarm="" maxWarning="" minWarning="" deltaTime="" deltaValue=""/> + </attributes> + <attributes name="DRandMax" attType="Scalar" rwType="READ_WRITE" displayLevel="OPERATOR" polledPeriod="0" maxX="" maxY="" memorized="true" memorizedAtInit="true" allocReadMember="true" 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="" label="" unit="" standardUnit="" displayUnit="" format="%f" maxValue="500000000000" minValue="-500000000000" maxAlarm="" minAlarm="" maxWarning="" minWarning="" deltaTime="" deltaValue=""/> + </attributes> + <attributes name="LRand" attType="Scalar" rwType="READ" displayLevel="OPERATOR" polledPeriod="0" maxX="" maxY="" allocReadMember="true" isDynamic="false"> + <dataType xsi:type="pogoDsl:IntType"/> + <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="" label="" unit="" standardUnit="" displayUnit="" format="" maxValue="2147483647" minValue="-2147483648" maxAlarm="" minAlarm="" maxWarning="" minWarning="" deltaTime="" deltaValue=""/> + </attributes> + <attributes name="LRandMin" attType="Scalar" rwType="READ_WRITE" displayLevel="OPERATOR" polledPeriod="0" maxX="" maxY="" memorized="true" memorizedAtInit="true" allocReadMember="true" isDynamic="false"> + <dataType xsi:type="pogoDsl:IntType"/> + <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="" label="" unit="" standardUnit="" displayUnit="" format="" maxValue="2147483647" minValue="-2147483648" maxAlarm="" minAlarm="" maxWarning="" minWarning="" deltaTime="" deltaValue=""/> + </attributes> + <attributes name="LRandMax" attType="Scalar" rwType="READ_WRITE" displayLevel="OPERATOR" polledPeriod="0" maxX="" maxY="" memorized="true" memorizedAtInit="true" allocReadMember="true" isDynamic="false"> + <dataType xsi:type="pogoDsl:IntType"/> + <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="" label="" unit="" standardUnit="" displayUnit="" format="" maxValue="2147483647" minValue="-2147483648" maxAlarm="" minAlarm="" maxWarning="" minWarning="" deltaTime="" deltaValue=""/> + </attributes> + <attributes name="Data" attType="Scalar" rwType="READ_WRITE" displayLevel="OPERATOR" polledPeriod="0" maxX="" maxY="" allocReadMember="true" 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="" label="" unit="" standardUnit="" displayUnit="" format="" maxValue="" minValue="" maxAlarm="" minAlarm="" maxWarning="" minWarning="" deltaTime="" deltaValue=""/> + <writeExcludedStates>OFF</writeExcludedStates> + <writeExcludedStates>FAULT</writeExcludedStates> + </attributes> + <attributes name="Data1" attType="Scalar" rwType="READ_WRITE" displayLevel="OPERATOR" polledPeriod="0" maxX="" maxY="" allocReadMember="true" 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="" label="" unit="" standardUnit="" displayUnit="" format="" maxValue="" minValue="" maxAlarm="" minAlarm="" maxWarning="" minWarning="" deltaTime="" deltaValue=""/> + </attributes> + <attributes name="LData" attType="Scalar" rwType="READ_WRITE" displayLevel="OPERATOR" polledPeriod="0" maxX="" maxY="" allocReadMember="true" isDynamic="false"> + <dataType xsi:type="pogoDsl:IntType"/> + <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="" label="" unit="" standardUnit="" displayUnit="" format="" maxValue="" minValue="" maxAlarm="" minAlarm="" maxWarning="" minWarning="" deltaTime="" deltaValue=""/> + <writeExcludedStates>OFF</writeExcludedStates> + <writeExcludedStates>FAULT</writeExcludedStates> + </attributes> + <attributes name="Date" attType="Spectrum" rwType="READ" displayLevel="OPERATOR" polledPeriod="0" maxX="2" maxY="" allocReadMember="true" isDynamic="false"> + <dataType xsi:type="pogoDsl:IntType"/> + <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="" label="" unit="" standardUnit="" displayUnit="" format="" maxValue="" minValue="" maxAlarm="" minAlarm="" maxWarning="" minWarning="" deltaTime="" deltaValue=""/> + </attributes> + <attributes name="LDate" attType="Spectrum" rwType="READ" displayLevel="OPERATOR" polledPeriod="0" maxX="2" maxY="" allocReadMember="true" isDynamic="false"> + <dataType xsi:type="pogoDsl:IntType"/> + <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="" label="" unit="" standardUnit="" displayUnit="" format="" maxValue="" minValue="" maxAlarm="" minAlarm="" maxWarning="" minWarning="" deltaTime="" deltaValue=""/> + </attributes> + <states name="ON" description=""> + <status abstract="false" inherited="false" concrete="true" concreteHere="true"/> + </states> + <states name="OFF" description=""> + <status abstract="false" inherited="false" concrete="true" concreteHere="true"/> + </states> + <states name="FAULT" description=""> + <status abstract="false" inherited="false" concrete="true" concreteHere="true"/> + </states> + <preferences docHome="./doc_html" makefileHome="/usr/local/tango-9.2.5a/share/pogo/preferences"/> + </classes> +</pogoDsl:PogoSystem> diff --git a/src/SeqUtilsClass.cpp b/src/SeqUtilsClass.cpp new file mode 100644 index 0000000..a6b2793 --- /dev/null +++ b/src/SeqUtilsClass.cpp @@ -0,0 +1,902 @@ +/*----- PROTECTED REGION ID(SeqUtilsClass.cpp) ENABLED START -----*/ +static const char *RcsId = "$Id: SeqUtilsClass.cpp,v 1.6 2020-01-15 10:29:01 giulio Exp $"; +static const char *TagName = "$Name: $"; +static const char *CvsPath = "$Source: /home/cvsadm/cvsroot/fermi/servers/sequtils/src/SeqUtilsClass.cpp,v $"; +static const char *SvnPath = "$HeadURL: $"; +static const char *HttpServer = "http://www.esrf.eu/computing/cs/tango/tango_doc/ds_doc/"; +//============================================================================= +// +// file : SeqUtilsClass.cpp +// +// description : C++ source for the SeqUtilsClass. +// A singleton class derived from DeviceClass. +// It implements the command and attribute list +// and all properties and methods required +// by the SeqUtils once per process. +// +// project : SeqUtils +// +// 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 <SeqUtilsClass.h> + +/*----- PROTECTED REGION END -----*/ // SeqUtilsClass.cpp + +//------------------------------------------------------------------- +/** + * Create SeqUtilsClass singleton and + * return it in a C function for Python usage + */ +//------------------------------------------------------------------- +extern "C" { +#ifdef _TG_WINDOWS_ + +__declspec(dllexport) + +#endif + + Tango::DeviceClass *_create_SeqUtils_class(const char *name) { + return SeqUtils_ns::SeqUtilsClass::init(name); + } +} + +namespace SeqUtils_ns +{ +//=================================================================== +// Initialize pointer for singleton pattern +//=================================================================== +SeqUtilsClass *SeqUtilsClass::_instance = NULL; + +//-------------------------------------------------------- +/** + * method : SeqUtilsClass::SeqUtilsClass(string &s) + * description : constructor for the SeqUtilsClass + * + * @param s The class name + */ +//-------------------------------------------------------- +SeqUtilsClass::SeqUtilsClass(string &s):Tango::DeviceClass(s) +{ + cout2 << "Entering SeqUtilsClass constructor" << endl; + set_default_property(); + write_class_property(); + + /*----- PROTECTED REGION ID(SeqUtilsClass::constructor) ENABLED START -----*/ + string tagname(TagName); + /*----- PROTECTED REGION END -----*/ // SeqUtilsClass::constructor + + cout2 << "Leaving SeqUtilsClass constructor" << endl; +} + +//-------------------------------------------------------- +/** + * method : SeqUtilsClass::~SeqUtilsClass() + * description : destructor for the SeqUtilsClass + */ +//-------------------------------------------------------- +SeqUtilsClass::~SeqUtilsClass() +{ + /*----- PROTECTED REGION ID(SeqUtilsClass::destructor) ENABLED START -----*/ + + /*----- PROTECTED REGION END -----*/ // SeqUtilsClass::destructor + + _instance = NULL; +} + + +//-------------------------------------------------------- +/** + * method : SeqUtilsClass::init + * description : Create the object if not already done. + * Otherwise, just return a pointer to the object + * + * @param name The class name + */ +//-------------------------------------------------------- +SeqUtilsClass *SeqUtilsClass::init(const char *name) +{ + if (_instance == NULL) + { + try + { + string s(name); + _instance = new SeqUtilsClass(s); + } + catch (bad_alloc &) + { + throw; + } + } + return _instance; +} + +//-------------------------------------------------------- +/** + * method : SeqUtilsClass::instance + * description : Check if object already created, + * and return a pointer to the object + */ +//-------------------------------------------------------- +SeqUtilsClass *SeqUtilsClass::instance() +{ + if (_instance == NULL) + { + cerr << "Class is not initialised !!" << endl; + exit(-1); + } + return _instance; +} + + + +//=================================================================== +// Command execution method calls +//=================================================================== +//-------------------------------------------------------- +/** + * method : OnClass::execute() + * description : method to trigger the execution of the command. + * + * @param device The device on which the command must be executed + * @param in_any The command input data + * + * returns The command output data (packed in the Any object) + */ +//-------------------------------------------------------- +CORBA::Any *OnClass::execute(Tango::DeviceImpl *device, TANGO_UNUSED(const CORBA::Any &in_any)) +{ + cout2 << "OnClass::execute(): arrived" << endl; + ((static_cast<SeqUtils *>(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)) +{ + cout2 << "OffClass::execute(): arrived" << endl; + ((static_cast<SeqUtils *>(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)) +{ + cout2 << "ResetClass::execute(): arrived" << endl; + ((static_cast<SeqUtils *>(device))->reset()); + return new CORBA::Any(); +} + +//-------------------------------------------------------- +/** + * method : SetFaultClass::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 *SetFaultClass::execute(Tango::DeviceImpl *device, TANGO_UNUSED(const CORBA::Any &in_any)) +{ + cout2 << "SetFaultClass::execute(): arrived" << endl; + ((static_cast<SeqUtils *>(device))->set_fault()); + return new CORBA::Any(); +} + +//-------------------------------------------------------- +/** + * method : StartClass::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 *StartClass::execute(Tango::DeviceImpl *device, TANGO_UNUSED(const CORBA::Any &in_any)) +{ + cout2 << "StartClass::execute(): arrived" << endl; + ((static_cast<SeqUtils *>(device))->start()); + return new CORBA::Any(); +} + +//-------------------------------------------------------- +/** + * method : StopClass::execute() + * description : method to trigger the execution of the command. + * + * @param device The device on which the command must be executed + * @param in_any The command input data + * + * returns The command output data (packed in the Any object) + */ +//-------------------------------------------------------- +CORBA::Any *StopClass::execute(Tango::DeviceImpl *device, TANGO_UNUSED(const CORBA::Any &in_any)) +{ + cout2 << "StopClass::execute(): arrived" << endl; + ((static_cast<SeqUtils *>(device))->stop()); + return new CORBA::Any(); +} + + +//=================================================================== +// Properties management +//=================================================================== +//-------------------------------------------------------- +/** + * Method : SeqUtilsClass::get_class_property() + * Description : Get the class property for specified name. + */ +//-------------------------------------------------------- +Tango::DbDatum SeqUtilsClass::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 : SeqUtilsClass::get_default_device_property() + * Description : Return the default value for device property. + */ +//-------------------------------------------------------- +Tango::DbDatum SeqUtilsClass::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 : SeqUtilsClass::get_default_class_property() + * Description : Return the default value for class property. + */ +//-------------------------------------------------------- +Tango::DbDatum SeqUtilsClass::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 : SeqUtilsClass::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 SeqUtilsClass::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 : SeqUtilsClass::write_class_property() + * Description : Set class description fields as property in database + */ +//-------------------------------------------------------- +void SeqUtilsClass::write_class_property() +{ + // First time, check if database used + if (Tango::Util::_UseDb == false) + return; + + Tango::DbData data; + string classname = get_name(); + string header; + string::size_type start, end; + + // Put title + Tango::DbDatum title("ProjectTitle"); + string str_title("SeqUtils"); + title << str_title; + data.push_back(title); + + // Put Description + Tango::DbDatum description("Description"); + vector<string> str_desc; + str_desc.push_back("It returns a random generated number, sec/nsec date"); + description << str_desc; + data.push_back(description); + + // Put inheritance + Tango::DbDatum inher_datum("InheritedFrom"); + vector<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 : SeqUtilsClass::device_factory() + * Description : Create the device object(s) + * and store them in the device list + */ +//-------------------------------------------------------- +void SeqUtilsClass::device_factory(const Tango::DevVarStringArray *devlist_ptr) +{ + /*----- PROTECTED REGION ID(SeqUtilsClass::device_factory_before) ENABLED START -----*/ + + // Add your own code + + /*----- PROTECTED REGION END -----*/ // SeqUtilsClass::device_factory_before + + // Create devices and add it into the device list + for (unsigned long i=0 ; i<devlist_ptr->length() ; i++) + { + cout4 << "Device name : " << (*devlist_ptr)[i].in() << endl; + device_list.push_back(new SeqUtils(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 + SeqUtils *dev = static_cast<SeqUtils *>(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(SeqUtilsClass::device_factory_after) ENABLED START -----*/ + + // Add your own code + + /*----- PROTECTED REGION END -----*/ // SeqUtilsClass::device_factory_after +} +//-------------------------------------------------------- +/** + * Method : SeqUtilsClass::attribute_factory() + * Description : Create the attribute object(s) + * and store them in the attribute list + */ +//-------------------------------------------------------- +void SeqUtilsClass::attribute_factory(vector<Tango::Attr *> &att_list) +{ + /*----- PROTECTED REGION ID(SeqUtilsClass::attribute_factory_before) ENABLED START -----*/ + + // Add your own code + + /*----- PROTECTED REGION END -----*/ // SeqUtilsClass::attribute_factory_before + // Attribute : DRand + DRandAttrib *drand = new DRandAttrib(); + Tango::UserDefaultAttrProp drand_prop; + // description not set for DRand + // label not set for DRand + // unit not set for DRand + // standard_unit not set for DRand + // display_unit not set for DRand + drand_prop.set_format("%f"); + drand_prop.set_max_value("500000000000"); + drand_prop.set_min_value("-500000000000"); + // max_alarm not set for DRand + // min_alarm not set for DRand + // max_warning not set for DRand + // min_warning not set for DRand + // delta_t not set for DRand + // delta_val not set for DRand + + drand->set_default_properties(drand_prop); + // Not Polled + drand->set_disp_level(Tango::OPERATOR); + // Not Memorized + att_list.push_back(drand); + + // Attribute : DRandMin + DRandMinAttrib *drandmin = new DRandMinAttrib(); + Tango::UserDefaultAttrProp drandmin_prop; + // description not set for DRandMin + // label not set for DRandMin + // unit not set for DRandMin + // standard_unit not set for DRandMin + // display_unit not set for DRandMin + drandmin_prop.set_format("%f"); + drandmin_prop.set_max_value("500000000000"); + drandmin_prop.set_min_value("-500000000000"); + // max_alarm not set for DRandMin + // min_alarm not set for DRandMin + // max_warning not set for DRandMin + // min_warning not set for DRandMin + // delta_t not set for DRandMin + // delta_val not set for DRandMin + + drandmin->set_default_properties(drandmin_prop); + // Not Polled + drandmin->set_disp_level(Tango::OPERATOR); + drandmin->set_memorized(); + drandmin->set_memorized_init(true); + att_list.push_back(drandmin); + + // Attribute : DRandMax + DRandMaxAttrib *drandmax = new DRandMaxAttrib(); + Tango::UserDefaultAttrProp drandmax_prop; + // description not set for DRandMax + // label not set for DRandMax + // unit not set for DRandMax + // standard_unit not set for DRandMax + // display_unit not set for DRandMax + drandmax_prop.set_format("%f"); + drandmax_prop.set_max_value("500000000000"); + drandmax_prop.set_min_value("-500000000000"); + // max_alarm not set for DRandMax + // min_alarm not set for DRandMax + // max_warning not set for DRandMax + // min_warning not set for DRandMax + // delta_t not set for DRandMax + // delta_val not set for DRandMax + + drandmax->set_default_properties(drandmax_prop); + // Not Polled + drandmax->set_disp_level(Tango::OPERATOR); + drandmax->set_memorized(); + drandmax->set_memorized_init(true); + att_list.push_back(drandmax); + + // Attribute : LRand + LRandAttrib *lrand = new LRandAttrib(); + Tango::UserDefaultAttrProp lrand_prop; + // description not set for LRand + // label not set for LRand + // unit not set for LRand + // standard_unit not set for LRand + // display_unit not set for LRand + // format not set for LRand + lrand_prop.set_max_value("2147483647"); + lrand_prop.set_min_value("-2147483648"); + // max_alarm not set for LRand + // min_alarm not set for LRand + // max_warning not set for LRand + // min_warning not set for LRand + // delta_t not set for LRand + // delta_val not set for LRand + + lrand->set_default_properties(lrand_prop); + // Not Polled + lrand->set_disp_level(Tango::OPERATOR); + // Not Memorized + att_list.push_back(lrand); + + // Attribute : LRandMin + LRandMinAttrib *lrandmin = new LRandMinAttrib(); + Tango::UserDefaultAttrProp lrandmin_prop; + // description not set for LRandMin + // label not set for LRandMin + // unit not set for LRandMin + // standard_unit not set for LRandMin + // display_unit not set for LRandMin + // format not set for LRandMin + lrandmin_prop.set_max_value("2147483647"); + lrandmin_prop.set_min_value("-2147483648"); + // max_alarm not set for LRandMin + // min_alarm not set for LRandMin + // max_warning not set for LRandMin + // min_warning not set for LRandMin + // delta_t not set for LRandMin + // delta_val not set for LRandMin + + lrandmin->set_default_properties(lrandmin_prop); + // Not Polled + lrandmin->set_disp_level(Tango::OPERATOR); + lrandmin->set_memorized(); + lrandmin->set_memorized_init(true); + att_list.push_back(lrandmin); + + // Attribute : LRandMax + LRandMaxAttrib *lrandmax = new LRandMaxAttrib(); + Tango::UserDefaultAttrProp lrandmax_prop; + // description not set for LRandMax + // label not set for LRandMax + // unit not set for LRandMax + // standard_unit not set for LRandMax + // display_unit not set for LRandMax + // format not set for LRandMax + lrandmax_prop.set_max_value("2147483647"); + lrandmax_prop.set_min_value("-2147483648"); + // max_alarm not set for LRandMax + // min_alarm not set for LRandMax + // max_warning not set for LRandMax + // min_warning not set for LRandMax + // delta_t not set for LRandMax + // delta_val not set for LRandMax + + lrandmax->set_default_properties(lrandmax_prop); + // Not Polled + lrandmax->set_disp_level(Tango::OPERATOR); + lrandmax->set_memorized(); + lrandmax->set_memorized_init(true); + att_list.push_back(lrandmax); + + // Attribute : Data + DataAttrib *data = new DataAttrib(); + Tango::UserDefaultAttrProp data_prop; + // description not set for Data + // label not set for Data + // unit not set for Data + // standard_unit not set for Data + // display_unit not set for Data + // format not set for Data + // max_value not set for Data + // min_value not set for Data + // max_alarm not set for Data + // min_alarm not set for Data + // max_warning not set for Data + // min_warning not set for Data + // delta_t not set for Data + // delta_val not set for Data + + data->set_default_properties(data_prop); + // Not Polled + data->set_disp_level(Tango::OPERATOR); + // Not Memorized + att_list.push_back(data); + + // Attribute : Data1 + Data1Attrib *data1 = new Data1Attrib(); + Tango::UserDefaultAttrProp data1_prop; + // description not set for Data1 + // label not set for Data1 + // unit not set for Data1 + // standard_unit not set for Data1 + // display_unit not set for Data1 + // format not set for Data1 + // max_value not set for Data1 + // min_value not set for Data1 + // max_alarm not set for Data1 + // min_alarm not set for Data1 + // max_warning not set for Data1 + // min_warning not set for Data1 + // delta_t not set for Data1 + // delta_val not set for Data1 + + data1->set_default_properties(data1_prop); + // Not Polled + data1->set_disp_level(Tango::OPERATOR); + // Not Memorized + att_list.push_back(data1); + + // Attribute : LData + LDataAttrib *ldata = new LDataAttrib(); + Tango::UserDefaultAttrProp ldata_prop; + // description not set for LData + // label not set for LData + // unit not set for LData + // standard_unit not set for LData + // display_unit not set for LData + // format not set for LData + // max_value not set for LData + // min_value not set for LData + // max_alarm not set for LData + // min_alarm not set for LData + // max_warning not set for LData + // min_warning not set for LData + // delta_t not set for LData + // delta_val not set for LData + + ldata->set_default_properties(ldata_prop); + // Not Polled + ldata->set_disp_level(Tango::OPERATOR); + // Not Memorized + att_list.push_back(ldata); + + // Attribute : Date + DateAttrib *date = new DateAttrib(); + Tango::UserDefaultAttrProp date_prop; + // description not set for Date + // label not set for Date + // unit not set for Date + // standard_unit not set for Date + // display_unit not set for Date + // format not set for Date + // max_value not set for Date + // min_value not set for Date + // max_alarm not set for Date + // min_alarm not set for Date + // max_warning not set for Date + // min_warning not set for Date + // delta_t not set for Date + // delta_val not set for Date + + date->set_default_properties(date_prop); + // Not Polled + date->set_disp_level(Tango::OPERATOR); + // Not Memorized + att_list.push_back(date); + + // Attribute : LDate + LDateAttrib *ldate = new LDateAttrib(); + Tango::UserDefaultAttrProp ldate_prop; + // description not set for LDate + // label not set for LDate + // unit not set for LDate + // standard_unit not set for LDate + // display_unit not set for LDate + // format not set for LDate + // max_value not set for LDate + // min_value not set for LDate + // max_alarm not set for LDate + // min_alarm not set for LDate + // max_warning not set for LDate + // min_warning not set for LDate + // delta_t not set for LDate + // delta_val not set for LDate + + ldate->set_default_properties(ldate_prop); + // Not Polled + ldate->set_disp_level(Tango::OPERATOR); + // Not Memorized + att_list.push_back(ldate); + + + // Create a list of static attributes + create_static_attribute_list(get_class_attr()->get_attr_list()); + /*----- PROTECTED REGION ID(SeqUtilsClass::attribute_factory_after) ENABLED START -----*/ + + // Add your own code + + /*----- PROTECTED REGION END -----*/ // SeqUtilsClass::attribute_factory_after +} +//-------------------------------------------------------- +/** + * Method : SeqUtilsClass::pipe_factory() + * Description : Create the pipe object(s) + * and store them in the pipe list + */ +//-------------------------------------------------------- +void SeqUtilsClass::pipe_factory() +{ + /*----- PROTECTED REGION ID(SeqUtilsClass::pipe_factory_before) ENABLED START -----*/ + + // Add your own code + + /*----- PROTECTED REGION END -----*/ // SeqUtilsClass::pipe_factory_before + /*----- PROTECTED REGION ID(SeqUtilsClass::pipe_factory_after) ENABLED START -----*/ + + // Add your own code + + /*----- PROTECTED REGION END -----*/ // SeqUtilsClass::pipe_factory_after +} +//-------------------------------------------------------- +/** + * Method : SeqUtilsClass::command_factory() + * Description : Create the command object(s) + * and store them in the command list + */ +//-------------------------------------------------------- +void SeqUtilsClass::command_factory() +{ + /*----- PROTECTED REGION ID(SeqUtilsClass::command_factory_before) ENABLED START -----*/ + + // Add your own code + + /*----- PROTECTED REGION END -----*/ // SeqUtilsClass::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 SetFault + SetFaultClass *pSetFaultCmd = + new SetFaultClass("SetFault", + Tango::DEV_VOID, Tango::DEV_VOID, + "", + "", + Tango::OPERATOR); + command_list.push_back(pSetFaultCmd); + + // Command Start + StartClass *pStartCmd = + new StartClass("Start", + Tango::DEV_VOID, Tango::DEV_VOID, + "", + "", + Tango::OPERATOR); + command_list.push_back(pStartCmd); + + // Command Stop + StopClass *pStopCmd = + new StopClass("Stop", + Tango::DEV_VOID, Tango::DEV_VOID, + "", + "", + Tango::OPERATOR); + command_list.push_back(pStopCmd); + + /*----- PROTECTED REGION ID(SeqUtilsClass::command_factory_after) ENABLED START -----*/ + + // Add your own code + + /*----- PROTECTED REGION END -----*/ // SeqUtilsClass::command_factory_after +} + +//=================================================================== +// Dynamic attributes related methods +//=================================================================== + +//-------------------------------------------------------- +/** + * method : SeqUtilsClass::create_static_attribute_list + * description : Create the a list of static attributes + * + * @param att_list the ceated attribute list + */ +//-------------------------------------------------------- +void SeqUtilsClass::create_static_attribute_list(vector<Tango::Attr *> &att_list) +{ + for (unsigned long i=0 ; i<att_list.size() ; i++) + { + string att_name(att_list[i]->get_name()); + transform(att_name.begin(), att_name.end(), att_name.begin(), ::tolower); + defaultAttList.push_back(att_name); + } + + cout2 << defaultAttList.size() << " attributes in default list" << endl; + + /*----- PROTECTED REGION ID(SeqUtilsClass::create_static_att_list) ENABLED START -----*/ + + /*----- PROTECTED REGION END -----*/ // SeqUtilsClass::create_static_att_list +} + + +//-------------------------------------------------------- +/** + * method : SeqUtilsClass::erase_dynamic_attributes + * description : delete the dynamic attributes if any. + * + * @param devlist_ptr the device list pointer + * @param list of all attributes + */ +//-------------------------------------------------------- +void SeqUtilsClass::erase_dynamic_attributes(const Tango::DevVarStringArray *devlist_ptr, vector<Tango::Attr *> &att_list) +{ + Tango::Util *tg = Tango::Util::instance(); + + for (unsigned long i=0 ; i<devlist_ptr->length() ; i++) + { + Tango::DeviceImpl *dev_impl = tg->get_device_by_name(((string)(*devlist_ptr)[i]).c_str()); + SeqUtils *dev = static_cast<SeqUtils *> (dev_impl); + + vector<Tango::Attribute *> &dev_att_list = dev->get_device_attr()->get_attribute_list(); + vector<Tango::Attribute *>::iterator ite_att; + for (ite_att=dev_att_list.begin() ; ite_att != dev_att_list.end() ; ++ite_att) + { + string att_name((*ite_att)->get_name_lower()); + if ((att_name == "state") || (att_name == "status")) + continue; + vector<string>::iterator ite_str = find(defaultAttList.begin(), defaultAttList.end(), att_name); + if (ite_str == defaultAttList.end()) + { + cout2 << att_name << " is a UNWANTED dynamic attribute for device " << (*devlist_ptr)[i] << endl; + Tango::Attribute &att = dev->get_device_attr()->get_attr_by_name(att_name.c_str()); + dev->remove_attribute(att_list[att.get_attr_idx()], true, false); + --ite_att; + } + } + } + /*----- PROTECTED REGION ID(SeqUtilsClass::erase_dynamic_attributes) ENABLED START -----*/ + + /*----- PROTECTED REGION END -----*/ // SeqUtilsClass::erase_dynamic_attributes +} + +//-------------------------------------------------------- +/** + * Method : SeqUtilsClass::get_attr_by_name() + * Description : returns Tango::Attr * object found by name + */ +//-------------------------------------------------------- +Tango::Attr *SeqUtilsClass::get_attr_object_by_name(vector<Tango::Attr *> &att_list, string attname) +{ + 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(SeqUtilsClass::Additional Methods) ENABLED START -----*/ + +/*----- PROTECTED REGION END -----*/ // SeqUtilsClass::Additional Methods +} // namespace diff --git a/src/SeqUtilsClass.h b/src/SeqUtilsClass.h new file mode 100644 index 0000000..bbe8211 --- /dev/null +++ b/src/SeqUtilsClass.h @@ -0,0 +1,408 @@ +/*----- PROTECTED REGION ID(SeqUtilsClass.h) ENABLED START -----*/ +//============================================================================= +// +// file : SeqUtilsClass.h +// +// description : Include for the SeqUtils root class. +// This class is the singleton class for +// the SeqUtils device class. +// It contains all properties and methods which the +// SeqUtils requires only once e.g. the commands. +// +// project : SeqUtils +// +// 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 SeqUtilsClass_H +#define SeqUtilsClass_H + +#include <tango.h> +#include <SeqUtils.h> + + +/*----- PROTECTED REGION END -----*/ // SeqUtilsClass.h + + +namespace SeqUtils_ns +{ +/*----- PROTECTED REGION ID(SeqUtilsClass::classes for dynamic creation) ENABLED START -----*/ + + +/*----- PROTECTED REGION END -----*/ // SeqUtilsClass::classes for dynamic creation + +//========================================= +// Define classes for attributes +//========================================= +// Attribute DRand class definition +class DRandAttrib: public Tango::Attr +{ +public: + DRandAttrib():Attr("DRand", + Tango::DEV_DOUBLE, Tango::READ) {}; + ~DRandAttrib() {}; + virtual void read(Tango::DeviceImpl *dev,Tango::Attribute &att) + {(static_cast<SeqUtils *>(dev))->read_DRand(att);} + virtual bool is_allowed(Tango::DeviceImpl *dev,Tango::AttReqType ty) + {return (static_cast<SeqUtils *>(dev))->is_DRand_allowed(ty);} +}; + +// Attribute DRandMin class definition +class DRandMinAttrib: public Tango::Attr +{ +public: + DRandMinAttrib():Attr("DRandMin", + Tango::DEV_DOUBLE, Tango::READ_WRITE) {}; + ~DRandMinAttrib() {}; + virtual void read(Tango::DeviceImpl *dev,Tango::Attribute &att) + {(static_cast<SeqUtils *>(dev))->read_DRandMin(att);} + virtual void write(Tango::DeviceImpl *dev,Tango::WAttribute &att) + {(static_cast<SeqUtils *>(dev))->write_DRandMin(att);} + virtual bool is_allowed(Tango::DeviceImpl *dev,Tango::AttReqType ty) + {return (static_cast<SeqUtils *>(dev))->is_DRandMin_allowed(ty);} +}; + +// Attribute DRandMax class definition +class DRandMaxAttrib: public Tango::Attr +{ +public: + DRandMaxAttrib():Attr("DRandMax", + Tango::DEV_DOUBLE, Tango::READ_WRITE) {}; + ~DRandMaxAttrib() {}; + virtual void read(Tango::DeviceImpl *dev,Tango::Attribute &att) + {(static_cast<SeqUtils *>(dev))->read_DRandMax(att);} + virtual void write(Tango::DeviceImpl *dev,Tango::WAttribute &att) + {(static_cast<SeqUtils *>(dev))->write_DRandMax(att);} + virtual bool is_allowed(Tango::DeviceImpl *dev,Tango::AttReqType ty) + {return (static_cast<SeqUtils *>(dev))->is_DRandMax_allowed(ty);} +}; + +// Attribute LRand class definition +class LRandAttrib: public Tango::Attr +{ +public: + LRandAttrib():Attr("LRand", + Tango::DEV_LONG, Tango::READ) {}; + ~LRandAttrib() {}; + virtual void read(Tango::DeviceImpl *dev,Tango::Attribute &att) + {(static_cast<SeqUtils *>(dev))->read_LRand(att);} + virtual bool is_allowed(Tango::DeviceImpl *dev,Tango::AttReqType ty) + {return (static_cast<SeqUtils *>(dev))->is_LRand_allowed(ty);} +}; + +// Attribute LRandMin class definition +class LRandMinAttrib: public Tango::Attr +{ +public: + LRandMinAttrib():Attr("LRandMin", + Tango::DEV_LONG, Tango::READ_WRITE) {}; + ~LRandMinAttrib() {}; + virtual void read(Tango::DeviceImpl *dev,Tango::Attribute &att) + {(static_cast<SeqUtils *>(dev))->read_LRandMin(att);} + virtual void write(Tango::DeviceImpl *dev,Tango::WAttribute &att) + {(static_cast<SeqUtils *>(dev))->write_LRandMin(att);} + virtual bool is_allowed(Tango::DeviceImpl *dev,Tango::AttReqType ty) + {return (static_cast<SeqUtils *>(dev))->is_LRandMin_allowed(ty);} +}; + +// Attribute LRandMax class definition +class LRandMaxAttrib: public Tango::Attr +{ +public: + LRandMaxAttrib():Attr("LRandMax", + Tango::DEV_LONG, Tango::READ_WRITE) {}; + ~LRandMaxAttrib() {}; + virtual void read(Tango::DeviceImpl *dev,Tango::Attribute &att) + {(static_cast<SeqUtils *>(dev))->read_LRandMax(att);} + virtual void write(Tango::DeviceImpl *dev,Tango::WAttribute &att) + {(static_cast<SeqUtils *>(dev))->write_LRandMax(att);} + virtual bool is_allowed(Tango::DeviceImpl *dev,Tango::AttReqType ty) + {return (static_cast<SeqUtils *>(dev))->is_LRandMax_allowed(ty);} +}; + +// Attribute Data class definition +class DataAttrib: public Tango::Attr +{ +public: + DataAttrib():Attr("Data", + Tango::DEV_DOUBLE, Tango::READ_WRITE) {}; + ~DataAttrib() {}; + virtual void read(Tango::DeviceImpl *dev,Tango::Attribute &att) + {(static_cast<SeqUtils *>(dev))->read_Data(att);} + virtual void write(Tango::DeviceImpl *dev,Tango::WAttribute &att) + {(static_cast<SeqUtils *>(dev))->write_Data(att);} + virtual bool is_allowed(Tango::DeviceImpl *dev,Tango::AttReqType ty) + {return (static_cast<SeqUtils *>(dev))->is_Data_allowed(ty);} +}; + +// Attribute Data1 class definition +class Data1Attrib: public Tango::Attr +{ +public: + Data1Attrib():Attr("Data1", + Tango::DEV_DOUBLE, Tango::READ_WRITE) {}; + ~Data1Attrib() {}; + virtual void read(Tango::DeviceImpl *dev,Tango::Attribute &att) + {(static_cast<SeqUtils *>(dev))->read_Data1(att);} + virtual void write(Tango::DeviceImpl *dev,Tango::WAttribute &att) + {(static_cast<SeqUtils *>(dev))->write_Data1(att);} + virtual bool is_allowed(Tango::DeviceImpl *dev,Tango::AttReqType ty) + {return (static_cast<SeqUtils *>(dev))->is_Data1_allowed(ty);} +}; + +// Attribute LData class definition +class LDataAttrib: public Tango::Attr +{ +public: + LDataAttrib():Attr("LData", + Tango::DEV_LONG, Tango::READ_WRITE) {}; + ~LDataAttrib() {}; + virtual void read(Tango::DeviceImpl *dev,Tango::Attribute &att) + {(static_cast<SeqUtils *>(dev))->read_LData(att);} + virtual void write(Tango::DeviceImpl *dev,Tango::WAttribute &att) + {(static_cast<SeqUtils *>(dev))->write_LData(att);} + virtual bool is_allowed(Tango::DeviceImpl *dev,Tango::AttReqType ty) + {return (static_cast<SeqUtils *>(dev))->is_LData_allowed(ty);} +}; + +// Attribute Date class definition +class DateAttrib: public Tango::SpectrumAttr +{ +public: + DateAttrib():SpectrumAttr("Date", + Tango::DEV_LONG, Tango::READ, 2) {}; + ~DateAttrib() {}; + virtual void read(Tango::DeviceImpl *dev,Tango::Attribute &att) + {(static_cast<SeqUtils *>(dev))->read_Date(att);} + virtual bool is_allowed(Tango::DeviceImpl *dev,Tango::AttReqType ty) + {return (static_cast<SeqUtils *>(dev))->is_Date_allowed(ty);} +}; + +// Attribute LDate class definition +class LDateAttrib: public Tango::SpectrumAttr +{ +public: + LDateAttrib():SpectrumAttr("LDate", + Tango::DEV_LONG, Tango::READ, 2) {}; + ~LDateAttrib() {}; + virtual void read(Tango::DeviceImpl *dev,Tango::Attribute &att) + {(static_cast<SeqUtils *>(dev))->read_LDate(att);} + virtual bool is_allowed(Tango::DeviceImpl *dev,Tango::AttReqType ty) + {return (static_cast<SeqUtils *>(dev))->is_LDate_allowed(ty);} +}; + + +//========================================= +// Define classes for commands +//========================================= +// Command On class definition +class OnClass : public Tango::Command +{ +public: + OnClass(const char *name, + Tango::CmdArgType in, + Tango::CmdArgType out, + const char *in_desc, + const char *out_desc, + Tango::DispLevel level) + :Command(name,in,out,in_desc,out_desc, level) {}; + + OnClass(const char *name, + Tango::CmdArgType in, + Tango::CmdArgType out) + :Command(name,in,out) {}; + ~OnClass() {}; + + virtual CORBA::Any *execute (Tango::DeviceImpl *dev, const CORBA::Any &any); + virtual bool is_allowed (Tango::DeviceImpl *dev, const CORBA::Any &any) + {return (static_cast<SeqUtils *>(dev))->is_On_allowed(any);} +}; + +// Command Off class definition +class OffClass : public Tango::Command +{ +public: + OffClass(const char *name, + Tango::CmdArgType in, + Tango::CmdArgType out, + const char *in_desc, + const char *out_desc, + Tango::DispLevel level) + :Command(name,in,out,in_desc,out_desc, level) {}; + + OffClass(const char *name, + Tango::CmdArgType in, + Tango::CmdArgType out) + :Command(name,in,out) {}; + ~OffClass() {}; + + virtual CORBA::Any *execute (Tango::DeviceImpl *dev, const CORBA::Any &any); + virtual bool is_allowed (Tango::DeviceImpl *dev, const CORBA::Any &any) + {return (static_cast<SeqUtils *>(dev))->is_Off_allowed(any);} +}; + +// Command Reset class definition +class ResetClass : public Tango::Command +{ +public: + ResetClass(const char *name, + Tango::CmdArgType in, + Tango::CmdArgType out, + const char *in_desc, + const char *out_desc, + Tango::DispLevel level) + :Command(name,in,out,in_desc,out_desc, level) {}; + + ResetClass(const char *name, + Tango::CmdArgType in, + Tango::CmdArgType out) + :Command(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<SeqUtils *>(dev))->is_Reset_allowed(any);} +}; + +// Command SetFault class definition +class SetFaultClass : public Tango::Command +{ +public: + SetFaultClass(const char *name, + Tango::CmdArgType in, + Tango::CmdArgType out, + const char *in_desc, + const char *out_desc, + Tango::DispLevel level) + :Command(name,in,out,in_desc,out_desc, level) {}; + + SetFaultClass(const char *name, + Tango::CmdArgType in, + Tango::CmdArgType out) + :Command(name,in,out) {}; + ~SetFaultClass() {}; + + 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<SeqUtils *>(dev))->is_SetFault_allowed(any);} +}; + +// Command Start class definition +class StartClass : public Tango::Command +{ +public: + StartClass(const char *name, + Tango::CmdArgType in, + Tango::CmdArgType out, + const char *in_desc, + const char *out_desc, + Tango::DispLevel level) + :Command(name,in,out,in_desc,out_desc, level) {}; + + StartClass(const char *name, + Tango::CmdArgType in, + Tango::CmdArgType out) + :Command(name,in,out) {}; + ~StartClass() {}; + + 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<SeqUtils *>(dev))->is_Start_allowed(any);} +}; + +// Command Stop class definition +class StopClass : public Tango::Command +{ +public: + StopClass(const char *name, + Tango::CmdArgType in, + Tango::CmdArgType out, + const char *in_desc, + const char *out_desc, + Tango::DispLevel level) + :Command(name,in,out,in_desc,out_desc, level) {}; + + StopClass(const char *name, + Tango::CmdArgType in, + Tango::CmdArgType out) + :Command(name,in,out) {}; + ~StopClass() {}; + + 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<SeqUtils *>(dev))->is_Stop_allowed(any);} +}; + + +/** + * The SeqUtilsClass singleton definition + */ + +#ifdef _TG_WINDOWS_ +class __declspec(dllexport) SeqUtilsClass : public Tango::DeviceClass +#else +class SeqUtilsClass : public Tango::DeviceClass +#endif +{ + /*----- PROTECTED REGION ID(SeqUtilsClass::Additionnal DServer data members) ENABLED START -----*/ + + + /*----- PROTECTED REGION END -----*/ // SeqUtilsClass::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 SeqUtilsClass *init(const char *); + static SeqUtilsClass *instance(); + ~SeqUtilsClass(); + Tango::DbDatum get_class_property(string &); + Tango::DbDatum get_default_device_property(string &); + Tango::DbDatum get_default_class_property(string &); + + protected: + SeqUtilsClass(string &); + static SeqUtilsClass *_instance; + void command_factory(); + void attribute_factory(vector<Tango::Attr *> &); + void pipe_factory(); + void write_class_property(); + void set_default_property(); + void get_class_property(); + string get_cvstag(); + string get_cvsroot(); + + private: + void device_factory(const Tango::DevVarStringArray *); + void create_static_attribute_list(vector<Tango::Attr *> &); + void erase_dynamic_attributes(const Tango::DevVarStringArray *,vector<Tango::Attr *> &); + vector<string> defaultAttList; + Tango::Attr *get_attr_object_by_name(vector<Tango::Attr *> &att_list, string attname); +}; + +} // End of namespace + +#endif // SeqUtils_H diff --git a/src/UtilsStateMachine.cpp b/src/UtilsStateMachine.cpp new file mode 100644 index 0000000..3fd69c9 --- /dev/null +++ b/src/UtilsStateMachine.cpp @@ -0,0 +1,386 @@ +/*----- PROTECTED REGION ID(SeqUtilsStateMachine.cpp) ENABLED START -----*/ +//============================================================================= +// +// file : SeqUtilsStateMachine.cpp +// +// description : State machine file for the SeqUtils class +// +// project : SeqUtils +// +// 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 <SeqUtils.h> + +/*----- PROTECTED REGION END -----*/ // SeqUtils::SeqUtilsStateMachine.cpp + +//================================================================ +// States | Description +//================================================================ +// ON | +// OFF | +// FAULT | + + +namespace SeqUtils_ns +{ +//================================================= +// Attributes Allowed Methods +//================================================= + +//-------------------------------------------------------- +/** + * Method : SeqUtils::is_DRand_allowed() + * Description : Execution allowed for DRand attribute + */ +//-------------------------------------------------------- +bool SeqUtils::is_DRand_allowed(TANGO_UNUSED(Tango::AttReqType type)) +{ + + // Not any excluded states for DRand attribute in read access. + /*----- PROTECTED REGION ID(SeqUtils::DRandStateAllowed_READ) ENABLED START -----*/ + + /*----- PROTECTED REGION END -----*/ // SeqUtils::DRandStateAllowed_READ + return true; +} + +//-------------------------------------------------------- +/** + * Method : SeqUtils::is_DRandMin_allowed() + * Description : Execution allowed for DRandMin attribute + */ +//-------------------------------------------------------- +bool SeqUtils::is_DRandMin_allowed(TANGO_UNUSED(Tango::AttReqType type)) +{ + // Not any excluded states for DRandMin attribute in Write access. + /*----- PROTECTED REGION ID(SeqUtils::DRandMinStateAllowed_WRITE) ENABLED START -----*/ + + /*----- PROTECTED REGION END -----*/ // SeqUtils::DRandMinStateAllowed_WRITE + + // Not any excluded states for DRandMin attribute in read access. + /*----- PROTECTED REGION ID(SeqUtils::DRandMinStateAllowed_READ) ENABLED START -----*/ + + /*----- PROTECTED REGION END -----*/ // SeqUtils::DRandMinStateAllowed_READ + return true; +} + +//-------------------------------------------------------- +/** + * Method : SeqUtils::is_DRandMax_allowed() + * Description : Execution allowed for DRandMax attribute + */ +//-------------------------------------------------------- +bool SeqUtils::is_DRandMax_allowed(TANGO_UNUSED(Tango::AttReqType type)) +{ + // Not any excluded states for DRandMax attribute in Write access. + /*----- PROTECTED REGION ID(SeqUtils::DRandMaxStateAllowed_WRITE) ENABLED START -----*/ + + /*----- PROTECTED REGION END -----*/ // SeqUtils::DRandMaxStateAllowed_WRITE + + // Not any excluded states for DRandMax attribute in read access. + /*----- PROTECTED REGION ID(SeqUtils::DRandMaxStateAllowed_READ) ENABLED START -----*/ + + /*----- PROTECTED REGION END -----*/ // SeqUtils::DRandMaxStateAllowed_READ + return true; +} + +//-------------------------------------------------------- +/** + * Method : SeqUtils::is_LRand_allowed() + * Description : Execution allowed for LRand attribute + */ +//-------------------------------------------------------- +bool SeqUtils::is_LRand_allowed(TANGO_UNUSED(Tango::AttReqType type)) +{ + + // Not any excluded states for LRand attribute in read access. + /*----- PROTECTED REGION ID(SeqUtils::LRandStateAllowed_READ) ENABLED START -----*/ + + /*----- PROTECTED REGION END -----*/ // SeqUtils::LRandStateAllowed_READ + return true; +} + +//-------------------------------------------------------- +/** + * Method : SeqUtils::is_LRandMin_allowed() + * Description : Execution allowed for LRandMin attribute + */ +//-------------------------------------------------------- +bool SeqUtils::is_LRandMin_allowed(TANGO_UNUSED(Tango::AttReqType type)) +{ + // Not any excluded states for LRandMin attribute in Write access. + /*----- PROTECTED REGION ID(SeqUtils::LRandMinStateAllowed_WRITE) ENABLED START -----*/ + + /*----- PROTECTED REGION END -----*/ // SeqUtils::LRandMinStateAllowed_WRITE + + // Not any excluded states for LRandMin attribute in read access. + /*----- PROTECTED REGION ID(SeqUtils::LRandMinStateAllowed_READ) ENABLED START -----*/ + + /*----- PROTECTED REGION END -----*/ // SeqUtils::LRandMinStateAllowed_READ + return true; +} + +//-------------------------------------------------------- +/** + * Method : SeqUtils::is_LRandMax_allowed() + * Description : Execution allowed for LRandMax attribute + */ +//-------------------------------------------------------- +bool SeqUtils::is_LRandMax_allowed(TANGO_UNUSED(Tango::AttReqType type)) +{ + // Not any excluded states for LRandMax attribute in Write access. + /*----- PROTECTED REGION ID(SeqUtils::LRandMaxStateAllowed_WRITE) ENABLED START -----*/ + + /*----- PROTECTED REGION END -----*/ // SeqUtils::LRandMaxStateAllowed_WRITE + + // Not any excluded states for LRandMax attribute in read access. + /*----- PROTECTED REGION ID(SeqUtils::LRandMaxStateAllowed_READ) ENABLED START -----*/ + + /*----- PROTECTED REGION END -----*/ // SeqUtils::LRandMaxStateAllowed_READ + return true; +} + +//-------------------------------------------------------- +/** + * Method : SeqUtils::is_Data_allowed() + * Description : Execution allowed for Data attribute + */ +//-------------------------------------------------------- +bool SeqUtils::is_Data_allowed(TANGO_UNUSED(Tango::AttReqType type)) +{ + // Check access type. + if ( type!=Tango::READ_REQ ) + { + // Compare device state with not allowed states for WRITE + if (get_state()==Tango::OFF || + get_state()==Tango::FAULT) + { + /*----- PROTECTED REGION ID(SeqUtils::DataStateAllowed_WRITE) ENABLED START -----*/ + + /*----- PROTECTED REGION END -----*/ // SeqUtils::DataStateAllowed_WRITE + return false; + } + return true; + } + else + + // Not any excluded states for Data attribute in read access. + /*----- PROTECTED REGION ID(SeqUtils::DataStateAllowed_READ) ENABLED START -----*/ + + /*----- PROTECTED REGION END -----*/ // SeqUtils::DataStateAllowed_READ + return true; +} + +//-------------------------------------------------------- +/** + * Method : SeqUtils::is_Data1_allowed() + * Description : Execution allowed for Data1 attribute + */ +//-------------------------------------------------------- +bool SeqUtils::is_Data1_allowed(TANGO_UNUSED(Tango::AttReqType type)) +{ + // Not any excluded states for Data1 attribute in Write access. + /*----- PROTECTED REGION ID(SeqUtils::Data1StateAllowed_WRITE) ENABLED START -----*/ + + /*----- PROTECTED REGION END -----*/ // SeqUtils::Data1StateAllowed_WRITE + + // Not any excluded states for Data1 attribute in read access. + /*----- PROTECTED REGION ID(SeqUtils::Data1StateAllowed_READ) ENABLED START -----*/ + + /*----- PROTECTED REGION END -----*/ // SeqUtils::Data1StateAllowed_READ + return true; +} + +//-------------------------------------------------------- +/** + * Method : SeqUtils::is_LData_allowed() + * Description : Execution allowed for LData attribute + */ +//-------------------------------------------------------- +bool SeqUtils::is_LData_allowed(TANGO_UNUSED(Tango::AttReqType type)) +{ + // Check access type. + if ( type!=Tango::READ_REQ ) + { + // Compare device state with not allowed states for WRITE + if (get_state()==Tango::OFF || + get_state()==Tango::FAULT) + { + /*----- PROTECTED REGION ID(SeqUtils::LDataStateAllowed_WRITE) ENABLED START -----*/ + + /*----- PROTECTED REGION END -----*/ // SeqUtils::LDataStateAllowed_WRITE + return false; + } + return true; + } + else + + // Not any excluded states for LData attribute in read access. + /*----- PROTECTED REGION ID(SeqUtils::LDataStateAllowed_READ) ENABLED START -----*/ + + /*----- PROTECTED REGION END -----*/ // SeqUtils::LDataStateAllowed_READ + return true; +} + +//-------------------------------------------------------- +/** + * Method : SeqUtils::is_Date_allowed() + * Description : Execution allowed for Date attribute + */ +//-------------------------------------------------------- +bool SeqUtils::is_Date_allowed(TANGO_UNUSED(Tango::AttReqType type)) +{ + + // Not any excluded states for Date attribute in read access. + /*----- PROTECTED REGION ID(SeqUtils::DateStateAllowed_READ) ENABLED START -----*/ + + /*----- PROTECTED REGION END -----*/ // SeqUtils::DateStateAllowed_READ + return true; +} + +//-------------------------------------------------------- +/** + * Method : SeqUtils::is_LDate_allowed() + * Description : Execution allowed for LDate attribute + */ +//-------------------------------------------------------- +bool SeqUtils::is_LDate_allowed(TANGO_UNUSED(Tango::AttReqType type)) +{ + + // Not any excluded states for LDate attribute in read access. + /*----- PROTECTED REGION ID(SeqUtils::LDateStateAllowed_READ) ENABLED START -----*/ + + /*----- PROTECTED REGION END -----*/ // SeqUtils::LDateStateAllowed_READ + return true; +} + + +//================================================= +// Commands Allowed Methods +//================================================= + +//-------------------------------------------------------- +/** + * Method : SeqUtils::is_On_allowed() + * Description : Execution allowed for On attribute + */ +//-------------------------------------------------------- +bool SeqUtils::is_On_allowed(TANGO_UNUSED(const CORBA::Any &any)) +{ + // Compare device state with not allowed states. + if (get_state()==Tango::FAULT) + { + /*----- PROTECTED REGION ID(SeqUtils::OnStateAllowed) ENABLED START -----*/ + + /*----- PROTECTED REGION END -----*/ // SeqUtils::OnStateAllowed + return false; + } + return true; +} + +//-------------------------------------------------------- +/** + * Method : SeqUtils::is_Off_allowed() + * Description : Execution allowed for Off attribute + */ +//-------------------------------------------------------- +bool SeqUtils::is_Off_allowed(TANGO_UNUSED(const CORBA::Any &any)) +{ + // Compare device state with not allowed states. + if (get_state()==Tango::FAULT) + { + /*----- PROTECTED REGION ID(SeqUtils::OffStateAllowed) ENABLED START -----*/ + + /*----- PROTECTED REGION END -----*/ // SeqUtils::OffStateAllowed + return false; + } + return true; +} + +//-------------------------------------------------------- +/** + * Method : SeqUtils::is_Reset_allowed() + * Description : Execution allowed for Reset attribute + */ +//-------------------------------------------------------- +bool SeqUtils::is_Reset_allowed(TANGO_UNUSED(const CORBA::Any &any)) +{ + // Not any excluded states for Reset command. + /*----- PROTECTED REGION ID(SeqUtils::ResetStateAllowed) ENABLED START -----*/ + + /*----- PROTECTED REGION END -----*/ // SeqUtils::ResetStateAllowed + return true; +} + +//-------------------------------------------------------- +/** + * Method : SeqUtils::is_SetFault_allowed() + * Description : Execution allowed for SetFault attribute + */ +//-------------------------------------------------------- +bool SeqUtils::is_SetFault_allowed(TANGO_UNUSED(const CORBA::Any &any)) +{ + // Not any excluded states for SetFault command. + /*----- PROTECTED REGION ID(SeqUtils::SetFaultStateAllowed) ENABLED START -----*/ + + /*----- PROTECTED REGION END -----*/ // SeqUtils::SetFaultStateAllowed + return true; +} + +//-------------------------------------------------------- +/** + * Method : SeqUtils::is_Start_allowed() + * Description : Execution allowed for Start attribute + */ +//-------------------------------------------------------- +bool SeqUtils::is_Start_allowed(TANGO_UNUSED(const CORBA::Any &any)) +{ + // Not any excluded states for Start command. + /*----- PROTECTED REGION ID(SeqUtils::StartStateAllowed) ENABLED START -----*/ + + /*----- PROTECTED REGION END -----*/ // SeqUtils::StartStateAllowed + return true; +} + +//-------------------------------------------------------- +/** + * Method : SeqUtils::is_Stop_allowed() + * Description : Execution allowed for Stop attribute + */ +//-------------------------------------------------------- +bool SeqUtils::is_Stop_allowed(TANGO_UNUSED(const CORBA::Any &any)) +{ + // Not any excluded states for Stop command. + /*----- PROTECTED REGION ID(SeqUtils::StopStateAllowed) ENABLED START -----*/ + + /*----- PROTECTED REGION END -----*/ // SeqUtils::StopStateAllowed + return true; +} + + +/*----- PROTECTED REGION ID(SeqUtils::SeqUtilsStateAllowed.AdditionalMethods) ENABLED START -----*/ + +// Additional Methods + +/*----- PROTECTED REGION END -----*/ // SeqUtils::SeqUtilsStateAllowed.AdditionalMethods + +} // End of namespace diff --git a/src/main.cpp b/src/main.cpp new file mode 100644 index 0000000..0437fdd --- /dev/null +++ b/src/main.cpp @@ -0,0 +1,81 @@ +/*----- PROTECTED REGION ID(SeqUtils::main.cpp) ENABLED START -----*/ +//============================================================================= +// +// file : main.cpp +// +// description : C++ source for the SeqUtils 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 : SeqUtils +// +// 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.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 + try + { + // Initialise the device server + //---------------------------------------- + Tango::Util *tg = Tango::Util::init(argc,argv); + + // Create the device server singleton + // which will create everything + //---------------------------------------- + tg->server_init(false); + + // Run the endless loop + //---------------------------------------- + cout << "Ready to accept request" << endl; + tg->server_run(); + } + catch (bad_alloc &) + { + cout << "Can't allocate memory to store device object !!!" << endl; + cout << "Exiting" << endl; + } + catch (CORBA::Exception &e) + { + Tango::Except::print_exception(e); + + cout << "Received a CORBA_Exception" << endl; + cout << "Exiting" << endl; + } + Tango::Util::instance()->server_cleanup(); + return(0); +} + +/*----- PROTECTED REGION END -----*/ // SeqUtils::main.cpp -- GitLab