Personal tools
You are here: Home HowTos CPP: Extracting read and set values from a scalar attribute
Document Actions

CPP: Extracting read and set values from a scalar attribute

by etaurel last modified 2007-01-26 10:49

This HowTo gives a CPP example of how you can retrieve a scalar attribute read and set value

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.

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.


Powered by Plone, the Open Source Content Management System

This site conforms to the following standards: