* idem for the state and status.
[diffractometer.git] / src / AxisAttrib.cpp
blob110f9c7ddeeac55d4674c24a1c03932bc2bd16cb
1 #include <iostream>
2 #include "AxisAttrib.h"
4 namespace Diffractometer_ns
7 AxisAttrib::AxisAttrib(char const *name, AxisAdapter & adapter):
8 Tango::Attr(name, Tango::DEV_DOUBLE, Tango::READ_WRITE),
9 _adapter(adapter)
11 Tango::UserDefaultAttrProp axis_prop;
12 axis_prop.set_label(name);
13 axis_prop.set_format("%7.4f");
15 std::string description;
16 description += "The ";
17 description += name;
18 description += " axis of the diffractometer";
19 axis_prop.set_description(description.c_str());
20 axis_prop.set_unit("°");
21 this->set_default_properties(axis_prop);
24 void AxisAttrib::read(Tango::DeviceImpl *dev,Tango::Attribute &att)
26 double read = _adapter.get_read();
27 double write = _adapter.get_write();
29 att.set_value(&read);
30 Tango::WAttribute & watt = dev->get_device_attr()->get_w_attr_by_name(name.c_str());
31 watt.set_write_value(write);
34 void AxisAttrib::write(Tango::DeviceImpl *dev,Tango::WAttribute &att)
36 double value;
38 att.get_write_value(value);
39 _adapter.write(value);
42 bool AxisAttrib::is_allowed(Tango::DeviceImpl *dev,Tango::AttReqType ty)
44 if (dev->get_state() == Tango::FAULT ||
45 dev->get_state() == Tango::ALARM)
46 if (type == Tango::READ_REQ)
47 return true;
48 else
49 return false;
50 return true;
53 } //- end namespace