The following piece of code shows how the double_scalar
attribute of the Tango test server is written and read;
#include <tango.h> using namespace Tango; main(unsigned int argc, char **argv) { string attrName = "double_scalar"; double x = 4.5; DeviceProxy *device = new DeviceProxy( "//has107k:10000/sys/tg_test/1"); DeviceAttribute *da = new DeviceAttribute( attrName, x); try { device->write_attribute( *da); } catch ( Tango::DevFailed &e) { fprintf( stderr, "TangoTest, DevFailed exception \n attr: %s\n", attrName.c_str()); fprintf( stderr, " reason: %s \n desc: %s \n origin: %s \n", e.errors[0].reason.in(), e.errors[0].desc.in(), e.errors[0].origin.in()); } DeviceAttribute dd = device->read_attribute( attrName); dd >> x; cout << " received " << x << endl; }