LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

RT Shared Library Import (.so) Arrays

I have a shared library (.so) file for the RT environment that I have to use with my RT LabVIEW code. The import wizard works easily enough however the way labview is importing fixed length arrays is very strange. Here is an example of one structure containing some fixed length arrays:

 

typedef struct dome_ShutterC {
   float Calibrated[16];
   long Raw[16];
} dome_Shutter_Ctl;

Labview Control.png is an image of the labview generated control for this structure. As you can see instead of accepting an array it is defaulting to breaking the array out into individual array elements.

 

Does anyone know how to change this default behavior into accepting arrays?

 

0 Kudos
Message 1 of 4
(1,401 Views)

That's how it works. A LabVIEW cluster is arranged in memory like a fixed-size array, with all the elements one after another in a single memory location. A LabVIEW array, on the other hand, is a struct with some size and dimension information along with a pointer to the actual data. It's not that hard in LabVIEW to use "Array to Cluster" and "Cluster to Array" to convert between the two.

0 Kudos
Message 2 of 4
(1,383 Views)

To my knowledge, array to cluster and cluster to array won't work in the example I gave. The C++ struct contains two different data typed fixed length arrays. I can't tell the cluster to array to work with items 0-15 as an array of SGL and 16-31 as an array of I32. Likewise I can't take my array of 16 SGL elements and 16 I32 elements and use array to cluster to convert it to the correct cluster type.

 

The main issue is that I have some functions that I have to call that require arrays with hundreds of elements. It isn't viable to call these functions in this manner.

0 Kudos
Message 3 of 4
(1,380 Views)

Does it help if you make clusters inside the cluster? That is, you can make a cluster of 16 floating-point values for the Calibrated array, and a separate cluster of 16 long values for the Raw array, then put those into the Shutter cluster. Embedding clusters into clusters does not change the layout in memory.

 

Your other option is to pass an array of bytes (basically a pointer to the correct amount of memory), and then parse that array of bytes yourself after calling the library function. For example you could call Split 1D Array, then type cast the resulting byte arrays into an array of floats and an array of longs. One possible issue with this approach is that you may need to swap the endianness of the returned values in your code; with the cluster approach LabVIEW will handle the endianness for you because you've already defined the data types.

0 Kudos
Message 4 of 4
(1,373 Views)