From 65f22c4c1766f5c88a65dd3b1d37af4f4ddf9647 Mon Sep 17 00:00:00 2001 From: System User Date: Thu, 14 Jan 2010 11:32:13 +0100 Subject: [PATCH] * prepare for the removal of the Simulated attribut. --- src/Diffractometer/Diffractometer.cpp | 10 ++++---- src/PseudoAxesAdapter.cpp | 2 +- src/TangoHKLAdapter.cpp | 46 +++++++++++++++-------------------- src/TangoHKLAdapter.h | 3 +-- 4 files changed, 26 insertions(+), 35 deletions(-) diff --git a/src/Diffractometer/Diffractometer.cpp b/src/Diffractometer/Diffractometer.cpp index edb59dd..b6e301f 100644 --- a/src/Diffractometer/Diffractometer.cpp +++ b/src/Diffractometer/Diffractometer.cpp @@ -1155,7 +1155,7 @@ void Diffractometer::read_Simulated(Tango::Attribute &attr) DEBUG_STREAM << "Diffractometer::read_Simulated(Tango::Attribute &attr) entering... "<< endl; if(_hklAdapter) - *attr_Simulated_read = _hklAdapter->simulated; + *attr_Simulated_read = !_hklAdapter->get_auto_update_from_proxies(); attr.set_value(attr_Simulated_read); } @@ -1172,7 +1172,7 @@ void Diffractometer::write_Simulated(Tango::WAttribute &attr) attr.get_write_value(attr_Simulated_write); if (_hklAdapter) - _hklAdapter->set_simulated(attr_Simulated_write); + _hklAdapter->set_auto_update_from_proxies(!attr_Simulated_write); } //+---------------------------------------------------------------------------- @@ -1241,7 +1241,7 @@ void Diffractometer::write_WaveLength(Tango::WAttribute &attr) if (_hklAdapter) { _hklAdapter->set_lambda(attr_WaveLength_write); - if (_hklAdapter->simulated) + if (!_hklAdapter->get_auto_update_from_proxies()) *attr_WaveLength_read = attr_WaveLength_write; } } @@ -1576,7 +1576,7 @@ void Diffractometer::copy_reflection_to(const Tango::DevVarDoubleStringArray *ar //+------------------------------------------------------------------ Tango::DevState Diffractometer::dev_state() { - Tango::DevState argout = DeviceImpl::dev_state(); + Tango::DevState argout;// = DeviceImpl::dev_state(); DEBUG_STREAM << "Diffractometer::dev_state(): entering... !" << endl; // Add your own code to control device here @@ -1657,7 +1657,7 @@ void Diffractometer::compute_u(const Tango::DevVarLongArray *argin) //+------------------------------------------------------------------ Tango::ConstDevString Diffractometer::dev_status() { - Tango::ConstDevString argout = DeviceImpl::dev_status(); + //Tango::ConstDevString argout = DeviceImpl::dev_status(); DEBUG_STREAM << "Diffractometer::dev_status(): entering... !" << endl; // Add your own code to control device here diff --git a/src/PseudoAxesAdapter.cpp b/src/PseudoAxesAdapter.cpp index 716581c..71caa38 100644 --- a/src/PseudoAxesAdapter.cpp +++ b/src/PseudoAxesAdapter.cpp @@ -146,7 +146,7 @@ namespace Diffractometer_ns _status = "PseudoAxes status: "; // now compute the state and status - if(_hklAdapter->simulated) + if(!_hklAdapter->_auto_update_from_proxies) _state = Tango::STANDBY; else{ size_t i; diff --git a/src/TangoHKLAdapter.cpp b/src/TangoHKLAdapter.cpp index b0f7577..8a71fc7 100644 --- a/src/TangoHKLAdapter.cpp +++ b/src/TangoHKLAdapter.cpp @@ -47,7 +47,7 @@ namespace Diffractometer_ns HklAxis *axes_w_real; this->ready = false; - this->simulated = true; + _auto_update_from_proxies = false; _lambdaAttributeProxy = NULL; _wrong_nb_of_axis_proxies = false; _ux = 0; @@ -99,9 +99,9 @@ namespace Diffractometer_ns _axes.push_back(AxisAdapter(this, &axes_r[i], &axes_w[i], &axes_r_real[i], &axes_w_real[i])); // hack to connect all axes the first time - this->simulated = false; + _auto_update_from_proxies = true; this->connect_all_proxies(); - this->simulated = true; + _auto_update_from_proxies = false; // fill the pseudoAxesAdapters { @@ -173,7 +173,7 @@ namespace Diffractometer_ns omni_mutex_lock lock(_lock); // connect the lambda proxy - if ((!_lambdaAttributeProxy && !this->simulated) + if ((!_lambdaAttributeProxy && _auto_update_from_proxies) && _device->lambdaAttributeProxy != "") { try { @@ -184,7 +184,7 @@ namespace Diffractometer_ns } // connect the axes proxies - if (!this->ready && !this->simulated) { + if (!this->ready && _auto_update_from_proxies) { unsigned int nb; nb = _device->realAxisProxies.size(); @@ -224,7 +224,7 @@ namespace Diffractometer_ns { omni_mutex_lock lock(_lock); - if ((this->simulated || _device->lambdaAttributeProxy == "") + if ((!_auto_update_from_proxies || _device->lambdaAttributeProxy == "") && lambda > 0){ _lambda = lambda; _diffractometer->geometry_r->source.wave_length = lambda; @@ -260,7 +260,7 @@ namespace Diffractometer_ns void TangoHKLAdapter::update_lambda(void) { - if (_lambdaAttributeProxy && !this->simulated){ + if (_lambdaAttributeProxy && _auto_update_from_proxies){ try{ _lambdaAttributeProxy->read() >> _lambda; _diffractometer->geometry_r->source.wave_length = _lambda; @@ -286,7 +286,7 @@ namespace Diffractometer_ns double *data; HklGeometry **geometries; - if(this->simulated) + if(!_auto_update_from_proxies) engine = hkl_pseudo_axis_engine_list_get_by_name(_diffractometer->engines_w, "hkl"); else engine = hkl_pseudo_axis_engine_list_get_by_name(_diffractometer->engines_w_real, "hkl"); @@ -425,7 +425,7 @@ namespace Diffractometer_ns duration.Stop(); if(duration.GetDurationInMs() >= 200 && _proxies) { for(size_t i=0; i<_axes.size(); ++i) - _axes[i].from_proxy(this->simulated); + _axes[i].from_proxy(!_auto_update_from_proxies); duration.Start(); }else for(i=0; i<_axes.size(); ++i) @@ -496,16 +496,16 @@ namespace Diffractometer_ns std::string extra_status; state = Tango::STANDBY; - if (this->simulated) - status = "Simulated Mode: Motors will NOT move."; + if (!_auto_update_from_proxies) + status = "AutoUpdateFromProxies OFF"; else { - status = "REAL Mode : Motors will REALLY move."; + status = "AutoUpdateFromProxies ON"; if (!this->ready) { state = Tango::FAULT; extra_status += "\nCan not connect to axes proxies"; // update the monochromator proxy status. - if (!_lambdaAttributeProxy && !this->simulated) { + if (!_lambdaAttributeProxy && _auto_update_from_proxies) { extra_status += "\nCan not connect to the lambdaAttributeProxy"; extra_status += "\nCheck also the lambdaAttributeProxy property"; } @@ -1572,8 +1572,8 @@ namespace Diffractometer_ns res = hkl_pseudo_axis_engine_set(engines_w->engines[idx]); if (HKL_SUCCESS == res){ - // force simulated when we write on a PseudoAxes. - this->simulated = true; + // force auto update OFF when we write on a PseudoAxes. + _auto_update_from_proxies = false; hkl_geometry_init_geometry(geometry_w, engines_w->geometries->geometries[0]); hkl_pseudo_axis_engine_list_get(engines_w); @@ -1831,22 +1831,14 @@ namespace Diffractometer_ns { omni_mutex_lock lock(_lock); - return !this->simulated; + return _auto_update_from_proxies; } void TangoHKLAdapter::set_auto_update_from_proxies(bool update) { - bool old = this->simulated; - this->simulated = !update; - if(old = true && update == true) - this->update(); - } - - void TangoHKLAdapter::set_simulated(bool simulated) - { - bool old = this->simulated; - this->simulated = simulated; - if (old == true && simulated == false) + bool old = _auto_update_from_proxies; + _auto_update_from_proxies = update; + if(old = false && update == true) this->update(); } diff --git a/src/TangoHKLAdapter.h b/src/TangoHKLAdapter.h index 1c38e65..b765f55 100644 --- a/src/TangoHKLAdapter.h +++ b/src/TangoHKLAdapter.h @@ -56,7 +56,7 @@ namespace Diffractometer_ns { class TangoHKLAdapter { public : - bool simulated; + bool _auto_update_from_proxies; bool ready; TangoHKLAdapter(Diffractometer *_device, HklGeometryType type); @@ -73,7 +73,6 @@ namespace Diffractometer_ns { bool get_auto_update_from_proxies(void); void set_auto_update_from_proxies(bool update); - void set_simulated(bool simulated); void connect_all_proxies(void); -- 2.11.4.GIT