From 57a3b07e5d31be527f050024fd76db671ff5e1b0 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Picca=20Fr=C3=A9d=C3=A9ric-Emmanuel?= Date: Fri, 17 Apr 2009 18:01:12 +0200 Subject: [PATCH] * add a first version of the PseudoAxesAttrib --- src/PseudoAxesAttrib.cpp | 56 ++++++++++++++++++++++++++++++++++++++++++++++++ src/PseudoAxesAttrib.h | 32 +++++++++++++++++++++++++++ 2 files changed, 88 insertions(+) create mode 100644 src/PseudoAxesAttrib.cpp create mode 100644 src/PseudoAxesAttrib.h diff --git a/src/PseudoAxesAttrib.cpp b/src/PseudoAxesAttrib.cpp new file mode 100644 index 0000000..ed66dff --- /dev/null +++ b/src/PseudoAxesAttrib.cpp @@ -0,0 +1,56 @@ +#include +#include "PseudoAxesAttrib.h" + +namespace DiffractometerDevice_ns +{ + + PseudoAxesAttrib::PseudoAxesAttrib(char const *name, PseudoAxesAdapter & adapter): + Tango::SpectrumAttr(name, Tango::DEV_DOUBLE, Tango::READ_WRITE, 10), + _adapter(adapter) + { + Tango::UserDefaultAttrProp axis_prop; + axis_prop.set_label(name); + axis_prop.set_format("%7.4f"); + + std::string description; + description += "The "; + description += name; + description += " pseudo axes of the diffractometer"; + axis_prop.set_description(description.c_str()); + axis_prop.set_unit("°"); + this->set_default_properties(axis_prop); + } + + void PseudoAxesAttrib::read(Tango::DeviceImpl *dev,Tango::Attribute &att) + { + Matrix const & read = _adapter.get_read(); + Matrix const & write = _adapter.get_write(); + att.set_value(read.data, read.xdim); + Tango::WAttribute & watt = dev->get_device_attr()->get_w_attr_by_name(name.c_str()); + watt.set_write_value(write.data, write.xdim); + } + + void PseudoAxesAttrib::write(Tango::DeviceImpl *dev,Tango::WAttribute &att) + { + Tango::DevDouble values; + att.get_write_value(values); + + Matrix img; + img.attach_to_buffer(&values, + att.get_w_dim_x(), att.get_w_dim_y()); + + _adapter.write(img); + } + + bool PseudoAxesAttrib::is_allowed(Tango::DeviceImpl *dev,Tango::AttReqType type) + { + if (dev->get_state() == Tango::FAULT || + dev->get_state() == Tango::ALARM) + if (type == Tango::READ_REQ) + return true; + else + return false; + return true; + } + +} //- end namespace diff --git a/src/PseudoAxesAttrib.h b/src/PseudoAxesAttrib.h new file mode 100644 index 0000000..5d5d465 --- /dev/null +++ b/src/PseudoAxesAttrib.h @@ -0,0 +1,32 @@ +#ifndef _PSEUDO_AXES_ATTRIB_H_ +#define _PSEDUO_AXES_ATTRIB_H_ + +#include +#include + +namespace DiffractometerDevice_ns +{ + class PseudoAxesAttrib : public Tango::SpectrumAttr + { + public: + PseudoAxesAttrib(char const *name, + PseudoAxesAdapter & adapter); + + virtual ~PseudoAxesAttrib(void) {}; + + virtual void read(Tango::DeviceImpl *dev, + Tango::Attribute &att); + + virtual void write(Tango::DeviceImpl *dev, + Tango::WAttribute &att); + + virtual bool is_allowed(Tango::DeviceImpl *dev, + Tango::AttReqType ty); + + protected: + PseudoAxesAdapter & _adapter; + }; + +} // namespace DiffractometerDevice_ns + +#endif // _PSEUDO_AXES_ATTRIB_H_ -- 2.11.4.GIT