LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Can I automate the creation of a cluster in LabView using the data structure created in an autogenerated .CSV, C header, or XML file?

Solved!
Go to solution

One addition, you can build your own variant datatypes quite easily with the OpenG toolkit. Here is a (simple) code snippet that shows how to build a cluster from scratch:

 

 

 

Ton

Message Edited by TonP on 05-01-2009 10:29 PM
Message Edited by TonP on 05-01-2009 10:30 PM
Free Code Capture Tool! Version 2.1.3 with comments, web-upload, back-save and snippets!
Nederlandse LabVIEW user groep www.lvug.nl
My LabVIEW Ideas

LabVIEW, programming like it should be!
Message 11 of 12
(6,181 Views)
Solution
Accepted by PhilipJoeP

All,  Thanks for your help on this.  I have been in contact with an NI developer and for my application of building cluster controls for a DLL blocks automatically, here was his solution (which works best).  Although not perfect, in that it doesn't keep embedded clusters structure, it does maintain the data type representation and names.  using Brute Force to piece these automatically generated controls together to build an large cluster is now simple and only has to be done once, and type def'ed.   This answers some other question I had posted on the forum... Such as:

 

1.  Issues with feeding a DLL call block with a cluster with an embedded array...  This was solved because now the Import Shared Library Wizard will automatically replace the array input with a cluster of elements.  No need to have an array in the cluster anymore!

http://forums.ni.com/ni/board/message?board.id=170&message.id=408616#M408616

 

2.  Auto resizing of cluster based on number of elements...  This was solved with the Import Shared Library Wizard because the clusters are automatically populated with the correct number of elements.  It avoids using arrays in the cluster feeding the DLL, even though the DLL calls for an array structure.  A cluster of elements, of course, does map to a C structure array. No limitations anymore with the max allowable array that an be converted into a cluster... no need!

http://forums.ni.com/ni/board/message?board.id=170&message.id=409766#M409766

 

3.  Maintaining the data type representation needed for the DLL inputs...  Using the Import Shared Library Wizard breaks out the arguments of each function inside the DLL.  When it does this, it will also build the DLL blocks and wire up controls of the correct data types to the block.  No need to manually change the representation!

http://forums.ni.com/ni/board/message?board.id=170&message.id=411649#M411649

 

 

HERE IS THE SOLUTION! 

(the files being referenced can be found here... http://forums.ni.com/ni/board/message?board.id=170&message.id=408616#M408616)

With regards to auto-generating a cluster based on a C structure, have you tried using the Import Shared Library wizard in LabVIEW?  To find it, navigate to Tools->Import->Shared Library.  To do this, you provide the links to a DLL and its associated header (.h) file.  The wizard will then automatically look at the parameters for a DLL that are defined in the header file and create VI's for each function in the DLL.  The parameters for the functions are also created.  In this particular case, it will define a single cluster with elements in it (see image below).  Each of these elements will be in the order the DLL is expecting them and will have associated names to indicate which elements are apart of an array, etc.  This is good because regardless of how big an array parameter is, LabVIEW will automatically create enough elements to satisfy it.  It is not so good because you lose the structure you originally had (elements grouped into clusters and arrays) and you have to recreate the cluster parameter every time you change the number of elements the array might have.  So depending on your application, this way work very well, or may prove to be more trouble than its worth.  However, when I ran the VI using this parameter as the input, everything worked properly...the numbers are all correctly added.

 

cluster.JPG

 

Thanks to everyone who posted and helped with this.

 

Phil

Message 12 of 12
(6,087 Views)