From 328a103f2a5dfe3547a2ecb008bc01de4c5f474a Mon Sep 17 00:00:00 2001 From: =?utf8?q?Picca=20Fr=C3=A9d=C3=A9ric-Emmanuel?= Date: Tue, 11 Aug 2009 13:05:48 +0200 Subject: [PATCH] * less crash now thaht the status is copied from one thread to the other. --- src/Diffractometer/Diffractometer.cpp | 10 ++++------ src/Diffractometer/Diffractometer.h | 2 ++ src/TangoHKLAdapter.cpp | 12 +++++++++++- src/TangoHKLAdapter.h | 4 ++-- 4 files changed, 19 insertions(+), 9 deletions(-) diff --git a/src/Diffractometer/Diffractometer.cpp b/src/Diffractometer/Diffractometer.cpp index 5d2a55d..bad3017 100644 --- a/src/Diffractometer/Diffractometer.cpp +++ b/src/Diffractometer/Diffractometer.cpp @@ -2122,13 +2122,11 @@ Tango::ConstDevString Diffractometer::dev_status() DEBUG_STREAM << "Diffractometer::dev_status(): entering... !" << endl; // Add your own code to control device here - if(_hklAdapter){ - _hklAdapter->update(); - argout = _hklAdapter->get_status().c_str(); - } + if(_hklAdapter) + _hklAdapter->get_status(_status); - this->set_status(argout); - return argout; + this->set_status(_status); + return _status.c_str(); } } // namespace diff --git a/src/Diffractometer/Diffractometer.h b/src/Diffractometer/Diffractometer.h index 457352a..063f771 100644 --- a/src/Diffractometer/Diffractometer.h +++ b/src/Diffractometer/Diffractometer.h @@ -960,6 +960,8 @@ protected : Tango::DevVarStringArray _mode_names_dev_varstring_array; Tango::DevVarStringArray _crystal_names_dev_varstring_array; + std::string _status; + // thoses methods are declared in the DiffractometerExtra.cpp void compute_angles(double h, double k ,double l); diff --git a/src/TangoHKLAdapter.cpp b/src/TangoHKLAdapter.cpp index 51d9c90..97063ab 100644 --- a/src/TangoHKLAdapter.cpp +++ b/src/TangoHKLAdapter.cpp @@ -589,7 +589,17 @@ namespace Diffractometer_ns * END OF CRITICAL SECTION **********************************************/ } - + + /********************/ + /* State and status */ + /********************/ + void TangoHKLAdapter::get_status(std::string & status) + { + omni_mutex_lock lock(_lock); + + status = _status; + } + /************/ /* hkl part */ /************/ diff --git a/src/TangoHKLAdapter.h b/src/TangoHKLAdapter.h index 15743ba..7df6bf2 100644 --- a/src/TangoHKLAdapter.h +++ b/src/TangoHKLAdapter.h @@ -74,9 +74,9 @@ namespace Diffractometer_ns { HKLBuffer const & get_HKLBuffer(void) const {return _hklBuffer;} - Tango::DevState const & get_state(void) const {return _state;} + Tango::DevState const get_state(void) const {return _state;} - std::string const & get_status(void) const {return _status;} + void get_status(std::string & status); bool internal_compute_angles(double h, double k, double l, std::string & status); -- 2.11.4.GIT