LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

How to parse visual studio List objects in Labview

Hello,

 

I am developing a LabView (LV2012 SP1) application that calls a .dll developed in .Net (Visual Studio 2010, target .Net Fx: 2.0, by myslef, so I can make all sorts of mods!). The final output of the .dll is given to me by a function call (Invoke Node) that generates a "List of byte arrays" (List<Byte[]>).

 

Now my question is that how to import the results in LabView? Ideally I would like to loop through all the elements of the list and process the binary data in them. Can I modify the .dll to give 2D arrays? and use them in LV? (this is not my preferred way, I like to stick to Lists as much as I can, OR a 1-D array.)

 

The other way that came to my mind as a dirty solution was to give the .dll results in String[] (array of strings) with each string representing the binary data in a "0x00-0x01....0xF0...." format and then convert the string to binary data &colon;smileyfrustrated: Smiley Frustrated Smiley Frustrated Smiley Frustrated

 

I noticed a .vi called ".Net Object to LabView variant", which connected to my invoke node output really nice, BUT, again I was not able to connect that to a :abView array object. Is there anyway to adjust this .VI to give me something similar to Lists?

 

Thanks for your responses oin advance.

 

 

0 Kudos
Message 1 of 6
(5,857 Views)

I don't think you'll be able to convert the List to an array in a single step. However, you can iterate through the List one element at a time, and convert each element to LabVIEW data.

 

Here's some LabVIEW code that creates a .NET array, which sort of the reverse of what you want to do but might give you some hints as to what's possible: http://forums.ni.com/t5/LabVIEW/How-to-pass-a-Labview-array-into-a-C-NET-array-object/m-p/1992795#M6...

Please post your code if you need further help, so we can see specifically what you're attempting.

0 Kudos
Message 2 of 6
(5,843 Views)

Thanks, Actually what I want to do is the opposite direction "C# List ===> LabView Array"

0 Kudos
Message 3 of 6
(5,834 Views)

Yes, I understand that. If you have a .NET object of type List, you should be able to use the Count property to get the number of items, and the Item property to get the item at a specific index. That lets you loop through all the elements in the list. For each element of the list, you can use .NET Object to Variant to get a variant, which you can most likely then convert to a String.

 

The .NET List interface also has a ToArray function, and you could see if you can take the output of that, wire it to .NET Object to Variant, and get an array of strings. No idea if it will work but it's easy to try.

0 Kudos
Message 4 of 6
(5,826 Views)

Except that LabVIEW does not support generics. So your interface can not return a List<String> but needs to return a specific type.

 

There is a way to handle generic objects anyhow but it involves invocation of reflection methods in .Net and that is a highly manual and complicated process. Look for other posts in this forum about .Net generics to see some samples of what reflection would mean.

 

http://forums.ni.com/t5/LabVIEW/NET-property-not-visible/td-p/2285594

Rolf Kalbermatter  My Blog
DEMO, Electronic and Mechanical Support department, room 36.LB00.390
0 Kudos
Message 5 of 6
(5,812 Views)

Thanks Nathand and Rolfk. So, the answer is:

There is straightforward way of importing a collection as list in Labview.

I decided to save the binary as string and return an Array of Strings to LabView

0 Kudos
Message 6 of 6
(5,805 Views)