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 1 month ago
Olivier Neveu
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 ?

There are no stupid questions smile.
The set value can be seen as the target value.
For example, if you have an attribute named Position which corresponds to the Position of an equipment controlled by a motor. The read point will correspond to the position read from the sensors (encoders for instance) and will give you the current position of the element controlled by your motor.
The set value will be updated when you write your attribute. It corresponds to the target position of the equipment. It is the position you want to reach. During the move, if you read this Position attribute, you will get a read value corresponding to the current position read on the sensors/encoders and the set value will stay at the last value you've written successfully in this attribute (the target position value). During the move, the read and set values will be different. They might also be slightly different at the end of the move, depending on the precision/resolution of your position sensors.

Olivier Neveu
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 ?

Indeed. in this use case, you get only the read part.
If you extract a scalar attribute in an array/vector, you will get the read value and the set value.
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.
Edited 1 month ago
Hi, Reynald,

yes, your explanation helps me a lot.
It is now clear for me… I think. I have no other questions.
Thank you very much.

Best regards, Olivier Neveu
 
Register or login to create to post a reply.