Scalar attribute values in Array[1] using JTango

Hi,

Using the JTango 9 (Java) API on a customer site, I get scalar attribute values embedded in an array.
Typically, I get Boolean or String scalar values in an array[1].
(I have double-checked with AtkPanel that the attribute type is really a scalar type).

Using the same JTango API (with the same java code), I don’t see this issue on my TangoBox.

Any explanation about this behavior? Is install/config issues could explain this?

Thanks,
Jerome

Hi Jerome

And what do you see ?
Another value ? Another configuration (not a boolean or String, or array size different) ?

If value is different, what is the value returned by TestDevice ?

Pascal

Hi Pascal,

I see the right type and value, but embedded in an array of one element.
For instance, for string “test”, I’ll get [“test”]

Thanks,
Jerome

Hello,

Some more questions:
What is the code that returns this array?
Is the source device/attribute is the same in your customer configuration and your tango box?

Gwenaëlle.

In TANGO all attribute values are transferred in an array.
Scalar:
READ_ONLY array[1]
READ_WRITE array[2]
Spectum n values:
READ_ONLY array[n]
READ_WRITE array[2*n]

Pascal

@Pascal,
ok, but since I’m using the JTango extractXXX calls, I should’nt get an array for scalar values.

Typically, for boolean values, the code is as follows:

Object value;
AttrDataFormat dataFormat = deviceAttribute.getDataFormat();
if (dataFormat == AttrDataFormat.SCALAR) {
    value = deviceAttribute.extractBoolean();
} else {
    value = deviceAttribute.extractBooleanArray();
}

@Gwenaëlle,
No, the device/attribute is not the same in the customer configuration.
But I’ve checker (from AtkPanel) the attribute is really a scalar one.

Seems there is a mismatch in DataFormat between Scalar an Array.
Is this could be caused by an issue in Tango configuration/install?
Or by the device server implementation?

Thanks,
Jerome

Are you using the same JTango release ?
Which one (client and server side) ?

We are using the same JTango library on the client side: JTango-9.1.2
On the server side, it may vary, depending on the device server we are connected to.
Is there any restriction about compatibility between JTango versions ?

Thanks,
Jerome

Hi,

My 50 cents:

DeviceAttribute has DataFormat == UNKNOWN by default, so in your case it might be the reason: you fall through if to else, hence Array. Debug would say exactly.

Why do not you use one of the high level APIs? There is JTangoClientLang (or so) embedded into JTango and ezTangORB: link source, link maven.

With this you can just do:


Object value = proxy.readAttribute("my-boolean-attribute")

or to be more specific:


boolean value = proxy.readAttribute("my-boolean-attribute")

Obviously that would not fix you problem, but at least less typing.

Finally as I can see you store value in Object, so I think it is even better to have arrays everywhere - the rest of the code becomes much more cleaner, this is how it is done in TINE BTW

Hi Igor,

Thanks for your response.

About ezTangORB, I’d like to stick to Tango official repositories (Tango Controls Core Projects · GitHub).
About JTango Client Lang, I didn’t know there is a high level API, if it can simplify my code it would be nice!
If you could give me a small usage example it would be great.

Thanks,
Jerome

Hello,

Here is an example code for jtangoclient:


import fr.soleil.tango.clientapi.TangoAttribute; 
...
TangoAttribute ta = new TangoAttribute("my/device/test/scalarAttributeName");
// return the read value with the type of the attribute
Object value = ta.read();
// in case of a READ/WRITE attribute, get write part
if(ta.isWritable){
  Object writeValue = ta.readWritten();
}
// read value and try to convert the attribute value to  adouble
double doubleValue = ta.read(double.class);
// read value and try to convert the attribute value to a String
String stringValue = ta.read(String.class);
// convert value to the attribute type and write it 
ta.write("50");

TangoAttribute taSpectrum = new TangoAttribute("my/device/test/spectrumAttributeName");
// return the value with the type of the attribute
Object value = taSpectrum.read();
// read value and try to convert the attribute value to  adouble
double doubleValue = taSpectrum.read(double[].class);
// read value and try to convert the attribute value to a String
String stringValue = taSpectrum.read(String.class);
// convert value to the attribute type and write it 
ta.write(new double[] { 1, 0, 1, 0, 1, 0 });

Hope this help,

Gwenaëlle.

Another hint,

What the IDL version of your server?

I think that


DeviceAttribute#getDataFormat();

is only working from IDL5 servers.
For older versions of servers, you have to do a separate request to the device to get the attribute format:


fr.esrf.TangoApi.AttributeProxy#get_info().data_format

Hi Gwenaelle,

Thank you very much for the code example.
I’ll use it in my code, it will significantly simplify my code I guess!

About IDL version, yes we are using IDL5.
I attached what I got from Astor > Help > JTango version.
(We got the same versions for both our TangoBox VM and on our customer site)

Thanks,
Jerome