* PseudoAxis is no more a friend of PseudoAxisAdapter.
[diffractometer.git] / src / DynamicAttrAxis.cpp
blobfbe4db9a880f1adfbc70fd622c7b386bfacfcb7e
1 #include <iostream>
2 #include "DynamicAttrAxis.h"
4 namespace DiffractometerDevice_ns
7 AxisAttrib::AxisAttrib(char const *name, TangoHKLAdapter *adapter,
8 unsigned int idx) :
9 Tango::Attr(name, Tango::DEV_DOUBLE, Tango::READ_WRITE),
10 _adapter(adapter),
11 _idx(idx)
13 Tango::UserDefaultAttrProp axis_prop;
14 axis_prop.set_label(name);
15 axis_prop.set_format("%7.4f");
17 std::string description;
18 description += "The ";
19 description += name;
20 description += " axis of the diffractometer";
21 axis_prop.set_description(description.c_str());
22 axis_prop.set_unit("°");
23 this->set_default_properties(axis_prop);
26 void AxisAttrib::read(Tango::DeviceImpl *dev,Tango::Attribute &att)
28 double read, write;
30 _adapter->read_axis(_idx, read, write);
31 att.set_value(&read);
32 Tango::WAttribute & watt = dev->get_device_attr()->get_w_attr_by_name(name.c_str());
33 watt.set_write_value(write);
36 void AxisAttrib::write(Tango::DeviceImpl *dev,Tango::WAttribute &att)
38 double value;
40 att.get_write_value(value);
41 _adapter->write_axis(_idx, value);
44 bool AxisAttrib::is_allowed(Tango::DeviceImpl *dev,Tango::AttReqType ty)
46 if (dev->get_state() == Tango::FAULT ||
47 dev->get_state() == Tango::ALARM)
48 if (type == Tango::READ_REQ)
49 return true;
50 else
51 return false;
52 return true;
55 } //- end namespace