* add the autotools buildsystem
[diffractometer.git] / src / PseudoAxesAttrib.cpp
blobe08e273feeda577643a029b2d47fad3607b19101
1 #include <iostream>
2 #include "PseudoAxesAttrib.h"
4 namespace Diffractometer_ns
6 /******************/
7 /* PseudoAxesAxis */
8 /******************/
10 PseudoAxesAxisAttrib::PseudoAxesAxisAttrib(char const *name, PseudoAxesAdapter & adapter, size_t idx):
11 Tango::Attr(name, Tango::DEV_DOUBLE, Tango::READ_WRITE),
12 _adapter(adapter),
13 _idx(idx)
15 Tango::UserDefaultAttrProp axis_prop;
16 axis_prop.set_label(name);
17 axis_prop.set_format("%7.4f");
19 std::string description;
20 description += "The ";
21 description += name;
22 description += " pseudo axes axis of the diffractometer";
23 axis_prop.set_description(description.c_str());
24 axis_prop.set_unit("°");
25 this->set_default_properties(axis_prop);
28 void PseudoAxesAxisAttrib::read(Tango::DeviceImpl *dev, Tango::Attribute &att)
30 // use Tango to aknowledge for the write part.
31 Tango::WAttribute & att_w = dev->get_device_attr()->get_w_attr_by_name(att.get_name().c_str());
32 Matrix<double> const & img = _adapter.get_write();
33 att_w.set_write_value(img.data[_idx]);
35 att.set_value(&_adapter.get_axis_value(_idx));
38 void PseudoAxesAxisAttrib::write(Tango::DeviceImpl *dev, Tango::WAttribute &att)
40 double value;
41 att.get_write_value(value);
43 _adapter.set_axis_value(_idx, value);
46 bool PseudoAxesAxisAttrib::is_allowed(Tango::DeviceImpl *dev,Tango::AttReqType type)
48 if (dev->get_state() == Tango::FAULT ||
49 dev->get_state() == Tango::ALARM)
50 if (type == Tango::READ_REQ)
51 return true;
52 else
53 return false;
54 return true;
57 } //- end namespace