How to extract read and set values from a scalar attribute¶
Intended audience: developers, Programming language: c++
The following example will show how you can extract the read and set values from a scalar attribute. In the example, the attribute is a Tango::DevDouble.
1 2 3 4 5 6 7 8 9 10 11 12 13 | Tango::DevVarDoubleArray * attr_val;
Tango::DevDouble read_value, set_value;
try {
Tango::DeviceAttribute dev_attr = tg_device_proxy->read_attribute("attr_name");
dev_attr >> attr_val;
read_value = (*attr_val)[0];
set_value = (*attr_val)[1];
delete attr_val;
}
catch(Tango::DevFailed &e){
Tango::Except::print_exception(e);
throw;
}
|
Note
The operator ** >>** will allocate the memory for the Tango::DevVarDoubleArray but the programmer should free this memory when the work is done with this variable.