LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Import DLL wizard creates massive cluster of variables rather than arrays

Solved!
Go to solution

Hi,

 

I'm writing a wrapper dll to make an instrument driver for Varian/Varex radiography panels. My wrapper dll includes header files which define structs that the original driver uses. Several of the structs have char arrays like below:

typedef struct SModeInfo
{ int LinesPerPixel; int ColsPerPixel; char ModeDescription[256]; char DirReadyModeDescription[256]; int DcdsEnable; ...

Out of convenience and because there are many large structs in this driver/wrapper, I am using the import DLL feature.

 

The ImportDLL wizard seems to work well and properly pick up the char arrays.

modeDescription_char_array.PNG

 

However, the created VI's just insert 256 uints in the cluster which makes up the struct. I recognize that this is technically correct and will work, however it is obviously inconvenient to work with. Ideally it would automatically be an array of 256 uints instead. I know I can manually fix it but seeing as how I have many structs I have to do this for with many char arrays it would be more convenient for it to be automated.

 mode_description_vi.PNG

 

Or otherwise is there an easy way to collapse these 256 items into a single array? (Like select all -> convert to array) I am finding it difficult to do given the massive size of the vi. 

Any help would be appreciated. Thank you.

0 Kudos
Message 1 of 5
(2,937 Views)

You cannot take those clusters and make them into arrays, because LabVIEW stores arrays and clusters differently in memory. If you turn them into arrays, the calls to the DLL will probably crash LabVIEW (or worse, introduce subtle errors). What you can do, though, is move all the elements of the "array" into their own cluster inside the overall cluster, since nesting additional layers of clusters does not change how LabVIEW stores the data in memory. Make sure those element stay in the same place with regard to the overall cluster element order - this isn't the layout of the cluster on the screen, but the element order as defined by right-clicking the cluster border and choosing Reorder Controls in Cluster. Once you've done this, when you unbundle that element of the cluster, you can use Cluster to Array to access it as an array.

0 Kudos
Message 2 of 5
(2,892 Views)

Thanks for your help. I see what you are saying. I didn't know about the cluster order sub-menu option but that makes sense.

 

Is there any way to make those 256 elements into clusters (rather than manually wire them)? It would be ideal if every struct array somehow automatically was a sub-cluster, but if not if there is some sort of function that makes x number of ordered items in a cluster into its own cluster that would be amazing. I tried clicking and dragging to select all but quickly lose count of how many elements I have.

0 Kudos
Message 3 of 5
(2,884 Views)
Solution
Accepted by topic author NiaccountAndrew

No, I don't think there's any way to do what you're asking automatically. I haven't experimented with this feature of the Import Wizard to know if you could force the desired behavior in LabVIEW by modifying the header file, but perhaps if you wrapped each array in a struct (again, this doesn't change the layout in memory, and you could point the wizard at a modified copy of the header file without changing the original) the wizard would do it the way you want.

 

Another option is to create the clusters yourself manually. It's easy to create a cluster with a given number of identical elements: create an empty array of the desired data type, wire it to "Array to Cluster," set the number of cluster elements, create a control or indicator. So, if you know you'll need a lot of clusters of 256 U8, you only need to create one such cluster, save it as a control, and then use it wherever needed.

0 Kudos
Message 4 of 5
(2,869 Views)

Hello!   I was wondering if you ever got your VI working for Varian/Varex digital x-ray detector panels?   I have a couple 4343 panels (formerly Perkin Elmer) and need to implement control of them in LabView as well.

 

If you do have it, would you be willing to share?

 

Thank you for considering this request.

 

- J. G. Schubert

 

0 Kudos
Message 5 of 5
(598 Views)