diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000000000000000000000000000000000000..32ea79976bb3f4ba8465ba4018c584782610be14 --- /dev/null +++ b/.gitignore @@ -0,0 +1,2 @@ +MYNOTES.txt +MSG.txt diff --git a/Makefile b/Makefile new file mode 100644 index 0000000000000000000000000000000000000000..526f64b6d39e77760f29c6c2e3223d2bae1789f5 --- /dev/null +++ b/Makefile @@ -0,0 +1,86 @@ +NAME_SRV = pespccdstage-srv + +CXXFLAGS = +LDFLAGS = -litpp + +#CXXFLAGS += -D_DBG_INIT +CXXFLAGS += -D_DBG_PARAMETERS +#CXXFLAGS += -D_DBG_TARDISTAGE + +#CXXFLAGS += -D_DBG_UPDATTR + +#CXXFLAGS += -D_DBG_CALCNL2XZ +#CXXFLAGS += -D_DBG_CALCXZ2BR +#CXXFLAGS += -D_DBG_ROTCENTER +#CXXFLAGS += -D_DBG_DYNATTR + +#CXXFLAGS += -D_DBG_CALCXZ2NL +#CXXFLAGS += -D_DBG_XZ2NL +#CXXFLAGS += -D_DBG_PP2P + +#CXXFLAGS += -D_DONT_WRITECENTERX +#CXXFLAGS += -D_DONT_WRITE_BR + +#CXXFLAGS += -D_DBG_CALCBR2XZ + +#CXXFLAGS += -D_WITHOUT_DIPLACEMENT + +##---------------------------------------------------------------------------- +# +# +ifeq ($(HOME), /home/abrami) + DO_LOCAL ?= yes +else + DO_LOCAL = no +endif + +SITE = $(shell a=`lsb_release -si`; b=`lsb_release -sr`; c=`uname -m`; echo $$a"_"$$b"_"$$c) +LOCAL_BASE = $(shell echo $$HOME)/my_runtime + +LOCAL_INC = $(LOCAL_BASE)/include +LOCAL_LIB = $(LOCAL_BASE)/site/$(SITE)/lib +LOCAL_BIN = $(LOCAL_BASE)/site/$(SITE)/bin + +ifeq ($(DO_LOCAL), yes) + CXXFLAGS += -I $(LOCAL_INC) + LDFLAGS += -L $(LOCAL_LIB) +endif + +# +# +##---------------------------------------------------------------------------- + +HAVE_SAFETYMANGER=no + +ifeq ($(HAVE_SAFETYMANGER), yes) + CXXFLAGS += -DHAVE_SAFETYMANAGER + ifeq ($(DO_LOCAL), yes) + CXXFLAGS += -I $(LOCAL_INC)/libsafetymanager + else + CXXFLAGS += -I /runtime/include/libsafetymanager + endif +endif + +ifeq ($(DO_LOCAL), yes) + CXXFLAGS += -I $(LOCAL_INC)/libaxisutils +else + CXXFLAGS += -I /runtime/include/libaxisutils +endif + +RELEASE := GIT:: $(shell git describe --dirty) +CXXFLAGS += -D'RELEASE="$(RELEASE)"' +REPO := GIT:: $(shell git config --get remote.origin.url) +LOC_REPO := GIT:: $(shell git rev-parse --show-toplevel) +CXXFLAGS += -D'REPO="$(LOC_REPO)"' + +include ../makefiles/Make-9.3.3.in + +LDFLAGS += -laxisutils + +ifeq ($(HAVE_SAFETYMANGER), yes) + LDFLAGS += -lsafetymanager +endif + +.PHONY: install +install: + @[ $(DO_LOCAL) = yes ] && cp -f bin/$(NAME_SRV) $(LOCAL_BIN) diff --git a/src/ClassFactory.cpp b/src/ClassFactory.cpp new file mode 100644 index 0000000000000000000000000000000000000000..58c32d39df8deee9ac9a4677c101a0e7ddcfe89d --- /dev/null +++ b/src/ClassFactory.cpp @@ -0,0 +1,42 @@ +/*----- PROTECTED REGION ID(PespCCDStage::ClassFactory.cpp) ENABLED START -----*/ +//+============================================================================= +// +// file : ClassFactory.cpp +// +// description : C++ source for the class_factory method of the DServer +// device class. This method is responsible to create +// all class singletin for a device server. It is called +// at device server startup +// +// project : TANGO Device Server +// +// $Author: abrami $ +// +// +// copyleft : European Synchrotron Radiation Facility +// BP 220, Grenoble 38043 +// FRANCE +// +//-============================================================================= +// +// This file is generated by POGO +// (Program Obviously used to Generate tango Object) +// +// (c) - Software Engineering Group - ESRF +//============================================================================= + + +#include <tango.h> +#include <PespCCDStageClass.h> + +/** + * Create PespCCDStageClass singleton and store it in DServer object. + */ + +void Tango::DServer::class_factory() +{ + + add_class(PespCCDStage_ns::PespCCDStageClass::init("PespCCDStage")); + +} +/*----- PROTECTED REGION END -----*/ // PespCCDStage::ClassFactory.cpp diff --git a/src/PespCCDStage.cpp b/src/PespCCDStage.cpp new file mode 100644 index 0000000000000000000000000000000000000000..909f63bf065cbb9a7c4f19b4e5468a06a2631481 --- /dev/null +++ b/src/PespCCDStage.cpp @@ -0,0 +1,1772 @@ +/*----- PROTECTED REGION ID(PespCCDStage.cpp) ENABLED START -----*/ +//============================================================================= +// +// file : PespCCDStage.cpp +// +// description : C++ source for the PespCCDStage 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 +// PespCCDStage are implemented in this file. +// +// project : PespCCDStage +// +// This file is part of Tango device class. +// +// Tango is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// Tango is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with Tango. If not, see <http://www.gnu.org/licenses/>. +// +// $Author: abrami $ +// +// +//============================================================================= +// This file is generated by POGO +// (Program Obviously used to Generate tango Object) +//============================================================================= + +#define MYDBG 0 +#define MYDBG2 0 +#define MYDBG3 0 +#define MYDBG4 0 + +#include <tango.h> +#include <PespCCDStage.h> +#include <PespCCDStageClass.h> +#include "Xstring.h" + +/*----- PROTECTED REGION END -----*/ // PespCCDStage.cpp + +/** + * PespCCDStage class description: + * + */ + +//================================================================ +// The following table gives the correspondence +// between command and method names. +// +// Command name | Method name +//================================================================ +// State | Inherited (no method) +// Status | Inherited (no method) +// SetAngleDistance | set_angle_distance +// Stop | stop +// GetInstrumentList | get_instrument_list +//================================================================ + +//================================================================ +// Attributes managed are: +//================================================================ +// StageType | Tango::DevString Scalar +// FocusX | Tango::DevDouble Scalar +// FocusZ | Tango::DevDouble Scalar +// FocusDistance | Tango::DevDouble Scalar +// FocusAngle | Tango::DevDouble Scalar +// Pitch | Tango::DevDouble Scalar +// BeamOnYagDisplacement | Tango::DevDouble Scalar +// UpdateOnDisplacement | Tango::DevBoolean Scalar +//================================================================ + +namespace PespCCDStage_ns +{ +/*----- PROTECTED REGION ID(PespCCDStage::namespace_starting) ENABLED START -----*/ + +// static initializations + +/*----- PROTECTED REGION END -----*/ // PespCCDStage::namespace_starting + +//-------------------------------------------------------- +/** + * Method : PespCCDStage::PespCCDStage() + * Description : Constructors for a Tango device + * implementing the classPespCCDStage + */ +//-------------------------------------------------------- +PespCCDStage::PespCCDStage(Tango::DeviceClass *cl, string &s) + : TANGO_BASE_CLASS(cl, s.c_str()) +{ + /*----- PROTECTED REGION ID(PespCCDStage::constructor_1) ENABLED START -----*/ + init_device(); + + /*----- PROTECTED REGION END -----*/ // PespCCDStage::constructor_1 +} +//-------------------------------------------------------- +PespCCDStage::PespCCDStage(Tango::DeviceClass *cl, const char *s) + : TANGO_BASE_CLASS(cl, s) +{ + /*----- PROTECTED REGION ID(PespCCDStage::constructor_2) ENABLED START -----*/ + init_device(); + + /*----- PROTECTED REGION END -----*/ // PespCCDStage::constructor_2 +} +//-------------------------------------------------------- +PespCCDStage::PespCCDStage(Tango::DeviceClass *cl, const char *s, const char *d) + : TANGO_BASE_CLASS(cl, s, d) +{ + /*----- PROTECTED REGION ID(PespCCDStage::constructor_3) ENABLED START -----*/ + init_device(); + + /*----- PROTECTED REGION END -----*/ // PespCCDStage::constructor_3 +} + +//-------------------------------------------------------- +/** + * Method : PespCCDStage::delete_device() + * Description : will be called at device destruction or at init command + */ +//-------------------------------------------------------- +void PespCCDStage::delete_device() +{ + DEBUG_STREAM << "PespCCDStage::delete_device() " << device_name << endl; + /*----- PROTECTED REGION ID(PespCCDStage::delete_device) ENABLED START -----*/ + + // Delete device allocated objects + // Delete device's allocated object + // + INFO_STREAM << "PespCCDStage::PespCCDStage() delete device " << device_name << endl; + + if (gridX.dp!= NULL) {delete gridX.dp; gridX.dp=NULL;}; + if (gridZ.dp!= NULL) {delete gridZ.dp; gridZ.dp=NULL;}; + if (gridpic.dp!= NULL) {delete gridpic.dp; gridpic.dp=NULL;}; + if (ccdstageN.dp!= NULL) {delete ccdstageN.dp; ccdstageN.dp=NULL;}; + if (ccdstageL.dp!= NULL) {delete ccdstageL.dp; ccdstageL.dp=NULL;}; +#if 1 + chamber.set_size(0,false); + ccd.set_size(0,false); + rot.set_size(0,0,false); + q.set_size(0,false); + offset.set_size(0,false); + p.set_size(0,false); + r.set_size(0,false); + br.set_size(0,false); + mr.set_size(0,0,false); + qr.set_size(0,false); +#endif + + if (attr_FocusX_read) { + delete attr_FocusX_read; + attr_FocusX_read = 0; + } + if (attr_FocusZ_read) { + delete attr_FocusZ_read; + attr_FocusZ_read = 0; + } + if (attr_FocusAngle_read) { + delete attr_FocusAngle_read; + attr_FocusAngle_read = 0; + } + if (attr_FocusDistance_read) { + delete attr_FocusDistance_read; + attr_FocusDistance_read = 0; + } + + +//Tango::DevDouble *attr_Pitch_read; + if (attr_Pitch_read) { + delete attr_Pitch_read; + attr_Pitch_read = 0; + } + + if (pstage) { + delete pstage; + pstage = NULL; + } + + CORBA::string_free(attr_StageType_read[0]); + + + INFO_STREAM << "PespCCDStage::PespCCDStage() delete device " << device_name << "exited!" << endl; + + /*----- PROTECTED REGION END -----*/ // PespCCDStage::delete_device + delete[] attr_StageType_read; + delete[] attr_FocusX_read; + delete[] attr_FocusZ_read; + delete[] attr_FocusDistance_read; + delete[] attr_FocusAngle_read; + delete[] attr_Pitch_read; + delete[] attr_BeamOnYagDisplacement_read; + delete[] attr_UpdateOnDisplacement_read; +} + +//-------------------------------------------------------- +/** + * Method : PespCCDStage::init_device() + * Description : will be called at device initialization. + */ +//-------------------------------------------------------- +void PespCCDStage::init_device() +{ + DEBUG_STREAM << "PespCCDStage::init_device() create device " << device_name << endl; + /*----- PROTECTED REGION ID(PespCCDStage::init_device_before) ENABLED START -----*/ + + // Initialization before get_device_property() call + + #ifdef _DBG_PARAMETERS + std::cout << "BEGIN -------- PespCCDStage::init_device(" << device_name << ") --------" << std::endl; + #endif + + bool init_ok = true; + +/* +typedef struct { + string dev; + string move_attr; + string move_dflt; // default value when dev in not configured + string stop_cmd; + bool configured; + Tango::DeviceProxy *dp; + long tmo; + double m; + doubel q; +} mover_t; +*/ + ccdstageN.dev.clear(); + ccdstageN.move_attr.clear(); + ccdstageN.move_dflt.clear(); + ccdstageN.stop_cmd.clear(); + ccdstageN.configured = false; + ccdstageN.dp = NULL; + ccdstageN.state = Tango::UNKNOWN; + ccdstageN.tmo = 3000; + ccdstageN.m = 1; + ccdstageN.q = 0; + + ccdstageL.dev.clear(); + ccdstageL.move_attr.clear(); + ccdstageL.move_dflt.clear(); + ccdstageL.stop_cmd.clear(); + ccdstageL.configured = false; + ccdstageL.dp = NULL; + ccdstageL.state = Tango::UNKNOWN; + ccdstageL.tmo = 3000; + ccdstageL.m = 1; + ccdstageL.q = 0; + + gridX.dev.clear(); + gridX.move_attr.clear(); + gridX.move_dflt.clear(); + gridX.stop_cmd.clear(); + gridX.configured = false; + gridX.dp = NULL; + gridX.state = Tango::UNKNOWN; + gridX.tmo = 3000; + gridX.m = 1; + gridX.q = 0; + + gridZ.dev.clear(); + gridZ.move_attr.clear(); + gridZ.move_dflt.clear(); + gridZ.stop_cmd.clear(); + gridZ.configured = false; + gridZ.dp = NULL; + gridZ.state = Tango::UNKNOWN; + gridZ.m = 1; + gridZ.q = 0; + + gridpic.dev.clear(); + gridpic.move_attr.clear(); + gridpic.move_dflt.clear(); + gridpic.stop_cmd.clear(); + gridpic.configured = false; + gridpic.dp = NULL; + gridpic.state = Tango::UNKNOWN; + gridpic.tmo = 3000; + gridpic.m = 1; + gridpic.q = 0; + + + /*----- PROTECTED REGION END -----*/ // PespCCDStage::init_device_before + + + // Get the device properties from database + get_device_property(); + + attr_StageType_read = new Tango::DevString[1]; + attr_FocusX_read = new Tango::DevDouble[1]; + attr_FocusZ_read = new Tango::DevDouble[1]; + attr_FocusDistance_read = new Tango::DevDouble[1]; + attr_FocusAngle_read = new Tango::DevDouble[1]; + attr_Pitch_read = new Tango::DevDouble[1]; + attr_BeamOnYagDisplacement_read = new Tango::DevDouble[1]; + attr_UpdateOnDisplacement_read = new Tango::DevBoolean[1]; + // No longer if mandatory property not set. + if (mandatoryNotDefined) + return; + + /*----- PROTECTED REGION ID(PespCCDStage::init_device) ENABLED START -----*/ + + // Initialize device + +#if 1 + chamber.set_size(2,false); + ccd.set_size(2,false); + rot.set_size(2,2,false); + q.set_size(2,false); + offset.set_size(2,false); + p.set_size(2,false); + r.set_size(2,false); + br.set_size(2,false); + mr.set_size(2,2,false); + qr.set_size(2,false); + +#endif + + rot(0,0)=cos(rotationXN); + rot(0,1)=-sin(rotationXN); + rot(1,0)=sin(rotationXN); + rot(1,1)=cos(rotationXN); + q(0)=originNL[0]; + q(1)=originNL[1]; + + if (stageType.compare("Presto") == 0) { + + //AA0611 + + itpp::vec o; + std::vector<itpp::vec> y; + + o.set_size(2,false); + y.resize(2); + + o(0)= offset(0)= yagCenterNL[0]; + o(1)= offset(1)= yagCenterNL[1]; + y[0] = o; + o(0)= yagCenterNL[2]; + o(1)= yagCenterNL[3]; + y[1] = o; + + pstage = new PespStage_ns::PrestoStage(rot, q, offset); + if (pstage) { + *attr_StageType_read = Tango::string_dup("Presto"); + ((PespStage_ns::PrestoStage *)pstage)->setyagsNL(y); + ((PespStage_ns::PrestoStage *)pstage)->select_yag(0); + } else { + pstage = NULL; + *attr_StageType_read = Tango::string_dup("Error"); + } + } else if (stageType.compare("Tardi") == 0) { + offset(0)= yagsCenterOffsets[0]; + if (yagsCenterOffsets.size() >= 2) offset(1)= yagsCenterOffsets[1]; + + itpp::vec __cr; + __cr.set_size(2,false); + __cr(0) = rotationCenterXZ[0]; + __cr(1) = rotationCenterXZ[1]; + + pstage = new PespStage_ns::TardiStage(__cr, rot, q, offset); + if (pstage) { + *attr_StageType_read = Tango::string_dup("Tardi"); + ((PespStage_ns::TardiStage *)pstage)->select_yag(0); + } else { + pstage = NULL; + *attr_StageType_read = Tango::string_dup("Error"); + } + } else { + pstage = NULL; + string s("Error :?"); + s.append(stageType); + s.append("?"); + *attr_StageType_read = Tango::string_dup(s.c_str()); + } + if (pstage == NULL){ + init_ok = false; + } + + + ccdstageN.dev = cCDStageAxis[0]; + ccdstageN.move_attr = cCDStageAxis[1]; + ccdstageN.stop_cmd = cCDStageAxis[2]; + + ccdstageL.dev = cCDStageAxis[3]; + ccdstageL.move_attr = cCDStageAxis[4]; + ccdstageL.stop_cmd = cCDStageAxis[5]; + + gridX.dev = gridChamber[0]; + gridX.move_attr = gridChamber[1]; + gridX.move_dflt = gridChamber[2]; + gridX.move_dflt_value = XString<double>::convertFromString(gridX.move_dflt); + gridX.stop_cmd = gridChamber[3]; + + gridZ.dev = gridChamber[4]; + gridZ.move_attr = gridChamber[5]; + gridZ.move_dflt = gridChamber[6]; + gridZ.move_dflt_value = XString<double>::convertFromString(gridZ.move_dflt); + gridZ.stop_cmd = gridChamber[7]; + + gridpic.dev = gridPitch[0]; + gridpic.move_attr = gridPitch[1]; + gridpic.move_dflt = gridPitch[2]; + gridpic.move_dflt_value = XString<double>::convertFromString(gridpic.move_dflt); + gridpic.stop_cmd = gridPitch[3]; + if (gridPitch.size() > 4) gridpic.m = XString<double>::convertFromString(gridPitch[4]); + if (gridPitch.size() > 5) gridpic.q = XString<double>::convertFromString(gridPitch[5]); + + #ifdef _DBG_PARAMETERS + std::cout << "originNL X= " << originNL[0] << endl; + std::cout << "originNL Z= " << originNL[1] << endl; + + if (yagCenterNL.size() > 0 ){ + std::cout << "yagCenterNL N= " << yagCenterNL[0] << endl; + std::cout << "yagCenterNL L= " << yagCenterNL[1] << endl; + } + + if (yagsCenterOffsets.size() > 0 ){ + std::cout << "yagsCenterOffsets 0= " << yagsCenterOffsets[0] << endl; + std::cout << "yagsCenterOffsets 1= " << yagsCenterOffsets[1] << endl; + } + + std::cout << "rotationXN = " << rotationXN << endl; + + std::cout << "CCD Stage N device = " << ccdstageN.dev << endl; + std::cout << "CCD Stage N move attr = " << ccdstageN.move_attr <<"; dflt: " << ccdstageN.move_dflt << endl; + printf("CCD Stage N dflt value =%6.3f\n", ccdstageN.move_dflt_value); + std::cout << "CCD Stage N stop cmd = " << ccdstageN.stop_cmd << endl; + + std::cout << "CCD Stage L device = " << ccdstageL.dev << endl; + std::cout << "CCD Stage L move attr = " << ccdstageL.move_attr <<"; dflt: " << ccdstageL.move_dflt << endl; + printf("CCD Stage L dflt value =%6.3f\n", ccdstageL.move_dflt_value); + std::cout << "CCD Stage L stop cmd = " << ccdstageL.stop_cmd << endl; + + std::cout << "gridChamber X device = " << gridX.dev << endl; + std::cout << "gridChamber X move attr = " << gridX.move_attr <<"; dflt: " << gridX.move_dflt << endl; + printf("gridChamber X dflt value =%6.3f\n", gridX.move_dflt_value); + std::cout << "gridChamber X stop cmd = " << gridX.stop_cmd << endl; + + std::cout << "gridChamber Z device = " << gridZ.dev << endl; + std::cout << "gridChamber Z move attr = " << gridZ.move_attr <<"; dflt: " << gridZ.move_dflt << endl; + printf("gridChamber Z dflt value =%6.3f\n", gridZ.move_dflt_value); + std::cout << "gridChamber Z stop cmd = " << gridZ.stop_cmd << endl; + + std::cout << "gridPitch device = " << gridpic.dev << endl; + std::cout << "gridPitch move attr = " << gridpic.move_attr <<"; dflt: " << gridpic.move_dflt << endl; + printf("gridPitch dflt value =%6.3f\n", gridpic.move_dflt_value); + std::cout << "gridPitch stop cmd = " << gridpic.stop_cmd << endl; + std::cout << "gridPitch m/q = " << gridpic.m << " / " << gridpic.q << endl; + + //AA0611 + if (stageType.compare("Tardi") == 0) { + //PespStage_ns::TardiStage * pstage = (PespStage_ns::TardiStage *)pstage; + std::cout << "Tardi get_yag_distance()= " << ((PespStage_ns::TardiStage *)pstage)->get_yag_distance() << std::endl; + } + + #endif + + + + /* check if device is responding */ + try { + gridX.dp = new Tango::DeviceProxy(gridX.dev); + + DEBUG_STREAM << "Connected to device '" + gridX.dev + "'"<< endl; + + float pingtime; + pingtime = gridX.dp->ping(); + INFO_STREAM << "PingTime= " << pingtime << endl; + } + catch(Tango::DevFailed e) { + INFO_STREAM << "Failed to connect to device '" << gridX.dev << "'" << endl; + gridX.dp = NULL; + } + try { + gridZ.dp = new Tango::DeviceProxy(gridX.move_attr); + + DEBUG_STREAM << "Connected to device '" + gridX.move_attr + "'"<< endl; + + float pingtime; + pingtime = gridZ.dp->ping(); + INFO_STREAM << "PingTime= " << pingtime << endl; + } + catch(Tango::DevFailed e) { + INFO_STREAM << "Failed to connect to device '" << gridX.move_attr << "'" << endl; + gridZ.dp = NULL; + } + + + try { + gridpic.dp = new Tango::DeviceProxy(gridpic.dev); + + DEBUG_STREAM << "Connected to device '" + gridpic.dev + "'"<< endl; + + float pingtime; + pingtime = gridpic.dp->ping(); + INFO_STREAM << "PingTime= " << pingtime << endl; + } + catch(Tango::DevFailed e) { + INFO_STREAM << "Failed to connect to device '" << gridpic.dev << "'" << endl; + gridpic.dp = NULL; + } + + try { + ccdstageN.dp = new Tango::DeviceProxy(ccdstageN.dev); + + DEBUG_STREAM << "Connected to device '" + ccdstageN.dev + "'"<< endl; + + float pingtime; + pingtime = ccdstageN.dp->ping(); + INFO_STREAM << "PingTime= " << pingtime << endl; + } + catch(Tango::DevFailed e) { + INFO_STREAM << "Failed to connect to device '" << ccdstageN.dev << "'" << endl; + ccdstageN.dp = NULL; + } + try { + ccdstageL.dp = new Tango::DeviceProxy(ccdstageL.dev); + + DEBUG_STREAM << "Connected to device '" + ccdstageL.dev + "'"<< endl; + + float pingtime; + pingtime = ccdstageL.dp->ping(); + INFO_STREAM << "PingTime= " << pingtime << endl; + } + catch(Tango::DevFailed e) { + INFO_STREAM << "Failed to connect to device '" << ccdstageL.dev << "'" << endl; + ccdstageL.dp = NULL; + } + + + +#if MYDBG + Tango::DeviceAttribute da; + try { + da = ccdstageN.dp->read_attribute(ccdstageN.move_attr); + cout << da << endl; + double mis; + da >> mis; + cout << mis << endl; + da = ccdstageL.dp->read_attribute(ccdstageL.move_attr); + cout << da << endl; + } catch(...) { + ERROR_STREAM << "Read attribute FAILED !!!" << endl; + } +#endif + + *attr_FocusX_read=0; + *attr_FocusZ_read=0; + + *attr_FocusAngle_read=0; + *attr_FocusDistance_read=0; + *attr_Pitch_read=0; + + attr_BeamOnYagDisplacement_read[0] = 0; + pstage->set_displacement(0); + + attr_UpdateOnDisplacement_read[0] = false; + attr_UpdateOnSelector = false; + + /***************************** + * + * + tg->is_svr_starting() ... sembra funzionare (e' il server!) + tg->is_device_restarting(device_name)... non sembra funzionare. + allora essendo due attrib write_on_init, ma volendo solo l'aggioramento + al passato dell'attributo senza fare l'update... che implica moto + si introducono i due bool di seguito + * + */ + first_write_YagSelector = true; + first_write_BeamOnYagDisplacement = true; + + + if (init_ok){ + set_state(Tango::ON); + set_status("Ready."); + } else { + set_state(Tango::FAULT); + set_status("Error in init_device()!"); + } + + + + #ifdef _DBG_PARAMETERS + std::cout << "END -------- PespCCDStage::init_device(" << device_name << ") --------" << std::endl; + #endif + /*----- PROTECTED REGION END -----*/ // PespCCDStage::init_device +} + +//-------------------------------------------------------- +/** + * Method : PespCCDStage::get_device_property() + * Description : Read database to initialize property data members. + */ +//-------------------------------------------------------- +void PespCCDStage::get_device_property() +{ + /*----- PROTECTED REGION ID(PespCCDStage::get_device_property_before) ENABLED START -----*/ + + // Initialize property data members + + /*----- PROTECTED REGION END -----*/ // PespCCDStage::get_device_property_before + + mandatoryNotDefined = false; + + // Read device properties from database. + Tango::DbData dev_prop; + dev_prop.push_back(Tango::DbDatum("OriginNL")); + dev_prop.push_back(Tango::DbDatum("YagCenterNL")); + dev_prop.push_back(Tango::DbDatum("RotationXN")); + dev_prop.push_back(Tango::DbDatum("GridChamber")); + dev_prop.push_back(Tango::DbDatum("GridPitch")); + dev_prop.push_back(Tango::DbDatum("CCDStageAxis")); + dev_prop.push_back(Tango::DbDatum("StageType")); + dev_prop.push_back(Tango::DbDatum("YagsCenterOffsets")); + dev_prop.push_back(Tango::DbDatum("RotationCenterXZ")); + + // 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 PespCCDStageClass to get class property + Tango::DbDatum def_prop, cl_prop; + PespCCDStageClass *ds_class = + (static_cast<PespCCDStageClass *>(get_device_class())); + int i = -1; + + // Try to initialize OriginNL from class property + cl_prop = ds_class->get_class_property(dev_prop[++i].name); + if (cl_prop.is_empty()==false) cl_prop >> originNL; + else { + // Try to initialize OriginNL from default device value + def_prop = ds_class->get_default_device_property(dev_prop[i].name); + if (def_prop.is_empty()==false) def_prop >> originNL; + } + // And try to extract OriginNL value from database + if (dev_prop[i].is_empty()==false) dev_prop[i] >> originNL; + // Property StartDsPath is mandatory, check if has been defined in database. + check_mandatory_property(cl_prop, dev_prop[i]); + + // Try to initialize YagCenterNL from class property + cl_prop = ds_class->get_class_property(dev_prop[++i].name); + if (cl_prop.is_empty()==false) cl_prop >> yagCenterNL; + else { + // Try to initialize YagCenterNL from default device value + def_prop = ds_class->get_default_device_property(dev_prop[i].name); + if (def_prop.is_empty()==false) def_prop >> yagCenterNL; + } + // And try to extract YagCenterNL value from database + if (dev_prop[i].is_empty()==false) dev_prop[i] >> yagCenterNL; + + // Try to initialize RotationXN from class property + cl_prop = ds_class->get_class_property(dev_prop[++i].name); + if (cl_prop.is_empty()==false) cl_prop >> rotationXN; + else { + // Try to initialize RotationXN from default device value + def_prop = ds_class->get_default_device_property(dev_prop[i].name); + if (def_prop.is_empty()==false) def_prop >> rotationXN; + } + // And try to extract RotationXN value from database + if (dev_prop[i].is_empty()==false) dev_prop[i] >> rotationXN; + // Property StartDsPath is mandatory, check if has been defined in database. + check_mandatory_property(cl_prop, dev_prop[i]); + + // Try to initialize GridChamber from class property + cl_prop = ds_class->get_class_property(dev_prop[++i].name); + if (cl_prop.is_empty()==false) cl_prop >> gridChamber; + else { + // Try to initialize GridChamber from default device value + def_prop = ds_class->get_default_device_property(dev_prop[i].name); + if (def_prop.is_empty()==false) def_prop >> gridChamber; + } + // And try to extract GridChamber value from database + if (dev_prop[i].is_empty()==false) dev_prop[i] >> gridChamber; + // Property StartDsPath is mandatory, check if has been defined in database. + check_mandatory_property(cl_prop, dev_prop[i]); + + // Try to initialize GridPitch from class property + cl_prop = ds_class->get_class_property(dev_prop[++i].name); + if (cl_prop.is_empty()==false) cl_prop >> gridPitch; + else { + // Try to initialize GridPitch from default device value + def_prop = ds_class->get_default_device_property(dev_prop[i].name); + if (def_prop.is_empty()==false) def_prop >> gridPitch; + } + // And try to extract GridPitch value from database + if (dev_prop[i].is_empty()==false) dev_prop[i] >> gridPitch; + // Property StartDsPath is mandatory, check if has been defined in database. + check_mandatory_property(cl_prop, dev_prop[i]); + + // Try to initialize CCDStageAxis from class property + cl_prop = ds_class->get_class_property(dev_prop[++i].name); + if (cl_prop.is_empty()==false) cl_prop >> cCDStageAxis; + else { + // Try to initialize CCDStageAxis from default device value + def_prop = ds_class->get_default_device_property(dev_prop[i].name); + if (def_prop.is_empty()==false) def_prop >> cCDStageAxis; + } + // And try to extract CCDStageAxis value from database + if (dev_prop[i].is_empty()==false) dev_prop[i] >> cCDStageAxis; + + // Try to initialize StageType from class property + cl_prop = ds_class->get_class_property(dev_prop[++i].name); + if (cl_prop.is_empty()==false) cl_prop >> stageType; + else { + // Try to initialize StageType from default device value + def_prop = ds_class->get_default_device_property(dev_prop[i].name); + if (def_prop.is_empty()==false) def_prop >> stageType; + } + // And try to extract StageType value from database + if (dev_prop[i].is_empty()==false) dev_prop[i] >> stageType; + // Property StartDsPath is mandatory, check if has been defined in database. + check_mandatory_property(cl_prop, dev_prop[i]); + + // Try to initialize YagsCenterOffsets from class property + cl_prop = ds_class->get_class_property(dev_prop[++i].name); + if (cl_prop.is_empty()==false) cl_prop >> yagsCenterOffsets; + else { + // Try to initialize YagsCenterOffsets from default device value + def_prop = ds_class->get_default_device_property(dev_prop[i].name); + if (def_prop.is_empty()==false) def_prop >> yagsCenterOffsets; + } + // And try to extract YagsCenterOffsets value from database + if (dev_prop[i].is_empty()==false) dev_prop[i] >> yagsCenterOffsets; + + // Try to initialize RotationCenterXZ from class property + cl_prop = ds_class->get_class_property(dev_prop[++i].name); + if (cl_prop.is_empty()==false) cl_prop >> rotationCenterXZ; + else { + // Try to initialize RotationCenterXZ from default device value + def_prop = ds_class->get_default_device_property(dev_prop[i].name); + if (def_prop.is_empty()==false) def_prop >> rotationCenterXZ; + } + // And try to extract RotationCenterXZ value from database + if (dev_prop[i].is_empty()==false) dev_prop[i] >> rotationCenterXZ; + + } + + /*----- PROTECTED REGION ID(PespCCDStage::get_device_property_after) ENABLED START -----*/ + + // Check device property data members init + + /*----- PROTECTED REGION END -----*/ // PespCCDStage::get_device_property_after +} +//-------------------------------------------------------- +/** + * Method : PespCCDStage::check_mandatory_property() + * Description : For mandatory properties check if defined in database. + */ +//-------------------------------------------------------- +void PespCCDStage::check_mandatory_property(Tango::DbDatum &class_prop, Tango::DbDatum &dev_prop) +{ + // Check if all properties are empty + if (class_prop.is_empty() && dev_prop.is_empty()) + { + TangoSys_OMemStream tms; + tms << endl <<"Property \'" << dev_prop.name; + if (Tango::Util::instance()->_UseDb==true) + tms << "\' is mandatory but not defined in database"; + else + tms << "\' is mandatory but cannot be defined without database"; + string status(get_status()); + status += tms.str(); + set_status(status); + mandatoryNotDefined = true; + /*----- PROTECTED REGION ID(PespCCDStage::check_mandatory_property) ENABLED START -----*/ + cerr << tms.str() << " for " << device_name << endl; + + /*----- PROTECTED REGION END -----*/ // PespCCDStage::check_mandatory_property + } +} + + +//-------------------------------------------------------- +/** + * Method : PespCCDStage::always_executed_hook() + * Description : method always executed before any command is executed + */ +//-------------------------------------------------------- +void PespCCDStage::always_executed_hook() +{ + DEBUG_STREAM << "PespCCDStage::always_executed_hook() " << device_name << endl; + if (mandatoryNotDefined) + { + string status(get_status()); + Tango::Except::throw_exception( + (const char *)"PROPERTY_NOT_SET", + status.c_str(), + (const char *)"PespCCDStage::always_executed_hook()"); + } + /*----- PROTECTED REGION ID(PespCCDStage::always_executed_hook) ENABLED START -----*/ + // code always executed before all requests + + if (get_state() != Tango::FAULT) updateattributes(); + + /*----- PROTECTED REGION END -----*/ // PespCCDStage::always_executed_hook +} + +//-------------------------------------------------------- +/** + * Method : PespCCDStage::read_attr_hardware() + * Description : Hardware acquisition for attributes + */ +//-------------------------------------------------------- +void PespCCDStage::read_attr_hardware(TANGO_UNUSED(vector<long> &attr_list)) +{ + DEBUG_STREAM << "PespCCDStage::read_attr_hardware(vector<long> &attr_list) entering... " << endl; + /*----- PROTECTED REGION ID(PespCCDStage::read_attr_hardware) ENABLED START -----*/ + + // Add your own code + // Add your own code here + + if (get_state() != Tango::FAULT) { + updateattributes(); + updatestatus(); + } + + /*----- PROTECTED REGION END -----*/ // PespCCDStage::read_attr_hardware +} +//-------------------------------------------------------- +/** + * Method : PespCCDStage::write_attr_hardware() + * Description : Hardware writing for attributes + */ +//-------------------------------------------------------- +void PespCCDStage::write_attr_hardware(TANGO_UNUSED(vector<long> &attr_list)) +{ + DEBUG_STREAM << "PespCCDStage::write_attr_hardware(vector<long> &attr_list) entering... " << endl; + /*----- PROTECTED REGION ID(PespCCDStage::write_attr_hardware) ENABLED START -----*/ + + // Add your own code + + /*----- PROTECTED REGION END -----*/ // PespCCDStage::write_attr_hardware +} + +//-------------------------------------------------------- +/** + * Read attribute StageType related method + * Description: + * + * Data type: Tango::DevString + * Attr type: Scalar + */ +//-------------------------------------------------------- +void PespCCDStage::read_StageType(Tango::Attribute &attr) +{ + DEBUG_STREAM << "PespCCDStage::read_StageType(Tango::Attribute &attr) entering... " << endl; + /*----- PROTECTED REGION ID(PespCCDStage::read_StageType) ENABLED START -----*/ + // Set the attribute value + attr.set_value(attr_StageType_read); + + /*----- PROTECTED REGION END -----*/ // PespCCDStage::read_StageType +} +//-------------------------------------------------------- +/** + * Read attribute FocusX related method + * Description: + * + * Data type: Tango::DevDouble + * Attr type: Scalar + */ +//-------------------------------------------------------- +void PespCCDStage::read_FocusX(Tango::Attribute &attr) +{ + DEBUG_STREAM << "PespCCDStage::read_FocusX(Tango::Attribute &attr) entering... " << endl; + /*----- PROTECTED REGION ID(PespCCDStage::read_FocusX) ENABLED START -----*/ + attr.set_value(attr_FocusX_read); + + /*----- PROTECTED REGION END -----*/ // PespCCDStage::read_FocusX +} +//-------------------------------------------------------- +/** + * Write attribute FocusX related method + * Description: + * + * Data type: Tango::DevDouble + * Attr type: Scalar + */ +//-------------------------------------------------------- +void PespCCDStage::write_FocusX(Tango::WAttribute &attr) +{ + DEBUG_STREAM << "PespCCDStage::write_FocusX(Tango::WAttribute &attr) entering... " << endl; + // Retrieve write value + Tango::DevDouble w_val; + attr.get_write_value(w_val); + /*----- PROTECTED REGION ID(PespCCDStage::write_FocusX) ENABLED START -----*/ + + if (get_state() == Tango::FAULT) return; + + try { + itpp::vec newccd; + INFO_STREAM << "PespCCDStage::write_FocusX("<<w_val <<")"<< endl; + + itpp::vec newXZ(2); + newXZ(0)=w_val; + newXZ(1)=(*attr_FocusZ_read); + newccd=pstage->calculateXZ2NL(newXZ); +//AAA + #ifndef _DONT_WRITECENTERX + double v = newccd(0); + Tango::DeviceAttribute daN(ccdstageN.move_attr, v); + ccdstageN.dp->write_attribute(daN); + v = newccd(1); + Tango::DeviceAttribute daL(ccdstageL.move_attr, v); + ccdstageL.dp->write_attribute(daL); + #endif + + } catch(...) { + ERROR_STREAM << "Write attribute FAILED !!!" << endl; + } + + /*----- PROTECTED REGION END -----*/ // PespCCDStage::write_FocusX +} +//-------------------------------------------------------- +/** + * Read attribute FocusZ related method + * Description: + * + * Data type: Tango::DevDouble + * Attr type: Scalar + */ +//-------------------------------------------------------- +void PespCCDStage::read_FocusZ(Tango::Attribute &attr) +{ + DEBUG_STREAM << "PespCCDStage::read_FocusZ(Tango::Attribute &attr) entering... " << endl; + /*----- PROTECTED REGION ID(PespCCDStage::read_FocusZ) ENABLED START -----*/ + attr.set_value(attr_FocusZ_read); + + /*----- PROTECTED REGION END -----*/ // PespCCDStage::read_FocusZ +} +//-------------------------------------------------------- +/** + * Write attribute FocusZ related method + * Description: + * + * Data type: Tango::DevDouble + * Attr type: Scalar + */ +//-------------------------------------------------------- +void PespCCDStage::write_FocusZ(Tango::WAttribute &attr) +{ + DEBUG_STREAM << "PespCCDStage::write_FocusZ(Tango::WAttribute &attr) entering... " << endl; + // Retrieve write value + Tango::DevDouble w_val; + attr.get_write_value(w_val); + /*----- PROTECTED REGION ID(PespCCDStage::write_FocusZ) ENABLED START -----*/ + + if (get_state() == Tango::FAULT) return; + + try { + itpp::vec newccd; + INFO_STREAM << "PespCCDStage::write_FocusZ("<<w_val <<")"<< endl; + + itpp::vec newXZ(2); + + newXZ(0)=(*attr_FocusX_read); + newXZ(1)=w_val; + + newccd=pstage->calculateXZ2NL(newXZ); +//AAA + double v = newccd(0); + Tango::DeviceAttribute daN(ccdstageN.move_attr, v); + ccdstageN.dp->write_attribute(daN); + v = newccd(1); + Tango::DeviceAttribute daL(ccdstageL.move_attr, v); + ccdstageL.dp->write_attribute(daL); + + } catch(...) { + ERROR_STREAM << "Write attribute FAILED !!!" << endl; + } + + /*----- PROTECTED REGION END -----*/ // PespCCDStage::write_FocusZ +} +//-------------------------------------------------------- +/** + * Read attribute FocusDistance related method + * Description: + * + * Data type: Tango::DevDouble + * Attr type: Scalar + */ +//-------------------------------------------------------- +void PespCCDStage::read_FocusDistance(Tango::Attribute &attr) +{ + DEBUG_STREAM << "PespCCDStage::read_FocusDistance(Tango::Attribute &attr) entering... " << endl; + /*----- PROTECTED REGION ID(PespCCDStage::read_FocusDistance) ENABLED START -----*/ + attr.set_value(attr_FocusDistance_read); + + /*----- PROTECTED REGION END -----*/ // PespCCDStage::read_FocusDistance +} +//-------------------------------------------------------- +/** + * Write attribute FocusDistance related method + * Description: + * + * Data type: Tango::DevDouble + * Attr type: Scalar + */ +//-------------------------------------------------------- +void PespCCDStage::write_FocusDistance(Tango::WAttribute &attr) +{ + DEBUG_STREAM << "PespCCDStage::write_FocusDistance(Tango::WAttribute &attr) entering... " << endl; + // Retrieve write value + Tango::DevDouble w_val; + attr.get_write_value(w_val); + /*----- PROTECTED REGION ID(PespCCDStage::write_FocusDistance) ENABLED START -----*/ + + if (get_state() == Tango::FAULT) return; + + try { + itpp::vec newccd; + INFO_STREAM << "PespCCDStage::write_FocusDistance("<<w_val <<")"<< endl; + + itpp::vec newXZ(2); + itpp::vec newBR(2); + + newBR(0)=(*attr_FocusAngle_read); + newBR(1)=w_val; + + + newXZ=pstage->calculateBR2XZ(newBR); + newccd=pstage->calculateXZ2NL(newXZ); +//AAA + + #ifndef _DONT_WRITE_BR + double v = newccd(0); + Tango::DeviceAttribute daN(ccdstageN.move_attr, v); + ccdstageN.dp->write_attribute(daN); + v = newccd(1); + Tango::DeviceAttribute daL(ccdstageL.move_attr, v); + ccdstageL.dp->write_attribute(daL); + #endif + + } catch(...) { + ERROR_STREAM << "Write attribute FAILED !!!" << endl; + } + + /*----- PROTECTED REGION END -----*/ // PespCCDStage::write_FocusDistance +} +//-------------------------------------------------------- +/** + * Read attribute FocusAngle related method + * Description: + * + * Data type: Tango::DevDouble + * Attr type: Scalar + */ +//-------------------------------------------------------- +void PespCCDStage::read_FocusAngle(Tango::Attribute &attr) +{ + DEBUG_STREAM << "PespCCDStage::read_FocusAngle(Tango::Attribute &attr) entering... " << endl; + /*----- PROTECTED REGION ID(PespCCDStage::read_FocusAngle) ENABLED START -----*/ + attr.set_value(attr_FocusAngle_read); + + /*----- PROTECTED REGION END -----*/ // PespCCDStage::read_FocusAngle +} +//-------------------------------------------------------- +/** + * Write attribute FocusAngle related method + * Description: + * + * Data type: Tango::DevDouble + * Attr type: Scalar + */ +//-------------------------------------------------------- +void PespCCDStage::write_FocusAngle(Tango::WAttribute &attr) +{ + DEBUG_STREAM << "PespCCDStage::write_FocusAngle(Tango::WAttribute &attr) entering... " << endl; + // Retrieve write value + Tango::DevDouble w_val; + attr.get_write_value(w_val); + /*----- PROTECTED REGION ID(PespCCDStage::write_FocusAngle) ENABLED START -----*/ + + if (get_state() == Tango::FAULT) return; + + try { + itpp::vec newccd; + INFO_STREAM << "PespCCDStage::write_FocusAngle("<<w_val <<")"<< endl; + + itpp::vec newXZ(2); + itpp::vec newBR(2); + + newBR(0)=w_val; + newBR(1)=(*attr_FocusDistance_read); + + + newXZ=pstage->calculateBR2XZ(newBR); + newccd=pstage->calculateXZ2NL(newXZ); +//AAA + #ifndef _DONT_WRITE_BR + double v = newccd(0); + Tango::DeviceAttribute daN(ccdstageN.move_attr, v); + ccdstageN.dp->write_attribute(daN); + v = newccd(1); + Tango::DeviceAttribute daL(ccdstageL.move_attr, v); + ccdstageL.dp->write_attribute(daL); + #endif + + } catch(...) { + ERROR_STREAM << "Write attribute FAILED !!!" << endl; + } + + /*----- PROTECTED REGION END -----*/ // PespCCDStage::write_FocusAngle +} +//-------------------------------------------------------- +/** + * Read attribute Pitch related method + * Description: + * + * Data type: Tango::DevDouble + * Attr type: Scalar + */ +//-------------------------------------------------------- +void PespCCDStage::read_Pitch(Tango::Attribute &attr) +{ + DEBUG_STREAM << "PespCCDStage::read_Pitch(Tango::Attribute &attr) entering... " << endl; + /*----- PROTECTED REGION ID(PespCCDStage::read_Pitch) ENABLED START -----*/ + attr.set_value(attr_Pitch_read); + + /*----- PROTECTED REGION END -----*/ // PespCCDStage::read_Pitch +} +//-------------------------------------------------------- +/** + * Read attribute BeamOnYagDisplacement related method + * Description: + * + * Data type: Tango::DevDouble + * Attr type: Scalar + */ +//-------------------------------------------------------- +void PespCCDStage::read_BeamOnYagDisplacement(Tango::Attribute &attr) +{ + DEBUG_STREAM << "PespCCDStage::read_BeamOnYagDisplacement(Tango::Attribute &attr) entering... " << endl; + /*----- PROTECTED REGION ID(PespCCDStage::read_BeamOnYagDisplacement) ENABLED START -----*/ + + attr_BeamOnYagDisplacement_read[0] = pstage->get_displacement(); + + // Set the attribute value + attr.set_value(attr_BeamOnYagDisplacement_read); + + /*----- PROTECTED REGION END -----*/ // PespCCDStage::read_BeamOnYagDisplacement +} +//-------------------------------------------------------- +/** + * Write attribute BeamOnYagDisplacement related method + * Description: + * + * Data type: Tango::DevDouble + * Attr type: Scalar + */ +//-------------------------------------------------------- +void PespCCDStage::write_BeamOnYagDisplacement(Tango::WAttribute &attr) +{ + DEBUG_STREAM << "PespCCDStage::write_BeamOnYagDisplacement(Tango::WAttribute &attr) entering... " << endl; + // Retrieve write value + Tango::DevDouble w_val; + attr.get_write_value(w_val); + /*----- PROTECTED REGION ID(PespCCDStage::write_BeamOnYagDisplacement) ENABLED START -----*/ + + // dall'ultimo updateattributes() grazie all'always_exe_hook() + // sono aggiornati: + itpp::vec oldXZ(2); + + oldXZ(0) = attr_FocusX_read[0]; + oldXZ(1) = attr_FocusZ_read[0]; + + pstage->set_displacement(w_val); // questo puo' cambiare FocusX e FocusZ MA NON gli assi NL ovvero + // l'ultimo acquisito ccd! + + if (0){ + Tango::Util *tg = Tango::Util::instance(); + std::cout << "is_svr_starting = " << tg->is_svr_starting() << " | "; + std::cout << "is_device_restarting(" << device_name << ") = " << tg->is_device_restarting(device_name) << std::endl; + //string dd("PespCCDStage::abrami/pespccdstage/tardi"); + string dd = get_name(); + + std::cout << "is_device_restarting(" << dd << ") = " << tg->is_device_restarting(dd) << std::endl; + } + + if (attr_UpdateOnDisplacement_read[0] && !first_write_BeamOnYagDisplacement){ + itpp::vec newccd(2); + + newccd=pstage->calculateXZ2NL(oldXZ); + + double v = newccd(0); + Tango::DeviceAttribute daN(ccdstageN.move_attr, v); + ccdstageN.dp->write_attribute(daN); + v = newccd(1); + Tango::DeviceAttribute daL(ccdstageL.move_attr, v); + ccdstageL.dp->write_attribute(daL); + } + + first_write_BeamOnYagDisplacement = false; + /*----- PROTECTED REGION END -----*/ // PespCCDStage::write_BeamOnYagDisplacement +} +//-------------------------------------------------------- +/** + * Read attribute UpdateOnDisplacement related method + * Description: + * + * Data type: Tango::DevBoolean + * Attr type: Scalar + */ +//-------------------------------------------------------- +void PespCCDStage::read_UpdateOnDisplacement(Tango::Attribute &attr) +{ + DEBUG_STREAM << "PespCCDStage::read_UpdateOnDisplacement(Tango::Attribute &attr) entering... " << endl; + /*----- PROTECTED REGION ID(PespCCDStage::read_UpdateOnDisplacement) ENABLED START -----*/ + // Set the attribute value + attr.set_value(attr_UpdateOnDisplacement_read); + + /*----- PROTECTED REGION END -----*/ // PespCCDStage::read_UpdateOnDisplacement +} +//-------------------------------------------------------- +/** + * Write attribute UpdateOnDisplacement related method + * Description: + * + * Data type: Tango::DevBoolean + * Attr type: Scalar + */ +//-------------------------------------------------------- +void PespCCDStage::write_UpdateOnDisplacement(Tango::WAttribute &attr) +{ + DEBUG_STREAM << "PespCCDStage::write_UpdateOnDisplacement(Tango::WAttribute &attr) entering... " << endl; + // Retrieve write value + Tango::DevBoolean w_val; + attr.get_write_value(w_val); + /*----- PROTECTED REGION ID(PespCCDStage::write_UpdateOnDisplacement) ENABLED START -----*/ + + attr_UpdateOnDisplacement_read[0] = w_val; + + /*----- PROTECTED REGION END -----*/ // PespCCDStage::write_UpdateOnDisplacement +} + +//-------------------------------------------------------- +/** + * Read attribute YagSelector related method + * Description: + * + * Data type: Tango::DevUShort + * Attr type: Scalar + */ +//-------------------------------------------------------- +void PespCCDStage::read_YagSelector(Tango::Attribute &attr) +{ + DEBUG_STREAM << "PespCCDStage::read_YagSelector(Tango::Attribute &attr) entering... " << endl; + Tango::DevUShort *att_value = get_YagSelector_data_ptr(attr.get_name()); + /*----- PROTECTED REGION ID(PespCCDStage::read_YagSelector) ENABLED START -----*/ + + + //AA0611 + if (stageType.compare("Tardi") == 0) { + *att_value = (Tango::DevUShort)((PespStage_ns::TardiStage *)pstage)->get_select_yag(); + } else + if (stageType.compare("Presto") == 0) { + *att_value = (Tango::DevUShort)((PespStage_ns::PrestoStage *)pstage)->get_select_yag(); + } else { + *att_value = 0; + }; + + // Set the attribute value + attr.set_value(att_value); + + /*----- PROTECTED REGION END -----*/ // PespCCDStage::read_YagSelector +} +//-------------------------------------------------------- +/** + * Write attribute YagSelector related method + * Description: + * + * Data type: Tango::DevUShort + * Attr type: Scalar + */ +//-------------------------------------------------------- +void PespCCDStage::write_YagSelector(Tango::WAttribute &attr) +{ + DEBUG_STREAM << "PespCCDStage::write_YagSelector(Tango::WAttribute &attr) entering... " << endl; + // Retrieve write value + Tango::DevUShort w_val; + attr.get_write_value(w_val); + /*----- PROTECTED REGION ID(PespCCDStage::write_YagSelector) ENABLED START -----*/ + + // dall'ultimo updateattributes() grazie all'always_exe_hook() + // sono aggiornati: + itpp::vec oldXZ(2); + + oldXZ(0) = attr_FocusX_read[0]; + oldXZ(1) = attr_FocusZ_read[0]; + + + //AA0611 + if (stageType.compare("Tardi") == 0) { + if ( ((int)w_val) > yagsCenterOffsets.size() ){ + Tango::Except::throw_exception( + (const char *) "Invalid value", + (const char *) "Invalid value", + (const char *) "PespCCDStage::write_YagSelector()"); + } + + ((PespStage_ns::TardiStage *)pstage)->select_yag((int)w_val); + + if (attr_UpdateOnSelector && !first_write_YagSelector){ + itpp::vec newccd(2); + + newccd=pstage->calculateXZ2NL(oldXZ); + + double v = newccd(0); + Tango::DeviceAttribute daN(ccdstageN.move_attr, v); + ccdstageN.dp->write_attribute(daN); + v = newccd(1); + Tango::DeviceAttribute daL(ccdstageL.move_attr, v); + ccdstageL.dp->write_attribute(daL); + } + }; + if (stageType.compare("Presto") == 0) { + if ( ((int)w_val) > yagCenterNL.size()/2 ){ + Tango::Except::throw_exception( + (const char *) "Invalid value", + (const char *) "Invalid value", + (const char *) "PespCCDStage::write_YagSelector()"); + } + + ((PespStage_ns::PrestoStage *)pstage)->select_yag((int)w_val); + + if (attr_UpdateOnSelector && !first_write_YagSelector){ + itpp::vec newccd(2); + + newccd=pstage->calculateXZ2NL(oldXZ); + + double v = newccd(0); + Tango::DeviceAttribute daN(ccdstageN.move_attr, v); + ccdstageN.dp->write_attribute(daN); + v = newccd(1); + Tango::DeviceAttribute daL(ccdstageL.move_attr, v); + ccdstageL.dp->write_attribute(daL); + } + }; + + first_write_YagSelector = false; + + /*----- PROTECTED REGION END -----*/ // PespCCDStage::write_YagSelector +} +//-------------------------------------------------------- +/** + * Read attribute UpdateOnSelector related method + * Description: + * + * Data type: Tango::DevBoolean + * Attr type: Scalar + */ +//-------------------------------------------------------- +void PespCCDStage::read_UpdateOnSelector(Tango::Attribute &attr) +{ + DEBUG_STREAM << "PespCCDStage::read_UpdateOnSelector(Tango::Attribute &attr) entering... " << endl; + Tango::DevBoolean *att_value = get_UpdateOnSelector_data_ptr(attr.get_name()); + /*----- PROTECTED REGION ID(PespCCDStage::read_UpdateOnSelector) ENABLED START -----*/ + + // Set the attribute value + + *att_value = attr_UpdateOnSelector; + attr.set_value(att_value); + + /*----- PROTECTED REGION END -----*/ // PespCCDStage::read_UpdateOnSelector +} +//-------------------------------------------------------- +/** + * Write attribute UpdateOnSelector related method + * Description: + * + * Data type: Tango::DevBoolean + * Attr type: Scalar + */ +//-------------------------------------------------------- +void PespCCDStage::write_UpdateOnSelector(Tango::WAttribute &attr) +{ + DEBUG_STREAM << "PespCCDStage::write_UpdateOnSelector(Tango::WAttribute &attr) entering... " << endl; + // Retrieve write value + Tango::DevBoolean w_val; + attr.get_write_value(w_val); + /*----- PROTECTED REGION ID(PespCCDStage::write_UpdateOnSelector) ENABLED START -----*/ + + attr_UpdateOnSelector = w_val; + + + /*----- PROTECTED REGION END -----*/ // PespCCDStage::write_UpdateOnSelector +} +//-------------------------------------------------------- +/** + * Method : PespCCDStage::add_dynamic_attributes() + * Description : Create the dynamic attributes if any + * for specified device. + */ +//-------------------------------------------------------- +void PespCCDStage::add_dynamic_attributes() +{ + // Example to add dynamic attribute: + // Copy inside the following protected area to create instance(s) at startup. + // add_YagSelector_dynamic_attribute("MyYagSelectorAttribute"); + // add_UpdateOnSelector_dynamic_attribute("MyUpdateOnSelectorAttribute"); + + /*----- PROTECTED REGION ID(PespCCDStage::add_dynamic_attributes) ENABLED START -----*/ + + // Add your own code to create and add dynamic attributes if any + + //AA0611 + if ((stageType.compare("Tardi") == 0) || (stageType.compare("Presto") == 0) ) { + #ifdef _DBG_DYNATTR + std::cout << "PespCCDStage::add_dynamic_attributes()" << std::endl; + #endif + add_YagSelector_dynamic_attribute("Selector"); + add_UpdateOnSelector_dynamic_attribute("UpdateOnSelector"); + } + + /*----- PROTECTED REGION END -----*/ // PespCCDStage::add_dynamic_attributes +} + +//-------------------------------------------------------- +/** + * Command SetAngleDistance related method + * Description: + * + * @param argin + * @returns + */ +//-------------------------------------------------------- +Tango::DevBoolean PespCCDStage::set_angle_distance(const Tango::DevVarDoubleArray *argin) +{ + Tango::DevBoolean argout; + DEBUG_STREAM << "PespCCDStage::SetAngleDistance() - " << device_name << endl; + /*----- PROTECTED REGION ID(PespCCDStage::set_angle_distance) ENABLED START -----*/ + + // Add your own code + DEBUG_STREAM << "PespCCDStage::set_angle_distance(): entering... !" << endl; + + // Add your own code to control device here + + if (get_state() == Tango::FAULT) return false; + + + + itpp::vec newccd; + double angle = (*argin)[0]; + double distance = (*argin)[1]; + + INFO_STREAM << "PespCCDStage::set_angle_distance("<<angle<<","<<distance<<")"<< endl; + + itpp::vec newXZ(2); + itpp::vec newBR(2); + + newBR(0)=angle; + newBR(1)=distance; + + + newXZ=pstage->calculateBR2XZ(newBR); + newccd=pstage->calculateXZ2NL(newXZ); +//AAA + double v = newccd(0); + Tango::DeviceAttribute daN(ccdstageN.move_attr, v); + + try { + ccdstageN.dp->write_attribute(daN); + } catch(...) { + ERROR_STREAM << "PespCCDStage::set_angle_distance Write CCDStageAxisN attribute FAILED !!!" << endl; + } + v = newccd(1); + Tango::DeviceAttribute daL(ccdstageL.move_attr, v); + + try { + ccdstageL.dp->write_attribute(daL); + } catch(...) { + ERROR_STREAM << "PespCCDStage::set_angle_distance Write CCDStageAxisL attribute FAILED !!!" << endl; + } + + argout = true; + + /*----- PROTECTED REGION END -----*/ // PespCCDStage::set_angle_distance + return argout; +} +//-------------------------------------------------------- +/** + * Command Stop related method + * Description: + * + */ +//-------------------------------------------------------- +void PespCCDStage::stop() +{ + DEBUG_STREAM << "PespCCDStage::Stop() - " << device_name << endl; + /*----- PROTECTED REGION ID(PespCCDStage::stop) ENABLED START -----*/ + + // Add your own code + + if (get_state() == Tango::FAULT) return; + + try { + ccdstageN.dp->command_inout(ccdstageN.stop_cmd); + } catch(...) { + ERROR_STREAM << "PespCCDStage::stop() on CCDStageAxisN FAILED !!!" << endl; + } + + try { + ccdstageL.dp->command_inout(ccdstageL.stop_cmd); + } catch(...) { + ERROR_STREAM << "PespCCDStage::stop() on CCDStageAxisL FAILED !!!" << endl; + } + + + /*----- PROTECTED REGION END -----*/ // PespCCDStage::stop +} +//-------------------------------------------------------- +/** + * Command GetInstrumentList related method + * Description: Se ritorna ``zero`` stringhe, allora non c`e` nemmeno il corrispondente ``selector`` + * + * @returns + */ +//-------------------------------------------------------- +Tango::DevVarStringArray *PespCCDStage::get_instrument_list() +{ + Tango::DevVarStringArray *argout; + DEBUG_STREAM << "PespCCDStage::GetInstrumentList() - " << device_name << endl; + /*----- PROTECTED REGION ID(PespCCDStage::get_instrument_list) ENABLED START -----*/ + + argout = new Tango::DevVarStringArray(); + + // Add your own code + //AA0611 + if (stageType.compare("Tardi") == 0) { + int k = yagsCenterOffsets.size(); + argout->length(k); + for (int i=0; i < k; i++){ + stringstream ss(""); + ss << "CCD" << (i+1); + (*argout)[i] = Tango::string_dup(ss.str().c_str()); + } + } else + if (stageType.compare("Presto") == 0) { + int k = yagCenterNL.size()/2; + argout->length(k); + for (int i=0; i < k; i++){ + stringstream ss(""); + ss << "CCD" << (i+1); + (*argout)[i] = Tango::string_dup(ss.str().c_str()); + } + } else { + argout->length(0); + } + + /*----- PROTECTED REGION END -----*/ // PespCCDStage::get_instrument_list + return argout; +} +//-------------------------------------------------------- +/** + * Method : PespCCDStage::add_dynamic_commands() + * Description : Create the dynamic commands if any + * for specified device. + */ +//-------------------------------------------------------- +void PespCCDStage::add_dynamic_commands() +{ + /*----- PROTECTED REGION ID(PespCCDStage::add_dynamic_commands) ENABLED START -----*/ + + // Add your own code to create and add dynamic commands if any + + /*----- PROTECTED REGION END -----*/ // PespCCDStage::add_dynamic_commands +} + +/*----- PROTECTED REGION ID(PespCCDStage::namespace_ending) ENABLED START -----*/ + +// Additional Methods +//----------------------------------------------------------------------------- +//----------------------------------------------------------------------------- +//BBB +void PespCCDStage::updateattributes(){ + + Tango::DeviceAttribute da; + double mis; + + if (gridX.dp!= NULL) try { + da = gridX.dp->read_attribute(gridX.move_attr); + da >> mis; + chamber[0]=mis; + + gridX.state = gridX.dp->state(); + + } catch(...) { + ERROR_STREAM << "Read attribute chamber FAILED !!!" << endl; + } else { + chamber[0] = gridX.move_dflt_value; + gridX.state = Tango::UNKNOWN; + } + + if (gridZ.dp!= NULL) try { + da = gridZ.dp->read_attribute(gridZ.dev); + da >> mis; + chamber[1]=mis; + + gridZ.state = gridZ.dp->state(); + + } catch(...) { + ERROR_STREAM << "Read attribute camber FAILED !!!" << endl; + } else { + chamber[1] = gridZ.move_dflt_value; + gridZ.state = Tango::UNKNOWN; + } + + pstage->set_chamber(chamber); + + if (gridpic.dp!= NULL) try { + da = gridpic.dp->read_attribute(gridpic.move_attr); + da >> pitch; + + pitch = gridpic.m * pitch + gridpic.q + gridpic.move_dflt_value; + + gridpic.state = gridpic.dp->state(); + + } catch(...) { + ERROR_STREAM << "Read attribute grid FAILED !!!" << endl; + } else { + pitch = gridpic.move_dflt_value; + gridpic.state = Tango::UNKNOWN; + } + *attr_Pitch_read = pitch; + + pstage->set_pitch(pitch); + + + if (ccdstageN.dp!= NULL) try { + da = ccdstageN.dp->read_attribute(ccdstageN.move_attr); + da >> mis; + ccd[0]=mis; + + ccdstageN.state = ccdstageN.dp->state(); + + } catch(...) { + ERROR_STREAM << "Read attribute ccd FAILED !!!" << endl; + } else { + ccd[0] = -1; + ccdstageN.state = Tango::UNKNOWN; + } + + if (ccdstageL.dp!= NULL) try { + da = ccdstageL.dp->read_attribute(ccdstageL.move_attr); + da >> mis; + ccd[1]=mis; + + ccdstageL.state = ccdstageL.dp->state(); + + } catch(...) { + ERROR_STREAM << "Read attribute ccd FAILED !!!" << endl; + } else { + ccd[1] = -1; + ccdstageL.state = Tango::UNKNOWN; + } + + + p = pstage->calculateNL2XZ(ccd); + +#ifdef _DBG_UPDATTR + cout << "yag center coord[x,z]= " << p << endl; +#endif + *attr_FocusX_read=p[0]; + *attr_FocusZ_read=p[1]; + + + br = pstage->calculateXZ2BR(p); + + *attr_FocusAngle_read = br[0]; + +#ifdef _DBG_UPDATTR + cout << "angolo " << br[0] << endl; + cout << "distanza " << br[1] << endl; +#endif + *attr_FocusDistance_read = br[1]; + + + +} +//----------------------------------------------------------------------------- +//----------------------------------------------------------------------------- +//----------------------------------------------------------------------------- +//BBB +void PespCCDStage::updatestatus(){ + +#if 0 + + if ((ccdstageN.state == Tango::MOVING) || (ccdstageL.state == Tango::MOVING)){ + set_state(Tango::MOVING); + set_status("Axis moving"); + } + +#if MYDBG3 + cout << ccdstageN.state << endl; + cout << ccdstageL.state << endl; +#endif + + + if ((gridX.dp!= NULL) && (gridX.state == Tango::MOVING)) set_state(Tango::MOVING); + if ((gridZ.dp!= NULL) && (gridZ.state == Tango::MOVING)) set_state(Tango::MOVING); + if ((gridpic.dp!= NULL) && (gridpic.state == Tango::MOVING)) set_state(Tango::MOVING); + +// Modif. 20120202 +// ccdstageN.state ccdstageL.state gridX.state gridZ.state gridpic.state STATE +// MOVING X X X X MOVING +// X MOVING X X X MOVING +// X X MOVING X X MOVING +// X X X MOVING X MOVING +// X X X X MOVING MOVING +// ON/OFF/STANDBY ON/OFF/STANDBY ON/OFF/STANDBY ON/OFF/STANDBY ON/OFF/STANDBY ON +// ALARM X X X X ALARM +// X ALARM X X X ALARM +// X X ALARM X X ALARM +// X X X ALARM X ALARM +// X X X X ALARM ALARM + +#else +#if MYDBG4 + cout << ccdstageN.state << endl; + cout << ccdstageL.state << endl; + cout << gridX.state << endl; + cout << gridZ.state << endl; + cout << gridpic.state << endl; +#endif + set_state(Tango::UNKNOWN); + set_status("Unknown"); + + if ( (ccdstageN.state == Tango::MOVING) || + (ccdstageL.state == Tango::MOVING) || + (gridX.state == Tango::MOVING) || + (gridZ.state == Tango::MOVING) || + (gridpic.state == Tango::MOVING) + ){ + set_state(Tango::MOVING); + set_status("Axis moving"); + } + if ( ((ccdstageN.state == Tango::ON) || (ccdstageN.state == Tango::OFF) || (ccdstageN.state == Tango::STANDBY)) && + ((ccdstageL.state == Tango::ON) || (ccdstageL.state == Tango::OFF) || (ccdstageL.state == Tango::STANDBY)) && + ((gridX.state == Tango::ON) || (gridX.state == Tango::OFF) || + (gridX.state == Tango::STANDBY) || (gridX.state == Tango::UNKNOWN)) && + ((gridZ.state == Tango::ON) || (gridZ.state == Tango::OFF) || + (gridZ.state == Tango::STANDBY) || (gridZ.state == Tango::UNKNOWN)) && + ((gridpic.state == Tango::ON) || (gridpic.state == Tango::OFF) || + (gridpic.state == Tango::STANDBY) || (gridpic.state == Tango::UNKNOWN)) + ){ + set_state(Tango::ON); + set_status("Ready"); + } + if ( (ccdstageN.state == Tango::ALARM) || + (ccdstageL.state == Tango::ALARM) || + (gridX.state == Tango::ALARM) || + (gridZ.state == Tango::ALARM) || + (gridpic.state == Tango::ALARM) + ){ + set_state(Tango::ALARM); + set_status("ALARM"); + } +#endif + +} + +/*----- PROTECTED REGION END -----*/ // PespCCDStage::namespace_ending +} // namespace diff --git a/src/PespCCDStage.h b/src/PespCCDStage.h new file mode 100644 index 0000000000000000000000000000000000000000..c3fdcc4cc7871c3cfd17b21409912cc445969fe0 --- /dev/null +++ b/src/PespCCDStage.h @@ -0,0 +1,414 @@ +/*----- PROTECTED REGION ID(PespCCDStage.h) ENABLED START -----*/ +//============================================================================= +// +// file : PespCCDStage.h +// +// description : Include file for the PespCCDStage class +// +// project : PespCCDStage +// +// This file is part of Tango device class. +// +// Tango is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// Tango is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with Tango. If not, see <http://www.gnu.org/licenses/>. +// +// $Author: abrami $ +// +//============================================================================= +// This file is generated by POGO +// (Program Obviously used to Generate tango Object) +//============================================================================= + + +#ifndef PespCCDStage_H +#define PespCCDStage_H + +#include <tango.h> +#include <itpp/itbase.h> +#include <itpp/itcomm.h> +#include <math.h> + + + + +#include "PespStage.h" + +#define PI 3.14159265 + +typedef struct { + string dev; + string move_attr; + string move_dflt; // default value when dev in not configured + double move_dflt_value; + string stop_cmd; + bool configured; + Tango::DeviceProxy *dp; + Tango::DevState state; + long tmo; + double m; // value = m * reading + q + double q; +} mover_t; + + + +/*----- PROTECTED REGION END -----*/ // PespCCDStage.h + +/** + * PespCCDStage class description: + * + */ + +namespace PespCCDStage_ns +{ +/*----- PROTECTED REGION ID(PespCCDStage::Additional Class Declarations) ENABLED START -----*/ + +// Additional Class Declarations + +/*----- PROTECTED REGION END -----*/ // PespCCDStage::Additional Class Declarations + +class PespCCDStage : public TANGO_BASE_CLASS +{ + +/*----- PROTECTED REGION ID(PespCCDStage::Data Members) ENABLED START -----*/ + +// Add your own data members +public: + mover_t ccdstageN; + mover_t ccdstageL; + mover_t gridX; + mover_t gridZ; + mover_t gridpic; + + itpp::vec chamber; //chamber + double pitch; + itpp::vec ccd; //ccd + itpp::mat rot; + itpp::vec q; //ccd origin in x,z + itpp::vec p; //yag center in x,z + itpp::vec br; //yag center in b,r + itpp::vec offset; //yag offset in n,l + itpp::vec r; //retta per centro yag e centro specchio/chamber in x,z + itpp::mat mr; + itpp::vec qr; + + PespStage_ns::PespStage *pstage; + + + bool first_write_YagSelector; + bool first_write_BeamOnYagDisplacement; + + bool attr_UpdateOnSelector; + +/*----- PROTECTED REGION END -----*/ // PespCCDStage::Data Members + +// Device property data members +public: + // OriginNL: Coordinate di Q in XZ: x,z + vector<Tango::DevDouble> originNL; + // YagCenterNL: Centro Yag in coord. NL + vector<Tango::DevDouble> yagCenterNL; + // RotationXN: Angolo (radianti) da N+ a X+ + Tango::DevDouble rotationXN; + // GridChamber: Device proxy + // AttributoX + // DefaultX + // Device proxy + // AttributoZ + // DefaultZ + // + // Coordinata X portareticolo o da device o da default: + // device, default + vector<string> gridChamber; + // GridPitch: Device proxy + // AttributoX + // DefaultX + // Valore pitch + vector<string> gridPitch; + // CCDStageAxis: device proxy + // Attributo N + // device proxy + // Attributo L + vector<string> cCDStageAxis; + // StageType: Presto + // Tardi + string stageType; + // YagsCenterOffsets: Offsets (d) Yag da centro di rotazione tavola lungo retta RQ` + vector<Tango::DevDouble> yagsCenterOffsets; + // RotationCenterXZ: Centro di rotazione (del naso) in coord. xOz + vector<Tango::DevDouble> rotationCenterXZ; + + bool mandatoryNotDefined; + +// Attribute data members +public: + Tango::DevString *attr_StageType_read; + Tango::DevDouble *attr_FocusX_read; + Tango::DevDouble *attr_FocusZ_read; + Tango::DevDouble *attr_FocusDistance_read; + Tango::DevDouble *attr_FocusAngle_read; + Tango::DevDouble *attr_Pitch_read; + Tango::DevDouble *attr_BeamOnYagDisplacement_read; + Tango::DevBoolean *attr_UpdateOnDisplacement_read; + +// Constructors and destructors +public: + /** + * Constructs a newly device object. + * + * @param cl Class. + * @param s Device Name + */ + PespCCDStage(Tango::DeviceClass *cl,string &s); + /** + * Constructs a newly device object. + * + * @param cl Class. + * @param s Device Name + */ + PespCCDStage(Tango::DeviceClass *cl,const char *s); + /** + * Constructs a newly device object. + * + * @param cl Class. + * @param s Device name + * @param d Device description. + */ + PespCCDStage(Tango::DeviceClass *cl,const char *s,const char *d); + /** + * The device object destructor. + */ + ~PespCCDStage() {delete_device();}; + + +// Miscellaneous methods +public: + /* + * will be called at device destruction or at init command. + */ + void delete_device(); + /* + * Initialize the device + */ + virtual void init_device(); + /* + * Read the device properties from database + */ + void get_device_property(); + /* + * Always executed method before execution command method. + */ + virtual void always_executed_hook(); + + /* + * Check if mandatory property has been set + */ + void check_mandatory_property(Tango::DbDatum &class_prop, Tango::DbDatum &dev_prop); + +// Attribute methods +public: + //-------------------------------------------------------- + /* + * Method : PespCCDStage::read_attr_hardware() + * Description : Hardware acquisition for attributes. + */ + //-------------------------------------------------------- + virtual void read_attr_hardware(vector<long> &attr_list); + //-------------------------------------------------------- + /* + * Method : PespCCDStage::write_attr_hardware() + * Description : Hardware writing for attributes. + */ + //-------------------------------------------------------- + virtual void write_attr_hardware(vector<long> &attr_list); + +/** + * Attribute StageType related methods + * Description: + * + * Data type: Tango::DevString + * Attr type: Scalar + */ + virtual void read_StageType(Tango::Attribute &attr); + virtual bool is_StageType_allowed(Tango::AttReqType type); +/** + * Attribute FocusX related methods + * Description: + * + * Data type: Tango::DevDouble + * Attr type: Scalar + */ + virtual void read_FocusX(Tango::Attribute &attr); + virtual void write_FocusX(Tango::WAttribute &attr); + virtual bool is_FocusX_allowed(Tango::AttReqType type); +/** + * Attribute FocusZ related methods + * Description: + * + * Data type: Tango::DevDouble + * Attr type: Scalar + */ + virtual void read_FocusZ(Tango::Attribute &attr); + virtual void write_FocusZ(Tango::WAttribute &attr); + virtual bool is_FocusZ_allowed(Tango::AttReqType type); +/** + * Attribute FocusDistance related methods + * Description: + * + * Data type: Tango::DevDouble + * Attr type: Scalar + */ + virtual void read_FocusDistance(Tango::Attribute &attr); + virtual void write_FocusDistance(Tango::WAttribute &attr); + virtual bool is_FocusDistance_allowed(Tango::AttReqType type); +/** + * Attribute FocusAngle related methods + * Description: + * + * Data type: Tango::DevDouble + * Attr type: Scalar + */ + virtual void read_FocusAngle(Tango::Attribute &attr); + virtual void write_FocusAngle(Tango::WAttribute &attr); + virtual bool is_FocusAngle_allowed(Tango::AttReqType type); +/** + * Attribute Pitch related methods + * Description: + * + * Data type: Tango::DevDouble + * Attr type: Scalar + */ + virtual void read_Pitch(Tango::Attribute &attr); + virtual bool is_Pitch_allowed(Tango::AttReqType type); +/** + * Attribute BeamOnYagDisplacement related methods + * Description: + * + * Data type: Tango::DevDouble + * Attr type: Scalar + */ + virtual void read_BeamOnYagDisplacement(Tango::Attribute &attr); + virtual void write_BeamOnYagDisplacement(Tango::WAttribute &attr); + virtual bool is_BeamOnYagDisplacement_allowed(Tango::AttReqType type); +/** + * Attribute UpdateOnDisplacement related methods + * Description: + * + * Data type: Tango::DevBoolean + * Attr type: Scalar + */ + virtual void read_UpdateOnDisplacement(Tango::Attribute &attr); + virtual void write_UpdateOnDisplacement(Tango::WAttribute &attr); + virtual bool is_UpdateOnDisplacement_allowed(Tango::AttReqType type); + +// Dynamic attribute methods +public: + + /** + * Attribute YagSelector related methods + * Description: + * + * Data type: Tango::DevUShort + * Attr type: Scalar + */ + virtual void read_YagSelector(Tango::Attribute &attr); + virtual void write_YagSelector(Tango::WAttribute &attr); + virtual bool is_YagSelector_allowed(Tango::AttReqType type); + void add_YagSelector_dynamic_attribute(string attname); + void remove_YagSelector_dynamic_attribute(string attname); + Tango::DevUShort *get_YagSelector_data_ptr(string &name); + map<string,Tango::DevUShort> YagSelector_data; + + /** + * Attribute UpdateOnSelector related methods + * Description: + * + * Data type: Tango::DevBoolean + * Attr type: Scalar + */ + virtual void read_UpdateOnSelector(Tango::Attribute &attr); + virtual void write_UpdateOnSelector(Tango::WAttribute &attr); + virtual bool is_UpdateOnSelector_allowed(Tango::AttReqType type); + void add_UpdateOnSelector_dynamic_attribute(string attname); + void remove_UpdateOnSelector_dynamic_attribute(string attname); + Tango::DevBoolean *get_UpdateOnSelector_data_ptr(string &name); + map<string,Tango::DevBoolean> UpdateOnSelector_data; + + //-------------------------------------------------------- + /** + * Method : PespCCDStage::add_dynamic_attributes() + * Description : Add dynamic attributes if any. + */ + //-------------------------------------------------------- + void add_dynamic_attributes(); + + + + +// Command related methods +public: + /** + * Command SetAngleDistance related method + * Description: + * + * @param argin + * @returns + */ + virtual Tango::DevBoolean set_angle_distance(const Tango::DevVarDoubleArray *argin); + virtual bool is_SetAngleDistance_allowed(const CORBA::Any &any); + /** + * Command Stop related method + * Description: + * + */ + virtual void stop(); + virtual bool is_Stop_allowed(const CORBA::Any &any); + /** + * Command GetInstrumentList related method + * Description: Se ritorna ``zero`` stringhe, allora non c`e` nemmeno il corrispondente ``selector`` + * + * @returns + */ + virtual Tango::DevVarStringArray *get_instrument_list(); + virtual bool is_GetInstrumentList_allowed(const CORBA::Any &any); + + + //-------------------------------------------------------- + /** + * Method : PespCCDStage::add_dynamic_commands() + * Description : Add dynamic commands if any. + */ + //-------------------------------------------------------- + void add_dynamic_commands(); + +/*----- PROTECTED REGION ID(PespCCDStage::Additional Method prototypes) ENABLED START -----*/ + +// Additional Method prototypes +protected : + // + + void updateattributes(); + void updatestatus(); + + +/*----- PROTECTED REGION END -----*/ // PespCCDStage::Additional Method prototypes +}; + +/*----- PROTECTED REGION ID(PespCCDStage::Additional Classes Definitions) ENABLED START -----*/ + +// Additional Classes Definitions + +/*----- PROTECTED REGION END -----*/ // PespCCDStage::Additional Classes Definitions + +} // End of namespace + +#endif // PespCCDStage_H diff --git a/src/PespCCDStage.xmi b/src/PespCCDStage.xmi new file mode 100644 index 0000000000000000000000000000000000000000..e7306f705f186b17bfddf9ea6413dcebd1022d64 --- /dev/null +++ b/src/PespCCDStage.xmi @@ -0,0 +1,171 @@ +<?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="PespCCDStage" pogoRevision="9.4"> + <description description="" title="" sourcePath="/home/abrami/devel-T9/fermi/servers/pespccdstage/src" language="Cpp" filestogenerate="XMI file,Code files,Protected Regions" license="GPL" hasMandatoryProperty="true" hasConcreteProperty="true" hasAbstractCommand="false" hasAbstractAttribute="false"> + <inheritances classname="Device_Impl" sourcePath=""/> + <identification contact="at elettra.trieste.it - alessandro.abrami" author="alessandro.abrami" emailDomain="elettra.trieste.it" classFamily="BeamlineComponents" siteSpecific="" platform="All Platforms" bus="Not Applicable" manufacturer="none" reference=""/> + </description> + <deviceProperties name="OriginNL" mandatory="true" description="Coordinate di Q in XZ: x,z"> + <type xsi:type="pogoDsl:DoubleVectorType"/> + <status abstract="false" inherited="false" concrete="true" concreteHere="true"/> + </deviceProperties> + <deviceProperties name="YagCenterNL" description="Centro Yag in coord. NL"> + <type xsi:type="pogoDsl:DoubleVectorType"/> + <status abstract="false" inherited="false" concrete="true" concreteHere="true"/> + </deviceProperties> + <deviceProperties name="RotationXN" mandatory="true" description="Angolo (radianti) da N+ a X+"> + <type xsi:type="pogoDsl:DoubleType"/> + <status abstract="false" inherited="false" concrete="true" concreteHere="true"/> + </deviceProperties> + <deviceProperties name="GridChamber" mandatory="true" description="Device proxy
AttributoX
DefaultX
Device proxy
AttributoZ
DefaultZ

