Client side : wrong number of values for the spectrum attributes

Hello dear all,

I have a very strange problem.
When I do this, client side :

std::vector<Tango::DevLong> vec;
auto data = device->read_attribute(attributeName);
data >> vec;

I have twice the datas in "vec". For example if an attribute "attributeName" has the following values : "1, 2, 3". The values in vec are : "1, 2, 3, 1, 2, 3". If the attribute "attributeName" is read only, I have not this problem.

If the datas are pushed, I have an another problem :
void SomeClass::push_event(Tango::EventData * ed)
{
std::vector<Tango::DevLong> vec;
(*ed->attr_value) >> vec;
}

In this case, the values in vec are : "1, 2, 3, 0" (one 0 is added).

So, have you encountered a problem that looks like this ?

Best regards, Olivier Neveu
Hi Olivier,

When you read the attribute, the values in vec are : "1, 2, 3, 1, 2, 3" because you get the read and set values together when you are using the
DeviceAttribute::operator>>

You can use
DeviceAttribute::get_dim_x()
or
DeviceAttribute::get_r_dimension()
to know the size of the read value part and
DeviceAttribute::get_written_dim_x()
or
DeviceAttribute::get_r_dimension()
to know the size of the set point part for Read/Write Spectrum Attributes.

You can also use
DeviceData::extract_read()
to extract only the read part of the Attribute data.
You can use
DeviceData::extract_set()
to extract only the written part (set point) of the attribute data.

You can look at the Doxygen documentation to get the interface details of these methods: https://tango-controls.gitlab.io/cppTango/10.0.0/classDeviceAttribute.html

It looks like this use case is not yet well documented on readthedocs.
The scalar use case is documented, though: https://tango-controls.readthedocs.io/en/latest/tutorials-and-howtos/how-tos/how-to-extract-scalar-attribute.html

Hoping this helps a bit,
Reynald
Rosenberg's Law: Software is easy to make, except when you want it to do something new.
Corollary: The only software that's worth making is software that does something new.
Thank you, Reynald !

I just discovered the read and the set parts and I was just going to answer myself. Thank you very much for the confirmation.
I have a stupid question though : I don't really understand the difference between the read values and the set values. Can you, please, enlighten me on this point ?

Another thing : It seems ok to extract a Tango::DevLong scalar in a Tango::DevLong variable (not an array). In this case, we get the read part, I think ?

Best regards, Olivier Neveu
Edited 5 hours ago
 
Register or login to create to post a reply.