On 03/13/2017 04:43 PM, Madden, Timothy J. wrote:
Thanks Kay. That worked. I can now get the NTNDArray. I still have to use wrapUnsafe rather than wrap, ...but it works.
Another mystery:
When I call myarray.getValue() it returns a PVUnion. somehow the PVUnion knows that the data is ushort[] uint[] or whatever type the image data is.
How do we ask the PVUnion what data type it is?
For the following you will want to add the import
import org.epics.pvdata.pv.*;
Try the following starting with line 85
PVUnion pvu = myarray.getValue();
PVScalarArray pvarray = pvu.getField(PVScalarArray.class);
ScalarType scalarType= pvarray.getScalarArray().getElementType();
switch (scalarType) {
case pvByte: {
PVByteArray pv = (PVByteArray)pvarray;
... // details left to reader!!!
break;
}
case pvShort: {
...
break;
}
case pvInt: {
...
break;
}
case pvLong: {
...
break;
}
case pvUByte: {
...
break;
}
case pvUShort: {
...
break;
}
case pvUInt: {
...
break;
}
case pvULong: {
...
break;
}
case pvFloat: {
...
break;
}
case pvDouble: {
...
break;
}
default:
throw new IllegalArgumentException("Unsupported scalarType "
+ scalarType.toString());
}
Also to help you get going try the following starting with line 69
PVStructure pvs = easydata.getPVStructure();
System.out.println(pvs.getStructure());
Marty
In Eclipse I can trap on the code and see it is ushort, for my array, which is correct. But I cannot figure out
how my own code would know it i ushort. It must be the introspection interface? I have been mucking with with this....
I guess I use the convert utility to convert to a real Java tupe like int[]. But I have to know which Java type to use....
Thanks
Tim
________________________________________
From: Kasemir, Kay [[email protected]]
Sent: Monday, March 13, 2017 1:43 PM
To: Madden, Timothy J.
Cc: EPICS tech-talk
Subject: Re: NTNDArrays, Java
Not sure how to request the entire normative type on pvget.
Try "field()" as the request to get all fields:
pvget -r "field()" ...
Same when you assemble request in Java:
PVStructure read_request = CreateRequest.create().createRequest("field()");
... channel.createMonitor(.., read_request);
-Kay