From 6f75002dbef2caf7f662030585cc4bebfb9f7948 Mon Sep 17 00:00:00 2001 From: System User Date: Tue, 14 Apr 2009 14:15:01 +0200 Subject: [PATCH] * new from/to_proxy for the AxisAdpater class use thoses methodes in the TangoHKLAdapter. --- src/AxisAdapter.cpp | 31 +++++++++++++++++-------- src/AxisAdapter.h | 4 ++-- src/TangoHKLAdapter.cpp | 60 +++++-------------------------------------------- 3 files changed, 30 insertions(+), 65 deletions(-) diff --git a/src/AxisAdapter.cpp b/src/AxisAdapter.cpp index 8f27cec..ee0c0a4 100644 --- a/src/AxisAdapter.cpp +++ b/src/AxisAdapter.cpp @@ -112,15 +112,19 @@ namespace DiffractometerDevice_ns { hkl_axis_set_range_unit(_axis_w, _min, _max); } - void AxisAdapter::set_read_write(std::vector const & positions) - { - _read = positions[0]; - _write = positions[1]; - } - - void AxisAdapter::set_min_max_from_proxy(void) + void AxisAdapter::from_proxy(void) { if(this->is_ready()){ + Tango::DeviceAttribute attr; + std::vector positions; + + // read the position attribute + attr = _proxy->read_attribute(AXIS_ATTRIBUTE_POSITION_NAME); + attr >> positions; + _read = positions[0]; + _write = positions[1]; + + // read the range /* * here an hack due to the * get_attribute_config signature @@ -139,11 +143,20 @@ namespace DiffractometerDevice_ns { token = info.max_value.c_str(); if (!strstr(token, "Not specified")) _max = atof(token); + + // read the state + _state = _proxy->state(); } } - double AxisAdapter::get_write_for_proxy(void) + void AxisAdapter::to_proxy(void) { - return hkl_axis_get_value_closest_unit(_axis_w, _axis_r); +#ifdef WRITE_TO_PROXY_ALLOWED + if(this->is_ready()){ + Tango::DeviceAttribute attr(AXIS_ATTRBIUTE_POSITION_NAME, _write); + _state = Tango::MOVING; + _proxy->write_attribute(attr); + } +#endif } } diff --git a/src/AxisAdapter.h b/src/AxisAdapter.h index 6a8b640..189ca0e 100644 --- a/src/AxisAdapter.h +++ b/src/AxisAdapter.h @@ -37,9 +37,9 @@ namespace DiffractometerDevice_ns { void to_HklAxis(void); - void set_read_write(std::vector const & positions); + void from_proxy(void); - void set_min_max_from_proxy(void); + void to_proxy(void); private: diff --git a/src/TangoHKLAdapter.cpp b/src/TangoHKLAdapter.cpp index cf6f90f..bd87508 100644 --- a/src/TangoHKLAdapter.cpp +++ b/src/TangoHKLAdapter.cpp @@ -498,67 +498,19 @@ namespace DiffractometerDevice_ns void TangoHKLAdapter::update_axisBuffers_from_proxies(void) { - size_t i; - duration.Stop(); - double current_duration = duration.GetDurationInMs(); - - if(current_duration >= 200 && _proxies) { - //- enable exceptions from GroupReply - // keep the last mode to restore it at the end. - bool last_mode = Tango::GroupReply::enable_exception(true); - Tango::GroupCmdReplyList stateReply = _proxies->command_inout("State", true); - Tango::GroupAttrReplyList reply = _proxies->read_attribute(AXIS_ATTRIBUTE_POSITION_NAME, true); - Tango::GroupReply::enable_exception(last_mode); - - // restart counter + if(duration.GetDurationInMs() >= 200 && _proxies) { + for(size_t i=0; i<_axes.size(); ++i) + _axes[i].from_proxy(); duration.Start(); - - for(i=0; i<_axes.size(); ++i) { - Tango::DevState state; - AxisAdapter & axis = _axes[i]; - - if(!stateReply.has_failed()){ - stateReply[i] >> state; - axis.set_state(state); - } - - if(!reply[i].has_failed()) { - std::vector positions; - - reply[i] >> positions; - - axis.set_read_write(positions); - axis.set_min_max_from_proxy(); - } - } } } void TangoHKLAdapter::update_proxies_from_axisBuffers(void) { - size_t i; - std::vector values(_axes.size()); - _proxies->command_inout(AXIS_COMMAND_STOP_NAME); - for(i=0; i<_axes.size(); ++i) { - AxisAdapter & axis = _axes[i]; - - values[i] = axis.get_write_for_proxy(); - axis.set_state(Tango::MOVING); - } - -#ifdef WRITE_TO_PROXY_ALLOWED - // Launch in one time - try - { - _proxies->write_attribute(AXIS_ATTRIBUTE_POSITION_NAME, values, true); - } - catch(...) - { - //TODO remove this try catch when tango group will be updated - } -#endif + for(size_t i=0; i<_axes.size(); ++i) + _axes[i].to_proxy(); } void TangoHKLAdapter::update_proxies_from_pseudoAxesBuffer(PseudoAxisBuffer *buffer) @@ -573,7 +525,7 @@ namespace DiffractometerDevice_ns for (i=0; iaxes[i]; group->add(axis->get_device_name()); - values[i] = axis->get_write_for_proxy(); + values[i] = axis->get_write(); axis->set_state(Tango::MOVING); } -- 2.11.4.GIT