From 1c3a88fa744731da38c5feeb83831cebe31eba07 Mon Sep 17 00:00:00 2001 From: gscalamera <graziano.scalamera@elettra.eu> Date: Tue, 5 Mar 2024 12:22:34 +0100 Subject: [PATCH] First import --- .gitignore | 8 + Makefile | 9 + src/CCDSpectrometer.cpp | 3616 +++++++++++++++++++++++++++ src/CCDSpectrometer.h | 847 +++++++ src/CCDSpectrometer.xmi | 553 ++++ src/CCDSpectrometerClass.cpp | 2068 +++++++++++++++ src/CCDSpectrometerClass.h | 1027 ++++++++ src/CCDSpectrometerStateMachine.cpp | 1033 ++++++++ src/ClassFactory.cpp | 52 + src/main.cpp | 88 + src/readthread.cpp | 1098 ++++++++ src/readthread.h | 66 + src/tbuffer.hpp | 2326 +++++++++++++++++ src/tcheck_get_rt_buffer.hpp | 394 +++ 14 files changed, 13185 insertions(+) create mode 100644 .gitignore create mode 100644 Makefile create mode 100644 src/CCDSpectrometer.cpp create mode 100644 src/CCDSpectrometer.h create mode 100644 src/CCDSpectrometer.xmi create mode 100644 src/CCDSpectrometerClass.cpp create mode 100644 src/CCDSpectrometerClass.h create mode 100644 src/CCDSpectrometerStateMachine.cpp create mode 100644 src/ClassFactory.cpp create mode 100644 src/main.cpp create mode 100644 src/readthread.cpp create mode 100644 src/readthread.h create mode 100644 src/tbuffer.hpp create mode 100644 src/tcheck_get_rt_buffer.hpp diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..0d4c718 --- /dev/null +++ b/.gitignore @@ -0,0 +1,8 @@ +.nse_depinfo +bin +obj + +# Eclipse +.cproject +.project +.settings diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..a84cdcf --- /dev/null +++ b/Makefile @@ -0,0 +1,9 @@ +NAME_SRV = ccd-spectrometer-srv +LDFLAGS = -lfit +HAVE_RNM = 1 +ifeq ($(HAVE_RNM),1) + CXXFLAGS += -DHAVE_RNM + LDFLAGS += -lrnm -lrnmshare +endif + +include ../makefiles/Make-9.3.3.in diff --git a/src/CCDSpectrometer.cpp b/src/CCDSpectrometer.cpp new file mode 100644 index 0000000..09fa6d1 --- /dev/null +++ b/src/CCDSpectrometer.cpp @@ -0,0 +1,3616 @@ +/*----- PROTECTED REGION ID(CCDSpectrometer.cpp) ENABLED START -----*/ +/* clang-format on */ +//============================================================================= +// +// file : CCDSpectrometer.cpp +// +// description : C++ source for the CCDSpectrometer 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 +// CCDSpectrometer are implemented in this file. +// +// project : CCDSpectrometer +// +// 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 "CCDSpectrometer.h" +#include "CCDSpectrometerClass.h" +#include <readthread.h> +#include "tcheck_get_rt_buffer.hpp" +/* clang-format off */ +/*----- PROTECTED REGION END -----*/ // CCDSpectrometer.cpp + +/** + * CCDSpectrometer class description: + * Laser Spectrometer based on Basler CCD Tango Device + */ + +//================================================================ +// The following table gives the correspondence +// between command and method names. +// +// Command name | Method name +//================================================================ +// State | Inherited (no method) +// Status | Inherited (no method) +// Start | start +// Stop | stop +// Reset | reset +// StartSingle | start_single +// StartContinuous | start_continuous +// GetLastData | get_last_data +// AcquireNoise | acquire_noise +// SaveReferenceData | save_reference_data +// GetData | get_data +// GetGaussFitCenter | get_gauss_fit_center +// GetGaussFitWidth | get_gauss_fit_width +// GetFWHMCenter | get_fwhmcenter +// GetFWHMWidth | get_fwhmwidth +// ExportWavelength | export_wavelength +// GetArea | get_area +// GetWave | get_wave +// GetLambda | get_lambda +//================================================================ + +//================================================================ +// Attributes managed are: +//================================================================ +// SyncMode | Tango::DevLong Scalar +// ExposureTime | Tango::DevDouble Scalar +// NoiseSubtraction | Tango::DevBoolean Scalar +// GaussFitEnable | Tango::DevBoolean Scalar +// FWHMEnable | Tango::DevBoolean Scalar +// GaussFitCenter | Tango::DevDouble Scalar +// GaussFitWidth | Tango::DevDouble Scalar +// FWHMCenter | Tango::DevDouble Scalar +// FWHMWidth | Tango::DevDouble Scalar +// Center | Tango::DevDouble Scalar +// Width | Tango::DevDouble Scalar +// FitType | Tango::DevLong Scalar +// FWHMAvg | Tango::DevLong Scalar +// NoiseLevel | Tango::DevLong Scalar +// DataReferenceFile | Tango::DevString Scalar +// AutoExposure | Tango::DevBoolean Scalar +// RtMode | Tango::DevBoolean Scalar +// IntensityCalibrationEnable | Tango::DevBoolean Scalar +// Area | Tango::DevDouble Scalar +// AreaRegion | Tango::DevDouble Scalar +// AreaEnable | Tango::DevBoolean Scalar +// WidthCorrectionEnable | Tango::DevBoolean Scalar +// IncrSensitivity | Tango::DevBoolean Scalar +// Data | Tango::DevDouble Spectrum ( max = 4100) +// NumPixels | Tango::DevLong Spectrum ( max = 2) +// RegionOfInterest | Tango::DevDouble Spectrum ( max = 2) +// AnalysisRegion | Tango::DevDouble Spectrum ( max = 2) +// GaussFit | Tango::DevDouble Spectrum ( max = 4) +// FWHM | Tango::DevDouble Spectrum ( max = 3) +// GaussReference | Tango::DevDouble Spectrum ( max = 4) +// DataReference | Tango::DevDouble Spectrum ( max = 5000) +// IntensityCalibration | Tango::DevDouble Spectrum ( max = 5000) +// NoiseProfile | Tango::DevDouble Spectrum ( max = 5000) +// Wave | Tango::DevDouble Spectrum ( max = 5000) +// Lambda | Tango::DevDouble Spectrum ( max = 5000) +//================================================================ + +namespace CCDSpectrometer_ns +{ +/*----- PROTECTED REGION ID(CCDSpectrometer::namespace_starting) ENABLED START -----*/ +/* clang-format on */ +// static initializations +/* clang-format off */ +/*----- PROTECTED REGION END -----*/ // CCDSpectrometer::namespace_starting + +//-------------------------------------------------------- +/** + * Method : CCDSpectrometer::CCDSpectrometer() + * Description: Constructors for a Tango device + * implementing the classCCDSpectrometer + */ +//-------------------------------------------------------- +CCDSpectrometer::CCDSpectrometer(Tango::DeviceClass *cl, std::string &s) + : TANGO_BASE_CLASS(cl, s.c_str()) +{ + /*----- PROTECTED REGION ID(CCDSpectrometer::constructor_1) ENABLED START -----*/ + /* clang-format on */ + init_device(); + /* clang-format off */ + /*----- PROTECTED REGION END -----*/ // CCDSpectrometer::constructor_1 +} +//-------------------------------------------------------- +CCDSpectrometer::CCDSpectrometer(Tango::DeviceClass *cl, const char *s) + : TANGO_BASE_CLASS(cl, s) +{ + /*----- PROTECTED REGION ID(CCDSpectrometer::constructor_2) ENABLED START -----*/ + /* clang-format on */ + init_device(); + /* clang-format off */ + /*----- PROTECTED REGION END -----*/ // CCDSpectrometer::constructor_2 +} +//-------------------------------------------------------- +CCDSpectrometer::CCDSpectrometer(Tango::DeviceClass *cl, const char *s, const char *d) + : TANGO_BASE_CLASS(cl, s, d) +{ + /*----- PROTECTED REGION ID(CCDSpectrometer::constructor_3) ENABLED START -----*/ + /* clang-format on */ + init_device(); + /* clang-format off */ + /*----- PROTECTED REGION END -----*/ // CCDSpectrometer::constructor_3 +} +//-------------------------------------------------------- +CCDSpectrometer::~CCDSpectrometer() +{ + delete_device(); +} + +//-------------------------------------------------------- +/** + * Method : CCDSpectrometer::delete_device() + * Description: will be called at device destruction or at init command + */ +//-------------------------------------------------------- +void CCDSpectrometer::delete_device() +{ + DEBUG_STREAM << "CCDSpectrometer::delete_device() " << device_name << std::endl; + /*----- PROTECTED REGION ID(CCDSpectrometer::delete_device) ENABLED START -----*/ + /* clang-format on */ + // Delete device allocated objects + loop->abortflag = true; + abortflag = true; + sleep(1); + + Tango::DbDatum gr("DefaultGaussRef"); + vector<double> gref; + gref.push_back(attr_GaussReference_read[0]); + gref.push_back(attr_GaussReference_read[1]); + gref.push_back(attr_GaussReference_read[2]); + gref.push_back(attr_GaussReference_read[3]); + gr << gref; + Tango::DbDatum ar("AnalysisRegion"); + vector<double> anre; + anre.push_back(attr_AnalysisRegion_read[0]); + anre.push_back(attr_AnalysisRegion_read[1]); + ar << anre; + Tango::DbDatum ri("RegionOfInterest"); + vector<double> rein; + rein.push_back(attr_RegionOfInterest_read[0]); + rein.push_back(attr_RegionOfInterest_read[1]); + ri << rein; + Tango::DbDatum et("ExposureTime"); + et << *attr_ExposureTime_read; + Tango::DbDatum sm("SyncMode"); + sm << *attr_SyncMode_read; + Tango::DbData data; + data.push_back(gr); + data.push_back(ar); + data.push_back(ri); + data.push_back(et); + data.push_back(sm); + Tango::Database *db = new Tango::Database(); + try + { + db->set_timeout_millis(15000); + db->put_device_property(get_name(), data); + } + catch(Tango::DevFailed &e) + { + stringstream o; + o << " Error saving properties='" << e.errors[0].desc << "'"; + WARN_STREAM << __FUNCTION__<< o.str(); + } + delete db; + + delete [] x_values; + if(pLiveData_avg) + { + delete [] pLiveData_avg; + pLiveData_avg = NULL; + } + if(pLiveData) + { + delete [] pLiveData; + pLiveData = NULL; + } + if(pNoiseMask_avg) + { + delete [] pNoiseMask_avg; + pNoiseMask_avg = NULL; + } + if(pReferenceData) + { + delete [] pReferenceData; + pReferenceData = NULL; + } + /*if(pMeasData) + { + delete [] pMeasData; + pMeasData = NULL; + }*/ + if(pFrameBuffer) + { + delete [] pFrameBuffer; + pFrameBuffer = NULL; + } + delete m_gaussfit; + delete m_asyngaussfit; + delete m_confiteorfit; + + for(int i=0; i<NUM_BUF; i++) + { + tbuf[i].delete_rt_buffer(); + } + tbuf_array.delete_rt_buffer(); + tbuf_array_w.delete_rt_buffer(); + tbuf_array_l.delete_rt_buffer(); + + delete dpmutex; + /* clang-format off */ + /*----- PROTECTED REGION END -----*/ // CCDSpectrometer::delete_device + delete[] attr_SyncMode_read; + delete[] attr_ExposureTime_read; + delete[] attr_NoiseSubtraction_read; + delete[] attr_GaussFitEnable_read; + delete[] attr_FWHMEnable_read; + delete[] attr_GaussFitCenter_read; + delete[] attr_GaussFitWidth_read; + delete[] attr_FWHMCenter_read; + delete[] attr_FWHMWidth_read; + delete[] attr_Center_read; + delete[] attr_Width_read; + delete[] attr_FitType_read; + delete[] attr_FWHMAvg_read; + delete[] attr_NoiseLevel_read; + delete[] attr_AutoExposure_read; + delete[] attr_RtMode_read; + delete[] attr_IntensityCalibrationEnable_read; + delete[] attr_Area_read; + delete[] attr_AreaRegion_read; + delete[] attr_AreaEnable_read; + delete[] attr_WidthCorrectionEnable_read; + delete[] attr_IncrSensitivity_read; + delete[] attr_NumPixels_read; + delete[] attr_RegionOfInterest_read; + delete[] attr_AnalysisRegion_read; + delete[] attr_GaussFit_read; + delete[] attr_FWHM_read; + delete[] attr_GaussReference_read; + delete[] attr_IntensityCalibration_read; +} + +//-------------------------------------------------------- +/** + * Method : CCDSpectrometer::init_device() + * Description: will be called at device initialization. + */ +//-------------------------------------------------------- +void CCDSpectrometer::init_device() +{ + DEBUG_STREAM << "CCDSpectrometer::init_device() create device " << device_name << std::endl; + /*----- PROTECTED REGION ID(CCDSpectrometer::init_device_before) ENABLED START -----*/ + /* clang-format on */ + // Initialization before get_device_property() call + abortflag = false; + /* clang-format off */ + /*----- PROTECTED REGION END -----*/ // CCDSpectrometer::init_device_before + + + // Get the device properties from database + get_device_property(); + + attr_SyncMode_read = new Tango::DevLong[1]; + attr_ExposureTime_read = new Tango::DevDouble[1]; + attr_NoiseSubtraction_read = new Tango::DevBoolean[1]; + attr_GaussFitEnable_read = new Tango::DevBoolean[1]; + attr_FWHMEnable_read = new Tango::DevBoolean[1]; + attr_GaussFitCenter_read = new Tango::DevDouble[1]; + attr_GaussFitWidth_read = new Tango::DevDouble[1]; + attr_FWHMCenter_read = new Tango::DevDouble[1]; + attr_FWHMWidth_read = new Tango::DevDouble[1]; + attr_Center_read = new Tango::DevDouble[1]; + attr_Width_read = new Tango::DevDouble[1]; + attr_FitType_read = new Tango::DevLong[1]; + attr_FWHMAvg_read = new Tango::DevLong[1]; + attr_NoiseLevel_read = new Tango::DevLong[1]; + attr_AutoExposure_read = new Tango::DevBoolean[1]; + attr_RtMode_read = new Tango::DevBoolean[1]; + attr_IntensityCalibrationEnable_read = new Tango::DevBoolean[1]; + attr_Area_read = new Tango::DevDouble[1]; + attr_AreaRegion_read = new Tango::DevDouble[1]; + attr_AreaEnable_read = new Tango::DevBoolean[1]; + attr_WidthCorrectionEnable_read = new Tango::DevBoolean[1]; + attr_IncrSensitivity_read = new Tango::DevBoolean[1]; + attr_NumPixels_read = new Tango::DevLong[2]; + attr_RegionOfInterest_read = new Tango::DevDouble[2]; + attr_AnalysisRegion_read = new Tango::DevDouble[2]; + attr_GaussFit_read = new Tango::DevDouble[4]; + attr_FWHM_read = new Tango::DevDouble[3]; + attr_GaussReference_read = new Tango::DevDouble[4]; + attr_IntensityCalibration_read = new Tango::DevDouble[5000]; + /*----- PROTECTED REGION ID(CCDSpectrometer::init_device) ENABLED START -----*/ + /* clang-format on */ + // Initialize device + *attr_FitType_read = GAUSS_FIT; + *attr_FWHMAvg_read = 3; + defaultStartRegion = floor(defaultStartRegion*1000.0)*0.001; + defaultEndRegion = floor(defaultEndRegion*1000.0)*0.001; + for(int i=0; i<5000; i++) + attr_IntensityCalibration_read[i] = 1.0; + *attr_IntensityCalibrationEnable_read = false; + + attr_GaussFit_read[0]=attr_GaussFit_read[1]=attr_GaussFit_read[2]=attr_GaussFit_read[3]=0; + *attr_ExposureTime_read = exposureTime; + *attr_SyncMode_read = syncMode; + attr_AnalysisRegion_read[0] = attr_RegionOfInterest_read[0] = defaultStartRegion; + attr_AnalysisRegion_read[1] = attr_RegionOfInterest_read[1] = defaultEndRegion; + if(regionOfInterest.size() >= 2) + { + attr_RegionOfInterest_read[0] = regionOfInterest[0]; + attr_RegionOfInterest_read[1] = regionOfInterest[1]; + } + if(analysisRegion.size() >= 2) + { + attr_AnalysisRegion_read[0] = analysisRegion[0]; + attr_AnalysisRegion_read[1] = analysisRegion[1]; + } + if(defaultGaussRef.size() == 4) + { + int i=0; + for(vector<double>::iterator it = defaultGaussRef.begin(); it != defaultGaussRef.end(); it++) + attr_GaussReference_read[i++] = *it; + /*attr_GaussReference_read[0] = defaultGaussRef[0]; + attr_GaussReference_read[1] = defaultGaussRef[1]; + attr_GaussReference_read[2] = defaultGaussRef[2]; + attr_GaussReference_read[3] = defaultGaussRef[3];*/ + } + else + attr_GaussReference_read[0] = attr_GaussReference_read[1] = attr_GaussReference_read[2] = attr_GaussReference_read[3]= 0; + + FrameBufferIndex = 0; + + pLiveData = NULL; + pReferenceData = NULL; + pFrameBuffer = NULL; + x_values = NULL; + pLiveData_avg = NULL; + pNoiseMask_avg = NULL; + + ostringstream tempstr; + tempstr << dataReferenceFile << ends; + if(tempstr.str().length() < sizeof(attr_strchar)) + strcpy(attr_strchar,tempstr.str().c_str()); + + live_mode = false; + init_live_mode = false; + measure_mode = false; + init_measure_mode = false; + acquire_noise_mode = false; + init_acquire_noise_mode = false; + stop_mode = false; + noise_level = 0; + GaussFit_valid = false; + + y_max_mean = 0; + memset(exposures, 0, sizeof(int)*AUTO_EXPOSURE_MEAN); + exposure_idx = 0; + +// m_gaussfit = new GaussFit(NUM_GAUSS_PARAMETER, gauss_f, gauss_df, gauss_fdf); +// m_gaussfit = new Fit(NUM_GAUSS_PARAMETER, gauss_f, gauss_df, gauss_fdf); + m_gaussfit = new Fit(GAUSS_FIT, GAUSS_FIT_NUM_PARAM, 1); + m_asyngaussfit = new Fit(GAUSS_FIT_ASYMM, GAUSS_FIT_ASYMM_NUM_PARAM, 1); + m_confiteorfit = new Fit(CONFITEOR2_FIT, CONFITEOR_FIT_NUM_PARAM, 1); + + for(int i=0; i<NUM_BUF; i++) + { + tbuf[i].init_rt_buffer(BUF_SIZE); + tbuf[i].set_mode(tbuffer::BUF_RT_CIRCULAR); + //set_fill_hole(BUF_RT_FILL_0, buf[i]); + //set_fill_hole(BUF_RT_NO_FILL, buf[i]); + tbuf[i].set_fill_hole(BUF_RT_FILL_1); + } + tbuf_array.init_rt_buffer(BUF_SIZE); + tbuf_array.set_mode(tbuffer::BUF_RT_CIRCULAR); + tbuf_array.set_fill_hole(BUF_RT_FILL_1); + + tbuf_array_w.init_rt_buffer(BUF_SIZE); + tbuf_array_w.set_mode(tbuffer::BUF_RT_CIRCULAR); + tbuf_array_w.set_fill_hole(BUF_RT_FILL_1); + + tbuf_array_l.init_rt_buffer(BUF_SIZE); + tbuf_array_l.set_mode(tbuffer::BUF_RT_CIRCULAR); + tbuf_array_l.set_fill_hole(BUF_RT_FILL_1); + + // Initialize device + set_state(Tango::ON); + + if(intensityCalibrationFile.length() > 0) + load_intensity_cal_file(intensityCalibrationFile); + + init_data(false); + dpmutex = new omni_mutex(); + dp = new Tango::DeviceProxy(deviceName); + loop = new readthread(this); + loop->start(); + + if(autoStart && conn_status) + { + try + { + start(); + } + catch(Tango::DevFailed &e) + { + INFO_STREAM << __func__ << ": error autostarting=" << e.errors[0].desc; + } + } + + /* clang-format off */ + /*----- PROTECTED REGION END -----*/ // CCDSpectrometer::init_device +} + +//-------------------------------------------------------- +/** + * Method : CCDSpectrometer::get_device_property() + * Description: Read database to initialize property data members. + */ +//-------------------------------------------------------- +void CCDSpectrometer::get_device_property() +{ + /*----- PROTECTED REGION ID(CCDSpectrometer::get_device_property_before) ENABLED START -----*/ + /* clang-format on */ + // Initialize property data members + /* clang-format off */ + /*----- PROTECTED REGION END -----*/ // CCDSpectrometer::get_device_property_before + + + // Read device properties from database. + Tango::DbData dev_prop; + dev_prop.push_back(Tango::DbDatum("DeviceName")); + dev_prop.push_back(Tango::DbDatum("DefaultGaussRef")); + dev_prop.push_back(Tango::DbDatum("DataReferenceFile")); + dev_prop.push_back(Tango::DbDatum("DefaultStartRegion")); + dev_prop.push_back(Tango::DbDatum("DefaultEndRegion")); + dev_prop.push_back(Tango::DbDatum("PreferFWHM")); + dev_prop.push_back(Tango::DbDatum("AutoExposureRange")); + dev_prop.push_back(Tango::DbDatum("AutoExposureStep")); + dev_prop.push_back(Tango::DbDatum("AutoExposureAmpRange")); + dev_prop.push_back(Tango::DbDatum("IntensityCalibrationFile")); + dev_prop.push_back(Tango::DbDatum("NoiseProfileFile")); + dev_prop.push_back(Tango::DbDatum("WavelengthAttr")); + dev_prop.push_back(Tango::DbDatum("AreaInAnalysisRegion")); + dev_prop.push_back(Tango::DbDatum("WidthCorrection")); + dev_prop.push_back(Tango::DbDatum("NFramesBuffered")); + dev_prop.push_back(Tango::DbDatum("AnalysisRegion")); + dev_prop.push_back(Tango::DbDatum("RegionOfInterest")); + dev_prop.push_back(Tango::DbDatum("ExposureTime")); + dev_prop.push_back(Tango::DbDatum("SyncMode")); + dev_prop.push_back(Tango::DbDatum("AutoStart")); + dev_prop.push_back(Tango::DbDatum("NumPixel")); + dev_prop.push_back(Tango::DbDatum("CameraLabel")); + + // 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 CCDSpectrometerClass to get class property + Tango::DbDatum def_prop, cl_prop; + CCDSpectrometerClass *ds_class = + (static_cast<CCDSpectrometerClass *>(get_device_class())); + int i = -1; + + // Try to initialize DeviceName from class property + cl_prop = ds_class->get_class_property(dev_prop[++i].name); + if (cl_prop.is_empty()==false) cl_prop >> deviceName; + else { + // Try to initialize DeviceName from default device value + def_prop = ds_class->get_default_device_property(dev_prop[i].name); + if (def_prop.is_empty()==false) def_prop >> deviceName; + } + // And try to extract DeviceName value from database + if (dev_prop[i].is_empty()==false) dev_prop[i] >> deviceName; + + // Try to initialize DefaultGaussRef from class property + cl_prop = ds_class->get_class_property(dev_prop[++i].name); + if (cl_prop.is_empty()==false) cl_prop >> defaultGaussRef; + else { + // Try to initialize DefaultGaussRef from default device value + def_prop = ds_class->get_default_device_property(dev_prop[i].name); + if (def_prop.is_empty()==false) def_prop >> defaultGaussRef; + } + // And try to extract DefaultGaussRef value from database + if (dev_prop[i].is_empty()==false) dev_prop[i] >> defaultGaussRef; + + // Try to initialize DataReferenceFile from class property + cl_prop = ds_class->get_class_property(dev_prop[++i].name); + if (cl_prop.is_empty()==false) cl_prop >> dataReferenceFile; + else { + // Try to initialize DataReferenceFile from default device value + def_prop = ds_class->get_default_device_property(dev_prop[i].name); + if (def_prop.is_empty()==false) def_prop >> dataReferenceFile; + } + // And try to extract DataReferenceFile value from database + if (dev_prop[i].is_empty()==false) dev_prop[i] >> dataReferenceFile; + + // Try to initialize DefaultStartRegion from class property + cl_prop = ds_class->get_class_property(dev_prop[++i].name); + if (cl_prop.is_empty()==false) cl_prop >> defaultStartRegion; + else { + // Try to initialize DefaultStartRegion from default device value + def_prop = ds_class->get_default_device_property(dev_prop[i].name); + if (def_prop.is_empty()==false) def_prop >> defaultStartRegion; + } + // And try to extract DefaultStartRegion value from database + if (dev_prop[i].is_empty()==false) dev_prop[i] >> defaultStartRegion; + + // Try to initialize DefaultEndRegion from class property + cl_prop = ds_class->get_class_property(dev_prop[++i].name); + if (cl_prop.is_empty()==false) cl_prop >> defaultEndRegion; + else { + // Try to initialize DefaultEndRegion from default device value + def_prop = ds_class->get_default_device_property(dev_prop[i].name); + if (def_prop.is_empty()==false) def_prop >> defaultEndRegion; + } + // And try to extract DefaultEndRegion value from database + if (dev_prop[i].is_empty()==false) dev_prop[i] >> defaultEndRegion; + + // Try to initialize PreferFWHM from class property + cl_prop = ds_class->get_class_property(dev_prop[++i].name); + if (cl_prop.is_empty()==false) cl_prop >> preferFWHM; + else { + // Try to initialize PreferFWHM from default device value + def_prop = ds_class->get_default_device_property(dev_prop[i].name); + if (def_prop.is_empty()==false) def_prop >> preferFWHM; + } + // And try to extract PreferFWHM value from database + if (dev_prop[i].is_empty()==false) dev_prop[i] >> preferFWHM; + + // Try to initialize AutoExposureRange from class property + cl_prop = ds_class->get_class_property(dev_prop[++i].name); + if (cl_prop.is_empty()==false) cl_prop >> autoExposureRange; + else { + // Try to initialize AutoExposureRange from default device value + def_prop = ds_class->get_default_device_property(dev_prop[i].name); + if (def_prop.is_empty()==false) def_prop >> autoExposureRange; + } + // And try to extract AutoExposureRange value from database + if (dev_prop[i].is_empty()==false) dev_prop[i] >> autoExposureRange; + + // Try to initialize AutoExposureStep from class property + cl_prop = ds_class->get_class_property(dev_prop[++i].name); + if (cl_prop.is_empty()==false) cl_prop >> autoExposureStep; + else { + // Try to initialize AutoExposureStep from default device value + def_prop = ds_class->get_default_device_property(dev_prop[i].name); + if (def_prop.is_empty()==false) def_prop >> autoExposureStep; + } + // And try to extract AutoExposureStep value from database + if (dev_prop[i].is_empty()==false) dev_prop[i] >> autoExposureStep; + + // Try to initialize AutoExposureAmpRange from class property + cl_prop = ds_class->get_class_property(dev_prop[++i].name); + if (cl_prop.is_empty()==false) cl_prop >> autoExposureAmpRange; + else { + // Try to initialize AutoExposureAmpRange from default device value + def_prop = ds_class->get_default_device_property(dev_prop[i].name); + if (def_prop.is_empty()==false) def_prop >> autoExposureAmpRange; + } + // And try to extract AutoExposureAmpRange value from database + if (dev_prop[i].is_empty()==false) dev_prop[i] >> autoExposureAmpRange; + + // Try to initialize IntensityCalibrationFile from class property + cl_prop = ds_class->get_class_property(dev_prop[++i].name); + if (cl_prop.is_empty()==false) cl_prop >> intensityCalibrationFile; + else { + // Try to initialize IntensityCalibrationFile from default device value + def_prop = ds_class->get_default_device_property(dev_prop[i].name); + if (def_prop.is_empty()==false) def_prop >> intensityCalibrationFile; + } + // And try to extract IntensityCalibrationFile value from database + if (dev_prop[i].is_empty()==false) dev_prop[i] >> intensityCalibrationFile; + + // Try to initialize NoiseProfileFile from class property + cl_prop = ds_class->get_class_property(dev_prop[++i].name); + if (cl_prop.is_empty()==false) cl_prop >> noiseProfileFile; + else { + // Try to initialize NoiseProfileFile from default device value + def_prop = ds_class->get_default_device_property(dev_prop[i].name); + if (def_prop.is_empty()==false) def_prop >> noiseProfileFile; + } + // And try to extract NoiseProfileFile value from database + if (dev_prop[i].is_empty()==false) dev_prop[i] >> noiseProfileFile; + + // Try to initialize WavelengthAttr from class property + cl_prop = ds_class->get_class_property(dev_prop[++i].name); + if (cl_prop.is_empty()==false) cl_prop >> wavelengthAttr; + else { + // Try to initialize WavelengthAttr from default device value + def_prop = ds_class->get_default_device_property(dev_prop[i].name); + if (def_prop.is_empty()==false) def_prop >> wavelengthAttr; + } + // And try to extract WavelengthAttr value from database + if (dev_prop[i].is_empty()==false) dev_prop[i] >> wavelengthAttr; + + // Try to initialize AreaInAnalysisRegion from class property + cl_prop = ds_class->get_class_property(dev_prop[++i].name); + if (cl_prop.is_empty()==false) cl_prop >> areaInAnalysisRegion; + else { + // Try to initialize AreaInAnalysisRegion from default device value + def_prop = ds_class->get_default_device_property(dev_prop[i].name); + if (def_prop.is_empty()==false) def_prop >> areaInAnalysisRegion; + } + // And try to extract AreaInAnalysisRegion value from database + if (dev_prop[i].is_empty()==false) dev_prop[i] >> areaInAnalysisRegion; + + // Try to initialize WidthCorrection from class property + cl_prop = ds_class->get_class_property(dev_prop[++i].name); + if (cl_prop.is_empty()==false) cl_prop >> widthCorrection; + else { + // Try to initialize WidthCorrection from default device value + def_prop = ds_class->get_default_device_property(dev_prop[i].name); + if (def_prop.is_empty()==false) def_prop >> widthCorrection; + } + // And try to extract WidthCorrection value from database + if (dev_prop[i].is_empty()==false) dev_prop[i] >> widthCorrection; + + // Try to initialize NFramesBuffered from class property + cl_prop = ds_class->get_class_property(dev_prop[++i].name); + if (cl_prop.is_empty()==false) cl_prop >> nFramesBuffered; + else { + // Try to initialize NFramesBuffered from default device value + def_prop = ds_class->get_default_device_property(dev_prop[i].name); + if (def_prop.is_empty()==false) def_prop >> nFramesBuffered; + } + // And try to extract NFramesBuffered value from database + if (dev_prop[i].is_empty()==false) dev_prop[i] >> nFramesBuffered; + + // Try to initialize AnalysisRegion from class property + cl_prop = ds_class->get_class_property(dev_prop[++i].name); + if (cl_prop.is_empty()==false) cl_prop >> analysisRegion; + else { + // Try to initialize AnalysisRegion from default device value + def_prop = ds_class->get_default_device_property(dev_prop[i].name); + if (def_prop.is_empty()==false) def_prop >> analysisRegion; + } + // And try to extract AnalysisRegion value from database + if (dev_prop[i].is_empty()==false) dev_prop[i] >> analysisRegion; + + // Try to initialize RegionOfInterest from class property + cl_prop = ds_class->get_class_property(dev_prop[++i].name); + if (cl_prop.is_empty()==false) cl_prop >> regionOfInterest; + else { + // Try to initialize RegionOfInterest from default device value + def_prop = ds_class->get_default_device_property(dev_prop[i].name); + if (def_prop.is_empty()==false) def_prop >> regionOfInterest; + } + // And try to extract RegionOfInterest value from database + if (dev_prop[i].is_empty()==false) dev_prop[i] >> regionOfInterest; + + // Try to initialize ExposureTime from class property + cl_prop = ds_class->get_class_property(dev_prop[++i].name); + if (cl_prop.is_empty()==false) cl_prop >> exposureTime; + else { + // Try to initialize ExposureTime from default device value + def_prop = ds_class->get_default_device_property(dev_prop[i].name); + if (def_prop.is_empty()==false) def_prop >> exposureTime; + } + // And try to extract ExposureTime value from database + if (dev_prop[i].is_empty()==false) dev_prop[i] >> exposureTime; + + // Try to initialize SyncMode from class property + cl_prop = ds_class->get_class_property(dev_prop[++i].name); + if (cl_prop.is_empty()==false) cl_prop >> syncMode; + else { + // Try to initialize SyncMode from default device value + def_prop = ds_class->get_default_device_property(dev_prop[i].name); + if (def_prop.is_empty()==false) def_prop >> syncMode; + } + // And try to extract SyncMode value from database + if (dev_prop[i].is_empty()==false) dev_prop[i] >> syncMode; + + // Try to initialize AutoStart from class property + cl_prop = ds_class->get_class_property(dev_prop[++i].name); + if (cl_prop.is_empty()==false) cl_prop >> autoStart; + else { + // Try to initialize AutoStart from default device value + def_prop = ds_class->get_default_device_property(dev_prop[i].name); + if (def_prop.is_empty()==false) def_prop >> autoStart; + } + // And try to extract AutoStart value from database + if (dev_prop[i].is_empty()==false) dev_prop[i] >> autoStart; + + // Try to initialize NumPixel from class property + cl_prop = ds_class->get_class_property(dev_prop[++i].name); + if (cl_prop.is_empty()==false) cl_prop >> numPixel; + else { + // Try to initialize NumPixel from default device value + def_prop = ds_class->get_default_device_property(dev_prop[i].name); + if (def_prop.is_empty()==false) def_prop >> numPixel; + } + // And try to extract NumPixel value from database + if (dev_prop[i].is_empty()==false) dev_prop[i] >> numPixel; + + // Try to initialize CameraLabel from class property + cl_prop = ds_class->get_class_property(dev_prop[++i].name); + if (cl_prop.is_empty()==false) cl_prop >> cameraLabel; + else { + // Try to initialize CameraLabel from default device value + def_prop = ds_class->get_default_device_property(dev_prop[i].name); + if (def_prop.is_empty()==false) def_prop >> cameraLabel; + } + // And try to extract CameraLabel value from database + if (dev_prop[i].is_empty()==false) dev_prop[i] >> cameraLabel; + + } + + /*----- PROTECTED REGION ID(CCDSpectrometer::get_device_property_after) ENABLED START -----*/ + /* clang-format on */ + // Check device property data members init + /* clang-format off */ + /*----- PROTECTED REGION END -----*/ // CCDSpectrometer::get_device_property_after +} + +//-------------------------------------------------------- +/** + * Method : CCDSpectrometer::always_executed_hook() + * Description: method always executed before any command is executed + */ +//-------------------------------------------------------- +void CCDSpectrometer::always_executed_hook() +{ + DEBUG_STREAM << "CCDSpectrometer::always_executed_hook() " << device_name << std::endl; + /*----- PROTECTED REGION ID(CCDSpectrometer::always_executed_hook) ENABLED START -----*/ + /* clang-format on */ + // code always executed before all requests + /* clang-format off */ + /*----- PROTECTED REGION END -----*/ // CCDSpectrometer::always_executed_hook +} + +//-------------------------------------------------------- +/** + * Method : CCDSpectrometer::read_attr_hardware() + * Description: Hardware acquisition for attributes + */ +//-------------------------------------------------------- +void CCDSpectrometer::read_attr_hardware(TANGO_UNUSED(std::vector<long> &attr_list)) +{ + DEBUG_STREAM << "CCDSpectrometer::read_attr_hardware(std::vector<long> &attr_list) entering... " << std::endl; + /*----- PROTECTED REGION ID(CCDSpectrometer::read_attr_hardware) ENABLED START -----*/ + /* clang-format on */ + // Add your own code + /* clang-format off */ + /*----- PROTECTED REGION END -----*/ // CCDSpectrometer::read_attr_hardware +} +//-------------------------------------------------------- +/** + * Method : CCDSpectrometer::write_attr_hardware() + * Description: Hardware writing for attributes + */ +//-------------------------------------------------------- +void CCDSpectrometer::write_attr_hardware(TANGO_UNUSED(std::vector<long> &attr_list)) +{ + DEBUG_STREAM << "CCDSpectrometer::write_attr_hardware(std::vector<long> &attr_list) entering... " << std::endl; + /*----- PROTECTED REGION ID(CCDSpectrometer::write_attr_hardware) ENABLED START -----*/ + /* clang-format on */ + // Add your own code + /* clang-format off */ + /*----- PROTECTED REGION END -----*/ // CCDSpectrometer::write_attr_hardware +} + +//-------------------------------------------------------- +/** + * Read attribute SyncMode related method + * Description: 0=SW + * 1=HW Sync input + * 2=HW external trigger + * + * Data type: Tango::DevLong + * Attr type: Scalar + */ +//-------------------------------------------------------- +void CCDSpectrometer::read_SyncMode(Tango::Attribute &attr) +{ + DEBUG_STREAM << "CCDSpectrometer::read_SyncMode(Tango::Attribute &attr) entering... " << std::endl; + /*----- PROTECTED REGION ID(CCDSpectrometer::read_SyncMode) ENABLED START -----*/ + /* clang-format on */ + Tango::DevBoolean syncmode; + try { + dpmutex->lock(); + dp->read_attribute(TRIGGER_ATTR)>>(syncmode); + dpmutex->unlock(); + *attr_SyncMode_read = syncmode ? 1 : 0; + } + catch(Tango::DevFailed &e) + { + dpmutex->unlock(); + INFO_STREAM << __func__ << ": error reading =" << e.errors[0].desc; + } + // Set the attribute value + attr.set_value(attr_SyncMode_read); + /* clang-format off */ + /*----- PROTECTED REGION END -----*/ // CCDSpectrometer::read_SyncMode +} +//-------------------------------------------------------- +/** + * Write attribute SyncMode related method + * Description: 0=SW + * 1=HW Sync input + * 2=HW external trigger + * + * Data type: Tango::DevLong + * Attr type: Scalar + */ +//-------------------------------------------------------- +void CCDSpectrometer::write_SyncMode(Tango::WAttribute &attr) +{ + DEBUG_STREAM << "CCDSpectrometer::write_SyncMode(Tango::WAttribute &attr) entering... " << std::endl; + // Retrieve write value + Tango::DevLong w_val; + attr.get_write_value(w_val); + /*----- PROTECTED REGION ID(CCDSpectrometer::write_SyncMode) ENABLED START -----*/ + /* clang-format on */ + // Add your own code + if(w_val < 0 || w_val > 1) + { + stringstream tmp; + tmp << "Allowed values: 0=No Trigger, 1=HW Trigger"; + Tango::Except::throw_exception( + (const char *) "OutOfRange", + tmp.str(), + (const char *) __func__, Tango::ERR); + } + Tango::DevBoolean syncmode = w_val==1; + try { + Tango::DeviceAttribute Din(TRIGGER_ATTR,syncmode); + dpmutex->lock(); + dp->write_attribute(Din); + dpmutex->unlock(); + } + catch(Tango::DevFailed &e) + { + dpmutex->unlock(); + INFO_STREAM << __func__ << ": error writing =" << e.errors[0].desc; + } + /* clang-format off */ + /*----- PROTECTED REGION END -----*/ // CCDSpectrometer::write_SyncMode +} +//-------------------------------------------------------- +/** + * Read attribute ExposureTime related method + * Description: Exposure time in milliseconds + * + * Data type: Tango::DevDouble + * Attr type: Scalar + */ +//-------------------------------------------------------- +void CCDSpectrometer::read_ExposureTime(Tango::Attribute &attr) +{ + DEBUG_STREAM << "CCDSpectrometer::read_ExposureTime(Tango::Attribute &attr) entering... " << std::endl; + /*----- PROTECTED REGION ID(CCDSpectrometer::read_ExposureTime) ENABLED START -----*/ + /* clang-format on */ + Tango::DevLong exposure; + try { + dpmutex->lock(); + dp->read_attribute(EXPOSURE_ATTR)>>(exposure); + dpmutex->unlock(); + *attr_ExposureTime_read = (double)exposure/1000.0; + } + catch(Tango::DevFailed &e) + { + dpmutex->unlock(); + INFO_STREAM << __func__ << ": error reading =" << e.errors[0].desc; + } + // Set the attribute value + attr.set_value(attr_ExposureTime_read); + /* clang-format off */ + /*----- PROTECTED REGION END -----*/ // CCDSpectrometer::read_ExposureTime +} +//-------------------------------------------------------- +/** + * Write attribute ExposureTime related method + * Description: Exposure time in milliseconds + * + * Data type: Tango::DevDouble + * Attr type: Scalar + */ +//-------------------------------------------------------- +void CCDSpectrometer::write_ExposureTime(Tango::WAttribute &attr) +{ + DEBUG_STREAM << "CCDSpectrometer::write_ExposureTime(Tango::WAttribute &attr) entering... " << std::endl; + // Retrieve write value + Tango::DevDouble w_val; + attr.get_write_value(w_val); + /*----- PROTECTED REGION ID(CCDSpectrometer::write_ExposureTime) ENABLED START -----*/ + /* clang-format on */ + // Add your own code + Tango::DevLong exposure = (Tango::DevLong)(w_val*1000); + try { + Tango::DeviceAttribute Din(EXPOSURE_ATTR,exposure); + dpmutex->lock(); + dp->write_attribute(Din); + dpmutex->unlock(); + } + catch(Tango::DevFailed &e) + { + dpmutex->unlock(); + INFO_STREAM << __func__ << ": error writing =" << e.errors[0].desc; + } + /* clang-format off */ + /*----- PROTECTED REGION END -----*/ // CCDSpectrometer::write_ExposureTime +} +//-------------------------------------------------------- +/** + * Read attribute NoiseSubtraction related method + * Description: Enable/Disable subtraction of background noise profile + * acquired with the AcquireNoise command + * + * Data type: Tango::DevBoolean + * Attr type: Scalar + */ +//-------------------------------------------------------- +void CCDSpectrometer::read_NoiseSubtraction(Tango::Attribute &attr) +{ + DEBUG_STREAM << "CCDSpectrometer::read_NoiseSubtraction(Tango::Attribute &attr) entering... " << std::endl; + /*----- PROTECTED REGION ID(CCDSpectrometer::read_NoiseSubtraction) ENABLED START -----*/ + /* clang-format on */ + // Set the attribute value + attr.set_value(attr_NoiseSubtraction_read); + /* clang-format off */ + /*----- PROTECTED REGION END -----*/ // CCDSpectrometer::read_NoiseSubtraction +} +//-------------------------------------------------------- +/** + * Write attribute NoiseSubtraction related method + * Description: Enable/Disable subtraction of background noise profile + * acquired with the AcquireNoise command + * + * Data type: Tango::DevBoolean + * Attr type: Scalar + */ +//-------------------------------------------------------- +void CCDSpectrometer::write_NoiseSubtraction(Tango::WAttribute &attr) +{ + DEBUG_STREAM << "CCDSpectrometer::write_NoiseSubtraction(Tango::WAttribute &attr) entering... " << std::endl; + // Retrieve write value + Tango::DevBoolean w_val; + attr.get_write_value(w_val); + /*----- PROTECTED REGION ID(CCDSpectrometer::write_NoiseSubtraction) ENABLED START -----*/ + /* clang-format on */ + // Add your own code + *attr_NoiseSubtraction_read = w_val; + /* clang-format off */ + /*----- PROTECTED REGION END -----*/ // CCDSpectrometer::write_NoiseSubtraction +} +//-------------------------------------------------------- +/** + * Read attribute GaussFitEnable related method + * + * + * Data type: Tango::DevBoolean + * Attr type: Scalar + */ +//-------------------------------------------------------- +void CCDSpectrometer::read_GaussFitEnable(Tango::Attribute &attr) +{ + DEBUG_STREAM << "CCDSpectrometer::read_GaussFitEnable(Tango::Attribute &attr) entering... " << std::endl; + /*----- PROTECTED REGION ID(CCDSpectrometer::read_GaussFitEnable) ENABLED START -----*/ + /* clang-format on */ + // Set the attribute value + attr.set_value(attr_GaussFitEnable_read); + /* clang-format off */ + /*----- PROTECTED REGION END -----*/ // CCDSpectrometer::read_GaussFitEnable +} +//-------------------------------------------------------- +/** + * Write attribute GaussFitEnable related method + * + * + * Data type: Tango::DevBoolean + * Attr type: Scalar + */ +//-------------------------------------------------------- +void CCDSpectrometer::write_GaussFitEnable(Tango::WAttribute &attr) +{ + DEBUG_STREAM << "CCDSpectrometer::write_GaussFitEnable(Tango::WAttribute &attr) entering... " << std::endl; + // Retrieve write value + Tango::DevBoolean w_val; + attr.get_write_value(w_val); + /*----- PROTECTED REGION ID(CCDSpectrometer::write_GaussFitEnable) ENABLED START -----*/ + /* clang-format on */ + // Add your own code + *attr_GaussFitEnable_read = w_val; + /* clang-format off */ + /*----- PROTECTED REGION END -----*/ // CCDSpectrometer::write_GaussFitEnable +} +//-------------------------------------------------------- +/** + * Read attribute FWHMEnable related method + * + * + * Data type: Tango::DevBoolean + * Attr type: Scalar + */ +//-------------------------------------------------------- +void CCDSpectrometer::read_FWHMEnable(Tango::Attribute &attr) +{ + DEBUG_STREAM << "CCDSpectrometer::read_FWHMEnable(Tango::Attribute &attr) entering... " << std::endl; + /*----- PROTECTED REGION ID(CCDSpectrometer::read_FWHMEnable) ENABLED START -----*/ + /* clang-format on */ + // Set the attribute value + attr.set_value(attr_FWHMEnable_read); + /* clang-format off */ + /*----- PROTECTED REGION END -----*/ // CCDSpectrometer::read_FWHMEnable +} +//-------------------------------------------------------- +/** + * Write attribute FWHMEnable related method + * + * + * Data type: Tango::DevBoolean + * Attr type: Scalar + */ +//-------------------------------------------------------- +void CCDSpectrometer::write_FWHMEnable(Tango::WAttribute &attr) +{ + DEBUG_STREAM << "CCDSpectrometer::write_FWHMEnable(Tango::WAttribute &attr) entering... " << std::endl; + // Retrieve write value + Tango::DevBoolean w_val; + attr.get_write_value(w_val); + /*----- PROTECTED REGION ID(CCDSpectrometer::write_FWHMEnable) ENABLED START -----*/ + /* clang-format on */ + // Add your own code + *attr_FWHMEnable_read = w_val; + /* clang-format off */ + /*----- PROTECTED REGION END -----*/ // CCDSpectrometer::write_FWHMEnable +} +//-------------------------------------------------------- +/** + * Read attribute GaussFitCenter related method + * Description: wavelength of peak of Gaussian Fit + * + * Data type: Tango::DevDouble + * Attr type: Scalar + */ +//-------------------------------------------------------- +void CCDSpectrometer::read_GaussFitCenter(Tango::Attribute &attr) +{ + DEBUG_STREAM << "CCDSpectrometer::read_GaussFitCenter(Tango::Attribute &attr) entering... " << std::endl; + /*----- PROTECTED REGION ID(CCDSpectrometer::read_GaussFitCenter) ENABLED START -----*/ + /* clang-format on */ + // Set the attribute value + if(GaussFit_valid) + { + attr.set_value(attr_GaussFitCenter_read); + } + else + { + attr.set_quality(Tango::ATTR_INVALID); + } + /* clang-format off */ + /*----- PROTECTED REGION END -----*/ // CCDSpectrometer::read_GaussFitCenter +} +//-------------------------------------------------------- +/** + * Read attribute GaussFitWidth related method + * Description: width of Gaussian Fit + * + * Data type: Tango::DevDouble + * Attr type: Scalar + */ +//-------------------------------------------------------- +void CCDSpectrometer::read_GaussFitWidth(Tango::Attribute &attr) +{ + DEBUG_STREAM << "CCDSpectrometer::read_GaussFitWidth(Tango::Attribute &attr) entering... " << std::endl; + /*----- PROTECTED REGION ID(CCDSpectrometer::read_GaussFitWidth) ENABLED START -----*/ + /* clang-format on */ + // Set the attribute value + if(GaussFit_valid) + { + attr.set_value(attr_GaussFitWidth_read); + } + else + { + attr.set_quality(Tango::ATTR_INVALID); + } + /* clang-format off */ + /*----- PROTECTED REGION END -----*/ // CCDSpectrometer::read_GaussFitWidth +} +//-------------------------------------------------------- +/** + * Read attribute FWHMCenter related method + * Description: wavelength of peak of FWHM + * + * Data type: Tango::DevDouble + * Attr type: Scalar + */ +//-------------------------------------------------------- +void CCDSpectrometer::read_FWHMCenter(Tango::Attribute &attr) +{ + DEBUG_STREAM << "CCDSpectrometer::read_FWHMCenter(Tango::Attribute &attr) entering... " << std::endl; + /*----- PROTECTED REGION ID(CCDSpectrometer::read_FWHMCenter) ENABLED START -----*/ + /* clang-format on */ + // Set the attribute value + attr.set_value(attr_FWHMCenter_read); + /* clang-format off */ + /*----- PROTECTED REGION END -----*/ // CCDSpectrometer::read_FWHMCenter +} +//-------------------------------------------------------- +/** + * Read attribute FWHMWidth related method + * Description: width of FWHM + * + * Data type: Tango::DevDouble + * Attr type: Scalar + */ +//-------------------------------------------------------- +void CCDSpectrometer::read_FWHMWidth(Tango::Attribute &attr) +{ + DEBUG_STREAM << "CCDSpectrometer::read_FWHMWidth(Tango::Attribute &attr) entering... " << std::endl; + /*----- PROTECTED REGION ID(CCDSpectrometer::read_FWHMWidth) ENABLED START -----*/ + /* clang-format on */ + // Set the attribute value + attr.set_value(attr_FWHMWidth_read); + /* clang-format off */ + /*----- PROTECTED REGION END -----*/ // CCDSpectrometer::read_FWHMWidth +} +//-------------------------------------------------------- +/** + * Read attribute Center related method + * Description: wavelength of peak of FWHM or of Gaussian Fit + * + * Data type: Tango::DevDouble + * Attr type: Scalar + */ +//-------------------------------------------------------- +void CCDSpectrometer::read_Center(Tango::Attribute &attr) +{ + DEBUG_STREAM << "CCDSpectrometer::read_Center(Tango::Attribute &attr) entering... " << std::endl; + /*----- PROTECTED REGION ID(CCDSpectrometer::read_Center) ENABLED START -----*/ + /* clang-format on */ + // Set the attribute value + if(*attr_FWHMEnable_read || (*attr_GaussFitEnable_read && GaussFit_valid)) + attr.set_value(attr_Center_read); + else + attr.set_quality(Tango::ATTR_INVALID); + /* clang-format off */ + /*----- PROTECTED REGION END -----*/ // CCDSpectrometer::read_Center +} +//-------------------------------------------------------- +/** + * Read attribute Width related method + * Description: width of FWHM or of Gaussian Fit + * + * Data type: Tango::DevDouble + * Attr type: Scalar + */ +//-------------------------------------------------------- +void CCDSpectrometer::read_Width(Tango::Attribute &attr) +{ + DEBUG_STREAM << "CCDSpectrometer::read_Width(Tango::Attribute &attr) entering... " << std::endl; + /*----- PROTECTED REGION ID(CCDSpectrometer::read_Width) ENABLED START -----*/ + /* clang-format on */ + // Set the attribute value + if(*attr_FWHMEnable_read || (*attr_GaussFitEnable_read && GaussFit_valid)) + attr.set_value(attr_Width_read); + else + attr.set_quality(Tango::ATTR_INVALID); + /* clang-format off */ + /*----- PROTECTED REGION END -----*/ // CCDSpectrometer::read_Width +} +//-------------------------------------------------------- +/** + * Read attribute FitType related method + * Description: 1=Gaussian 2=Gaussian Asymm 3=Confiteor + * + * Data type: Tango::DevLong + * Attr type: Scalar + */ +//-------------------------------------------------------- +void CCDSpectrometer::read_FitType(Tango::Attribute &attr) +{ + DEBUG_STREAM << "CCDSpectrometer::read_FitType(Tango::Attribute &attr) entering... " << std::endl; + /*----- PROTECTED REGION ID(CCDSpectrometer::read_FitType) ENABLED START -----*/ + /* clang-format on */ + // Set the attribute value + attr.set_value(attr_FitType_read); + /* clang-format off */ + /*----- PROTECTED REGION END -----*/ // CCDSpectrometer::read_FitType +} +//-------------------------------------------------------- +/** + * Write attribute FitType related method + * Description: 1=Gaussian 2=Gaussian Asymm 3=Confiteor + * + * Data type: Tango::DevLong + * Attr type: Scalar + */ +//-------------------------------------------------------- +void CCDSpectrometer::write_FitType(Tango::WAttribute &attr) +{ + DEBUG_STREAM << "CCDSpectrometer::write_FitType(Tango::WAttribute &attr) entering... " << std::endl; + // Retrieve write value + Tango::DevLong w_val; + attr.get_write_value(w_val); + /*----- PROTECTED REGION ID(CCDSpectrometer::write_FitType) ENABLED START -----*/ + /* clang-format on */ + // Add your own code + *attr_FitType_read = w_val; + /* clang-format off */ + /*----- PROTECTED REGION END -----*/ // CCDSpectrometer::write_FitType +} +//-------------------------------------------------------- +/** + * Read attribute FWHMAvg related method + * + * + * Data type: Tango::DevLong + * Attr type: Scalar + */ +//-------------------------------------------------------- +void CCDSpectrometer::read_FWHMAvg(Tango::Attribute &attr) +{ + DEBUG_STREAM << "CCDSpectrometer::read_FWHMAvg(Tango::Attribute &attr) entering... " << std::endl; + /*----- PROTECTED REGION ID(CCDSpectrometer::read_FWHMAvg) ENABLED START -----*/ + /* clang-format on */ + // Set the attribute value + attr.set_value(attr_FWHMAvg_read); + /* clang-format off */ + /*----- PROTECTED REGION END -----*/ // CCDSpectrometer::read_FWHMAvg +} +//-------------------------------------------------------- +/** + * Write attribute FWHMAvg related method + * + * + * Data type: Tango::DevLong + * Attr type: Scalar + */ +//-------------------------------------------------------- +void CCDSpectrometer::write_FWHMAvg(Tango::WAttribute &attr) +{ + DEBUG_STREAM << "CCDSpectrometer::write_FWHMAvg(Tango::WAttribute &attr) entering... " << std::endl; + // Retrieve write value + Tango::DevLong w_val; + attr.get_write_value(w_val); + /*----- PROTECTED REGION ID(CCDSpectrometer::write_FWHMAvg) ENABLED START -----*/ + /* clang-format on */ + // Add your own code + *attr_FWHMAvg_read = w_val; + /* clang-format off */ + /*----- PROTECTED REGION END -----*/ // CCDSpectrometer::write_FWHMAvg +} +//-------------------------------------------------------- +/** + * Read attribute NoiseLevel related method + * + * + * Data type: Tango::DevLong + * Attr type: Scalar + */ +//-------------------------------------------------------- +void CCDSpectrometer::read_NoiseLevel(Tango::Attribute &attr) +{ + DEBUG_STREAM << "CCDSpectrometer::read_NoiseLevel(Tango::Attribute &attr) entering... " << std::endl; + /*----- PROTECTED REGION ID(CCDSpectrometer::read_NoiseLevel) ENABLED START -----*/ + /* clang-format on */ + // Set the attribute value + *attr_NoiseLevel_read = noise_level; + attr.set_value(attr_NoiseLevel_read); + /* clang-format off */ + /*----- PROTECTED REGION END -----*/ // CCDSpectrometer::read_NoiseLevel +} +//-------------------------------------------------------- +/** + * Write attribute NoiseLevel related method + * + * + * Data type: Tango::DevLong + * Attr type: Scalar + */ +//-------------------------------------------------------- +void CCDSpectrometer::write_NoiseLevel(Tango::WAttribute &attr) +{ + DEBUG_STREAM << "CCDSpectrometer::write_NoiseLevel(Tango::WAttribute &attr) entering... " << std::endl; + // Retrieve write value + Tango::DevLong w_val; + attr.get_write_value(w_val); + /*----- PROTECTED REGION ID(CCDSpectrometer::write_NoiseLevel) ENABLED START -----*/ + /* clang-format on */ + // Add your own code + noise_level = w_val; + /* clang-format off */ + /*----- PROTECTED REGION END -----*/ // CCDSpectrometer::write_NoiseLevel +} +//-------------------------------------------------------- +/** + * Read attribute DataReferenceFile related method + * + * + * Data type: Tango::DevString + * Attr type: Scalar + */ +//-------------------------------------------------------- +void CCDSpectrometer::read_DataReferenceFile(Tango::Attribute &attr) +{ + DEBUG_STREAM << "CCDSpectrometer::read_DataReferenceFile(Tango::Attribute &attr) entering... " << std::endl; + /*----- PROTECTED REGION ID(CCDSpectrometer::read_DataReferenceFile) ENABLED START -----*/ + /* clang-format on */ + // Set the attribute value + attr_tmp_ptr = attr_strchar; + attr_DataReferenceFile_read = &attr_tmp_ptr; + attr.set_value(attr_DataReferenceFile_read); + /* clang-format off */ + /*----- PROTECTED REGION END -----*/ // CCDSpectrometer::read_DataReferenceFile +} +//-------------------------------------------------------- +/** + * Write attribute DataReferenceFile related method + * + * + * Data type: Tango::DevString + * Attr type: Scalar + */ +//-------------------------------------------------------- +void CCDSpectrometer::write_DataReferenceFile(Tango::WAttribute &attr) +{ + DEBUG_STREAM << "CCDSpectrometer::write_DataReferenceFile(Tango::WAttribute &attr) entering... " << std::endl; + // Retrieve write value + Tango::DevString w_val; + attr.get_write_value(w_val); + /*----- PROTECTED REGION ID(CCDSpectrometer::write_DataReferenceFile) ENABLED START -----*/ + /* clang-format on */ + // Add your own code + ostringstream tempstr; + + tempstr << w_val << ends; + if(tempstr.str().length() < sizeof(attr_strchar)) + { + strcpy(attr_strchar,tempstr.str().c_str()); + if(strlen(attr_strchar) > 0) + { + dataReferenceFile = tempstr.str(); + + ifstream fd; //startup file + fd.open(dataReferenceFile.c_str()); + if (!fd) + { + stringstream tmp; + tmp << "Cannot open Data Reference file:" << strerror(errno) << endl; + INFO_STREAM << "CCDSpectrometer::write_DataReferenceFile(): " << tmp.str(); + Tango::Except::throw_exception( + (const char *) "Error opening file", + tmp.str(), + (const char *) "CCDSpectrometer::write_DataReferenceFile()", Tango::ERR); + } + else{ + DEBUG_STREAM << "CCDSpectrometer::write_DataReferenceFile(): file opened successfully" << endl; + string lineread; + int i=0; + double val; + while(std::getline(fd, lineread, '\n')) + { // Read line by line + if(lineread.length() > 0 && i < numPixel) + { + sscanf(lineread.c_str(),"%lf",&val); + pReferenceData[i++] = val; + } + } + fd.close(); + } + } + } + /* clang-format off */ + /*----- PROTECTED REGION END -----*/ // CCDSpectrometer::write_DataReferenceFile +} +//-------------------------------------------------------- +/** + * Read attribute AutoExposure related method + * + * + * Data type: Tango::DevBoolean + * Attr type: Scalar + */ +//-------------------------------------------------------- +void CCDSpectrometer::read_AutoExposure(Tango::Attribute &attr) +{ + DEBUG_STREAM << "CCDSpectrometer::read_AutoExposure(Tango::Attribute &attr) entering... " << std::endl; + /*----- PROTECTED REGION ID(CCDSpectrometer::read_AutoExposure) ENABLED START -----*/ + /* clang-format on */ + // Set the attribute value + attr.set_value(attr_AutoExposure_read); + /* clang-format off */ + /*----- PROTECTED REGION END -----*/ // CCDSpectrometer::read_AutoExposure +} +//-------------------------------------------------------- +/** + * Write attribute AutoExposure related method + * + * + * Data type: Tango::DevBoolean + * Attr type: Scalar + */ +//-------------------------------------------------------- +void CCDSpectrometer::write_AutoExposure(Tango::WAttribute &attr) +{ + DEBUG_STREAM << "CCDSpectrometer::write_AutoExposure(Tango::WAttribute &attr) entering... " << std::endl; + // Retrieve write value + Tango::DevBoolean w_val; + attr.get_write_value(w_val); + /*----- PROTECTED REGION ID(CCDSpectrometer::write_AutoExposure) ENABLED START -----*/ + /* clang-format on */ + // Add your own code + *attr_AutoExposure_read = w_val; + /* clang-format off */ + /*----- PROTECTED REGION END -----*/ // CCDSpectrometer::write_AutoExposure +} +//-------------------------------------------------------- +/** + * Read attribute RtMode related method + * + * + * Data type: Tango::DevBoolean + * Attr type: Scalar + */ +//-------------------------------------------------------- +void CCDSpectrometer::read_RtMode(Tango::Attribute &attr) +{ + DEBUG_STREAM << "CCDSpectrometer::read_RtMode(Tango::Attribute &attr) entering... " << std::endl; + /*----- PROTECTED REGION ID(CCDSpectrometer::read_RtMode) ENABLED START -----*/ + /* clang-format on */ + // Set the attribute value + attr.set_value(attr_RtMode_read); + /* clang-format off */ + /*----- PROTECTED REGION END -----*/ // CCDSpectrometer::read_RtMode +} +//-------------------------------------------------------- +/** + * Write attribute RtMode related method + * + * + * Data type: Tango::DevBoolean + * Attr type: Scalar + */ +//-------------------------------------------------------- +void CCDSpectrometer::write_RtMode(Tango::WAttribute &attr) +{ + DEBUG_STREAM << "CCDSpectrometer::write_RtMode(Tango::WAttribute &attr) entering... " << std::endl; + // Retrieve write value + Tango::DevBoolean w_val; + attr.get_write_value(w_val); + /*----- PROTECTED REGION ID(CCDSpectrometer::write_RtMode) ENABLED START -----*/ + /* clang-format on */ + // Add your own code + *attr_RtMode_read = w_val; + /* clang-format off */ + /*----- PROTECTED REGION END -----*/ // CCDSpectrometer::write_RtMode +} +//-------------------------------------------------------- +/** + * Read attribute IntensityCalibrationEnable related method + * + * + * Data type: Tango::DevBoolean + * Attr type: Scalar + */ +//-------------------------------------------------------- +void CCDSpectrometer::read_IntensityCalibrationEnable(Tango::Attribute &attr) +{ + DEBUG_STREAM << "CCDSpectrometer::read_IntensityCalibrationEnable(Tango::Attribute &attr) entering... " << std::endl; + /*----- PROTECTED REGION ID(CCDSpectrometer::read_IntensityCalibrationEnable) ENABLED START -----*/ + /* clang-format on */ + // Set the attribute value + attr.set_value(attr_IntensityCalibrationEnable_read); + /* clang-format off */ + /*----- PROTECTED REGION END -----*/ // CCDSpectrometer::read_IntensityCalibrationEnable +} +//-------------------------------------------------------- +/** + * Write attribute IntensityCalibrationEnable related method + * + * + * Data type: Tango::DevBoolean + * Attr type: Scalar + */ +//-------------------------------------------------------- +void CCDSpectrometer::write_IntensityCalibrationEnable(Tango::WAttribute &attr) +{ + DEBUG_STREAM << "CCDSpectrometer::write_IntensityCalibrationEnable(Tango::WAttribute &attr) entering... " << std::endl; + // Retrieve write value + Tango::DevBoolean w_val; + attr.get_write_value(w_val); + /*----- PROTECTED REGION ID(CCDSpectrometer::write_IntensityCalibrationEnable) ENABLED START -----*/ + /* clang-format on */ + // Add your own code + *attr_IntensityCalibrationEnable_read = w_val; + /* clang-format off */ + /*----- PROTECTED REGION END -----*/ // CCDSpectrometer::write_IntensityCalibrationEnable +} +//-------------------------------------------------------- +/** + * Read attribute Area related method + * + * + * Data type: Tango::DevDouble + * Attr type: Scalar + */ +//-------------------------------------------------------- +void CCDSpectrometer::read_Area(Tango::Attribute &attr) +{ + DEBUG_STREAM << "CCDSpectrometer::read_Area(Tango::Attribute &attr) entering... " << std::endl; + /*----- PROTECTED REGION ID(CCDSpectrometer::read_Area) ENABLED START -----*/ + /* clang-format on */ + // Set the attribute value + attr.set_value(attr_Area_read); + /* clang-format off */ + /*----- PROTECTED REGION END -----*/ // CCDSpectrometer::read_Area +} +//-------------------------------------------------------- +/** + * Read attribute AreaRegion related method + * + * + * Data type: Tango::DevDouble + * Attr type: Scalar + */ +//-------------------------------------------------------- +void CCDSpectrometer::read_AreaRegion(Tango::Attribute &attr) +{ + DEBUG_STREAM << "CCDSpectrometer::read_AreaRegion(Tango::Attribute &attr) entering... " << std::endl; + /*----- PROTECTED REGION ID(CCDSpectrometer::read_AreaRegion) ENABLED START -----*/ + /* clang-format on */ + // Set the attribute value + attr.set_value(attr_AreaRegion_read); + /* clang-format off */ + /*----- PROTECTED REGION END -----*/ // CCDSpectrometer::read_AreaRegion +} +//-------------------------------------------------------- +/** + * Write attribute AreaRegion related method + * + * + * Data type: Tango::DevDouble + * Attr type: Scalar + */ +//-------------------------------------------------------- +void CCDSpectrometer::write_AreaRegion(Tango::WAttribute &attr) +{ + DEBUG_STREAM << "CCDSpectrometer::write_AreaRegion(Tango::WAttribute &attr) entering... " << std::endl; + // Retrieve write value + Tango::DevDouble w_val; + attr.get_write_value(w_val); + /*----- PROTECTED REGION ID(CCDSpectrometer::write_AreaRegion) ENABLED START -----*/ + /* clang-format on */ + // Add your own code + *attr_AreaRegion_read = w_val; + /* clang-format off */ + /*----- PROTECTED REGION END -----*/ // CCDSpectrometer::write_AreaRegion +} +//-------------------------------------------------------- +/** + * Read attribute AreaEnable related method + * + * + * Data type: Tango::DevBoolean + * Attr type: Scalar + */ +//-------------------------------------------------------- +void CCDSpectrometer::read_AreaEnable(Tango::Attribute &attr) +{ + DEBUG_STREAM << "CCDSpectrometer::read_AreaEnable(Tango::Attribute &attr) entering... " << std::endl; + /*----- PROTECTED REGION ID(CCDSpectrometer::read_AreaEnable) ENABLED START -----*/ + /* clang-format on */ + // Set the attribute value + attr.set_value(attr_AreaEnable_read); + /* clang-format off */ + /*----- PROTECTED REGION END -----*/ // CCDSpectrometer::read_AreaEnable +} +//-------------------------------------------------------- +/** + * Write attribute AreaEnable related method + * + * + * Data type: Tango::DevBoolean + * Attr type: Scalar + */ +//-------------------------------------------------------- +void CCDSpectrometer::write_AreaEnable(Tango::WAttribute &attr) +{ + DEBUG_STREAM << "CCDSpectrometer::write_AreaEnable(Tango::WAttribute &attr) entering... " << std::endl; + // Retrieve write value + Tango::DevBoolean w_val; + attr.get_write_value(w_val); + /*----- PROTECTED REGION ID(CCDSpectrometer::write_AreaEnable) ENABLED START -----*/ + /* clang-format on */ + // Add your own code + *attr_AreaEnable_read = w_val; + /* clang-format off */ + /*----- PROTECTED REGION END -----*/ // CCDSpectrometer::write_AreaEnable +} +//-------------------------------------------------------- +/** + * Read attribute WidthCorrectionEnable related method + * Description: enable widht correction + * + * Data type: Tango::DevBoolean + * Attr type: Scalar + */ +//-------------------------------------------------------- +void CCDSpectrometer::read_WidthCorrectionEnable(Tango::Attribute &attr) +{ + DEBUG_STREAM << "CCDSpectrometer::read_WidthCorrectionEnable(Tango::Attribute &attr) entering... " << std::endl; + /*----- PROTECTED REGION ID(CCDSpectrometer::read_WidthCorrectionEnable) ENABLED START -----*/ + /* clang-format on */ + // Set the attribute value + attr.set_value(attr_WidthCorrectionEnable_read); + /* clang-format off */ + /*----- PROTECTED REGION END -----*/ // CCDSpectrometer::read_WidthCorrectionEnable +} +//-------------------------------------------------------- +/** + * Write attribute WidthCorrectionEnable related method + * Description: enable widht correction + * + * Data type: Tango::DevBoolean + * Attr type: Scalar + */ +//-------------------------------------------------------- +void CCDSpectrometer::write_WidthCorrectionEnable(Tango::WAttribute &attr) +{ + DEBUG_STREAM << "CCDSpectrometer::write_WidthCorrectionEnable(Tango::WAttribute &attr) entering... " << std::endl; + // Retrieve write value + Tango::DevBoolean w_val; + attr.get_write_value(w_val); + /*----- PROTECTED REGION ID(CCDSpectrometer::write_WidthCorrectionEnable) ENABLED START -----*/ + /* clang-format on */ + // Add your own code + *attr_WidthCorrectionEnable_read = w_val; + /* clang-format off */ + /*----- PROTECTED REGION END -----*/ // CCDSpectrometer::write_WidthCorrectionEnable +} +//-------------------------------------------------------- +/** + * Read attribute IncrSensitivity related method + * Description: false: use standard sensitivity + * true: use increased sensitivity + * + * Data type: Tango::DevBoolean + * Attr type: Scalar + */ +//-------------------------------------------------------- +void CCDSpectrometer::read_IncrSensitivity(Tango::Attribute &attr) +{ + DEBUG_STREAM << "CCDSpectrometer::read_IncrSensitivity(Tango::Attribute &attr) entering... " << std::endl; + /*----- PROTECTED REGION ID(CCDSpectrometer::read_IncrSensitivity) ENABLED START -----*/ + /* clang-format on */ + // Set the attribute value + attr.set_value(attr_IncrSensitivity_read); + /* clang-format off */ + /*----- PROTECTED REGION END -----*/ // CCDSpectrometer::read_IncrSensitivity +} +//-------------------------------------------------------- +/** + * Write attribute IncrSensitivity related method + * Description: false: use standard sensitivity + * true: use increased sensitivity + * + * Data type: Tango::DevBoolean + * Attr type: Scalar + */ +//-------------------------------------------------------- +void CCDSpectrometer::write_IncrSensitivity(Tango::WAttribute &attr) +{ + DEBUG_STREAM << "CCDSpectrometer::write_IncrSensitivity(Tango::WAttribute &attr) entering... " << std::endl; + // Retrieve write value + Tango::DevBoolean w_val; + attr.get_write_value(w_val); + /*----- PROTECTED REGION ID(CCDSpectrometer::write_IncrSensitivity) ENABLED START -----*/ + /* clang-format on */ + // Add your own code + *attr_IncrSensitivity_read = w_val;//TODO: SUPPORTED? + /* clang-format off */ + /*----- PROTECTED REGION END -----*/ // CCDSpectrometer::write_IncrSensitivity +} +//-------------------------------------------------------- +/** + * Read attribute Data related method + * + * + * Data type: Tango::DevDouble + * Attr type: Spectrum max = 4100 + */ +//-------------------------------------------------------- +void CCDSpectrometer::read_Data(Tango::Attribute &attr) +{ + DEBUG_STREAM << "CCDSpectrometer::read_Data(Tango::Attribute &attr) entering... " << std::endl; + /*----- PROTECTED REGION ID(CCDSpectrometer::read_Data) ENABLED START -----*/ + /* clang-format on */ + // Set the attribute value + //attr.set_value(attr_Data_read, DataAttrib::X_DATA_SIZE); +#ifdef _NON_AVERAGE + if(pLiveData) + { + attr_Data_read = (Tango::DevLong *)&(pLiveData[0 + attr_RegionOfInterest_read[0]]); + attr.set_value(attr_Data_read,attr_RegionOfInterest_read[1] - attr_RegionOfInterest_read[0]); + } +#else + if(pLiveData_avg) + { + //DEBUG_STREAM << "CCDSpectrometer::read_Data() ROIStartPix"<<RegionOfInterestStartPix<<" ROIEndPix="<<RegionOfInterestEndPix<<" size="<<RegionOfInterestEndPix - RegionOfInterestStartPix + 1<< endl; + //attr_Data_read = (Tango::DevLong *)&(pLiveData_avg[0 + WaveLenght2Pix(attr_RegionOfInterest_read[0])]); + attr_Data_read = (Tango::DevDouble *)&(pLiveData_avg[0 + RegionOfInterestStartPix]); + //attr.set_value(attr_Data_read,WaveLenght2Pix(attr_RegionOfInterest_read[1]) - WaveLenght2Pix(attr_RegionOfInterest_read[0])); + attr.set_value(attr_Data_read,RegionOfInterestEndPix - RegionOfInterestStartPix + 1); + } +#endif + else + attr.set_quality(Tango::ATTR_INVALID); + /* clang-format off */ + /*----- PROTECTED REGION END -----*/ // CCDSpectrometer::read_Data +} +//-------------------------------------------------------- +/** + * Read attribute NumPixels related method + * Description: long[0]: number of pixels horizontally (number of CCD-array columns) + * long[1]: number of pixels vertically (number of CCD-array lines) + * + * Data type: Tango::DevLong + * Attr type: Spectrum max = 2 + */ +//-------------------------------------------------------- +void CCDSpectrometer::read_NumPixels(Tango::Attribute &attr) +{ + DEBUG_STREAM << "CCDSpectrometer::read_NumPixels(Tango::Attribute &attr) entering... " << std::endl; + /*----- PROTECTED REGION ID(CCDSpectrometer::read_NumPixels) ENABLED START -----*/ + /* clang-format on */ + attr_NumPixels_read[0] = numPixel; + attr_NumPixels_read[1] = 1; + // Set the attribute value + attr.set_value(attr_NumPixels_read, NumPixelsAttrib::X_DATA_SIZE); + /* clang-format off */ + /*----- PROTECTED REGION END -----*/ // CCDSpectrometer::read_NumPixels +} +//-------------------------------------------------------- +/** + * Read attribute RegionOfInterest related method + * Description: Region of interest returned by the Data attribute + * double[0]=start of the region + * double[1]=end of the region + * + * Values are in nm according with the conversion factor in x_values + * Data attribute property + * + * Data type: Tango::DevDouble + * Attr type: Spectrum max = 2 + */ +//-------------------------------------------------------- +void CCDSpectrometer::read_RegionOfInterest(Tango::Attribute &attr) +{ + DEBUG_STREAM << "CCDSpectrometer::read_RegionOfInterest(Tango::Attribute &attr) entering... " << std::endl; + /*----- PROTECTED REGION ID(CCDSpectrometer::read_RegionOfInterest) ENABLED START -----*/ + /* clang-format on */ + // Set the attribute value + vector<Tango::DevLong> hwroi; + try { + dpmutex->lock(); + dp->read_attribute(ROI_ATTR)>>(hwroi); + dpmutex->unlock(); + DEBUG_STREAM << __func__ << ": read hwroi.size=" << hwroi.size(); + if(hwroi.size() >= 4) + { + if(hwroi[0] > 0 && hwroi[0] < numPixel) + { + attr_RegionOfInterest_read[0] = x_values[hwroi[0]]; + RegionOfInterestStartPix = hwroi[0]; + + } + if(hwroi[2] > 0 && hwroi[2] < numPixel) + { + attr_RegionOfInterest_read[1] = x_values[hwroi[2]]; + RegionOfInterestEndPix = hwroi[2]; + } + } + } + catch(Tango::DevFailed &e) + { + dpmutex->unlock(); + INFO_STREAM << __func__ << ": error reading =" << e.errors[0].desc; + Tango::Except::re_throw_exception(e, + (const char *) "Error", + (const char *) "Read Error", + (const char *) __func__, Tango::ERR); + } + + + attr.set_value(attr_RegionOfInterest_read, RegionOfInterestAttrib::X_DATA_SIZE); + /* clang-format off */ + /*----- PROTECTED REGION END -----*/ // CCDSpectrometer::read_RegionOfInterest +} +//-------------------------------------------------------- +/** + * Write attribute RegionOfInterest related method + * Description: Region of interest returned by the Data attribute + * double[0]=start of the region + * double[1]=end of the region + * + * Values are in nm according with the conversion factor in x_values + * Data attribute property + * + * Data type: Tango::DevDouble + * Attr type: Spectrum max = 2 + */ +//-------------------------------------------------------- +void CCDSpectrometer::write_RegionOfInterest(Tango::WAttribute &attr) +{ + DEBUG_STREAM << "CCDSpectrometer::write_RegionOfInterest(Tango::WAttribute &attr) entering... " << std::endl; + // Retrieve number of write values + int w_length = attr.get_write_value_length(); + + // Retrieve pointer on write values (Do not delete !) + const Tango::DevDouble *w_val; + attr.get_write_value(w_val); + /*----- PROTECTED REGION ID(CCDSpectrometer::write_RegionOfInterest) ENABLED START -----*/ + /* clang-format on */ + // Add your own code + if(get_state()==Tango::FAULT) + { + Tango::Except::throw_exception( + (const char *) "CCD not communicating", + (const char *) "CCD not communicating", + (const char *) __func__, Tango::ERR); + } + if(w_length != 2) + { + Tango::Except::throw_exception( + (const char *) "Wrong parameters", + (const char *) "Expected 2 parameters", + (const char *) __func__, Tango::ERR); + } + Tango::DevDouble w_val_[2]; + w_val_[0] = floor(w_val[0]*1000.0)*0.001; + w_val_[1] = floor(w_val[1]*1000.0)*0.001; + if(w_val_[0] < x_values[0] || w_val_[0] > x_values[numPixel-1] || + w_val_[1] < x_values[0] || w_val_[1] > x_values[numPixel-1] || + w_val_[0] >= w_val_[1]) + { + TangoSys_MemStream out_stream; + out_stream << "Region ["<<w_val_[0]<<","<<w_val_[1]<<"] not allowed, it has to be in ["<<x_values[0]<<"," << x_values[numPixel-1] << "]" << ends; + Tango::Except::throw_exception( + (const char *) "Value not Allowed", + out_stream.str(), + (const char *) __func__, Tango::ERR); + } + RegionOfInterestStartPix = WaveLenght2Pix(w_val_[0]); + DEBUG_STREAM << __func__<<": StartROI="<<w_val_[0]<<" -> start pix="<<RegionOfInterestStartPix; + if(x_values[RegionOfInterestStartPix] < w_val_[0]) + { + RegionOfInterestStartPix++; + } + DEBUG_STREAM << __func__<<": ...-> adjusted start pix="<<RegionOfInterestStartPix; + attr_RegionOfInterest_read[0] = x_values[RegionOfInterestStartPix]; + RegionOfInterestEndPix = WaveLenght2Pix(w_val_[1]); + DEBUG_STREAM << __func__<<": EndROI="<<w_val_[1]<<" -> end pix="<<RegionOfInterestEndPix; + if(x_values[RegionOfInterestEndPix] > w_val_[1]) + { + RegionOfInterestEndPix--; + } + DEBUG_STREAM << __func__<<": ...-> adjusted end pix="<<RegionOfInterestEndPix; + attr_RegionOfInterest_read[1] = x_values[RegionOfInterestEndPix]; + tbuf_array_w.reset_rt_buffer(); + tbuf_array_l.reset_rt_buffer(); + + vector<Tango::DevLong> hwroi_r; + vector<Tango::DevLong> hwroi_w; + try { + dpmutex->lock(); + dp->read_attribute(ROI_ATTR)>>(hwroi_r); + if(hwroi_r.size() >= 4) + { + hwroi_w.push_back(RegionOfInterestStartPix); + hwroi_w.push_back(hwroi_r[1]); + hwroi_w.push_back(RegionOfInterestEndPix); + hwroi_w.push_back(hwroi_r[3]); + } + Tango::DeviceAttribute Din(ROI_ATTR,hwroi_w); + dp->write_attribute(Din); + dpmutex->unlock(); + } + catch(Tango::DevFailed &e) + { + dpmutex->unlock(); + INFO_STREAM << __func__ << ": error reading =" << e.errors[0].desc; + Tango::Except::re_throw_exception(e, + (const char *) "Error", + (const char *) "Read Error", + (const char *) __func__, Tango::ERR); + } + + + /* clang-format off */ + /*----- PROTECTED REGION END -----*/ // CCDSpectrometer::write_RegionOfInterest +} +//-------------------------------------------------------- +/** + * Read attribute AnalysisRegion related method + * Description: Region used for gaussian and fwhm analysis + * double[0]=start of the region + * double[1]=end of the region + * + * Values are in nm according with the conversion factor in x_values + * Data attribute property + * + * Data type: Tango::DevDouble + * Attr type: Spectrum max = 2 + */ +//-------------------------------------------------------- +void CCDSpectrometer::read_AnalysisRegion(Tango::Attribute &attr) +{ + DEBUG_STREAM << "CCDSpectrometer::read_AnalysisRegion(Tango::Attribute &attr) entering... " << std::endl; + /*----- PROTECTED REGION ID(CCDSpectrometer::read_AnalysisRegion) ENABLED START -----*/ + /* clang-format on */ + // Set the attribute value + attr.set_value(attr_AnalysisRegion_read, AnalysisRegionAttrib::X_DATA_SIZE); + /* clang-format off */ + /*----- PROTECTED REGION END -----*/ // CCDSpectrometer::read_AnalysisRegion +} +//-------------------------------------------------------- +/** + * Write attribute AnalysisRegion related method + * Description: Region used for gaussian and fwhm analysis + * double[0]=start of the region + * double[1]=end of the region + * + * Values are in nm according with the conversion factor in x_values + * Data attribute property + * + * Data type: Tango::DevDouble + * Attr type: Spectrum max = 2 + */ +//-------------------------------------------------------- +void CCDSpectrometer::write_AnalysisRegion(Tango::WAttribute &attr) +{ + DEBUG_STREAM << "CCDSpectrometer::write_AnalysisRegion(Tango::WAttribute &attr) entering... " << std::endl; + // Retrieve number of write values + int w_length = attr.get_write_value_length(); + + // Retrieve pointer on write values (Do not delete !) + const Tango::DevDouble *w_val; + attr.get_write_value(w_val); + /*----- PROTECTED REGION ID(CCDSpectrometer::write_AnalysisRegion) ENABLED START -----*/ + /* clang-format on */ + // Add your own code + if(get_state()==Tango::FAULT) + { + Tango::Except::throw_exception( + (const char *) "CCD not communicating", + (const char *) "CCD not communicating", + (const char *) __func__, Tango::ERR); + } if(w_val[0] < x_values[0] || w_val[0] > x_values[numPixel-1] || + w_val[1] < x_values[0] || w_val[1] > x_values[numPixel-1] || + w_val[0] >= w_val[1]) + { + TangoSys_MemStream out_stream; + out_stream << "Region not allowed, it has to be in ["<<x_values[0]<<"," << x_values[numPixel-1] << "]" << ends; + Tango::Except::throw_exception( + (const char *) "Value not Allowed", + out_stream.str(), + (const char *) __func__, Tango::ERR); + } + AnalysisRegionStartPix = WaveLenght2Pix(w_val[0]); + if(x_values[AnalysisRegionStartPix] < w_val[0]) + { + AnalysisRegionStartPix++; + } + attr_AnalysisRegion_read[0] = x_values[AnalysisRegionStartPix]; + AnalysisRegionEndPix = WaveLenght2Pix(w_val[1]); + if(x_values[AnalysisRegionEndPix] > w_val[1]) + { + AnalysisRegionEndPix--; + } + attr_AnalysisRegion_read[1] = x_values[AnalysisRegionEndPix]; + /* clang-format off */ + /*----- PROTECTED REGION END -----*/ // CCDSpectrometer::write_AnalysisRegion +} +//-------------------------------------------------------- +/** + * Read attribute GaussFit related method + * Description: double[0]= wavelength of peak of Gaussian Fit + * double[1]= width of Gaussian Fit + * + * Data type: Tango::DevDouble + * Attr type: Spectrum max = 4 + */ +//-------------------------------------------------------- +void CCDSpectrometer::read_GaussFit(Tango::Attribute &attr) +{ + DEBUG_STREAM << "CCDSpectrometer::read_GaussFit(Tango::Attribute &attr) entering... " << std::endl; + /*----- PROTECTED REGION ID(CCDSpectrometer::read_GaussFit) ENABLED START -----*/ + /* clang-format on */ + // Set the attribute value + if(GaussFit_valid) + { + attr.set_value(attr_GaussFit_read,GaussFitAttrib::X_DATA_SIZE); + } + else + { + attr.set_quality(Tango::ATTR_INVALID); + } + /* clang-format off */ + /*----- PROTECTED REGION END -----*/ // CCDSpectrometer::read_GaussFit +} +//-------------------------------------------------------- +/** + * Read attribute FWHM related method + * Description: double[0]= wavelength of peak of FWHM + * double[1]= width of FWHM + * + * Data type: Tango::DevDouble + * Attr type: Spectrum max = 3 + */ +//-------------------------------------------------------- +void CCDSpectrometer::read_FWHM(Tango::Attribute &attr) +{ + DEBUG_STREAM << "CCDSpectrometer::read_FWHM(Tango::Attribute &attr) entering... " << std::endl; + /*----- PROTECTED REGION ID(CCDSpectrometer::read_FWHM) ENABLED START -----*/ + /* clang-format on */ + // Set the attribute value + attr.set_value(attr_FWHM_read, FWHMAttrib::X_DATA_SIZE); + /* clang-format off */ + /*----- PROTECTED REGION END -----*/ // CCDSpectrometer::read_FWHM +} +//-------------------------------------------------------- +/** + * Read attribute GaussReference related method + * Description: double[0]= wavelength of peak of Gaussian Fit + * double[1]= width of Gaussian Fit + * + * Data type: Tango::DevDouble + * Attr type: Spectrum max = 4 + */ +//-------------------------------------------------------- +void CCDSpectrometer::read_GaussReference(Tango::Attribute &attr) +{ + DEBUG_STREAM << "CCDSpectrometer::read_GaussReference(Tango::Attribute &attr) entering... " << std::endl; + /*----- PROTECTED REGION ID(CCDSpectrometer::read_GaussReference) ENABLED START -----*/ + /* clang-format on */ + // Set the attribute value + attr.set_value(attr_GaussReference_read, GaussReferenceAttrib::X_DATA_SIZE); + /* clang-format off */ + /*----- PROTECTED REGION END -----*/ // CCDSpectrometer::read_GaussReference +} +//-------------------------------------------------------- +/** + * Write attribute GaussReference related method + * Description: double[0]= wavelength of peak of Gaussian Fit + * double[1]= width of Gaussian Fit + * + * Data type: Tango::DevDouble + * Attr type: Spectrum max = 4 + */ +//-------------------------------------------------------- +void CCDSpectrometer::write_GaussReference(Tango::WAttribute &attr) +{ + DEBUG_STREAM << "CCDSpectrometer::write_GaussReference(Tango::WAttribute &attr) entering... " << std::endl; + // Retrieve number of write values + int w_length = attr.get_write_value_length(); + + // Retrieve pointer on write values (Do not delete !) + const Tango::DevDouble *w_val; + attr.get_write_value(w_val); + /*----- PROTECTED REGION ID(CCDSpectrometer::write_GaussReference) ENABLED START -----*/ + /* clang-format on */ + // Add your own code + attr_GaussReference_read[0] = w_val[0]; + attr_GaussReference_read[1] = w_val[1]; + attr_GaussReference_read[2] = w_val[2]; + attr_GaussReference_read[3] = w_val[3]; + /* clang-format off */ + /*----- PROTECTED REGION END -----*/ // CCDSpectrometer::write_GaussReference +} +//-------------------------------------------------------- +/** + * Read attribute DataReference related method + * Description: A reference curve + * + * Data type: Tango::DevDouble + * Attr type: Spectrum max = 5000 + */ +//-------------------------------------------------------- +void CCDSpectrometer::read_DataReference(Tango::Attribute &attr) +{ + DEBUG_STREAM << "CCDSpectrometer::read_DataReference(Tango::Attribute &attr) entering... " << std::endl; + /*----- PROTECTED REGION ID(CCDSpectrometer::read_DataReference) ENABLED START -----*/ + /* clang-format on */ + // Set the attribute value + if(pReferenceData) + { + //attr_DataReference_read = (Tango::DevLong *)&(pReferenceData[0 + WaveLenght2Pix(attr_RegionOfInterest_read[0])]); + attr_DataReference_read = (Tango::DevDouble *)&(pReferenceData[0 + RegionOfInterestStartPix]); + //attr.set_value(attr_DataReference_read,WaveLenght2Pix(attr_RegionOfInterest_read[1]) - WaveLenght2Pix(attr_RegionOfInterest_read[0])); + attr.set_value(attr_DataReference_read,RegionOfInterestEndPix - RegionOfInterestStartPix + 1); + } + else + attr.set_quality(Tango::ATTR_INVALID); + /* clang-format off */ + /*----- PROTECTED REGION END -----*/ // CCDSpectrometer::read_DataReference +} +//-------------------------------------------------------- +/** + * Write attribute DataReference related method + * Description: A reference curve + * + * Data type: Tango::DevDouble + * Attr type: Spectrum max = 5000 + */ +//-------------------------------------------------------- +void CCDSpectrometer::write_DataReference(Tango::WAttribute &attr) +{ + DEBUG_STREAM << "CCDSpectrometer::write_DataReference(Tango::WAttribute &attr) entering... " << std::endl; + // Retrieve number of write values + int w_length = attr.get_write_value_length(); + + // Retrieve pointer on write values (Do not delete !) + const Tango::DevDouble *w_val; + attr.get_write_value(w_val); + /*----- PROTECTED REGION ID(CCDSpectrometer::write_DataReference) ENABLED START -----*/ + /* clang-format on */ + // Add your own code + if((attr.get_write_value_length() != RegionOfInterestEndPix - RegionOfInterestStartPix + 1) && + (attr.get_write_value_length() != numPixel)) + { + ostringstream tmp; + tmp << "Accepting attribute size = " << numPixel << " or " << RegionOfInterestEndPix - RegionOfInterestStartPix + 1 << ends; + Tango::Except::throw_exception( + (const char *) "Wrong size", + tmp.str(), + (const char *) "CCDSpectrometer::write_DataReference()", Tango::ERR); + } if(attr.get_write_value_length() == RegionOfInterestEndPix - RegionOfInterestStartPix + 1) + { + for(unsigned int i=0; i<RegionOfInterestStartPix; i++) + pReferenceData[i] = 0; + for(unsigned int i=RegionOfInterestStartPix; i< RegionOfInterestEndPix + 1; i++) + pReferenceData[i] = w_val[i-RegionOfInterestStartPix]; + for(unsigned int i=RegionOfInterestEndPix + 1; i<numPixel; i++) + pReferenceData[i] = 0; + } + else if(attr.get_write_value_length() == numPixel) + { + for(unsigned int i=0; i< numPixel; i++) + pReferenceData[i] = w_val[i]; + } + + ofstream fd; //startup file + fd.open(dataReferenceFile.c_str()); + if (!fd) + { + stringstream tmp; + tmp << "Cannot open Data Reference default file " << dataReferenceFile<< " err:" << strerror(errno) << endl; + INFO_STREAM << "CCDSpectrometer::write_DataReference(): " << tmp.str(); + } + else + { + DEBUG_STREAM << "CCDSpectrometer::write_DataReference(): file " << dataReferenceFile << " opened successfully" << endl; + for(size_t i=0; i<numPixel; i++) + { + fd << pReferenceData[i] << endl; + } + fd.close(); + } + /* clang-format off */ + /*----- PROTECTED REGION END -----*/ // CCDSpectrometer::write_DataReference +} +//-------------------------------------------------------- +/** + * Read attribute IntensityCalibration related method + * Description: A reference curve + * + * Data type: Tango::DevDouble + * Attr type: Spectrum max = 5000 + */ +//-------------------------------------------------------- +void CCDSpectrometer::read_IntensityCalibration(Tango::Attribute &attr) +{ + DEBUG_STREAM << "CCDSpectrometer::read_IntensityCalibration(Tango::Attribute &attr) entering... " << std::endl; + /*----- PROTECTED REGION ID(CCDSpectrometer::read_IntensityCalibration) ENABLED START -----*/ + /* clang-format on */ + // Set the attribute value + attr.set_value(attr_IntensityCalibration_read, numPixel); + /* clang-format off */ + /*----- PROTECTED REGION END -----*/ // CCDSpectrometer::read_IntensityCalibration +} +//-------------------------------------------------------- +/** + * Write attribute IntensityCalibration related method + * Description: A reference curve + * + * Data type: Tango::DevDouble + * Attr type: Spectrum max = 5000 + */ +//-------------------------------------------------------- +void CCDSpectrometer::write_IntensityCalibration(Tango::WAttribute &attr) +{ + DEBUG_STREAM << "CCDSpectrometer::write_IntensityCalibration(Tango::WAttribute &attr) entering... " << std::endl; + // Retrieve number of write values + int w_length = attr.get_write_value_length(); + + // Retrieve pointer on write values (Do not delete !) + const Tango::DevDouble *w_val; + attr.get_write_value(w_val); + /*----- PROTECTED REGION ID(CCDSpectrometer::write_IntensityCalibration) ENABLED START -----*/ + /* clang-format on */ + // Add your own code + if(w_length != numPixel) + { + ostringstream tmp; + tmp << "Expected size is " << numPixel << " but read " << w_length << ends; + Tango::Except::throw_exception( + (const char *) "Wrong size", + tmp.str(), + (const char *) "CCDSpectrometer::write_IntensityCalibration()", Tango::ERR); + } + for(int i=0; i<w_length; i++) + { + attr_IntensityCalibration_read[i] = w_val[i]; + } + save_intensity_cal_file(intensityCalibrationFile); + /* clang-format off */ + /*----- PROTECTED REGION END -----*/ // CCDSpectrometer::write_IntensityCalibration +} +//-------------------------------------------------------- +/** + * Read attribute NoiseProfile related method + * Description: A reference curve + * + * Data type: Tango::DevDouble + * Attr type: Spectrum max = 5000 + */ +//-------------------------------------------------------- +void CCDSpectrometer::read_NoiseProfile(Tango::Attribute &attr) +{ + DEBUG_STREAM << "CCDSpectrometer::read_NoiseProfile(Tango::Attribute &attr) entering... " << std::endl; + /*----- PROTECTED REGION ID(CCDSpectrometer::read_NoiseProfile) ENABLED START -----*/ + /* clang-format on */ + // Set the attribute value +#ifdef _NON_AVERAGE + if(pNoiseMask) + { + attr_Data_read = (Tango::DevLong *)&(pNoiseMask[0 + attr_RegionOfInterest_read[0]]); + attr.set_value(attr_NoiseMask_read,attr_RegionOfInterest_read[1] - attr_RegionOfInterest_read[0]); + } +#else + if(pNoiseMask_avg) + { + attr_NoiseProfile_read = (Tango::DevDouble *)&(pNoiseMask_avg[0 + RegionOfInterestStartPix]); + attr.set_value(attr_NoiseProfile_read,RegionOfInterestEndPix - RegionOfInterestStartPix + 1); + } +#endif + else + attr.set_quality(Tango::ATTR_INVALID); + /* clang-format off */ + /*----- PROTECTED REGION END -----*/ // CCDSpectrometer::read_NoiseProfile +} +//-------------------------------------------------------- +/** + * Read attribute Wave related method + * + * + * Data type: Tango::DevDouble + * Attr type: Spectrum max = 5000 + */ +//-------------------------------------------------------- +void CCDSpectrometer::read_Wave(Tango::Attribute &attr) +{ + DEBUG_STREAM << "CCDSpectrometer::read_Wave(Tango::Attribute &attr) entering... " << std::endl; + /*----- PROTECTED REGION ID(CCDSpectrometer::read_Wave) ENABLED START -----*/ + /* clang-format on */ + // Set the attribute value +#ifdef _NON_AVERAGE + if(pLiveData) + { + attr_Wave_read = (Tango::DevLong *)&(pLiveData[0 + attr_RegionOfInterest_read[0]]); + attr.set_value(attr_Wave_read,attr_RegionOfInterest_read[1] - attr_RegionOfInterest_read[0]); + } +#else + if(pLiveData_avg) + { + //DEBUG_STREAM << "CCDSpectrometer::read_Data() ROIStartPix"<<RegionOfInterestStartPix<<" ROIEndPix="<<RegionOfInterestEndPix<<" size="<<RegionOfInterestEndPix - RegionOfInterestStartPix + 1<< endl; + //attr_Wave_read = (Tango::DevLong *)&(pLiveData_avg[0 + WaveLenght2Pix(attr_RegionOfInterest_read[0])]); + attr_Wave_read = (Tango::DevDouble *)&(pLiveData_avg[0 + RegionOfInterestStartPix]); + //attr.set_value(attr_Wave_read,WaveLenght2Pix(attr_RegionOfInterest_read[1]) - WaveLenght2Pix(attr_RegionOfInterest_read[0])); + attr.set_value(attr_Wave_read,RegionOfInterestEndPix - RegionOfInterestStartPix + 1); + } +#endif + else + attr.set_quality(Tango::ATTR_INVALID); + /* clang-format off */ + /*----- PROTECTED REGION END -----*/ // CCDSpectrometer::read_Wave +} +//-------------------------------------------------------- +/** + * Read attribute Lambda related method + * + * + * Data type: Tango::DevDouble + * Attr type: Spectrum max = 5000 + */ +//-------------------------------------------------------- +void CCDSpectrometer::read_Lambda(Tango::Attribute &attr) +{ + DEBUG_STREAM << "CCDSpectrometer::read_Lambda(Tango::Attribute &attr) entering... " << std::endl; + /*----- PROTECTED REGION ID(CCDSpectrometer::read_Lambda) ENABLED START -----*/ + /* clang-format on */ + // Set the attribute value +#ifdef _NON_AVERAGE + if(pLiveData) + { + attr_Lambda_read = (Tango::DevLong *)&(pLiveData[0 + attr_RegionOfInterest_read[0]]); + attr.set_value(attr_Lambda_read,attr_RegionOfInterest_read[1] - attr_RegionOfInterest_read[0]); + } +#else + if(pLiveData_avg) + { + //DEBUG_STREAM << "CCDSpectrometer::read_Data() ROIStartPix"<<RegionOfInterestStartPix<<" ROIEndPix="<<RegionOfInterestEndPix<<" size="<<RegionOfInterestEndPix - RegionOfInterestStartPix + 1<< endl; + //attr_Lambda_read = (Tango::DevLong *)&(x_values[0 + WaveLenght2Pix(attr_RegionOfInterest_read[0])]); + attr_Lambda_read = (Tango::DevDouble *)&(x_values[0 + RegionOfInterestStartPix]); + //attr.set_value(attr_Lambda_read,WaveLenght2Pix(attr_RegionOfInterest_read[1]) - WaveLenght2Pix(attr_RegionOfInterest_read[0])); + attr.set_value(attr_Lambda_read,RegionOfInterestEndPix - RegionOfInterestStartPix + 1); + } +#endif + else + attr.set_quality(Tango::ATTR_INVALID); + /* clang-format off */ + /*----- PROTECTED REGION END -----*/ // CCDSpectrometer::read_Lambda +} + +//-------------------------------------------------------- +/** + * Method : CCDSpectrometer::add_dynamic_attributes() + * Description: Create the dynamic attributes if any + * for specified device. + */ +//-------------------------------------------------------- +void CCDSpectrometer::add_dynamic_attributes() +{ + /*----- PROTECTED REGION ID(CCDSpectrometer::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 -----*/ // CCDSpectrometer::add_dynamic_attributes +} + +//-------------------------------------------------------- +/** + * Command Start related method + * + * + */ +//-------------------------------------------------------- +void CCDSpectrometer::start() +{ + DEBUG_STREAM << "CCDSpectrometer::Start() - " << device_name << std::endl; + /*----- PROTECTED REGION ID(CCDSpectrometer::start) ENABLED START -----*/ + /* clang-format on */ + + // Add your own code + start_continuous(); + /* clang-format off */ + /*----- PROTECTED REGION END -----*/ // CCDSpectrometer::start +} +//-------------------------------------------------------- +/** + * Command Stop related method + * + * + */ +//-------------------------------------------------------- +void CCDSpectrometer::stop() +{ + DEBUG_STREAM << "CCDSpectrometer::Stop() - " << device_name << std::endl; + /*----- PROTECTED REGION ID(CCDSpectrometer::stop) ENABLED START -----*/ + /* clang-format on */ + + // Add your own code + if(get_state() == Tango::ON) + { + TangoSys_MemStream out_stream; + out_stream << "Device already stopped" << ends; + Tango::Except::throw_exception( + (const char *) "Device stopped", + out_stream.str(), + (const char *) "CCDSpectrometer::stop()", Tango::ERR); + } + try { + dpmutex->lock(); + dp->command_inout(STOP_CMD); + dpmutex->unlock(); + } + catch(Tango::DevFailed &e) + { + dpmutex->unlock(); + INFO_STREAM << __func__ << ": error command =" << e.errors[0].desc; + Tango::Except::re_throw_exception(e, + (const char *) "Error", + (const char *) "Command Error", + (const char *) __func__, Tango::ERR); + } + + // Add your own code to control device here + loop->pausesec = 1; + live_mode = false; + init_live_mode = false; + measure_mode = false; + init_measure_mode = false; + if(get_state() != Tango::FAULT) + stop_mode = true; + omni_thread::sleep(0,200000000); //0.2 s + //loop->mutex_sleep->lock(); + loop->pausesec = 1; + loop->pausenano = 0; + if(get_state() != Tango::FAULT) + set_status("Ready"); + //loop->mutex_sleep->unlock(); + set_state(Tango::ON); + + /* clang-format off */ + /*----- PROTECTED REGION END -----*/ // CCDSpectrometer::stop +} +//-------------------------------------------------------- +/** + * Command Reset related method + * + * + */ +//-------------------------------------------------------- +void CCDSpectrometer::reset() +{ + DEBUG_STREAM << "CCDSpectrometer::Reset() - " << device_name << std::endl; + /*----- PROTECTED REGION ID(CCDSpectrometer::reset) ENABLED START -----*/ + /* clang-format on */ + + // Add your own code + Tango::Except::throw_exception( + (const char *) "NotSupported", + (const char *) "Command not supported", + (const char *) __func__, Tango::ERR); + /* clang-format off */ + /*----- PROTECTED REGION END -----*/ // CCDSpectrometer::reset +} +//-------------------------------------------------------- +/** + * Command StartSingle related method + * Description: Start single acquisition + * + */ +//-------------------------------------------------------- +void CCDSpectrometer::start_single() +{ + DEBUG_STREAM << "CCDSpectrometer::StartSingle() - " << device_name << std::endl; + /*----- PROTECTED REGION ID(CCDSpectrometer::start_single) ENABLED START -----*/ + /* clang-format on */ + + // Add your own code + Tango::Except::throw_exception( + (const char *) "NotSupported", + (const char *) "Command not supported", + (const char *) __func__, Tango::ERR); + /* clang-format off */ + /*----- PROTECTED REGION END -----*/ // CCDSpectrometer::start_single +} +//-------------------------------------------------------- +/** + * Command StartContinuous related method + * Description: Start acquisition in Continuous mode + * + */ +//-------------------------------------------------------- +void CCDSpectrometer::start_continuous() +{ + DEBUG_STREAM << "CCDSpectrometer::StartContinuous() - " << device_name << std::endl; + /*----- PROTECTED REGION ID(CCDSpectrometer::start_continuous) ENABLED START -----*/ + /* clang-format on */ + + // Add your own code + if(get_state() != Tango::ON && get_state() != Tango::OFF) + { + TangoSys_MemStream out_stream; + out_stream << "Device not ready, it is in '" << get_status() << "'" << ends; + Tango::Except::throw_exception( + (const char *) "Device not ready", + out_stream.str(), + (const char *) __func__, Tango::ERR); + } + if(get_state() == Tango::OFF) + { + vector<Tango::DevLong> exposure; + try { + dpmutex->lock(); + dp->read_attribute(EXPOSURE_ATTR)>>(exposure); + dpmutex->unlock(); + cout << __func__ << ": exposure size=" << exposure.size(); + *attr_ExposureTime_read = (double)exposure[1]/1000.0; + } + catch(Tango::DevFailed &e) + { + dpmutex->unlock(); + INFO_STREAM << __func__ << ": error reading =" << e.errors[0].desc; + } + } + if(*attr_ExposureTime_read <=0) + { + TangoSys_MemStream out_stream; + out_stream << "ExposureTime invalid" << ends; + Tango::Except::throw_exception( + (const char *) "ExposureTime invalid", + out_stream.str(), + (const char *) __func__, Tango::ERR); + } + try { + Tango::DeviceData Din; + Din << cameraLabel.c_str(); + dpmutex->lock(); + dp->command_inout(START_CMD, Din); + dpmutex->unlock(); + } + catch(Tango::DevFailed &e) + { + dpmutex->unlock(); + INFO_STREAM << __func__ << ": error command =" << e.errors[0].desc; +#if 0//TODO: to skip ALARM: "signal under threshold" on the CCD + Tango::Except::re_throw_exception(e, + (const char *) "Error", + (const char *) "Command Error", + (const char *) __func__, Tango::ERR); +#endif + } + clock_gettime(CLOCK_MONOTONIC,&last_read); + set_state(Tango::RUNNING); + set_status("Continuous Mode"); + loop->min_fit_time = 1000000000.0; + loop->max_fit_time = 0; + loop->avg_fit_time = 0; + loop->tot_fit_time = 0; + loop->fit_counter = 0; + measure_mode = false; + init_measure_mode = false; + acquire_noise_mode = false; + init_acquire_noise_mode = false; + live_mode = true; + init_live_mode = true; + stop_mode = false; + + /* clang-format off */ + /*----- PROTECTED REGION END -----*/ // CCDSpectrometer::start_continuous +} +//-------------------------------------------------------- +/** + * Command GetLastData related method + * Description: returns the last argin frames saved + * + * @param argin number of frames to return + * @returns + */ +//-------------------------------------------------------- +Tango::DevVarDoubleArray *CCDSpectrometer::get_last_data(Tango::DevLong argin) +{ + Tango::DevVarDoubleArray *argout; + DEBUG_STREAM << "CCDSpectrometer::GetLastData() - " << device_name << std::endl; + /*----- PROTECTED REGION ID(CCDSpectrometer::get_last_data) ENABLED START -----*/ + /* clang-format on */ + + // Add your own code + if(get_state() == Tango::FAULT) + { + TangoSys_MemStream out_stream; + out_stream << "Device not ready, it is in '" << get_status() << "'" << ends; + Tango::Except::throw_exception( + (const char *) "Device not ready", + out_stream.str(), + (const char *) "CCDSpectrometer::get_last_data()", Tango::ERR); + } + argout = new Tango::DevVarDoubleArray(); + DEBUG_STREAM << "CCDSpectrometer::get_last_data(): entering... FrameBufferIndex=" << FrameBufferIndex << endl; + + // Add your own code to control device here + if(argin > nFramesBuffered || argin < 1) + { + TangoSys_MemStream out_stream; + out_stream << "MAx number of frames=" << nFramesBuffered << ends; + Tango::Except::throw_exception( + (const char *) "Argin out of bounds", + out_stream.str(), + (const char *) "CCDSpectrometer::get_last_data()", Tango::ERR); + } + //int region_size = RegionOfInterestEndPix - RegionOfInterestStartPix; + //argout->length(argin * numPixel); + int j; + DEBUG_STREAM << "CCDSpectrometer::get_last_data() (FrameBufferIndex - argin)=" << ((int)FrameBufferIndex - argin) << endl; + if(((int)FrameBufferIndex - argin) >= 0) + { + j = (int)FrameBufferIndex - argin; + } + else + { + j = nFramesBuffered - (argin - FrameBufferIndex); + } + int region_size = RegionOfInterestEndPix - RegionOfInterestStartPix + 1; + argout->length(argin * region_size); + DEBUG_STREAM << "CCDSpectrometer::get_last_data: region size=" << region_size << " new data_counter=" << argin * region_size << endl; + for(int i=0; i < argin; i++) + { + //DEBUG_STREAM << "CCDSpectrometer::get_last_data() copying DATA! from " << j*numPixel << " to " << i*numPixel << endl; + //copying only region of interest: + //i*region_size: beginning of frame=i reduced to dimension region_size + //j*numPixel: beginning of original frame=j of dimension numPixel + //j*numPixel + attr_RegionOfInterest_read[0]: beginning of region of interest in frame=j + memcpy(&((*argout)[i*region_size]),&(pFrameBuffer[j*numPixel + RegionOfInterestStartPix]), region_size*sizeof(double)); + j = (j + 1) % nFramesBuffered; + } + + /* clang-format off */ + /*----- PROTECTED REGION END -----*/ // CCDSpectrometer::get_last_data + return argout; +} +//-------------------------------------------------------- +/** + * Command AcquireNoise related method + * Description: Acquire argin frames of background noise + * + * @param argin Number of frames to acquire as noise + */ +//-------------------------------------------------------- +void CCDSpectrometer::acquire_noise(Tango::DevLong argin) +{ + DEBUG_STREAM << "CCDSpectrometer::AcquireNoise() - " << device_name << std::endl; + /*----- PROTECTED REGION ID(CCDSpectrometer::acquire_noise) ENABLED START -----*/ + /* clang-format on */ + + // Add your own code + if(get_state() != Tango::ON) + { + TangoSys_MemStream out_stream; + out_stream << "Device not ready, it is in '" << get_status() << "'" << ends; + Tango::Except::throw_exception( + (const char *) "Device not ready", + out_stream.str(), + (const char *) __func__, Tango::ERR); + } + if(argin <= 0) + { + TangoSys_MemStream out_stream; + out_stream << "Number of frames has to be > 0" << ends; + Tango::Except::throw_exception( + (const char *) "Wrong argument", + out_stream.str(), + (const char *) __func__, Tango::ERR); + } + if(*attr_ExposureTime_read <=0) + { + TangoSys_MemStream out_stream; + out_stream << "ExposureTime invalid" << ends; + Tango::Except::throw_exception( + (const char *) "ExposureTime invalid", + out_stream.str(), + (const char *) __func__, Tango::ERR); + } + noise_frames = argin; + noise_frames_counter = 0; + set_state(Tango::RUNNING); + set_status("Acquiring noise"); + live_mode = false; + init_live_mode = false; + measure_mode = false; + init_measure_mode = false; + acquire_noise_mode = true; + init_acquire_noise_mode = true; + + /* clang-format off */ + /*----- PROTECTED REGION END -----*/ // CCDSpectrometer::acquire_noise +} +//-------------------------------------------------------- +/** + * Command SaveReferenceData related method + * Description: Save current curve as reference curve + * + */ +//-------------------------------------------------------- +void CCDSpectrometer::save_reference_data() +{ + DEBUG_STREAM << "CCDSpectrometer::SaveReferenceData() - " << device_name << std::endl; + /*----- PROTECTED REGION ID(CCDSpectrometer::save_reference_data) ENABLED START -----*/ + /* clang-format on */ + + // Add your own code + ofstream fd; //startup file + fd.open(dataReferenceFile.c_str()); + for(unsigned int i=0; i<numPixel; i++) + { +#ifdef _NON_AVERAGE + if(pLiveData && pReferenceData) + { + pReferenceData[i] = pLiveData[i]; + if (fd) + { + fd << (long)pReferenceData[i] << endl; + } + } +#else + if(pLiveData_avg && pReferenceData) + { + pReferenceData[i] = pLiveData_avg[i]; + if (fd) + { + fd << (double)pReferenceData[i] << endl; + } + } +#endif + } + + if (!fd) + { + stringstream tmp; + tmp << "Cannot save on Data Reference file " << dataReferenceFile<< " err:" << strerror(errno) << endl; + INFO_STREAM << "AvaSpec::save_reference_data(): " << tmp.str(); + Tango::Except::throw_exception( + (const char *) "File opening exception", + tmp.str(), + (const char *) "AvaSpec::save_reference_data()", Tango::ERR); + } + else + { + fd.close(); + } + + /* clang-format off */ + /*----- PROTECTED REGION END -----*/ // CCDSpectrometer::save_reference_data +} +//-------------------------------------------------------- +/** + * Command GetData related method + * + * + * @param argin + * @returns + */ +//-------------------------------------------------------- +Tango::DevVarDoubleArray *CCDSpectrometer::get_data(const Tango::DevVarLongArray *argin) +{ + Tango::DevVarDoubleArray *argout; + DEBUG_STREAM << "CCDSpectrometer::GetData() - " << device_name << std::endl; + /*----- PROTECTED REGION ID(CCDSpectrometer::get_data) ENABLED START -----*/ + /* clang-format on */ + + // Add your own code + if(!(*attr_RtMode_read) && ((*argin)[0] == BUF_GET_BUNCH_MODE || (*argin)[0] == BUF_GET_BUNCH_UNIQUE_MODE || (*argin)[0] == BUF_GET_BUNCH_BUNCH_MODE)) + Tango::Except::throw_exception( + "NON RT MODE", + "Supported only in RT mode", + __func__, Tango::ERR); + long buf_idx[2], num_samples; + unsigned char unique; + + tbuffer::tcheck_get_data_param<tbuffer::_data_array<double> >(argin, &tbuf_array, buf_idx, &num_samples, &unique); + argout = new Tango::DevVarDoubleArray(); + num_samples *= tbuf_array.get_data_size(); + argout->length(num_samples); + tbuffer::_data_array<double> foo; + tbuf_array.read_data(unique, buf_idx, &(*argout)[0], &foo); + + /* clang-format off */ + /*----- PROTECTED REGION END -----*/ // CCDSpectrometer::get_data + return argout; +} +//-------------------------------------------------------- +/** + * Command GetGaussFitCenter related method + * + * + * @param argin + * @returns + */ +//-------------------------------------------------------- +Tango::DevVarDoubleArray *CCDSpectrometer::get_gauss_fit_center(const Tango::DevVarLongArray *argin) +{ + Tango::DevVarDoubleArray *argout; + DEBUG_STREAM << "CCDSpectrometer::GetGaussFitCenter() - " << device_name << std::endl; + /*----- PROTECTED REGION ID(CCDSpectrometer::get_gauss_fit_center) ENABLED START -----*/ + /* clang-format on */ + + // Add your own code + if(!(*attr_RtMode_read) && ((*argin)[0] == BUF_GET_BUNCH_MODE || (*argin)[0] == BUF_GET_BUNCH_UNIQUE_MODE || (*argin)[0] == BUF_GET_BUNCH_BUNCH_MODE)) + Tango::Except::throw_exception( + "NON RT MODE", + "Supported only in RT mode", + __func__, Tango::ERR); + long buf_idx[2], num_samples; + unsigned char unique; + + tbuffer::tcheck_get_data_param<double>(argin, &tbuf[BUF_ID_GAUSS_CENTER], buf_idx, &num_samples, &unique); + argout = new Tango::DevVarDoubleArray(); + argout->length(num_samples); + tbuf[BUF_ID_GAUSS_CENTER].read_data_calib(unique, buf_idx, &(*argout)[0], 0, 1, 0); + + /* clang-format off */ + /*----- PROTECTED REGION END -----*/ // CCDSpectrometer::get_gauss_fit_center + return argout; +} +//-------------------------------------------------------- +/** + * Command GetGaussFitWidth related method + * + * + * @param argin + * @returns + */ +//-------------------------------------------------------- +Tango::DevVarDoubleArray *CCDSpectrometer::get_gauss_fit_width(const Tango::DevVarLongArray *argin) +{ + Tango::DevVarDoubleArray *argout; + DEBUG_STREAM << "CCDSpectrometer::GetGaussFitWidth() - " << device_name << std::endl; + /*----- PROTECTED REGION ID(CCDSpectrometer::get_gauss_fit_width) ENABLED START -----*/ + /* clang-format on */ + + // Add your own code + if(!(*attr_RtMode_read) && ((*argin)[0] == BUF_GET_BUNCH_MODE || (*argin)[0] == BUF_GET_BUNCH_UNIQUE_MODE || (*argin)[0] == BUF_GET_BUNCH_BUNCH_MODE)) + Tango::Except::throw_exception( + "NON RT MODE", + "Supported only in RT mode", + __func__, Tango::ERR); + long buf_idx[2], num_samples; + unsigned char unique; + + tbuffer::tcheck_get_data_param<double>(argin, &tbuf[BUF_ID_GAUSS_WIDTH], buf_idx, &num_samples, &unique); + argout = new Tango::DevVarDoubleArray(); + argout->length(num_samples); + tbuf[BUF_ID_GAUSS_WIDTH].read_data_calib(unique, buf_idx, &(*argout)[0], 0, 1, 0); + + /* clang-format off */ + /*----- PROTECTED REGION END -----*/ // CCDSpectrometer::get_gauss_fit_width + return argout; +} +//-------------------------------------------------------- +/** + * Command GetFWHMCenter related method + * + * + * @param argin + * @returns + */ +//-------------------------------------------------------- +Tango::DevVarDoubleArray *CCDSpectrometer::get_fwhmcenter(const Tango::DevVarLongArray *argin) +{ + Tango::DevVarDoubleArray *argout; + DEBUG_STREAM << "CCDSpectrometer::GetFWHMCenter() - " << device_name << std::endl; + /*----- PROTECTED REGION ID(CCDSpectrometer::get_fwhmcenter) ENABLED START -----*/ + /* clang-format on */ + + // Add your own code + if(!(*attr_RtMode_read) && ((*argin)[0] == BUF_GET_BUNCH_MODE || (*argin)[0] == BUF_GET_BUNCH_UNIQUE_MODE || (*argin)[0] == BUF_GET_BUNCH_BUNCH_MODE)) + Tango::Except::throw_exception( + "NON RT MODE", + "Supported only in RT mode", + __func__, Tango::ERR); + long buf_idx[2], num_samples; + unsigned char unique; + + tbuffer::tcheck_get_data_param<double>(argin, &tbuf[BUF_ID_FWHM_CENTER], buf_idx, &num_samples, &unique); + argout = new Tango::DevVarDoubleArray(); + argout->length(num_samples); + tbuf[BUF_ID_FWHM_CENTER].read_data_calib(unique, buf_idx, &(*argout)[0], 0, 1, 0); + + /* clang-format off */ + /*----- PROTECTED REGION END -----*/ // CCDSpectrometer::get_fwhmcenter + return argout; +} +//-------------------------------------------------------- +/** + * Command GetFWHMWidth related method + * + * + * @param argin + * @returns + */ +//-------------------------------------------------------- +Tango::DevVarDoubleArray *CCDSpectrometer::get_fwhmwidth(const Tango::DevVarLongArray *argin) +{ + Tango::DevVarDoubleArray *argout; + DEBUG_STREAM << "CCDSpectrometer::GetFWHMWidth() - " << device_name << std::endl; + /*----- PROTECTED REGION ID(CCDSpectrometer::get_fwhmwidth) ENABLED START -----*/ + /* clang-format on */ + + // Add your own code + if(!(*attr_RtMode_read) && ((*argin)[0] == BUF_GET_BUNCH_MODE || (*argin)[0] == BUF_GET_BUNCH_UNIQUE_MODE || (*argin)[0] == BUF_GET_BUNCH_BUNCH_MODE)) + Tango::Except::throw_exception( + "NON RT MODE", + "Supported only in RT mode", + __func__, Tango::ERR); + long buf_idx[2], num_samples; + unsigned char unique; + + tcheck_get_data_param(argin, &tbuf[BUF_ID_FWHM_WIDTH], buf_idx, &num_samples, &unique); + argout = new Tango::DevVarDoubleArray(); + argout->length(num_samples); + tbuf[BUF_ID_FWHM_WIDTH].read_data_calib(unique, buf_idx, &(*argout)[0], 0, 1, 0); + + /* clang-format off */ + /*----- PROTECTED REGION END -----*/ // CCDSpectrometer::get_fwhmwidth + return argout; +} +//-------------------------------------------------------- +/** + * Command ExportWavelength related method + * + * + */ +//-------------------------------------------------------- +void CCDSpectrometer::export_wavelength() +{ + DEBUG_STREAM << "CCDSpectrometer::ExportWavelength() - " << device_name << std::endl; + /*----- PROTECTED REGION ID(CCDSpectrometer::export_wavelength) ENABLED START -----*/ + /* clang-format on */ + + // Add your own code + if(wavelengthAttr.size() != 2) + { + Tango::Except::throw_exception( + (const char *) "Beam Status Server Not Set", + (const char *) "Beam Status Server Not Set", + (const char *) "SolarS100::export_wavelength()", Tango::ERR); + } + Tango::DeviceProxy *devbeamstatus; + devbeamstatus = new Tango::DeviceProxy(wavelengthAttr[0]); + try + { + Tango::DeviceAttribute Din(wavelengthAttr[1],*attr_Center_read); + devbeamstatus->write_attribute(Din); + } + catch(Tango::DevFailed e) + { + delete devbeamstatus; + stringstream tmp; + tmp << "Failed to write attribute, err=" <<e.errors[0].desc; + Tango::Except::re_throw_exception(e, + (const char *) "Failed", + tmp.str(), + (const char *) "SolarS100::export_wavelength()", Tango::ERR); + } + delete devbeamstatus; + + /* clang-format off */ + /*----- PROTECTED REGION END -----*/ // CCDSpectrometer::export_wavelength +} +//-------------------------------------------------------- +/** + * Command GetArea related method + * + * + * @param argin + * @returns + */ +//-------------------------------------------------------- +Tango::DevVarDoubleArray *CCDSpectrometer::get_area(const Tango::DevVarLongArray *argin) +{ + Tango::DevVarDoubleArray *argout; + DEBUG_STREAM << "CCDSpectrometer::GetArea() - " << device_name << std::endl; + /*----- PROTECTED REGION ID(CCDSpectrometer::get_area) ENABLED START -----*/ + /* clang-format on */ + + // Add your own code + if(!(*attr_RtMode_read) && ((*argin)[0] == BUF_GET_BUNCH_MODE || (*argin)[0] == BUF_GET_BUNCH_UNIQUE_MODE || (*argin)[0] == BUF_GET_BUNCH_BUNCH_MODE)) + Tango::Except::throw_exception( + "NON RT MODE", + "Supported only in RT mode", + __func__, Tango::ERR); + long buf_idx[2], num_samples; + unsigned char unique; + + tbuffer::tcheck_get_data_param<double>(argin, &tbuf[BUF_ID_AREA], buf_idx, &num_samples, &unique); + argout = new Tango::DevVarDoubleArray(); + argout->length(num_samples); + tbuf[BUF_ID_AREA].read_data_calib(unique, buf_idx, &(*argout)[0], 0, 1, 0); + + /* clang-format off */ + /*----- PROTECTED REGION END -----*/ // CCDSpectrometer::get_area + return argout; +} +//-------------------------------------------------------- +/** + * Command GetWave related method + * Description: Same as GetData + * + * @param argin + * @returns + */ +//-------------------------------------------------------- +Tango::DevVarDoubleArray *CCDSpectrometer::get_wave(const Tango::DevVarLongArray *argin) +{ + Tango::DevVarDoubleArray *argout; + DEBUG_STREAM << "CCDSpectrometer::GetWave() - " << device_name << std::endl; + /*----- PROTECTED REGION ID(CCDSpectrometer::get_wave) ENABLED START -----*/ + /* clang-format on */ + + // Add your own code + if(!(*attr_RtMode_read) && ((*argin)[0] == BUF_GET_BUNCH_MODE || (*argin)[0] == BUF_GET_BUNCH_UNIQUE_MODE || (*argin)[0] == BUF_GET_BUNCH_BUNCH_MODE)) + Tango::Except::throw_exception( + "NON RT MODE", + "Supported only in RT mode", + __func__, Tango::ERR); + long buf_idx[2], num_samples; + unsigned char unique; + + tbuffer::tcheck_get_data_param<tbuffer::_data_array<double> >(argin, &tbuf_array_w, buf_idx, &num_samples, &unique); + argout = new Tango::DevVarDoubleArray(); + num_samples *= tbuf_array_w.get_data_size(); + argout->length(num_samples); + tbuffer::_data_array<double> foo; + tbuf_array_w.read_data(unique, buf_idx, &(*argout)[0], &foo); + + /* clang-format off */ + /*----- PROTECTED REGION END -----*/ // CCDSpectrometer::get_wave + return argout; +} +//-------------------------------------------------------- +/** + * Command GetLambda related method + * + * + * @param argin + * @returns + */ +//-------------------------------------------------------- +Tango::DevVarDoubleArray *CCDSpectrometer::get_lambda(const Tango::DevVarLongArray *argin) +{ + Tango::DevVarDoubleArray *argout; + DEBUG_STREAM << "CCDSpectrometer::GetLambda() - " << device_name << std::endl; + /*----- PROTECTED REGION ID(CCDSpectrometer::get_lambda) ENABLED START -----*/ + /* clang-format on */ + + // Add your own code + if(!(*attr_RtMode_read) && ((*argin)[0] == BUF_GET_BUNCH_MODE || (*argin)[0] == BUF_GET_BUNCH_UNIQUE_MODE || (*argin)[0] == BUF_GET_BUNCH_BUNCH_MODE)) + Tango::Except::throw_exception( + "NON RT MODE", + "Supported only in RT mode", + __func__, Tango::ERR); + long buf_idx[2], num_samples; + unsigned char unique; + + tbuffer::tcheck_get_data_param<tbuffer::_data_array<double> >(argin, &tbuf_array_l, buf_idx, &num_samples, &unique); + argout = new Tango::DevVarDoubleArray(); + num_samples *= tbuf_array_l.get_data_size(); + argout->length(num_samples); + tbuffer::_data_array<double> foo; + tbuf_array_l.read_data(unique, buf_idx, &(*argout)[0], &foo); + +#if 0 + size_t num_samples = RegionOfInterestEndPix - RegionOfInterestStartPix + 1; + + argout = new Tango::DevVarDoubleArray(); + argout->length(num_samples); + for(size_t i=0; i<num_samples; i++) + (*argout)[i] = x_values[i+RegionOfInterestStartPix]; +#endif + + /* clang-format off */ + /*----- PROTECTED REGION END -----*/ // CCDSpectrometer::get_lambda + return argout; +} +//-------------------------------------------------------- +/** + * Method : CCDSpectrometer::add_dynamic_commands() + * Description: Create the dynamic commands if any + * for specified device. + */ +//-------------------------------------------------------- +void CCDSpectrometer::add_dynamic_commands() +{ + /*----- PROTECTED REGION ID(CCDSpectrometer::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 -----*/ // CCDSpectrometer::add_dynamic_commands +} + +/*----- PROTECTED REGION ID(CCDSpectrometer::namespace_ending) ENABLED START -----*/ +/* clang-format on */ +// Additional Methods + +void CCDSpectrometer::init_data(bool reconnection = false) +{ + /*if(!m_usbCCD.GetParameters()) + INFO_STREAM << "CCDSpectrometer::init_data(): error in GetParameters()" << endl; + numPixel = m_usbCCD.m_nNumPixelsH * m_usbCCD.m_nNumPixelsV;*/ + int res; + int flag; + unsigned int NumPixel = numPixel; + attr_NumPixels_read[0] = NumPixel; + attr_NumPixels_read[1] = 1; + + if(x_values != NULL) + { + delete [] x_values; + x_values = NULL; + } + DEBUG_STREAM << "CCDSpectrometer::init_data(): NumPixel="<<NumPixel << endl; + x_values = new Tango::DevDouble[NumPixel]; + Tango::DbData db_data_get; + try { + db_data_get.push_back(Tango::DbDatum("Data")); + get_db_device()->get_attribute_property(db_data_get); + vector<Tango::DevDouble> xval; + for(unsigned int i=0; i<db_data_get.size(); i++) + { + long nb_prop; + //string &att_name = db_data[i].name; + db_data_get[i] >> nb_prop; + i++; + for(int k=0; k < nb_prop; k++) + { + string &prop_name = db_data_get[i].name; + if(prop_name == "x_values") + { + db_data_get[i] >> xval; + break; + } + } + } + if(xval.size() > NumPixel) + { + WARN_STREAM << "CCDSpectrometer::init_data(): x_values property size=" << xval.size() << " greater than frame size=" << NumPixel << endl; + } + else + { + DEBUG_STREAM << "CCDSpectrometer::init_data(): x_values property size=" << xval.size() << ", frame size=" << NumPixel << endl; + for(unsigned int i=0; i<xval.size(); i++) + { + x_values[i] = (Tango::DevDouble)xval[i]; + } + //TEMP: if missing some xval, fill continuing with linear interpulation + if(xval.size() < NumPixel) + { + for(unsigned int i=xval.size(); i<NumPixel; i++) + { + x_values[i] = (Tango::DevDouble)(xval[xval.size()-1] + (xval[xval.size()-1] - xval[xval.size()-2])*(i-xval.size()+1)); + DEBUG_STREAM << "CCDSpectrometer::init_data(): added missing x_values: x_values["<<i<<"]=" << x_values[i] << endl; + } + } + } + } + catch(Tango::DevFailed e) { + string temp; + temp = e.errors[0].desc; + WARN_STREAM << "CCDSpectrometer::init_data() error getting x_values attribute property: " << temp << endl; + } + if(pLiveData_avg != NULL) + { + delete [] pLiveData_avg; + pLiveData_avg = NULL; + } + pLiveData_avg = new double[NumPixel]; + memset(pLiveData_avg,0,NumPixel*sizeof(double)); + if(pNoiseMask_avg != NULL) + { + delete [] pNoiseMask_avg; + pNoiseMask_avg = NULL; + } + pNoiseMask_avg = new double[NumPixel]; + memset(pNoiseMask_avg,0,NumPixel*sizeof(double)); + if(pReferenceData != NULL) + { + delete [] pReferenceData; + pReferenceData = NULL; + } + pReferenceData = new double[NumPixel]; + memset(pReferenceData,0,NumPixel*sizeof(double)); + + /*defaultEndRegion = (defaultEndRegion > (int)NumPixel) ? NumPixel : + (defaultEndRegion < 0) ? NumPixel : defaultEndRegion; + defaultStartRegion = (defaultStartRegion < 0) ? 0 : + ((defaultStartRegion > (int)NumPixel) ? 0 : + ((defaultStartRegion >= defaultEndRegion) ? defaultEndRegion-1 : defaultStartRegion));*/ + + RegionOfInterestStartPix = WaveLenght2Pix(attr_RegionOfInterest_read[0]); + DEBUG_STREAM << __func__<<": StartROI="<<defaultStartRegion<<" -> start pix="<<RegionOfInterestStartPix; + while(x_values[RegionOfInterestStartPix] < defaultStartRegion) + { + RegionOfInterestStartPix++; + } + DEBUG_STREAM << __func__<<": ... -> adjusted start pix="<<RegionOfInterestStartPix; + AnalysisRegionStartPix = RegionOfInterestStartPix; + + RegionOfInterestEndPix = WaveLenght2Pix(attr_RegionOfInterest_read[1]); + DEBUG_STREAM << __func__<<": EndROI="<<defaultEndRegion<<" -> end pix="<<RegionOfInterestEndPix; + while(x_values[RegionOfInterestEndPix] > defaultEndRegion) + { + RegionOfInterestEndPix--; + } + DEBUG_STREAM << __func__<<": ... -> adjusted end pix="<<RegionOfInterestEndPix; + AnalysisRegionEndPix = RegionOfInterestEndPix; + attr_GaussFit_read[0] = attr_GaussFit_read[1] = attr_GaussFit_read[2] = attr_GaussFit_read[3] = 0; + attr_FWHM_read[0] = attr_FWHM_read[1] = attr_FWHM_read[2] = 0; + *attr_GaussFitCenter_read = 0; + *attr_GaussFitWidth_read = 0; + *attr_FWHMCenter_read = 0; + *attr_FWHMWidth_read = 0; + GaussFit_valid = false; + + Tango::MultiAttribute *attr_list = get_device_attr(); + + vector<double> region_write; + region_write.push_back(x_values[RegionOfInterestStartPix]); + region_write.push_back(x_values[RegionOfInterestEndPix]); + Tango::WAttribute &attr_reg = attr_list->get_w_attr_by_name ("RegionOfInterest"); + attr_reg.set_write_value(region_write,2); + Tango::WAttribute &attr_reg2 = attr_list->get_w_attr_by_name ("AnalysisRegion"); + attr_reg2.set_write_value(region_write,2); + if(reconnection) + { + usleep(500000); + try + { + Tango::WAttribute &attr_reg3 = attr_list->get_w_attr_by_name ("ExposureTime"); + write_ExposureTime(attr_reg3); + }catch (...){} + usleep(100000); + try + { + Tango::WAttribute &attr_reg4 = attr_list->get_w_attr_by_name ("SyncMode"); + write_SyncMode(attr_reg4); + }catch (...){} + usleep(100000); + } + if(nFramesBuffered > 0) + { + if(pFrameBuffer != NULL) + { + delete [] pFrameBuffer; + pFrameBuffer = NULL; + } + pFrameBuffer = new double[NumPixel * nFramesBuffered]; + memset(pFrameBuffer,0,NumPixel * nFramesBuffered * sizeof(double)); + } + ifstream fd; //startup file + fd.open(dataReferenceFile.c_str()); + if (!fd) + { + stringstream tmp; + tmp << "Cannot open Data Reference default file:" << strerror(errno) << endl; + INFO_STREAM << "CCDSpectrometer::init_data(): " << tmp.str(); + } + else{ + DEBUG_STREAM << "CCDSpectrometer::init_data(): file opened successfully" << endl; + string lineread; + size_t i=0; + double val; + while(std::getline(fd, lineread, '\n')) + { // Read line by line + if(lineread.length() > 0 && i < NumPixel) + { + sscanf(lineread.c_str(),"%lf",&val); + pReferenceData[i++] = val; + } + } + fd.close(); + } + fd.open(noiseProfileFile.c_str()); + if (!fd) + { + stringstream tmp; + tmp << "Cannot open Noise Profile default file:" << strerror(errno) << endl; + INFO_STREAM << "CCDSpectrometer::init_data(): " << tmp.str(); + } + else{ + DEBUG_STREAM << "CCDSpectrometer::init_data(): file " << noiseProfileFile << " opened successfully" << endl; + string lineread; + int i=0; + double val; + while(std::getline(fd, lineread, '\n')) + { // Read line by line + if(lineread.length() > 0 && i < NumPixel) + { + sscanf(lineread.c_str(),"%lf",&val); + pNoiseMask_avg[i++] = val; + } + } + fd.close(); + } +} + +unsigned int CCDSpectrometer::WaveLenght2Pix(double val) +{ + if(!x_values || numPixel==0) + return 0; + double tmp_val; + unsigned int tmp_pix, step; + tmp_pix= (unsigned int)(((double)numPixel)/2); + step= (unsigned int)(((double)numPixel)/2); + tmp_val = x_values[tmp_pix]; + //DEBUG_STREAM << "CCDSpectrometer::WaveLenght2Pix: ENTERING: val="<<val<<" tmp_val="<<tmp_val<<" tmp_pix="<<tmp_pix<<" step="<<step<<endl; + if(val <= x_values[0]) + return 0; + else if(val >= x_values[numPixel-1]) + return numPixel-1; + while((val != tmp_val) && (step > 1)) + { + step = (unsigned int)((((double)step)/2) + 0.5); //round + //DEBUG_STREAM << "CCDSpectrometer::WaveLenght2Pix: LOOPING: val="<<val<<" tmp_val="<<tmp_val<<" tmp_pix="<<tmp_pix<<" step="<<step<<endl; + if(val > tmp_val) + { + if((((int)tmp_pix) + ((int)step)) < (int)numPixel) + { + tmp_pix = tmp_pix + step; + } + else + { + //DEBUG_STREAM << "CCDSpectrometer::WaveLenght2Pix("<<val<<"): LOOPING: tmp_pix="<<tmp_pix<<"+step="<<step<<" >=numPixel="<<numPixel<<endl; + tmp_pix = numPixel-1; + //break; + } + } + else if(val < tmp_val) + { + if((((int)tmp_pix) - ((int)step)) >= 0) + { + //DEBUG_STREAM << "CCDSpectrometer::WaveLenght2Pix("<<val<<"): LOOPING: tmp_pix="<<tmp_pix<<"-step="<<step<<" ="<<tmp_pix - step<<" new tmp_val=" << x_values[tmp_pix- step] << endl; + tmp_pix = tmp_pix - step; + } + else + { + //DEBUG_STREAM << "CCDSpectrometer::WaveLenght2Pix("<<val<<"): LOOPING: tmp_pix="<<tmp_pix<<"-step="<<step<<" <=0"<<endl; + tmp_pix = 0; + //break; + } + } + else + { + break; + } + tmp_val = x_values[tmp_pix]; + } + if(step == 1) + { + //DEBUG_STREAM << "CCDSpectrometer::WaveLenght2Pix: LAST TEST: val="<<val<<" tmp_val="<<tmp_val<<" tmp_pix="<<tmp_pix<<" step="<<step<<endl; + if(val > tmp_val) + { + if((((int)tmp_pix) + ((int)step)) < (int)numPixel) + { + tmp_pix = tmp_pix + step; + } + else + { + //DEBUG_STREAM << "CCDSpectrometer::WaveLenght2Pix("<<val<<"): LAST TEST: tmp_pix="<<tmp_pix<<"+step="<<step<<" >=numPixel="<<numPixel<<endl; + tmp_pix = numPixel-1; + //break; + } + } + else if(val < tmp_val) + { + if((((int)tmp_pix) - ((int)step)) >= 0) + { + //DEBUG_STREAM << "CCDSpectrometer::WaveLenght2Pix("<<val<<"): LAST TEST: tmp_pix="<<tmp_pix<<"-step="<<step<<" ="<<tmp_pix - step<<" new tmp_val=" << x_values[tmp_pix- step] << endl; + tmp_pix = tmp_pix - step; + } + else + { + DEBUG_STREAM << "CCDSpectrometer::WaveLenght2Pix("<<val<<"): LAST TEST: tmp_pix="<<tmp_pix<<"-step="<<step<<" <=0"<<endl; + tmp_pix = 0; + //break; + } + } + } + //DEBUG_STREAM << "CCDSpectrometer::WaveLenght2Pix: EXITING: val="<<val<<" tmp_val="<<tmp_val<<" tmp_pix="<<tmp_pix<<" step="<<step<<endl; + return (unsigned int)tmp_pix; +} +//==== argin: +// DWORD *data_array: sequence of "num_frames" frames +// int dim_frame: dimensione of one frame +// int x_start_analysis: start of region of analysis within the frame +// int x_end_analysis: end of region of analysis within the frame +// int num_frames: number of frames passed for the average between frames +// int avg_val: number of adjacent values with which calculate the average +// +//==== argout: +// int x_peak: x of the peak +// int y_peak: y of the peak +// int x_half_min: smallest x of the value at half maximum +// int x_half_max: largest x of the value at half maximum + +bool CCDSpectrometer::fwhm_calculate(double *data_array, size_t dim_frame, size_t x_start_analysis, size_t x_end_analysis, size_t num_frames, size_t avg_val, size_t &x_peak, double &y_peak, size_t &x_half_min, size_t &x_half_max) +{ + bool ret = true; + if(num_frames < 1) + num_frames = 1; + int dim_frame_analysis = x_end_analysis - x_start_analysis + 1; + if(avg_val-1 > dim_frame_analysis) + { + avg_val = dim_frame_analysis; + } + if(avg_val < 1) + avg_val = 1; + if((avg_val % 2) != 1) //has to be odd + avg_val += 1; + + size_t half_avg_val = (size_t)(floor((double)avg_val)/2); + + double *data_tmp = new double[dim_frame_analysis]; + //memset(data_tmp, 0, sizeof(double)*dim_frame_analysis); + double y_min=1E17; //TODO: start from max value + x_peak = x_start_analysis + avg_val; + y_peak = -1E17; + x_half_min=x_start_analysis + avg_val; + x_half_max=x_end_analysis-(int)(((double)avg_val)/2); + + double inv_num_frame = 1.0/(double)num_frames; + double inv_avg_val = 1.0/(double)avg_val; + //cout << "GGG avg_val="<<avg_val<<" looping ["<<x_start_analysis + avg_val<<","<<x_end_analysis - avg_val<<"]" << endl; + //calculate average and max + //if(int_num_frames > 1) + { + for(size_t i=x_start_analysis + avg_val; i < x_end_analysis - avg_val; i++) + { + //average with num_frames before + for(size_t j=0; j < num_frames; j++) + { + if(avg_val == 1) + { + data_tmp[i-x_start_analysis] = ((double)data_array[i + j*num_frames])*inv_num_frame; + } + else + { + double tmp_val=0; + //average from (size_t)(((double)avg_val)/2) before value i to (size_t)(((double)avg_val)/2) after + for(size_t k=i-half_avg_val; k<=i+half_avg_val; k++) + { + tmp_val += ((double)data_array[k + j*num_frames]); + //cout << "GGG i="<<i<<" k="<<k<<" data_array["<<k + j*num_frames<<"]="<< ((double)data_array[k + j*num_frames]) << endl; + } + data_tmp[i-x_start_analysis] = tmp_val*inv_num_frame*inv_avg_val; + //cout << "GGG i="<<i<<" data_tmp["<<i-x_start_analysis<<"]="<< data_tmp[i-x_start_analysis] << endl; + } + } + if(data_tmp[i-x_start_analysis] > y_peak) + { + y_peak = (data_tmp[i-x_start_analysis]); + x_peak = i; + //cout << "GGG FOUND peak: i="<<i<<" data_tmp["<<i-x_start_analysis<<"]="<< data_tmp[i-x_start_analysis] << endl; + } + if(data_tmp[i-x_start_analysis] < y_min) + { + y_min = (data_tmp[i-x_start_analysis]); + } + } + + //now search for x at half maximum + //exterior half maximum on the left + //for(int i=x_start_analysis + avg_val; i < x_peak; i++) + for(int i=x_peak-1; i>=x_start_analysis + avg_val; i--) + { + //cout << "GGG i="<<i<<" data_tmp["<<i-x_start_analysis<<"]="<< data_tmp[i-x_start_analysis] <<" y_min="<<y_min<<" y_peak="<<y_peak<<" x_peak="<<x_peak<< endl; + //if(data_tmp[i-x_start_analysis] >= (double)y_min + ((double)y_peak-y_min)/2) + if(data_tmp[i-x_start_analysis] < (double)y_min + ((double)y_peak-y_min)/2) + { + //cout << "GGG FOUND x_half_min="<<i<< endl; + //x_half_min = i; + x_half_min = i+1; + break; + } + } + + //exterior half maximum on the right + //for(int i=x_end_analysis - avg_val; i > x_peak; i--) + for(int i = x_peak+1; i <= x_end_analysis - avg_val; i++) + { + //cout << "GGG i="<<i<<" data_tmp["<<i-x_start_analysis<<"]="<< data_tmp[i-x_start_analysis] <<" y_min="<<y_min<<" y_peak="<<y_peak<<" x_peak="<<x_peak<< endl; + //if(data_tmp[i-x_start_analysis] >= (double)y_min + ((double)y_peak-y_min)/2) + if(data_tmp[i-x_start_analysis] < (double)y_min + ((double)y_peak-y_min)/2) + { + //cout << "GGG FOUND x_half_max="<<i<< endl; + //x_half_max = i; + x_half_max = i-1; + break; + } + } + } + delete [] data_tmp; + return ret; +} + +uint32_t CCDSpectrometer::myntohl(uint32_t val_l) +{ + volatile uint32_t ret_val=val_l; + uint32_t volatile *pval_l; + pval_l = (uint32_t volatile *)&ret_val; + +#if __BYTE_ORDER == __BIG_ENDIAN //NOT STANDARD: ASSUMING __LITTLE_ENDIAN as the network ordering + *pval_l = __bswap_32(*pval_l); +#else + *pval_l = *pval_l; +#endif + + return ret_val; +} + + +//+------------------------------------------------------------------ +/** + * method: CCDSpectrometer::string_explode + * Explode a string +*/ +//+------------------------------------------------------------------ +void CCDSpectrometer::string_explode(string str, string separator, vector<string>* results) +{ + size_t found; + + found = str.find_first_of(separator); + while(found != 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); + } + +} + +int CCDSpectrometer::load_intensity_cal_file(string filename) +{ + string line; + ifstream infile (filename.c_str(), ios_base::in); + while (getline(infile, line, '\n')) + { + vector<string> results; + string_explode(line, "\t", &results); + if(results.size() == 3) + { + int ind; + float wl, cal; + int ret = sscanf(line.c_str(), "%d\t%f\t%f", &ind, &wl, &cal); + DEBUG_STREAM <<__func__ << ":Parsed from " << filename << " ret=" << ret << " cal[" << ind << "]=" << cal; + if(ret == 3 && ind >=1 && ind <= numPixel) + { + attr_IntensityCalibration_read[ind-1] = cal; + } + } + } + + infile.close(); + //DEBUG_STREAM <<__func__ << ": Read from " << filename << " " << tmp.size << " lines or " << tmp.size_d << " reals"; +} + +int CCDSpectrometer::save_intensity_cal_file(string filename) +{ + string line; + ofstream outfile (filename.c_str(), ios_base::out | ios_base::trunc); + for(size_t i=0; i<numPixel; i++) + { + outfile << i+1 << "\t" << x_values[i] << "\t" << attr_IntensityCalibration_read[i] << endl; + } + + outfile.close(); +} + +/* clang-format off */ +/*----- PROTECTED REGION END -----*/ // CCDSpectrometer::namespace_ending +} // namespace diff --git a/src/CCDSpectrometer.h b/src/CCDSpectrometer.h new file mode 100644 index 0000000..6cf3b2b --- /dev/null +++ b/src/CCDSpectrometer.h @@ -0,0 +1,847 @@ +/*----- PROTECTED REGION ID(CCDSpectrometer.h) ENABLED START -----*/ +/* clang-format on */ +//============================================================================= +// +// file : CCDSpectrometer.h +// +// description : Include file for the CCDSpectrometer class +// +// project : CCDSpectrometer +// +// 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 CCDSpectrometer_H +#define CCDSpectrometer_H + +#include <tango.h> +#include "readthread.h" +#include "Fit.h" +#include "tbuffer.hpp" + +#define MAX_GAUSS_ITERATION 25 +#define MAX_CONFITEOR_ITERATION 20 +#define NUM_GAUSS_PARAMETER 4 +#define AUTO_EXPOSURE_MEAN 4 +#define SIGMA_TO_FWHM_FACTOR 0.4246609 + +#define NUM_BUF 5 +#define BUF_SIZE 10000 +#define BUF_ID_FWHM_CENTER 0 +#define BUF_ID_FWHM_WIDTH 1 +#define BUF_ID_GAUSS_CENTER 2 +#define BUF_ID_GAUSS_WIDTH 3 +#define BUF_ID_AREA 4 + +#define DATA_ATTR "HorProfile" +#define EXPOSURE_ATTR "Exposure" +#define TRIGGER_ATTR "Trigger" +#define COUNTER_ATTR "AcquisitionCounter" +#define ROI_ATTR "HwRoiParam" +#define START_CMD "Start" +#define STOP_CMD "Stop" +#define GET_DATA_CMD "GetHorPosProfile" + +/* clang-format off */ +/*----- PROTECTED REGION END -----*/ // CCDSpectrometer.h + +#ifdef TANGO_LOG + // cppTango after c934adea (Merge branch 'remove-cout-definition' into 'main', 2022-05-23) + // nothing to do +#else + // cppTango 9.3-backports and older + #define TANGO_LOG cout + #define TANGO_LOG_INFO cout2 + #define TANGO_LOG_DEBUG cout3 +#endif // TANGO_LOG + +/** + * CCDSpectrometer class description: + * Laser Spectrometer based on Basler CCD Tango Device + */ + + +namespace CCDSpectrometer_ns +{ +/*----- PROTECTED REGION ID(CCDSpectrometer::Additional Class Declarations) ENABLED START -----*/ +/* clang-format on */ +// Additional Class Declarations +uint16_t const MAX_NR_PIXELS = 4096; +/* clang-format off */ +/*----- PROTECTED REGION END -----*/ // CCDSpectrometer::Additional Class Declarations + +class CCDSpectrometer : public TANGO_BASE_CLASS +{ + +/*----- PROTECTED REGION ID(CCDSpectrometer::Data Members) ENABLED START -----*/ +/* clang-format on */ +// Add your own data members + readthread *loop; +public: + Tango::DeviceProxy *dp; + omni_mutex *dpmutex; + tbuffer::buffer_t<double> tbuf[NUM_BUF]; + tbuffer::buffer_t<tbuffer::_data_array<double> > tbuf_array;//GetData + tbuffer::buffer_t<tbuffer::_data_array<double> > tbuf_array_w;//GetWave + tbuffer::buffer_t<tbuffer::_data_array<double> > tbuf_array_l;//GetLambda + + bool conn_status; + bool abortflag; + bool live_mode; + bool init_live_mode; + bool measure_mode; + bool init_measure_mode; + bool acquire_noise_mode; + bool init_acquire_noise_mode; + bool stop_mode; + + uint32_t noise_frames; + int noise_frames_counter; + int noise_level; + timespec last_read; + + /*LibFit_ns::*/Fit *m_gaussfit;// + /*LibFit_ns::*/Fit *m_asyngaussfit;// + /*LibFit_ns::*/Fit *m_confiteorfit;// + bool GaussFit_valid; + + //DWORD *pMeasData; + double *pLiveData; + double *pLiveData_avg; + double *pNoiseMask_avg; + double *pFrameBuffer; //bi-dimensional array + double *pReferenceData; + unsigned int FrameBufferIndex; + Tango::DevDouble *x_values; + unsigned int RegionOfInterestStartPix; + unsigned int RegionOfInterestEndPix; + unsigned int AnalysisRegionStartPix; + unsigned int AnalysisRegionEndPix; + void init_data(bool reconnection); + unsigned int WaveLenght2Pix(double val); + bool fwhm_calculate(double */*restrict*/ data_array, size_t dim_frame, size_t x_start_analysis, size_t x_end_analisys, size_t num_frames, size_t avg_val, size_t &x_peak, double &y_peak, size_t &x_half_min, size_t &x_half_max); + int y_max_mean; + int exposures[AUTO_EXPOSURE_MEAN]; + int exposure_idx; + void string_explode(string str, string separator, vector<string>* results); + int load_intensity_cal_file(string filename); + int save_intensity_cal_file(string filename); + uint32_t myntohl(uint32_t val_l); + + float fit[5/*NR_WAVELEN_POL_COEF*/]; + + double m_pLambda[MAX_NR_PIXELS]; + unsigned int l_Time; + double l_pSpectrum[MAX_NR_PIXELS];//TODO: REMOVE + char attr_strchar[1024]; + Tango::DevString attr_tmp_ptr; +/* clang-format off */ +/*----- PROTECTED REGION END -----*/ // CCDSpectrometer::Data Members + +// Device property data members +public: + // DeviceName: + std::string deviceName; + // DefaultGaussRef: Default Gauss Reference + std::vector<Tango::DevDouble> defaultGaussRef; + // DataReferenceFile: Default Data Reference File + std::string dataReferenceFile; + // DefaultStartRegion: Beginning of the region of interest + Tango::DevDouble defaultStartRegion; + // DefaultEndRegion: End of the region of interest + Tango::DevDouble defaultEndRegion; + // PreferFWHM: Choose FWHM instead og GaussianFit if both enabled + Tango::DevBoolean preferFWHM; + // AutoExposureRange: AutoExposure Range + std::vector<Tango::DevDouble> autoExposureRange; + // AutoExposureStep: AutoExposure Step + Tango::DevDouble autoExposureStep; + // AutoExposureAmpRange: AutoExposure Amp Range + std::vector<Tango::DevDouble> autoExposureAmpRange; + // IntensityCalibrationFile: + std::string intensityCalibrationFile; + // NoiseProfileFile: + std::string noiseProfileFile; + // WavelengthAttr: device name + // attribute name + std::vector<std::string> wavelengthAttr; + // AreaInAnalysisRegion: use AnalysisRegion for area instead of AreaRegion + Tango::DevBoolean areaInAnalysisRegion; + // WidthCorrection: widht_in^2 + widthcorrection^2 = widht_out^2 + Tango::DevDouble widthCorrection; + // NFramesBuffered: number of frames buffered when in live mode + Tango::DevLong nFramesBuffered; + // AnalysisRegion: AnalysisRegion + std::vector<Tango::DevDouble> analysisRegion; + // RegionOfInterest: RegionOfInterest + std::vector<Tango::DevDouble> regionOfInterest; + // ExposureTime: ExposureTime + Tango::DevDouble exposureTime; + // SyncMode: ExposureTime + Tango::DevLong syncMode; + // AutoStart: AutoStart + Tango::DevBoolean autoStart; + // NumPixel: Number of pixel of the CCD + Tango::DevLong numPixel; + // CameraLabel: Camera label or IP + std::string cameraLabel; + +// Attribute data members +public: + Tango::DevLong *attr_SyncMode_read; + Tango::DevDouble *attr_ExposureTime_read; + Tango::DevBoolean *attr_NoiseSubtraction_read; + Tango::DevBoolean *attr_GaussFitEnable_read; + Tango::DevBoolean *attr_FWHMEnable_read; + Tango::DevDouble *attr_GaussFitCenter_read; + Tango::DevDouble *attr_GaussFitWidth_read; + Tango::DevDouble *attr_FWHMCenter_read; + Tango::DevDouble *attr_FWHMWidth_read; + Tango::DevDouble *attr_Center_read; + Tango::DevDouble *attr_Width_read; + Tango::DevLong *attr_FitType_read; + Tango::DevLong *attr_FWHMAvg_read; + Tango::DevLong *attr_NoiseLevel_read; + Tango::DevString *attr_DataReferenceFile_read; + Tango::DevBoolean *attr_AutoExposure_read; + Tango::DevBoolean *attr_RtMode_read; + Tango::DevBoolean *attr_IntensityCalibrationEnable_read; + Tango::DevDouble *attr_Area_read; + Tango::DevDouble *attr_AreaRegion_read; + Tango::DevBoolean *attr_AreaEnable_read; + Tango::DevBoolean *attr_WidthCorrectionEnable_read; + Tango::DevBoolean *attr_IncrSensitivity_read; + Tango::DevDouble *attr_Data_read; + Tango::DevLong *attr_NumPixels_read; + Tango::DevDouble *attr_RegionOfInterest_read; + Tango::DevDouble *attr_AnalysisRegion_read; + Tango::DevDouble *attr_GaussFit_read; + Tango::DevDouble *attr_FWHM_read; + Tango::DevDouble *attr_GaussReference_read; + Tango::DevDouble *attr_DataReference_read; + Tango::DevDouble *attr_IntensityCalibration_read; + Tango::DevDouble *attr_NoiseProfile_read; + Tango::DevDouble *attr_Wave_read; + Tango::DevDouble *attr_Lambda_read; + +// Constructors and destructors +public: + /** + * Constructs a newly device object. + * + * @param cl Class. + * @param s Device Name + */ + CCDSpectrometer(Tango::DeviceClass *cl,std::string &s); + /** + * Constructs a newly device object. + * + * @param cl Class. + * @param s Device Name + */ + CCDSpectrometer(Tango::DeviceClass *cl,const char *s); + /** + * Constructs a newly device object. + * + * @param cl Class. + * @param s Device name + * @param d Device description. + */ + CCDSpectrometer(Tango::DeviceClass *cl,const char *s,const char *d); + /** + * The device object destructor. + */ + ~CCDSpectrometer(); + + +// 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 : CCDSpectrometer::read_attr_hardware() + * Description: Hardware acquisition for attributes. + */ + //-------------------------------------------------------- + virtual void read_attr_hardware(std::vector<long> &attr_list); + //-------------------------------------------------------- + /* + * Method : CCDSpectrometer::write_attr_hardware() + * Description: Hardware writing for attributes. + */ + //-------------------------------------------------------- + virtual void write_attr_hardware(std::vector<long> &attr_list); + +/** + * Attribute SyncMode related methods + * Description: 0=SW + * 1=HW Sync input + * 2=HW external trigger + * + * Data type: Tango::DevLong + * Attr type: Scalar + */ + virtual void read_SyncMode(Tango::Attribute &attr); + virtual void write_SyncMode(Tango::WAttribute &attr); + virtual bool is_SyncMode_allowed(Tango::AttReqType type); +/** + * Attribute ExposureTime related methods + * Description: Exposure time in milliseconds + * + * Data type: Tango::DevDouble + * Attr type: Scalar + */ + virtual void read_ExposureTime(Tango::Attribute &attr); + virtual void write_ExposureTime(Tango::WAttribute &attr); + virtual bool is_ExposureTime_allowed(Tango::AttReqType type); +/** + * Attribute NoiseSubtraction related methods + * Description: Enable/Disable subtraction of background noise profile + * acquired with the AcquireNoise command + * + * Data type: Tango::DevBoolean + * Attr type: Scalar + */ + virtual void read_NoiseSubtraction(Tango::Attribute &attr); + virtual void write_NoiseSubtraction(Tango::WAttribute &attr); + virtual bool is_NoiseSubtraction_allowed(Tango::AttReqType type); +/** + * Attribute GaussFitEnable related methods + * + * + * Data type: Tango::DevBoolean + * Attr type: Scalar + */ + virtual void read_GaussFitEnable(Tango::Attribute &attr); + virtual void write_GaussFitEnable(Tango::WAttribute &attr); + virtual bool is_GaussFitEnable_allowed(Tango::AttReqType type); +/** + * Attribute FWHMEnable related methods + * + * + * Data type: Tango::DevBoolean + * Attr type: Scalar + */ + virtual void read_FWHMEnable(Tango::Attribute &attr); + virtual void write_FWHMEnable(Tango::WAttribute &attr); + virtual bool is_FWHMEnable_allowed(Tango::AttReqType type); +/** + * Attribute GaussFitCenter related methods + * Description: wavelength of peak of Gaussian Fit + * + * Data type: Tango::DevDouble + * Attr type: Scalar + */ + virtual void read_GaussFitCenter(Tango::Attribute &attr); + virtual bool is_GaussFitCenter_allowed(Tango::AttReqType type); +/** + * Attribute GaussFitWidth related methods + * Description: width of Gaussian Fit + * + * Data type: Tango::DevDouble + * Attr type: Scalar + */ + virtual void read_GaussFitWidth(Tango::Attribute &attr); + virtual bool is_GaussFitWidth_allowed(Tango::AttReqType type); +/** + * Attribute FWHMCenter related methods + * Description: wavelength of peak of FWHM + * + * Data type: Tango::DevDouble + * Attr type: Scalar + */ + virtual void read_FWHMCenter(Tango::Attribute &attr); + virtual bool is_FWHMCenter_allowed(Tango::AttReqType type); +/** + * Attribute FWHMWidth related methods + * Description: width of FWHM + * + * Data type: Tango::DevDouble + * Attr type: Scalar + */ + virtual void read_FWHMWidth(Tango::Attribute &attr); + virtual bool is_FWHMWidth_allowed(Tango::AttReqType type); +/** + * Attribute Center related methods + * Description: wavelength of peak of FWHM or of Gaussian Fit + * + * Data type: Tango::DevDouble + * Attr type: Scalar + */ + virtual void read_Center(Tango::Attribute &attr); + virtual bool is_Center_allowed(Tango::AttReqType type); +/** + * Attribute Width related methods + * Description: width of FWHM or of Gaussian Fit + * + * Data type: Tango::DevDouble + * Attr type: Scalar + */ + virtual void read_Width(Tango::Attribute &attr); + virtual bool is_Width_allowed(Tango::AttReqType type); +/** + * Attribute FitType related methods + * Description: 1=Gaussian 2=Gaussian Asymm 3=Confiteor + * + * Data type: Tango::DevLong + * Attr type: Scalar + */ + virtual void read_FitType(Tango::Attribute &attr); + virtual void write_FitType(Tango::WAttribute &attr); + virtual bool is_FitType_allowed(Tango::AttReqType type); +/** + * Attribute FWHMAvg related methods + * + * + * Data type: Tango::DevLong + * Attr type: Scalar + */ + virtual void read_FWHMAvg(Tango::Attribute &attr); + virtual void write_FWHMAvg(Tango::WAttribute &attr); + virtual bool is_FWHMAvg_allowed(Tango::AttReqType type); +/** + * Attribute NoiseLevel related methods + * + * + * Data type: Tango::DevLong + * Attr type: Scalar + */ + virtual void read_NoiseLevel(Tango::Attribute &attr); + virtual void write_NoiseLevel(Tango::WAttribute &attr); + virtual bool is_NoiseLevel_allowed(Tango::AttReqType type); +/** + * Attribute DataReferenceFile related methods + * + * + * Data type: Tango::DevString + * Attr type: Scalar + */ + virtual void read_DataReferenceFile(Tango::Attribute &attr); + virtual void write_DataReferenceFile(Tango::WAttribute &attr); + virtual bool is_DataReferenceFile_allowed(Tango::AttReqType type); +/** + * Attribute AutoExposure related methods + * + * + * Data type: Tango::DevBoolean + * Attr type: Scalar + */ + virtual void read_AutoExposure(Tango::Attribute &attr); + virtual void write_AutoExposure(Tango::WAttribute &attr); + virtual bool is_AutoExposure_allowed(Tango::AttReqType type); +/** + * Attribute RtMode related methods + * + * + * Data type: Tango::DevBoolean + * Attr type: Scalar + */ + virtual void read_RtMode(Tango::Attribute &attr); + virtual void write_RtMode(Tango::WAttribute &attr); + virtual bool is_RtMode_allowed(Tango::AttReqType type); +/** + * Attribute IntensityCalibrationEnable related methods + * + * + * Data type: Tango::DevBoolean + * Attr type: Scalar + */ + virtual void read_IntensityCalibrationEnable(Tango::Attribute &attr); + virtual void write_IntensityCalibrationEnable(Tango::WAttribute &attr); + virtual bool is_IntensityCalibrationEnable_allowed(Tango::AttReqType type); +/** + * Attribute Area related methods + * + * + * Data type: Tango::DevDouble + * Attr type: Scalar + */ + virtual void read_Area(Tango::Attribute &attr); + virtual bool is_Area_allowed(Tango::AttReqType type); +/** + * Attribute AreaRegion related methods + * + * + * Data type: Tango::DevDouble + * Attr type: Scalar + */ + virtual void read_AreaRegion(Tango::Attribute &attr); + virtual void write_AreaRegion(Tango::WAttribute &attr); + virtual bool is_AreaRegion_allowed(Tango::AttReqType type); +/** + * Attribute AreaEnable related methods + * + * + * Data type: Tango::DevBoolean + * Attr type: Scalar + */ + virtual void read_AreaEnable(Tango::Attribute &attr); + virtual void write_AreaEnable(Tango::WAttribute &attr); + virtual bool is_AreaEnable_allowed(Tango::AttReqType type); +/** + * Attribute WidthCorrectionEnable related methods + * Description: enable widht correction + * + * Data type: Tango::DevBoolean + * Attr type: Scalar + */ + virtual void read_WidthCorrectionEnable(Tango::Attribute &attr); + virtual void write_WidthCorrectionEnable(Tango::WAttribute &attr); + virtual bool is_WidthCorrectionEnable_allowed(Tango::AttReqType type); +/** + * Attribute IncrSensitivity related methods + * Description: false: use standard sensitivity + * true: use increased sensitivity + * + * Data type: Tango::DevBoolean + * Attr type: Scalar + */ + virtual void read_IncrSensitivity(Tango::Attribute &attr); + virtual void write_IncrSensitivity(Tango::WAttribute &attr); + virtual bool is_IncrSensitivity_allowed(Tango::AttReqType type); +/** + * Attribute Data related methods + * + * + * Data type: Tango::DevDouble + * Attr type: Spectrum max = 4100 + */ + virtual void read_Data(Tango::Attribute &attr); + virtual bool is_Data_allowed(Tango::AttReqType type); +/** + * Attribute NumPixels related methods + * Description: long[0]: number of pixels horizontally (number of CCD-array columns) + * long[1]: number of pixels vertically (number of CCD-array lines) + * + * Data type: Tango::DevLong + * Attr type: Spectrum max = 2 + */ + virtual void read_NumPixels(Tango::Attribute &attr); + virtual bool is_NumPixels_allowed(Tango::AttReqType type); +/** + * Attribute RegionOfInterest related methods + * Description: Region of interest returned by the Data attribute + * double[0]=start of the region + * double[1]=end of the region + * + * Values are in nm according with the conversion factor in x_values + * Data attribute property + * + * Data type: Tango::DevDouble + * Attr type: Spectrum max = 2 + */ + virtual void read_RegionOfInterest(Tango::Attribute &attr); + virtual void write_RegionOfInterest(Tango::WAttribute &attr); + virtual bool is_RegionOfInterest_allowed(Tango::AttReqType type); +/** + * Attribute AnalysisRegion related methods + * Description: Region used for gaussian and fwhm analysis + * double[0]=start of the region + * double[1]=end of the region + * + * Values are in nm according with the conversion factor in x_values + * Data attribute property + * + * Data type: Tango::DevDouble + * Attr type: Spectrum max = 2 + */ + virtual void read_AnalysisRegion(Tango::Attribute &attr); + virtual void write_AnalysisRegion(Tango::WAttribute &attr); + virtual bool is_AnalysisRegion_allowed(Tango::AttReqType type); +/** + * Attribute GaussFit related methods + * Description: double[0]= wavelength of peak of Gaussian Fit + * double[1]= width of Gaussian Fit + * + * Data type: Tango::DevDouble + * Attr type: Spectrum max = 4 + */ + virtual void read_GaussFit(Tango::Attribute &attr); + virtual bool is_GaussFit_allowed(Tango::AttReqType type); +/** + * Attribute FWHM related methods + * Description: double[0]= wavelength of peak of FWHM + * double[1]= width of FWHM + * + * Data type: Tango::DevDouble + * Attr type: Spectrum max = 3 + */ + virtual void read_FWHM(Tango::Attribute &attr); + virtual bool is_FWHM_allowed(Tango::AttReqType type); +/** + * Attribute GaussReference related methods + * Description: double[0]= wavelength of peak of Gaussian Fit + * double[1]= width of Gaussian Fit + * + * Data type: Tango::DevDouble + * Attr type: Spectrum max = 4 + */ + virtual void read_GaussReference(Tango::Attribute &attr); + virtual void write_GaussReference(Tango::WAttribute &attr); + virtual bool is_GaussReference_allowed(Tango::AttReqType type); +/** + * Attribute DataReference related methods + * Description: A reference curve + * + * Data type: Tango::DevDouble + * Attr type: Spectrum max = 5000 + */ + virtual void read_DataReference(Tango::Attribute &attr); + virtual void write_DataReference(Tango::WAttribute &attr); + virtual bool is_DataReference_allowed(Tango::AttReqType type); +/** + * Attribute IntensityCalibration related methods + * Description: A reference curve + * + * Data type: Tango::DevDouble + * Attr type: Spectrum max = 5000 + */ + virtual void read_IntensityCalibration(Tango::Attribute &attr); + virtual void write_IntensityCalibration(Tango::WAttribute &attr); + virtual bool is_IntensityCalibration_allowed(Tango::AttReqType type); +/** + * Attribute NoiseProfile related methods + * Description: A reference curve + * + * Data type: Tango::DevDouble + * Attr type: Spectrum max = 5000 + */ + virtual void read_NoiseProfile(Tango::Attribute &attr); + virtual bool is_NoiseProfile_allowed(Tango::AttReqType type); +/** + * Attribute Wave related methods + * + * + * Data type: Tango::DevDouble + * Attr type: Spectrum max = 5000 + */ + virtual void read_Wave(Tango::Attribute &attr); + virtual bool is_Wave_allowed(Tango::AttReqType type); +/** + * Attribute Lambda related methods + * + * + * Data type: Tango::DevDouble + * Attr type: Spectrum max = 5000 + */ + virtual void read_Lambda(Tango::Attribute &attr); + virtual bool is_Lambda_allowed(Tango::AttReqType type); + + + //-------------------------------------------------------- + /** + * Method : CCDSpectrometer::add_dynamic_attributes() + * Description: Add dynamic attributes if any. + */ + //-------------------------------------------------------- + void add_dynamic_attributes(); + + + + +// Command related methods +public: + /** + * Command Start related method + * + * + */ + virtual void start(); + virtual bool is_Start_allowed(const CORBA::Any &any); + /** + * Command Stop related method + * + * + */ + virtual void stop(); + virtual bool is_Stop_allowed(const CORBA::Any &any); + /** + * Command Reset related method + * + * + */ + virtual void reset(); + virtual bool is_Reset_allowed(const CORBA::Any &any); + /** + * Command StartSingle related method + * Description: Start single acquisition + * + */ + virtual void start_single(); + virtual bool is_StartSingle_allowed(const CORBA::Any &any); + /** + * Command StartContinuous related method + * Description: Start acquisition in Continuous mode + * + */ + virtual void start_continuous(); + virtual bool is_StartContinuous_allowed(const CORBA::Any &any); + /** + * Command GetLastData related method + * Description: returns the last argin frames saved + * + * @param argin number of frames to return + * @returns + */ + virtual Tango::DevVarDoubleArray *get_last_data(Tango::DevLong argin); + virtual bool is_GetLastData_allowed(const CORBA::Any &any); + /** + * Command AcquireNoise related method + * Description: Acquire argin frames of background noise + * + * @param argin Number of frames to acquire as noise + */ + virtual void acquire_noise(Tango::DevLong argin); + virtual bool is_AcquireNoise_allowed(const CORBA::Any &any); + /** + * Command SaveReferenceData related method + * Description: Save current curve as reference curve + * + */ + virtual void save_reference_data(); + virtual bool is_SaveReferenceData_allowed(const CORBA::Any &any); + /** + * Command GetData related method + * + * + * @param argin + * @returns + */ + virtual Tango::DevVarDoubleArray *get_data(const Tango::DevVarLongArray *argin); + virtual bool is_GetData_allowed(const CORBA::Any &any); + /** + * Command GetGaussFitCenter related method + * + * + * @param argin + * @returns + */ + virtual Tango::DevVarDoubleArray *get_gauss_fit_center(const Tango::DevVarLongArray *argin); + virtual bool is_GetGaussFitCenter_allowed(const CORBA::Any &any); + /** + * Command GetGaussFitWidth related method + * + * + * @param argin + * @returns + */ + virtual Tango::DevVarDoubleArray *get_gauss_fit_width(const Tango::DevVarLongArray *argin); + virtual bool is_GetGaussFitWidth_allowed(const CORBA::Any &any); + /** + * Command GetFWHMCenter related method + * + * + * @param argin + * @returns + */ + virtual Tango::DevVarDoubleArray *get_fwhmcenter(const Tango::DevVarLongArray *argin); + virtual bool is_GetFWHMCenter_allowed(const CORBA::Any &any); + /** + * Command GetFWHMWidth related method + * + * + * @param argin + * @returns + */ + virtual Tango::DevVarDoubleArray *get_fwhmwidth(const Tango::DevVarLongArray *argin); + virtual bool is_GetFWHMWidth_allowed(const CORBA::Any &any); + /** + * Command ExportWavelength related method + * + * + */ + virtual void export_wavelength(); + virtual bool is_ExportWavelength_allowed(const CORBA::Any &any); + /** + * Command GetArea related method + * + * + * @param argin + * @returns + */ + virtual Tango::DevVarDoubleArray *get_area(const Tango::DevVarLongArray *argin); + virtual bool is_GetArea_allowed(const CORBA::Any &any); + /** + * Command GetWave related method + * Description: Same as GetData + * + * @param argin + * @returns + */ + virtual Tango::DevVarDoubleArray *get_wave(const Tango::DevVarLongArray *argin); + virtual bool is_GetWave_allowed(const CORBA::Any &any); + /** + * Command GetLambda related method + * + * + * @param argin + * @returns + */ + virtual Tango::DevVarDoubleArray *get_lambda(const Tango::DevVarLongArray *argin); + virtual bool is_GetLambda_allowed(const CORBA::Any &any); + + + //-------------------------------------------------------- + /** + * Method : CCDSpectrometer::add_dynamic_commands() + * Description: Add dynamic commands if any. + */ + //-------------------------------------------------------- + void add_dynamic_commands(); + +/*----- PROTECTED REGION ID(CCDSpectrometer::Additional Method prototypes) ENABLED START -----*/ +/* clang-format on */ +// Additional Method prototypes + +/* clang-format off */ +/*----- PROTECTED REGION END -----*/ // CCDSpectrometer::Additional Method prototypes +}; + +/*----- PROTECTED REGION ID(CCDSpectrometer::Additional Classes Definitions) ENABLED START -----*/ +/* clang-format on */ +// Additional Classes Definitions +/* clang-format off */ +/*----- PROTECTED REGION END -----*/ // CCDSpectrometer::Additional Classes Definitions + +} // End of namespace + +#endif // CCDSpectrometer_H diff --git a/src/CCDSpectrometer.xmi b/src/CCDSpectrometer.xmi new file mode 100644 index 0000000..a28f15c --- /dev/null +++ b/src/CCDSpectrometer.xmi @@ -0,0 +1,553 @@ +<?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="CCDSpectrometer" pogoRevision="9.7"> + <description description="Laser Spectrometer based on Basler CCD Tango Device" title="CCDSpectrometer" sourcePath="/home/graziano/ws/ds/ccd-spectrometer/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 - graziano.scalamera" author="graziano.scalamera" emailDomain="elettra.eu" classFamily="BeamDiagnostics" siteSpecific="" platform="Unix Like" bus="Not Applicable" manufacturer="Elettra" reference=""/> + </description> + <deviceProperties name="DeviceName" description=""> + <type xsi:type="pogoDsl:StringType"/> + <status abstract="false" inherited="false" concrete="true" concreteHere="true"/> + </deviceProperties> + <deviceProperties name="DefaultGaussRef" description="Default Gauss Reference"> + <type xsi:type="pogoDsl:DoubleVectorType"/> + <status abstract="false" inherited="false" concrete="true" concreteHere="true"/> + </deviceProperties> + <deviceProperties name="DataReferenceFile" description="Default Data Reference File"> + <type xsi:type="pogoDsl:StringType"/> + <status abstract="false" inherited="false" concrete="true" concreteHere="true"/> + </deviceProperties> + <deviceProperties name="DefaultStartRegion" description="Beginning of the region of interest"> + <type xsi:type="pogoDsl:DoubleType"/> + <status abstract="false" inherited="false" concrete="true" concreteHere="true"/> + </deviceProperties> + <deviceProperties name="DefaultEndRegion" description="End of the region of interest"> + <type xsi:type="pogoDsl:DoubleType"/> + <status abstract="false" inherited="false" concrete="true" concreteHere="true"/> + </deviceProperties> + <deviceProperties name="PreferFWHM" description="Choose FWHM instead og GaussianFit if both enabled"> + <type xsi:type="pogoDsl:BooleanType"/> + <status abstract="false" inherited="false" concrete="true" concreteHere="true"/> + <DefaultPropValue>false</DefaultPropValue> + </deviceProperties> + <deviceProperties name="AutoExposureRange" description="AutoExposure Range"> + <type xsi:type="pogoDsl:DoubleVectorType"/> + <status abstract="false" inherited="false" concrete="true" concreteHere="true"/> + </deviceProperties> + <deviceProperties name="AutoExposureStep" description="AutoExposure Step"> + <type xsi:type="pogoDsl:DoubleType"/> + <status abstract="false" inherited="false" concrete="true" concreteHere="true"/> + </deviceProperties> + <deviceProperties name="AutoExposureAmpRange" description="AutoExposure Amp Range"> + <type xsi:type="pogoDsl:DoubleVectorType"/> + <status abstract="false" inherited="false" concrete="true" concreteHere="true"/> + </deviceProperties> + <deviceProperties name="IntensityCalibrationFile" description=""> + <type xsi:type="pogoDsl:StringType"/> + <status abstract="false" inherited="false" concrete="true" concreteHere="true"/> + </deviceProperties> + <deviceProperties name="NoiseProfileFile" description=""> + <type xsi:type="pogoDsl:StringType"/> + <status abstract="false" inherited="false" concrete="true" concreteHere="true"/> + </deviceProperties> + <deviceProperties name="WavelengthAttr" description="device name
attribute name"> + <type xsi:type="pogoDsl:StringVectorType"/> + <status abstract="false" inherited="false" concrete="true" concreteHere="true"/> + </deviceProperties> + <deviceProperties name="AreaInAnalysisRegion" description="use AnalysisRegion for area instead of AreaRegion"> + <type xsi:type="pogoDsl:BooleanType"/> + <status abstract="false" inherited="false" concrete="true" concreteHere="true"/> + <DefaultPropValue>false</DefaultPropValue> + </deviceProperties> + <deviceProperties name="WidthCorrection" description="widht_in^2 + widthcorrection^2 = widht_out^2"> + <type xsi:type="pogoDsl:DoubleType"/> + <status abstract="false" inherited="false" concrete="true" concreteHere="true"/> + <DefaultPropValue>0</DefaultPropValue> + </deviceProperties> + <deviceProperties name="NFramesBuffered" description="number of frames buffered when in live mode"> + <type xsi:type="pogoDsl:IntType"/> + <status abstract="false" inherited="false" concrete="true" concreteHere="true"/> + <DefaultPropValue>1000</DefaultPropValue> + </deviceProperties> + <deviceProperties name="AnalysisRegion" description="AnalysisRegion"> + <type xsi:type="pogoDsl:DoubleVectorType"/> + <status abstract="false" inherited="false" concrete="true" concreteHere="true"/> + </deviceProperties> + <deviceProperties name="RegionOfInterest" description="RegionOfInterest"> + <type xsi:type="pogoDsl:DoubleVectorType"/> + <status abstract="false" inherited="false" concrete="true" concreteHere="true"/> + </deviceProperties> + <deviceProperties name="ExposureTime" description="ExposureTime"> + <type xsi:type="pogoDsl:DoubleType"/> + <status abstract="false" inherited="false" concrete="true" concreteHere="true"/> + </deviceProperties> + <deviceProperties name="SyncMode" description="ExposureTime"> + <type xsi:type="pogoDsl:IntType"/> + <status abstract="false" inherited="false" concrete="true" concreteHere="true"/> + </deviceProperties> + <deviceProperties name="AutoStart" description="AutoStart"> + <type xsi:type="pogoDsl:BooleanType"/> + <status abstract="false" inherited="false" concrete="true" concreteHere="true"/> + </deviceProperties> + <deviceProperties name="NumPixel" description="Number of pixel of the CCD"> + <type xsi:type="pogoDsl:IntType"/> + <status abstract="false" inherited="false" concrete="true" concreteHere="true"/> + </deviceProperties> + <deviceProperties name="CameraLabel" description="Camera label or IP"> + <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="Start" description="" execMethod="start" displayLevel="OPERATOR" polledPeriod="0" isDynamic="false"> + <argin description=""> + <type xsi:type="pogoDsl:VoidType"/> + </argin> + <argout description=""> + <type xsi:type="pogoDsl:VoidType"/> + </argout> + <status abstract="false" inherited="false" concrete="true" concreteHere="true"/> + </commands> + <commands name="Stop" description="" execMethod="stop" displayLevel="OPERATOR" polledPeriod="0" isDynamic="false"> + <argin description=""> + <type xsi:type="pogoDsl:VoidType"/> + </argin> + <argout description=""> + <type xsi:type="pogoDsl:VoidType"/> + </argout> + <status abstract="false" inherited="false" concrete="true" concreteHere="true"/> + </commands> + <commands name="Reset" description="" execMethod="reset" displayLevel="OPERATOR" polledPeriod="0" isDynamic="false"> + <argin description=""> + <type xsi:type="pogoDsl:VoidType"/> + </argin> + <argout description=""> + <type xsi:type="pogoDsl:VoidType"/> + </argout> + <status abstract="false" inherited="false" concrete="true" concreteHere="true"/> + </commands> + <commands name="StartSingle" description="Start single acquisition" execMethod="start_single" displayLevel="OPERATOR" polledPeriod="0" isDynamic="false"> + <argin description=""> + <type xsi:type="pogoDsl:VoidType"/> + </argin> + <argout description=""> + <type xsi:type="pogoDsl:VoidType"/> + </argout> + <status abstract="false" inherited="false" concrete="true" concreteHere="true"/> + </commands> + <commands name="StartContinuous" description="Start acquisition in Continuous mode" execMethod="start_continuous" displayLevel="OPERATOR" polledPeriod="0" isDynamic="false"> + <argin description=""> + <type xsi:type="pogoDsl:VoidType"/> + </argin> + <argout description=""> + <type xsi:type="pogoDsl:VoidType"/> + </argout> + <status abstract="false" inherited="false" concrete="true" concreteHere="true"/> + </commands> + <commands name="GetLastData" description="returns the last argin frames saved" execMethod="get_last_data" displayLevel="OPERATOR" polledPeriod="0" isDynamic="false"> + <argin description="number of frames to return"> + <type xsi:type="pogoDsl:IntType"/> + </argin> + <argout description=""> + <type xsi:type="pogoDsl:DoubleArrayType"/> + </argout> + <status abstract="false" inherited="false" concrete="true" concreteHere="true"/> + </commands> + <commands name="AcquireNoise" description="Acquire argin frames of background noise" execMethod="acquire_noise" displayLevel="OPERATOR" polledPeriod="0" isDynamic="false"> + <argin description="Number of frames to acquire as noise"> + <type xsi:type="pogoDsl:IntType"/> + </argin> + <argout description=""> + <type xsi:type="pogoDsl:VoidType"/> + </argout> + <status abstract="false" inherited="false" concrete="true" concreteHere="true"/> + </commands> + <commands name="SaveReferenceData" description="Save current curve as reference curve" execMethod="save_reference_data" displayLevel="OPERATOR" polledPeriod="0" isDynamic="false"> + <argin description=""> + <type xsi:type="pogoDsl:VoidType"/> + </argin> + <argout description=""> + <type xsi:type="pogoDsl:VoidType"/> + </argout> + <status abstract="false" inherited="false" concrete="true" concreteHere="true"/> + </commands> + <commands name="GetData" description="" execMethod="get_data" displayLevel="OPERATOR" polledPeriod="0" isDynamic="false"> + <argin description=""> + <type xsi:type="pogoDsl:IntArrayType"/> + </argin> + <argout description=""> + <type xsi:type="pogoDsl:DoubleArrayType"/> + </argout> + <status abstract="false" inherited="false" concrete="true" concreteHere="true"/> + </commands> + <commands name="GetGaussFitCenter" description="" execMethod="get_gauss_fit_center" displayLevel="OPERATOR" polledPeriod="0" isDynamic="false"> + <argin description=""> + <type xsi:type="pogoDsl:IntArrayType"/> + </argin> + <argout description=""> + <type xsi:type="pogoDsl:DoubleArrayType"/> + </argout> + <status abstract="false" inherited="false" concrete="true" concreteHere="true"/> + </commands> + <commands name="GetGaussFitWidth" description="" execMethod="get_gauss_fit_width" displayLevel="OPERATOR" polledPeriod="0" isDynamic="false"> + <argin description=""> + <type xsi:type="pogoDsl:IntArrayType"/> + </argin> + <argout description=""> + <type xsi:type="pogoDsl:DoubleArrayType"/> + </argout> + <status abstract="false" inherited="false" concrete="true" concreteHere="true"/> + </commands> + <commands name="GetFWHMCenter" description="" execMethod="get_fwhmcenter" displayLevel="OPERATOR" polledPeriod="0" isDynamic="false"> + <argin description=""> + <type xsi:type="pogoDsl:IntArrayType"/> + </argin> + <argout description=""> + <type xsi:type="pogoDsl:DoubleArrayType"/> + </argout> + <status abstract="false" inherited="false" concrete="true" concreteHere="true"/> + </commands> + <commands name="GetFWHMWidth" description="" execMethod="get_fwhmwidth" displayLevel="OPERATOR" polledPeriod="0" isDynamic="false"> + <argin description=""> + <type xsi:type="pogoDsl:IntArrayType"/> + </argin> + <argout description=""> + <type xsi:type="pogoDsl:DoubleArrayType"/> + </argout> + <status abstract="false" inherited="false" concrete="true" concreteHere="true"/> + </commands> + <commands name="ExportWavelength" description="" execMethod="export_wavelength" displayLevel="OPERATOR" polledPeriod="0" isDynamic="false"> + <argin description=""> + <type xsi:type="pogoDsl:VoidType"/> + </argin> + <argout description=""> + <type xsi:type="pogoDsl:VoidType"/> + </argout> + <status abstract="false" inherited="false" concrete="true" concreteHere="true"/> + </commands> + <commands name="GetArea" description="" execMethod="get_area" displayLevel="OPERATOR" polledPeriod="0" isDynamic="false"> + <argin description=""> + <type xsi:type="pogoDsl:IntArrayType"/> + </argin> + <argout description=""> + <type xsi:type="pogoDsl:DoubleArrayType"/> + </argout> + <status abstract="false" inherited="false" concrete="true" concreteHere="true"/> + </commands> + <commands name="GetWave" description="Same as GetData" execMethod="get_wave" displayLevel="OPERATOR" polledPeriod="0" isDynamic="false"> + <argin description=""> + <type xsi:type="pogoDsl:IntArrayType"/> + </argin> + <argout description=""> + <type xsi:type="pogoDsl:DoubleArrayType"/> + </argout> + <status abstract="false" inherited="false" concrete="true" concreteHere="true"/> + </commands> + <commands name="GetLambda" description="" execMethod="get_lambda" displayLevel="OPERATOR" polledPeriod="0" isDynamic="false"> + <argin description=""> + <type xsi:type="pogoDsl:IntArrayType"/> + </argin> + <argout description=""> + <type xsi:type="pogoDsl:DoubleArrayType"/> + </argout> + <status abstract="false" inherited="false" concrete="true" concreteHere="true"/> + </commands> + <attributes name="SyncMode" attType="Scalar" rwType="READ_WRITE" displayLevel="OPERATOR" polledPeriod="0" maxX="" maxY="" memorized="true" memorizedAtInit="false" 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=SW
1=HW Sync input
2=HW external trigger" label="" unit="" standardUnit="" displayUnit="" format="" maxValue="" minValue="" maxAlarm="" minAlarm="" maxWarning="" minWarning="" deltaTime="" deltaValue=""/> + </attributes> + <attributes name="ExposureTime" attType="Scalar" rwType="READ_WRITE" displayLevel="OPERATOR" polledPeriod="0" maxX="" maxY="" memorized="true" memorizedAtInit="false" 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="Exposure time in milliseconds" label="" unit="ms" standardUnit="1" displayUnit="ms" format="" maxValue="" minValue="" maxAlarm="" minAlarm="" maxWarning="" minWarning="" deltaTime="" deltaValue=""/> + </attributes> + <attributes name="NoiseSubtraction" 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="Enable/Disable subtraction of background noise profile 
acquired with the AcquireNoise command" label="" unit="" standardUnit="" displayUnit="" format="" maxValue="" minValue="" maxAlarm="" minAlarm="" maxWarning="" minWarning="" deltaTime="" deltaValue=""/> + </attributes> + <attributes name="GaussFitEnable" 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="FWHMEnable" 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="GaussFitCenter" 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="wavelength of peak of Gaussian Fit" label="" unit="" standardUnit="" displayUnit="" format="" maxValue="" minValue="" maxAlarm="" minAlarm="" maxWarning="" minWarning="" deltaTime="" deltaValue=""/> + </attributes> + <attributes name="GaussFitWidth" 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="width of Gaussian Fit" label="" unit="" standardUnit="" displayUnit="" format="" maxValue="" minValue="" maxAlarm="" minAlarm="" maxWarning="" minWarning="" deltaTime="" deltaValue=""/> + </attributes> + <attributes name="FWHMCenter" 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="wavelength of peak of FWHM" label="" unit="" standardUnit="" displayUnit="" format="" maxValue="" minValue="" maxAlarm="" minAlarm="" maxWarning="" minWarning="" deltaTime="" deltaValue=""/> + </attributes> + <attributes name="FWHMWidth" 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="width of FWHM" label="" unit="" standardUnit="" displayUnit="" format="" maxValue="" minValue="" maxAlarm="" minAlarm="" maxWarning="" minWarning="" deltaTime="" deltaValue=""/> + </attributes> + <attributes name="Center" 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="wavelength of peak of FWHM or of Gaussian Fit" label="" unit="" standardUnit="" displayUnit="" format="" maxValue="" minValue="" maxAlarm="" minAlarm="" maxWarning="" minWarning="" deltaTime="" deltaValue=""/> + </attributes> + <attributes name="Width" 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="width of FWHM or of Gaussian Fit" label="" unit="" standardUnit="" displayUnit="" format="" maxValue="" minValue="" maxAlarm="" minAlarm="" maxWarning="" minWarning="" deltaTime="" deltaValue=""/> + </attributes> + <attributes name="FitType" 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=Gaussian 2=Gaussian Asymm 3=Confiteor" label="" unit="" standardUnit="" displayUnit="" format="" maxValue="3" minValue="1" maxAlarm="" minAlarm="" maxWarning="" minWarning="" deltaTime="" deltaValue=""/> + </attributes> + <attributes name="FWHMAvg" 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="NoiseLevel" 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="DataReferenceFile" attType="Scalar" rwType="READ_WRITE" displayLevel="OPERATOR" polledPeriod="0" maxX="" maxY="" memorized="true" memorizedAtInit="false" allocReadMember="false" 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="AutoExposure" 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="RtMode" 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="IntensityCalibrationEnable" 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="Area" 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="" maxValue="" minValue="" maxAlarm="" minAlarm="" maxWarning="" minWarning="" deltaTime="" deltaValue=""/> + </attributes> + <attributes name="AreaRegion" 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="" maxValue="" minValue="" maxAlarm="" minAlarm="" maxWarning="" minWarning="" deltaTime="" deltaValue=""/> + </attributes> + <attributes name="AreaEnable" 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="WidthCorrectionEnable" 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="enable widht correction" label="" unit="" standardUnit="" displayUnit="" format="" maxValue="" minValue="" maxAlarm="" minAlarm="" maxWarning="" minWarning="" deltaTime="" deltaValue=""/> + </attributes> + <attributes name="IncrSensitivity" 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="false: use standard sensitivity
true: use increased sensitivity" label="" unit="" standardUnit="" displayUnit="" format="" maxValue="" minValue="" maxAlarm="" minAlarm="" maxWarning="" minWarning="" deltaTime="" deltaValue=""/> + </attributes> + <attributes name="Data" attType="Spectrum" rwType="READ" displayLevel="OPERATOR" polledPeriod="0" maxX="4100" maxY="" allocReadMember="false" isDynamic="false"> + <dataType xsi:type="pogoDsl:DoubleType"/> + <changeEvent fire="false" libCheckCriteria="false"/> + <archiveEvent fire="false" libCheckCriteria="false"/> + <dataReadyEvent fire="false" libCheckCriteria="true"/> + <status abstract="false" inherited="false" concrete="true" concreteHere="true"/> + <properties description="" label="" unit="" standardUnit="" displayUnit="" format="" maxValue="" minValue="" maxAlarm="" minAlarm="" maxWarning="" minWarning="" deltaTime="" deltaValue=""/> + </attributes> + <attributes name="NumPixels" attType="Spectrum" rwType="READ" displayLevel="OPERATOR" polledPeriod="0" maxX="2" maxY="" allocReadMember="true" isDynamic="false"> + <dataType xsi:type="pogoDsl:IntType"/> + <changeEvent fire="false" libCheckCriteria="false"/> + <archiveEvent fire="false" libCheckCriteria="false"/> + <dataReadyEvent fire="false" libCheckCriteria="true"/> + <status abstract="false" inherited="false" concrete="true" concreteHere="true"/> + <properties description="long[0]: number of pixels horizontally (number of CCD-array columns)
long[1]: number of pixels vertically (number of CCD-array lines)" label="" unit="" standardUnit="" displayUnit="" format="" maxValue="" minValue="" maxAlarm="" minAlarm="" maxWarning="" minWarning="" deltaTime="" deltaValue=""/> + </attributes> + <attributes name="RegionOfInterest" attType="Spectrum" rwType="READ_WRITE" displayLevel="OPERATOR" polledPeriod="0" maxX="2" 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="Region of interest returned by the Data attribute
double[0]=start of the region
double[1]=end of the region

Values are in nm according with the conversion factor in x_values
Data attribute property" label="" unit="" standardUnit="" displayUnit="" format="" maxValue="" minValue="" maxAlarm="" minAlarm="" maxWarning="" minWarning="" deltaTime="" deltaValue=""/> + </attributes> + <attributes name="AnalysisRegion" attType="Spectrum" rwType="READ_WRITE" displayLevel="OPERATOR" polledPeriod="0" maxX="2" 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="Region used for gaussian and fwhm analysis
double[0]=start of the region
double[1]=end of the region

Values are in nm according with the conversion factor in x_values
Data attribute property" label="" unit="" standardUnit="" displayUnit="" format="" maxValue="" minValue="" maxAlarm="" minAlarm="" maxWarning="" minWarning="" deltaTime="" deltaValue=""/> + </attributes> + <attributes name="GaussFit" attType="Spectrum" rwType="READ" displayLevel="OPERATOR" polledPeriod="0" maxX="4" 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="double[0]= wavelength of peak of Gaussian Fit
double[1]= width of Gaussian Fit" label="" unit="" standardUnit="" displayUnit="" format="" maxValue="" minValue="" maxAlarm="" minAlarm="" maxWarning="" minWarning="" deltaTime="" deltaValue=""/> + </attributes> + <attributes name="FWHM" attType="Spectrum" rwType="READ" displayLevel="OPERATOR" polledPeriod="0" maxX="3" 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="double[0]= wavelength of peak of FWHM
double[1]= width of FWHM" label="" unit="" standardUnit="" displayUnit="" format="" maxValue="" minValue="" maxAlarm="" minAlarm="" maxWarning="" minWarning="" deltaTime="" deltaValue=""/> + </attributes> + <attributes name="GaussReference" attType="Spectrum" rwType="READ_WRITE" displayLevel="OPERATOR" polledPeriod="0" maxX="4" 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="double[0]= wavelength of peak of Gaussian Fit
double[1]= width of Gaussian Fit" label="" unit="" standardUnit="" displayUnit="" format="" maxValue="" minValue="" maxAlarm="" minAlarm="" maxWarning="" minWarning="" deltaTime="" deltaValue=""/> + </attributes> + <attributes name="DataReference" attType="Spectrum" rwType="READ_WRITE" displayLevel="OPERATOR" polledPeriod="0" maxX="5000" maxY="" allocReadMember="false" isDynamic="false"> + <dataType xsi:type="pogoDsl:DoubleType"/> + <changeEvent fire="false" libCheckCriteria="false"/> + <archiveEvent fire="false" libCheckCriteria="false"/> + <dataReadyEvent fire="false" libCheckCriteria="true"/> + <status abstract="false" inherited="false" concrete="true" concreteHere="true"/> + <properties description="A reference curve" label="" unit="" standardUnit="" displayUnit="" format="" maxValue="" minValue="" maxAlarm="" minAlarm="" maxWarning="" minWarning="" deltaTime="" deltaValue=""/> + </attributes> + <attributes name="IntensityCalibration" attType="Spectrum" rwType="READ_WRITE" displayLevel="OPERATOR" polledPeriod="0" maxX="5000" 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="A reference curve" label="" unit="" standardUnit="" displayUnit="" format="" maxValue="" minValue="" maxAlarm="" minAlarm="" maxWarning="" minWarning="" deltaTime="" deltaValue=""/> + </attributes> + <attributes name="NoiseProfile" attType="Spectrum" rwType="READ" displayLevel="OPERATOR" polledPeriod="0" maxX="5000" maxY="" allocReadMember="false" isDynamic="false"> + <dataType xsi:type="pogoDsl:DoubleType"/> + <changeEvent fire="false" libCheckCriteria="false"/> + <archiveEvent fire="false" libCheckCriteria="false"/> + <dataReadyEvent fire="false" libCheckCriteria="true"/> + <status abstract="false" inherited="false" concrete="true" concreteHere="true"/> + <properties description="A reference curve" label="" unit="" standardUnit="" displayUnit="" format="" maxValue="" minValue="" maxAlarm="" minAlarm="" maxWarning="" minWarning="" deltaTime="" deltaValue=""/> + </attributes> + <attributes name="Wave" attType="Spectrum" rwType="READ" displayLevel="OPERATOR" polledPeriod="0" maxX="5000" maxY="" allocReadMember="false" isDynamic="false"> + <dataType xsi:type="pogoDsl:DoubleType"/> + <changeEvent fire="false" libCheckCriteria="false"/> + <archiveEvent fire="false" libCheckCriteria="false"/> + <dataReadyEvent fire="false" libCheckCriteria="true"/> + <status abstract="false" inherited="false" concrete="true" concreteHere="true"/> + <properties description="" label="" unit="" standardUnit="" displayUnit="" format="" maxValue="" minValue="" maxAlarm="" minAlarm="" maxWarning="" minWarning="" deltaTime="" deltaValue=""/> + </attributes> + <attributes name="Lambda" attType="Spectrum" rwType="READ" displayLevel="OPERATOR" polledPeriod="0" maxX="5000" maxY="" allocReadMember="false" isDynamic="false"> + <dataType xsi:type="pogoDsl:DoubleType"/> + <changeEvent fire="false" libCheckCriteria="false"/> + <archiveEvent fire="false" libCheckCriteria="false"/> + <dataReadyEvent fire="false" libCheckCriteria="true"/> + <status abstract="false" inherited="false" concrete="true" concreteHere="true"/> + <properties description="" label="" unit="" standardUnit="" displayUnit="" format="" maxValue="" minValue="" maxAlarm="" minAlarm="" maxWarning="" minWarning="" deltaTime="" deltaValue=""/> + </attributes> + <preferences docHome="./doc_html" makefileHome="$(TANGO_HOME)"/> + </classes> +</pogoDsl:PogoSystem> diff --git a/src/CCDSpectrometerClass.cpp b/src/CCDSpectrometerClass.cpp new file mode 100644 index 0000000..494c0d4 --- /dev/null +++ b/src/CCDSpectrometerClass.cpp @@ -0,0 +1,2068 @@ +/*----- PROTECTED REGION ID(CCDSpectrometerClass.cpp) ENABLED START -----*/ +/* clang-format on */ +//============================================================================= +// +// file : CCDSpectrometerClass.cpp +// +// description : C++ source for the CCDSpectrometerClass. +// A singleton class derived from DeviceClass. +// It implements the command and attribute list +// and all properties and methods required +// by the CCDSpectrometer once per process. +// +// project : CCDSpectrometer +// +// 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 "CCDSpectrometerClass.h" +/* clang-format off */ +/*----- PROTECTED REGION END -----*/ // CCDSpectrometerClass.cpp + +//------------------------------------------------------------------- +/** + * Create CCDSpectrometerClass singleton and + * return it in a C function for Python usage + */ +//------------------------------------------------------------------- +extern "C" { +#ifdef _TG_WINDOWS_ + +__declspec(dllexport) + +#endif + + Tango::DeviceClass *_create_CCDSpectrometer_class(const char *name) { + return CCDSpectrometer_ns::CCDSpectrometerClass::init(name); + } +} + +namespace CCDSpectrometer_ns +{ +//=================================================================== +// Initialize pointer for singleton pattern +//=================================================================== +CCDSpectrometerClass *CCDSpectrometerClass::_instance = NULL; + +//=================================================================== +// Class constants +//=================================================================== +const long DataAttrib::X_DATA_SIZE; +const long NumPixelsAttrib::X_DATA_SIZE; +const long RegionOfInterestAttrib::X_DATA_SIZE; +const long AnalysisRegionAttrib::X_DATA_SIZE; +const long GaussFitAttrib::X_DATA_SIZE; +const long FWHMAttrib::X_DATA_SIZE; +const long GaussReferenceAttrib::X_DATA_SIZE; +const long DataReferenceAttrib::X_DATA_SIZE; +const long IntensityCalibrationAttrib::X_DATA_SIZE; +const long NoiseProfileAttrib::X_DATA_SIZE; +const long WaveAttrib::X_DATA_SIZE; +const long LambdaAttrib::X_DATA_SIZE; +//-------------------------------------------------------- +/** + * method : CCDSpectrometerClass::CCDSpectrometerClass(std::string &s) + * description : constructor for the CCDSpectrometerClass + * + * @param s The class name + */ +//-------------------------------------------------------- +CCDSpectrometerClass::CCDSpectrometerClass(std::string &s):Tango::DeviceClass(s) +{ + TANGO_LOG_INFO << "Entering CCDSpectrometerClass constructor" << std::endl; + set_default_property(); + write_class_property(); + + /*----- PROTECTED REGION ID(CCDSpectrometerClass::constructor) ENABLED START -----*/ + /* clang-format on */ + /* clang-format off */ + /*----- PROTECTED REGION END -----*/ // CCDSpectrometerClass::constructor + + TANGO_LOG_INFO << "Leaving CCDSpectrometerClass constructor" << std::endl; +} + +//-------------------------------------------------------- +/** + * method : CCDSpectrometerClass::~CCDSpectrometerClass() + * description : destructor for the CCDSpectrometerClass + */ +//-------------------------------------------------------- +CCDSpectrometerClass::~CCDSpectrometerClass() +{ + /*----- PROTECTED REGION ID(CCDSpectrometerClass::destructor) ENABLED START -----*/ + /* clang-format on */ + /* clang-format off */ + /*----- PROTECTED REGION END -----*/ // CCDSpectrometerClass::destructor + + _instance = NULL; +} + + +//-------------------------------------------------------- +/** + * method : CCDSpectrometerClass::init + * description : Create the object if not already done. + * Otherwise, just return a pointer to the object + * + * @param name The class name + */ +//-------------------------------------------------------- +CCDSpectrometerClass *CCDSpectrometerClass::init(const char *name) +{ + if (_instance == NULL) + { + try + { + std::string s(name); + _instance = new CCDSpectrometerClass(s); + } + catch (std::bad_alloc &) + { + throw; + } + } + return _instance; +} + +//-------------------------------------------------------- +/** + * method : CCDSpectrometerClass::instance + * description : Check if object already created, + * and return a pointer to the object + */ +//-------------------------------------------------------- +CCDSpectrometerClass *CCDSpectrometerClass::instance() +{ + if (_instance == NULL) + { + std::cerr << "Class is not initialized !!" << std::endl; + exit(-1); + } + return _instance; +} + + + +//=================================================================== +// Command execution method calls +//=================================================================== +//-------------------------------------------------------- +/** + * method : StartClass::execute() + * description : method to trigger the execution of the command. + * + * @param device The device on which the command must be executed + * @param in_any The command input data + * + * returns The command output data (packed in the Any object) + */ +//-------------------------------------------------------- +CORBA::Any *StartClass::execute(Tango::DeviceImpl *device, TANGO_UNUSED(const CORBA::Any &in_any)) +{ + TANGO_LOG_INFO << "StartClass::execute(): arrived" << std::endl; + ((static_cast<CCDSpectrometer *>(device))->start()); + return new CORBA::Any(); +} + +//-------------------------------------------------------- +/** + * method : StopClass::execute() + * description : method to trigger the execution of the command. + * + * @param device The device on which the command must be executed + * @param in_any The command input data + * + * returns The command output data (packed in the Any object) + */ +//-------------------------------------------------------- +CORBA::Any *StopClass::execute(Tango::DeviceImpl *device, TANGO_UNUSED(const CORBA::Any &in_any)) +{ + TANGO_LOG_INFO << "StopClass::execute(): arrived" << std::endl; + ((static_cast<CCDSpectrometer *>(device))->stop()); + return new CORBA::Any(); +} + +//-------------------------------------------------------- +/** + * method : ResetClass::execute() + * description : method to trigger the execution of the command. + * + * @param device The device on which the command must be executed + * @param in_any The command input data + * + * returns The command output data (packed in the Any object) + */ +//-------------------------------------------------------- +CORBA::Any *ResetClass::execute(Tango::DeviceImpl *device, TANGO_UNUSED(const CORBA::Any &in_any)) +{ + TANGO_LOG_INFO << "ResetClass::execute(): arrived" << std::endl; + ((static_cast<CCDSpectrometer *>(device))->reset()); + return new CORBA::Any(); +} + +//-------------------------------------------------------- +/** + * method : StartSingleClass::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 *StartSingleClass::execute(Tango::DeviceImpl *device, TANGO_UNUSED(const CORBA::Any &in_any)) +{ + TANGO_LOG_INFO << "StartSingleClass::execute(): arrived" << std::endl; + ((static_cast<CCDSpectrometer *>(device))->start_single()); + return new CORBA::Any(); +} + +//-------------------------------------------------------- +/** + * method : StartContinuousClass::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 *StartContinuousClass::execute(Tango::DeviceImpl *device, TANGO_UNUSED(const CORBA::Any &in_any)) +{ + TANGO_LOG_INFO << "StartContinuousClass::execute(): arrived" << std::endl; + ((static_cast<CCDSpectrometer *>(device))->start_continuous()); + return new CORBA::Any(); +} + +//-------------------------------------------------------- +/** + * method : GetLastDataClass::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 *GetLastDataClass::execute(Tango::DeviceImpl *device, const CORBA::Any &in_any) +{ + TANGO_LOG_INFO << "GetLastDataClass::execute(): arrived" << std::endl; + Tango::DevLong argin; + extract(in_any, argin); + return insert((static_cast<CCDSpectrometer *>(device))->get_last_data(argin)); +} + +//-------------------------------------------------------- +/** + * method : AcquireNoiseClass::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 *AcquireNoiseClass::execute(Tango::DeviceImpl *device, const CORBA::Any &in_any) +{ + TANGO_LOG_INFO << "AcquireNoiseClass::execute(): arrived" << std::endl; + Tango::DevLong argin; + extract(in_any, argin); + ((static_cast<CCDSpectrometer *>(device))->acquire_noise(argin)); + return new CORBA::Any(); +} + +//-------------------------------------------------------- +/** + * method : SaveReferenceDataClass::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 *SaveReferenceDataClass::execute(Tango::DeviceImpl *device, TANGO_UNUSED(const CORBA::Any &in_any)) +{ + TANGO_LOG_INFO << "SaveReferenceDataClass::execute(): arrived" << std::endl; + ((static_cast<CCDSpectrometer *>(device))->save_reference_data()); + return new CORBA::Any(); +} + +//-------------------------------------------------------- +/** + * method : GetDataClass::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 *GetDataClass::execute(Tango::DeviceImpl *device, const CORBA::Any &in_any) +{ + TANGO_LOG_INFO << "GetDataClass::execute(): arrived" << std::endl; + const Tango::DevVarLongArray *argin; + extract(in_any, argin); + return insert((static_cast<CCDSpectrometer *>(device))->get_data(argin)); +} + +//-------------------------------------------------------- +/** + * method : GetGaussFitCenterClass::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 *GetGaussFitCenterClass::execute(Tango::DeviceImpl *device, const CORBA::Any &in_any) +{ + TANGO_LOG_INFO << "GetGaussFitCenterClass::execute(): arrived" << std::endl; + const Tango::DevVarLongArray *argin; + extract(in_any, argin); + return insert((static_cast<CCDSpectrometer *>(device))->get_gauss_fit_center(argin)); +} + +//-------------------------------------------------------- +/** + * method : GetGaussFitWidthClass::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 *GetGaussFitWidthClass::execute(Tango::DeviceImpl *device, const CORBA::Any &in_any) +{ + TANGO_LOG_INFO << "GetGaussFitWidthClass::execute(): arrived" << std::endl; + const Tango::DevVarLongArray *argin; + extract(in_any, argin); + return insert((static_cast<CCDSpectrometer *>(device))->get_gauss_fit_width(argin)); +} + +//-------------------------------------------------------- +/** + * method : GetFWHMCenterClass::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 *GetFWHMCenterClass::execute(Tango::DeviceImpl *device, const CORBA::Any &in_any) +{ + TANGO_LOG_INFO << "GetFWHMCenterClass::execute(): arrived" << std::endl; + const Tango::DevVarLongArray *argin; + extract(in_any, argin); + return insert((static_cast<CCDSpectrometer *>(device))->get_fwhmcenter(argin)); +} + +//-------------------------------------------------------- +/** + * method : GetFWHMWidthClass::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 *GetFWHMWidthClass::execute(Tango::DeviceImpl *device, const CORBA::Any &in_any) +{ + TANGO_LOG_INFO << "GetFWHMWidthClass::execute(): arrived" << std::endl; + const Tango::DevVarLongArray *argin; + extract(in_any, argin); + return insert((static_cast<CCDSpectrometer *>(device))->get_fwhmwidth(argin)); +} + +//-------------------------------------------------------- +/** + * method : ExportWavelengthClass::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 *ExportWavelengthClass::execute(Tango::DeviceImpl *device, TANGO_UNUSED(const CORBA::Any &in_any)) +{ + TANGO_LOG_INFO << "ExportWavelengthClass::execute(): arrived" << std::endl; + ((static_cast<CCDSpectrometer *>(device))->export_wavelength()); + return new CORBA::Any(); +} + +//-------------------------------------------------------- +/** + * method : GetAreaClass::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 *GetAreaClass::execute(Tango::DeviceImpl *device, const CORBA::Any &in_any) +{ + TANGO_LOG_INFO << "GetAreaClass::execute(): arrived" << std::endl; + const Tango::DevVarLongArray *argin; + extract(in_any, argin); + return insert((static_cast<CCDSpectrometer *>(device))->get_area(argin)); +} + +//-------------------------------------------------------- +/** + * method : GetWaveClass::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 *GetWaveClass::execute(Tango::DeviceImpl *device, const CORBA::Any &in_any) +{ + TANGO_LOG_INFO << "GetWaveClass::execute(): arrived" << std::endl; + const Tango::DevVarLongArray *argin; + extract(in_any, argin); + return insert((static_cast<CCDSpectrometer *>(device))->get_wave(argin)); +} + +//-------------------------------------------------------- +/** + * method : GetLambdaClass::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 *GetLambdaClass::execute(Tango::DeviceImpl *device, const CORBA::Any &in_any) +{ + TANGO_LOG_INFO << "GetLambdaClass::execute(): arrived" << std::endl; + const Tango::DevVarLongArray *argin; + extract(in_any, argin); + return insert((static_cast<CCDSpectrometer *>(device))->get_lambda(argin)); +} + + +//=================================================================== +// Properties management +//=================================================================== +//-------------------------------------------------------- +/** + * Method : CCDSpectrometerClass::get_class_property() + * Description: Get the class property for specified name. + */ +//-------------------------------------------------------- +Tango::DbDatum CCDSpectrometerClass::get_class_property(std::string &prop_name) +{ + for (unsigned int i=0 ; i<cl_prop.size() ; i++) + if (cl_prop[i].name == prop_name) + return cl_prop[i]; + // if not found, returns an empty DbDatum + return Tango::DbDatum(prop_name); +} + +//-------------------------------------------------------- +/** + * Method : CCDSpectrometerClass::get_default_device_property() + * Description: Return the default value for device property. + */ +//-------------------------------------------------------- +Tango::DbDatum CCDSpectrometerClass::get_default_device_property(std::string &prop_name) +{ + for (unsigned int i=0 ; i<dev_def_prop.size() ; i++) + if (dev_def_prop[i].name == prop_name) + return dev_def_prop[i]; + // if not found, return an empty DbDatum + return Tango::DbDatum(prop_name); +} + +//-------------------------------------------------------- +/** + * Method : CCDSpectrometerClass::get_default_class_property() + * Description: Return the default value for class property. + */ +//-------------------------------------------------------- +Tango::DbDatum CCDSpectrometerClass::get_default_class_property(std::string &prop_name) +{ + for (unsigned int i=0 ; i<cl_def_prop.size() ; i++) + if (cl_def_prop[i].name == prop_name) + return cl_def_prop[i]; + // if not found, return an empty DbDatum + return Tango::DbDatum(prop_name); +} + + +//-------------------------------------------------------- +/** + * Method : CCDSpectrometerClass::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 CCDSpectrometerClass::set_default_property() +{ + std::string prop_name; + std::string prop_desc; + std::string prop_def; + std::vector<std::string> vect_data; + + // Set Default Class Properties + + // Set Default device Properties + prop_name = "DeviceName"; + 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 = "DefaultGaussRef"; + prop_desc = "Default Gauss Reference"; + 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 = "DataReferenceFile"; + prop_desc = "Default Data Reference File"; + 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 = "DefaultStartRegion"; + prop_desc = "Beginning of the region of interest"; + 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 = "DefaultEndRegion"; + prop_desc = "End of the region of interest"; + 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 = "PreferFWHM"; + prop_desc = "Choose FWHM instead og GaussianFit if both enabled"; + prop_def = "false"; + vect_data.clear(); + vect_data.push_back("false"); + 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 = "AutoExposureRange"; + prop_desc = "AutoExposure Range"; + 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 = "AutoExposureStep"; + prop_desc = "AutoExposure Step"; + 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 = "AutoExposureAmpRange"; + prop_desc = "AutoExposure Amp Range"; + 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 = "IntensityCalibrationFile"; + 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 = "NoiseProfileFile"; + 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 = "WavelengthAttr"; + prop_desc = "device name\nattribute name"; + 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 = "AreaInAnalysisRegion"; + prop_desc = "use AnalysisRegion for area instead of AreaRegion"; + prop_def = "false"; + vect_data.clear(); + vect_data.push_back("false"); + 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 = "WidthCorrection"; + prop_desc = "widht_in^2 + widthcorrection^2 = widht_out^2"; + prop_def = "0"; + vect_data.clear(); + vect_data.push_back("0"); + 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 = "NFramesBuffered"; + prop_desc = "number of frames buffered when in live mode"; + prop_def = "1000"; + vect_data.clear(); + vect_data.push_back("1000"); + 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 = "AnalysisRegion"; + prop_desc = "AnalysisRegion"; + 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 = "RegionOfInterest"; + prop_desc = "RegionOfInterest"; + 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 = "ExposureTime"; + prop_desc = "ExposureTime"; + 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 = "SyncMode"; + prop_desc = "ExposureTime"; + 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 = "AutoStart"; + prop_desc = "AutoStart"; + 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 = "NumPixel"; + prop_desc = "Number of pixel of the CCD"; + 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 = "CameraLabel"; + prop_desc = "Camera label or IP"; + 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 : CCDSpectrometerClass::write_class_property() + * Description: Set class description fields as property in database + */ +//-------------------------------------------------------- +void CCDSpectrometerClass::write_class_property() +{ + // First time, check if database used + if (Tango::Util::_UseDb == false) + return; + + Tango::DbData data; + std::string classname = get_name(); + std::string header; + + // Put title + Tango::DbDatum title("ProjectTitle"); + std::string str_title("CCDSpectrometer"); + title << str_title; + data.push_back(title); + + // Put Description + Tango::DbDatum description("Description"); + std::vector<std::string> str_desc; + str_desc.push_back("Laser Spectrometer based on Basler CCD Tango Device"); + description << str_desc; + data.push_back(description); + + // Put inheritance + Tango::DbDatum inher_datum("InheritedFrom"); + std::vector<std::string> inheritance; + inheritance.push_back("TANGO_BASE_CLASS"); + inher_datum << inheritance; + data.push_back(inher_datum); + + // Call database and and values + get_db_class()->put_property(data); +} + +//=================================================================== +// Factory methods +//=================================================================== + +//-------------------------------------------------------- +/** + * Method : CCDSpectrometerClass::device_factory() + * Description: Create the device object(s) + * and store them in the device list + */ +//-------------------------------------------------------- +void CCDSpectrometerClass::device_factory(const Tango::DevVarStringArray *devlist_ptr) +{ + /*----- PROTECTED REGION ID(CCDSpectrometerClass::device_factory_before) ENABLED START -----*/ + /* clang-format on */ + // Add your own code + /* clang-format off */ + /*----- PROTECTED REGION END -----*/ // CCDSpectrometerClass::device_factory_before + + // Create devices and add it into the device list + for (unsigned long i=0 ; i<devlist_ptr->length() ; i++) + { + TANGO_LOG_DEBUG << "Device name : " << (*devlist_ptr)[i].in() << std::endl; + device_list.push_back(new CCDSpectrometer(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 + CCDSpectrometer *dev = static_cast<CCDSpectrometer *>(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(CCDSpectrometerClass::device_factory_after) ENABLED START -----*/ + /* clang-format on */ + // Add your own code + /* clang-format off */ + /*----- PROTECTED REGION END -----*/ // CCDSpectrometerClass::device_factory_after +} +//-------------------------------------------------------- +/** + * Method : CCDSpectrometerClass::attribute_factory() + * Description: Create the attribute object(s) + * and store them in the attribute list + */ +//-------------------------------------------------------- +void CCDSpectrometerClass::attribute_factory(std::vector<Tango::Attr *> &att_list) +{ + /*----- PROTECTED REGION ID(CCDSpectrometerClass::attribute_factory_before) ENABLED START -----*/ + /* clang-format on */ + // Add your own code + /* clang-format off */ + /*----- PROTECTED REGION END -----*/ // CCDSpectrometerClass::attribute_factory_before + // Attribute : SyncMode + SyncModeAttrib *syncmode = new SyncModeAttrib(); + Tango::UserDefaultAttrProp syncmode_prop; + syncmode_prop.set_description("0=SW\n1=HW Sync input\n2=HW external trigger"); + // label not set for SyncMode + // unit not set for SyncMode + // standard_unit not set for SyncMode + // display_unit not set for SyncMode + // format not set for SyncMode + // max_value not set for SyncMode + // min_value not set for SyncMode + // max_alarm not set for SyncMode + // min_alarm not set for SyncMode + // max_warning not set for SyncMode + // min_warning not set for SyncMode + // delta_t not set for SyncMode + // delta_val not set for SyncMode + syncmode->set_default_properties(syncmode_prop); + // Not Polled + syncmode->set_disp_level(Tango::OPERATOR); + syncmode->set_memorized(); + syncmode->set_memorized_init(false); + att_list.push_back(syncmode); + + // Attribute : ExposureTime + ExposureTimeAttrib *exposuretime = new ExposureTimeAttrib(); + Tango::UserDefaultAttrProp exposuretime_prop; + exposuretime_prop.set_description("Exposure time in milliseconds"); + // label not set for ExposureTime + exposuretime_prop.set_unit("ms"); + exposuretime_prop.set_standard_unit("1"); + exposuretime_prop.set_display_unit("ms"); + // format not set for ExposureTime + // max_value not set for ExposureTime + // min_value not set for ExposureTime + // max_alarm not set for ExposureTime + // min_alarm not set for ExposureTime + // max_warning not set for ExposureTime + // min_warning not set for ExposureTime + // delta_t not set for ExposureTime + // delta_val not set for ExposureTime + exposuretime->set_default_properties(exposuretime_prop); + // Not Polled + exposuretime->set_disp_level(Tango::OPERATOR); + exposuretime->set_memorized(); + exposuretime->set_memorized_init(false); + att_list.push_back(exposuretime); + + // Attribute : NoiseSubtraction + NoiseSubtractionAttrib *noisesubtraction = new NoiseSubtractionAttrib(); + Tango::UserDefaultAttrProp noisesubtraction_prop; + noisesubtraction_prop.set_description("Enable/Disable subtraction of background noise profile \nacquired with the AcquireNoise command"); + // label not set for NoiseSubtraction + // unit not set for NoiseSubtraction + // standard_unit not set for NoiseSubtraction + // display_unit not set for NoiseSubtraction + // format not set for NoiseSubtraction + // max_value not set for NoiseSubtraction + // min_value not set for NoiseSubtraction + // max_alarm not set for NoiseSubtraction + // min_alarm not set for NoiseSubtraction + // max_warning not set for NoiseSubtraction + // min_warning not set for NoiseSubtraction + // delta_t not set for NoiseSubtraction + // delta_val not set for NoiseSubtraction + noisesubtraction->set_default_properties(noisesubtraction_prop); + // Not Polled + noisesubtraction->set_disp_level(Tango::OPERATOR); + noisesubtraction->set_memorized(); + noisesubtraction->set_memorized_init(true); + att_list.push_back(noisesubtraction); + + // Attribute : GaussFitEnable + GaussFitEnableAttrib *gaussfitenable = new GaussFitEnableAttrib(); + Tango::UserDefaultAttrProp gaussfitenable_prop; + // description not set for GaussFitEnable + // label not set for GaussFitEnable + // unit not set for GaussFitEnable + // standard_unit not set for GaussFitEnable + // display_unit not set for GaussFitEnable + // format not set for GaussFitEnable + // max_value not set for GaussFitEnable + // min_value not set for GaussFitEnable + // max_alarm not set for GaussFitEnable + // min_alarm not set for GaussFitEnable + // max_warning not set for GaussFitEnable + // min_warning not set for GaussFitEnable + // delta_t not set for GaussFitEnable + // delta_val not set for GaussFitEnable + gaussfitenable->set_default_properties(gaussfitenable_prop); + // Not Polled + gaussfitenable->set_disp_level(Tango::OPERATOR); + gaussfitenable->set_memorized(); + gaussfitenable->set_memorized_init(true); + att_list.push_back(gaussfitenable); + + // Attribute : FWHMEnable + FWHMEnableAttrib *fwhmenable = new FWHMEnableAttrib(); + Tango::UserDefaultAttrProp fwhmenable_prop; + // description not set for FWHMEnable + // label not set for FWHMEnable + // unit not set for FWHMEnable + // standard_unit not set for FWHMEnable + // display_unit not set for FWHMEnable + // format not set for FWHMEnable + // max_value not set for FWHMEnable + // min_value not set for FWHMEnable + // max_alarm not set for FWHMEnable + // min_alarm not set for FWHMEnable + // max_warning not set for FWHMEnable + // min_warning not set for FWHMEnable + // delta_t not set for FWHMEnable + // delta_val not set for FWHMEnable + fwhmenable->set_default_properties(fwhmenable_prop); + // Not Polled + fwhmenable->set_disp_level(Tango::OPERATOR); + fwhmenable->set_memorized(); + fwhmenable->set_memorized_init(true); + att_list.push_back(fwhmenable); + + // Attribute : GaussFitCenter + GaussFitCenterAttrib *gaussfitcenter = new GaussFitCenterAttrib(); + Tango::UserDefaultAttrProp gaussfitcenter_prop; + gaussfitcenter_prop.set_description("wavelength of peak of Gaussian Fit"); + // label not set for GaussFitCenter + // unit not set for GaussFitCenter + // standard_unit not set for GaussFitCenter + // display_unit not set for GaussFitCenter + // format not set for GaussFitCenter + // max_value not set for GaussFitCenter + // min_value not set for GaussFitCenter + // max_alarm not set for GaussFitCenter + // min_alarm not set for GaussFitCenter + // max_warning not set for GaussFitCenter + // min_warning not set for GaussFitCenter + // delta_t not set for GaussFitCenter + // delta_val not set for GaussFitCenter + gaussfitcenter->set_default_properties(gaussfitcenter_prop); + // Not Polled + gaussfitcenter->set_disp_level(Tango::OPERATOR); + // Not Memorized + att_list.push_back(gaussfitcenter); + + // Attribute : GaussFitWidth + GaussFitWidthAttrib *gaussfitwidth = new GaussFitWidthAttrib(); + Tango::UserDefaultAttrProp gaussfitwidth_prop; + gaussfitwidth_prop.set_description("width of Gaussian Fit"); + // label not set for GaussFitWidth + // unit not set for GaussFitWidth + // standard_unit not set for GaussFitWidth + // display_unit not set for GaussFitWidth + // format not set for GaussFitWidth + // max_value not set for GaussFitWidth + // min_value not set for GaussFitWidth + // max_alarm not set for GaussFitWidth + // min_alarm not set for GaussFitWidth + // max_warning not set for GaussFitWidth + // min_warning not set for GaussFitWidth + // delta_t not set for GaussFitWidth + // delta_val not set for GaussFitWidth + gaussfitwidth->set_default_properties(gaussfitwidth_prop); + // Not Polled + gaussfitwidth->set_disp_level(Tango::OPERATOR); + // Not Memorized + att_list.push_back(gaussfitwidth); + + // Attribute : FWHMCenter + FWHMCenterAttrib *fwhmcenter = new FWHMCenterAttrib(); + Tango::UserDefaultAttrProp fwhmcenter_prop; + fwhmcenter_prop.set_description("wavelength of peak of FWHM"); + // label not set for FWHMCenter + // unit not set for FWHMCenter + // standard_unit not set for FWHMCenter + // display_unit not set for FWHMCenter + // format not set for FWHMCenter + // max_value not set for FWHMCenter + // min_value not set for FWHMCenter + // max_alarm not set for FWHMCenter + // min_alarm not set for FWHMCenter + // max_warning not set for FWHMCenter + // min_warning not set for FWHMCenter + // delta_t not set for FWHMCenter + // delta_val not set for FWHMCenter + fwhmcenter->set_default_properties(fwhmcenter_prop); + // Not Polled + fwhmcenter->set_disp_level(Tango::OPERATOR); + // Not Memorized + att_list.push_back(fwhmcenter); + + // Attribute : FWHMWidth + FWHMWidthAttrib *fwhmwidth = new FWHMWidthAttrib(); + Tango::UserDefaultAttrProp fwhmwidth_prop; + fwhmwidth_prop.set_description("width of FWHM"); + // label not set for FWHMWidth + // unit not set for FWHMWidth + // standard_unit not set for FWHMWidth + // display_unit not set for FWHMWidth + // format not set for FWHMWidth + // max_value not set for FWHMWidth + // min_value not set for FWHMWidth + // max_alarm not set for FWHMWidth + // min_alarm not set for FWHMWidth + // max_warning not set for FWHMWidth + // min_warning not set for FWHMWidth + // delta_t not set for FWHMWidth + // delta_val not set for FWHMWidth + fwhmwidth->set_default_properties(fwhmwidth_prop); + // Not Polled + fwhmwidth->set_disp_level(Tango::OPERATOR); + // Not Memorized + att_list.push_back(fwhmwidth); + + // Attribute : Center + CenterAttrib *center = new CenterAttrib(); + Tango::UserDefaultAttrProp center_prop; + center_prop.set_description("wavelength of peak of FWHM or of Gaussian Fit"); + // label not set for Center + // unit not set for Center + // standard_unit not set for Center + // display_unit not set for Center + // format not set for Center + // max_value not set for Center + // min_value not set for Center + // max_alarm not set for Center + // min_alarm not set for Center + // max_warning not set for Center + // min_warning not set for Center + // delta_t not set for Center + // delta_val not set for Center + center->set_default_properties(center_prop); + // Not Polled + center->set_disp_level(Tango::OPERATOR); + // Not Memorized + att_list.push_back(center); + + // Attribute : Width + WidthAttrib *width = new WidthAttrib(); + Tango::UserDefaultAttrProp width_prop; + width_prop.set_description("width of FWHM or of Gaussian Fit"); + // label not set for Width + // unit not set for Width + // standard_unit not set for Width + // display_unit not set for Width + // format not set for Width + // max_value not set for Width + // min_value not set for Width + // max_alarm not set for Width + // min_alarm not set for Width + // max_warning not set for Width + // min_warning not set for Width + // delta_t not set for Width + // delta_val not set for Width + width->set_default_properties(width_prop); + // Not Polled + width->set_disp_level(Tango::OPERATOR); + // Not Memorized + att_list.push_back(width); + + // Attribute : FitType + FitTypeAttrib *fittype = new FitTypeAttrib(); + Tango::UserDefaultAttrProp fittype_prop; + fittype_prop.set_description("1=Gaussian 2=Gaussian Asymm 3=Confiteor"); + // label not set for FitType + // unit not set for FitType + // standard_unit not set for FitType + // display_unit not set for FitType + // format not set for FitType + fittype_prop.set_max_value("3"); + fittype_prop.set_min_value("1"); + // max_alarm not set for FitType + // min_alarm not set for FitType + // max_warning not set for FitType + // min_warning not set for FitType + // delta_t not set for FitType + // delta_val not set for FitType + fittype->set_default_properties(fittype_prop); + // Not Polled + fittype->set_disp_level(Tango::OPERATOR); + fittype->set_memorized(); + fittype->set_memorized_init(true); + att_list.push_back(fittype); + + // Attribute : FWHMAvg + FWHMAvgAttrib *fwhmavg = new FWHMAvgAttrib(); + Tango::UserDefaultAttrProp fwhmavg_prop; + // description not set for FWHMAvg + // label not set for FWHMAvg + // unit not set for FWHMAvg + // standard_unit not set for FWHMAvg + // display_unit not set for FWHMAvg + // format not set for FWHMAvg + // max_value not set for FWHMAvg + // min_value not set for FWHMAvg + // max_alarm not set for FWHMAvg + // min_alarm not set for FWHMAvg + // max_warning not set for FWHMAvg + // min_warning not set for FWHMAvg + // delta_t not set for FWHMAvg + // delta_val not set for FWHMAvg + fwhmavg->set_default_properties(fwhmavg_prop); + // Not Polled + fwhmavg->set_disp_level(Tango::OPERATOR); + fwhmavg->set_memorized(); + fwhmavg->set_memorized_init(true); + att_list.push_back(fwhmavg); + + // Attribute : NoiseLevel + NoiseLevelAttrib *noiselevel = new NoiseLevelAttrib(); + Tango::UserDefaultAttrProp noiselevel_prop; + // description not set for NoiseLevel + // label not set for NoiseLevel + // unit not set for NoiseLevel + // standard_unit not set for NoiseLevel + // display_unit not set for NoiseLevel + // format not set for NoiseLevel + // max_value not set for NoiseLevel + // min_value not set for NoiseLevel + // max_alarm not set for NoiseLevel + // min_alarm not set for NoiseLevel + // max_warning not set for NoiseLevel + // min_warning not set for NoiseLevel + // delta_t not set for NoiseLevel + // delta_val not set for NoiseLevel + noiselevel->set_default_properties(noiselevel_prop); + // Not Polled + noiselevel->set_disp_level(Tango::OPERATOR); + noiselevel->set_memorized(); + noiselevel->set_memorized_init(true); + att_list.push_back(noiselevel); + + // Attribute : DataReferenceFile + DataReferenceFileAttrib *datareferencefile = new DataReferenceFileAttrib(); + Tango::UserDefaultAttrProp datareferencefile_prop; + // description not set for DataReferenceFile + // label not set for DataReferenceFile + // unit not set for DataReferenceFile + // standard_unit not set for DataReferenceFile + // display_unit not set for DataReferenceFile + // format not set for DataReferenceFile + // max_value not set for DataReferenceFile + // min_value not set for DataReferenceFile + // max_alarm not set for DataReferenceFile + // min_alarm not set for DataReferenceFile + // max_warning not set for DataReferenceFile + // min_warning not set for DataReferenceFile + // delta_t not set for DataReferenceFile + // delta_val not set for DataReferenceFile + datareferencefile->set_default_properties(datareferencefile_prop); + // Not Polled + datareferencefile->set_disp_level(Tango::OPERATOR); + datareferencefile->set_memorized(); + datareferencefile->set_memorized_init(false); + att_list.push_back(datareferencefile); + + // Attribute : AutoExposure + AutoExposureAttrib *autoexposure = new AutoExposureAttrib(); + Tango::UserDefaultAttrProp autoexposure_prop; + // description not set for AutoExposure + // label not set for AutoExposure + // unit not set for AutoExposure + // standard_unit not set for AutoExposure + // display_unit not set for AutoExposure + // format not set for AutoExposure + // max_value not set for AutoExposure + // min_value not set for AutoExposure + // max_alarm not set for AutoExposure + // min_alarm not set for AutoExposure + // max_warning not set for AutoExposure + // min_warning not set for AutoExposure + // delta_t not set for AutoExposure + // delta_val not set for AutoExposure + autoexposure->set_default_properties(autoexposure_prop); + // Not Polled + autoexposure->set_disp_level(Tango::OPERATOR); + autoexposure->set_memorized(); + autoexposure->set_memorized_init(true); + att_list.push_back(autoexposure); + + // Attribute : RtMode + RtModeAttrib *rtmode = new RtModeAttrib(); + Tango::UserDefaultAttrProp rtmode_prop; + // description not set for RtMode + // label not set for RtMode + // unit not set for RtMode + // standard_unit not set for RtMode + // display_unit not set for RtMode + // format not set for RtMode + // max_value not set for RtMode + // min_value not set for RtMode + // max_alarm not set for RtMode + // min_alarm not set for RtMode + // max_warning not set for RtMode + // min_warning not set for RtMode + // delta_t not set for RtMode + // delta_val not set for RtMode + rtmode->set_default_properties(rtmode_prop); + // Not Polled + rtmode->set_disp_level(Tango::OPERATOR); + rtmode->set_memorized(); + rtmode->set_memorized_init(true); + att_list.push_back(rtmode); + + // Attribute : IntensityCalibrationEnable + IntensityCalibrationEnableAttrib *intensitycalibrationenable = new IntensityCalibrationEnableAttrib(); + Tango::UserDefaultAttrProp intensitycalibrationenable_prop; + // description not set for IntensityCalibrationEnable + // label not set for IntensityCalibrationEnable + // unit not set for IntensityCalibrationEnable + // standard_unit not set for IntensityCalibrationEnable + // display_unit not set for IntensityCalibrationEnable + // format not set for IntensityCalibrationEnable + // max_value not set for IntensityCalibrationEnable + // min_value not set for IntensityCalibrationEnable + // max_alarm not set for IntensityCalibrationEnable + // min_alarm not set for IntensityCalibrationEnable + // max_warning not set for IntensityCalibrationEnable + // min_warning not set for IntensityCalibrationEnable + // delta_t not set for IntensityCalibrationEnable + // delta_val not set for IntensityCalibrationEnable + intensitycalibrationenable->set_default_properties(intensitycalibrationenable_prop); + // Not Polled + intensitycalibrationenable->set_disp_level(Tango::OPERATOR); + intensitycalibrationenable->set_memorized(); + intensitycalibrationenable->set_memorized_init(true); + att_list.push_back(intensitycalibrationenable); + + // Attribute : Area + AreaAttrib *area = new AreaAttrib(); + Tango::UserDefaultAttrProp area_prop; + // description not set for Area + // label not set for Area + // unit not set for Area + // standard_unit not set for Area + // display_unit not set for Area + // format not set for Area + // max_value not set for Area + // min_value not set for Area + // max_alarm not set for Area + // min_alarm not set for Area + // max_warning not set for Area + // min_warning not set for Area + // delta_t not set for Area + // delta_val not set for Area + area->set_default_properties(area_prop); + // Not Polled + area->set_disp_level(Tango::OPERATOR); + // Not Memorized + att_list.push_back(area); + + // Attribute : AreaRegion + AreaRegionAttrib *arearegion = new AreaRegionAttrib(); + Tango::UserDefaultAttrProp arearegion_prop; + // description not set for AreaRegion + // label not set for AreaRegion + // unit not set for AreaRegion + // standard_unit not set for AreaRegion + // display_unit not set for AreaRegion + // format not set for AreaRegion + // max_value not set for AreaRegion + // min_value not set for AreaRegion + // max_alarm not set for AreaRegion + // min_alarm not set for AreaRegion + // max_warning not set for AreaRegion + // min_warning not set for AreaRegion + // delta_t not set for AreaRegion + // delta_val not set for AreaRegion + arearegion->set_default_properties(arearegion_prop); + // Not Polled + arearegion->set_disp_level(Tango::OPERATOR); + arearegion->set_memorized(); + arearegion->set_memorized_init(true); + att_list.push_back(arearegion); + + // Attribute : AreaEnable + AreaEnableAttrib *areaenable = new AreaEnableAttrib(); + Tango::UserDefaultAttrProp areaenable_prop; + // description not set for AreaEnable + // label not set for AreaEnable + // unit not set for AreaEnable + // standard_unit not set for AreaEnable + // display_unit not set for AreaEnable + // format not set for AreaEnable + // max_value not set for AreaEnable + // min_value not set for AreaEnable + // max_alarm not set for AreaEnable + // min_alarm not set for AreaEnable + // max_warning not set for AreaEnable + // min_warning not set for AreaEnable + // delta_t not set for AreaEnable + // delta_val not set for AreaEnable + areaenable->set_default_properties(areaenable_prop); + // Not Polled + areaenable->set_disp_level(Tango::OPERATOR); + areaenable->set_memorized(); + areaenable->set_memorized_init(true); + att_list.push_back(areaenable); + + // Attribute : WidthCorrectionEnable + WidthCorrectionEnableAttrib *widthcorrectionenable = new WidthCorrectionEnableAttrib(); + Tango::UserDefaultAttrProp widthcorrectionenable_prop; + widthcorrectionenable_prop.set_description("enable widht correction"); + // label not set for WidthCorrectionEnable + // unit not set for WidthCorrectionEnable + // standard_unit not set for WidthCorrectionEnable + // display_unit not set for WidthCorrectionEnable + // format not set for WidthCorrectionEnable + // max_value not set for WidthCorrectionEnable + // min_value not set for WidthCorrectionEnable + // max_alarm not set for WidthCorrectionEnable + // min_alarm not set for WidthCorrectionEnable + // max_warning not set for WidthCorrectionEnable + // min_warning not set for WidthCorrectionEnable + // delta_t not set for WidthCorrectionEnable + // delta_val not set for WidthCorrectionEnable + widthcorrectionenable->set_default_properties(widthcorrectionenable_prop); + // Not Polled + widthcorrectionenable->set_disp_level(Tango::OPERATOR); + widthcorrectionenable->set_memorized(); + widthcorrectionenable->set_memorized_init(true); + att_list.push_back(widthcorrectionenable); + + // Attribute : IncrSensitivity + IncrSensitivityAttrib *incrsensitivity = new IncrSensitivityAttrib(); + Tango::UserDefaultAttrProp incrsensitivity_prop; + incrsensitivity_prop.set_description("false: use standard sensitivity\ntrue: use increased sensitivity"); + // label not set for IncrSensitivity + // unit not set for IncrSensitivity + // standard_unit not set for IncrSensitivity + // display_unit not set for IncrSensitivity + // format not set for IncrSensitivity + // max_value not set for IncrSensitivity + // min_value not set for IncrSensitivity + // max_alarm not set for IncrSensitivity + // min_alarm not set for IncrSensitivity + // max_warning not set for IncrSensitivity + // min_warning not set for IncrSensitivity + // delta_t not set for IncrSensitivity + // delta_val not set for IncrSensitivity + incrsensitivity->set_default_properties(incrsensitivity_prop); + // Not Polled + incrsensitivity->set_disp_level(Tango::OPERATOR); + incrsensitivity->set_memorized(); + incrsensitivity->set_memorized_init(true); + att_list.push_back(incrsensitivity); + + // Attribute : Data + DataAttrib *data = new DataAttrib(); + Tango::UserDefaultAttrProp data_prop; + // description not set for Data + // label not set for Data + // unit not set for Data + // standard_unit not set for Data + // display_unit not set for Data + // format not set for Data + // max_value not set for Data + // min_value not set for Data + // max_alarm not set for Data + // min_alarm not set for Data + // max_warning not set for Data + // min_warning not set for Data + // delta_t not set for Data + // delta_val not set for Data + data->set_default_properties(data_prop); + // Not Polled + data->set_disp_level(Tango::OPERATOR); + // Not Memorized + att_list.push_back(data); + + // Attribute : NumPixels + NumPixelsAttrib *numpixels = new NumPixelsAttrib(); + Tango::UserDefaultAttrProp numpixels_prop; + numpixels_prop.set_description("long[0]: number of pixels horizontally (number of CCD-array columns)\nlong[1]: number of pixels vertically (number of CCD-array lines)"); + // label not set for NumPixels + // unit not set for NumPixels + // standard_unit not set for NumPixels + // display_unit not set for NumPixels + // format not set for NumPixels + // max_value not set for NumPixels + // min_value not set for NumPixels + // max_alarm not set for NumPixels + // min_alarm not set for NumPixels + // max_warning not set for NumPixels + // min_warning not set for NumPixels + // delta_t not set for NumPixels + // delta_val not set for NumPixels + numpixels->set_default_properties(numpixels_prop); + // Not Polled + numpixels->set_disp_level(Tango::OPERATOR); + // Not Memorized + att_list.push_back(numpixels); + + // Attribute : RegionOfInterest + RegionOfInterestAttrib *regionofinterest = new RegionOfInterestAttrib(); + Tango::UserDefaultAttrProp regionofinterest_prop; + regionofinterest_prop.set_description("Region of interest returned by the Data attribute\ndouble[0]=start of the region\ndouble[1]=end of the region\n\nValues are in nm according with the conversion factor in x_values\nData attribute property"); + // label not set for RegionOfInterest + // unit not set for RegionOfInterest + // standard_unit not set for RegionOfInterest + // display_unit not set for RegionOfInterest + // format not set for RegionOfInterest + // max_value not set for RegionOfInterest + // min_value not set for RegionOfInterest + // max_alarm not set for RegionOfInterest + // min_alarm not set for RegionOfInterest + // max_warning not set for RegionOfInterest + // min_warning not set for RegionOfInterest + // delta_t not set for RegionOfInterest + // delta_val not set for RegionOfInterest + regionofinterest->set_default_properties(regionofinterest_prop); + // Not Polled + regionofinterest->set_disp_level(Tango::OPERATOR); + // Not Memorized + att_list.push_back(regionofinterest); + + // Attribute : AnalysisRegion + AnalysisRegionAttrib *analysisregion = new AnalysisRegionAttrib(); + Tango::UserDefaultAttrProp analysisregion_prop; + analysisregion_prop.set_description("Region used for gaussian and fwhm analysis\ndouble[0]=start of the region\ndouble[1]=end of the region\n\nValues are in nm according with the conversion factor in x_values\nData attribute property"); + // label not set for AnalysisRegion + // unit not set for AnalysisRegion + // standard_unit not set for AnalysisRegion + // display_unit not set for AnalysisRegion + // format not set for AnalysisRegion + // max_value not set for AnalysisRegion + // min_value not set for AnalysisRegion + // max_alarm not set for AnalysisRegion + // min_alarm not set for AnalysisRegion + // max_warning not set for AnalysisRegion + // min_warning not set for AnalysisRegion + // delta_t not set for AnalysisRegion + // delta_val not set for AnalysisRegion + analysisregion->set_default_properties(analysisregion_prop); + // Not Polled + analysisregion->set_disp_level(Tango::OPERATOR); + // Not Memorized + att_list.push_back(analysisregion); + + // Attribute : GaussFit + GaussFitAttrib *gaussfit = new GaussFitAttrib(); + Tango::UserDefaultAttrProp gaussfit_prop; + gaussfit_prop.set_description("double[0]= wavelength of peak of Gaussian Fit\ndouble[1]= width of Gaussian Fit"); + // label not set for GaussFit + // unit not set for GaussFit + // standard_unit not set for GaussFit + // display_unit not set for GaussFit + // format not set for GaussFit + // max_value not set for GaussFit + // min_value not set for GaussFit + // max_alarm not set for GaussFit + // min_alarm not set for GaussFit + // max_warning not set for GaussFit + // min_warning not set for GaussFit + // delta_t not set for GaussFit + // delta_val not set for GaussFit + gaussfit->set_default_properties(gaussfit_prop); + // Not Polled + gaussfit->set_disp_level(Tango::OPERATOR); + // Not Memorized + att_list.push_back(gaussfit); + + // Attribute : FWHM + FWHMAttrib *fwhm = new FWHMAttrib(); + Tango::UserDefaultAttrProp fwhm_prop; + fwhm_prop.set_description("double[0]= wavelength of peak of FWHM\ndouble[1]= width of FWHM"); + // label not set for FWHM + // unit not set for FWHM + // standard_unit not set for FWHM + // display_unit not set for FWHM + // format not set for FWHM + // max_value not set for FWHM + // min_value not set for FWHM + // max_alarm not set for FWHM + // min_alarm not set for FWHM + // max_warning not set for FWHM + // min_warning not set for FWHM + // delta_t not set for FWHM + // delta_val not set for FWHM + fwhm->set_default_properties(fwhm_prop); + // Not Polled + fwhm->set_disp_level(Tango::OPERATOR); + // Not Memorized + att_list.push_back(fwhm); + + // Attribute : GaussReference + GaussReferenceAttrib *gaussreference = new GaussReferenceAttrib(); + Tango::UserDefaultAttrProp gaussreference_prop; + gaussreference_prop.set_description("double[0]= wavelength of peak of Gaussian Fit\ndouble[1]= width of Gaussian Fit"); + // label not set for GaussReference + // unit not set for GaussReference + // standard_unit not set for GaussReference + // display_unit not set for GaussReference + // format not set for GaussReference + // max_value not set for GaussReference + // min_value not set for GaussReference + // max_alarm not set for GaussReference + // min_alarm not set for GaussReference + // max_warning not set for GaussReference + // min_warning not set for GaussReference + // delta_t not set for GaussReference + // delta_val not set for GaussReference + gaussreference->set_default_properties(gaussreference_prop); + // Not Polled + gaussreference->set_disp_level(Tango::OPERATOR); + // Not Memorized + att_list.push_back(gaussreference); + + // Attribute : DataReference + DataReferenceAttrib *datareference = new DataReferenceAttrib(); + Tango::UserDefaultAttrProp datareference_prop; + datareference_prop.set_description("A reference curve"); + // label not set for DataReference + // unit not set for DataReference + // standard_unit not set for DataReference + // display_unit not set for DataReference + // format not set for DataReference + // max_value not set for DataReference + // min_value not set for DataReference + // max_alarm not set for DataReference + // min_alarm not set for DataReference + // max_warning not set for DataReference + // min_warning not set for DataReference + // delta_t not set for DataReference + // delta_val not set for DataReference + datareference->set_default_properties(datareference_prop); + // Not Polled + datareference->set_disp_level(Tango::OPERATOR); + // Not Memorized + att_list.push_back(datareference); + + // Attribute : IntensityCalibration + IntensityCalibrationAttrib *intensitycalibration = new IntensityCalibrationAttrib(); + Tango::UserDefaultAttrProp intensitycalibration_prop; + intensitycalibration_prop.set_description("A reference curve"); + // label not set for IntensityCalibration + // unit not set for IntensityCalibration + // standard_unit not set for IntensityCalibration + // display_unit not set for IntensityCalibration + // format not set for IntensityCalibration + // max_value not set for IntensityCalibration + // min_value not set for IntensityCalibration + // max_alarm not set for IntensityCalibration + // min_alarm not set for IntensityCalibration + // max_warning not set for IntensityCalibration + // min_warning not set for IntensityCalibration + // delta_t not set for IntensityCalibration + // delta_val not set for IntensityCalibration + intensitycalibration->set_default_properties(intensitycalibration_prop); + // Not Polled + intensitycalibration->set_disp_level(Tango::OPERATOR); + // Not Memorized + att_list.push_back(intensitycalibration); + + // Attribute : NoiseProfile + NoiseProfileAttrib *noiseprofile = new NoiseProfileAttrib(); + Tango::UserDefaultAttrProp noiseprofile_prop; + noiseprofile_prop.set_description("A reference curve"); + // label not set for NoiseProfile + // unit not set for NoiseProfile + // standard_unit not set for NoiseProfile + // display_unit not set for NoiseProfile + // format not set for NoiseProfile + // max_value not set for NoiseProfile + // min_value not set for NoiseProfile + // max_alarm not set for NoiseProfile + // min_alarm not set for NoiseProfile + // max_warning not set for NoiseProfile + // min_warning not set for NoiseProfile + // delta_t not set for NoiseProfile + // delta_val not set for NoiseProfile + noiseprofile->set_default_properties(noiseprofile_prop); + // Not Polled + noiseprofile->set_disp_level(Tango::OPERATOR); + // Not Memorized + att_list.push_back(noiseprofile); + + // Attribute : Wave + WaveAttrib *wave = new WaveAttrib(); + Tango::UserDefaultAttrProp wave_prop; + // description not set for Wave + // label not set for Wave + // unit not set for Wave + // standard_unit not set for Wave + // display_unit not set for Wave + // format not set for Wave + // max_value not set for Wave + // min_value not set for Wave + // max_alarm not set for Wave + // min_alarm not set for Wave + // max_warning not set for Wave + // min_warning not set for Wave + // delta_t not set for Wave + // delta_val not set for Wave + wave->set_default_properties(wave_prop); + // Not Polled + wave->set_disp_level(Tango::OPERATOR); + // Not Memorized + att_list.push_back(wave); + + // Attribute : Lambda + LambdaAttrib *lambda = new LambdaAttrib(); + Tango::UserDefaultAttrProp lambda_prop; + // description not set for Lambda + // label not set for Lambda + // unit not set for Lambda + // standard_unit not set for Lambda + // display_unit not set for Lambda + // format not set for Lambda + // max_value not set for Lambda + // min_value not set for Lambda + // max_alarm not set for Lambda + // min_alarm not set for Lambda + // max_warning not set for Lambda + // min_warning not set for Lambda + // delta_t not set for Lambda + // delta_val not set for Lambda + lambda->set_default_properties(lambda_prop); + // Not Polled + lambda->set_disp_level(Tango::OPERATOR); + // Not Memorized + att_list.push_back(lambda); + + + // Create a list of static attributes + create_static_attribute_list(get_class_attr()->get_attr_list()); + /*----- PROTECTED REGION ID(CCDSpectrometerClass::attribute_factory_after) ENABLED START -----*/ + /* clang-format on */ + // Add your own code + /* clang-format off */ + /*----- PROTECTED REGION END -----*/ // CCDSpectrometerClass::attribute_factory_after +} +//-------------------------------------------------------- +/** + * Method : CCDSpectrometerClass::pipe_factory() + * Description: Create the pipe object(s) + * and store them in the pipe list + */ +//-------------------------------------------------------- +void CCDSpectrometerClass::pipe_factory() +{ + /*----- PROTECTED REGION ID(CCDSpectrometerClass::pipe_factory_before) ENABLED START -----*/ + /* clang-format on */ + // Add your own code + /* clang-format off */ + /*----- PROTECTED REGION END -----*/ // CCDSpectrometerClass::pipe_factory_before + /*----- PROTECTED REGION ID(CCDSpectrometerClass::pipe_factory_after) ENABLED START -----*/ + /* clang-format on */ + // Add your own code + /* clang-format off */ + /*----- PROTECTED REGION END -----*/ // CCDSpectrometerClass::pipe_factory_after +} +//-------------------------------------------------------- +/** + * Method : CCDSpectrometerClass::command_factory() + * Description: Create the command object(s) + * and store them in the command list + */ +//-------------------------------------------------------- +void CCDSpectrometerClass::command_factory() +{ + /*----- PROTECTED REGION ID(CCDSpectrometerClass::command_factory_before) ENABLED START -----*/ + /* clang-format on */ + // Add your own code + /* clang-format off */ + /*----- PROTECTED REGION END -----*/ // CCDSpectrometerClass::command_factory_before + + + // Command Start + StartClass *pStartCmd = + new StartClass("Start", + Tango::DEV_VOID, Tango::DEV_VOID, + "", + "", + Tango::OPERATOR); + command_list.push_back(pStartCmd); + + // Command Stop + StopClass *pStopCmd = + new StopClass("Stop", + Tango::DEV_VOID, Tango::DEV_VOID, + "", + "", + Tango::OPERATOR); + command_list.push_back(pStopCmd); + + // Command Reset + ResetClass *pResetCmd = + new ResetClass("Reset", + Tango::DEV_VOID, Tango::DEV_VOID, + "", + "", + Tango::OPERATOR); + command_list.push_back(pResetCmd); + + // Command StartSingle + StartSingleClass *pStartSingleCmd = + new StartSingleClass("StartSingle", + Tango::DEV_VOID, Tango::DEV_VOID, + "", + "", + Tango::OPERATOR); + command_list.push_back(pStartSingleCmd); + + // Command StartContinuous + StartContinuousClass *pStartContinuousCmd = + new StartContinuousClass("StartContinuous", + Tango::DEV_VOID, Tango::DEV_VOID, + "", + "", + Tango::OPERATOR); + command_list.push_back(pStartContinuousCmd); + + // Command GetLastData + GetLastDataClass *pGetLastDataCmd = + new GetLastDataClass("GetLastData", + Tango::DEV_LONG, Tango::DEVVAR_DOUBLEARRAY, + "number of frames to return", + "", + Tango::OPERATOR); + command_list.push_back(pGetLastDataCmd); + + // Command AcquireNoise + AcquireNoiseClass *pAcquireNoiseCmd = + new AcquireNoiseClass("AcquireNoise", + Tango::DEV_LONG, Tango::DEV_VOID, + "Number of frames to acquire as noise", + "", + Tango::OPERATOR); + command_list.push_back(pAcquireNoiseCmd); + + // Command SaveReferenceData + SaveReferenceDataClass *pSaveReferenceDataCmd = + new SaveReferenceDataClass("SaveReferenceData", + Tango::DEV_VOID, Tango::DEV_VOID, + "", + "", + Tango::OPERATOR); + command_list.push_back(pSaveReferenceDataCmd); + + // Command GetData + GetDataClass *pGetDataCmd = + new GetDataClass("GetData", + Tango::DEVVAR_LONGARRAY, Tango::DEVVAR_DOUBLEARRAY, + "", + "", + Tango::OPERATOR); + command_list.push_back(pGetDataCmd); + + // Command GetGaussFitCenter + GetGaussFitCenterClass *pGetGaussFitCenterCmd = + new GetGaussFitCenterClass("GetGaussFitCenter", + Tango::DEVVAR_LONGARRAY, Tango::DEVVAR_DOUBLEARRAY, + "", + "", + Tango::OPERATOR); + command_list.push_back(pGetGaussFitCenterCmd); + + // Command GetGaussFitWidth + GetGaussFitWidthClass *pGetGaussFitWidthCmd = + new GetGaussFitWidthClass("GetGaussFitWidth", + Tango::DEVVAR_LONGARRAY, Tango::DEVVAR_DOUBLEARRAY, + "", + "", + Tango::OPERATOR); + command_list.push_back(pGetGaussFitWidthCmd); + + // Command GetFWHMCenter + GetFWHMCenterClass *pGetFWHMCenterCmd = + new GetFWHMCenterClass("GetFWHMCenter", + Tango::DEVVAR_LONGARRAY, Tango::DEVVAR_DOUBLEARRAY, + "", + "", + Tango::OPERATOR); + command_list.push_back(pGetFWHMCenterCmd); + + // Command GetFWHMWidth + GetFWHMWidthClass *pGetFWHMWidthCmd = + new GetFWHMWidthClass("GetFWHMWidth", + Tango::DEVVAR_LONGARRAY, Tango::DEVVAR_DOUBLEARRAY, + "", + "", + Tango::OPERATOR); + command_list.push_back(pGetFWHMWidthCmd); + + // Command ExportWavelength + ExportWavelengthClass *pExportWavelengthCmd = + new ExportWavelengthClass("ExportWavelength", + Tango::DEV_VOID, Tango::DEV_VOID, + "", + "", + Tango::OPERATOR); + command_list.push_back(pExportWavelengthCmd); + + // Command GetArea + GetAreaClass *pGetAreaCmd = + new GetAreaClass("GetArea", + Tango::DEVVAR_LONGARRAY, Tango::DEVVAR_DOUBLEARRAY, + "", + "", + Tango::OPERATOR); + command_list.push_back(pGetAreaCmd); + + // Command GetWave + GetWaveClass *pGetWaveCmd = + new GetWaveClass("GetWave", + Tango::DEVVAR_LONGARRAY, Tango::DEVVAR_DOUBLEARRAY, + "", + "", + Tango::OPERATOR); + command_list.push_back(pGetWaveCmd); + + // Command GetLambda + GetLambdaClass *pGetLambdaCmd = + new GetLambdaClass("GetLambda", + Tango::DEVVAR_LONGARRAY, Tango::DEVVAR_DOUBLEARRAY, + "", + "", + Tango::OPERATOR); + command_list.push_back(pGetLambdaCmd); + + /*----- PROTECTED REGION ID(CCDSpectrometerClass::command_factory_after) ENABLED START -----*/ + /* clang-format on */ + // Add your own code + /* clang-format off */ + /*----- PROTECTED REGION END -----*/ // CCDSpectrometerClass::command_factory_after +} + +//=================================================================== +// Dynamic attributes related methods +//=================================================================== + +//-------------------------------------------------------- +/** + * method : CCDSpectrometerClass::create_static_attribute_list + * description : Create the a list of static attributes + * + * @param att_list the created attribute list + */ +//-------------------------------------------------------- +void CCDSpectrometerClass::create_static_attribute_list(std::vector<Tango::Attr *> &att_list) +{ + for (unsigned long i=0 ; i<att_list.size() ; i++) + { + std::string att_name(att_list[i]->get_name()); + transform(att_name.begin(), att_name.end(), att_name.begin(), ::tolower); + defaultAttList.push_back(att_name); + } + + TANGO_LOG_INFO << defaultAttList.size() << " attributes in default list" << std::endl; + + /*----- PROTECTED REGION ID(CCDSpectrometerClass::create_static_att_list) ENABLED START -----*/ + /* clang-format on */ + /* clang-format off */ + /*----- PROTECTED REGION END -----*/ // CCDSpectrometerClass::create_static_att_list +} + + +//-------------------------------------------------------- +/** + * method : CCDSpectrometerClass::erase_dynamic_attributes + * description : delete the dynamic attributes if any. + * + * @param devlist_ptr the device list pointer + * @param list of all attributes + */ +//-------------------------------------------------------- +void CCDSpectrometerClass::erase_dynamic_attributes(const Tango::DevVarStringArray *devlist_ptr, std::vector<Tango::Attr *> &att_list) +{ + Tango::Util *tg = Tango::Util::instance(); + + for (unsigned long i=0 ; i<devlist_ptr->length() ; i++) + { + Tango::DeviceImpl *dev_impl = tg->get_device_by_name(((std::string)(*devlist_ptr)[i]).c_str()); + CCDSpectrometer *dev = static_cast<CCDSpectrometer *> (dev_impl); + + std::vector<Tango::Attribute *> &dev_att_list = dev->get_device_attr()->get_attribute_list(); + std::vector<Tango::Attribute *>::iterator ite_att; + for (ite_att=dev_att_list.begin() ; ite_att != dev_att_list.end() ; ++ite_att) + { + std::string att_name((*ite_att)->get_name_lower()); + if ((att_name == "state") || (att_name == "status")) + continue; + std::vector<std::string>::iterator ite_str = find(defaultAttList.begin(), defaultAttList.end(), att_name); + if (ite_str == defaultAttList.end()) + { + TANGO_LOG_INFO << att_name << " is a UNWANTED dynamic attribute for device " << (*devlist_ptr)[i] << std::endl; + Tango::Attribute &att = dev->get_device_attr()->get_attr_by_name(att_name.c_str()); + dev->remove_attribute(att_list[att.get_attr_idx()], true, false); + --ite_att; + } + } + } + /*----- PROTECTED REGION ID(CCDSpectrometerClass::erase_dynamic_attributes) ENABLED START -----*/ + /* clang-format on */ + /* clang-format off */ + /*----- PROTECTED REGION END -----*/ // CCDSpectrometerClass::erase_dynamic_attributes +} + +//-------------------------------------------------------- +/** + * Method : CCDSpectrometerClass::get_attr_object_by_name() + * Description: returns Tango::Attr * object found by name + */ +//-------------------------------------------------------- +Tango::Attr *CCDSpectrometerClass::get_attr_object_by_name(std::vector<Tango::Attr *> &att_list, std::string attname) +{ + std::vector<Tango::Attr *>::iterator it; + for (it=att_list.begin() ; it<att_list.end() ; ++it) + if ((*it)->get_name()==attname) + return (*it); + // Attr does not exist + return NULL; +} + + +/*----- PROTECTED REGION ID(CCDSpectrometerClass::Additional Methods) ENABLED START -----*/ +/* clang-format on */ +/* clang-format off */ +/*----- PROTECTED REGION END -----*/ // CCDSpectrometerClass::Additional Methods +} // namespace diff --git a/src/CCDSpectrometerClass.h b/src/CCDSpectrometerClass.h new file mode 100644 index 0000000..49a7aa3 --- /dev/null +++ b/src/CCDSpectrometerClass.h @@ -0,0 +1,1027 @@ +/*----- PROTECTED REGION ID(CCDSpectrometerClass.h) ENABLED START -----*/ +/* clang-format on */ +//============================================================================= +// +// file : CCDSpectrometerClass.h +// +// description : Include for the CCDSpectrometer root class. +// This class is the singleton class for +// the CCDSpectrometer device class. +// It contains all properties and methods which the +// CCDSpectrometer requires only once e.g. the commands. +// +// project : CCDSpectrometer +// +// 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 CCDSpectrometerClass_H +#define CCDSpectrometerClass_H + +#include <tango.h> +#include "CCDSpectrometer.h" + +/* clang-format off */ +/*----- PROTECTED REGION END -----*/ // CCDSpectrometerClass.h + + +namespace CCDSpectrometer_ns +{ +/*----- PROTECTED REGION ID(CCDSpectrometerClass::classes for dynamic creation) ENABLED START -----*/ +/* clang-format on */ + +/* clang-format off */ +/*----- PROTECTED REGION END -----*/ // CCDSpectrometerClass::classes for dynamic creation + +//========================================= +// Define classes for attributes +//========================================= +// Attribute SyncMode class definition +class SyncModeAttrib: public Tango::Attr +{ +public: + SyncModeAttrib():Attr("SyncMode", + Tango::DEV_LONG, Tango::READ_WRITE) {} + ~SyncModeAttrib() {} + virtual void read(Tango::DeviceImpl *dev,Tango::Attribute &att) + {(static_cast<CCDSpectrometer *>(dev))->read_SyncMode(att);} + virtual void write(Tango::DeviceImpl *dev,Tango::WAttribute &att) + {(static_cast<CCDSpectrometer *>(dev))->write_SyncMode(att);} + virtual bool is_allowed(Tango::DeviceImpl *dev,Tango::AttReqType ty) + {return (static_cast<CCDSpectrometer *>(dev))->is_SyncMode_allowed(ty);} +}; + +// Attribute ExposureTime class definition +class ExposureTimeAttrib: public Tango::Attr +{ +public: + ExposureTimeAttrib():Attr("ExposureTime", + Tango::DEV_DOUBLE, Tango::READ_WRITE) {} + ~ExposureTimeAttrib() {} + virtual void read(Tango::DeviceImpl *dev,Tango::Attribute &att) + {(static_cast<CCDSpectrometer *>(dev))->read_ExposureTime(att);} + virtual void write(Tango::DeviceImpl *dev,Tango::WAttribute &att) + {(static_cast<CCDSpectrometer *>(dev))->write_ExposureTime(att);} + virtual bool is_allowed(Tango::DeviceImpl *dev,Tango::AttReqType ty) + {return (static_cast<CCDSpectrometer *>(dev))->is_ExposureTime_allowed(ty);} +}; + +// Attribute NoiseSubtraction class definition +class NoiseSubtractionAttrib: public Tango::Attr +{ +public: + NoiseSubtractionAttrib():Attr("NoiseSubtraction", + Tango::DEV_BOOLEAN, Tango::READ_WRITE) {} + ~NoiseSubtractionAttrib() {} + virtual void read(Tango::DeviceImpl *dev,Tango::Attribute &att) + {(static_cast<CCDSpectrometer *>(dev))->read_NoiseSubtraction(att);} + virtual void write(Tango::DeviceImpl *dev,Tango::WAttribute &att) + {(static_cast<CCDSpectrometer *>(dev))->write_NoiseSubtraction(att);} + virtual bool is_allowed(Tango::DeviceImpl *dev,Tango::AttReqType ty) + {return (static_cast<CCDSpectrometer *>(dev))->is_NoiseSubtraction_allowed(ty);} +}; + +// Attribute GaussFitEnable class definition +class GaussFitEnableAttrib: public Tango::Attr +{ +public: + GaussFitEnableAttrib():Attr("GaussFitEnable", + Tango::DEV_BOOLEAN, Tango::READ_WRITE) {} + ~GaussFitEnableAttrib() {} + virtual void read(Tango::DeviceImpl *dev,Tango::Attribute &att) + {(static_cast<CCDSpectrometer *>(dev))->read_GaussFitEnable(att);} + virtual void write(Tango::DeviceImpl *dev,Tango::WAttribute &att) + {(static_cast<CCDSpectrometer *>(dev))->write_GaussFitEnable(att);} + virtual bool is_allowed(Tango::DeviceImpl *dev,Tango::AttReqType ty) + {return (static_cast<CCDSpectrometer *>(dev))->is_GaussFitEnable_allowed(ty);} +}; + +// Attribute FWHMEnable class definition +class FWHMEnableAttrib: public Tango::Attr +{ +public: + FWHMEnableAttrib():Attr("FWHMEnable", + Tango::DEV_BOOLEAN, Tango::READ_WRITE) {} + ~FWHMEnableAttrib() {} + virtual void read(Tango::DeviceImpl *dev,Tango::Attribute &att) + {(static_cast<CCDSpectrometer *>(dev))->read_FWHMEnable(att);} + virtual void write(Tango::DeviceImpl *dev,Tango::WAttribute &att) + {(static_cast<CCDSpectrometer *>(dev))->write_FWHMEnable(att);} + virtual bool is_allowed(Tango::DeviceImpl *dev,Tango::AttReqType ty) + {return (static_cast<CCDSpectrometer *>(dev))->is_FWHMEnable_allowed(ty);} +}; + +// Attribute GaussFitCenter class definition +class GaussFitCenterAttrib: public Tango::Attr +{ +public: + GaussFitCenterAttrib():Attr("GaussFitCenter", + Tango::DEV_DOUBLE, Tango::READ) {} + ~GaussFitCenterAttrib() {} + virtual void read(Tango::DeviceImpl *dev,Tango::Attribute &att) + {(static_cast<CCDSpectrometer *>(dev))->read_GaussFitCenter(att);} + virtual bool is_allowed(Tango::DeviceImpl *dev,Tango::AttReqType ty) + {return (static_cast<CCDSpectrometer *>(dev))->is_GaussFitCenter_allowed(ty);} +}; + +// Attribute GaussFitWidth class definition +class GaussFitWidthAttrib: public Tango::Attr +{ +public: + GaussFitWidthAttrib():Attr("GaussFitWidth", + Tango::DEV_DOUBLE, Tango::READ) {} + ~GaussFitWidthAttrib() {} + virtual void read(Tango::DeviceImpl *dev,Tango::Attribute &att) + {(static_cast<CCDSpectrometer *>(dev))->read_GaussFitWidth(att);} + virtual bool is_allowed(Tango::DeviceImpl *dev,Tango::AttReqType ty) + {return (static_cast<CCDSpectrometer *>(dev))->is_GaussFitWidth_allowed(ty);} +}; + +// Attribute FWHMCenter class definition +class FWHMCenterAttrib: public Tango::Attr +{ +public: + FWHMCenterAttrib():Attr("FWHMCenter", + Tango::DEV_DOUBLE, Tango::READ) {} + ~FWHMCenterAttrib() {} + virtual void read(Tango::DeviceImpl *dev,Tango::Attribute &att) + {(static_cast<CCDSpectrometer *>(dev))->read_FWHMCenter(att);} + virtual bool is_allowed(Tango::DeviceImpl *dev,Tango::AttReqType ty) + {return (static_cast<CCDSpectrometer *>(dev))->is_FWHMCenter_allowed(ty);} +}; + +// Attribute FWHMWidth class definition +class FWHMWidthAttrib: public Tango::Attr +{ +public: + FWHMWidthAttrib():Attr("FWHMWidth", + Tango::DEV_DOUBLE, Tango::READ) {} + ~FWHMWidthAttrib() {} + virtual void read(Tango::DeviceImpl *dev,Tango::Attribute &att) + {(static_cast<CCDSpectrometer *>(dev))->read_FWHMWidth(att);} + virtual bool is_allowed(Tango::DeviceImpl *dev,Tango::AttReqType ty) + {return (static_cast<CCDSpectrometer *>(dev))->is_FWHMWidth_allowed(ty);} +}; + +// Attribute Center class definition +class CenterAttrib: public Tango::Attr +{ +public: + CenterAttrib():Attr("Center", + Tango::DEV_DOUBLE, Tango::READ) {} + ~CenterAttrib() {} + virtual void read(Tango::DeviceImpl *dev,Tango::Attribute &att) + {(static_cast<CCDSpectrometer *>(dev))->read_Center(att);} + virtual bool is_allowed(Tango::DeviceImpl *dev,Tango::AttReqType ty) + {return (static_cast<CCDSpectrometer *>(dev))->is_Center_allowed(ty);} +}; + +// Attribute Width class definition +class WidthAttrib: public Tango::Attr +{ +public: + WidthAttrib():Attr("Width", + Tango::DEV_DOUBLE, Tango::READ) {} + ~WidthAttrib() {} + virtual void read(Tango::DeviceImpl *dev,Tango::Attribute &att) + {(static_cast<CCDSpectrometer *>(dev))->read_Width(att);} + virtual bool is_allowed(Tango::DeviceImpl *dev,Tango::AttReqType ty) + {return (static_cast<CCDSpectrometer *>(dev))->is_Width_allowed(ty);} +}; + +// Attribute FitType class definition +class FitTypeAttrib: public Tango::Attr +{ +public: + FitTypeAttrib():Attr("FitType", + Tango::DEV_LONG, Tango::READ_WRITE) {} + ~FitTypeAttrib() {} + virtual void read(Tango::DeviceImpl *dev,Tango::Attribute &att) + {(static_cast<CCDSpectrometer *>(dev))->read_FitType(att);} + virtual void write(Tango::DeviceImpl *dev,Tango::WAttribute &att) + {(static_cast<CCDSpectrometer *>(dev))->write_FitType(att);} + virtual bool is_allowed(Tango::DeviceImpl *dev,Tango::AttReqType ty) + {return (static_cast<CCDSpectrometer *>(dev))->is_FitType_allowed(ty);} +}; + +// Attribute FWHMAvg class definition +class FWHMAvgAttrib: public Tango::Attr +{ +public: + FWHMAvgAttrib():Attr("FWHMAvg", + Tango::DEV_LONG, Tango::READ_WRITE) {} + ~FWHMAvgAttrib() {} + virtual void read(Tango::DeviceImpl *dev,Tango::Attribute &att) + {(static_cast<CCDSpectrometer *>(dev))->read_FWHMAvg(att);} + virtual void write(Tango::DeviceImpl *dev,Tango::WAttribute &att) + {(static_cast<CCDSpectrometer *>(dev))->write_FWHMAvg(att);} + virtual bool is_allowed(Tango::DeviceImpl *dev,Tango::AttReqType ty) + {return (static_cast<CCDSpectrometer *>(dev))->is_FWHMAvg_allowed(ty);} +}; + +// Attribute NoiseLevel class definition +class NoiseLevelAttrib: public Tango::Attr +{ +public: + NoiseLevelAttrib():Attr("NoiseLevel", + Tango::DEV_LONG, Tango::READ_WRITE) {} + ~NoiseLevelAttrib() {} + virtual void read(Tango::DeviceImpl *dev,Tango::Attribute &att) + {(static_cast<CCDSpectrometer *>(dev))->read_NoiseLevel(att);} + virtual void write(Tango::DeviceImpl *dev,Tango::WAttribute &att) + {(static_cast<CCDSpectrometer *>(dev))->write_NoiseLevel(att);} + virtual bool is_allowed(Tango::DeviceImpl *dev,Tango::AttReqType ty) + {return (static_cast<CCDSpectrometer *>(dev))->is_NoiseLevel_allowed(ty);} +}; + +// Attribute DataReferenceFile class definition +class DataReferenceFileAttrib: public Tango::Attr +{ +public: + DataReferenceFileAttrib():Attr("DataReferenceFile", + Tango::DEV_STRING, Tango::READ_WRITE) {} + ~DataReferenceFileAttrib() {} + virtual void read(Tango::DeviceImpl *dev,Tango::Attribute &att) + {(static_cast<CCDSpectrometer *>(dev))->read_DataReferenceFile(att);} + virtual void write(Tango::DeviceImpl *dev,Tango::WAttribute &att) + {(static_cast<CCDSpectrometer *>(dev))->write_DataReferenceFile(att);} + virtual bool is_allowed(Tango::DeviceImpl *dev,Tango::AttReqType ty) + {return (static_cast<CCDSpectrometer *>(dev))->is_DataReferenceFile_allowed(ty);} +}; + +// Attribute AutoExposure class definition +class AutoExposureAttrib: public Tango::Attr +{ +public: + AutoExposureAttrib():Attr("AutoExposure", + Tango::DEV_BOOLEAN, Tango::READ_WRITE) {} + ~AutoExposureAttrib() {} + virtual void read(Tango::DeviceImpl *dev,Tango::Attribute &att) + {(static_cast<CCDSpectrometer *>(dev))->read_AutoExposure(att);} + virtual void write(Tango::DeviceImpl *dev,Tango::WAttribute &att) + {(static_cast<CCDSpectrometer *>(dev))->write_AutoExposure(att);} + virtual bool is_allowed(Tango::DeviceImpl *dev,Tango::AttReqType ty) + {return (static_cast<CCDSpectrometer *>(dev))->is_AutoExposure_allowed(ty);} +}; + +// Attribute RtMode class definition +class RtModeAttrib: public Tango::Attr +{ +public: + RtModeAttrib():Attr("RtMode", + Tango::DEV_BOOLEAN, Tango::READ_WRITE) {} + ~RtModeAttrib() {} + virtual void read(Tango::DeviceImpl *dev,Tango::Attribute &att) + {(static_cast<CCDSpectrometer *>(dev))->read_RtMode(att);} + virtual void write(Tango::DeviceImpl *dev,Tango::WAttribute &att) + {(static_cast<CCDSpectrometer *>(dev))->write_RtMode(att);} + virtual bool is_allowed(Tango::DeviceImpl *dev,Tango::AttReqType ty) + {return (static_cast<CCDSpectrometer *>(dev))->is_RtMode_allowed(ty);} +}; + +// Attribute IntensityCalibrationEnable class definition +class IntensityCalibrationEnableAttrib: public Tango::Attr +{ +public: + IntensityCalibrationEnableAttrib():Attr("IntensityCalibrationEnable", + Tango::DEV_BOOLEAN, Tango::READ_WRITE) {} + ~IntensityCalibrationEnableAttrib() {} + virtual void read(Tango::DeviceImpl *dev,Tango::Attribute &att) + {(static_cast<CCDSpectrometer *>(dev))->read_IntensityCalibrationEnable(att);} + virtual void write(Tango::DeviceImpl *dev,Tango::WAttribute &att) + {(static_cast<CCDSpectrometer *>(dev))->write_IntensityCalibrationEnable(att);} + virtual bool is_allowed(Tango::DeviceImpl *dev,Tango::AttReqType ty) + {return (static_cast<CCDSpectrometer *>(dev))->is_IntensityCalibrationEnable_allowed(ty);} +}; + +// Attribute Area class definition +class AreaAttrib: public Tango::Attr +{ +public: + AreaAttrib():Attr("Area", + Tango::DEV_DOUBLE, Tango::READ) {} + ~AreaAttrib() {} + virtual void read(Tango::DeviceImpl *dev,Tango::Attribute &att) + {(static_cast<CCDSpectrometer *>(dev))->read_Area(att);} + virtual bool is_allowed(Tango::DeviceImpl *dev,Tango::AttReqType ty) + {return (static_cast<CCDSpectrometer *>(dev))->is_Area_allowed(ty);} +}; + +// Attribute AreaRegion class definition +class AreaRegionAttrib: public Tango::Attr +{ +public: + AreaRegionAttrib():Attr("AreaRegion", + Tango::DEV_DOUBLE, Tango::READ_WRITE) {} + ~AreaRegionAttrib() {} + virtual void read(Tango::DeviceImpl *dev,Tango::Attribute &att) + {(static_cast<CCDSpectrometer *>(dev))->read_AreaRegion(att);} + virtual void write(Tango::DeviceImpl *dev,Tango::WAttribute &att) + {(static_cast<CCDSpectrometer *>(dev))->write_AreaRegion(att);} + virtual bool is_allowed(Tango::DeviceImpl *dev,Tango::AttReqType ty) + {return (static_cast<CCDSpectrometer *>(dev))->is_AreaRegion_allowed(ty);} +}; + +// Attribute AreaEnable class definition +class AreaEnableAttrib: public Tango::Attr +{ +public: + AreaEnableAttrib():Attr("AreaEnable", + Tango::DEV_BOOLEAN, Tango::READ_WRITE) {} + ~AreaEnableAttrib() {} + virtual void read(Tango::DeviceImpl *dev,Tango::Attribute &att) + {(static_cast<CCDSpectrometer *>(dev))->read_AreaEnable(att);} + virtual void write(Tango::DeviceImpl *dev,Tango::WAttribute &att) + {(static_cast<CCDSpectrometer *>(dev))->write_AreaEnable(att);} + virtual bool is_allowed(Tango::DeviceImpl *dev,Tango::AttReqType ty) + {return (static_cast<CCDSpectrometer *>(dev))->is_AreaEnable_allowed(ty);} +}; + +// Attribute WidthCorrectionEnable class definition +class WidthCorrectionEnableAttrib: public Tango::Attr +{ +public: + WidthCorrectionEnableAttrib():Attr("WidthCorrectionEnable", + Tango::DEV_BOOLEAN, Tango::READ_WRITE) {} + ~WidthCorrectionEnableAttrib() {} + virtual void read(Tango::DeviceImpl *dev,Tango::Attribute &att) + {(static_cast<CCDSpectrometer *>(dev))->read_WidthCorrectionEnable(att);} + virtual void write(Tango::DeviceImpl *dev,Tango::WAttribute &att) + {(static_cast<CCDSpectrometer *>(dev))->write_WidthCorrectionEnable(att);} + virtual bool is_allowed(Tango::DeviceImpl *dev,Tango::AttReqType ty) + {return (static_cast<CCDSpectrometer *>(dev))->is_WidthCorrectionEnable_allowed(ty);} +}; + +// Attribute IncrSensitivity class definition +class IncrSensitivityAttrib: public Tango::Attr +{ +public: + IncrSensitivityAttrib():Attr("IncrSensitivity", + Tango::DEV_BOOLEAN, Tango::READ_WRITE) {} + ~IncrSensitivityAttrib() {} + virtual void read(Tango::DeviceImpl *dev,Tango::Attribute &att) + {(static_cast<CCDSpectrometer *>(dev))->read_IncrSensitivity(att);} + virtual void write(Tango::DeviceImpl *dev,Tango::WAttribute &att) + {(static_cast<CCDSpectrometer *>(dev))->write_IncrSensitivity(att);} + virtual bool is_allowed(Tango::DeviceImpl *dev,Tango::AttReqType ty) + {return (static_cast<CCDSpectrometer *>(dev))->is_IncrSensitivity_allowed(ty);} +}; + +// Attribute Data class definition +class DataAttrib: public Tango::SpectrumAttr +{ +public: + // Constants for Data attribute + const static long X_DATA_SIZE = 4100; + DataAttrib():SpectrumAttr("Data", + Tango::DEV_DOUBLE, Tango::READ, DataAttrib::X_DATA_SIZE) {} + ~DataAttrib() {} + virtual void read(Tango::DeviceImpl *dev,Tango::Attribute &att) + {(static_cast<CCDSpectrometer *>(dev))->read_Data(att);} + virtual bool is_allowed(Tango::DeviceImpl *dev,Tango::AttReqType ty) + {return (static_cast<CCDSpectrometer *>(dev))->is_Data_allowed(ty);} +}; + +// Attribute NumPixels class definition +class NumPixelsAttrib: public Tango::SpectrumAttr +{ +public: + // Constants for NumPixels attribute + const static long X_DATA_SIZE = 2; + NumPixelsAttrib():SpectrumAttr("NumPixels", + Tango::DEV_LONG, Tango::READ, NumPixelsAttrib::X_DATA_SIZE) {} + ~NumPixelsAttrib() {} + virtual void read(Tango::DeviceImpl *dev,Tango::Attribute &att) + {(static_cast<CCDSpectrometer *>(dev))->read_NumPixels(att);} + virtual bool is_allowed(Tango::DeviceImpl *dev,Tango::AttReqType ty) + {return (static_cast<CCDSpectrometer *>(dev))->is_NumPixels_allowed(ty);} +}; + +// Attribute RegionOfInterest class definition +class RegionOfInterestAttrib: public Tango::SpectrumAttr +{ +public: + // Constants for RegionOfInterest attribute + const static long X_DATA_SIZE = 2; + RegionOfInterestAttrib():SpectrumAttr("RegionOfInterest", + Tango::DEV_DOUBLE, Tango::READ_WRITE, RegionOfInterestAttrib::X_DATA_SIZE) {} + ~RegionOfInterestAttrib() {} + virtual void read(Tango::DeviceImpl *dev,Tango::Attribute &att) + {(static_cast<CCDSpectrometer *>(dev))->read_RegionOfInterest(att);} + virtual void write(Tango::DeviceImpl *dev,Tango::WAttribute &att) + {(static_cast<CCDSpectrometer *>(dev))->write_RegionOfInterest(att);} + virtual bool is_allowed(Tango::DeviceImpl *dev,Tango::AttReqType ty) + {return (static_cast<CCDSpectrometer *>(dev))->is_RegionOfInterest_allowed(ty);} +}; + +// Attribute AnalysisRegion class definition +class AnalysisRegionAttrib: public Tango::SpectrumAttr +{ +public: + // Constants for AnalysisRegion attribute + const static long X_DATA_SIZE = 2; + AnalysisRegionAttrib():SpectrumAttr("AnalysisRegion", + Tango::DEV_DOUBLE, Tango::READ_WRITE, AnalysisRegionAttrib::X_DATA_SIZE) {} + ~AnalysisRegionAttrib() {} + virtual void read(Tango::DeviceImpl *dev,Tango::Attribute &att) + {(static_cast<CCDSpectrometer *>(dev))->read_AnalysisRegion(att);} + virtual void write(Tango::DeviceImpl *dev,Tango::WAttribute &att) + {(static_cast<CCDSpectrometer *>(dev))->write_AnalysisRegion(att);} + virtual bool is_allowed(Tango::DeviceImpl *dev,Tango::AttReqType ty) + {return (static_cast<CCDSpectrometer *>(dev))->is_AnalysisRegion_allowed(ty);} +}; + +// Attribute GaussFit class definition +class GaussFitAttrib: public Tango::SpectrumAttr +{ +public: + // Constants for GaussFit attribute + const static long X_DATA_SIZE = 4; + GaussFitAttrib():SpectrumAttr("GaussFit", + Tango::DEV_DOUBLE, Tango::READ, GaussFitAttrib::X_DATA_SIZE) {} + ~GaussFitAttrib() {} + virtual void read(Tango::DeviceImpl *dev,Tango::Attribute &att) + {(static_cast<CCDSpectrometer *>(dev))->read_GaussFit(att);} + virtual bool is_allowed(Tango::DeviceImpl *dev,Tango::AttReqType ty) + {return (static_cast<CCDSpectrometer *>(dev))->is_GaussFit_allowed(ty);} +}; + +// Attribute FWHM class definition +class FWHMAttrib: public Tango::SpectrumAttr +{ +public: + // Constants for FWHM attribute + const static long X_DATA_SIZE = 3; + FWHMAttrib():SpectrumAttr("FWHM", + Tango::DEV_DOUBLE, Tango::READ, FWHMAttrib::X_DATA_SIZE) {} + ~FWHMAttrib() {} + virtual void read(Tango::DeviceImpl *dev,Tango::Attribute &att) + {(static_cast<CCDSpectrometer *>(dev))->read_FWHM(att);} + virtual bool is_allowed(Tango::DeviceImpl *dev,Tango::AttReqType ty) + {return (static_cast<CCDSpectrometer *>(dev))->is_FWHM_allowed(ty);} +}; + +// Attribute GaussReference class definition +class GaussReferenceAttrib: public Tango::SpectrumAttr +{ +public: + // Constants for GaussReference attribute + const static long X_DATA_SIZE = 4; + GaussReferenceAttrib():SpectrumAttr("GaussReference", + Tango::DEV_DOUBLE, Tango::READ_WRITE, GaussReferenceAttrib::X_DATA_SIZE) {} + ~GaussReferenceAttrib() {} + virtual void read(Tango::DeviceImpl *dev,Tango::Attribute &att) + {(static_cast<CCDSpectrometer *>(dev))->read_GaussReference(att);} + virtual void write(Tango::DeviceImpl *dev,Tango::WAttribute &att) + {(static_cast<CCDSpectrometer *>(dev))->write_GaussReference(att);} + virtual bool is_allowed(Tango::DeviceImpl *dev,Tango::AttReqType ty) + {return (static_cast<CCDSpectrometer *>(dev))->is_GaussReference_allowed(ty);} +}; + +// Attribute DataReference class definition +class DataReferenceAttrib: public Tango::SpectrumAttr +{ +public: + // Constants for DataReference attribute + const static long X_DATA_SIZE = 5000; + DataReferenceAttrib():SpectrumAttr("DataReference", + Tango::DEV_DOUBLE, Tango::READ_WRITE, DataReferenceAttrib::X_DATA_SIZE) {} + ~DataReferenceAttrib() {} + virtual void read(Tango::DeviceImpl *dev,Tango::Attribute &att) + {(static_cast<CCDSpectrometer *>(dev))->read_DataReference(att);} + virtual void write(Tango::DeviceImpl *dev,Tango::WAttribute &att) + {(static_cast<CCDSpectrometer *>(dev))->write_DataReference(att);} + virtual bool is_allowed(Tango::DeviceImpl *dev,Tango::AttReqType ty) + {return (static_cast<CCDSpectrometer *>(dev))->is_DataReference_allowed(ty);} +}; + +// Attribute IntensityCalibration class definition +class IntensityCalibrationAttrib: public Tango::SpectrumAttr +{ +public: + // Constants for IntensityCalibration attribute + const static long X_DATA_SIZE = 5000; + IntensityCalibrationAttrib():SpectrumAttr("IntensityCalibration", + Tango::DEV_DOUBLE, Tango::READ_WRITE, IntensityCalibrationAttrib::X_DATA_SIZE) {} + ~IntensityCalibrationAttrib() {} + virtual void read(Tango::DeviceImpl *dev,Tango::Attribute &att) + {(static_cast<CCDSpectrometer *>(dev))->read_IntensityCalibration(att);} + virtual void write(Tango::DeviceImpl *dev,Tango::WAttribute &att) + {(static_cast<CCDSpectrometer *>(dev))->write_IntensityCalibration(att);} + virtual bool is_allowed(Tango::DeviceImpl *dev,Tango::AttReqType ty) + {return (static_cast<CCDSpectrometer *>(dev))->is_IntensityCalibration_allowed(ty);} +}; + +// Attribute NoiseProfile class definition +class NoiseProfileAttrib: public Tango::SpectrumAttr +{ +public: + // Constants for NoiseProfile attribute + const static long X_DATA_SIZE = 5000; + NoiseProfileAttrib():SpectrumAttr("NoiseProfile", + Tango::DEV_DOUBLE, Tango::READ, NoiseProfileAttrib::X_DATA_SIZE) {} + ~NoiseProfileAttrib() {} + virtual void read(Tango::DeviceImpl *dev,Tango::Attribute &att) + {(static_cast<CCDSpectrometer *>(dev))->read_NoiseProfile(att);} + virtual bool is_allowed(Tango::DeviceImpl *dev,Tango::AttReqType ty) + {return (static_cast<CCDSpectrometer *>(dev))->is_NoiseProfile_allowed(ty);} +}; + +// Attribute Wave class definition +class WaveAttrib: public Tango::SpectrumAttr +{ +public: + // Constants for Wave attribute + const static long X_DATA_SIZE = 5000; + WaveAttrib():SpectrumAttr("Wave", + Tango::DEV_DOUBLE, Tango::READ, WaveAttrib::X_DATA_SIZE) {} + ~WaveAttrib() {} + virtual void read(Tango::DeviceImpl *dev,Tango::Attribute &att) + {(static_cast<CCDSpectrometer *>(dev))->read_Wave(att);} + virtual bool is_allowed(Tango::DeviceImpl *dev,Tango::AttReqType ty) + {return (static_cast<CCDSpectrometer *>(dev))->is_Wave_allowed(ty);} +}; + +// Attribute Lambda class definition +class LambdaAttrib: public Tango::SpectrumAttr +{ +public: + // Constants for Lambda attribute + const static long X_DATA_SIZE = 5000; + LambdaAttrib():SpectrumAttr("Lambda", + Tango::DEV_DOUBLE, Tango::READ, LambdaAttrib::X_DATA_SIZE) {} + ~LambdaAttrib() {} + virtual void read(Tango::DeviceImpl *dev,Tango::Attribute &att) + {(static_cast<CCDSpectrometer *>(dev))->read_Lambda(att);} + virtual bool is_allowed(Tango::DeviceImpl *dev,Tango::AttReqType ty) + {return (static_cast<CCDSpectrometer *>(dev))->is_Lambda_allowed(ty);} +}; + + +//========================================= +// Define classes for commands +//========================================= +// Command Start class definition +class StartClass : public Tango::Command +{ +public: + StartClass(const char *cmd_name, + Tango::CmdArgType in, + Tango::CmdArgType out, + const char *in_desc, + const char *out_desc, + Tango::DispLevel level) + :Command(cmd_name,in,out,in_desc,out_desc, level) {} + + StartClass(const char *cmd_name, + Tango::CmdArgType in, + Tango::CmdArgType out) + :Command(cmd_name,in,out) {} + ~StartClass() {} + + virtual CORBA::Any *execute (Tango::DeviceImpl *dev, const CORBA::Any &any); + virtual bool is_allowed (Tango::DeviceImpl *dev, const CORBA::Any &any) + {return (static_cast<CCDSpectrometer *>(dev))->is_Start_allowed(any);} +}; + +// Command Stop class definition +class StopClass : public Tango::Command +{ +public: + StopClass(const char *cmd_name, + Tango::CmdArgType in, + Tango::CmdArgType out, + const char *in_desc, + const char *out_desc, + Tango::DispLevel level) + :Command(cmd_name,in,out,in_desc,out_desc, level) {} + + StopClass(const char *cmd_name, + Tango::CmdArgType in, + Tango::CmdArgType out) + :Command(cmd_name,in,out) {} + ~StopClass() {} + + virtual CORBA::Any *execute (Tango::DeviceImpl *dev, const CORBA::Any &any); + virtual bool is_allowed (Tango::DeviceImpl *dev, const CORBA::Any &any) + {return (static_cast<CCDSpectrometer *>(dev))->is_Stop_allowed(any);} +}; + +// Command Reset class definition +class ResetClass : public Tango::Command +{ +public: + ResetClass(const char *cmd_name, + Tango::CmdArgType in, + Tango::CmdArgType out, + const char *in_desc, + const char *out_desc, + Tango::DispLevel level) + :Command(cmd_name,in,out,in_desc,out_desc, level) {} + + ResetClass(const char *cmd_name, + Tango::CmdArgType in, + Tango::CmdArgType out) + :Command(cmd_name,in,out) {} + ~ResetClass() {} + + virtual CORBA::Any *execute (Tango::DeviceImpl *dev, const CORBA::Any &any); + virtual bool is_allowed (Tango::DeviceImpl *dev, const CORBA::Any &any) + {return (static_cast<CCDSpectrometer *>(dev))->is_Reset_allowed(any);} +}; + +// Command StartSingle class definition +class StartSingleClass : public Tango::Command +{ +public: + StartSingleClass(const char *cmd_name, + Tango::CmdArgType in, + Tango::CmdArgType out, + const char *in_desc, + const char *out_desc, + Tango::DispLevel level) + :Command(cmd_name,in,out,in_desc,out_desc, level) {} + + StartSingleClass(const char *cmd_name, + Tango::CmdArgType in, + Tango::CmdArgType out) + :Command(cmd_name,in,out) {} + ~StartSingleClass() {} + + 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<CCDSpectrometer *>(dev))->is_StartSingle_allowed(any);} +}; + +// Command StartContinuous class definition +class StartContinuousClass : public Tango::Command +{ +public: + StartContinuousClass(const char *cmd_name, + Tango::CmdArgType in, + Tango::CmdArgType out, + const char *in_desc, + const char *out_desc, + Tango::DispLevel level) + :Command(cmd_name,in,out,in_desc,out_desc, level) {} + + StartContinuousClass(const char *cmd_name, + Tango::CmdArgType in, + Tango::CmdArgType out) + :Command(cmd_name,in,out) {} + ~StartContinuousClass() {} + + 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<CCDSpectrometer *>(dev))->is_StartContinuous_allowed(any);} +}; + +// Command GetLastData class definition +class GetLastDataClass : public Tango::Command +{ +public: + GetLastDataClass(const char *cmd_name, + Tango::CmdArgType in, + Tango::CmdArgType out, + const char *in_desc, + const char *out_desc, + Tango::DispLevel level) + :Command(cmd_name,in,out,in_desc,out_desc, level) {} + + GetLastDataClass(const char *cmd_name, + Tango::CmdArgType in, + Tango::CmdArgType out) + :Command(cmd_name,in,out) {} + ~GetLastDataClass() {} + + 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<CCDSpectrometer *>(dev))->is_GetLastData_allowed(any);} +}; + +// Command AcquireNoise class definition +class AcquireNoiseClass : public Tango::Command +{ +public: + AcquireNoiseClass(const char *cmd_name, + Tango::CmdArgType in, + Tango::CmdArgType out, + const char *in_desc, + const char *out_desc, + Tango::DispLevel level) + :Command(cmd_name,in,out,in_desc,out_desc, level) {} + + AcquireNoiseClass(const char *cmd_name, + Tango::CmdArgType in, + Tango::CmdArgType out) + :Command(cmd_name,in,out) {} + ~AcquireNoiseClass() {} + + 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<CCDSpectrometer *>(dev))->is_AcquireNoise_allowed(any);} +}; + +// Command SaveReferenceData class definition +class SaveReferenceDataClass : public Tango::Command +{ +public: + SaveReferenceDataClass(const char *cmd_name, + Tango::CmdArgType in, + Tango::CmdArgType out, + const char *in_desc, + const char *out_desc, + Tango::DispLevel level) + :Command(cmd_name,in,out,in_desc,out_desc, level) {} + + SaveReferenceDataClass(const char *cmd_name, + Tango::CmdArgType in, + Tango::CmdArgType out) + :Command(cmd_name,in,out) {} + ~SaveReferenceDataClass() {} + + 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<CCDSpectrometer *>(dev))->is_SaveReferenceData_allowed(any);} +}; + +// Command GetData class definition +class GetDataClass : public Tango::Command +{ +public: + GetDataClass(const char *cmd_name, + Tango::CmdArgType in, + Tango::CmdArgType out, + const char *in_desc, + const char *out_desc, + Tango::DispLevel level) + :Command(cmd_name,in,out,in_desc,out_desc, level) {} + + GetDataClass(const char *cmd_name, + Tango::CmdArgType in, + Tango::CmdArgType out) + :Command(cmd_name,in,out) {} + ~GetDataClass() {} + + 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<CCDSpectrometer *>(dev))->is_GetData_allowed(any);} +}; + +// Command GetGaussFitCenter class definition +class GetGaussFitCenterClass : public Tango::Command +{ +public: + GetGaussFitCenterClass(const char *cmd_name, + Tango::CmdArgType in, + Tango::CmdArgType out, + const char *in_desc, + const char *out_desc, + Tango::DispLevel level) + :Command(cmd_name,in,out,in_desc,out_desc, level) {} + + GetGaussFitCenterClass(const char *cmd_name, + Tango::CmdArgType in, + Tango::CmdArgType out) + :Command(cmd_name,in,out) {} + ~GetGaussFitCenterClass() {} + + 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<CCDSpectrometer *>(dev))->is_GetGaussFitCenter_allowed(any);} +}; + +// Command GetGaussFitWidth class definition +class GetGaussFitWidthClass : public Tango::Command +{ +public: + GetGaussFitWidthClass(const char *cmd_name, + Tango::CmdArgType in, + Tango::CmdArgType out, + const char *in_desc, + const char *out_desc, + Tango::DispLevel level) + :Command(cmd_name,in,out,in_desc,out_desc, level) {} + + GetGaussFitWidthClass(const char *cmd_name, + Tango::CmdArgType in, + Tango::CmdArgType out) + :Command(cmd_name,in,out) {} + ~GetGaussFitWidthClass() {} + + 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<CCDSpectrometer *>(dev))->is_GetGaussFitWidth_allowed(any);} +}; + +// Command GetFWHMCenter class definition +class GetFWHMCenterClass : public Tango::Command +{ +public: + GetFWHMCenterClass(const char *cmd_name, + Tango::CmdArgType in, + Tango::CmdArgType out, + const char *in_desc, + const char *out_desc, + Tango::DispLevel level) + :Command(cmd_name,in,out,in_desc,out_desc, level) {} + + GetFWHMCenterClass(const char *cmd_name, + Tango::CmdArgType in, + Tango::CmdArgType out) + :Command(cmd_name,in,out) {} + ~GetFWHMCenterClass() {} + + 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<CCDSpectrometer *>(dev))->is_GetFWHMCenter_allowed(any);} +}; + +// Command GetFWHMWidth class definition +class GetFWHMWidthClass : public Tango::Command +{ +public: + GetFWHMWidthClass(const char *cmd_name, + Tango::CmdArgType in, + Tango::CmdArgType out, + const char *in_desc, + const char *out_desc, + Tango::DispLevel level) + :Command(cmd_name,in,out,in_desc,out_desc, level) {} + + GetFWHMWidthClass(const char *cmd_name, + Tango::CmdArgType in, + Tango::CmdArgType out) + :Command(cmd_name,in,out) {} + ~GetFWHMWidthClass() {} + + 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<CCDSpectrometer *>(dev))->is_GetFWHMWidth_allowed(any);} +}; + +// Command ExportWavelength class definition +class ExportWavelengthClass : public Tango::Command +{ +public: + ExportWavelengthClass(const char *cmd_name, + Tango::CmdArgType in, + Tango::CmdArgType out, + const char *in_desc, + const char *out_desc, + Tango::DispLevel level) + :Command(cmd_name,in,out,in_desc,out_desc, level) {} + + ExportWavelengthClass(const char *cmd_name, + Tango::CmdArgType in, + Tango::CmdArgType out) + :Command(cmd_name,in,out) {} + ~ExportWavelengthClass() {} + + 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<CCDSpectrometer *>(dev))->is_ExportWavelength_allowed(any);} +}; + +// Command GetArea class definition +class GetAreaClass : public Tango::Command +{ +public: + GetAreaClass(const char *cmd_name, + Tango::CmdArgType in, + Tango::CmdArgType out, + const char *in_desc, + const char *out_desc, + Tango::DispLevel level) + :Command(cmd_name,in,out,in_desc,out_desc, level) {} + + GetAreaClass(const char *cmd_name, + Tango::CmdArgType in, + Tango::CmdArgType out) + :Command(cmd_name,in,out) {} + ~GetAreaClass() {} + + 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<CCDSpectrometer *>(dev))->is_GetArea_allowed(any);} +}; + +// Command GetWave class definition +class GetWaveClass : public Tango::Command +{ +public: + GetWaveClass(const char *cmd_name, + Tango::CmdArgType in, + Tango::CmdArgType out, + const char *in_desc, + const char *out_desc, + Tango::DispLevel level) + :Command(cmd_name,in,out,in_desc,out_desc, level) {} + + GetWaveClass(const char *cmd_name, + Tango::CmdArgType in, + Tango::CmdArgType out) + :Command(cmd_name,in,out) {} + ~GetWaveClass() {} + + 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<CCDSpectrometer *>(dev))->is_GetWave_allowed(any);} +}; + +// Command GetLambda class definition +class GetLambdaClass : public Tango::Command +{ +public: + GetLambdaClass(const char *cmd_name, + Tango::CmdArgType in, + Tango::CmdArgType out, + const char *in_desc, + const char *out_desc, + Tango::DispLevel level) + :Command(cmd_name,in,out,in_desc,out_desc, level) {} + + GetLambdaClass(const char *cmd_name, + Tango::CmdArgType in, + Tango::CmdArgType out) + :Command(cmd_name,in,out) {} + ~GetLambdaClass() {} + + 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<CCDSpectrometer *>(dev))->is_GetLambda_allowed(any);} +}; + + +/** + * The CCDSpectrometerClass singleton definition + */ + +#ifdef _TG_WINDOWS_ +class __declspec(dllexport) CCDSpectrometerClass : public Tango::DeviceClass +#else +class CCDSpectrometerClass : public Tango::DeviceClass +#endif +{ + /*----- PROTECTED REGION ID(CCDSpectrometerClass::Additional DServer data members) ENABLED START -----*/ + /* clang-format on */ + // Add your own code + /* clang-format off */ + /*----- PROTECTED REGION END -----*/ // CCDSpectrometerClass::Additional DServer data members + + public: + // write class properties data members + Tango::DbData cl_prop; + Tango::DbData cl_def_prop; + Tango::DbData dev_def_prop; + // Method prototypes + static CCDSpectrometerClass *init(const char *); + static CCDSpectrometerClass *instance(); + ~CCDSpectrometerClass(); + Tango::DbDatum get_class_property(std::string &); + Tango::DbDatum get_default_device_property(std::string &); + Tango::DbDatum get_default_class_property(std::string &); + + protected: + CCDSpectrometerClass(std::string &); + static CCDSpectrometerClass *_instance; + void command_factory(); + void attribute_factory(std::vector<Tango::Attr *> &); + void pipe_factory(); + void write_class_property(); + void set_default_property(); + void get_class_property(); + std::string get_cvstag(); + std::string get_cvsroot(); + + private: + void device_factory(TANGO_UNUSED(const Tango::DevVarStringArray *)); + void create_static_attribute_list(std::vector<Tango::Attr *> &); + void erase_dynamic_attributes(const Tango::DevVarStringArray *,std::vector<Tango::Attr *> &); + std::vector<std::string> defaultAttList; + Tango::Attr *get_attr_object_by_name(std::vector<Tango::Attr *> &att_list, std::string attname); +}; + +} // End of namespace + +#endif // CCDSpectrometer_H diff --git a/src/CCDSpectrometerStateMachine.cpp b/src/CCDSpectrometerStateMachine.cpp new file mode 100644 index 0000000..6bf1911 --- /dev/null +++ b/src/CCDSpectrometerStateMachine.cpp @@ -0,0 +1,1033 @@ +/*----- PROTECTED REGION ID(CCDSpectrometerStateMachine.cpp) ENABLED START -----*/ +/* clang-format on */ +//============================================================================= +// +// file : CCDSpectrometerStateMachine.cpp +// +// description : State machine file for the CCDSpectrometer class +// +// project : CCDSpectrometer +// +// 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 "CCDSpectrometer.h" + +/* clang-format off */ +/*----- PROTECTED REGION END -----*/ // CCDSpectrometer::CCDSpectrometerStateMachine.cpp + +//================================================================ +// States | Description +//================================================================ + + +namespace CCDSpectrometer_ns +{ +//================================================= +// Attributes Allowed Methods +//================================================= + +//-------------------------------------------------------- +/** + * Method : CCDSpectrometer::is_SyncMode_allowed() + * Description: Execution allowed for SyncMode attribute + */ +//-------------------------------------------------------- +bool CCDSpectrometer::is_SyncMode_allowed(TANGO_UNUSED(Tango::AttReqType type)) +{ + // Not any excluded states for SyncMode attribute in Write access. + /*----- PROTECTED REGION ID(CCDSpectrometer::SyncModeStateAllowed_WRITE) ENABLED START -----*/ + /* clang-format on */ + /* clang-format off */ + /*----- PROTECTED REGION END -----*/ // CCDSpectrometer::SyncModeStateAllowed_WRITE + + // Not any excluded states for SyncMode attribute in read access. + /*----- PROTECTED REGION ID(CCDSpectrometer::SyncModeStateAllowed_READ) ENABLED START -----*/ + /* clang-format on */ + /* clang-format off */ + /*----- PROTECTED REGION END -----*/ // CCDSpectrometer::SyncModeStateAllowed_READ + return true; +} + +//-------------------------------------------------------- +/** + * Method : CCDSpectrometer::is_ExposureTime_allowed() + * Description: Execution allowed for ExposureTime attribute + */ +//-------------------------------------------------------- +bool CCDSpectrometer::is_ExposureTime_allowed(TANGO_UNUSED(Tango::AttReqType type)) +{ + // Not any excluded states for ExposureTime attribute in Write access. + /*----- PROTECTED REGION ID(CCDSpectrometer::ExposureTimeStateAllowed_WRITE) ENABLED START -----*/ + /* clang-format on */ + /* clang-format off */ + /*----- PROTECTED REGION END -----*/ // CCDSpectrometer::ExposureTimeStateAllowed_WRITE + + // Not any excluded states for ExposureTime attribute in read access. + /*----- PROTECTED REGION ID(CCDSpectrometer::ExposureTimeStateAllowed_READ) ENABLED START -----*/ + /* clang-format on */ + /* clang-format off */ + /*----- PROTECTED REGION END -----*/ // CCDSpectrometer::ExposureTimeStateAllowed_READ + return true; +} + +//-------------------------------------------------------- +/** + * Method : CCDSpectrometer::is_NoiseSubtraction_allowed() + * Description: Execution allowed for NoiseSubtraction attribute + */ +//-------------------------------------------------------- +bool CCDSpectrometer::is_NoiseSubtraction_allowed(TANGO_UNUSED(Tango::AttReqType type)) +{ + // Not any excluded states for NoiseSubtraction attribute in Write access. + /*----- PROTECTED REGION ID(CCDSpectrometer::NoiseSubtractionStateAllowed_WRITE) ENABLED START -----*/ + /* clang-format on */ + /* clang-format off */ + /*----- PROTECTED REGION END -----*/ // CCDSpectrometer::NoiseSubtractionStateAllowed_WRITE + + // Not any excluded states for NoiseSubtraction attribute in read access. + /*----- PROTECTED REGION ID(CCDSpectrometer::NoiseSubtractionStateAllowed_READ) ENABLED START -----*/ + /* clang-format on */ + /* clang-format off */ + /*----- PROTECTED REGION END -----*/ // CCDSpectrometer::NoiseSubtractionStateAllowed_READ + return true; +} + +//-------------------------------------------------------- +/** + * Method : CCDSpectrometer::is_GaussFitEnable_allowed() + * Description: Execution allowed for GaussFitEnable attribute + */ +//-------------------------------------------------------- +bool CCDSpectrometer::is_GaussFitEnable_allowed(TANGO_UNUSED(Tango::AttReqType type)) +{ + // Not any excluded states for GaussFitEnable attribute in Write access. + /*----- PROTECTED REGION ID(CCDSpectrometer::GaussFitEnableStateAllowed_WRITE) ENABLED START -----*/ + /* clang-format on */ + /* clang-format off */ + /*----- PROTECTED REGION END -----*/ // CCDSpectrometer::GaussFitEnableStateAllowed_WRITE + + // Not any excluded states for GaussFitEnable attribute in read access. + /*----- PROTECTED REGION ID(CCDSpectrometer::GaussFitEnableStateAllowed_READ) ENABLED START -----*/ + /* clang-format on */ + /* clang-format off */ + /*----- PROTECTED REGION END -----*/ // CCDSpectrometer::GaussFitEnableStateAllowed_READ + return true; +} + +//-------------------------------------------------------- +/** + * Method : CCDSpectrometer::is_FWHMEnable_allowed() + * Description: Execution allowed for FWHMEnable attribute + */ +//-------------------------------------------------------- +bool CCDSpectrometer::is_FWHMEnable_allowed(TANGO_UNUSED(Tango::AttReqType type)) +{ + // Not any excluded states for FWHMEnable attribute in Write access. + /*----- PROTECTED REGION ID(CCDSpectrometer::FWHMEnableStateAllowed_WRITE) ENABLED START -----*/ + /* clang-format on */ + /* clang-format off */ + /*----- PROTECTED REGION END -----*/ // CCDSpectrometer::FWHMEnableStateAllowed_WRITE + + // Not any excluded states for FWHMEnable attribute in read access. + /*----- PROTECTED REGION ID(CCDSpectrometer::FWHMEnableStateAllowed_READ) ENABLED START -----*/ + /* clang-format on */ + /* clang-format off */ + /*----- PROTECTED REGION END -----*/ // CCDSpectrometer::FWHMEnableStateAllowed_READ + return true; +} + +//-------------------------------------------------------- +/** + * Method : CCDSpectrometer::is_GaussFitCenter_allowed() + * Description: Execution allowed for GaussFitCenter attribute + */ +//-------------------------------------------------------- +bool CCDSpectrometer::is_GaussFitCenter_allowed(TANGO_UNUSED(Tango::AttReqType type)) +{ + + // Not any excluded states for GaussFitCenter attribute in read access. + /*----- PROTECTED REGION ID(CCDSpectrometer::GaussFitCenterStateAllowed_READ) ENABLED START -----*/ + /* clang-format on */ + /* clang-format off */ + /*----- PROTECTED REGION END -----*/ // CCDSpectrometer::GaussFitCenterStateAllowed_READ + return true; +} + +//-------------------------------------------------------- +/** + * Method : CCDSpectrometer::is_GaussFitWidth_allowed() + * Description: Execution allowed for GaussFitWidth attribute + */ +//-------------------------------------------------------- +bool CCDSpectrometer::is_GaussFitWidth_allowed(TANGO_UNUSED(Tango::AttReqType type)) +{ + + // Not any excluded states for GaussFitWidth attribute in read access. + /*----- PROTECTED REGION ID(CCDSpectrometer::GaussFitWidthStateAllowed_READ) ENABLED START -----*/ + /* clang-format on */ + /* clang-format off */ + /*----- PROTECTED REGION END -----*/ // CCDSpectrometer::GaussFitWidthStateAllowed_READ + return true; +} + +//-------------------------------------------------------- +/** + * Method : CCDSpectrometer::is_FWHMCenter_allowed() + * Description: Execution allowed for FWHMCenter attribute + */ +//-------------------------------------------------------- +bool CCDSpectrometer::is_FWHMCenter_allowed(TANGO_UNUSED(Tango::AttReqType type)) +{ + + // Not any excluded states for FWHMCenter attribute in read access. + /*----- PROTECTED REGION ID(CCDSpectrometer::FWHMCenterStateAllowed_READ) ENABLED START -----*/ + /* clang-format on */ + /* clang-format off */ + /*----- PROTECTED REGION END -----*/ // CCDSpectrometer::FWHMCenterStateAllowed_READ + return true; +} + +//-------------------------------------------------------- +/** + * Method : CCDSpectrometer::is_FWHMWidth_allowed() + * Description: Execution allowed for FWHMWidth attribute + */ +//-------------------------------------------------------- +bool CCDSpectrometer::is_FWHMWidth_allowed(TANGO_UNUSED(Tango::AttReqType type)) +{ + + // Not any excluded states for FWHMWidth attribute in read access. + /*----- PROTECTED REGION ID(CCDSpectrometer::FWHMWidthStateAllowed_READ) ENABLED START -----*/ + /* clang-format on */ + /* clang-format off */ + /*----- PROTECTED REGION END -----*/ // CCDSpectrometer::FWHMWidthStateAllowed_READ + return true; +} + +//-------------------------------------------------------- +/** + * Method : CCDSpectrometer::is_Center_allowed() + * Description: Execution allowed for Center attribute + */ +//-------------------------------------------------------- +bool CCDSpectrometer::is_Center_allowed(TANGO_UNUSED(Tango::AttReqType type)) +{ + + // Not any excluded states for Center attribute in read access. + /*----- PROTECTED REGION ID(CCDSpectrometer::CenterStateAllowed_READ) ENABLED START -----*/ + /* clang-format on */ + /* clang-format off */ + /*----- PROTECTED REGION END -----*/ // CCDSpectrometer::CenterStateAllowed_READ + return true; +} + +//-------------------------------------------------------- +/** + * Method : CCDSpectrometer::is_Width_allowed() + * Description: Execution allowed for Width attribute + */ +//-------------------------------------------------------- +bool CCDSpectrometer::is_Width_allowed(TANGO_UNUSED(Tango::AttReqType type)) +{ + + // Not any excluded states for Width attribute in read access. + /*----- PROTECTED REGION ID(CCDSpectrometer::WidthStateAllowed_READ) ENABLED START -----*/ + /* clang-format on */ + /* clang-format off */ + /*----- PROTECTED REGION END -----*/ // CCDSpectrometer::WidthStateAllowed_READ + return true; +} + +//-------------------------------------------------------- +/** + * Method : CCDSpectrometer::is_FitType_allowed() + * Description: Execution allowed for FitType attribute + */ +//-------------------------------------------------------- +bool CCDSpectrometer::is_FitType_allowed(TANGO_UNUSED(Tango::AttReqType type)) +{ + // Not any excluded states for FitType attribute in Write access. + /*----- PROTECTED REGION ID(CCDSpectrometer::FitTypeStateAllowed_WRITE) ENABLED START -----*/ + /* clang-format on */ + /* clang-format off */ + /*----- PROTECTED REGION END -----*/ // CCDSpectrometer::FitTypeStateAllowed_WRITE + + // Not any excluded states for FitType attribute in read access. + /*----- PROTECTED REGION ID(CCDSpectrometer::FitTypeStateAllowed_READ) ENABLED START -----*/ + /* clang-format on */ + /* clang-format off */ + /*----- PROTECTED REGION END -----*/ // CCDSpectrometer::FitTypeStateAllowed_READ + return true; +} + +//-------------------------------------------------------- +/** + * Method : CCDSpectrometer::is_FWHMAvg_allowed() + * Description: Execution allowed for FWHMAvg attribute + */ +//-------------------------------------------------------- +bool CCDSpectrometer::is_FWHMAvg_allowed(TANGO_UNUSED(Tango::AttReqType type)) +{ + // Not any excluded states for FWHMAvg attribute in Write access. + /*----- PROTECTED REGION ID(CCDSpectrometer::FWHMAvgStateAllowed_WRITE) ENABLED START -----*/ + /* clang-format on */ + /* clang-format off */ + /*----- PROTECTED REGION END -----*/ // CCDSpectrometer::FWHMAvgStateAllowed_WRITE + + // Not any excluded states for FWHMAvg attribute in read access. + /*----- PROTECTED REGION ID(CCDSpectrometer::FWHMAvgStateAllowed_READ) ENABLED START -----*/ + /* clang-format on */ + /* clang-format off */ + /*----- PROTECTED REGION END -----*/ // CCDSpectrometer::FWHMAvgStateAllowed_READ + return true; +} + +//-------------------------------------------------------- +/** + * Method : CCDSpectrometer::is_NoiseLevel_allowed() + * Description: Execution allowed for NoiseLevel attribute + */ +//-------------------------------------------------------- +bool CCDSpectrometer::is_NoiseLevel_allowed(TANGO_UNUSED(Tango::AttReqType type)) +{ + // Not any excluded states for NoiseLevel attribute in Write access. + /*----- PROTECTED REGION ID(CCDSpectrometer::NoiseLevelStateAllowed_WRITE) ENABLED START -----*/ + /* clang-format on */ + /* clang-format off */ + /*----- PROTECTED REGION END -----*/ // CCDSpectrometer::NoiseLevelStateAllowed_WRITE + + // Not any excluded states for NoiseLevel attribute in read access. + /*----- PROTECTED REGION ID(CCDSpectrometer::NoiseLevelStateAllowed_READ) ENABLED START -----*/ + /* clang-format on */ + /* clang-format off */ + /*----- PROTECTED REGION END -----*/ // CCDSpectrometer::NoiseLevelStateAllowed_READ + return true; +} + +//-------------------------------------------------------- +/** + * Method : CCDSpectrometer::is_DataReferenceFile_allowed() + * Description: Execution allowed for DataReferenceFile attribute + */ +//-------------------------------------------------------- +bool CCDSpectrometer::is_DataReferenceFile_allowed(TANGO_UNUSED(Tango::AttReqType type)) +{ + // Not any excluded states for DataReferenceFile attribute in Write access. + /*----- PROTECTED REGION ID(CCDSpectrometer::DataReferenceFileStateAllowed_WRITE) ENABLED START -----*/ + /* clang-format on */ + /* clang-format off */ + /*----- PROTECTED REGION END -----*/ // CCDSpectrometer::DataReferenceFileStateAllowed_WRITE + + // Not any excluded states for DataReferenceFile attribute in read access. + /*----- PROTECTED REGION ID(CCDSpectrometer::DataReferenceFileStateAllowed_READ) ENABLED START -----*/ + /* clang-format on */ + /* clang-format off */ + /*----- PROTECTED REGION END -----*/ // CCDSpectrometer::DataReferenceFileStateAllowed_READ + return true; +} + +//-------------------------------------------------------- +/** + * Method : CCDSpectrometer::is_AutoExposure_allowed() + * Description: Execution allowed for AutoExposure attribute + */ +//-------------------------------------------------------- +bool CCDSpectrometer::is_AutoExposure_allowed(TANGO_UNUSED(Tango::AttReqType type)) +{ + // Not any excluded states for AutoExposure attribute in Write access. + /*----- PROTECTED REGION ID(CCDSpectrometer::AutoExposureStateAllowed_WRITE) ENABLED START -----*/ + /* clang-format on */ + /* clang-format off */ + /*----- PROTECTED REGION END -----*/ // CCDSpectrometer::AutoExposureStateAllowed_WRITE + + // Not any excluded states for AutoExposure attribute in read access. + /*----- PROTECTED REGION ID(CCDSpectrometer::AutoExposureStateAllowed_READ) ENABLED START -----*/ + /* clang-format on */ + /* clang-format off */ + /*----- PROTECTED REGION END -----*/ // CCDSpectrometer::AutoExposureStateAllowed_READ + return true; +} + +//-------------------------------------------------------- +/** + * Method : CCDSpectrometer::is_RtMode_allowed() + * Description: Execution allowed for RtMode attribute + */ +//-------------------------------------------------------- +bool CCDSpectrometer::is_RtMode_allowed(TANGO_UNUSED(Tango::AttReqType type)) +{ + // Not any excluded states for RtMode attribute in Write access. + /*----- PROTECTED REGION ID(CCDSpectrometer::RtModeStateAllowed_WRITE) ENABLED START -----*/ + /* clang-format on */ + /* clang-format off */ + /*----- PROTECTED REGION END -----*/ // CCDSpectrometer::RtModeStateAllowed_WRITE + + // Not any excluded states for RtMode attribute in read access. + /*----- PROTECTED REGION ID(CCDSpectrometer::RtModeStateAllowed_READ) ENABLED START -----*/ + /* clang-format on */ + /* clang-format off */ + /*----- PROTECTED REGION END -----*/ // CCDSpectrometer::RtModeStateAllowed_READ + return true; +} + +//-------------------------------------------------------- +/** + * Method : CCDSpectrometer::is_IntensityCalibrationEnable_allowed() + * Description: Execution allowed for IntensityCalibrationEnable attribute + */ +//-------------------------------------------------------- +bool CCDSpectrometer::is_IntensityCalibrationEnable_allowed(TANGO_UNUSED(Tango::AttReqType type)) +{ + // Not any excluded states for IntensityCalibrationEnable attribute in Write access. + /*----- PROTECTED REGION ID(CCDSpectrometer::IntensityCalibrationEnableStateAllowed_WRITE) ENABLED START -----*/ + /* clang-format on */ + /* clang-format off */ + /*----- PROTECTED REGION END -----*/ // CCDSpectrometer::IntensityCalibrationEnableStateAllowed_WRITE + + // Not any excluded states for IntensityCalibrationEnable attribute in read access. + /*----- PROTECTED REGION ID(CCDSpectrometer::IntensityCalibrationEnableStateAllowed_READ) ENABLED START -----*/ + /* clang-format on */ + /* clang-format off */ + /*----- PROTECTED REGION END -----*/ // CCDSpectrometer::IntensityCalibrationEnableStateAllowed_READ + return true; +} + +//-------------------------------------------------------- +/** + * Method : CCDSpectrometer::is_Area_allowed() + * Description: Execution allowed for Area attribute + */ +//-------------------------------------------------------- +bool CCDSpectrometer::is_Area_allowed(TANGO_UNUSED(Tango::AttReqType type)) +{ + + // Not any excluded states for Area attribute in read access. + /*----- PROTECTED REGION ID(CCDSpectrometer::AreaStateAllowed_READ) ENABLED START -----*/ + /* clang-format on */ + /* clang-format off */ + /*----- PROTECTED REGION END -----*/ // CCDSpectrometer::AreaStateAllowed_READ + return true; +} + +//-------------------------------------------------------- +/** + * Method : CCDSpectrometer::is_AreaRegion_allowed() + * Description: Execution allowed for AreaRegion attribute + */ +//-------------------------------------------------------- +bool CCDSpectrometer::is_AreaRegion_allowed(TANGO_UNUSED(Tango::AttReqType type)) +{ + // Not any excluded states for AreaRegion attribute in Write access. + /*----- PROTECTED REGION ID(CCDSpectrometer::AreaRegionStateAllowed_WRITE) ENABLED START -----*/ + /* clang-format on */ + /* clang-format off */ + /*----- PROTECTED REGION END -----*/ // CCDSpectrometer::AreaRegionStateAllowed_WRITE + + // Not any excluded states for AreaRegion attribute in read access. + /*----- PROTECTED REGION ID(CCDSpectrometer::AreaRegionStateAllowed_READ) ENABLED START -----*/ + /* clang-format on */ + /* clang-format off */ + /*----- PROTECTED REGION END -----*/ // CCDSpectrometer::AreaRegionStateAllowed_READ + return true; +} + +//-------------------------------------------------------- +/** + * Method : CCDSpectrometer::is_AreaEnable_allowed() + * Description: Execution allowed for AreaEnable attribute + */ +//-------------------------------------------------------- +bool CCDSpectrometer::is_AreaEnable_allowed(TANGO_UNUSED(Tango::AttReqType type)) +{ + // Not any excluded states for AreaEnable attribute in Write access. + /*----- PROTECTED REGION ID(CCDSpectrometer::AreaEnableStateAllowed_WRITE) ENABLED START -----*/ + /* clang-format on */ + /* clang-format off */ + /*----- PROTECTED REGION END -----*/ // CCDSpectrometer::AreaEnableStateAllowed_WRITE + + // Not any excluded states for AreaEnable attribute in read access. + /*----- PROTECTED REGION ID(CCDSpectrometer::AreaEnableStateAllowed_READ) ENABLED START -----*/ + /* clang-format on */ + /* clang-format off */ + /*----- PROTECTED REGION END -----*/ // CCDSpectrometer::AreaEnableStateAllowed_READ + return true; +} + +//-------------------------------------------------------- +/** + * Method : CCDSpectrometer::is_WidthCorrectionEnable_allowed() + * Description: Execution allowed for WidthCorrectionEnable attribute + */ +//-------------------------------------------------------- +bool CCDSpectrometer::is_WidthCorrectionEnable_allowed(TANGO_UNUSED(Tango::AttReqType type)) +{ + // Not any excluded states for WidthCorrectionEnable attribute in Write access. + /*----- PROTECTED REGION ID(CCDSpectrometer::WidthCorrectionEnableStateAllowed_WRITE) ENABLED START -----*/ + /* clang-format on */ + /* clang-format off */ + /*----- PROTECTED REGION END -----*/ // CCDSpectrometer::WidthCorrectionEnableStateAllowed_WRITE + + // Not any excluded states for WidthCorrectionEnable attribute in read access. + /*----- PROTECTED REGION ID(CCDSpectrometer::WidthCorrectionEnableStateAllowed_READ) ENABLED START -----*/ + /* clang-format on */ + /* clang-format off */ + /*----- PROTECTED REGION END -----*/ // CCDSpectrometer::WidthCorrectionEnableStateAllowed_READ + return true; +} + +//-------------------------------------------------------- +/** + * Method : CCDSpectrometer::is_IncrSensitivity_allowed() + * Description: Execution allowed for IncrSensitivity attribute + */ +//-------------------------------------------------------- +bool CCDSpectrometer::is_IncrSensitivity_allowed(TANGO_UNUSED(Tango::AttReqType type)) +{ + // Not any excluded states for IncrSensitivity attribute in Write access. + /*----- PROTECTED REGION ID(CCDSpectrometer::IncrSensitivityStateAllowed_WRITE) ENABLED START -----*/ + /* clang-format on */ + /* clang-format off */ + /*----- PROTECTED REGION END -----*/ // CCDSpectrometer::IncrSensitivityStateAllowed_WRITE + + // Not any excluded states for IncrSensitivity attribute in read access. + /*----- PROTECTED REGION ID(CCDSpectrometer::IncrSensitivityStateAllowed_READ) ENABLED START -----*/ + /* clang-format on */ + /* clang-format off */ + /*----- PROTECTED REGION END -----*/ // CCDSpectrometer::IncrSensitivityStateAllowed_READ + return true; +} + +//-------------------------------------------------------- +/** + * Method : CCDSpectrometer::is_Data_allowed() + * Description: Execution allowed for Data attribute + */ +//-------------------------------------------------------- +bool CCDSpectrometer::is_Data_allowed(TANGO_UNUSED(Tango::AttReqType type)) +{ + + // Not any excluded states for Data attribute in read access. + /*----- PROTECTED REGION ID(CCDSpectrometer::DataStateAllowed_READ) ENABLED START -----*/ + /* clang-format on */ + /* clang-format off */ + /*----- PROTECTED REGION END -----*/ // CCDSpectrometer::DataStateAllowed_READ + return true; +} + +//-------------------------------------------------------- +/** + * Method : CCDSpectrometer::is_NumPixels_allowed() + * Description: Execution allowed for NumPixels attribute + */ +//-------------------------------------------------------- +bool CCDSpectrometer::is_NumPixels_allowed(TANGO_UNUSED(Tango::AttReqType type)) +{ + + // Not any excluded states for NumPixels attribute in read access. + /*----- PROTECTED REGION ID(CCDSpectrometer::NumPixelsStateAllowed_READ) ENABLED START -----*/ + /* clang-format on */ + /* clang-format off */ + /*----- PROTECTED REGION END -----*/ // CCDSpectrometer::NumPixelsStateAllowed_READ + return true; +} + +//-------------------------------------------------------- +/** + * Method : CCDSpectrometer::is_RegionOfInterest_allowed() + * Description: Execution allowed for RegionOfInterest attribute + */ +//-------------------------------------------------------- +bool CCDSpectrometer::is_RegionOfInterest_allowed(TANGO_UNUSED(Tango::AttReqType type)) +{ + // Not any excluded states for RegionOfInterest attribute in Write access. + /*----- PROTECTED REGION ID(CCDSpectrometer::RegionOfInterestStateAllowed_WRITE) ENABLED START -----*/ + /* clang-format on */ + /* clang-format off */ + /*----- PROTECTED REGION END -----*/ // CCDSpectrometer::RegionOfInterestStateAllowed_WRITE + + // Not any excluded states for RegionOfInterest attribute in read access. + /*----- PROTECTED REGION ID(CCDSpectrometer::RegionOfInterestStateAllowed_READ) ENABLED START -----*/ + /* clang-format on */ + /* clang-format off */ + /*----- PROTECTED REGION END -----*/ // CCDSpectrometer::RegionOfInterestStateAllowed_READ + return true; +} + +//-------------------------------------------------------- +/** + * Method : CCDSpectrometer::is_AnalysisRegion_allowed() + * Description: Execution allowed for AnalysisRegion attribute + */ +//-------------------------------------------------------- +bool CCDSpectrometer::is_AnalysisRegion_allowed(TANGO_UNUSED(Tango::AttReqType type)) +{ + // Not any excluded states for AnalysisRegion attribute in Write access. + /*----- PROTECTED REGION ID(CCDSpectrometer::AnalysisRegionStateAllowed_WRITE) ENABLED START -----*/ + /* clang-format on */ + /* clang-format off */ + /*----- PROTECTED REGION END -----*/ // CCDSpectrometer::AnalysisRegionStateAllowed_WRITE + + // Not any excluded states for AnalysisRegion attribute in read access. + /*----- PROTECTED REGION ID(CCDSpectrometer::AnalysisRegionStateAllowed_READ) ENABLED START -----*/ + /* clang-format on */ + /* clang-format off */ + /*----- PROTECTED REGION END -----*/ // CCDSpectrometer::AnalysisRegionStateAllowed_READ + return true; +} + +//-------------------------------------------------------- +/** + * Method : CCDSpectrometer::is_GaussFit_allowed() + * Description: Execution allowed for GaussFit attribute + */ +//-------------------------------------------------------- +bool CCDSpectrometer::is_GaussFit_allowed(TANGO_UNUSED(Tango::AttReqType type)) +{ + + // Not any excluded states for GaussFit attribute in read access. + /*----- PROTECTED REGION ID(CCDSpectrometer::GaussFitStateAllowed_READ) ENABLED START -----*/ + /* clang-format on */ + /* clang-format off */ + /*----- PROTECTED REGION END -----*/ // CCDSpectrometer::GaussFitStateAllowed_READ + return true; +} + +//-------------------------------------------------------- +/** + * Method : CCDSpectrometer::is_FWHM_allowed() + * Description: Execution allowed for FWHM attribute + */ +//-------------------------------------------------------- +bool CCDSpectrometer::is_FWHM_allowed(TANGO_UNUSED(Tango::AttReqType type)) +{ + + // Not any excluded states for FWHM attribute in read access. + /*----- PROTECTED REGION ID(CCDSpectrometer::FWHMStateAllowed_READ) ENABLED START -----*/ + /* clang-format on */ + /* clang-format off */ + /*----- PROTECTED REGION END -----*/ // CCDSpectrometer::FWHMStateAllowed_READ + return true; +} + +//-------------------------------------------------------- +/** + * Method : CCDSpectrometer::is_GaussReference_allowed() + * Description: Execution allowed for GaussReference attribute + */ +//-------------------------------------------------------- +bool CCDSpectrometer::is_GaussReference_allowed(TANGO_UNUSED(Tango::AttReqType type)) +{ + // Not any excluded states for GaussReference attribute in Write access. + /*----- PROTECTED REGION ID(CCDSpectrometer::GaussReferenceStateAllowed_WRITE) ENABLED START -----*/ + /* clang-format on */ + /* clang-format off */ + /*----- PROTECTED REGION END -----*/ // CCDSpectrometer::GaussReferenceStateAllowed_WRITE + + // Not any excluded states for GaussReference attribute in read access. + /*----- PROTECTED REGION ID(CCDSpectrometer::GaussReferenceStateAllowed_READ) ENABLED START -----*/ + /* clang-format on */ + /* clang-format off */ + /*----- PROTECTED REGION END -----*/ // CCDSpectrometer::GaussReferenceStateAllowed_READ + return true; +} + +//-------------------------------------------------------- +/** + * Method : CCDSpectrometer::is_DataReference_allowed() + * Description: Execution allowed for DataReference attribute + */ +//-------------------------------------------------------- +bool CCDSpectrometer::is_DataReference_allowed(TANGO_UNUSED(Tango::AttReqType type)) +{ + // Not any excluded states for DataReference attribute in Write access. + /*----- PROTECTED REGION ID(CCDSpectrometer::DataReferenceStateAllowed_WRITE) ENABLED START -----*/ + /* clang-format on */ + /* clang-format off */ + /*----- PROTECTED REGION END -----*/ // CCDSpectrometer::DataReferenceStateAllowed_WRITE + + // Not any excluded states for DataReference attribute in read access. + /*----- PROTECTED REGION ID(CCDSpectrometer::DataReferenceStateAllowed_READ) ENABLED START -----*/ + /* clang-format on */ + /* clang-format off */ + /*----- PROTECTED REGION END -----*/ // CCDSpectrometer::DataReferenceStateAllowed_READ + return true; +} + +//-------------------------------------------------------- +/** + * Method : CCDSpectrometer::is_IntensityCalibration_allowed() + * Description: Execution allowed for IntensityCalibration attribute + */ +//-------------------------------------------------------- +bool CCDSpectrometer::is_IntensityCalibration_allowed(TANGO_UNUSED(Tango::AttReqType type)) +{ + // Not any excluded states for IntensityCalibration attribute in Write access. + /*----- PROTECTED REGION ID(CCDSpectrometer::IntensityCalibrationStateAllowed_WRITE) ENABLED START -----*/ + /* clang-format on */ + /* clang-format off */ + /*----- PROTECTED REGION END -----*/ // CCDSpectrometer::IntensityCalibrationStateAllowed_WRITE + + // Not any excluded states for IntensityCalibration attribute in read access. + /*----- PROTECTED REGION ID(CCDSpectrometer::IntensityCalibrationStateAllowed_READ) ENABLED START -----*/ + /* clang-format on */ + /* clang-format off */ + /*----- PROTECTED REGION END -----*/ // CCDSpectrometer::IntensityCalibrationStateAllowed_READ + return true; +} + +//-------------------------------------------------------- +/** + * Method : CCDSpectrometer::is_NoiseProfile_allowed() + * Description: Execution allowed for NoiseProfile attribute + */ +//-------------------------------------------------------- +bool CCDSpectrometer::is_NoiseProfile_allowed(TANGO_UNUSED(Tango::AttReqType type)) +{ + + // Not any excluded states for NoiseProfile attribute in read access. + /*----- PROTECTED REGION ID(CCDSpectrometer::NoiseProfileStateAllowed_READ) ENABLED START -----*/ + /* clang-format on */ + /* clang-format off */ + /*----- PROTECTED REGION END -----*/ // CCDSpectrometer::NoiseProfileStateAllowed_READ + return true; +} + +//-------------------------------------------------------- +/** + * Method : CCDSpectrometer::is_Wave_allowed() + * Description: Execution allowed for Wave attribute + */ +//-------------------------------------------------------- +bool CCDSpectrometer::is_Wave_allowed(TANGO_UNUSED(Tango::AttReqType type)) +{ + + // Not any excluded states for Wave attribute in read access. + /*----- PROTECTED REGION ID(CCDSpectrometer::WaveStateAllowed_READ) ENABLED START -----*/ + /* clang-format on */ + /* clang-format off */ + /*----- PROTECTED REGION END -----*/ // CCDSpectrometer::WaveStateAllowed_READ + return true; +} + +//-------------------------------------------------------- +/** + * Method : CCDSpectrometer::is_Lambda_allowed() + * Description: Execution allowed for Lambda attribute + */ +//-------------------------------------------------------- +bool CCDSpectrometer::is_Lambda_allowed(TANGO_UNUSED(Tango::AttReqType type)) +{ + + // Not any excluded states for Lambda attribute in read access. + /*----- PROTECTED REGION ID(CCDSpectrometer::LambdaStateAllowed_READ) ENABLED START -----*/ + /* clang-format on */ + /* clang-format off */ + /*----- PROTECTED REGION END -----*/ // CCDSpectrometer::LambdaStateAllowed_READ + return true; +} + + +//================================================= +// Commands Allowed Methods +//================================================= + +//-------------------------------------------------------- +/** + * Method : CCDSpectrometer::is_Start_allowed() + * Description: Execution allowed for Start attribute + */ +//-------------------------------------------------------- +bool CCDSpectrometer::is_Start_allowed(TANGO_UNUSED(const CORBA::Any &any)) +{ + // Not any excluded states for Start command. + /*----- PROTECTED REGION ID(CCDSpectrometer::StartStateAllowed) ENABLED START -----*/ + /* clang-format on */ + /* clang-format off */ + /*----- PROTECTED REGION END -----*/ // CCDSpectrometer::StartStateAllowed + return true; +} + +//-------------------------------------------------------- +/** + * Method : CCDSpectrometer::is_Stop_allowed() + * Description: Execution allowed for Stop attribute + */ +//-------------------------------------------------------- +bool CCDSpectrometer::is_Stop_allowed(TANGO_UNUSED(const CORBA::Any &any)) +{ + // Not any excluded states for Stop command. + /*----- PROTECTED REGION ID(CCDSpectrometer::StopStateAllowed) ENABLED START -----*/ + /* clang-format on */ + /* clang-format off */ + /*----- PROTECTED REGION END -----*/ // CCDSpectrometer::StopStateAllowed + return true; +} + +//-------------------------------------------------------- +/** + * Method : CCDSpectrometer::is_Reset_allowed() + * Description: Execution allowed for Reset attribute + */ +//-------------------------------------------------------- +bool CCDSpectrometer::is_Reset_allowed(TANGO_UNUSED(const CORBA::Any &any)) +{ + // Not any excluded states for Reset command. + /*----- PROTECTED REGION ID(CCDSpectrometer::ResetStateAllowed) ENABLED START -----*/ + /* clang-format on */ + /* clang-format off */ + /*----- PROTECTED REGION END -----*/ // CCDSpectrometer::ResetStateAllowed + return true; +} + +//-------------------------------------------------------- +/** + * Method : CCDSpectrometer::is_StartSingle_allowed() + * Description: Execution allowed for StartSingle attribute + */ +//-------------------------------------------------------- +bool CCDSpectrometer::is_StartSingle_allowed(TANGO_UNUSED(const CORBA::Any &any)) +{ + // Not any excluded states for StartSingle command. + /*----- PROTECTED REGION ID(CCDSpectrometer::StartSingleStateAllowed) ENABLED START -----*/ + /* clang-format on */ + /* clang-format off */ + /*----- PROTECTED REGION END -----*/ // CCDSpectrometer::StartSingleStateAllowed + return true; +} + +//-------------------------------------------------------- +/** + * Method : CCDSpectrometer::is_StartContinuous_allowed() + * Description: Execution allowed for StartContinuous attribute + */ +//-------------------------------------------------------- +bool CCDSpectrometer::is_StartContinuous_allowed(TANGO_UNUSED(const CORBA::Any &any)) +{ + // Not any excluded states for StartContinuous command. + /*----- PROTECTED REGION ID(CCDSpectrometer::StartContinuousStateAllowed) ENABLED START -----*/ + /* clang-format on */ + /* clang-format off */ + /*----- PROTECTED REGION END -----*/ // CCDSpectrometer::StartContinuousStateAllowed + return true; +} + +//-------------------------------------------------------- +/** + * Method : CCDSpectrometer::is_GetLastData_allowed() + * Description: Execution allowed for GetLastData attribute + */ +//-------------------------------------------------------- +bool CCDSpectrometer::is_GetLastData_allowed(TANGO_UNUSED(const CORBA::Any &any)) +{ + // Not any excluded states for GetLastData command. + /*----- PROTECTED REGION ID(CCDSpectrometer::GetLastDataStateAllowed) ENABLED START -----*/ + /* clang-format on */ + /* clang-format off */ + /*----- PROTECTED REGION END -----*/ // CCDSpectrometer::GetLastDataStateAllowed + return true; +} + +//-------------------------------------------------------- +/** + * Method : CCDSpectrometer::is_AcquireNoise_allowed() + * Description: Execution allowed for AcquireNoise attribute + */ +//-------------------------------------------------------- +bool CCDSpectrometer::is_AcquireNoise_allowed(TANGO_UNUSED(const CORBA::Any &any)) +{ + // Not any excluded states for AcquireNoise command. + /*----- PROTECTED REGION ID(CCDSpectrometer::AcquireNoiseStateAllowed) ENABLED START -----*/ + /* clang-format on */ + /* clang-format off */ + /*----- PROTECTED REGION END -----*/ // CCDSpectrometer::AcquireNoiseStateAllowed + return true; +} + +//-------------------------------------------------------- +/** + * Method : CCDSpectrometer::is_SaveReferenceData_allowed() + * Description: Execution allowed for SaveReferenceData attribute + */ +//-------------------------------------------------------- +bool CCDSpectrometer::is_SaveReferenceData_allowed(TANGO_UNUSED(const CORBA::Any &any)) +{ + // Not any excluded states for SaveReferenceData command. + /*----- PROTECTED REGION ID(CCDSpectrometer::SaveReferenceDataStateAllowed) ENABLED START -----*/ + /* clang-format on */ + /* clang-format off */ + /*----- PROTECTED REGION END -----*/ // CCDSpectrometer::SaveReferenceDataStateAllowed + return true; +} + +//-------------------------------------------------------- +/** + * Method : CCDSpectrometer::is_GetData_allowed() + * Description: Execution allowed for GetData attribute + */ +//-------------------------------------------------------- +bool CCDSpectrometer::is_GetData_allowed(TANGO_UNUSED(const CORBA::Any &any)) +{ + // Not any excluded states for GetData command. + /*----- PROTECTED REGION ID(CCDSpectrometer::GetDataStateAllowed) ENABLED START -----*/ + /* clang-format on */ + /* clang-format off */ + /*----- PROTECTED REGION END -----*/ // CCDSpectrometer::GetDataStateAllowed + return true; +} + +//-------------------------------------------------------- +/** + * Method : CCDSpectrometer::is_GetGaussFitCenter_allowed() + * Description: Execution allowed for GetGaussFitCenter attribute + */ +//-------------------------------------------------------- +bool CCDSpectrometer::is_GetGaussFitCenter_allowed(TANGO_UNUSED(const CORBA::Any &any)) +{ + // Not any excluded states for GetGaussFitCenter command. + /*----- PROTECTED REGION ID(CCDSpectrometer::GetGaussFitCenterStateAllowed) ENABLED START -----*/ + /* clang-format on */ + /* clang-format off */ + /*----- PROTECTED REGION END -----*/ // CCDSpectrometer::GetGaussFitCenterStateAllowed + return true; +} + +//-------------------------------------------------------- +/** + * Method : CCDSpectrometer::is_GetGaussFitWidth_allowed() + * Description: Execution allowed for GetGaussFitWidth attribute + */ +//-------------------------------------------------------- +bool CCDSpectrometer::is_GetGaussFitWidth_allowed(TANGO_UNUSED(const CORBA::Any &any)) +{ + // Not any excluded states for GetGaussFitWidth command. + /*----- PROTECTED REGION ID(CCDSpectrometer::GetGaussFitWidthStateAllowed) ENABLED START -----*/ + /* clang-format on */ + /* clang-format off */ + /*----- PROTECTED REGION END -----*/ // CCDSpectrometer::GetGaussFitWidthStateAllowed + return true; +} + +//-------------------------------------------------------- +/** + * Method : CCDSpectrometer::is_GetFWHMCenter_allowed() + * Description: Execution allowed for GetFWHMCenter attribute + */ +//-------------------------------------------------------- +bool CCDSpectrometer::is_GetFWHMCenter_allowed(TANGO_UNUSED(const CORBA::Any &any)) +{ + // Not any excluded states for GetFWHMCenter command. + /*----- PROTECTED REGION ID(CCDSpectrometer::GetFWHMCenterStateAllowed) ENABLED START -----*/ + /* clang-format on */ + /* clang-format off */ + /*----- PROTECTED REGION END -----*/ // CCDSpectrometer::GetFWHMCenterStateAllowed + return true; +} + +//-------------------------------------------------------- +/** + * Method : CCDSpectrometer::is_GetFWHMWidth_allowed() + * Description: Execution allowed for GetFWHMWidth attribute + */ +//-------------------------------------------------------- +bool CCDSpectrometer::is_GetFWHMWidth_allowed(TANGO_UNUSED(const CORBA::Any &any)) +{ + // Not any excluded states for GetFWHMWidth command. + /*----- PROTECTED REGION ID(CCDSpectrometer::GetFWHMWidthStateAllowed) ENABLED START -----*/ + /* clang-format on */ + /* clang-format off */ + /*----- PROTECTED REGION END -----*/ // CCDSpectrometer::GetFWHMWidthStateAllowed + return true; +} + +//-------------------------------------------------------- +/** + * Method : CCDSpectrometer::is_ExportWavelength_allowed() + * Description: Execution allowed for ExportWavelength attribute + */ +//-------------------------------------------------------- +bool CCDSpectrometer::is_ExportWavelength_allowed(TANGO_UNUSED(const CORBA::Any &any)) +{ + // Not any excluded states for ExportWavelength command. + /*----- PROTECTED REGION ID(CCDSpectrometer::ExportWavelengthStateAllowed) ENABLED START -----*/ + /* clang-format on */ + /* clang-format off */ + /*----- PROTECTED REGION END -----*/ // CCDSpectrometer::ExportWavelengthStateAllowed + return true; +} + +//-------------------------------------------------------- +/** + * Method : CCDSpectrometer::is_GetArea_allowed() + * Description: Execution allowed for GetArea attribute + */ +//-------------------------------------------------------- +bool CCDSpectrometer::is_GetArea_allowed(TANGO_UNUSED(const CORBA::Any &any)) +{ + // Not any excluded states for GetArea command. + /*----- PROTECTED REGION ID(CCDSpectrometer::GetAreaStateAllowed) ENABLED START -----*/ + /* clang-format on */ + /* clang-format off */ + /*----- PROTECTED REGION END -----*/ // CCDSpectrometer::GetAreaStateAllowed + return true; +} + +//-------------------------------------------------------- +/** + * Method : CCDSpectrometer::is_GetWave_allowed() + * Description: Execution allowed for GetWave attribute + */ +//-------------------------------------------------------- +bool CCDSpectrometer::is_GetWave_allowed(TANGO_UNUSED(const CORBA::Any &any)) +{ + // Not any excluded states for GetWave command. + /*----- PROTECTED REGION ID(CCDSpectrometer::GetWaveStateAllowed) ENABLED START -----*/ + /* clang-format on */ + /* clang-format off */ + /*----- PROTECTED REGION END -----*/ // CCDSpectrometer::GetWaveStateAllowed + return true; +} + +//-------------------------------------------------------- +/** + * Method : CCDSpectrometer::is_GetLambda_allowed() + * Description: Execution allowed for GetLambda attribute + */ +//-------------------------------------------------------- +bool CCDSpectrometer::is_GetLambda_allowed(TANGO_UNUSED(const CORBA::Any &any)) +{ + // Not any excluded states for GetLambda command. + /*----- PROTECTED REGION ID(CCDSpectrometer::GetLambdaStateAllowed) ENABLED START -----*/ + /* clang-format on */ + /* clang-format off */ + /*----- PROTECTED REGION END -----*/ // CCDSpectrometer::GetLambdaStateAllowed + return true; +} + + +/*----- PROTECTED REGION ID(CCDSpectrometer::CCDSpectrometerStateAllowed.AdditionalMethods) ENABLED START -----*/ +/* clang-format on */ +// Additional Methods +/* clang-format off */ +/*----- PROTECTED REGION END -----*/ // CCDSpectrometer::CCDSpectrometerStateAllowed.AdditionalMethods + +} // End of namespace diff --git a/src/ClassFactory.cpp b/src/ClassFactory.cpp new file mode 100644 index 0000000..0a8e98e --- /dev/null +++ b/src/ClassFactory.cpp @@ -0,0 +1,52 @@ +/*----- PROTECTED REGION ID(CCDSpectrometer::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 : CCDSpectrometer +// +// This file is part of Tango device class. +// +// Tango is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// Tango is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with Tango. If not, see <http://www.gnu.org/licenses/>. +// +// +// +//============================================================================= +// This file is generated by POGO +// (Program Obviously used to Generate tango Object) +//============================================================================= + +#include <tango.h> +#include "CCDSpectrometerClass.h" + +// Add class header files if needed + + +/** + * Create CCDSpectrometer Class singleton and store it in DServer object. + */ + +void Tango::DServer::class_factory() +{ + // Add method class init if needed + add_class(CCDSpectrometer_ns::CCDSpectrometerClass::init("CCDSpectrometer")); +} +/* clang-format off */ +/*----- PROTECTED REGION END -----*/ // CCDSpectrometer::ClassFactory.cpp diff --git a/src/main.cpp b/src/main.cpp new file mode 100644 index 0000000..5d2bd93 --- /dev/null +++ b/src/main.cpp @@ -0,0 +1,88 @@ +/*----- PROTECTED REGION ID(CCDSpectrometer::main.cpp) ENABLED START -----*/ +/* clang-format on */ +//============================================================================= +// +// file : main.cpp +// +// description : C++ source for the CCDSpectrometer device server main. +// The main rule is to initialize (and create) the Tango +// system and to create the DServerClass singleton. +// The main should be the same for every Tango device server. +// +// project : CCDSpectrometer +// +// This file is part of Tango device class. +// +// Tango is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// Tango is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with Tango. If not, see <http://www.gnu.org/licenses/>. +// +// +// +//============================================================================= +// This file is generated by POGO +// (Program Obviously used to Generate tango Object) +//============================================================================= +#include <tango.h> + +// Check if crash reporting is used. +#if defined(ENABLE_CRASH_REPORT) +# include <crashreporting/crash_report.h> +#else +# define DECLARE_CRASH_HANDLER +# define INSTALL_CRASH_HANDLER +#endif + +DECLARE_CRASH_HANDLER + +int main(int argc,char *argv[]) +{ + INSTALL_CRASH_HANDLER + Tango::Util *tg = nullptr; + try + { + // Initialize 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 -----*/ // CCDSpectrometer::main.cpp diff --git a/src/readthread.cpp b/src/readthread.cpp new file mode 100644 index 0000000..9e5ddfd --- /dev/null +++ b/src/readthread.cpp @@ -0,0 +1,1098 @@ +// +// file : readthread.cpp +// +// description : ramping thread +// +// +// copyleft : Sincrotrone Trieste S.C.p.A. +// Strada Statale 14 - km 163,5 in AREA Science Park +// 34012 Basovizza, Trieste ITALY +// + +#include "readthread.h" +#include "CCDSpectrometer.h" +#include <math.h> +#include <iomanip> //used for debug dump of db +#ifdef HAVE_RNM +#include "k_rnmshare.h" +#endif + +namespace CCDSpectrometer_ns +{ + +//+------------------------------------------------------------------ +// +// method: readthread::readthread() +// +// description: readthread constructor +// +//------------------------------------------------------------------- +//readthread::readthread(Tango::DeviceImpl* devImpl):Tango::LogAdapter(devImpl),cond(&mut) +readthread::readthread(Tango::DeviceImpl* devImpl):Tango::LogAdapter(devImpl) +{ + DEBUG_STREAM << "readthread::readthread(): constructor..." << endl; + device = devImpl; + waitflag = true; + last_camera_counter = 0; +#ifdef HAVE_RNM + int ret = rnmshare_init(0); +#endif +} + +//+------------------------------------------------------------------ +// +// method: readthread::~readthread() +// +// description: readthread destructor +// +//------------------------------------------------------------------- +readthread::~readthread() +{ + DEBUG_STREAM << "readthread::~readthread(): destructor... !" << endl; +#ifdef HAVE_RNM + rnmshare_deinit(); +#endif +} +#if 0 +union +{ + uint16_t value; + uint8_t data[2]; +} chat_to_int16; +#endif + + +string dump_hex(const vector<unsigned char> &data) +{ + stringstream mesg_hex; + + for (unsigned int i=0; i<data.size(); ++i) { + mesg_hex << setw(2) << setfill('0') + << hex << (int)data[i] << " "; + } + + return mesg_hex.str(); +} + + +//+------------------------------------------------------------------ +// +// method: readthread::run() +// +// description: Run +// +//------------------------------------------------------------------- +void readthread::run(void *) +{ + INFO_STREAM << "readthread::run(): running... !" << endl; + /*int pausesec,pausenano,pausesec_dfl,pausenano_dfl, + cnt_err = 0, + max_cnt_err = 3, + ret;*/ + pausesec = 1; + pausenano = 0; + //mutex_sleep->unlock(); + double *pNoiseData=NULL; + int flag; + + unsigned long counter =0; + abortflag = false; + CCDSpectrometer *_device = static_cast<CCDSpectrometer *>(device); + + INFO_STREAM << "readthread::run(): before while(!abortflag... !" << endl; + while (!abortflag/* && !_device->abortflag*/) + { + DEBUG_STREAM << "readthread::run(): pausasec="<<pausesec<<" init_live_mode="<<(int)_device->init_live_mode<< " live_mode="<<_device->live_mode<<" abortflag="<<(int)abortflag<<endl; + //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++// + //+++++++++++++++++++++++++++++INIT MODE+++++++++++++++++++++++++++++++// + //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++// + if(_device->init_live_mode || _device->init_measure_mode || _device->init_acquire_noise_mode) + { + { + Tango::DevLong num_pixel = _device->numPixel;//1280;//TODO: read num pixel!! + //_device->dp->read_attribute()>>num_pixel;//TODO: read num pixel!! + _device->numPixel = num_pixel;//TODO: read num pixel!! + + DEBUG_STREAM << "readthread::run() allocating for Data size=" << ((int)_device->numPixel)/**((int)_device->m_usbCCD.m_nNumReadOuts)*/ << endl; + if((!_device->init_acquire_noise_mode) && _device->pLiveData) + { + delete [] _device->pLiveData; + _device->pLiveData = NULL; + } + if(!_device->init_acquire_noise_mode) + { + _device->pLiveData = new double[((int)_device->numPixel)/**((int)_device->m_usbCCD.m_nNumReadOuts)*/]; + memset(_device->pLiveData,0,((int)_device->numPixel)*sizeof(double)); + } + else + { + pNoiseData = new double[((int)_device->numPixel)/**((int)_device->m_usbCCD.m_nNumReadOuts)*/ * _device->noise_frames]; + memset(pNoiseData,0,((int)_device->numPixel)* _device->noise_frames*sizeof(double)); + + } + //DEBUG_STREAM << "readthread::run() allocated for Data size=" << ((int)_device->numPixel)*((int)_device->m_usbCCD.m_nNumReadOuts) << endl; + /*if(_device->nFramesBuffered > 0) + { + _device->pFrameBuffer = new DWORD[_device->numPixel * _device->nFramesBuffered]; + memset(_device->pFrameBuffer,0,_device->numPixel * _device->nFramesBuffered * sizeof(DWORD)); + }*/ + //mutex_sleep->lock(); + pausesec = 0; + //pausenano = 1000000; //TODO: 1 msec, it should depend on freq of CCD + //pausenano = (*(_device->attr_ExposureTime_read) * *(_device->attr_NumReadouts_read) * 300000); //TODO: 10 msec, it should depend on freq of CCD + pausenano = 0; + DEBUG_STREAM << "readthread::run(): setting sleep_time(ns)="<<pausenano<<endl; + //mutex_sleep->unlock(); + _device->init_live_mode = false; + _device->init_measure_mode = false; + _device->init_acquire_noise_mode = false; + counter =0; + } + } + //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++// + //+++++++++++++++++++++++++++ACQUIRE MODE++++++++++++++++++++++++++++++// + //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++// + if(_device->live_mode || _device->measure_mode || _device->stop_mode) + { + //DWORD stat; + //DEBUG_STREAM << "readthread::run(): before GetMeasStatus"<<endl; + //_device->m_usbCCD.GetMeasStatus(&stat); + //if(stat == STATUS_DATA_READY) + + //if(_device->m_usbCCD.m_nNumReadOuts == 1) + if(1) + { + if(*(_device->attr_NoiseSubtraction_read)) + { + //DEBUG_STREAM << "readthread::run(): before GetData readouts=1, noise subtraction"<<endl; + if(counter==0 || (*(_device->attr_SyncMode_read) != 0)) + flag = PrepareMeas(); + else + flag = 0; + if(flag==0) + flag = Measure(_device->pLiveData); + if(flag < 0) + { + if(flag==-1) + { + _device->set_state(Tango::FAULT); + //_device->set_status("Communication error"); + //_device->disconnect_device(); + /*if(_device->live_mode) + _device->init_live_mode = true; + if(_device->measure_mode) + _device->init_measure_mode = true;*/ + _device->live_mode = false; + _device->init_live_mode = false; + _device->measure_mode = false; + _device->init_measure_mode = false; + _device->stop_mode = false; + pausesec = 1; + pausenano = 0; + _device->conn_status = false; + } + else if(flag==-2) + { + _device->set_state(Tango::OFF); + } + continue; + } + else if(flag > 0) + { + if(_device->stop_mode) + { + _device->live_mode=false; + _device->measure_mode=false; + } + else + { + _device->set_state(Tango::ALARM); + } + //_device->set_status("Trigger Missing"); + continue; + } + else + { + if(_device->get_state()==Tango::ALARM || _device->get_state()==Tango::OFF) + { + _device->set_state(Tango::RUNNING); + _device->set_status("Continuous Mode"); + } + } + for(unsigned int j=0; j < _device->numPixel; j++) + { + //_device->pLiveData[j] = (((int)_device->pLiveData[j] - _device->noise_level) > 0) ? ((int)_device->pLiveData[j] - _device->noise_level) : 0; + if(*_device->attr_IntensityCalibrationEnable_read) + { + _device->pLiveData_avg[j] = (_device->pLiveData[j] - _device->pNoiseMask_avg[j]); + if(_device->pLiveData_avg[j] > 0) + _device->pLiveData_avg[j] *= _device->attr_IntensityCalibration_read[j]; + } + else + { + _device->pLiveData_avg[j] = (_device->pLiveData[j] - _device->pNoiseMask_avg[j]); + } + /*//TTTTTTTTTTTTTTTTEEEEEEEEEEEEEEEEESSSSSSSSSSSSSSTTTTTTTTTTTTTTTTTTTTTTTTTTTT: generate fake gaussian + double base = 0 + (-1 + 2*(counter%2)) * counter%101; + double amp =15000 + (1 - 2*(counter%2)) * counter%547; + double center = 350 + (-1 + 2*(counter%2)) * counter%3; + double width = 10 + (1 - 2*(counter%2)) * counter%2; + _device->pLiveData_avg[j] += base + amp*exp((-0.5) * pow((_device->x_values[j]-center)/width,2));*/ + } + //memcpy(_device->pLiveData_avg,_device->pLiveData,_device->numPixel * sizeof(DWORD)); + } + else + { + //DEBUG_STREAM << "readthread::run(): before GetData readouts=1"<<endl; + if(counter==0 || (*(_device->attr_SyncMode_read) != 0)) + flag = PrepareMeas(); + else + flag = 0; + if(flag==0) + flag = Measure(_device->pLiveData); + if(flag < 0) + { + if(flag==-1) + { + _device->set_state(Tango::FAULT); + //_device->set_status("Communication error"); + //_device->disconnect_device(); + /*if(_device->live_mode) + _device->init_live_mode = true; + if(_device->measure_mode) + _device->init_measure_mode = true;*/ + _device->live_mode = false; + _device->init_live_mode = false; + _device->measure_mode = false; + _device->init_measure_mode = false; + _device->stop_mode = false; + pausesec = 1; + pausenano = 0; + _device->conn_status = false; + } + else if(flag==-2) + { + _device->set_state(Tango::OFF); + } + continue; + } + else if(flag > 0) + { + if(_device->stop_mode) + { + _device->live_mode=false; + _device->measure_mode=false; + } + else + { + _device->set_state(Tango::ALARM); + } + //_device->set_status("Trigger Missing"); + continue; + } + else + { + if(_device->get_state()==Tango::ALARM || _device->get_state()==Tango::OFF) + { + _device->set_state(Tango::RUNNING); + _device->set_status("Continuous Mode"); + } + } + if(*_device->attr_IntensityCalibrationEnable_read) + { + for(unsigned int j=0; j < _device->numPixel; j++) + _device->pLiveData_avg[j] = (_device->attr_IntensityCalibration_read[j] * _device->pLiveData[j]); + } + else + { + memcpy(_device->pLiveData_avg,_device->pLiveData,_device->numPixel * sizeof(double)); + } + } + /*for(unsigned int i=0; i<_device->numPixel; i++) + { + DEBUG_STREAM << "OceanOptics::OceanOptics(): _device->pLiveData["<<i<<"]=" << _device->pLiveData[i] << endl; + }*/ + DEBUG_STREAM << __func__<<": READ DATA" << endl; + clock_gettime(CLOCK_MONOTONIC,&_device->last_read); + } + /*else + { + //DEBUG_STREAM << "readthread::run(): before GetData readouts>1"<<endl; + _device->m_usbCCD.GetData(_device->pLiveData); + //memset(&(_device->pLiveData_avg[0]), 0,_device->numPixel*sizeof(DWORD)); + + //for every pixel + for(unsigned int j=0; j < _device->numPixel; j++) + { + _device->pLiveData_avg[j] = 0; + //sum value in this pixel point for every frame + for(int i=0; i < _device->m_usbCCD.m_nNumReadOuts; i++) + { + _device->pLiveData_avg[j] += _device->pLiveData[i * _device->numPixel + j]; + } + //divide the sum per the number of frames + _device->pLiveData_avg[j] = (DWORD)((((double)_device->pLiveData_avg[j])/((double)_device->m_usbCCD.m_nNumReadOuts)) + 0.5); //+0.5 to round and not truncate + if(*(_device->attr_NoiseSubtraction_read)) + { + //_device->pLiveData_avg[j] = (((int)_device->pLiveData_avg[j] - _device->noise_level) > 0) ? ((int)_device->pLiveData_avg[j] - _device->noise_level) : 0; + _device->pLiveData_avg[j] = (int)_device->pLiveData_avg[j] - _device->noise_level; + } + } + }*/ + if(_device->nFramesBuffered > 0) + { + //copy the average frame + memcpy(&(_device->pFrameBuffer[_device->numPixel * _device->FrameBufferIndex]), &(_device->pLiveData_avg[0]),_device->numPixel*sizeof(double)); + ////update index in buffer once for all readout frames + _device->FrameBufferIndex = (_device->FrameBufferIndex + 1) % _device->nFramesBuffered; + } + + struct timeval buf_time; + gettimeofday(&buf_time,NULL); + int32_t buf_bunch_num; + + + if(*_device->attr_RtMode_read) + { +#ifdef HAVE_RNM + char check; + rnm_bunch_number_get_value(0, 1, &buf_bunch_num, &check); + //buf_bunch_num = fit_counter; +#endif + if(old_bunch_number != buf_bunch_num-1) + { + //INFO_STREAM << "readthread::run(): BUNCH error: previous="<<old_bunch_number<<" present="<<bunch_number; + //cout << "--------------------------------------->>>>>>>>>>>>>>>>>>>>>>>>> BUNCH error: previous="<<old_bunch_number<<" present="<<bunch_number<<"<<<<<<<<<<<<<<<<<<<<<<<<<---------------------------"<<endl; + INFO_STREAM << "--->>> BUNCH error: previous="<<old_bunch_number<<" present="<<buf_bunch_num<<"<<<---"<<endl; + old_bunch_number = buf_bunch_num; + } + else + { + old_bunch_number++; + } + } + else + { + buf_bunch_num = fit_counter; + } + //cout << __func__<<": before push_data data[0]="<<_device->pLiveData_avg[0]<<" data[1]="<<_device->pLiveData_avg[1]<<" data[2]="<<_device->pLiveData_avg[2]<<" data[1000]="<<_device->pLiveData_avg[1000]<<" data[1001]="<<_device->pLiveData_avg[1001]<<" data[1002]="<<_device->pLiveData_avg[1002]<<endl; + tbuffer::_data_array<double> val_array(_device->pLiveData_avg, _device->numPixel); + _device->tbuf_array.push_data(&val_array,buf_time,buf_bunch_num); + tbuffer::_data_array<double> val_array_w(&(_device->pLiveData_avg[0 + _device->RegionOfInterestStartPix]), _device->RegionOfInterestEndPix - _device->RegionOfInterestStartPix + 1); + _device->tbuf_array_w.push_data(&val_array_w,buf_time,buf_bunch_num); + tbuffer::_data_array<double> val_array_l(&(_device->x_values[0 + _device->RegionOfInterestStartPix]), _device->RegionOfInterestEndPix - _device->RegionOfInterestStartPix + 1); + _device->tbuf_array_l.push_data(&val_array_l,buf_time,buf_bunch_num); + //^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + //::::::::::::::::::::::: FWHM processing ::::::::::::::::::::::: + //________________________________________________________________ + if(*(_device->attr_FWHMEnable_read)) + { + size_t x_peak, x_half_min, x_half_max; + double y_peak; + _device->fwhm_calculate(_device->pLiveData_avg,_device->numPixel, + _device->AnalysisRegionStartPix,_device->AnalysisRegionEndPix, + 1, //average on 1 frame + *(_device->attr_FWHMAvg_read), //average between 3 adjacent values + x_peak, y_peak, + x_half_min, x_half_max); + _device->attr_FWHM_read[0]=_device->x_values[x_peak]; + _device->attr_FWHM_read[1]=y_peak; + if(*(_device->attr_WidthCorrectionEnable_read)) + { + _device->attr_FWHM_read[2]=sqrt((_device->x_values[x_half_max] - _device->x_values[x_half_min])*(_device->x_values[x_half_max] - _device->x_values[x_half_min]) + _device->widthCorrection*_device->widthCorrection); + } + else + { + _device->attr_FWHM_read[2]=_device->x_values[x_half_max] - _device->x_values[x_half_min]; + } + *(_device->attr_FWHMCenter_read) = _device->attr_FWHM_read[0]; + *(_device->attr_FWHMWidth_read) = _device->attr_FWHM_read[2]; + double val_buff; + val_buff = *(_device->attr_FWHMCenter_read); + _device->tbuf[BUF_ID_FWHM_CENTER].push_data(&val_buff,buf_time,buf_bunch_num); + val_buff = *(_device->attr_FWHMWidth_read); + _device->tbuf[BUF_ID_FWHM_WIDTH].push_data(&val_buff,buf_time,buf_bunch_num); + if(!(*(_device->attr_GaussFitEnable_read)) || _device->preferFWHM) + *(_device->attr_Center_read) = _device->attr_FWHM_read[0]; + *(_device->attr_Width_read) = _device->attr_FWHM_read[2]; + } + //^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + //:::::::::::::::::::::::: AUTO EXPOSURE :::::::::::::::::::::::: + //________________________________________________________________ + if(*(_device->attr_AutoExposure_read)) + { + double y_max; + if(*(_device->attr_FWHMEnable_read)) + { + y_max=_device->attr_FWHM_read[1]; + } + else + { + size_t x_peak, x_half_min, x_half_max; + double y_peak; + _device->fwhm_calculate(_device->pLiveData_avg,_device->numPixel, + _device->AnalysisRegionStartPix,_device->AnalysisRegionEndPix, + 1, //average on 1 frame + *(_device->attr_FWHMAvg_read), //average between 3 adjacent values + x_peak, y_peak, + x_half_min, x_half_max); + y_max = y_peak; + } + _device->exposures[_device->exposure_idx] = y_max; + _device->exposure_idx = (_device->exposure_idx + 1)%AUTO_EXPOSURE_MEAN; + _device->y_max_mean = 0; + for(int i=0; i<AUTO_EXPOSURE_MEAN; i++) + _device->y_max_mean += _device->exposures[i]; + _device->y_max_mean = (int)(((double)_device->y_max_mean)/AUTO_EXPOSURE_MEAN); + + DEBUG_STREAM << "readthread::run(): AutoExposure: max="<<_device->y_max_mean<<endl; + + if(_device->y_max_mean > _device->autoExposureAmpRange[1]) + { + double exposure = *(_device->attr_ExposureTime_read); + if(exposure - _device->autoExposureStep >= _device->autoExposureRange[0]) + { + exposure -= _device->autoExposureStep; + } + else + { + exposure = _device->autoExposureRange[0]; + } + if(exposure != *(_device->attr_ExposureTime_read)) + { + DEBUG_STREAM << "readthread::run(): AutoExposure: decreasing to "<<exposure<<endl; + *(_device->attr_ExposureTime_read) = exposure; + } + } + else if(_device->y_max_mean < _device->autoExposureAmpRange[0]) + { + double exposure = *(_device->attr_ExposureTime_read); + if(exposure + _device->autoExposureStep <= _device->autoExposureRange[1]) + { + exposure += _device->autoExposureStep; + } + else + { + exposure = _device->autoExposureRange[1]; + } + if(exposure != *(_device->attr_ExposureTime_read)) + { + DEBUG_STREAM << "readthread::run(): AutoExposure: increasing to "<<exposure<<endl; + *(_device->attr_ExposureTime_read) = exposure; + } + } + } + //^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + //:::::::::::::::::::::: Gaussian Fitting :::::::::::::::::::::::: + //________________________________________________________________ + if(*(_device->attr_GaussFitEnable_read)) + { + + int ret_fun; + double fit[CONFITEOR_FIT_NUM_PARAM]; + //if last fit ok, initial guess is last fit + if(_device->GaussFit_valid || use_last_fit) + { + fit[0] = _device->attr_GaussFit_read[0]; + fit[1] = (_device->attr_GaussFit_read[1] > 0) ? _device->attr_GaussFit_read[1] : + ((*(_device->attr_FWHMEnable_read) && (_device->attr_FWHM_read[1] > 0)) ? + _device->attr_FWHM_read[1] : 50 + (10*counter % 950)); + int center_ind=(int)(((double)(_device->AnalysisRegionEndPix - _device->AnalysisRegionStartPix + 1))/2); + //if center is inside analysis region use it, otherwise use fwhm, otherwise use center of analysis region + fit[2] = (_device->attr_GaussFit_read[2] > _device->x_values[_device->AnalysisRegionStartPix] && _device->attr_GaussFit_read[2] < _device->x_values[_device->AnalysisRegionEndPix]) ? + _device->attr_GaussFit_read[2] : ((*(_device->attr_FWHMEnable_read) && (_device->attr_FWHM_read[0] > 0)) ? _device->attr_FWHM_read[0] : _device->x_values[center_ind]); + double width = (_device->x_values[_device->AnalysisRegionEndPix] - _device->x_values[_device->AnalysisRegionStartPix]); + + double width_fit_uncalibr; + if(*(_device->attr_WidthCorrectionEnable_read)) + { + width_fit_uncalibr=sqrt(_device->attr_GaussFit_read[3]*_device->attr_GaussFit_read[3] - _device->widthCorrection*_device->widthCorrection); + } + else + { + width_fit_uncalibr=_device->attr_GaussFit_read[3]; + } + + //if rms computed is too big, use last fwhm, otherwise use a fraction of analysis region + fit[3] = (width_fit_uncalibr > 0 && width_fit_uncalibr < width) ? width_fit_uncalibr*SIGMA_TO_FWHM_FACTOR : + ((*(_device->attr_FWHMEnable_read) && (_device->attr_FWHM_read[2] > 0)) ? _device->attr_FWHM_read[2]*SIGMA_TO_FWHM_FACTOR : width/10.0); + fit[4] = fit[3]; + DEBUG_STREAM << __func__<<": initial guess with GaussFit_valid="<<(int)_device->GaussFit_valid<<" use_last_fit="<<(int)use_last_fit<<" fit[0]="<<fit[0]<<" fit[1]="<<fit[1]<<" fit[2]="<<fit[2]<<" fit[3]="<<fit[3]<<endl; + } + //otherwise if center and width reference are defined, use that (but not always, maybe they are set to bad values) + else if ((_device->attr_GaussReference_read[2]) != 0 && (_device->attr_GaussReference_read[3]) && (counter % 10 == 0)) + { + fit[0] = _device->attr_GaussReference_read[0]; + fit[1] = _device->attr_GaussReference_read[1]; + fit[2] = _device->attr_GaussReference_read[2]; + + double width_ref_uncalibr; + if(*(_device->attr_WidthCorrectionEnable_read)) + { + width_ref_uncalibr=sqrt(_device->attr_GaussReference_read[3]*_device->attr_GaussReference_read[3] - _device->widthCorrection*_device->widthCorrection); + } + else + { + width_ref_uncalibr=_device->attr_GaussReference_read[3]; + } + fit[3] = width_ref_uncalibr*SIGMA_TO_FWHM_FACTOR; //TODO: user is aware of using fwhm instead of sigma? + fit[4] = fit[3]; + DEBUG_STREAM << __func__<<": initial guess from attr_GaussReference_read"<<endl; + } + //otherwise start with some default values + else + { + //fit[0] = _device->noise_level; //TODO: +//#ifdef _NON_AVERAGE +// fit[0] = //TODO: +//#else + //average on 4 points: (2 at beginning + 2 at end)/4 + fit[0] = (_device->pLiveData_avg[2 + _device->AnalysisRegionStartPix] + + _device->pLiveData_avg[5 + _device->AnalysisRegionStartPix] + + _device->pLiveData_avg[_device->AnalysisRegionEndPix -3] + + _device->pLiveData_avg[_device->AnalysisRegionEndPix -6])/4; +//#endif + //try the range 50...10000 as amplitude + fit[1] = (_device->attr_FWHM_read[1] > 0 && *(_device->attr_FWHMEnable_read)) ? _device->attr_FWHM_read[1] : 50 + (10*counter % 950); + //if don't have a value from FWHM, use as center the middle of analysis region + int analysis_region_size = _device->AnalysisRegionEndPix - _device->AnalysisRegionStartPix + 1; + int center_ind=(int)(((double)(analysis_region_size + ((-1 + 2*(counter%2)) * counter%(analysis_region_size/5))))/2); + fit[2] = (_device->attr_FWHM_read[0] > 0 && *(_device->attr_FWHMEnable_read)) ? _device->attr_FWHM_read[0] : _device->x_values[center_ind]; + //if don't have a value from FWHM, use as rms a fraction of analysis region + double width = (_device->x_values[_device->AnalysisRegionEndPix] - _device->x_values[_device->AnalysisRegionStartPix]) / (10.0 + ((1 - 2*(counter%2)) * counter%9)); + fit[3] = (_device->attr_FWHM_read[2] > 0 && *(_device->attr_FWHMEnable_read)) ? _device->attr_FWHM_read[2]*SIGMA_TO_FWHM_FACTOR : width; + fit[4] = (_device->attr_FWHM_read[2] > 0 && *(_device->attr_FWHMEnable_read)) ? _device->attr_FWHM_read[2]*SIGMA_TO_FWHM_FACTOR : width; + DEBUG_STREAM << __func__<<": initial guess GENERIC center_ind="<<center_ind<<endl; + } + fit[5] = 2; + fit[6] = 2; + //DEBUG_STREAM << "readthread::run(): gaussfit initial guess="<<fit[0]<<","<<fit[1]<<","<<fit[2]<<","<<fit[3]<<","<<endl; + double *data = new double[_device->AnalysisRegionEndPix - _device->AnalysisRegionStartPix + 1]; + for(unsigned int i=_device->AnalysisRegionStartPix; i <= _device->AnalysisRegionEndPix; i++) + { + data[i-_device->AnalysisRegionStartPix] = _device->pLiveData_avg[i]; + } + //size_t fitting_iter; + unsigned int fitting_iter; + //SYSTEMTIME ts_end, ts_start; + //GetSystemTime(&ts_start); +// ret_fun = (_device->m_gaussfit)->perform(data,_device->AnalysisRegionEndPix - _device->AnalysisRegionStartPix + 1, MAX_GAUSS_ITERATION, fitting_iter, &(_device->x_values[_device->AnalysisRegionStartPix]), fit); + double tmperr[CONFITEOR_FIT_NUM_PARAM], tmpchi; + double mean, rms; + int ret_fun2; + timespec start, now; + clock_gettime(CLOCK_MONOTONIC,&start); + switch(*(_device->attr_FitType_read)) + { + case GAUSS_FIT: + default: + ret_fun = (_device->m_gaussfit)->perform(data,&(_device->x_values[_device->AnalysisRegionStartPix]), _device->AnalysisRegionEndPix - _device->AnalysisRegionStartPix + 1, MAX_GAUSS_ITERATION, 0, fitting_iter, NULL/*weights*/, fit, tmperr, tmpchi); + ret_fun2 = (_device->m_gaussfit)->compute_rms(fit, &mean, &rms); + break; + case GAUSS_FIT_ASYMM: + ret_fun = (_device->m_asyngaussfit)->perform(data,&(_device->x_values[_device->AnalysisRegionStartPix]), _device->AnalysisRegionEndPix - _device->AnalysisRegionStartPix + 1, MAX_GAUSS_ITERATION, 0, fitting_iter, NULL/*weights*/, fit, tmperr, tmpchi); + ret_fun2 = (_device->m_asyngaussfit)->compute_rms(fit, &mean, &rms); + break; + case CONFITEOR_FIT: + ret_fun = (_device->m_confiteorfit)->perform(data,&(_device->x_values[_device->AnalysisRegionStartPix]), _device->AnalysisRegionEndPix - _device->AnalysisRegionStartPix + 1, MAX_CONFITEOR_ITERATION, 0, fitting_iter, NULL/*weights*/, fit, tmperr, tmpchi); + ret_fun2 = (_device->m_confiteorfit)->compute_rms(fit, &mean, &rms); + break; + } + delete [] data; + clock_gettime(CLOCK_MONOTONIC,&now); + //printf ("gauss_f: f[0]=%f f[50]=%f\n",f[0],f[50]); + double fit_time =(now.tv_sec - start.tv_sec)*1000000 + ((double)(now.tv_nsec - start.tv_nsec))/1000; + fit_counter++; + if(fit_time < min_fit_time) + min_fit_time = fit_time; + if(fit_time > max_fit_time) + max_fit_time = fit_time; + tot_fit_time += fit_time; + //if(fit_counter > 1) + avg_fit_time = tot_fit_time/(fit_counter); + //GetSystemTime(&ts_end); + //DEBUG_STREAM << "readthread::run(): gaussfit performing time: start="<<ts_start.wSecond<<"."<<ts_start.wMilliseconds<<" end="<<ts_end.wSecond<<"."<<ts_end.wMilliseconds<<endl; + //if(ret_fun) + bool fit_valid = false; + //TODO: adjust rms thresh with fwhm + //eg: if(*(_device->attr_FWHMEnable_read)) + //rms_thresh=fabs(_device->attr_FWHM_read[2]*SIGMA_TO_FWHM_FACTOR/2) + //if(ret_fun >= 0 && fabs(rms) > 0.08) + if(0) + { + use_last_fit = true; + _device->attr_GaussFit_read[0] = fit[0]; + _device->attr_GaussFit_read[1] = fit[1]; + //_device->attr_GaussFit_read[2] = fit[2]; + _device->attr_GaussFit_read[2] = mean; + //double temp = fit[3]/(double)(SIGMA_TO_FWHM_FACTOR); + double temp = rms/(double)(SIGMA_TO_FWHM_FACTOR); + if(*(_device->attr_WidthCorrectionEnable_read)) + { + _device->attr_GaussFit_read[3]=sqrt(temp*temp + _device->widthCorrection*_device->widthCorrection); + } + else + { + _device->attr_GaussFit_read[3] = (temp > 0) ? temp : -temp; + } + } + else + { + use_last_fit = false; + } + if(!ret_fun && !ret_fun2) + { + //if constraints amp > 0, mean inside analysis region and rms > 1 + if(fit[1] > 0 && mean > _device->x_values[_device->AnalysisRegionStartPix] && mean < _device->x_values[_device->AnalysisRegionEndPix] && fabs(rms) > 0.08) + fit_valid = true; + } + if(fit_valid) + { + _device->attr_GaussFit_read[0] = fit[0]; + _device->attr_GaussFit_read[1] = fit[1]; + //_device->attr_GaussFit_read[2] = fit[2]; + _device->attr_GaussFit_read[2] = mean; + //double temp = fit[3]/(double)(SIGMA_TO_FWHM_FACTOR); + double temp = rms/(double)(SIGMA_TO_FWHM_FACTOR); + if(*(_device->attr_WidthCorrectionEnable_read)) + { + _device->attr_GaussFit_read[3]=sqrt(temp*temp + _device->widthCorrection*_device->widthCorrection); + } + else + { + _device->attr_GaussFit_read[3] = (temp > 0) ? temp : -temp; + } + *(_device->attr_GaussFitCenter_read) = _device->attr_GaussFit_read[2]; + *(_device->attr_GaussFitWidth_read) = _device->attr_GaussFit_read[3]; + double val_buff; + val_buff = *(_device->attr_GaussFitCenter_read); + _device->tbuf[BUF_ID_GAUSS_CENTER].push_data(&val_buff,buf_time,buf_bunch_num); + val_buff = *(_device->attr_GaussFitWidth_read); + _device->tbuf[BUF_ID_GAUSS_WIDTH].push_data(&val_buff,buf_time,buf_bunch_num); + _device->GaussFit_valid = true; + if(!(*(_device->attr_FWHMEnable_read)) || !_device->preferFWHM) + *(_device->attr_Center_read) = _device->attr_GaussFit_read[2]; + *(_device->attr_Width_read) = _device->attr_GaussFit_read[3]; + DEBUG_STREAM << "readthread::run(): FIT VALID! fit_time="<<fit_time << "["<<min_fit_time<<","<<max_fit_time<<"]->"<<avg_fit_time << " fit[1]="<<fit[1]<<" mean="<<mean<<" rms="<<rms; + } + else + { + DEBUG_STREAM << "readthread::run(): FIT NOT VALID: ret_fun="<<ret_fun<<" ret_fun2="<<ret_fun2<<" fit[1]="<<fit[1]<<" mean="<<mean<<" rms="<<rms<<" fit_time="<<fit_time << "["<<min_fit_time<<","<<max_fit_time<<"]->"<<avg_fit_time; + _device->GaussFit_valid = false; + } + + } + //^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + //::::::::::::::::::::::: AREA processing ::::::::::::::::::::::: + //________________________________________________________________ + if(*(_device->attr_AreaEnable_read)) + { + size_t x_start, x_end; + double wl_start, wl_end; + bool region_ok = false; + if((*(_device->attr_FWHMEnable_read) || (*(_device->attr_GaussFitEnable_read) && _device->GaussFit_valid)) && + *(_device->attr_Center_read) > _device->attr_RegionOfInterest_read[0] && + *(_device->attr_Center_read) < _device->attr_RegionOfInterest_read[1] && !_device->areaInAnalysisRegion) + { + wl_start = *(_device->attr_Center_read) - (*(_device->attr_AreaRegion_read)/2); + if(wl_start < _device->attr_RegionOfInterest_read[0]) + wl_start = _device->attr_RegionOfInterest_read[0]; + wl_end = *(_device->attr_Center_read) + (*(_device->attr_AreaRegion_read)/2); + if(wl_end > _device->attr_RegionOfInterest_read[1]) + wl_end = _device->attr_RegionOfInterest_read[1]; + x_start = _device->WaveLenght2Pix(wl_start); + x_end = _device->WaveLenght2Pix(wl_end); + region_ok = true; + } + else if(_device->attr_AnalysisRegion_read[0] >= _device->attr_RegionOfInterest_read[0] && + _device->attr_AnalysisRegion_read[1] <= _device->attr_RegionOfInterest_read[1] && _device->areaInAnalysisRegion) + { + wl_start = _device->attr_AnalysisRegion_read[0]; + wl_end = _device->attr_AnalysisRegion_read[1]; + x_start = _device->WaveLenght2Pix(wl_start); + x_end = _device->WaveLenght2Pix(wl_end); + region_ok = true; + } + + if(region_ok) + { + double area=0; + for(size_t x = x_start; x <= x_end; x++) + area += fabs(_device->pLiveData_avg[x]); + *(_device->attr_Area_read) = area; + _device->tbuf[BUF_ID_AREA].push_data(&area,buf_time,buf_bunch_num); + } + } + //^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + //:::::::::::::::: End of Single Mode Acquirement :::::::::::::::: + //________________________________________________________________ + if(_device->measure_mode) + { + //mutex_sleep->lock(); + pausesec = 1; + pausenano = 0; + //mutex_sleep->unlock(); + _device->init_measure_mode = false; + _device->measure_mode = false; + _device->set_state(Tango::ON); + _device->set_status("Data ready"); + } + /*ret= _device->m_usbCCD.StartMeasuring(&(pNoiseData[_device->noise_frames_counter * _device->m_usbCCD.m_nNumReadOuts * _device->numPixel])); + if(!ret) + { + INFO_STREAM << "readthread::run(): error in StartMeasuring()" << endl; + }*/ + + if(_device->stop_mode) + { + _device->live_mode = false; + _device->stop_mode = false; + pausesec = 1; + pausenano = 0; + StopMeas(); + } + } + //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++// + //++++++++++++++++++++++++ACQUIRE NOISE MODE+++++++++++++++++++++++++++// + //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++// + if(_device->acquire_noise_mode || _device->stop_mode) + { + //DWORD stat; + //_device->m_usbCCD.GetMeasStatus(&stat); + //if(stat == STATUS_DATA_READY) + + //_device->m_usbCCD.GetData(&(pNoiseData[_device->noise_frames_counter * _device->m_usbCCD.m_nNumReadOuts * _device->numPixel])); + if(counter==0 || (*(_device->attr_SyncMode_read) != 0)) + flag = PrepareMeas(); + else + flag = 0; + if(flag==0) + flag = Measure(&(pNoiseData[_device->noise_frames_counter * _device->numPixel])); + if(flag < 0) + { + if(flag==-1) + { + _device->set_state(Tango::FAULT); + //_device->set_status("Communication error"); + //_device->disconnect_device(); + _device->init_acquire_noise_mode = false; + _device->acquire_noise_mode = false; + _device->stop_mode = false; + pausesec = 1; + pausenano = 0; + _device->conn_status = false; + } + else if(flag==-2) + { + _device->set_state(Tango::OFF); + } + continue; + } + else if(flag > 0) + { + if(_device->stop_mode) + { + _device->acquire_noise_mode=false; + } + else + { + _device->set_state(Tango::ALARM); + } + //_device->set_status("Trigger Missing"); + //_device->disconnect_device(); + continue; + } + else + { + if(_device->get_state()==Tango::ALARM || _device->get_state()==Tango::OFF) + { + _device->set_state(Tango::RUNNING); + _device->set_status("Acquiring noise"); + } + } + _device->noise_frames_counter++; + DEBUG_STREAM << "readthread::run() DATA_READY!! noise_frames_counter="<<_device->noise_frames_counter <<" noise_frames="<<_device->noise_frames << endl; + if(_device->noise_frames_counter >= _device->noise_frames) + { + double noise_avg=0; + double min_val=0, max_val=10000; + int tmp_count=0; + //for every pixel + for(unsigned int j=0; j < _device->noise_frames * _device->numPixel; j++) + { + if(pNoiseData[j] >= min_val && pNoiseData[j] <= max_val) + { + noise_avg += pNoiseData[j]; + tmp_count++; + } + } + DEBUG_STREAM << "readthread::run() DATA_READY!! noise sum="<<noise_avg <<" noise pixel counter="<<tmp_count<<" noise pixel total=" << _device->noise_frames * _device->numPixel<< endl; + //divide the sum per the number of frames + noise_avg = noise_avg/((double)tmp_count); + //noise_avg = noise_avg/((double)_device->noise_frames * _device->m_usbCCD.m_nNumReadOuts * _device->numPixel); + _device->noise_level = (int)noise_avg; //truncate + *(_device->attr_NoiseLevel_read) = _device->noise_level; + + for(size_t k=0; k<_device->numPixel; k++) + { + noise_avg=0; + for(size_t j=0; j<_device->noise_frames; j++) + { + noise_avg += pNoiseData[j* _device->numPixel + k]; + } + _device->pNoiseMask_avg[k] = noise_avg/_device->noise_frames; + } + + ofstream fd; //startup file + fd.open(_device->noiseProfileFile.c_str()); + if (!fd) + { + stringstream tmp; + tmp << "Cannot open Noise Profile default file " << _device->noiseProfileFile<< " err:" << strerror(errno) << endl; + INFO_STREAM << "readthread::acquire_noise(): " << tmp.str(); + } + else + { + DEBUG_STREAM << "readthread::acquire_noise(): file " << _device->noiseProfileFile << " opened successfully" << endl; + for(size_t i=0; i<_device->numPixel; i++) + { + fd << _device->pNoiseMask_avg[i] << endl; + } + fd.close(); + } + + try + { + Tango::MultiAttribute *attr_list; + attr_list = _device->get_device_attr(); + Tango::WAttribute &attr_l = attr_list->get_w_attr_by_name ("NoiseLevel"); + attr_l.set_write_value(*(_device->attr_NoiseLevel_read)); + } catch(...) + { + DEBUG_STREAM << "readthread::run(): failed setting write value of 'NoiseLevel'"; + } + DEBUG_STREAM << "readthread::run(): calculated noise average="<<noise_avg<<" -> noise_level="<<_device->noise_level<<endl; + + if(pNoiseData) + delete [] pNoiseData; + pNoiseData=NULL; + + //mutex_sleep->lock(); + pausesec = 1; + pausenano = 0; + //mutex_sleep->unlock(); + _device->init_acquire_noise_mode = false; + _device->acquire_noise_mode = false; + _device->set_state(Tango::ON); + _device->set_status("Data ready"); + } + /*else + { + ret= _device->m_usbCCD.StartMeasuring(&(pNoiseData[_device->noise_frames_counter * _device->m_usbCCD.m_nNumReadOuts * _device->numPixel])); + if(!ret) + { + INFO_STREAM << "readthread::run(): error in StartMeasuring()" << endl; + } + }*/ + if(_device->stop_mode) + { + if(pNoiseData) + delete [] pNoiseData; + pNoiseData=NULL; + _device->acquire_noise_mode = false; + _device->stop_mode = false; + pausesec = 1; + pausenano = 0; + StopMeas(); + } + } + if(!(_device->init_live_mode || _device->init_measure_mode || _device->init_acquire_noise_mode) + && !(_device->live_mode || _device->measure_mode || _device->stop_mode) + && !(_device->acquire_noise_mode || _device->stop_mode)) + { + try { + Tango::DevState ccd_state; + _device->dpmutex->lock(); + _device->dp->read_attribute("State")>>ccd_state; + _device->dpmutex->unlock(); + if(ccd_state != Tango::ON) + { + _device->set_state(Tango::OFF); + } + } + catch(Tango::DevFailed &e) + { + _device->dpmutex->unlock(); + INFO_STREAM << __func__ << ": error reading =" << e.errors[0].desc; + _device->set_state(Tango::OFF); + _device->set_status(string(e.errors[0].desc)); + } + + } + if(((_device->measure_mode || _device->live_mode || _device->acquire_noise_mode) && ((counter % 100) == 0)) || + (!_device->measure_mode && !_device->live_mode && !_device->acquire_noise_mode)) + { + //DEBUG_STREAM << "readthread::run(): measure_mode=" << _device->measure_mode << " _device->live_mode=" << _device->live_mode << endl; + //DEBUG_STREAM << "readthread::run(): pausesec=" << pausesec << " pausenano=" << pausenano << endl; + //DEBUG_STREAM << "readthread::run(): before GetParameters()" << endl; + } + abort_sleep(pausesec + ((double)pausenano)/1000000000); + counter++; + //if stopped and connection OK -> heartbeat + if(_device->conn_status && (!_device->measure_mode && !_device->live_mode && !_device->acquire_noise_mode)) + { + /*int ret = Heartbeat(); + if(ret < 0) + { + _device->set_state(Tango::FAULT); + _device->disconnect_device(); + _device->conn_status = false; + }*/ + } + //if stopped and connection NOK -> reconnect + else if(!_device->measure_mode && !_device->live_mode && !_device->acquire_noise_mode) + { + //_device->conn_status = _device->OpenComm(true); + if(_device->autoStart && _device->conn_status) + { + try + { + _device->start(); + } + catch(Tango::DevFailed &e) + { + INFO_STREAM << __func__ << ": error autostarting=" << e.errors[0].desc; + } + } + } + + } //end while(!abortflag) + if(pNoiseData) + delete [] pNoiseData; + pNoiseData=NULL; + DEBUG_STREAM << "readthread::run(): exit!!!" << endl; +} + +//+------------------------------------------------------------------ +// +// method: readthread::abort_sleep +// +// description: Resume from sleep if abort_flag set (sec.) +// +//------------------------------------------------------------------- +void readthread::abort_sleep(double time) +{ + omni_mutex_lock sync(*this); + long time_millis = (long)(time*1000); + int res = wait(time_millis); +} + +int readthread::PrepareMeas() +{ + CCDSpectrometer *_device = static_cast<CCDSpectrometer *>(device); + Tango::DevState ccd_state; + int retry_cnt=0; + do + { + retry_cnt++; + try { + Tango::DevState data; + _device->dpmutex->lock(); + _device->dp->read_attribute("State")>>ccd_state; + _device->dpmutex->unlock(); + } + catch(Tango::DevFailed &e) + { + _device->dpmutex->unlock(); + INFO_STREAM << __func__ << ": error reading =" << e.errors[0].desc; + return -1; + } + if(ccd_state == Tango::INIT || ccd_state == Tango::OFF) + abort_sleep(1); + } while ((ccd_state == Tango::INIT || ccd_state == Tango::OFF) && retry_cnt < 30); + if(retry_cnt >= 30) + return -1; + return 0; +} + +int readthread::Measure(double *l_pSpectrum) +{ + CCDSpectrometer *_device = static_cast<CCDSpectrometer *>(device); + Tango::DevLong camera_counter; + int retry_cnt=0; + do + { + retry_cnt++; + try { + //Tango::DevDouble data; + _device->dpmutex->lock(); + _device->dp->read_attribute(COUNTER_ATTR)>>camera_counter; + _device->dpmutex->unlock(); + } + catch(Tango::DevFailed &e) + { + _device->dpmutex->unlock(); + INFO_STREAM << __func__ << ": error reading =" << e.errors[0].desc; + _device->set_status("Camera Stopped"); + abort_sleep(0.5); + return -2; + } + if(camera_counter == last_camera_counter) + abort_sleep(0.01); + } while (camera_counter == last_camera_counter && retry_cnt < 100); + //DEBUG_STREAM << __func__ << ": camera_counter=" << camera_counter << " retry_cnt="<<retry_cnt; + last_camera_counter = camera_counter; + if(retry_cnt >= 100) + { + if((*(_device->attr_SyncMode_read) != 0)) //-> HW + { + ERROR_STREAM << "Communication error (read Measurement TIMEOUT)"; + if(_device->live_mode || _device->measure_mode || _device->acquire_noise_mode) + _device->set_status("Timeout reading"); + return 1; + } + else + { + ERROR_STREAM << "Communication error (read Measurement failed)"; + _device->set_status("Timeout reading"); + return -1; + } + } + + try { + vector<Tango::DevDouble> data; + Tango::DeviceAttribute dattr; + _device->dpmutex->lock(); + _device->dp->read_attribute(DATA_ATTR)>>(data); + for(size_t i=0; i<_device->numPixel; i++) + { + if(i < _device->RegionOfInterestStartPix || i > _device->RegionOfInterestEndPix) + { + l_pSpectrum[i] = 0; + } + else if(i-_device->RegionOfInterestStartPix < data.size()) + { + l_pSpectrum[i] = data[i-_device->RegionOfInterestStartPix]; + //DEBUG_STREAM << __func__ << ": read data.size()=" << data.size() << " data[data.size()-1]="<<data[data.size()-1]; + } + } + _device->dpmutex->unlock(); + } + catch(Tango::DevFailed &e) + { + _device->dpmutex->unlock(); + INFO_STREAM << __func__ << ": error reading =" << e.errors[0].desc; + if(_device->get_state() == Tango::OFF) + return -2; + return -1; + } + return 0; +} + +void readthread::StopMeas() +{ +} + +} + + diff --git a/src/readthread.h b/src/readthread.h new file mode 100644 index 0000000..46bf6d8 --- /dev/null +++ b/src/readthread.h @@ -0,0 +1,66 @@ +// +// file : readthread.h +// +// description : reading thread +// +// +// +// copyleft : Sincrotrone Trieste S.C.p.A. +// Strada Statale 14 - km 163,5 in AREA Science Park +// 34012 Basovizza, Trieste ITALY +// + + +#ifndef RAMPTHREAD_H +#define RAMPTHREAD_H + +#include <omnithread.h> +#include <tango.h> +#include <inttypes.h> + +namespace CCDSpectrometer_ns +{ + +class readthread : public omni_thread, public Tango::TangoMonitor, public Tango::LogAdapter +{ + private: + Tango::DeviceImpl* device; + void abort_sleep(double time); + Tango::DevLong last_camera_counter; + int wait_counter; + + bool use_last_fit; + + unsigned long old_bunch_number; + + bool just_reconnected; + + uint32_t numavg; + int PrepareMeas(); + int Measure(double *l_pSpectrum); + + void StopMeas(); + int Heartbeat(); + + public: + readthread(Tango::DeviceImpl* devImpl); + ~readthread(); + int pausesec,pausenano; + double min_fit_time; + double max_fit_time; + double tot_fit_time; + double avg_fit_time; + size_t fit_counter; + bool abortflag; + bool waitflag; + + protected: + void run(void *); + +}; /* end class readthread() */ + +} + +#endif + +/* EOF */ diff --git a/src/tbuffer.hpp b/src/tbuffer.hpp new file mode 100644 index 0000000..a159a44 --- /dev/null +++ b/src/tbuffer.hpp @@ -0,0 +1,2326 @@ +#ifndef __TBUFFER_H +#define __TBUFFER_H + +#include <stdio.h> +#include <unistd.h> +#include <stdlib.h> +#include <string.h> +#include <sys/time.h> +#include <math.h> //for NAN(18.04) +//#include <bits/nan.h> //for NAN(14.04) +#include <stdint.h> + +#define BUF_RT_NO_FILL 0 +#define BUF_RT_FILL_1 1 +#define BUF_RT_FILL_PREV 2 +#define BUF_RT_FILL_0 3 + +#define FILL_ZERO 0x00000000 +#define FILL_NAN NAN +#define FILL_ONE_CHAR (char)0xf +#define FILL_ONE_SHORT (short)0xfff +#define FILL_ONE_LONG (int32_t)0xfffffff +#define FILL_ONE_LONG_LONG (int64_t)(0xfffffffffffffffULL) + +#define BUF_GET_LAST_MODE 0 +#define BUF_GET_BUNCH_MODE 1 +#define BUF_GET_TIME_MODE 2 +#define BUF_GET_LAST_UNIQUE_MODE 3 +#define BUF_GET_BUNCH_UNIQUE_MODE 4 +#define BUF_GET_TIME_UNIQUE_MODE 5 +#define BUF_GET_LAST_BUNCH_MODE 6 +#define BUF_GET_BUNCH_BUNCH_MODE 7 +#define BUF_GET_TIME_BUNCH_MODE 8 + +#define BUF_FILT_STD 0x00000001 +#define BUF_FILT_MEDIAN 0x00000002 +#define BUF_FILT_KALMAN 0x00000004 + +#define MAX_MEDIAN_SAMPLE 4096 + +//#define DEBUG_BUFF 1 + +#ifdef DEBUG_BUFF +#define PRINT(...) (DEBUG_BUFF ? (printf("%s: ", __func__), \ +printf(__VA_ARGS__)) : 0) +#else +#define PRINT(...) +#endif + +namespace tbuffer +{ + +typedef enum +{ + BUF_RT_LINEAR, + BUF_RT_CIRCULAR +} bufRtMode_t; + +typedef enum +{ + typeChar, + typeShort, + typeLong, + typeFloat, + typeDouble, + typeLongLong, + typeCharArray, + typeShortArray, + typeLongArray, + typeFloatArray, + typeDoubleArray, + typeLongLongArray +} type_t; + +/*template <typename T> +class _buffer_data +{ + uint32_t bunchnr; // bunch number -unambiguous- + T data; // data + struct timeval time; // timestamp +};*/ + +/*template <typename T> +class _buffer_data +{ + T data; // data +};*/ + +/*class _bunch_time +{ + uint32_t bunchnr; // bunch number -unambiguous- + struct timeval time; // timestamp +};*/ + +template <typename T> +class _data_array +{ + T *data; // data + size_t count; +public: + _data_array(size_t num){data=new T[num]; count=num;} + _data_array(T *val, size_t num) + { + data=new T[num]; + count=num; + memcpy(data, val, sizeof(T)*num); +// cout<<"copyed num="<<num<<" in _data_array, data[0]="<<data[0]<<" data[1]="<<data[1]<<" data[2]="<<data[2]<<" data[1000]="<<data[1000]<<" data[1001]="<<data[1001]<<" data[1002]="<<data[1002]<<endl; + } + _data_array(){data=NULL; count=0;} + ~_data_array(){if(data) delete [] data;} + T& operator[] (const size_t& i){ return data[i]; } + //T& operator new [] (const int& i){ return data[i]; } + //const _data_array& operator= (const _data_array<T>&){ _data_array<T> ret(count); memcpy(ret.data, data, sizeof(T)*count); return ret; } + const _data_array& operator= (const _data_array<T>& arg) + { + if(count != arg.count) + { + delete [] data; + data=new T[arg.count]; + count=arg.count; + } + memcpy(data, arg.data, sizeof(T)*arg.count); return *this; + } + const _data_array& operator= (const T& arg) + { + if(data) + delete [] data; + data=new T[1]; + count=1; + memcpy(data, &arg, sizeof(T)*1); + return *this; + } + size_t extract_data(T* arg) + { + //cout << __func__<<": entering, count="<<count<<endl; + if(count > 0) + memcpy(arg, &data[0], sizeof(T)*count); + //cout << __func__<<": after memcpy, count="<<count<<" data[0]="<<data[0]<<" data[1]="<<data[1]<<" data[2]="<<data[2]<<" data[1000]="<<data[1000]<<" data[1001]="<<data[1001]<<" data[1002]="<<data[1002]<<endl; + return count; + } + size_t get_count() + { + return count; + } +}; + + +template<typename T> +struct identity { typedef T type; }; + +//----------------------------------------------------------------------------------------------------------------- + +int tv_compare(struct timeval ts1, struct timeval ts2); + +template <typename T> +class buffer_t +{ +private: + long size; // size of circular buffer + type_t type; //type of data + long idx; // index inside the buffer + unsigned long counter; // number of push executed + unsigned long mode; // flag that enables circular buffer, when 0 and the buffer is + // full, push will return false + unsigned long fill_hole;// is a bunch hole happens, this flag determines behaviour: + // 0 = no fill + // 1 = fill with 0xffffffff or NaN + // 2 = fill with previous value inside the buffer + // 3 = fill with 0 + //T *buffer_data; // data + uint32_t bunchnr[100000]; // bunch number -unambiguous- + T data[100000]; // data + timeval time[100000]; // timestamp + //()()()()()()()()()()()()()()() KALMAN ()()()()()()()()()()()()()()() + double sigmav; //observation noise covariance + double sigmaw; //observation noise covariance + double P; //error covariance + double x; //real state + double x_; //predicted state + double z; //observation + +type_t get_type(T foo) +{ + return m_get_type(foo); +} + +public: +//template <typename TL> +type_t get_type() +{ + return get_type(identity<T>()); +} +void fill0(T *val) +{ + *val = 0; +} +void fill1(T *val) +{ + fill1(val, identity<T>()); +} +private: +template<typename TL> +type_t get_type(identity<TL>) +{ + return -1; +} + +type_t get_type(identity<int8_t>) +{ + return typeChar; +} +type_t get_type(identity<int16_t>) +{ + return typeShort; +} +type_t get_type(identity<int32_t>) +{ + return typeLong; +} +type_t get_type(identity<int64_t>) +{ + return typeLongLong; +} +type_t get_type(identity<float>) +{ + return typeFloat; +} +type_t get_type(identity<double>) +{ + return typeDouble; +} +type_t get_type(identity<_data_array<int8_t> >) +{ + return typeCharArray; +} +type_t get_type(identity<_data_array<int16_t> >) +{ + return typeShortArray; +} +type_t get_type(identity<_data_array<int32_t> >) +{ + return typeLongArray; +} +type_t get_type(identity<_data_array<int64_t> >) +{ + return typeLongLongArray; +} +type_t get_type(identity<_data_array<float> >) +{ + return typeFloatArray; +} +type_t get_type(identity<_data_array<double> >) +{ + return typeDoubleArray; +} + +template<typename TL> +void fill1(TL *val, identity<TL>) +{ + //TODO: data_array!!!!!!!!!!!!!!!!!!!!!! +} +void fill1(int8_t *val, identity<int8_t>) +{ + *val = FILL_ONE_CHAR; +} +void fill1(int16_t *val, identity<int16_t>) +{ + *val = FILL_ONE_SHORT; +} +void fill1(int32_t *val, identity<int32_t>) +{ + *val = FILL_ONE_LONG; +} +void fill1(int64_t *val, identity<int64_t>) +{ + *val = FILL_ONE_LONG_LONG; +} +void fill1(float *val, identity<float>) +{ + *val = FILL_NAN; +} +void fill1(double *val, identity<double>) +{ + *val = FILL_NAN; +} +void fill1(_data_array<int8_t> *val, identity<_data_array<int8_t> >) +{ + *val = _data_array<int8_t>(FILL_ONE_CHAR); +} +void fill1(_data_array<int16_t> *val, identity<_data_array<int16_t> >) +{ + *val = _data_array<int16_t>(FILL_ONE_SHORT); +} +void fill1(_data_array<int32_t> *val, identity<_data_array<int32_t> >) +{ + *val = _data_array<int32_t>(FILL_ONE_LONG); +} +void fill1(_data_array<int64_t> *val, identity<_data_array<int64_t> >) +{ + *val = _data_array<int64_t>(FILL_ONE_LONG_LONG); +} +void fill1(_data_array<float> *val, identity<_data_array<float> >) +{ + *val = _data_array<float>(FILL_NAN); +} +void fill1(_data_array<double> *val, identity<_data_array<double> >) +{ + *val = _data_array<double>(FILL_NAN); +} + + +public: +/*********************************** + * allocates memory + ***********************************/ +int init_rt_buffer(long numsamples) +{ + + //unsigned long type_size; + //PRINT("entering... ver: %s %s file: %s\n", version_string, release_string, __FILE__rev); + //trick to have release string in the binary, but I don't want the printf to be executed + + type = get_type(); //TODO + //PRINT("setting type=%d\n",buffer.type); + if(numsamples == 0) + return -1; + + // allocates memory + /*buffer_data = new T[numsamples]; + if (!buffer_data) + return -ENOMEM;*/ +#ifdef _DYNAMIC_ALLOC + bunchnr = NULL; + data = NULL; + time = NULL; + + bunchnr = new uint32_t[numsamples]; // bunch number -unambiguous- + data = new T[numsamples]; // data + time = new timeval[numsamples]; // timestamp + if (!bunchnr || !data || !time) + return -ENOMEM; +// clean buffer + //memset(buffer_data, 0, sizeof(buffer_data)*numsamples); + memset(bunchnr, 0, sizeof(uint32_t)*numsamples); + memset(data, 0, sizeof(T)*numsamples); + memset(time, 0, sizeof(timeval)*numsamples); +#else + memset(bunchnr, 0, sizeof(uint32_t)*100000); + memset(data, 0, sizeof(T)*100000); + memset(time, 0, sizeof(timeval)*100000); +#endif +// init size + size = numsamples; + +// init index + idx = 0; + counter = 0; + mode = BUF_RT_CIRCULAR; + fill_hole = BUF_RT_NO_FILL; + + return 0; +} + +/*********************************** + * free memory + ***********************************/ +int delete_rt_buffer() +{ +// frees memory + //delete [] buffer_data; +#ifdef _DYNAMIC_ALLOC + delete [] bunchnr; + delete [] data; + delete [] time; +#endif + return 0; +} + +/*********************************** + * reset buffer + ***********************************/ +int reset_rt_buffer() +{ +// init index + idx = 0; + counter = 0; + return 0; +} + +/*********************************** + * push data into buffer + ***********************************/ +int push_data(T *value, timeval timestamp, uint32_t bunchnumber) +{ + struct timeval now; + struct timezone tz; + +//manage -full- condition + if((counter < size)||(mode == BUF_RT_CIRCULAR)) + { + +//buffer not full or circular => hole check + if(counter!=0) //first push skip hole check + { + long prev_idx = (idx-1+size)%size; +//found a hole + while(((bunchnumber > bunchnr[prev_idx]) && (bunchnumber!=(bunchnr[prev_idx])+1)&&((counter != size)||(mode == BUF_RT_CIRCULAR)))&&(fill_hole!=BUF_RT_NO_FILL)){ + PRINT("data pushed pos: %li\n", idx); + switch(fill_hole) + { + case BUF_RT_FILL_1: //fill with 0xffffffff, NAN + fill1(&data[idx]); + gettimeofday(&now,&tz); + (time[idx]).tv_sec = now.tv_sec; + (time[idx]).tv_usec = now.tv_usec; + /*printf("pushed: %d, %d, %d-%d\n", FILL_ONE_LONG, (bunchnr_ptr[prev_idx])+1, now.tv_sec, now.tv_usec);*/ + PRINT("fill policy: added 1 on pos=%li\n", idx); + break; + case BUF_RT_FILL_0: //fill with 0 + fill0(&data[idx]); + gettimeofday(&now,&tz); + (time[idx]).tv_sec = now.tv_sec; + (time[idx]).tv_usec = now.tv_usec; + /*printf("pushed: %d, %d, %d-%d\n", FILL_ONE_LONG, (bunchnr_ptr[prev_idx])+1, now.tv_sec, now.tv_usec);*/ + PRINT("fill policy: added 0 on pos=%li\n", idx); + break; + case BUF_RT_FILL_PREV: //fill with previous value + data[idx] = data[prev_idx]; + (time[idx]).tv_sec = (time[prev_idx]).tv_sec; + (time[idx]).tv_usec = (time[prev_idx]).tv_usec; + /*PRINT("pushed: %f, %d, %d-%d\n", data_ptr[prev_idx], (bunchnr_ptr[prev_idx])+1, time_ptr[prev_idx].tv_sec, time_ptr[prev_idx].tv_usec);*/ + PRINT("fill policy: added previous on pos=%li\n", idx); + break; + } + bunchnr[idx] = bunchnr[prev_idx]+1; + //TODO: why counter limited to size? + //this->counter = (this->counter==this->size)?this->size:this->counter+1; + counter++; + idx = ((idx + 1) % size); + prev_idx = (idx-1+size)%size; + } + } + else + { + //PRINT("no holes check\n"); + } +//insertion + if((counter != size)||(mode == BUF_RT_CIRCULAR)) + { + data[idx] = *value; + (time[idx]).tv_sec = timestamp.tv_sec; + (time[idx]).tv_usec = timestamp.tv_usec; + bunchnr[idx] = bunchnumber; + //TODO: why counter limited to size? + //this->counter = (this->counter==this->size)?this->size:this->counter+1; + counter++; + //TODO: memory barrier here? +#ifndef __KERNEL__ +#if __BYTE_ORDER == __BIG_ENDIAN //powerpc + asm volatile("lwsync"); +#else + asm volatile("mfence"); +#endif +#endif + idx = ((idx + 1) % size); + return 0; + } + else{ + PRINT("no push after holes check: buffer is full counter=%li size=%li\n",counter,size); + return -1; + } + } + else{ + PRINT("no push: buffer is full counter=%li size=%li\n",counter,size); + return -1; + } +}; + +/*********************************** + * extract data from buffer + ***********************************/ +int pop_data(unsigned char unique, long idx[2], T *data_buf) +{ + long i = idx[0]; + long h = idx[1]; + long size_tmp1 = 0; + long size_tmp2 = 0; + read_data(unique, idx, data_buf); + if(i < h) + { + size_tmp1 = h-i; + } + else if(i > h) + { + size_tmp1 = this->size - i; //i -> buffer size + size_tmp2 = h; //0 -> h + } + idx = ((this->idx)-(size_tmp1 + size_tmp2)+size)%size; + return 0; +}; + +/*int read_data(unsigned char unique, long idx[2], T *data_buf) +{ + return read_data(unsigned char unique, long idx[2], T *data_buf); +}; +private: +template<typename TL> +long get_data_size(identity<TL>) +{ + return this->size; +} +template<typename TL> +long get_data_size(identity<_data_array<TL> >) +{ + long ret_size=0; + for(int i=0; i<size; i++) + { + ret_size += data[i].count; + } + return ret_size; +} + +private:*/ +/*********************************** + * read data from buffer + ***********************************/ +int read_data(unsigned char unique, long idx[2], T *data_buf){ + + long i = idx[0]; + long h = idx[1]; + long size_tmp1 = 0; + long size_tmp2 = 0; + int k = 0, j=0; + long ns; + unsigned long last_bunchnr = -1; + T *data_ptr = &data[0]; + uint32_t *bunchnr_ptr = (uint32_t *)&bunchnr[0]; + if(i < 0 || h < 0) + return -1; + //long ns = (h-i+this->size)%this->size; + PRINT("from idx[0] = %li, to idx[1] = %li\n", idx[0], idx[1]); + /*while(k<ns){ //TODO: memcpy + switch(this->type) + { + case typeChar: + ((char*)data_buf)[k] = ((char*)data_ptr)[i]; + break; + case typeShort: + ((short*)data_buf)[k] = ((short*)data_ptr)[i]; + break; + case typeLong: + ((long*)data_buf)[k] = ((long*)data_ptr)[i]; + break; + case typeFloat: + ((float*)data_buf)[k] = ((float*)data_ptr)[i]; + break; + case typeDouble: + ((double*)data_buf)[k] = ((double*)data_ptr)[i]; + break; + case typeLongLong: + ((long long*)data_buf)[k] = ((long long*)data_ptr)[i]; + break; + default: + break; + } + i+=1; + if(i==this->size)i=0; + k+=1; + PRINT("saving index %d to pos %d\n", i, k); + }*/ + if(unique!=1) + { + //case 1: just memcpy between indexes + if(i <= h) + { + size_tmp1 = h-i+1; + switch(type) + { + case typeChar: + case typeShort: + memcpy(&((T*)data_buf)[0], &((T*)data_ptr)[i], size_tmp1 * sizeof(T)); + break; + case typeLong: + memcpy(&((T*)data_buf)[0], &((T*)data_ptr)[i], size_tmp1 * sizeof(T)); + if(unique == 2) + memcpy(&((T)data_buf)[size_tmp1], &bunchnr_ptr[i], size_tmp1 * sizeof(T)); + //PRINT("copied from %li, to %li\n", ((long*)data_ptr)[i],((long*)data_buf)[0]); + break; + case typeFloat: + case typeDouble: + case typeLongLong: + memcpy(&((T*)data_buf)[0], &((T*)data_ptr)[i], size_tmp1 * sizeof(T)); + if(unique == 2) + { + for(k=0; k < size_tmp1; k++) + { + ((T*)data_buf)[size_tmp1+k] = (T)bunchnr_ptr[i+k]; + } + } + break; + default: + break; + } + } + //case 2: memcpy from i -> buffer size and from 0 to h + else if(i > h) + { + size_tmp1 = size - i; //i -> buffer size + size_tmp2 = h+1; //0 -> h + switch(type) + { + case typeChar: + case typeShort: + memcpy(&((T*)data_buf)[0], &((T*)data_ptr)[i], size_tmp1 * sizeof(T)); + memcpy(&((T*)data_buf)[size_tmp1], &((T*)data_ptr)[0], size_tmp2 * sizeof(T)); + break; + case typeLong: + memcpy(&((T*)data_buf)[0], &((T*)data_ptr)[i], size_tmp1 * sizeof(T)); + memcpy(&((T*)data_buf)[size_tmp1], &((T*)data_ptr)[0], size_tmp2 * sizeof(T)); + if(unique == 2) + { + memcpy(&((T*)data_buf)[size_tmp1+size_tmp2], &bunchnr_ptr[i], size_tmp1 * sizeof(T)); + memcpy(&((T*)data_buf)[size_tmp1+size_tmp2+size_tmp1], &bunchnr_ptr[0], size_tmp2 * sizeof(T)); + } + break; + case typeFloat: + case typeDouble: + case typeLongLong: + memcpy(&((T*)data_buf)[0], &((T*)data_ptr)[i], size_tmp1 * sizeof(T)); + memcpy(&((T*)data_buf)[size_tmp1], &((T*)data_ptr)[0], size_tmp2 * sizeof(T)); + if(unique == 2) + { + for(k=0; k < size_tmp1; k++) + { + ((T*)data_buf)[size_tmp1+size_tmp2+k] = (T)bunchnr_ptr[i+k]; + } + for(k=0; k < size_tmp2; k++) + { + ((T*)data_buf)[size_tmp1+size_tmp2+size_tmp1+k] = (T)bunchnr_ptr[k]; + } + } + break; + default: + break; + } + } + } + else //unique + { + //ns = (h-i+1+this->size)%this->size; + if(h > i) + { + ns = h - i; + } + else if(h < i) + { + ns = this->size - i + h; + } + else + { + ns = 0; + } + ns+=1; + PRINT("from idx[0] = %li, to idx[1] = %li, unique size=%li\n", idx[0], idx[1], ns); + while(j<ns) + { + if(last_bunchnr == bunchnr_ptr[i]) + { + i+=1; + if(i==size)i=0; + j++; + PRINT("skipped bunchnr=%li, now i=%li, j=%i\n", last_bunchnr, i,j); + continue; + } + else + { + last_bunchnr = bunchnr_ptr[i]; + j++; + PRINT("now bunchnr=%li, i=%li,j=%i\n", last_bunchnr, i,j); + } + ((T*)data_buf)[k] = ((T*)data_ptr)[i]; + i+=1; + if(i==size)i=0; + k+=1; + } + } + return 0; +}; + +/*********************************** + * read data from buffer + ***********************************/ +template <typename TL> int read_data(unsigned char unique, long idx[2], TL *data_buf, _data_array<TL> *foo){ + + long i = idx[0]; + long h = idx[1]; + long size_tmp1 = 0; + long size_tmp2 = 0; + int k = 0, j=0; + long ns; + unsigned long last_bunchnr = -1; + T *data_ptr = &data[0]; + uint32_t *bunchnr_ptr = (uint32_t *)&bunchnr[0]; + if(i < 0 || h < 0) + return -1; + //long ns = (h-i+this->size)%this->size; + PRINT("from idx[0] = %li, to idx[1] = %li\n", idx[0], idx[1]); + /*while(k<ns){ //TODO: memcpy + switch(this->type) + { + case typeChar: + ((char*)data_buf)[k] = ((char*)data_ptr)[i]; + break; + case typeShort: + ((short*)data_buf)[k] = ((short*)data_ptr)[i]; + break; + case typeLong: + ((long*)data_buf)[k] = ((long*)data_ptr)[i]; + break; + case typeFloat: + ((float*)data_buf)[k] = ((float*)data_ptr)[i]; + break; + case typeDouble: + ((double*)data_buf)[k] = ((double*)data_ptr)[i]; + break; + case typeLongLong: + ((long long*)data_buf)[k] = ((long long*)data_ptr)[i]; + break; + default: + break; + } + i+=1; + if(i==this->size)i=0; + k+=1; + PRINT("saving index %d to pos %d\n", i, k); + }*/ + if(unique!=1) + { + //case 1: just memcpy between indexes + if(i <= h) + { + size_tmp1 = h-i+1; + switch(type) + { + case typeCharArray: + case typeShortArray: + case typeLongArray: + case typeFloatArray: + case typeDoubleArray: + case typeLongLongArray: + { + int z=0; + //(unique == 2) not supported + for(k=0; k < size_tmp1; k++) + { + PRINT("k=%d size_tmp1=%d\n", k, size_tmp1); + int ret=data_ptr[i+k].extract_data(&data_buf[z]); + z+=ret; + PRINT("z=%d\n", z); + } + break; + } + default: + break; + } + } + //case 2: memcpy from i -> buffer size and from 0 to h + else if(i > h) + { + size_tmp1 = size - i; //i -> buffer size + size_tmp2 = h+1; //0 -> h + switch(type) + { + case typeCharArray: + case typeShortArray: + case typeLongArray: + case typeFloatArray: + case typeDoubleArray: + case typeLongLongArray: + { + int z=0; + //(unique == 2) not supported + for(k=0; k < size_tmp1; k++) + { + int ret=data_ptr[i+k].extract_data(&data_buf[z]); + z+=ret; + } + for(k=0; k < size_tmp2; k++) + { + int ret=data_ptr[0+k].extract_data(&data_buf[z]); + z+=ret; + } + break; + } + default: + break; + } + } + } + else //unique + { + //ns = (h-i+1+this->size)%this->size; + if(h > i) + { + ns = h - i; + } + else if(h < i) + { + ns = this->size - i + h; + } + else + { + ns = 0; + } + ns+=1; + PRINT("from idx[0] = %li, to idx[1] = %li, unique size=%li\n", idx[0], idx[1], ns); + while(j<ns) + { + if(last_bunchnr == bunchnr_ptr[i]) + { + i+=1; + if(i==size)i=0; + j++; + PRINT("skipped bunchnr=%li, now i=%li, j=%i\n", last_bunchnr, i,j); + continue; + } + else + { + last_bunchnr = bunchnr_ptr[i]; + j++; + PRINT("now bunchnr=%li, i=%li,j=%i\n", last_bunchnr, i,j); + } + ((T*)data_buf)[k] = ((T*)data_ptr)[i]; + i+=1; + if(i==size)i=0; + k+=1; + } + } + return 0; +} + +public: + +#define ELEM_SWAP_L(a,b) { register int32_t t=(a);(a)=(b);(b)=t; } +#define ELEM_SWAP_D(a,b) { register double t=(a);(a)=(b);(b)=t; } + +int read_data_filter(unsigned char unique, long idx[2], double x2, double x1, double x0, double *std, double *mean, void *median, double *kalman, int mask, void *skip) +{ + long i = idx[0]; + long h = idx[1]; + int ns; + char to_be_skipped=0; + + uint32_t last_bunchnr = -1; + int k = 0, j=0; + int count=0; + double val; + double delta = 0.0; + double M2 = 0.0; + + int low, high ; + int median_idx; + int middle, ll, hh; + unsigned long type_size; +// long *arr_l; + int32_t arr_l[MAX_MEDIAN_SAMPLE]; +// double *arr_d; + double arr_d[MAX_MEDIAN_SAMPLE]; + + T *data_ptr = &data[0]; + uint32_t *bunchnr_ptr = (uint32_t *)&bunchnr[0]; + + if(mean) + *mean=0; + if(std) + *std=0; + if(median) + { + switch(this->type) + { + case typeChar: + case typeShort: + case typeFloat: + case typeLongLong: + break; + case typeLong: + case typeDouble: + *(T *)median=0; + break; + } + } + if(kalman) + *kalman=0; + + if(mask == 0) //if no mask selected + { + //return last (average of 1) + mask = BUF_FILT_STD; + i=h; + } + + if(h > i) + ns = h - i; + else if(h < i) + ns = size - i + h; + else + ns = 0; + ns+=1; + + if(i < 0 || h < 0) + return -1; + //long ns = (h-i+this->size)%this->size; + PRINT("from idx[0] = %li, to idx[1] = %li numsample=%i\n", idx[0], idx[1], ns); + //std/mean algorithm due to Knuth + if(mask & BUF_FILT_STD) + { + while(j<ns) + { + if(unique==1) + { + if(last_bunchnr == bunchnr_ptr[i]) + { + i+=1; + if(i==this->size)i=0; + j++; + continue; + } + else + { + last_bunchnr = bunchnr_ptr[i]; + } + } + + switch(this->type) + { + case typeChar: + case typeShort: + case typeLong: + case typeLongLong: + val = x2 * ((T*)data_ptr)[i] * ((T*)data_ptr)[i] + x1 * ((T*)data_ptr)[i] + x0; + to_be_skipped = (skip != NULL) ? ((((T*)data_ptr)[i] == *(T*)skip) ? 1 : 0) : 0; + break; + case typeFloat: + case typeDouble: + val = x2 * ((T*)data_ptr)[i] * ((T*)data_ptr)[i] + x1 * ((T*)data_ptr)[i] + x0; + to_be_skipped = (skip != NULL) ? ((((T*)data_ptr)[i] == *(T*)skip) ? 1 : ((isnan(((T*)data_ptr)[i]) || isinf(((T*)data_ptr)[i])) ? 1 : 0)) : 0; + break; + case typeCharArray: + case typeShortArray: + case typeLongArray: + case typeFloatArray: + case typeDoubleArray: + case typeLongLongArray: + break; + default: + break; + } + + i+=1; + if(i==this->size)i=0; + k+=1; + j++; + if(to_be_skipped == 1) + continue; + //std/mean algorithm due to Knuth + count++; + delta = val - (*mean); + *mean = *mean + delta/count; + M2 = M2 + delta*(val - *mean); // This expression uses the new value of mean + PRINT("MEAN/STD: count=%d val=%f mean=%f\n", count, val, *mean); + } + if(count < 1) + { + return -1; + } + else if(count == 1) + { + *std = 0; + } + else + { + *std = M2/(count - 1); + *std = sqrt(*std); + } + } + if(mask & BUF_FILT_MEDIAN) + { + if(ns > MAX_MEDIAN_SAMPLE) + return -1; + switch(this->type) + { + case typeChar: + type_size = sizeof(char); + break; + case typeShort: + type_size = sizeof(short); + break; + case typeLong: + type_size = sizeof(int32_t); + break; + case typeFloat: + type_size = sizeof(float); + break; + case typeDouble: + type_size = sizeof(double); + break; + case typeLongLong: + type_size = sizeof(int64_t); + break; + default: + type_size = 0; + break; + } + + + +// allocates memory + switch(this->type) + { + case typeChar: + case typeShort: + case typeFloat: + case typeLongLong: + break; + case typeLong: + /*arr_l = malloc(type_size*ns); + if (!arr_l) + { + return -ENOMEM; + }*/ + read_data(unique%2, idx, (void *)arr_l); //not interested in bunchnumbers if unique=2 here + break; + case typeDouble: + /*arr_d = malloc(type_size*ns); + if (!arr_d) + { + return -ENOMEM; + }*/ + read_data(unique%2, idx, (void *)arr_d); //not interested in bunchnumbers if unique=2 here + break; + } + + switch(this->type) + { + case typeChar: + case typeShort: + case typeFloat: + case typeLongLong: + break; + case typeLong: + if(skip != NULL) + { + j=0; + for(i=0; i<ns; i++) + { + if(arr_l[i] != *(int32_t*)skip) + { + arr_l[j++] = arr_l[i]; + PRINT("MEDIAN: skipping... arr_l[%d]=%li\n", j, arr_l[j-1]); + } + /*else //to be skipped + */ + + } + ns = j; + } + low = 0 ; high = ns-1 ; median_idx = (low + high) / 2; + for (;;) { + PRINT("MEDIAN: low=%d high=%d median_idx=%d\n", low, high, median_idx); + if (high <= low) /* One element only */ + goto found_median; + + if (high == low + 1) { /* Two elements only */ + if (arr_l[low] > arr_l[high]) + ELEM_SWAP_L(arr_l[low], arr_l[high]); + goto found_median; + } + + /* Find median of low, middle and high items; swap into position low */ + middle = (low + high) / 2; + if (arr_l[middle] > arr_l[high]) ELEM_SWAP_L(arr_l[middle], arr_l[high]) ; + if (arr_l[low] > arr_l[high]) ELEM_SWAP_L(arr_l[low], arr_l[high]) ; + if (arr_l[middle] > arr_l[low]) ELEM_SWAP_L(arr_l[middle], arr_l[low]) ; + + /* Swap low item (now in position middle) into position (low+1) */ + ELEM_SWAP_L(arr_l[middle], arr_l[low+1]) ; + + /* Nibble from each end towards middle, swapping items when stuck */ + ll = low + 1; + hh = high; + for (;;) { + do ll++; while (arr_l[low] > arr_l[ll]) ; + do hh--; while (arr_l[hh] > arr_l[low]) ; + + if (hh < ll) + break; + + ELEM_SWAP_L(arr_l[ll], arr_l[hh]) ; + } + + /* Swap middle item (in position low) back into correct position */ + ELEM_SWAP_L(arr_l[low], arr_l[hh]) ; + + /* Re-set active partition */ + if (hh <= median_idx) + low = ll; + if (hh >= median_idx) + high = hh - 1; + } + break; + case typeDouble: + if(skip != NULL) + { + j=0; + for(i=0; i<ns; i++) + { + if(arr_d[i] != *(double*)skip) + { + arr_d[j++] = arr_d[i]; + PRINT("MEDIAN: skipping... arr_d[%d]=%f\n", j, arr_d[j-1]); + } + /*else //to be skipped + */ + + } + ns = j; + } + low = 0 ; high = ns-1 ; median_idx = (low + high) / 2; + for (;;) { + PRINT("MEDIAN: low=%d high=%d median_idx=%d\n", low, high, median_idx); + if (high <= low) /* One element only */ + goto found_median; + + if (high == low + 1) { /* Two elements only */ + if (arr_d[low] > arr_d[high]) + ELEM_SWAP_D(arr_d[low], arr_d[high]); + goto found_median; + } + + /* Find median of low, middle and high items; swap into position low */ + middle = (low + high) / 2; + if (arr_d[middle] > arr_d[high]) ELEM_SWAP_D(arr_d[middle], arr_d[high]) ; + if (arr_d[low] > arr_d[high]) ELEM_SWAP_D(arr_d[low], arr_d[high]) ; + if (arr_d[middle] > arr_d[low]) ELEM_SWAP_D(arr_d[middle], arr_d[low]) ; + + /* Swap low item (now in position middle) into position (low+1) */ + ELEM_SWAP_D(arr_d[middle], arr_d[low+1]) ; + + /* Nibble from each end towards middle, swapping items when stuck */ + ll = low + 1; + hh = high; + for (;;) { + do ll++; while (arr_d[low] > arr_d[ll]) ; + do hh--; while (arr_d[hh] > arr_d[low]) ; + + if (hh < ll) + break; + + ELEM_SWAP_D(arr_d[ll], arr_d[hh]) ; + } + + /* Swap middle item (in position low) back into correct position */ + ELEM_SWAP_D(arr_d[low], arr_d[hh]) ; + + /* Re-set active partition */ + if (hh <= median_idx) + low = ll; + if (hh >= median_idx) + high = hh - 1; + } + break; + } +found_median: + switch(this->type) + { + case typeChar: + case typeShort: + case typeFloat: + case typeLongLong: + break; + case typeLong: + *(double *)median = x2*arr_l[median_idx]*arr_l[median_idx] + x1*arr_l[median_idx] + x0; + break; + case typeDouble: + *(double *)median = x2*arr_d[median_idx]*arr_d[median_idx] + x1*arr_d[median_idx] +x0; + break; + } +// frees memory + switch(this->type) + { + case typeChar: + case typeShort: + case typeFloat: + case typeLongLong: + break; + case typeLong: + // free(arr_l); + break; + case typeDouble: + // free(arr_d); + break; + } + } + return 0; +} + + +/**************************************** + * read data calibrated from buffer + * each data is calibrated as: + * x2 * d^2 + x1 * d + x0 + * return the number of data read + ****************************************/ +int read_data_calib(unsigned char unique, long idx[2], double *data_buf, double x2, double x1, double x0){ + + long i = idx[0]; + long h = idx[1]; + int k = 0, j=0; + int ns; + uint32_t last_bunchnr = -1; + + T *data_ptr = &data[0]; + uint32_t *bunchnr_ptr = (uint32_t *)&bunchnr[0]; + + if(h > i) + ns = h - i; + else if(h < i) + ns = this->size - i + h; + else + ns = 0; + ns+=1; + + if(i < 0 || h < 0) + return -1; + //long ns = (h-i+this->size)%this->size; + //PRINT("from idx[0] = %li, to idx[1] = %li numsample=%i\n", idx[0], idx[1], ns); + while(j<ns) + { + if(unique == 1) + { + if(last_bunchnr == bunchnr_ptr[i]) + { + i+=1; + if(i==this->size)i=0; + j++; + continue; + } + else + { + last_bunchnr = bunchnr_ptr[i]; + } + } + switch(this->type) + { + case typeChar: + data_buf[k] = x2 * ((int8_t*)data_ptr)[i] * ((int8_t*)data_ptr)[i] + x1 * ((int8_t*)data_ptr)[i] + x0; + break; + case typeShort: + data_buf[k] = x2 * ((int16_t*)data_ptr)[i] * ((int16_t*)data_ptr)[i] + x1 * ((int16_t*)data_ptr)[i] + x0; + break; + case typeLong: + data_buf[k] = x2 * ((int32_t*)data_ptr)[i] * ((int32_t*)data_ptr)[i] + x1 * ((int32_t*)data_ptr)[i] + x0; + break; + case typeFloat: + data_buf[k] = x2 * ((float*)data_ptr)[i] * ((float*)data_ptr)[i] + x1 * ((float*)data_ptr)[i] + x0; + break; + case typeDouble: + data_buf[k] = x2 * ((double*)data_ptr)[i] * ((double*)data_ptr)[i] + x1 * ((double*)data_ptr)[i] + x0; + break; + case typeLongLong: + data_buf[k] = x2 * ((int64_t*)data_ptr)[i] * ((int64_t*)data_ptr)[i] + x1 * ((int64_t*)data_ptr)[i] + x0; + break; + case typeCharArray: + case typeShortArray: + case typeLongArray: + case typeFloatArray: + case typeDoubleArray: + case typeLongLongArray: + /*{ + int ret=data_ptr[i].extract_data(&data_buf[k]); + for(int zz=i; zz<i+ret; zz++) + { + data_buf[zz] = x2 * (data_buf)[zz] * (data_buf)[zz] + x1 * (data_buf)[zz] + x0; + } + break; + }*/ + default: + break; + } + if(unique == 2) + data_buf[k+ns] = (double)bunchnr_ptr[i]; //concatenate bunchnumbers + i+=1; + if(i==this->size)i=0; + k+=1; + j++; + //PRINT("saving index %ld to pos %d\n", i, k); + } + return 0; +}; +//#endif +//#ifndef __KERNEL__ //TODO: __floatdidf +//std/mean algorithm due to Knuth +template <typename TL> int read_std_calib(unsigned char unique, long idx[2], double x2, double x1, double x0, double *std, double *mean) +{ + long i = idx[0]; + long h = idx[1]; + int k = 0, j=0; + int ns; + uint32_t last_bunchnr = -1; + + int count=0; + double val; + double delta = 0; + double M2 = 0; + + TL *data_ptr = &data[0]; + uint32_t *bunchnr_ptr = (uint32_t *)&bunchnr[0]; + + *mean=0; + *std=0; + + if(h > i) + ns = h - i; + else if(h < i) + ns = this->size - i + h; + else + ns = 0; + ns+=1; + + if(i < 0 || h < 0) + return -1; + //long ns = (h-i+this->size)%this->size; + PRINT("from idx[0] = %li, to idx[1] = %li numsample=%i\n", idx[0], idx[1], ns); + while(j<ns) + { + if(unique==1) + { + if(last_bunchnr == bunchnr_ptr[i]) + { + i+=1; + if(i==this->size)i=0; + j++; + continue; + } + else + { + last_bunchnr = bunchnr_ptr[i]; + } + } + switch(this->type) + { + case typeChar: + val = x2 * ((int8_t*)data_ptr)[i] * ((int8_t*)data_ptr)[i] + x1 * ((int8_t*)data_ptr)[i] + x0; + break; + case typeShort: + val = x2 * ((int16_t*)data_ptr)[i] * ((int16_t*)data_ptr)[i] + x1 * ((int16_t*)data_ptr)[i] + x0; + break; + case typeLong: + val = x2 * ((int32_t*)data_ptr)[i] * ((int32_t*)data_ptr)[i] + x1 * ((int32_t*)data_ptr)[i] + x0; + break; + case typeFloat: + val = x2 * ((float*)data_ptr)[i] * ((float*)data_ptr)[i] + x1 * ((float*)data_ptr)[i] + x0; + break; + case typeDouble: + val = x2 * ((double*)data_ptr)[i] * ((double*)data_ptr)[i] + x1 * ((double*)data_ptr)[i] + x0; + break; + case typeLongLong: + val = x2 * ((int64_t*)data_ptr)[i] * ((int64_t*)data_ptr)[i] + x1 * ((int64_t*)data_ptr)[i] + x0; + break; + case typeCharArray: + case typeShortArray: + case typeLongArray: + case typeFloatArray: + case typeDoubleArray: + case typeLongLongArray: + { + /*int ret=data_ptr[i].extract_data(&data_buf[k]); + for(int zz=i; zz<i+ret; zz++) + { + data_ptr[zz] = x2 * ((T*)data_ptr)[zz] * ((T*)data_ptr)[zz] + x1 * ((T*)data_ptr)[zz] + x0; + }*/ + break; + } + default: + break; + } + i+=1; + if(i==this->size)i=0; + k+=1; + j++; + + //std/mean algorithm due to Knuth + count++; + delta = val - *mean; + *mean = *mean + delta/count; + M2 = M2 + delta*(val - *mean); // This expression uses the new value of mean + } + if(count < 1) + { + return -1; + } + else if(count == 1) + { + *std = 0; + } + else + { + *std = M2/(count - 1); + *std = sqrt(*std); + } + return 0; +} + +int init_kalman(double sigmav, double sigmaw, double P) +{ + long idx; + T *data_ptr = &data[0]; + + this->sigmav = sigmav; + this->sigmaw = sigmaw; + this->P = P; //initial error covariance + + //initial predicted state + if(this->counter != 0) + { + idx = (this->idx-1+this->size)%this->size; + switch(this->type) + { + case typeChar: + this->x_ = ((char*)data_ptr)[idx]; + break; + case typeShort: + this->x_ = ((short*)data_ptr)[idx]; + break; + case typeLong: + this->x_ = ((int32_t*)data_ptr)[idx]; + break; + case typeFloat: + this->x_ = ((float*)data_ptr)[idx]; + break; + case typeDouble: + this->x_ = ((double*)data_ptr)[idx]; + break; + case typeLongLong: + this->x_ = ((int64_t*)data_ptr)[idx]; + break; + default: + break; + } + } + else + { + this->x_ = 0; + } + return 0; +} + +int read_kalman(double *data_buf, unsigned int num_samples) +{ + unsigned long num; + long idx[2]; + unsigned int i; + long ind; + T *data_ptr = this->data; + double Q,R; + double S; + double K; + + Q = this->sigmav * this->sigmav; + R = this->sigmaw * this->sigmaw; + num = get_last_idx(num_samples, 0, idx); + PRINT("read_kalman entering: Q=%f R=%f P=%.11e num_samples=%ld x_=%f\n", Q, R, this->P, num, this->x_); + if(num > 0) + { + ind = idx[0]; + for(i=0; i<num; i++) + { + this->P = this->P + Q; //Prediction of the plant covariance + S = this->P + R; //Innovation Covariance + K = this->P/S; //Kalman's gain + + switch(this->type) + { + case typeChar: + this->z = ((char*)data_ptr)[ind]; + break; + case typeShort: + this->z = ((short*)data_ptr)[ind]; + break; + case typeLong: + this->z = ((int32_t*)data_ptr)[ind]; + break; + case typeFloat: + this->z = ((float*)data_ptr)[ind]; + break; + case typeDouble: + this->z = ((double*)data_ptr)[ind]; + break; + case typeLongLong: + this->z = ((int64_t*)data_ptr)[ind]; + break; + default: + break; + } + this->x_ = this->x_ + K * (this->z - this->x_); + this->P = (1 - K) * this->P; + ind = ((ind + 1) % this->size); + PRINT("read_kalman filtering: P=%.13e K=%.11e i=%d/%ld index=%ld | z=%f x_=%.20f\n", this->P,K, i, num, ind, this->z, this->x_); + } + } + else + return -1; + + *data_buf = this->x_; + return 0; +} + +/*************************************** + * read last data, last timestamp * + * and last bunch number * + * return -1 on error, 0 if OK * + ***************************************/ +int read_last(void *dat, struct timeval *timestamp, uint32_t *bunchnumber) +{ + long idx; + T *data_ptr = &data[0]; + struct timeval *time_ptr = (struct timeval *)&time[0]; + uint32_t *bunchnr_ptr = (uint32_t *)&bunchnr[0]; + if(this->counter != 0) + { + PRINT("read_last this->counter=%ld\n",this->counter); + idx = (this->idx-1+this->size)%this->size; + switch(this->type) + { + case typeChar: + memcpy(&((char*)dat)[0], &((char*)data_ptr)[idx], 1 * sizeof(char)); + break; + case typeShort: + memcpy(&((short*)dat)[0], &((short*)data_ptr)[idx], 1 * sizeof(short)); + break; + case typeLong: + memcpy(&((int32_t*)dat)[0], &((int32_t*)data_ptr)[idx], 1 * sizeof(int32_t)); + break; + case typeFloat: + memcpy(&((float*)dat)[0], &((float*)data_ptr)[idx], 1 * sizeof(float)); + break; + case typeDouble: + memcpy(&((double*)dat)[0], &((double*)data_ptr)[idx], 1 * sizeof(double)); + //PRINT("read_last: copying %f in %f\n", ((double*)data_ptr)[idx], *(double*)dat); + break; + case typeLongLong: + memcpy(&((int64_t*)dat)[0], &((int64_t*)data_ptr)[idx], 1 * sizeof(int64_t)); + break; + default: + break; + } + *bunchnumber = bunchnr_ptr[idx]; + *timestamp = time_ptr[idx]; + } + else + { + return -1; + } + return 0; +} + + +/*********************************** + * search pop time indexes + ***********************************/ +unsigned long get_time_idx(struct timeval tval_start, struct timeval tval_end, unsigned char unique, long idx[2]) +{ + long ini; + long fin; + unsigned long result; + unsigned long count; + int k=0,i; + uint32_t last_bunchnr=-1; + long tmp_idx = this->idx; + + struct timeval *time_ptr = (struct timeval *)this->time; + uint32_t *bunchnr_ptr = (uint32_t *)this->bunchnr; + + if(this->counter <= this->size) + { + ini = (tmp_idx - this->counter+this->size)%this->size; //TODO: ini = 0; ? + fin =(tmp_idx-1+this->size)%this->size; + } + else + { + ini = tmp_idx; + fin =(tmp_idx-1+this->size)%this->size; + } + idx[0] = -1; + idx[1] = -1; + PRINT("this->idx: %li, this->counter: %li, this->size: %li\n", tmp_idx, this->counter, this->size); + PRINT("ini: %li\n", ini); + PRINT("fin: %li\n", fin); + + if((tval_start.tv_sec > tval_end.tv_sec)||((tval_start.tv_sec == tval_end.tv_sec)&&(tval_start.tv_usec > tval_end.tv_usec))){//reverse order + //idx[0] = this->idx; + //idx[1] = this->idx; + idx[0] = -1; + idx[1] = -1; + + PRINT("reverse order: lower = %d, upper = %d\n", (int)tval_start.tv_sec, (int)tval_end.tv_sec); + return 0; + + } + else if((tval_start.tv_sec == tval_end.tv_sec)&&(tval_start.tv_usec == tval_end.tv_usec)){// one sample, one search + long ind = -1; + ind = search_time(tval_start, ini, fin); + + PRINT("one sample: tval_start, ini, fin: %d, %li, %li\n", (int)tval_start.tv_sec, ini, fin); + + if(ind!=-1){ + idx[0] = ind; + idx[1] = ind; + + PRINT("found idx[0] = %li, idx[1] = %li, ind = %li\n", idx[0], idx[1], ind); + if(idx[1] == ini) //if returned first index + { + if(tv_compare(time_ptr[ini],tval_end) > 0) //and if tval_end is older than the first present in buffer + { + idx[0] = -1; // -> not found + idx[1] = -1; // -> not found + return 0; + } + } + + } + else + { + PRINT("not found \n"); + return 0; + } + + } + else{// more samples + long ind = -1; + + PRINT("right order: tval_start.sec, tval_end.sec, ini, fin: %d, %d, %li, %li\n", (int)tval_start.tv_sec, (int)tval_end.tv_sec, ini, fin); + PRINT("right order: lower = %d, upper = %d\n", (int)tval_start.tv_sec, (int)tval_end.tv_sec); + + ind = search_time(tval_start, ini, fin); + if(ind!=-1) + { + idx[0] = ind; + + PRINT("found idx[0] = %li\n", idx[0]); + ini = ind; + } + else + { + PRINT("not found tval_start\n"); + } + + ind = -1; + ind = search_time(tval_end, ini, fin); + if(ind!=-1) + { + idx[1] = ind; + + PRINT("found idx[1] = %li\n", idx[1]); + + } + else + { + PRINT("not found tval_end\n"); + } + + if(idx[1] == ini && idx[1] == idx[0]) //if tval_end and tval_start returned first index + { + if(tv_compare(time_ptr[ini],tval_end) > 0) //and if tval_end is older than the first present in buffer + { + idx[0] = -1; // -> not found + idx[1] = -1; // -> not found + return 0; + } + } + + } + if(idx[1] > idx[0]) + count = idx[1] - idx[0]; + else if(idx[1] < idx[0]) + count = this->size - idx[0] + idx[1]; + else + count = 0; + result = count+1; + + if(unique==1) + { + count = 0; + i=idx[0]; + while(k<result) + { + if(last_bunchnr != bunchnr_ptr[i]) + { + last_bunchnr = bunchnr_ptr[i]; + count++; + } + i+=1; + if(i==this->size)i=0; + k++; + } + result = count; + } + return result; +}; + +/*********************************** + * search pop bunch indexes + ***********************************/ +unsigned long get_bunch_idx(uint32_t bunch_start, uint32_t bunch_end, unsigned char unique, long idx[2]) +{ + long ini,fin; + unsigned long result,count; + int k=0,i; + uint32_t last_bunchnr=-1; + long tmp_idx = this->idx; + uint32_t *bunchnr_ptr = (uint32_t *)&bunchnr[0]; + + if(this->counter <= this->size) + { + ini = (tmp_idx - this->counter+this->size)%this->size; //TODO: ini = 0; ? + fin =(tmp_idx-1+this->size)%this->size; + } + else + { + ini = tmp_idx; + fin =(tmp_idx-1+this->size)%this->size; + } + idx[0] = -1; + idx[1] = -1; + //PRINT("buffer=0x%lx\n", (unsigned long)buffer); //TEMP!! + PRINT("this->idx: %li, this->counter: %li, this->size: %li\n", tmp_idx, this->counter, this->size); + PRINT("ini: %li\n", ini); + PRINT("fin: %li\n", fin); + + if(bunch_start > bunch_end) + {//reverse order + //idx[0] = this->idx; + //idx[1] = this->idx; + idx[0] = -1; + idx[1] = -1; + + PRINT("reverse order: lower = %li, upper = %li\n", bunch_start, bunch_end); + return 0; + } + else if(bunch_start == bunch_end) + {// one sample, one search + long ind = -1; + ind = search_limit(bunch_start, ini, fin, unique); + + PRINT("one sample: bunch_start, ini, fin: %li, %li, %li\n", bunch_start, ini, fin); + idx[0] = ind; + idx[1] = ind; + if(ind!=-1) + { + PRINT("found idx[0] = %li, idx[1] = %li, ind = %li\n", idx[0], idx[1], ind); + if((bunchnr_ptr[ini] > bunch_end) && (unique != 2)) //and if bunch_end is older than the first present in buffer + { + idx[0] = -1; // -> not found + idx[1] = -1; // -> not found + return 0; + } + } + else + { + PRINT("not found \n"); + } + if((idx[0] == -1) || (idx[1] == -1)) + return 0; + + } + else + {// more samples + long ind = -1; + + PRINT("right order: bunch_start, bunch_end, ini, fin: %li, %li, %li, %li\n", bunch_start, bunch_end, ini, fin); + PRINT("right order: lower = %li, upper = %li\n", bunch_start, bunch_end); + + ind = search_limit(bunch_start, ini, fin, unique); + idx[0] = ind; + if(ind!=-1){ + + PRINT("found idx[0] = %li\n", idx[0]); + ini = ind; + } + else + { + PRINT("not found bunch_start\n"); + } + + ind = search_limit(bunch_end, ini, fin, unique); + idx[1] = ind; + if(ind!=-1){ + PRINT("found idx[1] = %li\n", idx[1]); + } + else + { + PRINT("not found bunch_end\n"); + } + + if(idx[1] == ini && idx[1] == idx[0]) //if bunch_end and bunch_start returned first index + { + if((bunchnr_ptr[ini] > bunch_end) && (unique != 2)) //and if bunch_end is older than the first present in buffer + { + idx[0] = -1; // -> not found + idx[1] = -1; // -> not found + return 0; + } + } + if((idx[0] == -1) || (idx[1] == -1)) + return 0; + + } + if(idx[1] > idx[0]) + count = idx[1] - idx[0]; + else if(idx[1] < idx[0]) + count = this->size - idx[0] + idx[1]; + else + count = 0; + result = count+1; + + if(unique==1) + { + count = 0; + i=idx[0]; + while(k<result) + { + if(last_bunchnr != bunchnr_ptr[i]) + { + last_bunchnr = bunchnr_ptr[i]; + count++; + } + i+=1; + if(i==this->size)i=0; + k++; + } + result = count; + } + return result; +}; + +/*********************************** + * search pop last indexes + ***********************************/ +unsigned long get_last_idx(unsigned long last_samples, unsigned char unique, long idx[2]) +{ + unsigned long result; + int k=0,i,j=0,z; + uint32_t last_bunchnr=-1; + long tmp_idx = this->idx; + uint32_t *bunchnr_ptr = (uint32_t *)&bunchnr[0]; + PRINT("requested %li values, pushed %li values, size=%li\n",last_samples, this->counter, this->size); + PRINT("type=%d idx=%li mode=%li fill_hole=%li\n",this->type, tmp_idx,this->mode,this->fill_hole); + //PRINT("buff=0x%lx data=0x%lx time=0x%lx bunchnr=0x%lx\n",(unsigned long)buffer, (unsigned long)this->data,(unsigned long)this->time,(unsigned long)this->bunchnr); + + if(last_samples > this->size) + last_samples = this->size; + if(last_samples > this->counter) + last_samples = this->counter; + if(this->counter != 0) + { + if(unique!=1) + { + idx[1] = (tmp_idx-1+this->size)%this->size; + idx[0] = (tmp_idx - last_samples + this->size)%this->size; + } + else + { + i = tmp_idx; + //look for the first value with this bunchnumber + do + { + i = (i-1+this->size)%this->size; + j = (i-1+this->size)%this->size; + k++; + if(k>this->counter) + { + idx[1]=i; + idx[0]=i; + return 1; + } + } + while(bunchnr_ptr[i] == bunchnr_ptr[j]); + + idx[1] = i; + last_bunchnr = bunchnr_ptr[i]; + j=1; + k=1; + //go back of last_samples bunch numbers + while(k<last_samples) + { + j++; + if(j > this->counter) + break; + i = (i-1+this->size)%this->size; + if(last_bunchnr != bunchnr_ptr[i]) + { + last_bunchnr = bunchnr_ptr[i]; + k++; + } + } + z = j; + //look for the first value with this bunchnumber + j = (i-1+this->size)%this->size; + while(bunchnr_ptr[i] == bunchnr_ptr[j]) + { + i = (i-1+this->size)%this->size; + j = (i-1+this->size)%this->size; + z++; + if(z>this->counter) + { + idx[1]=i; + idx[0]=i; + return 1; + } + } + idx[0] = i; + return k; + } + } + else + { + idx[0] = -1; + idx[1] = -1; + return 0; + } + if(idx[1] > idx[0]) + result = idx[1] - idx[0]; + else if(idx[1] < idx[0]) + result = this->size - idx[0] + idx[1]; + else + result = 0; + return result+1; +}; + +/*********************************** + * set method for mode + ***********************************/ +int set_mode(unsigned long mod) +{ + switch(mod){ + case BUF_RT_LINEAR: //buffer not circular + case BUF_RT_CIRCULAR: //buffer circular + this->mode = mod; + return 0; + break; + default: //unexpected value + PRINT("value not allowed\n"); + return -1; + break; + } +}; + +/*********************************** + * get method for mode + ***********************************/ +ulong get_mode() +{ + return this->mode; +}; + +/*********************************** + * get method for size + ***********************************/ +long get_size() +{ + return this->size; +}; + +/*********************************** + * get data size + ***********************************/ +long get_data_size() +{ + return get_data_size(identity<T>()); +}; +private: +template<typename TL> +long get_data_size(identity<TL>) +{ + return (size > 0) ? 1 : 0; +} +template<typename TL> +long get_data_size(identity<_data_array<TL> >) +{ + return (size > 0) ? data[0].get_count() : 0; +} + +public: + +/*********************************** + * set method for fill_hole + ***********************************/ +int set_fill_hole(unsigned long fill){ + + switch(fill){ + case BUF_RT_NO_FILL: // 0 = no fill + case BUF_RT_FILL_1: // 1 = fill with 0xffffffff or NaN + case BUF_RT_FILL_PREV: // 2 = fill with previous value inside the buffer + case BUF_RT_FILL_0: // 3 = fill with 0 + this->fill_hole = fill; + return 0; + break; + default: //unexpected value + + PRINT("value not allowed\n"); + + return -1; + break; + } +}; + +/*********************************** + * get method for fill_hole + ***********************************/ +ulong get_fill_hole(){ + return this->fill_hole; +}; + +/*********************************** + * get method for type + ***********************************/ +/*type_t get_type() +{ + switch(this->type) + { + case typeChar: + PRINT("type is char: %d\n",this->type); + break; + case typeShort: + PRINT("type is short: %d\n",this->type); + break; + case typeLong: + PRINT("type is long: %d\n",this->type); + break; + case typeFloat: + PRINT("type is float: %d\n",this->type); + break; + case typeDouble: + PRINT("type is double: %d\n",this->type); + break; + case typeLongLong: + PRINT("type is long long: %d\n",this->type); + break; + default: + break; + } + return this->type; +};*/ + +/*********************************** + * search method + ***********************************/ +long search_limit(uint32_t nr, long lower, long upper, unsigned char unique) +{ + int found = -1; + long ini = lower; + long fin = upper; + long med = (ini+((fin-ini+this->size)%this->size)/2)%this->size; + long result = med; + int counter = 0; + + uint32_t *bunchnr_ptr = (uint32_t *)this->bunchnr; + + PRINT("searching from ini = %li, to fin = %li\n", ini, fin); + if((ini==fin) && (bunchnr_ptr[ini] != nr)) + { + if(unique != 2) + return -1; + else + return ini; + } + while(found<0) + { + if(bunchnr_ptr[med] == nr) + { //equals + found = 0; + while(bunchnr_ptr[(med-1+this->size)%this->size]==nr && med >= lower) + { + med = (med-1+this->size)%this->size; + PRINT("changing med to %li\n", med); + } + PRINT("found med=%li, bunchnr[med]=%li, med-1=%li, bunchnr[med-1]=%li\n", med, bunchnr_ptr[med], (med-1+this->size)%this->size, bunchnr_ptr[(med-1+this->size)%this->size]); + result = med; + } + else + { + if(((fin-ini+this->size)%this->size)==1) + { + //PRINT("in step=1: ini=%li, fin=%li bunchnr[ini]=%li bunchnr[fin]=%li\n", ini, fin ,bunchnr_ptr[ini], bunchnr_ptr[fin]); + //step == 1, last test + if(bunchnr_ptr[ini]==nr) + { + found = 0; + while(bunchnr_ptr[(ini-1+this->size)%this->size]==nr && ini >= lower) + { + ini = (ini-1+this->size)%this->size; + PRINT("changing ini to %li\n", ini); + } + PRINT("found ini=%li, bunchnr[ini]=%li, ini-1=%li, bunchnr[ini-1]=%li\n", ini, bunchnr_ptr[ini], (ini-1+this->size)%this->size, bunchnr_ptr[(ini-1+this->size)%this->size]); + result = ini; + } + else if(bunchnr_ptr[ini]>nr) + { + found = 0; + if(unique != 2) + result = -1; + else + result = ini; + } + else if(bunchnr_ptr[fin]==nr) + { + found = 0; + while(bunchnr_ptr[(fin-1+this->size)%this->size]==nr && fin >= lower) + { + fin = (fin-1+this->size)%this->size; + PRINT("changing fin to %li\n", fin); + } + PRINT("found fin=%li, bunchnr[fin]=%li, fin-1=%li, bunchnr[fin-1]=%li\n", fin, bunchnr_ptr[fin], (fin-1+this->size)%this->size, bunchnr_ptr[(fin-1+this->size)%this->size]); + result = fin; + } + else if(bunchnr_ptr[fin]<nr) + { + found = 0; + if(unique != 2) + result = -1; + else + result = fin; + } + //between ini and fin, but step == 1, hole? + else + { + found = 0; + //result = ini; + if(unique != 2) + result = -1; + else + result = ini; + } + break; + } + med = (ini+((fin-ini+this->size)%this->size)/2)%this->size; + if(bunchnr_ptr[med] < nr) + { //lower + ini = med/*%this->size*/; + //PRINT("adjusted ini: ini=%li, fin=%li bunchnr[ini]=%li\n", ini, fin, bunchnr_ptr[ini]); + } + else + { //greater + fin = med/*%this->size*/; + //PRINT("adjusted fin: ini=%li, fin=%li bunchnr[fin]=%li\n", ini, fin, bunchnr_ptr[fin]); + } + } + counter+=1; + } + + PRINT("Result: idx=%li bunchnr[idx]=%li bunchnr[lower]=%li bunchnr[upper]=%li\n", result, (result != -1) ? bunchnr_ptr[result] : -1, bunchnr_ptr[lower], bunchnr_ptr[upper]); + + return result; +}; + +int tv_compare(struct timeval ts1, struct timeval ts2) +{ + if(ts1.tv_sec < ts2.tv_sec) + return - 1; + else if(ts1.tv_sec == ts2.tv_sec) + { + if(ts1.tv_usec < ts2.tv_usec) + return -1; + if(ts1.tv_usec == ts2.tv_usec) + return 0; + else + return 1; + } + else + return 1; + +} + +long search_time(struct timeval p, long lower, long upper) +{ + int found = -2; + long ini = lower; + long fin = upper; + long med = (ini+((fin-ini+this->size)%this->size)/2)%this->size; + long result = med; +// long reslow = med; +// long reshi = med; + int counter = 0; +// int counter2 = 0; + + struct timeval *time_ptr = (struct timeval *)this->time; + + + PRINT("searching from ini = %li, to fin = %li\n", ini, fin); +#if 0 + while(found<0){ + if(time_ptr[med].tv_sec == p.tv_sec){ //equals + found +=1; + reslow = med; + reshi = med; + while(time_ptr[reslow].tv_sec == p.tv_sec){ + reslow=(reslow-1+this->size)%this->size; + } + while(time_ptr[reshi].tv_sec == p.tv_sec){ + reshi = (reshi+1)%this->size; + } + reslow = (reslow+1)%this->size; + reshi = (reshi-1+this->size)%this->size; + } + else{ + if(((fin-ini+this->size)%this->size)==1) + { + if(time_ptr[fin].tv_sec!=p.tv_sec){ + found +=1; + reslow = ini; + } + else{ + found +=1; + reshi = fin; + } + } + med = (ini+((fin-ini+this->size)%this->size)/2)%this->size; + if(time_ptr[med].tv_sec < p.tv_sec){ //lower + ini = med/*%this->size*/; + } + else{ //greater + fin = med/*%this->size*/; + } + } + counter+=1; + } + + PRINT("reslow %li reshi %li\n", reslow, reshi); + + + //finding usec + found = -1; + + PRINT("searching from reslow = %li, to reshi = %li\n", reslow, reshi); + + med = reslow+((reshi-reslow+this->size)%this->size)/2; + result = med; + while(found<0){ + if(time_ptr[med].tv_usec == p.tv_usec){ //equals + found = 0; + while(time_ptr[med].tv_usec == p.tv_usec){ + med=(med-1+this->size)%this->size; + } + result =(med+1)%this->size; + } + else{ + if(((reshi-reslow+this->size)%this->size)==1) + { + if(time_ptr[reshi].tv_usec!=p.tv_usec){ + found = 0; + result = reslow; + } + else{ + found = 0; + result = reshi; + } + } + med = reslow+((reshi-reslow+this->size)%this->size)/2; + if(time_ptr[med].tv_usec < p.tv_usec){ //lower + reslow = med%this->size; + } + else{ //greater + reshi = med%this->size; + } + } + counter2+=1; + } +#else + if((ini==fin) && (tv_compare(time_ptr[ini],p)!=0)) + return -1; + while(found<0){ + if(tv_compare(time_ptr[med],p)==0){ //equals + found = 0; + result = med; + } + else{ + if(((fin-ini+this->size)%this->size)==1) + { + //step == 1, last test + if(tv_compare(time_ptr[ini],p)>=0){ //equal to p, or p lower than the min + found = 0; + result = ini; + } + else if(tv_compare(time_ptr[fin],p)<=0){ //equal to p, or p greater than the max + found = 0; + result = fin; + } + //between ini and fin, but step == 1 + else{ + found = 0; + result = ini; + } + break; + } + med = (ini+((fin-ini+this->size)%this->size)/2)%this->size; + if(tv_compare(time_ptr[med],p)<0){ //lower + ini = med/*%this->size*/; + } + else{ //greater + fin = med/*%this->size*/; + } + } + counter+=1; + } +#endif + PRINT("Searched %d.%d, result %li time[lower]=%d.%d time[upper]=%d.%d\n", (int)p.tv_sec, (int)p.tv_usec, result, (int)time_ptr[lower].tv_sec, (int)time_ptr[lower].tv_usec, (int)time_ptr[upper].tv_sec, (int)time_ptr[upper].tv_usec); + + + return result; + +}; + +}; +} //namespace tbuffer + +#endif //__TBUFFER_H diff --git a/src/tcheck_get_rt_buffer.hpp b/src/tcheck_get_rt_buffer.hpp new file mode 100644 index 0000000..33894a7 --- /dev/null +++ b/src/tcheck_get_rt_buffer.hpp @@ -0,0 +1,394 @@ +//============================================================================= +// +// file : tcheck_get_rt_buffer.hpp +// +// description : Include with utility to read rt buffers. +// +// project : RT BUFFER +// +// $Author: graziano $ +// +// $Revision: 1.1 $ +// +// $Log: tcheck_get_rt_buffer.hpp,v $ +// Revision 1.1 2018-03-26 13:46:42 graziano +// first commit +// +// Revision 1.1 2015-09-08 09:00:52 graziano +// upgraded to template buffer +// +// +// +// +// copyleft : Sincrotrone Trieste S.C.p.A. +// Strada Statale 14 - km 163,5 in AREA Science Park +// 34012 Basovizza (TS) +// ITALY +// +//============================================================================= +#ifndef _T_CHECK_GET_RT_BUFFER_H +#define _T_CHECK_GET_RT_BUFFER_H + +#include <tango.h> +#include <tbuffer.hpp> + +namespace tbuffer +{ + +//+------------------------------------------------------------------ +/** + * method: check_get_data_param + * + * description: get data indexes + * + * @param[in] buffer search params + * @param[in] rt buffer + * @param[out] buffer indexes + * @param[out] num samples between indexes + * @param[in] unique + * @return + * + */ +//+------------------------------------------------------------------ +template <typename T> void tcheck_get_data_param(const Tango::DevVarLongArray *argin, buffer_t<T> *tbuf, long *buf_idx, long *data_size, unsigned char *unique) +{ + long nargin = argin->length(); + long ret_num_samples; + //struct _buffer *locbuf; + long mode = (*argin)[0]; + + if ((*argin)[0] <= BUF_GET_TIME_MODE) + *unique = 0; + else if((*argin)[0] <= BUF_GET_TIME_UNIQUE_MODE) + *unique = 1; + else + *unique = 2; + /* non unique modes (0,1,2); unique modes (3,4,5); bunch modes (6,7,8) */ + mode = mode - (*unique) * 3; + + /* get last values */ + if (nargin == 2) + { + long num_samples = (*argin)[1]; + + if ((num_samples < 0) || (num_samples > tbuf->get_size())) + { + Tango::Except::throw_exception ( + (const char *)"Invalid number of data requested", + (const char *)"Failed to retreive last data", + (const char *)__FUNCTION__); + } + + if (mode == BUF_GET_LAST_MODE) + { + ret_num_samples = tbuf->get_last_idx(num_samples, *unique, buf_idx); + } + else + { + Tango::Except::throw_exception ( + (const char *)"Wrong get mode parameter (0,1,2)", + (const char *)"Failed to retreive last data", + (const char *)__FUNCTION__); + } + + if (ret_num_samples != num_samples && (*unique != 2)) + { + stringstream tmp; + tmp << " Can't retreive all data requested: requested="<<num_samples << " received="<<ret_num_samples; + //DEBUG_STREAM << __FUNCTION__ << tmp.str(); + Tango::Except::throw_exception ( + (const char *)"Can't retreive all data requested", + tmp.str(), + (const char *)__FUNCTION__); + } + else if (ret_num_samples == 0) + { + stringstream tmp; + tmp << " Can't retreive all data requested: requested="<<num_samples << " but buffer empty!"; + //DEBUG_STREAM << __FUNCTION__ << tmp.str(); + Tango::Except::throw_exception ( + (const char *)"Can't retreive all data requested", + tmp.str(), + (const char *)__FUNCTION__); + } + *data_size = ret_num_samples; + if(*unique == 2) + *data_size *= 2; //concatenate bunchnumbers + } + /* get bunch mode values */ + else if (nargin == 3) + { + long bunch_start = (*argin)[1], bunch_end = (*argin)[2]; + + if (((bunch_end-bunch_start) < 0) || ((bunch_end-bunch_start) > tbuf->get_size())) + { + stringstream out_stream; + out_stream << "Invalid bunch numbers: bunch start=" << bunch_start << ", bunch end=" << bunch_end << ends; + //DEBUG_STREAM << __FUNCTION__ << out_stream.str(); + Tango::Except::throw_exception ( + out_stream.str(), + (const char *)"Failed to retreive bunch data", + (const char *)__FUNCTION__); + } + + if (mode == BUF_GET_BUNCH_MODE) + { + ret_num_samples = tbuf->get_bunch_idx(bunch_start, bunch_end, *unique, buf_idx); + } + else + { + stringstream out_stream; + out_stream << "Invalid mode=" << mode << ends; + //DEBUG_STREAM << __FUNCTION__ << out_stream.str(); + Tango::Except::throw_exception ( + out_stream.str(), + (const char *)"Failed to retrive bunch data", + (const char *)__FUNCTION__); + } + + /* check data size */ + if ((((ret_num_samples-1) != (bunch_end-bunch_start)) && (*unique ==1)) || + (((ret_num_samples-1) < (bunch_end-bunch_start)) && (*unique == 0))) + { + stringstream out_stream; + out_stream << "Invalid bunch numbers: bunch start=" << bunch_start << ", bunch end=" << bunch_end << ", ret_num_samples=" << + (ret_num_samples-1) << ends; + //DEBUG_STREAM << __FUNCTION__ << out_stream.str(); + Tango::Except::throw_exception ( + (const char *)"Failed to retreive bunch data", + out_stream.str(), + (const char *)__FUNCTION__); + } + else if(ret_num_samples == 0) + { + stringstream out_stream; + out_stream << "Invalid bunch numbers."; + if(buf_idx[0] == -1) + out_stream<< " Bunch start=" << bunch_start << " not valid."; + if(buf_idx[1] == -1) + out_stream<< " Bunch end=" << bunch_end << " not valid."; + out_stream << ends; + //DEBUG_STREAM << __FUNCTION__ << out_stream.str(); + Tango::Except::throw_exception ( + (const char *)"Failed to retreive bunch data", + out_stream.str(), + (const char *)__FUNCTION__); + } + *data_size = ret_num_samples; + if(*unique == 2) + *data_size *= 2; //concatenate bunchnumbers + } + /* get time mode values */ + else if (nargin == 5) + { + struct timeval time_start, time_end; + + time_start.tv_sec = (*argin)[1]; time_start.tv_usec = (*argin)[2]; + time_end.tv_sec = (*argin)[3]; time_end.tv_usec = (*argin)[4]; + + if (((time_end.tv_sec-time_start.tv_sec)*1000000+(time_end.tv_usec-time_start.tv_usec)) < 0) + { + Tango::Except::throw_exception ( + (const char *)"Invalid time slice requested", + (const char *)"Failed to retreive timed data", + (const char *)__FUNCTION__); + } + + if (mode == BUF_GET_TIME_MODE) + { + ret_num_samples = tbuf->get_time_idx(time_start, time_end, *unique, buf_idx); + } + else + { + Tango::Except::throw_exception ( + (const char *)"Wrong get mode parameter (0,1,2)", + (const char *)"Failed to retreive timed data", + (const char *)__FUNCTION__); + } + *data_size = ret_num_samples; + if(*unique == 2) + *data_size *= 2; //concatenate bunchnumbers + } + /* invalid number of input parameters */ + else + { + Tango::Except::throw_exception ( + (const char *)"Invalid number of input parameters", + (const char *)"Failed to get data", + (const char *)__FUNCTION__); + } + +} + +template <typename T> void tcheck_get_data_param(const Tango::DevVarLongArray *argin, buffer_t<tbuffer::_data_array<T> > *tbuf, long *buf_idx, long *data_size, unsigned char *unique) +{ + long nargin = argin->length(); + long ret_num_samples; + //struct _buffer *locbuf; + long mode = (*argin)[0]; + + if ((*argin)[0] <= BUF_GET_TIME_MODE) + *unique = 0; + else if((*argin)[0] <= BUF_GET_TIME_UNIQUE_MODE) + *unique = 1; + else + *unique = 2; + /* non unique modes (0,1,2); unique modes (3,4,5); bunch modes (6,7,8) */ + mode = mode - (*unique) * 3; + + /* get last values */ + if (nargin == 2) + { + long num_samples = (*argin)[1]; + + if ((num_samples < 0) || (num_samples > tbuf->get_size())) + { + Tango::Except::throw_exception ( + (const char *)"Invalid number of data requested", + (const char *)"Failed to retreive last data", + (const char *)__FUNCTION__); + } + + if (mode == BUF_GET_LAST_MODE) + { + ret_num_samples = tbuf->get_last_idx(num_samples, *unique, buf_idx); + } + else + { + Tango::Except::throw_exception ( + (const char *)"Wrong get mode parameter (0,1,2)", + (const char *)"Failed to retreive last data", + (const char *)__FUNCTION__); + } + + if (ret_num_samples != num_samples && (*unique != 2)) + { + stringstream tmp; + tmp << " Can't retreive all data requested: requested="<<num_samples << " received="<<ret_num_samples; + //DEBUG_STREAM << __FUNCTION__ << tmp.str(); + Tango::Except::throw_exception ( + (const char *)"Can't retreive all data requested", + tmp.str(), + (const char *)__FUNCTION__); + } + else if (ret_num_samples == 0) + { + stringstream tmp; + tmp << " Can't retreive all data requested: requested="<<num_samples << " but buffer empty!"; + //DEBUG_STREAM << __FUNCTION__ << tmp.str(); + Tango::Except::throw_exception ( + (const char *)"Can't retreive all data requested", + tmp.str(), + (const char *)__FUNCTION__); + } + *data_size = ret_num_samples; + if(*unique == 2) + *data_size *= 2; //concatenate bunchnumbers + } + /* get bunch mode values */ + else if (nargin == 3) + { + long bunch_start = (*argin)[1], bunch_end = (*argin)[2]; + + if (((bunch_end-bunch_start) < 0) || ((bunch_end-bunch_start) > tbuf->get_size())) + { + stringstream out_stream; + out_stream << "Invalid bunch numbers: bunch start=" << bunch_start << ", bunch end=" << bunch_end << ends; + //DEBUG_STREAM << __FUNCTION__ << out_stream.str(); + Tango::Except::throw_exception ( + out_stream.str(), + (const char *)"Failed to retreive bunch data", + (const char *)__FUNCTION__); + } + + if (mode == BUF_GET_BUNCH_MODE) + { + ret_num_samples = tbuf->get_bunch_idx(bunch_start, bunch_end, *unique, buf_idx); + } + else + { + stringstream out_stream; + out_stream << "Invalid mode=" << mode << ends; + //DEBUG_STREAM << __FUNCTION__ << out_stream.str(); + Tango::Except::throw_exception ( + out_stream.str(), + (const char *)"Failed to retrive bunch data", + (const char *)__FUNCTION__); + } + + /* check data size */ + if ((((ret_num_samples-1) != (bunch_end-bunch_start)) && (*unique ==1)) || + (((ret_num_samples-1) < (bunch_end-bunch_start)) && (*unique == 0))) + { + stringstream out_stream; + out_stream << "Invalid bunch numbers: bunch start=" << bunch_start << ", bunch end=" << bunch_end << ", ret_num_samples=" << + (ret_num_samples-1) << ends; + //DEBUG_STREAM << __FUNCTION__ << out_stream.str(); + Tango::Except::throw_exception ( + (const char *)"Failed to retreive bunch data", + out_stream.str(), + (const char *)__FUNCTION__); + } + else if(ret_num_samples == 0) + { + stringstream out_stream; + out_stream << "Invalid bunch numbers."; + if(buf_idx[0] == -1) + out_stream<< " Bunch start=" << bunch_start << " not valid."; + if(buf_idx[1] == -1) + out_stream<< " Bunch end=" << bunch_end << " not valid."; + out_stream << ends; + //DEBUG_STREAM << __FUNCTION__ << out_stream.str(); + Tango::Except::throw_exception ( + (const char *)"Failed to retreive bunch data", + out_stream.str(), + (const char *)__FUNCTION__); + } + *data_size = ret_num_samples; + if(*unique == 2) + *data_size *= 2; //concatenate bunchnumbers + } + /* get time mode values */ + else if (nargin == 5) + { + struct timeval time_start, time_end; + + time_start.tv_sec = (*argin)[1]; time_start.tv_usec = (*argin)[2]; + time_end.tv_sec = (*argin)[3]; time_end.tv_usec = (*argin)[4]; + + if (((time_end.tv_sec-time_start.tv_sec)*1000000+(time_end.tv_usec-time_start.tv_usec)) < 0) + { + Tango::Except::throw_exception ( + (const char *)"Invalid time slice requested", + (const char *)"Failed to retreive timed data", + (const char *)__FUNCTION__); + } + + if (mode == BUF_GET_TIME_MODE) + { + ret_num_samples = tbuf->get_time_idx(time_start, time_end, *unique, buf_idx); + } + else + { + Tango::Except::throw_exception ( + (const char *)"Wrong get mode parameter (0,1,2)", + (const char *)"Failed to retreive timed data", + (const char *)__FUNCTION__); + } + *data_size = ret_num_samples; + if(*unique == 2) + *data_size *= 2; //concatenate bunchnumbers + } + /* invalid number of input parameters */ + else + { + Tango::Except::throw_exception ( + (const char *)"Invalid number of input parameters", + (const char *)"Failed to get data", + (const char *)__FUNCTION__); + } + +} + +}//namespace +#endif //_T_CHECK_GET_RT_BUFFER_H -- GitLab