From 56eb6388a7563a3702edfcde730bc16d22fce430 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Picca=20Fr=C3=A9d=C3=A9ric-Emmanuel?= Date: Fri, 17 Apr 2009 15:14:37 +0200 Subject: [PATCH] * add the PseudoAxesAdapter. --- src/Matrix.h | 13 --------- src/PseudoAxesAdapter.cpp | 24 ++++++++++++++++ src/PseudoAxesAdapter.h | 30 ++++++++++++++++++++ src/TangoHKLAdapter.cpp | 71 ++++++++++++++++++++++++++++++++++++++++++++++- src/TangoHKLAdapter.h | 5 ++++ 5 files changed, 129 insertions(+), 14 deletions(-) create mode 100644 src/PseudoAxesAdapter.cpp create mode 100644 src/PseudoAxesAdapter.h diff --git a/src/Matrix.h b/src/Matrix.h index 59715b5..6cd2801 100644 --- a/src/Matrix.h +++ b/src/Matrix.h @@ -20,19 +20,6 @@ struct Matrix this->_own_data = true; } - Matrix(Matrix const & m) - { - this->xdim = m.xdim; - this->ydim = m.ydim; - _own_data = m._own_data; - if(_own_data){ - this->data = new T[this->xdim * this->ydim]; - ::memcpy(this->data, m.data, sizeof(*m.data) * this->xdim * this->ydim); - } else { - this->data = m.data; - } - } - virtual ~Matrix(void) { if(_own_data){ diff --git a/src/PseudoAxesAdapter.cpp b/src/PseudoAxesAdapter.cpp new file mode 100644 index 0000000..f395e68 --- /dev/null +++ b/src/PseudoAxesAdapter.cpp @@ -0,0 +1,24 @@ +#include "TangoHKLAdapter.h" +#include "PseudoAxesAdapter.h" + +namespace DiffractometerDevice_ns +{ + + PseudoAxesAdapter::PseudoAxesAdapter(TangoHKLAdapter *hklAdapter, size_t idx): + _hklAdapter(hklAdapter), + _idx(idx) + { + HklPseudoAxisEngine *engine; + size_t len; + + engine = _hklAdapter->diffractometer()->engines_r->engines[_idx]; + len = HKL_LIST_LEN(engine->pseudoAxes); + _read.resize(len, 1); + _write.resize(len, 1); + } + + void PseudoAxesAdapter::write(Matrix const & write) + { + _hklAdapter->pseudo_axes_write(_idx, write); + } +} diff --git a/src/PseudoAxesAdapter.h b/src/PseudoAxesAdapter.h new file mode 100644 index 0000000..9eb6a31 --- /dev/null +++ b/src/PseudoAxesAdapter.h @@ -0,0 +1,30 @@ +#ifndef __PSEUDOAXES_ADAPTER_H__ +#define __PSEUDOAXES_ADAPTER_H__ + +#include "Matrix.h" + +namespace DiffractometerDevice_ns { + + //forwar declaration + class TangoHKLAdapter; + + class PseudoAxesAdapter { + friend class TangoHKLAdapter; + + public: + PseudoAxesAdapter(TangoHKLAdapter *hklAdapter, size_t _idx); + + Matrix const & get_read(void) const {return _read;} + Matrix const & get_write(void) const {return _write;} + + void write(Matrix const & write); + private: + TangoHKLAdapter *_hklAdapter; + size_t _idx; + Matrix _read; + Matrix _write; + }; +} + + +#endif // __PSEUDOAXES_ADAPTER_H__ diff --git a/src/TangoHKLAdapter.cpp b/src/TangoHKLAdapter.cpp index e9263e4..6a2d4cd 100644 --- a/src/TangoHKLAdapter.cpp +++ b/src/TangoHKLAdapter.cpp @@ -81,6 +81,11 @@ namespace DiffractometerDevice_ns for(i=0; iengines_r->engines); + for(i=0; iset_lambda(1.54); } @@ -459,6 +464,23 @@ namespace DiffractometerDevice_ns buffer->to_proxies(); } + void TangoHKLAdapter::update_pseudo_axes_adapters(void) + { + size_t i, j, len; + HklPseudoAxisEngine *engine_r, *engine_w; + + for(i=0; i<_pseudos.size(); ++i){ + engine_r = _diffractometer->engines_r->engines[i]; + engine_w = _diffractometer->engines_w->engines[i]; + len = HKL_LIST_LEN(engine_r->pseudoAxes); + for(j=0; jpseudoAxes[j]->parent); + _pseudos[i]._write.data[j] = hkl_parameter_get_value_unit(&engine_w->pseudoAxes[j]->parent); + + } + } + } + void TangoHKLAdapter::update(void) { /********************************************** @@ -471,6 +493,7 @@ namespace DiffractometerDevice_ns this->update_library_from_axisBuffers(); this->update_HKLBuffer_from_library(); this->update_pseudo_axis_buffers_from_library(); + this->update_pseudo_axes_adapters(); /********************************************** * END OF CRITICAL SECTION **********************************************/ @@ -1071,7 +1094,7 @@ namespace DiffractometerDevice_ns } /*******************/ - /* pseudoAxes part */ + /* pseudoAxis part */ /*******************/ std::vector TangoHKLAdapter::pseudo_axis_get_names(void) @@ -1161,6 +1184,52 @@ namespace DiffractometerDevice_ns } + /*******************/ + /* pseudoAxes part */ + /*******************/ + + void TangoHKLAdapter::pseudo_axes_write(size_t idx, Matrix const & write) + { + omni_mutex_lock lock(_lock); + + size_t i, len; + int res = HKL_FAIL; + HklPseudoAxisEngineList *engines_r, *engines_w; + HklGeometry *geometry_r, *geometry_w; + HklDetector *detector; + HklSample *sample; + + engines_r = _diffractometer->engines_r; + engines_w = _diffractometer->engines_w; + len = HKL_LIST_LEN(engines_w->engines); + + geometry_r = _diffractometer->geometry_r; + geometry_w = _diffractometer->geometry_w; + + detector = &_diffractometer->detector; + + sample = _diffractometer->samples->current; + + for(i=0; iengines[idx]->pseudoAxes[i]->parent, write.data[i]); + + res = hkl_pseudo_axis_engine_setter(engines_w->engines[idx], geometry_w, detector, sample); + if (HKL_SUCCESS == res){ + hkl_geometry_init_geometry(geometry_w, engines_w->geometries->geometries[0]); + hkl_pseudo_axis_engine_list_getter(engines_w, geometry_w, detector, sample); + if(this->simulated){ + hkl_geometry_init_geometry(geometry_r, engines_w->geometries->geometries[0]); + hkl_pseudo_axis_engine_list_getter(engines_r, geometry_r, detector, sample); + } + + this->update_angles(); + this->update_axis_adapters(); + this->update_pseudo_axis_buffers_from_library(); + }else + TANGO_EXCEPTION_THROW_WITHOUT_LOG("Can not write on this pseudo axis", + "Check the sample"); + + } /********************/ /* State and Status */ /********************/ diff --git a/src/TangoHKLAdapter.h b/src/TangoHKLAdapter.h index 1102876..79b2fd2 100644 --- a/src/TangoHKLAdapter.h +++ b/src/TangoHKLAdapter.h @@ -13,6 +13,7 @@ #include "AxisAdapter.h" #include "PseudoAxisAdapter.h" +#include "PseudoAxesAdapter.h" #include "Matrix.h" #if ( _MSC_VER && _MSC_VER <= 1200 ) @@ -213,12 +214,14 @@ namespace DiffractometerDevice_ns { Matrix & get_pseudo_axes_names(void) {omni_mutex_lock lock(_lock); return _pseudo_axes_names;} + void pseudo_axes_write(size_t idx, Matrix const & write); protected : omni_mutex _lock; HklDiffractometer *_diffractometer; std::vector _axes; std::vector _pseudoAxes; + std::vector _pseudos; HKLBuffer _hklBuffer; Tango::Group *_proxies; Tango::AttributeProxy *_lambdaAttributeProxy; @@ -246,6 +249,8 @@ namespace DiffractometerDevice_ns { void update_pseudo_axis_buffers_from_library(void); + void update_pseudo_axes_adapters(void); + void update_library_from_axisBuffers(void); void update_proxies_from_axisBuffers(void); -- 2.11.4.GIT