From 52ae6a63a73f988c287654d4102ac02eafca1475 Mon Sep 17 00:00:00 2001 From: Giulio Gaio <giulio.gaio@elettra.eu> Date: Tue, 2 May 2023 08:46:06 +0200 Subject: [PATCH] First release --- Makefile | 20 + src/ClassFactory.cpp | 52 + src/DataVampire.cpp | 2453 +++++++++++++++++++++++++++++++ src/DataVampire.h | 552 +++++++ src/DataVampire.xmi | 308 ++++ src/DataVampireClass.cpp | 1313 +++++++++++++++++ src/DataVampireClass.h | 622 ++++++++ src/DataVampireStateMachine.cpp | 640 ++++++++ src/main.cpp | 88 ++ 9 files changed, 6048 insertions(+) create mode 100644 Makefile create mode 100644 src/ClassFactory.cpp create mode 100644 src/DataVampire.cpp create mode 100644 src/DataVampire.h create mode 100644 src/DataVampire.xmi create mode 100644 src/DataVampireClass.cpp create mode 100644 src/DataVampireClass.h create mode 100644 src/DataVampireStateMachine.cpp create mode 100644 src/main.cpp diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..08b2d96 --- /dev/null +++ b/Makefile @@ -0,0 +1,20 @@ +NAME_SRV = datavampire-srv + +UNAME := $(shell uname -r) + +# 2.6.32.59+drm33.24-e1000e: sakurambo64 ubuntu 10.04 +# 3.14.58-rt59-e1000e: sakurambo ubuntu 14.04 +# else: new voltumna based architecture + + +ifeq ($(UNAME),$(filter $(UNAME),2.6.32.59+drm33.24-e1000e 3.14.58-rt59-e1000e)) + + include ../makefiles/Make-9.3.4.in + +else + + include ../makefiles/Make-9.3.4.in + +endif + + diff --git a/src/ClassFactory.cpp b/src/ClassFactory.cpp new file mode 100644 index 0000000..e8c4acc --- /dev/null +++ b/src/ClassFactory.cpp @@ -0,0 +1,52 @@ +/*----- PROTECTED REGION ID(DataVampire::ClassFactory.cpp) ENABLED START -----*/ +/* clang-format on */ +//============================================================================= +// +// file : ClassFactory.cpp +// +// description : C++ source for the class_factory method of the DServer +// device class. This method is responsible for the creation of +// all class singleton for a device server. It is called +// at device server startup. +// +// project : DataVampire +// +// This file is part of Tango device class. +// +// Tango is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// Tango is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with Tango. If not, see <http://www.gnu.org/licenses/>. +// +// +// +//============================================================================= +// This file is generated by POGO +// (Program Obviously used to Generate tango Object) +//============================================================================= + +#include <tango/tango.h> +#include "DataVampireClass.h" + +// Add class header files if needed + + +/** + * Create DataVampire Class singleton and store it in DServer object. + */ + +void Tango::DServer::class_factory() +{ + // Add method class init if needed + add_class(DataVampire_ns::DataVampireClass::init("DataVampire")); +} +/* clang-format off */ +/*----- PROTECTED REGION END -----*/ // DataVampire::ClassFactory.cpp diff --git a/src/DataVampire.cpp b/src/DataVampire.cpp new file mode 100644 index 0000000..90986fc --- /dev/null +++ b/src/DataVampire.cpp @@ -0,0 +1,2453 @@ +/*----- PROTECTED REGION ID(DataVampire.cpp) ENABLED START -----*/ +/* clang-format on */ +//============================================================================= +// +// file : DataVampire.cpp +// +// description : C++ source for the DataVampire 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 +// DataVampire are implemented in this file. +// +// project : DataVampire +// +// 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 "DataVampire.h" +#include "DataVampireClass.h" +/* clang-format off */ +/*----- PROTECTED REGION END -----*/ // DataVampire.cpp + +/** + * DataVampire class description: + * Get vectors of 1D or 2D data and calculate sum, mean, horpos, verpos, horsigma, versigma, numsamples + */ + +//================================================================ +// The following table gives the correspondence +// between command and method names. +// +// Command name | Method name +//================================================================ +// State | Inherited (no method) +// Status | Inherited (no method) +// GetSum | get_sum +// GetMean | get_mean +// GetHorPos | get_hor_pos +// GetVerPos | get_ver_pos +// GetHorSigma | get_hor_sigma +// GetVerSigma | get_ver_sigma +// GetValidValues | get_valid_values +// SetBackground | set_background +//================================================================ + +//================================================================ +// Attributes managed are: +//================================================================ +// MinThreshold | Tango::DevDouble Scalar +// MaxThreshold | Tango::DevDouble Scalar +// CommandString | Tango::DevString Scalar +// PollingTime | Tango::DevLong Scalar +// PollingSamples | Tango::DevLong Scalar +// Sum | Tango::DevDouble Scalar +// Mean | Tango::DevDouble Scalar +// HorPos | Tango::DevDouble Scalar +// VerPos | Tango::DevDouble Scalar +// HorSigma | Tango::DevDouble Scalar +// VerSigma | Tango::DevDouble Scalar +// ValidValues | Tango::DevLong Scalar +// Enable | Tango::DevBoolean Scalar +// CacheSize | Tango::DevLong Scalar +// AutoBackgroundSamples | Tango::DevLong Scalar +// PostAcqRoi | Tango::DevBoolean Scalar +// ImageWidth | Tango::DevLong Scalar +// ImageHeight | Tango::DevLong Scalar +// RoiParam | Tango::DevLong Spectrum ( max = 4) +// Spectrum | Tango::DevDouble Spectrum ( max = 1000000) +// HorBackground | Tango::DevDouble Spectrum ( max = 1000000) +// VerBackground | Tango::DevDouble Spectrum ( max = 1000000) +// Image | Tango::DevDouble Image ( max = 5000 x 5000) +//================================================================ + +namespace DataVampire_ns +{ +/*----- PROTECTED REGION ID(DataVampire::namespace_starting) ENABLED START -----*/ +/* clang-format on */ +// static initializations +/* clang-format off */ +/*----- PROTECTED REGION END -----*/ // DataVampire::namespace_starting + +//-------------------------------------------------------- +/** + * Method : DataVampire::DataVampire() + * Description : Constructors for a Tango device + * implementing the classDataVampire + */ +//-------------------------------------------------------- +DataVampire::DataVampire(Tango::DeviceClass *cl, string &s) + : TANGO_BASE_CLASS(cl, s.c_str()) +{ + /*----- PROTECTED REGION ID(DataVampire::constructor_1) ENABLED START -----*/ + /* clang-format on */ + init_device(); + /* clang-format off */ + /*----- PROTECTED REGION END -----*/ // DataVampire::constructor_1 +} +//-------------------------------------------------------- +DataVampire::DataVampire(Tango::DeviceClass *cl, const char *s) + : TANGO_BASE_CLASS(cl, s) +{ + /*----- PROTECTED REGION ID(DataVampire::constructor_2) ENABLED START -----*/ + /* clang-format on */ + init_device(); + /* clang-format off */ + /*----- PROTECTED REGION END -----*/ // DataVampire::constructor_2 +} +//-------------------------------------------------------- +DataVampire::DataVampire(Tango::DeviceClass *cl, const char *s, const char *d) + : TANGO_BASE_CLASS(cl, s, d) +{ + /*----- PROTECTED REGION ID(DataVampire::constructor_3) ENABLED START -----*/ + /* clang-format on */ + init_device(); + /* clang-format off */ + /*----- PROTECTED REGION END -----*/ // DataVampire::constructor_3 +} + +//-------------------------------------------------------- +/** + * Method : DataVampire::delete_device() + * Description : will be called at device destruction or at init command + */ +//-------------------------------------------------------- +void DataVampire::delete_device() +{ + DEBUG_STREAM << "DataVampire::delete_device() " << device_name << endl; + /*----- PROTECTED REGION ID(DataVampire::delete_device) ENABLED START -----*/ + /* clang-format on */ + // Delete device allocated objects + /* clang-format off */ + if (device) + delete device; + + free_cache_buffer(); + + /*----- PROTECTED REGION END -----*/ // DataVampire::delete_device + delete[] attr_MinThreshold_read; + delete[] attr_MaxThreshold_read; + delete[] attr_CommandString_read; + delete[] attr_PollingTime_read; + delete[] attr_PollingSamples_read; + delete[] attr_Sum_read; + delete[] attr_Mean_read; + delete[] attr_HorPos_read; + delete[] attr_VerPos_read; + delete[] attr_HorSigma_read; + delete[] attr_VerSigma_read; + delete[] attr_ValidValues_read; + delete[] attr_Enable_read; + delete[] attr_CacheSize_read; + delete[] attr_AutoBackgroundSamples_read; + delete[] attr_PostAcqRoi_read; + delete[] attr_ImageWidth_read; + delete[] attr_ImageHeight_read; + delete[] attr_RoiParam_read; + delete[] attr_Spectrum_read; + delete[] attr_HorBackground_read; + delete[] attr_VerBackground_read; + delete[] attr_Image_read; +} + +//-------------------------------------------------------- +/** + * Method : DataVampire::init_device() + * Description : will be called at device initialization. + */ +//-------------------------------------------------------- +void DataVampire::init_device() +{ + DEBUG_STREAM << "DataVampire::init_device() create device " << device_name << endl; + /*----- PROTECTED REGION ID(DataVampire::init_device_before) ENABLED START -----*/ + /* clang-format on */ + // Initialization before get_device_property() call + /* clang-format off */ + /*----- PROTECTED REGION END -----*/ // DataVampire::init_device_before + + + // Get the device properties from database + get_device_property(); + + attr_MinThreshold_read = new Tango::DevDouble[1]; + attr_MaxThreshold_read = new Tango::DevDouble[1]; + attr_CommandString_read = new Tango::DevString[1]; + attr_PollingTime_read = new Tango::DevLong[1]; + attr_PollingSamples_read = new Tango::DevLong[1]; + attr_Sum_read = new Tango::DevDouble[1]; + attr_Mean_read = new Tango::DevDouble[1]; + attr_HorPos_read = new Tango::DevDouble[1]; + attr_VerPos_read = new Tango::DevDouble[1]; + attr_HorSigma_read = new Tango::DevDouble[1]; + attr_VerSigma_read = new Tango::DevDouble[1]; + attr_ValidValues_read = new Tango::DevLong[1]; + attr_Enable_read = new Tango::DevBoolean[1]; + attr_CacheSize_read = new Tango::DevLong[1]; + attr_AutoBackgroundSamples_read = new Tango::DevLong[1]; + attr_PostAcqRoi_read = new Tango::DevBoolean[1]; + attr_ImageWidth_read = new Tango::DevLong[1]; + attr_ImageHeight_read = new Tango::DevLong[1]; + attr_RoiParam_read = new Tango::DevLong[4]; + attr_Spectrum_read = new Tango::DevDouble[1000000]; + attr_HorBackground_read = new Tango::DevDouble[1000000]; + attr_VerBackground_read = new Tango::DevDouble[1000000]; + attr_Image_read = new Tango::DevDouble[5000*5000]; + /*----- PROTECTED REGION ID(DataVampire::init_device) ENABLED START -----*/ + /* clang-format on */ + // Initialize device + /* clang-format off */ + + *attr_AutoBackgroundSamples_read = 0; + *attr_MinThreshold_read = -99999; + *attr_MaxThreshold_read = 99999; + *attr_CacheSize_read = 100; + *attr_PostAcqRoi_read = false; + + num_rows_image = 0; + num_cols_image = 0; + num_cols_spectrum = 0; + + roi_dim = 0; + for (int i = 0; i < 4; i++) { + attr_RoiParam_read[i] = roiParam[i]; + if (attr_RoiParam_read[i] >= 0) + roi_dim++; + } + + std::vector<std::string> results; + std::string new_configuration(commandString); + string_explode(new_configuration, "/", &results); + + command_name = results[results.size()-1]; + size_t pos = new_configuration.find(command_name); + if (pos != std::string::npos) { // if str2 found in str1 + new_configuration.erase(pos-1, command_name.length()+1); // erase str2 from str1 + } + device_name = new_configuration; + + device = new Tango::DeviceProxy(device_name); + + Tango::CommandInfo cmd_info = device->command_query(command_name); + cmd_in_type = cmd_info.in_type; + cmd_out_type = cmd_info.out_type; + + + cache_buffer = 0; + allocate_cache_buffer(); + + + /*----- PROTECTED REGION END -----*/ // DataVampire::init_device +} + +//-------------------------------------------------------- +/** + * Method : DataVampire::get_device_property() + * Description : Read database to initialize property data members. + */ +//-------------------------------------------------------- +void DataVampire::get_device_property() +{ + /*----- PROTECTED REGION ID(DataVampire::get_device_property_before) ENABLED START -----*/ + /* clang-format on */ + // Initialize property data members + /* clang-format off */ + /*----- PROTECTED REGION END -----*/ // DataVampire::get_device_property_before + + + // Read device properties from database. + Tango::DbData dev_prop; + dev_prop.push_back(Tango::DbDatum("HorCalib")); + dev_prop.push_back(Tango::DbDatum("VerCalib")); + dev_prop.push_back(Tango::DbDatum("RoiParam")); + dev_prop.push_back(Tango::DbDatum("CommandString")); + + // is there at least one property to be read ? + if (dev_prop.size()>0) + { + // Call database and extract values + if (Tango::Util::instance()->_UseDb==true) + get_db_device()->get_property(dev_prop); + + // get instance on DataVampireClass to get class property + Tango::DbDatum def_prop, cl_prop; + DataVampireClass *ds_class = + (static_cast<DataVampireClass *>(get_device_class())); + int i = -1; + + // Try to initialize HorCalib from class property + cl_prop = ds_class->get_class_property(dev_prop[++i].name); + if (cl_prop.is_empty()==false) cl_prop >> horCalib; + else { + // Try to initialize HorCalib from default device value + def_prop = ds_class->get_default_device_property(dev_prop[i].name); + if (def_prop.is_empty()==false) def_prop >> horCalib; + } + // And try to extract HorCalib value from database + if (dev_prop[i].is_empty()==false) dev_prop[i] >> horCalib; + + // Try to initialize VerCalib from class property + cl_prop = ds_class->get_class_property(dev_prop[++i].name); + if (cl_prop.is_empty()==false) cl_prop >> verCalib; + else { + // Try to initialize VerCalib from default device value + def_prop = ds_class->get_default_device_property(dev_prop[i].name); + if (def_prop.is_empty()==false) def_prop >> verCalib; + } + // And try to extract VerCalib value from database + if (dev_prop[i].is_empty()==false) dev_prop[i] >> verCalib; + + // Try to initialize RoiParam from class property + cl_prop = ds_class->get_class_property(dev_prop[++i].name); + if (cl_prop.is_empty()==false) cl_prop >> roiParam; + else { + // Try to initialize RoiParam from default device value + def_prop = ds_class->get_default_device_property(dev_prop[i].name); + if (def_prop.is_empty()==false) def_prop >> roiParam; + } + // And try to extract RoiParam value from database + if (dev_prop[i].is_empty()==false) dev_prop[i] >> roiParam; + + // Try to initialize CommandString from class property + cl_prop = ds_class->get_class_property(dev_prop[++i].name); + if (cl_prop.is_empty()==false) cl_prop >> commandString; + else { + // Try to initialize CommandString from default device value + def_prop = ds_class->get_default_device_property(dev_prop[i].name); + if (def_prop.is_empty()==false) def_prop >> commandString; + } + // And try to extract CommandString value from database + if (dev_prop[i].is_empty()==false) dev_prop[i] >> commandString; + + } + + /*----- PROTECTED REGION ID(DataVampire::get_device_property_after) ENABLED START -----*/ + /* clang-format on */ + // Check device property data members init + /* clang-format off */ + /*----- PROTECTED REGION END -----*/ // DataVampire::get_device_property_after +} + +//-------------------------------------------------------- +/** + * Method : DataVampire::always_executed_hook() + * Description : method always executed before any command is executed + */ +//-------------------------------------------------------- +void DataVampire::always_executed_hook() +{ + DEBUG_STREAM << "DataVampire::always_executed_hook() " << device_name << endl; + /*----- PROTECTED REGION ID(DataVampire::always_executed_hook) ENABLED START -----*/ + /* clang-format on */ + // code always executed before all requests + /* clang-format off */ + /*----- PROTECTED REGION END -----*/ // DataVampire::always_executed_hook +} + +//-------------------------------------------------------- +/** + * Method : DataVampire::read_attr_hardware() + * Description : Hardware acquisition for attributes + */ +//-------------------------------------------------------- +void DataVampire::read_attr_hardware(TANGO_UNUSED(vector<long> &attr_list)) +{ + DEBUG_STREAM << "DataVampire::read_attr_hardware(vector<long> &attr_list) entering... " << endl; + /*----- PROTECTED REGION ID(DataVampire::read_attr_hardware) ENABLED START -----*/ + /* clang-format on */ + // Add your own code + /* clang-format off */ + /*----- PROTECTED REGION END -----*/ // DataVampire::read_attr_hardware +} +//-------------------------------------------------------- +/** + * Method : DataVampire::write_attr_hardware() + * Description : Hardware writing for attributes + */ +//-------------------------------------------------------- +void DataVampire::write_attr_hardware(TANGO_UNUSED(vector<long> &attr_list)) +{ + DEBUG_STREAM << "DataVampire::write_attr_hardware(vector<long> &attr_list) entering... " << endl; + /*----- PROTECTED REGION ID(DataVampire::write_attr_hardware) ENABLED START -----*/ + /* clang-format on */ + // Add your own code + /* clang-format off */ + /*----- PROTECTED REGION END -----*/ // DataVampire::write_attr_hardware +} + +//-------------------------------------------------------- +/** + * Read attribute MinThreshold related method + * Description: + * + * Data type: Tango::DevDouble + * Attr type: Scalar + */ +//-------------------------------------------------------- +void DataVampire::read_MinThreshold(Tango::Attribute &attr) +{ + DEBUG_STREAM << "DataVampire::read_MinThreshold(Tango::Attribute &attr) entering... " << endl; + /*----- PROTECTED REGION ID(DataVampire::read_MinThreshold) ENABLED START -----*/ + /* clang-format on */ + // Set the attribute value + attr.set_value(attr_MinThreshold_read); + /* clang-format off */ + /*----- PROTECTED REGION END -----*/ // DataVampire::read_MinThreshold +} +//-------------------------------------------------------- +/** + * Write attribute MinThreshold related method + * Description: + * + * Data type: Tango::DevDouble + * Attr type: Scalar + */ +//-------------------------------------------------------- +void DataVampire::write_MinThreshold(Tango::WAttribute &attr) +{ + DEBUG_STREAM << "DataVampire::write_MinThreshold(Tango::WAttribute &attr) entering... " << endl; + // Retrieve write value + Tango::DevDouble w_val; + attr.get_write_value(w_val); + /*----- PROTECTED REGION ID(DataVampire::write_MinThreshold) ENABLED START -----*/ + /* clang-format on */ + // Add your own code + *attr_MinThreshold_read = w_val; + + + /* clang-format off */ + /*----- PROTECTED REGION END -----*/ // DataVampire::write_MinThreshold +} +//-------------------------------------------------------- +/** + * Read attribute MaxThreshold related method + * Description: + * + * Data type: Tango::DevDouble + * Attr type: Scalar + */ +//-------------------------------------------------------- +void DataVampire::read_MaxThreshold(Tango::Attribute &attr) +{ + DEBUG_STREAM << "DataVampire::read_MaxThreshold(Tango::Attribute &attr) entering... " << endl; + /*----- PROTECTED REGION ID(DataVampire::read_MaxThreshold) ENABLED START -----*/ + /* clang-format on */ + // Set the attribute value + attr.set_value(attr_MaxThreshold_read); + /* clang-format off */ + /*----- PROTECTED REGION END -----*/ // DataVampire::read_MaxThreshold +} +//-------------------------------------------------------- +/** + * Write attribute MaxThreshold related method + * Description: + * + * Data type: Tango::DevDouble + * Attr type: Scalar + */ +//-------------------------------------------------------- +void DataVampire::write_MaxThreshold(Tango::WAttribute &attr) +{ + DEBUG_STREAM << "DataVampire::write_MaxThreshold(Tango::WAttribute &attr) entering... " << endl; + // Retrieve write value + Tango::DevDouble w_val; + attr.get_write_value(w_val); + /*----- PROTECTED REGION ID(DataVampire::write_MaxThreshold) ENABLED START -----*/ + /* clang-format on */ + // Add your own code + *attr_MaxThreshold_read = w_val; + /* clang-format off */ + /*----- PROTECTED REGION END -----*/ // DataVampire::write_MaxThreshold +} +//-------------------------------------------------------- +/** + * Read attribute CommandString related method + * Description: + * + * Data type: Tango::DevString + * Attr type: Scalar + */ +//-------------------------------------------------------- +void DataVampire::read_CommandString(Tango::Attribute &attr) +{ + DEBUG_STREAM << "DataVampire::read_CommandString(Tango::Attribute &attr) entering... " << endl; + /*----- PROTECTED REGION ID(DataVampire::read_CommandString) ENABLED START -----*/ + /* clang-format on */ + // Set the attribute value + attr.set_value(attr_CommandString_read); + /* clang-format off */ + /*----- PROTECTED REGION END -----*/ // DataVampire::read_CommandString +} +//-------------------------------------------------------- +/** + * Write attribute CommandString related method + * Description: + * + * Data type: Tango::DevString + * Attr type: Scalar + */ +//-------------------------------------------------------- +void DataVampire::write_CommandString(Tango::WAttribute &attr) +{ + DEBUG_STREAM << "DataVampire::write_CommandString(Tango::WAttribute &attr) entering... " << endl; + // Retrieve write value + Tango::DevString w_val; + attr.get_write_value(w_val); + /*----- PROTECTED REGION ID(DataVampire::write_CommandString) ENABLED START -----*/ + /* clang-format on */ + // Add your own code + /* clang-format off */ + /*----- PROTECTED REGION END -----*/ // DataVampire::write_CommandString +} +//-------------------------------------------------------- +/** + * Read attribute PollingTime related method + * Description: -1: disabled + * + * Data type: Tango::DevLong + * Attr type: Scalar + */ +//-------------------------------------------------------- +void DataVampire::read_PollingTime(Tango::Attribute &attr) +{ + DEBUG_STREAM << "DataVampire::read_PollingTime(Tango::Attribute &attr) entering... " << endl; + /*----- PROTECTED REGION ID(DataVampire::read_PollingTime) ENABLED START -----*/ + /* clang-format on */ + // Set the attribute value + attr.set_value(attr_PollingTime_read); + /* clang-format off */ + /*----- PROTECTED REGION END -----*/ // DataVampire::read_PollingTime +} +//-------------------------------------------------------- +/** + * Write attribute PollingTime related method + * Description: -1: disabled + * + * Data type: Tango::DevLong + * Attr type: Scalar + */ +//-------------------------------------------------------- +void DataVampire::write_PollingTime(Tango::WAttribute &attr) +{ + DEBUG_STREAM << "DataVampire::write_PollingTime(Tango::WAttribute &attr) entering... " << endl; + // Retrieve write value + Tango::DevLong w_val; + attr.get_write_value(w_val); + /*----- PROTECTED REGION ID(DataVampire::write_PollingTime) ENABLED START -----*/ + /* clang-format on */ + // Add your own code + /* clang-format off */ + *attr_PollingTime_read = w_val; + + /*----- PROTECTED REGION END -----*/ // DataVampire::write_PollingTime +} +//-------------------------------------------------------- +/** + * Read attribute PollingSamples related method + * Description: -1: disabled + * + * Data type: Tango::DevLong + * Attr type: Scalar + */ +//-------------------------------------------------------- +void DataVampire::read_PollingSamples(Tango::Attribute &attr) +{ + DEBUG_STREAM << "DataVampire::read_PollingSamples(Tango::Attribute &attr) entering... " << endl; + /*----- PROTECTED REGION ID(DataVampire::read_PollingSamples) ENABLED START -----*/ + /* clang-format on */ + // Set the attribute value + attr.set_value(attr_PollingSamples_read); + /* clang-format off */ + /*----- PROTECTED REGION END -----*/ // DataVampire::read_PollingSamples +} +//-------------------------------------------------------- +/** + * Write attribute PollingSamples related method + * Description: -1: disabled + * + * Data type: Tango::DevLong + * Attr type: Scalar + */ +//-------------------------------------------------------- +void DataVampire::write_PollingSamples(Tango::WAttribute &attr) +{ + DEBUG_STREAM << "DataVampire::write_PollingSamples(Tango::WAttribute &attr) entering... " << endl; + // Retrieve write value + Tango::DevLong w_val; + attr.get_write_value(w_val); + /*----- PROTECTED REGION ID(DataVampire::write_PollingSamples) ENABLED START -----*/ + /* clang-format on */ + // Add your own code + /* clang-format off */ + *attr_PollingSamples_read = w_val; + /*----- PROTECTED REGION END -----*/ // DataVampire::write_PollingSamples +} +//-------------------------------------------------------- +/** + * Read attribute Sum related method + * Description: + * + * Data type: Tango::DevDouble + * Attr type: Scalar + */ +//-------------------------------------------------------- +void DataVampire::read_Sum(Tango::Attribute &attr) +{ + DEBUG_STREAM << "DataVampire::read_Sum(Tango::Attribute &attr) entering... " << endl; + /*----- PROTECTED REGION ID(DataVampire::read_Sum) ENABLED START -----*/ + /* clang-format on */ + // Set the attribute value + attr.set_value(attr_Sum_read); + /* clang-format off */ + /*----- PROTECTED REGION END -----*/ // DataVampire::read_Sum +} +//-------------------------------------------------------- +/** + * Read attribute Mean related method + * Description: + * + * Data type: Tango::DevDouble + * Attr type: Scalar + */ +//-------------------------------------------------------- +void DataVampire::read_Mean(Tango::Attribute &attr) +{ + DEBUG_STREAM << "DataVampire::read_Mean(Tango::Attribute &attr) entering... " << endl; + /*----- PROTECTED REGION ID(DataVampire::read_Mean) ENABLED START -----*/ + /* clang-format on */ + // Set the attribute value + attr.set_value(attr_Mean_read); + /* clang-format off */ + /*----- PROTECTED REGION END -----*/ // DataVampire::read_Mean +} +//-------------------------------------------------------- +/** + * Read attribute HorPos related method + * Description: + * + * Data type: Tango::DevDouble + * Attr type: Scalar + */ +//-------------------------------------------------------- +void DataVampire::read_HorPos(Tango::Attribute &attr) +{ + DEBUG_STREAM << "DataVampire::read_HorPos(Tango::Attribute &attr) entering... " << endl; + /*----- PROTECTED REGION ID(DataVampire::read_HorPos) ENABLED START -----*/ + /* clang-format on */ + // Set the attribute value + attr.set_value(attr_HorPos_read); + /* clang-format off */ + /*----- PROTECTED REGION END -----*/ // DataVampire::read_HorPos +} +//-------------------------------------------------------- +/** + * Read attribute VerPos related method + * Description: + * + * Data type: Tango::DevDouble + * Attr type: Scalar + */ +//-------------------------------------------------------- +void DataVampire::read_VerPos(Tango::Attribute &attr) +{ + DEBUG_STREAM << "DataVampire::read_VerPos(Tango::Attribute &attr) entering... " << endl; + /*----- PROTECTED REGION ID(DataVampire::read_VerPos) ENABLED START -----*/ + /* clang-format on */ + // Set the attribute value + attr.set_value(attr_VerPos_read); + /* clang-format off */ + /*----- PROTECTED REGION END -----*/ // DataVampire::read_VerPos +} +//-------------------------------------------------------- +/** + * Read attribute HorSigma related method + * Description: + * + * Data type: Tango::DevDouble + * Attr type: Scalar + */ +//-------------------------------------------------------- +void DataVampire::read_HorSigma(Tango::Attribute &attr) +{ + DEBUG_STREAM << "DataVampire::read_HorSigma(Tango::Attribute &attr) entering... " << endl; + /*----- PROTECTED REGION ID(DataVampire::read_HorSigma) ENABLED START -----*/ + /* clang-format on */ + // Set the attribute value + attr.set_value(attr_HorSigma_read); + /* clang-format off */ + /*----- PROTECTED REGION END -----*/ // DataVampire::read_HorSigma +} +//-------------------------------------------------------- +/** + * Read attribute VerSigma related method + * Description: + * + * Data type: Tango::DevDouble + * Attr type: Scalar + */ +//-------------------------------------------------------- +void DataVampire::read_VerSigma(Tango::Attribute &attr) +{ + DEBUG_STREAM << "DataVampire::read_VerSigma(Tango::Attribute &attr) entering... " << endl; + /*----- PROTECTED REGION ID(DataVampire::read_VerSigma) ENABLED START -----*/ + /* clang-format on */ + // Set the attribute value + attr.set_value(attr_VerSigma_read); + /* clang-format off */ + /*----- PROTECTED REGION END -----*/ // DataVampire::read_VerSigma +} +//-------------------------------------------------------- +/** + * Read attribute ValidValues related method + * Description: + * + * Data type: Tango::DevLong + * Attr type: Scalar + */ +//-------------------------------------------------------- +void DataVampire::read_ValidValues(Tango::Attribute &attr) +{ + DEBUG_STREAM << "DataVampire::read_ValidValues(Tango::Attribute &attr) entering... " << endl; + /*----- PROTECTED REGION ID(DataVampire::read_ValidValues) ENABLED START -----*/ + /* clang-format on */ + // Set the attribute value + attr.set_value(attr_ValidValues_read); + /* clang-format off */ + /*----- PROTECTED REGION END -----*/ // DataVampire::read_ValidValues +} +//-------------------------------------------------------- +/** + * Read attribute Enable related method + * Description: + * + * Data type: Tango::DevBoolean + * Attr type: Scalar + */ +//-------------------------------------------------------- +void DataVampire::read_Enable(Tango::Attribute &attr) +{ + DEBUG_STREAM << "DataVampire::read_Enable(Tango::Attribute &attr) entering... " << endl; + /*----- PROTECTED REGION ID(DataVampire::read_Enable) ENABLED START -----*/ + /* clang-format on */ + // Set the attribute value + attr.set_value(attr_Enable_read); + /* clang-format off */ + /*----- PROTECTED REGION END -----*/ // DataVampire::read_Enable +} +//-------------------------------------------------------- +/** + * Write attribute Enable related method + * Description: + * + * Data type: Tango::DevBoolean + * Attr type: Scalar + */ +//-------------------------------------------------------- +void DataVampire::write_Enable(Tango::WAttribute &attr) +{ + DEBUG_STREAM << "DataVampire::write_Enable(Tango::WAttribute &attr) entering... " << endl; + // Retrieve write value + Tango::DevBoolean w_val; + attr.get_write_value(w_val); + /*----- PROTECTED REGION ID(DataVampire::write_Enable) ENABLED START -----*/ + /* clang-format on */ + // Add your own code + /* clang-format off */ + *attr_Enable_read = w_val; + /*----- PROTECTED REGION END -----*/ // DataVampire::write_Enable +} +//-------------------------------------------------------- +/** + * Read attribute CacheSize related method + * Description: + * + * Data type: Tango::DevLong + * Attr type: Scalar + */ +//-------------------------------------------------------- +void DataVampire::read_CacheSize(Tango::Attribute &attr) +{ + DEBUG_STREAM << "DataVampire::read_CacheSize(Tango::Attribute &attr) entering... " << endl; + /*----- PROTECTED REGION ID(DataVampire::read_CacheSize) ENABLED START -----*/ + /* clang-format on */ + // Set the attribute value + attr.set_value(attr_CacheSize_read); + /* clang-format off */ + /*----- PROTECTED REGION END -----*/ // DataVampire::read_CacheSize +} +//-------------------------------------------------------- +/** + * Write attribute CacheSize related method + * Description: + * + * Data type: Tango::DevLong + * Attr type: Scalar + */ +//-------------------------------------------------------- +void DataVampire::write_CacheSize(Tango::WAttribute &attr) +{ + DEBUG_STREAM << "DataVampire::write_CacheSize(Tango::WAttribute &attr) entering... " << endl; + // Retrieve write value + Tango::DevLong w_val; + attr.get_write_value(w_val); + /*----- PROTECTED REGION ID(DataVampire::write_CacheSize) ENABLED START -----*/ + /* clang-format on */ + // Add your own code + *attr_CacheSize_read = w_val; + + /* clang-format off */ + /*----- PROTECTED REGION END -----*/ // DataVampire::write_CacheSize +} +//-------------------------------------------------------- +/** + * Read attribute AutoBackgroundSamples related method + * Description: 0 to disable + * + * Data type: Tango::DevLong + * Attr type: Scalar + */ +//-------------------------------------------------------- +void DataVampire::read_AutoBackgroundSamples(Tango::Attribute &attr) +{ + DEBUG_STREAM << "DataVampire::read_AutoBackgroundSamples(Tango::Attribute &attr) entering... " << endl; + /*----- PROTECTED REGION ID(DataVampire::read_AutoBackgroundSamples) ENABLED START -----*/ + /* clang-format on */ + // Set the attribute value + attr.set_value(attr_AutoBackgroundSamples_read); + /* clang-format off */ + /*----- PROTECTED REGION END -----*/ // DataVampire::read_AutoBackgroundSamples +} +//-------------------------------------------------------- +/** + * Write attribute AutoBackgroundSamples related method + * Description: 0 to disable + * + * Data type: Tango::DevLong + * Attr type: Scalar + */ +//-------------------------------------------------------- +void DataVampire::write_AutoBackgroundSamples(Tango::WAttribute &attr) +{ + DEBUG_STREAM << "DataVampire::write_AutoBackgroundSamples(Tango::WAttribute &attr) entering... " << endl; + // Retrieve write value + Tango::DevLong w_val; + attr.get_write_value(w_val); + /*----- PROTECTED REGION ID(DataVampire::write_AutoBackgroundSamples) ENABLED START -----*/ + /* clang-format on */ + // Add your own code + /* clang-format off */ + *attr_AutoBackgroundSamples_read = w_val; + + /*----- PROTECTED REGION END -----*/ // DataVampire::write_AutoBackgroundSamples +} +//-------------------------------------------------------- +/** + * Read attribute PostAcqRoi related method + * Description: + * + * Data type: Tango::DevBoolean + * Attr type: Scalar + */ +//-------------------------------------------------------- +void DataVampire::read_PostAcqRoi(Tango::Attribute &attr) +{ + DEBUG_STREAM << "DataVampire::read_PostAcqRoi(Tango::Attribute &attr) entering... " << endl; + /*----- PROTECTED REGION ID(DataVampire::read_PostAcqRoi) ENABLED START -----*/ + /* clang-format on */ + // Set the attribute value + attr.set_value(attr_PostAcqRoi_read); + /* clang-format off */ + /*----- PROTECTED REGION END -----*/ // DataVampire::read_PostAcqRoi +} +//-------------------------------------------------------- +/** + * Write attribute PostAcqRoi related method + * Description: + * + * Data type: Tango::DevBoolean + * Attr type: Scalar + */ +//-------------------------------------------------------- +void DataVampire::write_PostAcqRoi(Tango::WAttribute &attr) +{ + DEBUG_STREAM << "DataVampire::write_PostAcqRoi(Tango::WAttribute &attr) entering... " << endl; + // Retrieve write value + Tango::DevBoolean w_val; + attr.get_write_value(w_val); + /*----- PROTECTED REGION ID(DataVampire::write_PostAcqRoi) ENABLED START -----*/ + /* clang-format on */ + // Add your own code + /* clang-format off */ + *attr_PostAcqRoi_read = w_val; + + /*----- PROTECTED REGION END -----*/ // DataVampire::write_PostAcqRoi +} +//-------------------------------------------------------- +/** + * Read attribute ImageWidth related method + * Description: + * + * Data type: Tango::DevLong + * Attr type: Scalar + */ +//-------------------------------------------------------- +void DataVampire::read_ImageWidth(Tango::Attribute &attr) +{ + DEBUG_STREAM << "DataVampire::read_ImageWidth(Tango::Attribute &attr) entering... " << endl; + /*----- PROTECTED REGION ID(DataVampire::read_ImageWidth) ENABLED START -----*/ + /* clang-format on */ + // Set the attribute value + attr.set_value(attr_ImageWidth_read); + /* clang-format off */ + /*----- PROTECTED REGION END -----*/ // DataVampire::read_ImageWidth +} +//-------------------------------------------------------- +/** + * Write attribute ImageWidth related method + * Description: + * + * Data type: Tango::DevLong + * Attr type: Scalar + */ +//-------------------------------------------------------- +void DataVampire::write_ImageWidth(Tango::WAttribute &attr) +{ + DEBUG_STREAM << "DataVampire::write_ImageWidth(Tango::WAttribute &attr) entering... " << endl; + // Retrieve write value + Tango::DevLong w_val; + attr.get_write_value(w_val); + /*----- PROTECTED REGION ID(DataVampire::write_ImageWidth) ENABLED START -----*/ + /* clang-format on */ + // Add your own code + /* clang-format off */ + *attr_ImageWidth_read = w_val; + + /*----- PROTECTED REGION END -----*/ // DataVampire::write_ImageWidth +} +//-------------------------------------------------------- +/** + * Read attribute ImageHeight related method + * Description: + * + * Data type: Tango::DevLong + * Attr type: Scalar + */ +//-------------------------------------------------------- +void DataVampire::read_ImageHeight(Tango::Attribute &attr) +{ + DEBUG_STREAM << "DataVampire::read_ImageHeight(Tango::Attribute &attr) entering... " << endl; + /*----- PROTECTED REGION ID(DataVampire::read_ImageHeight) ENABLED START -----*/ + // Set the attribute value + attr.set_value(attr_ImageHeight_read); + + /*----- PROTECTED REGION END -----*/ // DataVampire::read_ImageHeight +} +//-------------------------------------------------------- +/** + * Write attribute ImageHeight related method + * Description: + * + * Data type: Tango::DevLong + * Attr type: Scalar + */ +//-------------------------------------------------------- +void DataVampire::write_ImageHeight(Tango::WAttribute &attr) +{ + DEBUG_STREAM << "DataVampire::write_ImageHeight(Tango::WAttribute &attr) entering... " << endl; + // Retrieve write value + Tango::DevLong w_val; + attr.get_write_value(w_val); + /*----- PROTECTED REGION ID(DataVampire::write_ImageHeight) ENABLED START -----*/ + *attr_ImageHeight_read = w_val; + + /*----- PROTECTED REGION END -----*/ // DataVampire::write_ImageHeight +} +//-------------------------------------------------------- +/** + * Read attribute RoiParam related method + * Description: + * + * Data type: Tango::DevLong + * Attr type: Spectrum max = 4 + */ +//-------------------------------------------------------- +void DataVampire::read_RoiParam(Tango::Attribute &attr) +{ + DEBUG_STREAM << "DataVampire::read_RoiParam(Tango::Attribute &attr) entering... " << endl; + /*----- PROTECTED REGION ID(DataVampire::read_RoiParam) ENABLED START -----*/ + /* clang-format on */ + // Set the attribute value + attr.set_value(attr_RoiParam_read, roi_dim); + /* clang-format off */ + /*----- PROTECTED REGION END -----*/ // DataVampire::read_RoiParam +} +//-------------------------------------------------------- +/** + * Write attribute RoiParam related method + * Description: + * + * Data type: Tango::DevLong + * Attr type: Spectrum max = 4 + */ +//-------------------------------------------------------- +void DataVampire::write_RoiParam(Tango::WAttribute &attr) +{ + DEBUG_STREAM << "DataVampire::write_RoiParam(Tango::WAttribute &attr) entering... " << endl; + // Retrieve number of write values + int w_length = attr.get_write_value_length(); + + // Retrieve pointer on write values (Do not delete !) + const Tango::DevLong *w_val; + attr.get_write_value(w_val); + /*----- PROTECTED REGION ID(DataVampire::write_RoiParam) ENABLED START -----*/ + /* clang-format on */ + // Add your own code + /* clang-format off */ + store_roi_param(w_val, w_length); + + /*----- PROTECTED REGION END -----*/ // DataVampire::write_RoiParam +} +//-------------------------------------------------------- +/** + * Read attribute Spectrum related method + * Description: + * + * Data type: Tango::DevDouble + * Attr type: Spectrum max = 1000000 + */ +//-------------------------------------------------------- +void DataVampire::read_Spectrum(Tango::Attribute &attr) +{ + DEBUG_STREAM << "DataVampire::read_Spectrum(Tango::Attribute &attr) entering... " << endl; + /*----- PROTECTED REGION ID(DataVampire::read_Spectrum) ENABLED START -----*/ + /* clang-format on */ + // Set the attribute value + attr.set_value(attr_Spectrum_read, num_cols_spectrum); + /* clang-format off */ + /*----- PROTECTED REGION END -----*/ // DataVampire::read_Spectrum +} +//-------------------------------------------------------- +/** + * Read attribute HorBackground related method + * Description: + * + * Data type: Tango::DevDouble + * Attr type: Spectrum max = 1000000 + */ +//-------------------------------------------------------- +void DataVampire::read_HorBackground(Tango::Attribute &attr) +{ + DEBUG_STREAM << "DataVampire::read_HorBackground(Tango::Attribute &attr) entering... " << endl; + /*----- PROTECTED REGION ID(DataVampire::read_HorBackground) ENABLED START -----*/ + /* clang-format on */ + // Set the attribute value + int hor_size = 0; + if (roi_dim == 2) + hor_size = attr_RoiParam_read[1] - attr_RoiParam_read[0] + 1; + else if (roi_dim == 4) + hor_size = attr_RoiParam_read[2] - attr_RoiParam_read[0] + 1; + + attr.set_value(attr_HorBackground_read, hor_size); + /* clang-format off */ + /*----- PROTECTED REGION END -----*/ // DataVampire::read_HorBackground +} +//-------------------------------------------------------- +/** + * Read attribute VerBackground related method + * Description: + * + * Data type: Tango::DevDouble + * Attr type: Spectrum max = 1000000 + */ +//-------------------------------------------------------- +void DataVampire::read_VerBackground(Tango::Attribute &attr) +{ + DEBUG_STREAM << "DataVampire::read_VerBackground(Tango::Attribute &attr) entering... " << endl; + /*----- PROTECTED REGION ID(DataVampire::read_VerBackground) ENABLED START -----*/ + /* clang-format on */ + // Set the attribute value + int ver_size = 0; + if (roi_dim == 2) + ver_size = 0; + else if (roi_dim == 4) + ver_size = attr_RoiParam_read[3] - attr_RoiParam_read[1] + 1; + + attr.set_value(attr_VerBackground_read, ver_size); + /* clang-format off */ + /*----- PROTECTED REGION END -----*/ // DataVampire::read_VerBackground +} +//-------------------------------------------------------- +/** + * Read attribute Image related method + * Description: + * + * Data type: Tango::DevDouble + * Attr type: Image max = 5000 x 5000 + */ +//-------------------------------------------------------- +void DataVampire::read_Image(Tango::Attribute &attr) +{ + DEBUG_STREAM << "DataVampire::read_Image(Tango::Attribute &attr) entering... " << endl; + /*----- PROTECTED REGION ID(DataVampire::read_Image) ENABLED START -----*/ + /* clang-format on */ + // Set the attribute value + attr.set_value(attr_Image_read, num_cols_image, num_rows_image); + /* clang-format off */ + /*----- PROTECTED REGION END -----*/ // DataVampire::read_Image +} + +//-------------------------------------------------------- +/** + * Method : DataVampire::add_dynamic_attributes() + * Description : Create the dynamic attributes if any + * for specified device. + */ +//-------------------------------------------------------- +void DataVampire::add_dynamic_attributes() +{ + /*----- PROTECTED REGION ID(DataVampire::add_dynamic_attributes) ENABLED START -----*/ + /* clang-format on */ + // Add your own code to create and add dynamic attributes if any + /* clang-format off */ + /*----- PROTECTED REGION END -----*/ // DataVampire::add_dynamic_attributes +} + +//-------------------------------------------------------- +/** + * Command GetSum related method + * Description: + * + * @param argin mode,samples; mode,bunch start,bunch end + * @returns values + */ +//-------------------------------------------------------- +Tango::DevVarDoubleArray *DataVampire::get_sum(const Tango::DevVarLongArray *argin) +{ + Tango::DevVarDoubleArray *argout; + DEBUG_STREAM << "DataVampire::GetSum() - " << device_name << endl; + /*----- PROTECTED REGION ID(DataVampire::get_sum) ENABLED START -----*/ + /* clang-format on */ + + // Add your own code + acq_buffer_t *rec_data; + recover_data(argin, &rec_data); + + + argout = new Tango::DevVarDoubleArray(); + argout->length(rec_data->num_samples); + + for (int i = 0; i < rec_data->num_samples; i++) + (*argout)[i] = rec_data->sum[i]; + + /* clang-format off */ + /*----- PROTECTED REGION END -----*/ // DataVampire::get_sum + return argout; +} +//-------------------------------------------------------- +/** + * Command GetMean related method + * Description: + * + * @param argin mode,samples; mode,bunch start,bunch end + * @returns values + */ +//-------------------------------------------------------- +Tango::DevVarDoubleArray *DataVampire::get_mean(const Tango::DevVarLongArray *argin) +{ + Tango::DevVarDoubleArray *argout; + DEBUG_STREAM << "DataVampire::GetMean() - " << device_name << endl; + /*----- PROTECTED REGION ID(DataVampire::get_mean) ENABLED START -----*/ + /* clang-format on */ + + // Add your own code + acq_buffer_t *rec_data; + recover_data(argin, &rec_data); + + + argout = new Tango::DevVarDoubleArray(); + argout->length(rec_data->num_samples); + + for (int i = 0; i < rec_data->num_samples; i++) + (*argout)[i] = rec_data->mean[i]; + + /* clang-format off */ + /*----- PROTECTED REGION END -----*/ // DataVampire::get_mean + return argout; +} +//-------------------------------------------------------- +/** + * Command GetHorPos related method + * Description: + * + * @param argin mode,samples; mode,bunch start,bunch end + * @returns values + */ +//-------------------------------------------------------- +Tango::DevVarDoubleArray *DataVampire::get_hor_pos(const Tango::DevVarLongArray *argin) +{ + Tango::DevVarDoubleArray *argout; + DEBUG_STREAM << "DataVampire::GetHorPos() - " << device_name << endl; + /*----- PROTECTED REGION ID(DataVampire::get_hor_pos) ENABLED START -----*/ + /* clang-format on */ + + // Add your own code + acq_buffer_t *rec_data; + recover_data(argin, &rec_data); + + + argout = new Tango::DevVarDoubleArray(); + argout->length(rec_data->num_samples); + + for (int i = 0; i < rec_data->num_samples; i++) + (*argout)[i] = rec_data->horpos[i]; + + /* clang-format off */ + /*----- PROTECTED REGION END -----*/ // DataVampire::get_hor_pos + return argout; +} +//-------------------------------------------------------- +/** + * Command GetVerPos related method + * Description: + * + * @param argin mode,samples; mode,bunch start,bunch end + * @returns values + */ +//-------------------------------------------------------- +Tango::DevVarDoubleArray *DataVampire::get_ver_pos(const Tango::DevVarLongArray *argin) +{ + Tango::DevVarDoubleArray *argout; + DEBUG_STREAM << "DataVampire::GetVerPos() - " << device_name << endl; + /*----- PROTECTED REGION ID(DataVampire::get_ver_pos) ENABLED START -----*/ + /* clang-format on */ + + // Add your own code + acq_buffer_t *rec_data; + recover_data(argin, &rec_data); + + + argout = new Tango::DevVarDoubleArray(); + argout->length(rec_data->num_samples); + + for (int i = 0; i < rec_data->num_samples; i++) + (*argout)[i] = rec_data->verpos[i]; + + /* clang-format off */ + /*----- PROTECTED REGION END -----*/ // DataVampire::get_ver_pos + return argout; +} +//-------------------------------------------------------- +/** + * Command GetHorSigma related method + * Description: + * + * @param argin mode,samples; mode,bunch start,bunch end + * @returns values + */ +//-------------------------------------------------------- +Tango::DevVarDoubleArray *DataVampire::get_hor_sigma(const Tango::DevVarLongArray *argin) +{ + Tango::DevVarDoubleArray *argout; + DEBUG_STREAM << "DataVampire::GetHorSigma() - " << device_name << endl; + /*----- PROTECTED REGION ID(DataVampire::get_hor_sigma) ENABLED START -----*/ + /* clang-format on */ + + // Add your own code + acq_buffer_t *rec_data; + recover_data(argin, &rec_data); + + + argout = new Tango::DevVarDoubleArray(); + argout->length(rec_data->num_samples); + + for (int i = 0; i < rec_data->num_samples; i++) + (*argout)[i] = rec_data->horsigma[i]; + + /* clang-format off */ + /*----- PROTECTED REGION END -----*/ // DataVampire::get_hor_sigma + return argout; +} +//-------------------------------------------------------- +/** + * Command GetVerSigma related method + * Description: + * + * @param argin mode,samples; mode,bunch start,bunch end + * @returns values + */ +//-------------------------------------------------------- +Tango::DevVarDoubleArray *DataVampire::get_ver_sigma(const Tango::DevVarLongArray *argin) +{ + Tango::DevVarDoubleArray *argout; + DEBUG_STREAM << "DataVampire::GetVerSigma() - " << device_name << endl; + /*----- PROTECTED REGION ID(DataVampire::get_ver_sigma) ENABLED START -----*/ + /* clang-format on */ + + // Add your own code + acq_buffer_t *rec_data; + recover_data(argin, &rec_data); + + + argout = new Tango::DevVarDoubleArray(); + argout->length(rec_data->num_samples); + + for (int i = 0; i < rec_data->num_samples; i++) + (*argout)[i] = rec_data->versigma[i]; + + /* clang-format off */ + /*----- PROTECTED REGION END -----*/ // DataVampire::get_ver_sigma + return argout; +} +//-------------------------------------------------------- +/** + * Command GetValidValues related method + * Description: + * + * @param argin mode,samples; mode,bunch start,bunch end + * @returns values + */ +//-------------------------------------------------------- +Tango::DevVarDoubleArray *DataVampire::get_valid_values(const Tango::DevVarLongArray *argin) +{ + Tango::DevVarDoubleArray *argout; + DEBUG_STREAM << "DataVampire::GetValidValues() - " << device_name << endl; + /*----- PROTECTED REGION ID(DataVampire::get_valid_values) ENABLED START -----*/ + /* clang-format on */ + + // Add your own code + acq_buffer_t *rec_data; + recover_data(argin, &rec_data); + + + argout = new Tango::DevVarDoubleArray(); + argout->length(rec_data->num_samples); + + for (int i = 0; i < rec_data->num_samples; i++) + (*argout)[i] = rec_data->validvalues[i]; + /* clang-format off */ + /*----- PROTECTED REGION END -----*/ // DataVampire::get_valid_values + return argout; +} +//-------------------------------------------------------- +/** + * Command SetBackground related method + * Description: + * + */ +//-------------------------------------------------------- +void DataVampire::set_background() +{ + DEBUG_STREAM << "DataVampire::SetBackground() - " << device_name << endl; + /*----- PROTECTED REGION ID(DataVampire::set_background) ENABLED START -----*/ + /* clang-format on */ + + // Add your own code + + /* clang-format off */ + /*----- PROTECTED REGION END -----*/ // DataVampire::set_background +} +//-------------------------------------------------------- +/** + * Method : DataVampire::add_dynamic_commands() + * Description : Create the dynamic commands if any + * for specified device. + */ +//-------------------------------------------------------- +void DataVampire::add_dynamic_commands() +{ + /*----- PROTECTED REGION ID(DataVampire::add_dynamic_commands) ENABLED START -----*/ + /* clang-format on */ + // Add your own code to create and add dynamic commands if any + /* clang-format off */ + /*----- PROTECTED REGION END -----*/ // DataVampire::add_dynamic_commands +} + +/*----- PROTECTED REGION ID(DataVampire::namespace_ending) ENABLED START -----*/ +/* clang-format on */ +// Additional Methods +/* clang-format off */ + + + + + +void DataVampire::cmd_extract_values(Tango::DeviceData *cmd_value, std::vector<double> &val, std::vector<std::string> &val_string) +{ + + Tango::DevState stval; + std::vector<Tango::DevState> v_st; + std::vector<Tango::DevULong> v_ulo; + std::vector<Tango::DevUChar> v_uch; + std::vector<Tango::DevShort> v_sh; + std::vector<Tango::DevUShort> v_ush; + std::vector<Tango::DevLong> v_lo; + std::vector<Tango::DevDouble> v_do; + std::vector<Tango::DevFloat> v_fl; + std::vector<Tango::DevBoolean> v_bo; + std::vector<Tango::DevLong64> v_lo64; + std::vector<Tango::DevULong64> v_ulo64; + //vector<string> v_string; + + long cmd_type = cmd_value->get_type(); + + val.clear(); + + if ((cmd_type == Tango::DEV_UCHAR) || (cmd_type == Tango::DEVVAR_CHARARRAY)) + { + *cmd_value >> v_uch; + for(std::vector<Tango::DevUChar>::iterator it = v_uch.begin(); it != v_uch.end(); it++) + val.push_back((double)(*it)); //convert all to double + } + else if ((cmd_type == Tango::DEV_SHORT) || (cmd_type == Tango::DEVVAR_SHORTARRAY)) + { + *cmd_value >> v_sh; + for(std::vector<Tango::DevShort>::iterator it = v_sh.begin(); it != v_sh.end(); it++) + val.push_back((double)(*it)); //convert all to double + } + else if ((cmd_type == Tango::DEV_USHORT) || (cmd_type == Tango::DEVVAR_USHORTARRAY)) + { + *cmd_value >> v_ush; + for(std::vector<Tango::DevUShort>::iterator it = v_ush.begin(); it != v_ush.end(); it++) + val.push_back((double)(*it)); //convert all to double + } + else if ((cmd_type == Tango::DEV_LONG) || (cmd_type == Tango::DEVVAR_LONGARRAY)) + { + *cmd_value >> v_lo; + for(std::vector<Tango::DevLong>::iterator it = v_lo.begin(); it != v_lo.end(); it++) + val.push_back((double)(*it)); //convert all to double + } + else if ((cmd_type == Tango::DEV_LONG64) || (cmd_type == Tango::DEVVAR_LONG64ARRAY)) + { + *cmd_value >> v_lo64; + for(std::vector<Tango::DevLong64>::iterator it = v_lo64.begin(); it != v_lo64.end(); it++) + val.push_back((double)(*it)); //convert all to double + } + else if (cmd_type == Tango::DEV_STATE) + { + //*cmd_value >> v_st; + //TODO: why extract_read not working with State + std::cout << "GG: Do not compile cmd_value->get_type() == Tango::DEV_STATE ???" << std::endl; + if(v_st.size() == 0) + { + *cmd_value >> stval; + v_st.push_back(stval); + } + for(std::vector<Tango::DevState>::iterator it = v_st.begin(); it != v_st.end(); it++) + { + val.push_back((double)(*it)); //convert all to double + } + } + else if ((cmd_type == Tango::DEV_ULONG) || (cmd_type == Tango::DEVVAR_ULONGARRAY)) + { + *cmd_value >> v_ulo; + for(std::vector<Tango::DevULong>::iterator it = v_ulo.begin(); it != v_ulo.end(); it++) + val.push_back((double)(*it)); //convert all to double + } + else if ((cmd_type == Tango::DEV_ULONG64) || (cmd_type == Tango::DEVVAR_ULONG64ARRAY)) + { + *cmd_value >> v_ulo64; + for(std::vector<Tango::DevULong64>::iterator it = v_ulo64.begin(); it != v_ulo64.end(); it++) + val.push_back((double)(*it)); //convert all to double + } + else if ((cmd_type == Tango::DEV_DOUBLE) || (cmd_type == Tango::DEVVAR_DOUBLEARRAY)) + { + *cmd_value >> v_do; + + for(std::vector<Tango::DevDouble>::iterator it = v_do.begin(); it != v_do.end(); it++) + val.push_back((double)(*it)); //convert all to double + } + else if ((cmd_type == Tango::DEV_FLOAT) || (cmd_type == Tango::DEVVAR_FLOATARRAY)) + { + *cmd_value >> v_fl; + for(std::vector<Tango::DevFloat>::iterator it = v_fl.begin(); it != v_fl.end(); it++) + val.push_back((double)(*it)); //convert all to double + } + else if ((cmd_type == Tango::DEV_BOOLEAN) || (cmd_type == Tango::DEVVAR_BOOLEANARRAY)) + { + //*cmd_value >> v_bo; // GG do not compile ???? + std::cout << "GG: Do not compile cmd_value->get_type() == Tango::DEV_BOOLEAN ???" << std::endl; + for(std::vector<Tango::DevBoolean>::iterator it = v_bo.begin(); it != v_bo.end(); it++) + val.push_back((double)(*it)); //convert all to double + } + else if ((cmd_type == Tango::DEV_STRING) || (cmd_type == Tango::DEVVAR_STRINGARRAY)) + { + /*attr_value->extract_read(v_string); + val_string = *(v_string.begin());*/ + *cmd_value >> val_string; + } + else + { + printf("AZZ\n"); + + std::ostringstream o; + o << "unknown type" << std::ends; + throw o.str(); + } + +} + + +Tango::DeviceData DataVampire::cmd_insert_values(long cmd_type, std::vector<double> val, std::vector<std::string> val_string) +{ + Tango::DevState st; + std::vector<Tango::DevState> v_st; + std::vector<Tango::DevULong> v_ulo; + Tango::DevULong ulo; + std::vector<Tango::DevULong64> v_ulo64; + Tango::DevULong64 ulo64; + std::vector<Tango::DevUChar> v_uch; + Tango::DevUChar uch; + std::vector<Tango::DevShort> v_sh; + Tango::DevShort sh; + std::vector<Tango::DevUShort> v_ush; + Tango::DevUShort ush; + std::vector<Tango::DevLong> v_lo; + Tango::DevLong lo; + std::vector<Tango::DevLong64> v_lo64; + Tango::DevLong64 lo64; + std::vector<Tango::DevDouble> v_do; + Tango::DevDouble _do; + std::vector<Tango::DevFloat> v_fl; + Tango::DevFloat fl; + std::vector<Tango::DevBoolean> v_bo; + Tango::DevBoolean bo; + std::vector<std::string> v_string; + std::string _string; + Tango::DeviceData din_value; + + if ((cmd_type == Tango::DEV_UCHAR) || (cmd_type == Tango::DEVVAR_CHARARRAY)) + { + if(val.size() > 1) + { + for(std::vector<double>::iterator it = val.begin(); it != val.end(); it++) + v_uch.push_back((Tango::DevUChar)(*it)); //convert all from double + //din_value << v_uch; + std::cout << "GG: Do not compile cmd_type == Tango::DEV_UCHAR ???" << std::endl; + } + else + { + uch = (Tango::DevUChar)(*val.begin()); + // din_value << uch; + std::cout << "GG: Do not compile cmd_type == Tango::DEV_UCHAR ???" << std::endl; + } + } + else if ((cmd_type == Tango::DEV_SHORT) || (cmd_type == Tango::DEVVAR_SHORTARRAY)) + { + if(val.size() > 1) + { + for(std::vector<double>::iterator it = val.begin(); it != val.end(); it++) + v_sh.push_back((Tango::DevShort)(*it)); //convert all from double + din_value << v_sh; + } + else + { + sh = (Tango::DevShort)(*val.begin()); + din_value << sh; + } + } + else if ((cmd_type == Tango::DEV_USHORT) || (cmd_type == Tango::DEVVAR_USHORTARRAY)) + { + if(val.size() > 1) + { + for(std::vector<double>::iterator it = val.begin(); it != val.end(); it++) + v_ush.push_back((Tango::DevUShort)(*it)); //convert all from double + din_value << v_ush; + } + else + { + ush = (Tango::DevUShort)(*val.begin()); + din_value << ush; + } + } + else if ((cmd_type == Tango::DEV_LONG) || (cmd_type == Tango::DEVVAR_LONGARRAY)) + { + if(val.size() > 1) + { + for(std::vector<double>::iterator it = val.begin(); it != val.end(); it++) + v_lo.push_back((Tango::DevLong)(*it)); //convert all from double + din_value << v_lo; + } + else + { + lo = (Tango::DevLong)(*val.begin()); + din_value << lo; + } + } + else if ((cmd_type == Tango::DEV_LONG64) || (cmd_type == Tango::DEVVAR_LONG64ARRAY)) + { + if(val.size() > 1) + { + for(std::vector<double>::iterator it = val.begin(); it != val.end(); it++) + v_lo64.push_back((Tango::DevLong64)(*it)); //convert all from double + din_value << v_lo64; + } + else + { + lo64 = (Tango::DevLong64)(*val.begin()); + din_value << lo64; + } + } + else if (cmd_type == Tango::DEV_STATE) + { + if(val.size() > 1) + { + for(std::vector<double>::iterator it = val.begin(); it != val.end(); it++) + v_st.push_back((Tango::DevState)(*it)); //convert all from double + //din_value << v_st; + std::cout << "GG: Do not compile cmd_type == Tango::DEV_STATE ???" << std::endl; + } + else + { + st = (Tango::DevState)(*(val.begin())); + din_value << st; + } + } + else if ((cmd_type == Tango::DEV_ULONG) || (cmd_type == Tango::DEVVAR_ULONGARRAY)) + { + if(val.size() > 1) + { + for(std::vector<double>::iterator it = val.begin(); it != val.end(); it++) + v_ulo.push_back((Tango::DevULong)(*it)); //convert all from double + din_value << v_ulo; + } + else + { + ulo = (Tango::DevULong)(*(val.begin())); + din_value << ulo; + } + } + else if ((cmd_type == Tango::DEV_ULONG64) || (cmd_type == Tango::DEVVAR_ULONG64ARRAY)) + { + if(val.size() > 1) + { + for(std::vector<double>::iterator it = val.begin(); it != val.end(); it++) + v_ulo64.push_back((Tango::DevULong64)(*it)); //convert all from double + din_value << v_ulo64; + } + else + { + ulo64 = (Tango::DevULong64)(*(val.begin())); + din_value << ulo64; + } + } + else if ((cmd_type == Tango::DEV_DOUBLE) || (cmd_type == Tango::DEVVAR_DOUBLEARRAY)) + { + if(val.size() > 1) + { + for(std::vector<double>::iterator it = val.begin(); it != val.end(); it++) + { + v_do.push_back((Tango::DevDouble)(*it)); //convert all from double + } + din_value << v_do; + } + else + { + _do = (Tango::DevDouble)(*(val.begin())); + din_value << _do; + } + } + else if ((cmd_type == Tango::DEV_FLOAT) || (cmd_type == Tango::DEVVAR_FLOATARRAY)) + { + if(val.size() > 1) + { + for(std::vector<double>::iterator it = val.begin(); it != val.end(); it++) + v_fl.push_back((Tango::DevFloat)(*it)); //convert all from double + din_value << v_fl; + } + else + { + fl = (Tango::DevFloat)(*(val.begin())); + din_value << fl; + } + } + else if ((cmd_type == Tango::DEV_BOOLEAN) || (cmd_type == Tango::DEVVAR_BOOLEANARRAY)) + { + if(val.size() > 1) + { + for(std::vector<double>::iterator it = val.begin(); it != val.end(); it++) + v_bo.push_back((Tango::DevBoolean)(*it)); //convert all from double + // din_value << v_bo; + std::cout << "GG: Do not compile cmd_type == Tango::DEV_BOOLEAN ???" << std::endl; + } + else + { + bo = (Tango::DevBoolean)(*(val.begin())); + din_value << bo; + } + } + else if ((cmd_type == Tango::DEV_STRING) || (cmd_type == Tango::DEVVAR_STRINGARRAY)) + { + if(val.size() > 1) + { + for(std::vector<std::string>::iterator it = val_string.begin(); it != val_string.end(); it++) + v_string.push_back(*it); //convert all from string + din_value << v_string; + } + else + { + _string = *(val_string.begin()); + din_value << _string; + } + } + else + { + std::ostringstream o; + o << "unknown type" << std::ends; + throw o.str(); + } + + return din_value; +} + + +//+------------------------------------------------------------------ +/** + * method: DataVampire::string_explode + * Explode a string +*/ +//+------------------------------------------------------------------ +void DataVampire::string_explode(std::string str, std::string separator, std::vector<std::string>* results) +{ + size_t found; + + found = str.find_first_of(separator); + while(found != std::string::npos) { + if(found > 0) { + results->push_back(str.substr(0,found)); + } + str = str.substr(found+1); + found = str.find_first_of(separator); + } + if(str.length() > 0) { + results->push_back(str); + } + +} + + + +//+------------------------------------------------------------------ +/** + * method: DataVampire::store_roi_param + * Store command string +*/ +//+------------------------------------------------------------------ +void DataVampire::store_roi_param(const Tango::DevLong *w_val, int size) +{ + + Tango::Database *db = new Tango::Database(); + char conf_str[20]; + + /* manual ROI x1,y1,x2,y2 */ + try { + Tango::DbDatum config("RoiParam"); + Tango::DbData db_data_put; + std::vector<std::string> val; + for (int i = 0; i < size; i++) { + memset(conf_str,0,20); + sprintf(conf_str,"%d", w_val[i]); + val.push_back(conf_str); + } + roi_dim = size; + for (int i = size; i < 4; i++) { + memset(conf_str,0,20); + sprintf(conf_str,"-1"); + val.push_back(conf_str); + } + + config << val; + db_data_put.push_back(config); + db->put_device_property(get_name(), db_data_put); + } + catch (Tango::DevFailed &e) { + delete db; + Tango::Except::throw_exception ( + (const char *)"Failed to update configuration", + (const char *)"Can't write into database", + __FUNCTION__); + } + delete db; + + for (int i = 0; i < size; i++) { + attr_RoiParam_read[i] = w_val[i]; + } + for (int i = size; i < 4; i++) { + attr_RoiParam_read[i] = -1; + } + + roi_dim = size; + +} + + +//+------------------------------------------------------------------ +/** + * method: DataVampire::store_command_string + * Store command string +*/ +//+------------------------------------------------------------------ +void DataVampire::store_command_string(Tango::DevString w_val) +{ + std::string new_configuration(w_val); + std::string dev_property("CommandString"); + + Tango::Database *db = new Tango::Database(); + + try { + std::string dev_property("CommandString"); + Tango::DbDatum config(dev_property); + Tango::DbData db_data_del, db_data_put; + db_data_del.push_back(config); + /* start data */ + config << new_configuration; + /* end data */ + db_data_put.push_back(config); + db->put_device_property(get_name(), db_data_put); + } + catch (CORBA::Exception &e) { + delete db; + ERROR_STREAM << "write_CommandString(): failed to save parameters" << std::endl; + Tango::Except::throw_exception ( + (const char *)"Failed to update configuration", + (const char *)"Can't write into database", + __FUNCTION__); + } + delete db; + + strncpy(*attr_CommandString_read, new_configuration.c_str(), 256); + + std::vector<std::string> results; + string_explode(new_configuration, "/", &results); + + command_name = results[results.size()-1]; + size_t pos = new_configuration.find(command_name); + if (pos != std::string::npos) { // if str2 found in str1 + new_configuration.erase(pos-1, command_name.length()+1); // erase str2 from str1 + } + device_name = new_configuration; + +} + + + +void DataVampire::extract_input_parameters(const Tango::DevVarLongArray *argin, int *mode, int *num_samples, int *bn_start, int *bn_end, int *roi) +{ + if (argin->length() < 2) { + Tango::Except::throw_exception ( + (const char *)"Failed input parameters size", + (const char *)"Minimum number is 4", + __FUNCTION__); + + } + + *mode = ((*argin)[0] % 10) & 0x1; // 20->0 21->1 + + // return the last number + if (*mode == 0) { + *num_samples = (*argin)[1]; + *bn_start = 0; + *bn_end = 0; + } + else if (*mode == 1) { + *bn_start = (*argin)[1]; + *bn_end = (*argin)[2]; + *num_samples = *bn_end - *bn_start + 1; + } + + for (int i = 0; i < 4; i++) { + roi[i] = attr_RoiParam_read[i]; + } + + +} + + + + +//+------------------------------------------------------------------ +/** + * method: DataVampire::free_cache_buffer + * Free cache buffer +*/ +//+------------------------------------------------------------------ +void DataVampire::free_cache_buffer(void) +{ + if (cache_buffer != NULL) { + for (int i = 0; i < *attr_CacheSize_read; i++) { + if (cache_buffer[i].databuf) + free(cache_buffer[i].databuf); + if (cache_buffer[i].datavalid) + free(cache_buffer[i].datavalid); + if (cache_buffer[i].sum) + free(cache_buffer[i].sum); + if (cache_buffer[i].mean) + free(cache_buffer[i].mean); + if (cache_buffer[i].horpos) + free(cache_buffer[i].horpos); + if (cache_buffer[i].verpos) + free(cache_buffer[i].verpos); + if (cache_buffer[i].horsigma) + free(cache_buffer[i].horsigma); + if (cache_buffer[i].versigma) + free(cache_buffer[i].versigma); + if (cache_buffer[i].validvalues) + free(cache_buffer[i].validvalues); + } + } + free(cache_buffer); + +} + + +//+------------------------------------------------------------------ +/** + * method: DataVampire::allocate_cache_buffer + * Allocate cache buffer +*/ +//+------------------------------------------------------------------ +void DataVampire::allocate_cache_buffer(void) +{ + if (cache_buffer != NULL) { + free_cache_buffer(); + } + + cache_buffer = (acq_buffer_t *) malloc(*attr_CacheSize_read * sizeof(acq_buffer_t)); + + for (int i = 0; i < *attr_CacheSize_read; i++) { + cache_buffer[i].databuf = 0; + cache_buffer[i].datavalid = 0; + cache_buffer[i].sum = 0; + cache_buffer[i].mean = 0; + cache_buffer[i].horpos = 0; + cache_buffer[i].verpos = 0; + cache_buffer[i].horsigma = 0; + cache_buffer[i].versigma = 0; + cache_buffer[i].validvalues = 0; + clock_gettime(CLOCK_REALTIME, &cache_buffer[i].timerec); + cache_buffer[i].bn_start = 0; + cache_buffer[i].bn_end = 0; + cache_buffer[i].num_samples = 0; + cache_buffer[i].num_rows = 0; + cache_buffer[i].num_cols = 0; + cache_buffer[i].data_size = 0; + } + + cache_idx = 0; + +} + + +//+------------------------------------------------------------------ +/** + * method: DataVampire::store_data + * Allocate cache buffer +*/ +//+------------------------------------------------------------------ +void DataVampire::store_data(Tango::DeviceData *cmd_value, int32_t num_samples, int32_t bn_start, int32_t bn_end, int32_t *roi, struct acq_buffer_t **rec_data) +{ + std::vector<double> val; + std::vector<std::string> val_string; + + clock_gettime(CLOCK_REALTIME, &cache_buffer[cache_idx].timerec); + cmd_extract_values(cmd_value, val, val_string); + + int num_rows, num_cols; + + if (roi_dim == 2) { + num_cols = roi[1] - roi[0] + 1; + num_rows = 1; + } + else { + num_rows = roi[3]-roi[1]+1, + num_cols = roi[2]-roi[0]+1; + } + + int32_t wave_size = val.size() / num_samples; + + printf("rows=%d cols=%d valsize=%d num_samples=%d\n",num_rows,num_cols,val.size(),num_samples); + + printf("GGT1\n"); + + if (((num_cols * num_rows * num_samples) != val.size()) && (*attr_PostAcqRoi_read == false)) { + Tango::Except::throw_exception ( + (const char *)"Failed to store data", + (const char *)"Data size does not match roi setting", + __FUNCTION__); + } + + printf("GGT3\n"); + + // reallocate buffer + if (val.size() != cache_buffer[cache_idx].data_size) { + cache_buffer[cache_idx].databuf = (double *)realloc(cache_buffer[cache_idx].databuf, val.size() * sizeof(double)); + cache_buffer[cache_idx].datavalid = (bool *)realloc(cache_buffer[cache_idx].datavalid, val.size() * sizeof(bool)); + cache_buffer[cache_idx].data_size = val.size(); + cache_buffer[cache_idx].sum = (double *)realloc(cache_buffer[cache_idx].sum, num_samples * sizeof(double)); + cache_buffer[cache_idx].mean = (double *)realloc(cache_buffer[cache_idx].mean, num_samples * sizeof(double)); + cache_buffer[cache_idx].horpos = (double *)realloc(cache_buffer[cache_idx].horpos, num_samples * sizeof(double)); + cache_buffer[cache_idx].horsigma = (double *)realloc(cache_buffer[cache_idx].horsigma, num_samples * sizeof(double)); + if (num_rows > 1) { + cache_buffer[cache_idx].verpos = (double *)realloc(cache_buffer[cache_idx].verpos, num_samples * sizeof(double)); + cache_buffer[cache_idx].versigma = (double *)realloc(cache_buffer[cache_idx].versigma, num_samples * sizeof(double)); + } + cache_buffer[cache_idx].validvalues = (double *)realloc(cache_buffer[cache_idx].validvalues, num_samples * sizeof(double)); + } + + printf("GGT4\n"); + + if (*attr_PostAcqRoi_read == false) { + for (int i = 0; i < cache_buffer[cache_idx].data_size; i++) { + cache_buffer[cache_idx].databuf[i] = val[i]; + + if ((val[i] >= *attr_MinThreshold_read) || (val[i] <= *attr_MaxThreshold_read)) + cache_buffer[cache_idx].datavalid[i] = true; + else + cache_buffer[cache_idx].datavalid[i] = false; + } + + } + // ROI is not supported by command inout so get all the image stream with command inout + else { + int cnt = 0; + + for (int i = 0; i < num_samples; i++) { + int offset = wave_size * i; + printf("num_samples = %d, wave_size = %d offset = %d val.size=%d\n",num_samples, wave_size, offset, val.size()); + double *data = &val[offset]; + // ImageWidth must be defined because command_inout does not report the Image width/length values + if ((*attr_ImageWidth_read > 0) && (roi_dim == 4)) { + for (int j = roi[1]; j <= roi[3]; j++) { + for (int k = roi[0]; k <= roi[2]; k++) { + //cache_buffer[cache_idx].databuf[cnt] = data[j * *attr_ImageWidth_read + k]; + cache_buffer[cache_idx].databuf[cnt] = k; + if ((data[j * *attr_ImageWidth_read + k] >= *attr_MinThreshold_read) || + (data[j * *attr_ImageWidth_read + k] <= *attr_MaxThreshold_read)) + cache_buffer[cache_idx].datavalid[cnt] = true; + else + cache_buffer[cache_idx].datavalid[cnt] = false; + + + cnt++; + } + } + } + else if (roi_dim == 2) { + printf("roi0 = %d roi1 = %d\n",roi[0],roi[1]); + for (int k = roi[0]; k <= roi[1]; k++) { + cache_buffer[cache_idx].databuf[cnt] = data[k]; + + if ((data[k] >= *attr_MinThreshold_read) || (data[k] <= *attr_MaxThreshold_read)) + cache_buffer[cache_idx].datavalid[cnt] = true; + else + cache_buffer[cache_idx].datavalid[cnt] = false; + cnt++; + } + } + } + + + + } + + + if (num_rows > 1) { + for (int i = 0; i < num_rows*num_cols; i++) { + attr_Image_read[i] = cache_buffer[cache_idx].databuf[i]; + } + num_rows_image = num_rows; + num_cols_image = num_cols; + } + /* performed in process_1D + else if (num_rows == 1) { + for (int i = 0; i < num_cols; i++) { + attr_Spectrum_read[i] = cache_buffer[cache_idx].databuf[i]; + } + num_cols_spectrum = num_cols; + }*/ + + + + + printf("GGT5 num_cols=%d\n", num_cols); + + cache_buffer[cache_idx].bn_start = bn_start; + cache_buffer[cache_idx].bn_end = bn_end; + cache_buffer[cache_idx].num_samples = num_samples; + if (roi_dim == 2) { + cache_buffer[cache_idx].num_rows = 1; + cache_buffer[cache_idx].num_cols = num_cols; + } + else if (roi_dim == 4) { + cache_buffer[cache_idx].num_rows = num_rows; + cache_buffer[cache_idx].num_cols = num_cols; + } + + if (cache_buffer[cache_idx].num_rows == 1) { + process_1D(cache_idx, *attr_AutoBackgroundSamples_read); + } + else if (cache_buffer[cache_idx].num_rows > 1) { + process_2D(cache_idx, *attr_AutoBackgroundSamples_read); + } + + printf("GGT6\n"); + + *rec_data = &cache_buffer[cache_idx]; + + printf("GGT7\n"); + + cache_idx++; + if (cache_idx >= *attr_CacheSize_read) + cache_idx = 0; + +} + + +void DataVampire::process_2D(int32_t cache_idx, int32_t auto_bck_samples) +{ + + int32_t num_rows = cache_buffer[cache_idx].num_rows; + int32_t num_cols = cache_buffer[cache_idx].num_cols; + + int32_t wave_size = num_rows * num_cols; + int32_t data_size = cache_buffer[cache_idx].data_size; + int32_t num_samples = cache_buffer[cache_idx].num_samples; + + double *hor_profile_bck, *ver_profile_bck; + uint32_t *hor_profile_bck_cnt, *ver_profile_bck_cnt; + + // for Image display + num_rows_image = num_rows; + num_cols_image = num_cols; + + hor_profile_bck = (double *) calloc(num_cols, sizeof(double)); + ver_profile_bck = (double *) calloc(num_rows, sizeof(double)); + hor_profile_bck_cnt = (uint32_t *) calloc(num_cols, sizeof(uint32_t)); + ver_profile_bck_cnt = (uint32_t *) calloc(num_rows, sizeof(uint32_t)); + + for (int i = 0; i < num_samples; i++) { + + memset(hor_profile_bck, 0, sizeof(float) * num_cols); + memset(ver_profile_bck, 0, sizeof(float) * num_rows); + memset(hor_profile_bck_cnt, 0, sizeof(uint32_t) * num_cols); + memset(ver_profile_bck_cnt, 0, sizeof(uint32_t) * num_rows); + + if (auto_bck_samples) { + // calculate horizontal background profile from top and bottom auto_bck_samples rows + for (int j = 0; j < *attr_AutoBackgroundSamples_read; j++) { + for (int k = 0; k < num_cols; k++) { + int idx = j*num_cols+k+wave_size*i; + if (cache_buffer[cache_idx].datavalid[idx]) { + hor_profile_bck[k] += cache_buffer[cache_idx].databuf[idx]; + hor_profile_bck_cnt[k]++; + } + idx = (num_rows-j-1)*num_cols+k+wave_size*i; + if (cache_buffer[cache_idx].datavalid[idx]) { + hor_profile_bck[k] += cache_buffer[cache_idx].databuf[idx]; + hor_profile_bck_cnt[k]++; + } + } + } + + // calculate vertical background profile from left and right auto_bck_samples columns + for (int j = 0; j < *attr_AutoBackgroundSamples_read; j++) { + // rows + for (int k = 0; k < num_rows; k++) { + int idx = k*num_cols+j+wave_size*i; + if (cache_buffer[cache_idx].datavalid[idx]) { + ver_profile_bck[k] += cache_buffer[cache_idx].databuf[idx]; + printf("k=%d ver_bck=%f idx=%d \n",k,cache_buffer[cache_idx].databuf[idx],idx); + ver_profile_bck_cnt[k]++; + } + //int idx2 = (num_rows-k-1)*num_cols-j+wave_size*i; + int idx2 = idx + (num_cols - 1) - j; + if (cache_buffer[cache_idx].datavalid[idx2]) { + ver_profile_bck[k] += cache_buffer[cache_idx].databuf[idx2]; + printf("k=%d ver_bck=%f idx2=%d \n",k,cache_buffer[cache_idx].databuf[idx2],idx2); + ver_profile_bck_cnt[k]++; + } + printf("k=%d ver_bck=%f ver_bck_cnt=%d idx=%d idx2=%d\n",k,ver_profile_bck[k],ver_profile_bck_cnt[k],idx,idx2); + } + } + + + for (int j = 0; j < num_cols; j++) { + if (hor_profile_bck_cnt[j] > 0) { + hor_profile_bck[j] = hor_profile_bck[j] / (double)hor_profile_bck_cnt[j]; + } + else + hor_profile_bck[j] = 0; + } + for (int j = 0; j < num_rows; j++) { + if (ver_profile_bck_cnt[j] > 0) { + ver_profile_bck[j] = ver_profile_bck[j] / (double)ver_profile_bck_cnt[j]; + } + else + ver_profile_bck[j] = 0; + } + + if (i == 0) { + for (int j = 0; j < num_cols; j++) + attr_HorBackground_read[j] = hor_profile_bck[j]; + for (int j = 0; j < num_rows; j++) + attr_VerBackground_read[j] = ver_profile_bck[j]; + } + + // remove horizontal backgroud + for (int j = 0; j < num_rows; j++) { + for (int k = 0; k < num_cols; k++) { + int idx = j * num_cols + k + wave_size*i; + cache_buffer[cache_idx].databuf[idx] -= hor_profile_bck[k]; + } + } + + // remove vertical backgroud + for (int j = 0; j < num_cols; j++) { + for (int k = 0; k < num_rows; k++) { + int idx = k * num_cols + j + wave_size*i; + cache_buffer[cache_idx].databuf[idx] -= ver_profile_bck[k]; + } + } + + + for (int j = 0; j < num_rows; j++) { + for (int k = 0; k < num_cols; k++) { + int idx = j * num_cols + k + wave_size*i; + if (cache_buffer[cache_idx].databuf[idx] < 0) + cache_buffer[cache_idx].databuf[idx] = 0; + } + } + + } // auto_bck_samples + + + // calculate position, intensity and rms of the image + double hor_pos = 0, ver_pos = 0, mean = 0; + double std_hor_pos = 0, std_ver_pos = 0; + double total_sum = 0; + int32_t valid_values = 0; + + for(int j = 0; j < num_rows; j++) { + for(int k = 0; k < num_cols; k++) { + int idx = j * num_cols + k + wave_size*i; + + if (i == 0) + attr_Image_read[idx] = cache_buffer[cache_idx].databuf[idx]; + + if (cache_buffer[cache_idx].datavalid[idx]) { + hor_pos += (cache_buffer[cache_idx].databuf[idx] * (k+1)); + ver_pos += (cache_buffer[cache_idx].databuf[idx] * (j+1)); + total_sum += cache_buffer[cache_idx].databuf[idx]; + valid_values++; + } + } + } + + hor_pos /= total_sum; + ver_pos /= total_sum; + + for(int i = 0; i < num_rows; i++) { + for(int j = 0; j < num_cols; j++) { + std_hor_pos += (i-hor_pos)*(i-hor_pos); + std_ver_pos += (j-ver_pos)*(j-ver_pos); + } + } + + if (total_sum > 0) { + std_hor_pos = pow(std_hor_pos / total_sum, 0.5); + std_ver_pos = pow(std_ver_pos / total_sum, 0.5); + } + + cache_buffer[cache_idx].sum[i] = total_sum; + printf("total sum %d = %f\n", cache_idx, cache_buffer[cache_idx].sum[i]); + cache_buffer[cache_idx].mean[i] = total_sum / (double)valid_values; + cache_buffer[cache_idx].horpos[i] = hor_pos; + cache_buffer[cache_idx].verpos[i] = ver_pos; + cache_buffer[cache_idx].horsigma[i] = std_hor_pos; + cache_buffer[cache_idx].versigma[i] = std_ver_pos; + cache_buffer[cache_idx].validvalues[i] = valid_values; + + } + + free(hor_profile_bck); + free(ver_profile_bck); + free(hor_profile_bck_cnt); + free(ver_profile_bck_cnt); + +} + + +void DataVampire::process_1D(int32_t cache_idx, int32_t auto_bck_samples) +{ + int32_t wave_size = cache_buffer[cache_idx].num_rows * + cache_buffer[cache_idx].num_cols; + int32_t num_samples = cache_buffer[cache_idx].num_samples; + int32_t data_size = cache_buffer[cache_idx].data_size; + + printf("GG 1 process_1D cache_idx=%d num_cols=%d\n",cache_idx,cache_buffer[cache_idx].num_cols); + + // for spectrum display + num_cols_spectrum = cache_buffer[cache_idx].num_cols; + + for (int i = 0; i < num_samples; i++) { + double sum = 0; + double mean = 0; + double sum_left = 0; + double sum_right = 0; + double sum_top = 0; + double sum_bottom = 0; + double offset = 0; + double slope = 0; + double pos = 0; + double std = 0; + int cnt_left = 0, cnt_right = 0, cnt = 0; + double valid_values = 0; + if (auto_bck_samples) { + for (int j = 0; j < auto_bck_samples; j++) { + if (cache_buffer[cache_idx].datavalid[i*wave_size+j]) { + double val = cache_buffer[cache_idx].databuf[i*wave_size+j]; + sum_left += val; + cnt_left++; + } + if (cache_buffer[cache_idx].datavalid[i*wave_size+j]) { + double val = cache_buffer[cache_idx].databuf[i*wave_size+(wave_size-auto_bck_samples)+j]; + sum_right += val; + cnt_right++; + } + } + if (cnt_left) + sum_left /= (double)cnt_left; + else + sum_left = 0; + if (cnt_right) + sum_right /= (double)cnt_right; + else + sum_right = 0; + + if (auto_bck_samples > 0) { + slope = (sum_right - sum_left) / + ((double) (wave_size - (double)(cnt_left+cnt_right)/2)); + offset = sum_left; + if (offset > sum_right) + offset = sum_right; + } + else { + slope = 0; offset = 0; + } + } + + + + + + // get sum, mean and position + for (int j = 0; j < cache_buffer[cache_idx].num_cols; j++) { + //printf("j=%d idx=%d\n",j,i*wave_size+j); + double val = (cache_buffer[cache_idx].databuf[i*wave_size+j] + slope * (double)(cache_buffer[cache_idx].num_cols - j) - offset); + + // for spectrum displaying + if (i == 0) + attr_Spectrum_read[j] = val; + + if (cache_buffer[cache_idx].datavalid[i*wave_size+j]) { + sum += val; + pos += val * (j + 1); + cnt++; + } + } + mean = sum / (double) cnt; + + // get std + cnt = 0; + for (int j = 0; j < cache_buffer[cache_idx].num_cols; j++) { + double val = (cache_buffer[cache_idx].databuf[i*wave_size+j] + slope * (double)j - offset); + if (cache_buffer[cache_idx].datavalid[i*wave_size+j]) { + std += ((double)j - pos) * ((double)j - pos); cnt++; + } + } + if (cnt != 0) + std = pow(std / (double) cnt, 0.5); + std = 0; + + cache_buffer[cache_idx].sum[i] = sum; + cache_buffer[cache_idx].mean[i] = mean; + cache_buffer[cache_idx].horpos[i] = pos; + cache_buffer[cache_idx].horsigma[i] = std; + cache_buffer[cache_idx].validvalues[i] = cnt; + + + } + +} + + + +//+------------------------------------------------------------------ +/** + * method: DataVampire::recover_data + * Recover data + */ +//+------------------------------------------------------------------ +void DataVampire::recover_data(const Tango::DevVarLongArray *argin, struct acq_buffer_t **rec_data) +{ + + std::vector<double> cmd_input_value; + std::vector<std::string> cmd_input_value_str; + std::vector<double> cmd_output_value; + std::vector<std::string> cmd_output_value_str; + + struct acq_buffer_t *tmp; + + int32_t mode, num_samples, bn_start, bn_end, roi[4]; + + for (unsigned int i = 0; i < argin->length(); i++) { + cmd_input_value.push_back((*argin)[i]); + } + + if (*attr_PostAcqRoi_read == false) { + for (unsigned int i = 0; i < roi_dim; i++) { + cmd_input_value.push_back(attr_RoiParam_read[i]); + } + } + + Tango::DeviceData Din = cmd_insert_values(cmd_in_type, cmd_input_value, cmd_input_value_str); + + extract_input_parameters(argin, &mode, &num_samples, &bn_start, &bn_end, roi); + + Tango::DeviceData Dout = device->command_inout(command_name, Din); + + store_data(&Dout, num_samples, bn_start, bn_end, roi, rec_data); + +} + + +/*----- PROTECTED REGION END -----*/ // DataVampire::namespace_ending +} // namespace diff --git a/src/DataVampire.h b/src/DataVampire.h new file mode 100644 index 0000000..1c3adc9 --- /dev/null +++ b/src/DataVampire.h @@ -0,0 +1,552 @@ +/*----- PROTECTED REGION ID(DataVampire.h) ENABLED START -----*/ +/* clang-format on */ +//============================================================================= +// +// file : DataVampire.h +// +// description : Include file for the DataVampire class +// +// project : DataVampire +// +// 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 DataVampire_H +#define DataVampire_H + +#include <ostream> +#include <iostream> +#include <vector> + +#include <tango/tango.h> + +/* clang-format off */ +/*----- PROTECTED REGION END -----*/ // DataVampire.h + +/** + * DataVampire class description: + * Get vectors of 1D or 2D data and calculate sum, mean, horpos, verpos, horsigma, versigma, numsamples + */ + +namespace DataVampire_ns +{ +/*----- PROTECTED REGION ID(DataVampire::Additional Class Declarations) ENABLED START -----*/ +/* clang-format on */ +// Additional Class Declarations +/* clang-format off */ + + + +/*----- PROTECTED REGION END -----*/ // DataVampire::Additional Class Declarations + +class DataVampire : public TANGO_BASE_CLASS +{ + +/*----- PROTECTED REGION ID(DataVampire::Data Members) ENABLED START -----*/ +/* clang-format on */ +// Add your own data members +/* clang-format off */ + + +struct acq_buffer_t +{ + struct timespec timerec; + uint32_t bn_start, bn_end; + uint32_t num_samples; + uint32_t num_rows, num_cols; + uint32_t data_size; + double *databuf; + bool *datavalid; + double *sum; + double *mean; + double *horpos; + double *verpos; + double *horsigma; + double *versigma; + double *validvalues; +}; + +Tango::DeviceProxy *device; +std::string device_name, command_name; + +acq_buffer_t *cache_buffer; +uint32_t cache_idx, roi_dim; +long cmd_in_type, cmd_out_type; +int32_t num_rows_image, num_cols_image, num_cols_spectrum; + + + +/*----- PROTECTED REGION END -----*/ // DataVampire::Data Members + +// Device property data members +public: + // HorCalib: + vector<Tango::DevDouble> horCalib; + // VerCalib: + vector<Tango::DevDouble> verCalib; + // RoiParam: + vector<Tango::DevLong> roiParam; + // CommandString: + string commandString; + +// Attribute data members +public: + Tango::DevDouble *attr_MinThreshold_read; + Tango::DevDouble *attr_MaxThreshold_read; + Tango::DevString *attr_CommandString_read; + Tango::DevLong *attr_PollingTime_read; + Tango::DevLong *attr_PollingSamples_read; + Tango::DevDouble *attr_Sum_read; + Tango::DevDouble *attr_Mean_read; + Tango::DevDouble *attr_HorPos_read; + Tango::DevDouble *attr_VerPos_read; + Tango::DevDouble *attr_HorSigma_read; + Tango::DevDouble *attr_VerSigma_read; + Tango::DevLong *attr_ValidValues_read; + Tango::DevBoolean *attr_Enable_read; + Tango::DevLong *attr_CacheSize_read; + Tango::DevLong *attr_AutoBackgroundSamples_read; + Tango::DevBoolean *attr_PostAcqRoi_read; + Tango::DevLong *attr_ImageWidth_read; + Tango::DevLong *attr_ImageHeight_read; + Tango::DevLong *attr_RoiParam_read; + Tango::DevDouble *attr_Spectrum_read; + Tango::DevDouble *attr_HorBackground_read; + Tango::DevDouble *attr_VerBackground_read; + Tango::DevDouble *attr_Image_read; + +// Constructors and destructors +public: + /** + * Constructs a newly device object. + * + * @param cl Class. + * @param s Device Name + */ + DataVampire(Tango::DeviceClass *cl,string &s); + /** + * Constructs a newly device object. + * + * @param cl Class. + * @param s Device Name + */ + DataVampire(Tango::DeviceClass *cl,const char *s); + /** + * Constructs a newly device object. + * + * @param cl Class. + * @param s Device name + * @param d Device description. + */ + DataVampire(Tango::DeviceClass *cl,const char *s,const char *d); + /** + * The device object destructor. + */ + ~DataVampire() {delete_device();}; + + +// Miscellaneous methods +public: + /* + * will be called at device destruction or at init command. + */ + void delete_device(); + /* + * Initialize the device + */ + virtual void init_device(); + /* + * Read the device properties from database + */ + void get_device_property(); + /* + * Always executed method before execution command method. + */ + virtual void always_executed_hook(); + + +// Attribute methods +public: + //-------------------------------------------------------- + /* + * Method : DataVampire::read_attr_hardware() + * Description : Hardware acquisition for attributes. + */ + //-------------------------------------------------------- + virtual void read_attr_hardware(vector<long> &attr_list); + //-------------------------------------------------------- + /* + * Method : DataVampire::write_attr_hardware() + * Description : Hardware writing for attributes. + */ + //-------------------------------------------------------- + virtual void write_attr_hardware(vector<long> &attr_list); + +/** + * Attribute MinThreshold related methods + * Description: + * + * Data type: Tango::DevDouble + * Attr type: Scalar + */ + virtual void read_MinThreshold(Tango::Attribute &attr); + virtual void write_MinThreshold(Tango::WAttribute &attr); + virtual bool is_MinThreshold_allowed(Tango::AttReqType type); +/** + * Attribute MaxThreshold related methods + * Description: + * + * Data type: Tango::DevDouble + * Attr type: Scalar + */ + virtual void read_MaxThreshold(Tango::Attribute &attr); + virtual void write_MaxThreshold(Tango::WAttribute &attr); + virtual bool is_MaxThreshold_allowed(Tango::AttReqType type); +/** + * Attribute CommandString related methods + * Description: + * + * Data type: Tango::DevString + * Attr type: Scalar + */ + virtual void read_CommandString(Tango::Attribute &attr); + virtual void write_CommandString(Tango::WAttribute &attr); + virtual bool is_CommandString_allowed(Tango::AttReqType type); +/** + * Attribute PollingTime related methods + * Description: -1: disabled + * + * Data type: Tango::DevLong + * Attr type: Scalar + */ + virtual void read_PollingTime(Tango::Attribute &attr); + virtual void write_PollingTime(Tango::WAttribute &attr); + virtual bool is_PollingTime_allowed(Tango::AttReqType type); +/** + * Attribute PollingSamples related methods + * Description: -1: disabled + * + * Data type: Tango::DevLong + * Attr type: Scalar + */ + virtual void read_PollingSamples(Tango::Attribute &attr); + virtual void write_PollingSamples(Tango::WAttribute &attr); + virtual bool is_PollingSamples_allowed(Tango::AttReqType type); +/** + * Attribute Sum related methods + * Description: + * + * Data type: Tango::DevDouble + * Attr type: Scalar + */ + virtual void read_Sum(Tango::Attribute &attr); + virtual bool is_Sum_allowed(Tango::AttReqType type); +/** + * Attribute Mean related methods + * Description: + * + * Data type: Tango::DevDouble + * Attr type: Scalar + */ + virtual void read_Mean(Tango::Attribute &attr); + virtual bool is_Mean_allowed(Tango::AttReqType type); +/** + * Attribute HorPos related methods + * Description: + * + * Data type: Tango::DevDouble + * Attr type: Scalar + */ + virtual void read_HorPos(Tango::Attribute &attr); + virtual bool is_HorPos_allowed(Tango::AttReqType type); +/** + * Attribute VerPos related methods + * Description: + * + * Data type: Tango::DevDouble + * Attr type: Scalar + */ + virtual void read_VerPos(Tango::Attribute &attr); + virtual bool is_VerPos_allowed(Tango::AttReqType type); +/** + * Attribute HorSigma related methods + * Description: + * + * Data type: Tango::DevDouble + * Attr type: Scalar + */ + virtual void read_HorSigma(Tango::Attribute &attr); + virtual bool is_HorSigma_allowed(Tango::AttReqType type); +/** + * Attribute VerSigma related methods + * Description: + * + * Data type: Tango::DevDouble + * Attr type: Scalar + */ + virtual void read_VerSigma(Tango::Attribute &attr); + virtual bool is_VerSigma_allowed(Tango::AttReqType type); +/** + * Attribute ValidValues related methods + * Description: + * + * Data type: Tango::DevLong + * Attr type: Scalar + */ + virtual void read_ValidValues(Tango::Attribute &attr); + virtual bool is_ValidValues_allowed(Tango::AttReqType type); +/** + * Attribute Enable related methods + * Description: + * + * Data type: Tango::DevBoolean + * Attr type: Scalar + */ + virtual void read_Enable(Tango::Attribute &attr); + virtual void write_Enable(Tango::WAttribute &attr); + virtual bool is_Enable_allowed(Tango::AttReqType type); +/** + * Attribute CacheSize related methods + * Description: + * + * Data type: Tango::DevLong + * Attr type: Scalar + */ + virtual void read_CacheSize(Tango::Attribute &attr); + virtual void write_CacheSize(Tango::WAttribute &attr); + virtual bool is_CacheSize_allowed(Tango::AttReqType type); +/** + * Attribute AutoBackgroundSamples related methods + * Description: 0 to disable + * + * Data type: Tango::DevLong + * Attr type: Scalar + */ + virtual void read_AutoBackgroundSamples(Tango::Attribute &attr); + virtual void write_AutoBackgroundSamples(Tango::WAttribute &attr); + virtual bool is_AutoBackgroundSamples_allowed(Tango::AttReqType type); +/** + * Attribute PostAcqRoi related methods + * Description: + * + * Data type: Tango::DevBoolean + * Attr type: Scalar + */ + virtual void read_PostAcqRoi(Tango::Attribute &attr); + virtual void write_PostAcqRoi(Tango::WAttribute &attr); + virtual bool is_PostAcqRoi_allowed(Tango::AttReqType type); +/** + * Attribute ImageWidth related methods + * Description: + * + * Data type: Tango::DevLong + * Attr type: Scalar + */ + virtual void read_ImageWidth(Tango::Attribute &attr); + virtual void write_ImageWidth(Tango::WAttribute &attr); + virtual bool is_ImageWidth_allowed(Tango::AttReqType type); +/** + * Attribute ImageHeight related methods + * Description: + * + * Data type: Tango::DevLong + * Attr type: Scalar + */ + virtual void read_ImageHeight(Tango::Attribute &attr); + virtual void write_ImageHeight(Tango::WAttribute &attr); + virtual bool is_ImageHeight_allowed(Tango::AttReqType type); +/** + * Attribute RoiParam related methods + * Description: + * + * Data type: Tango::DevLong + * Attr type: Spectrum max = 4 + */ + virtual void read_RoiParam(Tango::Attribute &attr); + virtual void write_RoiParam(Tango::WAttribute &attr); + virtual bool is_RoiParam_allowed(Tango::AttReqType type); +/** + * Attribute Spectrum related methods + * Description: + * + * Data type: Tango::DevDouble + * Attr type: Spectrum max = 1000000 + */ + virtual void read_Spectrum(Tango::Attribute &attr); + virtual bool is_Spectrum_allowed(Tango::AttReqType type); +/** + * Attribute HorBackground related methods + * Description: + * + * Data type: Tango::DevDouble + * Attr type: Spectrum max = 1000000 + */ + virtual void read_HorBackground(Tango::Attribute &attr); + virtual bool is_HorBackground_allowed(Tango::AttReqType type); +/** + * Attribute VerBackground related methods + * Description: + * + * Data type: Tango::DevDouble + * Attr type: Spectrum max = 1000000 + */ + virtual void read_VerBackground(Tango::Attribute &attr); + virtual bool is_VerBackground_allowed(Tango::AttReqType type); +/** + * Attribute Image related methods + * Description: + * + * Data type: Tango::DevDouble + * Attr type: Image max = 5000 x 5000 + */ + virtual void read_Image(Tango::Attribute &attr); + virtual bool is_Image_allowed(Tango::AttReqType type); + + + //-------------------------------------------------------- + /** + * Method : DataVampire::add_dynamic_attributes() + * Description : Add dynamic attributes if any. + */ + //-------------------------------------------------------- + void add_dynamic_attributes(); + + + + +// Command related methods +public: + /** + * Command GetSum related method + * Description: + * + * @param argin mode,samples; mode,bunch start,bunch end + * @returns values + */ + virtual Tango::DevVarDoubleArray *get_sum(const Tango::DevVarLongArray *argin); + virtual bool is_GetSum_allowed(const CORBA::Any &any); + /** + * Command GetMean related method + * Description: + * + * @param argin mode,samples; mode,bunch start,bunch end + * @returns values + */ + virtual Tango::DevVarDoubleArray *get_mean(const Tango::DevVarLongArray *argin); + virtual bool is_GetMean_allowed(const CORBA::Any &any); + /** + * Command GetHorPos related method + * Description: + * + * @param argin mode,samples; mode,bunch start,bunch end + * @returns values + */ + virtual Tango::DevVarDoubleArray *get_hor_pos(const Tango::DevVarLongArray *argin); + virtual bool is_GetHorPos_allowed(const CORBA::Any &any); + /** + * Command GetVerPos related method + * Description: + * + * @param argin mode,samples; mode,bunch start,bunch end + * @returns values + */ + virtual Tango::DevVarDoubleArray *get_ver_pos(const Tango::DevVarLongArray *argin); + virtual bool is_GetVerPos_allowed(const CORBA::Any &any); + /** + * Command GetHorSigma related method + * Description: + * + * @param argin mode,samples; mode,bunch start,bunch end + * @returns values + */ + virtual Tango::DevVarDoubleArray *get_hor_sigma(const Tango::DevVarLongArray *argin); + virtual bool is_GetHorSigma_allowed(const CORBA::Any &any); + /** + * Command GetVerSigma related method + * Description: + * + * @param argin mode,samples; mode,bunch start,bunch end + * @returns values + */ + virtual Tango::DevVarDoubleArray *get_ver_sigma(const Tango::DevVarLongArray *argin); + virtual bool is_GetVerSigma_allowed(const CORBA::Any &any); + /** + * Command GetValidValues related method + * Description: + * + * @param argin mode,samples; mode,bunch start,bunch end + * @returns values + */ + virtual Tango::DevVarDoubleArray *get_valid_values(const Tango::DevVarLongArray *argin); + virtual bool is_GetValidValues_allowed(const CORBA::Any &any); + /** + * Command SetBackground related method + * Description: + * + */ + virtual void set_background(); + virtual bool is_SetBackground_allowed(const CORBA::Any &any); + + + //-------------------------------------------------------- + /** + * Method : DataVampire::add_dynamic_commands() + * Description : Add dynamic commands if any. + */ + //-------------------------------------------------------- + void add_dynamic_commands(); + +/*----- PROTECTED REGION ID(DataVampire::Additional Method prototypes) ENABLED START -----*/ +/* clang-format on */ +// Additional Method prototypes +/* clang-format off */ +void cmd_extract_values(Tango::DeviceData *cmd_value, std::vector<double> &val, std::vector<std::string> &val_string); +Tango::DeviceData cmd_insert_values(long cmd_type, std::vector<double> val, std::vector<std::string> val_string); +void string_explode(std::string str, std::string separator, std::vector<std::string>* results); +void store_roi_param(const Tango::DevLong *w_val, int size); +void store_command_string(Tango::DevString w_val); +void extract_input_parameters(const Tango::DevVarLongArray *argin, int32_t *mode, int32_t *num_samples, int32_t *bn_start, int32_t *bn_end, int32_t *roi); +void free_cache_buffer(void); +void allocate_cache_buffer(void); +void store_data(Tango::DeviceData *cmd_value, int32_t num_samples, int32_t bn_start, int32_t bn_end, int32_t *roi, struct acq_buffer_t **rec_data); +void process_2D(int32_t cache_idx, int32_t auto_bck_samples); +void process_1D(int32_t cache_idx, int32_t auto_bck_samples); +void recover_data(const Tango::DevVarLongArray *argin, struct acq_buffer_t **rec_data); + + + + + + +/*----- PROTECTED REGION END -----*/ // DataVampire::Additional Method prototypes +}; + +/*----- PROTECTED REGION ID(DataVampire::Additional Classes Definitions) ENABLED START -----*/ +/* clang-format on */ +// Additional Classes Definitions +/* clang-format off */ +/*----- PROTECTED REGION END -----*/ // DataVampire::Additional Classes Definitions + +} // End of namespace + +#endif // DataVampire_H diff --git a/src/DataVampire.xmi b/src/DataVampire.xmi new file mode 100644 index 0000000..377c5b8 --- /dev/null +++ b/src/DataVampire.xmi @@ -0,0 +1,308 @@ +<?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="DataVampire" pogoRevision="9.6"> + <description description="Get vectors of 1D or 2D data and calculate sum, mean, horpos, verpos, horsigma, versigma, numsamples" title="DataVampire" sourcePath="/home/giulio.gaio/src/gitlab/cs/ds/datavampire/src" language="Cpp" filestogenerate="XMI file,Code files,Protected Regions" license="GPL" copyright="" hasMandatoryProperty="false" hasConcreteProperty="true" hasAbstractCommand="false" hasAbstractAttribute="false"> + <inheritances classname="Device_Impl" sourcePath=""/> + <identification contact="at elettra.eu - giulio.gaio" author="giulio.gaio" emailDomain="elettra.eu" classFamily="Calculation" siteSpecific="" platform="All Platforms" bus="Not Applicable" manufacturer="none" reference=""/> + </description> + <deviceProperties name="HorCalib" description=""> + <type xsi:type="pogoDsl:DoubleVectorType"/> + <status abstract="false" inherited="false" concrete="true" concreteHere="true"/> + <DefaultPropValue>1</DefaultPropValue> + </deviceProperties> + <deviceProperties name="VerCalib" description=""> + <type xsi:type="pogoDsl:DoubleVectorType"/> + <status abstract="false" inherited="false" concrete="true" concreteHere="true"/> + <DefaultPropValue>1</DefaultPropValue> + </deviceProperties> + <deviceProperties name="RoiParam" description=""> + <type xsi:type="pogoDsl:IntVectorType"/> + <status abstract="false" inherited="false" concrete="true" concreteHere="true"/> + </deviceProperties> + <deviceProperties name="CommandString" description=""> + <type xsi:type="pogoDsl:StringType"/> + <status abstract="false" inherited="false" concrete="true" concreteHere="true"/> + </deviceProperties> + <commands name="State" description="This command gets the device state (stored in its device_state data member) and returns it to the caller." execMethod="dev_state" displayLevel="OPERATOR" 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="GetSum" description="" execMethod="get_sum" displayLevel="OPERATOR" polledPeriod="0" isDynamic="false"> + <argin description="mode,samples; mode,bunch start,bunch end"> + <type xsi:type="pogoDsl:IntArrayType"/> + </argin> + <argout description="values"> + <type xsi:type="pogoDsl:DoubleArrayType"/> + </argout> + <status abstract="false" inherited="false" concrete="true" concreteHere="true"/> + </commands> + <commands name="GetMean" description="" execMethod="get_mean" displayLevel="OPERATOR" polledPeriod="0" isDynamic="false"> + <argin description="mode,samples; mode,bunch start,bunch end"> + <type xsi:type="pogoDsl:IntArrayType"/> + </argin> + <argout description="values"> + <type xsi:type="pogoDsl:DoubleArrayType"/> + </argout> + <status abstract="false" inherited="false" concrete="true" concreteHere="true"/> + </commands> + <commands name="GetHorPos" description="" execMethod="get_hor_pos" displayLevel="OPERATOR" polledPeriod="0" isDynamic="false"> + <argin description="mode,samples; mode,bunch start,bunch end"> + <type xsi:type="pogoDsl:IntArrayType"/> + </argin> + <argout description="values"> + <type xsi:type="pogoDsl:DoubleArrayType"/> + </argout> + <status abstract="false" inherited="false" concrete="true" concreteHere="true"/> + </commands> + <commands name="GetVerPos" description="" execMethod="get_ver_pos" displayLevel="OPERATOR" polledPeriod="0" isDynamic="false"> + <argin description="mode,samples; mode,bunch start,bunch end"> + <type xsi:type="pogoDsl:IntArrayType"/> + </argin> + <argout description="values"> + <type xsi:type="pogoDsl:DoubleArrayType"/> + </argout> + <status abstract="false" inherited="false" concrete="true" concreteHere="true"/> + </commands> + <commands name="GetHorSigma" description="" execMethod="get_hor_sigma" displayLevel="OPERATOR" polledPeriod="0" isDynamic="false"> + <argin description="mode,samples; mode,bunch start,bunch end"> + <type xsi:type="pogoDsl:IntArrayType"/> + </argin> + <argout description="values"> + <type xsi:type="pogoDsl:DoubleArrayType"/> + </argout> + <status abstract="false" inherited="false" concrete="true" concreteHere="true"/> + </commands> + <commands name="GetVerSigma" description="" execMethod="get_ver_sigma" displayLevel="OPERATOR" polledPeriod="0" isDynamic="false"> + <argin description="mode,samples; mode,bunch start,bunch end"> + <type xsi:type="pogoDsl:IntArrayType"/> + </argin> + <argout description="values"> + <type xsi:type="pogoDsl:DoubleArrayType"/> + </argout> + <status abstract="false" inherited="false" concrete="true" concreteHere="true"/> + </commands> + <commands name="GetValidValues" description="" execMethod="get_valid_values" displayLevel="OPERATOR" polledPeriod="0" isDynamic="false"> + <argin description="mode,samples; mode,bunch start,bunch end"> + <type xsi:type="pogoDsl:IntArrayType"/> + </argin> + <argout description="values"> + <type xsi:type="pogoDsl:DoubleArrayType"/> + </argout> + <status abstract="false" inherited="false" concrete="true" concreteHere="true"/> + </commands> + <commands name="SetBackground" description="" execMethod="set_background" 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="MinThreshold" 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="%.5f" maxValue="9.99e10" minValue="-9.99e10" maxAlarm="" minAlarm="" maxWarning="" minWarning="" deltaTime="" deltaValue=""/> + </attributes> + <attributes name="MaxThreshold" 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="%.5f" maxValue="9.99e10" minValue="-9.99e10" maxAlarm="" minAlarm="" maxWarning="" minWarning="" deltaTime="" deltaValue=""/> + </attributes> + <attributes name="CommandString" attType="Scalar" rwType="READ_WRITE" displayLevel="OPERATOR" polledPeriod="0" maxX="" maxY="" memorized="true" memorizedAtInit="true" allocReadMember="true" isDynamic="false"> + <dataType xsi:type="pogoDsl:StringType"/> + <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="PollingTime" 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="-1: disabled" label="" unit="ms" standardUnit="" displayUnit="ms" format="%d" maxValue="100000" minValue="-1" maxAlarm="" minAlarm="" maxWarning="" minWarning="" deltaTime="" deltaValue=""/> + </attributes> + <attributes name="PollingSamples" 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="-1: disabled" label="" unit="" standardUnit="" displayUnit="" format="" maxValue="1000000" minValue="-1000000" maxAlarm="" minAlarm="" maxWarning="" minWarning="" deltaTime="" deltaValue=""/> + </attributes> + <attributes name="Sum" 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="%.5f" maxValue="9999999999" minValue="-9999999999" maxAlarm="" minAlarm="" maxWarning="" minWarning="" deltaTime="" deltaValue=""/> + </attributes> + <attributes name="Mean" 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="%.5f" maxValue="9999999999" minValue="-9999999999" maxAlarm="" minAlarm="" maxWarning="" minWarning="" deltaTime="" deltaValue=""/> + </attributes> + <attributes name="HorPos" 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="%.5f" maxValue="9999999999" minValue="-9999999999" maxAlarm="" minAlarm="" maxWarning="" minWarning="" deltaTime="" deltaValue=""/> + </attributes> + <attributes name="VerPos" 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="%.5f" maxValue="9999999999" minValue="-9999999999" maxAlarm="" minAlarm="" maxWarning="" minWarning="" deltaTime="" deltaValue=""/> + </attributes> + <attributes name="HorSigma" 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="%.5f" maxValue="9999999999" minValue="-9999999999" maxAlarm="" minAlarm="" maxWarning="" minWarning="" deltaTime="" deltaValue=""/> + </attributes> + <attributes name="VerSigma" 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="%.5f" maxValue="9999999999" minValue="-9999999999" maxAlarm="" minAlarm="" maxWarning="" minWarning="" deltaTime="" deltaValue=""/> + </attributes> + <attributes name="ValidValues" 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="%d" maxValue="99999999" minValue="0" maxAlarm="" minAlarm="" maxWarning="" minWarning="" deltaTime="" deltaValue=""/> + </attributes> + <attributes name="Enable" attType="Scalar" rwType="READ_WRITE" displayLevel="OPERATOR" polledPeriod="0" maxX="" maxY="" memorized="true" memorizedAtInit="true" allocReadMember="true" isDynamic="false"> + <dataType xsi:type="pogoDsl:BooleanType"/> + <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="CacheSize" 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="" minValue="" maxAlarm="" minAlarm="" maxWarning="" minWarning="" deltaTime="" deltaValue=""/> + </attributes> + <attributes name="AutoBackgroundSamples" 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="0 to disable" label="" unit="" standardUnit="" displayUnit="" format="%d" maxValue="9999" minValue="-1" maxAlarm="" minAlarm="" maxWarning="" minWarning="" deltaTime="" deltaValue=""/> + </attributes> + <attributes name="PostAcqRoi" attType="Scalar" rwType="READ_WRITE" displayLevel="OPERATOR" polledPeriod="0" maxX="" maxY="" memorized="true" memorizedAtInit="true" allocReadMember="true" isDynamic="false"> + <dataType xsi:type="pogoDsl:BooleanType"/> + <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="ImageWidth" 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="%d" maxValue="9999" minValue="0" maxAlarm="" minAlarm="" maxWarning="" minWarning="" deltaTime="" deltaValue=""/> + </attributes> + <attributes name="ImageHeight" 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="%d" maxValue="9999" minValue="0" maxAlarm="" minAlarm="" maxWarning="" minWarning="" deltaTime="" deltaValue=""/> + </attributes> + <attributes name="RoiParam" attType="Spectrum" rwType="READ_WRITE" displayLevel="OPERATOR" polledPeriod="0" maxX="4" 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="Spectrum" attType="Spectrum" rwType="READ" displayLevel="OPERATOR" polledPeriod="0" maxX="1000000" 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="HorBackground" attType="Spectrum" rwType="READ" displayLevel="OPERATOR" polledPeriod="0" maxX="1000000" 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="VerBackground" attType="Spectrum" rwType="READ" displayLevel="OPERATOR" polledPeriod="0" maxX="1000000" 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="Image" attType="Image" rwType="READ" displayLevel="OPERATOR" polledPeriod="0" maxX="5000" maxY="5000" 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> + <states name="ON" 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.3.4/share/pogo/preferences"/> + </classes> +</pogoDsl:PogoSystem> diff --git a/src/DataVampireClass.cpp b/src/DataVampireClass.cpp new file mode 100644 index 0000000..dffa77c --- /dev/null +++ b/src/DataVampireClass.cpp @@ -0,0 +1,1313 @@ +/*----- PROTECTED REGION ID(DataVampireClass.cpp) ENABLED START -----*/ +/* clang-format on */ +//============================================================================= +// +// file : DataVampireClass.cpp +// +// description : C++ source for the DataVampireClass. +// A singleton class derived from DeviceClass. +// It implements the command and attribute list +// and all properties and methods required +// by the DataVampire once per process. +// +// project : DataVampire +// +// 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 "DataVampireClass.h" +/* clang-format off */ +/*----- PROTECTED REGION END -----*/ // DataVampireClass.cpp + +//------------------------------------------------------------------- +/** + * Create DataVampireClass singleton and + * return it in a C function for Python usage + */ +//------------------------------------------------------------------- +extern "C" { +#ifdef _TG_WINDOWS_ + +__declspec(dllexport) + +#endif + + Tango::DeviceClass *_create_DataVampire_class(const char *name) { + return DataVampire_ns::DataVampireClass::init(name); + } +} + +namespace DataVampire_ns +{ +//=================================================================== +// Initialize pointer for singleton pattern +//=================================================================== +DataVampireClass *DataVampireClass::_instance = NULL; + +//-------------------------------------------------------- +/** + * method : DataVampireClass::DataVampireClass(string &s) + * description : constructor for the DataVampireClass + * + * @param s The class name + */ +//-------------------------------------------------------- +DataVampireClass::DataVampireClass(string &s):Tango::DeviceClass(s) +{ + cout2 << "Entering DataVampireClass constructor" << endl; + set_default_property(); + write_class_property(); + + /*----- PROTECTED REGION ID(DataVampireClass::constructor) ENABLED START -----*/ + /* clang-format on */ + /* clang-format off */ + /*----- PROTECTED REGION END -----*/ // DataVampireClass::constructor + + cout2 << "Leaving DataVampireClass constructor" << endl; +} + +//-------------------------------------------------------- +/** + * method : DataVampireClass::~DataVampireClass() + * description : destructor for the DataVampireClass + */ +//-------------------------------------------------------- +DataVampireClass::~DataVampireClass() +{ + /*----- PROTECTED REGION ID(DataVampireClass::destructor) ENABLED START -----*/ + /* clang-format on */ + /* clang-format off */ + /*----- PROTECTED REGION END -----*/ // DataVampireClass::destructor + + _instance = NULL; +} + + +//-------------------------------------------------------- +/** + * method : DataVampireClass::init + * description : Create the object if not already done. + * Otherwise, just return a pointer to the object + * + * @param name The class name + */ +//-------------------------------------------------------- +DataVampireClass *DataVampireClass::init(const char *name) +{ + if (_instance == NULL) + { + try + { + string s(name); + _instance = new DataVampireClass(s); + } + catch (bad_alloc &) + { + throw; + } + } + return _instance; +} + +//-------------------------------------------------------- +/** + * method : DataVampireClass::instance + * description : Check if object already created, + * and return a pointer to the object + */ +//-------------------------------------------------------- +DataVampireClass *DataVampireClass::instance() +{ + if (_instance == NULL) + { + cerr << "Class is not initialised !!" << endl; + exit(-1); + } + return _instance; +} + + + +//=================================================================== +// Command execution method calls +//=================================================================== +//-------------------------------------------------------- +/** + * method : GetSumClass::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 *GetSumClass::execute(Tango::DeviceImpl *device, const CORBA::Any &in_any) +{ + cout2 << "GetSumClass::execute(): arrived" << endl; + const Tango::DevVarLongArray *argin; + extract(in_any, argin); + return insert((static_cast<DataVampire *>(device))->get_sum(argin)); +} + +//-------------------------------------------------------- +/** + * method : GetMeanClass::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 *GetMeanClass::execute(Tango::DeviceImpl *device, const CORBA::Any &in_any) +{ + cout2 << "GetMeanClass::execute(): arrived" << endl; + const Tango::DevVarLongArray *argin; + extract(in_any, argin); + return insert((static_cast<DataVampire *>(device))->get_mean(argin)); +} + +//-------------------------------------------------------- +/** + * method : GetHorPosClass::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 *GetHorPosClass::execute(Tango::DeviceImpl *device, const CORBA::Any &in_any) +{ + cout2 << "GetHorPosClass::execute(): arrived" << endl; + const Tango::DevVarLongArray *argin; + extract(in_any, argin); + return insert((static_cast<DataVampire *>(device))->get_hor_pos(argin)); +} + +//-------------------------------------------------------- +/** + * method : GetVerPosClass::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 *GetVerPosClass::execute(Tango::DeviceImpl *device, const CORBA::Any &in_any) +{ + cout2 << "GetVerPosClass::execute(): arrived" << endl; + const Tango::DevVarLongArray *argin; + extract(in_any, argin); + return insert((static_cast<DataVampire *>(device))->get_ver_pos(argin)); +} + +//-------------------------------------------------------- +/** + * method : GetHorSigmaClass::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 *GetHorSigmaClass::execute(Tango::DeviceImpl *device, const CORBA::Any &in_any) +{ + cout2 << "GetHorSigmaClass::execute(): arrived" << endl; + const Tango::DevVarLongArray *argin; + extract(in_any, argin); + return insert((static_cast<DataVampire *>(device))->get_hor_sigma(argin)); +} + +//-------------------------------------------------------- +/** + * method : GetVerSigmaClass::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 *GetVerSigmaClass::execute(Tango::DeviceImpl *device, const CORBA::Any &in_any) +{ + cout2 << "GetVerSigmaClass::execute(): arrived" << endl; + const Tango::DevVarLongArray *argin; + extract(in_any, argin); + return insert((static_cast<DataVampire *>(device))->get_ver_sigma(argin)); +} + +//-------------------------------------------------------- +/** + * method : GetValidValuesClass::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 *GetValidValuesClass::execute(Tango::DeviceImpl *device, const CORBA::Any &in_any) +{ + cout2 << "GetValidValuesClass::execute(): arrived" << endl; + const Tango::DevVarLongArray *argin; + extract(in_any, argin); + return insert((static_cast<DataVampire *>(device))->get_valid_values(argin)); +} + +//-------------------------------------------------------- +/** + * method : SetBackgroundClass::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 *SetBackgroundClass::execute(Tango::DeviceImpl *device, TANGO_UNUSED(const CORBA::Any &in_any)) +{ + cout2 << "SetBackgroundClass::execute(): arrived" << endl; + ((static_cast<DataVampire *>(device))->set_background()); + return new CORBA::Any(); +} + + +//=================================================================== +// Properties management +//=================================================================== +//-------------------------------------------------------- +/** + * Method : DataVampireClass::get_class_property() + * Description : Get the class property for specified name. + */ +//-------------------------------------------------------- +Tango::DbDatum DataVampireClass::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 : DataVampireClass::get_default_device_property() + * Description : Return the default value for device property. + */ +//-------------------------------------------------------- +Tango::DbDatum DataVampireClass::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 : DataVampireClass::get_default_class_property() + * Description : Return the default value for class property. + */ +//-------------------------------------------------------- +Tango::DbDatum DataVampireClass::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 : DataVampireClass::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 DataVampireClass::set_default_property() +{ + string prop_name; + string prop_desc; + string prop_def; + vector<string> vect_data; + + // Set Default Class Properties + + // Set Default device Properties + prop_name = "HorCalib"; + prop_desc = ""; + prop_def = "1"; + vect_data.clear(); + vect_data.push_back("1"); + if (prop_def.length()>0) + { + Tango::DbDatum data(prop_name); + data << vect_data ; + dev_def_prop.push_back(data); + add_wiz_dev_prop(prop_name, prop_desc, prop_def); + } + else + add_wiz_dev_prop(prop_name, prop_desc); + prop_name = "VerCalib"; + prop_desc = ""; + prop_def = "1"; + vect_data.clear(); + vect_data.push_back("1"); + if (prop_def.length()>0) + { + Tango::DbDatum data(prop_name); + data << vect_data ; + dev_def_prop.push_back(data); + add_wiz_dev_prop(prop_name, prop_desc, prop_def); + } + else + add_wiz_dev_prop(prop_name, prop_desc); + prop_name = "RoiParam"; + prop_desc = ""; + prop_def = ""; + vect_data.clear(); + if (prop_def.length()>0) + { + Tango::DbDatum data(prop_name); + data << vect_data ; + dev_def_prop.push_back(data); + add_wiz_dev_prop(prop_name, prop_desc, prop_def); + } + else + add_wiz_dev_prop(prop_name, prop_desc); + prop_name = "CommandString"; + prop_desc = ""; + prop_def = ""; + vect_data.clear(); + if (prop_def.length()>0) + { + Tango::DbDatum data(prop_name); + data << vect_data ; + dev_def_prop.push_back(data); + add_wiz_dev_prop(prop_name, prop_desc, prop_def); + } + else + add_wiz_dev_prop(prop_name, prop_desc); +} + +//-------------------------------------------------------- +/** + * Method : DataVampireClass::write_class_property() + * Description : Set class description fields as property in database + */ +//-------------------------------------------------------- +void DataVampireClass::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("DataVampire"); + title << str_title; + data.push_back(title); + + // Put Description + Tango::DbDatum description("Description"); + vector<string> str_desc; + str_desc.push_back("Get vectors of 1D or 2D data and calculate sum, mean, horpos, verpos, horsigma, versigma, numsamples"); + 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 : DataVampireClass::device_factory() + * Description : Create the device object(s) + * and store them in the device list + */ +//-------------------------------------------------------- +void DataVampireClass::device_factory(const Tango::DevVarStringArray *devlist_ptr) +{ + /*----- PROTECTED REGION ID(DataVampireClass::device_factory_before) ENABLED START -----*/ +/* clang-format on */ +// Add your own code +/* clang-format off */ +/*----- PROTECTED REGION END -----*/ // DataVampireClass::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 DataVampire(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 + DataVampire *dev = static_cast<DataVampire *>(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(DataVampireClass::device_factory_after) ENABLED START -----*/ +/* clang-format on */ +// Add your own code +/* clang-format off */ +/*----- PROTECTED REGION END -----*/ // DataVampireClass::device_factory_after +} +//-------------------------------------------------------- +/** + * Method : DataVampireClass::attribute_factory() + * Description : Create the attribute object(s) + * and store them in the attribute list + */ +//-------------------------------------------------------- +void DataVampireClass::attribute_factory(vector<Tango::Attr *> &att_list) +{ + /*----- PROTECTED REGION ID(DataVampireClass::attribute_factory_before) ENABLED START -----*/ + /* clang-format on */ + // Add your own code + /* clang-format off */ + /*----- PROTECTED REGION END -----*/ // DataVampireClass::attribute_factory_before + // Attribute : MinThreshold + MinThresholdAttrib *minthreshold = new MinThresholdAttrib(); + Tango::UserDefaultAttrProp minthreshold_prop; + // description not set for MinThreshold + // label not set for MinThreshold + // unit not set for MinThreshold + // standard_unit not set for MinThreshold + // display_unit not set for MinThreshold + minthreshold_prop.set_format("%.5f"); + minthreshold_prop.set_max_value("9.99e10"); + minthreshold_prop.set_min_value("-9.99e10"); + // max_alarm not set for MinThreshold + // min_alarm not set for MinThreshold + // max_warning not set for MinThreshold + // min_warning not set for MinThreshold + // delta_t not set for MinThreshold + // delta_val not set for MinThreshold + + minthreshold->set_default_properties(minthreshold_prop); + // Not Polled + minthreshold->set_disp_level(Tango::OPERATOR); + minthreshold->set_memorized(); + minthreshold->set_memorized_init(true); + att_list.push_back(minthreshold); + + // Attribute : MaxThreshold + MaxThresholdAttrib *maxthreshold = new MaxThresholdAttrib(); + Tango::UserDefaultAttrProp maxthreshold_prop; + // description not set for MaxThreshold + // label not set for MaxThreshold + // unit not set for MaxThreshold + // standard_unit not set for MaxThreshold + // display_unit not set for MaxThreshold + maxthreshold_prop.set_format("%.5f"); + maxthreshold_prop.set_max_value("9.99e10"); + maxthreshold_prop.set_min_value("-9.99e10"); + // max_alarm not set for MaxThreshold + // min_alarm not set for MaxThreshold + // max_warning not set for MaxThreshold + // min_warning not set for MaxThreshold + // delta_t not set for MaxThreshold + // delta_val not set for MaxThreshold + + maxthreshold->set_default_properties(maxthreshold_prop); + // Not Polled + maxthreshold->set_disp_level(Tango::OPERATOR); + maxthreshold->set_memorized(); + maxthreshold->set_memorized_init(true); + att_list.push_back(maxthreshold); + + // Attribute : CommandString + CommandStringAttrib *commandstring = new CommandStringAttrib(); + Tango::UserDefaultAttrProp commandstring_prop; + // description not set for CommandString + // label not set for CommandString + // unit not set for CommandString + // standard_unit not set for CommandString + // display_unit not set for CommandString + // format not set for CommandString + // max_value not set for CommandString + // min_value not set for CommandString + // max_alarm not set for CommandString + // min_alarm not set for CommandString + // max_warning not set for CommandString + // min_warning not set for CommandString + // delta_t not set for CommandString + // delta_val not set for CommandString + + commandstring->set_default_properties(commandstring_prop); + // Not Polled + commandstring->set_disp_level(Tango::OPERATOR); + commandstring->set_memorized(); + commandstring->set_memorized_init(true); + att_list.push_back(commandstring); + + // Attribute : PollingTime + PollingTimeAttrib *pollingtime = new PollingTimeAttrib(); + Tango::UserDefaultAttrProp pollingtime_prop; + pollingtime_prop.set_description("-1: disabled"); + // label not set for PollingTime + pollingtime_prop.set_unit("ms"); + // standard_unit not set for PollingTime + pollingtime_prop.set_display_unit("ms"); + pollingtime_prop.set_format("%d"); + pollingtime_prop.set_max_value("100000"); + pollingtime_prop.set_min_value("-1"); + // max_alarm not set for PollingTime + // min_alarm not set for PollingTime + // max_warning not set for PollingTime + // min_warning not set for PollingTime + // delta_t not set for PollingTime + // delta_val not set for PollingTime + + pollingtime->set_default_properties(pollingtime_prop); + // Not Polled + pollingtime->set_disp_level(Tango::OPERATOR); + pollingtime->set_memorized(); + pollingtime->set_memorized_init(true); + att_list.push_back(pollingtime); + + // Attribute : PollingSamples + PollingSamplesAttrib *pollingsamples = new PollingSamplesAttrib(); + Tango::UserDefaultAttrProp pollingsamples_prop; + pollingsamples_prop.set_description("-1: disabled"); + // label not set for PollingSamples + // unit not set for PollingSamples + // standard_unit not set for PollingSamples + // display_unit not set for PollingSamples + // format not set for PollingSamples + pollingsamples_prop.set_max_value("1000000"); + pollingsamples_prop.set_min_value("-1000000"); + // max_alarm not set for PollingSamples + // min_alarm not set for PollingSamples + // max_warning not set for PollingSamples + // min_warning not set for PollingSamples + // delta_t not set for PollingSamples + // delta_val not set for PollingSamples + + pollingsamples->set_default_properties(pollingsamples_prop); + // Not Polled + pollingsamples->set_disp_level(Tango::OPERATOR); + pollingsamples->set_memorized(); + pollingsamples->set_memorized_init(true); + att_list.push_back(pollingsamples); + + // Attribute : Sum + SumAttrib *sum = new SumAttrib(); + Tango::UserDefaultAttrProp sum_prop; + // description not set for Sum + // label not set for Sum + // unit not set for Sum + // standard_unit not set for Sum + // display_unit not set for Sum + sum_prop.set_format("%.5f"); + sum_prop.set_max_value("9999999999"); + sum_prop.set_min_value("-9999999999"); + // max_alarm not set for Sum + // min_alarm not set for Sum + // max_warning not set for Sum + // min_warning not set for Sum + // delta_t not set for Sum + // delta_val not set for Sum + + sum->set_default_properties(sum_prop); + // Not Polled + sum->set_disp_level(Tango::OPERATOR); + // Not Memorized + att_list.push_back(sum); + + // Attribute : Mean + MeanAttrib *mean = new MeanAttrib(); + Tango::UserDefaultAttrProp mean_prop; + // description not set for Mean + // label not set for Mean + // unit not set for Mean + // standard_unit not set for Mean + // display_unit not set for Mean + mean_prop.set_format("%.5f"); + mean_prop.set_max_value("9999999999"); + mean_prop.set_min_value("-9999999999"); + // max_alarm not set for Mean + // min_alarm not set for Mean + // max_warning not set for Mean + // min_warning not set for Mean + // delta_t not set for Mean + // delta_val not set for Mean + + mean->set_default_properties(mean_prop); + // Not Polled + mean->set_disp_level(Tango::OPERATOR); + // Not Memorized + att_list.push_back(mean); + + // Attribute : HorPos + HorPosAttrib *horpos = new HorPosAttrib(); + Tango::UserDefaultAttrProp horpos_prop; + // description not set for HorPos + // label not set for HorPos + // unit not set for HorPos + // standard_unit not set for HorPos + // display_unit not set for HorPos + horpos_prop.set_format("%.5f"); + horpos_prop.set_max_value("9999999999"); + horpos_prop.set_min_value("-9999999999"); + // max_alarm not set for HorPos + // min_alarm not set for HorPos + // max_warning not set for HorPos + // min_warning not set for HorPos + // delta_t not set for HorPos + // delta_val not set for HorPos + + horpos->set_default_properties(horpos_prop); + // Not Polled + horpos->set_disp_level(Tango::OPERATOR); + // Not Memorized + att_list.push_back(horpos); + + // Attribute : VerPos + VerPosAttrib *verpos = new VerPosAttrib(); + Tango::UserDefaultAttrProp verpos_prop; + // description not set for VerPos + // label not set for VerPos + // unit not set for VerPos + // standard_unit not set for VerPos + // display_unit not set for VerPos + verpos_prop.set_format("%.5f"); + verpos_prop.set_max_value("9999999999"); + verpos_prop.set_min_value("-9999999999"); + // max_alarm not set for VerPos + // min_alarm not set for VerPos + // max_warning not set for VerPos + // min_warning not set for VerPos + // delta_t not set for VerPos + // delta_val not set for VerPos + + verpos->set_default_properties(verpos_prop); + // Not Polled + verpos->set_disp_level(Tango::OPERATOR); + // Not Memorized + att_list.push_back(verpos); + + // Attribute : HorSigma + HorSigmaAttrib *horsigma = new HorSigmaAttrib(); + Tango::UserDefaultAttrProp horsigma_prop; + // description not set for HorSigma + // label not set for HorSigma + // unit not set for HorSigma + // standard_unit not set for HorSigma + // display_unit not set for HorSigma + horsigma_prop.set_format("%.5f"); + horsigma_prop.set_max_value("9999999999"); + horsigma_prop.set_min_value("-9999999999"); + // max_alarm not set for HorSigma + // min_alarm not set for HorSigma + // max_warning not set for HorSigma + // min_warning not set for HorSigma + // delta_t not set for HorSigma + // delta_val not set for HorSigma + + horsigma->set_default_properties(horsigma_prop); + // Not Polled + horsigma->set_disp_level(Tango::OPERATOR); + // Not Memorized + att_list.push_back(horsigma); + + // Attribute : VerSigma + VerSigmaAttrib *versigma = new VerSigmaAttrib(); + Tango::UserDefaultAttrProp versigma_prop; + // description not set for VerSigma + // label not set for VerSigma + // unit not set for VerSigma + // standard_unit not set for VerSigma + // display_unit not set for VerSigma + versigma_prop.set_format("%.5f"); + versigma_prop.set_max_value("9999999999"); + versigma_prop.set_min_value("-9999999999"); + // max_alarm not set for VerSigma + // min_alarm not set for VerSigma + // max_warning not set for VerSigma + // min_warning not set for VerSigma + // delta_t not set for VerSigma + // delta_val not set for VerSigma + + versigma->set_default_properties(versigma_prop); + // Not Polled + versigma->set_disp_level(Tango::OPERATOR); + // Not Memorized + att_list.push_back(versigma); + + // Attribute : ValidValues + ValidValuesAttrib *validvalues = new ValidValuesAttrib(); + Tango::UserDefaultAttrProp validvalues_prop; + // description not set for ValidValues + // label not set for ValidValues + // unit not set for ValidValues + // standard_unit not set for ValidValues + // display_unit not set for ValidValues + validvalues_prop.set_format("%d"); + validvalues_prop.set_max_value("99999999"); + validvalues_prop.set_min_value("0"); + // max_alarm not set for ValidValues + // min_alarm not set for ValidValues + // max_warning not set for ValidValues + // min_warning not set for ValidValues + // delta_t not set for ValidValues + // delta_val not set for ValidValues + + validvalues->set_default_properties(validvalues_prop); + // Not Polled + validvalues->set_disp_level(Tango::OPERATOR); + // Not Memorized + att_list.push_back(validvalues); + + // Attribute : Enable + EnableAttrib *enable = new EnableAttrib(); + Tango::UserDefaultAttrProp enable_prop; + // description not set for Enable + // label not set for Enable + // unit not set for Enable + // standard_unit not set for Enable + // display_unit not set for Enable + // format not set for Enable + // max_value not set for Enable + // min_value not set for Enable + // max_alarm not set for Enable + // min_alarm not set for Enable + // max_warning not set for Enable + // min_warning not set for Enable + // delta_t not set for Enable + // delta_val not set for Enable + + enable->set_default_properties(enable_prop); + // Not Polled + enable->set_disp_level(Tango::OPERATOR); + enable->set_memorized(); + enable->set_memorized_init(true); + att_list.push_back(enable); + + // Attribute : CacheSize + CacheSizeAttrib *cachesize = new CacheSizeAttrib(); + Tango::UserDefaultAttrProp cachesize_prop; + // description not set for CacheSize + // label not set for CacheSize + // unit not set for CacheSize + // standard_unit not set for CacheSize + // display_unit not set for CacheSize + // format not set for CacheSize + // max_value not set for CacheSize + // min_value not set for CacheSize + // max_alarm not set for CacheSize + // min_alarm not set for CacheSize + // max_warning not set for CacheSize + // min_warning not set for CacheSize + // delta_t not set for CacheSize + // delta_val not set for CacheSize + + cachesize->set_default_properties(cachesize_prop); + // Not Polled + cachesize->set_disp_level(Tango::OPERATOR); + cachesize->set_memorized(); + cachesize->set_memorized_init(true); + att_list.push_back(cachesize); + + // Attribute : AutoBackgroundSamples + AutoBackgroundSamplesAttrib *autobackgroundsamples = new AutoBackgroundSamplesAttrib(); + Tango::UserDefaultAttrProp autobackgroundsamples_prop; + autobackgroundsamples_prop.set_description("0 to disable"); + // label not set for AutoBackgroundSamples + // unit not set for AutoBackgroundSamples + // standard_unit not set for AutoBackgroundSamples + // display_unit not set for AutoBackgroundSamples + autobackgroundsamples_prop.set_format("%d"); + autobackgroundsamples_prop.set_max_value("9999"); + autobackgroundsamples_prop.set_min_value("-1"); + // max_alarm not set for AutoBackgroundSamples + // min_alarm not set for AutoBackgroundSamples + // max_warning not set for AutoBackgroundSamples + // min_warning not set for AutoBackgroundSamples + // delta_t not set for AutoBackgroundSamples + // delta_val not set for AutoBackgroundSamples + + autobackgroundsamples->set_default_properties(autobackgroundsamples_prop); + // Not Polled + autobackgroundsamples->set_disp_level(Tango::OPERATOR); + autobackgroundsamples->set_memorized(); + autobackgroundsamples->set_memorized_init(true); + att_list.push_back(autobackgroundsamples); + + // Attribute : PostAcqRoi + PostAcqRoiAttrib *postacqroi = new PostAcqRoiAttrib(); + Tango::UserDefaultAttrProp postacqroi_prop; + // description not set for PostAcqRoi + // label not set for PostAcqRoi + // unit not set for PostAcqRoi + // standard_unit not set for PostAcqRoi + // display_unit not set for PostAcqRoi + // format not set for PostAcqRoi + // max_value not set for PostAcqRoi + // min_value not set for PostAcqRoi + // max_alarm not set for PostAcqRoi + // min_alarm not set for PostAcqRoi + // max_warning not set for PostAcqRoi + // min_warning not set for PostAcqRoi + // delta_t not set for PostAcqRoi + // delta_val not set for PostAcqRoi + + postacqroi->set_default_properties(postacqroi_prop); + // Not Polled + postacqroi->set_disp_level(Tango::OPERATOR); + postacqroi->set_memorized(); + postacqroi->set_memorized_init(true); + att_list.push_back(postacqroi); + + // Attribute : ImageWidth + ImageWidthAttrib *imagewidth = new ImageWidthAttrib(); + Tango::UserDefaultAttrProp imagewidth_prop; + // description not set for ImageWidth + // label not set for ImageWidth + // unit not set for ImageWidth + // standard_unit not set for ImageWidth + // display_unit not set for ImageWidth + imagewidth_prop.set_format("%d"); + imagewidth_prop.set_max_value("9999"); + imagewidth_prop.set_min_value("0"); + // max_alarm not set for ImageWidth + // min_alarm not set for ImageWidth + // max_warning not set for ImageWidth + // min_warning not set for ImageWidth + // delta_t not set for ImageWidth + // delta_val not set for ImageWidth + + imagewidth->set_default_properties(imagewidth_prop); + // Not Polled + imagewidth->set_disp_level(Tango::OPERATOR); + imagewidth->set_memorized(); + imagewidth->set_memorized_init(true); + att_list.push_back(imagewidth); + + // Attribute : ImageHeight + ImageHeightAttrib *imageheight = new ImageHeightAttrib(); + Tango::UserDefaultAttrProp imageheight_prop; + // description not set for ImageHeight + // label not set for ImageHeight + // unit not set for ImageHeight + // standard_unit not set for ImageHeight + // display_unit not set for ImageHeight + imageheight_prop.set_format("%d"); + imageheight_prop.set_max_value("9999"); + imageheight_prop.set_min_value("0"); + // max_alarm not set for ImageHeight + // min_alarm not set for ImageHeight + // max_warning not set for ImageHeight + // min_warning not set for ImageHeight + // delta_t not set for ImageHeight + // delta_val not set for ImageHeight + + imageheight->set_default_properties(imageheight_prop); + // Not Polled + imageheight->set_disp_level(Tango::OPERATOR); + imageheight->set_memorized(); + imageheight->set_memorized_init(true); + att_list.push_back(imageheight); + + // Attribute : RoiParam + RoiParamAttrib *roiparam = new RoiParamAttrib(); + Tango::UserDefaultAttrProp roiparam_prop; + // description not set for RoiParam + // label not set for RoiParam + // unit not set for RoiParam + // standard_unit not set for RoiParam + // display_unit not set for RoiParam + // format not set for RoiParam + // max_value not set for RoiParam + // min_value not set for RoiParam + // max_alarm not set for RoiParam + // min_alarm not set for RoiParam + // max_warning not set for RoiParam + // min_warning not set for RoiParam + // delta_t not set for RoiParam + // delta_val not set for RoiParam + + roiparam->set_default_properties(roiparam_prop); + // Not Polled + roiparam->set_disp_level(Tango::OPERATOR); + // Not Memorized + att_list.push_back(roiparam); + + // Attribute : Spectrum + SpectrumAttrib *spectrum = new SpectrumAttrib(); + Tango::UserDefaultAttrProp spectrum_prop; + // description not set for Spectrum + // label not set for Spectrum + // unit not set for Spectrum + // standard_unit not set for Spectrum + // display_unit not set for Spectrum + // format not set for Spectrum + // max_value not set for Spectrum + // min_value not set for Spectrum + // max_alarm not set for Spectrum + // min_alarm not set for Spectrum + // max_warning not set for Spectrum + // min_warning not set for Spectrum + // delta_t not set for Spectrum + // delta_val not set for Spectrum + + spectrum->set_default_properties(spectrum_prop); + // Not Polled + spectrum->set_disp_level(Tango::OPERATOR); + // Not Memorized + att_list.push_back(spectrum); + + // Attribute : HorBackground + HorBackgroundAttrib *horbackground = new HorBackgroundAttrib(); + Tango::UserDefaultAttrProp horbackground_prop; + // description not set for HorBackground + // label not set for HorBackground + // unit not set for HorBackground + // standard_unit not set for HorBackground + // display_unit not set for HorBackground + // format not set for HorBackground + // max_value not set for HorBackground + // min_value not set for HorBackground + // max_alarm not set for HorBackground + // min_alarm not set for HorBackground + // max_warning not set for HorBackground + // min_warning not set for HorBackground + // delta_t not set for HorBackground + // delta_val not set for HorBackground + + horbackground->set_default_properties(horbackground_prop); + // Not Polled + horbackground->set_disp_level(Tango::OPERATOR); + // Not Memorized + att_list.push_back(horbackground); + + // Attribute : VerBackground + VerBackgroundAttrib *verbackground = new VerBackgroundAttrib(); + Tango::UserDefaultAttrProp verbackground_prop; + // description not set for VerBackground + // label not set for VerBackground + // unit not set for VerBackground + // standard_unit not set for VerBackground + // display_unit not set for VerBackground + // format not set for VerBackground + // max_value not set for VerBackground + // min_value not set for VerBackground + // max_alarm not set for VerBackground + // min_alarm not set for VerBackground + // max_warning not set for VerBackground + // min_warning not set for VerBackground + // delta_t not set for VerBackground + // delta_val not set for VerBackground + + verbackground->set_default_properties(verbackground_prop); + // Not Polled + verbackground->set_disp_level(Tango::OPERATOR); + // Not Memorized + att_list.push_back(verbackground); + + // Attribute : Image + ImageAttrib *image = new ImageAttrib(); + Tango::UserDefaultAttrProp image_prop; + // description not set for Image + // label not set for Image + // unit not set for Image + // standard_unit not set for Image + // display_unit not set for Image + // format not set for Image + // max_value not set for Image + // min_value not set for Image + // max_alarm not set for Image + // min_alarm not set for Image + // max_warning not set for Image + // min_warning not set for Image + // delta_t not set for Image + // delta_val not set for Image + + image->set_default_properties(image_prop); + // Not Polled + image->set_disp_level(Tango::OPERATOR); + // Not Memorized + att_list.push_back(image); + + + // Create a list of static attributes + create_static_attribute_list(get_class_attr()->get_attr_list()); + /*----- PROTECTED REGION ID(DataVampireClass::attribute_factory_after) ENABLED START -----*/ + /* clang-format on */ + // Add your own code + /* clang-format off */ + /*----- PROTECTED REGION END -----*/ // DataVampireClass::attribute_factory_after +} +//-------------------------------------------------------- +/** + * Method : DataVampireClass::pipe_factory() + * Description : Create the pipe object(s) + * and store them in the pipe list + */ +//-------------------------------------------------------- +void DataVampireClass::pipe_factory() +{ + /*----- PROTECTED REGION ID(DataVampireClass::pipe_factory_before) ENABLED START -----*/ + /* clang-format on */ + // Add your own code + /* clang-format off */ + /*----- PROTECTED REGION END -----*/ // DataVampireClass::pipe_factory_before + /*----- PROTECTED REGION ID(DataVampireClass::pipe_factory_after) ENABLED START -----*/ + /* clang-format on */ + // Add your own code + /* clang-format off */ + /*----- PROTECTED REGION END -----*/ // DataVampireClass::pipe_factory_after +} +//-------------------------------------------------------- +/** + * Method : DataVampireClass::command_factory() + * Description : Create the command object(s) + * and store them in the command list + */ +//-------------------------------------------------------- +void DataVampireClass::command_factory() +{ + /*----- PROTECTED REGION ID(DataVampireClass::command_factory_before) ENABLED START -----*/ + /* clang-format on */ + // Add your own code + /* clang-format off */ + /*----- PROTECTED REGION END -----*/ // DataVampireClass::command_factory_before + + + // Command GetSum + GetSumClass *pGetSumCmd = + new GetSumClass("GetSum", + Tango::DEVVAR_LONGARRAY, Tango::DEVVAR_DOUBLEARRAY, + "mode,samples; mode,bunch start,bunch end", + "values", + Tango::OPERATOR); + command_list.push_back(pGetSumCmd); + + // Command GetMean + GetMeanClass *pGetMeanCmd = + new GetMeanClass("GetMean", + Tango::DEVVAR_LONGARRAY, Tango::DEVVAR_DOUBLEARRAY, + "mode,samples; mode,bunch start,bunch end", + "values", + Tango::OPERATOR); + command_list.push_back(pGetMeanCmd); + + // Command GetHorPos + GetHorPosClass *pGetHorPosCmd = + new GetHorPosClass("GetHorPos", + Tango::DEVVAR_LONGARRAY, Tango::DEVVAR_DOUBLEARRAY, + "mode,samples; mode,bunch start,bunch end", + "values", + Tango::OPERATOR); + command_list.push_back(pGetHorPosCmd); + + // Command GetVerPos + GetVerPosClass *pGetVerPosCmd = + new GetVerPosClass("GetVerPos", + Tango::DEVVAR_LONGARRAY, Tango::DEVVAR_DOUBLEARRAY, + "mode,samples; mode,bunch start,bunch end", + "values", + Tango::OPERATOR); + command_list.push_back(pGetVerPosCmd); + + // Command GetHorSigma + GetHorSigmaClass *pGetHorSigmaCmd = + new GetHorSigmaClass("GetHorSigma", + Tango::DEVVAR_LONGARRAY, Tango::DEVVAR_DOUBLEARRAY, + "mode,samples; mode,bunch start,bunch end", + "values", + Tango::OPERATOR); + command_list.push_back(pGetHorSigmaCmd); + + // Command GetVerSigma + GetVerSigmaClass *pGetVerSigmaCmd = + new GetVerSigmaClass("GetVerSigma", + Tango::DEVVAR_LONGARRAY, Tango::DEVVAR_DOUBLEARRAY, + "mode,samples; mode,bunch start,bunch end", + "values", + Tango::OPERATOR); + command_list.push_back(pGetVerSigmaCmd); + + // Command GetValidValues + GetValidValuesClass *pGetValidValuesCmd = + new GetValidValuesClass("GetValidValues", + Tango::DEVVAR_LONGARRAY, Tango::DEVVAR_DOUBLEARRAY, + "mode,samples; mode,bunch start,bunch end", + "values", + Tango::OPERATOR); + command_list.push_back(pGetValidValuesCmd); + + // Command SetBackground + SetBackgroundClass *pSetBackgroundCmd = + new SetBackgroundClass("SetBackground", + Tango::DEV_VOID, Tango::DEV_VOID, + "", + "", + Tango::OPERATOR); + command_list.push_back(pSetBackgroundCmd); + + /*----- PROTECTED REGION ID(DataVampireClass::command_factory_after) ENABLED START -----*/ + /* clang-format on */ + // Add your own code + /* clang-format off */ + /*----- PROTECTED REGION END -----*/ // DataVampireClass::command_factory_after +} + +//=================================================================== +// Dynamic attributes related methods +//=================================================================== + +//-------------------------------------------------------- +/** + * method : DataVampireClass::create_static_attribute_list + * description : Create the a list of static attributes + * + * @param att_list the ceated attribute list + */ +//-------------------------------------------------------- +void DataVampireClass::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(DataVampireClass::create_static_att_list) ENABLED START -----*/ + /* clang-format on */ + /* clang-format off */ + /*----- PROTECTED REGION END -----*/ // DataVampireClass::create_static_att_list +} + + +//-------------------------------------------------------- +/** + * method : DataVampireClass::erase_dynamic_attributes + * description : delete the dynamic attributes if any. + * + * @param devlist_ptr the device list pointer + * @param list of all attributes + */ +//-------------------------------------------------------- +void DataVampireClass::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()); + DataVampire *dev = static_cast<DataVampire *> (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(DataVampireClass::erase_dynamic_attributes) ENABLED START -----*/ + /* clang-format on */ + /* clang-format off */ + /*----- PROTECTED REGION END -----*/ // DataVampireClass::erase_dynamic_attributes +} + +//-------------------------------------------------------- +/** + * Method : DataVampireClass::get_attr_object_by_name() + * Description : returns Tango::Attr * object found by name + */ +//-------------------------------------------------------- +Tango::Attr *DataVampireClass::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(DataVampireClass::Additional Methods) ENABLED START -----*/ +/* clang-format on */ +/* clang-format off */ +/*----- PROTECTED REGION END -----*/ // DataVampireClass::Additional Methods +} // namespace diff --git a/src/DataVampireClass.h b/src/DataVampireClass.h new file mode 100644 index 0000000..1691c73 --- /dev/null +++ b/src/DataVampireClass.h @@ -0,0 +1,622 @@ +/*----- PROTECTED REGION ID(DataVampireClass.h) ENABLED START -----*/ +/* clang-format on */ +//============================================================================= +// +// file : DataVampireClass.h +// +// description : Include for the DataVampire root class. +// This class is the singleton class for +// the DataVampire device class. +// It contains all properties and methods which the +// DataVampire requires only once e.g. the commands. +// +// project : DataVampire +// +// 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 DataVampireClass_H +#define DataVampireClass_H + +#include <tango/tango.h> +#include "DataVampire.h" + +/* clang-format off */ +/*----- PROTECTED REGION END -----*/ // DataVampireClass.h + + +namespace DataVampire_ns +{ +/*----- PROTECTED REGION ID(DataVampireClass::classes for dynamic creation) ENABLED START -----*/ +/* clang-format on */ + +/* clang-format off */ +/*----- PROTECTED REGION END -----*/ // DataVampireClass::classes for dynamic creation + +//========================================= +// Define classes for attributes +//========================================= +// Attribute MinThreshold class definition +class MinThresholdAttrib: public Tango::Attr +{ +public: + MinThresholdAttrib():Attr("MinThreshold", + Tango::DEV_DOUBLE, Tango::READ_WRITE) {}; + ~MinThresholdAttrib() {}; + virtual void read(Tango::DeviceImpl *dev,Tango::Attribute &att) + {(static_cast<DataVampire *>(dev))->read_MinThreshold(att);} + virtual void write(Tango::DeviceImpl *dev,Tango::WAttribute &att) + {(static_cast<DataVampire *>(dev))->write_MinThreshold(att);} + virtual bool is_allowed(Tango::DeviceImpl *dev,Tango::AttReqType ty) + {return (static_cast<DataVampire *>(dev))->is_MinThreshold_allowed(ty);} +}; + +// Attribute MaxThreshold class definition +class MaxThresholdAttrib: public Tango::Attr +{ +public: + MaxThresholdAttrib():Attr("MaxThreshold", + Tango::DEV_DOUBLE, Tango::READ_WRITE) {}; + ~MaxThresholdAttrib() {}; + virtual void read(Tango::DeviceImpl *dev,Tango::Attribute &att) + {(static_cast<DataVampire *>(dev))->read_MaxThreshold(att);} + virtual void write(Tango::DeviceImpl *dev,Tango::WAttribute &att) + {(static_cast<DataVampire *>(dev))->write_MaxThreshold(att);} + virtual bool is_allowed(Tango::DeviceImpl *dev,Tango::AttReqType ty) + {return (static_cast<DataVampire *>(dev))->is_MaxThreshold_allowed(ty);} +}; + +// Attribute CommandString class definition +class CommandStringAttrib: public Tango::Attr +{ +public: + CommandStringAttrib():Attr("CommandString", + Tango::DEV_STRING, Tango::READ_WRITE) {}; + ~CommandStringAttrib() {}; + virtual void read(Tango::DeviceImpl *dev,Tango::Attribute &att) + {(static_cast<DataVampire *>(dev))->read_CommandString(att);} + virtual void write(Tango::DeviceImpl *dev,Tango::WAttribute &att) + {(static_cast<DataVampire *>(dev))->write_CommandString(att);} + virtual bool is_allowed(Tango::DeviceImpl *dev,Tango::AttReqType ty) + {return (static_cast<DataVampire *>(dev))->is_CommandString_allowed(ty);} +}; + +// Attribute PollingTime class definition +class PollingTimeAttrib: public Tango::Attr +{ +public: + PollingTimeAttrib():Attr("PollingTime", + Tango::DEV_LONG, Tango::READ_WRITE) {}; + ~PollingTimeAttrib() {}; + virtual void read(Tango::DeviceImpl *dev,Tango::Attribute &att) + {(static_cast<DataVampire *>(dev))->read_PollingTime(att);} + virtual void write(Tango::DeviceImpl *dev,Tango::WAttribute &att) + {(static_cast<DataVampire *>(dev))->write_PollingTime(att);} + virtual bool is_allowed(Tango::DeviceImpl *dev,Tango::AttReqType ty) + {return (static_cast<DataVampire *>(dev))->is_PollingTime_allowed(ty);} +}; + +// Attribute PollingSamples class definition +class PollingSamplesAttrib: public Tango::Attr +{ +public: + PollingSamplesAttrib():Attr("PollingSamples", + Tango::DEV_LONG, Tango::READ_WRITE) {}; + ~PollingSamplesAttrib() {}; + virtual void read(Tango::DeviceImpl *dev,Tango::Attribute &att) + {(static_cast<DataVampire *>(dev))->read_PollingSamples(att);} + virtual void write(Tango::DeviceImpl *dev,Tango::WAttribute &att) + {(static_cast<DataVampire *>(dev))->write_PollingSamples(att);} + virtual bool is_allowed(Tango::DeviceImpl *dev,Tango::AttReqType ty) + {return (static_cast<DataVampire *>(dev))->is_PollingSamples_allowed(ty);} +}; + +// Attribute Sum class definition +class SumAttrib: public Tango::Attr +{ +public: + SumAttrib():Attr("Sum", + Tango::DEV_DOUBLE, Tango::READ) {}; + ~SumAttrib() {}; + virtual void read(Tango::DeviceImpl *dev,Tango::Attribute &att) + {(static_cast<DataVampire *>(dev))->read_Sum(att);} + virtual bool is_allowed(Tango::DeviceImpl *dev,Tango::AttReqType ty) + {return (static_cast<DataVampire *>(dev))->is_Sum_allowed(ty);} +}; + +// Attribute Mean class definition +class MeanAttrib: public Tango::Attr +{ +public: + MeanAttrib():Attr("Mean", + Tango::DEV_DOUBLE, Tango::READ) {}; + ~MeanAttrib() {}; + virtual void read(Tango::DeviceImpl *dev,Tango::Attribute &att) + {(static_cast<DataVampire *>(dev))->read_Mean(att);} + virtual bool is_allowed(Tango::DeviceImpl *dev,Tango::AttReqType ty) + {return (static_cast<DataVampire *>(dev))->is_Mean_allowed(ty);} +}; + +// Attribute HorPos class definition +class HorPosAttrib: public Tango::Attr +{ +public: + HorPosAttrib():Attr("HorPos", + Tango::DEV_DOUBLE, Tango::READ) {}; + ~HorPosAttrib() {}; + virtual void read(Tango::DeviceImpl *dev,Tango::Attribute &att) + {(static_cast<DataVampire *>(dev))->read_HorPos(att);} + virtual bool is_allowed(Tango::DeviceImpl *dev,Tango::AttReqType ty) + {return (static_cast<DataVampire *>(dev))->is_HorPos_allowed(ty);} +}; + +// Attribute VerPos class definition +class VerPosAttrib: public Tango::Attr +{ +public: + VerPosAttrib():Attr("VerPos", + Tango::DEV_DOUBLE, Tango::READ) {}; + ~VerPosAttrib() {}; + virtual void read(Tango::DeviceImpl *dev,Tango::Attribute &att) + {(static_cast<DataVampire *>(dev))->read_VerPos(att);} + virtual bool is_allowed(Tango::DeviceImpl *dev,Tango::AttReqType ty) + {return (static_cast<DataVampire *>(dev))->is_VerPos_allowed(ty);} +}; + +// Attribute HorSigma class definition +class HorSigmaAttrib: public Tango::Attr +{ +public: + HorSigmaAttrib():Attr("HorSigma", + Tango::DEV_DOUBLE, Tango::READ) {}; + ~HorSigmaAttrib() {}; + virtual void read(Tango::DeviceImpl *dev,Tango::Attribute &att) + {(static_cast<DataVampire *>(dev))->read_HorSigma(att);} + virtual bool is_allowed(Tango::DeviceImpl *dev,Tango::AttReqType ty) + {return (static_cast<DataVampire *>(dev))->is_HorSigma_allowed(ty);} +}; + +// Attribute VerSigma class definition +class VerSigmaAttrib: public Tango::Attr +{ +public: + VerSigmaAttrib():Attr("VerSigma", + Tango::DEV_DOUBLE, Tango::READ) {}; + ~VerSigmaAttrib() {}; + virtual void read(Tango::DeviceImpl *dev,Tango::Attribute &att) + {(static_cast<DataVampire *>(dev))->read_VerSigma(att);} + virtual bool is_allowed(Tango::DeviceImpl *dev,Tango::AttReqType ty) + {return (static_cast<DataVampire *>(dev))->is_VerSigma_allowed(ty);} +}; + +// Attribute ValidValues class definition +class ValidValuesAttrib: public Tango::Attr +{ +public: + ValidValuesAttrib():Attr("ValidValues", + Tango::DEV_LONG, Tango::READ) {}; + ~ValidValuesAttrib() {}; + virtual void read(Tango::DeviceImpl *dev,Tango::Attribute &att) + {(static_cast<DataVampire *>(dev))->read_ValidValues(att);} + virtual bool is_allowed(Tango::DeviceImpl *dev,Tango::AttReqType ty) + {return (static_cast<DataVampire *>(dev))->is_ValidValues_allowed(ty);} +}; + +// Attribute Enable class definition +class EnableAttrib: public Tango::Attr +{ +public: + EnableAttrib():Attr("Enable", + Tango::DEV_BOOLEAN, Tango::READ_WRITE) {}; + ~EnableAttrib() {}; + virtual void read(Tango::DeviceImpl *dev,Tango::Attribute &att) + {(static_cast<DataVampire *>(dev))->read_Enable(att);} + virtual void write(Tango::DeviceImpl *dev,Tango::WAttribute &att) + {(static_cast<DataVampire *>(dev))->write_Enable(att);} + virtual bool is_allowed(Tango::DeviceImpl *dev,Tango::AttReqType ty) + {return (static_cast<DataVampire *>(dev))->is_Enable_allowed(ty);} +}; + +// Attribute CacheSize class definition +class CacheSizeAttrib: public Tango::Attr +{ +public: + CacheSizeAttrib():Attr("CacheSize", + Tango::DEV_LONG, Tango::READ_WRITE) {}; + ~CacheSizeAttrib() {}; + virtual void read(Tango::DeviceImpl *dev,Tango::Attribute &att) + {(static_cast<DataVampire *>(dev))->read_CacheSize(att);} + virtual void write(Tango::DeviceImpl *dev,Tango::WAttribute &att) + {(static_cast<DataVampire *>(dev))->write_CacheSize(att);} + virtual bool is_allowed(Tango::DeviceImpl *dev,Tango::AttReqType ty) + {return (static_cast<DataVampire *>(dev))->is_CacheSize_allowed(ty);} +}; + +// Attribute AutoBackgroundSamples class definition +class AutoBackgroundSamplesAttrib: public Tango::Attr +{ +public: + AutoBackgroundSamplesAttrib():Attr("AutoBackgroundSamples", + Tango::DEV_LONG, Tango::READ_WRITE) {}; + ~AutoBackgroundSamplesAttrib() {}; + virtual void read(Tango::DeviceImpl *dev,Tango::Attribute &att) + {(static_cast<DataVampire *>(dev))->read_AutoBackgroundSamples(att);} + virtual void write(Tango::DeviceImpl *dev,Tango::WAttribute &att) + {(static_cast<DataVampire *>(dev))->write_AutoBackgroundSamples(att);} + virtual bool is_allowed(Tango::DeviceImpl *dev,Tango::AttReqType ty) + {return (static_cast<DataVampire *>(dev))->is_AutoBackgroundSamples_allowed(ty);} +}; + +// Attribute PostAcqRoi class definition +class PostAcqRoiAttrib: public Tango::Attr +{ +public: + PostAcqRoiAttrib():Attr("PostAcqRoi", + Tango::DEV_BOOLEAN, Tango::READ_WRITE) {}; + ~PostAcqRoiAttrib() {}; + virtual void read(Tango::DeviceImpl *dev,Tango::Attribute &att) + {(static_cast<DataVampire *>(dev))->read_PostAcqRoi(att);} + virtual void write(Tango::DeviceImpl *dev,Tango::WAttribute &att) + {(static_cast<DataVampire *>(dev))->write_PostAcqRoi(att);} + virtual bool is_allowed(Tango::DeviceImpl *dev,Tango::AttReqType ty) + {return (static_cast<DataVampire *>(dev))->is_PostAcqRoi_allowed(ty);} +}; + +// Attribute ImageWidth class definition +class ImageWidthAttrib: public Tango::Attr +{ +public: + ImageWidthAttrib():Attr("ImageWidth", + Tango::DEV_LONG, Tango::READ_WRITE) {}; + ~ImageWidthAttrib() {}; + virtual void read(Tango::DeviceImpl *dev,Tango::Attribute &att) + {(static_cast<DataVampire *>(dev))->read_ImageWidth(att);} + virtual void write(Tango::DeviceImpl *dev,Tango::WAttribute &att) + {(static_cast<DataVampire *>(dev))->write_ImageWidth(att);} + virtual bool is_allowed(Tango::DeviceImpl *dev,Tango::AttReqType ty) + {return (static_cast<DataVampire *>(dev))->is_ImageWidth_allowed(ty);} +}; + +// Attribute ImageHeight class definition +class ImageHeightAttrib: public Tango::Attr +{ +public: + ImageHeightAttrib():Attr("ImageHeight", + Tango::DEV_LONG, Tango::READ_WRITE) {}; + ~ImageHeightAttrib() {}; + virtual void read(Tango::DeviceImpl *dev,Tango::Attribute &att) + {(static_cast<DataVampire *>(dev))->read_ImageHeight(att);} + virtual void write(Tango::DeviceImpl *dev,Tango::WAttribute &att) + {(static_cast<DataVampire *>(dev))->write_ImageHeight(att);} + virtual bool is_allowed(Tango::DeviceImpl *dev,Tango::AttReqType ty) + {return (static_cast<DataVampire *>(dev))->is_ImageHeight_allowed(ty);} +}; + +// Attribute RoiParam class definition +class RoiParamAttrib: public Tango::SpectrumAttr +{ +public: + RoiParamAttrib():SpectrumAttr("RoiParam", + Tango::DEV_LONG, Tango::READ_WRITE, 4) {}; + ~RoiParamAttrib() {}; + virtual void read(Tango::DeviceImpl *dev,Tango::Attribute &att) + {(static_cast<DataVampire *>(dev))->read_RoiParam(att);} + virtual void write(Tango::DeviceImpl *dev,Tango::WAttribute &att) + {(static_cast<DataVampire *>(dev))->write_RoiParam(att);} + virtual bool is_allowed(Tango::DeviceImpl *dev,Tango::AttReqType ty) + {return (static_cast<DataVampire *>(dev))->is_RoiParam_allowed(ty);} +}; + +// Attribute Spectrum class definition +class SpectrumAttrib: public Tango::SpectrumAttr +{ +public: + SpectrumAttrib():SpectrumAttr("Spectrum", + Tango::DEV_DOUBLE, Tango::READ, 1000000) {}; + ~SpectrumAttrib() {}; + virtual void read(Tango::DeviceImpl *dev,Tango::Attribute &att) + {(static_cast<DataVampire *>(dev))->read_Spectrum(att);} + virtual bool is_allowed(Tango::DeviceImpl *dev,Tango::AttReqType ty) + {return (static_cast<DataVampire *>(dev))->is_Spectrum_allowed(ty);} +}; + +// Attribute HorBackground class definition +class HorBackgroundAttrib: public Tango::SpectrumAttr +{ +public: + HorBackgroundAttrib():SpectrumAttr("HorBackground", + Tango::DEV_DOUBLE, Tango::READ, 1000000) {}; + ~HorBackgroundAttrib() {}; + virtual void read(Tango::DeviceImpl *dev,Tango::Attribute &att) + {(static_cast<DataVampire *>(dev))->read_HorBackground(att);} + virtual bool is_allowed(Tango::DeviceImpl *dev,Tango::AttReqType ty) + {return (static_cast<DataVampire *>(dev))->is_HorBackground_allowed(ty);} +}; + +// Attribute VerBackground class definition +class VerBackgroundAttrib: public Tango::SpectrumAttr +{ +public: + VerBackgroundAttrib():SpectrumAttr("VerBackground", + Tango::DEV_DOUBLE, Tango::READ, 1000000) {}; + ~VerBackgroundAttrib() {}; + virtual void read(Tango::DeviceImpl *dev,Tango::Attribute &att) + {(static_cast<DataVampire *>(dev))->read_VerBackground(att);} + virtual bool is_allowed(Tango::DeviceImpl *dev,Tango::AttReqType ty) + {return (static_cast<DataVampire *>(dev))->is_VerBackground_allowed(ty);} +}; + +// Attribute Image class definition +class ImageAttrib: public Tango::ImageAttr +{ +public: + ImageAttrib():ImageAttr("Image", + Tango::DEV_DOUBLE, Tango::READ, 5000, 5000) {}; + ~ImageAttrib() {}; + virtual void read(Tango::DeviceImpl *dev,Tango::Attribute &att) + {(static_cast<DataVampire *>(dev))->read_Image(att);} + virtual bool is_allowed(Tango::DeviceImpl *dev,Tango::AttReqType ty) + {return (static_cast<DataVampire *>(dev))->is_Image_allowed(ty);} +}; + + +//========================================= +// Define classes for commands +//========================================= +// Command GetSum class definition +class GetSumClass : public Tango::Command +{ +public: + GetSumClass(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) {}; + + GetSumClass(const char *name, + Tango::CmdArgType in, + Tango::CmdArgType out) + :Command(name,in,out) {}; + ~GetSumClass() {}; + + 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<DataVampire *>(dev))->is_GetSum_allowed(any);} +}; + +// Command GetMean class definition +class GetMeanClass : public Tango::Command +{ +public: + GetMeanClass(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) {}; + + GetMeanClass(const char *name, + Tango::CmdArgType in, + Tango::CmdArgType out) + :Command(name,in,out) {}; + ~GetMeanClass() {}; + + 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<DataVampire *>(dev))->is_GetMean_allowed(any);} +}; + +// Command GetHorPos class definition +class GetHorPosClass : public Tango::Command +{ +public: + GetHorPosClass(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) {}; + + GetHorPosClass(const char *name, + Tango::CmdArgType in, + Tango::CmdArgType out) + :Command(name,in,out) {}; + ~GetHorPosClass() {}; + + 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<DataVampire *>(dev))->is_GetHorPos_allowed(any);} +}; + +// Command GetVerPos class definition +class GetVerPosClass : public Tango::Command +{ +public: + GetVerPosClass(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) {}; + + GetVerPosClass(const char *name, + Tango::CmdArgType in, + Tango::CmdArgType out) + :Command(name,in,out) {}; + ~GetVerPosClass() {}; + + 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<DataVampire *>(dev))->is_GetVerPos_allowed(any);} +}; + +// Command GetHorSigma class definition +class GetHorSigmaClass : public Tango::Command +{ +public: + GetHorSigmaClass(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) {}; + + GetHorSigmaClass(const char *name, + Tango::CmdArgType in, + Tango::CmdArgType out) + :Command(name,in,out) {}; + ~GetHorSigmaClass() {}; + + 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<DataVampire *>(dev))->is_GetHorSigma_allowed(any);} +}; + +// Command GetVerSigma class definition +class GetVerSigmaClass : public Tango::Command +{ +public: + GetVerSigmaClass(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) {}; + + GetVerSigmaClass(const char *name, + Tango::CmdArgType in, + Tango::CmdArgType out) + :Command(name,in,out) {}; + ~GetVerSigmaClass() {}; + + 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<DataVampire *>(dev))->is_GetVerSigma_allowed(any);} +}; + +// Command GetValidValues class definition +class GetValidValuesClass : public Tango::Command +{ +public: + GetValidValuesClass(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) {}; + + GetValidValuesClass(const char *name, + Tango::CmdArgType in, + Tango::CmdArgType out) + :Command(name,in,out) {}; + ~GetValidValuesClass() {}; + + 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<DataVampire *>(dev))->is_GetValidValues_allowed(any);} +}; + +// Command SetBackground class definition +class SetBackgroundClass : public Tango::Command +{ +public: + SetBackgroundClass(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) {}; + + SetBackgroundClass(const char *name, + Tango::CmdArgType in, + Tango::CmdArgType out) + :Command(name,in,out) {}; + ~SetBackgroundClass() {}; + + 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<DataVampire *>(dev))->is_SetBackground_allowed(any);} +}; + + +/** + * The DataVampireClass singleton definition + */ + +#ifdef _TG_WINDOWS_ +class __declspec(dllexport) DataVampireClass : public Tango::DeviceClass +#else +class DataVampireClass : public Tango::DeviceClass +#endif +{ + /*----- PROTECTED REGION ID(DataVampireClass::Additionnal DServer data members) ENABLED START -----*/ + + + /*----- PROTECTED REGION END -----*/ // DataVampireClass::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 DataVampireClass *init(const char *); + static DataVampireClass *instance(); + ~DataVampireClass(); + Tango::DbDatum get_class_property(string &); + Tango::DbDatum get_default_device_property(string &); + Tango::DbDatum get_default_class_property(string &); + + protected: + DataVampireClass(string &); + static DataVampireClass *_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 // DataVampire_H diff --git a/src/DataVampireStateMachine.cpp b/src/DataVampireStateMachine.cpp new file mode 100644 index 0000000..2edcc8b --- /dev/null +++ b/src/DataVampireStateMachine.cpp @@ -0,0 +1,640 @@ +/*----- PROTECTED REGION ID(DataVampireStateMachine.cpp) ENABLED START -----*/ +/* clang-format on */ +//============================================================================= +// +// file : DataVampireStateMachine.cpp +// +// description : State machine file for the DataVampire class +// +// project : DataVampire +// +// 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 "DataVampire.h" + +/* clang-format off */ +/*----- PROTECTED REGION END -----*/ // DataVampire::DataVampireStateMachine.cpp + +//================================================================ +// States | Description +//================================================================ +// ON | +// FAULT | + + +namespace DataVampire_ns +{ +//================================================= +// Attributes Allowed Methods +//================================================= + +//-------------------------------------------------------- +/** + * Method : DataVampire::is_MinThreshold_allowed() + * Description : Execution allowed for MinThreshold attribute + */ +//-------------------------------------------------------- +bool DataVampire::is_MinThreshold_allowed(TANGO_UNUSED(Tango::AttReqType type)) +{ + // Not any excluded states for MinThreshold attribute in Write access. + /*----- PROTECTED REGION ID(DataVampire::MinThresholdStateAllowed_WRITE) ENABLED START -----*/ + /* clang-format on */ + /* clang-format off */ + /*----- PROTECTED REGION END -----*/ // DataVampire::MinThresholdStateAllowed_WRITE + + // Not any excluded states for MinThreshold attribute in read access. + /*----- PROTECTED REGION ID(DataVampire::MinThresholdStateAllowed_READ) ENABLED START -----*/ + /* clang-format on */ + /* clang-format off */ + /*----- PROTECTED REGION END -----*/ // DataVampire::MinThresholdStateAllowed_READ + return true; +} + +//-------------------------------------------------------- +/** + * Method : DataVampire::is_MaxThreshold_allowed() + * Description : Execution allowed for MaxThreshold attribute + */ +//-------------------------------------------------------- +bool DataVampire::is_MaxThreshold_allowed(TANGO_UNUSED(Tango::AttReqType type)) +{ + // Not any excluded states for MaxThreshold attribute in Write access. + /*----- PROTECTED REGION ID(DataVampire::MaxThresholdStateAllowed_WRITE) ENABLED START -----*/ + /* clang-format on */ + /* clang-format off */ + /*----- PROTECTED REGION END -----*/ // DataVampire::MaxThresholdStateAllowed_WRITE + + // Not any excluded states for MaxThreshold attribute in read access. + /*----- PROTECTED REGION ID(DataVampire::MaxThresholdStateAllowed_READ) ENABLED START -----*/ + /* clang-format on */ + /* clang-format off */ + /*----- PROTECTED REGION END -----*/ // DataVampire::MaxThresholdStateAllowed_READ + return true; +} + +//-------------------------------------------------------- +/** + * Method : DataVampire::is_CommandString_allowed() + * Description : Execution allowed for CommandString attribute + */ +//-------------------------------------------------------- +bool DataVampire::is_CommandString_allowed(TANGO_UNUSED(Tango::AttReqType type)) +{ + // Not any excluded states for CommandString attribute in Write access. + /*----- PROTECTED REGION ID(DataVampire::CommandStringStateAllowed_WRITE) ENABLED START -----*/ + /* clang-format on */ + /* clang-format off */ + /*----- PROTECTED REGION END -----*/ // DataVampire::CommandStringStateAllowed_WRITE + + // Not any excluded states for CommandString attribute in read access. + /*----- PROTECTED REGION ID(DataVampire::CommandStringStateAllowed_READ) ENABLED START -----*/ + /* clang-format on */ + /* clang-format off */ + /*----- PROTECTED REGION END -----*/ // DataVampire::CommandStringStateAllowed_READ + return true; +} + +//-------------------------------------------------------- +/** + * Method : DataVampire::is_PollingTime_allowed() + * Description : Execution allowed for PollingTime attribute + */ +//-------------------------------------------------------- +bool DataVampire::is_PollingTime_allowed(TANGO_UNUSED(Tango::AttReqType type)) +{ + // Not any excluded states for PollingTime attribute in Write access. + /*----- PROTECTED REGION ID(DataVampire::PollingTimeStateAllowed_WRITE) ENABLED START -----*/ + /* clang-format on */ + /* clang-format off */ + /*----- PROTECTED REGION END -----*/ // DataVampire::PollingTimeStateAllowed_WRITE + + // Not any excluded states for PollingTime attribute in read access. + /*----- PROTECTED REGION ID(DataVampire::PollingTimeStateAllowed_READ) ENABLED START -----*/ + /* clang-format on */ + /* clang-format off */ + /*----- PROTECTED REGION END -----*/ // DataVampire::PollingTimeStateAllowed_READ + return true; +} + +//-------------------------------------------------------- +/** + * Method : DataVampire::is_PollingSamples_allowed() + * Description : Execution allowed for PollingSamples attribute + */ +//-------------------------------------------------------- +bool DataVampire::is_PollingSamples_allowed(TANGO_UNUSED(Tango::AttReqType type)) +{ + // Not any excluded states for PollingSamples attribute in Write access. + /*----- PROTECTED REGION ID(DataVampire::PollingSamplesStateAllowed_WRITE) ENABLED START -----*/ + /* clang-format on */ + /* clang-format off */ + /*----- PROTECTED REGION END -----*/ // DataVampire::PollingSamplesStateAllowed_WRITE + + // Not any excluded states for PollingSamples attribute in read access. + /*----- PROTECTED REGION ID(DataVampire::PollingSamplesStateAllowed_READ) ENABLED START -----*/ + /* clang-format on */ + /* clang-format off */ + /*----- PROTECTED REGION END -----*/ // DataVampire::PollingSamplesStateAllowed_READ + return true; +} + +//-------------------------------------------------------- +/** + * Method : DataVampire::is_Sum_allowed() + * Description : Execution allowed for Sum attribute + */ +//-------------------------------------------------------- +bool DataVampire::is_Sum_allowed(TANGO_UNUSED(Tango::AttReqType type)) +{ + + // Not any excluded states for Sum attribute in read access. + /*----- PROTECTED REGION ID(DataVampire::SumStateAllowed_READ) ENABLED START -----*/ + /* clang-format on */ + /* clang-format off */ + /*----- PROTECTED REGION END -----*/ // DataVampire::SumStateAllowed_READ + return true; +} + +//-------------------------------------------------------- +/** + * Method : DataVampire::is_Mean_allowed() + * Description : Execution allowed for Mean attribute + */ +//-------------------------------------------------------- +bool DataVampire::is_Mean_allowed(TANGO_UNUSED(Tango::AttReqType type)) +{ + + // Not any excluded states for Mean attribute in read access. + /*----- PROTECTED REGION ID(DataVampire::MeanStateAllowed_READ) ENABLED START -----*/ + /* clang-format on */ + /* clang-format off */ + /*----- PROTECTED REGION END -----*/ // DataVampire::MeanStateAllowed_READ + return true; +} + +//-------------------------------------------------------- +/** + * Method : DataVampire::is_HorPos_allowed() + * Description : Execution allowed for HorPos attribute + */ +//-------------------------------------------------------- +bool DataVampire::is_HorPos_allowed(TANGO_UNUSED(Tango::AttReqType type)) +{ + + // Not any excluded states for HorPos attribute in read access. + /*----- PROTECTED REGION ID(DataVampire::HorPosStateAllowed_READ) ENABLED START -----*/ + /* clang-format on */ + /* clang-format off */ + /*----- PROTECTED REGION END -----*/ // DataVampire::HorPosStateAllowed_READ + return true; +} + +//-------------------------------------------------------- +/** + * Method : DataVampire::is_VerPos_allowed() + * Description : Execution allowed for VerPos attribute + */ +//-------------------------------------------------------- +bool DataVampire::is_VerPos_allowed(TANGO_UNUSED(Tango::AttReqType type)) +{ + + // Not any excluded states for VerPos attribute in read access. + /*----- PROTECTED REGION ID(DataVampire::VerPosStateAllowed_READ) ENABLED START -----*/ + /* clang-format on */ + /* clang-format off */ + /*----- PROTECTED REGION END -----*/ // DataVampire::VerPosStateAllowed_READ + return true; +} + +//-------------------------------------------------------- +/** + * Method : DataVampire::is_HorSigma_allowed() + * Description : Execution allowed for HorSigma attribute + */ +//-------------------------------------------------------- +bool DataVampire::is_HorSigma_allowed(TANGO_UNUSED(Tango::AttReqType type)) +{ + + // Not any excluded states for HorSigma attribute in read access. + /*----- PROTECTED REGION ID(DataVampire::HorSigmaStateAllowed_READ) ENABLED START -----*/ + /* clang-format on */ + /* clang-format off */ + /*----- PROTECTED REGION END -----*/ // DataVampire::HorSigmaStateAllowed_READ + return true; +} + +//-------------------------------------------------------- +/** + * Method : DataVampire::is_VerSigma_allowed() + * Description : Execution allowed for VerSigma attribute + */ +//-------------------------------------------------------- +bool DataVampire::is_VerSigma_allowed(TANGO_UNUSED(Tango::AttReqType type)) +{ + + // Not any excluded states for VerSigma attribute in read access. + /*----- PROTECTED REGION ID(DataVampire::VerSigmaStateAllowed_READ) ENABLED START -----*/ + /* clang-format on */ + /* clang-format off */ + /*----- PROTECTED REGION END -----*/ // DataVampire::VerSigmaStateAllowed_READ + return true; +} + +//-------------------------------------------------------- +/** + * Method : DataVampire::is_ValidValues_allowed() + * Description : Execution allowed for ValidValues attribute + */ +//-------------------------------------------------------- +bool DataVampire::is_ValidValues_allowed(TANGO_UNUSED(Tango::AttReqType type)) +{ + + // Not any excluded states for ValidValues attribute in read access. + /*----- PROTECTED REGION ID(DataVampire::ValidValuesStateAllowed_READ) ENABLED START -----*/ + /* clang-format on */ + /* clang-format off */ + /*----- PROTECTED REGION END -----*/ // DataVampire::ValidValuesStateAllowed_READ + return true; +} + +//-------------------------------------------------------- +/** + * Method : DataVampire::is_Enable_allowed() + * Description : Execution allowed for Enable attribute + */ +//-------------------------------------------------------- +bool DataVampire::is_Enable_allowed(TANGO_UNUSED(Tango::AttReqType type)) +{ + // Not any excluded states for Enable attribute in Write access. + /*----- PROTECTED REGION ID(DataVampire::EnableStateAllowed_WRITE) ENABLED START -----*/ + /* clang-format on */ + /* clang-format off */ + /*----- PROTECTED REGION END -----*/ // DataVampire::EnableStateAllowed_WRITE + + // Not any excluded states for Enable attribute in read access. + /*----- PROTECTED REGION ID(DataVampire::EnableStateAllowed_READ) ENABLED START -----*/ + /* clang-format on */ + /* clang-format off */ + /*----- PROTECTED REGION END -----*/ // DataVampire::EnableStateAllowed_READ + return true; +} + +//-------------------------------------------------------- +/** + * Method : DataVampire::is_CacheSize_allowed() + * Description : Execution allowed for CacheSize attribute + */ +//-------------------------------------------------------- +bool DataVampire::is_CacheSize_allowed(TANGO_UNUSED(Tango::AttReqType type)) +{ + // Not any excluded states for CacheSize attribute in Write access. + /*----- PROTECTED REGION ID(DataVampire::CacheSizeStateAllowed_WRITE) ENABLED START -----*/ + /* clang-format on */ + /* clang-format off */ + /*----- PROTECTED REGION END -----*/ // DataVampire::CacheSizeStateAllowed_WRITE + + // Not any excluded states for CacheSize attribute in read access. + /*----- PROTECTED REGION ID(DataVampire::CacheSizeStateAllowed_READ) ENABLED START -----*/ + /* clang-format on */ + /* clang-format off */ + /*----- PROTECTED REGION END -----*/ // DataVampire::CacheSizeStateAllowed_READ + return true; +} + +//-------------------------------------------------------- +/** + * Method : DataVampire::is_AutoBackgroundSamples_allowed() + * Description : Execution allowed for AutoBackgroundSamples attribute + */ +//-------------------------------------------------------- +bool DataVampire::is_AutoBackgroundSamples_allowed(TANGO_UNUSED(Tango::AttReqType type)) +{ + // Not any excluded states for AutoBackgroundSamples attribute in Write access. + /*----- PROTECTED REGION ID(DataVampire::AutoBackgroundSamplesStateAllowed_WRITE) ENABLED START -----*/ + /* clang-format on */ + /* clang-format off */ + /*----- PROTECTED REGION END -----*/ // DataVampire::AutoBackgroundSamplesStateAllowed_WRITE + + // Not any excluded states for AutoBackgroundSamples attribute in read access. + /*----- PROTECTED REGION ID(DataVampire::AutoBackgroundSamplesStateAllowed_READ) ENABLED START -----*/ + /* clang-format on */ + /* clang-format off */ + /*----- PROTECTED REGION END -----*/ // DataVampire::AutoBackgroundSamplesStateAllowed_READ + return true; +} + +//-------------------------------------------------------- +/** + * Method : DataVampire::is_PostAcqRoi_allowed() + * Description : Execution allowed for PostAcqRoi attribute + */ +//-------------------------------------------------------- +bool DataVampire::is_PostAcqRoi_allowed(TANGO_UNUSED(Tango::AttReqType type)) +{ + // Not any excluded states for PostAcqRoi attribute in Write access. + /*----- PROTECTED REGION ID(DataVampire::PostAcqRoiStateAllowed_WRITE) ENABLED START -----*/ + /* clang-format on */ + /* clang-format off */ + /*----- PROTECTED REGION END -----*/ // DataVampire::PostAcqRoiStateAllowed_WRITE + + // Not any excluded states for PostAcqRoi attribute in read access. + /*----- PROTECTED REGION ID(DataVampire::PostAcqRoiStateAllowed_READ) ENABLED START -----*/ + /* clang-format on */ + /* clang-format off */ + /*----- PROTECTED REGION END -----*/ // DataVampire::PostAcqRoiStateAllowed_READ + return true; +} + +//-------------------------------------------------------- +/** + * Method : DataVampire::is_ImageWidth_allowed() + * Description : Execution allowed for ImageWidth attribute + */ +//-------------------------------------------------------- +bool DataVampire::is_ImageWidth_allowed(TANGO_UNUSED(Tango::AttReqType type)) +{ + // Not any excluded states for ImageWidth attribute in Write access. + /*----- PROTECTED REGION ID(DataVampire::ImageWidthStateAllowed_WRITE) ENABLED START -----*/ + /* clang-format on */ + /* clang-format off */ + /*----- PROTECTED REGION END -----*/ // DataVampire::ImageWidthStateAllowed_WRITE + + // Not any excluded states for ImageWidth attribute in read access. + /*----- PROTECTED REGION ID(DataVampire::ImageWidthStateAllowed_READ) ENABLED START -----*/ + /* clang-format on */ + /* clang-format off */ + /*----- PROTECTED REGION END -----*/ // DataVampire::ImageWidthStateAllowed_READ + return true; +} + +//-------------------------------------------------------- +/** + * Method : DataVampire::is_ImageHeight_allowed() + * Description : Execution allowed for ImageHeight attribute + */ +//-------------------------------------------------------- +bool DataVampire::is_ImageHeight_allowed(TANGO_UNUSED(Tango::AttReqType type)) +{ + // Not any excluded states for ImageHeight attribute in Write access. + /*----- PROTECTED REGION ID(DataVampire::ImageHeightStateAllowed_WRITE) ENABLED START -----*/ + + /*----- PROTECTED REGION END -----*/ // DataVampire::ImageHeightStateAllowed_WRITE + + // Not any excluded states for ImageHeight attribute in read access. + /*----- PROTECTED REGION ID(DataVampire::ImageHeightStateAllowed_READ) ENABLED START -----*/ + + /*----- PROTECTED REGION END -----*/ // DataVampire::ImageHeightStateAllowed_READ + return true; +} + +//-------------------------------------------------------- +/** + * Method : DataVampire::is_RoiParam_allowed() + * Description : Execution allowed for RoiParam attribute + */ +//-------------------------------------------------------- +bool DataVampire::is_RoiParam_allowed(TANGO_UNUSED(Tango::AttReqType type)) +{ + // Not any excluded states for RoiParam attribute in Write access. + /*----- PROTECTED REGION ID(DataVampire::RoiParamStateAllowed_WRITE) ENABLED START -----*/ + /* clang-format on */ + /* clang-format off */ + /*----- PROTECTED REGION END -----*/ // DataVampire::RoiParamStateAllowed_WRITE + + // Not any excluded states for RoiParam attribute in read access. + /*----- PROTECTED REGION ID(DataVampire::RoiParamStateAllowed_READ) ENABLED START -----*/ + /* clang-format on */ + /* clang-format off */ + /*----- PROTECTED REGION END -----*/ // DataVampire::RoiParamStateAllowed_READ + return true; +} + +//-------------------------------------------------------- +/** + * Method : DataVampire::is_Spectrum_allowed() + * Description : Execution allowed for Spectrum attribute + */ +//-------------------------------------------------------- +bool DataVampire::is_Spectrum_allowed(TANGO_UNUSED(Tango::AttReqType type)) +{ + + // Not any excluded states for Spectrum attribute in read access. + /*----- PROTECTED REGION ID(DataVampire::SpectrumStateAllowed_READ) ENABLED START -----*/ + /* clang-format on */ + /* clang-format off */ + /*----- PROTECTED REGION END -----*/ // DataVampire::SpectrumStateAllowed_READ + return true; +} + +//-------------------------------------------------------- +/** + * Method : DataVampire::is_HorBackground_allowed() + * Description : Execution allowed for HorBackground attribute + */ +//-------------------------------------------------------- +bool DataVampire::is_HorBackground_allowed(TANGO_UNUSED(Tango::AttReqType type)) +{ + + // Not any excluded states for HorBackground attribute in read access. + /*----- PROTECTED REGION ID(DataVampire::HorBackgroundStateAllowed_READ) ENABLED START -----*/ + /* clang-format on */ + /* clang-format off */ + /*----- PROTECTED REGION END -----*/ // DataVampire::HorBackgroundStateAllowed_READ + return true; +} + +//-------------------------------------------------------- +/** + * Method : DataVampire::is_VerBackground_allowed() + * Description : Execution allowed for VerBackground attribute + */ +//-------------------------------------------------------- +bool DataVampire::is_VerBackground_allowed(TANGO_UNUSED(Tango::AttReqType type)) +{ + + // Not any excluded states for VerBackground attribute in read access. + /*----- PROTECTED REGION ID(DataVampire::VerBackgroundStateAllowed_READ) ENABLED START -----*/ + /* clang-format on */ + /* clang-format off */ + /*----- PROTECTED REGION END -----*/ // DataVampire::VerBackgroundStateAllowed_READ + return true; +} + +//-------------------------------------------------------- +/** + * Method : DataVampire::is_Image_allowed() + * Description : Execution allowed for Image attribute + */ +//-------------------------------------------------------- +bool DataVampire::is_Image_allowed(TANGO_UNUSED(Tango::AttReqType type)) +{ + + // Not any excluded states for Image attribute in read access. + /*----- PROTECTED REGION ID(DataVampire::ImageStateAllowed_READ) ENABLED START -----*/ + /* clang-format on */ + /* clang-format off */ + /*----- PROTECTED REGION END -----*/ // DataVampire::ImageStateAllowed_READ + return true; +} + + +//================================================= +// Commands Allowed Methods +//================================================= + +//-------------------------------------------------------- +/** + * Method : DataVampire::is_GetSum_allowed() + * Description : Execution allowed for GetSum attribute + */ +//-------------------------------------------------------- +bool DataVampire::is_GetSum_allowed(TANGO_UNUSED(const CORBA::Any &any)) +{ + // Not any excluded states for GetSum command. + /*----- PROTECTED REGION ID(DataVampire::GetSumStateAllowed) ENABLED START -----*/ + /* clang-format on */ + /* clang-format off */ + /*----- PROTECTED REGION END -----*/ // DataVampire::GetSumStateAllowed + return true; +} + +//-------------------------------------------------------- +/** + * Method : DataVampire::is_GetMean_allowed() + * Description : Execution allowed for GetMean attribute + */ +//-------------------------------------------------------- +bool DataVampire::is_GetMean_allowed(TANGO_UNUSED(const CORBA::Any &any)) +{ + // Not any excluded states for GetMean command. + /*----- PROTECTED REGION ID(DataVampire::GetMeanStateAllowed) ENABLED START -----*/ + /* clang-format on */ + /* clang-format off */ + /*----- PROTECTED REGION END -----*/ // DataVampire::GetMeanStateAllowed + return true; +} + +//-------------------------------------------------------- +/** + * Method : DataVampire::is_GetHorPos_allowed() + * Description : Execution allowed for GetHorPos attribute + */ +//-------------------------------------------------------- +bool DataVampire::is_GetHorPos_allowed(TANGO_UNUSED(const CORBA::Any &any)) +{ + // Not any excluded states for GetHorPos command. + /*----- PROTECTED REGION ID(DataVampire::GetHorPosStateAllowed) ENABLED START -----*/ + /* clang-format on */ + /* clang-format off */ + /*----- PROTECTED REGION END -----*/ // DataVampire::GetHorPosStateAllowed + return true; +} + +//-------------------------------------------------------- +/** + * Method : DataVampire::is_GetVerPos_allowed() + * Description : Execution allowed for GetVerPos attribute + */ +//-------------------------------------------------------- +bool DataVampire::is_GetVerPos_allowed(TANGO_UNUSED(const CORBA::Any &any)) +{ + // Not any excluded states for GetVerPos command. + /*----- PROTECTED REGION ID(DataVampire::GetVerPosStateAllowed) ENABLED START -----*/ + /* clang-format on */ + /* clang-format off */ + /*----- PROTECTED REGION END -----*/ // DataVampire::GetVerPosStateAllowed + return true; +} + +//-------------------------------------------------------- +/** + * Method : DataVampire::is_GetHorSigma_allowed() + * Description : Execution allowed for GetHorSigma attribute + */ +//-------------------------------------------------------- +bool DataVampire::is_GetHorSigma_allowed(TANGO_UNUSED(const CORBA::Any &any)) +{ + // Not any excluded states for GetHorSigma command. + /*----- PROTECTED REGION ID(DataVampire::GetHorSigmaStateAllowed) ENABLED START -----*/ + /* clang-format on */ + /* clang-format off */ + /*----- PROTECTED REGION END -----*/ // DataVampire::GetHorSigmaStateAllowed + return true; +} + +//-------------------------------------------------------- +/** + * Method : DataVampire::is_GetVerSigma_allowed() + * Description : Execution allowed for GetVerSigma attribute + */ +//-------------------------------------------------------- +bool DataVampire::is_GetVerSigma_allowed(TANGO_UNUSED(const CORBA::Any &any)) +{ + // Not any excluded states for GetVerSigma command. + /*----- PROTECTED REGION ID(DataVampire::GetVerSigmaStateAllowed) ENABLED START -----*/ + /* clang-format on */ + /* clang-format off */ + /*----- PROTECTED REGION END -----*/ // DataVampire::GetVerSigmaStateAllowed + return true; +} + +//-------------------------------------------------------- +/** + * Method : DataVampire::is_GetValidValues_allowed() + * Description : Execution allowed for GetValidValues attribute + */ +//-------------------------------------------------------- +bool DataVampire::is_GetValidValues_allowed(TANGO_UNUSED(const CORBA::Any &any)) +{ + // Not any excluded states for GetValidValues command. + /*----- PROTECTED REGION ID(DataVampire::GetValidValuesStateAllowed) ENABLED START -----*/ + /* clang-format on */ + /* clang-format off */ + /*----- PROTECTED REGION END -----*/ // DataVampire::GetValidValuesStateAllowed + return true; +} + +//-------------------------------------------------------- +/** + * Method : DataVampire::is_SetBackground_allowed() + * Description : Execution allowed for SetBackground attribute + */ +//-------------------------------------------------------- +bool DataVampire::is_SetBackground_allowed(TANGO_UNUSED(const CORBA::Any &any)) +{ + // Not any excluded states for SetBackground command. + /*----- PROTECTED REGION ID(DataVampire::SetBackgroundStateAllowed) ENABLED START -----*/ + /* clang-format on */ + /* clang-format off */ + /*----- PROTECTED REGION END -----*/ // DataVampire::SetBackgroundStateAllowed + return true; +} + + +/*----- PROTECTED REGION ID(DataVampire::DataVampireStateAllowed.AdditionalMethods) ENABLED START -----*/ +/* clang-format on */ +// Additional Methods +/* clang-format off */ +/*----- PROTECTED REGION END -----*/ // DataVampire::DataVampireStateAllowed.AdditionalMethods + +} // End of namespace diff --git a/src/main.cpp b/src/main.cpp new file mode 100644 index 0000000..db1dd4e --- /dev/null +++ b/src/main.cpp @@ -0,0 +1,88 @@ +/*----- PROTECTED REGION ID(DataVampire::main.cpp) ENABLED START -----*/ +/* clang-format on */ +//============================================================================= +// +// file : main.cpp +// +// description : C++ source for the DataVampire 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 : DataVampire +// +// This file is part of Tango device class. +// +// Tango is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// Tango is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with Tango. If not, see <http://www.gnu.org/licenses/>. +// +// +// +//============================================================================= +// This file is generated by POGO +// (Program Obviously used to Generate tango Object) +//============================================================================= +#include <tango/tango.h> + +// Check if crash reporting is used. +#if defined(ENABLE_CRASH_REPORT) +# include <crashreporting/crash_report.h> +#else +# define DECLARE_CRASH_HANDLER +# define INSTALL_CRASH_HANDLER +#endif + +DECLARE_CRASH_HANDLER + +int main(int argc,char *argv[]) +{ + INSTALL_CRASH_HANDLER + Tango::Util *tg; + try + { + // Initialise the device server + //---------------------------------------- + tg = Tango::Util::init(argc,argv); + + // Create the device server singleton + // which will create everything + //---------------------------------------- + tg->server_init(false); + + // Run the endless loop + //---------------------------------------- + std::cout << "Ready to accept request" << std::endl; + tg->server_run(); + } + catch (std::bad_alloc &) + { + std::cout << "Can't allocate memory to store device object !!!" << std::endl; + std::cout << "Exiting" << std::endl; + } + catch (CORBA::Exception &e) + { + Tango::Except::print_exception(e); + + std::cout << "Received a CORBA_Exception" << std::endl; + std::cout << "Exiting" << std::endl; + } + + if(tg) + { + tg->server_cleanup(); + } + return(0); +} + +/* clang-format off */ +/*----- PROTECTED REGION END -----*/ // DataVampire::main.cpp -- GitLab