Coordinata X portareticolo o da device o da default:
device, default"> + <type xsi:type="pogoDsl:StringVectorType"/> + <status abstract="false" inherited="false" concrete="true" concreteHere="true"/> + </deviceProperties> + <deviceProperties name="GridPitch" mandatory="true" description="Device proxy
AttributoX
DefaultX
Valore pitch"> + <type xsi:type="pogoDsl:StringVectorType"/> + <status abstract="false" inherited="false" concrete="true" concreteHere="true"/> + </deviceProperties> + <deviceProperties name="CCDStageAxis" description="device proxy
Attributo N
device proxy
Attributo L"> + <type xsi:type="pogoDsl:StringVectorType"/> + <status abstract="false" inherited="false" concrete="true" concreteHere="true"/> + </deviceProperties> + <deviceProperties name="StageType" mandatory="true" description="Presto
Tardi"> + <type xsi:type="pogoDsl:StringType"/> + <status abstract="false" inherited="false" concrete="true" concreteHere="true"/> + </deviceProperties> + <deviceProperties name="YagsCenterOffsets" description="Offsets (d) Yag da centro di rotazione tavola lungo retta RQ`"> + <type xsi:type="pogoDsl:DoubleVectorType"/> + <status abstract="false" inherited="false" concrete="true" concreteHere="true"/> + </deviceProperties> + <deviceProperties name="RotationCenterXZ" description="Centro di rotazione (del naso) in coord. xOz"> + <type xsi:type="pogoDsl:DoubleVectorType"/> + <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="SetAngleDistance" description="" execMethod="set_angle_distance" displayLevel="OPERATOR" polledPeriod="0"> + <argin description=""> + <type xsi:type="pogoDsl:DoubleArrayType"/> + </argin> + <argout description=""> + <type xsi:type="pogoDsl:BooleanType"/> + </argout> + <status abstract="false" inherited="false" concrete="true" concreteHere="true"/> + </commands> + <commands name="Stop" description="" execMethod="stop" displayLevel="OPERATOR" polledPeriod="0"> + <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="GetInstrumentList" description="Se ritorna ``zero`` stringhe, allora non c`e` nemmeno il corrispondente ``selector``" execMethod="get_instrument_list" displayLevel="OPERATOR" polledPeriod="0" isDynamic="false"> + <argin description=""> + <type xsi:type="pogoDsl:VoidType"/> + </argin> + <argout description=""> + <type xsi:type="pogoDsl:StringArrayType"/> + </argout> + <status abstract="false" inherited="false" concrete="true" concreteHere="true"/> + </commands> + <attributes name="StageType" attType="Scalar" rwType="READ" displayLevel="OPERATOR" polledPeriod="0" maxX="" maxY="" allocReadMember="true" isDynamic="false"> + <dataType xsi:type="pogoDsl:StringType"/> + <changeEvent fire="false" libCheckCriteria="false"/> + <archiveEvent fire="false" libCheckCriteria="false"/> + <dataReadyEvent fire="false" libCheckCriteria="true"/> + <status abstract="false" inherited="false" concrete="true" concreteHere="true"/> + <properties description="" label="" unit="" standardUnit="" displayUnit="" format="" maxValue="" minValue="" maxAlarm="" minAlarm="" maxWarning="" minWarning="" deltaTime="" deltaValue=""/> + </attributes> + <attributes name="FocusX" attType="Scalar" rwType="READ_WRITE" displayLevel="OPERATOR" polledPeriod="0" maxX="" maxY="" memorized="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="Focus X" unit="mm" standardUnit="mm" displayUnit="mm" format="%7.3f" maxValue="" minValue="" maxAlarm="" minAlarm="" maxWarning="" minWarning="" deltaTime="" deltaValue=""/> + </attributes> + <attributes name="FocusZ" attType="Scalar" rwType="READ_WRITE" displayLevel="OPERATOR" polledPeriod="0" maxX="" maxY="" memorized="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="Focus Z" unit="mm" standardUnit="mm" displayUnit="mm" format="%7.3f" maxValue="" minValue="" maxAlarm="" minAlarm="" maxWarning="" minWarning="" deltaTime="" deltaValue=""/> + </attributes> + <attributes name="FocusDistance" attType="Scalar" rwType="READ_WRITE" displayLevel="OPERATOR" polledPeriod="0" maxX="" maxY="" memorized="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="Focus Distance (r')" unit="mm" standardUnit="mm" displayUnit="mm" format="%7.3f" maxValue="" minValue="" maxAlarm="" minAlarm="" maxWarning="" minWarning="" deltaTime="" deltaValue=""/> + </attributes> + <attributes name="FocusAngle" attType="Scalar" rwType="READ_WRITE" displayLevel="OPERATOR" polledPeriod="0" maxX="" maxY="" memorized="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="Focus Angle (beta)" unit="rad" standardUnit="rad" displayUnit="rad" format="%6.5f" maxValue="" minValue="" maxAlarm="" minAlarm="" maxWarning="" minWarning="" deltaTime="" deltaValue=""/> + </attributes> + <attributes name="Pitch" 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="rad" standardUnit="rad" displayUnit="rad" format="%6.3f" maxValue="" minValue="" maxAlarm="" minAlarm="" maxWarning="" minWarning="" deltaTime="" deltaValue=""/> + </attributes> + <attributes name="BeamOnYagDisplacement" 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="UpdateOnDisplacement" attType="Scalar" rwType="READ_WRITE" displayLevel="EXPERT" 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> + <dynamicAttributes name="YagSelector" attType="Scalar" rwType="READ_WRITE" displayLevel="OPERATOR" polledPeriod="0" maxX="" maxY="" memorized="true" memorizedAtInit="true" allocReadMember="true" isDynamic="true"> + <dataType xsi:type="pogoDsl:UShortType"/> + <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=""/> + </dynamicAttributes> + <dynamicAttributes name="UpdateOnSelector" attType="Scalar" rwType="READ_WRITE" displayLevel="EXPERT" polledPeriod="0" maxX="" maxY="" memorized="true" memorizedAtInit="true" allocReadMember="true" isDynamic="true"> + <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=""/> + </dynamicAttributes> + <preferences docHome="./doc_html" makefileHome="/usr/local/tango-9.2.5a/share/pogo/preferences"/> + </classes> +</pogoDsl:PogoSystem> diff --git a/src/PespCCDStageClass.cpp b/src/PespCCDStageClass.cpp new file mode 100644 index 0000000000000000000000000000000000000000..3db9c465c633ae2ef6192fd7c5a511316b713f0f --- /dev/null +++ b/src/PespCCDStageClass.cpp @@ -0,0 +1,875 @@ +/*----- PROTECTED REGION ID(PespCCDStageClass.cpp) ENABLED START -----*/ +//============================================================================= +// +// file : PespCCDStageClass.cpp +// +// description : C++ source for the PespCCDStageClass. +// A singleton class derived from DeviceClass. +// It implements the command and attribute list +// and all properties and methods required +// by the PespCCDStage once per process. +// +// project : PespCCDStage +// +// This file is part of Tango device class. +// +// Tango is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// Tango is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with Tango. If not, see <http://www.gnu.org/licenses/>. +// +// $Author: abrami $ +// +//============================================================================= +// This file is generated by POGO +// (Program Obviously used to Generate tango Object) +//============================================================================= + + +#include <tango.h> +#include <PespCCDStage.h> +#include <PespCCDStageClass.h> + +/*----- PROTECTED REGION END -----*/ // PespCCDStageClass.cpp + +//------------------------------------------------------------------- +/** + * Create PespCCDStageClass singleton and + * return it in a C function for Python usage + */ +//------------------------------------------------------------------- +extern "C" { +#ifdef _TG_WINDOWS_ + +__declspec(dllexport) + +#endif + + Tango::DeviceClass *_create_PespCCDStage_class(const char *name) { + return PespCCDStage_ns::PespCCDStageClass::init(name); + } +} + +namespace PespCCDStage_ns +{ +//=================================================================== +// Initialize pointer for singleton pattern +//=================================================================== +PespCCDStageClass *PespCCDStageClass::_instance = NULL; + +//-------------------------------------------------------- +/** + * method : PespCCDStageClass::PespCCDStageClass(string &s) + * description : constructor for the PespCCDStageClass + * + * @param s The class name + */ +//-------------------------------------------------------- +PespCCDStageClass::PespCCDStageClass(string &s):Tango::DeviceClass(s) +{ + cout2 << "Entering PespCCDStageClass constructor" << endl; + set_default_property(); + write_class_property(); + + /*----- PROTECTED REGION ID(PespCCDStageClass::constructor) ENABLED START -----*/ + + // version tag + + string Release(RELEASE); + set_cvs_tag(Release); + + string Repository(REPO); + set_cvs_location(Repository); + + doc_url = REPO; + + /*----- PROTECTED REGION END -----*/ // PespCCDStageClass::constructor + + cout2 << "Leaving PespCCDStageClass constructor" << endl; +} + +//-------------------------------------------------------- +/** + * method : PespCCDStageClass::~PespCCDStageClass() + * description : destructor for the PespCCDStageClass + */ +//-------------------------------------------------------- +PespCCDStageClass::~PespCCDStageClass() +{ + /*----- PROTECTED REGION ID(PespCCDStageClass::destructor) ENABLED START -----*/ + + /*----- PROTECTED REGION END -----*/ // PespCCDStageClass::destructor + + _instance = NULL; +} + + +//-------------------------------------------------------- +/** + * method : PespCCDStageClass::init + * description : Create the object if not already done. + * Otherwise, just return a pointer to the object + * + * @param name The class name + */ +//-------------------------------------------------------- +PespCCDStageClass *PespCCDStageClass::init(const char *name) +{ + if (_instance == NULL) + { + try + { + string s(name); + _instance = new PespCCDStageClass(s); + } + catch (bad_alloc &) + { + throw; + } + } + return _instance; +} + +//-------------------------------------------------------- +/** + * method : PespCCDStageClass::instance + * description : Check if object already created, + * and return a pointer to the object + */ +//-------------------------------------------------------- +PespCCDStageClass *PespCCDStageClass::instance() +{ + if (_instance == NULL) + { + cerr << "Class is not initialised !!" << endl; + exit(-1); + } + return _instance; +} + + + +//=================================================================== +// Command execution method calls +//=================================================================== +//-------------------------------------------------------- +/** + * method : SetAngleDistanceClass::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 *SetAngleDistanceClass::execute(Tango::DeviceImpl *device, const CORBA::Any &in_any) +{ + cout2 << "SetAngleDistanceClass::execute(): arrived" << endl; + const Tango::DevVarDoubleArray *argin; + extract(in_any, argin); + return insert((static_cast<PespCCDStage *>(device))->set_angle_distance(argin)); +} + +//-------------------------------------------------------- +/** + * method : StopClass::execute() + * description : method to trigger the execution of the command. + * + * @param device The device on which the command must be executed + * @param in_any The command input data + * + * returns The command output data (packed in the Any object) + */ +//-------------------------------------------------------- +CORBA::Any *StopClass::execute(Tango::DeviceImpl *device, TANGO_UNUSED(const CORBA::Any &in_any)) +{ + cout2 << "StopClass::execute(): arrived" << endl; + ((static_cast<PespCCDStage *>(device))->stop()); + return new CORBA::Any(); +} + +//-------------------------------------------------------- +/** + * method : GetInstrumentListClass::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 *GetInstrumentListClass::execute(Tango::DeviceImpl *device, TANGO_UNUSED(const CORBA::Any &in_any)) +{ + cout2 << "GetInstrumentListClass::execute(): arrived" << endl; + return insert((static_cast<PespCCDStage *>(device))->get_instrument_list()); +} + + +//=================================================================== +// Properties management +//=================================================================== +//-------------------------------------------------------- +/** + * Method : PespCCDStageClass::get_class_property() + * Description : Get the class property for specified name. + */ +//-------------------------------------------------------- +Tango::DbDatum PespCCDStageClass::get_class_property(string &prop_name) +{ + for (unsigned int i=0 ; i<cl_prop.size() ; i++) + if (cl_prop[i].name == prop_name) + return cl_prop[i]; + // if not found, returns an empty DbDatum + return Tango::DbDatum(prop_name); +} + +//-------------------------------------------------------- +/** + * Method : PespCCDStageClass::get_default_device_property() + * Description : Return the default value for device property. + */ +//-------------------------------------------------------- +Tango::DbDatum PespCCDStageClass::get_default_device_property(string &prop_name) +{ + for (unsigned int i=0 ; i<dev_def_prop.size() ; i++) + if (dev_def_prop[i].name == prop_name) + return dev_def_prop[i]; + // if not found, return an empty DbDatum + return Tango::DbDatum(prop_name); +} + +//-------------------------------------------------------- +/** + * Method : PespCCDStageClass::get_default_class_property() + * Description : Return the default value for class property. + */ +//-------------------------------------------------------- +Tango::DbDatum PespCCDStageClass::get_default_class_property(string &prop_name) +{ + for (unsigned int i=0 ; i<cl_def_prop.size() ; i++) + if (cl_def_prop[i].name == prop_name) + return cl_def_prop[i]; + // if not found, return an empty DbDatum + return Tango::DbDatum(prop_name); +} + + +//-------------------------------------------------------- +/** + * Method : PespCCDStageClass::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 PespCCDStageClass::set_default_property() +{ + string prop_name; + string prop_desc; + string prop_def; + vector<string> vect_data; + + // Set Default Class Properties + + // Set Default device Properties + prop_name = "OriginNL"; + prop_desc = "Coordinate di Q in XZ: x,z"; + 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 = "YagCenterNL"; + prop_desc = "Centro Yag in coord. NL"; + 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 = "RotationXN"; + prop_desc = "Angolo (radianti) da N+ a X+"; + 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 = "GridChamber"; + prop_desc = "Device proxy\nAttributoX\nDefaultX\nDevice proxy\nAttributoZ\nDefaultZ\n\nCoordinata X portareticolo o da device o da default:\ndevice, default"; + 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 = "GridPitch"; + prop_desc = "Device proxy\nAttributoX\nDefaultX\nValore pitch"; + 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 = "CCDStageAxis"; + prop_desc = "device proxy\nAttributo N\ndevice proxy\nAttributo L"; + 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 = "StageType"; + prop_desc = "Presto\nTardi"; + 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 = "YagsCenterOffsets"; + prop_desc = "Offsets (d) Yag da centro di rotazione tavola lungo retta RQ`"; + 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 = "RotationCenterXZ"; + prop_desc = "Centro di rotazione (del naso) in coord. xOz"; + 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 : PespCCDStageClass::write_class_property() + * Description : Set class description fields as property in database + */ +//-------------------------------------------------------- +void PespCCDStageClass::write_class_property() +{ + // First time, check if database used + if (Tango::Util::_UseDb == false) + return; + + Tango::DbData data; + string classname = get_name(); + string header; + string::size_type start, end; + + // Put title + Tango::DbDatum title("ProjectTitle"); + string str_title(""); + title << str_title; + data.push_back(title); + + // Put Description + Tango::DbDatum description("Description"); + vector<string> str_desc; + str_desc.push_back(""); + description << str_desc; + data.push_back(description); + + // Put inheritance + Tango::DbDatum inher_datum("InheritedFrom"); + vector<string> inheritance; + inheritance.push_back("TANGO_BASE_CLASS"); + inher_datum << inheritance; + data.push_back(inher_datum); + + // Call database and and values + get_db_class()->put_property(data); +} + +//=================================================================== +// Factory methods +//=================================================================== + +//-------------------------------------------------------- +/** + * Method : PespCCDStageClass::device_factory() + * Description : Create the device object(s) + * and store them in the device list + */ +//-------------------------------------------------------- +void PespCCDStageClass::device_factory(const Tango::DevVarStringArray *devlist_ptr) +{ + /*----- PROTECTED REGION ID(PespCCDStageClass::device_factory_before) ENABLED START -----*/ + + // Add your own code + + /*----- PROTECTED REGION END -----*/ // PespCCDStageClass::device_factory_before + + // Create devices and add it into the device list + for (unsigned long i=0 ; i<devlist_ptr->length() ; i++) + { + cout4 << "Device name : " << (*devlist_ptr)[i].in() << endl; + device_list.push_back(new PespCCDStage(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 + PespCCDStage *dev = static_cast<PespCCDStage *>(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(PespCCDStageClass::device_factory_after) ENABLED START -----*/ + + // Add your own code + + /*----- PROTECTED REGION END -----*/ // PespCCDStageClass::device_factory_after +} +//-------------------------------------------------------- +/** + * Method : PespCCDStageClass::attribute_factory() + * Description : Create the attribute object(s) + * and store them in the attribute list + */ +//-------------------------------------------------------- +void PespCCDStageClass::attribute_factory(vector<Tango::Attr *> &att_list) +{ + /*----- PROTECTED REGION ID(PespCCDStageClass::attribute_factory_before) ENABLED START -----*/ + + // Add your own code + + /*----- PROTECTED REGION END -----*/ // PespCCDStageClass::attribute_factory_before + // Attribute : StageType + StageTypeAttrib *stagetype = new StageTypeAttrib(); + Tango::UserDefaultAttrProp stagetype_prop; + // description not set for StageType + // label not set for StageType + // unit not set for StageType + // standard_unit not set for StageType + // display_unit not set for StageType + // format not set for StageType + // max_value not set for StageType + // min_value not set for StageType + // max_alarm not set for StageType + // min_alarm not set for StageType + // max_warning not set for StageType + // min_warning not set for StageType + // delta_t not set for StageType + // delta_val not set for StageType + + stagetype->set_default_properties(stagetype_prop); + // Not Polled + stagetype->set_disp_level(Tango::OPERATOR); + // Not Memorized + att_list.push_back(stagetype); + + // Attribute : FocusX + FocusXAttrib *focusx = new FocusXAttrib(); + Tango::UserDefaultAttrProp focusx_prop; + // description not set for FocusX + focusx_prop.set_label("Focus X"); + focusx_prop.set_unit("mm"); + focusx_prop.set_standard_unit("mm"); + focusx_prop.set_display_unit("mm"); + focusx_prop.set_format("%7.3f"); + // max_value not set for FocusX + // min_value not set for FocusX + // max_alarm not set for FocusX + // min_alarm not set for FocusX + // max_warning not set for FocusX + // min_warning not set for FocusX + // delta_t not set for FocusX + // delta_val not set for FocusX + + focusx->set_default_properties(focusx_prop); + // Not Polled + focusx->set_disp_level(Tango::OPERATOR); + focusx->set_memorized(); + focusx->set_memorized_init(false); + att_list.push_back(focusx); + + // Attribute : FocusZ + FocusZAttrib *focusz = new FocusZAttrib(); + Tango::UserDefaultAttrProp focusz_prop; + // description not set for FocusZ + focusz_prop.set_label("Focus Z"); + focusz_prop.set_unit("mm"); + focusz_prop.set_standard_unit("mm"); + focusz_prop.set_display_unit("mm"); + focusz_prop.set_format("%7.3f"); + // max_value not set for FocusZ + // min_value not set for FocusZ + // max_alarm not set for FocusZ + // min_alarm not set for FocusZ + // max_warning not set for FocusZ + // min_warning not set for FocusZ + // delta_t not set for FocusZ + // delta_val not set for FocusZ + + focusz->set_default_properties(focusz_prop); + // Not Polled + focusz->set_disp_level(Tango::OPERATOR); + focusz->set_memorized(); + focusz->set_memorized_init(false); + att_list.push_back(focusz); + + // Attribute : FocusDistance + FocusDistanceAttrib *focusdistance = new FocusDistanceAttrib(); + Tango::UserDefaultAttrProp focusdistance_prop; + // description not set for FocusDistance + focusdistance_prop.set_label("Focus Distance (r')"); + focusdistance_prop.set_unit("mm"); + focusdistance_prop.set_standard_unit("mm"); + focusdistance_prop.set_display_unit("mm"); + focusdistance_prop.set_format("%7.3f"); + // max_value not set for FocusDistance + // min_value not set for FocusDistance + // max_alarm not set for FocusDistance + // min_alarm not set for FocusDistance + // max_warning not set for FocusDistance + // min_warning not set for FocusDistance + // delta_t not set for FocusDistance + // delta_val not set for FocusDistance + + focusdistance->set_default_properties(focusdistance_prop); + // Not Polled + focusdistance->set_disp_level(Tango::OPERATOR); + focusdistance->set_memorized(); + focusdistance->set_memorized_init(false); + att_list.push_back(focusdistance); + + // Attribute : FocusAngle + FocusAngleAttrib *focusangle = new FocusAngleAttrib(); + Tango::UserDefaultAttrProp focusangle_prop; + // description not set for FocusAngle + focusangle_prop.set_label("Focus Angle (beta)"); + focusangle_prop.set_unit("rad"); + focusangle_prop.set_standard_unit("rad"); + focusangle_prop.set_display_unit("rad"); + focusangle_prop.set_format("%6.5f"); + // max_value not set for FocusAngle + // min_value not set for FocusAngle + // max_alarm not set for FocusAngle + // min_alarm not set for FocusAngle + // max_warning not set for FocusAngle + // min_warning not set for FocusAngle + // delta_t not set for FocusAngle + // delta_val not set for FocusAngle + + focusangle->set_default_properties(focusangle_prop); + // Not Polled + focusangle->set_disp_level(Tango::OPERATOR); + focusangle->set_memorized(); + focusangle->set_memorized_init(false); + att_list.push_back(focusangle); + + // Attribute : Pitch + PitchAttrib *pitch = new PitchAttrib(); + Tango::UserDefaultAttrProp pitch_prop; + // description not set for Pitch + // label not set for Pitch + pitch_prop.set_unit("rad"); + pitch_prop.set_standard_unit("rad"); + pitch_prop.set_display_unit("rad"); + pitch_prop.set_format("%6.3f"); + // max_value not set for Pitch + // min_value not set for Pitch + // max_alarm not set for Pitch + // min_alarm not set for Pitch + // max_warning not set for Pitch + // min_warning not set for Pitch + // delta_t not set for Pitch + // delta_val not set for Pitch + + pitch->set_default_properties(pitch_prop); + // Not Polled + pitch->set_disp_level(Tango::OPERATOR); + // Not Memorized + att_list.push_back(pitch); + + // Attribute : BeamOnYagDisplacement + BeamOnYagDisplacementAttrib *beamonyagdisplacement = new BeamOnYagDisplacementAttrib(); + Tango::UserDefaultAttrProp beamonyagdisplacement_prop; + // description not set for BeamOnYagDisplacement + // label not set for BeamOnYagDisplacement + // unit not set for BeamOnYagDisplacement + // standard_unit not set for BeamOnYagDisplacement + // display_unit not set for BeamOnYagDisplacement + // format not set for BeamOnYagDisplacement + // max_value not set for BeamOnYagDisplacement + // min_value not set for BeamOnYagDisplacement + // max_alarm not set for BeamOnYagDisplacement + // min_alarm not set for BeamOnYagDisplacement + // max_warning not set for BeamOnYagDisplacement + // min_warning not set for BeamOnYagDisplacement + // delta_t not set for BeamOnYagDisplacement + // delta_val not set for BeamOnYagDisplacement + + beamonyagdisplacement->set_default_properties(beamonyagdisplacement_prop); + // Not Polled + beamonyagdisplacement->set_disp_level(Tango::OPERATOR); + beamonyagdisplacement->set_memorized(); + beamonyagdisplacement->set_memorized_init(true); + att_list.push_back(beamonyagdisplacement); + + // Attribute : UpdateOnDisplacement + UpdateOnDisplacementAttrib *updateondisplacement = new UpdateOnDisplacementAttrib(); + Tango::UserDefaultAttrProp updateondisplacement_prop; + // description not set for UpdateOnDisplacement + // label not set for UpdateOnDisplacement + // unit not set for UpdateOnDisplacement + // standard_unit not set for UpdateOnDisplacement + // display_unit not set for UpdateOnDisplacement + // format not set for UpdateOnDisplacement + // max_value not set for UpdateOnDisplacement + // min_value not set for UpdateOnDisplacement + // max_alarm not set for UpdateOnDisplacement + // min_alarm not set for UpdateOnDisplacement + // max_warning not set for UpdateOnDisplacement + // min_warning not set for UpdateOnDisplacement + // delta_t not set for UpdateOnDisplacement + // delta_val not set for UpdateOnDisplacement + + updateondisplacement->set_default_properties(updateondisplacement_prop); + // Not Polled + updateondisplacement->set_disp_level(Tango::EXPERT); + updateondisplacement->set_memorized(); + updateondisplacement->set_memorized_init(true); + att_list.push_back(updateondisplacement); + + + // Create a list of static attributes + create_static_attribute_list(get_class_attr()->get_attr_list()); + /*----- PROTECTED REGION ID(PespCCDStageClass::attribute_factory_after) ENABLED START -----*/ + + // Add your own code + + /*----- PROTECTED REGION END -----*/ // PespCCDStageClass::attribute_factory_after +} +//-------------------------------------------------------- +/** + * Method : PespCCDStageClass::pipe_factory() + * Description : Create the pipe object(s) + * and store them in the pipe list + */ +//-------------------------------------------------------- +void PespCCDStageClass::pipe_factory() +{ + /*----- PROTECTED REGION ID(PespCCDStageClass::pipe_factory_before) ENABLED START -----*/ + + // Add your own code + + /*----- PROTECTED REGION END -----*/ // PespCCDStageClass::pipe_factory_before + /*----- PROTECTED REGION ID(PespCCDStageClass::pipe_factory_after) ENABLED START -----*/ + + // Add your own code + + /*----- PROTECTED REGION END -----*/ // PespCCDStageClass::pipe_factory_after +} +//-------------------------------------------------------- +/** + * Method : PespCCDStageClass::command_factory() + * Description : Create the command object(s) + * and store them in the command list + */ +//-------------------------------------------------------- +void PespCCDStageClass::command_factory() +{ + /*----- PROTECTED REGION ID(PespCCDStageClass::command_factory_before) ENABLED START -----*/ + + // Add your own code + + /*----- PROTECTED REGION END -----*/ // PespCCDStageClass::command_factory_before + + + // Command SetAngleDistance + SetAngleDistanceClass *pSetAngleDistanceCmd = + new SetAngleDistanceClass("SetAngleDistance", + Tango::DEVVAR_DOUBLEARRAY, Tango::DEV_BOOLEAN, + "", + "", + Tango::OPERATOR); + command_list.push_back(pSetAngleDistanceCmd); + + // Command Stop + StopClass *pStopCmd = + new StopClass("Stop", + Tango::DEV_VOID, Tango::DEV_VOID, + "", + "", + Tango::OPERATOR); + command_list.push_back(pStopCmd); + + // Command GetInstrumentList + GetInstrumentListClass *pGetInstrumentListCmd = + new GetInstrumentListClass("GetInstrumentList", + Tango::DEV_VOID, Tango::DEVVAR_STRINGARRAY, + "", + "", + Tango::OPERATOR); + command_list.push_back(pGetInstrumentListCmd); + + /*----- PROTECTED REGION ID(PespCCDStageClass::command_factory_after) ENABLED START -----*/ + + // Add your own code + + /*----- PROTECTED REGION END -----*/ // PespCCDStageClass::command_factory_after +} + +//=================================================================== +// Dynamic attributes related methods +//=================================================================== + +//-------------------------------------------------------- +/** + * method : PespCCDStageClass::create_static_attribute_list + * description : Create the a list of static attributes + * + * @param att_list the ceated attribute list + */ +//-------------------------------------------------------- +void PespCCDStageClass::create_static_attribute_list(vector<Tango::Attr *> &att_list) +{ + for (unsigned long i=0 ; i<att_list.size() ; i++) + { + string att_name(att_list[i]->get_name()); + transform(att_name.begin(), att_name.end(), att_name.begin(), ::tolower); + defaultAttList.push_back(att_name); + } + + cout2 << defaultAttList.size() << " attributes in default list" << endl; + + /*----- PROTECTED REGION ID(PespCCDStageClass::create_static_att_list) ENABLED START -----*/ + + /*----- PROTECTED REGION END -----*/ // PespCCDStageClass::create_static_att_list +} + + +//-------------------------------------------------------- +/** + * method : PespCCDStageClass::erase_dynamic_attributes + * description : delete the dynamic attributes if any. + * + * @param devlist_ptr the device list pointer + * @param list of all attributes + */ +//-------------------------------------------------------- +void PespCCDStageClass::erase_dynamic_attributes(const Tango::DevVarStringArray *devlist_ptr, vector<Tango::Attr *> &att_list) +{ + Tango::Util *tg = Tango::Util::instance(); + + for (unsigned long i=0 ; i<devlist_ptr->length() ; i++) + { + Tango::DeviceImpl *dev_impl = tg->get_device_by_name(((string)(*devlist_ptr)[i]).c_str()); + PespCCDStage *dev = static_cast<PespCCDStage *> (dev_impl); + + vector<Tango::Attribute *> &dev_att_list = dev->get_device_attr()->get_attribute_list(); + vector<Tango::Attribute *>::iterator ite_att; + for (ite_att=dev_att_list.begin() ; ite_att != dev_att_list.end() ; ++ite_att) + { + string att_name((*ite_att)->get_name_lower()); + if ((att_name == "state") || (att_name == "status")) + continue; + vector<string>::iterator ite_str = find(defaultAttList.begin(), defaultAttList.end(), att_name); + if (ite_str == defaultAttList.end()) + { + cout2 << att_name << " is a UNWANTED dynamic attribute for device " << (*devlist_ptr)[i] << endl; + Tango::Attribute &att = dev->get_device_attr()->get_attr_by_name(att_name.c_str()); + dev->remove_attribute(att_list[att.get_attr_idx()], true, false); + --ite_att; + } + } + } + /*----- PROTECTED REGION ID(PespCCDStageClass::erase_dynamic_attributes) ENABLED START -----*/ + + /*----- PROTECTED REGION END -----*/ // PespCCDStageClass::erase_dynamic_attributes +} + +//-------------------------------------------------------- +/** + * Method : PespCCDStageClass::get_attr_by_name() + * Description : returns Tango::Attr * object found by name + */ +//-------------------------------------------------------- +Tango::Attr *PespCCDStageClass::get_attr_object_by_name(vector<Tango::Attr *> &att_list, string attname) +{ + vector<Tango::Attr *>::iterator it; + for (it=att_list.begin() ; it<att_list.end() ; ++it) + if ((*it)->get_name()==attname) + return (*it); + // Attr does not exist + return NULL; +} + + +/*----- PROTECTED REGION ID(PespCCDStageClass::Additional Methods) ENABLED START -----*/ + +/*----- PROTECTED REGION END -----*/ // PespCCDStageClass::Additional Methods +} // namespace diff --git a/src/PespCCDStageClass.h b/src/PespCCDStageClass.h new file mode 100644 index 0000000000000000000000000000000000000000..6d583562ecc6856c0e7ca85abfa577ef5c9a52f1 --- /dev/null +++ b/src/PespCCDStageClass.h @@ -0,0 +1,332 @@ +/*----- PROTECTED REGION ID(PespCCDStageClass.h) ENABLED START -----*/ +//============================================================================= +// +// file : PespCCDStageClass.h +// +// description : Include for the PespCCDStage root class. +// This class is the singleton class for +// the PespCCDStage device class. +// It contains all properties and methods which the +// PespCCDStage requires only once e.g. the commands. +// +// project : PespCCDStage +// +// This file is part of Tango device class. +// +// Tango is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// Tango is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with Tango. If not, see <http://www.gnu.org/licenses/>. +// +// $Author: abrami $ +// +// +//============================================================================= +// This file is generated by POGO +// (Program Obviously used to Generate tango Object) +//============================================================================= + + +#ifndef PespCCDStageClass_H +#define PespCCDStageClass_H + +#include <tango.h> +#include <PespCCDStage.h> + +/*----- PROTECTED REGION END -----*/ // PespCCDStageClass.h + + +namespace PespCCDStage_ns +{ +/*----- PROTECTED REGION ID(PespCCDStageClass::classes for dynamic creation) ENABLED START -----*/ + + +/*----- PROTECTED REGION END -----*/ // PespCCDStageClass::classes for dynamic creation + +//========================================= +// Define classes for attributes +//========================================= +// Attribute StageType class definition +class StageTypeAttrib: public Tango::Attr +{ +public: + StageTypeAttrib():Attr("StageType", + Tango::DEV_STRING, Tango::READ) {}; + ~StageTypeAttrib() {}; + virtual void read(Tango::DeviceImpl *dev,Tango::Attribute &att) + {(static_cast<PespCCDStage *>(dev))->read_StageType(att);} + virtual bool is_allowed(Tango::DeviceImpl *dev,Tango::AttReqType ty) + {return (static_cast<PespCCDStage *>(dev))->is_StageType_allowed(ty);} +}; + +// Attribute FocusX class definition +class FocusXAttrib: public Tango::Attr +{ +public: + FocusXAttrib():Attr("FocusX", + Tango::DEV_DOUBLE, Tango::READ_WRITE) {}; + ~FocusXAttrib() {}; + virtual void read(Tango::DeviceImpl *dev,Tango::Attribute &att) + {(static_cast<PespCCDStage *>(dev))->read_FocusX(att);} + virtual void write(Tango::DeviceImpl *dev,Tango::WAttribute &att) + {(static_cast<PespCCDStage *>(dev))->write_FocusX(att);} + virtual bool is_allowed(Tango::DeviceImpl *dev,Tango::AttReqType ty) + {return (static_cast<PespCCDStage *>(dev))->is_FocusX_allowed(ty);} +}; + +// Attribute FocusZ class definition +class FocusZAttrib: public Tango::Attr +{ +public: + FocusZAttrib():Attr("FocusZ", + Tango::DEV_DOUBLE, Tango::READ_WRITE) {}; + ~FocusZAttrib() {}; + virtual void read(Tango::DeviceImpl *dev,Tango::Attribute &att) + {(static_cast<PespCCDStage *>(dev))->read_FocusZ(att);} + virtual void write(Tango::DeviceImpl *dev,Tango::WAttribute &att) + {(static_cast<PespCCDStage *>(dev))->write_FocusZ(att);} + virtual bool is_allowed(Tango::DeviceImpl *dev,Tango::AttReqType ty) + {return (static_cast<PespCCDStage *>(dev))->is_FocusZ_allowed(ty);} +}; + +// Attribute FocusDistance class definition +class FocusDistanceAttrib: public Tango::Attr +{ +public: + FocusDistanceAttrib():Attr("FocusDistance", + Tango::DEV_DOUBLE, Tango::READ_WRITE) {}; + ~FocusDistanceAttrib() {}; + virtual void read(Tango::DeviceImpl *dev,Tango::Attribute &att) + {(static_cast<PespCCDStage *>(dev))->read_FocusDistance(att);} + virtual void write(Tango::DeviceImpl *dev,Tango::WAttribute &att) + {(static_cast<PespCCDStage *>(dev))->write_FocusDistance(att);} + virtual bool is_allowed(Tango::DeviceImpl *dev,Tango::AttReqType ty) + {return (static_cast<PespCCDStage *>(dev))->is_FocusDistance_allowed(ty);} +}; + +// Attribute FocusAngle class definition +class FocusAngleAttrib: public Tango::Attr +{ +public: + FocusAngleAttrib():Attr("FocusAngle", + Tango::DEV_DOUBLE, Tango::READ_WRITE) {}; + ~FocusAngleAttrib() {}; + virtual void read(Tango::DeviceImpl *dev,Tango::Attribute &att) + {(static_cast<PespCCDStage *>(dev))->read_FocusAngle(att);} + virtual void write(Tango::DeviceImpl *dev,Tango::WAttribute &att) + {(static_cast<PespCCDStage *>(dev))->write_FocusAngle(att);} + virtual bool is_allowed(Tango::DeviceImpl *dev,Tango::AttReqType ty) + {return (static_cast<PespCCDStage *>(dev))->is_FocusAngle_allowed(ty);} +}; + +// Attribute Pitch class definition +class PitchAttrib: public Tango::Attr +{ +public: + PitchAttrib():Attr("Pitch", + Tango::DEV_DOUBLE, Tango::READ) {}; + ~PitchAttrib() {}; + virtual void read(Tango::DeviceImpl *dev,Tango::Attribute &att) + {(static_cast<PespCCDStage *>(dev))->read_Pitch(att);} + virtual bool is_allowed(Tango::DeviceImpl *dev,Tango::AttReqType ty) + {return (static_cast<PespCCDStage *>(dev))->is_Pitch_allowed(ty);} +}; + +// Attribute BeamOnYagDisplacement class definition +class BeamOnYagDisplacementAttrib: public Tango::Attr +{ +public: + BeamOnYagDisplacementAttrib():Attr("BeamOnYagDisplacement", + Tango::DEV_DOUBLE, Tango::READ_WRITE) {}; + ~BeamOnYagDisplacementAttrib() {}; + virtual void read(Tango::DeviceImpl *dev,Tango::Attribute &att) + {(static_cast<PespCCDStage *>(dev))->read_BeamOnYagDisplacement(att);} + virtual void write(Tango::DeviceImpl *dev,Tango::WAttribute &att) + {(static_cast<PespCCDStage *>(dev))->write_BeamOnYagDisplacement(att);} + virtual bool is_allowed(Tango::DeviceImpl *dev,Tango::AttReqType ty) + {return (static_cast<PespCCDStage *>(dev))->is_BeamOnYagDisplacement_allowed(ty);} +}; + +// Attribute UpdateOnDisplacement class definition +class UpdateOnDisplacementAttrib: public Tango::Attr +{ +public: + UpdateOnDisplacementAttrib():Attr("UpdateOnDisplacement", + Tango::DEV_BOOLEAN, Tango::READ_WRITE) {}; + ~UpdateOnDisplacementAttrib() {}; + virtual void read(Tango::DeviceImpl *dev,Tango::Attribute &att) + {(static_cast<PespCCDStage *>(dev))->read_UpdateOnDisplacement(att);} + virtual void write(Tango::DeviceImpl *dev,Tango::WAttribute &att) + {(static_cast<PespCCDStage *>(dev))->write_UpdateOnDisplacement(att);} + virtual bool is_allowed(Tango::DeviceImpl *dev,Tango::AttReqType ty) + {return (static_cast<PespCCDStage *>(dev))->is_UpdateOnDisplacement_allowed(ty);} +}; + + +//========================================= +// Define classes for dynamic attributes +//========================================= +// Attribute YagSelector class definition +class YagSelectorAttrib: public Tango::Attr +{ +public: + YagSelectorAttrib(const string &att_name):Attr(att_name.c_str(), + Tango::DEV_USHORT, Tango::READ_WRITE) {}; + ~YagSelectorAttrib() {}; + virtual void read(Tango::DeviceImpl *dev,Tango::Attribute &att) + {(static_cast<PespCCDStage *>(dev))->read_YagSelector(att);} + virtual void write(Tango::DeviceImpl *dev,Tango::WAttribute &att) + {(static_cast<PespCCDStage *>(dev))->write_YagSelector(att);} + virtual bool is_allowed(Tango::DeviceImpl *dev,Tango::AttReqType ty) + {return (static_cast<PespCCDStage *>(dev))->is_YagSelector_allowed(ty);} +}; + +// Attribute UpdateOnSelector class definition +class UpdateOnSelectorAttrib: public Tango::Attr +{ +public: + UpdateOnSelectorAttrib(const string &att_name):Attr(att_name.c_str(), + Tango::DEV_BOOLEAN, Tango::READ_WRITE) {}; + ~UpdateOnSelectorAttrib() {}; + virtual void read(Tango::DeviceImpl *dev,Tango::Attribute &att) + {(static_cast<PespCCDStage *>(dev))->read_UpdateOnSelector(att);} + virtual void write(Tango::DeviceImpl *dev,Tango::WAttribute &att) + {(static_cast<PespCCDStage *>(dev))->write_UpdateOnSelector(att);} + virtual bool is_allowed(Tango::DeviceImpl *dev,Tango::AttReqType ty) + {return (static_cast<PespCCDStage *>(dev))->is_UpdateOnSelector_allowed(ty);} +}; + + +//========================================= +// Define classes for commands +//========================================= +// Command SetAngleDistance class definition +class SetAngleDistanceClass : public Tango::Command +{ +public: + SetAngleDistanceClass(const char *name, + Tango::CmdArgType in, + Tango::CmdArgType out, + const char *in_desc, + const char *out_desc, + Tango::DispLevel level) + :Command(name,in,out,in_desc,out_desc, level) {}; + + SetAngleDistanceClass(const char *name, + Tango::CmdArgType in, + Tango::CmdArgType out) + :Command(name,in,out) {}; + ~SetAngleDistanceClass() {}; + + 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<PespCCDStage *>(dev))->is_SetAngleDistance_allowed(any);} +}; + +// Command Stop class definition +class StopClass : public Tango::Command +{ +public: + StopClass(const char *name, + Tango::CmdArgType in, + Tango::CmdArgType out, + const char *in_desc, + const char *out_desc, + Tango::DispLevel level) + :Command(name,in,out,in_desc,out_desc, level) {}; + + StopClass(const char *name, + Tango::CmdArgType in, + Tango::CmdArgType out) + :Command(name,in,out) {}; + ~StopClass() {}; + + virtual CORBA::Any *execute (Tango::DeviceImpl *dev, const CORBA::Any &any); + virtual bool is_allowed (Tango::DeviceImpl *dev, const CORBA::Any &any) + {return (static_cast<PespCCDStage *>(dev))->is_Stop_allowed(any);} +}; + +// Command GetInstrumentList class definition +class GetInstrumentListClass : public Tango::Command +{ +public: + GetInstrumentListClass(const char *name, + Tango::CmdArgType in, + Tango::CmdArgType out, + const char *in_desc, + const char *out_desc, + Tango::DispLevel level) + :Command(name,in,out,in_desc,out_desc, level) {}; + + GetInstrumentListClass(const char *name, + Tango::CmdArgType in, + Tango::CmdArgType out) + :Command(name,in,out) {}; + ~GetInstrumentListClass() {}; + + 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<PespCCDStage *>(dev))->is_GetInstrumentList_allowed(any);} +}; + + +/** + * The PespCCDStageClass singleton definition + */ + +#ifdef _TG_WINDOWS_ +class __declspec(dllexport) PespCCDStageClass : public Tango::DeviceClass +#else +class PespCCDStageClass : public Tango::DeviceClass +#endif +{ + /*----- PROTECTED REGION ID(PespCCDStageClass::Additionnal DServer data members) ENABLED START -----*/ + + + /*----- PROTECTED REGION END -----*/ // PespCCDStageClass::Additionnal DServer data members + + public: + // write class properties data members + Tango::DbData cl_prop; + Tango::DbData cl_def_prop; + Tango::DbData dev_def_prop; + + // Method prototypes + static PespCCDStageClass *init(const char *); + static PespCCDStageClass *instance(); + ~PespCCDStageClass(); + Tango::DbDatum get_class_property(string &); + Tango::DbDatum get_default_device_property(string &); + Tango::DbDatum get_default_class_property(string &); + + protected: + PespCCDStageClass(string &); + static PespCCDStageClass *_instance; + void command_factory(); + void attribute_factory(vector<Tango::Attr *> &); + void pipe_factory(); + void write_class_property(); + void set_default_property(); + void get_class_property(); + string get_cvstag(); + string get_cvsroot(); + + private: + void device_factory(const Tango::DevVarStringArray *); + void create_static_attribute_list(vector<Tango::Attr *> &); + void erase_dynamic_attributes(const Tango::DevVarStringArray *,vector<Tango::Attr *> &); + vector<string> defaultAttList; + Tango::Attr *get_attr_object_by_name(vector<Tango::Attr *> &att_list, string attname); +}; + +} // End of namespace + +#endif // PespCCDStage_H diff --git a/src/PespCCDStageDynAttrUtils.cpp b/src/PespCCDStageDynAttrUtils.cpp new file mode 100644 index 0000000000000000000000000000000000000000..6ea71569e6a53117a47a696ba653c7c7a2b9b570 --- /dev/null +++ b/src/PespCCDStageDynAttrUtils.cpp @@ -0,0 +1,231 @@ +/*----- PROTECTED REGION ID(PespCCDStage::DynAttrUtils.cpp) ENABLED START -----*/ +//============================================================================= +// +// file : PespCCDStageDynAttrUtils.cpp +// +// description : Dynamic attributes utilities file for the PespCCDStage class +// +// project : +// +// 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 <PespCCDStage.h> +#include <PespCCDStageClass.h> + +/*----- PROTECTED REGION END -----*/ // PespCCDStage::DynAttrUtils.cpp + +//================================================================ +// Attributes managed are: +//================================================================ +// YagSelector | Tango::DevUShort Scalar +// UpdateOnSelector | Tango::DevBoolean Scalar +//================================================================ + +// For compatibility reason, this file (PespCCDStageDynAttrUtils) +// manage also the dynamic command utilities. +//================================================================ +// The following table gives the correspondence +// between command and method names. +// +// Command name | Method name +//================================================================ +//================================================================ + +namespace PespCCDStage_ns +{ +//============================================================= +// Add/Remove dynamic attribute methods +//============================================================= + +//-------------------------------------------------------- +/** + * Add a YagSelector dynamic attribute. + * + * parameter attname: attribute name to be cretated and added. + */ +//-------------------------------------------------------- +void PespCCDStage::add_YagSelector_dynamic_attribute(string attname) +{ + // Attribute : YagSelector + YagSelectorAttrib *yagselector = new YagSelectorAttrib(attname); + Tango::UserDefaultAttrProp yagselector_prop; + // description not set for YagSelector + // label not set for YagSelector + // unit not set for YagSelector + // standard_unit not set for YagSelector + // display_unit not set for YagSelector + // format not set for YagSelector + // max_value not set for YagSelector + // min_value not set for YagSelector + // max_alarm not set for YagSelector + // min_alarm not set for YagSelector + // max_warning not set for YagSelector + // min_warning not set for YagSelector + // delta_t not set for YagSelector + // delta_val not set for YagSelector + + /*----- PROTECTED REGION ID(PespCCDStage::att_YagSelector_dynamic_attribute) ENABLED START -----*/ + + + /*----- PROTECTED REGION END -----*/ // PespCCDStage::att_YagSelector_dynamic_attribute + yagselector->set_default_properties(yagselector_prop); + // Not Polled + yagselector->set_disp_level(Tango::OPERATOR); + yagselector->set_memorized(); + yagselector->set_memorized_init(true); + YagSelector_data.insert(make_pair(attname, 0)); + add_attribute(yagselector); +} +//-------------------------------------------------------- +/** + * remove a YagSelector dynamic attribute. + * + * parameter attname: attribute name to be removed. + */ +//-------------------------------------------------------- +void PespCCDStage::remove_YagSelector_dynamic_attribute(string attname) +{ + remove_attribute(attname, true); + map<string,Tango::DevUShort>::iterator ite; + if ((ite=YagSelector_data.find(attname))!=YagSelector_data.end()) + { + /*----- PROTECTED REGION ID(PespCCDStage::remove_YagSelector_dynamic_attribute) ENABLED START -----*/ + + /*----- PROTECTED REGION END -----*/ // PespCCDStage::remove_YagSelector_dynamic_attribute + YagSelector_data.erase(ite); + } +} +//-------------------------------------------------------- +/** + * Add a UpdateOnSelector dynamic attribute. + * + * parameter attname: attribute name to be cretated and added. + */ +//-------------------------------------------------------- +void PespCCDStage::add_UpdateOnSelector_dynamic_attribute(string attname) +{ + // Attribute : UpdateOnSelector + UpdateOnSelectorAttrib *updateonselector = new UpdateOnSelectorAttrib(attname); + Tango::UserDefaultAttrProp updateonselector_prop; + // description not set for UpdateOnSelector + // label not set for UpdateOnSelector + // unit not set for UpdateOnSelector + // standard_unit not set for UpdateOnSelector + // display_unit not set for UpdateOnSelector + // format not set for UpdateOnSelector + // max_value not set for UpdateOnSelector + // min_value not set for UpdateOnSelector + // max_alarm not set for UpdateOnSelector + // min_alarm not set for UpdateOnSelector + // max_warning not set for UpdateOnSelector + // min_warning not set for UpdateOnSelector + // delta_t not set for UpdateOnSelector + // delta_val not set for UpdateOnSelector + + /*----- PROTECTED REGION ID(PespCCDStage::att_UpdateOnSelector_dynamic_attribute) ENABLED START -----*/ + + + /*----- PROTECTED REGION END -----*/ // PespCCDStage::att_UpdateOnSelector_dynamic_attribute + updateonselector->set_default_properties(updateonselector_prop); + // Not Polled + updateonselector->set_disp_level(Tango::EXPERT); + updateonselector->set_memorized(); + updateonselector->set_memorized_init(true); + UpdateOnSelector_data.insert(make_pair(attname, false)); + add_attribute(updateonselector); +} +//-------------------------------------------------------- +/** + * remove a UpdateOnSelector dynamic attribute. + * + * parameter attname: attribute name to be removed. + */ +//-------------------------------------------------------- +void PespCCDStage::remove_UpdateOnSelector_dynamic_attribute(string attname) +{ + remove_attribute(attname, true); + map<string,Tango::DevBoolean>::iterator ite; + if ((ite=UpdateOnSelector_data.find(attname))!=UpdateOnSelector_data.end()) + { + /*----- PROTECTED REGION ID(PespCCDStage::remove_UpdateOnSelector_dynamic_attribute) ENABLED START -----*/ + + /*----- PROTECTED REGION END -----*/ // PespCCDStage::remove_UpdateOnSelector_dynamic_attribute + UpdateOnSelector_data.erase(ite); + } +} + + +//============================================================ +// Tool methods to get pointer on attribute data buffer +//============================================================ +//-------------------------------------------------------- +/** + * Return a pointer on YagSelector data. + * + * parameter attname: the specified attribute name. + */ +//-------------------------------------------------------- +Tango::DevUShort *PespCCDStage::get_YagSelector_data_ptr(string &name) +{ + map<string,Tango::DevUShort>::iterator ite; + if ((ite=YagSelector_data.find(name))==YagSelector_data.end()) + { + TangoSys_OMemStream tms; + tms << "Dynamic attribute " << name << " has not been created"; + Tango::Except::throw_exception( + (const char *)"ATTRIBUTE_NOT_FOUND", + tms.str().c_str(), + (const char *)"PespCCDStage::get_YagSelector_data_ptr()"); + } + return &(ite->second); +} +//-------------------------------------------------------- +/** + * Return a pointer on UpdateOnSelector data. + * + * parameter attname: the specified attribute name. + */ +//-------------------------------------------------------- +Tango::DevBoolean *PespCCDStage::get_UpdateOnSelector_data_ptr(string &name) +{ + map<string,Tango::DevBoolean>::iterator ite; + if ((ite=UpdateOnSelector_data.find(name))==UpdateOnSelector_data.end()) + { + TangoSys_OMemStream tms; + tms << "Dynamic attribute " << name << " has not been created"; + Tango::Except::throw_exception( + (const char *)"ATTRIBUTE_NOT_FOUND", + tms.str().c_str(), + (const char *)"PespCCDStage::get_UpdateOnSelector_data_ptr()"); + } + return &(ite->second); +} + + +//============================================================= +// Add/Remove dynamic command methods +//============================================================= + + +} // namespace diff --git a/src/PespCCDStageStateMachine.cpp b/src/PespCCDStageStateMachine.cpp new file mode 100644 index 0000000000000000000000000000000000000000..aade630b1c71f897fe248048cb9dacbe9be88f4e --- /dev/null +++ b/src/PespCCDStageStateMachine.cpp @@ -0,0 +1,297 @@ +/*----- PROTECTED REGION ID(PespCCDStageStateMachine.cpp) ENABLED START -----*/ +//============================================================================= +// +// file : PespCCDStageStateMachine.cpp +// +// description : State machine file for the PespCCDStage class +// +// project : PespCCDStage +// +// This file is part of Tango device class. +// +// Tango is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// Tango is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with Tango. If not, see <http://www.gnu.org/licenses/>. +// +// $Author: abrami $ +// +// +//============================================================================= +// This file is generated by POGO +// (Program Obviously used to Generate tango Object) +//============================================================================= + +#include <PespCCDStage.h> + +/*----- PROTECTED REGION END -----*/ // PespCCDStage::PespCCDStageStateMachine.cpp + +//================================================================ +// States | Description +//================================================================ + + +namespace PespCCDStage_ns +{ +//================================================= +// Attributes Allowed Methods +//================================================= + +//-------------------------------------------------------- +/** + * Method : PespCCDStage::is_StageType_allowed() + * Description : Execution allowed for StageType attribute + */ +//-------------------------------------------------------- +bool PespCCDStage::is_StageType_allowed(TANGO_UNUSED(Tango::AttReqType type)) +{ + + // Not any excluded states for StageType attribute in read access. + /*----- PROTECTED REGION ID(PespCCDStage::StageTypeStateAllowed_READ) ENABLED START -----*/ + + /*----- PROTECTED REGION END -----*/ // PespCCDStage::StageTypeStateAllowed_READ + return true; +} + +//-------------------------------------------------------- +/** + * Method : PespCCDStage::is_FocusX_allowed() + * Description : Execution allowed for FocusX attribute + */ +//-------------------------------------------------------- +bool PespCCDStage::is_FocusX_allowed(TANGO_UNUSED(Tango::AttReqType type)) +{ + // Not any excluded states for FocusX attribute in Write access. + /*----- PROTECTED REGION ID(PespCCDStage::FocusXStateAllowed_WRITE) ENABLED START -----*/ + + /*----- PROTECTED REGION END -----*/ // PespCCDStage::FocusXStateAllowed_WRITE + + // Not any excluded states for FocusX attribute in read access. + /*----- PROTECTED REGION ID(PespCCDStage::FocusXStateAllowed_READ) ENABLED START -----*/ + + /*----- PROTECTED REGION END -----*/ // PespCCDStage::FocusXStateAllowed_READ + return true; +} + +//-------------------------------------------------------- +/** + * Method : PespCCDStage::is_FocusZ_allowed() + * Description : Execution allowed for FocusZ attribute + */ +//-------------------------------------------------------- +bool PespCCDStage::is_FocusZ_allowed(TANGO_UNUSED(Tango::AttReqType type)) +{ + // Not any excluded states for FocusZ attribute in Write access. + /*----- PROTECTED REGION ID(PespCCDStage::FocusZStateAllowed_WRITE) ENABLED START -----*/ + + /*----- PROTECTED REGION END -----*/ // PespCCDStage::FocusZStateAllowed_WRITE + + // Not any excluded states for FocusZ attribute in read access. + /*----- PROTECTED REGION ID(PespCCDStage::FocusZStateAllowed_READ) ENABLED START -----*/ + + /*----- PROTECTED REGION END -----*/ // PespCCDStage::FocusZStateAllowed_READ + return true; +} + +//-------------------------------------------------------- +/** + * Method : PespCCDStage::is_FocusDistance_allowed() + * Description : Execution allowed for FocusDistance attribute + */ +//-------------------------------------------------------- +bool PespCCDStage::is_FocusDistance_allowed(TANGO_UNUSED(Tango::AttReqType type)) +{ + // Not any excluded states for FocusDistance attribute in Write access. + /*----- PROTECTED REGION ID(PespCCDStage::FocusDistanceStateAllowed_WRITE) ENABLED START -----*/ + + /*----- PROTECTED REGION END -----*/ // PespCCDStage::FocusDistanceStateAllowed_WRITE + + // Not any excluded states for FocusDistance attribute in read access. + /*----- PROTECTED REGION ID(PespCCDStage::FocusDistanceStateAllowed_READ) ENABLED START -----*/ + + /*----- PROTECTED REGION END -----*/ // PespCCDStage::FocusDistanceStateAllowed_READ + return true; +} + +//-------------------------------------------------------- +/** + * Method : PespCCDStage::is_FocusAngle_allowed() + * Description : Execution allowed for FocusAngle attribute + */ +//-------------------------------------------------------- +bool PespCCDStage::is_FocusAngle_allowed(TANGO_UNUSED(Tango::AttReqType type)) +{ + // Not any excluded states for FocusAngle attribute in Write access. + /*----- PROTECTED REGION ID(PespCCDStage::FocusAngleStateAllowed_WRITE) ENABLED START -----*/ + + /*----- PROTECTED REGION END -----*/ // PespCCDStage::FocusAngleStateAllowed_WRITE + + // Not any excluded states for FocusAngle attribute in read access. + /*----- PROTECTED REGION ID(PespCCDStage::FocusAngleStateAllowed_READ) ENABLED START -----*/ + + /*----- PROTECTED REGION END -----*/ // PespCCDStage::FocusAngleStateAllowed_READ + return true; +} + +//-------------------------------------------------------- +/** + * Method : PespCCDStage::is_Pitch_allowed() + * Description : Execution allowed for Pitch attribute + */ +//-------------------------------------------------------- +bool PespCCDStage::is_Pitch_allowed(TANGO_UNUSED(Tango::AttReqType type)) +{ + + // Not any excluded states for Pitch attribute in read access. + /*----- PROTECTED REGION ID(PespCCDStage::PitchStateAllowed_READ) ENABLED START -----*/ + + /*----- PROTECTED REGION END -----*/ // PespCCDStage::PitchStateAllowed_READ + return true; +} + +//-------------------------------------------------------- +/** + * Method : PespCCDStage::is_BeamOnYagDisplacement_allowed() + * Description : Execution allowed for BeamOnYagDisplacement attribute + */ +//-------------------------------------------------------- +bool PespCCDStage::is_BeamOnYagDisplacement_allowed(TANGO_UNUSED(Tango::AttReqType type)) +{ + // Not any excluded states for BeamOnYagDisplacement attribute in Write access. + /*----- PROTECTED REGION ID(PespCCDStage::BeamOnYagDisplacementStateAllowed_WRITE) ENABLED START -----*/ + + /*----- PROTECTED REGION END -----*/ // PespCCDStage::BeamOnYagDisplacementStateAllowed_WRITE + + // Not any excluded states for BeamOnYagDisplacement attribute in read access. + /*----- PROTECTED REGION ID(PespCCDStage::BeamOnYagDisplacementStateAllowed_READ) ENABLED START -----*/ + + /*----- PROTECTED REGION END -----*/ // PespCCDStage::BeamOnYagDisplacementStateAllowed_READ + return true; +} + +//-------------------------------------------------------- +/** + * Method : PespCCDStage::is_UpdateOnDisplacement_allowed() + * Description : Execution allowed for UpdateOnDisplacement attribute + */ +//-------------------------------------------------------- +bool PespCCDStage::is_UpdateOnDisplacement_allowed(TANGO_UNUSED(Tango::AttReqType type)) +{ + // Not any excluded states for UpdateOnDisplacement attribute in Write access. + /*----- PROTECTED REGION ID(PespCCDStage::UpdateOnDisplacementStateAllowed_WRITE) ENABLED START -----*/ + + /*----- PROTECTED REGION END -----*/ // PespCCDStage::UpdateOnDisplacementStateAllowed_WRITE + + // Not any excluded states for UpdateOnDisplacement attribute in read access. + /*----- PROTECTED REGION ID(PespCCDStage::UpdateOnDisplacementStateAllowed_READ) ENABLED START -----*/ + + /*----- PROTECTED REGION END -----*/ // PespCCDStage::UpdateOnDisplacementStateAllowed_READ + return true; +} + +//-------------------------------------------------------- +/** + * Method : PespCCDStage::is_YagSelector_allowed() + * Description : Execution allowed for YagSelector attribute + */ +//-------------------------------------------------------- +bool PespCCDStage::is_YagSelector_allowed(TANGO_UNUSED(Tango::AttReqType type)) +{ + // Not any excluded states for YagSelector attribute in Write access. + /*----- PROTECTED REGION ID(PespCCDStage::YagSelectorStateAllowed_WRITE) ENABLED START -----*/ + + /*----- PROTECTED REGION END -----*/ // PespCCDStage::YagSelectorStateAllowed_WRITE + + // Not any excluded states for YagSelector attribute in read access. + /*----- PROTECTED REGION ID(PespCCDStage::YagSelectorStateAllowed_READ) ENABLED START -----*/ + + /*----- PROTECTED REGION END -----*/ // PespCCDStage::YagSelectorStateAllowed_READ + return true; +} + +//-------------------------------------------------------- +/** + * Method : PespCCDStage::is_UpdateOnSelector_allowed() + * Description : Execution allowed for UpdateOnSelector attribute + */ +//-------------------------------------------------------- +bool PespCCDStage::is_UpdateOnSelector_allowed(TANGO_UNUSED(Tango::AttReqType type)) +{ + // Not any excluded states for UpdateOnSelector attribute in Write access. + /*----- PROTECTED REGION ID(PespCCDStage::UpdateOnSelectorStateAllowed_WRITE) ENABLED START -----*/ + + /*----- PROTECTED REGION END -----*/ // PespCCDStage::UpdateOnSelectorStateAllowed_WRITE + + // Not any excluded states for UpdateOnSelector attribute in read access. + /*----- PROTECTED REGION ID(PespCCDStage::UpdateOnSelectorStateAllowed_READ) ENABLED START -----*/ + + /*----- PROTECTED REGION END -----*/ // PespCCDStage::UpdateOnSelectorStateAllowed_READ + return true; +} + + +//================================================= +// Commands Allowed Methods +//================================================= + +//-------------------------------------------------------- +/** + * Method : PespCCDStage::is_SetAngleDistance_allowed() + * Description : Execution allowed for SetAngleDistance attribute + */ +//-------------------------------------------------------- +bool PespCCDStage::is_SetAngleDistance_allowed(TANGO_UNUSED(const CORBA::Any &any)) +{ + // Not any excluded states for SetAngleDistance command. + /*----- PROTECTED REGION ID(PespCCDStage::SetAngleDistanceStateAllowed) ENABLED START -----*/ + + /*----- PROTECTED REGION END -----*/ // PespCCDStage::SetAngleDistanceStateAllowed + return true; +} + +//-------------------------------------------------------- +/** + * Method : PespCCDStage::is_Stop_allowed() + * Description : Execution allowed for Stop attribute + */ +//-------------------------------------------------------- +bool PespCCDStage::is_Stop_allowed(TANGO_UNUSED(const CORBA::Any &any)) +{ + // Not any excluded states for Stop command. + /*----- PROTECTED REGION ID(PespCCDStage::StopStateAllowed) ENABLED START -----*/ + + /*----- PROTECTED REGION END -----*/ // PespCCDStage::StopStateAllowed + return true; +} + +//-------------------------------------------------------- +/** + * Method : PespCCDStage::is_GetInstrumentList_allowed() + * Description : Execution allowed for GetInstrumentList attribute + */ +//-------------------------------------------------------- +bool PespCCDStage::is_GetInstrumentList_allowed(TANGO_UNUSED(const CORBA::Any &any)) +{ + // Not any excluded states for GetInstrumentList command. + /*----- PROTECTED REGION ID(PespCCDStage::GetInstrumentListStateAllowed) ENABLED START -----*/ + + /*----- PROTECTED REGION END -----*/ // PespCCDStage::GetInstrumentListStateAllowed + return true; +} + + +/*----- PROTECTED REGION ID(PespCCDStage::PespCCDStageStateAllowed.AdditionalMethods) ENABLED START -----*/ + +// Additional Methods + +/*----- PROTECTED REGION END -----*/ // PespCCDStage::PespCCDStageStateAllowed.AdditionalMethods + +} // End of namespace diff --git a/src/PespStage.h b/src/PespStage.h new file mode 100644 index 0000000000000000000000000000000000000000..a48f1020dfc078adbd9241649eba34faa8bf2af6 --- /dev/null +++ b/src/PespStage.h @@ -0,0 +1,112 @@ +#ifndef PespStage_H +#define PespStage_H + +#include <itpp/itbase.h> +#include <itpp/itcomm.h> +#include <math.h> +#include <vector> + +#define PI 3.14159265 + + +/** + * PespStage class description: + * + */ + +namespace PespStage_ns +{ + +//======================================================================= +// +// +class PespStage { +protected: + itpp::vec _chamber; + double _pitch; + + itpp::mat _rot; + itpp::vec _q; + itpp::vec _offset; + + double displacement; + +public: + PespStage(itpp::mat rot, itpp::vec q, itpp::vec offset) { _rot = rot; _q = q; _offset = offset;}; + + void set_chamber(itpp::vec chamber) { _chamber = chamber;}; + void set_pitch(double pitch) { _pitch = pitch;}; + + virtual itpp::vec calculateXZ2NL(itpp::vec p)=0; + virtual itpp::vec calculateNL2XZ(itpp::vec ccd)=0; + + virtual itpp::vec calculateBR2XZ(itpp::vec p)=0; + virtual itpp::vec calculateXZ2BR(itpp::vec Focus)=0; + + + double get_displacement() { return displacement;}; + void set_displacement(double v) { displacement = v;}; + +}; + +//======================================================================= +// +// +class PrestoStage : public PespStage { +private: + std::vector<itpp::vec> _yagsNL; + int _k; +public: + PrestoStage(itpp::mat rot, itpp::vec q, itpp::vec offset) : PespStage(rot, q, offset) { _yagsNL.resize(2); }; + + itpp::vec calculateXZ2NL(itpp::vec p); + itpp::vec calculateNL2XZ(itpp::vec ccd); + + itpp::vec calculateBR2XZ(itpp::vec p); + itpp::vec calculateXZ2BR(itpp::vec Focus); + + void setyagsNL(std::vector<itpp::vec> y) { _yagsNL = y; }; + void set_yag_NL(itpp::vec d) { _offset = d; }; + itpp::vec get_yag_NL() { return _offset; }; + void select_yag(int k) { _k = k; _offset = _yagsNL[k]; }; + int get_select_yag() { return _k; }; +}; + +//======================================================================= +// +// +class TardiStage : public PespStage { +private: + itpp::vec _cr; // in xOz + itpp::vec _crnl; // in nQl + double _d; + int _k; +public: + TardiStage(itpp::vec __cr, itpp::mat rot, itpp::vec q, itpp::vec offset) : PespStage(rot, q, offset) { set_rotcenter(__cr); _d = 0; }; + + itpp::vec NL2XZ(itpp::vec p); + itpp::vec XZ2NL(itpp::vec p); + itpp::mat rettap_nQl(itpp::vec qp); + itpp::mat rettap_xOz(itpp::vec p); + + itpp::mat rettap_orto(itpp::mat rtta, itpp::vec pto); + + itpp::vec pp2p(itpp::vec pp); + + void set_rotcenter(itpp::vec cr); // in xOz + void set_yag_distance(double d) { _d = d; }; + double get_yag_distance() { return _d; }; + void select_yag(int k) { _k = k; _d = _offset[k]; }; + int get_select_yag() { return _k; }; + + itpp::vec calculateXZ2NL(itpp::vec p); + itpp::vec calculateNL2XZ(itpp::vec ccd); + + itpp::vec calculateBR2XZ(itpp::vec p); + itpp::vec calculateXZ2BR(itpp::vec Focus); + +}; + +} // End of namespace + +#endif // PespCCDStage_H diff --git a/src/PrestoStage.cpp b/src/PrestoStage.cpp new file mode 100644 index 0000000000000000000000000000000000000000..da340509d5fc41914751a5efd6d85d9879e00848 --- /dev/null +++ b/src/PrestoStage.cpp @@ -0,0 +1,199 @@ +#include <PespStage.h> + + +namespace PespStage_ns +{ + + +//BBB +itpp::vec PrestoStage::calculateNL2XZ(itpp::vec ccd){ +// ccd coord. dello stage nel suo sitema di rif.: n,l +// offset dello yag rispetto 0,0 di rif n,l +// rot matrice di rotazione da n,l a x,z +// q coord di origine rif stage in sistema x,z +// +// p coord x,z dello yag + +itpp::vec Focus; + + #ifndef _WITHOUT_DIPLACEMENT + // SE si vuole introdurre il "displacement" sullo yag, + // allora gli offset (in particolare la coord n) + // deve essere modificata prima di fare il calcolo du cui sotto + + itpp::vec newoffset(_offset); + newoffset(0) += -displacement; + + Focus = _rot * (ccd + newoffset) + _q ; + #else + + Focus = _rot * (ccd + _offset) + _q ; + #endif + +#if MYDBG + cout << "yag center coord[x,z]= " << Focus << endl; +#endif + + return Focus; +} + +//------------------------------------------------------------------ +// +// +// + +itpp::vec PrestoStage::calculateXZ2BR(itpp::vec Focus){ +itpp::vec AngleDistance; +itpp::mat mr; +itpp::vec qr; +itpp::vec r; //retta per centro yag e centro specchio/chamber in x,z + + + mr.set_size(2,2,false); + qr.set_size(2,false); + r.set_size(2,false); + AngleDistance.set_size(2,false); + + + +#ifdef _DBG_CALCXZ2BR + std::cout << std::endl; + std::cout << "_chamber coord[x,z]= " << _chamber << std::endl; + std::cout << "Focus= " << Focus << std::endl; +#endif +//retta yag centro e contro camera/reticolo +// + mr(0,0)= _chamber[0]; + mr(0,1)= 1; + qr(0)= _chamber[1]; + mr(1,0)= Focus[0]; + mr(1,1)= 1; + qr(1)= Focus[1]; + + r = itpp::inv(mr) * qr; + +#ifdef _DBG_CALCXZ2BR + std::cout << "z1= " << qr(0) << std::endl; + std::cout << "x1= " << mr(0,0) << std::endl; + std::cout << "z2= " << qr(1) << std::endl; + std::cout << "x2= " << mr(1,0) << std::endl; + std::cout << "retta in coord[x,z]= " << r << std::endl; + std::cout << "angolo rispetto asse x= " << atan (r(0)) * 180 / PI << " gradi " << std::endl; + std::cout << "angolo rispetto asse z= " << 90 + atan (r(0)) * 180 / PI << " gradi " << std::endl; +#endif + + AngleDistance[0] = PI/2 + atan (r[0]) + _pitch; + + double d; + { + double x1=_chamber[0]; + double z1=_chamber[1]; + double x2=Focus[0]; + double z2=Focus[1]; + + d=sqrt((x1-x2)*(x1-x2)+(z1-z2)*(z1-z2)); + } +#ifdef _DBG_CALCXZ2BR + std::cout << "distanza " << d << std::endl; +#endif + AngleDistance[1] = d; + + mr.set_size(0,0,false); + qr.set_size(0,false); + r.set_size(0,false); + //AngleDistance.set_size(0,false); + + + return AngleDistance; +} +//----------------------------------------------------------------------------- +//----------------------------------------------------------------------------- +itpp::vec PrestoStage::calculateXZ2NL(itpp::vec p){ +itpp::vec ris(2); +itpp::mat tmat(2,2); + +// ccd coord. dello stage nel suo sitema di rif.: n,l +// offset dello yag rispetto 0,0 di rif n,l +// rot matrice di rotazione da n,l a x,z +// q coord di origine rif stage in sistema x,z +// +// p coord x,z dello yag +// +// ris coord ccd coord[n,l] +// + tmat = itpp::inv(_rot); +#if MYDBG2 + cout << "yag offset coord[n,l]= " << offset << endl; + cout << "ccd origin coord[x,z]= " << q << endl; + cout << "new yag center coord[x,z]= " << p << endl; + cout << "rot mat= " << rot << endl; + cout << " inv(rot) mat= " << tmat << endl; +#endif + + #ifndef _WITHOUT_DIPLACEMENT + // SE si vuole introdurre il "displacement" sullo yag, + // allora gli offset (in particolare la coord n) + // deve essere modificata prima di fare il calcolo du cui sotto + + itpp::vec newoffset(_offset); + newoffset(0) += -displacement; + + ris = (tmat*(p-_q))-newoffset; + #else + + ris = (tmat*(p-_q))-_offset; + + #endif + +#if MYDBG2 + cout << "new ccd coord[n,l]= " << ris << endl; +#endif + std::cout << "new ccd stage[n,l]= " << ris << std::endl; + + return ris; + +} +//----------------------------------------------------------------------------- +//----------------------------------------------------------------------------- +itpp::vec PrestoStage::calculateBR2XZ(itpp::vec p){ +itpp::vec ris(2); + +// +// p coord b,r dello yag rispetto specchio +// +// ris coord ccd coord[x,z] +// +#if MYDBG2 + cout << "chamber coord[x,z]= " << chamber << endl; + cout << "pitch= " << pitch << endl; + cout << "new yag center coord[b,r]= " << p << endl; + cout << endl; + cout << "angolo rispetto specchio= " << p(0) * 180 / PI << "gradi " << endl; +#endif +double m, x1, z1, x2, z2; + + m = p(0) - _pitch ; // angolo rispetto asse z + m = m + PI/2; // angolo rispetto asse x + + x1=_chamber[0]; + z1=_chamber[1]; + x2=x1 + p(1) * cos(m); + z2=z1 + p(1) * sin(m); + + ris(0)= x2; + ris(1)= z2; + +#if MYDBG2 + cout << "new stage coord[x,z]= " << ris << endl; +#endif + + std::cout << "new yag[b,r]= " << p << " " + << "new yag[x,z]= " << ris << std::endl; + + + return ris; +} + + +/*----- PROTECTED REGION END -----*/ // PespCCDStage::namespace_ending +} // namespace diff --git a/src/TardiStage.cpp b/src/TardiStage.cpp new file mode 100644 index 0000000000000000000000000000000000000000..1d0c7dee1be39265aac589e7257a97c7e28ab12c --- /dev/null +++ b/src/TardiStage.cpp @@ -0,0 +1,459 @@ +#include <PespStage.h> + + +namespace PespStage_ns +{ + +/********************************************************** +* +* +**********************************************************/ +itpp::vec TardiStage::pp2p(itpp::vec pp){ + + itpp::vec ris(2); + + ris = pp; + + double t = _cr(0); + double u = _cr(1); + double v = pp(0); + double w = pp(1); + double o = displacement; + + #ifdef _DBG_PP2P + std::cout << "_cr= " << _cr << std::endl; + std::cout << " pp= " << pp << std::endl; + std::cout << " o= " << o << std::endl; + #endif + + //double a = o*o -4*u*w -pow(t-v,2); + //double b = 2*(u-w)*(t-v); + //double c = -u*u -2*w*u +o*o -w*w; + + double R = fabs(o); + double a = -v+t+R; + double b = -2*u+2*w; + double c = v-t+R; + + double dlt = sqrt( b*b -4*a*c); + + double a1 = (-b + dlt)/(2*a); + double a2 = (-b - dlt)/(2*a); + + #ifdef _DBG_PP2P + std::cout << "a = " << a << std::endl; + std::cout << "b = " << b << std::endl; + std::cout << "c = " << c << std::endl; + std::cout << "dlt= " << dlt << std::endl; + std::cout << "a1 = " << a1 << std::endl; + std::cout << "a2 = " << a2 << std::endl; + #endif + + double costheta; + double sintheta; + if ( fabs(a1) <=1 ) { + costheta = (1-a1*a1)/(1+a1*a1); + sintheta = (2*a1)/(1+a1*a1); + } + if ( fabs(a2) <=1 ) { + costheta = (1-a2*a2)/(1+a2*a2); + sintheta = (2*a2)/(1+a2*a2); + } + + // rispetto al verso positivo di displa da P, devo togliere o... + // quindi -o + // + ris(0) = pp(0) + -o * costheta; + ris(1) = pp(1) + -o * sintheta; + + #ifdef _DBG_PP2P + std::cout << "costheta= " << costheta << std::endl; + std::cout << "sintheta= " << sintheta << std::endl; + std::cout << "R= " << R << std::endl; + + std::cout << "ris= " << ris << std::endl; + #endif + + return ris; +} + +/********************************************************** +* +* +**********************************************************/ +itpp::vec TardiStage::NL2XZ(itpp::vec p){ + itpp::vec ris(2); + + ris = _rot * p + _q; + + return ris; +} + +/********************************************************** +* +* +**********************************************************/ +itpp::vec TardiStage::XZ2NL(itpp::vec p){ + itpp::vec ris(2); + itpp::mat tmat(2,2); + + tmat = itpp::inv(_rot); + ris = (tmat*(p-_q)); + + #if _DBG_XZ2NL + std::cout << "NL origin coord[x,z]= " << _q << std::endl; + std::cout << "p in coord[x,z]= " << p << std::endl; + std::cout << "rot mat = " << std::endl << _rot << std::endl; + std::cout << "inv(rot) mat= " << std::endl << tmat << std::endl; + std::cout << "p in coord[n,l]= " << ris << std::endl; + #endif + + return ris; +} + + +/********************************************************** +* +* retta parametrica da R (cr) a Q' in nQl +* +**********************************************************/ +itpp::mat TardiStage::rettap_nQl(itpp::vec qp){ + itpp::mat rmat(2,2); + + rmat(0,0) = _crnl(0); + rmat(1,0) = _crnl(1); + rmat(0,1) = qp(0) - _crnl(0); + rmat(1,1) = qp(1) - _crnl(1); + + return rmat; +} + + +/********************************************************** +* +* retta parametrica ortogonale a rtta e passante per il puntp pto +* +**********************************************************/ +itpp::mat TardiStage::rettap_orto(itpp::mat rtta, itpp::vec pto){ + itpp::mat rmat(2,2); + + double m = sqrt( pow(rtta(1,1),2) + pow(rtta(0,1),2) ); + + rmat(0,0) = pto(0); + rmat(1,0) = pto(1); + rmat(0,1) = -rtta(1,1)/m; + rmat(1,1) = rtta(0,1)/m; + + return rmat; +} + + +/********************************************************** +* +* retta parametrica da R (cr) a Q' in xOz +* +**********************************************************/ +itpp::mat TardiStage::rettap_xOz(itpp::vec qp){ + itpp::mat rmat(2,2); + + rmat(0,0) = _cr(0); + rmat(1,0) = _cr(1); + rmat(0,1) = qp(0) - _cr(0); + rmat(1,1) = qp(1) - _cr(1); + + return rmat; +} + +/********************************************************** +* +* +**********************************************************/ +void TardiStage::set_rotcenter(itpp::vec cr){ + #ifdef _DBG_ROTCENTER + std::cout << "TardiStage::set_rotcenter(" << cr(0) << "," << cr(1) << ") in xOz" << std::endl; + #endif + + _cr = cr; + _crnl = XZ2NL(cr); + + #ifdef _DBG_ROTCENTER + std::cout << "TardiStage::set_rotcenter(" << _crnl(0) << "," << _crnl(1) << ") in nQl" << std::endl; + #endif +} + + +/********************************************************** +* +* qp coord di Q' in nQl +* +* _crnl coord centro rotazione in nQl +* +* p coord x,z dello yag +* +**********************************************************/ + +itpp::vec TardiStage::calculateNL2XZ(itpp::vec qp){ + + #ifdef _DBG_CALCNL2XZ + std::cout << "TardiStage::calculateNL2XZ()" << std::endl; + std::cout << "TardiStage::calculateNL2XZ() centro rotazione nQl = " << _crnl[0] << "," << _crnl[1] << std::endl; + #endif + + itpp::vec Focus(2), p_nQl(2), vt(2); + + double d; + { + double n1=_crnl[0]; + double l1=_crnl[1]; + double n2=qp[0]; + double l2=qp[1]; + + d=sqrt((n1-n2)*(n1-n2)+(l1-l2)*(l1-l2)); + } + double t; + { + t = (d + _d) / d ; + } + vt(0) = 1; + vt(1) = t; + + #ifndef _WITHOUT_DIPLACEMENT + // SE si vuole introdurre il "displacement" sullo yag, + // chiamiamo pp (P primo) questo nuovo punto, + // allora + // qui bisogna calcolare un nuovo "p_nQl": + // calcolare la retta ortogonale a retta_nQl e + // passante per il sopra calcolato p_nQl + // spostarsi sulla orto per il "displacement": + // si ottiene cosi' il nuovo "p_nQl" ovvero pp_nQl + + itpp::mat rtta(2,2); + itpp::mat rorto(2,2); + + rtta = rettap_nQl(qp); + p_nQl = rtta * vt; + rorto = rettap_orto(rtta, p_nQl); + + #ifdef _DBG_CALCNL2XZ + std::cout << std::endl; + std::cout << "----------------------------" << std::endl; + std::cout << "rtta = " << rtta << std::endl; + std::cout << "----------------------------" << std::endl; + std::cout << "p_nQl = " << p_nQl << std::endl; + std::cout << "----------------------------" << std::endl; + std::cout << "rorto = " << rorto << std::endl; + #endif + + itpp::vec dspl(2); + dspl[0] = 1; + dspl[1] = -displacement; // n ha verso opposto a x! + + itpp::vec pp_nQl(2); + pp_nQl = rorto * dspl; + + Focus = NL2XZ(pp_nQl); + + #else /* _WITHOUT_DIPLACEMENT */ + + p_nQl = rettap_nQl(qp) * vt; + Focus = NL2XZ(p_nQl); + + #endif /* _WITHOUT_DIPLACEMENT */ + + #ifdef _DBG_CALCNL2XZ + std::cout << "yag center coord[x,z]= " << Focus << std::endl; + #endif + + return Focus; +} + + +/********************************************************** +* +* +**********************************************************/ +itpp::vec TardiStage::calculateXZ2BR(itpp::vec Focus){ +itpp::vec AngleDistance; +itpp::mat mr; +itpp::vec qr; +itpp::vec r; //retta per centro yag e centro specchio/chamber in x,z + + + #ifdef _DBG_CALCXZ2BR + std::cout << "TardiStage::calculateXZ2BR()" << std::endl; + #endif + + mr.set_size(2,2,false); + qr.set_size(2,false); + r.set_size(2,false); + AngleDistance.set_size(2,false); + + + +#ifdef NNN_DBG_CALCXZ2BR + std::cout << "chamber coord[x,z]= " << chamber << std::endl; + std::cout << "pitch= " << pitch << std::endl; + std::cout << "ccd coord[n,l]= " << ccd << std::endl; + std::cout << "yag offset coord[n,l]= " << offset << std::endl; + std::cout << "ccd origin coord[x,z]= " << q << std::endl; +#endif +//retta yag centro e centro camera/reticolo +// + mr(0,0)= _chamber[0]; + mr(0,1)= 1; + qr(0)= _chamber[1]; + mr(1,0)= Focus[0]; + mr(1,1)= 1; + qr(1)= Focus[1]; + + r = itpp::inv(mr) * qr; + +#ifdef _DBG_CALCXZ2BR + std::cout << "z1= " << qr(0) << std::endl; + std::cout << "x1= " << mr(0,0) << std::endl; + std::cout << "z2= " << qr(1) << std::endl; + std::cout << "x2= " << mr(1,0) << std::endl; + std::cout << "retta centro yag - centro reticolo in coord[x,z]= " << r << std::endl; + std::cout << "angolo rispetto asse x= " << atan (r(0)) * 180 / PI << " gradi " << std::endl; + std::cout << "angolo rispetto asse z= " << 90 + atan (r(0)) * 180 / PI << " gradi " << std::endl; +#endif + + AngleDistance[0] = PI/2 + atan (r[0]) + _pitch; + + double d; + { + double x1=_chamber[0]; + double z1=_chamber[1]; + double x2=Focus[0]; + double z2=Focus[1]; + + d=sqrt((x1-x2)*(x1-x2)+(z1-z2)*(z1-z2)); + } +#ifdef _DBG_CALCXZ2BR + std::cout << "distanza " << d << std::endl; +#endif + AngleDistance[1] = d; + + mr.set_size(0,0,false); + qr.set_size(0,false); + r.set_size(0,false); + //AngleDistance.set_size(0,false); + + + return AngleDistance; +} +//----------------------------------------------------------------------------- +//----------------------------------------------------------------------------- +itpp::vec TardiStage::calculateXZ2NL(itpp::vec p){ +itpp::vec ris(2); +itpp::mat tmat(2,2); + +// ccd coord. dello stage nel suo sitema di rif.: n,l +// offset dello yag rispetto 0,0 di rif n,l +// rot matrice di rotazione da n,l a x,z +// q coord di origine rif stage in sistema x,z +// +// p coord x,z dello yag +// +// ris coord ccd coord[n,l] +// + + itpp::vec _p(2); + + #ifndef _WITHOUT_DIPLACEMENT + // SE si vuole introdurre il "displacement" sullo yag, + // chiamiamo pp (P primo) questo nuovo punto, + // allora + // + // dato il cerchio di centro pp e raggio "displacement + // devo trovare la (le) tangente al cerchio passante per cr + // il punto di tangenza e' p, + // da cui con la formula parametrica della retta cr-p + // trovo qp.... + + if (displacement == 0.0 ){ + _p = p; + } else { + itpp::vec pp(p); + _p = pp2p(pp); + } + + #else /* _WITHOUT_DIPLACEMENT */ + _p = p; + + #endif /* _WITHOUT_DIPLACEMENT */ + + double d; + { + double x1=_cr[0]; + double z1=_cr[1]; + double x2=_p[0]; + double z2=_p[1]; + + d=sqrt((x1-x2)*(x1-x2)+(z1-z2)*(z1-z2)); + } + + double t; + { + t = (d - _d) / d ; + } + + itpp::vec vt(2); + vt(0) = 1; + vt(1) = t; + + itpp::vec qp(2); + qp = rettap_xOz(_p) * vt; + + ris = XZ2NL(qp); + + #if _DBG_CALCXZ2NL + std::cout << "new ccd coord[n,l]= " << ris << std::endl; + #endif + + return ris; + +} +//----------------------------------------------------------------------------- +//----------------------------------------------------------------------------- +itpp::vec TardiStage::calculateBR2XZ(itpp::vec p){ +itpp::vec ris(2); + +// +// p coord b,r dello yag rispetto specchio +// +// ris coord ccd coord[x,z] +// + #if _DBG_CALCBR2XZ + std::cout << "chamber coord[x,z]= " << _chamber << std::endl; + std::cout << "pitch= " << _pitch << std::endl; + std::cout << "angolo rispetto specchio= " << p(0) * 180 / PI << "gradi " << std::endl; + #endif + +double m, x1, z1, x2, z2; + + m = p(0) - _pitch ; // angolo rispetto asse z + m = m + PI/2; // angolo rispetto asse x + + x1=_chamber[0]; + z1=_chamber[1]; + x2=x1 + p(1) * cos(m); + z2=z1 + p(1) * sin(m); + + ris(0)= x2; + ris(1)= z2; + + #if _DBG_CALCBR2XZ + std::cout << "new stage coord[x,z]= " << ris << std::endl; + + std::cout << "new yag[b,r]= " << p << " " + << "new yag[x,z]= " << ris << std::endl; + #endif + + + return ris; +} + + +/*----- PROTECTED REGION END -----*/ // PespCCDStage::namespace_ending +} // namespace diff --git a/src/Xstring.h b/src/Xstring.h new file mode 100644 index 0000000000000000000000000000000000000000..7eb7a54783ee3bead92b7eda2a0669d386af7e9c --- /dev/null +++ b/src/Xstring.h @@ -0,0 +1,62 @@ +#ifndef XSTRING_H + +#define XSTRING_H + + + +#include <sstream> + +#include <string> + + + +template<class T> class XString{ + + + +public: + + + + inline static T convertFromString(const std::string& s) + + { + + std::istringstream in(s); + + T x; + + if (in >> x) + + return x; + + // some sort of error handling goes here... + + return 0; + + } + +// + + inline static std::string convertToString(const T & t) + + { + + std::ostringstream out ; + + if (out << t ) + + return out.str(); + + // some sort of error handling goes here... + + return 0; + + } + + + +}; + +#endif + diff --git a/src/main.cpp b/src/main.cpp new file mode 100644 index 0000000000000000000000000000000000000000..86c5c7cc1150492e5815374c67e0ec9f693a5ae3 --- /dev/null +++ b/src/main.cpp @@ -0,0 +1,83 @@ +/*----- PROTECTED REGION ID(PespCCDStage::main.cpp) ENABLED START -----*/ +//============================================================================= +// +// file : main.cpp +// +// description : C++ source for the PespCCDStage device server main. +// The main rule is to initialise (and create) the Tango +// system and to create the DServerClass singleton. +// The main should be the same for every Tango device server. +// +// project : PespCCDStage +// +// This file is part of Tango device class. +// +// Tango is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// Tango is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with Tango. If not, see <http://www.gnu.org/licenses/>. +// +// $Author: abrami $ +// +// +//============================================================================= +// This file is generated by POGO +// (Program Obviously used to Generate tango Object) +//============================================================================= + + +#include <tango.h> +#include "libaxisutils.h" + + + +int main(int argc,char *argv[]) +{ + + Tango::Util *tg; + + //This is added for priority fixing + dserver_extra(argc,argv); + + try + { + // Initialise the device server + //---------------------------------------- + tg = Tango::Util::init(argc,argv); + + // Create the device server singleton + // which will create everything + //---------------------------------------- + tg->server_init(false); + + // Run the endless loop + //---------------------------------------- + cout << "Ready to accept request" << endl; + tg->server_run(); + } + catch (bad_alloc) + { + cout << "Can't allocate memory to store device object !!!" << endl; + cout << "Exiting" << endl; + } + catch (CORBA::Exception &e) + { + Tango::Except::print_exception(e); + + cout << "Received a CORBA_Exception" << endl; + cout << "Exiting" << endl; + } + tg->server_cleanup(); + return(0); +} + + +/*----- PROTECTED REGION END -----*/ // PespCCDStage::main.cpp